Browse Source

feat:去提交

maliang 4 ngày trước cách đây
mục cha
commit
b5ca95b69f

+ 3 - 0
common/request/apis/inventoryTask.js

@@ -11,6 +11,9 @@ export const taskStocktakingDetail = (
 //开始任务
 export const startTask = (taskId, config = { custom: { auth: true } }) =>
   uni.$u.http.get(`/pda/startTask/${taskId}`, config);
+//完成任务
+export const taskComplete = (taskId, config = { custom: { auth: true } }) =>
+  uni.$u.http.get(`/pda/taskComplete/${taskId}`, config);
 //负责人下拉列表
 export const creatorSpinnerList = (
   taskId,

+ 1 - 0
pages/inventory-task/components/check-item.vue

@@ -109,6 +109,7 @@ export default {
         background: "#0256ff",
         fontSize: "32rpx",
         borderRadius: "8rpx",
+        marginLeft: "20rpx",
       },
     };
   },

+ 60 - 0
pages/inventory-task/index.vue

@@ -41,20 +41,35 @@
         <u-loadmore :status="loadStatus" @loadmore="onLoadMore" />
       </view>
     </view>
+
+    <error-pop
+      v-model="actionPop.errorShow"
+      isCenter
+      cancelBtnText="取消"
+      confirmBtnText="确定"
+      @close="actionPop.errorShow = false"
+      @confirm="submit"
+      :content="actionPop.errorText"
+    ></error-pop>
   </view>
 </template>
 
 <script>
 import checkItem from "./components/check-item.vue";
+import errorPop from "@/components/error-pop/error-pop.vue";
+
 import {
   taskStocktakingList,
   startTask,
+  taskComplete,
+  taskStocktakingDetail,
 } from "@/common/request/apis/inventoryTask";
 import { taskStatusList } from "../inventory-task/utils/index.js";
 
 export default {
   components: {
     checkItem,
+    errorPop,
   },
   data() {
     return {
@@ -68,6 +83,14 @@ export default {
       pageSize: 10,
       loadStatus: "loadmore", //加载前值为loadmore,加载中为loading,没有数据为nomore
       list: [],
+
+      activeTaskId: null,
+      actionPop: {
+        // 警告提示弹框状态
+        errorShow: false,
+        submitActionFlag: false,
+        errorText: "是否提交盘点?",
+      },
     };
   },
   onLoad() {
@@ -158,9 +181,46 @@ export default {
           });
           break;
         case "去提交":
+          taskStocktakingDetail(data.id).then((res) => {
+            console.log("taskStocktakingDetail=======", res);
+            let { finishCount, materialCount } = res.data;
+            const a = Number(finishCount || 0);
+            const b = Number(materialCount || 0);
+            this.activeTaskId = data.id;
+            this.actionPop.errorShow = true;
+            if (a === b) {
+              // 进度100%
+              this.actionPop.errorText = "是否提交盘点?";
+              this.actionPop.submitActionFlag = true;
+            } else {
+              this.actionPop.errorText = "尚有货物未完成盘点,请先去盘点";
+              this.actionPop.submitActionFlag = false;
+            }
+          });
+
           break;
       }
     },
+    resetErrorPopData() {
+      this.actionPop.errorShow = false;
+      this.actionPop.submitActionFlag = false;
+      this.actionPop.errorShow = "";
+    },
+    submit() {
+      if (this.actionPop.submitActionFlag) {
+        taskComplete(this.activeTaskId).then((res) => {
+          this.resetErrorPopData();
+          if (res.code === 200) {
+            uni.$u.toast(res.msg);
+            this.onRefresh();
+          } else {
+            uni.$u.toast(res.data);
+          }
+        });
+      } else {
+        this.resetErrorPopData();
+      }
+    },
   },
 };
 </script>