Преглед на файлове

Merge branch 'master' of http://47.101.159.18:3000/Muchinfo/MTP2.0_WEB

huangbin преди 4 години
родител
ревизия
0d0f2c40a4
променени са 1 файла, в които са добавени 58 реда и са изтрити 0 реда
  1. 58 0
      src/views/information/warehouse-info/compoments/setup.ts

+ 58 - 0
src/views/information/warehouse-info/compoments/setup.ts

@@ -0,0 +1,58 @@
+import {warehouseStateChangeReq} from "@/services/proto/warehouse";
+import {WarehouseStateChangeReq} from "@/services/proto/warehouse/interface";
+import {getSelectedAccountId} from "@/services/bus/account";
+import {ref} from "vue";
+
+export const enum wareType {
+    normal = 1, // 正常
+    stop = 2, // 停用
+}
+
+/**
+ * 更变仓库信息状态
+ * @param type normal: 将停用恢复成正常  stop: 将正常设置为停用
+ */
+export function stopOrResumeWarehouse(type: wareType){
+    const loading = ref<boolean>(false);
+    let warehousestatus = 1;
+    switch (type) {
+        case wareType.normal:
+            warehousestatus = 1  // 恢复
+            break;
+        case wareType.stop:
+            warehousestatus = 2  // 停用
+            break;
+    }
+    /**
+     * 提交切换状态请求
+     * @param warehouseid 操作的仓库id
+     */
+    function changeStatus(warehouseid: number): Promise<string>{
+        let accountid = getSelectedAccountId()?.toNumber()
+        const req: WarehouseStateChangeReq = {
+            accountid: accountid === undefined ? 0 : accountid,
+            warehouseid: warehouseid,
+            warehousestatus: warehousestatus
+        }
+        debugger
+        return warehouseStateChangeReq(req)
+            .then(res => {
+                if(warehousestatus === 1){
+                    return Promise.resolve("恢复成功")
+                }else{
+                    return Promise.resolve("停用成功")
+                }
+            })
+            .catch(err => {
+                if(warehousestatus === 1){
+                    return Promise.reject("恢复失败:"+ err)
+                }else{
+                    return Promise.reject("停用失败:"+ err)
+                }
+            })
+            .finally(() => {
+                loading.value = false
+            })
+    }
+    return {loading, changeStatus}
+}