Pārlūkot izejas kodu

新增导出导入方法

zhouhao 2 gadi atpakaļ
vecāks
revīzija
86d5483317

+ 64 - 0
src/utils/request.js

@@ -116,3 +116,67 @@ export function postBlob(data) {
       })
   })
 }
+
+// get方式导出文件
+export function getBlob(data) {
+  return new Promise(function (r, j) {
+    axios({
+      url: process.env.VUE_APP_BASE_API + data.url,
+      method: 'get',
+      responseType: 'blob',
+      params: data.data, // 与post传参方式不同之处
+      headers: {
+        'x-token': getToken() // 请求头
+      }
+    })
+      .then(res => {
+        var blob = new Blob([res.data], {
+          type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document;charset=utf-8'
+        })
+        var filename = data.name + '.xlsx'
+        var downloadElement = document.createElement('a')
+        var href = window.URL.createObjectURL(blob) // 创建下载的链接
+        downloadElement.style.display = 'none'
+        downloadElement.href = href
+        downloadElement.download = filename // 下载后文件名
+        document.body.appendChild(downloadElement)
+        downloadElement.click() // 点击下载
+        document.body.removeChild(downloadElement) // 下载完成移除元素
+        window.URL.revokeObjectURL(href) // 释放掉blob对象
+        r()
+      })
+      .catch(err => {
+        console.log(err.message)
+        j()
+      })
+  })
+}
+
+/**
+ * 导入功能
+ * @param {*} url
+ * @param {*} formData
+ * @param {*} id
+ */
+export async function handleImport(url, formData, id = '') {
+  return await new Promise((resolve, reject) => {
+    axios
+      .post(process.env.VUE_APP_BASE_API + url, formData, {
+        headers: {
+          'Content-Type': 'multipart/form-data',
+          'x-token': getToken(),
+          id
+        }
+      })
+      .then(res => {
+        if (res.data.code !== 1) {
+          reject(new Error(res.data.message || 'Error'))
+          return
+        }
+        resolve(res.data)
+      })
+      .catch(err => {
+        reject(err)
+      })
+  })
+}

+ 11 - 9
src/views/supply/apply/apply_list.vue

@@ -7,10 +7,12 @@
           <template #left_btn>
             <el-radio-group v-model="screenForm.status" size="mini" @change="getList()">
               <el-radio-button label="">全部</el-radio-button>
-              <el-radio-button v-for="(item, index) in statusList" :key="index" :label="item.value">{{
-                  item.label
-                }}
-              </el-radio-button>
+              <template v-for="(item, index) in statusList" >
+                <el-radio-button v-if="index !== 3" :key="index" :label="item.value">{{
+                    item.label
+                  }}
+                </el-radio-button>
+              </template>
             </el-radio-group>
           </template>
           <template #right_btn>
@@ -383,10 +385,10 @@
                   v-if="
                     $checkBtnRole('apply', $route.meta.roles) &&
                     (( !isCustomer && !scope.row.automaticStatus &&
-                    scope.row.examineStatus === 'SAVE')||(isCustomer && !scope.row.automaticStatus &&
-                    scope.row.examineStatus === 'SAVE' && scope.row.type!=2) || (
+                    (scope.row.examineStatus === 'SAVE'|| scope.row.examineStatus === 'FAIL'))||(isCustomer && !scope.row.automaticStatus &&
+                    (scope.row.examineStatus === 'SAVE'|| scope.row.examineStatus === 'FAIL') && scope.row.type!=2) || (
                     !isCustomer  &&  scope.row.automaticStatus &&
-                     scope.row.examineStatus === 'SAVE' &&
+                     (scope.row.examineStatus === 'SAVE'|| scope.row.examineStatus === 'FAIL') &&
                      scope.row.type===2
                     ) )
                   "
@@ -442,7 +444,7 @@
                       ((!isCustomer && !scope.row.automaticStatus &&
                       (scope.row.examineStatus === 'SAVE' || scope.row.examineStatus === 'FAIL') &&
                       scope.row.type === 2)||(isCustomer && !scope.row.automaticStatus &&
-                    (scope.row.examineStatus === 'SAVE' || scope.row.examineStatus === 'FAIL') && scope.row.type!=2)  ||
+                    (scope.row.examineStatus === 'SAVE' || scope.row.examineStatus === 'FAIL') && scope.row.type!=2 && scope.row.type !==1)  ||
                       ( !isCustomer && scope.row.automaticStatus &&
                      (scope.row.examineStatus === 'SAVE' || scope.row.examineStatus === 'FAIL') &&
                      scope.row.type===2)
@@ -567,7 +569,7 @@ export default {
         { label: '已保存', value: 'SAVE' },
         { label: '待审核', value: 'WAIT' },
         { label: '审核通过', value: 'OK' },
-        //  // { label: '审核驳回', value: 'FAIL' },,
+        { label: '审核驳回', value: 'FAIL' },
         { label: '已关闭', value: 'CLOSE' }
       ],
       orderTypeList: [

+ 13 - 10
src/views/supply/apply/engin_list.vue

@@ -7,10 +7,13 @@
           <template #left_btn>
             <el-radio-group size="mini" v-model="screenForm.status" @change="getList()">
               <el-radio-button label="">全部</el-radio-button>
-              <el-radio-button v-for="(item, index) in statusList" :key="index" :label="item.value">{{
-                  item.label
-                }}
-              </el-radio-button>
+              <template v-for="(item, index) in statusList" >
+                <el-radio-button v-if="index !== 3" :key="index" :label="item.value">{{
+                    item.label
+                  }}
+                </el-radio-button>
+              </template>
+
             </el-radio-group>
           </template>
           <template #right_btn>
@@ -412,10 +415,10 @@
                   v-if="
                     $checkBtnRole('apply', $route.meta.roles) &&
                     ((!isCustomer &&!scope.row.automaticStatus &&
-                    scope.row.examineStatus === 'SAVE')||(isCustomer && !scope.row.automaticStatus &&
-                    scope.row.examineStatus === 'SAVE' && scope.row.type!=2)  || (
+                    (scope.row.examineStatus === 'SAVE'|| scope.row.examineStatus === 'FAIL'))||(isCustomer && !scope.row.automaticStatus &&
+                    (scope.row.examineStatus === 'SAVE'|| scope.row.examineStatus === 'FAIL') && scope.row.type!=2)  || (
                      !isCustomer  && scope.row.automaticStatus &&
-                     scope.row.examineStatus === 'SAVE' &&
+                    (scope.row.examineStatus === 'SAVE'|| scope.row.examineStatus === 'FAIL') &&
                      scope.row.type===2
                     ) )
                   "
@@ -455,7 +458,7 @@
                 </el-popconfirm>
                 <el-button
                   v-if="
-                    !scope.row.automaticStatus &&
+                     !scope.row.automaticStatus &&
                     $checkBtnRole('edit', $route.meta.roles) &&
                     (scope.row.examineStatus === 'SAVE' || scope.row.examineStatus === 'FAIL') &&
                     scope.row.type === 1
@@ -471,7 +474,7 @@
                     (( !isCustomer &&!scope.row.automaticStatus &&
                       (scope.row.examineStatus === 'SAVE' || scope.row.examineStatus === 'FAIL') &&
                       scope.row.type === 2 )||(isCustomer && !scope.row.automaticStatus &&
-                    (scope.row.examineStatus === 'SAVE' || scope.row.examineStatus === 'FAIL') && scope.row.type!=2) ||
+                    (scope.row.examineStatus === 'SAVE' || scope.row.examineStatus === 'FAIL') && scope.row.type!=2 && scope.type!==1) ||
                        (!isCustomer  &&scope.row.automaticStatus &&
                       (scope.row.examineStatus === 'SAVE' || scope.row.examineStatus === 'FAIL') &&
                      scope.row.type===2))
@@ -596,7 +599,7 @@ export default {
         { label: '已保存', value: 'SAVE' },
         { label: '待审核', value: 'WAIT' },
         { label: '审核通过', value: 'OK' },
-        //  // { label: '审核驳回', value: 'FAIL' },,
+        { label: '审核驳回', value: 'FAIL' },
         { label: '已关闭', value: 'CLOSE' }
       ],
       orderTypeList: [