Browse Source

采购流程

lxf 1 year ago
parent
commit
39512fb280

+ 556 - 0
src/components/process/purchase.vue

@@ -0,0 +1,556 @@
+<template>
+  <div>
+    <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
+      <template #supplier>
+        <div style="width: 100%">
+          <el-form-item label="供应商" prop="supplierId" style="width: 100%; margin-bottom: 18px">
+            <el-col :span="12">
+              <el-select v-model="formData.data.supplierId" placeholder="请选择供应商" clearable style="width: 100%" @change="changeSupplier">
+                <el-option v-for="item in supplierList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
+              </el-select>
+            </el-col>
+          </el-form-item>
+          <el-form-item label="地址" required style="width: 100%; margin-bottom: 18px">
+            <el-col :span="6">
+              <el-form-item prop="province" style="width: 100%">
+                <el-input v-model="formData.data.province" placeholder="请输入省份" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="6">
+              <el-form-item prop="city" style="width: 100%">
+                <el-input v-model="formData.data.city" placeholder="请输入城市" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="6">
+              <el-form-item prop="detailedAddress" style="width: 100%">
+                <el-input v-model="formData.data.detailedAddress" placeholder="请输入地址" />
+              </el-form-item>
+            </el-col>
+          </el-form-item>
+          <el-form-item label="联系人" required style="width: 100%">
+            <el-col :span="6">
+              <el-form-item prop="contactPerson" style="width: 100%">
+                <el-input v-model="formData.data.contactPerson" placeholder="请输入联系人" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="6">
+              <el-form-item prop="contactNumber" style="width: 100%">
+                <el-input v-model="formData.data.contactNumber" placeholder="请输入联系人电话" />
+              </el-form-item>
+            </el-col>
+          </el-form-item>
+        </div>
+      </template>
+      <template #purchaseBomList>
+        <div style="width: 100%">
+          <el-table :data="formData.data.purchaseBomList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
+            <el-table-column label="品号" prop="bomSpecCode" width="120" />
+            <el-table-column label="品名" prop="bomSpecName" min-width="240" />
+            <el-table-column label="颜色" prop="bomSpecColour" width="140" />
+            <el-table-column label="尺寸(长宽高,cm)" width="160">
+              <template #default="{ row }">
+                <div>{{ row.bomSpecLength }} * {{ row.bomSpecWidth }} * {{ row.bomSpecHeight }}</div>
+              </template>
+            </el-table-column>
+            <el-table-column label="含税单价" width="140">
+              <template #default="{ row, $index }">
+                <el-form-item
+                  :prop="'purchaseBomList.' + $index + '.unitPrice'"
+                  :rules="rules.unitPrice"
+                  :inline-message="true"
+                  style="width: 100%"
+                  @change="calculatedTotalAmount">
+                  <el-input-number
+                    onmousewheel="return false;"
+                    v-model="row.unitPrice"
+                    placeholder="含税单价"
+                    style="width: 100%"
+                    :controls="false"
+                    :min="0"
+                    :precision="2" />
+                </el-form-item>
+              </template>
+            </el-table-column>
+            <el-table-column label="税率" width="120">
+              <template #default="{ row, $index }">
+                <el-form-item
+                  :prop="'purchaseBomList.' + $index + '.taxRate'"
+                  :rules="rules.taxRate"
+                  :inline-message="true"
+                  style="width: 100%"
+                  @change="calculatedTotalAmount">
+                  <el-input-number
+                    onmousewheel="return false;"
+                    v-model="row.taxRate"
+                    placeholder="税率"
+                    style="width: 100%"
+                    :controls="false"
+                    :min="0"
+                    :max="100"
+                    :precision="2" />
+                </el-form-item>
+              </template>
+            </el-table-column>
+            <el-table-column label="不含税单价" width="100">
+              <template #default="{ row }">
+                <div>{{ moneyFormat(Number(Math.round(((row.unitPrice * 100) / (100 + row.taxRate)) * 100) / 100)) }}</div>
+              </template>
+            </el-table-column>
+            <el-table-column label="可采购数量" prop="quantity" width="100" />
+            <el-table-column label="采购数量" width="120">
+              <template #default="{ row, $index }">
+                <el-form-item
+                  :prop="'purchaseBomList.' + $index + '.purchaseQuantity'"
+                  :rules="rules.purchaseQuantity"
+                  :inline-message="true"
+                  style="width: 100%"
+                  @change="calculatedTotalAmount">
+                  <el-input-number
+                    onmousewheel="return false;"
+                    v-model="row.purchaseQuantity"
+                    placeholder="采购数量"
+                    style="width: 100%"
+                    :controls="false"
+                    :min="0"
+                    :max="row.quantity"
+                    :precision="0" />
+                </el-form-item>
+              </template>
+            </el-table-column>
+            <el-table-column label="含税小计" align="right" width="120">
+              <template #default="{ row }">
+                <div>{{ moneyFormat(Number(Math.round(row.unitPrice * row.purchaseQuantity * 100) / 100)) }}</div>
+              </template>
+            </el-table-column>
+            <el-table-column label="不含税小计" align="right" width="120">
+              <template #default="{ row }">
+                <div>
+                  {{
+                    moneyFormat(Number(Math.round((Math.round(((row.unitPrice * 100) / (100 + row.taxRate)) * 100) / 100) * row.purchaseQuantity * 100) / 100))
+                  }}
+                </div>
+              </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>
+      <template #deliveryAddress>
+        <div style="width: 100%">
+          <el-form-item label=" " prop="receiveGoodsType" style="width: 100%; margin-bottom: 18px">
+            <el-radio-group v-model="formData.data.receiveGoodsType" @change="changeReceiveGoodsType">
+              <el-radio :label="1">供应商运输</el-radio>
+              <el-radio :label="2">自取</el-radio>
+            </el-radio-group>
+          </el-form-item>
+          <el-form-item label="地址" required style="width: 100%; margin-bottom: 18px" v-if="formData.data.receiveGoodsType == 1">
+            <el-col :span="6">
+              <el-form-item prop="receiveProvince" style="width: 100%">
+                <el-input v-model="formData.data.receiveProvince" placeholder="请输入省份" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="6">
+              <el-form-item prop="receiveCity" style="width: 100%">
+                <el-input v-model="formData.data.receiveCity" placeholder="请输入城市" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item prop="receiveDetailedAddress" style="width: 100%">
+                <el-input v-model="formData.data.receiveDetailedAddress" placeholder="请输入地址" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="4">
+              <el-form-item prop="receivePostcode" style="width: 100%">
+                <el-input v-model="formData.data.receivePostcode" placeholder="请输入邮编" />
+              </el-form-item>
+            </el-col>
+          </el-form-item>
+          <el-form-item label="联系人" required style="width: 100%" v-if="formData.data.receiveGoodsType == 1">
+            <el-col :span="6">
+              <el-form-item prop="receiveContactPerson" style="width: 100%">
+                <el-input v-model="formData.data.receiveContactPerson" placeholder="请输入联系人" />
+              </el-form-item>
+            </el-col>
+            <el-col :span="6">
+              <el-form-item prop="receiveContactNumber" style="width: 100%">
+                <el-input v-model="formData.data.receiveContactNumber" placeholder="请输入联系人电话" />
+              </el-form-item>
+            </el-col>
+          </el-form-item>
+        </div>
+      </template>
+      <template #money>
+        <div style="width: 100%">
+          <div style="padding: 8px; background-color: #e9f5fb; font-size: 12px; font-weight: 700">
+            <span>含税总金额: {{ moneyFormat(formData.data.totalAmountIncludingTax) }} ({{ formData.data.totalAmountIncludingTaxCn }})</span>
+            <span style="margin-left: 32px">
+              不含税总金额: {{ moneyFormat(formData.data.totalAmountExcludingTax) }} ({{ formData.data.totalAmountExcludingTaxCn }})
+            </span>
+          </div>
+        </div>
+      </template>
+      <template #template>
+        <div style="width: 100%">
+          <el-form-item label="合同模板" prop="contractTemplateId" style="width: 100%; margin-bottom: 18px">
+            <el-col :span="12">
+              <el-select v-model="formData.data.contractTemplateId" placeholder="请选择合同模板" clearable style="width: 100%" @change="changeTemplate">
+                <el-option v-for="item in templateList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
+              </el-select>
+            </el-col>
+          </el-form-item>
+          <div v-if="formOption.disabled">
+            <div v-html="formData.data.contract"></div>
+          </div>
+          <Editor v-else :value="formData.data.contract" @updateValue="updateValue" ref="editor" />
+        </div>
+      </template>
+    </byForm>
+  </div>
+</template>
+
+<script setup>
+import byForm from "@/components/byForm/index";
+import { useRoute } from "vue-router";
+import Editor from "@/components/Editor/index.vue";
+import { ElMessage } from "element-plus";
+
+const route = useRoute();
+// 接收父组件的传值
+const props = defineProps({
+  queryData: Object,
+});
+const { proxy } = getCurrentInstance();
+const supplierList = ref([]);
+const templateList = ref([]);
+const formData = reactive({
+  data: {
+    receiveGoodsType: 1,
+    contract: "",
+    purchaseBomList: [],
+  },
+});
+const judgeStatus = () => {
+  if (route.query.processType == 20 || route.query.processType == 10) {
+    return true;
+  }
+  if (props.queryData.recordList && props.queryData.recordList.length > 0) {
+    let data = props.queryData.recordList.filter((item) => item.status === 2 && item.nodeType !== 1);
+    if (data && data.length > 0) {
+      return true;
+    }
+  }
+  return false;
+};
+const formOption = reactive({
+  inline: true,
+  labelWidth: "100px",
+  itemWidth: 100,
+  rules: [],
+  labelPosition: "right",
+  disabled: false,
+});
+const formConfig = computed(() => {
+  return [
+    {
+      type: "title",
+      title: "供应商",
+      label: "",
+    },
+    {
+      type: "slot",
+      slotName: "supplier",
+    },
+    {
+      type: "title",
+      title: "采购清单",
+      label: "",
+    },
+    {
+      type: "slot",
+      slotName: "purchaseBomList",
+    },
+    {
+      type: "title",
+      title: "收货地址",
+      label: "",
+    },
+
+    {
+      type: "slot",
+      slotName: "deliveryAddress",
+    },
+    {
+      type: "title",
+      title: "付款信息",
+      label: "",
+    },
+    {
+      type: "select",
+      label: "结算方式",
+      prop: "settlementMethod",
+      data: proxy.useUserStore().allDict["settlement_method"],
+      itemWidth: 33,
+    },
+    {
+      type: "select",
+      label: "发票类型",
+      prop: "invoiceType",
+      data: proxy.useUserStore().allDict["invoice_type"],
+      itemWidth: 33,
+    },
+    {
+      type: "date",
+      prop: "deliveryDate",
+      label: "交付日期",
+      format: "YYYY-MM-DD HH:mm:ss",
+      itemType: "datetime",
+      itemWidth: 34,
+    },
+    {
+      type: "select",
+      label: "币种",
+      prop: "currency",
+      data: proxy.useUserStore().allDict["currency"],
+      itemWidth: 33,
+    },
+    {
+      type: "number",
+      prop: "advancePayment",
+      label: "预付款 (%)",
+      min: 0,
+      max: 100,
+      precision: 2,
+      controls: false,
+      itemWidth: 33,
+    },
+    // {
+    //   type: "title",
+    //   title: "附件",
+    //   label: "",
+    // },
+    {
+      type: "title",
+      title: "款项金额",
+      label: "",
+    },
+    {
+      type: "slot",
+      slotName: "money",
+    },
+    {
+      type: "title",
+      title: "合同内容",
+      label: "",
+    },
+    {
+      type: "slot",
+      slotName: "template",
+    },
+  ];
+});
+const rules = ref({
+  supplierId: [{ required: true, message: "请选择供应商", trigger: "change" }],
+  province: [{ required: true, message: "请输入省份", trigger: "blur" }],
+  city: [{ required: true, message: "请输入城市", trigger: "blur" }],
+  detailedAddress: [{ required: true, message: "请输入地址", trigger: "blur" }],
+  contactPerson: [{ required: true, message: "请输入联系人", trigger: "blur" }],
+  contactNumber: [{ required: true, message: "请输入联系人电话", trigger: "blur" }],
+  unitPrice: [{ required: true, message: "请输入含税单价", trigger: "blur" }],
+  taxRate: [{ required: true, message: "请输入税率", trigger: "blur" }],
+  purchaseQuantity: [{ required: true, message: "请输入采购数量", trigger: "blur" }],
+  receiveProvince: [{ required: true, message: "请输入省份", trigger: "blur" }],
+  receiveCity: [{ required: true, message: "请输入城市", trigger: "blur" }],
+  receiveDetailedAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
+  receivePostcode: [{ required: true, message: "请输入邮编", trigger: "blur" }],
+  receiveContactPerson: [{ required: true, message: "请输入联系人", trigger: "blur" }],
+  receiveContactNumber: [{ required: true, message: "请输入联系人电话", trigger: "blur" }],
+  settlementMethod: [{ required: true, message: "请选择结算方式", trigger: "change" }],
+  invoiceType: [{ required: true, message: "请选择发票类型", trigger: "change" }],
+  deliveryDate: [{ required: true, message: "请选择交付日期", trigger: "change" }],
+  currency: [{ required: true, message: "请选择币种", trigger: "change" }],
+  advancePayment: [{ required: true, message: "请输入预付款", trigger: "blur" }],
+});
+const getDemandData = () => {
+  proxy.post("/supplier/page", { pageNum: 1, pageSize: 999 }).then((res) => {
+    if (res.rows && res.rows.length > 0) {
+      supplierList.value = res.rows.map((item) => {
+        return {
+          ...item,
+          dictKey: item.id,
+          dictValue: item.name,
+        };
+      });
+    }
+  });
+  proxy.post("/contractTemplate/page", { pageNum: 1, pageSize: 999 }).then((res) => {
+    if (res.rows && res.rows.length > 0) {
+      templateList.value = res.rows.map((item) => {
+        return {
+          ...item,
+          dictKey: item.id,
+          dictValue: item.name,
+        };
+      });
+    }
+  });
+};
+getDemandData();
+const changeSupplier = () => {
+  if (formData.data.supplierId) {
+    let list = supplierList.value.filter((item) => item.id === formData.data.supplierId);
+    if (list && list.length > 0) {
+      formData.data.province = list[0].province;
+      formData.data.city = list[0].city;
+      formData.data.detailedAddress = list[0].detailedAddress;
+      formData.data.contactPerson = list[0].contactPerson1;
+      formData.data.contactNumber = list[0].contactNumber1;
+    }
+  } else {
+    formData.data.province = "";
+    formData.data.city = "";
+    formData.data.detailedAddress = "";
+    formData.data.contactPerson = "";
+    formData.data.contactNumber = "";
+  }
+};
+const calculatedTotalAmount = () => {
+  let money = 0;
+  let notTaxMoney = 0;
+  if (formData.data.purchaseBomList && formData.data.purchaseBomList.length > 0) {
+    for (let i = 0; i < formData.data.purchaseBomList.length; i++) {
+      if (formData.data.purchaseBomList[i].unitPrice && formData.data.purchaseBomList[i].purchaseQuantity) {
+        money = Number(Math.round((money + formData.data.purchaseBomList[i].unitPrice * formData.data.purchaseBomList[i].purchaseQuantity) * 100) / 100);
+        if (formData.data.purchaseBomList[i].taxRate) {
+          notTaxMoney = Number(
+            Math.round(
+              (notTaxMoney +
+                (Math.round(((formData.data.purchaseBomList[i].unitPrice * 100) / (100 + formData.data.purchaseBomList[i].taxRate)) * 100) / 100) *
+                  formData.data.purchaseBomList[i].purchaseQuantity) *
+                100
+            ) / 100
+          );
+        }
+      }
+    }
+  }
+  formData.data.totalAmountIncludingTax = money;
+  formData.data.totalAmountIncludingTaxCn = proxy.NumberToChinese(money);
+  formData.data.totalAmountExcludingTax = notTaxMoney;
+  formData.data.totalAmountExcludingTaxCn = proxy.NumberToChinese(notTaxMoney);
+};
+const clickDelete = (index) => {
+  formData.data.purchaseBomList.splice(index, 1);
+};
+const changeReceiveGoodsType = () => {
+  formData.data.receiveProvince = "";
+  formData.data.receiveCity = "";
+  formData.data.receiveDetailedAddress = "";
+  formData.data.receivePostcode = "";
+  formData.data.receiveContactPerson = "";
+  formData.data.receiveContactNumber = "";
+};
+const changeTemplate = () => {
+  if (formData.data.contractTemplateId) {
+    proxy.post("/contractTemplate/detail", { id: formData.data.contractTemplateId }).then((res) => {
+      proxy.$refs.editor.changeHtml(res.content);
+    });
+  }
+};
+const updateValue = (val) => {
+  formData.data.contract = val;
+};
+const handleSubmit = async (flag) => {
+  if (flag) {
+    return true;
+  } else {
+    let status = await proxy.$refs.submit.handleSubmit(() => {});
+    if (status) {
+      if (!(formData.data.purchaseBomList && formData.data.purchaseBomList.length > 0)) {
+        ElMessage("请添加采购清单");
+        return false;
+      }
+      return true;
+    } else {
+      setTimeout(() => {
+        const errorDiv = document.getElementsByClassName("is-error");
+        errorDiv[0].scrollIntoView();
+      }, 0);
+    }
+    return false;
+  }
+};
+const getFormData = () => {
+  return proxy.deepClone(formData.data);
+};
+watch(
+  () => props.queryData,
+  (newValue) => {
+    formOption.disabled = judgeStatus();
+    if (props.queryData && ["10", "20", "30", "40"].includes(route.query.processType)) {
+      formData.data = proxy.deepClone(newValue);
+      if (formData.data.contract) {
+        proxy.$refs.editor.changeHtml(formData.data.contract);
+      }
+      formData.data.totalAmountIncludingTaxCn = proxy.NumberToChinese(formData.data.totalAmountIncludingTax);
+      formData.data.totalAmountExcludingTaxCn = proxy.NumberToChinese(formData.data.totalAmountExcludingTax);
+      if (formData.data.applyBuyId) {
+        proxy.post("/applyBuy/detail", { id: formData.data.applyBuyId }).then((res) => {
+          if (formData.data.purchaseBomList && formData.data.purchaseBomList.length > 0 && res.applyBuyBomList && res.applyBuyBomList.length > 0) {
+            for (let i = 0; i < formData.data.purchaseBomList.length; i++) {
+              for (let j = 0; j < res.applyBuyBomList.length; j++) {
+                if (formData.data.purchaseBomList[i].applyBuyBomId === res.applyBuyBomList[j].id) {
+                  formData.data.purchaseBomList[i].quantity = res.applyBuyBomList[j].quantity;
+                }
+              }
+            }
+          }
+        });
+      }
+    }
+  },
+  {
+    deep: true,
+  }
+);
+onMounted(() => {
+  if (route.query.subscribeId) {
+    formData.data.applyBuyId = route.query.subscribeId;
+    proxy.post("/applyBuy/detail", { id: route.query.subscribeId }).then((res) => {
+      if (res.applyBuyBomList && res.applyBuyBomList.length > 0) {
+        formData.data.purchaseBomList = res.applyBuyBomList.map((item) => {
+          return {
+            applyBuyBomId: item.id,
+            bomSpecId: item.bomSpecId,
+            unitPrice: undefined,
+            taxRate: undefined,
+            purchaseQuantity: undefined,
+            bomSpecCode: item.bomSpecCode,
+            bomSpecName: item.bomSpecName,
+            bomSpecColour: item.bomSpecColour,
+            bomSpecLength: item.bomSpecLength,
+            bomSpecWidth: item.bomSpecWidth,
+            bomSpecHeight: item.bomSpecHeight,
+            quantity: item.quantity,
+          };
+        });
+      }
+    });
+  }
+});
+// 向父组件暴露
+defineExpose({ getFormData, handleSubmit });
+</script>
+
+<style lang="scss" scoped>
+::v-deep(.el-input-number .el-input__inner) {
+  text-align: left;
+}
+:deep(.el-dialog) {
+  margin-top: 10px !important;
+  margin-bottom: 10px !important;
+}
+</style>

+ 3 - 0
src/main.js

@@ -49,6 +49,7 @@ import {
   timeInterval,
   compareTime,
   downloadFile,
+  NumberToChinese,
 } from "@/utils/util";
 import '@/utils/table2excel'
 
@@ -93,6 +94,8 @@ app.config.globalProperties.deepClone = deepClone;
 app.config.globalProperties.timeInterval = timeInterval;
 app.config.globalProperties.compareTime = compareTime;
 app.config.globalProperties.downloadFile = downloadFile;
+app.config.globalProperties.NumberToChinese = NumberToChinese;
+
 app.config.globalProperties.useUserStore = useUserStore;
 
 // 全局组件挂载

+ 250 - 45
src/views/group/purchase/contract/index.vue

@@ -20,16 +20,65 @@
           </byTable>
         </el-tab-pane>
         <el-tab-pane label="采购合同" name="second">
-          <!-- <byTable
+          <byTable
             :source="sourceListTwo.data"
             :pagination="sourceListTwo.pagination"
             :config="configTwo"
             :loading="loading"
-            :searchConfig="searchConfig"
+            :searchConfig="searchConfigTwo"
             highlight-current-row
             @get-list="getListTwo"
             @clickReset="clickResetTwo">
-          </byTable> -->
+            <template #typeExpand="{ item }">
+              <div style="padding: 0 20px">
+                <el-table :data="item.purchaseBomList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader" border>
+                  <el-table-column label="品号" prop="bomSpecCode" width="120" />
+                  <el-table-column label="品名" prop="bomSpecName" min-width="240" />
+                  <el-table-column label="颜色" prop="bomSpecColour" width="180" />
+                  <el-table-column label="尺寸(长宽高,cm)" width="160">
+                    <template #default="{ row }">
+                      <div>{{ row.bomSpecLength }} * {{ row.bomSpecWidth }} * {{ row.bomSpecHeight }}</div>
+                    </template>
+                  </el-table-column>
+                  <el-table-column label="含税单价" prop="unitPrice" width="140" />
+                  <el-table-column label="税率" prop="taxRate" width="120" />
+                  <el-table-column label="不含税单价" width="100">
+                    <template #default="{ row }">
+                      <div>{{ moneyFormat(Number(Math.round(((row.unitPrice * 100) / (100 + row.taxRate)) * 100) / 100)) }}</div>
+                    </template>
+                  </el-table-column>
+                  <el-table-column label="采购数量" prop="purchaseQuantity" width="120" />
+                  <el-table-column label="含税小计" align="right" width="140">
+                    <template #default="{ row }">
+                      <div>{{ moneyFormat(Number(Math.round(row.unitPrice * row.purchaseQuantity * 100) / 100)) }}</div>
+                    </template>
+                  </el-table-column>
+                  <el-table-column label="不含税小计" align="right" width="140">
+                    <template #default="{ row }">
+                      <div>
+                        {{
+                          moneyFormat(
+                            Number(Math.round((Math.round(((row.unitPrice * 100) / (100 + row.taxRate)) * 100) / 100) * row.purchaseQuantity * 100) / 100)
+                          )
+                        }}
+                      </div>
+                    </template>
+                  </el-table-column>
+                </el-table>
+              </div>
+            </template>
+            <template #code="{ item }">
+              <div>
+                <a style="color: #409eff; cursor: pointer; word-break: break-all" @click="clickPurchaseCode(item)">{{ item.code }}</a>
+              </div>
+            </template>
+            <template #advancePayment="{ item }">
+              <div>{{ item.advancePayment }}%</div>
+            </template>
+            <template #finalPayment="{ item }">
+              <div>{{ 100 - item.advancePayment }}%</div>
+            </template>
+          </byTable>
         </el-tab-pane>
       </el-tabs>
     </el-card>
@@ -38,9 +87,28 @@
 
 <script setup>
 import byTable from "@/components/byTable/index";
+import { ElMessage, ElMessageBox } from "element-plus";
 
 const { proxy } = getCurrentInstance();
 const activeName = ref("first");
+const flowStatus = ref([
+  {
+    dictKey: "0",
+    dictValue: "未发起",
+  },
+  {
+    dictKey: "1",
+    dictValue: "进行中",
+  },
+  {
+    dictKey: "2",
+    dictValue: "已通过",
+  },
+  {
+    dictKey: "3",
+    dictValue: "已驳回",
+  },
+]);
 const sourceList = ref({
   data: [],
   pagination: {
@@ -59,16 +127,9 @@ const sourceListTwo = ref({
     total: 0,
     pageNum: 1,
     pageSize: 10,
-    type: "1",
-    orderCode: "",
-    orderWlnCode: "",
-    bomSpecCode: "",
-    bomSpecName: "",
-    skuSpecCode: "",
-    skuSpecName: "",
-    departmentId: "",
-    warehouseName: "",
-    width: "",
+    code: "",
+    flowStatus: "",
+    supplierName: "",
   },
 });
 const loading = ref(false);
@@ -86,6 +147,26 @@ const searchConfig = computed(() => {
     },
   ];
 });
+const searchConfigTwo = computed(() => {
+  return [
+    {
+      type: "input",
+      prop: "code",
+      label: "采购单号",
+    },
+    {
+      type: "select",
+      prop: "flowStatus",
+      data: flowStatus.value,
+      label: "流程状态",
+    },
+    {
+      type: "input",
+      prop: "supplierName",
+      label: "供应商",
+    },
+  ];
+});
 const config = computed(() => {
   return [
     {
@@ -144,83 +225,156 @@ const config = computed(() => {
 const configTwo = computed(() => {
   return [
     {
+      type: "expand",
       attrs: {
-        label: "设计图",
-        slot: "blueprint",
-        width: 80,
+        label: " ",
+        slot: "typeExpand",
+        width: 50,
       },
     },
     {
       attrs: {
-        label: "事业部",
-        prop: "departmentName",
+        label: "采购单号",
+        slot: "code",
         width: 160,
       },
     },
     {
       attrs: {
-        label: "BOM品号",
-        prop: "bomSpecCode",
+        label: "申购单号",
+        prop: "applyBuyCode",
         width: 160,
       },
     },
     {
       attrs: {
-        label: "BOM品名",
-        prop: "bomSpecName",
-        "min-width": 240,
+        label: "状态",
+        prop: "flowStatus",
+        width: 100,
+      },
+      render(val) {
+        return proxy.dictKeyValue(val, flowStatus.value);
       },
     },
     {
       attrs: {
-        label: "SKU品号",
-        prop: "skuSpecCode",
-        width: 160,
+        label: "币种",
+        prop: "currency",
+        width: 100,
+      },
+      render(val) {
+        return proxy.dictKeyValue(val, proxy.useUserStore().allDict["currency"]);
       },
     },
     {
       attrs: {
-        label: "SKU品名",
-        prop: "skuSpecName",
-        "min-width": 200,
+        label: "预付款",
+        slot: "advancePayment",
+        width: 80,
       },
     },
     {
       attrs: {
-        label: "尺寸(长宽高,cm)",
-        slot: "size",
-        width: 160,
+        label: "尾款",
+        slot: "finalPayment",
+        width: 80,
       },
     },
     {
       attrs: {
-        label: "数量",
-        prop: "quantity",
-        width: 100,
+        label: "含税总金额",
+        prop: "totalAmountIncludingTax",
+        width: 120,
+        align: "right",
       },
     },
     {
       attrs: {
-        label: "投产时间",
-        prop: "createTime",
-        width: 160,
-        align: "center",
+        label: "不含税总金额",
+        prop: "totalAmountExcludingTax",
+        width: 120,
+        align: "right",
+      },
+    },
+    {
+      attrs: {
+        label: "结算方式",
+        prop: "settlementMethod",
+        width: 120,
+      },
+      render(val) {
+        return proxy.dictKeyValue(val, proxy.useUserStore().allDict["settlement_method"]);
       },
     },
     {
       attrs: {
-        label: "订单号",
-        prop: "orderCode",
+        label: "发票类型",
+        prop: "invoiceType",
+        width: 140,
+      },
+      render(val) {
+        return proxy.dictKeyValue(val, proxy.useUserStore().allDict["invoice_type"]);
+      },
+    },
+    {
+      attrs: {
+        label: "交期",
+        prop: "deliveryDate",
         width: 160,
       },
     },
     {
       attrs: {
-        label: "万里牛单号",
-        prop: "orderWlnCode",
+        label: "供应商",
+        prop: "supplierName",
+        "min-width": 160,
+      },
+    },
+    {
+      attrs: {
+        label: "创建时间",
+        prop: "createTime",
         width: 160,
       },
     },
+    {
+      attrs: {
+        label: "操作",
+        width: 120,
+        align: "center",
+        fixed: "right",
+      },
+      renderHTML(row) {
+        return [
+          row.flowStatus == "0" || row.flowStatus == "3"
+            ? {
+                attrs: {
+                  label: "编辑",
+                  type: "primary",
+                  text: true,
+                },
+                el: "button",
+                click() {
+                  clickUpdate(row);
+                },
+              }
+            : {},
+          row.flowStatus == "0" || row.flowStatus == "3"
+            ? {
+                attrs: {
+                  label: "删除",
+                  type: "danger",
+                  text: true,
+                },
+                el: "button",
+                click() {
+                  clickDelete(row);
+                },
+              }
+            : {},
+        ];
+      },
+    },
   ];
 });
 const getList = async (req) => {
@@ -247,7 +401,7 @@ const getListTwo = async (req, status) => {
     sourceListTwo.value.pagination = { ...sourceListTwo.value.pagination, ...req };
   }
   loading.value = true;
-  proxy.post("/stockPreparation/completedPage", sourceListTwo.value.pagination).then((res) => {
+  proxy.post("/purchase/page", sourceListTwo.value.pagination).then((res) => {
     sourceListTwo.value.data = res.rows;
     sourceListTwo.value.pagination.total = res.total;
     setTimeout(() => {
@@ -278,8 +432,55 @@ const clickCode = (item) => {
     },
   });
 };
+const clickPurchaseCode = (item) => {
+  proxy.$router.replace({
+    path: "/platform_manage/process/processApproval",
+    query: {
+      flowKey: "purchase",
+      flowName: "采购流程",
+      processType: "20",
+      id: item.id,
+      flowId: item.flowId,
+      random: proxy.random(),
+    },
+  });
+};
 const clickPurchase = (item) => {
-  console.log(item);
+  proxy.$router.replace({
+    path: "/platform_manage/process/processApproval",
+    query: {
+      flowKey: "purchase",
+      flowName: "采购流程",
+      random: proxy.random(),
+      subscribeId: item.id,
+    },
+  });
+};
+const clickUpdate = (item) => {
+  proxy.$router.replace({
+    path: "/platform_manage/process/processApproval",
+    query: {
+      flowKey: "purchase",
+      flowName: "采购流程",
+      processType: "40",
+      id: item.id,
+      random: proxy.random(),
+    },
+  });
+};
+const clickDelete = (row) => {
+  ElMessageBox.confirm("你是否确认此操作", "提示", {
+    confirmButtonText: "确定",
+    cancelButtonText: "取消",
+    type: "warning",
+  })
+    .then(() => {
+      proxy.post("/purchase/delete", { id: row.id }).then(() => {
+        ElMessage({ message: "删除成功", type: "success" });
+        getListTwo();
+      });
+    })
+    .catch(() => {});
 };
 </script>
 
@@ -287,4 +488,8 @@ const clickPurchase = (item) => {
 ::v-deep(.el-input-number .el-input__inner) {
   text-align: left;
 }
+::v-deep(.el-table__expand-icon) {
+  display: grid;
+  place-items: center;
+}
 </style>

+ 43 - 24
src/views/process/processApproval/index.vue

@@ -10,7 +10,8 @@
           }}
         </div>
         <div class="line"></div>
-        <Subscribe :queryData="queryData.data" v-if="flowForm.flowKey == 'apply_buy'" ref="makeDom"></Subscribe>
+        <Subscribe :queryData="detailsData.data" v-if="route.query.flowKey == 'apply_buy'" ref="makeDom"></Subscribe>
+        <Purchase :queryData="detailsData.data" v-else-if="route.query.flowKey == 'purchase'" ref="makeDom"></Purchase>
       </div>
       <div class="bottom" v-if="route.query.processType != 20">
         <div class="commons-title title">处理意见</div>
@@ -88,20 +89,41 @@
   </div>
 </template>
 
-<script setup name="ProcessApproval">
+<script setup>
 import useTagsViewStore from "@/store/modules/tagsView.js";
 import { useRouter, useRoute } from "vue-router";
 import { ElMessage } from "element-plus";
 // 申购单
 import Subscribe from "@/components/process/subscribe";
+// 采购合同
+import Purchase from "@/components/process/purchase";
 
 const typeName = ref({
   10: "(审批)",
   20: "(详情)",
   30: "(发起)",
+  40: "(发起)",
 });
 const keyName = ref({
   apply_buy: "申购流程",
+  purchase: "采购流程",
+});
+const flowKeyCollect = reactive({
+  apply_buy: {
+    backPath: "/group/oa/subscribe",
+    edit: "/applyBuy/edit",
+    add: "/applyBuy/add",
+    detail: "/applyBuy/detail",
+  },
+  purchase: {
+    backPath: "/group/purchase/purchase-contract",
+    edit: "/purchase/edit",
+    add: "/purchase/add",
+    detail: "/purchase/detail",
+  },
+});
+const detailsData = reactive({
+  data: {},
 });
 const router = useRouter();
 const route = useRoute();
@@ -119,6 +141,7 @@ const flowForm = reactive({
 const flowRules = reactive({
   // remark: [{ required: true, message: "请输入处理意见", trigger: "blur" }],
 });
+
 //组件实例
 const { proxy } = getCurrentInstance();
 const flowFormDom = ref(null);
@@ -150,7 +173,7 @@ const handleSubmit = async (_type) => {
       flowFormDom.value.validate((valid) => {
         if (valid) {
           const data = { ...proxy.$refs.makeDom.getFormData() };
-          if (route.query.processType == '10' || route.query.processType == '30') {
+          if (route.query.processType == "10" || route.query.processType == "30") {
             if (_type && _type == 1) {
               proxy
                 .post("/flowExample/setStartData", {
@@ -192,17 +215,15 @@ const handleSubmit = async (_type) => {
 const skipPage = () => {
   const useTagsStore = useTagsViewStore();
   useTagsStore.delVisitedView(router.currentRoute.value);
-  if (route.query.processType && route.query.processType != '40') {
+  if (route.query.processType && route.query.processType != "40") {
     router.replace({
       path: "/oa/1/dealWith",
     });
   } else {
     ElMessage({ message: "操作成功!", type: "success" });
-    if (flowForm.flowKey == "apply_buy") {
-      router.replace({
-        path: "/group/oa/subscribe",
-      });
-    }
+    router.replace({
+      path: flowKeyCollect[route.query.flowKey].backPath,
+    });
   }
 };
 let queryData = reactive({
@@ -235,7 +256,7 @@ const getRecords = (_id) => {
   } else {
     proxy
       .post("/flowExample/getFlowNode", {
-        flowKey: flowForm.flowKey,
+        flowKey: route.query.flowKey,
       })
       .then((res) => {
         recordList.value = res;
@@ -245,17 +266,15 @@ const getRecords = (_id) => {
 const handleSaveDraft = async () => {
   const flag = await proxy.$refs.makeDom.handleSubmit();
   if (flag) {
-    if (flowForm.flowKey == "apply_buy") {
-      let data = proxy.$refs.makeDom.getFormData();
-      if (data.id) {
-        proxy.post("/applyBuy/edit", data).then(() => {
-          skipPage();
-        });
-      } else {
-        proxy.post("/applyBuy/add", data).then(() => {
-          skipPage();
-        });
-      }
+    let data = proxy.$refs.makeDom.getFormData();
+    if (data.id) {
+      proxy.post(flowKeyCollect[route.query.flowKey].edit, data).then(() => {
+        skipPage();
+      });
+    } else {
+      proxy.post(flowKeyCollect[route.query.flowKey].add, data).then(() => {
+        skipPage();
+      });
     }
   }
 };
@@ -278,9 +297,9 @@ onMounted(() => {
       }
     });
   }
-  if (route.query.flowKey == "apply_buy") {
-    proxy.post("/applyBuy/detail", { id: route.query.id }).then((res) => {
-      queryData.data = { ...res };
+  if (route.query.id) {
+    proxy.post(flowKeyCollect[route.query.flowKey].detail, { id: route.query.id }).then((res) => {
+      detailsData.data = { ...res };
     });
   }
   getRecords(route.query.flowId);