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

158 lines
4.9 KiB
Vue
Raw Normal View History

2022-10-24 16:13:01 +08:00
<template>
<section class="detailPanel">
2022-10-27 18:07:02 +08:00
<ai-title :title="`本届任职${!disabled?'(必填)':''}`">
<template #rightBtn v-if="!disabled">
<el-button type="text" icon="iconfont iconAdd" @click="showDialog({type:0})">添加任职人员</el-button>
</template>
</ai-title>
<el-table :data="serveList" border size="small">
2022-10-24 16:13:01 +08:00
<el-table-column label="职位" width="180px" prop="position"/>
<el-table-column label="姓名" prop="name"/>
2022-10-27 18:07:02 +08:00
<el-table-column label="操作" width="200px" align="center" v-if="!disabled">
2022-10-24 16:13:01 +08:00
<div slot-scope="{row,$index}" class="table-operation">
2022-10-27 18:07:02 +08:00
<el-button type="text" @click="showDialog(row,$index)">编辑</el-button>
<el-button type="text" @click="deleteItem($index,0)">删除</el-button>
2022-10-24 16:13:01 +08:00
</div>
</el-table-column>
</el-table>
2022-10-27 18:07:02 +08:00
<ai-title title="本届候选人">
<template #rightBtn v-if="!disabled">
<el-button type="text" icon="iconfont iconAdd" @click="showDialog({type:1})">添加候选人</el-button>
</template>
</ai-title>
<el-table :data="candidateList" border size="small">
2022-10-24 16:13:01 +08:00
<el-table-column label="职位" width="180px" prop="position"/>
<el-table-column label="候选人" prop="name"/>
2022-10-27 18:07:02 +08:00
<el-table-column label="操作" width="200px" align="center" v-if="!disabled">
2022-10-24 16:13:01 +08:00
<div slot-scope="{row,$index}" class="table-operation">
2022-10-27 18:07:02 +08:00
<el-button type="text" @click="showDialog(row,$index)">编辑</el-button>
<el-button type="text" @click="deleteItem($index,1)">删除</el-button>
2022-10-24 16:13:01 +08:00
</div>
</el-table-column>
</el-table>
2022-10-28 11:19:39 +08:00
<ai-dialog :visible.sync="visible" width="520px" :title="dialog.title" class="editStyle"
2022-10-27 18:07:02 +08:00
@closed="dialog={}" @onConfirm="submitAdd">
2022-10-24 16:13:01 +08:00
<el-form ref="editListItemForm" size="small" :model="dialog" :rules="rules" label-width="100px"
:validate-on-rule-change="false">
<el-form-item label="职位:" prop="position">
<el-input v-model="dialog.position" placeholder="请输入..."/>
</el-form-item>
<el-form-item :label="currentList.name+''" prop="name">
<el-input v-if="dialog.type==0" v-model="dialog.name" placeholder="请输入..."/>
<div v-else>
<el-input type="textarea" :rows="3" v-model="dialog.name" placeholder="请输入..."/>
<span style="color:#999;font-size: 12px">输入候选人姓名用空格隔开</span>
</div>
</el-form-item>
</el-form>
2022-10-27 18:07:02 +08:00
</ai-dialog>
2022-10-24 16:13:01 +08:00
</section>
</template>
<script>
2022-10-27 18:07:02 +08:00
export default {
name: "detailPanel",
props: {
candidateList: {default: () => []},
serveList: {default: () => []},
disabled: Boolean
},
data() {
return {
2022-10-28 11:19:39 +08:00
visible: false,
2022-10-27 18:07:02 +08:00
dialog: {
title: "",
name: "",
changeTime: ""
}
}
},
computed: {
currentList() {
let initData = {
0: {name: "姓名", dialogTitle: "本届任职人", list: "serveList"},
1: {name: "候选人", dialogTitle: "本届候选人", list: "candidateList"}
}
return initData[this.dialog.type || 0]
2022-10-24 16:13:01 +08:00
},
2022-10-27 18:07:02 +08:00
rules() {
2022-10-24 16:13:01 +08:00
return {
2022-10-27 18:07:02 +08:00
name: [{required: true, message: "请输入" + this.currentList.name, trigger: "change"}],
position: [{required: true, message: "请输入职位", trigger: "change"}],
2022-10-24 16:13:01 +08:00
}
},
2022-10-27 18:07:02 +08:00
},
methods: {
showDialog(v, rowIndex) {
this.dialog = {...this.dialog, ...v, rowIndex}
this.dialog.title = (this.dialog.rowIndex == 0 ? "编辑" : "添加") + this.currentList.dialogTitle
2022-10-28 11:19:39 +08:00
this.visible = true
2022-10-24 16:13:01 +08:00
},
2022-10-27 18:07:02 +08:00
submitAdd() {
this.$refs.editListItemForm.validate(v => {
if (v) {
this.handleData(this.currentList.list, list => {
if (this.dialog.rowIndex > -1) {
list.splice(this.dialog.rowIndex, 1, this.dialog)
} else list.push(this.dialog)
})
2022-10-28 11:19:39 +08:00
this.visible = false
2022-10-24 16:13:01 +08:00
}
2022-10-27 18:07:02 +08:00
})
2022-10-24 16:13:01 +08:00
},
2022-10-27 18:07:02 +08:00
handleData(prop, cb) {
2022-10-28 11:48:54 +08:00
const list = this.$copy(this.$props[prop]) || []
2022-10-27 18:07:02 +08:00
cb(list)
this.$emit("update:" + prop, list)
2022-10-24 16:13:01 +08:00
},
2022-10-27 18:07:02 +08:00
deleteItem(index, type) {
this.$confirm(`是否要删除该${type == 0 ? '本届任职人' : '本届候选人'}`, {type: "error"}).then(() => {
this.handleData(type == 0 ? "serveList" : "candidateList", list => {
list.splice(index, 1)
})
}).catch(() => {
2022-10-24 16:13:01 +08:00
})
}
}
2022-10-27 18:07:02 +08:00
}
2022-10-24 16:13:01 +08:00
</script>
<style lang="scss" scoped>
2022-10-27 18:07:02 +08:00
.detailPanel {
.itemTitle + .el-table {
margin-top: 16px;
}
2022-10-24 16:13:01 +08:00
2022-10-27 18:07:02 +08:00
.el-table + .itemTitle {
margin-top: 24px;
}
2022-10-24 16:13:01 +08:00
2022-12-01 09:35:20 +08:00
:deep( .table-header ){
2022-10-27 18:07:02 +08:00
box-sizing: border-box;
border-right: 1px solid #d0d4dc !important;
2022-10-24 16:13:01 +08:00
2022-10-27 18:07:02 +08:00
.cell {
padding-left: 32px;
}
2022-10-24 16:13:01 +08:00
2022-10-27 18:07:02 +08:00
&.is-center > .cell {
padding-left: 10px !important;
2022-10-24 16:13:01 +08:00
}
2022-10-27 18:07:02 +08:00
}
2022-10-24 16:13:01 +08:00
2022-12-01 09:35:20 +08:00
:deep( .table-cell ){
2022-10-27 18:07:02 +08:00
height: 44px;
color: #333;
2022-10-24 16:13:01 +08:00
2022-10-27 18:07:02 +08:00
.cell {
padding-left: 32px;
}
2022-10-24 16:13:01 +08:00
2022-10-27 18:07:02 +08:00
&.is-center > .cell {
padding-left: 10px !important;
2022-10-24 16:13:01 +08:00
}
}
2022-10-27 18:07:02 +08:00
}
2022-10-24 16:13:01 +08:00
</style>