增加软删除
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
:search-columns="searchColumns"
|
||||
:query="queryList"
|
||||
row-key="productId"
|
||||
:selection="true"
|
||||
>
|
||||
<template #toolbar="{ selection }">
|
||||
<el-col :span="1.5">
|
||||
@@ -33,6 +34,16 @@
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="!selection.length"
|
||||
@click="handleBatchDelete(selection)"
|
||||
v-hasPermi="['price:redline:remove']"
|
||||
>批量删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button plain icon="Clock" @click="expiredRef.open()" v-hasPermi="['price:redline:list']">失效价格</el-button>
|
||||
</el-col>
|
||||
@@ -152,9 +163,10 @@ import RedlineExcelFileDrawer from './components/RedlineExcelFileDrawer.vue'
|
||||
import RedlineCountryDrawer from './components/RedlineCountryDrawer.vue'
|
||||
import RedlineSurchargeDrawer from './components/RedlineSurchargeDrawer.vue'
|
||||
import RedlineExpiredDrawer from './components/RedlineExpiredDrawer.vue'
|
||||
import { listRedline, importRedlineExcelAsync, importRedlineCountryExcelAsync } from '@/api/price/redline'
|
||||
import { listRedline, delRedline, importRedlineExcelAsync, importRedlineCountryExcelAsync } from '@/api/price/redline'
|
||||
import { listRegionOptions } from '@/api/data/region'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bms_product_effect_status } = useDict('bms_product_effect_status')
|
||||
|
||||
const extraParams = { statusGroup: 'active' }
|
||||
@@ -240,6 +252,47 @@ function handleUpdate(row) {
|
||||
formRef.value.open(row)
|
||||
}
|
||||
|
||||
function isPendingProduct(row) {
|
||||
if (!row) return false
|
||||
if (String(row.status) === '0') return true
|
||||
if (!row.effectiveDate) return false
|
||||
const eff = new Date(String(row.effectiveDate).replace(/-/g, '/')).getTime()
|
||||
if (Number.isNaN(eff) || eff <= Date.now()) return false
|
||||
if (row.expireDate) {
|
||||
const exp = new Date(String(row.expireDate).replace(/-/g, '/')).getTime()
|
||||
if (!Number.isNaN(exp) && exp <= Date.now()) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function handleBatchDelete(selection) {
|
||||
const rows = (selection || []).filter(r => r && r.productId != null)
|
||||
if (!rows.length) {
|
||||
proxy.$modal.msgWarning('请先勾选红线价')
|
||||
return
|
||||
}
|
||||
const pending = rows.filter(isPendingProduct)
|
||||
const blocked = rows.filter(r => !isPendingProduct(r))
|
||||
if (!pending.length) {
|
||||
proxy.$modal.msgWarning('仅待生效红线价可删除,当前勾选无待生效记录')
|
||||
return
|
||||
}
|
||||
if (blocked.length) {
|
||||
const tip = blocked.map(r => r.productCode || r.productId).join('、')
|
||||
proxy.$modal.msgWarning('已跳过非待生效红线价:' + tip)
|
||||
}
|
||||
const codes = pending.map(r => r.productCode || r.productId).join('、')
|
||||
const ids = pending.map(r => r.productId)
|
||||
proxy.$modal.confirm(
|
||||
'确认删除已选待生效红线价(' + pending.length + '个):'
|
||||
+ codes
|
||||
+ '?删除后产品及国家/重量段明细将一并清除,且不可恢复。'
|
||||
).then(() => delRedline(ids)).then(() => {
|
||||
tableRef.value.refresh()
|
||||
proxy.$modal.msgSuccess('删除成功')
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function handleImportCommand(command) {
|
||||
if (command === 'country') {
|
||||
handleCountryImport()
|
||||
|
||||
Reference in New Issue
Block a user