Files
dvcp_v2_webapp/project/pingchang/apps/AppOrganizationChange/components/addChange.vue

147 lines
5.7 KiB
Vue
Raw Normal View History

2022-10-14 11:36:06 +08:00
<template>
2022-10-18 16:48:27 +08:00
<section class="addChange">
<ai-detail>
2022-10-21 11:53:29 +08:00
<ai-title slot="title" title="新增换届" isShowBottomBorder isShowBack @onBackClick="cancel(false)"/>
2022-10-18 16:48:27 +08:00
<template #content>
<ai-card title="基本信息">
<template #content>
<div class="Form">
2022-10-21 11:53:29 +08:00
<el-form ref="form" :model="form" :rules="rules" label-width="100px" label-position="right" size="small">
2022-10-18 16:48:27 +08:00
<el-row type="flex">
2022-10-21 11:53:29 +08:00
<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>
2022-10-18 16:48:27 +08:00
</el-row>
2022-10-21 11:53:29 +08:00
<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>
2022-10-18 16:48:27 +08:00
</template>
2022-10-21 11:53:29 +08:00
</ai-title>
2022-10-18 16:48:27 +08:00
<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}">
2022-10-21 11:53:29 +08:00
<el-input class="tableInput" v-model="row.name" clearable placeholder="请输入姓名"/>
2022-10-18 16:48:27 +08:00
</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>
2022-10-21 11:53:29 +08:00
<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>
2022-10-18 16:48:27 +08:00
</template>
2022-10-21 11:53:29 +08:00
</ai-title>
2022-10-18 16:48:27 +08:00
<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}">
2022-10-21 11:53:29 +08:00
<el-input class="tableInput" v-model="row.name" clearable placeholder="请输入姓名"/>
2022-10-18 16:48:27 +08:00
</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>
2022-10-18 15:56:46 +08:00
</template>
2022-10-18 16:48:27 +08:00
</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>
2022-10-14 11:36:06 +08:00
</template>
<script>
export default {
name: "addChange",
props: {
instance: Function,
permissions: Function,
dict: Object,
},
2022-10-14 17:32:19 +08:00
data() {
return {
form: {
2022-10-18 16:48:27 +08:00
addOrMakeup: true,
changeTime: '',
sessionTime: '',
serveList: [], // 任职人员列表
candidateList: [], // 候选人员列表
},
rules: {
2022-10-21 11:53:29 +08:00
changeTime: [{required: true, message: '请选择换届时间', trigger: 'blur'}],
sessionTime: [{required: true, message: '请输入届次', trigger: 'blur'}],
2022-10-17 11:09:47 +08:00
},
}
},
2022-10-14 17:32:19 +08:00
methods: {
2022-10-21 18:10:58 +08:00
// 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
// }
// })
// },
2022-10-21 11:53:29 +08:00
cancel() {
this.$router.push({})
2022-10-18 16:48:27 +08:00
},
handleDelete(i, type) {
this.$confirm("确定要删除该数据?").then(() => {
2022-10-21 11:53:29 +08:00
if (type == 'candidateList') {
2022-10-18 16:48:27 +08:00
this.form.candidateList.splice(i, 1)
2022-10-21 11:53:29 +08:00
} else if (type == 'serveList') {
2022-10-18 16:48:27 +08:00
this.form.serveList.splice(i, 1)
}
}).catch(() => 0)
},
confirm() {
this.$refs.form.validate((valid) => {
2022-10-21 11:53:29 +08:00
if (valid) {
2022-10-18 16:48:27 +08:00
this.instance.post(`/app/apporganizationgeneralelection/add`, {
...this.form
2022-10-21 11:53:29 +08:00
}).then(res => {
if (res.code == 0) {
2022-10-18 17:50:46 +08:00
this.$message.success('提交成功')
this.cancel(true)
2022-10-18 16:48:27 +08:00
}
})
}
})
},
2022-10-14 17:32:19 +08:00
}
2022-10-14 11:36:06 +08:00
}
</script>
<style lang="scss" scope>
2022-10-18 16:48:27 +08:00
.addChange {
height: 100%;
}
2022-10-21 11:53:29 +08:00
</style>