组织换届重构完成

This commit is contained in:
aixianling
2022-10-27 18:07:02 +08:00
parent a477039f7c
commit 31cbb5d2bf
7 changed files with 207 additions and 445 deletions

View File

@@ -8,7 +8,6 @@
<script> <script>
import {mapState} from "vuex"; import {mapState} from "vuex";
import addChange from "./components/addChange.vue";
import List from "./components/List.vue"; import List from "./components/List.vue";
import organizationSetting from "./components/organizationSetting.vue"; import organizationSetting from "./components/organizationSetting.vue";
@@ -27,7 +26,6 @@ export default {
}, },
components: { components: {
List, List,
addChange,
organizationSetting, organizationSetting,
}, },
computed: { computed: {
@@ -35,8 +33,6 @@ export default {
currentPage() { currentPage() {
const {hash} = this.$route const {hash} = this.$route
if (["#add","#makeup"].includes(hash)) { if (["#add","#makeup"].includes(hash)) {
return addChange
} else if (hash == "#setting") {
return organizationSetting return organizationSetting
} else return List } else return List
} }

View File

@@ -1,7 +1,12 @@
<template> <template>
<ai-list class="List"> <ai-list class="List">
<template slot="title"> <template slot="title">
<ai-title title="组织换届" isShowBottomBorder/> <ai-title title="组织换届" isShowBottomBorder>
<template #rightBtn>
<el-button size="small" type="primary" @click="toAdd(selected.id)" v-if="!hasConfig&&permissions('app_apporganizationchangeconfig')">换届设置
</el-button>
</template>
</ai-title>
</template> </template>
<template #left> <template #left>
<ai-tree-menu title="组织目录" searchPlaceholder="请输入组织名称" @search="onSearch"> <ai-tree-menu title="组织目录" searchPlaceholder="请输入组织名称" @search="onSearch">
@@ -15,14 +20,9 @@
</ai-tree-menu> </ai-tree-menu>
</template> </template>
<template slot="content" class="content"> <template slot="content" class="content">
<ai-title title="届次信息">
<template #rightBtn>
<el-button size="small" type="primary" @click="toSetting(selected.id)" v-if="permissions('app_apporganizationchangeconfig')">换届设置</el-button>
</template>
</ai-title>
<el-tabs v-model="currIndex"> <el-tabs v-model="currIndex">
<el-tab-pane v-for="(tab,i) in tabs" :key="i" :label="tab.label"> <el-tab-pane v-for="(tab,i) in tabs" :key="i" :label="tab.label">
<component :ref="tab.name" v-if="currIndex==i" :is="tab.comp" lazy :selected="selected" v-on="$listeners"/> <component :ref="tab.name" v-if="currIndex==i" :is="tab.comp" lazy :selected="selected" v-on="$listeners" :hasConfig.sync="hasConfig"/>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</template> </template>
@@ -44,7 +44,8 @@ export default {
{label: '历史届次', name: 'history', comp: history, permission: ''} {label: '历史届次', name: 'history', comp: history, permission: ''}
], ],
currIndex: '0', currIndex: '0',
selected: null selected: null,
hasConfig: false
} }
}, },
components: { components: {
@@ -57,7 +58,6 @@ export default {
methods: { methods: {
onTreeChange(e) { onTreeChange(e) {
this.selected = e this.selected = e
this.$refs[this.tabs[Number(this.currIndex)].name][0].getList(e.id)
}, },
onSearch(v) { onSearch(v) {
this.$refs.tree?.$refs?.partyTree?.filter(v) this.$refs.tree?.$refs?.partyTree?.filter(v)
@@ -66,12 +66,9 @@ export default {
if (!value) return true if (!value) return true
return data.name.indexOf(value) !== -1 return data.name.indexOf(value) !== -1
}, },
toAdd(id) { toAdd(oid) {
this.$router.push({hash: "#add", query: {id}}) this.$router.push({hash: "#add", query: {oid}})
}, },
toSetting(oid) {
this.$router.push({hash: "#setting", query: {oid, new: 1}})
}
}, },
created() { created() {
const {organizationId: id, organizationName: name} = this.user.info const {organizationId: id, organizationName: name} = this.user.info

View File

@@ -1,150 +0,0 @@
<template>
<section class="addChange">
<ai-detail>
<ai-title slot="title" :title="pageTitle" isShowBottomBorder isShowBack @onBackClick="cancel(false)"/>
<template #content>
<ai-card title="基本信息">
<template #content>
<div class="Form">
<el-form ref="form" :model="form" :rules="rules" label-width="100px" label-position="right" size="small">
<el-row type="flex">
<el-form-item class="fill" label="换届时间" prop="changeTime">
<el-date-picker v-model="form.changeTime" value-format="yyyy-MM-dd" type="date" placeholder="选择日期" style="width:338px">
</el-date-picker>
</el-form-item>
<el-form-item class="fill" label="届次" prop="sessionTime">
<el-input size="small" :maxlength="30" placeholder="请输入届次" v-model="form.sessionTime"></el-input>
</el-form-item>
</el-row>
<ai-title title="本届任职(必填)">
<template slot="rightBtn">
<el-button size="small" type="text" icon="iconfont iconAdd" @click="form.serveList.push({name:null,position:null,type:0})">添加任职人员
</el-button>
</template>
</ai-title>
<el-table :data="form.serveList" size="mini" border stripe>
<el-table-column label="职位" align="center">
<template slot-scope="{row}">
<el-input class="tableInput" v-model="row.position" clearable placeholder="请输入职位"/>
</template>
</el-table-column>
<el-table-column label="姓名" align="center">
<template slot-scope="{row}">
<el-input class="tableInput" v-model="row.name" clearable placeholder="请输入姓名"/>
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="{$index}">
<el-button type="text" @click="handleDelete($index, 'serveList')">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form>
<ai-title class="mar-t8" title="本届候选人">
<template slot="rightBtn">
<el-button size="small" type="text" icon="iconfont iconAdd" @click="form.candidateList.push({name:null,position:null,type: 1})">添加候选人
</el-button>
</template>
</ai-title>
<el-table :data="form.candidateList" size="mini" border stripe>
<el-table-column label="职位" align="center">
<template slot-scope="{row}">
<el-input class="tableInput" v-model="row.position" clearable placeholder="请输入职位"/>
</template>
</el-table-column>
<el-table-column label="候选人" align="center">
<template slot-scope="{row}">
<el-input class="tableInput" v-model="row.name" clearable placeholder="请输入姓名"/>
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="{$index}">
<el-button type="text" @click="handleDelete($index, 'candidateList')">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
</template>
</ai-card>
</template>
<template slot="footer" class="footer">
<el-button class="delete-btn footer-btn" @click="cancel(false)">取消</el-button>
<el-button class="footer-btn" type="primary" @click="confirm()">保存</el-button>
</template>
</ai-detail>
</section>
</template>
<script>
export default {
name: "addChange",
props: {
instance: Function,
permissions: Function,
dict: Object,
},
computed: {
isMakeUp: v => v.$route.hash == "#makeup",
pageTitle: v => v.isMakeUp ? "补录换届" : "新增换届"
},
data() {
return {
form: {
changeTime: '',
sessionTime: '',
serveList: [], // 任职人员列表
candidateList: [], // 候选人员列表
},
rules: {
changeTime: [{required: true, message: '请选择换届时间', trigger: 'blur'}],
sessionTime: [{required: true, message: '请输入届次', trigger: 'blur'}],
},
}
},
methods: {
// getDetail() {
// const {id: organizationId} = this.$route.query
// organizationId && this.instance.post(`/app/apporganizationgeneralelection/queryDetailByOrganizationId`, null, {
// params: {organizationId}
// }).then(res => {
// if (res?.data) {
// this.form = res.data
// }
// })
// },
cancel(refresh) {
refresh ? this.$router.push({}) : this.$router.back()
},
handleDelete(i, type) {
this.$confirm("确定要删除该数据?").then(() => {
if (type == 'candidateList') {
this.form.candidateList.splice(i, 1)
} else if (type == 'serveList') {
this.form.serveList.splice(i, 1)
}
}).catch(() => 0)
},
confirm() {
this.$refs.form.validate((valid) => {
if (valid) {
const addOrMakeup = !this.isMakeUp
this.instance.post(`/app/apporganizationgeneralelection/add`, {
...this.form, addOrMakeup
}).then(res => {
if (res.code == 0) {
this.$message.success('提交成功')
this.cancel(true)
}
})
}
})
},
}
}
</script>
<style lang="scss" scope>
.addChange {
height: 100%;
}
</style>

View File

@@ -1,35 +1,37 @@
<template> <template>
<section class="detailPanel"> <section class="detailPanel">
<div class="itemTitle"> <ai-title :title="`本届任职${!disabled?'(必填)':''}`">
<b>本届任职{{editable?"(必填)":""}}</b> <template #rightBtn v-if="!disabled">
<span type="text" class="iconfont iconAdd" @click="showDialog({type:0})">添加任职人员</span> <el-button type="text" icon="iconfont iconAdd" @click="showDialog({type:0})">添加任职人员</el-button>
</div> </template>
<el-table :data="serveList" border header-cell-class-name="table-header" cell-class-name="table-cell"> </ai-title>
<el-table :data="serveList" border size="small">
<el-table-column label="职位" width="180px" prop="position"/> <el-table-column label="职位" width="180px" prop="position"/>
<el-table-column label="姓名" prop="name"/> <el-table-column label="姓名" prop="name"/>
<el-table-column label="操作" width="120px" align="center"> <el-table-column label="操作" width="200px" align="center" v-if="!disabled">
<div slot-scope="{row,$index}" class="table-operation"> <div slot-scope="{row,$index}" class="table-operation">
<span class="iconfont iconEdit" @click="showDialog(row,$index)" title="编辑"/> <el-button type="text" @click="showDialog(row,$index)">编辑</el-button>
<span class="iconfont iconDelete" title="删除" @click="deleteItem($index,0)"/> <el-button type="text" @click="deleteItem($index,0)">删除</el-button>
</div> </div>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div class="itemTitle"> <ai-title title="本届候选人">
<b>本届候选人</b> <template #rightBtn v-if="!disabled">
<span type="text" class="iconfont iconAdd" @click="showDialog({type:1})">添加候选人</span> <el-button type="text" icon="iconfont iconAdd" @click="showDialog({type:1})">添加候选人</el-button>
</div> </template>
<el-table :data="candidateList" border header-cell-class-name="table-header" cell-class-name="table-cell"> </ai-title>
<el-table :data="candidateList" border size="small">
<el-table-column label="职位" width="180px" prop="position"/> <el-table-column label="职位" width="180px" prop="position"/>
<el-table-column label="候选人" prop="name"/> <el-table-column label="候选人" prop="name"/>
<el-table-column label="操作" width="120px" align="center"> <el-table-column label="操作" width="200px" align="center" v-if="!disabled">
<div slot-scope="{row,$index}" class="table-operation"> <div slot-scope="{row,$index}" class="table-operation">
<span class="iconfont iconEdit" @click="showDialog(row,$index)" title="编辑"/> <el-button type="text" @click="showDialog(row,$index)">编辑</el-button>
<span class="iconfont iconDelete" title="删除" @click="deleteItem($index,1)"/> <el-button type="text" @click="deleteItem($index,1)">删除</el-button>
</div> </div>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-dialog :visible.sync="dialog.visible" width="520px" :title="dialog.title" class="editStyle" <ai-dialog :visible.sync="dialog.visible" width="520px" :title="dialog.title" class="editStyle"
@close="dialog={visible: false},$refs.editListItemForm.clearValidate()"> @closed="dialog={}" @onConfirm="submitAdd">
<el-form ref="editListItemForm" size="small" :model="dialog" :rules="rules" label-width="100px" <el-form ref="editListItemForm" size="small" :model="dialog" :rules="rules" label-width="100px"
:validate-on-rule-change="false"> :validate-on-rule-change="false">
<el-form-item label="职位:" prop="position"> <el-form-item label="职位:" prop="position">
@@ -42,30 +44,19 @@
<span style="color:#999;font-size: 12px">输入候选人姓名用空格隔开</span> <span style="color:#999;font-size: 12px">输入候选人姓名用空格隔开</span>
</div> </div>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="footerBtns"> </ai-dialog>
<el-button size="small" @click="dialog.visible=false">取消</el-button>
<el-button size="small" type="primary" @click="submitAdd">确认</el-button>
</div>
</el-dialog>
</section> </section>
</template> </template>
<script> <script>
export default { export default {
name: "detailPanel", name: "detailPanel",
model: {
prop: "value",
event: "change"
},
props: { props: {
value: Object, candidateList: {default: () => []},
instance: Function, serveList: {default: () => []},
dict: Object, disabled: Boolean
permissions: Function,
editable: {type: Boolean, default: false}
}, },
data() { data() {
return { return {
@@ -74,15 +65,10 @@
title: "", title: "",
name: "", name: "",
changeTime: "" changeTime: ""
}, }
serveList: [],
candidateList: []
} }
}, },
computed: { computed: {
lists() {
return {candidateList: this.candidateList, serveList: this.serveList}
},
currentList() { currentList() {
let initData = { let initData = {
0: {name: "姓名", dialogTitle: "本届任职人", list: "serveList"}, 0: {name: "姓名", dialogTitle: "本届任职人", list: "serveList"},
@@ -97,62 +83,43 @@
} }
}, },
}, },
watch: {
lists: {
deep: true,
handler() {
this.$emit('change', this.lists)
}
},
value: {
deep: true,
handler(v) {
if (v) {
v.candidateList && (this.candidateList = v.candidateList)
v.serveList && (this.serveList = v.serveList)
}
}
}
},
methods: { methods: {
showDialog(v, rowIndex) { showDialog(v, rowIndex) {
this.dialog = {...this.dialog, ...v, rowIndex} this.dialog = {...this.dialog, ...v, rowIndex}
this.dialog.title = (this.dialog.rowIndex==0? "编辑" : "添加") + this.currentList.dialogTitle this.dialog.title = (this.dialog.rowIndex == 0 ? "编辑" : "添加") + this.currentList.dialogTitle
this.dialog.visible = true this.dialog.visible = true
}, },
submitAdd() { submitAdd() {
this.$refs.editListItemForm.validate(v => { this.$refs.editListItemForm.validate(v => {
if (v) { if (v) {
this.handleData(this.currentList.list, list => {
if (this.dialog.rowIndex > -1) { if (this.dialog.rowIndex > -1) {
this.$data[this.currentList.list].splice(this.dialog.rowIndex, 1, this.dialog) list.splice(this.dialog.rowIndex, 1, this.dialog)
} else this.$data[this.currentList.list].push(this.dialog) } else list.push(this.dialog)
})
this.dialog.visible = false this.dialog.visible = false
this.dialog.rowIndex==undefined ? this.$emit("refresh",1) : this.$emit("refresh",2);
} }
}) })
}, },
deleteItem(index,type) { handleData(prop, cb) {
this.$confirm(`是否要删除该${type==0?'本届任职人':'本届候选人'}`, {type: "error"}).then(() => { const list = this.$copy(this.$data[prop]) || []
type==0?this.$data["serveList"].splice(index, 1):this.$data["candidateList"].splice(index, 1) cb(list)
this.$emit("refresh",0) this.$emit("update:" + prop, list)
},
deleteItem(index, type) {
this.$confirm(`是否要删除该${type == 0 ? '本届任职人' : '本届候选人'}`, {type: "error"}).then(() => {
this.handleData(type == 0 ? "serveList" : "candidateList", list => {
list.splice(index, 1)
})
}).catch(() => { }).catch(() => {
}) })
} }
},
mounted() {
this.$nextTick(() => {
if (this.value) {
let v = JSON.parse(JSON.stringify(this.value))
v.candidateList && (this.candidateList = v.candidateList)
v.serveList && (this.serveList = v.serveList)
}
})
}
} }
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.detailPanel { .detailPanel {
.itemTitle + .el-table { .itemTitle + .el-table {
margin-top: 16px; margin-top: 16px;
} }
@@ -186,5 +153,5 @@
padding-left: 10px !important; padding-left: 10px !important;
} }
} }
} }
</style> </style>

View File

@@ -3,7 +3,7 @@
<ai-search-bar> <ai-search-bar>
<template #left> <template #left>
<el-button type="primary" icon="iconfont iconEdit" @click="$router.push({hash:'#makeup',query:{}})">补录</el-button> <el-button type="primary" icon="iconfont iconEdit" @click="$router.push({hash:'#makeup',query:{oid}})">补录</el-button>
</template> </template>
<template #right> <template #right>
<el-input size="small" placeholder="请输入届次" v-model="search.name" clearable <el-input size="small" placeholder="请输入届次" v-model="search.name" clearable
@@ -49,6 +49,14 @@ export default {
}, },
oid: v => v.$attrs.selected.id oid: v => v.$attrs.selected.id
}, },
watch: {
oid: {
immediate: true,
handler() {
this.getList()
}
}
},
methods: { methods: {
handleEdit(id) { handleEdit(id) {
this.$router.push({hash: "#makeup", query: {id}}) this.$router.push({hash: "#makeup", query: {id}})
@@ -67,7 +75,7 @@ export default {
}, },
getList() { getList() {
const {oid: organizationId} = this const {oid: organizationId} = this
this.instance.post("/app/apporganizationgeneralelection/list", null, { organizationId && this.instance.post("/app/apporganizationgeneralelection/list", null, {
params: {...this.search, organizationId} params: {...this.search, organizationId}
}).then(res => { }).then(res => {
if (res?.data) { if (res?.data) {
@@ -76,9 +84,6 @@ export default {
}) })
} }
}, },
created() {
this.getList()
},
} }
</script> </script>

View File

@@ -1,90 +1,31 @@
<template> <template>
<section class="moment"> <section class="moment">
<template v-if="detail.id"> <template v-if="detail.id">
<ai-title title="总体概况" class="mar-b8"> <ai-title :title="detail.organizationName||'基本信息'" class="mar-b8"/>
<template slot="rightBtn">
<el-button size="small" type="text" icon="iconfont iconEdit" @click="toEdit(oid)">修改</el-button>
</template>
</ai-title>
<ai-wrapper> <ai-wrapper>
<ai-info-item label="本届换届时间" :value="detail.changeTime"/> <ai-info-item label="本届换届时间" :value="detail.changeTime"/>
<ai-info-item label="换届类型" :value="dict.getLabel('organizationChangeType',detail.type)"/> <ai-info-item label="换届类型" :value="dict.getLabel('organizationChangeType',detail.type)"/>
<ai-info-item label="下届换届时间" :value="detail.nextChangeTime"/> <ai-info-item label="下届换届时间" :value="detail.nextChangeTime"/>
<ai-info-item label="当前届次" :value="detail.sessionTime"/> <ai-info-item label="当前届次" :value="detail.sessionTime"/>
</ai-wrapper> </ai-wrapper>
<ai-title title="本届任职" class="mar-b8"> <detail-panel :candidate-list="detail.candidateList" :serve-list="detail.serveList" disabled/>
<template slot="rightBtn">
<el-button size="small" type="text" icon="iconfont iconAdd" @click="dialogJob=true">添加任职人员</el-button>
</template> </template>
</ai-title> <ai-empty v-else>
<ai-table
class="detail-table__table"
:tableData="tableData"
:col-configs="colConfigs"
:total="totalJob"
:current.sync="current"
:size.sync="size"
@getList="getJobList">
<el-table-column slot="options" label="操作" align="center">
<template slot-scope="{ row }">
<el-button type="text" @click="jobEdit(row.id)">编辑</el-button>
<el-button type="text" @click="jobDelete(row.id)">删除</el-button>
</template>
</el-table-column>
</ai-table>
<ai-title title="本届候选人" class="mar-b8">
<template slot="rightBtn">
<el-button size="small" type="text" icon="iconfont iconAdd" @click="dialogCandidate = true">添加候选人</el-button>
</template>
</ai-title>
<ai-table
class="detail-table__table"
:tableData="tableData"
:col-configs="colConfigs"
:total="totalJob"
:current.sync="current"
:size.sync="size"
@getList="getJobList">
<el-table-column slot="options" label="操作" align="center">
<template slot-scope="{ row }">
<el-button type="text" @click="jobEdit(row.id)">编辑</el-button>
<el-button type="text" @click="jobDelete(row.id)">删除</el-button>
</template>
</el-table-column>
</ai-table>
</template>
<ai-empty>
<div>暂无换届信息</div> <div>暂无换届信息</div>
<el-row type="flex" justify="center" class="mar-t8"> <el-row type="flex" justify="center" class="mar-t8">
<ai-highlight content="请点击【@v】完善基础内容后,再进行后续操作" value="换届设置"/> <ai-highlight content="请点击【@v】完善基础内容后,再进行后续操作" value="开始设置"/>
</el-row> </el-row>
<el-button class="mar-t32" type="primary" @click="$router.push({hash:'#add',query:{oid,new:1}})">开始设置</el-button>
</ai-empty> </ai-empty>
<ai-dialog :visible.sync="dialogJob" title="添加本届任职人" width="720px" @closed="jobForm={}" @onConfirm="handleJobForm">
<el-form ref="jobForm" size="small" :model="jobForm" :rules="jobRules" label-width="80px">
<el-form-item label="职位" prop="job">
<el-input v-model="jobForm.job" clearable placeholder="请输入"/>
</el-form-item>
<el-form-item label="姓名" prop="name">
<el-input v-model="jobForm.name" clearable placeholder="请输入"/>
</el-form-item>
</el-form>
</ai-dialog>
<ai-dialog :visible.sync="dialogCandidate" title="添加本届候选人" width="720px" @closed="CandFrom={}" @onConfirm="handleCandForm">
<el-form ref="CandFrom" size="small" :model="CandFrom" :rules="candRules" label-width="80px">
<el-form-item label="职位" prop="job">
<el-input v-model="CandFrom.job" clearable placeholder="请输入"/>
</el-form-item>
<el-form-item label="候选人" prop="name">
<el-input type="textarea" rows="5" v-model="CandFrom.name" placeholder="请输入候选人姓名,用逗号隔开"/>
</el-form-item>
</el-form>
</ai-dialog>
</section> </section>
</template> </template>
<script> <script>
import DetailPanel from "./detailPanel";
export default { export default {
name: "moment", name: "moment",
components: {DetailPanel},
inject: ['permissions', 'instance', 'dict'], inject: ['permissions', 'instance', 'dict'],
data() { data() {
return { return {
@@ -113,47 +54,31 @@ export default {
{slot: 'options'}, {slot: 'options'},
] ]
}, },
jobRules() {
return {
job: [{required: true, message: "请输入职位"}],
name: [{required: true, message: "请输入姓名"}],
}
},
candRules() {
return {
job: [{required: true, message: "请输入职位"}],
name: [{required: true, message: "请输入姓名"}],
}
},
oid: v => v.$attrs.selected.id oid: v => v.$attrs.selected.id
}, },
created() { watch: {
this.getList() oid: {
immediate: true,
handler() {
this.getDetail()
}
}
}, },
methods: { methods: {
jobEdit() { getDetail() {
},
jobDelete() {
},
getJobList() {
},
toEdit(id) {
this.$router.push({hash: "#add", query: {id}})
},
getList() {
const {oid: organizationId} = this const {oid: organizationId} = this
organizationId && this.instance.post(`/app/apporganizationgeneralelection/queryDetailByOrganizationId`, null, { organizationId && this.instance.post(`/app/apporganizationgeneralelection/queryDetailByOrganizationId`, null, {
params: {organizationId} params: {organizationId}
}).then(res => { }).then(res => {
if (res?.data) { if (res?.data) {
this.detail = res.data this.detail = res.data
this.$emit("update:hasConfig")
} }
}) })
}, },
handleJobForm() {
},
handleCandForm() {
}, },
created() {
this.dict.load("organizationChangeType")
} }
} }
</script> </script>

View File

@@ -1,10 +1,10 @@
<template> <template>
<section class="organizationSetting"> <section class="organizationSetting">
<ai-detail> <ai-detail>
<ai-title slot="title" title="换届设置" isShowBottomBorder isShowBack @onBackClick="cancel(true)"/> <ai-title slot="title" :title="pageTitle" isShowBottomBorder isShowBack @onBackClick="cancel(true)"/>
<template slot="content"> <template slot="content">
<el-form ref="SettingForm" :model="form" :rules="formRules" size="small" label-width="150px"> <el-form ref="SettingForm" :model="form" :rules="formRules" size="small" label-width="150px">
<ai-card title="基本信息"> <ai-card title="基本信息" v-if="!isMakeUp">
<template #content> <template #content>
<div class="tips"> <div class="tips">
<i class="el-icon-warning"></i> <i class="el-icon-warning"></i>
@@ -27,17 +27,21 @@
</el-form-item> </el-form-item>
</template> </template>
</ai-card> </ai-card>
<ai-card v-if="isInit" title="届次设置"> <ai-card title="当前届次">
<el-form-item label="本届换届时间:" prop="changeTime"> <template #content>
<el-date-picker v-model="form.changeTime"/> <div flex>
<el-form-item class="fill" label="本届换届时间" prop="changeTime">
<el-date-picker v-model="form.changeTime" @change="getNextChangeTime" value-format="yyyy-MM-dd"/>
</el-form-item> </el-form-item>
<el-form-item label="下届换届时间" prop="nextChangeTime"> <el-form-item class="fill" label="下届换届时间" prop="nextChangeTime">
<el-date-picker disabled v-model="form.nextChangeTime"/> <el-date-picker disabled v-model="form.nextChangeTime"/>
</el-form-item> </el-form-item>
<el-form-item label="届次:" prop="sessionTime"> </div>
<el-form-item label="届次" prop="sessionTime">
<el-input v-model="form.sessionTime" placeholder="请输入..."/> <el-input v-model="form.sessionTime" placeholder="请输入..."/>
</el-form-item> </el-form-item>
<detail-panel :instance="instance" v-model="lists" editable/> <detail-panel :serve-list.sync="form.serveList" :candidate-list.sync="form.candidateList"/>
</template>
</ai-card> </ai-card>
</el-form> </el-form>
</template> </template>
@@ -59,28 +63,22 @@ export default {
components: {DetailPanel}, components: {DetailPanel},
inject: ['permissions', 'instance', 'dict'], inject: ['permissions', 'instance', 'dict'],
data() { data() {
let validUser = (rule, value, callback) => {
if (!value.length) {
return callback(new Error('请选择换届提醒人'));
} else {
callback();
}
};
return { return {
form: { form: {
type: "", type: "",
userList: [], userList: [],
sessionTime: "", sessionTime: "",
changeTime: "", changeTime: "",
nextChangeTime: "" nextChangeTime: "",
}, serveList: [],
lists: { candidateList: []
candidateList: [], //本届候选人
serveList: [] //本届任职
}, },
formRules: { formRules: {
type: [{required: true, message: "请选择选举方式", trigger: "blur"}], type: [{required: true, message: "请选择换届类型", trigger: "change"}],
userList: [{required: true, validator: validUser, trigger: "blur"}], sessionTime: [{required: true, message: "请输入届次", trigger: "change"}],
userList: [{required: true, message: "请选择换届提醒人", trigger: "change"}],
changeTime: [{required: true, message: "请选择本次换届时间", trigger: "change"}],
nextChangeTime: [{required: true, message: "请选择下次换届时间", trigger: "change"}]
}, },
chooseUserList: [], chooseUserList: [],
org: null org: null
@@ -88,26 +86,47 @@ export default {
}, },
computed: { computed: {
...mapState(['user']), ...mapState(['user']),
isInit: v => !!v.form.id, isMakeUp: v => v.$route.hash == "#makeup",
isNew: v => v.$route.query.new pageTitle: v => v.isMakeUp ? "补录换届" : "换届设置"
},
watch: {
'form.type'() {
this.getNextChangeTime()
}
}, },
created() { created() {
this.org = new this.MODEL.PartyOrg(this.$route.query.oid) this.org = new this.MODEL.PartyOrg(this.$route.query.oid)
!this.isNew && this.getDetail() !!this.$route.query.id ? this.getSession() : this.getDetail()
}, },
methods: { methods: {
cancel() { cancel() {
this.$router.back() this.$router.back()
}, },
getNextChangeTime() {
const {type, changeTime} = this.form, sessionPeriod = {0: 3, 1: 5}[type]
this.form.nextChangeTime = type && changeTime ? this.$dateFormat(this.$moment(changeTime).add(sessionPeriod, "years")) : ""
},
getSession() {
//根据id获取对应届次信息
const {id} = this.$route.query
this.instance.post(`/app/apporganizationchangeconfig/queryDetailById`, null, {
pureBack: true,
params: {id}
}).then((res) => {
if (res?.data) {
this.form = res.data
}
})
},
getDetail() { getDetail() {
//获取到当前届次信息
const {oid: organizationId} = this.$route.query const {oid: organizationId} = this.$route.query
this.instance.post(`/app/apporganizationchangeconfig/queryDetailByOrganizationId`, null, { this.instance.post(`/app/apporganizationchangeconfig/queryDetailByOrganizationId`, null, {
pureBack: true,
params: {organizationId} params: {organizationId}
}).then((res) => { }).then((res) => {
if (res?.data) { if (res?.data) {
this.form = res.data this.form = res.data
let {candidateList, serveList} = this.form
this.lists = {candidateList, serveList}
} }
}) })
}, },
@@ -122,10 +141,13 @@ export default {
this.$refs.SettingForm.validate(v => { this.$refs.SettingForm.validate(v => {
if (v) { if (v) {
const {id: organizationId, name: organizationName} = this.org const {id: organizationId, name: organizationName} = this.org
const action = `/app/apporganizationchangeconfig/${this.isInit ? 'update' : 'add'}` if (this.isMakeUp && !this.$route.query.id) {
delete this.form.id
}
const action = `/app/apporganizationchangeconfig/${!!this.form.id ? 'update' : 'add'}`
const addOrMakeup = !this.isMakeUp
this.instance.post(action, { this.instance.post(action, {
addOrMakeup: true, ...this.form, organizationId, organizationName, addOrMakeup
...this.form, organizationId, organizationName
}).then(res => { }).then(res => {
if (res.code == 0) { if (res.code == 0) {
this.$message.success('提交成功') this.$message.success('提交成功')
@@ -143,8 +165,8 @@ export default {
.organizationSetting { .organizationSetting {
height: 100%; height: 100%;
::v-deep .el-date-editor .el-input { .el-date-editor, .el-input {
width: 100%; width: 100% !important;
} }
.tips { .tips {