|
@@ -11,8 +11,8 @@
|
|
|
</div>
|
|
|
<div class="content">
|
|
|
<byTable
|
|
|
- :source="sourceList.data"
|
|
|
- :hidePagination="true"
|
|
|
+ :hideTable="true"
|
|
|
+ :hidePagination="true"
|
|
|
:config="config"
|
|
|
:loading="loading"
|
|
|
highlight-current-row
|
|
@@ -25,7 +25,7 @@
|
|
|
{
|
|
|
text: '添加机构',
|
|
|
action: () => openModal('add'),
|
|
|
- disabled:!sourceList.pagination.tenantId
|
|
|
+ disabled: !sourceList.pagination.tenantId,
|
|
|
},
|
|
|
]"
|
|
|
@get-list="getList"
|
|
@@ -34,6 +34,69 @@
|
|
|
{{ item.createTime }}
|
|
|
</template>
|
|
|
</byTable>
|
|
|
+ <el-table
|
|
|
+ v-loading="loading"
|
|
|
+ :data="sourceList.data"
|
|
|
+ row-key="deptId"
|
|
|
+ style="padding: 0 20px; box-sizing: border-box"
|
|
|
+ :tree-props="{
|
|
|
+ children: 'children',
|
|
|
+ hasChildren: 'hasChildren',
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <el-table-column
|
|
|
+ prop="deptName"
|
|
|
+ label="机构名称"
|
|
|
+ width="260"
|
|
|
+ ></el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="orderNum"
|
|
|
+ label="排序"
|
|
|
+ width="100"
|
|
|
+ ></el-table-column>
|
|
|
+ <el-table-column prop="type" label="机构类型" width="100">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="创建时间"
|
|
|
+ align="center"
|
|
|
+ prop="createTime"
|
|
|
+ width="200"
|
|
|
+ >
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ parseTime(scope.row.createTime) }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="操作"
|
|
|
+ align="center"
|
|
|
+ class-name="small-padding fixed-width"
|
|
|
+ >
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button
|
|
|
+ link
|
|
|
+ type="primary"
|
|
|
+ @click="getDtl(scope.row)"
|
|
|
+ v-hasPermi="['system:dept:edit']"
|
|
|
+ >修改</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ link
|
|
|
+ type="primary"
|
|
|
+ @click="handleAdd(scope.row)"
|
|
|
+ v-hasPermi="['system:dept:add']"
|
|
|
+ >新增</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ v-if="scope.row.parentId != 0"
|
|
|
+ link
|
|
|
+ type="primary"
|
|
|
+ @click="listDelete(scope.row)"
|
|
|
+ v-hasPermi="['system:dept:remove']"
|
|
|
+ >删除</el-button
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
</div>
|
|
|
<el-dialog
|
|
|
:title="modalType == 'add' ? '新增' : '编辑'"
|
|
@@ -48,11 +111,23 @@
|
|
|
:rules="rules"
|
|
|
ref="byform"
|
|
|
>
|
|
|
- <template #account>
|
|
|
- <el-input style="width:150px;margin-right: 10px;" v-model="formData.data.userName" placeholder="请输入用户名"></el-input>
|
|
|
- <el-input style="width:150px;margin-right: 10px;" v-model="formData.data.password" placeholder="密码"></el-input>
|
|
|
- <span style="color:#409EFF;cursor: pointer;" @click="newPassword">随机生成</span>
|
|
|
- </template>
|
|
|
+ <template #account>
|
|
|
+ <el-input
|
|
|
+ style="width: 150px; margin-right: 10px"
|
|
|
+ v-model="formData.data.userName"
|
|
|
+ placeholder="请输入用户名"
|
|
|
+ ></el-input>
|
|
|
+ <el-input
|
|
|
+ style="width: 150px; margin-right: 10px"
|
|
|
+ v-model="formData.data.password"
|
|
|
+ placeholder="密码"
|
|
|
+ ></el-input>
|
|
|
+ <span
|
|
|
+ style="color: #409eff; cursor: pointer"
|
|
|
+ @click="newPassword"
|
|
|
+ >随机生成</span
|
|
|
+ >
|
|
|
+ </template>
|
|
|
</byForm>
|
|
|
<template #footer>
|
|
|
<el-button @click="dialogVisible = false" size="large"
|
|
@@ -113,8 +188,8 @@ let dialogVisible = ref(false)
|
|
|
let modalType = ref('add')
|
|
|
let rules = ref({
|
|
|
roleKey: [{ required: true, message: '请选择部门', trigger: 'blur' }],
|
|
|
- nickName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
|
|
|
- userName:[{ required: true, message: '用户名不能为空', trigger: 'blur' }],
|
|
|
+ orderNum: [{ required: true, message: '排序不能为空', trigger: 'blur' }],
|
|
|
+ deptName: [{ required: true, message: '机构名称不能为空', trigger: 'blur' }],
|
|
|
})
|
|
|
const { proxy } = getCurrentInstance()
|
|
|
const selectConfig = computed(() => {
|
|
@@ -134,6 +209,16 @@ const config = computed(() => {
|
|
|
prop: 'userName',
|
|
|
align: 'left',
|
|
|
},
|
|
|
+
|
|
|
+ render(type) {
|
|
|
+ return type == '0'
|
|
|
+ ? '公司'
|
|
|
+ : type == '1'
|
|
|
+ ? '业务中心'
|
|
|
+ : type == '2'
|
|
|
+ ? '部门'
|
|
|
+ : '组'
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
@@ -144,7 +229,7 @@ const config = computed(() => {
|
|
|
{
|
|
|
attrs: {
|
|
|
label: '创建时间',
|
|
|
- prop: 'remark',
|
|
|
+ prop: 'createTime',
|
|
|
},
|
|
|
},
|
|
|
{
|
|
@@ -174,35 +259,7 @@ const config = computed(() => {
|
|
|
text: true,
|
|
|
},
|
|
|
el: 'button',
|
|
|
- click() {
|
|
|
- // 弹窗提示是否删除
|
|
|
- ElMessageBox.confirm(
|
|
|
- '此操作将永久删除该数据, 是否继续?',
|
|
|
- '提示',
|
|
|
- {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning',
|
|
|
- }
|
|
|
- ).then(() => {
|
|
|
- // 删除
|
|
|
- proxy
|
|
|
- .post(
|
|
|
- '/tenantUser/' + row.userId,
|
|
|
- {
|
|
|
- id: row.userId,
|
|
|
- },
|
|
|
- 'delete'
|
|
|
- )
|
|
|
- .then((res) => {
|
|
|
- ElMessage({
|
|
|
- message: '删除成功',
|
|
|
- type: 'success',
|
|
|
- })
|
|
|
- getList()
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
+ click() {},
|
|
|
},
|
|
|
]
|
|
|
},
|
|
@@ -238,13 +295,13 @@ const formConfig = computed(() => {
|
|
|
//disabled:true,
|
|
|
itemType: 'text',
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
{
|
|
|
type: 'select',
|
|
|
prop: 'type',
|
|
|
label: '机构类型',
|
|
|
required: true,
|
|
|
-
|
|
|
+
|
|
|
data: [
|
|
|
{
|
|
|
label: '公司',
|
|
@@ -254,11 +311,11 @@ const formConfig = computed(() => {
|
|
|
label: '业务中心',
|
|
|
id: 1,
|
|
|
},
|
|
|
- {
|
|
|
+ {
|
|
|
label: '部门',
|
|
|
id: 2,
|
|
|
},
|
|
|
- {
|
|
|
+ {
|
|
|
label: '组',
|
|
|
id: 3,
|
|
|
},
|
|
@@ -268,7 +325,7 @@ const formConfig = computed(() => {
|
|
|
type: 'select',
|
|
|
label: '负责人',
|
|
|
prop: 'leaderId',
|
|
|
- itemWidth: 50,
|
|
|
+ itemWidth: 50,
|
|
|
isLoad: {
|
|
|
url: '/tenantUser/list?pageNum=1&pageSize=10000',
|
|
|
labelKey: 'userName',
|
|
@@ -277,11 +334,11 @@ const formConfig = computed(() => {
|
|
|
resUrl: 'rows',
|
|
|
},
|
|
|
},
|
|
|
- {
|
|
|
+ {
|
|
|
type: 'select',
|
|
|
label: '总监',
|
|
|
prop: 'directorId',
|
|
|
- itemWidth: 50,
|
|
|
+ itemWidth: 50,
|
|
|
isLoad: {
|
|
|
url: '/tenantUser/list?pageNum=1&pageSize=10000',
|
|
|
labelKey: 'userName',
|
|
@@ -302,16 +359,17 @@ const formConfig = computed(() => {
|
|
|
]
|
|
|
})
|
|
|
const newPassword = () => {
|
|
|
- formData.data.password = generatePassword()
|
|
|
+ formData.data.password = generatePassword()
|
|
|
}
|
|
|
const generatePassword = () => {
|
|
|
- var length = 12,
|
|
|
- charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
|
|
|
- password = "";
|
|
|
- for (var i = 0, n = charset.length; i < length; ++i) {
|
|
|
- password += charset.charAt(Math.floor(Math.random() * n));
|
|
|
- }
|
|
|
- return password;
|
|
|
+ var length = 12,
|
|
|
+ charset =
|
|
|
+ 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
|
|
|
+ password = ''
|
|
|
+ for (var i = 0, n = charset.length; i < length; ++i) {
|
|
|
+ password += charset.charAt(Math.floor(Math.random() * n))
|
|
|
+ }
|
|
|
+ return password
|
|
|
}
|
|
|
|
|
|
const getTreeList = () => {
|
|
@@ -321,11 +379,10 @@ const getTreeList = () => {
|
|
|
item.id = item.tenantId
|
|
|
item.children = []
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
treeListData.value = message
|
|
|
console.log(treeListData.value)
|
|
|
})
|
|
|
-
|
|
|
}
|
|
|
const getList = async (req) => {
|
|
|
sourceList.value.pagination = { ...sourceList.value.pagination, ...req }
|
|
@@ -333,9 +390,11 @@ const getList = async (req) => {
|
|
|
proxy
|
|
|
.get('/tenantDept/list', sourceList.value.pagination)
|
|
|
.then((message) => {
|
|
|
- recursive(message.data)
|
|
|
- sourceList.value.data = message.data
|
|
|
- formConfig.value[0].data = message.data
|
|
|
+ recursive(message.data)
|
|
|
+
|
|
|
+ sourceList.value.data = proxy.handleTree(message.data, 'deptId')
|
|
|
+ console.log(sourceList.value)
|
|
|
+ formConfig.value[0].data = proxy.handleTree(message.data, 'deptId')
|
|
|
setTimeout(() => {
|
|
|
loading.value = false
|
|
|
}, 200)
|
|
@@ -367,6 +426,7 @@ const submitForm = () => {
|
|
|
byform.value.handleSubmit((valid) => {
|
|
|
const method = modalType.value == 'add' ? 'POST' : 'PUT'
|
|
|
console.log(method)
|
|
|
+ if(!formData.data.parentId) formData.data.parentId = '0'
|
|
|
proxy
|
|
|
.post(
|
|
|
'/tenantDept',
|
|
@@ -388,25 +448,47 @@ const submitForm = () => {
|
|
|
}
|
|
|
|
|
|
const recursive = (data) => {
|
|
|
- data.map((item) => {
|
|
|
- item.label = item.deptName
|
|
|
- item.id = item.deptId
|
|
|
- if (item.children) {
|
|
|
- recursive(item.children)
|
|
|
- }
|
|
|
- })
|
|
|
+ data.map((item) => {
|
|
|
+ item.label = item.deptName
|
|
|
+ item.id = item.deptId
|
|
|
+ if (item.children) {
|
|
|
+ recursive(item.children)
|
|
|
+ } else {
|
|
|
+ item.children = []
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
+const listDelete = (row) => {
|
|
|
+ // 弹窗提示是否删除
|
|
|
+ ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }).then(() => {
|
|
|
+ // 删除
|
|
|
+ proxy
|
|
|
+ .post(
|
|
|
+ '/tenantDept/' + row.deptId,{},'delete'
|
|
|
+ )
|
|
|
+ .then((res) => {
|
|
|
+ ElMessage({
|
|
|
+ message: '删除成功',
|
|
|
+ type: 'success',
|
|
|
+ })
|
|
|
+ getList()
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
const getDtl = (row) => {
|
|
|
- formData.data = {...row}
|
|
|
+ formData.data = { ...row }
|
|
|
modalType.value = 'edit'
|
|
|
console.log(modalType.value)
|
|
|
dialogVisible.value = true
|
|
|
}
|
|
|
getTreeList()
|
|
|
getList()
|
|
|
-
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|