|
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <div class="wrap">
|
|
|
3
|
+ <div class="descripEle">
|
|
|
4
|
+ <div class="title">
|
|
|
5
|
+ <span class="title-text">{{ planDetail.name }}</span>
|
|
|
6
|
+ <div class="title-btn">
|
|
|
7
|
+ <el-button :type="taskStatusMap[taskDetail.state].color" size="small"
|
|
|
8
|
+ v-if="taskStatusMap[taskDetail.state]">{{ taskStatusMap[taskDetail.state].title }}</el-button>
|
|
|
9
|
+ </div>
|
|
|
10
|
+ <div class="btn-call">
|
|
|
11
|
+ <el-button @click="callPhone" v-if="planDetail.way === 1 && planDetail.executionMethod === 1" :icon="Phone">呼叫</el-button>
|
|
|
12
|
+ <el-button @click="sendMessage" v-if="planDetail.way === 2 && planDetail.executionMethod === 1" :icon="Message">发送</el-button>
|
|
|
13
|
+ </div>
|
|
|
14
|
+ </div>
|
|
|
15
|
+ <div class="content">
|
|
|
16
|
+ <div class="content-info" v-if="planDetail.describes">{{ planDetail.describes }}</div>
|
|
|
17
|
+ <div class="content-item">
|
|
|
18
|
+ <div class="item1">
|
|
|
19
|
+ 更新时间:{{ planDetail.updateTime || planDetail.createTime }}
|
|
|
20
|
+ </div>
|
|
|
21
|
+ <div class="item2">
|
|
|
22
|
+ 周期:{{ getTimeFrame(planDetail.beginEffective, planDetail.endEffective) }}
|
|
|
23
|
+ </div>
|
|
|
24
|
+ </div>
|
|
|
25
|
+ <div class="content-form">
|
|
|
26
|
+ <el-form-item label="结果">
|
|
|
27
|
+ <el-radio-group v-model="form.state">
|
|
|
28
|
+ <el-radio :value="item.value" size="large"
|
|
|
29
|
+ v-for="item in taskResults.filter((o) => { return !!o.value })" :key="item.value">
|
|
|
30
|
+ {{ item.title }}
|
|
|
31
|
+ </el-radio>
|
|
|
32
|
+ </el-radio-group>
|
|
|
33
|
+ </el-form-item>
|
|
|
34
|
+ <el-form-item label="标签">
|
|
|
35
|
+ <el-radio-group v-model="form.resultLabel">
|
|
|
36
|
+ <el-radio :value="item.value" size="large"
|
|
|
37
|
+ v-for="item in resultLabels.filter((o) => { return !!o.value })" :key="item.value">
|
|
|
38
|
+ {{ item.title }}
|
|
|
39
|
+ </el-radio>
|
|
|
40
|
+ </el-radio-group>
|
|
|
41
|
+ </el-form-item>
|
|
|
42
|
+ <el-form-item label="备注">
|
|
|
43
|
+ <el-input v-model="form.desc" type="textarea" />
|
|
|
44
|
+ </el-form-item>
|
|
|
45
|
+ </div>
|
|
|
46
|
+ <div class="content-questionnaire">
|
|
|
47
|
+
|
|
|
48
|
+ <!-- 短信内容 -->
|
|
|
49
|
+ <!--TODO: 等添加的组件写完直接照抄-->
|
|
|
50
|
+ <div v-if="planDetail.way === 2">
|
|
|
51
|
+ <div style="margin-bottom: 10px;"><el-text tag="b">短信内容</el-text></div>
|
|
|
52
|
+ <div>
|
|
|
53
|
+ <span v-for="(node, index) in msgContent" :key="index">
|
|
|
54
|
+ <el-tag v-if="node.isTag" @click="node.click">{{ node.content }}</el-tag>
|
|
|
55
|
+ <el-link type="primary" v-if="node.isLink" @click="node.click" style="line-height: 24px;">{{ node.content }}</el-link>
|
|
|
56
|
+ <span v-if="!node.isTag && !node.isLink" v-html="node.content"></span>
|
|
|
57
|
+ </span>
|
|
|
58
|
+
|
|
|
59
|
+ </div>
|
|
|
60
|
+ </div>
|
|
|
61
|
+
|
|
|
62
|
+ <!-- 问卷组件 -->
|
|
|
63
|
+ <question v-if="planDetail.way === 1 && isParentMounted && (planDetail.way === 1 || (planDetail.messageType === 1 && planDetail.messageParameter))" ref="questionRef"
|
|
|
64
|
+ :surveyId="planDetail.questionnaire || planDetail.messageParameter" :userId="taskDetail.patientFiles" :taskId="taskDetail.patientTaskId"></question>
|
|
|
65
|
+ </div>
|
|
|
66
|
+ <div class="content-submit" v-if="taskDetail.state === 1 && planDetail.way === 1 && planDetail.executionMethod === 1">
|
|
|
67
|
+ <el-button @click="handleCreat">创建工单</el-button>
|
|
|
68
|
+ <el-button type="primary" @click="submit">提交</el-button>
|
|
|
69
|
+ </div>
|
|
|
70
|
+ <div class="content-submit" v-if="taskDetail.state === 3">
|
|
|
71
|
+ <el-button type="primary" @click="submit">保存</el-button>
|
|
|
72
|
+ </div>
|
|
|
73
|
+ </div>
|
|
|
74
|
+ </div>
|
|
|
75
|
+ <el-dialog
|
|
|
76
|
+ v-model="dialogAddWorkorder"
|
|
|
77
|
+ :title="modalTitle"
|
|
|
78
|
+ center
|
|
|
79
|
+ width="70%"
|
|
|
80
|
+ :modal="true"
|
|
|
81
|
+ :show-close="true"
|
|
|
82
|
+ >
|
|
|
83
|
+ <page-order :taskId="taskId" :getDefaultInfo="defaultOrderInfo" @refreshOrder="submitRefresh()"></page-order>
|
|
|
84
|
+ </el-dialog>
|
|
|
85
|
+ </div>
|
|
|
86
|
+</template>
|
|
|
87
|
+<script setup>
|
|
|
88
|
+import { ref,onMounted,watch, h } from "vue";
|
|
|
89
|
+import { useRouter } from 'vue-router';
|
|
|
90
|
+import { ElMessage } from 'element-plus'
|
|
|
91
|
+import { userDecrypt } from '@/utils/aes'
|
|
|
92
|
+import { Message, Phone } from '@element-plus/icons-vue'
|
|
|
93
|
+
|
|
|
94
|
+import PageOrder from '@/components/page-order';
|
|
|
95
|
+import question from '@/views/main/questionnaireManagement/fillOut.vue'
|
|
|
96
|
+
|
|
|
97
|
+import { getTimeFrame, ArrayToMap } from '@/utils/tools'
|
|
|
98
|
+import { taskResults, taskStatus } from "@/utils/commonDic.js"
|
|
|
99
|
+import useSocketStore from '@/store/modules/socket';
|
|
|
100
|
+import { Send } from '@/utils/telWebsocket';
|
|
|
101
|
+import useUserStore from '@/store/modules/user'
|
|
|
102
|
+import { matchTags } from '@/utils/sms'
|
|
|
103
|
+import useSelectStore from '@/store/commonSelect/common';
|
|
|
104
|
+
|
|
|
105
|
+import { getPlanInfo } from '@/api/patient/plan';
|
|
|
106
|
+import { getTaskInfo, submitTaskResult } from '@/api/patient/task';
|
|
|
107
|
+import { smsDetail } from '@/api/system/sms'
|
|
|
108
|
+import { getPhoneFix } from '@/api/main/main';
|
|
|
109
|
+
|
|
|
110
|
+const router = useRouter();
|
|
|
111
|
+let planDetail = ref({});
|
|
|
112
|
+let taskDetail = ref({});
|
|
|
113
|
+const isParentMounted = ref(false);
|
|
|
114
|
+const questionRef = ref();
|
|
|
115
|
+const { proxy } = getCurrentInstance();
|
|
|
116
|
+const callId = ref('');
|
|
|
117
|
+const lineState = ref('');
|
|
|
118
|
+const resultLabels = ref([]);
|
|
|
119
|
+const defaultOrderInfo = ref({
|
|
|
120
|
+ caller: '',
|
|
|
121
|
+ callnum: '',
|
|
|
122
|
+
|
|
|
123
|
+});
|
|
|
124
|
+
|
|
|
125
|
+const msgContent = ref();
|
|
|
126
|
+
|
|
|
127
|
+const form = ref({
|
|
|
128
|
+ state: '',
|
|
|
129
|
+ desc: '',
|
|
|
130
|
+ resultLabel: '',
|
|
|
131
|
+})
|
|
|
132
|
+
|
|
|
133
|
+const props = defineProps({
|
|
|
134
|
+ planId: {
|
|
|
135
|
+ type: Number,
|
|
|
136
|
+ default: 0
|
|
|
137
|
+ },
|
|
|
138
|
+ taskId: {
|
|
|
139
|
+ type: Number,
|
|
|
140
|
+ default: 0
|
|
|
141
|
+ },
|
|
|
142
|
+});
|
|
|
143
|
+watch(props, (nweProps) => {
|
|
|
144
|
+ console.log('watch props', nweProps);
|
|
|
145
|
+ initMethod(props)
|
|
|
146
|
+});
|
|
|
147
|
+
|
|
|
148
|
+const emit = defineEmits([
|
|
|
149
|
+ 'submit'
|
|
|
150
|
+])
|
|
|
151
|
+const dialogAddWorkorder = ref(false)
|
|
|
152
|
+const modalTitle = ref('添加工单')
|
|
|
153
|
+function submitRefresh() {
|
|
|
154
|
+ ElMessage({
|
|
|
155
|
+ message: '创建成功',
|
|
|
156
|
+ type: 'success',
|
|
|
157
|
+ })
|
|
|
158
|
+ dialogAddWorkorder.value = false
|
|
|
159
|
+}
|
|
|
160
|
+function handleCreat() {
|
|
|
161
|
+ defaultOrderInfo.value.caller = taskDetail.value.name;
|
|
|
162
|
+ defaultOrderInfo.value.callnum = userDecrypt(taskDetail.value.mobile);
|
|
|
163
|
+ console.log(defaultOrderInfo.value, 'defaultOrderInfo.value')
|
|
|
164
|
+ dialogAddWorkorder.value = true
|
|
|
165
|
+}
|
|
|
166
|
+
|
|
|
167
|
+const smsTempDetail = ref({})
|
|
|
168
|
+
|
|
|
169
|
+onMounted(() => {
|
|
|
170
|
+ resultLabels.value = useSelectStore().resultLabels;
|
|
|
171
|
+ initMethod(props)
|
|
|
172
|
+});
|
|
|
173
|
+
|
|
|
174
|
+const clickTag = () => {
|
|
|
175
|
+ console.log('处理厂k');
|
|
|
176
|
+}
|
|
|
177
|
+
|
|
|
178
|
+
|
|
|
179
|
+async function initMethod(props) {
|
|
|
180
|
+ callId.value = '';
|
|
|
181
|
+
|
|
|
182
|
+ const promiseAll = []
|
|
|
183
|
+ const types = [];
|
|
|
184
|
+ if (props.planId) {
|
|
|
185
|
+ types.push('plan');
|
|
|
186
|
+ promiseAll.push(getPlanInfo(props.planId));
|
|
|
187
|
+ }
|
|
|
188
|
+ if (props.taskId) {
|
|
|
189
|
+ types.push('task');
|
|
|
190
|
+ promiseAll.push(getTaskInfo(props.taskId));
|
|
|
191
|
+ }
|
|
|
192
|
+
|
|
|
193
|
+ const result = await Promise.all(promiseAll);
|
|
|
194
|
+
|
|
|
195
|
+ for (let index = 0; index < types.length; index++) {
|
|
|
196
|
+ const type = types[index];
|
|
|
197
|
+ const res = result[index];
|
|
|
198
|
+ if (res && res.state === 'success') {
|
|
|
199
|
+ if (type === 'plan') {
|
|
|
200
|
+ planDetail.value = res.data || {}
|
|
|
201
|
+ }
|
|
|
202
|
+ if (type === 'task') {
|
|
|
203
|
+ taskDetail.value = res.data || {}
|
|
|
204
|
+
|
|
|
205
|
+ if (taskDetail.value.callState && taskDetail.value.state > 1) {
|
|
|
206
|
+ form.value.state = taskDetail.value.callState;
|
|
|
207
|
+ form.value.desc = taskDetail.value.sfResult;
|
|
|
208
|
+ form.value.resultLabel = taskDetail.value.labelValue;
|
|
|
209
|
+ } else {
|
|
|
210
|
+ form.value.desc = '';
|
|
|
211
|
+ const initStatus = taskResults.find((o) => { return !!o.checked });
|
|
|
212
|
+ if (initStatus) form.value.state = initStatus.value
|
|
|
213
|
+ }
|
|
|
214
|
+ taskDetail.value.seatName = res.data.seatName ? res.data.seatName : useUserStore().name
|
|
|
215
|
+ isParentMounted.value = true;
|
|
|
216
|
+ }
|
|
|
217
|
+ }
|
|
|
218
|
+ }
|
|
|
219
|
+
|
|
|
220
|
+ if (planDetail.value.message && planDetail.value.way === 2) {
|
|
|
221
|
+ smsDetail(planDetail.value.message).then((smsRes) => {
|
|
|
222
|
+ if (smsRes && smsRes.state === 'success') {
|
|
|
223
|
+ smsTempDetail.value = smsRes.data
|
|
|
224
|
+
|
|
|
225
|
+ let urlLabel = '';
|
|
|
226
|
+ if (planDetail.value.messageType === 2) urlLabel = planDetail.value.messageParameter;
|
|
|
227
|
+ if (planDetail.value.messageType === 1) {
|
|
|
228
|
+ urlLabel = '问卷'
|
|
|
229
|
+ }
|
|
|
230
|
+ msgContent.value = matchTags(smsRes.data.content, {
|
|
|
231
|
+ userName: {
|
|
|
232
|
+ label: taskDetail.value.name,
|
|
|
233
|
+ },
|
|
|
234
|
+ seatUser: {
|
|
|
235
|
+ label: taskDetail.value.seatName,
|
|
|
236
|
+ // click: () => {
|
|
|
237
|
+ // console.log(111);
|
|
|
238
|
+ // }
|
|
|
239
|
+ },
|
|
|
240
|
+ url: {
|
|
|
241
|
+ label: urlLabel,
|
|
|
242
|
+ },
|
|
|
243
|
+ });
|
|
|
244
|
+
|
|
|
245
|
+ }
|
|
|
246
|
+ })
|
|
|
247
|
+ }
|
|
|
248
|
+}
|
|
|
249
|
+
|
|
|
250
|
+const taskStatusMap = ArrayToMap(taskStatus, 'value');
|
|
|
251
|
+
|
|
|
252
|
+// 提交结果
|
|
|
253
|
+const submit = () => {
|
|
|
254
|
+ console.log(lineState.value)
|
|
|
255
|
+ if (!(lineState.value === '' || lineState.value === '在线')) return proxy.$modal.msgError('请等待用户挂断');
|
|
|
256
|
+ let params = {}
|
|
|
257
|
+ if (planDetail.value.way === 1 && form.value.state === '正常接听') {
|
|
|
258
|
+ // if (planDetail.value.way === 1) {
|
|
|
259
|
+ params = questionRef.value.getParams();
|
|
|
260
|
+ }
|
|
|
261
|
+ console.log(params, 'params');
|
|
|
262
|
+
|
|
|
263
|
+ if (!params && form.value.state === '正常接听') return;
|
|
|
264
|
+ // if (!params) return;
|
|
|
265
|
+ params.entername = taskDetail.value.name;
|
|
|
266
|
+ params.answeruser = taskDetail.value.patientFiles;
|
|
|
267
|
+ params.enterphone = taskDetail.value.mobile;
|
|
|
268
|
+
|
|
|
269
|
+
|
|
|
270
|
+
|
|
|
271
|
+ // 更新state
|
|
|
272
|
+ const stateInfo = taskResults.find((o) => {
|
|
|
273
|
+ return o.value === form.value.state
|
|
|
274
|
+ });
|
|
|
275
|
+
|
|
|
276
|
+ let resultParams = {
|
|
|
277
|
+ patientTaskId: taskDetail.value.patientTaskId,
|
|
|
278
|
+ callState: form.value.state,
|
|
|
279
|
+ sfResult: form.value.desc,
|
|
|
280
|
+ labelValue: form.value.resultLabel || '',
|
|
|
281
|
+ };
|
|
|
282
|
+ if (callId.value) resultParams.callRecords = callId.value;
|
|
|
283
|
+ if (stateInfo) {
|
|
|
284
|
+ if (stateInfo.error) {
|
|
|
285
|
+ resultParams.state = 4;
|
|
|
286
|
+ } else if (stateInfo.end) {
|
|
|
287
|
+ resultParams.state = 3;
|
|
|
288
|
+ }
|
|
|
289
|
+ }
|
|
|
290
|
+
|
|
|
291
|
+ // if (stateInfo && stateInfo.end) resultParams.state = 3;
|
|
|
292
|
+ // if (form.value.state === '无人接听') {
|
|
|
293
|
+ // resultParams.state = 1
|
|
|
294
|
+ // }
|
|
|
295
|
+
|
|
|
296
|
+
|
|
|
297
|
+ console.log(resultParams)
|
|
|
298
|
+ console.log(params)
|
|
|
299
|
+ // return
|
|
|
300
|
+ //TODO: 增加判断,电话类型的如果接通,必须挂点电话之后才可以提交
|
|
|
301
|
+ submitTaskResult({
|
|
|
302
|
+ ...resultParams,
|
|
|
303
|
+ answer: params,
|
|
|
304
|
+ planId: planDetail.value.plId,
|
|
|
305
|
+ }).then((res) => {
|
|
|
306
|
+ if (res.state === 'success') {
|
|
|
307
|
+ ElMessage({
|
|
|
308
|
+ message: '操作成功',
|
|
|
309
|
+ type: 'success',
|
|
|
310
|
+ })
|
|
|
311
|
+
|
|
|
312
|
+ // 告诉父级组件完成了
|
|
|
313
|
+ emit('submit')
|
|
|
314
|
+ } else {
|
|
|
315
|
+ // 失败
|
|
|
316
|
+ ElMessage({
|
|
|
317
|
+ message: '操作失败',
|
|
|
318
|
+ type: 'error',
|
|
|
319
|
+ })
|
|
|
320
|
+ }
|
|
|
321
|
+ })
|
|
|
322
|
+}
|
|
|
323
|
+
|
|
|
324
|
+// 发送短信
|
|
|
325
|
+const sendMessage = () => {
|
|
|
326
|
+ //TODO: 组装短信,并发送短信
|
|
|
327
|
+
|
|
|
328
|
+ // 点击发送成功之后,需要更改状态
|
|
|
329
|
+}
|
|
|
330
|
+const scoketDatas = ref({});
|
|
|
331
|
+const stateObj = {
|
|
|
332
|
+ 0:'离线',
|
|
|
333
|
+ 1:'登录中',
|
|
|
334
|
+ 2:'在线',
|
|
|
335
|
+ 3:'通话中',
|
|
|
336
|
+ 4:'话后处理中',
|
|
|
337
|
+ 5:'离线',
|
|
|
338
|
+ 6:'振铃',
|
|
|
339
|
+ 7:'注销',
|
|
|
340
|
+}
|
|
|
341
|
+// 外呼
|
|
|
342
|
+const callPhone = () => {
|
|
|
343
|
+ lineState.value = '发起外呼';
|
|
|
344
|
+ // 获取解密后的手机号
|
|
|
345
|
+
|
|
|
346
|
+ const phone = userDecrypt(taskDetail.value.mobile);
|
|
|
347
|
+ // const phone = '15838094023'
|
|
|
348
|
+ //TODO: 增加外呼逻辑
|
|
|
349
|
+ if (!useSocketStore().accountNumber) {
|
|
|
350
|
+ proxy.$modal.msgSuccess('还没有签入');
|
|
|
351
|
+ lineState.value = '';
|
|
|
352
|
+ return
|
|
|
353
|
+ }
|
|
|
354
|
+ getPhoneFix(phone).then((data) => {
|
|
|
355
|
+ if (data.state === 'success') {
|
|
|
356
|
+ scoketDatas.value = {
|
|
|
357
|
+ AgentID: useSocketStore().accountNumber,
|
|
|
358
|
+ AgentExten: useSocketStore().extensionNumber,
|
|
|
359
|
+ Type: 'MakeCall',
|
|
|
360
|
+ DestinationNumber: data.data[0],
|
|
|
361
|
+ };
|
|
|
362
|
+ console.log(scoketDatas.value);
|
|
|
363
|
+ Send(scoketDatas.value, (data) => {
|
|
|
364
|
+ console.log(data, 'data'); //{CallID: 'c6207188-1361-11ef-8802-2b593e364a61', RecPath: '/home/wav/luyin/20240516/1009/165344_c6207188136111ef88022b593e364a61.wav', Result: true, Type: 'RecordPath'}
|
|
|
365
|
+ if (data.Type === 'MakeCall') {
|
|
|
366
|
+ console.log('外呼');
|
|
|
367
|
+
|
|
|
368
|
+ if (data.Result == true) {
|
|
|
369
|
+ proxy.$modal.msgSuccess('外呼成功');
|
|
|
370
|
+ } else {
|
|
|
371
|
+ proxy.$modal.msgError('外呼失败');
|
|
|
372
|
+ }
|
|
|
373
|
+ }
|
|
|
374
|
+
|
|
|
375
|
+ if (data.Type === 'CallID') {
|
|
|
376
|
+ callId.value = data.CallID;
|
|
|
377
|
+ }
|
|
|
378
|
+
|
|
|
379
|
+ if (data.Type === 'State') {
|
|
|
380
|
+ lineState.value = stateObj[data.State];
|
|
|
381
|
+ }
|
|
|
382
|
+ console.log(lineState.value)
|
|
|
383
|
+ });
|
|
|
384
|
+ } else {
|
|
|
385
|
+ lineState.value = '';
|
|
|
386
|
+ }
|
|
|
387
|
+ }).catch(() => {
|
|
|
388
|
+ proxy.$modal.msgError('外呼失败');
|
|
|
389
|
+ lineState.value = '';
|
|
|
390
|
+ });
|
|
|
391
|
+
|
|
|
392
|
+
|
|
|
393
|
+}
|
|
|
394
|
+
|
|
|
395
|
+</script>
|
|
|
396
|
+<style scoped lang="scss">
|
|
|
397
|
+.wrap {
|
|
|
398
|
+ .descripEle {
|
|
|
399
|
+ .title {
|
|
|
400
|
+ position: relative;
|
|
|
401
|
+ display: flex;
|
|
|
402
|
+
|
|
|
403
|
+ .title-text {
|
|
|
404
|
+ font-size: 18px;
|
|
|
405
|
+ font-weight: bold;
|
|
|
406
|
+ line-height: 36px;
|
|
|
407
|
+ margin-right: 30px;
|
|
|
408
|
+ }
|
|
|
409
|
+
|
|
|
410
|
+ .title-btn {
|
|
|
411
|
+ margin-top: 7px;
|
|
|
412
|
+ display: inline-block;
|
|
|
413
|
+ }
|
|
|
414
|
+
|
|
|
415
|
+ .btn-call {
|
|
|
416
|
+ position: absolute;
|
|
|
417
|
+ right: 15px;
|
|
|
418
|
+ top: 3px;
|
|
|
419
|
+ }
|
|
|
420
|
+ }
|
|
|
421
|
+
|
|
|
422
|
+ .content {
|
|
|
423
|
+ font-size: 14px;
|
|
|
424
|
+ color: #606266;
|
|
|
425
|
+
|
|
|
426
|
+ .content-info {
|
|
|
427
|
+ line-height: 28px;
|
|
|
428
|
+ }
|
|
|
429
|
+
|
|
|
430
|
+ .content-item {
|
|
|
431
|
+ display: flex;
|
|
|
432
|
+ margin-bottom: 15px;
|
|
|
433
|
+
|
|
|
434
|
+ .item1 {
|
|
|
435
|
+ margin-right: 30px;
|
|
|
436
|
+ }
|
|
|
437
|
+ }
|
|
|
438
|
+
|
|
|
439
|
+ .content-submit {
|
|
|
440
|
+ margin: 0 auto;
|
|
|
441
|
+ text-align: center;
|
|
|
442
|
+ position: absolute;
|
|
|
443
|
+ bottom: 12px;
|
|
|
444
|
+ width: 45%;
|
|
|
445
|
+ }
|
|
|
446
|
+
|
|
|
447
|
+ }
|
|
|
448
|
+
|
|
|
449
|
+ }
|
|
|
450
|
+}
|
|
|
451
|
+</style>
|