yangfeng
2024-03-08 60d0884f82141a0127fca7e2b03bf3c147436776
采购订单列表接口联调和添加采购订单接口联调
4个文件已修改
438 ■■■■■ 已修改文件
src/api/purchaseManage/purchase.js 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/makepager/CommonFormTableView.vue 197 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/purchaseManage/purchase/components/AddPurchase.vue 61 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/purchaseManage/purchase/index.vue 111 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/purchaseManage/purchase.js
@@ -49,7 +49,7 @@
    method: "get"
  })
}
// 采购单列表
// 采购单列表
// export const getPurchaseList = async (data) => {
//     return await axios.get(`/api/purchase/purchaseList`, {
//       params: data
@@ -72,36 +72,36 @@
}
// 更新采购单
export function updatePurchase(data) {
    return request({
      url: "/api/purchase/purchase",
      method: "put",
      data
    })
  }
  return request({
    url: "/api/purchase/purchase",
    method: "put",
    data
  })
}
//   获取采购单信息
export function getPurchaseInfo(data) {
    return request({
      url: "/api/purchase/purchase/"+data.id,
      method: "get",
      data
    })
  }
  //  删除采购单信息
  return request({
    url: "/api/purchase/purchase/" + data.id,
    method: "get",
    data
  })
}
//  删除采购单信息
export function deletePurchase(data) {
    return request({
      url: "/api/purchase/purchase/"+data.id,
      method: "delete",
      data
    })
  }
  return request({
    url: "/api/purchase/purchase/" + data.id,
    method: "delete",
    data
  })
}
//   提交采购单
export function submitPurchase(data) {
    return request({
      url: "/api/purchase/submit",
      method: "post",
      data
    })
  }
  return request({
    url: "/api/purchase/submit",
    method: "post",
    data
  })
}
// 新建采购类型
export function savePurchaseType(data) {
  return request({
@@ -123,4 +123,19 @@
  return await axios.get(`/api/purchase/qualityInspectList`, {
    params: data
  })
}
}
//   获取仓库列表
export function getWarehouseInfo() {
  return request({
    url: "/api/purchase/getWarehouseInfo/",
    method: "get"
  })
}
//   获取产品/收货信息
export function getOperationInfo(data) {
  return request({
    url: "/api/purchase/getOperationInfo/" + data.id,
    method: "get",
    data
  })
}
src/components/makepager/CommonFormTableView.vue
@@ -1,18 +1,30 @@
<template>
  <div class="page-view">
    <el-form ref="form" :model="tableList" :show-message="false" label-position="right">
      <el-table
      :data="tableList.tableData"
      style="width: 100%"
      :show-summary="showSummary.show"
      :summary-method="getSummaries"
      :span-method="arraySpanMethod"
      @row-click="rowClick"
      <el-table
        :data="tableList.tableData"
        style="width: 100%"
        :show-summary="showSummary.show"
        :summary-method="getSummaries"
        :span-method="arraySpanMethod"
        @row-click="rowClick"
      >
        <el-table-column type="index" v-if="tableList.tableColumn && tableList.tableColumn.length > 0" label="编号"
          width="50" align="center"></el-table-column>
        <el-table-column v-for="(item, i) in tableList.tableColumn" :key="i" :prop="item.prop" :label="item.label"
          :width="item.width" :min-width="item.min" align="center">
        <el-table-column
          type="index"
          v-if="tableList.tableColumn && tableList.tableColumn.length > 0"
          label="编号"
          width="50"
          align="center"
        ></el-table-column>
        <el-table-column
          v-for="(item, i) in tableList.tableColumn"
          :key="i"
          :prop="item.prop"
          :label="item.label"
          :width="item.width"
          :min-width="item.min"
          align="center"
        >
          <!-- 表头样式 -->
          <template slot="header">
            <span v-if="item.isRequird" style="color: #f56c6c">*</span>
@@ -21,64 +33,127 @@
          <!-- column样式 -->
          <template slot-scope="scope">
            <!-- <template v-if="!detailEnter"> -->
            <el-form-item v-if="item.input" label=" " :prop="'tableData.' + scope.$index + '.' + item.prop"
              :rules="[{ required: item.isRequird ? true : false, message: '输入不能为空' }]">
              <el-input :disabled="item.disabled" v-model.trim="scope.row[item.prop]" maxlength="50" size="mini" @change="(val) => {
                commonInputChange(val, item.prop, scope.row)
              }
                "></el-input>
            <el-form-item
              v-if="item.input"
              label=" "
              :prop="'tableData.' + scope.$index + '.' + item.prop"
              :rules="[{ required: item.isRequird ? true : false, message: '输入不能为空' }]"
            >
              <el-input
                :disabled="item.disabled"
                v-model.trim="scope.row[item.prop]"
                maxlength="50"
                size="mini"
                @change="
                  (val) => {
                    commonInputChange(val, item.prop, scope.row)
                  }
                "
              ></el-input>
            </el-form-item>
            <el-form-item v-else-if="item.productName" label=" " :prop="'tableData.' + scope.$index + '.' + item.prop">
              <div class="custom-name">
                <el-autocomplete :disabled="item.disabled" v-model="scope.row[item.prop]"
                  :fetch-suggestions="querySearchAsync" value-key="name" style="width: calc(100% - 70px)" size="mini"
                  @select="(val) => {
                    handleSelectClient(val, item.prop, scope.row)
                  }
                    "></el-autocomplete>
                <div v-if="!item.disabled" class="common-select-btn" @click="selClientClick(scope.row, item.prop, scope)">
                <el-autocomplete
                  :disabled="item.disabled"
                  v-model="scope.row[item.prop]"
                  :fetch-suggestions="querySearchAsync"
                  value-key="name"
                  style="width: calc(100% - 70px)"
                  size="mini"
                  @select="
                    (val) => {
                      handleSelectClient(val, item.prop, scope.row)
                    }
                  "
                ></el-autocomplete>
                <div
                  v-if="!item.disabled"
                  class="common-select-btn"
                  @click="selClientClick(scope.row, item.prop, scope)"
                >
                  <i class="el-icon-circle-plus-outline" title="选择"></i>
                </div>
                <div v-if="!item.disabled" class="common-select-btn" @click="clearupClient(scope.row, scope)">
                  <i class="el-icon-remove-outline" title="清除"></i>
                </div>
                <div class="common-select-btn" v-if="scope.$index != 0 || !item.disabled"
                  @click="deleteClient(scope.row, scope)">
                  <i class="el-icon-delete" title="删除"></i>
                </div>
                <template v-if="!item.disabled">
                  <div class="common-select-btn" v-if="scope.$index != 0" @click="deleteClient(scope.row, scope)">
                    <i class="el-icon-delete" title="删除"></i>
                  </div>
                </template>
              </div>
            </el-form-item>
            <el-form-item v-else-if="item.date" label=" " :prop="'tableData.' + scope.$index + '.' + item.prop"
              :rules="[{ required: item.isRequird ? true : false, message: '输入不能为空' }]">
            <el-form-item
              v-else-if="item.date"
              label=" "
              :prop="'tableData.' + scope.$index + '.' + item.prop"
              :rules="[{ required: item.isRequird ? true : false, message: '输入不能为空' }]"
            >
              <!-- <el-input v-model.trim="scope.row[item.prop]" maxlength="50" size="mini"></el-input> -->
              <el-date-picker v-model="scope.row[item.prop]" type="date" size="mini" style="width: 110px">
              </el-date-picker>
            </el-form-item>
            <el-form-item v-else-if="item.inputNumber" label=" " :prop="'tableData.' + scope.$index + '.' + item.prop"
              :rules="[{ required: item.isRequird ? true : false, message: '输入不能为空' }]">
              <el-input-number :disabled="item.disabled" v-model="scope.row[item.prop]" placeholder="" :min="0"
                :controls="false" size="mini" style="width: 100%; margin-right: 5px" @change="(val) => {
                  commonInputChange(val, item.prop, scope.row)
                }
                  "></el-input-number>
            <el-form-item
              v-else-if="item.inputNumber"
              label=" "
              :prop="'tableData.' + scope.$index + '.' + item.prop"
              :rules="[{ required: item.isRequird ? true : false, message: '输入不能为空' }]"
            >
              <el-input-number
                :disabled="item.disabled"
                v-model="scope.row[item.prop]"
                placeholder=""
                :min="0"
                :controls="false"
                size="mini"
                style="width: 100%; margin-right: 5px"
                @change="
                  (val) => {
                    commonInputChange(val, item.prop, scope.row)
                  }
                "
              ></el-input-number>
            </el-form-item>
            <el-form-item v-else-if="item.inputFloat" label=" " :prop="'tableData.' + scope.$index + '.' + item.prop"
              :rules="[{ required: item.isRequird ? true : false, message: '输入不能为空' }]">
            <el-form-item
              v-else-if="item.inputFloat"
              label=" "
              :prop="'tableData.' + scope.$index + '.' + item.prop"
              :rules="[{ required: item.isRequird ? true : false, message: '输入不能为空' }]"
            >
              <!-- 采购管理 -->
              <template v-if="item.multiply">
                <el-input-number :disabled="item.disabled"
                  :value="scope.row[showSummary.multiply[0]] * scope.row[showSummary.multiply[1]]" placeholder="" :min="0"
                  :precision="2" :controls="false" size="mini" style="width: 100%; margin-right: 5px" @input="(val) => {
                    commonInputChange(val, item.prop, scope.row)
                  }
                    "></el-input-number>
                <el-input-number
                  :disabled="item.disabled"
                  :value="scope.row[showSummary.multiply[0]] * scope.row[showSummary.multiply[1]]"
                  placeholder=""
                  :min="0"
                  :precision="2"
                  :controls="false"
                  size="mini"
                  style="width: 100%; margin-right: 5px"
                  @input="
                    (val) => {
                      commonInputChange(val, item.prop, scope.row)
                    }
                  "
                ></el-input-number>
              </template>
              <template v-else>
                <el-input-number :disabled="item.disabled" v-model="scope.row[item.prop]" placeholder="" :min="0"
                  :precision="2" :controls="false" size="mini" style="width: 100%; margin-right: 5px" @change="(val) => {
                    commonInputChange(val, item.prop, scope.row)
                  }
                    "></el-input-number>
                <el-input-number
                  :disabled="item.disabled"
                  v-model="scope.row[item.prop]"
                  placeholder=""
                  :min="0"
                  :precision="2"
                  :controls="false"
                  size="mini"
                  style="width: 100%; margin-right: 5px"
                  @change="
                    (val) => {
                      commonInputChange(val, item.prop, scope.row)
                    }
                  "
                ></el-input-number>
              </template>
            </el-form-item>
            <span v-else>{{ scope.row[item.prop] }}</span>
@@ -93,8 +168,12 @@
      <el-button :disabled="tableList.disabled" size="small" type="primary" @click="empty">清空</el-button>
    </div>
    <!-- 产品名称 -->
    <SelectCommonDialog v-if="editSelCommonConfig.editVisible" :edit-common-config="editSelCommonConfig" :sign="sign"
      @selClient="selClient" />
    <SelectCommonDialog
      v-if="editSelCommonConfig.editVisible"
      :edit-common-config="editSelCommonConfig"
      :sign="sign"
      @selClient="selClient"
    />
  </div>
</template>
@@ -157,7 +236,7 @@
        infomation: {}
      },
      productIndex: 0,
      tableProductLists: [],
      tableProductLists: []
    }
  },
  created() {
@@ -168,12 +247,12 @@
  watch: {
    productTableList() {
      this.tableList = this.productTableList
    },
    }
  },
  methods: {
    // 选择行
    rowClick(row){
      this.$emit("rowClick",row)
    rowClick(row) {
      this.$emit("rowClick", row)
    },
    // 产品名称
    async getProductList() {
@@ -318,7 +397,7 @@
      if (this.detailEnter) {
        this.setEditName(item, row.id)
      }
      this.$emit("handleProduct",item,row)
      this.$emit("handleProduct", item, row)
    },
    setEditName(item, id) {
      let selRow = {
@@ -365,7 +444,7 @@
          if (index === this.productIndex) {
            ite.name = item.name
            ite.productId = item.id
            ite.productIndex = this.productIndex+1
            ite.productIndex = this.productIndex + 1
            ite.amount = item.amount || 1
            ite.number = item.number
            ite.purchasePrice = item.purchasePrice
@@ -453,7 +532,7 @@
  }
  .el-table .cell,
  .el-table th.el-table__cell>.cell {
  .el-table th.el-table__cell > .cell {
    padding: 0 5px;
  }
src/views/purchaseManage/purchase/components/AddPurchase.vue
@@ -163,35 +163,51 @@
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="收货仓库" prop="receiveWarehouse">
                <el-form-item label="收货仓库" prop="warehouse">
                  <el-select
                    placeholder="请选择收货仓库"
                    v-model="editConfig.infomation.receiveWarehouse"
                    v-model="editConfig.infomation.warehouse"
                    clearable
                    style="width: calc(100% - 0px)"
                    :disabled="editConfig.isDisabled"
                  >
                    <el-option
                      v-for="(ele, index) in receiveWhouseList"
                      :key="index"
                      :label="ele.name"
                      :value="ele.id"
                      :value="ele.name"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="地址" prop="address">
                  <el-input v-model="editConfig.infomation.address" placeholder="请填写" clearable></el-input>
                <el-form-item label="地址" prop="warehouseAddress">
                  <el-input
                    :disabled="editConfig.isDisabled"
                    v-model="editConfig.infomation.warehouseAddress"
                    placeholder="请填写"
                    clearable
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="接收人" prop="recipient">
                  <el-input v-model="editConfig.infomation.recipient" placeholder="请填写" clearable></el-input>
                <el-form-item label="接收人" prop="principal">
                  <el-input
                    :disabled="editConfig.isDisabled"
                    v-model="editConfig.infomation.principal"
                    placeholder="请填写"
                    clearable
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="来源单据" prop="sourceDoc">
                  <el-input v-model="editConfig.infomation.sourceDoc" placeholder="请填写" clearable></el-input>
                <el-form-item label="来源单据" prop="sourceOrder">
                  <el-input
                    :disabled="editConfig.isDisabled"
                    v-model="editConfig.infomation.sourceOrder"
                    placeholder="请填写"
                    clearable
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="24">
@@ -319,7 +335,13 @@
import CommonFormTableView from "@/components/makepager/CommonFormTableView"
import BomDialog from "@/components/makepager/BomDialog"
import { getProductList } from "@/api/productManage/product"
import { addPurchase, updatePurchase, savePurchaseType, getPurchaseType } from "@/api/purchaseManage/purchase"
import {
  addPurchase,
  updatePurchase,
  savePurchaseType,
  getPurchaseType,
  getWarehouseInfo
} from "@/api/purchaseManage/purchase"
import SelectSupplierDialog from "@/views/purchaseManage/purchase/components/SelectSupplierDialog"
// import { formToJSON } from "axios";
import codeMixin from "@/components/mixin/codeMixin"
@@ -401,12 +423,14 @@
      total: 0,
      totalTwo: 0,
      productListIdx: 0,
      lacks: []
      lacks: [],
      receiveWhouseList: [] // 收货仓库列表
    }
  },
  created() {
    console.log(this.editConfig,"参数")
    console.log(this.editConfig, "参数")
    this.handleGetBomKindDictList()
    this.getWarehouseInfo()
    this.$store.dispatch("getSupplier")
    this.formInfo()
  },
@@ -683,7 +707,11 @@
          realTotalPrice: this.total ? Number(this.total) : 0,
          totalPrice: this.totalTwo ? Number(this.totalTwo) : 0,
          status: data.status,
          quantity: data.quantity // 采购数量
          quantity: data.quantity, // 采购数量
          warehouse: data.warehouse || "", // 收货仓库
          warehouseAddress: data.warehouseAddress || "", // 收货仓库地址
          principal: data.principal || "", // 仓库负责人
          sourceOrder: data.sourceOrder || "" //  来源单据
        }
      }
      if (data.id) {
@@ -897,6 +925,13 @@
    handleProduct(item) {
      this.tableData[this.productListIdx].productId = Number(item.id)
      console.log(item, "选中产品", this.tableData)
    },
    // 获取收货仓库列表
    async getWarehouseInfo() {
      await getWarehouseInfo().then((res) => {
        console.log(res)
        this.receiveWhouseList = res.data.info
      })
    }
  }
}
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">
@@ -120,7 +122,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"
@@ -134,12 +142,13 @@
  data() {
    // 产品信息
    const productColumn = [
      { label: "产品编号", prop: "number", default: true },
      { label: "产品名称", prop: "name" },
      { label: "规格型号", prop: "desc" },
      { label: "采购数量", prop: "purchaseAmount" },
      { label: "已发货数量", prop: "margin" },
      { label: "已入库数量", prop: "amount" },
      { label: "产品编号", prop: "productId", default: true },
      { label: "产品名称", prop: "productName" },
      { 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: "total", price: true }
@@ -147,13 +156,13 @@
    // 收货信息
    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: "warehouseName" },
      { label: "产品名称", prop: "productName" },
      { label: "产品编码", prop: "productId" },
      { label: "数量", prop: "amount" },
      { label: "入库时间", prop: "overTime" },
      { label: "收货人", prop: "principal" },
      { label: "状态", prop: "status" }
    ]
    return {
      purchaseStatusList: getDataByType("purchaseStatus"),
@@ -195,7 +204,8 @@
      showProductCol: [
        "产品编号",
        "产品名称",
        "规格型号",
        "规格",
        "型号",
        "采购数量",
        "已发货数量",
        "已入库数量",
@@ -205,8 +215,9 @@
      ],
      // 收货信息
      recriveColumn: recriveColumn,
      showReceiveCol: ["入库单号", "收货仓库", "产品名称", "产品编号", "数量", "入库时间", "收货人", "状态"],
      loading: false
      showReceiveCol: ["入库单号", "收货仓库", "产品名称", "产品编码", "数量", "入库时间", "收货人", "状态"],
      loading: false,
      selectRow: {}
    }
  },
  created() {
@@ -289,6 +300,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) => {
@@ -490,6 +505,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 +567,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 +577,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 + "," : "" + "获取信息失败!")
          }
        })
      }
    }
  }
}