feat: 采购管理税率+分开单价总价列 + 按单出/借库锁定扫描 + 含税法计算
- purchase: 新增tax_rate字段(model+service+frontend), 表格拆分为不含税单价/总价/税率三列 - buy.vue: 含税法计算(含税总价=数量×含税单价), 含税总价自动计算可手动覆盖 - create.vue: 按单出库模式下未选审批单时锁定摄像头和SKU输入 - borrow.vue: 未选审批单时锁定摄像头和SKU输入 - deploy_production.sql: 整合全部数据库变更(表结构+权限码+角色分配)
This commit is contained in:
@ -24,12 +24,19 @@
|
||||
<el-table-column prop="spec_model" label="规格型号" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="quantity" label="数量" width="80" align="center" />
|
||||
<el-table-column prop="purchase_date" label="采购日期" width="110" />
|
||||
<el-table-column label="单价/总价" width="120" align="right">
|
||||
<el-table-column label="不含税单价" width="110" align="right">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.unit_price || row.total_price">
|
||||
{{ row.unit_price || '-' }} / {{ row.total_price || '-' }}
|
||||
</span>
|
||||
<span v-else>-</span>
|
||||
{{ row.unit_price ? '¥' + Number(row.unit_price).toFixed(2) : '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="不含税总价" width="120" align="right">
|
||||
<template #default="{ row }">
|
||||
{{ row.total_price ? '¥' + Number(row.total_price).toFixed(2) : '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="tax_rate" label="税率" width="70" align="center">
|
||||
<template #default="{ row }">
|
||||
{{ row.tax_rate != null ? row.tax_rate + '%' : '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="requester_name" label="申请人" width="100" />
|
||||
@ -126,16 +133,26 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="单价">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="不含税单价">
|
||||
<el-input-number v-model="form.unit_price" :min="0" :precision="2" style="width: 100%;" @change="onUnitPriceChange" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="总价">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="不含税总价">
|
||||
<el-input-number v-model="form.total_price" :min="0" :precision="2" style="width: 100%;" @change="onTotalPriceChange" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="税率">
|
||||
<el-select v-model="form.tax_rate" style="width: 100%;" @change="onTaxRateChange">
|
||||
<el-option label="0%" :value="0" />
|
||||
<el-option label="1%" :value="1" />
|
||||
<el-option label="6%" :value="6" />
|
||||
<el-option label="13%" :value="13" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="商家链接">
|
||||
<el-input v-model="form.supplier_link" placeholder="商家地址链接" clearable />
|
||||
@ -311,6 +328,7 @@ const form = ref({
|
||||
remark: '',
|
||||
unit_price: undefined as number | undefined,
|
||||
total_price: undefined as number | undefined,
|
||||
tax_rate: 0,
|
||||
approver_id: undefined as number | undefined,
|
||||
images: [] as string[]
|
||||
})
|
||||
@ -381,7 +399,7 @@ const openCreateDialog = (prefill?: { materialId?: number; name?: string; spec?:
|
||||
quantity: 1,
|
||||
purchase_date: new Date().toISOString().split('T')[0],
|
||||
supplier_link: '', remark: '',
|
||||
unit_price: undefined, total_price: undefined,
|
||||
unit_price: undefined, total_price: undefined, tax_rate: 0,
|
||||
approver_id: undefined, images: []
|
||||
}
|
||||
|
||||
@ -506,11 +524,16 @@ const onUnitPriceChange = (val: number | undefined) => {
|
||||
}
|
||||
|
||||
const onTotalPriceChange = (_val: number | undefined) => {
|
||||
// 用户手动修改总价时:标记为已手动修改,不再反向强制覆盖单价
|
||||
// 允许用户输入打包一口价(如单价3元,买2个算5元),保留用户填入的单价和总价
|
||||
totalPriceManuallyEdited.value = true
|
||||
}
|
||||
|
||||
const onTaxRateChange = () => {
|
||||
// 税率变化时:保持不含税单价不变,重算不含税总价 = 单价×数量
|
||||
if (form.value.unit_price && form.value.quantity) {
|
||||
form.value.total_price = Number((form.value.unit_price * form.value.quantity).toFixed(2))
|
||||
}
|
||||
}
|
||||
|
||||
// --- 上传 ---
|
||||
const beforeAvatarUpload = (rawFile: any) => {
|
||||
const isTypeValid = ['image/jpeg', 'image/png', 'image/gif', 'image/webp', 'image/bmp'].includes(rawFile.type)
|
||||
|
||||
Reference in New Issue
Block a user