From 33889c6b19467e2f8dae9990359704adc6e3419d Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期日, 07 七月 2024 22:13:49 +0800 Subject: [PATCH] 部门管理树状 --- src/api/department.js | 3 + vue.config.js | 4 +- src/views/education/department/edit.vue | 20 ++++++++++ src/views/education/department/list.vue | 36 +++++++++++------ src/App.vue | 2 5 files changed, 48 insertions(+), 17 deletions(-) diff --git a/src/App.vue b/src/App.vue index 6425799..588a76a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -38,7 +38,7 @@ await departmentApi.pageList(this.queryParam).then(res => { console.log(res) if (res.code == 1) { - that.depart = res.response.list + that.depart = res.response console.log(that.depart) this.depart.map(item=>{ item.key = item.id diff --git a/src/api/department.js b/src/api/department.js index 6962299..6f52034 100644 --- a/src/api/department.js +++ b/src/api/department.js @@ -16,5 +16,6 @@ // 鑾峰彇褰撳墠鐢ㄦ埛绠$悊鐨勯儴闂� getDeptAdmins: id => get('/api/admin/department/getDeptAdmins'), // 淇敼閮ㄩ棬绠$悊鍛� - updateDeptAdmin: data => post('/api/admin/department/update-admin', data) + updateDeptAdmin: data => post('/api/admin/department/update-admin', data), + cascaderList: () => get('/api/admin/department/cascader') } diff --git a/src/views/education/department/edit.vue b/src/views/education/department/edit.vue index ef688f1..91efc79 100644 --- a/src/views/education/department/edit.vue +++ b/src/views/education/department/edit.vue @@ -5,6 +5,14 @@ <el-form-item label="閮ㄩ棬锛�" required> <el-input v-model="form.name"></el-input> </el-form-item> + <el-form-item label="涓婄骇閮ㄩ棬锛�"> + <el-cascader + clearable + v-model="form.parentId" + :options="cascaderList" + :props="{ checkStrictly: true }" + ></el-cascader> + </el-form-item> <!-- <el-form-item label="閮ㄩ棬锛�" required>--> <!-- <el-select v-model="form.level" placeholder="閮ㄩ棬">--> <!-- <el-option v-for="item in levelEnum" :key="item.key" :value="item.key" :label="item.value"></el-option>--> @@ -34,12 +42,15 @@ export default { data () { return { + // 閮ㄩ棬绾ц仈涓嬫媺 + cascaderList: [], // 閮ㄩ棬浜哄憳 deptUserList: [], depart: [], form: { id: null, name: '', + parentId: null, adminId: null // level: 1, // levelName: '' @@ -66,7 +77,15 @@ _this.fig = 0 // 鏄紪杈� } }, + mounted() { + this.getCascaderList() + }, methods: { + getCascaderList() { + departmentApi.cascaderList().then(res => { + this.cascaderList = res.response + }) + }, getUserSelect (id) { departmentApi.getDeptUserList(id).then(res => { this.deptUserList = res.response @@ -79,6 +98,7 @@ // let obj = { // name: this.form.name // } + _this.form.parentId = _this.form.parentId[0] if (_this.fig === 1) { departmentApi.addData(this.form.name).then(res => { console.log(res) diff --git a/src/views/education/department/list.vue b/src/views/education/department/list.vue index 9c2dc67..1e2e0fe 100644 --- a/src/views/education/department/list.vue +++ b/src/views/education/department/list.vue @@ -15,7 +15,14 @@ </el-form-item> </el-form> - <el-table v-loading="listLoading" :data="tableData" stripe border fit highlight-current-row style="width: 100%"> + <el-table + v-loading="listLoading" + :data="tableData" border fit + style="width: 100%" + :tree-props="{children: 'children', hasChildren: 'hasChildren'}" + :row-class-name="tableRowClassName" + row-key="id" + > <el-table-column prop="name" label="閮ㄩ棬"/> <el-table-column prop="adminNames" label="閮ㄩ棬璐熻矗浜�"/> <!-- <el-table-column prop="levelName" label="閮ㄩ棬" />--> @@ -29,8 +36,6 @@ </template> </el-table-column> </el-table> - <pagination v-show="total>0" :total="total" :page.sync="queryParam.pageIndex" :limit.sync="queryParam.pageSize" - @pagination="search"/> <el-dialog :title="title" @@ -74,8 +79,6 @@ depart: [], queryParam: { level: null, - pageIndex: 1, - pageSize: 10 }, listLoading: true, tableData: [], @@ -86,6 +89,12 @@ this.search() }, methods: { + tableRowClassName({row, rowIndex}) { + if (row.children && row.children.length > 0) { + return 'success-row'; + } + return ''; + }, changSelect( value ) { this.updateAdminForm.adminId = value }, @@ -123,19 +132,16 @@ search () { this.listLoading = true departmentApi.pageList(this.queryParam).then(data => { - const re = data.response - this.tableData = re.list - this.tableData.map(item => { + this.tableData = data.response + this.tableData.forEach(item => { if (item.adminNames) { item.adminNames = item.adminNames.join("銆�") } }) - this.total = re.total - this.queryParam.pageIndex = re.pageNum this.listLoading = false - this.depart = data.response.list - this.depart.map(item => { + this.depart = data.response + this.depart.forEach(item => { item.key = item.id item.value = item.name }) @@ -143,7 +149,6 @@ }) }, submitForm () { - this.queryParam.pageIndex = 1 this.search() }, delSubject (row) { @@ -172,3 +177,8 @@ } } </script> +<style scoped> +.el-table .success-row { + background: oldlace; +} +</style> diff --git a/vue.config.js b/vue.config.js index 1aa204f..eb70b65 100644 --- a/vue.config.js +++ b/vue.config.js @@ -19,9 +19,9 @@ hotOnly: false, proxy: { '/api': { - target: 'http://192.168.3.87:8085', + // target: 'http://192.168.3.87:8085', // target: 'http://192.168.3.88:8085', - // target: 'http://localhost:8085', + target: 'http://localhost:8085', changeOrigin: true } } -- Gitblit v1.8.0