xiangpei
2024-07-07 33889c6b19467e2f8dae9990359704adc6e3419d
部门管理树状
5个文件已修改
65 ■■■■ 已修改文件
src/App.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/department.js 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/education/department/edit.vue 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/education/department/list.vue 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
vue.config.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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
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')
}
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)
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>
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
      }
    }