From f7f0e44c4be8eb0e77fd310296c3b43bde21e4f9 Mon Sep 17 00:00:00 2001 From: ZZJ <10913410+zzj2100@user.noreply.gitee.com> Date: 星期四, 23 六月 2022 14:17:01 +0800 Subject: [PATCH] 新增联动场景 --- src/views/personalCenter/components/SubAccount.vue | 133 +++++++++++++++++++++++++++---------------- 1 files changed, 83 insertions(+), 50 deletions(-) diff --git a/src/views/personalCenter/components/SubAccount.vue b/src/views/personalCenter/components/SubAccount.vue index e71b049..dc001bc 100644 --- a/src/views/personalCenter/components/SubAccount.vue +++ b/src/views/personalCenter/components/SubAccount.vue @@ -29,7 +29,7 @@ </div> <div class="btns"> - <div class="button add" @click="isShowAdd = true"> + <div class="button add" @click="addSubCount"> <span class="iconfont"></span> <span>娣诲姞瀛愯处鍙�</span> </div> @@ -43,11 +43,9 @@ <el-table id="multipleTable" ref="multipleTable" - tooltip-effect="dark" :data="dataList" :fit="true" :default-sort="{ prop: 'createTime', order: 'descending' }" - :stripe="true" > <el-table-column label="搴忓彿" width="55" class-name="index"> <template slot-scope="scope">{{ @@ -69,8 +67,15 @@ <span>{{ scope.row.userType == 1 ? "涓汉" : "鍏徃" }}</span> </template> </el-table-column> + <el-table-column prop="authDuration" label="鎺堟潈鏃堕暱"> + <template slot-scope="scope"> + <span>{{ scope.row.authDuration + " 骞�" }} </span> + </template> </el-table-column> + + <!-- <el-table-column prop="authDuration" label="鎺堟潈鏃堕暱"> + </el-table-column> --> <el-table-column prop="dataNames" label="鏉冮檺"> </el-table-column> <el-table-column label="鐘舵��"> @@ -121,7 +126,7 @@ <el-form-item label="瀵嗙爜" prop="password"> <el-input v-model="ruleForm.password" style="width: 350px"></el-input> </el-form-item> - <el-form-item label="閲嶇疆瀵嗙爜" prop="isChangePwd"> + <el-form-item label="閲嶇疆瀵嗙爜"> <el-checkbox v-model="ruleForm.isChangePwd" >棣栨鐧婚檰淇敼瀵嗙爜</el-checkbox > @@ -133,11 +138,11 @@ <el-form-item label="濮撳悕" prop="trueName"> <el-input v-model="ruleForm.trueName" style="width: 350px"></el-input> </el-form-item> - <el-form-item label="閭" prop="email"> + <el-form-item label="閭"> <el-input v-model="ruleForm.email" style="width: 350px"></el-input> </el-form-item> - <el-form-item label="琛屼笟" prop="industryId"> + <el-form-item label="琛屼笟"> <el-select v-model="ruleForm.industryId" placeholder="璇烽�夋嫨琛屼笟" @@ -151,15 +156,14 @@ ></el-option> </el-select> </el-form-item> - <el-form-item label="鍦板尯" prop="address"> + <el-form-item label="鍦板尯"> <el-cascader v-model="ruleForm.address" :props="options" style="width: 350px" - @change="handleChange" ></el-cascader> </el-form-item> - <el-form-item label="鎺堟潈鏃堕暱" prop="authDuration"> + <el-form-item label="鎺堟潈鏃堕暱"> <el-select v-model="ruleForm.authDuration" style="width: 350px" @@ -172,8 +176,6 @@ </el-form-item> <el-form-item label="鐢ㄦ埛鏉冮檺" prop="menuIds" class="user-tree"> - <!-- <TreeBox :defaultProp="defaultProp" :treeData="sysMenus"></TreeBox> --> - <!-- <TreeBox :defaultProp="defaultProp2" :treeData="data2"></TreeBox> --> <div class="tree-box"> <div class="t">鑿滃崟鏉冮檺</div> <el-tree @@ -234,6 +236,18 @@ StepsCard, }, data() { + const validateTree = (rule, value, callback) => { + if ( + this.ruleForm.menuIds && + this.ruleForm.dataIds && + this.ruleForm.menuIds.length > 0 && + this.ruleForm.dataIds.length > 0 + ) { + callback(); + } else { + callback(new Error("璇烽�夎彍鍗曟潈闄愬拰鏁版嵁鏉冮檺")); + } + }; return { searchTime: [ this.$moment().format("YYYY-MM-DD 00:00:00"), @@ -311,17 +325,15 @@ dataIds: [], }, rules: { - name: [ - { required: true, message: "璇疯緭鍏ユ椿鍔ㄥ悕绉�", trigger: "blur" }, - { min: 3, max: 5, message: "闀垮害鍦� 3 鍒� 5 涓瓧绗�", trigger: "blur" }, + username: [ + { required: true, message: "璇疯緭鍏ョ敤鎴峰悕", trigger: "blur" }, ], - region: [ - { required: true, message: "璇烽�夋嫨娲诲姩鍖哄煙", trigger: "change" }, + password: [{ required: true, message: "璇疯緭鍏ュ瘑鐮�", trigger: "blur" }], + userType: [ + { required: true, message: "璇烽�夋嫨鐢ㄦ埛绫诲瀷", trigger: "blur" }, ], - resource: [ - { required: true, message: "璇烽�夋嫨娲诲姩璧勬簮", trigger: "change" }, - ], - desc: [{ required: true, message: "璇峰~鍐欐椿鍔ㄥ舰寮�", trigger: "blur" }], + trueName: [{ required: true, message: "璇疯緭鍏ュ鍚�", trigger: "blur" }], + menuIds: [{ validator: validateTree, trigger: "blur" }], }, sysMenus: [], DataTree: [], @@ -354,6 +366,10 @@ } }); }, + addSubCount() { + this.isShowAdd = true; + this.resetUser(); + }, editUser(row) { this.isShowAdd = true; this.isEditing = true; @@ -381,13 +397,16 @@ trueName: "", email: "", isChangePwd: false, + address: [], industryId: "", areaId: "", provinceId: "", authDuration: "", }; - this.$refs.treeMenus.setCheckedKeys([]); - this.$refs.treeData.setCheckedKeys([]); + this.$nextTick(() => { + this.$refs.treeMenus.setCheckedKeys([]); + this.$refs.treeData.setCheckedKeys([]); + }); }, async getIndustrys() { let res = await getDic(); @@ -400,34 +419,41 @@ saveSubUser() { this.ruleForm.menuIds = this.$refs.treeMenus.getCheckedKeys(); this.ruleForm.dataIds = this.$refs.treeData.getCheckedKeys(); - let json = { - id: this.isEditing ? this.ruleForm.id : "", - username: this.ruleForm.username, - password: this.ruleForm.password, - isChangePwd: this.ruleForm.isChangePwd, - userType: this.ruleForm.userType, - trueName: this.ruleForm.trueName, - email: this.ruleForm.email, - industryId: this.ruleForm.industryId, - areaId: this.ruleForm.address[1], - authDuration: this.ruleForm.authDuration, - menuIds: this.ruleForm.menuIds, - dataIds: this.ruleForm.dataIds, - }; - saveSubUser(json) - .then((res) => { - if (res.success) { - this.$notify.success(res.data) - this.isShowAdd = false; - this.isEditing = false; - this.findUserList(); - } else { - this.$notify.error(res.msg); - } - }) - .catch((err) => { - this.$notify.error(err.message); - }); + this.$refs["ruleForm"].validate((valid) => { + if (valid) { + let json = { + id: this.isEditing ? this.ruleForm.id : "", + username: this.ruleForm.username, + password: this.ruleForm.password, + isChangePwd: this.ruleForm.isChangePwd, + userType: this.ruleForm.userType, + trueName: this.ruleForm.trueName, + email: this.ruleForm.email, + industryId: this.ruleForm.industryId, + areaId: + this.ruleForm.address.length == 2 ? this.ruleForm.address[1] : "", + authDuration: this.ruleForm.authDuration, + menuIds: this.ruleForm.menuIds, + dataIds: this.ruleForm.dataIds, + }; + saveSubUser(json) + .then((res) => { + if (res.success) { + this.$notify.success(res.data); + this.isShowAdd = false; + this.isEditing = false; + this.findUserList(); + } else { + this.$notify.error(res.msg); + } + }) + .catch((err) => { + this.$notify.error(err.data.msg); + }); + } else { + return false; + } + }); }, findUserList() { findUserList({ @@ -491,10 +517,12 @@ //鍒嗛〉鍔熻兘 handleSizeChange(size) { this.size = size; + this.findUserList(); }, //鍒嗛〉鍔熻兘 refrash(page) { this.page = page; + this.findUserList(); }, //瑙g粦鎸夐挳 @@ -586,6 +614,11 @@ border-color: #c0c5cc; } .user-tree { + .el-form-item__label:before { + content: "*"; + color: #f52323; + margin-right: 4px; + } .el-form-item__content { display: flex; .tree-box { -- Gitblit v1.8.0