gaoluyang
2025-05-20 7aa0e0f68d2a3d1268a64e49ab47c0c046265e84
src/views/procurementManagement/procurementLedger/index.vue
@@ -40,9 +40,9 @@
              <el-table-column label="单位" prop="unit" />
              <el-table-column label="数量" prop="quantity" />
              <el-table-column label="税率(%)" prop="taxRate" />
              <el-table-column label="含税单价(元)" prop="taxInclusiveUnitPrice" />
              <el-table-column label="含税总价(元)" prop="taxInclusiveTotalPrice" />
              <el-table-column label="不含税总价(元)" prop="taxExclusiveTotalPrice" />
              <el-table-column label="含税单价(元)" prop="taxInclusiveUnitPrice" :formatter="formattedNumber" />
              <el-table-column label="含税总价(元)" prop="taxInclusiveTotalPrice" :formatter="formattedNumber" />
              <el-table-column label="不含税总价(元)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber" />
            </el-table>
          </template>
        </el-table-column>
@@ -50,10 +50,8 @@
        <el-table-column label="采购合同号" prop="purchaseContractNumber" show-overflow-tooltip/>
        <el-table-column label="销售合同号" prop="salesContractNo" show-overflow-tooltip/>
        <el-table-column label="供应商名称" prop="supplierName" show-overflow-tooltip/>
        <el-table-column label="业务员" prop="businessPerson" show-overflow-tooltip/>
        <el-table-column label="电话" prop="businessPerson" show-overflow-tooltip/>
        <el-table-column label="项目名称" prop="projectName" show-overflow-tooltip/>
        <el-table-column label="合同金额(元)" prop="contractAmount" show-overflow-tooltip/>
        <el-table-column label="合同金额(元)" prop="contractAmount" show-overflow-tooltip :formatter="formattedNumber"/>
        <el-table-column label="录入人" prop="recorderName" show-overflow-tooltip/>
        <el-table-column label="录入日期" prop="entryDate" show-overflow-tooltip/>
        <el-table-column fixed="right" label="操作" min-width="60" align="center">
@@ -83,27 +81,15 @@
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="供应商名称:" prop="supplierName">
              <el-input v-model="form.supplierName" placeholder="请输入" clearable/>
            <el-form-item label="供应商名称:" prop="supplierId">
              <el-select v-model="form.supplierId" placeholder="请选择" clearable>
                <el-option v-for="item in supplierList" :key="item.id" :label="item.supplierName" :value="item.id"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目名称:" prop="projectName">
              <el-input v-model="form.projectName" placeholder="请输入" clearable/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="业务员:" prop="businessPersonId">
              <el-select v-model="form.businessPersonId" placeholder="请选择" clearable @change="setPhone">
                <el-option v-for="item in userList" :key="item.userId" :label="item.nickName" :value="item.userId"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="电话:" prop="phoneNumber">
              <el-input v-model="form.phoneNumber" placeholder="请输入" clearable/>
            </el-form-item>
          </el-col>
        </el-row>
@@ -136,7 +122,7 @@
            <el-button plain type="danger" @click="deleteProduct">删除</el-button>
          </el-form-item>
        </el-row>
        <el-table :data="productData" border @selection-change="productSelected">
        <el-table :data="productData" border @selection-change="productSelected" show-summary :summary-method="summarizeProTable">
          <el-table-column align="center" type="selection" width="55" />
          <el-table-column align="center" label="序号" type="index" width="60" />
          <el-table-column label="产品大类" prop="productCategory" />
@@ -144,12 +130,12 @@
          <el-table-column label="单位" prop="unit" />
          <el-table-column label="数量" prop="quantity" />
          <el-table-column label="税率(%)" prop="taxRate" />
          <el-table-column label="含税单价(元)" prop="taxInclusiveUnitPrice" />
          <el-table-column label="含税总价(元)" prop="taxInclusiveTotalPrice" />
          <el-table-column label="不含税总价(元)" prop="taxExclusiveTotalPrice" />
          <el-table-column label="含税单价(元)" prop="taxInclusiveUnitPrice" :formatter="formattedNumber"/>
          <el-table-column label="含税总价(元)" prop="taxInclusiveTotalPrice" :formatter="formattedNumber"/>
          <el-table-column label="不含税总价(元)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber"/>
          <el-table-column fixed="right" label="操作" min-width="60" align="center">
            <template #default="scope">
              <el-button link type="primary" size="small" @click="openProductForm('edit', scope.row);">编辑</el-button>
              <el-button link type="primary" size="small" @click="openProductForm('edit', scope.row, scope.$index);">编辑</el-button>
            </template>
          </el-table-column>
        </el-table>
@@ -228,7 +214,7 @@
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="含税单价(元):" prop="taxInclusiveUnitPrice">
              <el-input v-model="productForm.taxInclusiveUnitPrice" placeholder="请输入" clearable/>
              <el-input-number v-model="productForm.taxInclusiveUnitPrice" :precision="2" :step="0.1" clearable style="width: 100%"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
@@ -244,12 +230,12 @@
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="含税总价(元):" prop="taxInclusiveTotalPrice">
              <el-input v-model="productForm.taxInclusiveTotalPrice" placeholder="请输入" clearable/>
              <el-input-number v-model="productForm.taxInclusiveTotalPrice" :precision="2" :step="0.1" clearable style="width: 100%"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="不含税总价(元):" prop="taxExclusiveTotalPrice">
              <el-input v-model="productForm.taxExclusiveTotalPrice" placeholder="请输入" clearable/>
              <el-input-number v-model="productForm.taxExclusiveTotalPrice" :precision="2" :step="0.1" clearable style="width: 100%"/>
            </el-form-item>
          </el-col>
        </el-row>
@@ -289,7 +275,7 @@
  delPurchase,
  getSalesNo,
  purchaseList,
  productList, getPurchaseById
  productList, getPurchaseById, getOptions
} from "@/api/procurementManagement/procurementLedger.js";
const { proxy } = getCurrentInstance()
const tableData = ref([])
@@ -298,6 +284,7 @@
const productSelectedRows = ref([])
const userList = ref([])
const salesContractList = ref([])
const supplierList = ref([])
const tableLoading = ref(false)
const page = reactive({
  current: 1,
@@ -323,23 +310,21 @@
    recorderId: '',
    entryDate: '',
    productData: [],
    businessPersonId: '',
    phoneNumber: '',
    supplierName: '',
    supplierId: '',
  },
  rules: {
    purchaseContractNumber: [{ required: true, message: "请输入", trigger: "blur" }],
    salesLedgerId: [{ required: true, message: "请选择", trigger: "change" }],
    projectName: [{ required: true, message: "请输入", trigger: "blur" }],
    businessPersonId: [{ required: true, message: "请选择", trigger: "change" }],
    phoneNumber: [{ required: true, message: "请输入", trigger: "blur" }],
    supplierName: [{ required: true, message: "请输入", trigger: "blur" }],
    supplierId: [{ required: true, message: "请输入", trigger: "blur" }],
  }
})
const { searchForm, form, rules } = toRefs(data)
// 产品表单弹框数据
const productFormVisible = ref(false)
const productOperationType = ref('')
const productOperationIndex = ref('')
const currentId = ref('')
const productFormData = reactive({
  productForm: {
@@ -373,7 +358,9 @@
  headers: { Authorization: "Bearer " + getToken() },
})
const formattedNumber = (row, column, cellValue) => {
  return parseFloat(cellValue).toFixed(2);
};
// 查询列表
/** 搜索按钮操作 */
const handleQuery = () => {
@@ -428,50 +415,12 @@
}
// 主表合计方法
const summarizeMainTable = (param) => {
  const { columns, data } = param;
  const sums = [];
  columns.forEach((column, index) => {
    if (index === 0) {
      sums[index] = '合计';
      return;
    }
    const prop = column.property;
    if (['contractAmount'].includes(prop)) {
      const values = data.map(item => Number(item[prop]));
      if (!values.every(value => isNaN(value))) {
        sums[index] = values.reduce((acc, val) => (!isNaN(val) ? acc + val : acc), 0);
      } else {
        sums[index] = '';
      }
    } else {
      sums[index] = '';
    }
  })
  return sums;
  return proxy.summarizeTable(param, ['contractAmount']);
};
// 子表合计方法
const summarizeChildrenTable = (param) => {
  const { columns, data } = param;
  const sums = [];
  columns.forEach((column, index) => {
    if (index === 0) {
      sums[index] = '合计';
      return;
    }
    const prop = column.property;
    if (['taxInclusiveUnitPrice', 'taxInclusiveTotalPrice', 'taxExclusiveTotalPrice'].includes(prop)) {
      const values = data.map(item => Number(item[prop]));
      if (!values.every(value => isNaN(value))) {
        sums[index] = values.reduce((acc, val) => (!isNaN(val) ? acc + val : acc), 0);
      } else {
        sums[index] = '';
      }
    } else {
      sums[index] = '';
    }
  });
  return sums;
}
const summarizeProTable = (param) => {
  return proxy.summarizeTable(param, ['taxInclusiveUnitPrice', 'taxInclusiveTotalPrice', 'taxExclusiveTotalPrice']);
};
// 打开弹框
const openForm = (type, row) => {
  operationType.value = type
@@ -483,6 +432,9 @@
  })
  getSalesNo().then(res => {
    salesContractList.value = res
  })
  getOptions().then(res => {
    supplierList.value = res.data
  })
  form.value.recorderId = userStore.id
  form.value.entryDate = getCurrentDate();
@@ -500,14 +452,10 @@
  }
  dialogFormVisible.value = true
}
// 赋值电话
const setPhone = (id) => {
  form.value.phoneNumber = userList.value.find(u => u.userId === id)?.phonenumber || '';
}
// 上传前校检
function handleBeforeUpload(file) {
  // 校检文件大小
  if (file.size > 1024 * 1024) {
  if (file.size > 1024 * 1024 * 10) {
    proxy.$modal.msgError('上传文件大小不能超过10MB!')
    return false
  }
@@ -571,8 +519,9 @@
  dialogFormVisible.value = false
}
// 打开产品弹框
const openProductForm = (type, row) => {
const openProductForm = (type, row, index) => {
  productOperationType.value = type
  productOperationIndex.value = index
  productForm.value = {}
  proxy.resetForm("productFormRef")
  if (type === 'edit') {
@@ -587,7 +536,11 @@
      if (operationType.value === "edit") {
        submitProductEdit()
      } else {
        productData.value.push({...productForm.value})
        if (productOperationType.value === 'add') {
          productData.value.push({...productForm.value})
        } else {
          productData.value[productOperationIndex.value] = {...productForm.value}
        }
        closeProductDia()
      }
    }
@@ -595,6 +548,7 @@
}
const submitProductEdit = () => {
  productForm.value.salesLedgerId = currentId.value
  productForm.value.type = 2
  addOrUpdateSalesLedgerProduct(productForm.value).then(res => {
    proxy.$modal.msgSuccess("提交成功")
    closeProductDia()