{"remainingRequest":"D:\\jenkins\\workspace\\artfess-module\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\artfess-module\\src\\components\\HtInput.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\artfess-module\\src\\components\\HtInput.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\r\nimport utils from \"@/utils.js\";\r\nimport FormMath from \"@/math.js\";\r\nimport HtFieldTail from \"@/components/HtFieldTail.vue\";\r\n\r\nexport default {\r\n name: \"ht-input\",\r\n props: {\r\n validate: [String, Object],\r\n value: [String, Number],\r\n format: [String, Number],\r\n name: String,\r\n size: {\r\n type: String,\r\n default: \"small\",\r\n },\r\n controlsPosition: {\r\n type: String,\r\n default: \"right\",\r\n },\r\n width: [String, Number],\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 clearable: {\r\n type: Boolean,\r\n default: true,\r\n },\r\n showPassword: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n mathExp: String,\r\n type: {\r\n type: String,\r\n default: \"text\",\r\n },\r\n dateCalcExp: Object,\r\n placeholder: {\r\n type: String,\r\n default: \"请输入内容\",\r\n },\r\n readonly: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n disabled: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n min: Number,\r\n max: Number,\r\n step: {\r\n type: Number,\r\n default: 1,\r\n },\r\n stepStrictly: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n precision: Number,\r\n cols: {\r\n type: Number,\r\n default: 60,\r\n },\r\n rows: {\r\n type: Number,\r\n default: 2,\r\n },\r\n autosize: {\r\n type: [Boolean, Object],\r\n default: false,\r\n },\r\n prefixIcon: String,\r\n suffixIcon: String,\r\n tabindex: String,\r\n modelExpression: {\r\n type: String,\r\n default: \"\",\r\n },\r\n minlength: {\r\n type: Number,\r\n },\r\n maxlength: {\r\n type: Number,\r\n },\r\n showWordLimit: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n readonlyFormat: {\r\n type: Function,\r\n },\r\n },\r\n components: {\r\n HtFieldTail,\r\n },\r\n data() {\r\n return {\r\n unwatchAry: [],\r\n inputName: null,\r\n writeable: true,\r\n newValidate: null,\r\n };\r\n },\r\n computed: {\r\n inputVal: {\r\n get() {\r\n if (!utils.isEmpty(this.format) && !this.inputWriteable) {\r\n return this.format;\r\n }\r\n if (this.readonlyFormat && !this.inputWriteable) {\r\n let resultVal = this.readonlyFormat(this.value);\r\n if (!utils.isEmpty(resultVal)) {\r\n return resultVal;\r\n }\r\n }\r\n if (utils.isEmpty(this.value)) {\r\n return \"\";\r\n }\r\n return this.value;\r\n },\r\n set(val) {\r\n this.$emit(\"input\", val);\r\n },\r\n },\r\n colsVal: function () {\r\n return this.type == \"textarea\" ? this.cols : null;\r\n },\r\n rowsVal: function () {\r\n return this.type == \"textarea\" ? this.rows : null;\r\n },\r\n inputWriteable: function () {\r\n return this.writeable ? utils.getWriteable(this.permission):this.writeable;\r\n },\r\n inputValidate: function () {\r\n if (this.newValidate) {\r\n return this.newValidate;\r\n }\r\n return utils.addRequiredOrNot(this.permission, this.validate, this);\r\n },\r\n inputWidth: function () {\r\n return this.width\r\n ? typeof this.width == \"string\"\r\n ? { width: this.width }\r\n : { width: `${this.width}px` }\r\n : null;\r\n },\r\n },\r\n mounted() {\r\n const _me = this;\r\n const exp = this.mathExp;\r\n const formVm = utils.getOnlineFormInstance(_me);\r\n\r\n // 数学运算表达式\r\n if (exp) {\r\n let elAttr = this.$vnode.data.model.expression;\r\n if (this.modelExpression) {\r\n elAttr = this.modelExpression;\r\n }\r\n const fields = FormMath.parseFuncexpField(exp);\r\n formVm.$on(elAttr, function (args) {\r\n if (args.hasOwnProperty(\"index\")) {\r\n const { subScopeEl, index } = utils.getSubScopeElAndIndex(_me.$el);\r\n if (subScopeEl != null && index === null) {\r\n throw \"要计算子表行数据的输入框不在包含data-subname属性的元素中.\";\r\n }\r\n if (index == args.index) {\r\n _me.$emit(\"input\", args.result);\r\n }\r\n } else {\r\n _me.$emit(\"input\", args.result);\r\n }\r\n });\r\n fields.forEach((ele) => {\r\n if (formVm.watchMap.has(ele)) {\r\n let ary = formVm.watchMap.get(ele);\r\n ary.push({ target: elAttr, exp });\r\n formVm.watchMap.set(ele, ary.unique(\"target\"));\r\n } else {\r\n formVm.watchMap.set(ele, [{ target: elAttr, exp }]);\r\n }\r\n });\r\n }\r\n // 日期计算表达式\r\n if (this.dateCalcExp) {\r\n // 计算日期间隔\r\n let handleDateCalc = function (startVal, endVal) {\r\n _me.$emit(\r\n \"input\",\r\n utils.dateCalc(startVal, endVal, _me.dateCalcExp.diffType)\r\n );\r\n };\r\n // 获取是否在子表中每一行进行日期计算\r\n const { subScopeEl, index } = utils.getSubScopeElAndIndex(_me.$el);\r\n if (subScopeEl) {\r\n const startScope = utils.getSubInputScopeByModelExpression(\r\n subScopeEl,\r\n this.dateCalcExp.start\r\n );\r\n const endScope = utils.getSubInputScopeByModelExpression(\r\n subScopeEl,\r\n this.dateCalcExp.end\r\n );\r\n // 对于子表中某行的日期计算,需要找到日期控件对应的vm实例\r\n startScope.$watch(\r\n \"inputVal\",\r\n function (newVal, oldVal) {\r\n if (newVal !== oldVal) {\r\n handleDateCalc(startScope.value, endScope.value);\r\n }\r\n },\r\n { immediate: true }\r\n );\r\n endScope.$watch(\r\n \"inputVal\",\r\n function (newVal, oldVal) {\r\n if (newVal !== oldVal) {\r\n handleDateCalc(startScope.value, endScope.value);\r\n }\r\n },\r\n { immediate: true }\r\n );\r\n } else {\r\n let cb = function (newVal, oldVal) {\r\n if (newVal !== oldVal) {\r\n let startVal = utils.getValueByPath(\r\n formVm,\r\n _me.dateCalcExp.start,\r\n index\r\n );\r\n let endVal = utils.getValueByPath(\r\n formVm,\r\n _me.dateCalcExp.end,\r\n index\r\n );\r\n handleDateCalc(startVal, endVal);\r\n }\r\n };\r\n // 主表中的日期计算,在表单上通过v-model的表达式来监控值变更\r\n formVm.$watch(this.dateCalcExp.start, cb, { immediate: true });\r\n formVm.$watch(this.dateCalcExp.end, cb, { immediate: true });\r\n }\r\n }\r\n },\r\n beforeDestroy() {\r\n let that = this;\r\n let watcher = that._watchers.find((m) => m.expression == \"inputVal\");\r\n if (watcher && watcher.cb) {\r\n // 单行文本销毁时,触发一次change事件,更新计算公式\r\n watcher.cb(\"0\", that.inputVal, true);\r\n }\r\n },\r\n destroyed() {\r\n this.unwatchAry &&\r\n this.unwatchAry.forEach((unwatch) => {\r\n unwatch.call();\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 },\r\n methods: {\r\n handleBlur(event) {\r\n this.$emit(\"blur\", event);\r\n },\r\n handleFocus(event) {\r\n this.$emit(\"focus\", event);\r\n },\r\n handleChange(val) {\r\n this.$emit(\"change\", val);\r\n },\r\n handleInput(val) {\r\n this.$emit(\"input\", val);\r\n },\r\n handleClear() {\r\n this.$emit(\"clear\");\r\n },\r\n },\r\n};\r\n",null]}