wenhongquan 3 years ago
parent
commit
e458660277
2 changed files with 300 additions and 78 deletions
  1. 214 73
      src/views/mb/task/disposal/index.vue
  2. 86 5
      src/views/mb/task/index.vue

+ 214 - 73
src/views/mb/task/disposal/index.vue

@@ -1,47 +1,104 @@
 <template>
   <div>
     <van-nav-bar
-      title="工单新增"
+      :title="route.query.bh == '1' ? '驳回反馈' : '处置反馈'"
       left-text="返回"
       left-arrow
       @click-left="onClickLeft"
     />
     <div class="listcontent" :style="`height:${bodyheight}px`">
-      <van-form @submit="onSubmit">
-        <van-cell-group>
-
-          <van-field
-            v-model="czobj.qsdes"
-            name="权属确认"
-            label="权属确认"
-            placeholder="请输入权属确认(现场勘查)"
-          />
-          <van-field
-            v-model="taskinfo.taskAddr"
-            name="详细地址"
-            label="详细地址"
-            placeholder="详细地址"
-          >
-            <template #button>
-              <van-button
-                size="small"
-                type="primary"
-                icon="search"
-                @click="searchaddr"
-              ></van-button>
-            </template>
-          </van-field>
-          <div style="padding-top: 10px">
-            <MapSelect ref="mapSelect" v-model:formv="formlocation"></MapSelect>
+      <div v-if="route.query.bh == '1'">
+        <van-form @submit="onSubmitbh">
+          <van-cell-group>
+            <van-field
+              v-model="bhobj.resonRemark"
+              name="驳回原因"
+              label="驳回原因"
+              placeholder="请输入驳回原因"
+            />
+            <van-field name="现场图片" label="现场图片">
+              <template #input>
+                <ImageUpload v-model="bhobj.images"></ImageUpload>
+              </template>
+            </van-field>
+
+            <van-field name="说明报告" label="说明报告">
+              <template #input>
+                <FileUpload v-model="bhobj.files" :fileSize="100"></FileUpload>
+              </template>
+            </van-field>
+          </van-cell-group>
+          <div style="margin: 16px">
+            <van-button round block type="primary" native-type="submit">
+              提交
+            </van-button>
+          </div>
+        </van-form>
+      </div>
+      <div v-if="route.query.bh != '1'">
+        <van-form @submit="onSubmit">
+          <van-cell-group>
+            <van-field
+              v-model="czobj.qsdes"
+              name="权属确认"
+              label="权属确认"
+              placeholder="请输入权属确认(现场勘查)"
+            />
+            <van-field
+              v-model="xyobj.zyrs"
+              name="作业人数"
+              label="作业人数"
+              type="number"
+              placeholder="请输入"
+            />
+            <van-field
+              v-model="xyobj.carxh"
+              name="车辆型号"
+              label="车辆型号"
+              placeholder="请输入车辆型号"
+            />
+            <van-field
+              v-model="xyobj.carnumber"
+              name="车辆号牌"
+              label="车辆号牌"
+              placeholder="请输入车辆号牌"
+            />
+            <van-field
+              v-model="xyobj.gls"
+              name="公里数"
+              label="公里数"
+              placeholder="请输入公里数"
+            />
+            <van-field
+              v-model="taskinfo.taskAddr"
+              name="详细地址"
+              label="详细地址"
+              placeholder="详细地址"
+            >
+              <template #button>
+                <van-button
+                  size="small"
+                  type="primary"
+                  icon="search"
+                  @click="searchaddr"
+                ></van-button>
+              </template>
+            </van-field>
+            <div style="padding-top: 10px">
+              <MapSelect
+                ref="mapSelect"
+                v-model:formv="formlocation"
+              ></MapSelect>
+            </div>
+          </van-cell-group>
+
+          <div style="margin: 16px">
+            <van-button round block type="primary" native-type="submit">
+              提交
+            </van-button>
           </div>
-        </van-cell-group>
-
-        <div style="margin: 16px">
-          <van-button round block type="primary" native-type="submit">
-            提交
-          </van-button>
-        </div>
-      </van-form>
+        </van-form>
+      </div>
     </div>
   </div>
 </template>
@@ -55,6 +112,8 @@ import { useDict } from "@/utils/dict";
 import { useRoute } from "vue-router";
 import MapSelect from "@/components/MapSelect";
 import moment from "moment";
+import ImageUpload from "@/components/ImageUpload";
+import FileUpload from "@/components/FileUpload";
 import {
   listTask,
   getTask,
@@ -66,7 +125,7 @@ import {
   czTask,
   gzTask,
   hcTask,
-  ddTask
+  ddTask,
 } from "@/api/system/task";
 import {
   changeUserStatus,
@@ -83,6 +142,7 @@ import router from "../../../../router";
 
 const route = useRoute();
 
+const bhobj = ref({ resonRemark: [], files: "", images: [] });
 
 const czobj = ref({
   qsdes: "",
@@ -100,7 +160,7 @@ try {
       Toast.fail("未查到任务");
       router.back();
     }
-    var logs = (task.tblTaskLogList ?? []).filter(i => i.taskStatus == 2);
+    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;
@@ -109,20 +169,36 @@ try {
     Toast.fail("未查到任务");
     router.back();
   }
-
-} catch (E) {
-
-}
-
-
-
-
+} catch (E) {}
 
 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 {
+        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;
+  return JSON.parse(templist[status + ""].logDes);
+}
 
 bodyheight.value = document.body.clientHeight - 48;
 
-
 const searchaddr = () => {
   if (taskinfo.value.taskAddr) {
     mapSelect.value.searchaddr(taskinfo.value.taskAddr);
@@ -132,62 +208,127 @@ const searchaddr = () => {
 };
 
 const taskinfo = ref({
-  taskId:Number(route.query.id),
+  taskId: Number(route.query.id),
   taskAddr: task.taskAddr,
   taskLocation: task.taskLocation,
-  taskArea:task.taskArea,
+  taskArea: task.taskArea,
 });
 
 const mapSelect = ref(null);
 const formlocation = ref({ addr: "", locations: "" });
-watch(
-  () => formlocation.value.addr,
-  () => {
-    taskinfo.value.taskAddr = formlocation.value.addr;
-
-  }
-);
-watch(
-  () => formlocation.value.locations,
-  () => {
-    taskinfo.value.taskLocation = formlocation.value.locations;
-    if (formlocation.value.locations != "") {
-      mapSelect.value.getlocationaddr(formlocation.value.locations, (data) => {
-         var qu = data.regeocode.addressComponent.district;
+if (route.query.bh != "1") {
+  watch(
+    () => formlocation.value.addr,
+    () => {
+      taskinfo.value.taskAddr = formlocation.value.addr;
+    }
+  );
+  watch(
+    () => formlocation.value.locations,
+    () => {
+      taskinfo.value.taskLocation = formlocation.value.locations;
+      if (formlocation.value.locations != "") {
+        mapSelect.value.getlocationaddr(
+          formlocation.value.locations,
+          (data) => {
+            var qu = data.regeocode.addressComponent.district;
             if (qu) {
               for (var i in sys_area.value) {
                 if (sys_area.value[i].label == qu) {
-                  taskinfo.value.taskArea = sys_area.value[i].value
+                  taskinfo.value.taskArea = sys_area.value[i].value;
                 }
               }
             }
-      })
+          }
+        );
+      }
     }
+  );
+}
+
+
+const xyobj = ref({
+  bzxytime: "",
+  ddxctime: "",
+  czwctime: "",
+  zysc: "",
+  clsc: "",
+  zyfzr: "",
+  zyrs: 0,
+  carxh: "",
+  carnumber: "",
+  gls: "",
+});
+const onSubmitbh = async () => {
 
+  const TaskClose = () => {
+    closeTask({
+      taskId: route.params.id,
+      logDes: JSON.stringify(bhobj.value),
+    }).then(async (res) => {
+      var logc = gettaskitemlogdes(taskinfo.value, -1);
+      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)
+     })
+      Toast.success("成功");
+      router.back();
+    });
+  };
+};
+
+watch(
+  [() => xyobj.value.bzxytime, xyobj.value.ddxctime, xyobj.value.czwctime],
+  () => {
+    if (xyobj.value.bzxytime != "" && xyobj.value.czwctime != "") {
+      xyobj.value.clsc =
+        (
+          (moment(xyobj.value.czwctime).unix() -
+            moment(xyobj.value.bzxytime).unix()) /
+          3600.0
+        ).toFixed(2) + "";
+    }
+    if (xyobj.value.ddxctime != "" && xyobj.value.czwctime != "") {
+      xyobj.value.zysc =
+        (
+          (moment(xyobj.value.czwctime).unix() -
+            moment(xyobj.value.ddxctime).unix()) /
+          3600.0
+        ).toFixed(2) + "";
+    }
   }
 );
 
-
 const onSubmit = async () => {
   ddTask({
     taskId: Number(route.query.id),
     taskStatus: 2,
-    logDes: JSON.stringify(czobj.value)
-  }).then( async res =>  {
+    logDes: JSON.stringify(czobj.value),
+  }).then(async (res) => {
     await updateTask(taskinfo.value);
-    Toast.success("成功");
-    router.back();
-  })
+    await ddTask({
+      taskId: item.taskId,
+      taskStatus: -1,
+      logDes: JSON.stringify(xyobj.value)
+     })
+      Toast.success("成功");
+      router.back();
+
+  });
 };
 
 const onClickLeft = () => {
   router.back();
 };
 onMounted(() => {
-   formlocation.value.addr = taskinfo.value.taskAddr;
+  formlocation.value.addr = taskinfo.value.taskAddr;
   formlocation.value.locations = taskinfo.value.taskLocation;
-
-})
+});
 </script>
 
 <style lang="scss">

+ 86 - 5
src/views/mb/task/index.vue

@@ -84,14 +84,18 @@
                     <van-row v-if="item.status == 2 && ((item.tblTaskLogList??[]).filter(i=>i.taskStatus==-1).length<1)">
                         <van-col span="24">
                          <div style="text-align:right">
-                            <van-button type="primary" size="small" @click.stop="daoda(item)">到达现场</van-button>
+                            <van-button type="primary" size="small" @click.stop="receivetask(item)">接收任务</van-button>
                           </div>
                         </van-col>
                     </van-row>
-                     <van-row v-if="item.status == 2 && ((item.tblTaskLogList??[]).filter(i=>i.taskStatus==-1).length>0)">
+
+
+                     <van-row v-if="item.status == 2 && (gettaskitemlogdes(item,-1)??{}).zyfzr === getters.userId">
                         <van-col span="24">
                          <div style="text-align:right">
-                            <van-button type="primary" size="small" @click.stop="czfk(item)">处置反馈</van-button>
+                          <van-button v-if="(gettaskitemlogdes(item,-1)??{}).ddxctime ==='' " type="primary" size="small" @click.stop="daoda(item)" style="margin-right:10px">到达现场</van-button>
+                          <van-button v-if="(gettaskitemlogdes(item,-1)??{}).ddxctime !=='' " type="primary" size="small" @click.stop="bhfk(item)" style="margin-right:10px">驳回反馈</van-button>
+                          <van-button v-if="(gettaskitemlogdes(item,-1)??{}).ddxctime !=='' " type="primary" size="small" @click.stop="czfk(item)">处置反馈</van-button>
                           </div>
                         </van-col>
                     </van-row>
@@ -120,6 +124,7 @@ import {
   ddTask,
 } from "@/api/system/task";
 import { Toast } from "vant";
+import moment from "moment";
 
 const tasklist = ref([]);
 const loading = ref(false);
@@ -199,12 +204,83 @@ const onClickRight = () => {
   router.push("/mb/task/add")
 };
 
+
+const xyobj = ref({
+  bzxytime: "",
+  ddxctime: "",
+  czwctime: "",
+  zysc: "",
+  clsc: "",
+  zyfzr: "",
+  zyrs: 0,
+  carxh: "",
+  carnumber: "",
+  gls: "",
+});
+
+const store = useStore();
+const getters = computed(() => store.getters);
+
+
+
+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 {
+        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;
+  return JSON.parse(templist[status + ""].logDes);
+}
+
+const receivetask = (item) => {
+
+  var logc = gettaskitemlogdes(item, -1);
+  if (logc !=null) {
+    xyobj.value = logc;
+  }
+
+  xyobj.value.bzxytime = moment().format("YYYY-MM-DD HH:mm:ss");
+  xyobj.value.zyfzr = getters.value.userId;
+  console.log(xyobj.value)
+   ddTask({
+    taskId: item.taskId,
+    taskStatus: -1,
+    logDes: JSON.stringify(xyobj.value)
+   }).then(res => {
+    Toast.success("成功");
+    onRefresh();
+  })
+}
+
 const daoda = (item) => {
+   var logc = gettaskitemlogdes(item, -1);
+  if (logc !=null) {
+    xyobj.value = logc;
+  }
+  xyobj.value.ddxctime = moment().format("YYYY-MM-DD HH:mm:ss");
+  xyobj.value.zyfzr = getters.value.userId;
+
   ddTask({
     taskId: item.taskId,
     taskStatus: -1,
-    logDes: JSON.stringify({"desc":"到达"})
-  }).then(res => {
+    logDes: JSON.stringify(xyobj.value)
+   }).then(res => {
     Toast.success("成功");
     onRefresh();
   })
@@ -214,6 +290,11 @@ const czfk = (item) => {
   router.push(`/mb/task/disposal?id=${item.taskId}`)
 }
 
+const bhfk = (item) => {
+  localStorage.setItem("currenttask", JSON.stringify(item));
+  router.push(`/mb/task/disposal?bh=1&id=${item.taskId}`)
+}
+
 </script>
 
 <style lang="scss">