-
@@ -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) {