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

/***/ 9589:
/***/ (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__(1305);
/* harmony import */ var _utils_common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4433);
/* harmony import */ var ramda__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(403);
/* 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__(9579);





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);

/***/ }),

/***/ 171:
/***/ (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 */ draggablelist; }
});

// EXTERNAL MODULE: external "vue"
var external_vue_ = __webpack_require__(1666);
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js!./node_modules/ts-loader/index.js??clonedRuleSet-41.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/draggablelist.vue?vue&type=template&id=802783c6&ts=true

const _hoisted_1 = ["id"];
const _hoisted_2 = {
  class: "draggable-list-item"
};
function render(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_Operation = (0,external_vue_.resolveComponent)("Operation");
  const _component_ElIcon = (0,external_vue_.resolveComponent)("ElIcon");
  const _component_ElInput = (0,external_vue_.resolveComponent)("ElInput");
  const _component_Expression = (0,external_vue_.resolveComponent)("Expression");
  const _component_ElColorPicker = (0,external_vue_.resolveComponent)("ElColorPicker");
  const _component_ElOption = (0,external_vue_.resolveComponent)("ElOption");
  const _component_ElSelect = (0,external_vue_.resolveComponent)("ElSelect");
  const _component_Remove = (0,external_vue_.resolveComponent)("Remove");
  const _component_draggable = (0,external_vue_.resolveComponent)("draggable");
  return (0,external_vue_.openBlock)(), (0,external_vue_.createElementBlock)("dl", {
    class: "draggable-list-widget",
    id: _ctx.widgetId
  }, [(0,external_vue_.createVNode)(_component_draggable, (0,external_vue_.mergeProps)($options.dragOptions(), {
    modelValue: _ctx.value,
    "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => _ctx.value = $event),
    "item-key": typeof _ctx.field.template == 'string' ? item => _ctx.value.indexOf(item) : _ctx.field.idKey,
    tag: "div"
  }), {
    item: (0,external_vue_.withCtx)(({
      element,
      index
    }) => [(0,external_vue_.createElementVNode)("dd", _hoisted_2, [(0,external_vue_.createVNode)(_component_ElIcon, {
      class: (0,external_vue_.normalizeClass)(['draggable-list-icon', 'list-handle-move'])
    }, {
      default: (0,external_vue_.withCtx)(() => [(0,external_vue_.createVNode)(_component_Operation)]),
      _: 1
    }), typeof element == 'string' ? ((0,external_vue_.openBlock)(), (0,external_vue_.createElementBlock)(external_vue_.Fragment, {
      key: 0
    }, [_ctx.field.strAttr.widget == 'input' ? ((0,external_vue_.openBlock)(), (0,external_vue_.createBlock)(_component_ElInput, {
      key: 0,
      class: "input-draggable",
      size: _ctx.field.size,
      modelValue: _ctx.value[index],
      "onUpdate:modelValue": $event => _ctx.value[index] = $event,
      placeholder: _ctx.value[index]
    }, null, 8, ["size", "modelValue", "onUpdate:modelValue", "placeholder"])) : _ctx.field.strAttr.widget == 'expression' ? ((0,external_vue_.openBlock)(), (0,external_vue_.createBlock)(_component_Expression, {
      key: 1,
      form: _ctx.form,
      values: _ctx.values,
      field: {
        name: _ctx.field.name,
        index,
        ..._ctx.field.strAttr
      }
    }, null, 8, ["form", "values", "field"])) : (0,external_vue_.createCommentVNode)("", true)], 64)) : ((0,external_vue_.openBlock)(true), (0,external_vue_.createElementBlock)(external_vue_.Fragment, {
      key: 1
    }, (0,external_vue_.renderList)(Object.keys(element), (key, index) => {
      return (0,external_vue_.openBlock)(), (0,external_vue_.createElementBlock)("div", {
        class: "column-wrapper",
        key: index
      }, [_ctx.field.attribute[key] && _ctx.field.attribute[key].editable && _ctx.field.attribute[key].widget == 'input' ? ((0,external_vue_.openBlock)(), (0,external_vue_.createBlock)(_component_ElInput, {
        key: 0,
        class: "input-draggable",
        modelValue: element[key],
        "onUpdate:modelValue": $event => element[key] = $event,
        size: _ctx.field.size,
        disabled: _ctx.field.attribute[key].disabled == true,
        placeholder: _ctx.field.attribute[key].placeholder || key
      }, null, 8, ["modelValue", "onUpdate:modelValue", "size", "disabled", "placeholder"])) : _ctx.field.attribute[key] && _ctx.field.attribute[key].editable && _ctx.field.attribute[key].widget == 'colorpicker' ? ((0,external_vue_.openBlock)(), (0,external_vue_.createBlock)(_component_ElColorPicker, {
        key: 1,
        disabled: _ctx.field.attribute[key].disabled == true,
        modelValue: element[key],
        "onUpdate:modelValue": $event => element[key] = $event,
        size: _ctx.field.size
      }, null, 8, ["disabled", "modelValue", "onUpdate:modelValue", "size"])) : _ctx.field.attribute[key] && _ctx.field.attribute[key].editable && _ctx.field.attribute[key].widget == 'select' ? ((0,external_vue_.openBlock)(), (0,external_vue_.createBlock)(_component_ElSelect, {
        key: 2,
        modelValue: element[key],
        "onUpdate:modelValue": $event => element[key] = $event,
        size: _ctx.field.size,
        disabled: _ctx.field.attribute[key].disabled == true,
        placeholder: _ctx.field.attribute[key].placeholder || key
      }, {
        default: (0,external_vue_.withCtx)(() => [((0,external_vue_.openBlock)(true), (0,external_vue_.createElementBlock)(external_vue_.Fragment, null, (0,external_vue_.renderList)(_ctx.field.attribute[key].options, element => {
          return (0,external_vue_.openBlock)(), (0,external_vue_.createBlock)(_component_ElOption, {
            key: element.value,
            label: element.label,
            value: element.value
          }, null, 8, ["label", "value"]);
        }), 128))]),
        _: 2
      }, 1032, ["modelValue", "onUpdate:modelValue", "size", "disabled", "placeholder"])) : (0,external_vue_.createCommentVNode)("", true)]);
    }), 128)), _ctx.field.showOperation ? ((0,external_vue_.openBlock)(), (0,external_vue_.createBlock)(_component_ElIcon, {
      key: 2,
      class: (0,external_vue_.normalizeClass)(['el-icon-remove', 'delete-list-icon']),
      onClick: $event => $options.deleteItem(index)
    }, {
      default: (0,external_vue_.withCtx)(() => [(0,external_vue_.createVNode)(_component_Remove)]),
      _: 2
    }, 1032, ["onClick"])) : (0,external_vue_.createCommentVNode)("", true)])]),
    _: 1
  }, 16, ["modelValue", "item-key"]), (0,external_vue_.withDirectives)((0,external_vue_.createElementVNode)("div", {
    class: "draggable-list-add",
    onClick: _cache[1] || (_cache[1] =
    //@ts-ignore
    (...args) => $options.addItem && $options.addItem(...args))
  }, " 添加 ", 512), [[external_vue_.vShow, _ctx.field.showOperation]])], 8, _hoisted_1);
}
;// CONCATENATED MODULE: ./src/components/Richform/src/widgets/draggablelist.vue?vue&type=template&id=802783c6&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__(9589);
// EXTERNAL MODULE: ./src/components/Richform/src/widgets/expression.vue + 6 modules
var expression = __webpack_require__(573);
// EXTERNAL MODULE: ./node_modules/vuedraggable/src/vuedraggable.js + 9 modules
var vuedraggable = __webpack_require__(6053);
// EXTERNAL MODULE: ./node_modules/@element-plus/icons-vue/dist/index.js
var dist = __webpack_require__(5781);
// EXTERNAL MODULE: external "element-plus"
var external_element_plus_ = __webpack_require__(7204);
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js!./node_modules/ts-loader/index.js??clonedRuleSet-41.use[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Richform/src/widgets/draggablelist.vue?vue&type=script&lang=ts






/* harmony default export */ var draggablelistvue_type_script_lang_ts = ({
  name: "DraggableListWidget",
  mixins: [baseMixin/* default */.Z],
  components: {
    Draggable: vuedraggable/* default */.Z,
    ElInput: external_element_plus_.ElInput,
    ElColorPicker: external_element_plus_.ElColorPicker,
    ElSelect: external_element_plus_.ElSelect,
    ElOption: external_element_plus_.ElOption,
    Expression: expression["default"],
    ElIcon: external_element_plus_.ElIcon,
    Operation: dist.Operation,
    Minus: dist.Minus,
    Remove: dist.Remove
  },
  data() {
    return {
      id: 1
    };
  },
  mounted() {
    if (!Array.isArray(this.value)) this.value = [];
    if (this.field.atLeastOne && this.value.length == 0) this.addItem();
    // 找出最大id
    for (let key in this.value) {
      let item = this.value[key];
      this.id = item.id > this.id ? item.id : this.id;
    }
  },
  methods: {
    // 定义一个规范化Schema的方法，用来为组件添加个性化的默认属性
    defaultFieldAttr() {
      return {
        idKey: "id",
        size: "default",
        title: "拖拽列表",
        atLeastOne: true,
        icon: "el-icon-circle-plus",
        showOperation: true,
        template: {
          label: "",
          value: ""
        },
        attribute: {
          // template各个字段属性
          label: {
            widget: "input",
            placeholder: "",
            editable: true,
            disabled: false,
            options: []
          },
          value: {
            widget: "input",
            placeholder: "",
            editable: true,
            disabled: false,
            options: [] // { label: "sss", value: "s" }
          }
        },

        strAttr: {
          // 当template为字符串时有效
          size: "default",
          widget: "input",
          key: {
            title: "字段",
            show: true,
            order: 1,
            options: []
          },
          exp: {
            title: "不等式",
            show: true,
            order: 2,
            options: [{
              label: "等于",
              value: "=="
            }]
          },
          val: {
            title: "值",
            show: true,
            order: 3,
            options: []
          }
        }
      };
    },
    // 增加项目
    addItem() {
      let template = null;
      if (typeof this.field.template == "string") template = this.field.template;else if (Object.keys(this.field.template).length > 0) {
        template = JSON.parse(JSON.stringify(this.field.template));
        let key = ++this.id;
        template[this.field.idKey] = key.toString();
      } else if (Array.isArray(this.field.template)) template = JSON.parse(JSON.stringify(this.field.template));
      this.value.push(template);
    },
    // 删除项目
    deleteItem(index) {
      if (this.value.length === 1 && this.field.atLeastOne) return;
      this.value.splice(index, 1);
    },
    // 拖拽配置
    dragOptions() {
      return {
        sort: true,
        animation: 200,
        ghostClass: "ghost",
        handle: ".list-handle-move",
        easing: "cubic-bezier(1, 0, 0, 1)",
        group: {
          name: "draggablelist",
          put: false
        }
      };
    }
  }
});
;// CONCATENATED MODULE: ./src/components/Richform/src/widgets/draggablelist.vue?vue&type=script&lang=ts
 
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-22.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-22.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-22.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-22.use[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Richform/src/widgets/draggablelist.vue?vue&type=style&index=0&id=802783c6&lang=scss
// extracted by mini-css-extract-plugin

;// CONCATENATED MODULE: ./src/components/Richform/src/widgets/draggablelist.vue?vue&type=style&index=0&id=802783c6&lang=scss

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




;


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

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

/***/ }),

/***/ 573:
/***/ (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 */ expression; }
});

// EXTERNAL MODULE: external "vue"
var external_vue_ = __webpack_require__(1666);
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js!./node_modules/ts-loader/index.js??clonedRuleSet-41.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/expression.vue?vue&type=template&id=c3229ae4&ts=true

const _hoisted_1 = {
  class: "expression-widget"
};
const _hoisted_2 = {
  class: "option-container"
};
const _hoisted_3 = ["onClick"];
function render(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_ElInput = (0,external_vue_.resolveComponent)("ElInput");
  const _component_perfect_scrollbar = (0,external_vue_.resolveComponent)("perfect-scrollbar");
  const _component_ElButton = (0,external_vue_.resolveComponent)("ElButton");
  const _component_ElPopover = (0,external_vue_.resolveComponent)("ElPopover");
  return (0,external_vue_.openBlock)(), (0,external_vue_.createElementBlock)("div", _hoisted_1, [(0,external_vue_.createVNode)(_component_ElPopover, {
    placement: "bottom",
    title: "",
    width: 635,
    trigger: "click",
    ref: "popoverRef"
  }, {
    reference: (0,external_vue_.withCtx)(() => [(0,external_vue_.createVNode)(_component_ElButton, {
      size: _ctx.field.size,
      onClick: $options.onExpressionBtn
    }, {
      default: (0,external_vue_.withCtx)(() => [(0,external_vue_.createTextVNode)((0,external_vue_.toDisplayString)($options.buttonLable), 1)]),
      _: 1
    }, 8, ["size", "onClick"])]),
    default: (0,external_vue_.withCtx)(() => [(0,external_vue_.createVNode)(_component_ElInput, {
      class: (0,external_vue_.normalizeClass)(['el-form-item', $data.isError ? 'is-error' : '']),
      ref: "expressionInput",
      modelValue: $data.expValue,
      "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => $data.expValue = $event),
      clearable: "",
      placeholder: "输入条件表达式"
    }, null, 8, ["class", "modelValue"]), (0,external_vue_.createElementVNode)("div", _hoisted_2, [((0,external_vue_.openBlock)(true), (0,external_vue_.createElementBlock)(external_vue_.Fragment, null, (0,external_vue_.renderList)($options.cardOptions, (obj, index) => {
      return (0,external_vue_.openBlock)(), (0,external_vue_.createElementBlock)(external_vue_.Fragment, null, [obj.show ? ((0,external_vue_.openBlock)(), (0,external_vue_.createElementBlock)("div", {
        class: "option-item",
        key: index
      }, [(0,external_vue_.createElementVNode)("div", {
        class: "title",
        style: (0,external_vue_.normalizeStyle)({
          background: _ctx.form.colors.btnBgColor || '#F5F7FA'
        })
      }, (0,external_vue_.toDisplayString)(obj.title), 5), (0,external_vue_.createVNode)(_component_perfect_scrollbar, {
        class: "option-list"
      }, {
        default: (0,external_vue_.withCtx)(() => [((0,external_vue_.openBlock)(true), (0,external_vue_.createElementBlock)(external_vue_.Fragment, null, (0,external_vue_.renderList)(obj.options, (item, index) => {
          return (0,external_vue_.openBlock)(), (0,external_vue_.createElementBlock)("div", {
            key: index,
            class: (0,external_vue_.normalizeClass)(['option', item.disabled ? 'disabled-option' : '']),
            onClick: $event => $options.clickOption(item)
          }, (0,external_vue_.toDisplayString)(item.label), 11, _hoisted_3);
        }), 128))]),
        _: 2
      }, 1024)])) : (0,external_vue_.createCommentVNode)("", true)], 64);
    }), 256))]), (0,external_vue_.createVNode)(_component_ElButton, {
      type: "primary",
      size: "small",
      class: "sure-exp",
      onClick: $options.onSureExp
    }, {
      default: (0,external_vue_.withCtx)(() => [(0,external_vue_.createTextVNode)("确定")]),
      _: 1
    }, 8, ["onClick"])]),
    _: 1
  }, 512)]);
}
;// CONCATENATED MODULE: ./src/components/Richform/src/widgets/expression.vue?vue&type=template&id=c3229ae4&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__(9589);
// EXTERNAL MODULE: external "element-plus"
var external_element_plus_ = __webpack_require__(7204);
// EXTERNAL MODULE: external "vue3-perfect-scrollbar"
var external_vue3_perfect_scrollbar_ = __webpack_require__(2087);
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js!./node_modules/ts-loader/index.js??clonedRuleSet-41.use[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Richform/src/widgets/expression.vue?vue&type=script&lang=ts




/* harmony default export */ var expressionvue_type_script_lang_ts = ({
  mixins: [baseMixin/* default */.Z],
  components: {
    ElInput: external_element_plus_.ElInput,
    ElButton: external_element_plus_.ElButton,
    ElPopover: external_element_plus_.ElPopover,
    PerfectScrollbar: external_vue3_perfect_scrollbar_.PerfectScrollbar
  },
  mounted() {
    this.$nextTick(() => {
      this.validateExpression();
      if (this.$refs.expressionInput) this.expressionInputEl = this.$refs.expressionInput.input;
    });
  },
  watch: {
    expValue(val) {
      this.validateExpression(val);
    }
  },
  computed: {
    cardOptions() {
      let options = [];
      for (let key in this.field) {
        if (["key", "exp", "val"].includes(key)) {
          this.field[key].name = key;
          options.push(this.field[key]);
        }
      }
      options.sort((a, b) => a.order - b.order);
      return options;
    },
    buttonLable() {
      let label = Array.isArray(this.value) ? this.value[this.field.index] : this.value;
      return label || "请选择";
    }
  },
  methods: {
    defaultFieldAttr() {
      return {
        size: "default",
        key: {
          title: "字段",
          show: true,
          order: 1,
          options: []
        },
        exp: {
          title: "不等式",
          show: true,
          order: 2,
          options: [{
            label: "等于",
            value: "=="
          }]
        },
        val: {
          title: "值",
          show: true,
          order: 3,
          options: []
        }
      };
    },
    // 获取表达式输入框光标位置
    getCursorPosition() {
      let startPos = this.expressionInputEl.selectionStart;
      let endPos = this.expressionInputEl.selectionEnd;
      if (startPos === undefined || endPos === undefined) return;
      this.cursorPosition = startPos;
    },
    // 迭代获取值
    iterationFindValue(obj) {
      let result = {};
      for (let key in obj) {
        if (typeof obj[key] == "object") {
          result[key] = this.iterationFindValue(obj[key]);
        } else {
          result[key] = obj[key];
        }
      }
      return result;
    },
    // 设置值
    async clickOption({
      value,
      disabled
    }) {
      if (disabled == true) return;
      this.getCursorPosition();
      let newCursorPosition = this.cursorPosition + value.length;
      let oldValue = this.expValue || "";
      let expressionValue = oldValue.slice(0, this.cursorPosition) + value + oldValue.slice(this.cursorPosition);
      this.cursorPosition = newCursorPosition;
      this.expValue = expressionValue;
      await this.$nextTick();
      this.expressionInputEl.focus();
      // this.expressionInputEl.setSelectionRange(
      //   newCursorPosition,
      //   newCursorPosition
      // );
    },

    // 校验
    validateExpression(expression) {
      let regValue = [];
      let inequality = ["!", ">", "<", ">=", "<=", "==", "!=", "&&", /\|\|/];
      this.combination(inequality, inequality, regValue); // 组合
      let regString = regValue.join("|");
      regString = regString.replace(/\//g, "");
      let reg = new RegExp(regString);
      let abnormalReg = /^[\||\&|\>|\<|\=]|\w[\||\&|\>|\<|\=|\!]+$/;
      this.isError = reg.test(expression) || abnormalReg.test(expression);
    },
    // 组合
    combination(base = [], sub = [], value = []) {
      base.map(baseItem => sub.map(subItem => value.push(`(${baseItem + subItem})`)));
    },
    onSureExp() {
      if (this.isError) return;
      if (Array.isArray(this.value)) {
        this.value[this.field.index] = this.expValue;
      } else this.value = this.expValue;
      this.$refs.popoverRef.hide();
    },
    onExpressionBtn() {
      if (!this.value || this.buttonLable == "请选择") return;
      this.expValue = this.buttonLable;
    }
  },
  data() {
    return {
      expValue: "",
      isError: false,
      cursorPosition: 0 // 光标位置
    };
  }
});
;// CONCATENATED MODULE: ./src/components/Richform/src/widgets/expression.vue?vue&type=script&lang=ts
 
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-22.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-22.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-22.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-22.use[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/Richform/src/widgets/expression.vue?vue&type=style&index=0&id=c3229ae4&lang=scss
// extracted by mini-css-extract-plugin

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

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




;


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

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

/***/ })

}]);