"use strict";
((typeof self !== 'undefined' ? self : this)["webpackChunklib"] = (typeof self !== 'undefined' ? self : this)["webpackChunklib"] || []).push([[286],{

/***/ 1462:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7658);
/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _utils_eventbus__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6587);
/* harmony import */ var _utils_common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7623);
/* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3288);
/* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(ramda__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(8180);





const baseMixin = {
  data() {
    return {
      updateValue: 0,
      widgetId: "widget-" + Math.random().toString(15).slice(2, 15)
    };
  },
  mixins: [_utils_common__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z],
  props: {
    field: {
      type: Object,
      default: () => ({})
    },
    schema: {
      type: Object,
      default: () => ({})
    },
    values: {
      type: Object,
      default: () => ({})
    },
    colors: {
      type: Object,
      default: () => ({})
    },
    fieldErrors: {
      type: Object,
      default: () => ({})
    },
    hideFields: {
      type: Object,
      default: () => ({})
    },
    isDark: {
      type: Boolean,
      default: false
    },
    form: {
      type: Object,
      default: () => ({})
    }
  },
  inject: ["formId", "dependencies", "regExpFields", "isDeepValues", "flatFields", "context"],
  computed: {
    value: {
      get() {
        this.updateValue++; // 强制更新
        let friendValue = {
          value: this.isDeepValues ? this.deepPick(this.field.name.split("."), this.values) : this.friendValue()
        };
        return friendValue.value;
      },
      set(value) {
        let emitValue = this.beforeChange(value);
        this.changeValue(emitValue);
      }
    }
  },
  created() {
    this.load();
  },
  methods: {
    actionEmit(type, arg) {
      if (arg) {
        let msg = {
          type,
          arg
        };
        _utils_eventbus__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z.$emit(`${this.formId}:action`, msg);
      }
    },
    load() {
      this.setFieldAttr();
      this.pickHideFields();
      this.pickDependencies();
      this.pickRegExp();
      this.loadCompleteDispatch();
      this.pickFlatField();
    },
    pickFlatField() {
      if (!this.field.name) return;
      this.flatFields[this.field.name] = this.field;
    },
    loadCompleteDispatch() {
      // 隐藏字段需要立马派发，不然视觉体验不友好
      for (let key in this.hideFields) this.dispatchHide(key);
      // 等所有字段都渲染完成在派发options依赖
      if (this.context.loadDebounce) clearTimeout(this.context.loadDebounce);
      this.context.loadDebounce = setTimeout(() => {
        for (let key in this.dependencies) this.dispatchOptions(key);
        this.context.loadCompleted = true;
      }, 500);
    },
    setFieldAttr() {
      const defaultFieldAttr = this.defaultFieldAttr();
      let fieldAttr = (0,ramda__WEBPACK_IMPORTED_MODULE_3__.mergeDeepRight)(defaultFieldAttr, this.field);
      for (const [key, value] of Object.entries(fieldAttr)) this.field[key] = value;
    },
    defaultFieldAttr() {
      return {};
    },
    beforeChange(value) {
      return this.schema.type == "number" ? parseFloat(value) ? parseFloat(value) : value : value;
    },
    changeValue(value) {
      this.updateValue++;
      this.$emit('changeValue', this.field.name, this.schema, value, this.field);
    },
    friendValue() {
      // 做一些友好值处理
      let friendValue = null;
      let value = this.values[this.field.name];
      try {
        switch (this.schema.type) {
          case "array":
            friendValue = Array.isArray(value) ? value : (0,_utils__WEBPACK_IMPORTED_MODULE_4__/* .strToObj */ .Vq)(value);
            break;
          case "number":
            friendValue = (0,ramda__WEBPACK_IMPORTED_MODULE_3__.type)(value) == "Number" ? value : parseFloat(value);
            break;
          case "datetime":
            friendValue = new Date(value);
            break;
          case "boolean":
            friendValue = (0,ramda__WEBPACK_IMPORTED_MODULE_3__.type)(value) == "Boolean" ? value : value ? Boolean(value) : false;
            break;
          case "integer":
            friendValue = (0,ramda__WEBPACK_IMPORTED_MODULE_3__.type)(value) == "Number" ? value : value ? parseInt(value) : value;
            break;
        }
        if (friendValue) this.values[this.field.name] = friendValue; // 有友好值，需要更新
      } catch (e) {
        console.error(`转换友好值错了：${e}`);
      }
      return friendValue || value;
    },
    // 字段依赖隐藏
    pickHideFields() {
      const hideRely = this.field.hideRely;
      if (!hideRely) return; // 若不存在依赖，则无需收集
      const hideFields = Array.isArray(hideRely) ? hideRely : (0,ramda__WEBPACK_IMPORTED_MODULE_3__.type)(hideRely) == "String" ? [hideRely] : [];
      hideFields.map(hideItem => {
        let splitHideExp = hideItem.split("==");
        if (splitHideExp.length != 2) return;
        let relyKey = splitHideExp[0].trim();
        let relyValue = splitHideExp[1].trim();
        if (!this.hideFields[relyKey]) this.hideFields[relyKey] = [];
        // 必须全部遍历，以应对依赖先后关系
        for (let key in this.hideFields) {
          // 已存在则不需要重新收集
          let hasExit = this.hideFields[key].find(item => {
            if (item.key == relyKey && item.value == relyValue && item.name == this.field.name) {
              // 必须重新赋值，因为form的地址已经变了
              item.field = this.field;
              return true;
            }
          });
          if (hasExit) return;
        }
        this.hideFields[relyKey].push({
          name: this.field.name,
          key: relyKey,
          value: relyValue,
          field: this.field
        });
      });
    },
    // 收集依赖关系
    async pickDependencies() {
      if (!this.field.hasOwnProperty("dict") || this.field.length == 0) return;
      if (typeof this.field.dict == "string" && (0,_utils__WEBPACK_IMPORTED_MODULE_4__/* .isUrl */ .CB)(this.field.dict)) {
        // dict字段是url则直接获取数据，并赋值给options     
        const {
          method,
          respProp,
          params,
          pickValues
        } = this.field.dictConfig;
        pickValues.map(key => {
          if (this.values[key] != undefined) params[key] = this.values[key];
        });
        const response = await (0,_utils__WEBPACK_IMPORTED_MODULE_4__/* .axios */ .od)(this.field.dict, params, method);
        const options = this.deepPick(respProp.split("."), response);
        if (Array.isArray(options) && options.length > 0) this.field.options = options;
        if (this.field.defaultOption >= 0 && this.field.options.length > 0) {
          let option = options[this.field.defaultOption];
          this.values[this.field.name] = typeof option == "object" ? option[this.field.defaultProp.value] : option;
        }
      } else if (Object.keys(this.field.dict).length > 0) {
        for (let key in this.field.dict) {
          let dictItem = this.field.dict[key];
          let dictKeyVal = key.split("==");
          let relyKey = dictKeyVal[0].trim();
          let relyValue = dictKeyVal[1].trim();
          // 赋值初始值
          if (!this.dependencies[relyKey]) this.dependencies[relyKey] = [];
          // 已存在就无需重复添加
          let hasExit = this.dependencies[relyKey].find(item => {
            if (item.keyValue == relyValue && item.name == this.field.name) {
              // 必须重新赋值，因为form的地址已经变了
              item.field = this.field;
              return true;
            }
          });
          if (!hasExit) {
            this.dependencies[relyKey].push({
              name: this.field.name,
              beRelyKey: relyKey,
              keyValue: relyValue,
              dictValue: dictItem,
              field: this.field,
              type: this.schema.type,
              options: JSON.parse(JSON.stringify(this.field.options))
            });
          }
        }
      }
    },
    // 收集表达式依赖
    pickRegExp() {
      const regExp = this.field.regExp;
      if (!regExp) return;
      regExp.map(regItem => {
        const {
          relyName
        } = regItem;
        if (!this.regExpFields[relyName]) this.regExpFields[relyName] = [];
        if (this.regExpFields[relyName].find(item => item.childrenName == this.field.name && item.relyName == regItem.relyName)) return; // 确保只收取一个表达式，
        // 正式收集
        this.regExpFields[relyName].push({
          ...regItem,
          childrenName: this.field.name,
          field: this.field
        });
      });
    }
  }
};
/* harmony default export */ __webpack_exports__.Z = (baseMixin);

/***/ }),

/***/ 286:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// EXPORTS
__webpack_require__.d(__webpack_exports__, {
  "default": function() { return /* binding */ upload; }
});

// EXTERNAL MODULE: external "vue"
var external_vue_ = __webpack_require__(748);
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js!./node_modules/ts-loader/index.js??clonedRuleSet-86.use[2]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[4]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Richform/src/widgets/upload.vue?vue&type=template&id=0414245c&ts=true

const _hoisted_1 = ["id"];
const _hoisted_2 = {
  key: 0,
  class: "upload-type"
};
const _hoisted_3 = {
  key: 2
};
const _hoisted_4 = /*#__PURE__*/(0,external_vue_.createElementVNode)("div", {
  class: "el-upload__text"
}, [/*#__PURE__*/(0,external_vue_.createTextVNode)("将文件拖到此处，或"), /*#__PURE__*/(0,external_vue_.createElementVNode)("em", null, "点击上传")], -1);
const _hoisted_5 = {
  class: "el-upload__tip"
};
const _hoisted_6 = ["src"];
function render(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_elSwitch = (0,external_vue_.resolveComponent)("elSwitch");
  const _component_ElButton = (0,external_vue_.resolveComponent)("ElButton");
  const _component_Plus = (0,external_vue_.resolveComponent)("Plus");
  const _component_ElIcon = (0,external_vue_.resolveComponent)("ElIcon");
  const _component_UploadFilled = (0,external_vue_.resolveComponent)("UploadFilled");
  const _component_ElUpload = (0,external_vue_.resolveComponent)("ElUpload");
  const _component_ElDialog = (0,external_vue_.resolveComponent)("ElDialog");
  return (0,external_vue_.openBlock)(), (0,external_vue_.createElementBlock)("div", {
    class: "upload-widget",
    id: _ctx.widgetId
  }, [_ctx.field.showType ? ((0,external_vue_.openBlock)(), (0,external_vue_.createElementBlock)("div", _hoisted_2, [(0,external_vue_.createElementVNode)("span", {
    class: "type-label",
    style: (0,external_vue_.normalizeStyle)({
      color: _ctx.colors.fontColor
    })
  }, "上传类型：", 4), (0,external_vue_.createVNode)(_component_elSwitch, {
    modelValue: _ctx.field.type,
    "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => _ctx.field.type = $event),
    "active-color": "#13ce66",
    "inactive-color": "#ff4949",
    "active-text": "文件夹",
    "inactive-text": "文件",
    "active-value": "folder",
    "inactive-value": "file"
  }, null, 8, ["modelValue"])])) : (0,external_vue_.createCommentVNode)("", true), (0,external_vue_.createVNode)(_component_ElUpload, {
    ref: "uploadWidget",
    class: "upload-wrapper",
    name: _ctx.field.name,
    "list-type": _ctx.field.listType,
    "file-list": $data.fileList,
    drag: _ctx.field.draggable && _ctx.field.listType == 'text',
    action: _ctx.field.actions,
    multiple: _ctx.field.multiple,
    "auto-upload": _ctx.field.autoUpload,
    headers: $data.header,
    limit: _ctx.field.limit,
    disabled: _ctx.field.disabled,
    "show-file-list": _ctx.field.showFileList,
    accept: _ctx.field.accept,
    "before-remove": $options.onBeforeRemove,
    "on-success": $options.onSuccess,
    "on-remove": $options.onRemoveSuccess,
    "on-preview": $options.pictureCardPreview
  }, (0,external_vue_.createSlots)({
    default: (0,external_vue_.withCtx)(() => [_ctx.field.listType == 'picture' ? ((0,external_vue_.openBlock)(), (0,external_vue_.createBlock)(_component_ElButton, {
      key: 0,
      size: "default",
      type: "primary"
    }, {
      default: (0,external_vue_.withCtx)(() => [(0,external_vue_.createTextVNode)("点击上传")]),
      _: 1
    })) : _ctx.field.listType == 'picture-card' ? ((0,external_vue_.openBlock)(), (0,external_vue_.createBlock)(_component_ElIcon, {
      key: 1,
      class: "avatar-uploader-icon"
    }, {
      default: (0,external_vue_.withCtx)(() => [(0,external_vue_.createVNode)(_component_Plus)]),
      _: 1
    })) : _ctx.field.listType == 'text' ? ((0,external_vue_.openBlock)(), (0,external_vue_.createElementBlock)("div", _hoisted_3, [(0,external_vue_.createVNode)(_component_ElIcon, {
      class: "el-icon--upload"
    }, {
      default: (0,external_vue_.withCtx)(() => [(0,external_vue_.createVNode)(_component_UploadFilled)]),
      _: 1
    }), _hoisted_4])) : (0,external_vue_.createCommentVNode)("", true)]),
    _: 2
  }, [_ctx.field.tips.length > 0 ? {
    name: "tip",
    fn: (0,external_vue_.withCtx)(() => [(0,external_vue_.createElementVNode)("div", _hoisted_5, (0,external_vue_.toDisplayString)(_ctx.field.tips), 1)]),
    key: "0"
  } : undefined]), 1032, ["name", "list-type", "file-list", "drag", "action", "multiple", "auto-upload", "headers", "limit", "disabled", "show-file-list", "accept", "before-remove", "on-success", "on-remove", "on-preview"]), (0,external_vue_.createVNode)(_component_ElDialog, {
    modelValue: $data.dialogVisible,
    "onUpdate:modelValue": _cache[1] || (_cache[1] = $event => $data.dialogVisible = $event)
  }, {
    default: (0,external_vue_.withCtx)(() => [(0,external_vue_.createElementVNode)("img", {
      "w-full": "",
      src: $data.dialogImageUrl,
      alt: "Preview Image"
    }, null, 8, _hoisted_6)]),
    _: 1
  }, 8, ["modelValue"])], 8, _hoisted_1);
}
;// CONCATENATED MODULE: ./src/components/Richform/src/widgets/upload.vue?vue&type=template&id=0414245c&ts=true

// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.push.js
var es_array_push = __webpack_require__(7658);
// EXTERNAL MODULE: ./src/components/Richform/src/widgets/baseMixin.ts
var baseMixin = __webpack_require__(1462);
// EXTERNAL MODULE: external "element-plus"
var external_element_plus_ = __webpack_require__(5224);
// EXTERNAL MODULE: ./node_modules/@element-plus/icons-vue/dist/index.js
var dist = __webpack_require__(5781);
// EXTERNAL MODULE: ./src/components/Richform/src/utils/index.ts + 1 modules
var utils = __webpack_require__(8180);
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js!./node_modules/ts-loader/index.js??clonedRuleSet-86.use[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Richform/src/widgets/upload.vue?vue&type=script&lang=ts





/* harmony default export */ var uploadvue_type_script_lang_ts = ({
  mixins: [baseMixin/* default */.Z],
  components: {
    ElUpload: external_element_plus_.ElUpload,
    ElButton: external_element_plus_.ElButton,
    ElDialog: external_element_plus_.ElDialog,
    elSwitch: external_element_plus_.ElSwitch,
    ElIcon: external_element_plus_.ElIcon,
    UploadFilled: dist.UploadFilled,
    Plus: dist.Plus
  },
  data() {
    return {
      header: {
        [sessionStorage.getItem("richform-key")]: sessionStorage.getItem("richform-value")
      },
      fileList: [],
      dialogVisible: false,
      dialogImageUrl: null
    };
  },
  mounted() {
    this.onFileList();
    this.onSwitchType();
  },
  watch: {
    "field.type"(newType) {
      this.onSwitchType(newType);
    }
  },
  methods: {
    defaultFieldAttr() {
      return {
        name: "file",
        tips: "",
        type: "file",
        showType: false,
        listType: "picture",
        actions: "http://127.0.0.1:8080/manage/minio/upload.do",
        deleteUrl: "http://127.0.0.1:8080/manage/minio/removeFile.do",
        draggable: true,
        multiple: true,
        autoUpload: true,
        limit: 2,
        disabled: false,
        showFileList: true,
        accept: "",
        mapValues: {
          // 将服务器返回值映射到values对应字段
          originalFilename: "filename",
          fileSize: "filesize"
        },
        removeFunc: null,
        uploadFunc: null // 上传自定义函数,返回一个异步函数
      };
    },

    pictureCardPreview(uploadFile) {
      this.dialogImageUrl = uploadFile.url;
      this.dialogVisible = true;
    },
    // 改变上传的是文件夹还是文件
    onSwitchType(newType = this.field.type) {
      this.$nextTick(() => {
        let isFolder = newType == "folder";
        if (this.field.listType == "text") {
          let uploadDom = document.querySelector(`#${this.widgetId} .upload-wrapper input`);
          if (uploadDom) uploadDom.webkitdirectory = isFolder;
        }
      });
    },
    onFileList() {
      if (Array.isArray(this.value) && this.value.length > 0) {
        this.value.map(urlItem => {
          // 后端生成的uuid文件名
          let filePath = urlItem.indexOf("?") == -1 ? urlItem : urlItem.slice(0, urlItem.indexOf("?"));
          let fileName = filePath.slice(filePath.lastIndexOf("/") + 1, filePath.length);
          // 原始文件名
          let mapValues = this.field.mapValues;
          let originalFilename = mapValues.originalFilename;
          originalFilename = this.values[originalFilename];
          // 初始值
          this.fileList.push({
            name: originalFilename || fileName,
            url: urlItem
          });
        });
      }
    },
    onSuccess(response, file, fileList) {
      const {
        payload,
        msg,
        status
      } = response;
      if (status != 200) {
        (0,external_element_plus_.ElMessage)({
          type: "error",
          message: `上传失败，${msg}`
        });
        fileList.splice(fileList.length - 1, 1);
        return;
      }
      Object.assign(file, payload);
      this.pickValues(fileList);
    },
    pickValues(fileList) {
      let pickPath = [],
        fileSize = 0,
        fileName = "";
      fileList.map((fileItem, index) => {
        let filesizeItem = fileItem.size || fileItem.fileSize;
        if (filesizeItem) fileSize += fileItem.size || fileItem.fileSize;
        fileName += fileItem.name || fileItem.fileName;
        if (index != fileList.length - 1) fileName += ",";
        pickPath.push(fileItem.path || fileItem.url);
      });
      // 设置值
      this.changeValue(pickPath);
      // 映射值
      let mapValues = this.field.mapValues;
      if (fileName) this.values[mapValues.originalFilename] = fileName;
      if (fileSize) this.values[mapValues.fileSize] = fileSize;
    },
    onBeforeRemove(file) {
      // 发送完整路径，后端可能是分布式的
      return typeof this.field.removeFunc == "function" ? this.field.removeFunc(file, this.field) : new Promise((resolve, reject) => {
        (0,utils/* axios */.od)(this.field.deleteUrl, file).then(response => {
          if (response.status != 200) {
            (0,external_element_plus_.ElMessage)({
              type: "error",
              message: `删除失败，${response.msg}`
            });
            reject();
          }
          resolve("");
        }).catch(error => {
          reject();
        });
      });
    },
    onRemoveSuccess(file, fileList) {
      this.pickValues(fileList);
    }
  }
});
;// CONCATENATED MODULE: ./src/components/Richform/src/widgets/upload.vue?vue&type=script&lang=ts
 
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-67.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-67.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-67.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-67.use[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Richform/src/widgets/upload.vue?vue&type=style&index=0&id=0414245c&lang=scss
// extracted by mini-css-extract-plugin

;// CONCATENATED MODULE: ./src/components/Richform/src/widgets/upload.vue?vue&type=style&index=0&id=0414245c&lang=scss

// EXTERNAL MODULE: ./node_modules/vue-loader/dist/exportHelper.js
var exportHelper = __webpack_require__(3744);
;// CONCATENATED MODULE: ./src/components/Richform/src/widgets/upload.vue




;


const __exports__ = /*#__PURE__*/(0,exportHelper/* default */.Z)(uploadvue_type_script_lang_ts, [['render',render]])

/* harmony default export */ var upload = (__exports__);

/***/ })

}]);