wenhongquan 3 年之前
父節點
當前提交
6ad20858d8
共有 2 個文件被更改,包括 256 次插入202 次删除
  1. 255 200
      src/views/mb/task/disposal/index.vue
  2. 1 2
      src/views/mb/task/index.vue

+ 255 - 200
src/views/mb/task/disposal/index.vue

@@ -70,148 +70,146 @@
               placeholder="请输入公里数"
             />
 
-
             <van-tabs v-model:active="activeName">
               <van-tab title="工作量" name="1">
                 <van-row>
                   <van-col :span="24" v-for="item in czobj.gzldata">
-                    <div style="margin-bottom:10px">
-                       <van-row>
-                      <!-- <van-col :span="8"><div style="text-align: right;padding-right:6px">{{ item.name }}:</div></van-col> -->
-                      <van-col :span="item.hasOwnProperty('value2') ? 16 : 24">
-                        <van-field
-                          v-model="item.value1"
-                          placeholder="请输入"
-                          :label="item.name"
-                        >
-                          <template #button v-if="item.unit1!==''">{{
-                            item.unit1
-                          }}</template></van-field
-                        >
-                      </van-col>
-                      <van-col :span="8" v-if="item.hasOwnProperty('value2')">
-                        <div style="padding-left:5px">
-                           <van-field
-                          v-if="item.hasOwnProperty('value2')"
-                          v-model="item.value2"
-                          placeholder="请输入"
+                    <div style="margin-bottom: 10px">
+                      <van-row>
+                        <!-- <van-col :span="8"><div style="text-align: right;padding-right:6px">{{ item.name }}:</div></van-col> -->
+                        <van-col
+                          :span="item.hasOwnProperty('value2') ? 16 : 24"
                         >
-                          <template #button v-if="item.unit2!==''">{{
-                            item.unit2
-                          }}</template></van-field>
-                        </div>
-                      </van-col>
-                    </van-row>
-
+                          <van-field
+                            v-model="item.value1"
+                            placeholder="请输入"
+                            :label="item.name"
+                          >
+                            <template #button v-if="item.unit1 !== ''">{{
+                              item.unit1
+                            }}</template></van-field
+                          >
+                        </van-col>
+                        <van-col :span="8" v-if="item.hasOwnProperty('value2')">
+                          <div style="padding-left: 5px">
+                            <van-field
+                              v-if="item.hasOwnProperty('value2')"
+                              v-model="item.value2"
+                              placeholder="请输入"
+                            >
+                              <template #button v-if="item.unit2 !== ''">{{
+                                item.unit2
+                              }}</template></van-field
+                            >
+                          </div>
+                        </van-col>
+                      </van-row>
                     </div>
                   </van-col>
-
                 </van-row>
               </van-tab>
               <van-tab title="车辆设备" name="2">
-                 <van-row>
+                <van-row>
                   <van-col :span="24" v-for="item in czobj.clsbdata">
-                    <div style="margin-bottom:10px">
-                       <van-row>
-                      <!-- <van-col :span="8"><div style="text-align: right;padding-right:6px">{{ item.name }}:</div></van-col> -->
-                      <van-col :span="item.hasOwnProperty('value2') ? 16 : 24">
-                        <van-field
-                          v-model="item.value1"
-                          placeholder="请输入"
-                          :label="item.name"
-                        >
-                          <template #button v-if="item.unit1!==''">{{
-                            item.unit1
-                          }}</template></van-field
+                    <div style="margin-bottom: 10px">
+                      <van-row>
+                        <!-- <van-col :span="8"><div style="text-align: right;padding-right:6px">{{ item.name }}:</div></van-col> -->
+                        <van-col
+                          :span="item.hasOwnProperty('value2') ? 16 : 24"
                         >
-                      </van-col>
-                      <van-col :span="8" v-if="item.hasOwnProperty('value2')">
-                        <div style="padding-left:5px">
-                           <van-field
-                          v-if="item.hasOwnProperty('value2')"
-                          v-model="item.value2"
-                          placeholder="请输入"
-                        >
-                          <template #button v-if="item.unit2!==''">{{
-                            item.unit2
-                          }}</template></van-field>
-                        </div>
-                      </van-col>
-                    </van-row>
-
+                          <van-field
+                            v-model="item.value1"
+                            placeholder="请输入"
+                            :label="item.name"
+                          >
+                            <template #button v-if="item.unit1 !== ''">{{
+                              item.unit1
+                            }}</template></van-field
+                          >
+                        </van-col>
+                        <van-col :span="8" v-if="item.hasOwnProperty('value2')">
+                          <div style="padding-left: 5px">
+                            <van-field
+                              v-if="item.hasOwnProperty('value2')"
+                              v-model="item.value2"
+                              placeholder="请输入"
+                            >
+                              <template #button v-if="item.unit2 !== ''">{{
+                                item.unit2
+                              }}</template></van-field
+                            >
+                          </div>
+                        </van-col>
+                      </van-row>
                     </div>
                   </van-col>
-
                 </van-row>
               </van-tab>
               <van-tab title="耗材" name="3">
-                 <van-row>
+                <van-row>
                   <van-col :span="24" v-for="item in czobj.hcdata">
-                    <div style="margin-bottom:10px">
-                       <van-row>
-                      <!-- <van-col :span="8"><div style="text-align: right;padding-right:6px">{{ item.name }}:</div></van-col> -->
-                      <van-col :span="item.hasOwnProperty('value2') ? 16 : 24">
-                        <van-field
-                          v-model="item.value1"
-                          placeholder="请输入"
-                          :label="item.name"
-                        >
-                          <template #button v-if="item.unit1!==''">{{
-                            item.unit1
-                          }}</template></van-field
+                    <div style="margin-bottom: 10px">
+                      <van-row>
+                        <!-- <van-col :span="8"><div style="text-align: right;padding-right:6px">{{ item.name }}:</div></van-col> -->
+                        <van-col
+                          :span="item.hasOwnProperty('value2') ? 16 : 24"
                         >
-                      </van-col>
-                      <van-col :span="8" v-if="item.hasOwnProperty('value2')">
-                        <div style="padding-left:5px">
-                           <van-field
-                          v-if="item.hasOwnProperty('value2')"
-                          v-model="item.value2"
-                          placeholder="请输入"
-                        >
-                          <template #button v-if="item.unit2!==''">{{
-                            item.unit2
-                          }}</template></van-field>
-                        </div>
-                      </van-col>
-                    </van-row>
-
+                          <van-field
+                            v-model="item.value1"
+                            placeholder="请输入"
+                            :label="item.name"
+                          >
+                            <template #button v-if="item.unit1 !== ''">{{
+                              item.unit1
+                            }}</template></van-field
+                          >
+                        </van-col>
+                        <van-col :span="8" v-if="item.hasOwnProperty('value2')">
+                          <div style="padding-left: 5px">
+                            <van-field
+                              v-if="item.hasOwnProperty('value2')"
+                              v-model="item.value2"
+                              placeholder="请输入"
+                            >
+                              <template #button v-if="item.unit2 !== ''">{{
+                                item.unit2
+                              }}</template></van-field
+                            >
+                          </div>
+                        </van-col>
+                      </van-row>
                     </div>
                   </van-col>
-
                 </van-row>
               </van-tab>
             </van-tabs>
 
-
             <van-field
               v-model="czobj.images[0]"
               name="处置前照片"
               label="处置前照片"
             >
-               <template #input>
+              <template #input>
                 <ImageUpload v-model="czobj.images[0]"></ImageUpload>
-               </template>
-
+              </template>
             </van-field>
-             <van-field
+            <van-field
               v-model="czobj.images[1]"
               name="处置中照片"
               label="处置中照片"
             >
-               <template #input>
+              <template #input>
                 <ImageUpload v-model="czobj.images[1]"></ImageUpload>
-               </template>
-
+              </template>
             </van-field>
-             <van-field
+            <van-field
               v-model="czobj.images[2]"
               name="处置后照片"
               label="处置后照片"
             >
-               <template #input>
+              <template #input>
                 <ImageUpload v-model="czobj.images[2]"></ImageUpload>
-               </template>
-
+              </template>
             </van-field>
             <van-field
               v-model="taskinfo.taskAddr"
@@ -237,13 +235,22 @@
           </van-cell-group>
 
           <div style="margin: 16px">
-            <van-button round block type="primary" native-type="submit">
-              暂存
-            </van-button>
-
-            <van-button round block type="primary" native-type="submit1">
-              处置完成
-            </van-button>
+            <van-row>
+              <van-col :span="12">
+                <div style="padding-right: 5px">
+                  <van-button round block type="primary" native-type="submit">
+                    暂存
+                  </van-button>
+                </div>
+              </van-col>
+              <van-col :span="12">
+                <div style="padding-left: 5px">
+                  <van-button round block type="primary" native-type="submit1">
+                    处置完成
+                  </van-button>
+                </div>
+              </van-col>
+            </van-row>
           </div>
         </van-form>
       </div>
@@ -288,19 +295,13 @@ import {
   addUser,
 } from "@/api/system/user";
 
-const {
-  sys_area,
-  task_work,
-  task_car,
-  task_consumables,
-} = useDict(
+const { sys_area, task_work, task_car, task_consumables } = useDict(
   "sys_area",
   "task_work",
   "task_car",
   "task_consumables"
 );
 
-
 const activeName = "1";
 const route = useRoute();
 
@@ -308,21 +309,76 @@ const bhobj = ref({ resonRemark: [], files: "", images: [] });
 
 const czobj = ref({
   qsdes: "",
-  images: ["","",""],
+  images: ["", "", ""],
   gzldata: [],
   clsbdata: [],
   hcdata: [],
 });
+const xyobj = ref({
+  bzxytime: "",
+  ddxctime: "",
+  czwctime: "",
+  zysc: "",
+  clsc: "",
+  zyfzr: "",
+  zyrs: 0,
+  carxh: "",
+  carnumber: "",
+  gls: "",
+});
 
 var task = localStorage.getItem("currenttask");
+
 try {
   if (task) {
     task = JSON.parse(task);
+
     if (task.taskId != Number(route.query.id)) {
       Toast.fail("未查到任务");
       router.back();
     }
+    var templist = {};
+    var list = task.tblTaskLogList;
+    for (var i in list) {
+      var log = list[i];
+      if (templist.hasOwnProperty(log.taskStatus + "")) {
+        if (
+          moment(templist[log.taskStatus + ""].createTime).unix() -
+            moment(log.createTime).unix() <
+          0
+        ) {
+          templist[log.taskStatus + ""] = log;
+        }
+      } else {
+        templist[log.taskStatus + ""] = log;
+      }
+    }
+    var lists = [];
+    for (var i in templist) {
+      lists.push(templist[i]);
+    }
+    task.tblTaskLogList = lists;
+
+
+
+    var logs1 = (task.tblTaskLogList ?? []).filter(
+      (i) => i.taskStatus == -1
+    );
+
+    if (Array.isArray(logs1) && logs1.length > 0) {
+      var log = JSON.parse(logs1[0].logDes);
+      if (log.bzxytime) log.bzxytime = moment(log.bzxytime)._d;
+      if (log.ddxctime) log.ddxctime = moment(log.ddxctime)._d;
+      if (log.czwctime) log.czwctime = moment(log.czwctime)._d;
+      xyobj.value = log;
+    }
+
+
+
+
+
     var logs = (task.tblTaskLogList ?? []).filter((i) => i.taskStatus == 2);
+
     if (Array.isArray(logs) && logs.length > 0) {
       var log = JSON.parse(logs[0].logDes);
       czobj.value = log;
@@ -333,18 +389,17 @@ try {
           czobj.value.images = log.images;
         }
       } else {
-         czobj.value.images = ["", "", ""]
+        czobj.value.images = ["", "", ""];
       }
-      if (!czobj.value.hasOwnProperty('gzldata')) {
+      if (!czobj.value.hasOwnProperty("gzldata")) {
         czobj.value.gzldata = [];
       }
-      if (!czobj.value.hasOwnProperty('clsbdata')) {
+      if (!czobj.value.hasOwnProperty("clsbdata")) {
         czobj.value.clsbdata = [];
       }
-      if (!czobj.value.hasOwnProperty('hcdata')) {
+      if (!czobj.value.hasOwnProperty("hcdata")) {
         czobj.value.hcdata = [];
       }
-
     }
   } else {
     Toast.fail("未查到任务");
@@ -354,29 +409,34 @@ try {
 
 const bodyheight = ref(0);
 const gettaskitemlogdes = (item, status) => {
-   var templist = {};
-    var list = item.tblTaskLogList;
-    for (var i in list) {
-      var log = list[i];
-      if (templist.hasOwnProperty(log.taskStatus + "")) {
-        if (
-          moment(templist[log.taskStatus + ""].createTime).unix() -
-            moment(log.createTime).unix() <
-          0
-        ) {
-          templist[log.taskStatus + ""] = log;
-        }
-      } else {
+  var templist = {};
+  var list = item.tblTaskLogList;
+  for (var i in list) {
+    var log = list[i];
+    if (templist.hasOwnProperty(log.taskStatus + "")) {
+      if (
+        moment(templist[log.taskStatus + ""].createTime).unix() -
+          moment(log.createTime).unix() <
+        0
+      ) {
         templist[log.taskStatus + ""] = log;
       }
+    } else {
+      templist[log.taskStatus + ""] = log;
     }
-    var lists = [];
-    for (var i in templist) {
-      lists.push(templist[i]);
-    }
-  if (templist[status + ""] == null || templist[status + ""] == undefined || templist[status + ""] == "") return null;
+  }
+  var lists = [];
+  for (var i in templist) {
+    lists.push(templist[i]);
+  }
+  if (
+    templist[status + ""] == null ||
+    templist[status + ""] == undefined ||
+    templist[status + ""] == ""
+  )
+    return null;
   return JSON.parse(templist[status + ""].logDes);
-}
+};
 
 bodyheight.value = document.body.clientHeight - 48;
 
@@ -428,18 +488,6 @@ if (route.query.bh != "1") {
 }
 
 
-const xyobj = ref({
-  bzxytime: "",
-  ddxctime: "",
-  czwctime: "",
-  zysc: "",
-  clsc: "",
-  zyfzr: "",
-  zyrs: 0,
-  carxh: "",
-  carnumber: "",
-  gls: "",
-});
 const onSubmitbh = async () => {
 
   const TaskClose = () => {
@@ -448,15 +496,15 @@ const onSubmitbh = async () => {
       logDes: JSON.stringify(bhobj.value),
     }).then(async (res) => {
       var logc = gettaskitemlogdes(taskinfo.value, -1);
-      if (logc !=null) {
-       xyobj.value = logc;
+      if (logc != null) {
+        xyobj.value = logc;
       }
-     xyobj.value.czwctime = moment().format("YYYY-MM-DD HH:mm:ss");
-     await ddTask({
-      taskId: item.taskId,
-      taskStatus: -1,
-      logDes: JSON.stringify(xyobj.value)
-     })
+      xyobj.value.czwctime = moment().format("YYYY-MM-DD HH:mm:ss");
+      await ddTask({
+        taskId: item.taskId,
+        taskStatus: -1,
+        logDes: JSON.stringify(xyobj.value),
+      });
       Toast.success("成功");
       router.back();
     });
@@ -487,9 +535,9 @@ watch(
 
 const onSubmit = async () => {
   Toast.loading({
-  message: '加载中...',
-  forbidClick: true,
-});
+    message: "加载中...",
+    forbidClick: true,
+  });
   ddTask({
     taskId: Number(route.query.id),
     taskStatus: 3,
@@ -499,52 +547,52 @@ const onSubmit = async () => {
     await ddTask({
       taskId: Number(route.query.id),
       taskStatus: -1,
-      logDes: JSON.stringify(xyobj.value)
-    })
+      logDes: JSON.stringify(xyobj.value),
+    });
     Toast.clear();
-      Toast.success("成功");
-      router.back();
-
+    Toast.success("成功");
+    router.back();
   });
 };
 
 const onSubmit1 = async () => {
   Toast.loading({
-  message: '加载中...',
-  forbidClick: true,
+    message: "加载中...",
+    forbidClick: true,
   });
   await updateTask(taskinfo.value);
+  await ddTask({
+    taskId: Number(route.query.id),
+    taskStatus: -1,
+    logDes: JSON.stringify(xyobj.value),
+  });
   czTask({
     taskId: Number(route.query.id),
     logDes: JSON.stringify(czobj.value),
   }).then((res) => {
-    await ddTask({
-      taskId: Number(route.query.id),
-      taskStatus: -1,
-      logDes: JSON.stringify(xyobj.value)
-    })
     Toast.clear();
-      Toast.success("成功");
-      router.back();
+    Toast.success("成功");
+    router.back();
   });
-
 };
 
 const onClickLeft = () => {
   router.back();
 };
 
-watch(() => task_work.value, () => {
-  task_work.value.map((i) => {
-      i.remark = i.remark == undefined || i.remark == null ? '' : i.remark;
+watch(
+  () => task_work.value,
+  () => {
+    task_work.value.map((i) => {
+      i.remark = i.remark == undefined || i.remark == null ? "" : i.remark;
       var data = { name: i.label, unit1: i.remark };
       if ((i.remark ?? "").split(",").length > 1) {
-        data["value1"] = '';
-        data["value2"] = '';
+        data["value1"] = "";
+        data["value2"] = "";
         data["unit1"] = (i.remark ?? "").split(",")[0];
         data["unit2"] = (i.remark ?? "").split(",")[1];
       } else {
-        data["value1"] = '';
+        data["value1"] = "";
       }
       var temp = czobj.value.gzldata.find((p) => {
         return p.name == data.name;
@@ -552,20 +600,23 @@ watch(() => task_work.value, () => {
       if (temp == undefined) {
         czobj.value.gzldata.push(data);
       }
-      });
-})
+    });
+  }
+);
 
-watch(() => task_car.value, () => {
-  task_car.value.map((i) => {
-      i.remark = i.remark == undefined || i.remark == null ? '' : i.remark;
+watch(
+  () => task_car.value,
+  () => {
+    task_car.value.map((i) => {
+      i.remark = i.remark == undefined || i.remark == null ? "" : i.remark;
       var data = { name: i.label, unit1: i.remark };
       if ((i.remark ?? "").split(",").length > 1) {
-        data["value1"] = '';
-        data["value2"] = '';
+        data["value1"] = "";
+        data["value2"] = "";
         data["unit1"] = (i.remark ?? "").split(",")[0];
         data["unit2"] = (i.remark ?? "").split(",")[1];
       } else {
-        data["value1"] = '';
+        data["value1"] = "";
       }
       var temp = czobj.value.clsbdata.find((p) => {
         return p.name == data.name;
@@ -573,20 +624,23 @@ watch(() => task_car.value, () => {
       if (temp == undefined) {
         czobj.value.clsbdata.push(data);
       }
-      });
-})
+    });
+  }
+);
 
-watch(() => task_consumables.value, () => {
-  task_consumables.value.map((i) => {
-      i.remark = i.remark == undefined || i.remark == null ? '' : i.remark;
+watch(
+  () => task_consumables.value,
+  () => {
+    task_consumables.value.map((i) => {
+      i.remark = i.remark == undefined || i.remark == null ? "" : i.remark;
       var data = { name: i.label, unit1: i.remark };
       if ((i.remark ?? "").split(",").length > 1) {
-        data["value1"] = '';
-        data["value2"] = '';
+        data["value1"] = "";
+        data["value2"] = "";
         data["unit1"] = (i.remark ?? "").split(",")[0];
         data["unit2"] = (i.remark ?? "").split(",")[1];
       } else {
-        data["value1"] = '';
+        data["value1"] = "";
       }
       var temp = czobj.value.hcdata.find((p) => {
         return p.name == data.name;
@@ -594,8 +648,9 @@ watch(() => task_consumables.value, () => {
       if (temp == undefined) {
         czobj.value.hcdata.push(data);
       }
-      });
-})
+    });
+  }
+);
 
 onMounted(() => {
   formlocation.value.addr = taskinfo.value.taskAddr;

+ 1 - 2
src/views/mb/task/index.vue

@@ -148,8 +148,7 @@
                           >
                           <van-button
                             v-if="
-                              (gettaskitemlogdes(item, -1) ?? {}).ddxctime !==
-                              ''
+                              item.status === 2
                             "
                             type="primary"
                             size="small"