From e730bc069de463d0e92de13e2038833fddf5dd92 Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Tue, 23 Jun 2026 15:58:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/system/user.js | 13 +++--- src/views/system/user.vue | 93 ++++++++++++++++++++++++++++++--------- 2 files changed, 78 insertions(+), 28 deletions(-) diff --git a/src/api/system/user.js b/src/api/system/user.js index 095d17d..c175593 100644 --- a/src/api/system/user.js +++ b/src/api/system/user.js @@ -8,12 +8,13 @@ export function save(data) { }) } -export function listuser() { +export function listuser(params) { return request({ url: '/api/admin/admin', - method: 'get' + method: 'get', + params }) -} +} export function del(data) { return request({ @@ -21,13 +22,13 @@ export function del(data) { method: 'post', data }) -} - +} + export function setRoles(data) { return request({ url: '/api/admin/admin/set-roles', method: 'post', data }) -} +} diff --git a/src/views/system/user.vue b/src/views/system/user.vue index b850b39..dad423d 100644 --- a/src/views/system/user.vue +++ b/src/views/system/user.vue @@ -7,8 +7,8 @@
- - + +
@@ -52,6 +52,17 @@ + + @@ -79,9 +90,13 @@
- @@ -137,7 +152,11 @@ departmentList: [], originzeList:[], catalogList: [], - checkArr: [], + paginations: { + page: 1, + page_size: 15, + total: 0 + }, defaultProps: { children: 'children', label: 'name' @@ -174,6 +193,15 @@ required: true, message: '请输入密码', trigger: 'blur', + validator: (rule, value, callback) => { + if (!this.form.id && !value) { + callback(new Error('请输入密码')) + } else if (value && value.length < 6) { + callback(new Error('密码不能少于6位')) + } else { + callback() + } + } }], originze_id:[{ required: true, @@ -184,7 +212,7 @@ tableHeight: 0, //查询条件字段 searchFields: { - KeyWord: "" + keyword: "" }, tableData: [] } @@ -207,15 +235,25 @@ this.catalogList = this.base.buildTree(res.data) } }, - getSelectedNodes(data, node) { - console.log("data", data,node) - // this.$refs.tree.setCheckedKeys([]); // 删除所有选中节点 - // this.$refs.tree.setCheckedNodes([data]); // 选中已选中节点 - // this.form.pName = data.name - // this.form.pid = data.id - this.form.catalogs_ids = node.checkedKeys - console.log("this.form.catalogs_ids",this.form.catalogs_ids) - this.$forceUpdate() + getSelectedNodes() { + if (this.$refs.tree) { + this.form.catalogs_ids = this.$refs.tree.getCheckedKeys() + } + }, + setCatalogCheckedKeys(catalogIds = []) { + this.$nextTick(() => { + if (this.$refs.tree) { + this.$refs.tree.setCheckedKeys(catalogIds, false) + } + }) + }, + handleCurrentChange(page) { + this.paginations.page = page + this.load() + }, + search() { + this.paginations.page = 1 + this.load() }, initLoad() { var that = this; @@ -236,8 +274,13 @@ }, load() { var that = this; - listuser().then(response => { + listuser({ + page: this.paginations.page, + page_size: this.paginations.page_size, + keyword: this.searchFields.keyword + }).then(response => { var data = response.data; + this.paginations.total = response.total; var _rolelist = []; for (var m of data) { _rolelist = that.roleList; @@ -253,8 +296,6 @@ mod.checked = false; } } - console.log(_u_rolelist) - //break; m.rolelist = _u_rolelist; } that.tableData = data; @@ -321,19 +362,26 @@ var result = Object.assign(this.form, obj); this.userNameStatus = false; this.form = result; + this.form.catalogs_ids = Array.isArray(obj.catalogs_ids) ? obj.catalogs_ids : [] + this.form.password = '' } else { this.userNameStatus = true; + this.form.catalogs_ids = [] } this.dialogFormVisible = true; + this.setCatalogCheckedKeys(this.form.catalogs_ids) }, submitForm(formName) { var that = this; - if(that.form.password.length<6){ + if (that.form.password && that.form.password.length < 6) { + this.$Message.warning('密码不能少于6位') + return + } + if (!that.form.id && (!that.form.password || that.form.password.length < 6)) { this.$Message.warning('密码不能少于6位') return } - console.log("that.form.catalogs_ids",that.form.catalogs_ids) - // return + this.getSelectedNodes() this.$refs[formName].validate((valid) => { if (valid) { save({ @@ -357,6 +405,7 @@ resetForm(formName) { var that = this; this.$refs[formName].resetFields(); + this.form.catalogs_ids = [] that.dialogFormVisible = false; }, setrole(obj) {