|
|
@ -30,7 +30,7 @@ |
|
|
|
</el-button> |
|
|
|
</template> |
|
|
|
<template v-slot:right> |
|
|
|
<el-button :loading="crud.downloadLoading" size="mini" :disabled="crud.selections.length === 0" @click="doExport(crud.selections)"> |
|
|
|
<el-button :loading="crud.downloadLoading" size="mini" :disabled="selections.length === 0" @click="doExport(selections)"> |
|
|
|
<i class="iconfont icon-daochu" /> |
|
|
|
导出 |
|
|
|
</el-button> |
|
|
@ -74,14 +74,19 @@ |
|
|
|
controls-position="right" |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
|
<!-- @input="changePid" --> |
|
|
|
<el-form-item v-if="form.isTop === '0'" label="上级部门" prop="deptsParentsId"> |
|
|
|
<treeselect |
|
|
|
v-model="form.deptsParentsId" |
|
|
|
:options="depts" |
|
|
|
:load-options="loadDepts" |
|
|
|
placeholder="选择所属全宗后再选上级部门" |
|
|
|
:normalizer="normalizer" |
|
|
|
:default-expand-level="2" |
|
|
|
/> |
|
|
|
:default-expand-level="levelNumber" |
|
|
|
@select="node => tenantIdHandleSelect(node)" |
|
|
|
> |
|
|
|
<div slot="value-label" slot-scope="{ node }">{{ getAutoNameUnknown(node.label) }}</div> |
|
|
|
</treeselect> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="状态" prop="deptsStatus" :style="form.isTop === '0'? 'margin-left:0': 'margin:0 0 0 360px'"> |
|
|
|
<el-radio-group v-model="form.deptsStatus"> |
|
|
@ -106,39 +111,14 @@ |
|
|
|
lazy |
|
|
|
:load="getDeptDatas" |
|
|
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}" |
|
|
|
:data="crud.data" |
|
|
|
row-key="id" |
|
|
|
@select="crud.selectChange" |
|
|
|
@select-all="crud.selectAllChange" |
|
|
|
:data="tableData" |
|
|
|
:row-key="getRowKey" |
|
|
|
@selection-change="crud.selectionChangeHandler" |
|
|
|
@expand-change="expandChange" |
|
|
|
@row-click="clickRowHandler" |
|
|
|
> |
|
|
|
<el-table-column type="selection" align="center" width="55" /> |
|
|
|
<el-table-column type="expand" width="20"> |
|
|
|
<template slot-scope="props"> |
|
|
|
<div v-if="props.row.sonNum"> |
|
|
|
<el-table :data="expandData" :show-header="false"> |
|
|
|
<el-table-column type="selection" align="center" width="55" /> |
|
|
|
<el-table-column label="部门名称" prop="deptsName" /> |
|
|
|
<el-table-column label="部门编码" prop="deptsCode" /> |
|
|
|
<el-table-column label="部门人数" prop="deptsTotalPeoNum" /> |
|
|
|
<el-table-column label="排序" prop="deptsOrders" /> |
|
|
|
<el-table-column label="所属全宗" prop="fondsName" /> |
|
|
|
<el-table-column label="状态" align="center" prop="deptsStatus"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-switch v-model="scope.row.deptsStatus" active-color="#409EFF" inactive-color="#F56C6C" :active-value="1" :inactive-value="0" @change="changeStatus(scope.row, scope.row.deptsStatus)" /> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column prop="createTime" label="创建日期"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<div>{{ scope.row.createTime | parseTime }}</div> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="部门名称" prop="deptsName" /> |
|
|
|
<el-table-column label="部门22" prop="hasChildren" /> |
|
|
|
<el-table-column label="部门编码" prop="deptsCode" /> |
|
|
|
<el-table-column label="部门人数" prop="deptsTotalPeoNum" /> |
|
|
|
<el-table-column label="排序" prop="deptsOrders" /> |
|
|
@ -197,7 +177,9 @@ export default { |
|
|
|
dicts: ['dept_status'], |
|
|
|
data() { |
|
|
|
return { |
|
|
|
selections: [], |
|
|
|
depts: [], |
|
|
|
tableData: [], |
|
|
|
rules: { |
|
|
|
fondsId: [ |
|
|
|
{ required: true, message: '请选择所属全宗', trigger: 'change' } |
|
|
@ -224,8 +206,7 @@ export default { |
|
|
|
{ required: true, message: '请选择状态', trigger: 'change' } |
|
|
|
] |
|
|
|
}, |
|
|
|
fondsName: '', deptDatas: [], jobs: [], level: 3, roles: [], |
|
|
|
jobDatas: [], roleDatas: [], // 多选时使用 |
|
|
|
fondsName: '', |
|
|
|
fondsDatas: [], |
|
|
|
filterText: '', |
|
|
|
defaultExpandedKeys: [], |
|
|
@ -242,7 +223,7 @@ export default { |
|
|
|
{ key: '1', display_name: '激活' }, |
|
|
|
{ key: '0', display_name: '锁定' } |
|
|
|
], |
|
|
|
expandData: [] |
|
|
|
levelNumber: 0 |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
@ -259,42 +240,71 @@ export default { |
|
|
|
this.getFondsDatas() |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
expandChange(row, expandRow) { |
|
|
|
crudDept.FetchSonDepts({ deptsId: row.deptsId }).then(res => { |
|
|
|
console.log(res) |
|
|
|
this.expandData = res |
|
|
|
}) |
|
|
|
}, |
|
|
|
tableRowInserted({ row, parentRow, $index }) { |
|
|
|
if (parentRow) { |
|
|
|
crudDept.FetchSonDepts({ deptsId: row.deptsId }).then(res => { |
|
|
|
console.log(res) |
|
|
|
parentRow.children.splice(1, 0, 1) |
|
|
|
}) |
|
|
|
|
|
|
|
parentRow.children.splice(1) |
|
|
|
// const data = crud.FetchSonDepts(row.id) // 使用异步请求获取数据 |
|
|
|
// data.then((result) => { |
|
|
|
// result.forEach((item, index) => { |
|
|
|
// parentRow.children.splice($index + index + 1, 0, item) // 将新数据插入到父行的children属性中 |
|
|
|
// }) |
|
|
|
// }) |
|
|
|
// 处理vue-treeSelect回显出现unknown问题 |
|
|
|
getAutoNameUnknown(name) { |
|
|
|
if (name.lastIndexOf('unknown') > -1) { |
|
|
|
return name.split('(')[0] |
|
|
|
} else { |
|
|
|
return name |
|
|
|
} |
|
|
|
}, |
|
|
|
getRowKey(row) { |
|
|
|
return row.deptsId |
|
|
|
}, |
|
|
|
[CRUD.HOOK.beforeRefresh]() { |
|
|
|
if (this.blurryTime) { |
|
|
|
this.crud.query.startTime = this.blurryTime[0] |
|
|
|
this.crud.query.endTime = this.blurryTime[1] |
|
|
|
} |
|
|
|
}, |
|
|
|
getDeptDatas(tree, treeNode, resolve) { |
|
|
|
const params = { pid: tree.id } |
|
|
|
setTimeout(() => { |
|
|
|
crudDept.getDepts(params).then(res => { |
|
|
|
resolve(res.content) |
|
|
|
}) |
|
|
|
}, 100) |
|
|
|
[CRUD.HOOK.afterRefresh](crud) { |
|
|
|
crud.data.forEach(function(item, index) { |
|
|
|
if (item.sonNum !== 0) { |
|
|
|
item.hasChildren = true |
|
|
|
} else { |
|
|
|
item.hasChildren = false |
|
|
|
} |
|
|
|
if (!item.hasChildren) { |
|
|
|
item.children = null |
|
|
|
} |
|
|
|
}) |
|
|
|
this.tableData = this.crud.data |
|
|
|
}, |
|
|
|
// 新增与编辑前做的操作 |
|
|
|
[CRUD.HOOK.afterToCU](crud, form) { |
|
|
|
console.log(crud) |
|
|
|
console.log(form) |
|
|
|
this.depts = [] |
|
|
|
this.levelNumber = 0 |
|
|
|
if (form.id != null) { |
|
|
|
if (form.deptsParentsId === null) { |
|
|
|
form.isTop = '1' |
|
|
|
} else { |
|
|
|
form.isTop = '0' |
|
|
|
const params = { |
|
|
|
'fondsId': form.fondsId, |
|
|
|
'fondsName': form.fondsName, |
|
|
|
'status': 1 |
|
|
|
} |
|
|
|
this.getDepts(params) |
|
|
|
this.levelNumber = 4 |
|
|
|
console.log(this.depts) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
// 编辑前 |
|
|
|
[CRUD.HOOK.beforeToEdit](crud, form) { |
|
|
|
crud.form.id = form.deptsId |
|
|
|
}, |
|
|
|
// 提交前的验证 |
|
|
|
[CRUD.HOOK.afterValidateCU](crud) { |
|
|
|
if (crud.form.isTop === '1') { |
|
|
|
crud.form.deptsParentsId = null |
|
|
|
} |
|
|
|
delete crud.form.isTop |
|
|
|
return true |
|
|
|
}, |
|
|
|
// 全宗选择 |
|
|
|
getFondsDatas() { |
|
|
|
const parent = {} |
|
|
|
parent.id = 0 |
|
|
@ -320,10 +330,17 @@ export default { |
|
|
|
this.query.fondsName = val.fondsName |
|
|
|
this.query.fondsNo = val.fondsNo |
|
|
|
this.crud.toQuery() |
|
|
|
const params = { |
|
|
|
'fondsId': val.id, |
|
|
|
'fondsName': val.fondsName, |
|
|
|
'status': 1 |
|
|
|
} |
|
|
|
this.getDepts(params) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
changeValue(value) { |
|
|
|
this.depts = [] |
|
|
|
var obj = {} |
|
|
|
obj = this.fondsOptions.find(function(item) { |
|
|
|
return item.id === value |
|
|
@ -336,19 +353,36 @@ export default { |
|
|
|
} |
|
|
|
this.getDepts(params) |
|
|
|
}, |
|
|
|
// 新增与编辑前做的操作 |
|
|
|
[CRUD.HOOK.afterToCU](crud, form) { |
|
|
|
if (form.fondsId !== null) { |
|
|
|
this.getDepts() |
|
|
|
} |
|
|
|
clickRowHandler(row) { |
|
|
|
this.$refs.table.clearSelection() |
|
|
|
this.$refs.table.toggleRowSelection(row) |
|
|
|
}, |
|
|
|
// 编辑前 |
|
|
|
[CRUD.HOOK.beforeToEdit](crud, form) { |
|
|
|
crud.form.id = form.deptsId |
|
|
|
getDeptDatas(tree, treeNode, resolve) { |
|
|
|
setTimeout(() => { |
|
|
|
crudDept.FetchSonDepts({ deptsId: tree.deptsId }).then(res => { |
|
|
|
const data = res.map(function(obj) { |
|
|
|
if (obj.sonNum !== 0) { |
|
|
|
obj.hasChildren = true |
|
|
|
} else { |
|
|
|
obj.hasChildren = false |
|
|
|
} |
|
|
|
if (obj.hasChildren) { |
|
|
|
obj.children = null |
|
|
|
} |
|
|
|
return obj |
|
|
|
}) |
|
|
|
resolve(data) |
|
|
|
}) |
|
|
|
}, 100) |
|
|
|
}, |
|
|
|
getDepts(params) { |
|
|
|
crudDept.getDepts(params).then(res => { |
|
|
|
this.depts = res.content.map(function(obj) { |
|
|
|
if (obj.sonNum !== 0) { |
|
|
|
obj.hasChildren = true |
|
|
|
} else { |
|
|
|
obj.hasChildren = false |
|
|
|
} |
|
|
|
if (obj.hasChildren) { |
|
|
|
obj.children = null |
|
|
|
} |
|
|
@ -359,8 +393,13 @@ export default { |
|
|
|
// 获取弹窗内部门数据 |
|
|
|
loadDepts({ action, parentNode, callback }) { |
|
|
|
if (action === LOAD_CHILDREN_OPTIONS) { |
|
|
|
crudDept.getDepts({ status: 1, pid: parentNode.id }).then(res => { |
|
|
|
parentNode.children = res.content.map(function(obj) { |
|
|
|
crudDept.FetchSonDepts({ deptsId: parentNode.deptsId }).then(res => { |
|
|
|
parentNode.children = res.map(function(obj) { |
|
|
|
if (obj.sonNum !== 0) { |
|
|
|
obj.hasChildren = true |
|
|
|
} else { |
|
|
|
obj.hasChildren = false |
|
|
|
} |
|
|
|
if (obj.hasChildren) { |
|
|
|
obj.children = null |
|
|
|
} |
|
|
@ -372,14 +411,6 @@ export default { |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
// 提交前的验证 |
|
|
|
[CRUD.HOOK.afterValidateCU](crud) { |
|
|
|
if (crud.form.isTop === '1') { |
|
|
|
crud.form.deptsParentsId = null |
|
|
|
} |
|
|
|
delete crud.form.isTop |
|
|
|
return true |
|
|
|
}, |
|
|
|
toDelete(datas) { |
|
|
|
this.deleteData = datas |
|
|
|
this.$confirm('此操作将删除当前所选' + this.crud.title + '<span>你是否还要继续?</span>', '提示', { |
|
|
@ -424,6 +455,7 @@ export default { |
|
|
|
}) |
|
|
|
}, |
|
|
|
doExport(data) { |
|
|
|
console.log(data) |
|
|
|
crud.downloadLoading = true |
|
|
|
this.$confirm('此操作将导出所选数据' + '<span>你是否还要继续?</span>', '提示', { |
|
|
|
confirmButtonText: '继续', |
|
|
@ -457,4 +489,7 @@ export default { |
|
|
|
</script> |
|
|
|
|
|
|
|
<style lang="scss" scoped> |
|
|
|
::v-deep .expanded-list.el-table .el-table__cell:first-child .cell{ |
|
|
|
margin-left: -20px; |
|
|
|
} |
|
|
|
</style> |