Bladeren bron

提交文件

Lijy 1 jaar geleden
bovenliggende
commit
1f5a7eece6

+ 3 - 3
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/product/index.vue

@@ -118,7 +118,7 @@
       </template>
       <div class="p-8">
         <div class="ml-4 mr-4">
-          <div class="flex items-center">1、点击下载 <el-link type="primary">产品导入模板.xlsx</el-link></div>
+          <div class="flex items-center">1、点击下载 <el-link type="primary" @click="downloadTemplate(MODUCODE, '产品导入模板.xlsx')">产品导入模板.xlsx</el-link></div>
           <div class="mt-4">2、填写excel文件、产品编号、产品名称、产品类别、标准价格、库存、状态必填</div>
         </div>
       </div>
@@ -131,8 +131,8 @@
 
 <script lang="ts" setup>
 import { ref, reactive, onMounted, inject } from "vue";
-import { GETSYSFILED, MOD, GETPERSONNEL, GETTEMPLATE, GETTABLELIST, ADDPRODUCT, ALLDETELE, UPLOADFILE } from './api'
-import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, getLastDayOfMonth, formatDate, createTaskFromType, confirmAction } from '@/utils/tools'
+import { GETSYSFILED, MOD, MODUCODE, GETPERSONNEL, GETTEMPLATE, GETTABLELIST, ADDPRODUCT, ALLDETELE, UPLOADFILE } from './api'
+import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, getLastDayOfMonth, formatDate, createTaskFromType, confirmAction, downloadTemplate } from '@/utils/tools'
 import { FormInstance, FormRules, ElMessageBox, ElTable, UploadRequestOptions } from 'element-plus'
 import { post, get, uploadFile } from "@/utils/request";
 import { useRouter, useRoute } from "vue-router";

+ 2 - 2
fhKeeper/formulahousekeeper/customerBuler-crm/src/utils/request.ts

@@ -30,10 +30,10 @@ instance.interceptors.request.use(
 instance.interceptors.response.use(
   (response: AxiosResponse) => {
     // 对响应数据进行处理
-    if (response.status != 200) {
+    if (response.status !== 200 || response.data.code === 'error') {
       ElNotification.closeAll()
       ElNotification({
-        message: showMessage(response.status), // 传入响应码,匹配响应码对应信息,
+        message: response.status !== 200 ? showMessage(response.status) : response.data.msg,
         type: "error",
       });
     }

+ 13 - 1
fhKeeper/formulahousekeeper/customerBuler-crm/src/utils/tools.ts

@@ -1,6 +1,7 @@
 import { defalutModalForm } from "@/components/TaskModal/api";
 import { ElMessageBox } from "element-plus";
-import { get } from "./request";
+import { IMPORTTIMELIST } from '../pages/api'
+import { get, post } from "./request";
 /**
  * 判断值是否为空
  * @param value 值
@@ -203,3 +204,14 @@ export function confirmAction(
 export function backPath() {
   window.history.go(-1);
 }
+
+/**
+ * 下载模板
+ * @param mod 模块名称(模板链接)
+ * @param fileName 下载的文件名称
+ */
+export function downloadTemplate(mod: any, fileName: string) {
+  post(`${IMPORTTIMELIST}`, { code: mod }).then((res: any) => {
+    downloadFile(res.data, fileName)
+  });
+}