master
lion 2 weeks ago
parent 43bfd1b822
commit e730bc069d

@ -8,10 +8,11 @@ export function save(data) {
}) })
} }
export function listuser() { export function listuser(params) {
return request({ return request({
url: '/api/admin/admin', url: '/api/admin/admin',
method: 'get' method: 'get',
params
}) })
} }

@ -7,8 +7,8 @@
<div slot="content"></div> <div slot="content"></div>
<slot> <slot>
<div> <div>
<Input style="width: 200px; margin-right: 10px" v-model.number="searchFields.Name" placeholder="关键字搜索" /> <Input style="width: 200px; margin-right: 10px" v-model="searchFields.keyword" placeholder="关键字搜索" />
<Button type="primary" @click="load" style="margin-left: 10px">查询</Button> <Button type="primary" @click="search" style="margin-left: 10px">查询</Button>
<Button type="primary" @click="edit()" style="margin-left: 10px">新增用户</Button> <Button type="primary" @click="edit()" style="margin-left: 10px">新增用户</Button>
</div> </div>
</slot> </slot>
@ -52,6 +52,17 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div class="pagination">
<el-pagination
@current-change="handleCurrentChange"
:current-page="paginations.page"
:page-size="paginations.page_size"
background
layout="prev, pager, next"
:total="paginations.total">
</el-pagination>
</div>
</div> </div>
<el-dialog title="用户编辑" :visible.sync="dialogFormVisible" width="30%"> <el-dialog title="用户编辑" :visible.sync="dialogFormVisible" width="30%">
<el-form :model="form" :rules="rules" ref="form" label-position="right" :label-width="formLabelWidth"> <el-form :model="form" :rules="rules" ref="form" label-position="right" :label-width="formLabelWidth">
@ -79,9 +90,13 @@
<el-form-item label="授权目录" prop="catalogs_ids"> <el-form-item label="授权目录" prop="catalogs_ids">
<div style="height:150px;overflow: scroll;"> <div style="height:150px;overflow: scroll;">
<el-tree :default-checked-keys="checkArr" @check="getSelectedNodes" <el-tree
:data="catalogList" node-key="id" ref="tree" highlight-current v-if="dialogFormVisible"
:check-strictly="true" @check="getSelectedNodes"
:data="catalogList"
node-key="id"
ref="tree"
highlight-current
:show-checkbox="true" :show-checkbox="true"
:props="defaultProps"> :props="defaultProps">
</el-tree> </el-tree>
@ -137,7 +152,11 @@
departmentList: [], departmentList: [],
originzeList:[], originzeList:[],
catalogList: [], catalogList: [],
checkArr: [], paginations: {
page: 1,
page_size: 15,
total: 0
},
defaultProps: { defaultProps: {
children: 'children', children: 'children',
label: 'name' label: 'name'
@ -174,6 +193,15 @@
required: true, required: true,
message: '请输入密码', message: '请输入密码',
trigger: 'blur', 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:[{ originze_id:[{
required: true, required: true,
@ -184,7 +212,7 @@
tableHeight: 0, tableHeight: 0,
// //
searchFields: { searchFields: {
KeyWord: "" keyword: ""
}, },
tableData: [] tableData: []
} }
@ -207,15 +235,25 @@
this.catalogList = this.base.buildTree(res.data) this.catalogList = this.base.buildTree(res.data)
} }
}, },
getSelectedNodes(data, node) { getSelectedNodes() {
console.log("data", data,node) if (this.$refs.tree) {
// this.$refs.tree.setCheckedKeys([]); // this.form.catalogs_ids = this.$refs.tree.getCheckedKeys()
// this.$refs.tree.setCheckedNodes([data]); // }
// this.form.pName = data.name },
// this.form.pid = data.id setCatalogCheckedKeys(catalogIds = []) {
this.form.catalogs_ids = node.checkedKeys this.$nextTick(() => {
console.log("this.form.catalogs_ids",this.form.catalogs_ids) if (this.$refs.tree) {
this.$forceUpdate() this.$refs.tree.setCheckedKeys(catalogIds, false)
}
})
},
handleCurrentChange(page) {
this.paginations.page = page
this.load()
},
search() {
this.paginations.page = 1
this.load()
}, },
initLoad() { initLoad() {
var that = this; var that = this;
@ -236,8 +274,13 @@
}, },
load() { load() {
var that = this; 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; var data = response.data;
this.paginations.total = response.total;
var _rolelist = []; var _rolelist = [];
for (var m of data) { for (var m of data) {
_rolelist = that.roleList; _rolelist = that.roleList;
@ -253,8 +296,6 @@
mod.checked = false; mod.checked = false;
} }
} }
console.log(_u_rolelist)
//break;
m.rolelist = _u_rolelist; m.rolelist = _u_rolelist;
} }
that.tableData = data; that.tableData = data;
@ -321,19 +362,26 @@
var result = Object.assign(this.form, obj); var result = Object.assign(this.form, obj);
this.userNameStatus = false; this.userNameStatus = false;
this.form = result; this.form = result;
this.form.catalogs_ids = Array.isArray(obj.catalogs_ids) ? obj.catalogs_ids : []
this.form.password = ''
} else { } else {
this.userNameStatus = true; this.userNameStatus = true;
this.form.catalogs_ids = []
} }
this.dialogFormVisible = true; this.dialogFormVisible = true;
this.setCatalogCheckedKeys(this.form.catalogs_ids)
}, },
submitForm(formName) { submitForm(formName) {
var that = this; 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位') this.$Message.warning('密码不能少于6位')
return return
} }
console.log("that.form.catalogs_ids",that.form.catalogs_ids) this.getSelectedNodes()
// return
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
save({ save({
@ -357,6 +405,7 @@
resetForm(formName) { resetForm(formName) {
var that = this; var that = this;
this.$refs[formName].resetFields(); this.$refs[formName].resetFields();
this.form.catalogs_ids = []
that.dialogFormVisible = false; that.dialogFormVisible = false;
}, },
setrole(obj) { setrole(obj) {

Loading…
Cancel
Save