30843
This commit is contained in:
		| @@ -104,9 +104,9 @@ | ||||
|       <ai-dialog title="选择网格" :visible.sync="showGrid" :customFooter="true" :destroyOnClose="true" border width="720px" append-to-body> | ||||
|         <div class="grid"> | ||||
|           <el-tree :data="treeObj.treeList" :props="treeObj.defaultProps" node-key="id" ref="tree"  | ||||
|            :check-strictly="true" show-checkbox lazy :load="loadNode" :default-checked-keys="currCheckedKeys" @check="onCheckChange"> | ||||
|             show-checkbox lazy :load="loadNode" :default-checked-keys="currCheckedKeys" @check="onCheckChange"> | ||||
|           </el-tree> | ||||
|           <!-- :default-expand-all="true" --> | ||||
|           <!-- :default-expand-all="true" :check-strictly="true" :check-strictly="true" --> | ||||
|         </div> | ||||
|         <div class="dialog-footer" slot="footer"> | ||||
|           <el-button size="medium" @click="showGrid = false">取消</el-button> | ||||
| @@ -127,6 +127,21 @@ export default { | ||||
|     permissions: Function, | ||||
|   }, | ||||
|   data() { | ||||
|     var validcode = (rule, value, callback) => { | ||||
|       if(value) { | ||||
|         if (value != 0) { | ||||
|           if(!/^([+-]?([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/.test(value)) { | ||||
|             callback(new Error('请输入积分分值,可输入正数、负数、最多保留两位小数')) | ||||
|           }else{ | ||||
|             callback(); | ||||
|           } | ||||
|         } else { | ||||
|           callback(new Error('请输入有效的积分分值')); | ||||
|         } | ||||
|       } else { | ||||
|         callback(new Error('请输入积分分值')); | ||||
|       } | ||||
|     } | ||||
|     return { | ||||
|       search: { | ||||
|         status: "", | ||||
| @@ -195,13 +210,7 @@ export default { | ||||
|         scoringCycle: [ | ||||
|           { required: true, message: "请选择周期范围", trigger: "change" }, | ||||
|         ], | ||||
|         integral: [ | ||||
|           { | ||||
|             required: true, | ||||
|             pattern: /(^[1-9]{1}[0-9]*$)|(^[0-9]*\.[0-9]{2}$)/, | ||||
|             message: "请输入积分分值,最多保留两位小数", | ||||
|           }, | ||||
|         ], | ||||
|         integral: [{required: true, validator: validcode,trigger: "blur"},], | ||||
|         validRangeType: [ | ||||
|           { required: true, message: "请选择有效范围", trigger: "change" }, | ||||
|         ], | ||||
| @@ -219,7 +228,7 @@ export default { | ||||
|         defaultProps: { | ||||
|           label: "girdName", | ||||
|           value: "id", | ||||
|           children: 'children', // 节点是否拥有子节点 | ||||
|           children: 'children', | ||||
|           isLeaf: 'leaf' | ||||
|         }, | ||||
|         checkedKeys: [], | ||||
| @@ -227,6 +236,7 @@ export default { | ||||
|       girdInfoList: [], | ||||
|       currCheckedKeys: [], | ||||
|       rulueType: "0", | ||||
|       // tree12: [] | ||||
|     }; | ||||
|   }, | ||||
|   created() { | ||||
| @@ -235,7 +245,7 @@ export default { | ||||
|         this.getList(); | ||||
|         this.getRulesList(); | ||||
|         this.beforeSelectTree(); | ||||
|         this.getList12() | ||||
|         // this.getList12() | ||||
|       }); | ||||
|   }, | ||||
|   methods: { | ||||
| @@ -265,6 +275,9 @@ export default { | ||||
|         validRangeType: "0", | ||||
|         validRangeData: "", | ||||
|       }; | ||||
|       if(!this.isEdit) { | ||||
|          this.girdInfoList = [] | ||||
|       } | ||||
|     }, | ||||
|     toEdit(row) { | ||||
|       this.form = {...row} | ||||
| @@ -428,10 +441,13 @@ export default { | ||||
|       this.treeObj.checkedKeys = []; | ||||
|       this.instance.post(`/app/appgirdinfo/listAll3`, null, null).then((res) => { | ||||
|           if (res.code == 0) { | ||||
|             this.treeObj.treeList = this.girdToTree(res.data); | ||||
|             let tree = this.girdToTree(res.data); | ||||
|             this.treeObj.treeList = this.addKey(tree) | ||||
|  | ||||
|             this.girdInfoList.map((e) => { | ||||
|               this.treeObj.checkedKeys.push(e.id); | ||||
|             }); | ||||
|              | ||||
|             this.$nextTick(() => { | ||||
|               this.currCheckedKeys = this.girdInfoList; | ||||
|               this.$nextTick(() => { | ||||
| @@ -441,30 +457,33 @@ export default { | ||||
|           } | ||||
|         }); | ||||
|     }, | ||||
|  | ||||
|     // 最后一级追加属性 | ||||
|     addKey(arr) { | ||||
|       for (let index = 0; index < arr.length; index++) { | ||||
|         const item = arr[index] | ||||
|         if (!item.children || !item.children.length) { | ||||
|           item.leaf = true | ||||
|         } else { | ||||
|           this.addKey(item.children) | ||||
|         } | ||||
|       } | ||||
|       return arr | ||||
|     }, | ||||
|  | ||||
|     // el-tree懒加载 | ||||
|     loadNode(node, resolve) { | ||||
|       if (node.level === 0) { | ||||
|         this.instance.post('/app/appgirdinfo/listBy12').then((res) => { | ||||
|           if(res?.data) { | ||||
|             console.log(this.girdToTree(res.data)) | ||||
|           } | ||||
|         return resolve(this.treeObj.treeList); | ||||
|       } | ||||
|       if (node.level >= 1 || node.data.children && node.data.children.length) { | ||||
|         return resolve(node.data.children) | ||||
|       } else { | ||||
|         return resolve({ | ||||
|           name: 'girdName', | ||||
|           isLeaf: true | ||||
|         }) | ||||
|         let arr = node.childNodes; | ||||
|         return resolve(arr); | ||||
|       } | ||||
|       if (node.level >= 1) { | ||||
|         let arr1 = node.data.children | ||||
|         return resolve(arr1); | ||||
|       } | ||||
|     }, | ||||
|  | ||||
|     // 加载一二级数据 | ||||
|     getList12() { | ||||
|       this.instance.post('/app/appgirdinfo/listBy12').then((res) => { | ||||
|         if(res?.data) { | ||||
|           console.log(this.girdToTree(res.data)) | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|  | ||||
|     onCheckChange(e) { | ||||
|   | ||||
| @@ -103,7 +103,7 @@ | ||||
|         </template> | ||||
|       </ai-detail> | ||||
|       <span slot="footer" class="dialog-footer" center> | ||||
|         <el-button @click="dialog = false">关闭</el-button> | ||||
|         <el-button @click="dialog = false" style="width: 92px">关闭</el-button> | ||||
|       </span> | ||||
|     </el-dialog> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user