spring
2025-02-28 dc3af0cbb4a6d105bdff497b510cc0a87b3e8d0a
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<template><div class="add">
  <el-dialog
    :title="isEdit ?'编辑附件资料':'新增附件资料'"
    :visible.sync="dialogVisible"
    width="40%"
  >
    <el-form
      :model="form"
      ref="form"
      :rules="rules"
      label-width="80px"
      size="small"
    >
      <el-form-item label="沟通人" prop="userId">
        <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="沟通时间" prop="communicationTime">
        <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="沟通地点" prop="communicationPlace">
        <el-input v-model="form.communicationPlace" placeholder="请填写沟通地点"></el-input>
      </el-form-item >
      <el-form-item label="沟通内容" prop="communicationContent">
        <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 {selectUserCondition} from "@/api/business/inspectionTask";
import {addOrUpdatePersonCommunicationAbility} from "@/api/cnas/personal/personPersonCommunicationAbilityPage";
 
export default {
  data() {
    return {
      isEdit: false,
      dialogVisible: false,
      form: {
        id: '',
        userId: [],
        communicationTime: undefined,
        communicationPlace: undefined,
        communicationContent: undefined
      },
      rules: {
        userId: [{ required: true, message: '请选择沟通人', trigger: 'change' }],
        communicationTime: [{ required: true, message: '请选择沟通时间', trigger: 'change' }],
        communicationPlace: [{ required: true, message: '请填写沟通地点', trigger: 'blur' }],
        communicationContent: [{ required: true, message: '请填写沟通内容', trigger: 'blur' }],
      },
      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.form.id = ''
        this.resetForm('form')
      }
    },
    /**
     * @desc 获取用户信息
     */
    async getUserList() {
      selectUserCondition().then((res) => {
        this.userList = res.data;
      })
    },
    /**
     * @desc 提交表单
     */
    async submitForm() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.loading = true
          const params = {
            id: this.form.id,
            userId: this.form.userId.join(','),
            communicationTime: this.form.communicationTime,
            communicationPlace: this.form.communicationPlace,
            communicationContent: this.form.communicationContent,
          }
          addOrUpdatePersonCommunicationAbility(params).then((res) => {
            this.loading = false
            this.resetForm('form')
            this.$emit('submit')
            this.dialogVisible = false
          }).catch((err) => {
            this.loading = false
          })
        }
      })
    }
  }
}
</script>
<style scoped>
</style>