瀏覽代碼

提取公共函数“dealStepData”

chris 3 年之前
父節點
當前提交
5e60d46005
共有 2 個文件被更改,包括 34 次插入25 次删除
  1. 32 0
      src/api/util.js
  2. 2 25
      src/views/modules/cus/contract-add-or-update.vue

+ 32 - 0
src/api/util.js

@@ -0,0 +1,32 @@
+/**
+ * 处理流程图数据
+ * @param list 数据来源
+ * @param stepList 流程数据列表
+ */
+export function dealStepData (list, stepList) {
+  if (list) {
+    stepList.push({
+      icon: 'el-icon-location-outline',
+      title: '开始'
+    })
+    list.forEach((item) => {
+      stepList.push({
+        icon: item.approvalState === '0' ? 'el-icon-location' : 'el-icon-location-outline',
+        title: item.stepName,
+        description: formatStepDesc(item.processLogInfoList)
+      })
+    })
+    stepList.push({
+      icon: 'el-icon-location-outline',
+      title: '结束'
+    })
+  }
+}
+export function formatStepDesc (lst) {
+  if (!lst) return ''
+  let str = ''
+  lst.forEach((item) => {
+    str = str + '\n' + item.approver + '    ' + item.createTime + '    ' + item.approvalValue
+  })
+  return str
+}

+ 2 - 25
src/views/modules/cus/contract-add-or-update.vue

@@ -109,6 +109,7 @@
   import { getCoCode, geTreDetail } from '@/api/cus'
   import { getDictList } from '@/api/dict'
   import { uploadUrl, downloadUrl, uploadFiles } from '@/api/file'
+  import { dealStepData } from '@/api/util'
   export default {
     name: 'stock-order-inbound',
     computed: {
@@ -180,23 +181,7 @@
           if (data && data.code === '200') {
             this.dataForm = data.data
             // 流程图展示
-            if (data.data.workFlowBusinessExt.workFlowStepInfoList) {
-              this.stepList.push({
-                icon: 'el-icon-location-outline',
-                title: '开始'
-              })
-              data.data.workFlowBusinessExt.workFlowStepInfoList.forEach((item) => {
-                this.stepList.push({
-                  icon: item.approvalState === '0' ? 'el-icon-location' : 'el-icon-location-outline',
-                  title: item.stepName,
-                  description: this.formatStepDesc(item.processLogInfoList)
-                })
-              })
-              this.stepList.push({
-                icon: 'el-icon-location-outline',
-                title: '结束'
-              })
-            }
+            dealStepData(data.data.workFlowBusinessExt.workFlowStepInfoList, this.stepList)
             // 附件显示
             this.fileList = []
             data.data.attachList.forEach((item) => {
@@ -209,14 +194,6 @@
           }
         })
       },
-      formatStepDesc (lst) {
-        if (!lst) return ''
-        let str = ''
-        lst.forEach((item) => {
-          str = str + '\n' + item.approver + '    ' + item.createTime + '    ' + item.approvalValue
-        })
-        return str
-      },
       submitUpload () {
         // this.$refs.upload.submit()
         if (this.fileList.length === 0) {