| | |
| | | v-else-if="item.type == 'cascader'" |
| | | :options="item.data" |
| | | :props="{ |
| | | checkStrictly: item.changeOnSelect || item.checkStrictly |
| | | checkStrictly: item.changeOnSelect || item.checkStrictly, |
| | | }" |
| | | @change="item.onChange" |
| | | > |
| | |
| | | type="textarea" |
| | | :autosize="{ |
| | | minRows: item.minRows || 2, |
| | | maxRows: item.maxRows || 10 |
| | | maxRows: item.maxRows || 10, |
| | | }" |
| | | :placeholder="item.placeholder ? item.placeholder : item.title" |
| | | /> |
| | |
| | | <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, |
| | |
| | | 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() { |
| | |
| | | }, 100); |
| | | } |
| | | return ruleResult; |
| | | } |
| | | }, |
| | | }, |
| | | setup(props, context) { |
| | | const { appContext, proxy } = getCurrentInstance(); |
| | |
| | | }); |
| | | } |
| | | row.forEach((item, yIndex) => { |
| | | if (item.type == 'number') { |
| | | if (item.type == "number") { |
| | | numberFields.push(item.field); |
| | | } |
| | | // ç®ååªæ¯æselectåéè¿ç¨æç´¢ï¼remoteè¿ç¨ä»åå°åå
¸æ°æ®æºè¿è¡æç´¢ï¼url仿å®çurlæç´¢ |
| | |
| | | // åå§åæ°æ®æºç©ºå¯¹è±¡ |
| | | 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); |
| | | } |
| | |
| | | |
| | | 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) => { |
| | |
| | | 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) => { |
| | |
| | | // å¦æææ°æ®çå䏿¥è¯¢ |
| | | 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( |
| | | let cascaderArr = |
| | | appContext.config.globalProperties.base.convertTree( |
| | | _data, |
| | | (node, data, isRoot) => { |
| | | if (!node.inited) { |
| | |
| | | } |
| | | }); |
| | | }); |
| | | } 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); |
| | |
| | | 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) { |
| | |
| | | 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) { |
| | |
| | | rangeFields, |
| | | numberFields, |
| | | validate, |
| | | volform |
| | | volform, |
| | | // initFormRules, |
| | | // initSource |
| | | }; |
| | |
| | | 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; |
| | | } |
| | | }); |
| | |
| | | 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: [], |
| | | }; |
| | |
| | | }, |
| | | 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; |
| | |
| | | // æ¯å¦ä¸ºå¾çæä»¶çæ ¼å¼å¹¶å¯¹å段çè½¬æ¢ææ°ç»ï¼[{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; |
| | |
| | | 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, |
| | | }); |
| | | } |
| | | } |
| | |
| | | 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(); |
| | | }, |
| | |
| | | ? 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) => { |
| | |
| | | // console.log(2); |
| | | }, |
| | | onChange(item, value) { |
| | | if (item.onChange && typeof item.onChange === 'function') { |
| | | if (item.onChange && typeof item.onChange === "function") { |
| | | item.onChange(value, item); |
| | | } |
| | | }, |
| | |
| | | // console.log('undefined'); |
| | | } |
| | | this.remoteCall = false; |
| | | if (item.onChange && typeof item.onChange === 'function') { |
| | | if (item.onChange && typeof item.onChange === "function") { |
| | | item.onChange(value, item); |
| | | } |
| | | }, |
| | |
| | | return; |
| | | } |
| | | if ( |
| | | val == '' || |
| | | val == "" || |
| | | (item.data.length == 1 && |
| | | (val == item.data[0].key || val == item.data[0].value)) |
| | | ) { |
| | |
| | | // å¼¹åºæ¡æåå§åè¡¨åæ¶ç»data设置æ°ç»é»è®¤å¼2 |
| | | // 2020.09.26ä¿®å¤è¿ç¨æç´¢èªå®ä¹urlä¸èµ·ä½ç¨çé®é¢ |
| | | 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) => { |
| | |
| | | }); |
| | | }, |
| | | 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); |
| | |
| | | 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ç§»é¤æä»¶ä¸ä¼ é»è®¤å¿
å¡« |
| | |
| | | (!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 [ |
| | |
| | | { |
| | | 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; |
| | | } |
| | |
| | | } |
| | | return ( |
| | | date1.valueOf() < |
| | | (typeof date2 == 'number' ? date2 : new Date(date2).valueOf()) |
| | | (typeof date2 == "number" ? date2 : new Date(date2).valueOf()) |
| | | ); |
| | | }, |
| | | getDateOptions(date, item) { |
| | |
| | | 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' |
| | | // } |
| | | //è§https://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); |
| | |
| | | return data.label.includes(value); |
| | | }, |
| | | getNode( label,node, data){ |
| | | console.log(label) |
| | | } |
| | | } |
| | | console.log(label); |
| | | }, |
| | | }, |
| | | }); |
| | | </script> |
| | | <style lang="less" scoped> |
| | |
| | | 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; |