askbot-dragon 1.0.0 → 1.0.2

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.0",
3
+ "version": "1.0.2",
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"
@@ -1904,9 +1904,74 @@ export default {
1904
1904
  }
1905
1905
  }
1906
1906
  },
1907
+ verificationDescription () {
1908
+ let textFlag = true
1909
+ let imageFlag = true
1910
+ let attachmentFlag = true
1911
+ let errorText = ''
1912
+ let checkDescription = {
1913
+ checkText:this.workOrderDestail.checkText ? this.workOrderDestail.checkText : false,
1914
+ checkImage:this.workOrderDestail.checkImage ? this.workOrderDestail.checkImage : false,
1915
+ checkAttachment:this.workOrderDestail.checkAttachment ? this.workOrderDestail.checkAttachment : false,
1916
+ required:this.workOrderDestail.required ? this.workOrderDestail.required : false,
1917
+ }
1918
+ if (checkDescription.checkText) {
1919
+ if (!this.workOrderDestail.value) {
1920
+ textFlag = false
1921
+ } else {
1922
+ let d = document.createElement('div')
1923
+ d.innerHTML = this.workOrderDestail.value
1924
+ if (!d.innerText) {
1925
+ textFlag = false
1926
+ }
1927
+ d = null
1928
+ }
1929
+ }
1930
+ if (checkDescription.checkImage && !this.workOrderDestail.value.includes('img')) {
1931
+ imageFlag = false
1932
+ }
1933
+ if (checkDescription.checkAttachment && this.attachments.length == 0) {
1934
+ attachmentFlag = false
1935
+ }
1936
+ if (!textFlag) {
1937
+ errorText = '问题描述必须要有文字'
1938
+ }
1939
+ if (!imageFlag) {
1940
+ errorText = '问题描述必须要有图片'
1941
+ }
1942
+ if (!attachmentFlag) {
1943
+ errorText = '问题描述必须要有附件'
1944
+ }
1945
+ if (!textFlag && (!imageFlag || !attachmentFlag)) {
1946
+ errorText = '问题描述必须要有文字和' + !imageFlag ? '图片' : '附件'
1947
+ }
1948
+ if (!imageFlag && !attachmentFlag) {
1949
+ errorText = '问题描述必须要有图片和附件'
1950
+ }
1951
+ if (!imageFlag && !attachmentFlag && !textFlag) {
1952
+ errorText = '问题描述必须要有文字、图片和附件'
1953
+ }
1954
+ if (errorText) {
1955
+ this.$message.error(errorText);
1956
+ return false
1957
+ } else {
1958
+ if (checkDescription.required && !this.workOrderDestail.value) {
1959
+ this.$message.error('问题描述是必填的');
1960
+ return false
1961
+ }
1962
+ return true
1963
+ }
1964
+ },
1907
1965
  //提交按钮事件
1908
1966
  submitClick() {
1909
-
1967
+ if (this.uploadImgQueue || this.attachmentList.some(arrach => { return !arrach.url })) {
1968
+ this.$message.warning('文件正在上传,请稍后')
1969
+ return
1970
+ }
1971
+ if(!this.verificationDescription()) {
1972
+ return
1973
+ }
1974
+ console.log(this.workOrderDestail);
1910
1975
  for (let i=0;i<this.formShow.form.formFieldRelation.length;i++)
1911
1976
  {
1912
1977
  if(this.formShow.form.formFieldRelation[i].formField.type==='CASCADER')
@@ -1990,13 +2055,14 @@ export default {
1990
2055
  }
1991
2056
  let extInfo = {
1992
2057
  extInfoFieldValue:this.extInfoFieldValue,
1993
- attachmentList:this.attachmentList
1994
2058
  }
1995
2059
  this.$set(this.formShow,'extInfo',extInfo)
1996
2060
  let newForm = JSON.parse(JSON.stringify(this.formShow));
1997
2061
  for (let i=0;i<newForm.form.formFieldRelation.length;i++){
1998
2062
  if (newForm.form.formFieldRelation[i].fieldId === 'workorder_description'){
1999
2063
  newForm.form.formFieldRelation[i].value = newForm.form.formFieldRelation[i].value.replace(/<img/g, "<img onclick='previewImage(this)' ")
2064
+ this.$set(newForm.form.formFieldRelation[i].extInfo,'attachments',this.attachments)
2065
+ this.$set(newForm.form.formFieldRelation[i].extInfo,'attachmentList',this.attachmentList)
2000
2066
  }
2001
2067
  }
2002
2068
  console.debug('formShow',this.formShow.form,newForm.form)
@@ -2733,16 +2799,38 @@ export default {
2733
2799
  this.uploadImgQueue = false
2734
2800
  }
2735
2801
  }
2736
- if (uploadList[index].childNodes[0].getAttribute('type') == 'MyFile') {
2802
+ if (uploadList[index].childNodes[0].getAttribute('type') == 'MyFile' || uploadList[index].childNodes[0].getAttribute('type') == 'FileUpload') {
2737
2803
  let span = uploadList[index].getElementsByClassName('ask-component-placeholder-span')[0]
2738
2804
  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
- })
2805
+ let value = ''
2806
+ let id = ''
2807
+ if (typeof span.getAttribute('data') == 'string' && !span.getAttribute('data').includes('default')) {
2808
+ id = span.getAttribute('data')
2809
+ this.attachmentList.push({
2810
+ name: text,
2811
+ id: id,
2812
+ url: '',
2813
+ })
2814
+ } else {
2815
+ value = JSON.parse(span.getAttribute('data')).default
2816
+ id = JSON.parse(span.getAttribute('data')).id
2817
+ this.attachments.push(value)
2818
+ this.attachmentList = this.attachmentList.filter(attach => {
2819
+ return attach.id != id
2820
+ })
2821
+ this.attachmentList.push({
2822
+ name: text,
2823
+ url: value,
2824
+ })
2825
+ let time = setTimeout(() => {
2826
+ this.currentEditor.model.change(writer => {
2827
+ writer.setSelection(writer.createPositionAt(this.currentEditor.model.document.getRoot(), 'end'));
2828
+ })
2829
+ this.currentEditor.editing.view.focus();
2830
+ clearTimeout(time)
2831
+ }, 500)
2832
+ }
2833
+ uploadList[index].setAttribute('type', 'MyFile')
2746
2834
  let ht = '<span class="ask-component-placeholder-container">' + uploadList[index].innerHTML + '</span>'
2747
2835
  newVal = newVal.replace(ht, '')
2748
2836
  span = null
@@ -2771,7 +2859,9 @@ export default {
2771
2859
  newVal = this.getAttach(newVal)
2772
2860
  if (this.currentEditor){
2773
2861
  if (this.workOrderDestail){
2774
- this.workOrderDestail.value = newVal;
2862
+ this.$nextTick(() =>{
2863
+ this.workOrderDestail.value = newVal;
2864
+ })
2775
2865
  }
2776
2866
  /*this.currentEditor.model.change( writer => {
2777
2867
  writer.setSelection( writer.createPositionAt( this.currentEditor.model.document.getRoot(), 'end' ) );
@@ -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
  },