¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div> |
| | | <avue-form v-model="form" :option="option" v-loading="loading" ref="form" :style="{minHeight: loading ? '300px' : ''}"> |
| | | <template :slot="item.prop + 'Label'" v-for="item in slotColumnList"> |
| | | <span> |
| | | <span>{{ item.label }} </span> |
| | | <el-tooltip |
| | | v-if="item.keyAttr" |
| | | class="item" |
| | | effect="dark" |
| | | content="è¯¥å±æ§ä¸ºå
³é®å±æ§" |
| | | placement="top-start" |
| | | > |
| | | <i class="el-icon-star-on key_attr_icon"></i> |
| | | </el-tooltip> |
| | | </span> |
| | | </template> |
| | | <template :slot="item.prop + ''" v-for="item in slotColumnList"> |
| | | <vciWebRefer v-if="item.type=='refer'" :value="item.value" :options="item.referConfig"></vciWebRefer> |
| | | </template> |
| | | </avue-form> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { getFormTemplate } from "@/api/formTemplate"; |
| | | import { getDictionary } from "../../api/system/dict"; |
| | | import vciWebRefer from "../refer/vciWebRefer.vue"; |
| | | export default { |
| | | name: "FormTemplate", |
| | | components: { vciWebRefer}, |
| | | props: { |
| | | // é»è®¤ç¦ç¨å
ç´ |
| | | disabledProp: { |
| | | type: Array, |
| | | default: () => ["id"], |
| | | }, |
| | | templateOid: { |
| | | type: String, |
| | | default: "", |
| | | }, |
| | | codeClassifyOid: { |
| | | type: String, |
| | | default: "", |
| | | }, |
| | | // ä¿®æ¹åæ¾çæ°æ® |
| | | editForm: { |
| | | type: Object, |
| | | default: () => ({}), |
| | | }, |
| | | // 表åç±»åï¼add, edit, detailï¼ |
| | | type: { |
| | | type: String, |
| | | default: "add", |
| | | }, |
| | | // èªå®ä¹è¡¨åç±»å |
| | | selfColumnType: { |
| | | type: Object, |
| | | default: () => ({}), |
| | | }, |
| | | // èªå®ä¹è¡¨å屿§ |
| | | selfColumnConfig: { |
| | | type: Object, |
| | | default: () => ({}), |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | | formIndex: 0, |
| | | form: {}, |
| | | option: { |
| | | emptyBtn: false, |
| | | submitBtn: false, |
| | | labelWidth: "130", |
| | | column: [], |
| | | group: [], |
| | | }, |
| | | loading: true, |
| | | columnType: { |
| | | text: "input", |
| | | combox: "select", |
| | | truefalse: "switch", |
| | | number: "number", |
| | | textarea: "textarea", |
| | | datetime: "datetime", |
| | | date: "date", |
| | | refer:"refer" |
| | | }, |
| | | // åæ°æ® |
| | | // testItems: [ |
| | | // { |
| | | // comboxKey: null, |
| | | // customClass: null, |
| | | // data: null, |
| | | // dateFormate: "", |
| | | // defaultValue: "", |
| | | // displayExtension: null, |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "id", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "", |
| | | // readOnly: false, |
| | | // referConfig: null, |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: null, |
| | | // suffix: "", |
| | | // text: "ä¼ å¼ç¦ç¨åè½", |
| | | // tooltips: "", |
| | | // type: "combox", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // { |
| | | // customClass: null, |
| | | // data: null, |
| | | // dateFormate: "", |
| | | // defaultValue: "", |
| | | // displayExtension: null, |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "state", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "", |
| | | // readOnly: true, |
| | | // referConfig: null, |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: null, |
| | | // suffix: "", |
| | | // text: "æ¥å£ç¦ç¨åè½", |
| | | // tooltips: "", |
| | | // type: "combox", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // { |
| | | // comboxKey: null, |
| | | // customClass: null, |
| | | // data: null, |
| | | // dateFormate: "", |
| | | // defaultValue: "", |
| | | // displayExtension: null, |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "oldcode", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "el-icon-search", |
| | | // readOnly: false, |
| | | // referConfig: null, |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: null, |
| | | // suffix: "ææ¬åç¼æµè¯", |
| | | // text: "ååç¼åè½", |
| | | // tooltips: "", |
| | | // type: "text", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // { |
| | | // comboxKey: null, |
| | | // customClass: null, |
| | | // data: null, |
| | | // dateFormate: "", |
| | | // defaultValue: "", |
| | | // displayExtension: null, |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "materialname", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "", |
| | | // readOnly: false, |
| | | // referConfig: null, |
| | | // required: true, |
| | | // selectLibFlag: "", |
| | | // showField: null, |
| | | // suffix: "", |
| | | // text: "æ£åæ ¡éªåè½", |
| | | // tooltips: "请è¾å
¥æ°å", |
| | | // type: "text", |
| | | // unique: false, |
| | | // verify: "/[0-9]/", |
| | | // }, |
| | | // { |
| | | // comboxKey: null, |
| | | // customClass: null, |
| | | // data: [ |
| | | // { |
| | | // attributes: {}, |
| | | // key: "model_type", |
| | | // value: "模å", |
| | | // }, |
| | | // { |
| | | // attributes: {}, |
| | | // key: "part_type", |
| | | // value: "é¶ä»¶", |
| | | // }, |
| | | // ], |
| | | // dateFormate: "", |
| | | // defaultValue: "", |
| | | // displayExtension: null, |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "dataSelect", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "", |
| | | // readOnly: false, |
| | | // referConfig: null, |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: null, |
| | | // suffix: "", |
| | | // text: "ç´æ¥è¿å䏿", |
| | | // tooltips: "", |
| | | // type: "combox", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // { |
| | | // comboxKey: "formTemplateTest", |
| | | // customClass: null, |
| | | // data: [], |
| | | // dateFormate: "", |
| | | // defaultValue: "", |
| | | // displayExtension: null, |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "dictSelect", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "", |
| | | // readOnly: false, |
| | | // referConfig: null, |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: null, |
| | | // suffix: "", |
| | | // text: "åå
¸è¿å䏿", |
| | | // tooltips: "", |
| | | // type: "combox", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // { |
| | | // comboxKey: null, |
| | | // customClass: null, |
| | | // data: null, |
| | | // dateFormate: "", |
| | | // defaultValue: "", |
| | | // displayExtension: null, |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "firstfl", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "", |
| | | // readOnly: false, |
| | | // referConfig: null, |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: null, |
| | | // suffix: "", |
| | | // text: "æ°åè¾å
¥æ¡", |
| | | // tooltips: "", |
| | | // type: "number", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // { |
| | | // comboxKey: null, |
| | | // customClass: null, |
| | | // data: null, |
| | | // dateFormate: "yyyy-MM-dd HH:mm:ss", |
| | | // defaultValue: "", |
| | | // displayExtension: null, |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "datetime", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "", |
| | | // readOnly: false, |
| | | // referConfig: null, |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: null, |
| | | // suffix: "", |
| | | // text: "æ¥ææ¶é´éæ©å¨", |
| | | // tooltips: "", |
| | | // type: "datetime", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // { |
| | | // comboxKey: null, |
| | | // customClass: null, |
| | | // data: null, |
| | | // dateFormate: "", |
| | | // defaultValue: "", |
| | | // displayExtension: null, |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "time", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "", |
| | | // readOnly: false, |
| | | // referConfig: null, |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: null, |
| | | // suffix: "", |
| | | // text: "æ¶é´éæ©å¨", |
| | | // tooltips: "", |
| | | // type: "date", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // { |
| | | // comboxKey: null, |
| | | // customClass: null, |
| | | // data: null, |
| | | // dateFormate: "", |
| | | // defaultValue: "false", |
| | | // displayExtension: null, |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "xiaoshouwl", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "", |
| | | // readOnly: false, |
| | | // referConfig: null, |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: null, |
| | | // suffix: "", |
| | | // text: "å¼å
³", |
| | | // tooltips: "", |
| | | // type: "truefalse", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // { |
| | | // comboxKey: null, |
| | | // customClass: null, |
| | | // data: null, |
| | | // dateFormate: "", |
| | | // defaultValue: "ææ¯é»è®¤å¼", |
| | | // displayExtension: null, |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "tuhao", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "", |
| | | // readOnly: false, |
| | | // referConfig: null, |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: null, |
| | | // suffix: "", |
| | | // text: "é»è®¤å¼åè½", |
| | | // tooltips: "æç¤º", |
| | | // type: "text", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // { |
| | | // comboxKey: null, |
| | | // customClass: null, |
| | | // data: null, |
| | | // dateFormate: "", |
| | | // defaultValue: "", |
| | | // displayExtension: null, |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "xinghaoguige", |
| | | // hidden: false, |
| | | // keyAttr: true, |
| | | // prefix: "", |
| | | // readOnly: false, |
| | | // referConfig: null, |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: null, |
| | | // suffix: "", |
| | | // text: "屿§å
³é®å¼", |
| | | // tooltips: "", |
| | | // type: "text", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // { |
| | | // comboxKey: null, |
| | | // customClass: null, |
| | | // data: null, |
| | | // dateFormate: "", |
| | | // defaultValue: "", |
| | | // displayExtension: null, |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "jiliangdw", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "", |
| | | // readOnly: false, |
| | | // tip: "ææ¯æç¤ºåè½", |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: "jiliangdwname", |
| | | // suffix: "", |
| | | // text: "æç¤ºåè½", |
| | | // tooltips: "", |
| | | // type: "text", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // { |
| | | // comboxKey: null, |
| | | // customClass: null, |
| | | // data: null, |
| | | // dateFormate: "", |
| | | // defaultValue: "", |
| | | // displayExtension: "this.form.sum = this.form.fun1 + this.form.fun2", |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "fun1", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "", |
| | | // readOnly: false, |
| | | // referConfig: null, |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: null, |
| | | // suffix: "", |
| | | // text: "åæ°1æµè¯js", |
| | | // tooltips: "", |
| | | // type: "text", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // { |
| | | // comboxKey: null, |
| | | // customClass: null, |
| | | // data: null, |
| | | // dateFormate: "", |
| | | // defaultValue: "", |
| | | // displayExtension: "this.form.sum = this.form.fun1 + this.form.fun2", |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "fun2", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "", |
| | | // readOnly: false, |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: "hesuanfenleiname", |
| | | // suffix: "", |
| | | // text: "åæ°2æµè¯js", |
| | | // tooltips: "", |
| | | // type: "text", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // { |
| | | // comboxKey: null, |
| | | // customClass: null, |
| | | // data: null, |
| | | // dateFormate: "", |
| | | // defaultValue: "", |
| | | // displayExtension: "", |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "sum", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "", |
| | | // readOnly: true, |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: "", |
| | | // suffix: "", |
| | | // text: "åæ°1åæ°2æ±å", |
| | | // tooltips: "", |
| | | // type: "text", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // { |
| | | // comboxKey: null, |
| | | // customClass: null, |
| | | // data: null, |
| | | // dateFormate: "", |
| | | // defaultValue: "", |
| | | // displayExtension: null, |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "textarea", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "", |
| | | // readOnly: false, |
| | | // referConfig: null, |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: null, |
| | | // suffix: "", |
| | | // text: "ææ¬å", |
| | | // tooltips: "", |
| | | // type: "textarea", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // { |
| | | // comboxKey: null, |
| | | // customClass: null, |
| | | // data: null, |
| | | // dateFormate: "", |
| | | // defaultValue: "", |
| | | // displayExtension: null, |
| | | // extendAttrMap: null, |
| | | // extendAttrString: null, |
| | | // field: "cz", |
| | | // hidden: false, |
| | | // keyAttr: false, |
| | | // prefix: "", |
| | | // readOnly: true, |
| | | // referConfig: true, |
| | | // required: false, |
| | | // selectLibFlag: "", |
| | | // showField: "depId", |
| | | // suffix: "", |
| | | // text: "åç
§", |
| | | // tooltips: "", |
| | | // type: "text", |
| | | // unique: false, |
| | | // verify: "", |
| | | // }, |
| | | // ], |
| | | trendsSpan: 8, |
| | | defaultValue: {}, |
| | | // 表å屿§ |
| | | attributes: [], |
| | | slotColumnList: [] |
| | | }; |
| | | }, |
| | | mounted() { |
| | | this.handleResize(); |
| | | }, |
| | | methods: { |
| | | init(columnList) { |
| | | if (Array.isArray(columnList)) { |
| | | this.templateRender(columnList); |
| | | } else { |
| | | this.getFormTemplate(); |
| | | } |
| | | }, |
| | | getFormTemplate() { |
| | | getFormTemplate({ |
| | | templateOid: this.templateOid, |
| | | codeClassifyOid: this.codeClassifyOid, |
| | | }) |
| | | .then((res) => { |
| | | if (res.status === 200) { |
| | | this.templateRender(res.data.formDefineVO.items); |
| | | this.$emit("getFormTemplateEnd", res.data); |
| | | } |
| | | }) |
| | | .catch((err) => { |
| | | this.loading = false; |
| | | console.log(err); |
| | | }); |
| | | }, |
| | | templateRender(formItemList) { |
| | | // æ éåç»æ°æ® |
| | | let column = []; |
| | | let group = []; |
| | | let dictKeys = []; |
| | | let slotColumnList = [] |
| | | formItemList.forEach((formItem) => { |
| | | formItem = this.resetFormConfig(formItem); |
| | | if (formItem.type === "line") { |
| | | group.push({ |
| | | label: formItem.text, |
| | | prop: formItem.text, |
| | | collapse: true, |
| | | column: [], |
| | | }); |
| | | } |
| | | if ( |
| | | formItem.type === "combox" && |
| | | formItem.comboxKey && |
| | | (!Array.isArray(formItem.dicData) || formItem.dicData.length === 0) |
| | | ) { |
| | | dictKeys.push({ dictKey: formItem.comboxKey, field: formItem.field }); |
| | | } |
| | | // ç¦ç¨é¨å屿§ï¼å¤é¨ä¼ å¼ç¦ç¨ååç
§ç¦ç¨ï¼ |
| | | if ( |
| | | this.disabledProp.includes(formItem.field) //|| |
| | | //this.$utilFunc.isValuableObj(formItem.referConfig) |
| | | ) { |
| | | formItem.readOnly = true; |
| | | } |
| | | // è®¾ç½®è¡¨åæ ¡éªçè§åï¼ææ¬ |
| | | let message = "è¯·éæ©"; |
| | | let trigger = "change"; |
| | | if (formItem.type === "text") { |
| | | message = "请è¾å
¥"; |
| | | trigger = "blur"; |
| | | } |
| | | let columnItem = { |
| | | label: formItem.text, |
| | | labelslot: true, |
| | | prop: this.$utilFunc.isValuableObj(formItem.referConfig) |
| | | ? formItem.showField || formItem.field |
| | | : formItem.field, |
| | | field: formItem.field, |
| | | type: this.columnType[formItem.type], |
| | | dicData: this.getDataList(formItem.type, formItem.data), |
| | | disabled: this.type === "detail" ? true : formItem.readOnly, |
| | | prepend: this.preOrSufFixShow("text", formItem.prefix), |
| | | append: this.preOrSufFixShow("text", formItem.suffix), |
| | | prefixIcon: this.preOrSufFixShow("icon", formItem.prefix), |
| | | suffixIcon: this.preOrSufFixShow("icon", formItem.suffix), |
| | | valueFormat: formItem.dateFormate, |
| | | format: formItem.dateFormate, |
| | | keyAttr: formItem.keyAttr, |
| | | value: formItem.defaultValue, |
| | | tip: formItem.tooltips, |
| | | tipPlacement: "right", |
| | | comboxKey: formItem.comboxKey, |
| | | display: !formItem.hidden, |
| | | maxlength: formItem.maxlength, |
| | | filterable: true, |
| | | referConfig:formItem.referConfig, |
| | | change: () => { |
| | | this.changeFun(formItem.displayExtension, formItem.prop); |
| | | }, |
| | | span: formItem.type === "textarea" ? 24 : this.trendsSpan, |
| | | click: () => { |
| | | this.clickFun(formItem.referConfig) |
| | | }, |
| | | rules: [ |
| | | { |
| | | required: formItem.required, |
| | | message: `请${message}${formItem.text}`, |
| | | trigger, |
| | | }, |
| | | { |
| | | // å¦ææ²¡ææ£ååå¹é
ä»»ä½å符 |
| | | pattern: formItem.verify ? formItem.verify : /[\s\S.]*/g, |
| | | message: formItem.tooltips, |
| | | trigger, |
| | | }, |
| | | ], |
| | | props: { |
| | | label: "value", |
| | | value: "key", |
| | | }, |
| | | }; |
| | | slotColumnList.push(columnItem) |
| | | if (group.length === 0) { |
| | | column.push(columnItem); |
| | | } else { |
| | | group[group.length - 1]["column"].push(columnItem); |
| | | } |
| | | }); |
| | | this.slotColumnList = slotColumnList; |
| | | this.$set(this.option, "column", column); |
| | | this.$set(this.option, "group", group); |
| | | this.formIndex++; |
| | | this.loading = false |
| | | this.geDictData(dictKeys); |
| | | }, |
| | | // 使ç¨ä¼ å
¥çè¡¨åæ°æ®é
ç½® |
| | | resetFormConfig(formItem) { |
| | | for (const configType in this.selfColumnConfig) { |
| | | if (Object.hasOwnProperty.call(this.selfColumnConfig, configType)) { |
| | | const element = this.selfColumnConfig[configType]; |
| | | if (configType === "function") { |
| | | for (const attr in element) { |
| | | if (Object.hasOwnProperty.call(element, attr)) { |
| | | const fun = element[attr]; |
| | | formItem[attr] = fun(formItem); |
| | | } |
| | | } |
| | | } else if (configType === "exchange") { |
| | | for (const newAttr in element) { |
| | | if (Object.hasOwnProperty.call(element, newAttr)) { |
| | | const oldAttr = element[newAttr]; |
| | | formItem[newAttr] = formItem[oldAttr]; |
| | | } |
| | | } |
| | | } else if (configType === "directVoluation") { |
| | | for (const attr in element) { |
| | | if (Object.hasOwnProperty.call(element, attr)) { |
| | | const value = element[attr]; |
| | | formItem[attr] = value; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return formItem; |
| | | }, |
| | | handleResize() { |
| | | let windowWidth = document.body.clientWidth; |
| | | this.trendsSpan = 24 / Math.floor(windowWidth / 500); |
| | | this.formIndex++; |
| | | }, |
| | | // ååç¼ |
| | | preOrSufFixShow(type, val) { |
| | | if (this.$utilFunc.isEmpty(val) && typeof val !== "string") return; |
| | | const isIcon = val.slice(0, 8) === "el-icon-"; |
| | | if ((type === "text" && !isIcon) || (type === "icon" && isIcon)) { |
| | | return val; |
| | | } |
| | | }, |
| | | changeFun(displayExtension, prop) { |
| | | // executeCode({displayExtension, data: this.form}).then(res => { |
| | | // this.form[prop] = res.data.data |
| | | // }) |
| | | }, |
| | | clickFun(referConfig) { |
| | | console.log(123123); |
| | | if (this.type === "detail") { |
| | | return; |
| | | } |
| | | }, |
| | | // è·åswichåå·²æ¿å°çä¸ææ°æ® |
| | | getDataList(type, dicData) { |
| | | if (type === "truefalse") { |
| | | return [ |
| | | { |
| | | key: false, |
| | | value: "å¦", |
| | | }, |
| | | { |
| | | key: true, |
| | | value: "æ¯", |
| | | }, |
| | | ]; |
| | | } else if (type === "combox") { |
| | | return dicData; |
| | | } |
| | | return []; |
| | | }, |
| | | // è·ååå
¸æ°æ® |
| | | geDictData(dictKeys) { |
| | | dictKeys.forEach((dictObj) => { |
| | | getDictionary({ code: dictObj.dictKey }).then((res) => { |
| | | if (res.data && res.data.code === 200) { |
| | | this.option.column = this.option.column.map((item) => { |
| | | if (item.field === dictObj.field) { |
| | | let dictData = (res.data.data || []).map((itm) => { |
| | | itm.value = itm.dictValue; |
| | | itm.key = itm.dictKey; |
| | | return itm; |
| | | }); |
| | | item.dicData = dictData; |
| | | } |
| | | return item; |
| | | }); |
| | | } |
| | | }); |
| | | }); |
| | | }, |
| | | }, |
| | | watch: { |
| | | form: { |
| | | deep: true, |
| | | immediate: true, |
| | | handler(newV) { |
| | | this.$emit("getFormData", newV); |
| | | }, |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="less" scoped></style> |