Quellcode durchsuchen

@zengqiao@部门相关

HexOr vor 3 Jahren
Ursprung
Commit
5d880deb46

+ 1 - 1
dmp-edge-ai/public/index.html

@ -25,7 +25,7 @@
25 25
      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
26 26
    </noscript>
27 27
    <div id="appLoading">
28
      <img src="./iot-loading.gif" alt="loading" />
28
      <img src="<%= BASE_URL %>iot-loading.gif" alt="loading" />
29 29
    </div>
30 30
    <div id="app"></div>
31 31
    <!-- built files will be auto injected -->

+ 1 - 1
dmp-edge-ai/src/service/OrganizeService.js

@ -29,7 +29,7 @@ export function getOrganizeInfo(organizeId) {
29 29
 */
30 30
export function add(data) {
31 31
  return request({
32
    url: '/organize/add',
32
    url: '/organize/addOrganize',
33 33
    method: 'post',
34 34
    data
35 35
  })

+ 2 - 2
dmp-edge-ai/src/utils/constant.js

@ -42,8 +42,8 @@ export const IframeFlag = createEnum({
42 42
 * @type {{getDescFromValue, options, getDesc}}
43 43
 */
44 44
export const OrganizeType = createEnum({
45
  COMPANY: [0, '公司'],
46
  DEPARTMENT: [1, '部门']
45
  COMPANY: ['0', '公司'],
46
  DEPARTMENT: ['1', '部门']
47 47
})
48 48
49 49
/**

+ 170 - 0
dmp-edge-ai/src/views/system/organize/components/BaseDialog.vue

@ -0,0 +1,170 @@
1
<template>
2
  <el-dialog :title="title" class="common-modal" :visible.sync="dialogVisible" width="68.75%" @open="initData">
3
    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
4
      <el-row>
5
        <el-col :span="10" :offset="2">
6
          <el-form-item label="部门名称" prop="organizeName">
7
            <el-input v-model.trim="form.organizeName"></el-input>
8
          </el-form-item>
9
        </el-col>
10
        <el-col :span="10">
11
          <el-form-item label="部门编码" prop="organizeCode">
12
            <el-input v-model.trim="form.organizeCode"></el-input>
13
          </el-form-item>
14
        </el-col>
15
      </el-row>
16
      <el-row>
17
        <el-col :span="10" :offset="2">
18
          <el-form-item label="上级部门" prop="parentOrganizeId">
19
            <select-tree
20
              clearable
21
              style="width: 100%"
22
              v-model="form.parentOrganizeId"
23
              :tree-data="organizeList"
24
              :config="selectTreeConfig"
25
              :disabled="modalType === ModalType.EDIT"
26
            ></select-tree>
27
          </el-form-item>
28
        </el-col>
29
        <el-col :span="10">
30
          <el-form-item label="组织类型" prop="organizeType">
31
            <el-select v-model="form.organizeType" style="width: 100%" clearable>
32
              <el-option v-for="item in OrganizeType.options" :key="item[0]" :label="item[1]" :value="item[0]">
33
              </el-option>
34
            </el-select>
35
          </el-form-item>
36
        </el-col>
37
      </el-row>
38
      <el-row>
39
        <el-col :span="20" :offset="2">
40
          <el-form-item label="部门描述" prop="remark">
41
            <el-input type="textarea" v-model.trim="form.remark" :rows="2"></el-input>
42
          </el-form-item>
43
        </el-col>
44
      </el-row>
45
    </el-form>
46
    <span slot="footer" class="dialog-footer">
47
      <el-button v-if="!submitLoading" type="primary" @click="submit(modalType)">提交</el-button>
48
      <el-button v-else type="primary" :loading="submitLoading">提交中</el-button>
49
      <el-button @click="dialogVisible = false">关闭并返回</el-button>
50
    </span>
51
  </el-dialog>
52
</template>
53
54
<script>
55
import * as OrganizeService from '@/service/OrganizeService'
56
import SelectTree from '@/components/SelectTree'
57
import { ModalType, OrganizeType } from '@/utils/constant'
58
export default {
59
  name: 'BaseDialog',
60
  props: {
61
    organizeId: {
62
      type: [Number, String]
63
    },
64
    show: {
65
      type: Boolean,
66
      required: true,
67
      default: false
68
    },
69
    organizeList: {
70
      type: Array,
71
      required: true,
72
      default: () => []
73
    }
74
  },
75
  components: {
76
    SelectTree
77
  },
78
  data() {
79
    this.OrganizeType = OrganizeType
80
    this.ModalType = ModalType
81
    // 组织树形下拉组件映射配置
82
    this.selectTreeConfig = {
83
      id: 'organizeId',
84
      label: 'organizeName',
85
      children: 'children'
86
    }
87
    return {
88
      form: {
89
        organizeName: '',
90
        organizeCode: '',
91
        parentOrganizeId: '',
92
        organizeType: '',
93
        remark: ''
94
      },
95
      rules: {
96
        organizeName: [{ required: true, message: '请输入部门名称', trigger: 'blur' }],
97
        organizeCode: [{ required: true, message: '请输入部门编码', trigger: 'blur' }],
98
        parentOrganizeId: [{ required: true, message: '请选择上级部门', trigger: 'change' }],
99
        organizeType: [{ required: true, message: '请选择组织类型', trigger: 'change' }]
100
      },
101
      modalType: ModalType.ADD,
102
      submitLoading: false
103
    }
104
  },
105
  computed: {
106
    dialogVisible: {
107
      set(val) {
108
        this.$emit('update:show', val)
109
      },
110
      get() {
111
        return this.show
112
      }
113
    },
114
    title() {
115
      return this.modalType === ModalType.ADD ? '新增角色' : '编辑角色'
116
    }
117
  },
118
  methods: {
119
    /**
120
     * 初始化模态框
121
     */
122
    initData() {
123
      this.$refs.form && this.$refs.form.resetFields()
124
      this.form = {
125
        organizeName: '',
126
        organizeCode: '',
127
        parentOrganizeId: '',
128
        organizeType: '',
129
        remark: ''
130
      }
131
      if (this.organizeId) {
132
        // 编辑
133
        this.modalType = ModalType.EDIT
134
        OrganizeService.getOrganizeInfo(this.organizeId).then((res) => {
135
          this.form = { ...res }
136
          Reflect.deleteProperty(this.form, 'createDate')
137
          Reflect.deleteProperty(this.form, 'doneDate')
138
        })
139
      } else {
140
        // 新增
141
        this.modalType = ModalType.ADD
142
      }
143
    },
144
    submit(type) {
145
      this.$refs['form'].validate(async (valid) => {
146
        if (!valid) {
147
          return
148
        }
149
        const params = { ...this.form }
150
        this.submitLoading = true
151
        try {
152
          if (type === ModalType.ADD) {
153
            // 新增
154
            await OrganizeService.add(params)
155
          } else {
156
            // 编辑
157
            await OrganizeService.edit(params)
158
          }
159
          this.dialogVisible = false
160
          this.$emit('refresh')
161
        } finally {
162
          this.submitLoading = false
163
        }
164
      })
165
    }
166
  }
167
}
168
</script>
169
170
<style scoped lang="scss"></style>

+ 34 - 5
dmp-edge-ai/src/views/system/organize/index.vue

@ -32,6 +32,9 @@
32 32
        </el-table-column>
33 33
      </el-table>
34 34
    </div>
35
    <!--新建/编辑部门模态框-->
36
    <base-dialog :show.sync="baseVisible" :organizeId="organizeId" :organizeList="tableData" @refresh="search">
37
    </base-dialog>
35 38
  </div>
36 39
</template>
37 40
@ -42,7 +45,8 @@ import * as OrganizeService from '@/service/OrganizeService'
42 45
export default {
43 46
  name: 'Organize',
44 47
  components: {
45
    PageHeader
48
    PageHeader,
49
    BaseDialog: () => import('./components/BaseDialog')
46 50
  },
47 51
  data() {
48 52
    this.OrganizeType = OrganizeType
@ -55,18 +59,43 @@ export default {
55 59
      searchContent: {
56 60
        keywords: ''
57 61
      },
58
      tableData: []
62
      tableData: [],
63
      organizeId: '',
64
      baseVisible: false
59 65
    }
60 66
  },
61 67
  methods: {
62 68
    addOrganize() {
63
      console.log(111)
69
      this.organizeId = ''
70
      this.baseVisible = true
64 71
    },
65 72
    edit(row) {
66
      console.log(row)
73
      this.organizeId = row.organizeId
74
      this.baseVisible = true
67 75
    },
68 76
    deleteItem(row) {
69
      console.log(row)
77
      this.$confirm(`您确定删除该部门吗?`, '提示', {
78
        confirmButtonText: '确定',
79
        cancelButtonText: '取消',
80
        type: 'warning',
81
        beforeClose: (action, instance, done) => {
82
          if (action === 'confirm') {
83
            instance.confirmButtonLoading = true
84
            instance.confirmButtonText = '删除中...'
85
            OrganizeService.deleteOrganize(row.organizeId)
86
              .then(() => {
87
                this.search()
88
                done()
89
              })
90
              .finally(() => {
91
                instance.confirmButtonText = '确定'
92
                instance.confirmButtonLoading = false
93
              })
94
          } else {
95
            done()
96
          }
97
        }
98
      })
70 99
    },
71 100
    search() {
72 101
      this.getOrganizeList()