diff --git a/src/page/accounts/unitAdminDialog/add.vue b/src/page/accounts/unitAdminDialog/add.vue index f05029069fcfc0f47225c9b5c6e789e69339cc9b..0d794a7083a3c74c3f1dcd6d84c37e62e6d24c1d 100644 --- a/src/page/accounts/unitAdminDialog/add.vue +++ b/src/page/accounts/unitAdminDialog/add.vue @@ -118,7 +118,7 @@ export default { phone: "", weChat: "", email: "", - type: 2, //1.ç”¨æˆ·è´¦å· 2.å¹³å°å•ä½ç®¡ç†å‘˜è´¦å· 3.æœºé¡¶ç›’è´¦å· 4.è¿ç»´è´¦å· + type: 2, //1.ç”¨æˆ·è´¦å· 2.å¹³å°å•ä½ç®¡ç†å‘˜è´¦å· 3.æœºé¡¶ç›’è´¦å· 4.è¿ç»´è´¦å· }, rules: { userName: [ @@ -176,19 +176,14 @@ export default { this.$message.error("请选择有效期"); return false; } - if(this.form.telephone){ - user.telephone = this.form.telephone; - } - if (!this.form.email) { - user.email = this.form.email; - } - if (!this.form.weChat) { - user.weChat = this.form.weChat; - } if (!this.form.permanent) { user.effectiveDate = this.form.date[0]; user.exiredDate = this.form.date[1]; - } + } + user.telephone = this.form.telephone || ""; + user.email = this.form.email || ""; + user.weChat = this.form.weChat || ""; + user.phone = this.form.phone; user.permanent = this.form.permanent; user.userName = this.form.userName; user.orgId = this.form.orgId; diff --git a/src/page/accounts/unitAdminDialog/edit.vue b/src/page/accounts/unitAdminDialog/edit.vue index 94a98aa466d09bc2e2095e4d19135ce27349bc2e..99c81f71a378ea2b103538d6ca8d6a9e99bcd39c 100644 --- a/src/page/accounts/unitAdminDialog/edit.vue +++ b/src/page/accounts/unitAdminDialog/edit.vue @@ -6,7 +6,7 @@ width="720px" :before-close="handleClose" > - <div class="dialog-content"> + <div class="dialog-content"> <el-form ref="form" :model="form" @@ -92,7 +92,7 @@ import { getOrgListWithOutPage } from "@/config/organ"; export default { data() { - var validateMobilePhone = (rule, value, callback) => { + var validateMobilePhone = (rule, value, callback) => { if (value === "") { callback(new Error("手机å·ä¸å¯ä¸ºç©º")); } else { @@ -109,9 +109,9 @@ export default { dialogVisible: false, organList: [], rolesList: [], - id:'', + id: "", form: { - id:'', + id: "", userName: "", telephone: "", orgId: "", @@ -120,8 +120,8 @@ export default { phone: "", weChat: "", email: "", - roleList:[], - type: 2, //1.ç”¨æˆ·è´¦å· 2.å¹³å°å•ä½ç®¡ç†å‘˜è´¦å· 3.æœºé¡¶ç›’è´¦å· 4.è¿ç»´è´¦å· + roleList: [], + type: 2, //1.ç”¨æˆ·è´¦å· 2.å¹³å°å•ä½ç®¡ç†å‘˜è´¦å· 3.æœºé¡¶ç›’è´¦å· 4.è¿ç»´è´¦å· }, rules: { userName: [ @@ -133,9 +133,14 @@ export default { permanent: [ { required: true, message: "è¯·é€‰æ‹©è´¦å·æœ‰æ•ˆæœŸ", trigger: "change" }, ], - roleList: [ - { type: 'array',required: true, message: "请选择账å·ç±»åž‹", trigger: "change" }, - ] + roleList: [ + { + type: "array", + required: true, + message: "请选择账å·ç±»åž‹", + trigger: "change", + }, + ], }, }; }, @@ -150,81 +155,82 @@ export default { }); }, // æ ¹æ®id获å–获å–详情内容 - getDetailById(){ - let _this = this - this.$https( - { - method: "get", - url: "tUser/getById", - authType: this.backToken, - }, - {id:_this.id} - ) - .then((res) => { - if(res.status == 200 ){ - if (res.data.resultCode == 200 ) { - let resData = res.data.data - for(let key in _this.form){ - this.form[key] = resData[key] - } - if(!this.form.permanent){ - this.form.date = [ - resData.effectiveDate, - resData.exiredDate - ] - } - } else { - _this.$message.error(res.data.message); - } - } else { - _this.$message.error(res.data); - } - }) - .catch((err) => { - console.log(err); - }); + getDetailById() { + let _this = this; + this.$https( + { + method: "get", + url: "tUser/getById", + authType: this.backToken, + }, + { id: _this.id } + ) + .then((res) => { + if (res.status == 200) { + if (res.data.resultCode == 200) { + let resData = res.data.data; + for (let key in _this.form) { + this.form[key] = resData[key]; + } + if (!this.form.permanent) { + this.form.date = [resData.effectiveDate, resData.exiredDate]; + } + } else { + _this.$message.error(res.data.message); + } + } else { + _this.$message.error(res.data); + } + }) + .catch((err) => { + console.log(err); + }); }, // å¼¹çª—å…³é— handleClose() { this.$confirm("确认关é—?") .then((_) => { - this.handleReset() + this.handleReset(); }) .catch((_) => {}); }, - handleReset(){ - this.dialogVisible = false - this.$refs.form.resetFields() - this.form = { - userName: "", - orgId: "", - permanent: true, - date: "", - roleList: [], - type: 2 - } + handleReset() { + this.dialogVisible = false; + this.$refs.form.resetFields(); + this.form = { + userName: "", + orgId: "", + permanent: true, + date: "", + roleList: [], + type: 2, + }; }, // æäº¤ - handleSubmit() { + handleSubmit() { // æ ¡éªŒç”¨æˆ·è¾“å…¥å€¼ - let _this = this + let _this = this; _this.$refs.form.validate((valid) => { if (valid) { - let user = {}; - if(!_this.form.permanent && !_this.form.date){ - _this.$message.error('请选择有效期') - return false - } - if(!_this.form.permanent){ - user.effectiveDate = _this.form.date[0]; - user.exiredDate = _this.form.date[1]; + let user = {}; + if (!_this.form.permanent && !_this.form.date) { + _this.$message.error("请选择有效期"); + return false; + } + if (!_this.form.permanent) { + user.effectiveDate = _this.form.date[0]; + user.exiredDate = _this.form.date[1]; } - user.userName = _this.form.userName; - user.orgId = _this.form.orgId; - user.roleList = _this.form.roleList - user.permanent = _this.form.permanent; - user.id = _this.id - user.type = this.form.type + user.id = _this.id; + user.telephone = this.form.telephone || ""; + user.email = this.form.email || ""; + user.weChat = this.form.weChat || ""; + user.phone = this.form.phone; + user.permanent = this.form.permanent; + user.userName = this.form.userName; + user.orgId = this.form.orgId; + user.type = this.form.type; + this.$https( { method: "put", @@ -234,22 +240,22 @@ export default { user ) .then((res) => { - if(res.status == 200 ){ - if (res.data.resultCode == 200 ) { - this.$message({ - type: "success", - message: res.data.message, - }); - _this.dialogVisible = false - this.$emit('success',true) + if (res.status == 200) { + if (res.data.resultCode == 200) { + this.$message({ + type: "success", + message: res.data.message, + }); + _this.dialogVisible = false; + this.$emit("success", true); } else { - this.$message.error(res.data.message); - this.$emit('success',false) - } + this.$message.error(res.data.message); + this.$emit("success", false); + } } else { - this.$message.error(res.data); - this.$emit('success',false) - } + this.$message.error(res.data); + this.$emit("success", false); + } }) .catch((err) => { console.log(err);