{"remainingRequest":"D:\\jenkins\\workspace\\artfess-module\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\artfess-module\\src\\components\\HtFile.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\artfess-module\\src\\components\\HtFile.vue","mtime":1675232038574},{"path":"D:\\jenkins\\workspace\\artfess-module\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\artfess-module\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\artfess-module\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\r\nimport utils from \"@/utils.js\";\r\nimport HtFieldTail from \"@/components/HtFieldTail.vue\";\r\nimport FileUpload from \"@/components/common/FileUpload.vue\";\r\nimport Locale from \"@/mixins/locale\";\r\n\r\nexport default {\r\n  name: \"ht-file\",\r\n  mixins: [Locale],\r\n  props: {\r\n    isSimple: {\r\n      type: Boolean,\r\n      default: false\r\n    },\r\n    withCredentials: {\r\n      type: Boolean,\r\n      default: false\r\n    },\r\n    actionUrl: {\r\n      type: String,\r\n      default: \"https://jsonplaceholder.typicode.com/posts/\"\r\n    },\r\n    value: {\r\n      type: String\r\n    },\r\n    validate: {\r\n      type: Object\r\n    },\r\n    name: {\r\n      type: String\r\n    },\r\n    multiple: {\r\n      type: Boolean,\r\n      default: false\r\n    },\r\n    permission: {\r\n      type: String,\r\n      default: \"w\",\r\n      validator: function(value) {\r\n        return [\"b\", \"w\", \"r\", \"n\"].indexOf(value) !== -1;\r\n      }\r\n    },\r\n    accept: {\r\n      type: String\r\n    },\r\n    limit: {\r\n      type: Number\r\n    },\r\n    header: {\r\n      type: Object\r\n    },\r\n    size: {\r\n      type: Number\r\n    },\r\n    previewable: {\r\n      type: Boolean,\r\n      default: true\r\n    },\r\n    downloadable: {\r\n      type: Boolean,\r\n      default: true\r\n    },\r\n    propConfList: {\r\n      type: Array,\r\n      default() {\r\n        return [];\r\n      }\r\n    },\r\n    beforeUpload: {\r\n      type: Function\r\n    },\r\n    onSuccess: {\r\n      type: Function\r\n    },\r\n    onError: {\r\n      type: Function\r\n    },\r\n    columnShow: {\r\n      type: Object,\r\n      default() {\r\n        return {};\r\n      }\r\n    }\r\n  },\r\n  components: { HtFieldTail, FileUpload },\r\n  data() {\r\n    return {\r\n      operateWidth: this.permission === \"r\" ? \"70\" : \"260\",\r\n      inputName: null,\r\n      writeable: true,\r\n      files: [],\r\n      filesData: [],\r\n      progressPercent: 0,\r\n      progressFlag: false\r\n    };\r\n  },\r\n  computed: {\r\n    inputWriteable: function() {\r\n      return this.writeable\r\n        ? utils.getWriteable(this.permission)\r\n        : this.writeable;\r\n    },\r\n    inputValidate: function() {\r\n      return utils.addRequiredOrNot(this.permission, this.validate, this);\r\n    },\r\n    calColumnShow: function() {\r\n      let defaultSetting = { fileType: true, fileSize: true };\r\n      return { ...defaultSetting, ...this.columnShow };\r\n    }\r\n  },\r\n  watch: {\r\n    filesData: function(newVal) {\r\n      let r = \"\";\r\n      if (newVal && newVal.constructor === Array && newVal.length > 0) {\r\n        // 只有上传成功的附件才能更新v-model值\r\n        let ary = newVal.filter(m => m.status === \"success\");\r\n        if (ary && ary.length > 0) {\r\n          r = JSON.stringify(ary);\r\n        }\r\n      }\r\n      this.$emit(\"input\", r);\r\n    },\r\n    files: function(newVal) {\r\n      if (!newVal || newVal.length == 0) {\r\n        this.filesData = [];\r\n      }\r\n    }\r\n  },\r\n  created() {\r\n    this.inputName = this.name ? this.name : utils.getName();\r\n    this.$validator = this.$root.$validator;\r\n    if (this.value && this.value.constructor === String) {\r\n      if (!this.value.response) {\r\n        let fileVal = [...JSON.parse(this.value)];\r\n        //获取附件类型\r\n        for (let i = 0; i < fileVal.length; i++) {\r\n          if (fileVal[i].name && fileVal[i].name.split(\".\")) {\r\n            fileVal[i].type = this.substringType(fileVal[i].name);\r\n            fileVal[i].state = \"success\";\r\n            fileVal[i].percentage = 100;\r\n          }\r\n        }\r\n        this.files = fileVal;\r\n        this.filesData = fileVal;\r\n      } else {\r\n        this.files = JSON.parse(this.value);\r\n        this.filesData = JSON.parse(this.value);\r\n      }\r\n    }\r\n  },\r\n  methods: {\r\n    //获取指定字符串点最后一个字符\r\n    substringType(str) {\r\n      let valueArr = str.split(\".\");\r\n      return valueArr[valueArr.length - 1];\r\n    },\r\n    handleError() {\r\n      this.progressFlag = false;\r\n    },\r\n    handleProgress(event, file, fileList) {\r\n      this.progressFlag = true;\r\n      this.progressPercent = Math.floor(event.percent);\r\n    },\r\n    move(item, direct) {\r\n      this.filesData = utils.arrayMove(this.filesData, item, direct);\r\n    },\r\n    uploadSuccess(response, file, fileList) {\r\n      //获取附件类型\r\n      let type = \"\";\r\n      if (file.name && file.name.split(\".\")) {\r\n        type = this.substringType(file.name);\r\n      } else {\r\n        type = file.type;\r\n      }\r\n      for (let i = 0; i < this.filesData.length; i++) {\r\n        if (this.filesData[i].uid == file.uid) {\r\n          this.filesData.splice(i, 1);\r\n          break;\r\n        }\r\n      }\r\n      this.filesData.push({\r\n        name: file.name,\r\n        size: file.size,\r\n        percentage: file.percentage,\r\n        status: file.status,\r\n        state: file.status,\r\n        response: file.response,\r\n        username: file.response.username || \"\",\r\n        type: type,\r\n        uid: file.uid,\r\n        prop1: \"\",\r\n        prop2: \"\",\r\n        prop3: \"\",\r\n        prop4: \"\",\r\n        prop5: \"\",\r\n        prop6: \"\"\r\n      });\r\n      this.progressPercent === 100\r\n        ? (this.progressFlag = false)\r\n        : (this.progressFlag = true);\r\n      this.$emit(\"onSuccess\", response, file, fileList);\r\n    },\r\n    removeFile(file) {\r\n      this.$confirm(`确定删除${file.name}?`)\r\n        .then(() => {\r\n          this.filesData.remove(file);\r\n          this.$refs.fileUpload.remove(file);\r\n          this.$emit(\"remove\", file, this.files);\r\n        })\r\n        .catch(() => {});\r\n    },\r\n    download(file) {\r\n      this.$emit(\"download\", file, this.files);\r\n    },\r\n    preview(file) {\r\n      if (this.previewable) {\r\n        this.$emit(\"preview\", file, this.files);\r\n      } else {\r\n        let msg = this.t(\"ht.file.nopreview\");\r\n        this.$message.warning(msg);\r\n      }\r\n    }\r\n  }\r\n};\r\n",null]}