Browse Source

feat(records): change url

gemercheung 1 year ago
parent
commit
21bc8ffe1d
3 changed files with 22 additions and 19 deletions
  1. 3 2
      src/request/index.ts
  2. 5 5
      src/store/case.ts
  3. 14 12
      src/view/case/records/index.vue

+ 3 - 2
src/request/index.ts

@@ -26,7 +26,7 @@ export type AuthHook = () => {
   clear: () => void;
 };
 export const setAuthHook = (hook: AuthHook) => (getAuth = hook);
-let getAuth: AuthHook = () => ({ token: "", userId: "0", clear: () => {} });
+let getAuth: AuthHook = () => ({ token: "", userId: "0", clear: () => { } });
 
 axios.defaults.baseURL = baseURL;
 
@@ -83,7 +83,8 @@ axios.interceptors.request.use(async (config) => {
 
 const responseInterceptor = (res: AxiosResponse<any, any>) => {
   closeLoading();
-  if (!successCode.includes(res.data.code)) {
+  const hasIgnore = res.config.params ? 'ingoreRes' in res.config.params : false
+  if (!successCode.includes(res.data.code) && !hasIgnore) {
     let errMsg = res.data.msg || res.data.message;
     openErrorMsg(errMsg);
 

+ 5 - 5
src/store/case.ts

@@ -29,9 +29,9 @@ export type Case = {
 export type CaseImg = {
   id: number;
   caseId: number;
-  imgInfo: string| null;
-  imgUrl: string| null;
-  status: number| null;
+  imgInfo: string | null;
+  imgUrl: string | null;
+  status: number | null;
   sort: number | null;
 };
 
@@ -89,7 +89,7 @@ export const caseImgList = (caseId: number, orderBy: string) =>
   axios.post(caseApiList, { orderBy: orderBy || '', caseId });
 
 export const saveOrUpdate = (params: CaseImg) =>
-  axios.post(saveApiOrUpdate, { ...params});
+  axios.post(saveApiOrUpdate, { ...params });
 
 export const caseDel = (id: number) =>
   axios.post(caseApiDel, { id });
@@ -102,4 +102,4 @@ export const saveCaseInquestInfo = (caseId: number, data) =>
   axios.post(caseInquestOpt, { caseId, ...data });
 
 export const exportCaseInquestInfo = (caseId: number) =>
-  axios.post(caseInquestExport, { caseId });
+  axios.get(caseInquestExport, { params: { caseId, ingoreRes: true }, responseType: 'blob' });

+ 14 - 12
src/view/case/records/index.vue

@@ -123,23 +123,23 @@
 
       <div class="gap"></div>
       <!-- 证人 -->
-      <template v-for="index of witnessInfoes">
+      <template v-for="item of data.witnessInfo">
         <div class="witnessInfo">
           <span class="sub-tit">证人信息:</span>
           <div class="line">
             <span>证人或当事人:</span>
-            <el-input class="input" v-model="data.witnessInfo[index - 1].name" placeholder="" style="width: 180px;" />
+            <el-input class="input" v-model="item.name" placeholder="" style="width: 180px;" />
             <div>
-              <el-input class="input" v-model="data.witnessInfo[index - 1].year" placeholder="" style="width: 80px;" />
+              <el-input class="input" v-model="item.year" placeholder="" style="width: 80px;" />
               <span>年</span>
-              <el-input class="input" v-model="data.witnessInfo[index - 1].month" placeholder="" style="width: 80px;" />
+              <el-input class="input" v-model="item.month" placeholder="" style="width: 80px;" />
               <span>月</span>
-              <el-input class="input" v-model="data.witnessInfo[index - 1].day" placeholder="" style="width: 80px;" />
+              <el-input class="input" v-model="item.day" placeholder="" style="width: 80px;" />
               <span>日</span>
             </div>
 
             <span style="margin-left:50px">身份证件号码:</span>
-            <el-input class="input" v-model="data.witnessInfo[index - 1].id" placeholder="" style="width: 280px;" />
+            <el-input class="input" v-model="item.id" placeholder="" style="width: 280px;" />
           </div>
         </div>
 
@@ -164,6 +164,7 @@ import {
   exportCaseInquestInfo
 } from "@/store/case";
 import { ElMessage } from 'element-plus'
+import saveAs from "@/util/file-serve";
 const props = defineProps({ caseId: Number })
 
 console.log(props)
@@ -252,21 +253,20 @@ watch(data, newValue => {
   deep: true
 })
 
-const witnessInfoes = ref(2)
-
 onMounted(async () => {
   const res = await getCaseInquestInfo(props.caseId);
   console.log('res', res)
   for (var k in data) {
-    if (res.data.hasOwnProperty(k)) {
-      // console.log("Key is " + k + ", value is " + res.data[k])
+    if (res.data && res.data.hasOwnProperty(k)) {
+      console.log("Key is " + k)
       data[k] = res.data[k]
     }
   }
+
 })
 
 const addwitnessInfo = () => {
-  witnessInfoes.value += 1
+  // witnessInfoes.value += 1
   data.witnessInfo.push({
     name: "",
     year: "",
@@ -284,7 +284,9 @@ const handleSave = async () => {
   }
 }
 const handleExport = async () => {
-  const res = exportCaseInquestInfo(props.caseId);
+  const res = await exportCaseInquestInfo(props.caseId);
+  console.log('res', res)
+  saveAs(res, `勘验笔录-${props.caseId}.docx`)
 }
 
 </script>