<template>
|
<div class="add">
|
<el-dialog :title="isEdit ? '编辑附件资料' : '新增附件资料'" :visible.sync="dialogVisible" width="40%">
|
<el-form :model="form" label-width="80px" size="small">
|
<el-form-item label="沟通人">
|
<el-select v-model="form.userId" placeholder="请选择" style="width: 100%" multiple>
|
<el-option v-for="(item, index) in userList" :key="index" :label="item.name"
|
:value="item.id"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="沟通时间">
|
<el-date-picker v-model="form.communicationTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
|
placeholder="请选择日期时间" style="width: 100%">
|
</el-date-picker>
|
</el-form-item>
|
<el-form-item label="沟通地点">
|
<el-input v-model="form.communicationPlace" placeholder="请选择"></el-input>
|
</el-form-item>
|
<el-form-item label="沟通内容">
|
<el-input v-model="form.communicationContent" placeholder="请选择"></el-input>
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="foot">
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
<el-button type="primary" :loading="loading" @click="submitForm">确 定</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
<script>
|
import {
|
selectUserList,
|
addOrUpdatePersonCommunicationAbility
|
} from '@/api/cnas/personnel/personnelInfo.js'
|
export default {
|
data() {
|
return {
|
isEdit: false,
|
dialogVisible: false,
|
form: {
|
id: undefined,
|
userId: [],
|
communicationTime: undefined,
|
communicationPlace: undefined,
|
communicationContent: undefined
|
},
|
loading: false,
|
userList: []
|
}
|
},
|
methods: {
|
/**
|
* @desc 显示模态框
|
* @param {*} row
|
* @param {*} type
|
*/
|
openDialog(row, type) {
|
this.getUserList()
|
this.dialogVisible = true
|
if (type) {
|
this.isEdit = true
|
this.form.id = row.id
|
this.form.userId = row.userId.split(',').map(m => Number(m))
|
this.form.communicationTime = row.communicationTime
|
this.form.communicationPlace = row.communicationPlace
|
this.form.communicationContent = row.communicationContent
|
} else {
|
this.isEdit = false
|
this.form.id = undefined
|
this.form.userId = []
|
this.form.communicationTime = undefined
|
this.form.communicationPlace = undefined
|
this.form.communicationContent = undefined
|
}
|
},
|
/**
|
* @desc 获取用户信息
|
*/
|
async getUserList() {
|
const { code, data } = await selectUserList()
|
if (code == 200) {
|
this.userList = data
|
}
|
},
|
/**
|
* @desc 提交表单
|
*/
|
async submitForm() {
|
this.loading = true
|
const { code, data } = await addOrUpdatePersonCommunicationAbility({
|
id: this.form.id,
|
userId: this.form.userId.join(','),
|
communicationTime: this.form.communicationTime,
|
communicationPlace: this.form.communicationPlace,
|
communicationContent: this.form.communicationContent,
|
})
|
if (code == 200) {
|
this.$emit('submit')
|
this.dialogVisible = false
|
} else {
|
this.$message.error(this.isEdit ? '编辑失败' : '新增失败')
|
}
|
this.loading = false
|
}
|
}
|
}
|
</script>
|
<style scoped>
|
.foot {
|
width: 100%;
|
}
|
|
.add>>>.el-dialog__footer {
|
padding-right: 20px;
|
}
|
</style>
|