Browse Source

feat(records): change url

gemercheung 1 year ago
parent
commit
be9bbcb033
2 changed files with 71 additions and 33 deletions
  1. 6 2
      src/store/case.ts
  2. 65 31
      src/view/case/records/index.vue

+ 6 - 2
src/store/case.ts

@@ -8,7 +8,8 @@ import {
   syncInfo,
   updateCaseFile,
   caseInquestInfo,
-  caseInquestOpt
+  caseInquestOpt,
+  caseInquestExport
 } from "@/request";
 import { ModelScene, QuoteScene, Scene, SceneType } from "./scene";
 import { CaseFile } from "./caseFile";
@@ -78,4 +79,7 @@ export const getCaseInquestInfo = (caseId: number) =>
 
 
 export const saveCaseInquestInfo = (caseId: number, data) =>
-  axios.post(caseInquestOpt, { caseId, ...data });
+  axios.post(caseInquestOpt, { caseId, ...data });
+
+export const exportCaseInquestInfo = (caseId: number) =>
+  axios.post(caseInquestExport, { caseId });

+ 65 - 31
src/view/case/records/index.vue

@@ -3,7 +3,7 @@
   <div class="records">
     <div class="header">
       <el-button type="primary" @click="handleSave">保存</el-button>
-      <el-button>导出</el-button>
+      <el-button @click="handleExport">导出</el-button>
     </div>
     <h3 class="title">基本信息</h3>
     <div class="content">
@@ -18,24 +18,36 @@
       <div class="line">
         <span>勘验时间:</span>
         <div>
-          <el-input class="input" :maxlength="4" type="text" v-model="data.start.year" placeholder=""
+          <el-input class="input" :maxlength="4" type="text" v-model="data.startTime.year" placeholder=""
             style="width: 80px;" />
           <span>年</span>
-          <el-input class="input" :maxlength="2" type="text" v-model="data.start.month" placeholder=""
+          <el-input class="input" :maxlength="2" type="text" v-model="data.startTime.month" placeholder=""
             style="width: 80px;" />
           <span>月</span>
-          <el-input class="input" :maxlength="2" type="text" v-model="data.start.day" placeholder=""
+          <el-input class="input" :maxlength="2" type="text" v-model="data.startTime.day" placeholder=""
             style="width: 80px;" />
           <span>日</span>
+          <el-input class="input" :maxlength="2" type="text" v-model="data.startTime.hour" placeholder=""
+            style="width: 80px;" />
+          <span>时</span>
+          <el-input class="input" :maxlength="2" type="text" v-model="data.startTime.min" placeholder=""
+            style="width: 80px;" />
+          <span>分</span>
         </div>
         <span style="width: 60px;text-align: center">至</span>
         <div>
-          <el-input class="input" :maxlength="4" v-model="data.end.year" placeholder="" style="width: 80px;" />
+          <el-input class="input" :maxlength="4" v-model="data.endTime.year" placeholder="" style="width: 80px;" />
           <span>年</span>
-          <el-input class="input" :maxlength="2" v-model="data.end.month" placeholder="" style="width: 80px;" />
+          <el-input class="input" :maxlength="2" v-model="data.endTime.month" placeholder="" style="width: 80px;" />
           <span>月</span>
-          <el-input class="input" :maxlength="2" v-model="data.end.day" placeholder="" style="width: 80px;" />
+          <el-input class="input" :maxlength="2" v-model="data.endTime.day" placeholder="" style="width: 80px;" />
           <span>日</span>
+          <el-input class="input" :maxlength="2" type="text" v-model="data.endTime.hour" placeholder=""
+            style="width: 80px;" />
+          <span>时</span>
+          <el-input class="input" :maxlength="2" type="text" v-model="data.endTime.min" placeholder=""
+            style="width: 80px;" />
+          <span>分</span>
         </div>
       </div>
 
@@ -148,24 +160,29 @@ import { onMounted, ref, watch } from 'vue';
 import { reactive } from 'vue'
 import {
   getCaseInquestInfo,
-  saveCaseInquestInfo
+  saveCaseInquestInfo,
+  exportCaseInquestInfo
 } from "@/store/case";
-import { start } from 'repl';
+import { ElMessage } from 'element-plus'
 const props = defineProps({ caseId: Number })
 
 console.log(props)
 
 const data = reactive({
   count: "",
-  start: {
+  startTime: {
     year: "",
     month: "",
-    day: ""
+    day: "",
+    hour: "",
+    min: ""
   },
-  end: {
+  endTime: {
     year: "",
     month: "",
-    day: ""
+    day: "",
+    hour: "",
+    min: ""
   },
   address: '',
   userInfo: '',
@@ -197,19 +214,29 @@ const data = reactive({
 
 watch(data, newValue => {
   // data.userName = newValue.userName.replace(/[^0-9]/g, '');
-  const sMonth = newValue.start.month.replace(/[^0-9]/g, '');
-  const sDay = newValue.start.day.replace(/[^0-9]/g, '');
+  const sMonth = newValue.startTime.month.replace(/[^0-9]/g, '');
+  const sDay = newValue.startTime.day.replace(/[^0-9]/g, '');
+  const sHour = newValue.startTime.hour.replace(/[^0-9]/g, '');
+  const sMin = newValue.startTime.min.replace(/[^0-9]/g, '');
 
-  const eMonth = newValue.end.month.replace(/[^0-9]/g, '');
-  const eDay = newValue.end.day.replace(/[^0-9]/g, '');
+  const eMonth = newValue.endTime.month.replace(/[^0-9]/g, '');
+  const eDay = newValue.endTime.day.replace(/[^0-9]/g, '');
+  const eHour = newValue.endTime.hour.replace(/[^0-9]/g, '');
+  const eMin = newValue.endTime.min.replace(/[^0-9]/g, '');
 
-  data.start.year = newValue.start.year.replace(/[^0-9]/g, '');
-  data.start.month = Number(sMonth) > 12 ? '12' : sMonth;
-  data.start.day = Number(sDay) > 31 ? '31' : sDay;
 
-  data.end.year = newValue.end.year.replace(/[^0-9]/g, '');
-  data.end.month = Number(eMonth) > 12 ? '12' : eMonth;
-  data.end.day = Number(eDay) > 31 ? '31' : eDay;
+  data.startTime.year = newValue.startTime.year.replace(/[^0-9]/g, '');
+  data.startTime.month = Number(sMonth) > 12 ? '12' : sMonth;
+  data.startTime.day = Number(sDay) > 31 ? '31' : sDay;
+  data.startTime.hour = Number(sDay) > 24 ? '24' : sHour;
+  data.startTime.min = Number(sMin) > 60 ? '0' : sMin;
+
+  data.endTime.year = newValue.endTime.year.replace(/[^0-9]/g, '');
+  data.endTime.month = Number(eMonth) > 12 ? '12' : eMonth;
+  data.endTime.day = Number(eDay) > 31 ? '31' : eDay;
+  data.endTime.hour = Number(eHour) > 24 ? '24' : eHour;
+  data.endTime.min = Number(eMin) > 60 ? '0' : eMin;
+
 
   newValue.witnessInfo.forEach((item, key) => {
     const year = newValue.witnessInfo[key].year.replace(/[^0-9]/g, '');
@@ -230,6 +257,12 @@ 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])
+      data[k] = res.data[k]
+    }
+  }
 })
 
 const addwitnessInfo = () => {
@@ -244,13 +277,14 @@ const addwitnessInfo = () => {
 }
 
 const handleSave = async () => {
-  // console.log('data', data)
-  // const postData = {
-  //   startTime: data.start.year + data.start.month + data.start.day,
-  //   endTime: data.end.year + data.end.month + data.end.day,
-  //   ...data
-  // }
-  // await saveCaseInquestInfo(props.caseId, postData);
+  console.log('data', data)
+  const res = await saveCaseInquestInfo(props.caseId, data);
+  if (res.code === 0) {
+    ElMessage.success('保存成功!')
+  }
+}
+const handleExport = async () => {
+  const res = exportCaseInquestInfo(props.caseId);
 }
 
 </script>
@@ -263,7 +297,7 @@ const handleSave = async () => {
 
   .header {
     display: flex;
-    justify-content: flex-end;
+    justify-content: flex-endTime;
   }
 
   .input {