zhouwx
8 小时以前 03b3624455b2f3a495ebb34349080e3bd35faff9
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
<template>
  <div class="notice">
    <el-dialog
        v-model="dialogVisible"
        :title="title"
        width="700px"
        :before-close="handleClose"
        :close-on-press-escape="false"
        :close-on-click-modal="false"
    >
      <el-form :model="state.form" size="default" ref="busRef" :rules="state.rules"  >
        <el-row :gutter="24">
          <el-col :span="24">
            <el-form-item label="企业名称:" prop="companyId" v-if="state.isAdmin">
              <el-select v-model="state.form.companyId" placeholder="请选择" filterable clearable style="width: 100%" :disabled="title == '查看' || title == '编辑' || !state.isAdmin" @change="selectValueCom">
                <el-option
                    v-for="item in state.companyList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="问卷名称:" prop="questionName" >
              <el-input :disabled="title === '查看'" v-model="state.form.questionName" placeholder="问卷名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="编号:" prop="number" >
              <el-input :disabled="title === '查看'" v-model="state.form.number" placeholder="编号"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="单位名称:" prop="unitName" >
              <el-input :disabled="title === '查看'" v-model="state.form.unitName" placeholder="单位名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系人:" prop="person" >
              <el-input :disabled="title === '查看'" v-model="state.form.person" placeholder="联系人"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="联系地址:" prop="address" >
              <el-input :disabled="title === '查看'" v-model="state.form.address" placeholder="联系地址"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="电话、传真:" prop="phone" >
              <el-input :disabled="title === '查看'" v-model="state.form.phone" placeholder="电话、传真"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="24">
            <div style="display:flex;flex-direction: column">
              <span style="font-size: 11px;font-weight: 700;margin-bottom: 5px" >贵单位使用我所何种类型的产品(可多选,在相应的选项“⬜︎︎︎”内打“√”):</span>
              <el-checkbox-group v-model="state.checkProductTypes" size="small"   :disabled="title === '查看'" style="display:flex;flex-wrap: wrap;margin-left: 20px">
                <div v-for="item in state.productTypeList">
                  <el-checkbox :label="item.id" :key="item.id" style="margin-left: 20px;">{{item.name}}</el-checkbox>
                </div>
              </el-checkbox-group>
            </div>
            <div style="display: flex;align-items: center;margin-top: 5px">
              <span style="font-size: 11px;font-weight: 700;margin-bottom: 5px;margin-right: 10px" >请注明产品的名称(如有保密情况可以不填):</span>
              <el-input style="width: 200px;" size="small" :disabled="title === '查看'" v-model="state.form.productName"></el-input>
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="24">
           <el-table style="margin: 20px 0" :data="state.dataList" :border="true">
             <el-table-column label="序号" width="80" prop="num" align="center"></el-table-column>
             <el-table-column label="调查项目" prop="item" align="center" >
               <template #default="scope">
                 <div v-if="scope.row.num == '说明'">
                   <span>{{scope.row.item}}</span>
                 </div>
                 <div v-else style="display: flex;align-items: center">
                   <span v-if="scope.row.num == 1" style="width: 210px">交付产品质量:</span>
                   <span v-if="scope.row.num == 2" style="width: 210px">项目进度的符合性:</span>
                   <span v-if="scope.row.num == 3" style="width: 210px">售后服务情况:</span>
                   <span v-if="scope.row.num == 4" style="width: 210px">技术/售后服务人员:</span>
                   <span v-if="scope.row.num == 5" style="width: 210px">市场人员服务与跟踪意识:</span>
                   <el-checkbox-group  v-model="scope.row.checkItem" size="small"   :disabled="title === '查看'" style="display:flex;flex-wrap: wrap;width: 600px;margin-left: 10px">
                     <div v-for="item in scope.row.item">
                       <el-checkbox style="margin-right: 15px" :label="item" :key="item" >{{item}}</el-checkbox>
                     </div>
                   </el-checkbox-group>
                 </div>
               </template>
             </el-table-column>
             <el-table-column label="满意度" prop="satisfied" align="center" >
               <template #default="scope">
                 <div v-if="scope.row.num == '说明'">
                   <span>{{scope.row.satisfied}}</span>
                 </div>
                 <el-radio-group v-else v-model="scope.row.check" size="small"   :disabled="title === '查看'" style="display:flex;flex-wrap: wrap;margin-left: 20px">
                   <div v-for="item in scope.row.satisfied">
                     <el-radio style="margin-right: 15px" :label="item" :key="item" >{{item}}</el-radio>
                   </div>
                 </el-radio-group>
               </template>
             </el-table-column>
           </el-table>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="24">
            <span style="font-size: 12px;font-weight: 700;margin-bottom: 5px" >重点说明不满意的原因以及其他意见、要求或建议,如同类产品的差距、市场信息、改进的建议等:</span>
            <el-input style="margin-top: 5px" :disabled="title === '查看'" v-model="state.form.suggest" type="textarea" :rows="4"></el-input>
          </el-col>
        </el-row>
      </el-form>
      <template #footer v-if="title !== '查看'">
        <span class="dialog-footer">
            <el-button @click="handleClose" size="default">取 消</el-button>
            <el-button type="primary"  @click="onSubmit" size="default" v-preReClick>确认</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>
<script setup>
import {onMounted, reactive, ref, toRefs} from 'vue'
import Cookies from "js-cookie";
import {getCompany} from "@/api/onlineEducation/company";
import {ElMessage} from "element-plus";
import {getUser} from "@/api/onlineEducation/user";
import {getDept, getObject, getObjectPage} from "@/api/qualityObjectives/object";
import {addTable, editTable, getTargetById} from "@/api/qualityObjectives/table";
import {addNeedDiscren, editNeedDiscren} from "@/api/need/need";
import {verifyPhone} from "@/utils/validate";
import {developList} from "@/views/work/qualityInfo/supplierQuality/supplierList/components/qualityDatas";
import {addDelivery, editDelivery} from "@/api/satisfiedNew/satisfiedNew";
 
const dialogVisible = ref(false);
const title = ref("");
const busRef = ref();
const length = ref()
const selectPopperClass = "max-width-select";
const emit = defineEmits(["getList"]);
const dataRef = ref();
const validatePhone = (rule, value, callback)=>{
  if(value === ''){
    callback(new Error('请输入手机号'))
  }else{
    if(!verifyPhone(value)){
      callback(new Error('手机号格式有误'))
    }else{
      callback()
    }
  }
}
const state = reactive({
  form: {
    id: '',
    companyId: null,
    questionName: null,
    number: '',
    unitName: null,
    person: null,
    address: null,
    phone: null,
    product: '',
    productName:'',
    mess: '',
    suggest: ''
  },
  rules: {
    companyId: [{ required: true, message: '请选择企业', trigger: 'blur' }],
    questionName: [{ required: true, message: '请输入问卷名称', trigger: 'blur' }],
    number: [{ required: true, message: '请输入编号', trigger: 'blur' }],
    unitName: [{ required: true, message: '请输入单位名称', trigger: 'blur' }],
    person: [{ required: true, message: '请输入联系人', trigger: 'blur' }],
    address: [{ required: true, message: '请输入联系地址', trigger: 'blur' }],
    product: [{ required: true, message: '请选择产品', trigger: 'blur' }],
    phone: [{required: true, trigger: "blur", validator: validatePhone}],
 
  },
  isAdmin: false,
  companyList: [],
  dataList: [
    {
      num: '说明',
      item: '哪项不满意,请在相应的选项“⬜︎︎︎”内打“√”',
      satisfied:'总体评价,请在相应的选项“⬜︎︎︎”内打“√”'
    },
    {
      num: '1',
      item: ['产品性能','技术资料','操作性','维护性','稳定性'],
      satisfied:['满意','基本满意','不满意']
    },
    {
      num: '2',
      item: ['节点控制','交付及时性','可靠性'],
      satisfied:['满意','基本满意','不满意']
    },
    {
      num: '3',
      item: ['顾客培训','技术支持','售后维修','备品及备件供应'],
      satisfied:['满意','基本满意','不满意']
    },
    {
      num: '4',
      item: ['技术技能','服务态度','过程规范','综合素质'],
      satisfied:['满意','基本满意','不满意']
    },
    {
      num: '5',
      item: ['服务的及时性','有效性','服务态度'],
      satisfied:['满意','基本满意','不满意']
    },
  ],
  productTypeList: [
    {
      id: 1,
      name: '系统'
    },
    {
      id: 2,
      name: '软件'
    },
    {
      id: 3,
      name: '整机'
    },
    {
      id: 4,
      name: '试剂柜'
    },
    {
      id: 5,
      name: '印制板'
    },
    {
      id: 6,
      name: '手持终端'
    },
    {
      id: 7,
      name: '其他'
    },
  ],
  checkProductTypes: []
})
 
onMounted(() => {
 
 
});
const openDialog = async (type, value,companyList) => {
  const userInfo = JSON.parse(Cookies.get('userInfo'))
  state.isAdmin = userInfo.userType === 0;
  state.form.companyName = userInfo.companyName
  state.form.companyId = userInfo.companyId
  if(state.isAdmin){
    state.form.companyId = value.companyId
    state.form.companyName = value.companyName
    state.companyList = companyList
  }
  title.value = type === 'add' ? '新增' : type ==='edit' ? '编辑' : '查看' ;
  if(type === 'edit' || type === 'review') {
    state.form = JSON.parse(JSON.stringify(value));
    if(state.isAdmin){
      state.form.companyId = value.companyId
      state.form.companyName = value.companyName
    }
    //解析json
    state.dataList = JSON.parse(value.mess)
    state.checkProductTypes = value.product.split(',').map(Number)
  }
  dialogVisible.value = true;
}
 
const onSubmit = async () => {
  state.form.mess = JSON.stringify(state.dataList)
  state.form.product = state.checkProductTypes.join(',')
  const valid = await busRef.value.validate();
  if(valid){
    if(title.value === '新增'){
      console.log('sta',state.form)
      const {id, ...data} = JSON.parse(JSON.stringify(state.form))
      const res = await addDelivery(data)
      if(res.code === 200){
        ElMessage({
          type: 'success',
          message: '新增成功'
        });
      }else{
        ElMessage.warning(res.message)
      }
      emit("getList")
      busRef.value.clearValidate();
      reset();
      dialogVisible.value = false;
    }else if(title.value === '编辑'){
      const {...data} = JSON.parse(JSON.stringify(state.form))
      const res = await editDelivery(data)
      if(res.code === 200){
        ElMessage({
          type: 'success',
          message: '编辑成功'
        });
      }else{
        ElMessage.warning(res.message)
      }
      emit("getList")
      busRef.value.clearValidate();
      reset();
      dialogVisible.value = false;
    }
  }
}
 
const handleClose = () => {
  busRef.value.clearValidate();
  reset();
  dialogVisible.value = false;
  emit("getList")
 
}
const reset = () => {
  state.form = {
    id: '',
    companyId: null,
    deptId: null,
    year: '',
    fictionId: null,
    checkId: null,
    ratifyId: null,
    fictionTime: null,
    frequency: '',
    expectContents:[],
  }
  state.checkProductTypes = []
  state.companyList = []
}
 
 
 
const selectValueCom = (val) => {
  state.form.fictionId = null
  state.form.checkId = null
  state.form.ratifyId = null
  state.form.deptId = null
  state.companyList.forEach(item => {
    if(item.name === val){
      state.form.companyId = item.id
    }
  })
}
 
const handleChangeNum = (value) => {
  if (!/^\d+$/.test(value)) { // 验证是否为数字
    ElMessage.warning('只能输入数字')
    state.form.year = '' // 重置选择,避免非法值被添加到options中
  } else if (!state.yearList.some(option => option.label === value)) { // 确保不是已存在的选项
    state.yearList.push({ value, label: value }); // 添加新选项(这里简单地将值和标签设为相同)
  }
}
 
defineExpose({
  openDialog
});
 
</script>
 
<style scoped lang="scss">
.notice{
  :deep(.el-form .el-form-item__label) {
    font-size: 15px;
  }
  :deep(.el-table .cell){
    font-size: small;
  }
  .file {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }
}
</style>