Prechádzať zdrojové kódy

增加辅料操作页面,修改了之前禅道的bug

ooo 1 rok pred
rodič
commit
20709e936c

+ 10 - 1
src/components/CommonTable/index.vue

@@ -69,6 +69,15 @@ const refreshDictData = (propName, dictData, keyName = "value") => {
   });
 };
 
+/**
+ * op 对象的字段要跟option实际字段一直 才能进行合并操作
+ */
+const mergeOption = (op) => {
+  for (const key of Object.keys(op)) {
+    option.value[key] = op[key];
+  }
+};
+
 // 传入一个url,后面不带/
 const {
   url,
@@ -165,5 +174,5 @@ const onSelected = () => {
   isShowTable.value = false;
 };
 
-defineExpose({ startSelect, refreshDictData });
+defineExpose({ startSelect, refreshDictData, mergeOption });
 </script>

+ 1 - 1
src/store/modules/dictionary.ts

@@ -19,7 +19,7 @@ export const useDictionaryStore = defineStore("dictionaryStore", () => {
     "process_type",
     "workshop_section",
     "skill_requirements",
-    "station_type",
+    "accessories_type",
     "danwei_type",
     "trace_type",
     "skill_type",

+ 149 - 0
src/views/base/accessories/index.vue

@@ -0,0 +1,149 @@
+<template>
+  <div class="mainContentBox">
+    <avue-crud
+      ref="crudRef"
+      v-model:search="search"
+      v-model="form"
+      :data="data"
+      :option="option"
+      v-model:page="page"
+      @row-save="createRow"
+      @row-update="updateRow"
+      @row-del="deleteRow"
+      @search-change="searchChange"
+      @search-reset="resetChange"
+      @size-change="dataList"
+      @current-change="dataList"
+      @selection-change="selectionChange"
+    >
+      <template #menu-left="{ size }">
+        <el-button
+          :disabled="toDeleteIds.length < 1"
+          type="danger"
+          icon="el-icon-delete"
+          :size="size"
+          @click="multipleDelete"
+          >删除</el-button
+        >
+      </template>
+    </avue-crud>
+    <CommonTable
+      ref="ctableRef"
+      tableTitle="物料"
+      tableType="MARTERIAL"
+      @selected-sure="onSelectedFinish"
+    />
+  </div>
+</template>
+<script setup>
+import { ref, getCurrentInstance } from "vue";
+import { useCrud } from "@/hooks/userCrud";
+import dictDataUtil from "@/common/configs/dictDataUtil";
+import ButtonPermKeys from "@/common/configs/buttonPermission";
+import { useCommonStoreHook, useDictionaryStoreHook } from "@/store";
+
+// 数据字典相关
+const { dicts } = useDictionaryStoreHook();
+
+// 传入一个url,后面不带/
+const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
+  useCrud({
+    src: "/api/v1/base/accessories/material",
+  });
+const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
+  Methords; //增删改查
+const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
+const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
+
+const crudRef = ref(null); //crudRef.value 获取avue-crud对象
+const repeatObj = ref({});
+onMounted(() => {
+  // console.log("crudRef", crudRef)
+  dataList();
+});
+// 公共弹窗相关
+const ctableRef = ref(null);
+const startCreat = () => {
+  if (ctableRef.value) {
+    ctableRef.value.startSelect();
+  }
+};
+defineExpose({ startCreat });
+/**
+ * 上传excel相关
+ */
+const uploadRef = ref(null);
+const uploadFinished = () => {
+  // 上传完成后的刷新操作
+  page.currentPage = 1;
+  dataList();
+};
+const importExcelData = () => {
+  if (uploadRef.value) {
+    uploadRef.value.show("/api/v1/plan/order/import");
+  }
+};
+
+const onSelectedFinish = (selectedValue) => {
+  form.value.materialCode = selectedValue.materialCode;
+  repeatObj.value.showCreate = false;
+};
+
+// 设置表格列或者其他自定义的option
+const switchOp = [
+  {
+    label: "",
+    value: 0,
+  },
+  {
+    label: "",
+    value: 1,
+  },
+];
+option.value = Object.assign(option.value, {
+  selection: true,
+  labelWidth: 110,
+  searchLabelWidth: 110,
+  column: [
+    {
+      label: "辅料类型",
+      prop: "accessoriesType",
+      search: true,
+      type: "select",
+      dicData: dicts.accessories_type,
+      props: {
+        label: "dictLabel",
+        value: "dictValue",
+      },
+      rules: [
+        {
+          required: true,
+          message: "辅料类型不能为空",
+          trigger: "blur",
+        },
+      ],
+    },
+    {
+      label: "生产物料编码",
+      prop: "materialCode",
+      clearable: false,
+      rules: [
+        {
+          required: true,
+          message: "生产物料编码不能为空",
+          trigger: "blur",
+        },
+      ],
+      click: ({ value, column }) => {
+        repeatObj.value.showCreate = true;
+        startCreat();
+      },
+      change: ({ value, column }) => {
+        if (value != form.value.materialCode && !repeatObj.value.showCreate) {
+          startCreat();
+        }
+      },
+    },
+  ],
+});
+</script>

+ 17 - 3
src/views/base/craftManagement/route/components/bottomTable.vue

@@ -73,6 +73,11 @@ const crudRef = ref(null); //crudRef.value 获取avue-crud对象
 
 const startCreat = () => {
   if (props.tableType === "wuliaocaiji") {
+    let bomVersion = null;
+    if (data.value && data.value.length > 0) {
+      bomVersion = data.value[0].recordVersion;
+    }
+    console.log("startCreat", data.value, "bomVersion", bomVersion);
     commonTableType.value = "MARTERIAL_BOM";
     if (!route.query.prodtCode) {
       ElMessage.error("物料编号读取错误");
@@ -91,11 +96,19 @@ const startCreat = () => {
           value: versions.bomVersion,
         });
       });
+      //查询参数
+      let configParam = {};
+      configParam.materialCode = route.query.prodtCode;
+      if (bomVersion) {
+        configParam.bomVersion = bomVersion;
+      }
+      console.log("configParam", configParam);
       //根据物料编码和版本号获取对应的物料BOM
-      commonTableRef.value?.startSelect({
-        materialCode: route.query.prodtCode,
-      });
+      commonTableRef.value?.startSelect(configParam);
       commonTableRef.value?.refreshDictData("bomVersion", resListMap, "value");
+      commonTableRef.value?.mergeOption({
+        searchShow: bomVersion ? false : true,
+      });
     });
   } else if (props.tableType === "dianjian") {
     commonTableType.value = "OP_CHECK";
@@ -104,6 +117,7 @@ const startCreat = () => {
     commonTableType.value = "ESOP";
     commonTableRef.value?.startSelect({
       materialCode: route.query.prodtCode,
+      enable: 1,
     });
   } else {
     crudRef.value && crudRef.value.rowAdd();

+ 191 - 198
src/views/base/modeling/factory/index.vue

@@ -9,7 +9,7 @@
       v-model:page="page"
       @row-save="createRow"
       @row-update="updateRow"
-      @row-del="delete(row,index,done)"
+      @row-del="deletes(row, index, done)"
       @search-change="searchChange"
       @search-reset="resetChange"
       @size-change="dataList"
@@ -23,25 +23,22 @@
           icon="el-icon-delete"
           :size="size"
           @click="multipleDelete"
-        >删除</el-button
+          >删除</el-button
         >
       </template>
-      <template #menu="{row,index,type}">
-        <el-button @click="binding(row)"
-                   icon="el-icon-link"
-                   text
-                   type="primary"
-                   >绑定子项</el-button>
+      <template #menu="{ row, index, type }">
+        <el-button @click="binding(row)" icon="el-icon-link" text type="primary"
+          >绑定子项</el-button
+        >
       </template>
-
     </avue-crud>
 
-      <CommonTable
-        ref="ctableRef"
-        tableTitle="绑定子项"
-        tableType="FACTORY"
-        @selected-sure="onSelectedFinish"
-      />
+    <CommonTable
+      ref="ctableRef"
+      tableTitle="绑定子项"
+      tableType="FACTORY"
+      @selected-sure="onSelectedFinish"
+    />
     <CommonTable
       ref="workShopRef"
       tableTitle="绑定子项"
@@ -59,205 +56,201 @@
   </div>
 </template>
 <script setup lang="ts">
-  import { ref, getCurrentInstance } from "vue";
-  import { useCrud } from "@/hooks/userCrud";
-  import ButtonPermKeys from "@/common/configs/buttonPermission";
-  import { useCommonStoreHook } from "@/store";
-  const { isShowTable, tableType } = toRefs(useCommonStoreHook());
-  import {
-    updateWorkShop,
-  } from "@/api/workShop";
-
-  import {
-    updateProductionLine,
-  } from "@/api/productionLine";
-  import {
-    updateStation,
-  } from "@/api/station";
-  // 公共弹窗相关
-  const ctableRef = ref(null);
-  const workShopRef=ref(null);
-  const productionLineRef=ref(null);
-  const factory=ref({});
-  const binding = (row) => {
-    factory.value=row;
-    if (row.level==="first") {
-      ctableRef.value.startSelect();
-    }
-    if(row.level==="second"){
-      workShopRef.value.startSelect();
-    }
-    if(row.level==="third"){
-      productionLineRef.value.startSelect();
-    }
+import { ref, getCurrentInstance } from "vue";
+import { useCrud } from "@/hooks/userCrud";
+import ButtonPermKeys from "@/common/configs/buttonPermission";
+import { useCommonStoreHook } from "@/store";
+const { isShowTable, tableType } = toRefs(useCommonStoreHook());
+import { updateWorkShop } from "@/api/workShop";
 
-  };
-  const delete=(row,index,done)=>{
-    if(row.level==="first"){
-      deleteRow(row,index,done);
-    }
-    if(row.level==="second"){
-      workShopRef.value.startSelect();
-    }
-    if(row.level==="third"){
-      productionLineRef.value.startSelect();
-    }
+import { updateProductionLine } from "@/api/productionLine";
+import { updateStation } from "@/api/station";
+// 公共弹窗相关
+const ctableRef = ref(null);
+const workShopRef = ref(null);
+const productionLineRef = ref(null);
+const factory = ref({});
+const binding = (row) => {
+  factory.value = row;
+  if (row.level === "first") {
+    ctableRef.value.startSelect();
   }
-  const dialog = reactive({
-    title: "绑定子项",
-    visible: false,
-  });
+  if (row.level === "second") {
+    workShopRef.value.startSelect();
+  }
+  if (row.level === "third") {
+    productionLineRef.value.startSelect();
+  }
+};
+const deletes = (row, index, done) => {
+  if (row.level === "first") {
+    deleteRow(row, index, done);
+  }
+  if (row.level === "second") {
+    workShopRef.value.startSelect();
+  }
+  if (row.level === "third") {
+    productionLineRef.value.startSelect();
+  }
+};
+const dialog = reactive({
+  title: "绑定子项",
+  visible: false,
+});
 
-  // 传入一个url,后面不带/
-  const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
-    useCrud({
-      src: "/api/v1/base/factory",
-    });
-  const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
-    Methords; //增删改查
-  const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
-  const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
-  // checkBtnPerm(ButtonPermKeys.PLAN.BTNS.order_add) :permission="permission"
-  // const permission = reactive({
-  //   delBtn: checkPerm(buttonPermission.PLAN.BTNS.order_del),
-  //   addBtn: checkPerm(buttonPermission.PLAN.BTNS.order_add),
-  //   editBtn: checkPerm(buttonPermission.PLAN.BTNS.order_edit),
-  //   menu: true,
-  // });
+// 传入一个url,后面不带/
+const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
+  useCrud({
+    src: "/api/v1/base/factory",
+  });
+const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
+  Methords; //增删改查
+const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
+const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
+// checkBtnPerm(ButtonPermKeys.PLAN.BTNS.order_add) :permission="permission"
+// const permission = reactive({
+//   delBtn: checkPerm(buttonPermission.PLAN.BTNS.order_del),
+//   addBtn: checkPerm(buttonPermission.PLAN.BTNS.order_add),
+//   editBtn: checkPerm(buttonPermission.PLAN.BTNS.order_edit),
+//   menu: true,
+// });
 
-  const crudRef = ref(null); //crudRef.value 获取avue-crud对象
+const crudRef = ref(null); //crudRef.value 获取avue-crud对象
 
-  onMounted(() => {
-    // console.log("crudRef", crudRef)
-    dataList();
-  });
+onMounted(() => {
+  // console.log("crudRef", crudRef)
+  dataList();
+});
 
-  /**
-   * 上传excel相关
-   */
-  const uploadRef = ref(null);
-  const uploadFinished = () => {
-    // 上传完成后的刷新操作
-    page.currentPage = 1;
-    dataList();
-  };
-  const importExcelData = () => {
-    if (uploadRef.value) {
-      uploadRef.value.show("/api/v1/plan/order/import");
-    }
-  };
-  const formData=ref({});
-  // 设置表格列或者其他自定义的option
-  option.value = Object.assign(option.value, {
-    selection: true,
-    menuWidth: 320,
-    border: true,
-    index: true,
-    rowKey: 'code',
-    rowParentKey: 'parentCode',
-    column: [
-      {
-        label: "厂区名称",
-        prop: "name",
-        search: true,
-        overHidden:true,
-        span: 24,
-        labelWidth: 100,
-        rules: [{
+/**
+ * 上传excel相关
+ */
+const uploadRef = ref(null);
+const uploadFinished = () => {
+  // 上传完成后的刷新操作
+  page.currentPage = 1;
+  dataList();
+};
+const importExcelData = () => {
+  if (uploadRef.value) {
+    uploadRef.value.show("/api/v1/plan/order/import");
+  }
+};
+const formData = ref({});
+// 设置表格列或者其他自定义的option
+option.value = Object.assign(option.value, {
+  selection: true,
+  menuWidth: 320,
+  border: true,
+  index: true,
+  rowKey: "code",
+  rowParentKey: "parentCode",
+  column: [
+    {
+      label: "厂区名称",
+      prop: "name",
+      search: true,
+      overHidden: true,
+      span: 24,
+      labelWidth: 100,
+      rules: [
+        {
           required: true,
           message: "请输入工厂名称",
-          trigger: "blur"
-        }]
-      },
-      {
-        label: "负责人",
-        prop: "manager",
-        span: 24,
-        labelWidth: 100,
-        rules: [{
+          trigger: "blur",
+        },
+      ],
+    },
+    {
+      label: "负责人",
+      prop: "manager",
+      span: 24,
+      labelWidth: 100,
+      rules: [
+        {
           required: true,
           message: "请选择厂区负责人",
-          trigger: "blur"
-        }],
-        type: 'select',
-        dicUrl:import.meta.env.VITE_APP_BASE_API+"/api/v1/sys/user/list",
-        dicMethod:"post",
-        props: {
-          label: "userName", // 下拉菜单显示的字段
-          value: "userName" // 下拉菜单值的字段
+          trigger: "blur",
         },
+      ],
+      type: "select",
+      dicUrl: import.meta.env.VITE_APP_BASE_API + "/api/v1/sys/user/list",
+      dicMethod: "post",
+      props: {
+        label: "userName", // 下拉菜单显示的字段
+        value: "userName", // 下拉菜单值的字段
       },
-      {
-        label: "厂区位置",
-        prop: "position",
-        overHidden:true,
-        span: 24,
-        labelWidth: 100,
-        rules: [{
+    },
+    {
+      label: "厂区位置",
+      prop: "position",
+      overHidden: true,
+      span: 24,
+      labelWidth: 100,
+      rules: [
+        {
           required: true,
           message: "请输入厂区位置",
-          trigger: "blur"
-        }]
-      },
-      {
-        label: "创建时间",
-        prop: "created",
-        display:false
-      },
-      {
-        label: "备注",
-        span: 24,
-        labelWidth: 100,
-        overHidden:true,
-        prop: "remark",
-        type: 'textarea',
-      },
-    ],
-  });
-
+          trigger: "blur",
+        },
+      ],
+    },
+    {
+      label: "创建时间",
+      prop: "created",
+      display: false,
+    },
+    {
+      label: "备注",
+      span: 24,
+      labelWidth: 100,
+      overHidden: true,
+      prop: "remark",
+      type: "textarea",
+    },
+  ],
+});
 
-  const onSelectedFinish = (selectedValue) => {
-    formData.code=selectedValue.code;
-    formData.parentCode=factory.value.code;
-    formData.id=selectedValue.id;
-    updateWorkShop(formData).then((data: any) => {
-      ElMessage({
-        message: data.msg,
-        type: "success",
-      });
-      // 上传完成后的刷新操作
-      page.currentPage = 1;
-      dataList();
+const onSelectedFinish = (selectedValue) => {
+  formData.value.code = selectedValue.code;
+  formData.value.parentCode = factory.value.code;
+  formData.value.id = selectedValue.id;
+  updateWorkShop(formData).then((data: any) => {
+    ElMessage({
+      message: data.msg,
+      type: "success",
     });
-  };
-  const onSelectedLineFinish = (selectedValue) => {
-    formData.code=selectedValue.code;
-    formData.parentCode=factory.value.code;
-    formData.id=selectedValue.id;
-    updateProductionLine(formData).then((data: any) => {
-      ElMessage({
-        message: data.msg,
-        type: "success",
-      });
-      // 上传完成后的刷新操作
-      page.currentPage = 1;
-      dataList();
+    // 上传完成后的刷新操作
+    page.currentPage = 1;
+    dataList();
+  });
+};
+const onSelectedLineFinish = (selectedValue) => {
+  formData.value.code = selectedValue.code;
+  formData.value.parentCode = factory.value.code;
+  formData.value.id = selectedValue.id;
+  updateProductionLine(formData).then((data: any) => {
+    ElMessage({
+      message: data.msg,
+      type: "success",
     });
-  };
-  const onSelectedStationFinish = (selectedValue) => {
-    formData.code=selectedValue.code;
-    formData.parentCode=factory.value.code;
-    formData.id=selectedValue.id;
-    updateStation(formData).then((data: any) => {
-      ElMessage({
-        message: data.msg,
-        type: "success",
-      });
-      // 上传完成后的刷新操作
-      page.currentPage = 1;
-      dataList();
+    // 上传完成后的刷新操作
+    page.currentPage = 1;
+    dataList();
+  });
+};
+const onSelectedStationFinish = (selectedValue) => {
+  formData.value.code = selectedValue.code;
+  formData.value.parentCode = factory.value.code;
+  formData.value.id = selectedValue.id;
+  updateStation(formData).then((data: any) => {
+    ElMessage({
+      message: data.msg,
+      type: "success",
     });
-  };
+    // 上传完成后的刷新操作
+    page.currentPage = 1;
+    dataList();
+  });
+};
 </script>
-
-