事项配置重构

This commit is contained in:
aixianling
2023-04-07 11:35:09 +08:00
parent aebf16936c
commit 485a294fb4
3 changed files with 189 additions and 261 deletions

View File

@@ -1,21 +1,6 @@
<template> <template>
<section class="matters-config"> <section class="matters-config">
<ai-list v-if="!showDetail"> <component :is="currentPage" v-bind="$props"/>
<template #title>
<ai-title title="事项配置" :isShowBottomBorder="false"></ai-title>
</template>
<template slot="tabs">
<el-tabs class="tabs-page" v-model="currIndex">
<el-tab-pane v-for="(tab,i) in tabs" :key="i" :label="tab.label" :name="String(i)">
<component :is="tab.comp" v-if="currIndex==i" :ref="currIndex" :instance="instance" :dict="dict"
:permissions="permissions" @goPage="goPage" :tab="currentTab"/>
</el-tab-pane>
</el-tabs>
</template>
</ai-list>
<component v-else :is="currentComp" :instance="instance" :dict="dict"
:processType="currentTab.value" :row="row"></component>
</section> </section>
</template> </template>
@@ -33,37 +18,14 @@ export default {
dict: Object, dict: Object,
permissions: Function permissions: Function
}, },
data() {
return {
currIndex: "0",
row: {},
currentComp: "",
}
},
computed: { computed: {
tabs() { currentPage() {
return [ const {hash} = this.$route
{label: "网上办事", name: "configList", value: "0", comp: configList, detail: addConfig, permission: ""}, return hash == "#add" ? addConfig : hash == "#guidance" ? guidance : configList
{label: "办事指南", name: "configList", value: "2", comp: configList, detail: guidance, permission: ""},
]
}, },
currentTab() {
return this.tabs?.[this.currIndex] || {}
},
showDetail() {
return !!this.$route.query?.id || !!this.$route.query?.processType
}
},
methods: {
goPage(params) {
this.row = params.row
this.currentComp = params.comp
this.$router.push({query: {processType: this.currentTab.value}})
}
}, },
created() { created() {
this.$router.push({query: {}}); this.dict.load("hbDepartment", 'sex', 'nation', 'marital', 'native_place', 'education', 'candidateApproverType', 'scopeCandidates', 'nodeType')
this.$dict.load("hbDepartment", 'sex', 'nation', 'marital', 'native_place', 'education', 'candidateApproverType', 'scopeCandidates', 'nodeType')
} }
} }
</script> </script>

View File

@@ -27,6 +27,7 @@
</template> </template>
<script> <script>
import {mapActions} from "vuex";
import {applyForm, attachmentMaterial, baseInfo, processApproval} from './index' import {applyForm, attachmentMaterial, baseInfo, processApproval} from './index'
export default { export default {
@@ -39,8 +40,6 @@ export default {
props: { props: {
instance: Function, instance: Function,
dict: Object, dict: Object,
row: Object,
processType: String
}, },
components: {baseInfo, applyForm, attachmentMaterial, processApproval}, components: {baseInfo, applyForm, attachmentMaterial, processApproval},
data() { data() {
@@ -69,11 +68,11 @@ export default {
{title: '审批流程', activeIndex: 3} {title: '审批流程', activeIndex: 3}
] ]
}, },
detailTitle() { detailTitle: v => v.detailObj?.id ? "编辑事项" : "添加事项",
return this.detailObj?.id ? "编辑事项" : "添加事项" processType: v => v.$route.hash == "#add" ? 0 : 2
}
}, },
methods: { methods: {
...mapActions(['closePage']),
/** /**
* 上一步 * 上一步
* */ * */
@@ -110,7 +109,6 @@ export default {
handleBaseInfo() { handleBaseInfo() {
this.$refs['baseInfo'].banseInfoForm().then(res => { this.$refs['baseInfo'].banseInfoForm().then(res => {
if (res) { if (res) {
// this.$refs['applyForm'].getFormList()
this.baseInfo = res this.baseInfo = res
this.activeStep++ this.activeStep++
} }
@@ -121,6 +119,7 @@ export default {
*/ */
save() { save() {
this.$refs['processApproval'].handleProcessApproval().then(res => { this.$refs['processApproval'].handleProcessApproval().then(res => {
const {processType} = this
this.instance.post(`/app/approval-process-def/add-update`, { this.instance.post(`/app/approval-process-def/add-update`, {
...this.detailObj, ...this.detailObj,
...this.baseInfo, ...this.baseInfo,
@@ -132,18 +131,19 @@ export default {
tableType: 0, tableType: 0,
processAnnexDefs: this.annexs.map(e => ({...e, mustFill: Number(e.mustFill)})), processAnnexDefs: this.annexs.map(e => ({...e, mustFill: Number(e.mustFill)})),
processNodeList: res.processNodeList, processNodeList: res.processNodeList,
processType: this.processType processType
}).then(res => { }).then(res => {
if (res.code == 0) { if (res.code == 0) {
this.$message.success("保存成功") this.$message.success("保存成功")
this.$router.push({query:{}}) this.handleBack()
} }
}) })
}).catch(err => { }).catch(err => {
console.error(err); console.error(err);
}) })
}, },
getDetail(id) { getDetail() {
const {id} = this.$route.query
this.instance.post(`/app/approval-process-def/info-id`, null, {params: {id}}).then(res => { this.instance.post(`/app/approval-process-def/info-id`, null, {params: {id}}).then(res => {
if (res?.data) { if (res?.data) {
this.detailObj = res.data this.detailObj = res.data
@@ -163,12 +163,11 @@ export default {
}, },
handleBack() { handleBack() {
this.$router.push({query: {}}) this.$router.push({query: {}})
this.closePage()
} }
}, },
created() { created() {
if (this.row?.id) { this.getDetail()
this.getDetail(this.row?.id)
}
} }
} }
</script> </script>

View File

@@ -1,25 +1,16 @@
<template> <template>
<div class="config-list"> <div class="config-list">
<ai-list isTabs> <ai-list>
<template #content> <ai-title slot="title" title="事项配置"/>
<template #tabs>
<el-tabs v-model="curTab">
<el-tab-pane v-for="tab in tabs" :key="tab.name" v-bind="tab" lazy>
<ai-card class="mar-t16" panel v-if="curTab==tab.name">
<ai-search-bar> <ai-search-bar>
<template #left> <template #left>
<el-select v-model="search.department" placeholder="请选择所属部门" @change="page.current=1,getList()" <ai-select v-model="search.department" placeholder="请选择所属部门" @change="page.current=1,getList()" dict="hbDepartment"/>
size="small" clearable> <ai-select v-model="search.department" placeholder="请选择所属分类" @change="page.current=1,getList()" :selectList="classList"
<el-option :prop="{label:'name'}"/>
v-for="(item,i) in dict.getDict('hbDepartment')" :key="i"
:label="item.dictName"
:value="item.dictValue">
</el-option>
</el-select>
<el-select v-model="search.classificationId" placeholder="请选择所属分类" @change="page.current=1,getList()"
size="small" clearable>
<el-option
v-for="(item,i) in classList" :key="i"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</template> </template>
<template #right> <template #right>
<el-input <el-input
@@ -34,7 +25,7 @@
</ai-search-bar> </ai-search-bar>
<ai-search-bar> <ai-search-bar>
<template #left> <template #left>
<el-button type="primary" icon="iconfont iconAdd" @click="goPage(tab.value==0 ? 'addConfig':'guidance')">添加{{tab.value==0?'事项':'办事指南'}}</el-button> <el-button type="primary" icon="iconfont iconAdd" @click="goPage()">添加{{ curTab == 'add' ? '事项' : '办事指南' }}</el-button>
</template> </template>
</ai-search-bar> </ai-search-bar>
<ai-table <ai-table
@@ -44,6 +35,7 @@
:total="page.total" :total="page.total"
:current.sync="page.current" :current.sync="page.current"
:size.sync="page.size" :size.sync="page.size"
:dict="dict"
@getList="getList"> @getList="getList">
<el-table-column label="是否启用" slot="processDefStatus" align="center" width="150"> <el-table-column label="是否启用" slot="processDefStatus" align="center" width="150">
<template v-slot="{row}"> <template v-slot="{row}">
@@ -58,19 +50,22 @@
<el-table-column label="操作" slot="options" align="center" width="150"> <el-table-column label="操作" slot="options" align="center" width="150">
<template v-slot="{row}"> <template v-slot="{row}">
<div class="table-options"> <div class="table-options">
<el-button type="text" title="编辑" @click="goPage(tab.value==0 ? 'addConfig':'guidance',row)">编辑</el-button> <el-button type="text" title="编辑" @click="goPage(row.id)">编辑</el-button>
<el-button type="text" title="删除" @click="delInfo(row)">删除</el-button> <el-button type="text" title="删除" @click="delInfo(row)">删除</el-button>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
</ai-table> </ai-table>
</ai-card>
</el-tab-pane>
</el-tabs>
</template> </template>
</ai-list> </ai-list>
</div> </div>
</template> </template>
<script> <script>
import day from 'dayjs' import {confirm} from "dui/lib/js/decorator";
export default { export default {
name: "configList", name: "configList",
@@ -92,55 +87,31 @@
row: {}, row: {},
tableData: [], tableData: [],
classList: [], classList: [],
curTab: "add",
tabs: [
{label: "网上办事", value: "0", name: "add"},
{label: "办事指南", value: "2", name: "guidance"},
]
} }
}, },
computed: { computed: {
currentTab: v => v.tabs.find(e => e.name == v.curTab),
colConfigs() { colConfigs() {
return [ return [
{ {prop: 'processName', align: 'left', label: '事项名称'},
prop: 'processName', {prop: 'department', align: 'left', label: '所属部门', dict: "hbDepartment"},
align: 'left', {prop: 'classificationName', align: 'center', label: '所属分类',},
label: '事项名称', {prop: 'timeLimit', align: 'center', label: '办结时限(日)',},
}, {prop: 'createUserName', align: 'center', label: '创建人',},
{ {prop: 'createTime', align: 'center', label: '最后修改时间', format: 'YYYY-MM-DD HH:mm'},
prop: 'department',
align: 'left',
label: '所属部门',
render: (h, {row}) => [ < span > {this.dict.getLabel('hbDepartment', row.department)} < /span>]
},
{
prop: 'classificationName',
align: 'center',
label: '所属分类',
},
{
prop: 'timeLimit',
align: 'center',
label: '办结时限(日)',
},
{
prop: 'createUserName',
align: 'center',
label: '创建人',
},
{
prop: 'createTime',
align: 'center',
label: '最后修改时间',
render: (h, {row}) => [ < span > {day(row.createTime
).
format("YYYY-MM-DD HH:mm")
}<
/span>]
},
{slot: 'processDefStatus', align: 'center', label: '是否启用',}, {slot: 'processDefStatus', align: 'center', label: '是否启用',},
{slot: 'options', align: 'center', label: '操作',}, {slot: 'options', align: 'center', label: '操作',},
].filter(e=>this.tab.value==0 ? true : (e.prop!="timeLimit")) ].filter(e => this.curTab == 'add' ? true : (e.prop != "timeLimit"))
}, },
}, },
methods: { methods: {
goPage(comp, row = {}) { goPage(id) {
this.$emit("goPage", {comp, row}) this.$router.push({query: {id}, hash: `#${this.curTab}`})
}, },
/** /**
* 获取分类 * 获取分类
@@ -158,18 +129,14 @@
} }
}) })
}, },
/** @confirm("是否删除?")
* 删除
* */
delInfo({id}) { delInfo({id}) {
this.$confirm("是否删除").then(() => {
this.instance.post(`/app/approval-process-def/delete?id=${id}`).then(res => { this.instance.post(`/app/approval-process-def/delete?id=${id}`).then(res => {
if (res.code == 0) { if (res.code == 0) {
this.$message.success("删除成功") this.$message.success("删除成功")
this.getList() this.getList()
} }
}) })
})
}, },
/** /**
* 启用,停用 * 启用,停用
@@ -190,7 +157,7 @@
params: { params: {
...this.page, ...this.page,
...this.search, ...this.search,
processType: this.tab.value processType: this.currentTab.value
}, },
}).then(res => { }).then(res => {
if (res?.data) { if (res?.data) {