From 2591e298a3fd1332ad0ca33059f6ba0b7d426f51 Mon Sep 17 00:00:00 2001 From: pengwei <2071057782@qq.com> Date: 星期四, 20 三月 2025 10:08:00 +0800 Subject: [PATCH] 最新代码提交 --- 项目代码/client/src/components/basic/VolForm.vue | 386 +++++++++++++++++++++++++++--------------------------- 1 files changed, 195 insertions(+), 191 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/client/src/components/basic/VolForm.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/client/src/components/basic/VolForm.vue" index 3e6b9b1..dfc6d08 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/client/src/components/basic/VolForm.vue" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/client/src/components/basic/VolForm.vue" @@ -82,12 +82,12 @@ node-key="key" :props="{ label: 'label' }" > - <template #default="{data,node }"> + <template #default="{ data, node }"> <!-- <el-checkbox v-model="node.checked"></el-checkbox> --> - <!-- {{getNode(node, data)}} --> - <!-- {{node.checked}} --> - <!-- 杩欓噷杩樻湁鐐归棶棰橈紝鍚庨潰澶勭悊 --> - {{ data.label}}</template + <!-- {{getNode(node, data)}} --> + <!-- {{node.checked}} --> + <!-- 杩欓噷杩樻湁鐐归棶棰橈紝鍚庨潰澶勭悊 --> + {{ data.label }}</template > </el-tree-select> <template @@ -358,7 +358,7 @@ v-else-if="item.type == 'cascader'" :options="item.data" :props="{ - checkStrictly: item.changeOnSelect || item.checkStrictly + checkStrictly: item.changeOnSelect || item.checkStrictly, }" @change="item.onChange" > @@ -404,7 +404,7 @@ type="textarea" :autosize="{ minRows: item.minRows || 2, - maxRows: item.maxRows || 10 + maxRows: item.maxRows || 10, }" :placeholder="item.placeholder ? item.placeholder : item.title" /> @@ -493,32 +493,32 @@ <script> const rule = { change: [ - 'checkbox', - 'select', - 'date', - 'datetime', - 'drop', - 'radio', - 'cascader' + "checkbox", + "select", + "date", + "datetime", + "drop", + "radio", + "cascader", ], // 2020.05.31澧炲姞绾ц仈绫诲瀷 phone: /^[1][3,4,5,6,7,8,9][0-9]{9}$/, decimal: /(^[\-0-9][0-9]*(.[0-9]+)?)$/, - number: /(^[\-0-9][0-9]*([0-9]+)?)$/ + number: /(^[\-0-9][0-9]*([0-9]+)?)$/, }; -const inputTypeArr = ['text', 'string', 'mail', 'textarea', 'password']; +const inputTypeArr = ["text", "string", "mail", "textarea", "password"]; const types = { - int: 'number', - byte: 'number', - decimal: 'number', // "float", - string: 'string', - bool: 'boolean', - date: 'datetime', - date: 'date', - mail: 'email' + int: "number", + byte: "number", + decimal: "number", // "float", + string: "string", + bool: "boolean", + date: "datetime", + date: "date", + mail: "email", }; //琛ㄥ崟楠岃瘉娉ㄦ剰锛氭瘡娆¢獙璇侀兘蹇呴』鎵цcallback,鍚﹀垯楠岃瘉涓嶆墽琛屽洖璋冩柟娉� const colPow = Math.pow(10, 3); -import FormExpand from './VolForm/VolFormRender'; +import FormExpand from "./VolForm/VolFormRender"; import { defineAsyncComponent, defineComponent, @@ -527,61 +527,61 @@ toRefs, getCurrentInstance, onMounted, - watch -} from 'vue'; + watch, +} from "vue"; export default defineComponent({ components: { FormExpand, - 'vol-upload': defineAsyncComponent(() => - import('@/components/basic/VolUpload.vue') + "vol-upload": defineAsyncComponent(() => + import("@/components/basic/VolUpload.vue") ), - 'vol-wang-editor': defineAsyncComponent(() => - import('@/components/editor/VolWangEditor.vue') - ) + "vol-wang-editor": defineAsyncComponent(() => + import("@/components/editor/VolWangEditor.vue") + ), }, props: { loadKey: { // 鏄惁鍔犺浇formRules瀛楁閰嶇疆鐨勬暟鎹簮 type: Boolean, - default: true + default: true, }, width: { // 琛ㄥ崟瀹藉害 type: Number, - default: 0 + default: 0, }, labelWidth: { // 琛ㄥ崟宸﹁竟label鏂囧瓧鏍囩鐨勫搴� type: Number, - default: 100 + default: 100, }, formRules: { // 琛ㄥ崟閰嶇疆瑙勫垯锛屽瀛楁绫诲瀷锛屾槸鍚﹀繀濉� type: Array, - default: [] + default: [], }, formFields: { type: Object, default: () => { return {}; - } + }, }, editor: { // 2021.01.16缂栬緫鍣ㄤ俊鎭� {uploadImgUrl:"",upload:null//涓婁紶鏂规硶} type: Object, default: () => { return {}; - } + }, }, size: { type: String, //large / default / small - default: 'large' + default: "large", }, select2Count: { //瓒呭嚭鏁伴噺鏄剧ずselect2缁勪欢 type: Number, - default: 500 - } + default: 500, + }, }, computed: { rules() { @@ -597,7 +597,7 @@ }, 100); } return ruleResult; - } + }, }, setup(props, context) { const { appContext, proxy } = getCurrentInstance(); @@ -630,7 +630,7 @@ }); } row.forEach((item, yIndex) => { - if (item.type == 'number') { + if (item.type == "number") { numberFields.push(item.field); } // 鐩墠鍙敮鎸乻elect鍗曢�夎繙绋嬫悳绱紝remote杩滅▼浠庡悗鍙板瓧鍏告暟鎹簮杩涜鎼滅储锛寀rl浠庢寚瀹氱殑url鎼滅储 @@ -644,18 +644,18 @@ // 鍒濆鍖栨暟鎹簮绌哄璞� if (item.dataKey) { // 涓嬫媺妗嗛兘寮哄埗璁剧疆涓哄瓧绗︿覆绫诲瀷 - item.columnType = 'string'; + item.columnType = "string"; if (!item.data) { item.data = []; } } - if (item.range || item.type == 'range') { + if (item.range || item.type == "range") { if ( !(props.formFields[item.field] instanceof Array) || props.formFields[item.field].length != 2 ) { - props.formFields[item.field] = ['', '']; + props.formFields[item.field] = ["", ""]; } rangeFields.push(item.field); } @@ -681,10 +681,10 @@ if (keys.length == 0) return; appContext.config.globalProperties.http - .post('/api/Sys_Dictionary/GetVueDictionary', keys) + .post("/api/Sys_Dictionary/GetVueDictionary", keys) .then((dic) => { bindOptions(dic, binds); - proxy.$emit('dicInited', dic); + proxy.$emit("dicInited", dic); }); }; const bindOptions = (dic, binds) => { @@ -692,7 +692,7 @@ if (d.data.length > props.select2Count) { if ( !binds.some((x) => { - return x.key == d.dicNo && x.type == 'cascader'; + return x.key == d.dicNo && x.type == "cascader"; }) ) { d.data.forEach((item) => { @@ -706,18 +706,19 @@ // 濡傛灉鏈夋暟鎹殑鍒欎笉鏌ヨ if (x.data.length > 0) return true; //2022.03.13澧炲姞绾ц仈鏁版嵁婧愯嚜鍔ㄨ浆鎹� - if (x.type == 'cascader' || x.type == 'treeSelect') { + if (x.type == "cascader" || x.type == "treeSelect") { let _data = JSON.parse(JSON.stringify(d.data)); - let cascaderArr = appContext.config.globalProperties.base.convertTree( - _data, - (node, data, isRoot) => { - if (!node.inited) { - node.inited = true; - node.label = node.value; - node.value = node.key; + let cascaderArr = + appContext.config.globalProperties.base.convertTree( + _data, + (node, data, isRoot) => { + if (!node.inited) { + node.inited = true; + node.label = node.value; + node.value = node.key; + } } - } - ); + ); props.formRules.forEach((option) => { option.forEach((item) => { if (item.dataKey == x.key) { @@ -726,13 +727,13 @@ } }); }); - } else if (d.data.length > 0 && !d.data[0].hasOwnProperty('key')) { + } else if (d.data.length > 0 && !d.data[0].hasOwnProperty("key")) { let source = d.data, newSource = new Array(source.length); for (let index = 0; index < source.length; index++) { newSource[index] = { - key: source['key'] + '', - value: source['value'] + key: source["key"] + "", + value: source["value"], }; } x.data.push(...newSource); @@ -746,17 +747,17 @@ const initUpload = (item, init) => { if (!init) return; if ( - ['img', 'excel', 'file'].indexOf(item.type != -1) || - item.columnType == 'img' + ["img", "excel", "file"].indexOf(item.type != -1) || + item.columnType == "img" ) { // 鍙槸娌¤缃槸鍚﹁嚜鍔ㄤ笂浼犵殑锛岄粯璁ら兘鏄�夋嫨鏂囦欢鍚庤嚜鍔ㄤ笂浼� - if (!item.hasOwnProperty('autoUpload')) { + if (!item.hasOwnProperty("autoUpload")) { item.autoUpload = true; } - if (!item.hasOwnProperty('fileList')) { + if (!item.hasOwnProperty("fileList")) { item.fileList = true; } - if (!item.hasOwnProperty('downLoad')) { + if (!item.hasOwnProperty("downLoad")) { item.downLoad = true; } if (!item.removeBefore) { @@ -790,9 +791,9 @@ let result = true; volform.value.validate((valid) => { if (!valid) { - appContext.config.globalProperties.$message.error('鏁版嵁楠岃瘉鏈�氳繃!'); + appContext.config.globalProperties.$message.error("鏁版嵁楠岃瘉鏈�氳繃!"); result = false; - } else if (typeof callback === 'function') { + } else if (typeof callback === "function") { try { callback(valid); } catch (error) { @@ -812,7 +813,7 @@ rangeFields, numberFields, validate, - volform + volform, // initFormRules, // initSource }; @@ -820,7 +821,7 @@ created() { this.formRules.forEach((rules) => { rules.forEach((option) => { - if (option.type == 'treeSelect' && option.multiple === undefined) { + if (option.type == "treeSelect" && option.multiple === undefined) { option.multiple = true; } }); @@ -830,7 +831,10 @@ data() { return { // remoteCall: true, - errorImg: 'this.src="' + require('@/assets/imgs/error-img.png') + '"' + errorImg: + 'this.src="' + + new URL("../assets/imgs/error-img.png", import.meta.url).href + + '"', // span: 1, // rangeFields: [], }; @@ -858,7 +862,7 @@ }, getSrc(path) { if (!path) return; - if (!this.base.isUrl(path) && path.indexOf('.') != -1) { + if (!this.base.isUrl(path) && path.indexOf(".") != -1) { return this.http.ipAddress + path; } return path; @@ -866,10 +870,10 @@ // 鏄惁涓哄浘鐗囨枃浠剁瓑鏍煎紡骞跺瀛楁鐨勮浆鎹㈡垚鏁扮粍锛歔{name:'1.jpg',path:'127.0.0.1/ff/1.jpg'}] isFile(item, formFields) { if ( - item.type == 'img' || - item.columnType == 'img' || - item.type == 'excel' || - item.type == 'file' + item.type == "img" || + item.columnType == "img" || + item.type == "excel" || + item.type == "file" ) { this.convertFileToArray(item, formFields); return true; @@ -896,21 +900,21 @@ return; } // 灏嗕互閫楀彿闅斿紑鐨勬枃浠跺垎鍓叉垚鏁扮粍127.0.0.1/aa/1.jpg,灏�127.0.0.1/aa/2.jpg - if (typeof fileInfo === 'string') { - if (fileInfo.trim() === '') { + if (typeof fileInfo === "string") { + if (fileInfo.trim() === "") { formFields[item.field] = []; return; } // 濡傛灉鏂囦欢璺緞鏄瓧绗︿覆锛屽垯浣跨敤锛屾媶鍒� - fileInfo = fileInfo.replace(/\\/g, '/'); - let files = fileInfo.split(','); + fileInfo = fileInfo.replace(/\\/g, "/"); + let files = fileInfo.split(","); formFields[item.field] = []; for (let index = 0; index < files.length; index++) { let file = files[index]; - let splitFile = file.split('/'); + let splitFile = file.split("/"); formFields[item.field].push({ name: splitFile.length > 0 ? splitFile[splitFile.length - 1] : file, - path: file // this.base.isUrl(file) ? file : this.http.ipAddress + file, + path: file, // this.base.isUrl(file) ? file : this.http.ipAddress + file, }); } } @@ -920,26 +924,26 @@ file.path, file.name, { - Authorization: this.$store.getters.getToken() + Authorization: this.$store.getters.getToken(), }, this.http.ipAddress ); }, validatorPhone(ruleOption, value, callback) { - if (!ruleOption.required && !value && value != '0') { + if (!ruleOption.required && !value && value != "0") { return callback(); } - if (!rule.phone.test((value || '').trim())) { - return callback(new Error('璇疯緭鍏ユ纭殑鎵嬫満鍙�')); + if (!rule.phone.test((value || "").trim())) { + return callback(new Error("璇疯緭鍏ユ纭殑鎵嬫満鍙�")); } callback(); }, validatorPwd(ruleOption, value, callback) { - if (!ruleOption.required && !value && value != '0') { + if (!ruleOption.required && !value && value != "0") { return callback(); } - if ((value + '').trim().length < 6) { - return callback(new Error('瀵嗙爜闀垮害涓嶈兘灏忎簬6浣�')); + if ((value + "").trim().length < 6) { + return callback(new Error("瀵嗙爜闀垮害涓嶈兘灏忎簬6浣�")); } callback(); }, @@ -951,33 +955,33 @@ ? val.map((x) => { return x; }) - : val.split(','); + : val.split(","); for (let index = 0; index < valArr.length; index++) { var _item = data.find((x) => { - return x.key && x.key != '0' && x.key + '' == valArr[index] + ''; + return x.key && x.key != "0" && x.key + "" == valArr[index] + ""; }); if (_item) { valArr[index] = _item.value; } } - return valArr.join(','); + return valArr.join(","); }, getText(formFields, item) { // 2019.10.24淇琛ㄥ崟select缁勪欢涓哄彧璇荤殑灞炴�ф椂娌℃湁缁戝畾鏁版嵁婧� let text = formFields[item.field]; - if (typeof text === 'function') return text(formFields); - if (text === 'null' || text === '' || text === null || text === undefined) - return '--'; + if (typeof text === "function") return text(formFields); + if (text === "null" || text === "" || text === null || text === undefined) + return "--"; //2021.03.02澧炲姞鍙鏃舵棩鏈熷鐞� - if (item.type == 'date') { - return text.replace('T', ' ').split(' ')[0]; + if (item.type == "date") { + return text.replace("T", " ").split(" ")[0]; } //2021.03.31淇琛ㄥ崟switch鍙鏃舵病鏈夎浆鎹㈠�肩殑闂 - if (item.type == 'switch') { - return text ? '鏄�' : '鍚�'; + if (item.type == "switch") { + return text ? "鏄�" : "鍚�"; } if (!item.data) return text; - if (item.type == 'selectList' || item.type == 'checkbox') { + if (item.type == "selectList" || item.type == "checkbox") { return this.convertArrayValue(item.data, text); } var _item = item.data.find((x) => { @@ -991,7 +995,7 @@ // console.log(2); }, onChange(item, value) { - if (item.onChange && typeof item.onChange === 'function') { + if (item.onChange && typeof item.onChange === "function") { item.onChange(value, item); } }, @@ -1002,7 +1006,7 @@ // console.log('undefined'); } this.remoteCall = false; - if (item.onChange && typeof item.onChange === 'function') { + if (item.onChange && typeof item.onChange === "function") { item.onChange(value, item); } }, @@ -1016,7 +1020,7 @@ return; } if ( - val == '' || + val == "" || (item.data.length == 1 && (val == item.data[0].key || val == item.data[0].value)) ) { @@ -1025,14 +1029,14 @@ // 寮瑰嚭妗嗘垨鍒濆鍖栬〃鍗曟椂缁檇ata璁剧疆鏁扮粍榛樿鍊�2 // 2020.09.26淇杩滅▼鎼滅储鑷畾涔塽rl涓嶈捣浣滅敤鐨勯棶棰� let url; - if (typeof item.url === 'function') { + if (typeof item.url === "function") { url = item.url(val, item.dataKey, item); } else { url = - (item.url || '/api/Sys_Dictionary/GetSearchDictionary') + - '?dicNo=' + + (item.url || "/api/Sys_Dictionary/GetSearchDictionary") + + "?dicNo=" + item.dataKey + - '&value=' + + "&value=" + val; } this.http.post(url).then((dicData) => { @@ -1043,14 +1047,14 @@ }); }, getObject(date) { - if (typeof date === 'object') { + if (typeof date === "object") { return date; } return new Date(date); }, reset(sourceObj) { // 閲嶇疆琛ㄥ崟鏃讹紝绂佺敤杩滅▼鏌ヨ - this.$refs['volform'].resetFields(); + this.$refs["volform"].resetFields(); if (this.rangeFields.length) { this.rangeFields.forEach((key) => { this.formFields[key].splice(0); @@ -1085,24 +1089,24 @@ if ( // item.readonly || // item.disabled || - item.type == 'switch' || - item.type == 'range' + item.type == "switch" || + item.type == "range" ) return { required: false }; // 鐢ㄦ埛璁剧疆鐨勮嚜瀹氫箟鏂规硶 - if (item.validator && typeof item.validator === 'function') { + if (item.validator && typeof item.validator === "function") { return { validator: (rule, val, callback) => { // 鐢ㄦ埛鑷畾涔夌殑鏂规硶锛屽鏋滆繑鍥炰簡鍊硷紝鐩存帴鏄剧ず杩斿洖鐨勫�硷紝楠岃瘉涓嶉�氳繃 let message = item.validator(rule, val); - if (message) return callback(new Error(message + '')); + if (message) return callback(new Error(message + "")); return callback(); }, required: item.required, - trigger: rule.change.indexOf(item.type) != -1 ? 'change' : 'blur' + trigger: rule.change.indexOf(item.type) != -1 ? "change" : "blur", }; } - if (['img', 'excel', 'file'].indexOf(item.type) != -1) { + if (["img", "excel", "file"].indexOf(item.type) != -1) { return { validator: (rule, val, callback) => { //2021.09.05绉婚櫎鏂囦欢涓婁紶榛樿蹇呭~ @@ -1112,118 +1116,118 @@ (!val || !val.length) ) { return callback( - new Error(item.type == 'img' ? '璇蜂笂浼犵収鐗�' : '璇蜂笂浼犳枃浠�') + new Error(item.type == "img" ? "璇蜂笂浼犵収鐗�" : "璇蜂笂浼犳枃浠�") ); } return callback(); }, required: item.required, - trigger: 'change' + trigger: "change", }; } // 璁剧疆鏁板瓧鐨勬渶澶у�兼皯鏈�灏忓�� if ( - item.type == 'number' || - item.columnType == 'number' || - item.columnType == 'int' || - item.type == 'decimal' + item.type == "number" || + item.columnType == "number" || + item.columnType == "int" || + item.type == "decimal" ) { // 濡傛灉鏄繀濉」鐨勬暟瀛楋紝璁剧疆涓�涓粯璁ゆ渶澶т笌鏈�鍊煎皬 - if (item.required && typeof item.min !== 'number') { + if (item.required && typeof item.min !== "number") { item.min = 0; //item.type == "decimal" ? 0.1 : 1; } return { required: item.required, - message: item.title + '鍙兘鏄暟瀛�', + message: item.title + "鍙兘鏄暟瀛�", title: item.title, - trigger: 'blur', + trigger: "blur", min: item.min, max: item.max, type: item.columnType || item.type, validator: (ruleObj, value, callback) => { if (!ruleObj.min && !ruleObj.max) { if (ruleObj.required) { - if ((!value && value != '0') || !rule.decimal.test(value)) { - return callback(new Error('鍙兘鏄暟瀛�')); + if ((!value && value != "0") || !rule.decimal.test(value)) { + return callback(new Error("鍙兘鏄暟瀛�")); } } return callback(); } if (this.isReadonly(item)) return callback(); - if (ruleObj.type == 'number') { + if (ruleObj.type == "number") { if (!rule.number.test(value)) { - ruleObj.message = ruleObj.title + '鍙兘鏄暣鏁�'; + ruleObj.message = ruleObj.title + "鍙兘鏄暣鏁�"; return callback(new Error(ruleObj.message)); } } else { if (!rule.decimal.test(value)) { - ruleObj.message = ruleObj.title + '鍙兘鏄暟瀛�'; + ruleObj.message = ruleObj.title + "鍙兘鏄暟瀛�"; return callback(new Error(ruleObj.message)); } } if ( ruleObj.min !== undefined && - typeof ruleObj.min === 'number' && + typeof ruleObj.min === "number" && value < ruleObj.min ) { - ruleObj.message = ruleObj.title + '涓嶈兘灏忎簬' + ruleObj.min; + ruleObj.message = ruleObj.title + "涓嶈兘灏忎簬" + ruleObj.min; return callback(new Error(ruleObj.message)); } if ( ruleObj.max !== undefined && - typeof ruleObj.max === 'number' && + typeof ruleObj.max === "number" && value > ruleObj.max ) { - ruleObj.message = ruleObj.title + '涓嶈兘澶т簬' + ruleObj.max; + ruleObj.message = ruleObj.title + "涓嶈兘澶т簬" + ruleObj.max; return callback(new Error(ruleObj.message)); } return callback(); - } + }, }; } // 鎵嬫満銆佸瘑鐮侀獙璇� - if (item.type == 'password' || item.type == 'phone') { + if (item.type == "password" || item.type == "phone") { return { validator: - item.type == 'phone' ? this.validatorPhone : this.validatorPwd, + item.type == "phone" ? this.validatorPhone : this.validatorPwd, required: item.required, - trigger: 'blur' + trigger: "blur", }; } - if (!item.required && item.type != 'mail') return { required: false }; + if (!item.required && item.type != "mail") return { required: false }; - if (!item.hasOwnProperty('type')) item.type = 'text'; + if (!item.hasOwnProperty("type")) item.type = "text"; if (inputTypeArr.indexOf(item.type) != -1) { let message = item.title + - (item.type == 'mail' ? '蹇呴』鏄竴涓偖绠卞湴鍧�' : '涓嶈兘涓虹┖'); - let type = item.type == 'mail' ? 'email' : types[item.columnType]; + (item.type == "mail" ? "蹇呴』鏄竴涓偖绠卞湴鍧�" : "涓嶈兘涓虹┖"); + let type = item.type == "mail" ? "email" : types[item.columnType]; let _rule = { required: true, message: message, - trigger: 'blur', + trigger: "blur", type: type, validator: (ruleObj, value, callback) => { if ( !this.isReadonly(item) && - (value === '' || value === undefined || value === null) + (value === "" || value === undefined || value === null) ) { return callback(new Error(ruleObj.message)); } return callback(); - } + }, }; - if (item.type == 'mail') { + if (item.type == "mail") { _rule.validator = undefined; return _rule; } if (item.min) { _rule.min = item.min; - _rule.message = item.title + '鑷冲皯' + item.min + '涓瓧绗�!'; + _rule.message = item.title + "鑷冲皯" + item.min + "涓瓧绗�!"; } if (item.max) { return [ @@ -1231,94 +1235,94 @@ { max: item.max, required: true, - message: item.title + '鏈�澶�' + item.max + '涓瓧绗�!', - trigger: 'blur' - } + message: item.title + "鏈�澶�" + item.max + "涓瓧绗�!", + trigger: "blur", + }, ]; } return _rule; } - if (item.type == 'radio') { + if (item.type == "radio") { return { required: item.required, - message: '璇烽�夋嫨' + item.title, - trigger: 'change', - type: 'string' + message: "璇烽�夋嫨" + item.title, + trigger: "change", + type: "string", }; } if ( - item.type == 'date' || - item.type == 'datetime' || - item.type == 'month' || - item.type == 'time' + item.type == "date" || + item.type == "datetime" || + item.type == "month" || + item.type == "time" ) { return { required: true, - message: '璇烽�夋嫨' + item.title, - trigger: 'change', - type: item.range ? 'array' : 'string', + message: "璇烽�夋嫨" + item.title, + trigger: "change", + type: item.range ? "array" : "string", validator: (rule, val, callback) => { if (this.isReadonly(item)) return callback(); // 鐢ㄦ埛鑷畾涔夌殑鏂规硶锛屽鏋滆繑鍥炰簡鍊硷紝鐩存帴鏄剧ず杩斿洖鐨勫�硷紝楠岃瘉涓嶉�氳繃 if (!val || (item.range && !val.length)) { - return callback(new Error('璇烽�夋嫨鏃ユ湡')); + return callback(new Error("璇烽�夋嫨鏃ユ湡")); } return callback(); - } + }, }; } - if (item.type == 'cascader') { + if (item.type == "cascader") { return { - type: 'array', + type: "array", required: true, min: item.min || 1, // message: "璇烽�夋嫨" + item.title, - trigger: 'change', + trigger: "change", validator: (rule, val, callback) => { if (this.isReadonly(item)) return callback(); // 鐢ㄦ埛鑷畾涔夌殑鏂规硶锛屽鏋滆繑鍥炰簡鍊硷紝鐩存帴鏄剧ず杩斿洖鐨勫�硷紝楠岃瘉涓嶉�氳繃 let _arr = this.formFields[item.field]; if (!_arr || !_arr.length) { - return callback(new Error('璇烽�夋嫨' + item.title)); + return callback(new Error("璇烽�夋嫨" + item.title)); } return callback(); - } + }, }; } if ( - ['select', 'selectList', 'checkbox', 'cascader', 'treeSelect'].indexOf( + ["select", "selectList", "checkbox", "cascader", "treeSelect"].indexOf( item.type ) != -1 ) { let _rule = { - type: item.type == 'select' ? 'string' : 'array', + type: item.type == "select" ? "string" : "array", required: true, min: item.min || 1, - message: '璇烽�夋嫨' + item.title, - trigger: 'change', + message: "璇烽�夋嫨" + item.title, + trigger: "change", validator: (rule, value, callback) => { if (this.isReadonly(item)) return callback(); //2021.11.27淇澶氶�夋病鏈夋彁绀虹殑闂 - if (value == undefined || value === '') { + if (value == undefined || value === "") { return callback(new Error(rule.message)); } else if ( - (item.type == 'checkbox' || - item.type == 'selectList' || - item.type == 'treeSelect') && + (item.type == "checkbox" || + item.type == "selectList" || + item.type == "treeSelect") && (!(value instanceof Array) || !value.length) ) { return callback(new Error(rule.message)); } return callback(); - } + }, }; if (_rule.max) { _rule.nax = item.max; - _rule.message = '鏈�澶氬彧鑳介�夋嫨' + item.max + '椤�'; + _rule.message = "鏈�澶氬彧鑳介�夋嫨" + item.max + "椤�"; } return _rule; } @@ -1330,7 +1334,7 @@ } return ( date1.valueOf() < - (typeof date2 == 'number' ? date2 : new Date(date2).valueOf()) + (typeof date2 == "number" ? date2 : new Date(date2).valueOf()) ); }, getDateOptions(date, item) { @@ -1338,27 +1342,27 @@ if ((!item.min && !item.max) || !date) { return false; } - if (item.min && item.min.indexOf(' ') == -1) { + if (item.min && item.min.indexOf(" ") == -1) { //涓嶈缃椂鍒嗙锛屽悗闈細鑷姩鍔犱笂 08:00 - item.min = item.min + ' 00:00:000'; + item.min = item.min + " 00:00:000"; } return ( this.compareDate(date, item.min) || !this.compareDate(date, item.max) ); }, getDateFormat(item) { - if (item.type == 'month') { - return 'YYYY-MM'; + if (item.type == "month") { + return "YYYY-MM"; } // if (item.type=='time') { // return 'HH:mm:ss' // } //瑙乭ttps://day.js.org/docs/zh-CN/display/format - return item.type == 'date' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'; + return item.type == "date" ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm:ss"; }, dateRangeChange(val, item) { if (!val) { - this.$emit('update:formFields'); + this.$emit("update:formFields"); return; } item.onChange && item.onChange(val); @@ -1372,10 +1376,10 @@ filterMethod(value, data) { return data.label.includes(value); }, - getNode( label,node, data){ - console.log(label) - } - } + getNode(label, node, data) { + console.log(label); + }, + }, }); </script> <style lang="less" scoped> @@ -1455,8 +1459,8 @@ padding-left: 5px; } .el-form-item ::v-deep(textarea) { - font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', - 'Microsoft YaHei', '寰蒋闆呴粦', Arial, sans-serif !important; + font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", + "Microsoft YaHei", "寰蒋闆呴粦", Arial, sans-serif !important; } .el-form-item ::v-deep(.el-select .el-select__tags > span) { display: flex; -- Gitblit v1.9.3