Pārlūkot izejas kodu

删除项目 功能

XuZinan 3 gadi atpakaļ
vecāks
revīzija
75fd67c93d
3 mainītis faili ar 64 papildinājumiem un 13 dzēšanām
  1. 8 5
      pages/Project/add.vue
  2. 52 8
      pages/Project/detail.vue
  3. 4 0
      services/project.js

+ 8 - 5
pages/Project/add.vue

@@ -262,16 +262,19 @@ export default {
         form.flow = this.flowList.find(
           (item) => item.id == this.currentProject.flow_id
         );
-        if (current.type.id != 7) {
+        if (current.type_id != 7) {
           form.industry = this.industryList.find(
             (item) => item.id == this.currentProject.industry_id
           );
-          form.location = current.location;
+          form.location = {
+            name: current.location,
+            code: current.location_code,
+          };
           form.name = current.name;
           form.version = current.version;
           code.type = form.type.code;
           code.industry = form.industry.code;
-          code.location = form.location;
+          code.location = form.location.code;
           code.name = form.name;
           code.version = form.version;
         }
@@ -325,10 +328,10 @@ export default {
       let location = provinces[multiIndex[0]].children
         ? provinces[multiIndex[0]].children[multiIndex[1]]
         : provinces[multiIndex[0]];
-      let code =
+      location.code =
         location.code.length == 4 ? location.code.substr(1) : location.code;
       this.formData.location = location;
-      this.formData.code.location = code;
+      this.formData.code.location = location.code;
     },
   },
 };

+ 52 - 8
pages/Project/detail.vue

@@ -101,13 +101,15 @@
 
     <uni-card title="操作">
       <view class="editBtns" slot="actions">
-        <view class="edit" v-if="canEdit(0)">编辑</view>
-        <view class="edit" v-if="canEdit(0)">删除</view>
-        <view class="edit" v-if="canEdit(0)">提交审核</view>
-        <view class="edit" v-if="canEdit(1)">成员管理</view>
-        <view class="edit" v-if="canEdit(2)">转执行</view>
-        <view class="edit" v-if="canEdit(3)">转质保</view>
-        <view class="edit" v-if="canEdit(3)">转运营</view>
+        <view class="edit" v-if="canEdit(0)" @click="onEdit()">编辑</view>
+        <view class="edit" v-if="canEdit(0)" @click="onDelete()">删除</view>
+        <view class="edit" v-if="canEdit(0)" @click="onSubmitAuth()"
+          >提交审核</view
+        >
+        <view class="edit" v-if="canEdit(1)" @click="onMember()">成员管理</view>
+        <view class="edit" v-if="canEdit(2)" @click="onExecute()">转执行</view>
+        <view class="edit" v-if="canEdit(3)" @click="onWarranty()">转质保</view>
+        <view class="edit" v-if="canEdit(3)" @click="onOperate()">转运营</view>
       </view>
     </uni-card>
 
@@ -129,7 +131,7 @@
 
 <script>
 import { mapState } from "vuex";
-import { queryFlow } from "@/services/project";
+import { queryFlow, deleteApproval } from "@/services/project";
 export default {
   data() {
     return {
@@ -249,6 +251,48 @@ export default {
           );
       }
     },
+    onEdit() {
+      uni.navigateTo({
+        url: `./add?project_id=${this.currentProject.id}`,
+      });
+    },
+    onDelete() {
+      uni.showModal({
+        title: "删除项目",
+        content: "是否确认删除该项目",
+        confirmText: "删除",
+        confirmColor: "#ff7875",
+        success: async (res) => {
+          if (res.confirm) {
+            await deleteApproval(this.currentProject);
+            uni.showToast({
+              title: "删除成功",
+            });
+            setTimeout(function () {
+              uni.hideToast();
+              uni.navigateTo({
+                url: "./list",
+              });
+            }, 1800);
+          }
+        },
+      });
+    },
+    onSubmitAuth() {
+      return;
+    },
+    onMember() {
+      return;
+    },
+    onExecute() {
+      return;
+    },
+    onWarranty() {
+      return;
+    },
+    onOperate() {
+      return;
+    },
   },
 };
 </script>

+ 4 - 0
services/project.js

@@ -19,3 +19,7 @@ export async function queryIndustry() {
 export async function queryFlow() {
   return await request("v2/approval/flow", "GET");
 }
+
+export async function deleteApproval(data) {
+  return request(`v2/approval/record/${data.id}`, { method: "DELETE" });
+}