spring
2025-03-12 7e4a48404dcca87fa8060fde21dcb5cdf6b651dc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<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>