|
|
|
@ -10,22 +10,16 @@ |
|
|
|
:inline="true" |
|
|
|
:inline="true" |
|
|
|
class="data-list-filter-form" |
|
|
|
class="data-list-filter-form" |
|
|
|
> |
|
|
|
> |
|
|
|
<el-form-item label="厂区" prop="deptId"> |
|
|
|
<el-form-item label="绑定部门" prop="deptId"> |
|
|
|
<el-select |
|
|
|
<treeselect |
|
|
|
v-model="queryParams.deptId" |
|
|
|
v-model="queryParams.deptId" |
|
|
|
:disabled="!isSuperAdmin" |
|
|
|
:options="deptTreeOptions" |
|
|
|
:loading="factoryLoading" |
|
|
|
:loading="deptLoading" |
|
|
|
|
|
|
|
:show-count="true" |
|
|
|
clearable |
|
|
|
clearable |
|
|
|
filterable |
|
|
|
placeholder="全部部门" |
|
|
|
placeholder="全部厂区" |
|
|
|
class="filter-treeselect" |
|
|
|
> |
|
|
|
/> |
|
|
|
<el-option |
|
|
|
|
|
|
|
v-for="item in displayedFactoryOptions" |
|
|
|
|
|
|
|
:key="factoryId(item)" |
|
|
|
|
|
|
|
:label="factoryName(item)" |
|
|
|
|
|
|
|
:value="factoryId(item)" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</el-select> |
|
|
|
|
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="隐患等级" prop="hazardLevel"> |
|
|
|
<el-form-item label="隐患等级" prop="hazardLevel"> |
|
|
|
<el-select |
|
|
|
<el-select |
|
|
|
@ -124,7 +118,7 @@ |
|
|
|
/> |
|
|
|
/> |
|
|
|
<el-table-column |
|
|
|
<el-table-column |
|
|
|
prop="deptName" |
|
|
|
prop="deptName" |
|
|
|
label="厂区名称" |
|
|
|
label="绑定部门" |
|
|
|
min-width="130" |
|
|
|
min-width="130" |
|
|
|
show-overflow-tooltip |
|
|
|
show-overflow-tooltip |
|
|
|
> |
|
|
|
> |
|
|
|
@ -204,7 +198,7 @@ |
|
|
|
@pagination="getList" |
|
|
|
@pagination="getList" |
|
|
|
/> |
|
|
|
/> |
|
|
|
<div class="scope-note"> |
|
|
|
<div class="scope-note"> |
|
|
|
管理员可查看/配置所有厂区;厂区二级管理员仅能查看本厂区配置(数据范围「本部门」自动过滤)。隐患上报时后端根据「用户所属厂区 + 隐患等级」自动匹配对应 flowKey 启动流程。 |
|
|
|
管理员可查看/配置全部部门;非管理员仅能查看本部门子树内(含下级部门)配置。新增可将流程绑定到厂区或其下级部门,隐患上报时后端按「用户所属部门沿部门链就近匹配」自动选择对应 flowKey 启动流程。 |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</data-list-panel> |
|
|
|
</data-list-panel> |
|
|
|
@ -226,22 +220,21 @@ |
|
|
|
> |
|
|
|
> |
|
|
|
<el-row :gutter="16"> |
|
|
|
<el-row :gutter="16"> |
|
|
|
<el-col :xs="24" :sm="12"> |
|
|
|
<el-col :xs="24" :sm="12"> |
|
|
|
<el-form-item label="厂区" prop="deptId"> |
|
|
|
<el-form-item label="绑定部门" prop="deptId"> |
|
|
|
<el-select |
|
|
|
<treeselect |
|
|
|
|
|
|
|
v-if="dialogMode === 'add'" |
|
|
|
v-model="form.deptId" |
|
|
|
v-model="form.deptId" |
|
|
|
:disabled="dialogMode === 'edit' || !isSuperAdmin" |
|
|
|
:options="deptTreeOptions" |
|
|
|
:loading="factoryLoading" |
|
|
|
:loading="deptLoading" |
|
|
|
filterable |
|
|
|
:show-count="true" |
|
|
|
placeholder="请选择厂区" |
|
|
|
placeholder="请选择绑定部门" |
|
|
|
style="width: 100%" |
|
|
|
/> |
|
|
|
> |
|
|
|
<el-input |
|
|
|
<el-option |
|
|
|
v-else |
|
|
|
v-for="item in displayedFactoryOptions" |
|
|
|
:value="form.deptName || form.deptId" |
|
|
|
:key="factoryId(item)" |
|
|
|
disabled |
|
|
|
:label="factoryName(item)" |
|
|
|
placeholder="请选择绑定部门" |
|
|
|
:value="factoryId(item)" |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
</el-select> |
|
|
|
|
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
</el-col> |
|
|
|
<el-col :xs="24" :sm="12"> |
|
|
|
<el-col :xs="24" :sm="12"> |
|
|
|
@ -322,14 +315,13 @@ |
|
|
|
import { |
|
|
|
import { |
|
|
|
addHazardFlowConfig, |
|
|
|
addHazardFlowConfig, |
|
|
|
deleteHazardFlowConfig, |
|
|
|
deleteHazardFlowConfig, |
|
|
|
|
|
|
|
getBindDeptTree, |
|
|
|
getHazardFlowConfig, |
|
|
|
getHazardFlowConfig, |
|
|
|
listHazardFlowConfigs, |
|
|
|
listHazardFlowConfigs, |
|
|
|
updateHazardFlowConfig |
|
|
|
updateHazardFlowConfig |
|
|
|
} from '@/api/flowable/hazardConfig' |
|
|
|
} from '@/api/flowable/hazardConfig' |
|
|
|
import { |
|
|
|
import Treeselect from '@riophae/vue-treeselect' |
|
|
|
getMyFactoryDepartment, |
|
|
|
import '@riophae/vue-treeselect/dist/vue-treeselect.css' |
|
|
|
listFactoryDepartments |
|
|
|
|
|
|
|
} from '@/api/system/dept' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const LEVEL_OPTIONS = [ |
|
|
|
const LEVEL_OPTIONS = [ |
|
|
|
{ value: 'general', label: '一般隐患' }, |
|
|
|
{ value: 'general', label: '一般隐患' }, |
|
|
|
@ -340,10 +332,11 @@ const LEVEL_OPTIONS = [ |
|
|
|
export default { |
|
|
|
export default { |
|
|
|
name: 'HazardFlowConfig', |
|
|
|
name: 'HazardFlowConfig', |
|
|
|
dicts: ['flow_biz_type'], |
|
|
|
dicts: ['flow_biz_type'], |
|
|
|
|
|
|
|
components: { Treeselect }, |
|
|
|
data() { |
|
|
|
data() { |
|
|
|
const validateDept = (rule, value, callback) => { |
|
|
|
const validateDept = (rule, value, callback) => { |
|
|
|
if (this.isSuperAdmin && !value) { |
|
|
|
if (!value) { |
|
|
|
callback(new Error('请选择厂区')) |
|
|
|
callback(new Error('请选择绑定部门')) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
callback() |
|
|
|
callback() |
|
|
|
@ -351,7 +344,7 @@ export default { |
|
|
|
return { |
|
|
|
return { |
|
|
|
showSearch: true, |
|
|
|
showSearch: true, |
|
|
|
loading: false, |
|
|
|
loading: false, |
|
|
|
factoryLoading: false, |
|
|
|
deptLoading: false, |
|
|
|
detailLoading: false, |
|
|
|
detailLoading: false, |
|
|
|
detailLoadingId: undefined, |
|
|
|
detailLoadingId: undefined, |
|
|
|
saving: false, |
|
|
|
saving: false, |
|
|
|
@ -360,8 +353,7 @@ export default { |
|
|
|
selectedRows: [], |
|
|
|
selectedRows: [], |
|
|
|
single: true, |
|
|
|
single: true, |
|
|
|
multiple: true, |
|
|
|
multiple: true, |
|
|
|
factoryOptions: [], |
|
|
|
deptTreeOptions: [], |
|
|
|
currentFactory: null, |
|
|
|
|
|
|
|
levelOptions: LEVEL_OPTIONS, |
|
|
|
levelOptions: LEVEL_OPTIONS, |
|
|
|
dialogVisible: false, |
|
|
|
dialogVisible: false, |
|
|
|
dialogMode: 'add', |
|
|
|
dialogMode: 'add', |
|
|
|
@ -388,24 +380,15 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
|
|
|
|
isSuperAdmin() { |
|
|
|
|
|
|
|
return (this.$store.getters.roles || []).indexOf('admin') !== -1 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
displayedFactoryOptions() { |
|
|
|
|
|
|
|
if (this.isSuperAdmin) return this.factoryOptions |
|
|
|
|
|
|
|
return this.currentFactory ? [this.currentFactory] : [] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
created() { |
|
|
|
created() { |
|
|
|
this.getList() |
|
|
|
this.getList() |
|
|
|
this.loadFactoryScope() |
|
|
|
this.loadDeptTree() |
|
|
|
}, |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
createEmptyForm() { |
|
|
|
createEmptyForm() { |
|
|
|
return { |
|
|
|
return { |
|
|
|
id: undefined, |
|
|
|
id: undefined, |
|
|
|
deptId: '', |
|
|
|
deptId: null, |
|
|
|
deptName: '', |
|
|
|
deptName: '', |
|
|
|
bizType: '', |
|
|
|
bizType: '', |
|
|
|
hazardLevel: '', |
|
|
|
hazardLevel: '', |
|
|
|
@ -421,7 +404,6 @@ export default { |
|
|
|
getList() { |
|
|
|
getList() { |
|
|
|
this.loading = true |
|
|
|
this.loading = true |
|
|
|
const params = Object.assign({}, this.queryParams) |
|
|
|
const params = Object.assign({}, this.queryParams) |
|
|
|
if (!this.isSuperAdmin) delete params.deptId |
|
|
|
|
|
|
|
listHazardFlowConfigs(params) |
|
|
|
listHazardFlowConfigs(params) |
|
|
|
.then(response => { |
|
|
|
.then(response => { |
|
|
|
const page = this.unwrapData(response) || {} |
|
|
|
const page = this.unwrapData(response) || {} |
|
|
|
@ -437,43 +419,47 @@ export default { |
|
|
|
this.loading = false |
|
|
|
this.loading = false |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
loadFactoryScope() { |
|
|
|
loadDeptTree() { |
|
|
|
this.factoryLoading = true |
|
|
|
this.deptLoading = true |
|
|
|
const request = this.isSuperAdmin |
|
|
|
getBindDeptTree() |
|
|
|
? listFactoryDepartments() |
|
|
|
|
|
|
|
: getMyFactoryDepartment() |
|
|
|
|
|
|
|
request |
|
|
|
|
|
|
|
.then(response => { |
|
|
|
.then(response => { |
|
|
|
const data = this.unwrapData(response) |
|
|
|
const data = this.unwrapData(response) |
|
|
|
if (this.isSuperAdmin) { |
|
|
|
let nodes = [] |
|
|
|
this.factoryOptions = Array.isArray(data) |
|
|
|
if (Array.isArray(data)) { |
|
|
|
? data |
|
|
|
nodes = data |
|
|
|
: (data && (data.list || data.rows)) || [] |
|
|
|
} else if (data && Array.isArray(data.children)) { |
|
|
|
return |
|
|
|
nodes = [data] |
|
|
|
} |
|
|
|
} else if (data && (data.list || data.rows)) { |
|
|
|
this.currentFactory = data || null |
|
|
|
nodes = data.list || data.rows |
|
|
|
if (this.currentFactory) { |
|
|
|
|
|
|
|
this.queryParams.deptId = this.factoryId(this.currentFactory) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.deptTreeOptions = this.normalizeTree(nodes) |
|
|
|
}) |
|
|
|
}) |
|
|
|
.catch(() => { |
|
|
|
.catch(() => { |
|
|
|
this.factoryOptions = [] |
|
|
|
this.deptTreeOptions = [] |
|
|
|
this.currentFactory = null |
|
|
|
this.$modal.msgError('组织树加载失败') |
|
|
|
this.$modal.msgError('厂区信息加载失败') |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
.finally(() => { |
|
|
|
.finally(() => { |
|
|
|
this.factoryLoading = false |
|
|
|
this.deptLoading = false |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
normalizeTree(nodes) { |
|
|
|
|
|
|
|
if (!Array.isArray(nodes)) return [] |
|
|
|
|
|
|
|
return nodes.map(node => { |
|
|
|
|
|
|
|
const item = { |
|
|
|
|
|
|
|
id: node.id === undefined || node.id === null ? node.id : String(node.id), |
|
|
|
|
|
|
|
label: node.label || node.deptName || node.name || '' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const children = this.normalizeTree(node.children) |
|
|
|
|
|
|
|
if (children.length) item.children = children |
|
|
|
|
|
|
|
return item |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
handleQuery() { |
|
|
|
handleQuery() { |
|
|
|
this.queryParams.pageNum = 1 |
|
|
|
this.queryParams.pageNum = 1 |
|
|
|
this.getList() |
|
|
|
this.getList() |
|
|
|
}, |
|
|
|
}, |
|
|
|
resetQuery() { |
|
|
|
resetQuery() { |
|
|
|
this.resetForm('queryForm') |
|
|
|
this.resetForm('queryForm') |
|
|
|
if (!this.isSuperAdmin && this.currentFactory) { |
|
|
|
|
|
|
|
this.queryParams.deptId = this.factoryId(this.currentFactory) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.handleQuery() |
|
|
|
this.handleQuery() |
|
|
|
}, |
|
|
|
}, |
|
|
|
handleSelectionChange(selection) { |
|
|
|
handleSelectionChange(selection) { |
|
|
|
@ -485,10 +471,6 @@ export default { |
|
|
|
this.dialogMode = 'add' |
|
|
|
this.dialogMode = 'add' |
|
|
|
this.dialogTitle = '新增流程模板配置' |
|
|
|
this.dialogTitle = '新增流程模板配置' |
|
|
|
this.form = this.createEmptyForm() |
|
|
|
this.form = this.createEmptyForm() |
|
|
|
if (!this.isSuperAdmin && this.currentFactory) { |
|
|
|
|
|
|
|
this.form.deptId = this.factoryId(this.currentFactory) |
|
|
|
|
|
|
|
this.form.deptName = this.factoryName(this.currentFactory) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.dialogVisible = true |
|
|
|
this.dialogVisible = true |
|
|
|
this.$nextTick(() => this.$refs.configForm.clearValidate()) |
|
|
|
this.$nextTick(() => this.$refs.configForm.clearValidate()) |
|
|
|
}, |
|
|
|
}, |
|
|
|
@ -518,7 +500,7 @@ export default { |
|
|
|
return { |
|
|
|
return { |
|
|
|
id: data.id, |
|
|
|
id: data.id, |
|
|
|
deptId: data.deptId === undefined || data.deptId === null |
|
|
|
deptId: data.deptId === undefined || data.deptId === null |
|
|
|
? '' |
|
|
|
? null |
|
|
|
: String(data.deptId), |
|
|
|
: String(data.deptId), |
|
|
|
deptName: data.deptName || '', |
|
|
|
deptName: data.deptName || '', |
|
|
|
bizType: data.bizType || '', |
|
|
|
bizType: data.bizType || '', |
|
|
|
@ -562,15 +544,9 @@ export default { |
|
|
|
flowName: source.flowName || undefined, |
|
|
|
flowName: source.flowName || undefined, |
|
|
|
status: this.statusValue(source.status) |
|
|
|
status: this.statusValue(source.status) |
|
|
|
} |
|
|
|
} |
|
|
|
const factory = this.displayedFactoryOptions.find( |
|
|
|
const node = this.findDeptNode(this.deptTreeOptions, payload.deptId) |
|
|
|
item => this.factoryId(item) === String(payload.deptId || '') |
|
|
|
if (node) payload.deptName = node.label |
|
|
|
) |
|
|
|
|
|
|
|
if (factory) payload.deptName = this.factoryName(factory) |
|
|
|
|
|
|
|
if (this.dialogMode === 'add') delete payload.id |
|
|
|
if (this.dialogMode === 'add') delete payload.id |
|
|
|
if (this.dialogMode === 'add' && !this.isSuperAdmin) { |
|
|
|
|
|
|
|
delete payload.deptId |
|
|
|
|
|
|
|
delete payload.deptName |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return payload |
|
|
|
return payload |
|
|
|
}, |
|
|
|
}, |
|
|
|
handleDelete(row) { |
|
|
|
handleDelete(row) { |
|
|
|
@ -589,12 +565,18 @@ export default { |
|
|
|
this.getList() |
|
|
|
this.getList() |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
factoryId(item) { |
|
|
|
findDeptNode(nodes, targetId) { |
|
|
|
const value = item && (item.deptId !== undefined ? item.deptId : item.id) |
|
|
|
if (!Array.isArray(nodes) || targetId === undefined || targetId === null) { |
|
|
|
return value === undefined || value === null ? '' : String(value) |
|
|
|
return null |
|
|
|
}, |
|
|
|
} |
|
|
|
factoryName(item) { |
|
|
|
const target = String(targetId) |
|
|
|
return (item && (item.deptName || item.label || item.name)) || '' |
|
|
|
for (let i = 0; i < nodes.length; i += 1) { |
|
|
|
|
|
|
|
const node = nodes[i] |
|
|
|
|
|
|
|
if (String(node.id) === target) return node |
|
|
|
|
|
|
|
const matched = this.findDeptNode(node.children, target) |
|
|
|
|
|
|
|
if (matched) return matched |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null |
|
|
|
}, |
|
|
|
}, |
|
|
|
levelName(value) { |
|
|
|
levelName(value) { |
|
|
|
const item = this.levelOptions.find(option => option.value === value) |
|
|
|
const item = this.levelOptions.find(option => option.value === value) |
|
|
|
@ -653,9 +635,26 @@ export default { |
|
|
|
margin-bottom: 18px; |
|
|
|
margin-bottom: 18px; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
::v-deep .config-form .vue-treeselect { |
|
|
|
|
|
|
|
width: 100%; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 下拉菜单宽度默认等于控件宽度,叶子节点名易被省略号截断,兜底加宽 |
|
|
|
|
|
|
|
::v-deep .vue-treeselect__menu-container { |
|
|
|
|
|
|
|
min-width: 320px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.filter-treeselect { |
|
|
|
|
|
|
|
width: 260px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@media (max-width: 768px) { |
|
|
|
@media (max-width: 768px) { |
|
|
|
::v-deep .el-dialog { |
|
|
|
::v-deep .el-dialog { |
|
|
|
width: calc(100% - 24px) !important; |
|
|
|
width: calc(100% - 24px) !important; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.filter-treeselect { |
|
|
|
|
|
|
|
width: 100%; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |
|
|
|
</style> |
|
|
|
|