|
@@ -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}
|
|
|
|
|
+}
|