wenhongquan 3 年之前
父節點
當前提交
596644de77
共有 2 個文件被更改,包括 100 次插入19 次删除
  1. 58 12
      src/views/detection/list/index.vue
  2. 42 7
      src/views/maintain/list/index.vue

+ 58 - 12
src/views/detection/list/index.vue

@@ -93,7 +93,7 @@
             <template #default="scope">
               {{
                 detection_status.filter(
-                  (i) => i.value === scope.row.status + ""
+                  (i) => i.value.toString() === scope.row.status.toString()
                 )[0]?.label ?? "-"
               }}
             </template>
@@ -102,11 +102,23 @@
             <template #default="scope">
               {{
                 detection_type.filter(
-                  (i) => i.value === scope.row.status + ""
+                  (i) => i.value.toString() === scope.row.detectionType.toString()
                 )[0]?.label ?? "-"
               }}
             </template>
           </el-table-column>
+          <el-table-column prop="address" label="操作">
+            <template #default="scope">
+              <el-button text size="small" @click.stop="edittask(scope.row)"
+                >修改
+              </el-button>
+              <el-popconfirm title="确定删除?" @confirm="deltask(scope.row)">
+                <template #reference>
+                  <el-button text size="small" @click.stop="">删除</el-button>
+                </template>
+              </el-popconfirm>
+            </template>
+          </el-table-column>
 
           <!-- <el-table-column prop="ext1" label="责任人" width="180">
             <template #default="scope">
@@ -172,7 +184,7 @@
                   <el-option
                     v-for="item in detection_type"
                     :label="item.label"
-                    :value="item.value"
+                    :value="parseInt(item.value)"
                   ></el-option>
                 </el-select>
               </el-form-item>
@@ -273,6 +285,7 @@ import { treeselect as deptTreeselect } from "@/api/system/dept";
 import { cloneDeep } from "lodash";
 import { ElMessage } from "element-plus";
 import { useRoute } from "vue-router";
+import { delDetection, updateDetection } from "../../../api/system/detection";
 
 const { detection_status, detection_type } = useDict(
   "detection_status",
@@ -314,6 +327,7 @@ const initadd = () => {
     detectionYear: "",
     ext1: "",
     ext2: "",
+    id:null,
     facilitiesId: 1,
     remark: null,
     status: 1,
@@ -332,16 +346,31 @@ const tblrowclick = (row) => {
 };
 
 const onadd = () => {
+ loading.value = true;
+  if (detectioninfo.value.id == null) {
+
+    var detectioninfoobj = cloneDeep(detectioninfo.value);
+    // delete detectioninfoobj.detectionDept;
+    detectioninfoobj.detectionDept = (detectioninfo.value.detectionDept instanceof Array) ? detectioninfo.value.detectionDept.join(",") : '';
+    addDetection(detectioninfoobj).then(res => {
+      loading.value = false;
+      showadd.value = false;
+      getList();
+    })
+
+  } else {
+      var detectioninfoobj = cloneDeep(detectioninfo.value);
+    // delete detectioninfoobj.detectionDept;
+    detectioninfoobj.detectionDept = (detectioninfo.value.detectionDept instanceof Array) ? detectioninfo.value.detectionDept.join(",") : '';
+    updateDetection(detectioninfoobj).then(res => {
+      loading.value = false;
+      showadd.value = false;
+      getList();
+    })
+
+  }
+
 
-  loading.value = true;
- var detectioninfoobj = cloneDeep(detectioninfo.value);
-  // delete detectioninfoobj.detectionDept;
-  detectioninfoobj.detectionDept = (detectioninfo.value.detectionDept instanceof Array) ? detectioninfo.value.detectionDept.join(","):'';
-  addDetection(detectioninfoobj).then(res => {
-    loading.value = false;
-    showadd.value = false;
-    getList();
-  })
 
 };
 
@@ -381,6 +410,23 @@ const getmonth = () => {
   return months;
 };
 
+
+
+const edittask = (row) => {
+  detectioninfo.value = cloneDeep(row);
+   if (detectioninfo.value.detectionDept!=null && detectioninfo.value.detectionDept!="" && detectioninfo.value.detectionDept!=undefined && !Array.isArray(detectioninfo.value.detectionDept)) {
+          detectioninfo.value.detectionDept = detectioninfo.value.detectionDept.split(",").map(i => parseInt(i));
+        }
+  showadd.value = true;
+};
+const deltask = (row) => {
+  delDetection(row.id).then((res) => {
+    ElMessage.success("删除成功");
+    getList();
+  });
+};
+
+
 onMounted(() => {});
 function setdatakey(dept) {
   if (dept.children) {

+ 42 - 7
src/views/maintain/list/index.vue

@@ -99,6 +99,18 @@
             </template>
           </el-table-column>
           <el-table-column prop="maintainUnit" label="养护单位" />
+          <el-table-column prop="address" label="操作">
+            <template #default="scope">
+              <el-button text size="small" @click.stop="edittask(scope.row)"
+                >修改
+              </el-button>
+              <el-popconfirm title="确定删除?" @confirm="deltask(scope.row)">
+                <template #reference>
+                  <el-button text size="small" @click.stop="">删除</el-button>
+                </template>
+              </el-popconfirm>
+            </template>
+          </el-table-column>
           <!-- <el-table-column prop="ext1" label="责任人" width="180">
             <template #default="scope">
               {{ (scope.row.ext1 == null || scope.row.ext1 === "")? "暂无" : scope.row.ext1 }}
@@ -151,7 +163,7 @@
                   <el-option
                     v-for="item in maintain_type"
                     :label="item.label"
-                    :value="item.value"
+                    :value="parseInt(item.value)"
                   ></el-option>
                 </el-select>
                 </el-form-item
@@ -251,6 +263,7 @@ import { cloneDeep } from "lodash";
 import { ElMessage } from "element-plus";
 
 import { useRoute } from "vue-router";
+import { delMaintain, updateMaintain } from "../../../api/system/maintain";
 
 const { maintain_status, maintain_type } = useDict(
   "maintain_status",
@@ -290,7 +303,8 @@ const initadd = () => {
     maintainType: "",
     maintainUnit: "",
     maintainYear: "",
-    maintainReportNp:1,
+    maintainReportNp: 1,
+    id:null,
     status: 1,
   };
 }
@@ -328,11 +342,20 @@ const tblrowclick = (row) => {
 const onadd = () => {
   // Element.loading();
   loading.value = true;
-  addMaintain(maintaininfo.value).then(res => {
-    loading.value = false;
-    showadd.value = false;
-    getList();
-  })
+  if (maintaininfo.value.id == null) {
+    addMaintain(maintaininfo.value).then(res => {
+      loading.value = false;
+      showadd.value = false;
+      getList();
+    })
+  } else {
+    updateMaintain(maintaininfo.value).then(res => {
+      loading.value = false;
+      showadd.value = false;
+      getList();
+    })
+  }
+
 };
 
 const getList = () => {
@@ -352,6 +375,18 @@ const getList = () => {
 };
 getList();
 
+
+const edittask = (row) => {
+  maintaininfo.value = cloneDeep(row);
+  showadd.value = true;
+};
+const deltask = (row) => {
+  delMaintain(row.id).then((res) => {
+    ElMessage.success("删除成功");
+    getList();
+  });
+};
+
 onMounted(() => {});
 </script>