Browse Source

出入库单下拉选择。

jxq 1 month ago
parent
commit
55bf30373e
2 changed files with 138 additions and 87 deletions
  1. 19 36
      src/api/storage/index.ts
  2. 119 51
      src/views/storage/wmsOrder/components/add_order_details.vue

+ 19 - 36
src/api/storage/index.ts

@@ -14,45 +14,35 @@ export function queryPlanPage(
     data: queryParams,
   });
 }
-export function deleteCheckPlan(
-    queryParams: object
-): AxiosPromise<any> {
+export function deleteCheckPlan(queryParams: object): AxiosPromise<any> {
   return request({
     url: "/api/v1/wms/check/del",
     method: "post",
     data: queryParams,
   });
 }
-export function saveCheckPlan(
-    queryParams: object
-): AxiosPromise<any> {
+export function saveCheckPlan(queryParams: object): AxiosPromise<any> {
   return request({
     url: "/api/v1/wms/check/add",
     method: "post",
     data: queryParams,
   });
 }
-export function queryByTaskNo(
-    taskNo: object
-): AxiosPromise<any> {
+export function queryByTaskNo(taskNo: object): AxiosPromise<any> {
   return request({
-    url: "/api/v1/wms/check/queryByTaskNo/"+ taskNo,
+    url: "/api/v1/wms/check/queryByTaskNo/" + taskNo,
     method: "get",
   });
 }
 
-export function saveDetails(
-    queryParams: object
-): AxiosPromise<any> {
+export function saveDetails(queryParams: object): AxiosPromise<any> {
   return request({
     url: "/api/v1/wms/check/saveDetails",
     method: "post",
     data: queryParams,
   });
 }
-export function auditPlan(
-    queryParams: object
-): AxiosPromise<any> {
+export function auditPlan(queryParams: object): AxiosPromise<any> {
   return request({
     url: "/api/v1/wms/check/audit",
     method: "post",
@@ -60,18 +50,14 @@ export function auditPlan(
   });
 }
 
-export function syncPositionVehicle(
-    queryParams: object
-): AxiosPromise<any> {
+export function syncPositionVehicle(queryParams: object): AxiosPromise<any> {
   return request({
     url: "/api/v1/stock/syncWcs",
     method: "post",
     data: queryParams,
   });
 }
-export function saveWmsOrder(
-    queryParams: object
-): AxiosPromise<any> {
+export function saveWmsOrder(queryParams: object): AxiosPromise<any> {
   return request({
     url: "/api/v1/wmsOrder/save",
     method: "post",
@@ -79,42 +65,39 @@ export function saveWmsOrder(
   });
 }
 
+// 根据仓库编码获取货区和货位
+export function getAreaAndPlaceByCode(houseNo: string): AxiosPromise<any> {
+  return request({
+    url: `/api/v1/wms/position/positionList/${houseNo}`,
+    method: "get",
+  });
+}
 
-export function queryWarningUser(
-    queryParams: object
-): AxiosPromise<any> {
+export function queryWarningUser(queryParams: object): AxiosPromise<any> {
   return request({
     url: "/api/v1/warningUser/page",
     method: "post",
     data: queryParams,
   });
 }
-export function delWarningUser(
-    queryParams: object
-): AxiosPromise<any> {
+export function delWarningUser(queryParams: object): AxiosPromise<any> {
   return request({
     url: "/api/v1/warningUser/del",
     method: "post",
     data: queryParams,
   });
 }
-export function addWarningUser(
-    queryParams: object
-): AxiosPromise<any> {
+export function addWarningUser(queryParams: object): AxiosPromise<any> {
   return request({
     url: "/api/v1/warningUser/add",
     method: "post",
     data: queryParams,
   });
 }
-export function outSingle(
-    queryParams: object
-): AxiosPromise<any> {
+export function outSingle(queryParams: object): AxiosPromise<any> {
   return request({
     url: "/api/v1/plan/requisition/outSingle",
     method: "post",
     data: queryParams,
   });
 }
-
-

+ 119 - 51
src/views/storage/wmsOrder/components/add_order_details.vue

@@ -30,18 +30,18 @@
       /></template>
     </avue-crud>
     <el-dialog
-        v-model="dialog1.visible"
-        :title="dialog1.title"
-        width="950px"
-        @close="dialog1.visible = false"
+      v-model="dialog1.visible"
+      :title="dialog1.title"
+      width="950px"
+      @close="dialog1.visible = false"
     >
-      <choice-item-page @material-info="materialInfo" :enabled="null"/>
+      <choice-item-page @material-info="materialInfo" :enabled="null" />
     </el-dialog>
     <el-dialog
-        v-model="dialog2.visible"
-        :title="dialog2.title"
-        width="950px"
-        @close="dialog2.visible = false"
+      v-model="dialog2.visible"
+      :title="dialog2.title"
+      width="950px"
+      @close="dialog2.visible = false"
     >
       <choice_out_materials @material-info="materialInfo" />
     </el-dialog>
@@ -54,7 +54,7 @@
 <script setup>
 import { ref, getCurrentInstance } from "vue";
 import { useCrud } from "@/hooks/userCrud";
-import {saveWmsOrder} from "@/api/storage";
+import { getAreaAndPlaceByCode, saveWmsOrder } from "@/api/storage";
 import { useCommonStoreHook, useDictionaryStore } from "@/store";
 import dictDataUtil from "@/common/configs/dictDataUtil";
 const { isShowTable, tableType } = toRefs(useCommonStoreHook());
@@ -67,12 +67,11 @@ const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
   useCrud({
     src: "/api/v1/sys/skillScore",
   });
-const emit = defineEmits(["closeDialog"])
+const emit = defineEmits(["closeDialog"]);
 const cancelWindow = () => {
-  emit("closeDialog", 11)
+  emit("closeDialog", 11);
 };
 
-
 const {
   dataList,
   createRow,
@@ -83,7 +82,7 @@ const {
 } = Methords; //增删改查
 const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
 const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
-const formRef = ref(null)
+const formRef = ref(null);
 const option2 = ref(null);
 const ctableRef = ref(null); //crudRef.value 获取avue-crud对象
 const router = useRouter();
@@ -96,7 +95,7 @@ const dialog2 = reactive({
   visible: false,
 });
 onMounted(() => {
-/*  const bom = ref({
+  /*  const bom = ref({
     batchCode: "",
     $cellEdit: true,
   });
@@ -116,15 +115,29 @@ const props = defineProps({
       return {};
     },
   },
-})
+});
 const materialInfo = (value) => {
-  if(form.value.type === '4'){
-    let item = {unit: value.unit,id: value.id,batchCode: value.batchCode,num: value.num,materialNo: value.materialNo,materialName: value.materialName,spec: value.spec,$cellEdit:
-    true,}
+  if (form.value.type === "4") {
+    let item = {
+      unit: value.unit,
+      id: value.id,
+      batchCode: value.batchCode,
+      num: value.num,
+      materialNo: value.materialNo,
+      materialName: value.materialName,
+      spec: value.spec,
+      $cellEdit: true,
+    };
     data.value[clickIndex.value] = item;
     dialog2.visible = false;
-  }else{
-    let item = {unit: value.unitDictValue,materialNo: value.materialCode,materialName: value.materialName,spec: value.spec,$cellEdit: true,}
+  } else {
+    let item = {
+      unit: value.unitDictValue,
+      materialNo: value.materialCode,
+      materialName: value.materialName,
+      spec: value.spec,
+      $cellEdit: true,
+    };
     data.value[clickIndex.value] = item;
     dialog1.visible = false;
   }
@@ -141,29 +154,67 @@ const onHandle = () => {
       }
       if (data.value.length > 0) {
         for (let i = 0; i < data.value.length; i++) {
-          if (data.value[i].materialNo === undefined || data.value[i].materialNo === null || data.value[i].materialNo === "" ) {
-            ElMessage({message: "第" + (i + 1) + "项没有选择物料",type: "error",});
+          if (
+            data.value[i].materialNo === undefined ||
+            data.value[i].materialNo === null ||
+            data.value[i].materialNo === ""
+          ) {
+            ElMessage({
+              message: "第" + (i + 1) + "项没有选择物料",
+              type: "error",
+            });
             return false;
           }
-          if ( data.value[i].batchCode === undefined || data.value[i].batchCode === null || data.value[i].batchCode === "" ) {
-            ElMessage({message: "第" + (i + 1) + "项没有输入批号",type: "error",});
+          if (
+            data.value[i].batchCode === undefined ||
+            data.value[i].batchCode === null ||
+            data.value[i].batchCode === ""
+          ) {
+            ElMessage({
+              message: "第" + (i + 1) + "项没有输入批号",
+              type: "error",
+            });
             return false;
           }
-          if ( data.value[i].num === undefined ||  data.value[i].num === null || data.value[i].num === "" ) {
-            ElMessage({message: "第" + (i + 1) + "项没有输入数量", type: "error",});
+          if (
+            data.value[i].num === undefined ||
+            data.value[i].num === null ||
+            data.value[i].num === ""
+          ) {
+            ElMessage({
+              message: "第" + (i + 1) + "项没有输入数量",
+              type: "error",
+            });
             return false;
           }
         }
       }
       //进行保存
-      const saveData = {detailsList: data.value,...form.value}
+      const saveData = { detailsList: data.value, ...form.value };
       saveData.vehicleCode = new Date().getTime();
-      saveWmsOrder(saveData).then((res)=>{
-        ElMessage.success("操作成功")
-        cancelWindow()
+      saveWmsOrder(saveData).then((res) => {
+        ElMessage.success("操作成功");
+        cancelWindow();
       });
     }
-  })
+  });
+};
+
+const areaArray = ref([]);
+const placeArray = ref([]);
+const houseNoChange = async ({ value }) => {
+  if (value) {
+    let res = await getAreaAndPlaceByCode(value);
+    areaArray.value = res.data;
+
+    formRef.value.updateDic("locationNo", areaArray.value);
+  }
+};
+
+const areaChange = async (obj) => {
+  let places = obj?.item?.positions ?? [];
+  placeArray.value = places;
+  formRef.value.updateDic("coordinate", placeArray.value);
 };
 
 // 设置表格列或者其他自定义的option
@@ -180,8 +231,8 @@ option2.value = {
       overHidden: true,
       type: "select",
       search: true,
-      change:()=>{
-        data.value = []
+      change: () => {
+        data.value = [];
       },
       rules: [
         {
@@ -190,7 +241,12 @@ option2.value = {
           trigger: "trigger",
         },
       ],
-      dicData:[{label: "原材料入库",value: "1"},{label: "工装入库",value: "2"},{label: "退料",value: "3"},{label: "出库",value: "4"}],
+      dicData: [
+        { label: "原材料入库", value: "1" },
+        { label: "工装入库", value: "2" },
+        { label: "退料", value: "3" },
+        { label: "出库", value: "4" },
+      ],
     },
     {
       label: "仓库编码",
@@ -200,9 +256,7 @@ option2.value = {
       width: 90,
       overHidden: true,
       editDisabled: true,
-      dicUrl:
-          dictDataUtil.request_url +
-          dictDataUtil.TYPE_CODE.warehouse_type,
+      dicUrl: dictDataUtil.request_url + dictDataUtil.TYPE_CODE.warehouse_type,
       props: {
         label: "dictLabel",
         value: "dictValue",
@@ -214,6 +268,7 @@ option2.value = {
           trigger: "trigger",
         },
       ],
+      change: houseNoChange,
     },
     {
       label: "任务单号",
@@ -233,7 +288,13 @@ option2.value = {
       label: "货区",
       width: 110,
       overHidden: true,
+      type: "select",
+      dictData: [],
       prop: "locationNo",
+      props: {
+        label: "area",
+        value: "area",
+      },
       rules: [
         {
           required: true,
@@ -241,11 +302,18 @@ option2.value = {
           trigger: "trigger",
         },
       ],
+      change: areaChange,
     },
     {
       label: "货位",
       overHidden: true,
       prop: "coordinate",
+      type: "select",
+      dictData: [],
+      props: {
+        label: "name",
+        value: "name",
+      },
       rules: [
         {
           required: true,
@@ -253,10 +321,10 @@ option2.value = {
           trigger: "trigger",
         },
       ],
-    }
+    },
   ],
 };
-const clickIndex = ref(0)
+const clickIndex = ref(0);
 
 // 设置表格列或者其他自定义的option
 option.value = Object.assign(option.value, {
@@ -275,15 +343,15 @@ option.value = Object.assign(option.value, {
       readonly: true,
       cell: true,
       overHidden: true,
-      click: ({ value, column ,index}) => {
-        clickIndex.value = index
-        if(!form.value.type){
-          ElMessage.error("请选择操作类型")
-        }else{
-          if(form.value.type === "4"){
-            dialog2.visible = true
-          }else{
-            dialog1.visible = true
+      click: ({ value, column, index }) => {
+        clickIndex.value = index;
+        if (!form.value.type) {
+          ElMessage.error("请选择操作类型");
+        } else {
+          if (form.value.type === "4") {
+            dialog2.visible = true;
+          } else {
+            dialog1.visible = true;
           }
         }
       },
@@ -309,7 +377,7 @@ option.value = Object.assign(option.value, {
     {
       label: "数量",
       prop: "num",
-      type: 'number',
+      type: "number",
       cell: true,
       min: 0,
       max: 99999,
@@ -317,7 +385,7 @@ option.value = Object.assign(option.value, {
     {
       label: "单位",
       prop: "unit",
-      width: 60
+      width: 60,
     },
   ],
 });