调整优化 审批和备货单 退税
This commit is contained in:
@@ -157,6 +157,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
|||||||
// 回显填充抑制标记:为 true 时不触发自动计算覆盖接口值
|
// 回显填充抑制标记:为 true 时不触发自动计算覆盖接口值
|
||||||
const isPopulating = ref(false)
|
const isPopulating = ref(false)
|
||||||
const userEditing = ref<Set<number>>(new Set()) // 跟踪用户正在编辑的行
|
const userEditing = ref<Set<number>>(new Set()) // 跟踪用户正在编辑的行
|
||||||
|
const manualTaxRefundRows = ref<Set<number>>(new Set()) // 跟踪用户手动编辑过预估退税额的行
|
||||||
|
|
||||||
// 选项数据
|
// 选项数据
|
||||||
const channelOptions = ref<any>()
|
const channelOptions = ref<any>()
|
||||||
@@ -766,14 +767,49 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
|||||||
const copyRow = (idx: number) => {
|
const copyRow = (idx: number) => {
|
||||||
const copied = JSON.parse(JSON.stringify(items.value[idx])) as ItemRow
|
const copied = JSON.parse(JSON.stringify(items.value[idx])) as ItemRow
|
||||||
items.value.splice(idx + 1, 0, copied)
|
items.value.splice(idx + 1, 0, copied)
|
||||||
|
// 如果原行是手动编辑的,复制的行也标记为手动编辑
|
||||||
|
if (manualTaxRefundRows.value.has(idx)) {
|
||||||
|
// 需要调整后续行的索引
|
||||||
|
const newManualRows = new Set<number>()
|
||||||
|
manualTaxRefundRows.value.forEach((rowIdx) => {
|
||||||
|
if (rowIdx <= idx) {
|
||||||
|
newManualRows.add(rowIdx)
|
||||||
|
} else {
|
||||||
|
newManualRows.add(rowIdx + 1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
newManualRows.add(idx + 1) // 新复制的行
|
||||||
|
manualTaxRefundRows.value = newManualRows
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const addRowAfter = (idx: number) => {
|
const addRowAfter = (idx: number) => {
|
||||||
items.value.splice(idx + 1, 0, newItem())
|
items.value.splice(idx + 1, 0, newItem())
|
||||||
|
// 调整后续行的手动编辑标记索引
|
||||||
|
const newManualRows = new Set<number>()
|
||||||
|
manualTaxRefundRows.value.forEach((rowIdx) => {
|
||||||
|
if (rowIdx <= idx) {
|
||||||
|
newManualRows.add(rowIdx)
|
||||||
|
} else {
|
||||||
|
newManualRows.add(rowIdx + 1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
manualTaxRefundRows.value = newManualRows
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeRow = (idx: number) => {
|
const removeRow = (idx: number) => {
|
||||||
items.value.splice(idx, 1)
|
items.value.splice(idx, 1)
|
||||||
|
// 移除该行的手动编辑标记,并调整后续行的索引
|
||||||
|
const newManualRows = new Set<number>()
|
||||||
|
manualTaxRefundRows.value.forEach((rowIdx) => {
|
||||||
|
if (rowIdx < idx) {
|
||||||
|
newManualRows.add(rowIdx)
|
||||||
|
} else if (rowIdx > idx) {
|
||||||
|
newManualRows.add(rowIdx - 1)
|
||||||
|
}
|
||||||
|
// rowIdx === idx 的行被删除,不添加到新集合中
|
||||||
|
})
|
||||||
|
manualTaxRefundRows.value = newManualRows
|
||||||
}
|
}
|
||||||
|
|
||||||
// 收款项操作方法
|
// 收款项操作方法
|
||||||
@@ -1098,6 +1134,16 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
|||||||
}
|
}
|
||||||
// 等待本轮变更完成后,再恢复自动计算
|
// 等待本轮变更完成后,再恢复自动计算
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
|
// 检查哪些行的预估退税额与自动计算值不同,标记为手动编辑
|
||||||
|
items.value.forEach((it: any, index: number) => {
|
||||||
|
const currentValue = String(it.tax_refund || '')
|
||||||
|
const autoCalculatedValue = String(calcTaxRefund(it) || '0')
|
||||||
|
if (currentValue !== autoCalculatedValue && currentValue !== '' && currentValue !== '0') {
|
||||||
|
manualTaxRefundRows.value.add(index)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 初始化 prevTaxRefundValues
|
||||||
|
prevTaxRefundValues.value = items.value.map((item: any) => String(item.tax_refund || ''))
|
||||||
isPopulating.value = false
|
isPopulating.value = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1329,11 +1375,13 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自动计算预估退税额
|
// 自动计算预估退税额(跳过用户手动编辑过的行)
|
||||||
const refund = calcTaxRefund(it)
|
if (!manualTaxRefundRows.value.has(index)) {
|
||||||
if (items.value[index]) {
|
const refund = calcTaxRefund(it)
|
||||||
items.value[index].tax_refund = isNaN(refund) ? '0' : String(Number(refund.toFixed(2)))
|
if (items.value[index]) {
|
||||||
;(items.value[index] as any).tax_refund_currency = 'CNY'
|
items.value[index].tax_refund = isNaN(refund) ? '0' : String(Number(refund.toFixed(2)))
|
||||||
|
;(items.value[index] as any).tax_refund_currency = 'CNY'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自动计算车价
|
// 自动计算车价
|
||||||
@@ -1385,13 +1433,41 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
|||||||
{ deep: true }
|
{ deep: true }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 存储上一次的 tax_refund 值,用于检测用户手动输入
|
||||||
|
const prevTaxRefundValues = ref<string[]>([])
|
||||||
|
|
||||||
// 当用户手动输入预估退税额时,重新计算利润
|
// 当用户手动输入预估退税额时,重新计算利润
|
||||||
watch(
|
watch(
|
||||||
() => items.value.map((item: any) => item.tax_refund),
|
() => items.value.map((item: any) => item.tax_refund),
|
||||||
() => {
|
(newValues) => {
|
||||||
if (isPopulating.value) return
|
if (isPopulating.value) return
|
||||||
|
|
||||||
|
// 初始化 prevTaxRefundValues
|
||||||
|
if (prevTaxRefundValues.value.length === 0) {
|
||||||
|
prevTaxRefundValues.value = newValues.map((v: any) => String(v || ''))
|
||||||
|
}
|
||||||
|
|
||||||
items.value.forEach((it: any, index: number) => {
|
items.value.forEach((it: any, index: number) => {
|
||||||
if (!items.value[index]) return
|
if (!items.value[index]) return
|
||||||
|
|
||||||
|
const currentValue = String(it.tax_refund || '')
|
||||||
|
const prevValue = prevTaxRefundValues.value[index] || ''
|
||||||
|
const autoCalculatedValue = String(calcTaxRefund(it) || '0')
|
||||||
|
|
||||||
|
// 如果当前值与自动计算值不同,且与上一次值不同,说明是用户手动输入的
|
||||||
|
if (
|
||||||
|
currentValue !== autoCalculatedValue &&
|
||||||
|
currentValue !== prevValue &&
|
||||||
|
currentValue !== ''
|
||||||
|
) {
|
||||||
|
// 标记该行已被用户手动编辑
|
||||||
|
manualTaxRefundRows.value.add(index)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新上一次的值
|
||||||
|
prevTaxRefundValues.value[index] = currentValue
|
||||||
|
|
||||||
|
// 重新计算利润
|
||||||
const profit = calcProfit(it)
|
const profit = calcProfit(it)
|
||||||
items.value[index].profit = isNaN(profit) ? 0 : Number(profit.toFixed(2))
|
items.value[index].profit = isNaN(profit) ? 0 : Number(profit.toFixed(2))
|
||||||
;(items.value[index] as any).profit_currency = (it as any).profit_currency || 'CNY'
|
;(items.value[index] as any).profit_currency = (it as any).profit_currency || 'CNY'
|
||||||
|
|||||||
@@ -176,7 +176,13 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="选项" size="small">
|
<el-form-item label="选项" size="small">
|
||||||
|
<el-input
|
||||||
|
v-if="group.type == 'field_user'"
|
||||||
|
placeholder="请输入"
|
||||||
|
v-model="group.users"
|
||||||
|
></el-input>
|
||||||
<el-select
|
<el-select
|
||||||
|
v-else
|
||||||
v-model="group.users"
|
v-model="group.users"
|
||||||
multiple
|
multiple
|
||||||
placeholder="请选择"
|
placeholder="请选择"
|
||||||
@@ -251,7 +257,13 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="选项" size="small">
|
<el-form-item label="选项" size="small">
|
||||||
|
<el-input
|
||||||
|
v-if="group.type == 'field_user'"
|
||||||
|
placeholder="请输入"
|
||||||
|
v-model="group.users"
|
||||||
|
></el-input>
|
||||||
<el-select
|
<el-select
|
||||||
|
v-else
|
||||||
v-model="group.users"
|
v-model="group.users"
|
||||||
multiple
|
multiple
|
||||||
placeholder="请选择"
|
placeholder="请选择"
|
||||||
@@ -660,6 +672,8 @@
|
|||||||
node.approverGroups.forEach((group) => {
|
node.approverGroups.forEach((group) => {
|
||||||
if (group && group.type === 'initiator_leader') {
|
if (group && group.type === 'initiator_leader') {
|
||||||
approvers.push({ type: 'initiator_leader' })
|
approvers.push({ type: 'initiator_leader' })
|
||||||
|
} else if (group && group.type === 'field_user') {
|
||||||
|
approvers.push({ type: group.type, value: group.users })
|
||||||
} else if (group && group.type && Array.isArray(group.users) && group.users.length > 0) {
|
} else if (group && group.type && Array.isArray(group.users) && group.users.length > 0) {
|
||||||
approvers.push({ type: group.type, value: group.users.join(',') })
|
approvers.push({ type: group.type, value: group.users.join(',') })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,7 +176,13 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="选项" size="small">
|
<el-form-item label="选项" size="small">
|
||||||
|
<el-input
|
||||||
|
v-if="group.type == 'field_user'"
|
||||||
|
placeholder="请输入"
|
||||||
|
v-model="group.users"
|
||||||
|
></el-input>
|
||||||
<el-select
|
<el-select
|
||||||
|
v-else
|
||||||
v-model="group.users"
|
v-model="group.users"
|
||||||
multiple
|
multiple
|
||||||
placeholder="请选择"
|
placeholder="请选择"
|
||||||
@@ -251,7 +257,13 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="选项" size="small">
|
<el-form-item label="选项" size="small">
|
||||||
|
<el-input
|
||||||
|
v-if="group.type == 'field_user'"
|
||||||
|
placeholder="请输入"
|
||||||
|
v-model="group.users"
|
||||||
|
></el-input>
|
||||||
<el-select
|
<el-select
|
||||||
|
v-else
|
||||||
v-model="group.users"
|
v-model="group.users"
|
||||||
multiple
|
multiple
|
||||||
placeholder="请选择"
|
placeholder="请选择"
|
||||||
@@ -604,6 +616,8 @@
|
|||||||
await ensureOptionsLoaded(group)
|
await ensureOptionsLoaded(group)
|
||||||
if (ap.type === 'initiator_leader') {
|
if (ap.type === 'initiator_leader') {
|
||||||
group.users = []
|
group.users = []
|
||||||
|
} else if (ap.type === 'field_user') {
|
||||||
|
group.users = ap.value.split(',').map((v) => v.trim())
|
||||||
} else if (ap.value) {
|
} else if (ap.value) {
|
||||||
const values = String(ap.value)
|
const values = String(ap.value)
|
||||||
.split(',')
|
.split(',')
|
||||||
@@ -637,6 +651,8 @@
|
|||||||
await ensureOptionsLoaded(group)
|
await ensureOptionsLoaded(group)
|
||||||
if (c.type === 'initiator_leader') {
|
if (c.type === 'initiator_leader') {
|
||||||
group.users = []
|
group.users = []
|
||||||
|
} else if (c.type === 'field_user') {
|
||||||
|
group.users = c.value.split(',').map((v) => v.trim())
|
||||||
} else if (c.value) {
|
} else if (c.value) {
|
||||||
// group.users = String(c.value)
|
// group.users = String(c.value)
|
||||||
// .split(',')
|
// .split(',')
|
||||||
@@ -773,6 +789,8 @@
|
|||||||
node.approverGroups.forEach((group) => {
|
node.approverGroups.forEach((group) => {
|
||||||
if (group && group.type === 'initiator_leader') {
|
if (group && group.type === 'initiator_leader') {
|
||||||
approvers.push({ type: 'initiator_leader' })
|
approvers.push({ type: 'initiator_leader' })
|
||||||
|
} else if (group && group.type === 'field_user') {
|
||||||
|
approvers.push({ type: group.type, value: group.users })
|
||||||
} else if (group && group.type && Array.isArray(group.users) && group.users.length > 0) {
|
} else if (group && group.type && Array.isArray(group.users) && group.users.length > 0) {
|
||||||
approvers.push({ type: group.type, value: group.users.join(',') })
|
approvers.push({ type: group.type, value: group.users.join(',') })
|
||||||
}
|
}
|
||||||
@@ -789,7 +807,7 @@
|
|||||||
if (group && group.type === 'initiator_leader') {
|
if (group && group.type === 'initiator_leader') {
|
||||||
cc.push({ type: 'initiator_leader' })
|
cc.push({ type: 'initiator_leader' })
|
||||||
} else if (group && group.type && Array.isArray(group.users) && group.users.length > 0) {
|
} else if (group && group.type && Array.isArray(group.users) && group.users.length > 0) {
|
||||||
cc.push({ type: group.type, value: group.users.join(',') })
|
cc.push({ type: group.type, value: group.users })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,11 +183,15 @@
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const { currentPage, pageSize } = pagination
|
const { currentPage, pageSize } = pagination
|
||||||
|
const params: any = {
|
||||||
const { records, current, size, total } = await systemService.getNoticeList({
|
|
||||||
current: currentPage,
|
current: currentPage,
|
||||||
size: pageSize
|
size: pageSize
|
||||||
})
|
}
|
||||||
|
if (keyword.value) {
|
||||||
|
params.keyword = keyword.value
|
||||||
|
}
|
||||||
|
|
||||||
|
const { records, current, size, total } = await systemService.getNoticeList(params)
|
||||||
tableData.value = records.map((item: any) => ({
|
tableData.value = records.map((item: any) => ({
|
||||||
...item
|
...item
|
||||||
}))
|
}))
|
||||||
|
|||||||
Reference in New Issue
Block a user