p-honggang.li
2025-08-29 ad106d35ebd06e5e122fd1af31c8e2aac94ab0c7
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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
<template>
  <div>
    <el-tabs v-model="currentTab">
      <el-tab-pane key="1" label="基本信息" name="1">
        <!-- 新增和编辑弹窗 -->
        <informationBasicInfo
          ref="informationBasicInfoRef"
          :customerInfo="state.basicInfo"
          @submitNext="handleShowNextTab"
        />
      </el-tab-pane>
      <el-tab-pane key="2" label="产品信息" name="2">
        <div class="bodyDiv">
          <el-scrollbar style="width: 100%">
            <div
              class="childDiv"
              v-for="(item, index) in state.richTextList"
              :key="item.sign"
            >
              <div class="titDiv">
                <span>产品标题 </span>
                <div class="iptDiv">
                  <el-input
                    v-model="item.chapterHead"
                    :disabled="state.disabledData"
                    clearable
                    placeholder="请输入标题"
                    maxlength="100"
                    show-word-limit
                  />
                </div>
              </div>
              <div class="ctnDiv">
                <div class="topDiv">
                  <span>产品内容 </span>
                  <div class="richTextDiv" v-if="!state.disabledData">
                    <richText
                      :ref="'richTextRefData' + index"
                      :indexData="index"
                      :modelData="state.richTextList[index].chapterContent"
                      @updateDataFun="updateDataFun"
                    ></richText>
                  </div>
                  <div class="richTextDiv" v-else>
                    <div
                      style="padding: 10px"
                      v-html="state.richTextList[index].chapterContent"
                    ></div>
                  </div>
                </div>
                <div class="btmBtnDiv">
                  <el-button type="danger" plain @click="deleteChapter(index)"
                    >删除本章</el-button
                  >
                </div>
              </div>
            </div>
          </el-scrollbar>
          <div class="form-footer">
            <el-button type="primary" @click="addChapter">添加章节</el-button>
          </div>
        </div>
      </el-tab-pane>
      <el-tab-pane key="3" label="附件管理" name="3">
        <uploadInfo ref="uploadVideoRef" :id="state.id" />
        <uploadInfo ref="uploadFileRef" :id="state.id" />
      </el-tab-pane>
    </el-tabs>
    <el-dialog
      style="width: 1300px; height: 88vh"
      v-model="state.visible"
      title="流程查看"
      :destroy-on-close="true"
      :close-on-click-modal="false"
    >
      <div class="bodyBox" v-if="state.routeData.flowId">
        <iframe
          style="width: 100%; height: 100%; border: none"
          :src="state.srcData"
        ></iframe>
      </div>
      <div v-else style="line-height: 300px; text-align: center">
        当前提报未提交,暂无流程查看信息
      </div>
    </el-dialog>
    <div class="absolutBnt">
      <el-button class="backicon" @click="goBackList">返回</el-button>
      <el-button type="primary" plain @click="saveBasicDraft">存草稿</el-button>
      <el-button
        type="primary"
        @click="submitClick"
        :disabled="state.submitDisabled"
        >提交</el-button
      >
      <el-button type="primary" @click="zuizClick">流程查看</el-button>
    </div>
  </div>
</template>
<script lang="ts">
export default {
  name: 'meritRatingDetail',
}
</script>
<script setup lang="ts">
import informationBasicInfo from './components/informationBasicInfo.vue'
import Base64 from '@/utils/base64'
import { useRoute } from 'vue-router'
import { useNavTabs } from '@/stores/modules/navTabs' // 标签导航
import productService from '@/api/zhongjian/productApi' // 接口文件
import _ from 'lodash'
import router from '@/router'
import uploadInfo from './components/uploadInfo.vue' // 上传文件、视频
const currentTab = ref<string>('1')
const route = useRoute()
interface BasicInfoType {
  id?: string // 客户id
  parentId: string
  editType: ''
  parentName: string
  terminalCategoryName: string
  terminalCategoryCode: string
  superior: string
  remark: string
  addType: string // 添加按钮类型
}
 
const state = reactive<any>({
  visible: false,
  title: '',
  editType: 'add',
  id: '',
  parentName: '',
  basicInfo: {
    editType: '',
    addType: '', // 添加按钮类型
  },
  fullscreen: false, // 全屏对话框
  routeData: {}, // 路由传参
  srcData: '',
  submitDisabled: false,
  isSaveChapter: false,
  richTextList: [],
  isSaveSubmit: false,
})
const richTextListCopy = [
  {
    chapterHead: '',
    chapterContent: '',
  },
]
const uploadVideoRef = ref()
const uploadFileRef = ref()
const informationBasicInfoRef = ref()
const goBackList = () => {
  currentTab.value = '1'
  router.push({
    path: '/safety/performance/meritRatingManage',
  })
}
// 产品章节------------------------开始
//添加 产品章节
const addChapter = () => {
  state.richTextList.push({
    chapterHead: '',
    chapterContent: '',
  })
}
// 删除产品章节
const deleteChapter = (index?: any) => {
  if (state.richTextList.length <= 1) {
    return
  }
  state.richTextList.splice(index, 1)
}
 
// 子级调用
const updateDataFun = (val?: any, indexData?: any) => {
  state.richTextList[indexData].chapterContent = val
}
// 产品章节------------------------结束
// ---------------------------------------------------------------
const saveBasicInfos = () => {
  informationBasicInfoRef.value.saveBasicInfo().then((res: any) => {
    console.log('resresresres', res)
    if (res) {
      const params = _.cloneDeep(res)
      let richText: any = state.richTextList.map((item: any, index) => {
        return {
          ...item,
          id: '',
          sort: index + 1,
          productId: state.id,
        }
      })
      params.list = richText
      saveCustomerBasicInfo(params).then((res: any) => {
        if (res && state.isSaveSubmit) {
          submitForm()
        }
      })
    } else {
      ElNotification({
        type: 'error',
        message: '请将基本信息的必填项填写完整!',
      })
      currentTab.value = '1'
      return
    }
  })
}
// 保存草稿
const saveBasicDraft = () => {
  state.isSaveSubmit = false
  saveBasicInfos()
}
// 提交
const submitClick = () => {
  ElMessageBox.confirm('确定要提交吗?', '提醒', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning',
  })
    .then(() => {
      state.isSaveSubmit = true
      saveBasicInfos()
    })
    .catch(() => {})
}
const submitForm = () => {
  productService.submitUrl({ id: state.id }).then((res: any) => {
    if (res.code == 200) {
      goBackList()
    }
  })
}
const handleShowNextTab = (data: any) => {
  if(data){
    saveBasic(data)
    currentTab.value = '2'
  }else{
    ElNotification({
        type: 'error',
        message: '请将基本信息的必填项填写完整!',
      })
      currentTab.value = '1'
      return
  }
}
// 保存基本信息
const saveBasic = (params: any) => {
    if (state.id) {
      params.id = state.id
      // 编辑- 更新
      updateCustomerInfo(params) 
    } else {
      // 新增
      addNewInformation(params) 
    }
}
// 保存基本信息
const saveCustomerBasicInfo = (params: any) => {
  return new Promise((resolve: any) => {
    if (state.id) {
      params.id = state.id
      // 编辑- 更新
      updateCustomerInfo(params).then((res: any) => {
        if (res) {
          ElNotification({
            type: 'success',
            message: state.isSaveSubmit?'产品信息提交成功!':'产品基本信息及章节信息保存成功!',
          })
          resolve(true)
        } else {
          resolve(false)
        }
      })
    } else {
      // 新增
      addNewInformation(params).then((res: any) => {
        if (res) {
          ElNotification({
            type: 'success',
            message: state.isSaveSubmit?'产品信息提交成功!':'产品基本信息及章节信息保存成功!',
          })
          resolve(true)
        } else {
          resolve(false)
        }
      })
    }
  })
}
const uploadFileRow = () => {
  const obj = {
    typeData: 'file',
    id: state.id,
  }
  uploadFileRef.value.visibleShowT(obj)
}
// 上传视频
const uploadVideoRow = () => {
  const obj = {
    typeData: 'video',
    id: state.id,
  }
  uploadVideoRef.value.visibleShowT(obj)
}
// 新增基本信息-存草稿
const addNewInformation = (data: any) => {
  return new Promise((resolve: any) => {
    productService
      .optionCreateUrl({
        ...data,
      })
      .then((res) => {
        if (res.code == 200) {
          state.id = res.data
          localStorage.setItem('productputid', res.data)
          resolve(true)
        } else {
          resolve(false)
        }
      })
  })
}
 
// 编辑修改基本信息-存草稿
const updateCustomerInfo = (data: any) => {
  return new Promise((resolve: any) => {
    productService
      .optionUpdateUrl({
        ...data,
      })
      .then((res: any) => {
        if (res.code == 200) {
          resolve(true)
        } else {
          resolve(false)
        }
      })
  })
}
 
// 根据id查看详情
const queryDetailById = () => {
  const param: object = {
    id: state.id,
  }
  productService
    .getIdListUrl({
      ...param,
    })
    .then((res) => {
      if (res.code == 200) {
        state.basicInfo = { ...res.data }
        informationBasicInfoRef.value.setData(res.data)
        let rich:any= res.data.productSubmissionDetailDOList 
        let richList:any =rich.length>0?rich: richTextListCopy
        state.richTextList = richList
      }
    })
}
 
const zuizClick = () => {
  state.visible = true
  const history_url: string = import.meta.env.VITE_IFREAM_URL as string
  if (state.routeData.flowId) {
    state.srcData = `${history_url}/activity/history?processinstId=${state.routeData.flowId}&token=${state.routeData.token}`
  }
}
onActivated(() => {
  currentTab.value = '1'
  state.routeData = JSON.parse(Base64.decode(route.query.info))
  state.id = localStorage.getItem('productputid')
  state.basicInfo = {
    quotationSystemName: '',
  }
  nextTick(() => {
    informationBasicInfoRef.value.handleRemoveFile()
  })
  if (!state.id) {
    state.title = '新增产品基本信息'
    state.isSaveChapter = false
    state.richTextList =[
      {
        chapterHead: '',
        chapterContent: '',
      },
    ]
    informationBasicInfoRef.value.setData(false)
    uploadFileRef.value.clearTableList()
    uploadVideoRef.value.clearTableList()
    uploadVideoRow()
    uploadFileRow()
  }
  if (state.id) {
    state.title = '编辑产品基本信息'
    // 编辑时根据id获取详情
    queryDetailById()
    uploadVideoRow()
    uploadFileRow()
  }
})
</script>
<style scoped lang="scss">
.bodyBox {
  width: 100%;
  height: 79vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.absolutBnt {
  position: absolute;
  width: 315px;
  top: 8px;
  right: 15px;
  z-index: 999;
  display: flex;
  justify-content: space-around;
}
.bodyDiv {
  width: 100%;
  height: 74vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
  padding-top: 10px;
  padding-bottom: 20px;
 
  .childDiv {
    width: 98%;
 
    .titDiv {
      width: 100%;
      height: 40px;
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: space-around;
 
      span {
        display: inline-block;
        font-size: 14px;
        display: inline-block;
        width: 70px;
        margin-left: 20px;
      }
 
      .iptDiv {
        width: 94%;
      }
    }
 
    .ctnDiv {
      width: 100%;
      height: 443px;
 
      .topDiv {
        width: 100%;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-around;
 
        span {
          font-size: 14px;
          display: inline-block;
          width: 70px;
          margin-left: 20px;
        }
 
        .richTextDiv {
          width: 94%;
        }
      }
 
      .btmBtnDiv {
        width: 100%;
        display: flex;
        margin-top: 10px;
        padding-left: 98px;
      }
    }
  }
}
.form-footer {
  position: fixed;
  height: 55px;
  bottom: 32px;
  width: 500px;
  z-index: 99;
  align-items: center;
  display: flex;
  justify-content: center;
  background-color: #fff;
  // margin-left: 20%;
}
</style>