Bladeren bron

申购单

lxf 1 jaar geleden
bovenliggende
commit
f57ea4663a

+ 123 - 39
src/components/process/subscribe.vue

@@ -1,13 +1,59 @@
 <template>
   <div>
-    <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit"> </byForm>
+    <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
+      <template #materiel>
+        <div style="width: 100%">
+          <div style="margin-bottom: 10px">
+            <el-button type="primary" @click="clickMateriel()" v-preReClick>选择物料</el-button>
+          </div>
+          <el-table :data="formData.data.applyBuyBomList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
+            <el-table-column label="品号" prop="bomSpecCode" width="140" />
+            <el-table-column label="品名" prop="bomSpecName" min-width="220" />
+            <el-table-column label="颜色" prop="bomSpecColour" width="160" />
+            <el-table-column label="尺寸(长宽高,cm)" prop="name" width="160">
+              <template #default="{ row }">
+                <div>{{ row.bomSpecLength }} * {{ row.bomSpecWidth }} * {{ row.bomSpecHeight }}</div>
+              </template>
+            </el-table-column>
+            <el-table-column label="申购数量" width="160">
+              <template #default="{ row, $index }">
+                <el-form-item :prop="'applyBuyBomList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true" style="width: 100%">
+                  <el-input-number
+                    onmousewheel="return false;"
+                    v-model="row.quantity"
+                    placeholder="申购数量"
+                    style="width: 100%"
+                    :controls="false"
+                    :min="0"
+                    :precision="0" />
+                </el-form-item>
+              </template>
+            </el-table-column>
+            <el-table-column label="操作" align="center" fixed="right" width="60">
+              <template #default="{ $index }">
+                <el-button type="danger" @click="clickDelete($index)" text>删除</el-button>
+              </template>
+            </el-table-column>
+          </el-table>
+        </div>
+      </template>
+    </byForm>
+
+    <el-dialog title="选择物料" v-if="openMateriel" v-model="openMateriel" width="90%">
+      <SelectBOM :selectStatus="true" @selectBOM="selectMateriel"></SelectBOM>
+      <template #footer>
+        <el-button @click="openMateriel = false" size="large">关 闭</el-button>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
 <script setup>
 import byForm from "@/components/byForm/index";
 import { useRoute } from "vue-router";
-// import { ElMessage } from "element-plus";
+import moment from "moment";
+import SelectBOM from "@/views/group/BOM/management/index";
+import { ElMessage } from "element-plus";
 
 const route = useRoute();
 // 接收父组件的传值
@@ -16,7 +62,12 @@ const props = defineProps({
 });
 const { proxy } = getCurrentInstance();
 const formData = reactive({
-  data: {},
+  data: {
+    applyName: proxy.useUserStore().user.nickName,
+    applyTime: moment().format("yyyy-MM-DD HH:mm:ss"),
+    remark: "",
+    applyBuyBomList: [],
+  },
 });
 const judgeStatus = () => {
   if (route.query.processType == 20 || route.query.processType == 10) {
@@ -32,9 +83,10 @@ const judgeStatus = () => {
 };
 const formOption = reactive({
   inline: true,
-  labelWidth: 100,
+  labelWidth: "120px",
   itemWidth: 100,
   rules: [],
+  labelPosition: "right",
   disabled: false,
 });
 const formConfig = computed(() => {
@@ -45,41 +97,79 @@ const formConfig = computed(() => {
       label: "",
     },
     {
+      type: "input",
+      prop: "applyName",
+      label: "申购人",
+      itemType: "text",
+      itemWidth: 51,
+    },
+    {
+      type: "date",
+      prop: "applyTime",
+      label: "申购时间",
+      format: "YYYY-MM-DD HH:mm:ss",
+      itemType: "datetime",
+      itemWidth: 51,
+    },
+    {
+      type: "input",
+      prop: "remark",
+      label: "申购说明",
+      itemType: "textarea",
+      itemWidth: 51,
+    },
+    {
       type: "title",
       title: "申购清单",
       label: "",
     },
+    {
+      type: "slot",
+      slotName: "materiel",
+    },
   ];
 });
 const rules = ref({
-  countryId: [{ required: true, message: "请选择国家", trigger: "change" }],
-  sellAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
+  applyName: [{ required: true, message: "请输入申购人", trigger: "blur" }],
+  applyTime: [{ required: true, message: "请选择申购时间", trigger: "change" }],
+  quantity: [{ required: true, message: "请输入申购数量", trigger: "blur" }],
 });
+const openMateriel = ref(false);
+const clickMateriel = () => {
+  openMateriel.value = true;
+};
+const selectMateriel = (row) => {
+  if (formData.data.applyBuyBomList && formData.data.applyBuyBomList.length > 0) {
+    let list = formData.data.applyBuyBomList.filter((item) => item.bomSpecId === row.id);
+    if (list && list.length > 0) {
+      return ElMessage("请勿重复添加!");
+    }
+  }
+  formData.data.applyBuyBomList.push({
+    bomSpecId: row.id,
+    bomSpecCode: row.code,
+    bomSpecName: row.name,
+    bomSpecColour: row.colour,
+    bomSpecLength: row.length,
+    bomSpecWidth: row.width,
+    bomSpecHeight: row.height,
+    quantity: undefined,
+  });
+  ElMessage({ message: "选择完成", type: "success" });
+};
+const clickDelete = (index) => {
+  formData.data.applyBuyBomList.splice(index, 1);
+};
 const handleSubmit = async (flag) => {
   if (flag) {
     return true;
   } else {
     let status = await proxy.$refs.submit.handleSubmit(() => {});
     if (status) {
-      // if (!(formData.data.contractProductList && formData.data.contractProductList.length > 0)) {
-      //   ElMessage("请添加至少一件商品");
-      //   return false;
-      // }
-      // if (formData.data.contractShipmentList && formData.data.contractShipmentList.length > 0) {
-      //   for (let i = 0; i < formData.data.contractProductList.length; i++) {
-      //     let data = formData.data.contractShipmentList.filter((item) => item.productId === formData.data.contractProductList[i].productId);
-      //     if (data && data.length > 0) {
-      //       let quantity = 0;
-      //       for (let j = 0; j < data.length; j++) {
-      //         quantity = parseFloat(Number(quantity) + Number(data[j].quantity));
-      //       }
-      //       if (quantity > formData.data.contractProductList[i].quantity) {
-      //         ElMessage("出货数量不能大于商品数量");
-      //         return false;
-      //       }
-      //     }
-      //   }
-      // }
+      if (!(formData.data.applyBuyBomList && formData.data.applyBuyBomList.length > 0)) {
+        ElMessage("请添加物料");
+        return false;
+      }
       return true;
     } else {
       setTimeout(() => {
@@ -96,20 +186,10 @@ const getFormData = () => {
 watch(
   () => props.queryData,
   (newValue) => {
-    console.log(proxy.deepClone(newValue));
-    // formOption.disabled = judgeStatus();
-    // if (props.queryData && ["10", "20", "30"].includes(route.query.processType)) {
-    //   for (var text in props.queryData) {
-    //     formData.data[text] = props.queryData[text];
-    //   }
-    //   if (formData.data.countryId) {
-    //     getCityData(formData.data.countryId, "20");
-    //   }
-    //   if (formData.data.provinceId) {
-    //     getCityData(formData.data.provinceId, "30");
-    //   }
-    //   getDecisionAids();
-    // }
+    formOption.disabled = judgeStatus();
+    if (props.queryData && ["10", "20", "30"].includes(route.query.processType)) {
+      formData.data = proxy.deepClone(newValue)
+    }
   },
   {
     deep: true,
@@ -124,4 +204,8 @@ defineExpose({ getFormData, handleSubmit });
 ::v-deep(.el-input-number .el-input__inner) {
   text-align: left;
 }
+:deep(.el-dialog) {
+  margin-top: 10px !important;
+  margin-bottom: 10px !important;
+}
 </style>

+ 163 - 0
src/views/group/oa/subscribe/index.vue

@@ -0,0 +1,163 @@
+<template>
+  <div>
+    <el-card class="box-card">
+      <byTable
+        :source="sourceList.data"
+        :pagination="sourceList.pagination"
+        :config="config"
+        :loading="loading"
+        :searchConfig="searchConfig"
+        highlight-current-row
+        :action-list="[
+          {
+            text: '新增',
+            action: () => clickAdd(),
+          },
+        ]"
+        @get-list="getList"
+        @clickReset="clickReset">
+      </byTable>
+    </el-card>
+  </div>
+</template>
+
+<script setup>
+import byTable from "@/components/byTable/index";
+
+const { proxy } = getCurrentInstance();
+const flowStatus = ref([
+  {
+    dictKey: "-1",
+    dictValue: "草稿",
+  },
+  {
+    dictKey: "0",
+    dictValue: "未发起",
+  },
+  {
+    dictKey: "1",
+    dictValue: "进行中",
+  },
+  {
+    dictKey: "2",
+    dictValue: "已通过",
+  },
+  {
+    dictKey: "3",
+    dictValue: "已驳回",
+  },
+]);
+const sourceList = ref({
+  data: [],
+  pagination: {
+    total: 0,
+    pageNum: 1,
+    pageSize: 10,
+    code: "",
+    flowStatus: "",
+    beginTime: "",
+    endTime: "",
+  },
+});
+const loading = ref(false);
+const searchConfig = computed(() => {
+  return [
+    {
+      type: "input",
+      prop: "code",
+      label: "申购单号",
+    },
+    {
+      type: "select",
+      prop: "flowStatus",
+      data: flowStatus.value,
+      label: "流程状态",
+    },
+    {
+      type: "date",
+      propList: ["beginTime", "endTime"],
+      label: "申购日期",
+    },
+  ];
+});
+const config = computed(() => {
+  return [
+    {
+      attrs: {
+        label: "申购单号",
+        prop: "code",
+        width: 220,
+      },
+    },
+    {
+      attrs: {
+        label: "申购时间",
+        prop: "applyTime",
+        align: "center",
+        width: 160,
+      },
+    },
+    {
+      attrs: {
+        label: "申购人",
+        prop: "applyName",
+        width: 160,
+      },
+    },
+    {
+      attrs: {
+        label: "状态",
+        prop: "flowStatus",
+        width: 160,
+      },
+      render(val) {
+        return proxy.dictKeyValue(val, flowStatus.value);
+      },
+    },
+    {
+      attrs: {
+        label: "申购说明",
+        prop: "remark",
+      },
+    },
+  ];
+});
+const getList = async (req, status) => {
+  if (status) {
+    sourceList.value.pagination = {
+      pageNum: sourceList.value.pagination.pageNum,
+      pageSize: sourceList.value.pagination.pageSize,
+    };
+  } else {
+    sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
+  }
+  loading.value = true;
+  proxy.post("/applyBuy/page", sourceList.value.pagination).then((res) => {
+    sourceList.value.data = res.rows;
+    sourceList.value.pagination.total = res.total;
+    setTimeout(() => {
+      loading.value = false;
+    }, 200);
+  });
+};
+getList();
+const clickReset = () => {
+  getList("", true);
+};
+const clickAdd = () => {
+  proxy.$router.replace({
+    path: "/platform_manage/process/processApproval",
+    query: {
+      flowKey: "apply_buy",
+      flowName: "申购流程(发起)",
+      random: proxy.random(),
+    },
+  });
+};
+</script>
+
+<style lang="scss" scoped>
+::v-deep(.el-input-number .el-input__inner) {
+  text-align: left;
+}
+</style>

+ 0 - 6
src/views/process/processApproval/index.vue

@@ -137,12 +137,6 @@ const handleSubmit = async (_type) => {
         btnLoading.value = true;
         if (valid) {
           const data = { ...proxy.$refs.makeDom.getFormData() };
-          // flowForm.fileList = flowForm.fileList.map((item) => {
-          //   return {
-          //     ...item,
-          //     ...item.raw,
-          //   };
-          // });
           if (route.query.processType == 10 || route.query.processType == 30) {
             if (_type && _type == 1) {
               proxy