Skip to content

Commit

Permalink
Fix bug in adding data tables to purchase modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Jzow committed Jun 3, 2024
1 parent e18c2f3 commit 22f6a47
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 21 deletions.
7 changes: 7 additions & 0 deletions web/src/views/purchase/model/addEditModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ const orderGridOptions = reactive<VxeGridProps<RowVO>>({
},
columns: [
{ type: 'checkbox', field:'productId', title: 'ID', width: 80},
{
field: 'warehouseId',
title: t('sales.shipments.form.table.warehouse'),
width: 130,
slots: { edit: 'warehouse_edit', default: 'warehouse_default' },
editRender: { name: 'input', attrs: { placeholder: t('sales.shipments.form.noticeEight') } }
},
{ field: 'barCode',
width:160,
title: t('purchase.order.form.table.barCode'),
Expand Down
67 changes: 52 additions & 15 deletions web/src/views/purchase/order/components/AddEditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
<a-button @click="addRowData" style="margin-right: 10px" v-text="t('purchase.order.form.insertRow')"/>
<a-button @click="deleteRowData" style="margin-right: 10px" v-text="t('purchase.order.form.deleteRow')"/>
</template>
<template #warehouse_default="{ row }">
<span>{{ formatWarehouseId(row.warehouseId) }}</span>
</template>
<template #warehouse_edit="{ row }">
<vxe-select v-model="row.warehouseId" :placeholder="t('sales.shipments.form.noticeEight')" @change="selectBarCode" :options="warehouseLabelList" clearable filterable></vxe-select>
</template>
<template #barCode_edit="{ row }">
<vxe-select v-model="row.barCode" :placeholder="t('purchase.order.form.table.inputBarCode')" @change="selectBarCode" :options="productLabelList" clearable filterable></vxe-select>
</template>
Expand Down Expand Up @@ -205,7 +211,7 @@ import {
tableData,
orderGridOptions,
getTaxTotalPrice,
} from '/src/views/purchase/model/addEditModel';
} from '@/views/purchase/model/addEditModel';
import {useModal} from "@/components/Modal";
import {generateId, uploadOss} from "@/api/basic/common";
import FinancialAccountModal from "@/views/basic/settlement-account/components/FinancialAccountModal.vue";
Expand Down Expand Up @@ -314,13 +320,15 @@ export default defineComponent({
const activeKey = ref('productDataTable');
const supplierList = ref<SupplierResp[]>([])
const accountList = ref<AccountResp[]>([]);
const warehouseList = ref<WarehouseResp[]>([]);
const multipleAccounts = ref();
const [supplierModal, {openModal}] = useModal();
const [accountModal, {openModal: openAccountModal}] = useModal();
const [selectProductModal, {openModal: openProductModal}] = useModal();
const [multipleAccountModal, {openModal: openManyAccountModal}] = useModal();
const productList = ref<ProductStockSkuResp[]>([]);
const productLabelList = ref<any[]>([]);
const warehouseLabelList = ref<any[]>([]);
const amountSymbol = ref<string>('')
const localeStore = useLocaleStore().getLocale;
if(localeStore === 'zh_CN') {
Expand All @@ -347,20 +355,26 @@ export default defineComponent({
title.value = t('purchase.order.addOrder')
loadGenerateId();
purchaseOrderFormState.receiptDate = dayjs(new Date());
addRowData();
}
}
function loadWarehouseList() {
getWarehouseList().then(res => {
const data = res.data
if(data) {
const defaultWarehouse = res.data.find(item => item.isDefault === 1)
if(defaultWarehouse) {
purchaseOrderFormState.warehouseId = defaultWarehouse.id
} else {
purchaseOrderFormState.warehouseId = res.data[0].id
const {columns} = orderGridOptions
if (columns) {
const warehouseColumn = columns[1]
warehouseColumn.editRender.options = [];
if (warehouseColumn && warehouseColumn.editRender) {
warehouseColumn.editRender.options?.push(...res.data.map(item => ({value: item.id, label: item.warehouseName})))
}
warehouseList.value = res.data
warehouseLabelList.value.push(...res.data.map(item => ({value: item.id, label: item.warehouseName})))
}
const defaultWarehouse = res.data.find(item => item.isDefault === 1)
if(defaultWarehouse) {
purchaseOrderFormState.warehouseId = defaultWarehouse.id
} else {
purchaseOrderFormState.warehouseId = res.data[0].id
}
})
}
Expand Down Expand Up @@ -420,14 +434,13 @@ export default defineComponent({
const {columns} = orderGridOptions
if (columns) {
const barCodeColumn = selectRow.row.barCode
const warehouseColumn = selectRow.row.warehouseId
if(barCodeColumn) {
const product = productList.value.find(item => {
return item.productBarcode === barCodeColumn;
return item.productBarcode === barCodeColumn && item.warehouseId === warehouseColumn;
});
if (product) {
selectRow.row.productId = product.productId
// 这里默认加载默认仓库
selectRow.row.warehouseId = purchaseOrderFormState.warehouseId
selectRow.row.productName = product.productName
selectRow.row.productStandard = product.productStandard
selectRow.row.productUnit = product.productUnit
Expand All @@ -437,9 +450,20 @@ export default defineComponent({
selectRow.row.amount = product.purchasePrice
selectRow.row.taxRate = 0
selectRow.row.productNumber = 1
table.updateData(selectRow.rowIndex, selectRow.row)
} else {
createMessage.warn(t('purchase.order.form.noticeFour'))
// 清空数据
selectRow.row.barCode = '';
selectRow.row.productId = undefined
selectRow.row.productName = ''
selectRow.row.productStandard = ''
selectRow.row.productUnit = ''
selectRow.row.stock = 0
selectRow.row.unitPrice = 0
selectRow.row.taxTotalPrice = 0
selectRow.row.amount = 0
selectRow.row.taxRate = 0
selectRow.row.productNumber = 0
}
}
}
Expand Down Expand Up @@ -679,7 +703,7 @@ export default defineComponent({
purchaseOrderFormState.multipleAccountAmounts = []
}
purchaseOrderFormState.discountLastAmount = purchaseOrderFormState.discountLastAmount.replace(/,/g, '').replace(amountSymbol.value, '')
purchaseOrderFormState.discountLastAmount = purchaseOrderFormState.discountLastAmount.toString().replace(/,/g, '').replace(amountSymbol.value, '')
const params: AddOrUpdateReceiptReq = {
...purchaseOrderFormState,
tableData: dataArray,
Expand Down Expand Up @@ -707,6 +731,8 @@ export default defineComponent({
barCode.value = ''
purchaseOrderFormState.remark = ''
fileList.value = []
warehouseList.value = []
warehouseLabelList.value = []
multipleAccounts.value = {}
const table = xGrid.value
if(table) {
Expand Down Expand Up @@ -772,8 +798,10 @@ export default defineComponent({
function addRowData() {
const table = xGrid.value
const defaultWarehouse = warehouseList.value.find(item => item.isDefault === 1)
const warehouseId = defaultWarehouse ? defaultWarehouse.id : warehouseList.value[0].id
if(table) {
table.insert({productNumber: 0})
table.insert({warehouseId: warehouseId})
}
}
Expand Down Expand Up @@ -921,6 +949,13 @@ export default defineComponent({
multipleAccounts.value = data;
}
const formatWarehouseId = (value: string) => {
const item = warehouseList.value.find(item => item.id === value)
if(item) {
return item.warehouseName
}
}
return {
t,
h,
Expand Down Expand Up @@ -984,6 +1019,8 @@ export default defineComponent({
multipleAccountModal,
handleAccountSuccess,
productList,
warehouseLabelList,
formatWarehouseId,
productLabelList,
selectBarCode,
handleSupplierModalSuccess
Expand Down
14 changes: 13 additions & 1 deletion web/src/views/purchase/refund/components/AddEditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,19 @@ export default defineComponent({
selectRow.row.amount = product.purchasePrice
selectRow.row.productNumber = 1
selectRow.row.taxRate = 0
table.updateData(selectRow.rowIndex, selectRow.row)
} else {
createMessage.warn(t('purchase.refund.form.noticeFour'))
selectRow.row.barCode = '';
selectRow.row.productId = undefined
selectRow.row.productName = ''
selectRow.row.productStandard = ''
selectRow.row.productUnit = ''
selectRow.row.stock = 0
selectRow.row.unitPrice = 0
selectRow.row.taxTotalPrice = 0
selectRow.row.amount = 0
selectRow.row.productNumber = 0
selectRow.row.taxRate = 0
}
}
}
Expand Down Expand Up @@ -812,6 +822,8 @@ export default defineComponent({
barCode.value = ''
purchaseRefundFormState.remark = ''
fileList.value = []
warehouseList.value = []
warehouseLabelList.value = []
multipleAccounts.value = {}
purchaseRefundFormState.receiptDate = undefined
clearTable()
Expand Down
20 changes: 16 additions & 4 deletions web/src/views/purchase/storage/components/AddEditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ import {
tableData,
gridOptions,
getTaxTotalPrice,
} from '/src/views/purchase/model/addEditModel';
} from '@/views/purchase/model/addEditModel';
import {useModal} from "@/components/Modal";
import {generateId, uploadOss} from "@/api/basic/common";
import FinancialAccountModal from "@/views/basic/settlement-account/components/FinancialAccountModal.vue";
Expand Down Expand Up @@ -468,9 +468,19 @@ export default defineComponent({
selectRow.row.amount = product.purchasePrice
selectRow.row.productNumber = 1
selectRow.row.taxRate = 0
table.updateData(selectRow.rowIndex, selectRow.row)
} else {
createMessage.warn(t('purchase.storage.form.noticeFour'))
selectRow.row.barCode = '';
selectRow.row.productId = undefined
selectRow.row.productName = ''
selectRow.row.productStandard = ''
selectRow.row.productUnit = ''
selectRow.row.stock = 0
selectRow.row.unitPrice = 0
selectRow.row.taxTotalPrice = 0
selectRow.row.amount = 0
selectRow.row.productNumber = 0
selectRow.row.taxRate = 0
}
}
}
Expand Down Expand Up @@ -816,6 +826,8 @@ export default defineComponent({
barCode.value = ''
purchaseStorageFormState.remark = ''
fileList.value = []
warehouseList.value = []
warehouseLabelList.value = []
multipleAccounts.value = {}
purchaseStorageFormState.receiptDate = undefined
clearTable()
Expand Down Expand Up @@ -1029,7 +1041,7 @@ export default defineComponent({
function otherAmountChange() {
const price = purchaseStorageFormState.paymentLastAmount;
const discountLastAmount = Number(price.replace(/,/g, '').replace(amountSymbol.value, ''))
const discountLastAmount = Number(price.toString().replace(/,/g, '').replace(amountSymbol.value, ''))
const otherAmount = purchaseStorageFormState.otherAmount
const lastAmount = Number((discountLastAmount + otherAmount));
Expand All @@ -1039,7 +1051,7 @@ export default defineComponent({
function thisPaymentAmountChange() {
const price = purchaseStorageFormState.paymentLastAmount;
const discountLastAmount = Number(price.replace(/,/g, '').replace(amountSymbol.value, ''))
const discountLastAmount = Number(price.toString().replace(/,/g, '').replace(amountSymbol.value, ''))
const otherAmount = purchaseStorageFormState.otherAmount
const thisCollectAmount = purchaseStorageFormState.thisPaymentAmount
const lastAmount = Number((discountLastAmount + otherAmount - thisCollectAmount));
Expand Down
1 change: 0 additions & 1 deletion web/src/views/sales/order/components/AddEditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ export default defineComponent({
createMessage.warn(t('sales.order.form.noticeFour'))
// 清空数据
selectRow.row.barCode = '';
selectRow.row.warhouse = undefined;
selectRow.row.productId = undefined
selectRow.row.productName = ''
selectRow.row.productStandard = ''
Expand Down

0 comments on commit 22f6a47

Please sign in to comment.