askbot-dragon 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "askbot-dragon",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build",
@@ -36,8 +36,9 @@
36
36
  <!-- @click="openDialog(item, item.name)" -->
37
37
  <span @click.stop="deleteAttch(index)"><i class="iconfont guoran-a-16-09"></i></span>
38
38
  <div class="attch-item-left">
39
+ <i v-if="item.url == ''" class="el-icon-loading" style="color:#366AFF;margin: 5px;"></i>
39
40
  <img src="../assets/image/video.png"
40
- v-if="setSrc(item.name) == 'video'" />
41
+ v-else-if="setSrc(item.name) == 'video'" />
41
42
  <img src="../assets/image/image.png"
42
43
  v-else-if="setSrc(item.name) == 'image'" />
43
44
  <img src="../assets/image/txt.png"
@@ -58,15 +58,16 @@
58
58
  :maxlength="item.formField.extInfo&&item.formField.extInfo.maxNum?item.formField.extInfo.maxNum*1:1000"
59
59
  v-if="item.formField.type==='TEXTAREA'&& item.fieldId!=='workorder_description'"
60
60
  ></el-input>
61
- <ckeditor
61
+ <div v-else-if="item.fieldId === 'workorder_description'">
62
+ <ckeditor
62
63
  :editor="ckeditor.editor"
63
64
  v-model="item.value"
64
65
  :config="{...ckeditor.editorConfig,placeholder:item.formField.extInfo && item.formField.extInfo.placeholder?item.formField.extInfo.placeholder:'请输入'}"
65
- v-else-if="item.fieldId==='workorder_description'"
66
66
  @ready="(editor)=>currentEditor=editor"
67
67
  @focus="(zh,editor)=>currentEditor=editor"
68
- ></ckeditor>
69
- <file-list-view v-else-if="item.fieldId==='workorder_description'" :attachmentList="attachmentList" @attachDeleteAttch="attachDeleteAttch"></file-list-view>
68
+ ></ckeditor>
69
+ <file-list-view :attachmentList="attachmentList" @attachDeleteAttch="attachDeleteAttch"></file-list-view>
70
+ </div>
70
71
  <el-date-picker
71
72
  v-model=item.value
72
73
  type="date"
@@ -1904,9 +1905,74 @@ export default {
1904
1905
  }
1905
1906
  }
1906
1907
  },
1908
+ verificationDescription () {
1909
+ let textFlag = true
1910
+ let imageFlag = true
1911
+ let attachmentFlag = true
1912
+ let errorText = ''
1913
+ let checkDescription = {
1914
+ checkText:this.workOrderDestail.checkText ? this.workOrderDestail.checkText : false,
1915
+ checkImage:this.workOrderDestail.checkImage ? this.workOrderDestail.checkImage : false,
1916
+ checkAttachment:this.workOrderDestail.checkAttachment ? this.workOrderDestail.checkAttachment : false,
1917
+ required:this.workOrderDestail.required ? this.workOrderDestail.required : false,
1918
+ }
1919
+ if (checkDescription.checkText) {
1920
+ if (!this.workOrderDestail.value) {
1921
+ textFlag = false
1922
+ } else {
1923
+ let d = document.createElement('div')
1924
+ d.innerHTML = this.workOrderDestail.value
1925
+ if (!d.innerText) {
1926
+ textFlag = false
1927
+ }
1928
+ d = null
1929
+ }
1930
+ }
1931
+ if (checkDescription.checkImage && !this.workOrderDestail.value.includes('img')) {
1932
+ imageFlag = false
1933
+ }
1934
+ if (checkDescription.checkAttachment && this.attachments.length == 0) {
1935
+ attachmentFlag = false
1936
+ }
1937
+ if (!textFlag) {
1938
+ errorText = '问题描述必须要有文字'
1939
+ }
1940
+ if (!imageFlag) {
1941
+ errorText = '问题描述必须要有图片'
1942
+ }
1943
+ if (!attachmentFlag) {
1944
+ errorText = '问题描述必须要有附件'
1945
+ }
1946
+ if (!textFlag && (!imageFlag || !attachmentFlag)) {
1947
+ errorText = '问题描述必须要有文字和' + !imageFlag ? '图片' : '附件'
1948
+ }
1949
+ if (!imageFlag && !attachmentFlag) {
1950
+ errorText = '问题描述必须要有图片和附件'
1951
+ }
1952
+ if (!imageFlag && !attachmentFlag && !textFlag) {
1953
+ errorText = '问题描述必须要有文字、图片和附件'
1954
+ }
1955
+ if (errorText) {
1956
+ this.$message.error(errorText);
1957
+ return false
1958
+ } else {
1959
+ if (checkDescription.required && !this.workOrderDestail.value) {
1960
+ this.$message.error('问题描述是必填的');
1961
+ return false
1962
+ }
1963
+ return true
1964
+ }
1965
+ },
1907
1966
  //提交按钮事件
1908
1967
  submitClick() {
1909
-
1968
+ if (this.uploadImgQueue || this.attachmentList.some(arrach => { return !arrach.url })) {
1969
+ this.$message.warning('文件正在上传,请稍后')
1970
+ return
1971
+ }
1972
+ if(!this.verificationDescription()) {
1973
+ return
1974
+ }
1975
+ console.log(this.workOrderDestail);
1910
1976
  for (let i=0;i<this.formShow.form.formFieldRelation.length;i++)
1911
1977
  {
1912
1978
  if(this.formShow.form.formFieldRelation[i].formField.type==='CASCADER')
@@ -1990,13 +2056,15 @@ export default {
1990
2056
  }
1991
2057
  let extInfo = {
1992
2058
  extInfoFieldValue:this.extInfoFieldValue,
1993
- attachmentList:this.attachmentList
1994
2059
  }
1995
2060
  this.$set(this.formShow,'extInfo',extInfo)
1996
2061
  let newForm = JSON.parse(JSON.stringify(this.formShow));
1997
2062
  for (let i=0;i<newForm.form.formFieldRelation.length;i++){
1998
2063
  if (newForm.form.formFieldRelation[i].fieldId === 'workorder_description'){
1999
2064
  newForm.form.formFieldRelation[i].value = newForm.form.formFieldRelation[i].value.replace(/<img/g, "<img onclick='previewImage(this)' ")
2065
+ console.log(newForm.form.formFieldRelation[i]);
2066
+ this.$set(newForm.form.formFieldRelation[i].formField.extInfo,'attachments',this.attachments)
2067
+ this.$set(newForm.form.formFieldRelation[i].formField.extInfo,'attachmentList',this.attachmentList)
2000
2068
  }
2001
2069
  }
2002
2070
  console.debug('formShow',this.formShow.form,newForm.form)
@@ -2733,16 +2801,38 @@ export default {
2733
2801
  this.uploadImgQueue = false
2734
2802
  }
2735
2803
  }
2736
- if (uploadList[index].childNodes[0].getAttribute('type') == 'MyFile') {
2804
+ if (uploadList[index].childNodes[0].getAttribute('type') == 'MyFile' || uploadList[index].childNodes[0].getAttribute('type') == 'FileUpload') {
2737
2805
  let span = uploadList[index].getElementsByClassName('ask-component-placeholder-span')[0]
2738
2806
  const text = span.innerText
2739
- const value = span.getAttribute('data')
2740
- this.attachments.push(value)
2741
- console.log(span.innerText,'texttext');
2742
- this.attachmentList.push({
2743
- name: text,
2744
- url: value
2745
- })
2807
+ let value = ''
2808
+ let id = ''
2809
+ if (typeof span.getAttribute('data') == 'string' && !span.getAttribute('data').includes('default')) {
2810
+ id = span.getAttribute('data')
2811
+ this.attachmentList.push({
2812
+ name: text,
2813
+ id: id,
2814
+ url: '',
2815
+ })
2816
+ } else {
2817
+ value = JSON.parse(span.getAttribute('data')).default
2818
+ id = JSON.parse(span.getAttribute('data')).id
2819
+ this.attachments.push(value)
2820
+ this.attachmentList = this.attachmentList.filter(attach => {
2821
+ return attach.id != id
2822
+ })
2823
+ this.attachmentList.push({
2824
+ name: text,
2825
+ url: value,
2826
+ })
2827
+ let time = setTimeout(() => {
2828
+ this.currentEditor.model.change(writer => {
2829
+ writer.setSelection(writer.createPositionAt(this.currentEditor.model.document.getRoot(), 'end'));
2830
+ })
2831
+ this.currentEditor.editing.view.focus();
2832
+ clearTimeout(time)
2833
+ }, 500)
2834
+ }
2835
+ uploadList[index].setAttribute('type', 'MyFile')
2746
2836
  let ht = '<span class="ask-component-placeholder-container">' + uploadList[index].innerHTML + '</span>'
2747
2837
  newVal = newVal.replace(ht, '')
2748
2838
  span = null
@@ -54,7 +54,17 @@ class MyUploadAdapter {
54
54
  );
55
55
  res.then(resp=>{
56
56
  imgInfo.url = ossFileUrl(ossConfig, resp.name)
57
- console.log(imgInfo)
57
+ let root = this.editor.model.document.getRoot()
58
+ let children = root.getChildren()
59
+ for(let child of children){
60
+ for (let index = 0; index < child._children._nodes.length; index++) {
61
+ if(child._children._nodes[index].name == 'askComponentPlaceholderContainer'){
62
+ this.editor.model.change(writer => {
63
+ writer.remove(child);
64
+ });
65
+ }
66
+ }
67
+ }
58
68
  let command = this.editor.commands.get("insertAskComponent");
59
69
  command.execute({
60
70
  tag: "img",
@@ -1,5 +1,6 @@
1
1
  import Command from "@ckeditor/ckeditor5-core/src/command";
2
2
  import { multipartUpload, ossFileUrl } from "../AliyunIssUtil";
3
+ import { v4 as uuidv4 } from "uuid";
3
4
  const ossConfig = {
4
5
  region: "oss-cn-zhangjiakou",
5
6
  //云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用STS方式来进行API访问
@@ -30,14 +31,28 @@ export default class FileCommand extends Command {
30
31
  let files = inputObj.files;
31
32
  for (let index = 0; index < files.length; index++) {
32
33
  const filed = files[index];
34
+ let uid = uuidv4()
35
+ let command = this.editor.commands.get("insertAskComponent");
36
+ command.execute({
37
+ tag: "span-editable",
38
+ options: {
39
+ name: filed.name,
40
+ data: uid,
41
+ editable:false,
42
+ type:'FileUpload'
43
+ },
44
+ })
33
45
  this.upload(filed).then(res =>{
34
46
  // 需要回调通知父组件 上传成功
35
- let command = this.editor.commands.get("insertAskComponent");
47
+ let data = JSON.stringify({
48
+ id: uid,
49
+ default:res.default
50
+ })
36
51
  command.execute({
37
52
  tag: "span-editable",
38
53
  options: {
39
54
  name: filed.name,
40
- data: res.default,
55
+ data: data ,
41
56
  editable:false,
42
57
  type:'MyFile'
43
58
  },