zuozhengqing
2024-03-20 f4ed5ae8873f65c36b5cf37be264f6ec1e154647
src/views/purchaseManage/purchase/index.vue
@@ -23,6 +23,8 @@
            :table-list="tableList"
            @selCommonClick="selCommonClick"
            @selTableCol="selTableCol"
            @tableRowClick="tableRowClick"
            :selectClassRow="selectRow"
          >
            <template slot="tableButton">
              <el-table-column label="状态" width="120">
@@ -51,6 +53,12 @@
                  <el-button type="text" size="small" @click="btnLook(scope.row)" style="margin-right: 5px"
                    >查看</el-button
                  >
                  <!-- <el-button type="text" size="small" @click="btnLook(scope.row)" style="margin-right: 5px"
                    >到货确认</el-button
                  >
                  <el-button type="text" size="small" @click="btnLook(scope.row)" style="margin-right: 5px"
                    >去质检</el-button
                  > -->
                  <el-button
                    v-if="scope.row.status === 1"
                    type="text"
@@ -120,7 +128,13 @@
<script>
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import { getPurchaseList, getPurchaseInfo, submitPurchase, deletePurchase } from "@/api/purchaseManage/purchase"
import {
  getPurchaseList,
  getPurchaseInfo,
  submitPurchase,
  deletePurchase,
  getOperationInfo
} from "@/api/purchaseManage/purchase"
import DetailSupplier from "@/views/purchaseManage/purchase/DetailSupplier"
import AddPurchase from "@/views/purchaseManage/purchase/components/AddPurchase"
import { getSupplierList } from "@/api/supplierManage/supplier"
@@ -136,27 +150,29 @@
    const productColumn = [
      { label: "产品编号", prop: "number", default: true },
      { label: "产品名称", prop: "name" },
      { label: "规格型号", prop: "desc" },
      { label: "采购数量", prop: "purchaseAmount" },
      { label: "已发货数量", prop: "margin" },
      { label: "已入库数量", prop: "amount" },
      { label: "规格", prop: "specifications" },
      { label: "型号", prop: "modelNumber" },
      { label: "采购数量", prop: "amount" },
      { label: "已发货数量", prop: "sendAmount" },
      { label: "已入库数量", prop: "overAmount" },
      { label: "单位", prop: "unit" },
      { label: "采购单价", prop: "price", price: true },
      { label: "采购单价", prop: "purchasePrice", price: true },
      { label: "价税合计", prop: "total", price: true }
    ]
    // 收货信息
    const recriveColumn = [
      { label: "入库单号", prop: "number", default: true },
      { label: "收货仓库", prop: "name" },
      { label: "产品名称", prop: "orderAmount" },
      { label: "产品编码", prop: "invoice" },
      { label: "数量", prop: "carrier" },
      { label: "入库时间", prop: "waybill" },
      { label: "收货人", prop: "warehouse" },
      { label: "状态", prop: "amount" }
      { label: "入库单号", prop: "operationNumber", default: true },
      { label: "收货仓库", prop: "warehouseName" },
      { label: "产品名称", prop: "name" },
      { label: "产品编码", prop: "number" },
      { label: "数量", prop: "amount" },
      { label: "入库时间", prop: "overTime" },
      { label: "收货人", prop: "principal" },
      { label: "状态", prop: "status", isCallMethod: true, getCallMethod: this.getreceiveStatusStatus }
    ]
    return {
      purchaseStatusList: getDataByType("purchaseStatus"),
      receiveStatusList: getDataByType("receiveStatus"),
      tableLoading: false,
      tableList: {}, // 列表
      selValueList: [],
@@ -195,7 +211,8 @@
      showProductCol: [
        "产品编号",
        "产品名称",
        "规格型号",
        "规格",
        "型号",
        "采购数量",
        "已发货数量",
        "已入库数量",
@@ -205,8 +222,9 @@
      ],
      // 收货信息
      recriveColumn: recriveColumn,
      showReceiveCol: ["入库单号", "收货仓库", "产品名称", "产品编号", "数量", "入库时间", "收货人", "状态"],
      loading: false
      showReceiveCol: ["入库单号", "收货仓库", "产品名称", "产品编码", "数量", "入库时间", "收货人", "状态"],
      loading: false,
      selectRow: {}
    }
  },
  created() {
@@ -242,6 +260,17 @@
        for (let i in this.purchaseStatusList) {
          if (this.purchaseStatusList[i].id == val) {
            return this.purchaseStatusList[i].name
          }
        }
      } else {
        return "--"
      }
    },
    getreceiveStatusStatus(val) {
      if (val) {
        for (let i in this.receiveStatusList) {
          if (this.receiveStatusList[i].id == val) {
            return this.receiveStatusList[i].name
          }
        }
      } else {
@@ -289,6 +318,10 @@
            })
            this.tableList.tableInfomation = list || []
            this.pagerOptions.totalCount = res.data.total
            if (res.data.total > 0) {
              this.selectRow = this.tableList.tableInfomation.length > 0 ? this.tableList.tableInfomation[0] : {}
              this.tableRowClick(this.selectRow)
            }
          }
        })
        .catch((err) => {
@@ -332,7 +365,7 @@
        number: "",
        contact: "",
        phone: "",
        signingDate: "",
        signingDate: this.getCurrentDate(),
        deliveryDate: "",
        remark: "",
        wholeDiscountType: null,
@@ -342,13 +375,20 @@
        realTotalPrice: 0
      }
    },
    // 获取当前日期
    getCurrentDate() {
      let now = new Date()
      let year = now.getFullYear()
      let month = now.getMonth() + 1
      let day = now.getDate()
      return year + "-" + month + "-" + day
    },
    // 编辑
    btnEdit(row) {
      this.editConfig.detailEnter = false
      this.editConfig.isDisabled = false
      this.tableLoading = true
      getPurchaseInfo({ id: row.id }).then((res) => {
      getPurchaseInfo({ id: Number(row.id) }).then((res) => {
        if (res.code == 200) {
          this.tableLoading = false
          this.editConfig.visible = true
@@ -368,9 +408,8 @@
      setTimeout(() => {
        this.tableLoading = false
      }, 3000)
      // this.editRow = row;
      // this.$refs.add.islook = true;
    },
    // 确认发货
    btnConfirm(row) {
      let string = "是否提交?"
@@ -386,7 +425,7 @@
          if (!row.supplierName) {
            this.btnEdit(row)
          } else {
            submitPurchase({ id: row.ID, status: 2 }).then((response) => {
            submitPurchase({ id: Number(row.id), status: 2 }).then((response) => {
              if (response.code === 200) {
                this.$message.success("提交成功")
                this.getData()
@@ -409,7 +448,7 @@
        type: "warning"
      }).then(
        () => {
          submitPurchase({ id: row.ID, status: 5 }).then((response) => {
          submitPurchase({ id: Number(row.id), status: 5 }).then((response) => {
            if (response.code === 200) {
              this.$message.success("已取消")
              this.getData()
@@ -431,7 +470,7 @@
        type: "warning"
      })
        .then(() => {
          deletePurchase({ id: row.ID }).then((response) => {
          deletePurchase({ id: Number(row.id) }).then((response) => {
            if (response.code === 200) {
              this.$message.success("删除成功")
              this.getData()
@@ -490,6 +529,29 @@
        this.tableLoading = false
      }, 3000)
    },
    // top 行点击
    tableRowClick(row) {
      this.selectRow = row
      if (row.status == 1 && this.TabsIndex == 0) {
        getPurchaseInfo({ id: row.id }).then((res) => {
          if (res.code == 200) {
            this.productTableList.tableInfomation = res.data.productList
          } else {
            this.$message.error(res.msg ? res.msg + "," : "" + "获取信息失败!")
          }
        })
      } else if (this.TabsIndex == 1 && row.status == 1) {
        this.productTableList.tableInfomation = []
      } else {
        getOperationInfo({ id: row.id }).then((res) => {
          if (res.code == 200) {
            this.productTableList.tableInfomation = res.data
          } else {
            this.$message.error(res.msg ? res.msg + "," : "" + "获取信息失败!")
          }
        })
      }
    },
    // bom 列表
    setBottomList() {
      this.productTableList = {
@@ -529,11 +591,7 @@
        this.tableBottomColumn = this.recriveColumn
        this.showBottomCol = this.showReceiveCol
        this.setBottomList()
        // if (this.selectRow.status == 1) {
        //   this.productTableList.tableInfomation = []
        // } else {
        this.getProductInventoryInfo(this.selectRow)
        // }
      }
    },
    // 状态
@@ -543,22 +601,25 @@
    // 获取产品/收货信息
    async getProductInventoryInfo(row) {
      console.log(row)
      // if (this.TabsIndex == 0 || row.status == 1) {
      //   this.productTableList.tableInfomation = row.products || []
      // } else {
      //   if (row.number) {
      //     this.loading = true
      //     await getProductInventoryInfo(row.number)
      //       .then((res) => {
      //         this.productTableList.tableInfomation = res.data?.length > 0 ? res.data : []
      //         this.loading = false
      //       })
      //       .catch(() => {
      //         this.productTableList.tableInfomation = []
      //         this.loading = false
      //       })
      //   }
      // }
      if (this.TabsIndex == 0 && row.status == 1) {
        getPurchaseInfo({ id: row.id }).then((res) => {
          if (res.code == 200) {
            this.productTableList.tableInfomation = res.data.productList
          } else {
            this.$message.error(res.msg ? res.msg + "," : "" + "获取信息失败!")
          }
        })
      } else if (this.TabsIndex == 1 && row.status == 1) {
        this.productTableList.tableInfomation = []
      } else {
        getOperationInfo({ id: row.id }).then((res) => {
          if (res.code == 200) {
            this.productTableList.tableInfomation = res.data
          } else {
            this.$message.error(res.msg ? res.msg + "," : "" + "获取信息失败!")
          }
        })
      }
    }
  }
}