{"remainingRequest":"D:\\jenkins\\workspace\\artfess-module\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\artfess-module\\src\\components\\HtJobSelector.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\artfess-module\\src\\components\\HtJobSelector.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\r\nimport utils from \"@/utils.js\";\r\nimport HtFieldTail from \"@/components/HtFieldTail.vue\";\r\nimport Selector from \"@/components/common/Selector.vue\";\r\nimport { setTimeout } from \"timers\";\r\n\r\nexport default {\r\n  name: \"ht-job-selector\",\r\n  props: {\r\n    validate: [String, Object],\r\n    value: String,\r\n    selectLabel: String,\r\n    placeholder: {\r\n      type: String,\r\n      default: \"请输入内容\"\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    single: {\r\n      type: Boolean,\r\n      default: false\r\n    },\r\n    config: Object,\r\n    data: {\r\n      type: Array,\r\n      default: () => {\r\n        return [];\r\n      }\r\n    },\r\n    tableColumns: {\r\n      type: Array,\r\n      default: () => {\r\n        return [];\r\n      }\r\n    },\r\n    pagination: {\r\n      type: Object,\r\n      default: () => {\r\n        return {\r\n          page: 1,\r\n          pageSize: 50,\r\n          total: 0\r\n        };\r\n      }\r\n    },\r\n    quickSearchProps: {\r\n      type: String,\r\n      required: true\r\n    },\r\n    appendToBody: {\r\n      type: Boolean,\r\n      default: false\r\n    }\r\n  },\r\n  components: {\r\n    HtFieldTail,\r\n    Selector\r\n  },\r\n  data() {\r\n    return {\r\n      inputName: null,\r\n      writeable: true,\r\n      inputSuffixHeight: 30,\r\n      selectors: [],\r\n      dialogVisible: false,\r\n      primaryField: this.selectLabel\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  },\r\n  watch: {\r\n    // 当所选择的数据发生变化时，同步到v-model中\r\n    selectors: function(newVal) {\r\n      let ary = [],\r\n        idAry = [],\r\n        codeAry = [];\r\n      if (newVal && newVal.constructor === Array && newVal.length > 0) {\r\n        newVal.forEach(m => {\r\n          ary.push(m.name);\r\n          if (m.hasOwnProperty(\"id\")) {\r\n            idAry.push(m.id);\r\n          }\r\n          if (m.hasOwnProperty(\"code\")) {\r\n            codeAry.push(m.code);\r\n          }\r\n        });\r\n      }\r\n      if (this.config) {\r\n        // 配置了id的绑定关系，则回填到指定属性上\r\n        if (this.config.hasOwnProperty(\"id\")) {\r\n          utils.setValueByConfigKey(this, this.config, \"id\", idAry.join(\",\"));\r\n          this.primaryField = \"id\";\r\n        }\r\n        // 配置了name的绑定关系，则回填到指定属性上\r\n        if (this.config.hasOwnProperty(\"name\")) {\r\n          utils.setValueByConfigKey(this, this.config, \"name\", ary.join(\",\"));\r\n        }\r\n        // 配置了code的绑定关系，则回填到指定的属性上\r\n        if (this.config.hasOwnProperty(\"code\")) {\r\n          utils.setValueByConfigKey(\r\n            this,\r\n            this.config,\r\n            \"code\",\r\n            codeAry.join(\",\")\r\n          );\r\n          this.primaryField = this.primaryField == \"id\" ? \"id\" : \"code\";\r\n        }\r\n      }\r\n      // 通过valueChange事件发布值变更消息\r\n      this.$emit(\"valueChange\", ary.join(\",\"));\r\n      setTimeout(() => {\r\n        this.calacInputSuffixHeight();\r\n        if (this.$refs.inputEl) {\r\n          this.$refs.inputEl.focus();\r\n          this.$refs.inputEl.blur();\r\n        }\r\n      }, 10);\r\n    },\r\n    value: function(newVal) {\r\n      // 父级传递进来的value发生变更时，需要同步到当前所选数据中\r\n      this.valueInit();\r\n    }\r\n  },\r\n  mounted() {\r\n    // 组件第一次挂载时，同步value到当前所选数据中\r\n    this.valueInit();\r\n  },\r\n  created() {\r\n    this.inputName = this.name ? this.name : utils.getName();\r\n    this.$validator = this.$root.$validator;\r\n  },\r\n  methods: {\r\n    // 同步value到当前所选数据中\r\n    valueInit() {\r\n      let tmpAry = [];\r\n      if (this.value) {\r\n        let idAry = [],\r\n          codeAry = [];\r\n        if (this.config) {\r\n          // 配置了id绑定关系，则获取id的值\r\n          if (this.config.hasOwnProperty(\"id\")) {\r\n            let idVal = utils.getValueByConfigKey(this, this.config, \"id\");\r\n            if (idVal) {\r\n              idAry = idVal.split(\",\").trim();\r\n            }\r\n          }\r\n          // 配置了code绑定关系，则获取code的值\r\n          if (this.config.hasOwnProperty(\"code\")) {\r\n            let codeVal = utils.getValueByConfigKey(this, this.config, \"code\");\r\n            if (codeVal) {\r\n              codeAry = codeVal.split(\",\").trim();\r\n            }\r\n          }\r\n        }\r\n        // 将name、id、code从逗号分割的字符串解析为json对象格式的数组\r\n        let valAry = this.value.split(\",\").trim();\r\n        valAry.forEach((m, index) => {\r\n          let item = { name: m };\r\n          if (idAry.length > index) {\r\n            item[\"id\"] = idAry[index];\r\n          }\r\n          if (codeAry.length > index) {\r\n            item[\"code\"] = codeAry[index];\r\n          }\r\n          tmpAry.push(item);\r\n        });\r\n      }\r\n      // 对数组做深度对比，如果值不完全相等，则进行赋值操作\r\n      if (!utils.arrayEquals(tmpAry, this.selectors)) {\r\n        this.selectors = tmpAry;\r\n      }\r\n    },\r\n    showDialog() {\r\n      if (!this.inputWriteable) {\r\n        return;\r\n      }\r\n      this.dialogVisible = true;\r\n      setTimeout(() => {\r\n        this.$refs.selectorRef.onShow();\r\n      });\r\n    },\r\n    handleClose(done) {\r\n      this.$refs.selectorRef.onHide();\r\n      done && done();\r\n    },\r\n    handleDialogSure() {\r\n      this.dialogVisible = false;\r\n      this.$refs.selectorRef.onHide(true);\r\n    },\r\n    handleDialogCancel() {\r\n      this.dialogVisible = false;\r\n      this.$refs.selectorRef.onHide();\r\n    },\r\n    handleRemove(item) {\r\n      this.selectors.remove(item);\r\n    },\r\n    // 更新当前输入框的高度来适配已选数据的高度\r\n    calacInputSuffixHeight() {\r\n      if (!this.$refs.tagSpans) return;\r\n      if (this.$refs.tagSpans.offsetHeight) {\r\n        this.inputSuffixHeight = this.$refs.tagSpans.offsetHeight + 5;\r\n      } else {\r\n        this.inputSuffixHeight = 30;\r\n      }\r\n    },\r\n    load(param, cb) {\r\n      this.$emit(\"load\", param, cb);\r\n    }\r\n  }\r\n};\r\n",null]}