Commit dd4d0ecaaef7e2f560d4aea117237e11f3c2b9b1
1 parent
75d9e98e
周五了,冲
Showing
73 changed files
with
5289 additions
and
1048 deletions
Antis.Erp.Plat/.cursor/mcp.json
| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | "args": [ |
| 7 | 7 | "--yes", |
| 8 | 8 | "@davewind/mysql-mcp-server", |
| 9 | - "mysql://netteam:netteam@rm-bp19ohrgc6111ynzh1o.mysql.rds.aliyuncs.com:3306/ncc_wutong" | |
| 9 | + "mysql://ponggame_db:Ponggame_db_mm@mysql-3e725c5c7aad-public.rds.volces.com:3306/ponggame_test_db" | |
| 10 | 10 | ] |
| 11 | 11 | }, |
| 12 | 12 | "my-api-spec": { | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/api/douyinLogistics.js
| ... | ... | @@ -53,8 +53,12 @@ export function getShops() { |
| 53 | 53 | return douyinLogisticsClient.get('/shops') |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | -export function createWaybill(id) { | |
| 57 | - return douyinLogisticsClient.post(`/orders/${id}/waybill`) | |
| 56 | +export function createWaybill(id, productType) { | |
| 57 | + const params = {} | |
| 58 | + if (productType != null && String(productType).trim() !== '') { | |
| 59 | + params.productType = String(productType).trim() | |
| 60 | + } | |
| 61 | + return douyinLogisticsClient.post(`/orders/${id}/waybill`, null, { params }) | |
| 58 | 62 | } |
| 59 | 63 | |
| 60 | 64 | export function getWaybillPreview(id) { | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/api/extend/wtBillRecycle.js
0 → 100644
| 1 | +import request from '@/utils/request' | |
| 2 | + | |
| 3 | +const base = '/api/Extend/WtBillRecycle' | |
| 4 | + | |
| 5 | +/** 回收站列表(分页);GET 的 data 在拦截器中会作为 axios params 发出 */ | |
| 6 | +export function getWtBillRecycleList(query) { | |
| 7 | + return request({ | |
| 8 | + url: base, | |
| 9 | + method: 'GET', | |
| 10 | + data: query | |
| 11 | + }) | |
| 12 | +} | |
| 13 | + | |
| 14 | +/** 恢复已删除单据 */ | |
| 15 | +export function restoreWtBillRecycle(billSource, id) { | |
| 16 | + return request({ | |
| 17 | + url: `${base}/${billSource}/${id}/Actions/Restore`, | |
| 18 | + method: 'POST', | |
| 19 | + data: {} | |
| 20 | + }) | |
| 21 | +} | |
| 22 | + | |
| 23 | +/** 彻底删除(物理清除,仅开发环境前端开放入口) */ | |
| 24 | +export function purgeWtBillRecycle(billSource, id) { | |
| 25 | + return request({ | |
| 26 | + url: `${base}/${billSource}/${id}/Actions/Purge`, | |
| 27 | + method: 'DELETE' | |
| 28 | + }) | |
| 29 | +} | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/api/wtHy.js
| ... | ... | @@ -58,3 +58,16 @@ export function WtHyAdjustKkjlExpireHistory(data) { |
| 58 | 58 | data |
| 59 | 59 | }) |
| 60 | 60 | } |
| 61 | + | |
| 62 | +/** | |
| 63 | + * 仅修改客户档案备注 | |
| 64 | + * @param {{ id: string, bz?: string }} data | |
| 65 | + */ | |
| 66 | +export function WtHyUpdateBz(data) { | |
| 67 | + return request({ | |
| 68 | + url: '/api/Extend/WtHy/Actions/UpdateBz', | |
| 69 | + method: 'post', | |
| 70 | + data | |
| 71 | + }) | |
| 72 | +} | |
| 73 | + | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/router/modules/base.js
| ... | ... | @@ -185,6 +185,18 @@ const baseRouter = [{ |
| 185 | 185 | affix: false, |
| 186 | 186 | zhTitle: '收银折扣权限' |
| 187 | 187 | } |
| 188 | + }, | |
| 189 | + // 统一单据回收站:菜单可在后台 system_menu 挂链 /wtBillRecycle/index | |
| 190 | + { | |
| 191 | + path: '/wtBillRecycle/index', | |
| 192 | + component: (resolve) => require(['@/views/wtBillRecycle/index'], resolve), | |
| 193 | + name: 'wtBillRecycle', | |
| 194 | + hidden: true, | |
| 195 | + meta: { | |
| 196 | + title: 'wtBillRecycle', | |
| 197 | + affix: false, | |
| 198 | + zhTitle: '单据回收站' | |
| 199 | + } | |
| 188 | 200 | } |
| 189 | 201 | ] |
| 190 | 202 | export default baseRouter |
| 191 | 203 | \ No newline at end of file | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/utils/request.js
| ... | ... | @@ -3,6 +3,7 @@ import { message } from '@/utils/message' |
| 3 | 3 | import store from '@/store' |
| 4 | 4 | import { getToken } from '@/utils/auth' |
| 5 | 5 | import define from '@/utils/define' |
| 6 | +import { isRecycleDeletedContext } from '@/utils/wtRecycleRequestContext' | |
| 6 | 7 | |
| 7 | 8 | |
| 8 | 9 | // create an axios instance |
| ... | ... | @@ -31,6 +32,10 @@ service.interceptors.request.use( |
| 31 | 32 | config.headers['Authorization'] = getToken() |
| 32 | 33 | } |
| 33 | 34 | if (config.method == 'get') { |
| 35 | + config.data = config.data || {} | |
| 36 | + if (isRecycleDeletedContext()) { | |
| 37 | + config.data.includeDeleted = true | |
| 38 | + } | |
| 34 | 39 | config.params = config.data |
| 35 | 40 | } |
| 36 | 41 | let timestamp = Date.parse(new Date()) / 1000 | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/utils/wtDjztDisplay.js
| ... | ... | @@ -55,6 +55,30 @@ export function getWtDjztDisplayLabel(djzt, spbz) { |
| 55 | 55 | return '待审核' |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | +/** | |
| 59 | + * 当前审核节点(按库内真实 djzt,不被「待审核」折叠口径影响)。 | |
| 60 | + * 用于列表「当前节点」列,区分待一级 / 待二级 / 已完成。 | |
| 61 | + */ | |
| 62 | +export function getWtAuditNodeLabel(djzt, spbz) { | |
| 63 | + const ctx = resolveWtBillAuditRow(djzt, spbz) | |
| 64 | + const z = ctx.djzt | |
| 65 | + if (isWtDjztRejected(z, ctx.spbz) || z === WT_REJECT_SPBZ_TAG) return '已驳回' | |
| 66 | + if (!z || z === '待审核') return '待一级审核' | |
| 67 | + if (z === '一级已审' || z === '待二级' || z === '一级已审/待二级') return '待二级审核' | |
| 68 | + if (z === '已审核' || z === '无需审核') return '审核完成' | |
| 69 | + if (z === '草稿') return '未提交' | |
| 70 | + return '待一级审核' | |
| 71 | +} | |
| 72 | + | |
| 73 | +export function getWtAuditNodeTagType(djzt, spbz) { | |
| 74 | + const label = getWtAuditNodeLabel(djzt, spbz) | |
| 75 | + if (label === '审核完成') return 'success' | |
| 76 | + if (label === '待二级审核') return 'warning' | |
| 77 | + if (label === '已驳回') return 'danger' | |
| 78 | + if (label === '未提交') return 'info' | |
| 79 | + return 'warning' | |
| 80 | +} | |
| 81 | + | |
| 58 | 82 | export function getWtDjztTagType(djzt, spbz) { |
| 59 | 83 | const label = getWtDjztDisplayLabel(djzt, spbz) |
| 60 | 84 | if (label === '已审核') return 'success' | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/utils/wtRecycleRequestContext.js
0 → 100644
| 1 | +/** 回收站打开详情时,请求拦截器自动附加 includeDeleted=true */ | |
| 2 | +let depth = 0 | |
| 3 | + | |
| 4 | +export function enterRecycleDeletedContext() { | |
| 5 | + depth += 1 | |
| 6 | +} | |
| 7 | + | |
| 8 | +export function leaveRecycleDeletedContext() { | |
| 9 | + if (depth > 0) depth -= 1 | |
| 10 | +} | |
| 11 | + | |
| 12 | +export function isRecycleDeletedContext() { | |
| 13 | + return depth > 0 | |
| 14 | +} | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/views/douyinLogistics/CreateWaybill.vue
| ... | ... | @@ -6,6 +6,16 @@ |
| 6 | 6 | <span class="page-title">{{ isMergedMode ? '合并发货单' : '编辑发货单' }}</span> |
| 7 | 7 | <div class="header-buttons"> |
| 8 | 8 | <el-button |
| 9 | + v-if="!waybillTrackingNumber && form.status !== 2 && form.status !== 3 && form.status !== 4" | |
| 10 | + type="warning" | |
| 11 | + size="small" | |
| 12 | + :loading="creatingWaybill" | |
| 13 | + :disabled="waybillSubmitBlocked" | |
| 14 | + @click="handleCreateSfWaybill" | |
| 15 | + > | |
| 16 | + 创建运单 | |
| 17 | + </el-button> | |
| 18 | + <el-button | |
| 9 | 19 | v-if="waybillTrackingNumber && form.status !== 2 && form.status !== 3 && form.status !== 4" |
| 10 | 20 | type="default" |
| 11 | 21 | size="small" |
| ... | ... | @@ -263,6 +273,21 @@ |
| 263 | 273 | <span class="product-list-hint">非赠品行合计 ¥{{ productListPaidSubtotalYuan.toFixed(2) }},与商家实际收入一致</span> |
| 264 | 274 | </div> |
| 265 | 275 | <div class="product-header-selects"> |
| 276 | + <el-form-item label="快递产品" required class="inline-select inline-select--product"> | |
| 277 | + <el-select | |
| 278 | + v-model="form.sfProductType" | |
| 279 | + placeholder="请选择" | |
| 280 | + size="small" | |
| 281 | + :disabled="!!waybillTrackingNumber" | |
| 282 | + > | |
| 283 | + <el-option | |
| 284 | + v-for="item in sfProductTypeOptions" | |
| 285 | + :key="item.value" | |
| 286 | + :label="item.label" | |
| 287 | + :value="item.value" | |
| 288 | + /> | |
| 289 | + </el-select> | |
| 290 | + </el-form-item> | |
| 266 | 291 | <el-form-item label="发货人" required class="inline-select"> |
| 267 | 292 | <el-select v-model="form.fhr" placeholder="请选择" clearable filterable size="small"> |
| 268 | 293 | <el-option |
| ... | ... | @@ -445,7 +470,7 @@ |
| 445 | 470 | {{ getSerialNumberTypeText(scope.row) }} |
| 446 | 471 | </el-tag> |
| 447 | 472 | <i |
| 448 | - v-if="scope.row.spbm || getSkuCode(scope.row)" | |
| 473 | + v-if="scope.row.spbm || getSkuCode(scope.row) || scope.row.erpSpbh" | |
| 449 | 474 | class="el-icon-refresh" |
| 450 | 475 | style="cursor: pointer; color: #409eff; font-size: 14px;" |
| 451 | 476 | @click="refreshSerialNumberType(scope.row)" |
| ... | ... | @@ -503,7 +528,7 @@ |
| 503 | 528 | type="primary" |
| 504 | 529 | size="small" |
| 505 | 530 | @click="openSerialNumberSelect(scope.row)" |
| 506 | - :disabled="!scope.row.spbm && !getSkuCode(scope.row)" | |
| 531 | + :disabled="!scope.row.spbm && !getSkuCode(scope.row) && !scope.row.erpSpbh" | |
| 507 | 532 | > |
| 508 | 533 | {{ scope.row.selectedSerialNumbers && scope.row.selectedSerialNumbers.length > 0 ? '修改序列号' : '选择序列号' }} |
| 509 | 534 | </el-button> |
| ... | ... | @@ -572,7 +597,7 @@ |
| 572 | 597 | <SerialNumberSelect ref="serialNumberSelectRef" @confirm="handleSerialNumberSelect" /> |
| 573 | 598 | |
| 574 | 599 | <!-- 商品选择对话框:打开时自动加载商品列表(无关键词时显示全部) --> |
| 575 | - <el-dialog :visible.sync="showProductDialog" title="选择ERP商品" width="800px" :close-on-click-modal="false" @opened="onProductDialogOpened"> | |
| 600 | + <el-dialog :visible.sync="showProductDialog" title="选择ERP商品" width="980px" :close-on-click-modal="false" @opened="onProductDialogOpened"> | |
| 576 | 601 | <el-form :inline="true" size="small" style="margin-bottom: 12px;"> |
| 577 | 602 | <el-form-item label="商品品类"> |
| 578 | 603 | <el-select |
| ... | ... | @@ -618,7 +643,7 @@ |
| 618 | 643 | </template> |
| 619 | 644 | </el-table-column> |
| 620 | 645 | <el-table-column prop="spbm" label="商品编码" width="130" /> |
| 621 | - <el-table-column prop="spmc" label="商品名称" min-width="180" show-overflow-tooltip /> | |
| 646 | + <el-table-column prop="spmc" label="商品名称" min-width="320" show-overflow-tooltip /> | |
| 622 | 647 | <el-table-column prop="dyspid" label="抖音SKU编码" width="130" show-overflow-tooltip /> |
| 623 | 648 | <el-table-column prop="dw" label="单位" width="70" /> |
| 624 | 649 | <el-table-column prop="gg" label="规格" width="100" /> |
| ... | ... | @@ -647,7 +672,7 @@ |
| 647 | 672 | import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue' |
| 648 | 673 | import router from '@/router' |
| 649 | 674 | import { Message as ElMessage, MessageBox as ElMessageBox } from 'element-ui' |
| 650 | -import { getOrderDetail, getMergedOrderDetail, searchProducts as searchProductsAPI, manualCreateWaybill, getProductInfo as getProductInfoAPI, getWarehouses, getProductCategories, updateSellerRemark, getDefaults, getCustomers, getPaymentAccounts, getUsers, getUsersByOrganize, getShopSettings, checkStock, getStockCostBreakdown, printWaybill } from '@/api/douyinLogistics' | |
| 675 | +import { getOrderDetail, getMergedOrderDetail, searchProducts as searchProductsAPI, manualCreateWaybill, getProductInfo as getProductInfoAPI, getWarehouses, getProductCategories, updateSellerRemark, getDefaults, getCustomers, getPaymentAccounts, getUsers, getUsersByOrganize, getShopSettings, checkStock, getStockCostBreakdown, printWaybill, createWaybill, shipToDouyin } from '@/api/douyinLogistics' | |
| 651 | 676 | import { getDouyinLogisticsBaseOrigin } from '@/utils/douyinLogisticsAxios' |
| 652 | 677 | import { directPrintWaybillFaceSheet } from '@/utils/waybillDirectPrint' |
| 653 | 678 | import { getErpAssetBaseUrl, resolveProductPicUrl } from '@/utils/douyinErpBase' |
| ... | ... | @@ -675,6 +700,14 @@ onBeforeUnmount(() => { |
| 675 | 700 | const loading = ref(false) |
| 676 | 701 | const submitting = ref(false) |
| 677 | 702 | const printing = ref(false) |
| 703 | +const creatingWaybill = ref(false) | |
| 704 | + | |
| 705 | +/** 顺丰抖店 product_type 选项 */ | |
| 706 | +const sfProductTypeOptions = [ | |
| 707 | + { value: '247', label: '电商标快' }, | |
| 708 | + { value: '2', label: '顺丰标快' }, | |
| 709 | + { value: '1', label: '顺丰特快' } | |
| 710 | +] | |
| 678 | 711 | const isMergedMode = computed(() => route.value.name === 'create-waybill-merged' && route.value.params.ids) |
| 679 | 712 | const orderId = ref(Number(route.value.params.id || 0)) |
| 680 | 713 | const mergedInternalIds = ref([]) |
| ... | ... | @@ -766,6 +799,8 @@ const form = ref({ |
| 766 | 799 | senderPhone: '18014801756', |
| 767 | 800 | senderAddress: '江苏省南京市浦口区浦洲路39号沿海创中心A301', |
| 768 | 801 | logisticsCompany: '顺丰', |
| 802 | + /** 顺丰快递产品:247电商标快(默认)、2标快、1特快 */ | |
| 803 | + sfProductType: '247', | |
| 769 | 804 | cjck: '', |
| 770 | 805 | kh: '', |
| 771 | 806 | skzh: '', |
| ... | ... | @@ -1616,11 +1651,15 @@ const searchProducts = async () => { |
| 1616 | 1651 | // 添加商品 |
| 1617 | 1652 | const addProduct = async (product) => { |
| 1618 | 1653 | const spbm = String(product.spbm || '').trim() |
| 1619 | - if (!spbm) { | |
| 1620 | - ElMessage.warning('商品编码为空,无法添加') | |
| 1654 | + const erpSpbh = String(product.id || product.F_Id || '').trim() | |
| 1655 | + if (!spbm && !erpSpbh) { | |
| 1656 | + ElMessage.warning('无法识别商品,缺少编码与主键') | |
| 1621 | 1657 | return |
| 1622 | 1658 | } |
| 1623 | - const exists = form.value.productItems.find((item) => String(item.spbm || '').trim() === spbm) | |
| 1659 | + const exists = form.value.productItems.find((item) => { | |
| 1660 | + if (spbm) return String(item.spbm || '').trim() === spbm | |
| 1661 | + return String(item.erpSpbh || '').trim() === erpSpbh | |
| 1662 | + }) | |
| 1624 | 1663 | if (exists) { |
| 1625 | 1664 | ElMessage.warning('该商品已存在') |
| 1626 | 1665 | return |
| ... | ... | @@ -1661,15 +1700,14 @@ const addProduct = async (product) => { |
| 1661 | 1700 | isFromErp: true, |
| 1662 | 1701 | selectedSerialNumbers: [], |
| 1663 | 1702 | spxlhLoaded: false, |
| 1664 | - spxlhType: '', | |
| 1665 | - erpSpbh: String(product.id || product.F_Id || '').trim() | |
| 1703 | + spxlhType: product.spxlhType != null && product.spxlhType !== '' ? String(product.spxlhType) : '', | |
| 1704 | + erpSpbh | |
| 1666 | 1705 | } |
| 1667 | 1706 | |
| 1668 | 1707 | // 弹窗选中的 spbm/spmc 为唯一来源,仅补序列号类型 |
| 1669 | - if (newProduct.spbm) { | |
| 1670 | - productCache.delete(String(newProduct.spbm).trim()) | |
| 1671 | - await loadSpxlhTypeOnlyForErpRow(newProduct) | |
| 1672 | - } | |
| 1708 | + if (newProduct.spbm) productCache.delete(String(newProduct.spbm).trim()) | |
| 1709 | + if (newProduct.erpSpbh) productCache.delete(String(newProduct.erpSpbh).trim()) | |
| 1710 | + await loadSpxlhTypeOnlyForErpRow(newProduct) | |
| 1673 | 1711 | |
| 1674 | 1712 | // 先隐藏表格(通过设置tableKey为-1) |
| 1675 | 1713 | tableKey.value = -1 |
| ... | ... | @@ -1737,12 +1775,15 @@ const getProductInfo = async (productCode, skuId, { skipCache = false } = {}) => |
| 1737 | 1775 | const response = await getProductInfoAPI(code || undefined, sku || undefined) |
| 1738 | 1776 | if (response.data && response.data.code === 200 && response.data.data) { |
| 1739 | 1777 | const product = response.data.data |
| 1740 | - if (code && product.spbm && String(product.spbm).trim() !== code) { | |
| 1778 | + const retSpbm = product.spbm != null ? String(product.spbm).trim() : '' | |
| 1779 | + const retId = String(product.id || product.F_Id || '').trim() | |
| 1780 | + if (code && retSpbm && retSpbm !== code && retId !== code) { | |
| 1741 | 1781 | return null |
| 1742 | 1782 | } |
| 1743 | 1783 | product.spxlhType = product.spxlhType != null && product.spxlhType !== '' ? String(product.spxlhType) : '' |
| 1744 | 1784 | productCache.set(cacheKey, product) |
| 1745 | - if (product.spbm) productCache.set(String(product.spbm).trim(), product) | |
| 1785 | + if (retSpbm) productCache.set(retSpbm, product) | |
| 1786 | + if (retId) productCache.set(retId, product) | |
| 1746 | 1787 | return product |
| 1747 | 1788 | } |
| 1748 | 1789 | return null |
| ... | ... | @@ -1756,9 +1797,18 @@ const loadSpxlhTypeOnlyForErpRow = async (item) => { |
| 1756 | 1797 | item.spxlhLoaded = false |
| 1757 | 1798 | try { |
| 1758 | 1799 | const spbm = String(item.spbm || '').trim() |
| 1759 | - if (!spbm) return | |
| 1760 | - const product = await getProductInfo(spbm, undefined, { skipCache: true }) | |
| 1761 | - if (!product || String(product.spbm || '').trim() !== spbm) return | |
| 1800 | + const erpSpbh = String(item.erpSpbh || '').trim() | |
| 1801 | + const lookupCode = spbm || erpSpbh | |
| 1802 | + if (!lookupCode) return | |
| 1803 | + const product = await getProductInfo(lookupCode, undefined, { skipCache: true }) | |
| 1804 | + if (!product) return | |
| 1805 | + if (spbm) { | |
| 1806 | + const retSpbm = String(product.spbm || '').trim() | |
| 1807 | + if (retSpbm && retSpbm !== spbm) return | |
| 1808 | + } else { | |
| 1809 | + const retId = String(product.id || product.F_Id || '').trim() | |
| 1810 | + if (retId && retId !== erpSpbh) return | |
| 1811 | + } | |
| 1762 | 1812 | if (product.id || product.F_Id) item.erpSpbh = String(product.id || product.F_Id).trim() |
| 1763 | 1813 | if (product.spxlhType !== undefined && product.spxlhType !== null && String(product.spxlhType) !== '') { |
| 1764 | 1814 | item.spxlhType = String(product.spxlhType) |
| ... | ... | @@ -1838,6 +1888,19 @@ const loadSerialNumberType = async (item) => { |
| 1838 | 1888 | } else { |
| 1839 | 1889 | applyProductDetailToItem(item, product, expectedSpbm) |
| 1840 | 1890 | } |
| 1891 | + } else if (item.erpSpbh) { | |
| 1892 | + const product = await getProductInfo(String(item.erpSpbh).trim(), undefined, { skipCache: item.isFromErp }) | |
| 1893 | + if (product) { | |
| 1894 | + const retId = String(product.id || product.F_Id || '').trim() | |
| 1895 | + if (!retId || retId === String(item.erpSpbh).trim()) { | |
| 1896 | + if (product.spxlhType !== undefined && product.spxlhType !== null && String(product.spxlhType) !== '') { | |
| 1897 | + item.spxlhType = String(product.spxlhType) | |
| 1898 | + } | |
| 1899 | + if (product.imageUrl && !item.erp_pic) { | |
| 1900 | + item.erp_pic = resolveProductPicUrl(product.imageUrl) | |
| 1901 | + } | |
| 1902 | + } | |
| 1903 | + } | |
| 1841 | 1904 | } |
| 1842 | 1905 | } catch { /* ignore */ } finally { |
| 1843 | 1906 | item.spxlhLoaded = true |
| ... | ... | @@ -1846,8 +1909,7 @@ const loadSerialNumberType = async (item) => { |
| 1846 | 1909 | |
| 1847 | 1910 | // 获取序列号类型显示文本 |
| 1848 | 1911 | const getSerialNumberTypeText = (row) => { |
| 1849 | - // 如果没有商品编码和sku_id,显示未选择 | |
| 1850 | - if (!row.spbm && !getSkuCode(row)) return '未选择' | |
| 1912 | + if (!row.spbm && !getSkuCode(row) && !String(row.erpSpbh || '').trim()) return '未选择' | |
| 1851 | 1913 | if (!row.spxlhLoaded) return '加载中...' |
| 1852 | 1914 | const spxlhType = row.spxlhType |
| 1853 | 1915 | if (spxlhType === '1') return '入1出1' |
| ... | ... | @@ -1858,7 +1920,7 @@ const getSerialNumberTypeText = (row) => { |
| 1858 | 1920 | |
| 1859 | 1921 | // 获取序列号类型标签颜色 |
| 1860 | 1922 | const getSerialNumberTypeTagType = (row) => { |
| 1861 | - if (!row.spbm && !getSkuCode(row)) return 'info' | |
| 1923 | + if (!row.spbm && !getSkuCode(row) && !String(row.erpSpbh || '').trim()) return 'info' | |
| 1862 | 1924 | if (!row.spxlhLoaded) return 'info' |
| 1863 | 1925 | const spxlhType = row.spxlhType |
| 1864 | 1926 | if (spxlhType === '1' || spxlhType === '2') return 'warning' // 需要序列号 - 橙色警告 |
| ... | ... | @@ -1868,7 +1930,7 @@ const getSerialNumberTypeTagType = (row) => { |
| 1868 | 1930 | |
| 1869 | 1931 | // 获取序列号类型描述 |
| 1870 | 1932 | const getSerialNumberTypeDescription = (row) => { |
| 1871 | - if (!row.spbm && !getSkuCode(row)) return '请先选择商品' | |
| 1933 | + if (!row.spbm && !getSkuCode(row) && !String(row.erpSpbh || '').trim()) return '请先选择商品' | |
| 1872 | 1934 | if (!row.spxlhLoaded) return '加载中...' |
| 1873 | 1935 | const spxlhType = row.spxlhType |
| 1874 | 1936 | if (spxlhType === '1') return '入库和出库都需要序列号' |
| ... | ... | @@ -1879,20 +1941,21 @@ const getSerialNumberTypeDescription = (row) => { |
| 1879 | 1941 | |
| 1880 | 1942 | // 刷新序列号类型信息 |
| 1881 | 1943 | const refreshSerialNumberType = async (row) => { |
| 1882 | - if (!row.spbm && !getSkuCode(row)) { | |
| 1944 | + if (!row.spbm && !getSkuCode(row) && !String(row.erpSpbh || '').trim()) { | |
| 1883 | 1945 | ElMessage.warning('请先选择商品') |
| 1884 | 1946 | return |
| 1885 | 1947 | } |
| 1886 | 1948 | |
| 1887 | 1949 | try { |
| 1888 | - if (!row.spbm) { | |
| 1950 | + if (!row.spbm && !String(row.erpSpbh || '').trim()) { | |
| 1889 | 1951 | const productCode = await getProductCodeForSerialNumber(row) |
| 1890 | 1952 | if (!productCode) { |
| 1891 | - ElMessage.warning('无法获取商品编码') | |
| 1953 | + ElMessage.warning('无法获取商品标识') | |
| 1892 | 1954 | return |
| 1893 | 1955 | } |
| 1894 | 1956 | } |
| 1895 | 1957 | if (row.spbm) productCache.delete(String(row.spbm)) |
| 1958 | + if (row.erpSpbh) productCache.delete(String(row.erpSpbh)) | |
| 1896 | 1959 | const sku = getSkuCode(row) |
| 1897 | 1960 | if (sku) productCache.delete(`sku:${sku}`) |
| 1898 | 1961 | await loadSerialNumberType(row) |
| ... | ... | @@ -1902,36 +1965,15 @@ const refreshSerialNumberType = async (row) => { |
| 1902 | 1965 | } |
| 1903 | 1966 | } |
| 1904 | 1967 | |
| 1905 | -// 获取用于序列号选择的商品编码(spbm) | |
| 1906 | -// 注意:序列号表中存储的是商品编码(spbm),不是抖音SKU编码(dyspid) | |
| 1907 | -// 如果商品只有抖音SKU编码,需要先通过它查找对应的商品编码 | |
| 1968 | +// 获取用于序列号选择的商品标识(spbm 或 ERP 商品主键 Id) | |
| 1908 | 1969 | const getProductCodeForSerialNumber = async (row) => { |
| 1909 | 1970 | const skuId = getSkuCode(row) |
| 1910 | 1971 | if (skuId) return skuId |
| 1911 | 1972 | if (row.spbm) return row.spbm |
| 1973 | + const erpSpbh = String(row.erpSpbh || '').trim() | |
| 1974 | + if (erpSpbh) return erpSpbh | |
| 1912 | 1975 | |
| 1913 | - const productId = row.id || row.F_Id || row.spbh | |
| 1914 | - if (productId && productId.length > 10) { | |
| 1915 | - try { | |
| 1916 | - const response = await searchProductsAPI(productId, 1, 10) | |
| 1917 | - if (response.data && response.data.data && response.data.data.length > 0) { | |
| 1918 | - let product = response.data.data.find((p) => | |
| 1919 | - p.id === productId || p.F_Id === productId || p.id === String(productId) | |
| 1920 | - ) || response.data.data[0] | |
| 1921 | - | |
| 1922 | - if (product.spbm) { | |
| 1923 | - row.spbm = product.spbm | |
| 1924 | - if (!row.product_name && product.spmc) row.product_name = product.spmc | |
| 1925 | - if (!row.spxlhType) await loadSerialNumberType(row) | |
| 1926 | - return product.spbm | |
| 1927 | - } else { | |
| 1928 | - ElMessage.warning(`商品"${row.product_name || productId}"未关联ERP商品编码,无法查询序列号`) | |
| 1929 | - } | |
| 1930 | - } | |
| 1931 | - } catch { /* ignore */ } | |
| 1932 | - } | |
| 1933 | - | |
| 1934 | - ElMessage.warning('商品缺少商品编码或抖音SKU编码,无法查询序列号') | |
| 1976 | + ElMessage.warning('商品缺少商品编码、抖音SKU或主键,无法查询序列号') | |
| 1935 | 1977 | return null |
| 1936 | 1978 | } |
| 1937 | 1979 | |
| ... | ... | @@ -1941,7 +1983,7 @@ const openSerialNumberSelect = async (row) => { |
| 1941 | 1983 | const productCode = await getProductCodeForSerialNumber(row) |
| 1942 | 1984 | |
| 1943 | 1985 | if (!productCode) { |
| 1944 | - ElMessage.warning('无法获取商品编码,请确保商品已关联ERP系统') | |
| 1986 | + ElMessage.warning('无法获取商品标识,请确保商品已关联ERP系统') | |
| 1945 | 1987 | return |
| 1946 | 1988 | } |
| 1947 | 1989 | |
| ... | ... | @@ -1971,7 +2013,9 @@ const handleSerialNumberSelect = (selectedSerialNumbers) => { |
| 1971 | 2013 | const currentProductCode = serialNumberSelectRef.value && serialNumberSelectRef.value.currentProductCode |
| 1972 | 2014 | if (currentProductCode) { |
| 1973 | 2015 | currentRow = form.value.productItems.find((item) => |
| 1974 | - item.spbm === currentProductCode || getSkuCode(item) === currentProductCode | |
| 2016 | + item.spbm === currentProductCode || | |
| 2017 | + getSkuCode(item) === currentProductCode || | |
| 2018 | + String(item.erpSpbh || '').trim() === currentProductCode | |
| 1975 | 2019 | ) || null |
| 1976 | 2020 | } |
| 1977 | 2021 | } |
| ... | ... | @@ -2183,20 +2227,22 @@ const handleSubmit = async () => { |
| 2183 | 2227 | return |
| 2184 | 2228 | } |
| 2185 | 2229 | |
| 2186 | - const invalidItems = shippableItems.filter((item) => !item.product_name && !item.spbm) | |
| 2230 | + const invalidItems = shippableItems.filter((item) => | |
| 2231 | + !item.product_name && !item.spbm && !String(item.erpSpbh || '').trim() | |
| 2232 | + ) | |
| 2187 | 2233 | if (invalidItems.length > 0) { |
| 2188 | - ElMessage.warning('存在无效商品,请检查商品名称或商品编码') | |
| 2234 | + ElMessage.warning('存在无效商品,请检查商品名称、编码或主键') | |
| 2189 | 2235 | return |
| 2190 | 2236 | } |
| 2191 | 2237 | |
| 2192 | 2238 | // 序列号校验(入0出1 可无在库序列号,须在弹窗内手动录入,与收银台 UpdateSerialNumberStatus 一致) |
| 2193 | 2239 | for (const item of shippableItems) { |
| 2194 | - if ((item.spbm || getSkuCode(item)) && !item.spxlhLoaded) await loadSerialNumberType(item) | |
| 2240 | + if ((item.spbm || getSkuCode(item) || item.erpSpbh) && !item.spxlhLoaded) await loadSerialNumberType(item) | |
| 2195 | 2241 | } |
| 2196 | 2242 | let serialValidationFailed = false |
| 2197 | 2243 | for (let i = 0; i < shippableItems.length; i++) { |
| 2198 | 2244 | const item = shippableItems[i] |
| 2199 | - if (!item.spbm && !getSkuCode(item)) continue | |
| 2245 | + if (!item.spbm && !getSkuCode(item) && !String(item.erpSpbh || '').trim()) continue | |
| 2200 | 2246 | const spxlhType = item.spxlhType |
| 2201 | 2247 | const itemNum = Number(item.item_num) || 0 |
| 2202 | 2248 | // 入1出1、入0出1:出库都需要序列号(与 ERP 商品档案口径一致) |
| ... | ... | @@ -2235,24 +2281,63 @@ const handleSubmit = async () => { |
| 2235 | 2281 | if (form.value.cjck && shippableItems.length > 0) { |
| 2236 | 2282 | try { |
| 2237 | 2283 | const stockItems = shippableItems |
| 2238 | - .filter((item) => item.spbm) | |
| 2239 | - .map((item) => ({ spbm: item.spbm, quantity: Number(item.item_num) || 1 })) | |
| 2284 | + .filter((item) => item.spbm || item.erpSpbh) | |
| 2285 | + .map((item) => { | |
| 2286 | + const spbm = String(item.spbm || '').trim() | |
| 2287 | + const erpSpbh = String(item.erpSpbh || '').trim() | |
| 2288 | + const quantity = Number(item.item_num) || 1 | |
| 2289 | + if (spbm) return { spbm, quantity } | |
| 2290 | + return { spId: erpSpbh, quantity } | |
| 2291 | + }) | |
| 2240 | 2292 | |
| 2241 | 2293 | if (stockItems.length > 0) { |
| 2242 | 2294 | const stockRes = await checkStock(form.value.cjck, stockItems) |
| 2243 | - const stockData = stockRes.data | |
| 2295 | + const stockData = stockRes && stockRes.data | |
| 2296 | + const stockList = Array.isArray(stockData) | |
| 2297 | + ? stockData | |
| 2298 | + : (stockData && Array.isArray(stockData.data) ? stockData.data : []) | |
| 2244 | 2299 | |
| 2245 | - const insufficientItems = (stockData && stockData.data && stockData.data.filter) | |
| 2246 | - ? stockData.data.filter((item) => !item.sufficient) | |
| 2247 | - : [] | |
| 2300 | + const insufficientItems = stockList.filter((item) => item && item.sufficient === false) | |
| 2248 | 2301 | |
| 2249 | 2302 | if (insufficientItems.length > 0) { |
| 2250 | - const itemNames = insufficientItems.map((item) => | |
| 2251 | - `${item.spmc || item.spbm}(库存: ${(item.stock !== undefined && item.stock !== null) ? item.stock : 0},需要: ${item.quantity})` | |
| 2252 | - ).join('\n') | |
| 2303 | + // 用发货明细里的商品名称兜底(很多商品无编码,BatchCheckStock 的 productName 可能为空) | |
| 2304 | + const localNameByKey = {} | |
| 2305 | + shippableItems.forEach((row) => { | |
| 2306 | + const name = String(row.erp_spmc || row.product_name || row.spmc || '').trim() | |
| 2307 | + const spbm = String(row.spbm || '').trim() | |
| 2308 | + const spId = String(row.erpSpbh || '').trim() | |
| 2309 | + if (spbm && name) localNameByKey[`bm:${spbm}`] = name | |
| 2310 | + if (spId && name) localNameByKey[`id:${spId}`] = name | |
| 2311 | + }) | |
| 2312 | + | |
| 2313 | + const formatStockNum = (v) => { | |
| 2314 | + if (v === null || v === undefined || v === '') return '0' | |
| 2315 | + const n = Number(v) | |
| 2316 | + return Number.isNaN(n) ? String(v) : String(n) | |
| 2317 | + } | |
| 2318 | + | |
| 2319 | + const itemLines = insufficientItems.map((item, idx) => { | |
| 2320 | + const spbm = String(item.spbm || '').trim() | |
| 2321 | + const spId = String(item.spId || '').trim() | |
| 2322 | + const name = String( | |
| 2323 | + item.productName || | |
| 2324 | + item.spmc || | |
| 2325 | + localNameByKey[`bm:${spbm}`] || | |
| 2326 | + localNameByKey[`id:${spId}`] || | |
| 2327 | + '' | |
| 2328 | + ).trim() || '未命名商品' | |
| 2329 | + const available = formatStockNum( | |
| 2330 | + item.available !== undefined && item.available !== null ? item.available : item.stock | |
| 2331 | + ) | |
| 2332 | + const required = formatStockNum( | |
| 2333 | + item.required !== undefined && item.required !== null ? item.required : item.quantity | |
| 2334 | + ) | |
| 2335 | + const codeHint = spbm ? `,编码 ${spbm}` : '' | |
| 2336 | + return `${idx + 1}. ${name}${codeHint}(账面库存 ${available},需要 ${required})` | |
| 2337 | + }).join('\n') | |
| 2253 | 2338 | |
| 2254 | 2339 | await ElMessageBox.alert( |
| 2255 | - `以下商品库存不足,无法发货:\n\n${itemNames}\n\n请先到 ERP 补充库存后再提交发货单。`, | |
| 2340 | + `以下商品库存不足,无法发货:\n\n${itemLines}\n\n请先到 ERP 补充库存后再提交发货单。`, | |
| 2256 | 2341 | '库存不足', |
| 2257 | 2342 | { confirmButtonText: '我知道了', type: 'error' } |
| 2258 | 2343 | ) |
| ... | ... | @@ -2266,7 +2351,10 @@ const handleSubmit = async () => { |
| 2266 | 2351 | |
| 2267 | 2352 | submitting.value = true |
| 2268 | 2353 | try { |
| 2269 | - const productItemsForSubmit = shippableItems.map((item) => ({ | |
| 2354 | + const productItemsForSubmit = shippableItems.map((item) => { | |
| 2355 | + const erpSpbh = String(item.erpSpbh || '').trim() | |
| 2356 | + const spbm = String(item.spbm || '').trim() | |
| 2357 | + return { | |
| 2270 | 2358 | product_name: item.product_name || '', |
| 2271 | 2359 | // product_pic 保留以兼容老后端;同时新增 douyin_pic/erp_pic 分别存抖音图和 ERP 图 |
| 2272 | 2360 | product_pic: item.erp_pic || item.product_pic || item.douyin_pic || '', |
| ... | ... | @@ -2277,12 +2365,14 @@ const handleSubmit = async () => { |
| 2277 | 2365 | spec: item.spec || '', |
| 2278 | 2366 | sku_id: item.sku_id || '', |
| 2279 | 2367 | out_sku_id: item.out_sku_id || '', |
| 2280 | - spbm: item.spbm || '', | |
| 2368 | + spbm: spbm || erpSpbh, | |
| 2369 | + spId: erpSpbh, | |
| 2370 | + erpSpbh: erpSpbh, | |
| 2281 | 2371 | dw: item.dw || '', |
| 2282 | 2372 | isGift: Boolean(item.isGift), |
| 2283 | 2373 | isFromErp: Boolean(item.isFromErp), |
| 2284 | 2374 | selectedSerialNumbers: item.selectedSerialNumbers || [] |
| 2285 | - })) | |
| 2375 | + }}) | |
| 2286 | 2376 | |
| 2287 | 2377 | syncMerchantIncomeFromOrder() |
| 2288 | 2378 | allocateProductPricesByMerchantIncome() |
| ... | ... | @@ -2360,6 +2450,56 @@ const handleCancel = () => { |
| 2360 | 2450 | } |
| 2361 | 2451 | |
| 2362 | 2452 | /** |
| 2453 | + * 创建运单:按所选快递产品调用抖店取号,并尝试同步抖音发货。 | |
| 2454 | + */ | |
| 2455 | +const handleCreateSfWaybill = async () => { | |
| 2456 | + const id = form.value.orderId | |
| 2457 | + if (!id) { | |
| 2458 | + ElMessage.warning('订单信息未加载完成') | |
| 2459 | + return | |
| 2460 | + } | |
| 2461 | + if (waybillTrackingNumber.value) { | |
| 2462 | + ElMessage.warning('已存在运单号,无需重复创建') | |
| 2463 | + return | |
| 2464 | + } | |
| 2465 | + if (form.value.status === 2 || form.value.status === 3 || form.value.status === 4) { | |
| 2466 | + ElMessage.warning('当前订单状态不允许创建运单') | |
| 2467 | + return | |
| 2468 | + } | |
| 2469 | + const productType = String(form.value.sfProductType || '247').trim() || '247' | |
| 2470 | + const productLabel = (sfProductTypeOptions.find(o => o.value === productType) || {}).label || '电商标快' | |
| 2471 | + try { | |
| 2472 | + await ElMessageBox.confirm( | |
| 2473 | + `确定以「${productLabel}」为该订单创建顺丰运单吗?\n创建成功后将尝试同步到抖音发货。`, | |
| 2474 | + '创建运单', | |
| 2475 | + { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' } | |
| 2476 | + ) | |
| 2477 | + } catch { | |
| 2478 | + return | |
| 2479 | + } | |
| 2480 | + creatingWaybill.value = true | |
| 2481 | + try { | |
| 2482 | + const res = await createWaybill(id, productType) | |
| 2483 | + const data = (res && res.data) || {} | |
| 2484 | + waybillTrackingNumber.value = data.trackingNumber || waybillTrackingNumber.value || '' | |
| 2485 | + if (data.productType) form.value.sfProductType = String(data.productType) | |
| 2486 | + try { | |
| 2487 | + await shipToDouyin(id) | |
| 2488 | + } catch (shipError) { | |
| 2489 | + const shipMsg = (shipError.response && shipError.response.data && shipError.response.data.message) || shipError.message || '未知错误' | |
| 2490 | + ElMessage.warning('运单已创建,但同步抖音发货失败:' + shipMsg) | |
| 2491 | + } | |
| 2492 | + await loadOrderDetail() | |
| 2493 | + ElMessage.success(data.message || `运单创建成功(${productLabel})`) | |
| 2494 | + } catch (error) { | |
| 2495 | + const msg = (error.response && error.response.data && error.response.data.message) || error.message || '未知错误' | |
| 2496 | + ElMessage.error('创建运单失败:' + msg) | |
| 2497 | + } finally { | |
| 2498 | + creatingWaybill.value = false | |
| 2499 | + } | |
| 2500 | +} | |
| 2501 | + | |
| 2502 | +/** | |
| 2363 | 2503 | * 打印 / 补打电子面单:隐藏 iframe 直连打印机,不打开预览页。 |
| 2364 | 2504 | */ |
| 2365 | 2505 | const handleWaybillPrintOrReprint = async () => { |
| ... | ... | @@ -2412,8 +2552,11 @@ onMounted(() => { |
| 2412 | 2552 | loading, |
| 2413 | 2553 | submitting, |
| 2414 | 2554 | printing, |
| 2555 | + creatingWaybill, | |
| 2415 | 2556 | handleWaybillPrintOrReprint, |
| 2557 | + handleCreateSfWaybill, | |
| 2416 | 2558 | form, |
| 2559 | + sfProductTypeOptions, | |
| 2417 | 2560 | waybillStatus, |
| 2418 | 2561 | waybillSalesOrderId, |
| 2419 | 2562 | waybillSubmitBlocked, |
| ... | ... | @@ -3173,6 +3316,9 @@ onMounted(() => { |
| 3173 | 3316 | margin-right: 0 !important; |
| 3174 | 3317 | vertical-align: middle; |
| 3175 | 3318 | } |
| 3319 | +.inline-select--product :deep(.el-select) { | |
| 3320 | + width: 120px; | |
| 3321 | +} | |
| 3176 | 3322 | |
| 3177 | 3323 | .inline-select { |
| 3178 | 3324 | margin-bottom: 0 !important; | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/views/douyinLogistics/OrderList.vue
| ... | ... | @@ -750,6 +750,37 @@ |
| 750 | 750 | </div> |
| 751 | 751 | </el-dialog> |
| 752 | 752 | |
| 753 | + <el-dialog | |
| 754 | + title="创建运单" | |
| 755 | + :visible.sync="createWaybillDialogVisible" | |
| 756 | + width="420px" | |
| 757 | + append-to-body | |
| 758 | + :close-on-click-modal="false" | |
| 759 | + @closed="onCreateWaybillDialogClosed" | |
| 760 | + > | |
| 761 | + <el-form label-width="88px" size="small" @submit.native.prevent> | |
| 762 | + <el-form-item label="快递产品" required> | |
| 763 | + <el-select v-model="createWaybillProductType" placeholder="请选择" style="width: 100%"> | |
| 764 | + <el-option | |
| 765 | + v-for="item in sfProductTypeOptions" | |
| 766 | + :key="item.value" | |
| 767 | + :label="item.label" | |
| 768 | + :value="item.value" | |
| 769 | + /> | |
| 770 | + </el-select> | |
| 771 | + </el-form-item> | |
| 772 | + <p class="create-waybill-dialog-tip"> | |
| 773 | + {{ createWaybillDialogMode === 'batch' | |
| 774 | + ? `将为 ${createWaybillBatchTargets.length} 个订单创建顺丰运单,并同步到抖音发货。默认电商标快。` | |
| 775 | + : '将创建顺丰运单并同步到抖音发货。完成后需手动创建发货单。默认电商标快。' }} | |
| 776 | + </p> | |
| 777 | + </el-form> | |
| 778 | + <div slot="footer"> | |
| 779 | + <el-button size="small" @click="createWaybillDialogVisible = false" :disabled="createWaybillDialogLoading">取消</el-button> | |
| 780 | + <el-button type="primary" size="small" :loading="createWaybillDialogLoading" @click="confirmCreateWaybillDialog">确定创建</el-button> | |
| 781 | + </div> | |
| 782 | + </el-dialog> | |
| 783 | + | |
| 753 | 784 | <ErpReturnDialog ref="erpReturnDialogRef" @success="onErpReturnSuccess" /> |
| 754 | 785 | </div> |
| 755 | 786 | </template> |
| ... | ... | @@ -787,6 +818,18 @@ const resyncClearAll = ref(false) |
| 787 | 818 | const syncStatus = ref(null) |
| 788 | 819 | let syncStatusTimer = null |
| 789 | 820 | |
| 821 | +const sfProductTypeOptions = [ | |
| 822 | + { value: '247', label: '电商标快' }, | |
| 823 | + { value: '2', label: '顺丰标快' }, | |
| 824 | + { value: '1', label: '顺丰特快' } | |
| 825 | +] | |
| 826 | +const createWaybillDialogVisible = ref(false) | |
| 827 | +const createWaybillDialogLoading = ref(false) | |
| 828 | +const createWaybillProductType = ref('247') | |
| 829 | +const createWaybillDialogMode = ref('single') // single | batch | |
| 830 | +const createWaybillSingleOrder = ref(null) | |
| 831 | +const createWaybillBatchTargets = ref([]) | |
| 832 | + | |
| 790 | 833 | const filterForm = ref({ |
| 791 | 834 | shopId: undefined, |
| 792 | 835 | status: 'pending_waybill', |
| ... | ... | @@ -1604,61 +1647,68 @@ const handleBatchCreateWaybill = async () => { |
| 1604 | 1647 | return |
| 1605 | 1648 | } |
| 1606 | 1649 | |
| 1650 | + createWaybillDialogMode.value = 'batch' | |
| 1651 | + createWaybillBatchTargets.value = batchTargets | |
| 1652 | + createWaybillSingleOrder.value = null | |
| 1653 | + createWaybillProductType.value = '247' | |
| 1654 | + createWaybillDialogVisible.value = true | |
| 1655 | +} | |
| 1656 | + | |
| 1657 | +const onCreateWaybillDialogClosed = () => { | |
| 1658 | + createWaybillDialogLoading.value = false | |
| 1659 | + createWaybillSingleOrder.value = null | |
| 1660 | + createWaybillBatchTargets.value = [] | |
| 1661 | + createWaybillProductType.value = '247' | |
| 1662 | +} | |
| 1663 | + | |
| 1664 | +const confirmCreateWaybillDialog = async () => { | |
| 1665 | + const productType = String(createWaybillProductType.value || '247').trim() || '247' | |
| 1666 | + if (createWaybillDialogMode.value === 'batch') { | |
| 1667 | + await runBatchCreateWaybill(createWaybillBatchTargets.value, productType) | |
| 1668 | + } else if (createWaybillSingleOrder.value) { | |
| 1669 | + await runSingleCreateWaybill(createWaybillSingleOrder.value, productType) | |
| 1670 | + } | |
| 1671 | +} | |
| 1672 | + | |
| 1673 | +const runBatchCreateWaybill = async (batchTargets, productType) => { | |
| 1674 | + createWaybillDialogLoading.value = true | |
| 1675 | + batchLoading.value = true | |
| 1607 | 1676 | try { |
| 1608 | - await ElMessageBox.confirm( | |
| 1609 | - `确定要为 ${batchTargets.length} 个订单批量创建运单吗?\n\n此操作将依次执行:\n1. 创建运单\n2. 同步到抖音发货\n\n完成后状态为「已发货-未提交发货单」,需手动创建发货单。`, | |
| 1610 | - '批量创建运单', | |
| 1611 | - { | |
| 1612 | - confirmButtonText: '确定', | |
| 1613 | - cancelButtonText: '取消', | |
| 1614 | - type: 'warning' | |
| 1615 | - } | |
| 1616 | - ) | |
| 1617 | - | |
| 1618 | - batchLoading.value = true | |
| 1619 | - | |
| 1620 | 1677 | let successCount = 0 |
| 1621 | 1678 | let failCount = 0 |
| 1622 | 1679 | const errors = [] |
| 1623 | 1680 | const successOrderIds = [] |
| 1624 | - | |
| 1681 | + | |
| 1625 | 1682 | const concurrency = 3 |
| 1626 | 1683 | const queue = batchTargets.slice() |
| 1627 | 1684 | const workers = Array.from({ length: Math.min(concurrency, queue.length) }).map(async () => { |
| 1628 | 1685 | while (queue.length > 0) { |
| 1629 | 1686 | const order = queue.shift() |
| 1630 | 1687 | if (!order) continue |
| 1631 | - try { | |
| 1632 | - // 1. 创建运单 | |
| 1633 | - await createWaybill(order.id) | |
| 1634 | - | |
| 1635 | - // 2. 同步到抖音发货 | |
| 1636 | 1688 | try { |
| 1637 | - await shipToDouyin(order.id) | |
| 1638 | - } catch (shipError) { | |
| 1639 | - const errorMsg = (shipError.response && shipError.response.data && shipError.response.data.message) || shipError.message || '未知错误' | |
| 1640 | - errors.push(`订单 ${order.orderId} 同步抖音失败: ${errorMsg}`) | |
| 1689 | + await createWaybill(order.id, productType) | |
| 1690 | + try { | |
| 1691 | + await shipToDouyin(order.id) | |
| 1692 | + } catch (shipError) { | |
| 1693 | + const errorMsg = (shipError.response && shipError.response.data && shipError.response.data.message) || shipError.message || '未知错误' | |
| 1694 | + errors.push(`订单 ${order.orderId} 同步抖音失败: ${errorMsg}`) | |
| 1695 | + } | |
| 1696 | + successCount++ | |
| 1697 | + successOrderIds.push(order.id) | |
| 1698 | + } catch (error) { | |
| 1699 | + failCount++ | |
| 1700 | + const errorMsg = (error.response && error.response.data && error.response.data.message) || error.message || '未知错误' | |
| 1701 | + errors.push(`订单 ${order.orderId} 创建运单失败: ${errorMsg}`) | |
| 1641 | 1702 | } |
| 1642 | - | |
| 1643 | - successCount++ | |
| 1644 | - successOrderIds.push(order.id) | |
| 1645 | - } catch (error) { | |
| 1646 | - failCount++ | |
| 1647 | - const errorMsg = (error.response && error.response.data && error.response.data.message) || error.message || '未知错误' | |
| 1648 | - errors.push(`订单 ${order.orderId} 创建运单失败: ${errorMsg}`) | |
| 1649 | - } | |
| 1650 | 1703 | } |
| 1651 | 1704 | }) |
| 1652 | 1705 | await Promise.all(workers) |
| 1653 | - | |
| 1654 | - // 先本地即时迁移,再立即回源刷新列表 | |
| 1706 | + | |
| 1655 | 1707 | applyWaybillTransitionLocal(successOrderIds) |
| 1656 | 1708 | await refreshListAndStats() |
| 1657 | - | |
| 1658 | - // 清空选择 | |
| 1659 | 1709 | selectedOrders.value = [] |
| 1660 | - | |
| 1661 | - // 显示结果 | |
| 1710 | + createWaybillDialogVisible.value = false | |
| 1711 | + | |
| 1662 | 1712 | if (errors.length > 0 && errors.length <= 5) { |
| 1663 | 1713 | ElMessage.warning(`批量创建完成:成功 ${successCount} 个,失败 ${failCount} 个。失败详情:${errors.join('; ')}`) |
| 1664 | 1714 | } else if (errors.length > 5) { |
| ... | ... | @@ -1667,12 +1717,11 @@ const handleBatchCreateWaybill = async () => { |
| 1667 | 1717 | ElMessage.success(`批量创建运单成功,共 ${successCount} 个订单`) |
| 1668 | 1718 | } |
| 1669 | 1719 | } catch (error) { |
| 1670 | - if (error !== 'cancel' && error !== 'close') { | |
| 1671 | - const errorMsg = error.message || '未知错误' | |
| 1672 | - ElMessage.error('批量创建运单失败:' + errorMsg) | |
| 1673 | - } | |
| 1720 | + const errorMsg = error.message || '未知错误' | |
| 1721 | + ElMessage.error('批量创建运单失败:' + errorMsg) | |
| 1674 | 1722 | } finally { |
| 1675 | 1723 | batchLoading.value = false |
| 1724 | + createWaybillDialogLoading.value = false | |
| 1676 | 1725 | } |
| 1677 | 1726 | } |
| 1678 | 1727 | |
| ... | ... | @@ -1731,28 +1780,24 @@ const handleCreateWaybill = async (order) => { |
| 1731 | 1780 | handleManualCreateWaybill(order) |
| 1732 | 1781 | return |
| 1733 | 1782 | } |
| 1783 | + createWaybillDialogMode.value = 'single' | |
| 1784 | + createWaybillSingleOrder.value = order | |
| 1785 | + createWaybillBatchTargets.value = [] | |
| 1786 | + createWaybillProductType.value = '247' | |
| 1787 | + createWaybillDialogVisible.value = true | |
| 1788 | +} | |
| 1789 | + | |
| 1790 | +const runSingleCreateWaybill = async (order, productType) => { | |
| 1791 | + createWaybillDialogLoading.value = true | |
| 1792 | + loading.value = true | |
| 1734 | 1793 | try { |
| 1735 | - await ElMessageBox.confirm( | |
| 1736 | - '确定要为该订单创建运单吗?\n\n此操作将依次执行:\n1. 创建运单\n2. 同步到抖音发货\n\n完成后状态将变为「已发货-未提交发货单」,需手动创建发货单。', | |
| 1737 | - '创建运单', | |
| 1738 | - { | |
| 1739 | - confirmButtonText: '确定', | |
| 1740 | - cancelButtonText: '取消', | |
| 1741 | - type: 'warning' | |
| 1742 | - } | |
| 1743 | - ) | |
| 1744 | - | |
| 1745 | - loading.value = true | |
| 1746 | - | |
| 1747 | - // 1. 创建运单 | |
| 1748 | 1794 | try { |
| 1749 | - await createWaybill(order.id) | |
| 1795 | + await createWaybill(order.id, productType) | |
| 1750 | 1796 | } catch (error) { |
| 1751 | 1797 | const errorMsg = (error.response && error.response.data && error.response.data.message) || error.message || '未知错误' |
| 1752 | 1798 | throw new Error('创建运单失败:' + errorMsg) |
| 1753 | 1799 | } |
| 1754 | - | |
| 1755 | - // 2. 同步到抖音发货 | |
| 1800 | + | |
| 1756 | 1801 | try { |
| 1757 | 1802 | await shipToDouyin(order.id) |
| 1758 | 1803 | } catch (error) { |
| ... | ... | @@ -1760,20 +1805,18 @@ const handleCreateWaybill = async (order) => { |
| 1760 | 1805 | ElMessage.warning('同步抖音发货失败:' + errorMsg) |
| 1761 | 1806 | } |
| 1762 | 1807 | |
| 1763 | - // 本地即时迁移 + 立即刷新列表 | |
| 1764 | 1808 | applyWaybillTransitionLocal([order.id]) |
| 1765 | 1809 | await refreshListAndStats() |
| 1810 | + createWaybillDialogVisible.value = false | |
| 1766 | 1811 | |
| 1767 | - // 创建运单后直接唤起打印机(隐藏 iframe,不打开面单预览页) | |
| 1768 | 1812 | await autoPrintWaybillFaceSheet(order) |
| 1769 | 1813 | ElMessage.success('运单已创建,正在发送到打印机') |
| 1770 | 1814 | } catch (error) { |
| 1771 | - if (error !== 'cancel' && error !== 'close') { | |
| 1772 | - const errorMsg = error.message || '未知错误' | |
| 1773 | - ElMessage.error(errorMsg) | |
| 1774 | - } | |
| 1815 | + const errorMsg = error.message || '未知错误' | |
| 1816 | + ElMessage.error(errorMsg) | |
| 1775 | 1817 | } finally { |
| 1776 | 1818 | loading.value = false |
| 1819 | + createWaybillDialogLoading.value = false | |
| 1777 | 1820 | } |
| 1778 | 1821 | } |
| 1779 | 1822 | |
| ... | ... | @@ -2408,6 +2451,14 @@ onUnmounted(() => { |
| 2408 | 2451 | handleSplitMerged, |
| 2409 | 2452 | handleUnsplit, |
| 2410 | 2453 | handleCreateWaybill, |
| 2454 | + createWaybillDialogVisible, | |
| 2455 | + createWaybillDialogLoading, | |
| 2456 | + createWaybillProductType, | |
| 2457 | + createWaybillDialogMode, | |
| 2458 | + createWaybillBatchTargets, | |
| 2459 | + sfProductTypeOptions, | |
| 2460 | + onCreateWaybillDialogClosed, | |
| 2461 | + confirmCreateWaybillDialog, | |
| 2411 | 2462 | viewWaybillOnline, |
| 2412 | 2463 | openWaybillFaceSheetPreview, |
| 2413 | 2464 | handleManualCreateWaybill, |
| ... | ... | @@ -2536,6 +2587,12 @@ onUnmounted(() => { |
| 2536 | 2587 | justify-content: flex-end; |
| 2537 | 2588 | gap: 8px; |
| 2538 | 2589 | } |
| 2590 | +.create-waybill-dialog-tip { | |
| 2591 | + margin: 0; | |
| 2592 | + color: #909399; | |
| 2593 | + font-size: 12px; | |
| 2594 | + line-height: 1.5; | |
| 2595 | +} | |
| 2539 | 2596 | |
| 2540 | 2597 | .order-list-container { |
| 2541 | 2598 | padding: 20px; | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/views/wtBillRecycle/index.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <div class="NCC-common-layout wt-bill-recycle"> | |
| 3 | + <div class="NCC-common-layout-center"> | |
| 4 | + <div class="NCC-common-search-box"> | |
| 5 | + <el-form @submit.native.prevent> | |
| 6 | + <el-row :gutter="16"> | |
| 7 | + <el-col :span="6"> | |
| 8 | + <el-form-item label="关键字"> | |
| 9 | + <el-input v-model="query.keyword" placeholder="单据编号/备注" clearable /> | |
| 10 | + </el-form-item> | |
| 11 | + </el-col> | |
| 12 | + <el-col :span="6"> | |
| 13 | + <el-form-item label="单据类型"> | |
| 14 | + <el-select v-model="query.djlx" placeholder="全部" clearable filterable style="width: 100%"> | |
| 15 | + <el-option | |
| 16 | + v-for="item in djlxOptions" | |
| 17 | + :key="item.id" | |
| 18 | + :label="item.fullName" | |
| 19 | + :value="item.id" | |
| 20 | + /> | |
| 21 | + </el-select> | |
| 22 | + </el-form-item> | |
| 23 | + </el-col> | |
| 24 | + <el-col :span="6"> | |
| 25 | + <el-form-item label="单据来源"> | |
| 26 | + <el-select v-model="query.billSource" placeholder="全部" clearable filterable style="width: 100%"> | |
| 27 | + <el-option | |
| 28 | + v-for="item in billSourceOptions" | |
| 29 | + :key="item.value" | |
| 30 | + :label="item.label" | |
| 31 | + :value="item.value" | |
| 32 | + /> | |
| 33 | + </el-select> | |
| 34 | + </el-form-item> | |
| 35 | + </el-col> | |
| 36 | + <el-col :span="6" class="NCC-common-search-btns"> | |
| 37 | + <el-form-item label-width="0"> | |
| 38 | + <el-button type="primary" size="small" icon="el-icon-search" @click="search">查询</el-button> | |
| 39 | + <el-button size="small" icon="el-icon-refresh-right" @click="reset">重置</el-button> | |
| 40 | + <el-button v-if="!showAll" type="text" icon="el-icon-arrow-down" @click="showAll = true">展开</el-button> | |
| 41 | + <el-button v-else type="text" icon="el-icon-arrow-up" @click="showAll = false">收起</el-button> | |
| 42 | + </el-form-item> | |
| 43 | + </el-col> | |
| 44 | + <template v-if="showAll"> | |
| 45 | + <el-col :span="6"> | |
| 46 | + <el-form-item label="删除时间"> | |
| 47 | + <el-date-picker | |
| 48 | + v-model="query.deleteTime" | |
| 49 | + type="datetimerange" | |
| 50 | + value-format="timestamp" | |
| 51 | + format="yyyy-MM-dd HH:mm" | |
| 52 | + start-placeholder="开始时间" | |
| 53 | + end-placeholder="结束时间" | |
| 54 | + style="width: 100%" | |
| 55 | + clearable | |
| 56 | + /> | |
| 57 | + </el-form-item> | |
| 58 | + </el-col> | |
| 59 | + </template> | |
| 60 | + </el-row> | |
| 61 | + </el-form> | |
| 62 | + </div> | |
| 63 | + <div class="NCC-common-layout-main NCC-flex-main"> | |
| 64 | + <div class="NCC-common-head"> | |
| 65 | + <div class="wt-bill-recycle-head-title"> | |
| 66 | + <i class="el-icon-delete wt-bill-recycle-head-icon" /> | |
| 67 | + <span>单据回收站</span> | |
| 68 | + </div> | |
| 69 | + <div class="NCC-common-head-right"> | |
| 70 | + <el-tooltip effect="dark" content="刷新" placement="top"> | |
| 71 | + <el-link | |
| 72 | + icon="icon-ym icon-ym-Refresh NCC-common-head-icon" | |
| 73 | + :underline="false" | |
| 74 | + @click="initData" | |
| 75 | + /> | |
| 76 | + </el-tooltip> | |
| 77 | + <screenfull isContainer /> | |
| 78 | + </div> | |
| 79 | + </div> | |
| 80 | + <NCC-table v-loading="listLoading" :data="list" row-key="rowKey"> | |
| 81 | + <el-table-column label="单据类型" align="left" min-width="130" show-overflow-tooltip class-name="cell-nowrap"> | |
| 82 | + <template slot-scope="scope"> | |
| 83 | + <i :class="['wt-bill-recycle-icon', billSourceIconClass(scope.row.billSource)]" /> | |
| 84 | + <span>{{ cellText(scope.row.djlx) }}</span> | |
| 85 | + </template> | |
| 86 | + </el-table-column> | |
| 87 | + <el-table-column label="单据编号" align="left" min-width="150" show-overflow-tooltip class-name="cell-nowrap"> | |
| 88 | + <template slot-scope="scope"> | |
| 89 | + <i class="el-icon-document wt-bill-recycle-icon wt-bill-recycle-icon--primary" /> | |
| 90 | + <el-link | |
| 91 | + type="primary" | |
| 92 | + :underline="false" | |
| 93 | + class="wt-bill-recycle-bill-link cell-nowrap" | |
| 94 | + @click="openBillDetail(scope.row)" | |
| 95 | + >{{ cellText(scope.row.billNo || scope.row.id) }}</el-link> | |
| 96 | + </template> | |
| 97 | + </el-table-column> | |
| 98 | + <el-table-column label="单据日期" align="left" min-width="110" show-overflow-tooltip class-name="cell-nowrap"> | |
| 99 | + <template slot-scope="scope"> | |
| 100 | + <span>{{ formatDate(scope.row.djrq) }}</span> | |
| 101 | + </template> | |
| 102 | + </el-table-column> | |
| 103 | + <el-table-column label="审核状态" align="left" width="120"> | |
| 104 | + <template slot-scope="scope"> | |
| 105 | + <WtDjztTag :row="scope.row" size="mini" /> | |
| 106 | + </template> | |
| 107 | + </el-table-column> | |
| 108 | + <el-table-column label="删除时间" align="left" min-width="150" show-overflow-tooltip class-name="cell-nowrap"> | |
| 109 | + <template slot-scope="scope"> | |
| 110 | + <i class="el-icon-time wt-bill-recycle-icon wt-bill-recycle-icon--danger" /> | |
| 111 | + <span>{{ formatDateTime(scope.row.deleteTime) }}</span> | |
| 112 | + </template> | |
| 113 | + </el-table-column> | |
| 114 | + <el-table-column label="删除人" align="left" min-width="100" show-overflow-tooltip class-name="cell-nowrap"> | |
| 115 | + <template slot-scope="scope"> | |
| 116 | + <i class="el-icon-user wt-bill-recycle-icon wt-bill-recycle-icon--muted" /> | |
| 117 | + <span>{{ cellText(scope.row.deleteUser || scope.row.deleteBy) }}</span> | |
| 118 | + </template> | |
| 119 | + </el-table-column> | |
| 120 | + <el-table-column label="操作" fixed="right" width="140"> | |
| 121 | + <template slot-scope="scope"> | |
| 122 | + <el-button type="text" @click="handleRestore(scope.row)">恢复</el-button> | |
| 123 | + <el-button | |
| 124 | + v-if="showPurgeBtn" | |
| 125 | + type="text" | |
| 126 | + class="NCC-table-delBtn" | |
| 127 | + @click="handlePurge(scope.row)" | |
| 128 | + >彻底删除</el-button> | |
| 129 | + </template> | |
| 130 | + </el-table-column> | |
| 131 | + </NCC-table> | |
| 132 | + <pagination | |
| 133 | + :total="total" | |
| 134 | + :page.sync="listQuery.currentPage" | |
| 135 | + :limit.sync="listQuery.pageSize" | |
| 136 | + @pagination="initData" | |
| 137 | + /> | |
| 138 | + </div> | |
| 139 | + </div> | |
| 140 | + <RecycleDetailHost ref="recycleDetailHost" /> | |
| 141 | + </div> | |
| 142 | +</template> | |
| 143 | + | |
| 144 | +<script> | |
| 145 | +import { djmcOptions } from '@/views/wtShrysz/djmcOptions' | |
| 146 | +import { | |
| 147 | + getWtBillRecycleList, | |
| 148 | + restoreWtBillRecycle, | |
| 149 | + purgeWtBillRecycle | |
| 150 | +} from '@/api/extend/wtBillRecycle' | |
| 151 | +import RecycleDetailHost from './recycle-detail-host' | |
| 152 | + | |
| 153 | +const EXTRA_DJLX_OPTIONS = [ | |
| 154 | + { fullName: '变价调拨单', id: '变价调拨单' }, | |
| 155 | + { fullName: '零售单', id: '零售单' }, | |
| 156 | + { fullName: '盘点单', id: '盘点单' }, | |
| 157 | + { fullName: '收付款单', id: '收付款单' }, | |
| 158 | + { fullName: '待摊费用发生', id: '待摊费用发生' }, | |
| 159 | + { fullName: '固定资产变卖', id: '固定资产变卖' } | |
| 160 | +] | |
| 161 | + | |
| 162 | +const BILL_SOURCE_OPTIONS = [ | |
| 163 | + { label: '进销存单据', value: 'WtXsckd' }, | |
| 164 | + { label: '财务单据', value: 'WtCwdj' }, | |
| 165 | + { label: '应收应付现金单', value: 'WtYskzjjs' }, | |
| 166 | + { label: '费用收入单', value: 'WtFysrd' }, | |
| 167 | + { label: '商品调价单', value: 'WtTjd' }, | |
| 168 | + { label: '拆装单', value: 'WtCzd' }, | |
| 169 | + { label: '发票申请', value: 'WtFpsq' }, | |
| 170 | + { label: '客服补发单', value: 'WtKfbfb' }, | |
| 171 | + { label: '转款单', value: 'WtZkd' }, | |
| 172 | + { label: '盘点单', value: 'WtPd' }, | |
| 173 | + { label: '会员到期退款', value: 'WtHydqtk' }, | |
| 174 | + { label: '收付款单', value: 'WtSfk' } | |
| 175 | +] | |
| 176 | + | |
| 177 | +function buildDjlxOptions() { | |
| 178 | + const map = new Map() | |
| 179 | + ;[...djmcOptions, ...EXTRA_DJLX_OPTIONS].forEach(item => { | |
| 180 | + if (item && item.id) map.set(item.id, item) | |
| 181 | + }) | |
| 182 | + return Array.from(map.values()) | |
| 183 | +} | |
| 184 | + | |
| 185 | +export default { | |
| 186 | + name: 'wtBillRecycle', | |
| 187 | + components: { RecycleDetailHost }, | |
| 188 | + data() { | |
| 189 | + return { | |
| 190 | + showAll: false, | |
| 191 | + showPurgeBtn: process.env.NODE_ENV === 'development', | |
| 192 | + query: { | |
| 193 | + keyword: undefined, | |
| 194 | + djlx: undefined, | |
| 195 | + billSource: undefined, | |
| 196 | + deleteTime: undefined | |
| 197 | + }, | |
| 198 | + djlxOptions: buildDjlxOptions(), | |
| 199 | + billSourceOptions: BILL_SOURCE_OPTIONS, | |
| 200 | + list: [], | |
| 201 | + listLoading: false, | |
| 202 | + total: 0, | |
| 203 | + listQuery: { | |
| 204 | + currentPage: 1, | |
| 205 | + pageSize: 20 | |
| 206 | + } | |
| 207 | + } | |
| 208 | + }, | |
| 209 | + created() { | |
| 210 | + this.initData() | |
| 211 | + }, | |
| 212 | + activated() { | |
| 213 | + this.initData() | |
| 214 | + }, | |
| 215 | + methods: { | |
| 216 | + cellText(v) { | |
| 217 | + if (v === null || v === undefined || v === '') return '无' | |
| 218 | + return v | |
| 219 | + }, | |
| 220 | + formatDate(v) { | |
| 221 | + if (v === null || v === undefined || v === '') return '无' | |
| 222 | + if (typeof this.ncc !== 'undefined' && this.ncc.tableDateFormat) { | |
| 223 | + return this.ncc.tableDateFormat(null, null, v) || '无' | |
| 224 | + } | |
| 225 | + return String(v) | |
| 226 | + }, | |
| 227 | + formatDateTime(v) { | |
| 228 | + if (v === null || v === undefined || v === '') return '无' | |
| 229 | + if (typeof this.ncc !== 'undefined' && this.ncc.tableDateFormat) { | |
| 230 | + return this.ncc.tableDateFormat(null, null, v) || '无' | |
| 231 | + } | |
| 232 | + return String(v) | |
| 233 | + }, | |
| 234 | + billSourceIconClass(billSource) { | |
| 235 | + const map = { | |
| 236 | + WtXsckd: 'el-icon-s-goods wt-bill-recycle-icon--primary', | |
| 237 | + WtCwdj: 'el-icon-s-finance wt-bill-recycle-icon--warning', | |
| 238 | + WtYskzjjs: 'el-icon-coin wt-bill-recycle-icon--success', | |
| 239 | + WtFysrd: 'el-icon-document-copy wt-bill-recycle-icon--warning', | |
| 240 | + WtTjd: 'el-icon-price-tag wt-bill-recycle-icon--primary', | |
| 241 | + WtCzd: 'el-icon-s-operation wt-bill-recycle-icon--muted', | |
| 242 | + WtFpsq: 'el-icon-tickets wt-bill-recycle-icon--primary', | |
| 243 | + WtKfbfb: 'el-icon-service wt-bill-recycle-icon--success', | |
| 244 | + WtZkd: 'el-icon-sort wt-bill-recycle-icon--warning', | |
| 245 | + WtPd: 'el-icon-notebook-2 wt-bill-recycle-icon--primary', | |
| 246 | + WtHydqtk: 'el-icon-user-solid wt-bill-recycle-icon--success', | |
| 247 | + WtSfk: 'el-icon-wallet wt-bill-recycle-icon--success' | |
| 248 | + } | |
| 249 | + return map[billSource] || 'el-icon-document wt-bill-recycle-icon--muted' | |
| 250 | + }, | |
| 251 | + buildListQuery() { | |
| 252 | + const q = { | |
| 253 | + currentPage: this.listQuery.currentPage, | |
| 254 | + pageSize: this.listQuery.pageSize | |
| 255 | + } | |
| 256 | + if (this.query.keyword) q.keyword = this.query.keyword | |
| 257 | + if (this.query.djlx) q.djlx = this.query.djlx | |
| 258 | + if (this.query.billSource) q.billSource = this.query.billSource | |
| 259 | + const dr = this.query.deleteTime | |
| 260 | + if (Array.isArray(dr) && dr.length === 2) { | |
| 261 | + q.deleteTimeStart = dr[0] | |
| 262 | + q.deleteTimeEnd = dr[1] | |
| 263 | + } | |
| 264 | + return q | |
| 265 | + }, | |
| 266 | + initData() { | |
| 267 | + this.listLoading = true | |
| 268 | + getWtBillRecycleList(this.buildListQuery()) | |
| 269 | + .then(res => { | |
| 270 | + const d = res.data || {} | |
| 271 | + const rows = d.list || [] | |
| 272 | + this.list = rows.map((row, index) => ({ | |
| 273 | + ...row, | |
| 274 | + rowKey: `${row.billSource || 'unknown'}_${row.id || index}` | |
| 275 | + })) | |
| 276 | + this.total = d.total != null ? d.total : (d.pagination && d.pagination.total) || 0 | |
| 277 | + }) | |
| 278 | + .catch(() => {}) | |
| 279 | + .finally(() => { | |
| 280 | + this.listLoading = false | |
| 281 | + }) | |
| 282 | + }, | |
| 283 | + search() { | |
| 284 | + this.listQuery.currentPage = 1 | |
| 285 | + this.initData() | |
| 286 | + }, | |
| 287 | + reset() { | |
| 288 | + this.showAll = false | |
| 289 | + this.query = { | |
| 290 | + keyword: undefined, | |
| 291 | + djlx: undefined, | |
| 292 | + billSource: undefined, | |
| 293 | + deleteTime: undefined | |
| 294 | + } | |
| 295 | + this.listQuery.currentPage = 1 | |
| 296 | + this.initData() | |
| 297 | + }, | |
| 298 | + handleRestore(row) { | |
| 299 | + const billNo = this.cellText(row.billNo || row.id) | |
| 300 | + const djlx = this.cellText(row.djlx) | |
| 301 | + this.$confirm(`确认恢复【${djlx} · ${billNo}】?恢复后可回到对应业务列表查看。`, '恢复单据', { | |
| 302 | + confirmButtonText: '确定', | |
| 303 | + cancelButtonText: '取消', | |
| 304 | + type: 'warning' | |
| 305 | + }).then(() => { | |
| 306 | + return restoreWtBillRecycle(row.billSource, row.id) | |
| 307 | + }).then(res => { | |
| 308 | + this.$message.success(res.msg || '恢复成功') | |
| 309 | + this.initData() | |
| 310 | + }).catch(() => {}) | |
| 311 | + }, | |
| 312 | + handlePurge(row) { | |
| 313 | + const billNo = this.cellText(row.billNo || row.id) | |
| 314 | + this.$confirm(`彻底删除后不可恢复,确认清除【${billNo}】?`, '彻底删除', { | |
| 315 | + confirmButtonText: '确定删除', | |
| 316 | + cancelButtonText: '取消', | |
| 317 | + type: 'error' | |
| 318 | + }).then(() => { | |
| 319 | + return purgeWtBillRecycle(row.billSource, row.id) | |
| 320 | + }).then(res => { | |
| 321 | + this.$message.success(res.msg || '已彻底删除') | |
| 322 | + this.initData() | |
| 323 | + }).catch(() => {}) | |
| 324 | + }, | |
| 325 | + openBillDetail(row) { | |
| 326 | + if (!row || !row.id) return | |
| 327 | + const host = this.$refs.recycleDetailHost | |
| 328 | + if (host && typeof host.open === 'function') { | |
| 329 | + host.open(row) | |
| 330 | + } | |
| 331 | + } | |
| 332 | + } | |
| 333 | +} | |
| 334 | +</script> | |
| 335 | + | |
| 336 | +<style scoped lang="scss"> | |
| 337 | +.wt-bill-recycle-head-title { | |
| 338 | + display: inline-flex; | |
| 339 | + align-items: center; | |
| 340 | + gap: 6px; | |
| 341 | + font-weight: 500; | |
| 342 | + color: #303133; | |
| 343 | +} | |
| 344 | + | |
| 345 | +.wt-bill-recycle-head-icon { | |
| 346 | + color: #f56c6c; | |
| 347 | + font-size: 16px; | |
| 348 | +} | |
| 349 | + | |
| 350 | +.wt-bill-recycle-icon { | |
| 351 | + margin-right: 4px; | |
| 352 | + flex-shrink: 0; | |
| 353 | + | |
| 354 | + &--primary { | |
| 355 | + color: #409eff; | |
| 356 | + } | |
| 357 | + | |
| 358 | + &--success { | |
| 359 | + color: #67c23a; | |
| 360 | + } | |
| 361 | + | |
| 362 | + &--warning { | |
| 363 | + color: #e6a23c; | |
| 364 | + } | |
| 365 | + | |
| 366 | + &--danger { | |
| 367 | + color: #f56c6c; | |
| 368 | + } | |
| 369 | + | |
| 370 | + &--muted { | |
| 371 | + color: #909399; | |
| 372 | + } | |
| 373 | +} | |
| 374 | + | |
| 375 | +.wt-bill-recycle-bill-link { | |
| 376 | + cursor: pointer; | |
| 377 | + font-weight: 500; | |
| 378 | +} | |
| 379 | + | |
| 380 | +.wt-bill-recycle ::v-deep .NCC-common-search-btns .el-button--small { | |
| 381 | + height: 32px; | |
| 382 | + line-height: 30px; | |
| 383 | + padding-top: 0; | |
| 384 | + padding-bottom: 0; | |
| 385 | +} | |
| 386 | +</style> | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/views/wtBillRecycle/recycle-detail-host.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <component | |
| 3 | + :is="activeComponent" | |
| 4 | + v-if="detailVisible && activeComponent" | |
| 5 | + ref="detailRef" | |
| 6 | + @close="onDetailClose" | |
| 7 | + /> | |
| 8 | +</template> | |
| 9 | + | |
| 10 | +<script> | |
| 11 | +import { | |
| 12 | + resolveRecycleDetailLoader, | |
| 13 | + isRecycleDetailSupported | |
| 14 | +} from './wtBillRecycleDetailMap' | |
| 15 | +import { | |
| 16 | + enterRecycleDeletedContext, | |
| 17 | + leaveRecycleDeletedContext | |
| 18 | +} from '@/utils/wtRecycleRequestContext' | |
| 19 | + | |
| 20 | +export default { | |
| 21 | + name: 'RecycleDetailHost', | |
| 22 | + data() { | |
| 23 | + return { | |
| 24 | + detailVisible: false, | |
| 25 | + activeComponent: null, | |
| 26 | + opening: false | |
| 27 | + } | |
| 28 | + }, | |
| 29 | + beforeDestroy() { | |
| 30 | + if (this.detailVisible) { | |
| 31 | + leaveRecycleDeletedContext() | |
| 32 | + } | |
| 33 | + }, | |
| 34 | + methods: { | |
| 35 | + canOpen(row) { | |
| 36 | + return isRecycleDetailSupported(row && row.billSource, row && row.djlx) | |
| 37 | + }, | |
| 38 | + async open(row) { | |
| 39 | + if (!row || !row.id) return | |
| 40 | + const loader = resolveRecycleDetailLoader(row.billSource, row.djlx) | |
| 41 | + if (!loader) { | |
| 42 | + const label = row.djlx || row.billSource || '未知类型' | |
| 43 | + this.$message.warning(`暂不支持查看该类型详情(${label})`) | |
| 44 | + return | |
| 45 | + } | |
| 46 | + if (this.opening) return | |
| 47 | + this.opening = true | |
| 48 | + try { | |
| 49 | + if (this.detailVisible) { | |
| 50 | + this.onDetailClose() | |
| 51 | + await this.$nextTick() | |
| 52 | + } | |
| 53 | + const mod = await loader() | |
| 54 | + this.activeComponent = mod.default || mod | |
| 55 | + this.detailVisible = true | |
| 56 | + enterRecycleDeletedContext() | |
| 57 | + await this.$nextTick() | |
| 58 | + const ref = this.$refs.detailRef | |
| 59 | + if (ref && typeof ref.init === 'function') { | |
| 60 | + ref.init(row.id) | |
| 61 | + } else { | |
| 62 | + leaveRecycleDeletedContext() | |
| 63 | + this.detailVisible = false | |
| 64 | + this.activeComponent = null | |
| 65 | + this.$message.warning('详情组件不可用') | |
| 66 | + } | |
| 67 | + } catch (e) { | |
| 68 | + leaveRecycleDeletedContext() | |
| 69 | + this.detailVisible = false | |
| 70 | + this.activeComponent = null | |
| 71 | + this.$message.error('打开详情失败') | |
| 72 | + } finally { | |
| 73 | + this.opening = false | |
| 74 | + } | |
| 75 | + }, | |
| 76 | + onDetailClose() { | |
| 77 | + leaveRecycleDeletedContext() | |
| 78 | + this.detailVisible = false | |
| 79 | + this.activeComponent = null | |
| 80 | + } | |
| 81 | + } | |
| 82 | +} | |
| 83 | +</script> | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/views/wtBillRecycle/recycle-pd-detail.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <el-dialog | |
| 3 | + title="盘点单详情(回收站只读)" | |
| 4 | + :close-on-click-modal="false" | |
| 5 | + :visible.sync="visible" | |
| 6 | + class="NCC-dialog NCC-dialog_center recycle-pd-detail-dialog" | |
| 7 | + lock-scroll | |
| 8 | + append-to-body | |
| 9 | + modal-append-to-body | |
| 10 | + width="1100px" | |
| 11 | + top="6vh" | |
| 12 | + @close="handleClose" | |
| 13 | + > | |
| 14 | + <div v-loading="loading" class="recycle-pd-detail"> | |
| 15 | + <template v-if="detail && detail.id"> | |
| 16 | + <div class="recycle-pd-detail__top"> | |
| 17 | + <div class="recycle-pd-detail__id"> | |
| 18 | + <i class="el-icon-document recycle-pd-detail__icon recycle-pd-detail__icon--primary" /> | |
| 19 | + <span class="cell-nowrap">{{ cellText(detail.pdbh || detail.id) }}</span> | |
| 20 | + </div> | |
| 21 | + <el-tag v-if="normStatus(detail.status) === '进行中'" type="primary" size="medium">进行中</el-tag> | |
| 22 | + <el-tag v-else-if="normStatus(detail.status) === '已完成'" type="success" size="medium">已完成</el-tag> | |
| 23 | + <el-tag v-else-if="normStatus(detail.status) === '已取消'" type="info" size="medium">已取消</el-tag> | |
| 24 | + <el-tag v-else type="info" size="medium">{{ cellText(detail.status) }}</el-tag> | |
| 25 | + </div> | |
| 26 | + | |
| 27 | + <el-descriptions | |
| 28 | + title="基本信息" | |
| 29 | + :column="3" | |
| 30 | + border | |
| 31 | + size="small" | |
| 32 | + class="recycle-pd-detail__desc" | |
| 33 | + :label-style="{ width: '108px' }" | |
| 34 | + > | |
| 35 | + <el-descriptions-item label="仓库"> | |
| 36 | + <span class="cell-nowrap">{{ cellText(detail.ckmc || detail.ckId) }}</span> | |
| 37 | + </el-descriptions-item> | |
| 38 | + <el-descriptions-item label="单据日期"> | |
| 39 | + <span class="cell-nowrap">{{ formatDate(detail.djrq) }}</span> | |
| 40 | + </el-descriptions-item> | |
| 41 | + <el-descriptions-item label="盈亏金额"> | |
| 42 | + <span class="cell-nowrap">{{ formatMoney(detail.ykje) }}</span> | |
| 43 | + </el-descriptions-item> | |
| 44 | + <el-descriptions-item label="账面总金额"> | |
| 45 | + <span class="cell-nowrap">{{ formatMoney(detail.zmzje) }}</span> | |
| 46 | + </el-descriptions-item> | |
| 47 | + <el-descriptions-item label="实盘总金额"> | |
| 48 | + <span class="cell-nowrap">{{ formatMoney(detail.sjzje) }}</span> | |
| 49 | + </el-descriptions-item> | |
| 50 | + <el-descriptions-item label="报损单号"> | |
| 51 | + <span class="cell-nowrap">{{ cellText(detail.bsdId) }}</span> | |
| 52 | + </el-descriptions-item> | |
| 53 | + <el-descriptions-item label="报溢单号"> | |
| 54 | + <span class="cell-nowrap">{{ cellText(detail.bydId) }}</span> | |
| 55 | + </el-descriptions-item> | |
| 56 | + <el-descriptions-item label="备注" :span="2"> | |
| 57 | + <span>{{ cellText(detail.bz) }}</span> | |
| 58 | + </el-descriptions-item> | |
| 59 | + </el-descriptions> | |
| 60 | + | |
| 61 | + <div class="recycle-pd-detail__mx-title">盘点明细</div> | |
| 62 | + <el-table | |
| 63 | + :data="mxList" | |
| 64 | + border | |
| 65 | + stripe | |
| 66 | + size="small" | |
| 67 | + max-height="420" | |
| 68 | + empty-text="无明细" | |
| 69 | + class="recycle-pd-detail__table" | |
| 70 | + > | |
| 71 | + <el-table-column type="index" label="#" width="52" align="center" /> | |
| 72 | + <el-table-column prop="spbh" label="商品编码" min-width="120" show-overflow-tooltip class-name="cell-nowrap" /> | |
| 73 | + <el-table-column prop="spmc" label="商品名称" min-width="160" show-overflow-tooltip class-name="cell-nowrap" /> | |
| 74 | + <el-table-column label="账面数量" width="100" align="right"> | |
| 75 | + <template slot-scope="scope">{{ displayNum(scope.row.ckc) }}</template> | |
| 76 | + </el-table-column> | |
| 77 | + <el-table-column label="实盘数量" width="100" align="right"> | |
| 78 | + <template slot-scope="scope">{{ displayNum(scope.row.sjsl) }}</template> | |
| 79 | + </el-table-column> | |
| 80 | + <el-table-column label="盈亏数量" width="100" align="right"> | |
| 81 | + <template slot-scope="scope">{{ displayNum(scope.row.yksl) }}</template> | |
| 82 | + </el-table-column> | |
| 83 | + <el-table-column label="盈亏金额" width="110" align="right"> | |
| 84 | + <template slot-scope="scope">{{ formatMoney(scope.row.ykje) }}</template> | |
| 85 | + </el-table-column> | |
| 86 | + <el-table-column prop="bz" label="备注" min-width="120" show-overflow-tooltip class-name="cell-nowrap" /> | |
| 87 | + </el-table> | |
| 88 | + </template> | |
| 89 | + </div> | |
| 90 | + <span slot="footer" class="dialog-footer"> | |
| 91 | + <el-button @click="visible = false">关 闭</el-button> | |
| 92 | + </span> | |
| 93 | + </el-dialog> | |
| 94 | +</template> | |
| 95 | + | |
| 96 | +<script> | |
| 97 | +import { getWtPdDetail } from '@/api/extend/wtPd' | |
| 98 | + | |
| 99 | +export default { | |
| 100 | + name: 'RecyclePdDetail', | |
| 101 | + data() { | |
| 102 | + return { | |
| 103 | + visible: false, | |
| 104 | + loading: false, | |
| 105 | + detail: null, | |
| 106 | + mxList: [] | |
| 107 | + } | |
| 108 | + }, | |
| 109 | + methods: { | |
| 110 | + cellText(v) { | |
| 111 | + if (v === null || v === undefined || v === '') return '无' | |
| 112 | + return v | |
| 113 | + }, | |
| 114 | + normStatus(v) { | |
| 115 | + return v == null ? '' : String(v).trim() | |
| 116 | + }, | |
| 117 | + formatDate(v) { | |
| 118 | + if (v === null || v === undefined || v === '') return '无' | |
| 119 | + if (typeof this.ncc !== 'undefined' && this.ncc.tableDateFormat) { | |
| 120 | + return this.ncc.tableDateFormat(null, null, v) || '无' | |
| 121 | + } | |
| 122 | + return String(v) | |
| 123 | + }, | |
| 124 | + formatMoney(v) { | |
| 125 | + if (v === null || v === undefined || v === '') return '无' | |
| 126 | + const n = Number(v) | |
| 127 | + if (Number.isNaN(n)) return String(v) | |
| 128 | + return n.toFixed(2) | |
| 129 | + }, | |
| 130 | + displayNum(v) { | |
| 131 | + if (v === null || v === undefined || v === '') return '无' | |
| 132 | + return v | |
| 133 | + }, | |
| 134 | + handleClose() { | |
| 135 | + this.detail = null | |
| 136 | + this.mxList = [] | |
| 137 | + this.$emit('close') | |
| 138 | + }, | |
| 139 | + init(id) { | |
| 140 | + if (!id) return | |
| 141 | + this.visible = true | |
| 142 | + this.loading = true | |
| 143 | + this.detail = null | |
| 144 | + this.mxList = [] | |
| 145 | + getWtPdDetail(id) | |
| 146 | + .then(res => { | |
| 147 | + const d = res.data || {} | |
| 148 | + this.detail = d | |
| 149 | + this.mxList = Array.isArray(d.mxList) ? d.mxList : [] | |
| 150 | + }) | |
| 151 | + .catch(() => { | |
| 152 | + this.$message.error('加载盘点详情失败') | |
| 153 | + this.visible = false | |
| 154 | + }) | |
| 155 | + .finally(() => { | |
| 156 | + this.loading = false | |
| 157 | + }) | |
| 158 | + } | |
| 159 | + } | |
| 160 | +} | |
| 161 | +</script> | |
| 162 | + | |
| 163 | +<style scoped lang="scss"> | |
| 164 | +.cell-nowrap { | |
| 165 | + white-space: nowrap; | |
| 166 | +} | |
| 167 | + | |
| 168 | +.recycle-pd-detail__top { | |
| 169 | + display: flex; | |
| 170 | + align-items: center; | |
| 171 | + gap: 10px; | |
| 172 | + margin-bottom: 12px; | |
| 173 | +} | |
| 174 | + | |
| 175 | +.recycle-pd-detail__id { | |
| 176 | + display: inline-flex; | |
| 177 | + align-items: center; | |
| 178 | + gap: 6px; | |
| 179 | + font-weight: 500; | |
| 180 | + color: #303133; | |
| 181 | +} | |
| 182 | + | |
| 183 | +.recycle-pd-detail__icon { | |
| 184 | + &--primary { | |
| 185 | + color: #409eff; | |
| 186 | + } | |
| 187 | +} | |
| 188 | + | |
| 189 | +.recycle-pd-detail__desc { | |
| 190 | + margin-bottom: 12px; | |
| 191 | +} | |
| 192 | + | |
| 193 | +.recycle-pd-detail__mx-title { | |
| 194 | + margin: 8px 0; | |
| 195 | + font-size: 14px; | |
| 196 | + font-weight: 500; | |
| 197 | + color: #303133; | |
| 198 | +} | |
| 199 | + | |
| 200 | +.recycle-pd-detail { | |
| 201 | + min-height: 120px; | |
| 202 | +} | |
| 203 | +</style> | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/views/wtBillRecycle/wtBillRecycleDetailMap.js
0 → 100644
| 1 | +/** WtXsckd 子类型(djlx)→ detail-view 动态加载器 */ | |
| 2 | +const WT_XSCKD_DJLX_LOADERS = { | |
| 3 | + 销售出库单: () => import('@/views/wtXsckd/detail-view.vue'), | |
| 4 | + 零售单: () => import('@/views/wtXsckd/detail-view.vue'), | |
| 5 | + 预售出库单: () => import('@/views/wtYsckd/detail-view.vue'), | |
| 6 | + 销售退货单: () => import('@/views/wtXsthd/detail-view.vue'), | |
| 7 | + 预售退货单: () => import('@/views/wtYsthd/detail-view.vue'), | |
| 8 | + 同价调拨单: () => import('@/views/wtTjdbd/detail-view.vue'), | |
| 9 | + 变价调拨单: () => import('@/views/wtBjdbd/detail-view.vue'), | |
| 10 | + 报损单: () => import('@/views/wtBsd/detail-view.vue'), | |
| 11 | + 报溢单: () => import('@/views/wtByd/detail-view.vue'), | |
| 12 | + 采购入库单: () => import('@/views/wtCgrkd/detail-view.vue'), | |
| 13 | + 采购退货单: () => import('@/views/wtCgthd/detail-view.vue'), | |
| 14 | + 赠送单: () => import('@/views/wtZsd/detail-view.vue'), | |
| 15 | + 委托代销发货单: () => import('@/views/wtXswtdxfhd/detail-view.vue'), | |
| 16 | + 委托代销退货单: () => import('@/views/wtXswtdxthd/detail-view.vue'), | |
| 17 | + 委托代销结算单: () => import('@/views/wtXswtdxjsd/detail-view.vue'), | |
| 18 | + 获赠单: () => import('@/views/wtHzd/detail-view.vue') | |
| 19 | +} | |
| 20 | + | |
| 21 | +/** WtCwdj 子类型(djlx)→ detail-view */ | |
| 22 | +const WT_CWDJ_DJLX_LOADERS = { | |
| 23 | + 收款单: () => import('@/views/wtCwdj_skd/detail-view.vue'), | |
| 24 | + 付款单: () => import('@/views/wtCwdj_fkd/detail-view.vue'), | |
| 25 | + 费用单: () => import('@/views/wtCwdj_fyd/detail-view.vue'), | |
| 26 | + 固定资产购买: () => import('@/views/wtCwdj_gdzcgm/detail-view.vue'), | |
| 27 | + 固定资产变卖: () => import('@/views/wtCwdj_gdzcbm/detail-view.vue'), | |
| 28 | + 固定资产折旧: () => import('@/views/wtCwdj_gdzczj/detail-view.vue'), | |
| 29 | + 待摊费用摊销: () => import('@/views/wtCwdj_dtfytx/detail-view.vue') | |
| 30 | +} | |
| 31 | + | |
| 32 | +/** WtYskzjjs 子类型(djlx)→ detail-view */ | |
| 33 | +const WT_YSKZJJS_DJLX_LOADERS = { | |
| 34 | + 应收款增加: () => import('@/views/wtYskzjjs/detail-view.vue'), | |
| 35 | + 应收款减少: () => import('@/views/wtYskzjjs_js/detail-view.vue'), | |
| 36 | + 应付款增加: () => import('@/views/wtYfkzjjs/detail-view.vue'), | |
| 37 | + 应付款减少: () => import('@/views/wtYfkzjjs_js/detail-view.vue'), | |
| 38 | + 现金费用单: () => import('@/views/wtYskzjjs_xj/detail-view.vue'), | |
| 39 | + 转款单: () => import('@/views/wtYskzjjs_zk/detail-view.vue'), | |
| 40 | + 会员到期退款: () => import('@/views/wtYskzjjs_hy/detail-view.vue'), | |
| 41 | + 其他收入单: () => import('@/views/wtYskzjjs_qt/detail-view.vue') | |
| 42 | +} | |
| 43 | + | |
| 44 | +/** billSource 级默认加载器(无 djlx 或未命中子映射时使用) */ | |
| 45 | +const BILL_SOURCE_LOADERS = { | |
| 46 | + WtXsckd: null, | |
| 47 | + WtCwdj: null, | |
| 48 | + WtYskzjjs: null, | |
| 49 | + WtFysrd: () => import('@/views/wtFysrd_qtsr/detail-view.vue'), | |
| 50 | + WtTjd: () => import('@/views/wtPriceAdjust/detail-view.vue'), | |
| 51 | + WtCzd: () => import('@/views/wtCzd/detail-view.vue'), | |
| 52 | + WtFpsq: () => import('@/views/wtFpsq/detail-view.vue'), | |
| 53 | + WtKfbfb: () => import('@/views/wtKfbfb/detail-view.vue'), | |
| 54 | + WtZkd: () => import('@/views/wtYskzjjs_zk/detail-view.vue'), | |
| 55 | + WtPd: () => import('@/views/wtBillRecycle/recycle-pd-detail.vue'), | |
| 56 | + WtHydqtk: () => import('@/views/wtYskzjjs_hy/detail-view.vue'), | |
| 57 | + WtSfk: null | |
| 58 | +} | |
| 59 | + | |
| 60 | +const BILL_SOURCE_DJLX_LOADERS = { | |
| 61 | + WtXsckd: WT_XSCKD_DJLX_LOADERS, | |
| 62 | + WtCwdj: WT_CWDJ_DJLX_LOADERS, | |
| 63 | + WtYskzjjs: WT_YSKZJJS_DJLX_LOADERS, | |
| 64 | + WtTjd: { | |
| 65 | + 商品调价单: () => import('@/views/wtPriceAdjust/detail-view.vue') | |
| 66 | + } | |
| 67 | +} | |
| 68 | + | |
| 69 | +function normalizeDjlx(djlx) { | |
| 70 | + if (djlx === null || djlx === undefined) return '' | |
| 71 | + return String(djlx).trim() | |
| 72 | +} | |
| 73 | + | |
| 74 | +/** | |
| 75 | + * 按 billSource + djlx 解析 detail-view 动态加载器。 | |
| 76 | + * @returns {(() => Promise<any>) | null} | |
| 77 | + */ | |
| 78 | +export function resolveRecycleDetailLoader(billSource, djlx) { | |
| 79 | + const source = billSource ? String(billSource).trim() : '' | |
| 80 | + const type = normalizeDjlx(djlx) | |
| 81 | + const byDjlx = BILL_SOURCE_DJLX_LOADERS[source] | |
| 82 | + if (byDjlx && type && byDjlx[type]) { | |
| 83 | + return byDjlx[type] | |
| 84 | + } | |
| 85 | + return BILL_SOURCE_LOADERS[source] || null | |
| 86 | +} | |
| 87 | + | |
| 88 | +/** 是否支持在回收站打开详情 */ | |
| 89 | +export function isRecycleDetailSupported(billSource, djlx) { | |
| 90 | + return !!resolveRecycleDetailLoader(billSource, djlx) | |
| 91 | +} | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/views/wtCgrkd/cgrkd-export-xlsx.js
| 1 | 1 | import * as XLSX from 'xlsx' |
| 2 | 2 | import { CGRKD_DETAIL_EXPORT_COLUMNS } from '@/utils/wtExportDialog' |
| 3 | +import { getWtDjztDisplayLabel, getWtAuditNodeLabel } from '@/utils/wtDjztDisplay' | |
| 3 | 4 | |
| 4 | 5 | export { CGRKD_DETAIL_EXPORT_COLUMNS } |
| 5 | 6 | |
| ... | ... | @@ -87,6 +88,8 @@ export function downloadCgrkdSummaryXlsx(rows, columnList, filename) { |
| 87 | 88 | const body = (rows || []).map(row => cols.map(c => { |
| 88 | 89 | const prop = c.prop |
| 89 | 90 | if (prop === 'djrq') return formatDjrq(row.djrq) |
| 91 | + if (prop === 'djzt') return getWtDjztDisplayLabel(row.djzt || row.shzt, row.spbz) || '无' | |
| 92 | + if (prop === 'auditNode') return getWtAuditNodeLabel(row.djzt || row.shzt, row.spbz) || '无' | |
| 90 | 93 | if (prop === 'rkck') return labelFromOptions(row.rkck, row._rkckOptions) || cellText(row.rkck) |
| 91 | 94 | if (prop === 'skzh' && row._skzhOptions) { |
| 92 | 95 | const hit = row._skzhOptions.find(o => String(o.id) === String(row.skzh)) | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/views/wtCgrkd/detail-view.vue
| ... | ... | @@ -18,7 +18,10 @@ |
| 18 | 18 | <i class="el-icon-document detail-top__icon detail-top__icon--primary" /> |
| 19 | 19 | <span class="cell-nowrap">{{ cellText(detail.id) }}</span> |
| 20 | 20 | </div> |
| 21 | - <WtDjztTag :row="detail" size="medium" effect="plain" /> | |
| 21 | + <div class="detail-top__tags"> | |
| 22 | + <WtDjztTag :row="detail" size="medium" effect="plain" /> | |
| 23 | + <el-tag :type="auditNodeTagType" size="medium" effect="plain">{{ auditNodeLabel }}</el-tag> | |
| 24 | + </div> | |
| 22 | 25 | </div> |
| 23 | 26 | |
| 24 | 27 | <div class="collect-stat-card"> |
| ... | ... | @@ -213,6 +216,7 @@ import PurchaseInboundSerialViewDialog from './purchase-inbound-serial-view-dial |
| 213 | 216 | import { previewDataInterface } from '@/api/systemData/dataInterface' |
| 214 | 217 | import { dynamicText } from '@/filters' |
| 215 | 218 | import { getAccountSelector } from '@/api/extend/wtAccount' |
| 219 | +import { getWtAuditNodeLabel, getWtAuditNodeTagType } from '@/utils/wtDjztDisplay' | |
| 216 | 220 | |
| 217 | 221 | export default { |
| 218 | 222 | name: 'WtCgrkdDetailView', |
| ... | ... | @@ -249,6 +253,14 @@ export default { |
| 249 | 253 | if (z === '待审核' || !z) return 'warning' |
| 250 | 254 | return 'info' |
| 251 | 255 | }, |
| 256 | + auditNodeLabel() { | |
| 257 | + if (!this.detail) return '无' | |
| 258 | + return getWtAuditNodeLabel(this.detail.djzt || this.detail.shzt, this.detail.spbz) || '无' | |
| 259 | + }, | |
| 260 | + auditNodeTagType() { | |
| 261 | + if (!this.detail) return 'info' | |
| 262 | + return getWtAuditNodeTagType(this.detail.djzt || this.detail.shzt, this.detail.spbz) | |
| 263 | + }, | |
| 252 | 264 | }, |
| 253 | 265 | methods: { |
| 254 | 266 | labelFromOptions(value, options) { |
| ... | ... | @@ -564,6 +576,12 @@ export default { |
| 564 | 576 | .detail-top__icon--primary { |
| 565 | 577 | color: #409eff; |
| 566 | 578 | } |
| 579 | +.detail-top__tags { | |
| 580 | + display: flex; | |
| 581 | + align-items: center; | |
| 582 | + flex-wrap: wrap; | |
| 583 | + gap: 8px; | |
| 584 | +} | |
| 567 | 585 | |
| 568 | 586 | .collect-stat-card { |
| 569 | 587 | height: 100px; | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/views/wtCgrkd/index.vue
| ... | ... | @@ -133,6 +133,13 @@ |
| 133 | 133 | <WtDjztTag :row="scope.row" size="mini" /> |
| 134 | 134 | </template> |
| 135 | 135 | </el-table-column> |
| 136 | + <el-table-column label="当前节点" align="left" show-overflow-tooltip class-name="cell-nowrap" min-width="120"> | |
| 137 | + <template slot-scope="scope"> | |
| 138 | + <el-tag :type="auditNodeTagType(scope.row)" size="mini" effect="plain"> | |
| 139 | + {{ auditNodeLabel(scope.row) }} | |
| 140 | + </el-tag> | |
| 141 | + </template> | |
| 142 | + </el-table-column> | |
| 136 | 143 | <el-table-column label="入库仓库" prop="rkck" align="left" min-width="120" show-overflow-tooltip class-name="cell-nowrap"> |
| 137 | 144 | <template slot-scope="scope"> |
| 138 | 145 | <span class="wt-cgrkd-cell"> |
| ... | ... | @@ -248,7 +255,7 @@ import { |
| 248 | 255 | } from './cgrkd-export-xlsx' |
| 249 | 256 | import { previewDataInterface } from '@/api/systemData/dataInterface' |
| 250 | 257 | import { getAccountSelector } from '@/api/extend/wtAccount' |
| 251 | - import { getWtDjztDisplayLabel, getWtDjztTagType, canWtBillEdit, canWtBillDelete } from '@/utils/wtDjztDisplay' | |
| 258 | + import { getWtDjztDisplayLabel, getWtDjztTagType, getWtAuditNodeLabel, getWtAuditNodeTagType, canWtBillEdit, canWtBillDelete } from '@/utils/wtDjztDisplay' | |
| 252 | 259 | import editDjrqListMixin from '@/mixins/editDjrqListMixin' |
| 253 | 260 | export default { |
| 254 | 261 | components: { NCCForm, DetailView }, |
| ... | ... | @@ -299,6 +306,7 @@ import { |
| 299 | 306 | { prop: 'bz', label: '备注' }, |
| 300 | 307 | { prop: 'djlx', label: '单据类型' }, |
| 301 | 308 | { prop: 'djzt', label: '审核状态' }, |
| 309 | + { prop: 'auditNode', label: '当前节点' }, | |
| 302 | 310 | ], |
| 303 | 311 | detailExportColumnList: CGRKD_DETAIL_EXPORT_COLUMNS, |
| 304 | 312 | cjckOptions : [], |
| ... | ... | @@ -342,6 +350,14 @@ import { |
| 342 | 350 | djztTagType(djzt) { |
| 343 | 351 | return getWtDjztTagType(djzt) |
| 344 | 352 | }, |
| 353 | + auditNodeLabel(row) { | |
| 354 | + if (!row) return '无' | |
| 355 | + return getWtAuditNodeLabel(row.djzt || row.shzt, row.spbz) || '无' | |
| 356 | + }, | |
| 357 | + auditNodeTagType(row) { | |
| 358 | + if (!row) return 'info' | |
| 359 | + return getWtAuditNodeTagType(row.djzt || row.shzt, row.spbz) | |
| 360 | + }, | |
| 345 | 361 | |
| 346 | 362 | /** 草稿/待审核/审核不通过可编辑(统一走 canWtBillEdit) */ |
| 347 | 363 | canEditRow(row) { | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/views/wtHy/edit-bz-dialog.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <el-dialog | |
| 3 | + title="修改备注" | |
| 4 | + :visible.sync="visible" | |
| 5 | + width="480px" | |
| 6 | + append-to-body | |
| 7 | + :close-on-click-modal="false" | |
| 8 | + @closed="handleClosed" | |
| 9 | + > | |
| 10 | + <el-form | |
| 11 | + ref="formRef" | |
| 12 | + :model="form" | |
| 13 | + label-width="80px" | |
| 14 | + size="small" | |
| 15 | + @submit.native.prevent | |
| 16 | + > | |
| 17 | + <el-form-item label="客户"> | |
| 18 | + <span class="cell-nowrap">{{ memberLabel || '无' }}</span> | |
| 19 | + </el-form-item> | |
| 20 | + <el-form-item label="备注"> | |
| 21 | + <el-input | |
| 22 | + v-model="form.bz" | |
| 23 | + type="textarea" | |
| 24 | + :rows="4" | |
| 25 | + maxlength="500" | |
| 26 | + show-word-limit | |
| 27 | + placeholder="请输入备注" | |
| 28 | + /> | |
| 29 | + </el-form-item> | |
| 30 | + </el-form> | |
| 31 | + <div slot="footer"> | |
| 32 | + <el-button size="small" @click="visible = false">取消</el-button> | |
| 33 | + <el-button type="primary" size="small" :loading="submitting" @click="submit">保存</el-button> | |
| 34 | + </div> | |
| 35 | + </el-dialog> | |
| 36 | +</template> | |
| 37 | + | |
| 38 | +<script> | |
| 39 | +import { WtHyUpdateBz } from '@/api/wtHy' | |
| 40 | + | |
| 41 | +export default { | |
| 42 | + name: 'EditBzDialog', | |
| 43 | + data() { | |
| 44 | + return { | |
| 45 | + visible: false, | |
| 46 | + submitting: false, | |
| 47 | + hyId: '', | |
| 48 | + memberLabel: '', | |
| 49 | + form: { | |
| 50 | + bz: '' | |
| 51 | + } | |
| 52 | + } | |
| 53 | + }, | |
| 54 | + methods: { | |
| 55 | + open(row) { | |
| 56 | + if (!row || !row.id) return | |
| 57 | + this.hyId = String(row.id) | |
| 58 | + const name = String(row.xm || '').trim() | |
| 59 | + const no = String(row.khbh || '').trim() | |
| 60 | + const phone = String(row.sjh || '').trim() | |
| 61 | + this.memberLabel = [no, name, phone].filter(Boolean).join(' / ') || this.hyId | |
| 62 | + this.form.bz = row.bz != null ? String(row.bz) : '' | |
| 63 | + this.visible = true | |
| 64 | + }, | |
| 65 | + handleClosed() { | |
| 66 | + this.hyId = '' | |
| 67 | + this.memberLabel = '' | |
| 68 | + this.form.bz = '' | |
| 69 | + this.submitting = false | |
| 70 | + }, | |
| 71 | + submit() { | |
| 72 | + if (!this.hyId || this.submitting) return | |
| 73 | + this.submitting = true | |
| 74 | + WtHyUpdateBz({ id: this.hyId, bz: this.form.bz }) | |
| 75 | + .then(() => { | |
| 76 | + this.$message.success('备注已保存') | |
| 77 | + this.visible = false | |
| 78 | + this.$emit('success') | |
| 79 | + }) | |
| 80 | + .catch(() => {}) | |
| 81 | + .finally(() => { | |
| 82 | + this.submitting = false | |
| 83 | + }) | |
| 84 | + } | |
| 85 | + } | |
| 86 | +} | |
| 87 | +</script> | |
| 88 | + | |
| 89 | +<style scoped> | |
| 90 | +.cell-nowrap { | |
| 91 | + white-space: nowrap; | |
| 92 | +} | |
| 93 | +</style> | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/views/wtHy/index.vue
| ... | ... | @@ -244,7 +244,7 @@ |
| 244 | 244 | <el-table-column prop="shdz" label="企业地址" align="left" min-width="160" show-overflow-tooltip /> |
| 245 | 245 | <el-table-column prop="khyh" label="开户银行" align="left" min-width="140" show-overflow-tooltip /> |
| 246 | 246 | <el-table-column prop="yhzh" label="银行账户" align="left" min-width="160" show-overflow-tooltip /> |
| 247 | - <el-table-column label="操作" fixed="right" width="190"> | |
| 247 | + <el-table-column label="操作" fixed="right" width="260"> | |
| 248 | 248 | <template slot-scope="scope"> |
| 249 | 249 | <el-button type="text" @click="openDetail(scope.row.id)">详情</el-button> |
| 250 | 250 | <el-button type="text" @click="openKkjlHistory(scope.row)">购卡记录</el-button> |
| ... | ... | @@ -252,6 +252,12 @@ |
| 252 | 252 | >编辑</el-button |
| 253 | 253 | > |
| 254 | 254 | <el-button |
| 255 | + v-has="'btn_editBz'" | |
| 256 | + type="text" | |
| 257 | + @click="openEditBz(scope.row)" | |
| 258 | + >修改备注</el-button | |
| 259 | + > | |
| 260 | + <el-button | |
| 255 | 261 | type="text" |
| 256 | 262 | @click="handleDel(scope.row.id)" |
| 257 | 263 | class="NCC-table-delBtn" |
| ... | ... | @@ -273,6 +279,7 @@ |
| 273 | 279 | <ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download" /> |
| 274 | 280 | <WtHyDetailView ref="hyDetailRef" /> |
| 275 | 281 | <KkjlHistoryDialog ref="kkjlHistoryRef" /> |
| 282 | + <EditBzDialog ref="editBzRef" @success="initData" /> | |
| 276 | 283 | </div> |
| 277 | 284 | </template> |
| 278 | 285 | <script> |
| ... | ... | @@ -284,9 +291,10 @@ import ImportForm from "./ImportForm"; |
| 284 | 291 | import ExportBox from "./ExportBox"; |
| 285 | 292 | import WtHyDetailView from "./detail-view"; |
| 286 | 293 | import KkjlHistoryDialog from "./kkjl-history-dialog"; |
| 294 | +import EditBzDialog from "./edit-bz-dialog"; | |
| 287 | 295 | import { WtHyTemplateDownload } from "@/api/wtHy"; |
| 288 | 296 | export default { |
| 289 | - components: { NCCForm, ImportForm, ExportBox, WtHyDetailView, KkjlHistoryDialog }, | |
| 297 | + components: { NCCForm, ImportForm, ExportBox, WtHyDetailView, KkjlHistoryDialog, EditBzDialog }, | |
| 290 | 298 | data() { |
| 291 | 299 | return { |
| 292 | 300 | showAll: false, |
| ... | ... | @@ -495,6 +503,18 @@ export default { |
| 495 | 503 | } |
| 496 | 504 | }, |
| 497 | 505 | |
| 506 | + openEditBz(row) { | |
| 507 | + if (!row || !row.id) return; | |
| 508 | + const ref = this.$refs.editBzRef; | |
| 509 | + if (ref) { | |
| 510 | + ref.open(row); | |
| 511 | + } else { | |
| 512 | + this.$nextTick(() => { | |
| 513 | + if (this.$refs.editBzRef) this.$refs.editBzRef.open(row); | |
| 514 | + }); | |
| 515 | + } | |
| 516 | + }, | |
| 517 | + | |
| 498 | 518 | formatQdCell(qd) { |
| 499 | 519 | const text = dynamicText(qd, this.qdOptions); |
| 500 | 520 | return text || "无"; | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/views/wtPd/DetailView.vue
| ... | ... | @@ -42,13 +42,6 @@ |
| 42 | 42 | <div class="wt-pd-kpi-card__value cell-nowrap">{{ cellText(detail.ckmc || detail.ckId) }}</div> |
| 43 | 43 | </div> |
| 44 | 44 | </div> |
| 45 | - <div class="wt-pd-kpi-card wt-pd-kpi-card--muted"> | |
| 46 | - <i class="el-icon-coin wt-pd-kpi-card__icon" /> | |
| 47 | - <div class="wt-pd-kpi-card__body"> | |
| 48 | - <div class="wt-pd-kpi-card__label">账面总金额</div> | |
| 49 | - <div class="wt-pd-kpi-card__value">{{ formatMoney(bookTotalAmount) }}</div> | |
| 50 | - </div> | |
| 51 | - </div> | |
| 52 | 45 | <div class="wt-pd-kpi-card wt-pd-kpi-card--accent"> |
| 53 | 46 | <i class="el-icon-data-analysis wt-pd-kpi-card__icon" /> |
| 54 | 47 | <div class="wt-pd-kpi-card__body"> |
| ... | ... | @@ -111,63 +104,98 @@ |
| 111 | 104 | <!-- 筛选条 --> |
| 112 | 105 | <div class="wt-pd-detail__filter-toolbar"> |
| 113 | 106 | <div class="NCC-common-search-box wt-pd-detail__mx-filter"> |
| 114 | -<el-form @submit.native.prevent size="small" label-width="80px"> | |
| 115 | - <el-row :gutter="16"> | |
| 116 | -<el-col :span="6"> | |
| 117 | - <el-form-item label="商品分类"> | |
| 118 | - <el-select | |
| 119 | - v-model="mxFilter.plId" | |
| 120 | - placeholder="全部分类" | |
| 121 | - clearable | |
| 122 | - filterable | |
| 123 | - style="width: 100%;" | |
| 124 | - @change="onMxFilterChange" | |
| 125 | - > | |
| 126 | - <el-option | |
| 127 | - v-for="item in plOptions" | |
| 128 | - :key="item.id || item.F_Id" | |
| 129 | - :label="item.pathLabel || item.F_Plmc || item.plmc" | |
| 130 | - :value="item.id || item.F_Id" | |
| 131 | - /> | |
| 132 | - </el-select> | |
| 133 | - </el-form-item> | |
| 134 | - </el-col><el-col :span="6"> | |
| 135 | - <el-form-item label="关键字"> | |
| 136 | - <el-input | |
| 137 | - v-model="mxFilter.keyword" | |
| 138 | - placeholder="编码 / 名称" | |
| 139 | - clearable | |
| 140 | - @keyup.enter.native="onMxFilterChange" | |
| 141 | - @clear="onMxFilterChange" | |
| 142 | - /> | |
| 143 | - </el-form-item> | |
| 144 | - </el-col><el-col :span="6"> | |
| 145 | - <el-form-item label="定位商品"> | |
| 146 | - <el-select | |
| 147 | - v-model="mxFilter.spbh" | |
| 148 | - placeholder="选择商品" | |
| 149 | - clearable | |
| 150 | - filterable | |
| 151 | - style="width: 100%;" | |
| 152 | - @change="onMxFilterChange" | |
| 153 | - > | |
| 154 | - <el-option | |
| 155 | - v-for="item in mxProductSelectOptions" | |
| 156 | - :key="item.value" | |
| 157 | - :label="item.label" | |
| 158 | - :value="item.value" | |
| 107 | + <el-form @submit.native.prevent size="small"> | |
| 108 | + <el-row :gutter="16"> | |
| 109 | + <el-col :span="6"> | |
| 110 | + <el-form-item label="商品分类"> | |
| 111 | + <el-select | |
| 112 | + v-model="mxFilter.plId" | |
| 113 | + placeholder="全部分类" | |
| 114 | + clearable | |
| 115 | + filterable | |
| 116 | + style="width: 100%;" | |
| 117 | + @change="onMxFilterChange" | |
| 118 | + > | |
| 119 | + <el-option | |
| 120 | + v-for="item in plOptions" | |
| 121 | + :key="item.id || item.F_Id" | |
| 122 | + :label="item.pathLabel || item.F_Plmc || item.plmc" | |
| 123 | + :value="item.id || item.F_Id" | |
| 124 | + /> | |
| 125 | + </el-select> | |
| 126 | + </el-form-item> | |
| 127 | + </el-col> | |
| 128 | + <el-col :span="6"> | |
| 129 | + <el-form-item label="关键字"> | |
| 130 | + <el-input | |
| 131 | + v-model="mxFilter.keyword" | |
| 132 | + placeholder="编码 / 名称" | |
| 133 | + clearable | |
| 134 | + @input="onMxKeywordInput" | |
| 135 | + @keyup.enter.native="onMxFilterChange" | |
| 136 | + @clear="onMxFilterChange" | |
| 159 | 137 | /> |
| 160 | - </el-select> | |
| 161 | - </el-form-item> | |
| 162 | - </el-col><el-col class="NCC-common-search-btns" :span="6"> | |
| 163 | - <el-form-item label-width="0"> | |
| 164 | - <el-button type="primary" icon="el-icon-search" :loading="mxFilterLoading" @click="onMxFilterChange">筛选</el-button> | |
| 165 | - <el-button icon="el-icon-refresh-right" :disabled="mxFilterLoading" @click="resetMxFilter">重置</el-button> | |
| 166 | - </el-form-item> | |
| 167 | - </el-col> | |
| 168 | - </el-row> | |
| 169 | - </el-form> | |
| 170 | - </div> | |
| 138 | + </el-form-item> | |
| 139 | + </el-col> | |
| 140 | + <el-col :span="6"> | |
| 141 | + <el-form-item label="期间变动"> | |
| 142 | + <el-select | |
| 143 | + v-model="mxFilter.periodChange" | |
| 144 | + placeholder="全部" | |
| 145 | + clearable | |
| 146 | + style="width: 100%;" | |
| 147 | + @change="onMxFilterChange" | |
| 148 | + > | |
| 149 | + <el-option label="全部" value="" /> | |
| 150 | + <el-option label="有变动" value="1" /> | |
| 151 | + <el-option label="无变动" value="0" /> | |
| 152 | + </el-select> | |
| 153 | + </el-form-item> | |
| 154 | + </el-col> | |
| 155 | + <el-col class="NCC-common-search-btns" :span="6"> | |
| 156 | + <el-form-item label-width="0"> | |
| 157 | + <el-button type="primary" size="small" icon="el-icon-search" @click="onMxFilterChange">筛选</el-button> | |
| 158 | + <el-button size="small" icon="el-icon-refresh-right" @click="resetMxFilter">重置</el-button> | |
| 159 | + <el-button | |
| 160 | + v-if="!showAll" | |
| 161 | + type="text" | |
| 162 | + size="small" | |
| 163 | + icon="el-icon-arrow-down" | |
| 164 | + @click="showAll = true" | |
| 165 | + >展开</el-button> | |
| 166 | + <el-button | |
| 167 | + v-else | |
| 168 | + type="text" | |
| 169 | + size="small" | |
| 170 | + icon="el-icon-arrow-up" | |
| 171 | + @click="showAll = false" | |
| 172 | + >收起</el-button> | |
| 173 | + </el-form-item> | |
| 174 | + </el-col> | |
| 175 | + </el-row> | |
| 176 | + <el-row v-if="showAll" :gutter="16"> | |
| 177 | + <el-col :span="6"> | |
| 178 | + <el-form-item label="定位商品"> | |
| 179 | + <el-select | |
| 180 | + v-model="mxFilter.spbh" | |
| 181 | + placeholder="选择商品" | |
| 182 | + clearable | |
| 183 | + filterable | |
| 184 | + style="width: 100%;" | |
| 185 | + @change="onMxFilterChange" | |
| 186 | + > | |
| 187 | + <el-option | |
| 188 | + v-for="item in mxProductSelectOptions" | |
| 189 | + :key="item.value" | |
| 190 | + :label="item.label" | |
| 191 | + :value="item.value" | |
| 192 | + /> | |
| 193 | + </el-select> | |
| 194 | + </el-form-item> | |
| 195 | + </el-col> | |
| 196 | + </el-row> | |
| 197 | + </el-form> | |
| 198 | + </div> | |
| 171 | 199 | <div class="wt-pd-detail__filter-meta"> |
| 172 | 200 | <span class="wt-pd-detail__mx-filter-hint">大批量可先选分类再盘</span> |
| 173 | 201 | <span class="wt-pd-detail__mx-filter-tip"> |
| ... | ... | @@ -204,7 +232,7 @@ |
| 204 | 232 | </span> |
| 205 | 233 | </template> |
| 206 | 234 | </el-table-column> |
| 207 | - <el-table-column label="商品名称" min-width="150" show-overflow-tooltip class-name="cell-nowrap"> | |
| 235 | + <el-table-column label="商品名称" width="280" show-overflow-tooltip class-name="cell-nowrap"> | |
| 208 | 236 | <template slot-scope="scope"> |
| 209 | 237 | <span |
| 210 | 238 | class="cell-nowrap" |
| ... | ... | @@ -233,13 +261,7 @@ |
| 233 | 261 | <template v-else>{{ displayTableNum(scope.row.ckc) }}</template> |
| 234 | 262 | </template> |
| 235 | 263 | </el-table-column> |
| 236 | - <el-table-column label="成本均价" width="96" align="right" show-overflow-tooltip> | |
| 237 | - <template slot-scope="scope"> | |
| 238 | - <span v-if="scope.row.isUnknown" class="text-muted-light"> </span> | |
| 239 | - <template v-else>{{ formatTableMoney(scope.row.cbj) }}</template> | |
| 240 | - </template> | |
| 241 | - </el-table-column> | |
| 242 | - <el-table-column width="140" align="center" show-overflow-tooltip class-name="cell-nowrap"> | |
| 264 | + <el-table-column min-width="200" align="left" show-overflow-tooltip class-name="cell-nowrap wt-pd-col-period"> | |
| 243 | 265 | <template slot="header"> |
| 244 | 266 | <span>期间变动</span> |
| 245 | 267 | <el-tooltip |
| ... | ... | @@ -251,20 +273,124 @@ |
| 251 | 273 | </template> |
| 252 | 274 | <template slot-scope="scope"> |
| 253 | 275 | <template v-if="hasPeriodSaleActivity(scope.row)"> |
| 254 | - <el-tag | |
| 276 | + <div | |
| 255 | 277 | v-if="periodQtyNum(scope.row.saleOutQty) > 0" |
| 256 | - class="wt-pd-period-tag" | |
| 257 | - type="warning" | |
| 258 | - size="mini" | |
| 259 | - effect="plain" | |
| 260 | - >出库 {{ displayPeriodQty(scope.row.saleOutQty) }}</el-tag> | |
| 261 | - <el-tag | |
| 278 | + class="wt-pd-period-line cell-nowrap" | |
| 279 | + > | |
| 280 | + <el-tag | |
| 281 | + class="wt-pd-period-tag" | |
| 282 | + type="warning" | |
| 283 | + size="mini" | |
| 284 | + effect="plain" | |
| 285 | + >{{ periodSummaryTagText(scope.row, 'out') }}</el-tag> | |
| 286 | + <el-popover | |
| 287 | + v-if="periodSaleOutBills(scope.row).length" | |
| 288 | + placement="left-start" | |
| 289 | + trigger="click" | |
| 290 | + width="360" | |
| 291 | + popper-class="wt-pd-period-bills-popover" | |
| 292 | + > | |
| 293 | + <div class="wt-pd-period-popover wt-pd-period-popover--out"> | |
| 294 | + <div class="wt-pd-period-popover__header"> | |
| 295 | + <div class="wt-pd-period-popover__header-main"> | |
| 296 | + <span class="wt-pd-period-popover__accent wt-pd-period-popover__accent--out" /> | |
| 297 | + <i class="el-icon-sold-out wt-pd-period-popover__icon wt-pd-period-popover__icon--out" /> | |
| 298 | + <span class="wt-pd-period-popover__title-text">销售出库</span> | |
| 299 | + </div> | |
| 300 | + <span class="wt-pd-period-popover__badge">{{ periodSaleOutBills(scope.row).length }} 笔</span> | |
| 301 | + </div> | |
| 302 | + <div class="wt-pd-period-popover__summary"> | |
| 303 | + <span class="wt-pd-period-popover__summary-label">数量合计</span> | |
| 304 | + <strong class="wt-pd-period-popover__summary-value">{{ displayPeriodQty(periodBillQtySum(periodSaleOutBills(scope.row))) }}</strong> | |
| 305 | + <p v-if="periodAuditMismatch(scope.row, 'out')" class="wt-pd-period-popover__warn"> | |
| 306 | + <i class="el-icon-warning-outline" /> | |
| 307 | + 审计累计与单据合计不一致,以单据为准 | |
| 308 | + </p> | |
| 309 | + </div> | |
| 310 | + <ul class="wt-pd-period-popover__list"> | |
| 311 | + <li | |
| 312 | + v-for="(bill, idx) in periodSaleOutBills(scope.row)" | |
| 313 | + :key="'out-' + (bill.id || idx)" | |
| 314 | + class="wt-pd-period-popover__item" | |
| 315 | + > | |
| 316 | + <span class="wt-pd-period-popover__idx">{{ idx + 1 }}</span> | |
| 317 | + <a | |
| 318 | + class="wt-pd-period-bill-link" | |
| 319 | + href="javascript:void(0)" | |
| 320 | + @click.stop="goXsckd(bill.id)" | |
| 321 | + >{{ displayPeriodBillId(bill) }}</a> | |
| 322 | + <span v-if="bill.sl > 0" class="wt-pd-period-popover__qty-pill">×{{ displayPeriodQty(bill.sl) }}</span> | |
| 323 | + </li> | |
| 324 | + </ul> | |
| 325 | + <div class="wt-pd-period-popover__footer">点击单号可打开详情</div> | |
| 326 | + </div> | |
| 327 | + <a | |
| 328 | + slot="reference" | |
| 329 | + class="wt-pd-period-bills-trigger" | |
| 330 | + href="javascript:void(0)" | |
| 331 | + @click.stop | |
| 332 | + >查看单据</a> | |
| 333 | + </el-popover> | |
| 334 | + </div> | |
| 335 | + <div | |
| 262 | 336 | v-if="periodQtyNum(scope.row.saleReturnQty) > 0" |
| 263 | - class="wt-pd-period-tag" | |
| 264 | - type="success" | |
| 265 | - size="mini" | |
| 266 | - effect="plain" | |
| 267 | - >退货 {{ displayPeriodQty(scope.row.saleReturnQty) }}</el-tag> | |
| 337 | + class="wt-pd-period-line cell-nowrap" | |
| 338 | + > | |
| 339 | + <el-tag | |
| 340 | + class="wt-pd-period-tag" | |
| 341 | + type="success" | |
| 342 | + size="mini" | |
| 343 | + effect="plain" | |
| 344 | + >{{ periodSummaryTagText(scope.row, 'ret') }}</el-tag> | |
| 345 | + <el-popover | |
| 346 | + v-if="periodSaleReturnBills(scope.row).length" | |
| 347 | + placement="left-start" | |
| 348 | + trigger="click" | |
| 349 | + width="360" | |
| 350 | + popper-class="wt-pd-period-bills-popover" | |
| 351 | + > | |
| 352 | + <div class="wt-pd-period-popover wt-pd-period-popover--ret"> | |
| 353 | + <div class="wt-pd-period-popover__header"> | |
| 354 | + <div class="wt-pd-period-popover__header-main"> | |
| 355 | + <span class="wt-pd-period-popover__accent wt-pd-period-popover__accent--ret" /> | |
| 356 | + <i class="el-icon-refresh-left wt-pd-period-popover__icon wt-pd-period-popover__icon--ret" /> | |
| 357 | + <span class="wt-pd-period-popover__title-text">销售退货</span> | |
| 358 | + </div> | |
| 359 | + <span class="wt-pd-period-popover__badge">{{ periodSaleReturnBills(scope.row).length }} 笔</span> | |
| 360 | + </div> | |
| 361 | + <div class="wt-pd-period-popover__summary"> | |
| 362 | + <span class="wt-pd-period-popover__summary-label">数量合计</span> | |
| 363 | + <strong class="wt-pd-period-popover__summary-value">{{ displayPeriodQty(periodBillQtySum(periodSaleReturnBills(scope.row))) }}</strong> | |
| 364 | + <p v-if="periodAuditMismatch(scope.row, 'ret')" class="wt-pd-period-popover__warn"> | |
| 365 | + <i class="el-icon-warning-outline" /> | |
| 366 | + 审计累计与单据合计不一致,以单据为准 | |
| 367 | + </p> | |
| 368 | + </div> | |
| 369 | + <ul class="wt-pd-period-popover__list"> | |
| 370 | + <li | |
| 371 | + v-for="(bill, idx) in periodSaleReturnBills(scope.row)" | |
| 372 | + :key="'ret-' + (bill.id || idx)" | |
| 373 | + class="wt-pd-period-popover__item" | |
| 374 | + > | |
| 375 | + <span class="wt-pd-period-popover__idx">{{ idx + 1 }}</span> | |
| 376 | + <a | |
| 377 | + class="wt-pd-period-bill-link" | |
| 378 | + href="javascript:void(0)" | |
| 379 | + @click.stop="goXsckd(bill.id)" | |
| 380 | + >{{ displayPeriodBillId(bill) }}</a> | |
| 381 | + <span v-if="bill.sl > 0" class="wt-pd-period-popover__qty-pill">×{{ displayPeriodQty(bill.sl) }}</span> | |
| 382 | + </li> | |
| 383 | + </ul> | |
| 384 | + <div class="wt-pd-period-popover__footer">点击单号可打开详情</div> | |
| 385 | + </div> | |
| 386 | + <a | |
| 387 | + slot="reference" | |
| 388 | + class="wt-pd-period-bills-trigger" | |
| 389 | + href="javascript:void(0)" | |
| 390 | + @click.stop | |
| 391 | + >查看单据</a> | |
| 392 | + </el-popover> | |
| 393 | + </div> | |
| 268 | 394 | </template> |
| 269 | 395 | <span v-else class="text-muted-light"> </span> |
| 270 | 396 | </template> |
| ... | ... | @@ -359,9 +485,10 @@ |
| 359 | 485 | </div> |
| 360 | 486 | </div> |
| 361 | 487 | </div> |
| 362 | - <!-- 报损/报溢单详情弹窗(本页内部弹出,避免被菜单框架劫持路由) --> | |
| 488 | + <!-- 报损/报溢/销售出库单详情弹窗(本页内部弹出,避免被菜单框架劫持路由) --> | |
| 363 | 489 | <WtBsdDetailView ref="bsdDv" /> |
| 364 | 490 | <WtBydDetailView ref="bydDv" /> |
| 491 | + <WtXsckdDetailView ref="xsckdDv" /> | |
| 365 | 492 | <el-dialog |
| 366 | 493 | title="新增商品(ERP 商品档案)" |
| 367 | 494 | :visible.sync="addProductDialogVisible" |
| ... | ... | @@ -417,11 +544,11 @@ import { |
| 417 | 544 | saveWtPdMx, |
| 418 | 545 | completeWtPd, |
| 419 | 546 | cancelWtPd, |
| 420 | - scanWtPdProduct, | |
| 421 | - filterWtPdMx | |
| 547 | + scanWtPdProduct | |
| 422 | 548 | } from '@/api/extend/wtPd' |
| 423 | 549 | import WtBsdDetailView from '@/views/wtBsd/detail-view.vue' |
| 424 | 550 | import WtBydDetailView from '@/views/wtByd/detail-view.vue' |
| 551 | +import WtXsckdDetailView from '@/views/wtXsckd/detail-view.vue' | |
| 425 | 552 | import SerialNumberSelect from '@/views/wtXsckd/SerialNumberSelect.vue' |
| 426 | 553 | import serialNumberRowMixin from '@/mixins/serialNumberRowMixin' |
| 427 | 554 | |
| ... | ... | @@ -429,7 +556,7 @@ let localKeySeq = 1 |
| 429 | 556 | |
| 430 | 557 | export default { |
| 431 | 558 | name: 'WtPdDetailView', |
| 432 | - components: { WtBsdDetailView, WtBydDetailView, SerialNumberSelect }, | |
| 559 | + components: { WtBsdDetailView, WtBydDetailView, WtXsckdDetailView, SerialNumberSelect }, | |
| 433 | 560 | mixins: [serialNumberRowMixin], |
| 434 | 561 | data() { |
| 435 | 562 | // 系统外表单:hand / scan |
| ... | ... | @@ -471,13 +598,13 @@ export default { |
| 471 | 598 | plOptions: [], |
| 472 | 599 | plDescendantMap: {}, |
| 473 | 600 | productPlMap: {}, |
| 601 | + showAll: false, | |
| 474 | 602 | mxFilter: { |
| 475 | 603 | plId: '', |
| 476 | 604 | keyword: '', |
| 477 | - spbh: '' | |
| 605 | + spbh: '', | |
| 606 | + periodChange: '' | |
| 478 | 607 | }, |
| 479 | - mxFilterMatchedIds: null, | |
| 480 | - mxFilterLoading: false, | |
| 481 | 608 | ykjeSummary: 0, |
| 482 | 609 | mxTableMaxHeight: 360, |
| 483 | 610 | _mxTableResizeObs: null |
| ... | ... | @@ -491,16 +618,35 @@ export default { |
| 491 | 618 | return this.normStatus(this.detail.status) === '进行中' |
| 492 | 619 | }, |
| 493 | 620 | mxFilterActive() { |
| 494 | - return !!(this.mxFilter.plId || String(this.mxFilter.keyword || '').trim() || this.mxFilter.spbh) | |
| 621 | + const f = this.mxFilter | |
| 622 | + return !!( | |
| 623 | + f.plId || | |
| 624 | + String(f.keyword || '').trim() || | |
| 625 | + f.spbh || | |
| 626 | + f.periodChange === '1' || | |
| 627 | + f.periodChange === '0' | |
| 628 | + ) | |
| 495 | 629 | }, |
| 496 | 630 | filteredMxList() { |
| 497 | 631 | if (!Array.isArray(this.mxList)) return [] |
| 498 | 632 | if (!this.mxFilterActive) return this.mxList |
| 499 | - const idSet = this.mxFilterMatchedIds | |
| 500 | - if (!idSet) return this.mxList | |
| 501 | - return this.mxList.filter(r => { | |
| 502 | - const id = r && r.id != null ? String(r.id) : '' | |
| 503 | - return id && idSet.has(id) | |
| 633 | + const { plId, keyword, spbh, periodChange } = this.mxFilter | |
| 634 | + const kw = String(keyword || '').trim().toLowerCase() | |
| 635 | + const spbhFilter = spbh ? String(spbh) : '' | |
| 636 | + let plIdSet = null | |
| 637 | + if (plId) { | |
| 638 | + const desc = this.plDescendantMap[String(plId)] | |
| 639 | + plIdSet = new Set( | |
| 640 | + Array.isArray(desc) && desc.length ? desc.map(x => String(x)) : [String(plId)] | |
| 641 | + ) | |
| 642 | + } | |
| 643 | + return this.mxList.filter(row => { | |
| 644 | + if (plIdSet && !this.rowMatchesPlFilter(row, plIdSet)) return false | |
| 645 | + if (spbhFilter && String(row.spbh || '') !== spbhFilter) return false | |
| 646 | + if (kw && !this.rowMatchesKeywordFilter(row, kw)) return false | |
| 647 | + if (periodChange === '1' && !this.hasPeriodSaleActivity(row)) return false | |
| 648 | + if (periodChange === '0' && this.hasPeriodSaleActivity(row)) return false | |
| 649 | + return true | |
| 504 | 650 | }) |
| 505 | 651 | }, |
| 506 | 652 | mxProductSelectOptions() { |
| ... | ... | @@ -549,20 +695,6 @@ export default { |
| 549 | 695 | this.addProductSelected && (this.addProductSelected.spxlhType || this.addProductSelected.F_SpxlhType) |
| 550 | 696 | ) |
| 551 | 697 | }, |
| 552 | - bookTotalAmount() { | |
| 553 | - if (this.detail.zmzje != null && this.detail.zmzje !== '') { | |
| 554 | - const n = Number(this.detail.zmzje) | |
| 555 | - if (!Number.isNaN(n)) return n | |
| 556 | - } | |
| 557 | - return (this.mxList || []).reduce((t, r) => { | |
| 558 | - if (r.isUnknown) return t | |
| 559 | - const ckc = Number(r.ckc) | |
| 560 | - const cbj = Number(r.cbj) | |
| 561 | - const q = Number.isNaN(ckc) ? 0 : ckc | |
| 562 | - const p = Number.isNaN(cbj) ? 0 : cbj | |
| 563 | - return t + q * p | |
| 564 | - }, 0) | |
| 565 | - }, | |
| 566 | 698 | filledMxCount() { |
| 567 | 699 | return Math.max(0, (this.mxList || []).length - this.countUnfilledSjsl()) |
| 568 | 700 | }, |
| ... | ... | @@ -668,6 +800,10 @@ export default { |
| 668 | 800 | clearTimeout(this.focusScanTimer) |
| 669 | 801 | this.focusScanTimer = null |
| 670 | 802 | } |
| 803 | + if (this._mxKeywordDebounceTimer) { | |
| 804 | + clearTimeout(this._mxKeywordDebounceTimer) | |
| 805 | + this._mxKeywordDebounceTimer = null | |
| 806 | + } | |
| 671 | 807 | }, |
| 672 | 808 | bindKeys(on) { |
| 673 | 809 | const fn = this.onGlobalKeydown |
| ... | ... | @@ -752,6 +888,56 @@ export default { |
| 752 | 888 | if (!row || row.isUnknown) return false |
| 753 | 889 | return this.periodQtyNum(row.saleOutQty) > 0 || this.periodQtyNum(row.saleReturnQty) > 0 |
| 754 | 890 | }, |
| 891 | + normalizePeriodBillList(list) { | |
| 892 | + if (!Array.isArray(list)) return [] | |
| 893 | + return list | |
| 894 | + .map(item => { | |
| 895 | + if (!item || typeof item !== 'object') return null | |
| 896 | + const id = item.id != null ? String(item.id).trim() : '' | |
| 897 | + if (!id) return null | |
| 898 | + return { | |
| 899 | + id, | |
| 900 | + djlx: item.djlx != null ? String(item.djlx).trim() : '', | |
| 901 | + sl: this.periodQtyNum(item.sl) | |
| 902 | + } | |
| 903 | + }) | |
| 904 | + .filter(Boolean) | |
| 905 | + }, | |
| 906 | + periodSaleOutBills(row) { | |
| 907 | + return this.normalizePeriodBillList(row && row.saleOutBills) | |
| 908 | + }, | |
| 909 | + periodSaleReturnBills(row) { | |
| 910 | + return this.normalizePeriodBillList(row && row.saleReturnBills) | |
| 911 | + }, | |
| 912 | + periodBillQtySum(bills) { | |
| 913 | + if (!Array.isArray(bills) || !bills.length) return 0 | |
| 914 | + return bills.reduce((sum, b) => sum + this.periodQtyNum(b && b.sl), 0) | |
| 915 | + }, | |
| 916 | + periodAuditQty(row, type) { | |
| 917 | + if (!row) return 0 | |
| 918 | + return type === 'out' ? this.periodQtyNum(row.saleOutQty) : this.periodQtyNum(row.saleReturnQty) | |
| 919 | + }, | |
| 920 | + periodAuditMismatch(row, type) { | |
| 921 | + const bills = type === 'out' ? this.periodSaleOutBills(row) : this.periodSaleReturnBills(row) | |
| 922 | + if (!bills.length) return false | |
| 923 | + const billSum = this.periodBillQtySum(bills) | |
| 924 | + const auditQty = this.periodAuditQty(row, type) | |
| 925 | + return auditQty > 0 && billSum !== auditQty | |
| 926 | + }, | |
| 927 | + periodSummaryTagText(row, type) { | |
| 928 | + const prefix = type === 'out' ? '出库' : '退货' | |
| 929 | + const bills = type === 'out' ? this.periodSaleOutBills(row) : this.periodSaleReturnBills(row) | |
| 930 | + const auditQty = this.periodAuditQty(row, type) | |
| 931 | + if (bills.length) { | |
| 932 | + const qty = this.periodBillQtySum(bills) | |
| 933 | + return `${prefix} ${bills.length}笔 / 数量${this.displayPeriodQty(qty)}` | |
| 934 | + } | |
| 935 | + return `${prefix} 数量${this.displayPeriodQty(auditQty)}` | |
| 936 | + }, | |
| 937 | + displayPeriodBillId(bill) { | |
| 938 | + if (!bill) return '' | |
| 939 | + return bill.id || '' | |
| 940 | + }, | |
| 755 | 941 | moneyClass(v) { |
| 756 | 942 | const n = Number(v) |
| 757 | 943 | if (Number.isNaN(n) || n === 0) return '' |
| ... | ... | @@ -946,6 +1132,23 @@ export default { |
| 946 | 1132 | .filter(Boolean) |
| 947 | 1133 | .some(id => idSet.has(String(id))) |
| 948 | 1134 | }, |
| 1135 | + rowMatchesKeywordFilter(row, kw) { | |
| 1136 | + if (!row || !kw) return true | |
| 1137 | + const candidates = [] | |
| 1138 | + const spbm = this.displaySpbm(row) | |
| 1139 | + if (spbm && spbm !== '—' && spbm !== '无') candidates.push(spbm) | |
| 1140 | + const spmc = this.displaySpmc(row) | |
| 1141 | + if (spmc && spmc !== '—' && spmc !== '无') candidates.push(spmc) | |
| 1142 | + if (row.spbh != null && String(row.spbh).trim()) candidates.push(String(row.spbh)) | |
| 1143 | + return candidates.some(c => String(c).toLowerCase().includes(kw)) | |
| 1144 | + }, | |
| 1145 | + onMxKeywordInput() { | |
| 1146 | + if (this._mxKeywordDebounceTimer) clearTimeout(this._mxKeywordDebounceTimer) | |
| 1147 | + this._mxKeywordDebounceTimer = setTimeout(() => { | |
| 1148 | + this._mxKeywordDebounceTimer = null | |
| 1149 | + this.onMxFilterChange() | |
| 1150 | + }, 250) | |
| 1151 | + }, | |
| 949 | 1152 | enrichMxFromArchive() { |
| 950 | 1153 | const map = {} |
| 951 | 1154 | ;(this.productOptions || []).forEach(p => { |
| ... | ... | @@ -976,49 +1179,15 @@ export default { |
| 976 | 1179 | }, |
| 977 | 1180 | onMxFilterChange() { |
| 978 | 1181 | this.mxPage = 1 |
| 979 | - const id = this.pdId | |
| 980 | - if (!id) return | |
| 981 | - if (!this.mxFilterActive) { | |
| 982 | - this.mxFilterMatchedIds = null | |
| 983 | - this.$nextTick(() => { | |
| 984 | - const tbl = this.$refs.mxTable | |
| 985 | - if (tbl && tbl.bodyWrapper) tbl.bodyWrapper.scrollTop = 0 | |
| 986 | - this.scheduleUpdateMxTableHeight() | |
| 987 | - }) | |
| 988 | - return | |
| 989 | - } | |
| 990 | - const seq = (this._mxFilterSeq = (this._mxFilterSeq || 0) + 1) | |
| 991 | - this.mxFilterLoading = true | |
| 992 | - filterWtPdMx(id, { | |
| 993 | - plId: this.mxFilter.plId || undefined, | |
| 994 | - keyword: String(this.mxFilter.keyword || '').trim() || undefined, | |
| 995 | - spbh: this.mxFilter.spbh || undefined | |
| 1182 | + this.$nextTick(() => { | |
| 1183 | + const tbl = this.$refs.mxTable | |
| 1184 | + if (tbl && tbl.bodyWrapper) tbl.bodyWrapper.scrollTop = 0 | |
| 1185 | + this.scheduleUpdateMxTableHeight() | |
| 996 | 1186 | }) |
| 997 | - .then(res => { | |
| 998 | - if (!this.pageActive || seq !== this._mxFilterSeq) return | |
| 999 | - const data = (res && res.data) || {} | |
| 1000 | - const ids = Array.isArray(data.mxIds) ? data.mxIds : [] | |
| 1001 | - this.mxFilterMatchedIds = new Set(ids.map(x => String(x))) | |
| 1002 | - }) | |
| 1003 | - .catch(() => { | |
| 1004 | - if (!this.pageActive || seq !== this._mxFilterSeq) return | |
| 1005 | - this.mxFilterMatchedIds = new Set() | |
| 1006 | - this.$message.error('明细筛选失败,请重试') | |
| 1007 | - }) | |
| 1008 | - .finally(() => { | |
| 1009 | - if (seq !== this._mxFilterSeq) return | |
| 1010 | - this.mxFilterLoading = false | |
| 1011 | - this.$nextTick(() => { | |
| 1012 | - const tbl = this.$refs.mxTable | |
| 1013 | - if (tbl && tbl.bodyWrapper) tbl.bodyWrapper.scrollTop = 0 | |
| 1014 | - this.scheduleUpdateMxTableHeight() | |
| 1015 | - }) | |
| 1016 | - }) | |
| 1017 | 1187 | }, |
| 1018 | 1188 | resetMxFilter() { |
| 1019 | - this.mxFilter = { plId: '', keyword: '', spbh: '' } | |
| 1020 | - this.mxFilterMatchedIds = null | |
| 1021 | - this.mxFilterLoading = false | |
| 1189 | + this.showAll = false | |
| 1190 | + this.mxFilter = { plId: '', keyword: '', spbh: '', periodChange: '' } | |
| 1022 | 1191 | this.mxPage = 1 |
| 1023 | 1192 | this.$nextTick(() => { |
| 1024 | 1193 | const tbl = this.$refs.mxTable |
| ... | ... | @@ -1347,6 +1516,17 @@ export default { |
| 1347 | 1516 | } |
| 1348 | 1517 | }) |
| 1349 | 1518 | }, |
| 1519 | + goXsckd(id) { | |
| 1520 | + if (!id) { | |
| 1521 | + this.$message.warning('单据编号为空') | |
| 1522 | + return | |
| 1523 | + } | |
| 1524 | + this.$nextTick(() => { | |
| 1525 | + if (this.$refs.xsckdDv && typeof this.$refs.xsckdDv.init === 'function') { | |
| 1526 | + this.$refs.xsckdDv.init(id) | |
| 1527 | + } | |
| 1528 | + }) | |
| 1529 | + }, | |
| 1350 | 1530 | ensureRowKeys() { |
| 1351 | 1531 | this.mxList.forEach(row => { |
| 1352 | 1532 | if (row.id == null && row.__localKey == null) { |
| ... | ... | @@ -1366,13 +1546,13 @@ export default { |
| 1366 | 1546 | const raw = Array.isArray(d.mxList) ? d.mxList : [] |
| 1367 | 1547 | this.mxList = raw.map(r => this.normalizeMxRow(r)) |
| 1368 | 1548 | this.mxPage = 1 |
| 1369 | - this.mxFilterMatchedIds = null | |
| 1370 | 1549 | this.ensureRowKeys() |
| 1371 | 1550 | this.scanTip = null |
| 1372 | 1551 | ;(this.mxList || []).forEach(row => { |
| 1373 | 1552 | if (row.pl && row.spbh) this.productPlMap[String(row.spbh)] = String(row.pl) |
| 1374 | 1553 | }) |
| 1375 | 1554 | this.enrichMxSpxlhTypes() |
| 1555 | + this.enrichMxFromArchive() | |
| 1376 | 1556 | this.refreshAllRowDiffCache() |
| 1377 | 1557 | }) |
| 1378 | 1558 | .catch(() => {}) |
| ... | ... | @@ -1420,6 +1600,7 @@ export default { |
| 1420 | 1600 | if (!this.pageActive) return |
| 1421 | 1601 | this.productOptions = Array.isArray(res.data) ? res.data : [] |
| 1422 | 1602 | this.enrichMxSpxlhTypes() |
| 1603 | + this.enrichMxFromArchive() | |
| 1423 | 1604 | this.refreshAllRowDiffCache() |
| 1424 | 1605 | }) |
| 1425 | 1606 | }, |
| ... | ... | @@ -1728,7 +1909,7 @@ export default { |
| 1728 | 1909 | }, |
| 1729 | 1910 | saveMx() { |
| 1730 | 1911 | if (!this.canEditMx || !this.pdId) return |
| 1731 | - if (!this.validateAllSjslFilled('保存')) return | |
| 1912 | + // 保存录入允许部分未盘(空白=未盘),后续可继续;「全部录完」仅在盘点完成时校验 | |
| 1732 | 1913 | this.saving = true |
| 1733 | 1914 | this.saveMxInternal({ silent: false, reload: true }) |
| 1734 | 1915 | .catch(() => {}) |
| ... | ... | @@ -2165,8 +2346,45 @@ export default { |
| 2165 | 2346 | cursor: help; |
| 2166 | 2347 | } |
| 2167 | 2348 | .wt-pd-period-tag { |
| 2168 | - margin: 0 2px; | |
| 2349 | + margin: 0 4px 0 0; | |
| 2169 | 2350 | vertical-align: middle; |
| 2351 | + flex-shrink: 0; | |
| 2352 | +} | |
| 2353 | +.wt-pd-period-line { | |
| 2354 | + display: inline-flex; | |
| 2355 | + align-items: center; | |
| 2356 | + max-width: 100%; | |
| 2357 | + line-height: 1.4; | |
| 2358 | + white-space: nowrap; | |
| 2359 | + & + .wt-pd-period-line { | |
| 2360 | + margin-top: 2px; | |
| 2361 | + } | |
| 2362 | +} | |
| 2363 | +.wt-pd-period-bills-trigger { | |
| 2364 | + flex-shrink: 0; | |
| 2365 | + margin-left: 2px; | |
| 2366 | + color: #409eff; | |
| 2367 | + font-size: 12px; | |
| 2368 | + text-decoration: none; | |
| 2369 | + cursor: pointer; | |
| 2370 | + white-space: nowrap; | |
| 2371 | + &:hover { | |
| 2372 | + text-decoration: underline; | |
| 2373 | + } | |
| 2374 | +} | |
| 2375 | +.wt-pd-period-bill-link { | |
| 2376 | + color: #409eff; | |
| 2377 | + text-decoration: none; | |
| 2378 | + cursor: pointer; | |
| 2379 | + &:hover { | |
| 2380 | + text-decoration: underline; | |
| 2381 | + } | |
| 2382 | +} | |
| 2383 | +.wt-pd-detail__mx-filter ::v-deep .NCC-common-search-btns .el-button--small { | |
| 2384 | + height: 32px; | |
| 2385 | + line-height: 30px; | |
| 2386 | + padding-top: 0; | |
| 2387 | + padding-bottom: 0; | |
| 2170 | 2388 | } |
| 2171 | 2389 | .wt-pd-add-r1c1-tip { |
| 2172 | 2390 | font-size: 13px; |
| ... | ... | @@ -2178,8 +2396,167 @@ export default { |
| 2178 | 2396 | } |
| 2179 | 2397 | </style> |
| 2180 | 2398 | |
| 2181 | -<!-- MessageBox 挂到 body,需非 scoped 才能作用到 customClass --> | |
| 2399 | +<!-- Popover / MessageBox 挂到 body,需非 scoped --> | |
| 2182 | 2400 | <style lang="scss"> |
| 2401 | +.wt-pd-period-bills-popover { | |
| 2402 | + padding: 0; | |
| 2403 | + border-radius: 8px; | |
| 2404 | + box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1); | |
| 2405 | + overflow: hidden; | |
| 2406 | +} | |
| 2407 | +.wt-pd-period-popover { | |
| 2408 | + &__header { | |
| 2409 | + display: flex; | |
| 2410 | + align-items: center; | |
| 2411 | + justify-content: space-between; | |
| 2412 | + gap: 10px; | |
| 2413 | + padding: 12px 14px 10px; | |
| 2414 | + background: #fafafa; | |
| 2415 | + border-bottom: 1px solid #ebeef5; | |
| 2416 | + } | |
| 2417 | + &__header-main { | |
| 2418 | + display: flex; | |
| 2419 | + align-items: center; | |
| 2420 | + gap: 8px; | |
| 2421 | + min-width: 0; | |
| 2422 | + } | |
| 2423 | + &__accent { | |
| 2424 | + width: 3px; | |
| 2425 | + height: 16px; | |
| 2426 | + border-radius: 2px; | |
| 2427 | + flex-shrink: 0; | |
| 2428 | + &--out { | |
| 2429 | + background: #e6a23c; | |
| 2430 | + } | |
| 2431 | + &--ret { | |
| 2432 | + background: #67c23a; | |
| 2433 | + } | |
| 2434 | + } | |
| 2435 | + &__title-text { | |
| 2436 | + font-size: 14px; | |
| 2437 | + font-weight: 600; | |
| 2438 | + color: #303133; | |
| 2439 | + line-height: 1.2; | |
| 2440 | + } | |
| 2441 | + &__icon { | |
| 2442 | + font-size: 16px; | |
| 2443 | + flex-shrink: 0; | |
| 2444 | + &--out { | |
| 2445 | + color: #e6a23c; | |
| 2446 | + } | |
| 2447 | + &--ret { | |
| 2448 | + color: #67c23a; | |
| 2449 | + } | |
| 2450 | + } | |
| 2451 | + &__badge { | |
| 2452 | + flex-shrink: 0; | |
| 2453 | + padding: 2px 8px; | |
| 2454 | + font-size: 12px; | |
| 2455 | + font-weight: 500; | |
| 2456 | + color: #606266; | |
| 2457 | + background: #fff; | |
| 2458 | + border: 1px solid #dcdfe6; | |
| 2459 | + border-radius: 10px; | |
| 2460 | + line-height: 1.4; | |
| 2461 | + } | |
| 2462 | + &__summary { | |
| 2463 | + display: flex; | |
| 2464 | + flex-wrap: wrap; | |
| 2465 | + align-items: center; | |
| 2466 | + gap: 6px 8px; | |
| 2467 | + padding: 10px 14px; | |
| 2468 | + background: #f5f7fa; | |
| 2469 | + border-bottom: 1px solid #ebeef5; | |
| 2470 | + font-size: 12px; | |
| 2471 | + color: #606266; | |
| 2472 | + } | |
| 2473 | + &__summary-label { | |
| 2474 | + color: #909399; | |
| 2475 | + } | |
| 2476 | + &__summary-value { | |
| 2477 | + font-size: 15px; | |
| 2478 | + font-weight: 600; | |
| 2479 | + color: #303133; | |
| 2480 | + } | |
| 2481 | + &__warn { | |
| 2482 | + flex: 1 1 100%; | |
| 2483 | + margin: 2px 0 0; | |
| 2484 | + padding: 0; | |
| 2485 | + font-size: 11px; | |
| 2486 | + line-height: 1.4; | |
| 2487 | + color: #e6a23c; | |
| 2488 | + display: flex; | |
| 2489 | + align-items: flex-start; | |
| 2490 | + gap: 4px; | |
| 2491 | + i { | |
| 2492 | + margin-top: 1px; | |
| 2493 | + flex-shrink: 0; | |
| 2494 | + } | |
| 2495 | + } | |
| 2496 | + &__list { | |
| 2497 | + margin: 0; | |
| 2498 | + padding: 6px 8px; | |
| 2499 | + list-style: none; | |
| 2500 | + max-height: 280px; | |
| 2501 | + overflow-y: auto; | |
| 2502 | + } | |
| 2503 | + &__item { | |
| 2504 | + display: flex; | |
| 2505 | + align-items: center; | |
| 2506 | + gap: 8px; | |
| 2507 | + padding: 8px 6px; | |
| 2508 | + line-height: 1.4; | |
| 2509 | + border-radius: 6px; | |
| 2510 | + transition: background-color 0.15s ease; | |
| 2511 | + &:hover { | |
| 2512 | + background: #f5f7fa; | |
| 2513 | + } | |
| 2514 | + & + & { | |
| 2515 | + margin-top: 2px; | |
| 2516 | + } | |
| 2517 | + } | |
| 2518 | + &__idx { | |
| 2519 | + flex-shrink: 0; | |
| 2520 | + width: 22px; | |
| 2521 | + height: 22px; | |
| 2522 | + border-radius: 50%; | |
| 2523 | + background: #ecf5ff; | |
| 2524 | + color: #409eff; | |
| 2525 | + font-size: 11px; | |
| 2526 | + font-weight: 600; | |
| 2527 | + display: inline-flex; | |
| 2528 | + align-items: center; | |
| 2529 | + justify-content: center; | |
| 2530 | + } | |
| 2531 | + &--out &__idx { | |
| 2532 | + background: #fdf6ec; | |
| 2533 | + color: #e6a23c; | |
| 2534 | + } | |
| 2535 | + &--ret &__idx { | |
| 2536 | + background: #f0f9eb; | |
| 2537 | + color: #67c23a; | |
| 2538 | + } | |
| 2539 | + &__qty-pill { | |
| 2540 | + flex-shrink: 0; | |
| 2541 | + margin-left: auto; | |
| 2542 | + padding: 2px 8px; | |
| 2543 | + font-size: 12px; | |
| 2544 | + font-weight: 500; | |
| 2545 | + color: #606266; | |
| 2546 | + background: #fff; | |
| 2547 | + border: 1px solid #e4e7ed; | |
| 2548 | + border-radius: 10px; | |
| 2549 | + line-height: 1.3; | |
| 2550 | + } | |
| 2551 | + &__footer { | |
| 2552 | + padding: 8px 14px 10px; | |
| 2553 | + font-size: 11px; | |
| 2554 | + color: #909399; | |
| 2555 | + text-align: center; | |
| 2556 | + border-top: 1px solid #ebeef5; | |
| 2557 | + background: #fafafa; | |
| 2558 | + } | |
| 2559 | +} | |
| 2183 | 2560 | .wt-pd-skip-alert .el-message-box__message { |
| 2184 | 2561 | white-space: pre-wrap; |
| 2185 | 2562 | text-align: left; | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/views/wtSp/Form.vue
| ... | ... | @@ -3,151 +3,190 @@ |
| 3 | 3 | :title="!dataForm.id ? '新建' : isDetail ? '详情' : '编辑'" |
| 4 | 4 | :close-on-click-modal="false" |
| 5 | 5 | :visible.sync="visible" |
| 6 | - class="NCC-dialog NCC-dialog_center" | |
| 6 | + class="NCC-dialog NCC-dialog_center wt-sp-form-dialog" | |
| 7 | 7 | lock-scroll |
| 8 | - width="820px" | |
| 8 | + width="900px" | |
| 9 | 9 | append-to-body |
| 10 | 10 | @close="onDialogClose" |
| 11 | 11 | > |
| 12 | - <el-row :gutter="15"> | |
| 13 | - <el-form | |
| 14 | - ref="elForm" | |
| 15 | - :model="dataForm" | |
| 16 | - size="small" | |
| 17 | - label-width="100px" | |
| 18 | - label-position="right" | |
| 19 | - :disabled="!!isDetail" | |
| 20 | - :rules="rules" | |
| 21 | - > | |
| 22 | - <el-col :span="24"> | |
| 23 | - <el-divider content-position="left">档案与定价</el-divider> | |
| 24 | - </el-col> | |
| 25 | - <el-col v-if="isKjqyVirtual" :span="24"> | |
| 12 | + <el-form | |
| 13 | + ref="elForm" | |
| 14 | + :model="dataForm" | |
| 15 | + size="small" | |
| 16 | + label-width="100px" | |
| 17 | + label-position="right" | |
| 18 | + :disabled="!!isDetail" | |
| 19 | + :rules="rules" | |
| 20 | + class="wt-sp-form" | |
| 21 | + > | |
| 22 | + <!-- 档案与定价 --> | |
| 23 | + <section class="wt-sp-form-section"> | |
| 24 | + <header class="wt-sp-form-section__head"> | |
| 25 | + <span class="wt-sp-form-section__bar" /> | |
| 26 | + <span class="wt-sp-form-section__title">档案与定价</span> | |
| 27 | + </header> | |
| 28 | + <div class="wt-sp-form-section__body"> | |
| 26 | 29 | <el-alert |
| 30 | + v-if="isKjqyVirtual" | |
| 31 | + class="wt-sp-form-alert" | |
| 27 | 32 | title="当前货品为权益卡虚拟SKU,请在【权益卡档案】中维护名称、价格与提成;货品档案仅用于查看。" |
| 28 | 33 | type="warning" |
| 29 | 34 | :closable="false" |
| 30 | 35 | show-icon |
| 31 | 36 | /> |
| 32 | - </el-col> | |
| 33 | - <el-col :span="12"> | |
| 34 | - <el-form-item label="货品名称" prop="spmc"> | |
| 35 | - <el-input v-model="dataForm.spmc" placeholder="请输入" clearable :style="{ width: '100%' }" :disabled="isKjqyVirtual" /> | |
| 36 | - </el-form-item> | |
| 37 | - </el-col> | |
| 38 | - <el-col :span="12"> | |
| 39 | - <el-form-item label="货品编码" prop="spbm"> | |
| 40 | - <el-input v-model="dataForm.spbm" placeholder="选填,69 码等" clearable :style="{ width: '100%' }" :disabled="isKjqyVirtual" /> | |
| 41 | - </el-form-item> | |
| 42 | - </el-col> | |
| 43 | - <el-col v-if="!isKjqyVirtual" :span="12"> | |
| 44 | - <el-form-item label="商品分类" prop="pl"> | |
| 45 | - <pl-tree-select v-model="dataForm.pl" placeholder="可多选" :disabled="!!isDetail" class="wt-sp-form__full" @change="onPlChange" /> | |
| 46 | - </el-form-item> | |
| 47 | - </el-col> | |
| 48 | - <el-col v-if="!isKjqyVirtual" :span="12"> | |
| 49 | - <el-form-item label="品牌" prop="pp"> | |
| 50 | - <el-select v-model="dataForm.pp" placeholder="请选择" clearable filterable :style="{ width: '100%' }"> | |
| 51 | - <el-option v-for="(item, index) in ppOptions" :key="index" :label="item.F_Ppmc" :value="item.F_Id" /> | |
| 52 | - </el-select> | |
| 53 | - </el-form-item> | |
| 54 | - </el-col> | |
| 55 | - <el-col v-if="!isKjqyVirtual" :span="12"> | |
| 56 | - <el-form-item label="销售渠道" prop="xsqd"> | |
| 57 | - <el-select v-model="dataForm.xsqd" placeholder="请选择" clearable multiple collapse-tags :style="{ width: '100%' }"> | |
| 58 | - <el-option v-for="(item, index) in xsqdOptions" :key="index" :label="item.fullName" :value="item.id" /> | |
| 59 | - </el-select> | |
| 60 | - <div class="ncc-form-hint">勾选后同步产品信息表;取消勾选将删除对应渠道记录</div> | |
| 61 | - </el-form-item> | |
| 62 | - </el-col> | |
| 63 | - <el-col v-if="!isKjqyVirtual" :span="12"> | |
| 64 | - <el-form-item label="序列号类型" prop="spxlhType"> | |
| 65 | - <el-select v-model="dataForm.spxlhType" placeholder="请选择" clearable :style="{ width: '100%' }"> | |
| 66 | - <el-option v-for="(item, index) in spxlhTypeOptions" :key="index" :label="item.fullName" :value="item.id" /> | |
| 67 | - </el-select> | |
| 68 | - </el-form-item> | |
| 69 | - </el-col> | |
| 70 | - <el-col :span="12"> | |
| 71 | - <el-form-item label="零售价" prop="lsj"> | |
| 72 | - <el-input-number | |
| 73 | - v-model="dataForm.lsj" | |
| 74 | - :step="0.01" | |
| 75 | - :precision="2" | |
| 76 | - :min="0" | |
| 77 | - controls-position="right" | |
| 78 | - :style="{ width: '100%' }" | |
| 79 | - :disabled="isKjqyVirtual || !!dataForm.id" | |
| 80 | - /> | |
| 81 | - <div v-if="!isKjqyVirtual && dataForm.id" class="ncc-form-hint"> | |
| 82 | - 常态零售价请在 | |
| 83 | - <el-link type="primary" :underline="false" @click="goProductPriceStore">产品信息表</el-link> | |
| 84 | - 维护 | |
| 85 | - </div> | |
| 86 | - <div v-else-if="!isKjqyVirtual && !dataForm.id" class="ncc-form-hint">新建时可填初始零售价,日常改价请走产品信息表</div> | |
| 87 | - </el-form-item> | |
| 88 | - </el-col> | |
| 89 | - <el-col v-if="!isKjqyVirtual" :span="12"> | |
| 90 | - <el-form-item label="限购" prop="zg"> | |
| 91 | - <el-input-number v-model="dataForm.zg" placeholder="0 不限" :step="1" :min="0" :style="{ width: '100%' }" /> | |
| 92 | - </el-form-item> | |
| 93 | - </el-col> | |
| 94 | - <el-col v-if="!isKjqyVirtual" :span="12"> | |
| 95 | - <el-form-item label="可积分" prop="sfkjf"> | |
| 96 | - <el-switch v-model="dataForm.sfkjf" :active-value="1" :inactive-value="0" active-text="参与" inactive-text="不参与" /> | |
| 97 | - </el-form-item> | |
| 98 | - </el-col> | |
| 99 | - <el-col v-if="!isKjqyVirtual" :span="12"> | |
| 100 | - <el-form-item label="复购折扣" prop="sfCyfgzk"> | |
| 101 | - <el-switch v-model="dataForm.sfCyfgzk" :active-value="1" :inactive-value="0" active-text="参与" inactive-text="不参与" /> | |
| 102 | - <div class="ncc-form-hint">收银台需手动点「权益卡复购」才打折;押金/主机/虚拟商品默认不参与,其它商品可单独开关</div> | |
| 103 | - </el-form-item> | |
| 104 | - </el-col> | |
| 105 | - | |
| 106 | - <template v-if="!isKjqyVirtual"> | |
| 107 | - <el-col :span="24"> | |
| 108 | - <el-divider content-position="left">展示与售后</el-divider> | |
| 109 | - </el-col> | |
| 110 | - <el-col :span="12"> | |
| 111 | - <el-form-item label="货品主图" prop="spzt"> | |
| 112 | - <NCC-UploadImg v-model="dataForm.spzt" :fileSize="5" sizeUnit="MB" :limit="9" /> | |
| 37 | + <div class="wt-sp-form-grid2"> | |
| 38 | + <el-form-item label="货品名称" prop="spmc"> | |
| 39 | + <el-input v-model="dataForm.spmc" placeholder="请输入" clearable class="wt-sp-form__full" :disabled="isKjqyVirtual" /> | |
| 113 | 40 | </el-form-item> |
| 114 | - </el-col> | |
| 115 | - <el-col :span="12"> | |
| 116 | - <el-form-item label="售后规则" prop="shgz"> | |
| 117 | - <el-input | |
| 118 | - v-model="dataForm.shgz" | |
| 119 | - type="textarea" | |
| 120 | - :autosize="{ minRows: 4, maxRows: 6 }" | |
| 121 | - placeholder="例:质保 1 年(主机),配件 3 个月;7 天无理由退换" | |
| 122 | - :style="{ width: '100%' }" | |
| 123 | - /> | |
| 124 | - <div class="ncc-form-hint">收银台及出库单明细行会展示,提醒经办人与客户</div> | |
| 41 | + <el-form-item label="货品编码" prop="spbm"> | |
| 42 | + <el-input v-model="dataForm.spbm" placeholder="选填,69 码等" clearable class="wt-sp-form__full" :disabled="isKjqyVirtual" /> | |
| 125 | 43 | </el-form-item> |
| 126 | - </el-col> | |
| 127 | - | |
| 128 | - <el-col :span="24"> | |
| 129 | - <el-divider content-position="left">销售范围</el-divider> | |
| 130 | - </el-col> | |
| 131 | - <el-col :span="12"> | |
| 132 | - <el-form-item label="渠道分组" prop="xsmd"> | |
| 133 | - <el-checkbox-group v-model="dataForm.xsmd" class="wt-sp-checkbox-group"> | |
| 134 | - <el-checkbox v-for="(item, index) in mdfzOptions" :key="index" :label="item.id">{{ item.fzmc }}</el-checkbox> | |
| 135 | - </el-checkbox-group> | |
| 136 | - <div class="ncc-form-hint">导购提成请在「提成设置」维护</div> | |
| 44 | + <template v-if="!isKjqyVirtual"> | |
| 45 | + <el-form-item label="商品分类" prop="pl"> | |
| 46 | + <pl-tree-select v-model="dataForm.pl" placeholder="可多选" :disabled="!!isDetail" class="wt-sp-form__full" @change="onPlChange" /> | |
| 47 | + </el-form-item> | |
| 48 | + <el-form-item label="品牌" prop="pp"> | |
| 49 | + <el-select v-model="dataForm.pp" placeholder="请选择" clearable filterable class="wt-sp-form__full"> | |
| 50 | + <el-option v-for="(item, index) in ppOptions" :key="index" :label="item.F_Ppmc" :value="item.F_Id" /> | |
| 51 | + </el-select> | |
| 52 | + </el-form-item> | |
| 53 | + <el-form-item prop="xsqd"> | |
| 54 | + <span slot="label"> | |
| 55 | + 销售渠道 | |
| 56 | + <el-tooltip content="勾选后同步产品信息表;取消勾选将删除对应渠道记录" placement="top"> | |
| 57 | + <i class="el-icon-question wt-sp-form-label-tip" /> | |
| 58 | + </el-tooltip> | |
| 59 | + </span> | |
| 60 | + <el-select v-model="dataForm.xsqd" placeholder="请选择" clearable multiple collapse-tags class="wt-sp-form__full"> | |
| 61 | + <el-option v-for="(item, index) in xsqdOptions" :key="index" :label="item.fullName" :value="item.id" /> | |
| 62 | + </el-select> | |
| 63 | + </el-form-item> | |
| 64 | + <el-form-item label="序列号类型" prop="spxlhType"> | |
| 65 | + <el-select v-model="dataForm.spxlhType" placeholder="请选择" clearable class="wt-sp-form__full"> | |
| 66 | + <el-option v-for="(item, index) in spxlhTypeOptions" :key="index" :label="item.fullName" :value="item.id" /> | |
| 67 | + </el-select> | |
| 68 | + </el-form-item> | |
| 69 | + </template> | |
| 70 | + <el-form-item prop="lsj"> | |
| 71 | + <span slot="label"> | |
| 72 | + 零售价 | |
| 73 | + <el-tooltip | |
| 74 | + v-if="!isKjqyVirtual && !dataForm.id" | |
| 75 | + content="新建时可填初始零售价,日常改价请走产品信息表" | |
| 76 | + placement="top" | |
| 77 | + > | |
| 78 | + <i class="el-icon-question wt-sp-form-label-tip" /> | |
| 79 | + </el-tooltip> | |
| 80 | + </span> | |
| 81 | + <div class="wt-sp-form-inline"> | |
| 82 | + <el-input-number | |
| 83 | + v-model="dataForm.lsj" | |
| 84 | + :step="0.01" | |
| 85 | + :precision="2" | |
| 86 | + :min="0" | |
| 87 | + controls-position="right" | |
| 88 | + class="wt-sp-form__full" | |
| 89 | + :disabled="isKjqyVirtual || !!dataForm.id" | |
| 90 | + /> | |
| 91 | + <el-link | |
| 92 | + v-if="!isKjqyVirtual && dataForm.id" | |
| 93 | + type="primary" | |
| 94 | + :underline="false" | |
| 95 | + class="wt-sp-form-inline__link" | |
| 96 | + @click="goProductPriceStore" | |
| 97 | + >产品信息表改价</el-link> | |
| 98 | + </div> | |
| 137 | 99 | </el-form-item> |
| 138 | - </el-col> | |
| 139 | - <el-col :span="12"> | |
| 140 | - <el-form-item label="关联权益卡" prop="hyxz"> | |
| 141 | - <el-checkbox-group v-model="hyxzArray" class="wt-sp-checkbox-group"> | |
| 142 | - <el-checkbox v-for="card in hyxzCardOptions" :key="card.id" :label="card.id">{{ card.kjmc }}</el-checkbox> | |
| 143 | - </el-checkbox-group> | |
| 144 | - <div class="ncc-form-hint">不选表示全员可购</div> | |
| 100 | + <el-form-item v-if="!isKjqyVirtual" label="限购" prop="zg"> | |
| 101 | + <el-input-number v-model="dataForm.zg" placeholder="0 不限" :step="1" :min="0" controls-position="right" class="wt-sp-form__full" /> | |
| 145 | 102 | </el-form-item> |
| 146 | - </el-col> | |
| 147 | - </template> | |
| 148 | - </el-form> | |
| 149 | - </el-row> | |
| 150 | - <span slot="footer" class="dialog-footer"> | |
| 103 | + <template v-if="!isKjqyVirtual"> | |
| 104 | + <el-form-item label="可积分" prop="sfkjf"> | |
| 105 | + <el-switch v-model="dataForm.sfkjf" :active-value="1" :inactive-value="0" active-text="参与" inactive-text="不参与" /> | |
| 106 | + </el-form-item> | |
| 107 | + <el-form-item prop="sfCyfgzk"> | |
| 108 | + <span slot="label"> | |
| 109 | + 复购折扣 | |
| 110 | + <el-tooltip content="收银台需手动点「权益卡复购」才打折;押金/主机/虚拟商品默认不参与,其它商品可单独开关" placement="top"> | |
| 111 | + <i class="el-icon-question wt-sp-form-label-tip" /> | |
| 112 | + </el-tooltip> | |
| 113 | + </span> | |
| 114 | + <el-switch v-model="dataForm.sfCyfgzk" :active-value="1" :inactive-value="0" active-text="参与" inactive-text="不参与" /> | |
| 115 | + </el-form-item> | |
| 116 | + </template> | |
| 117 | + </div> | |
| 118 | + </div> | |
| 119 | + </section> | |
| 120 | + | |
| 121 | + <template v-if="!isKjqyVirtual"> | |
| 122 | + <!-- 展示与售后 --> | |
| 123 | + <section class="wt-sp-form-section"> | |
| 124 | + <header class="wt-sp-form-section__head"> | |
| 125 | + <span class="wt-sp-form-section__bar" /> | |
| 126 | + <span class="wt-sp-form-section__title">展示与售后</span> | |
| 127 | + </header> | |
| 128 | + <div class="wt-sp-form-section__body"> | |
| 129 | + <div class="wt-sp-form-grid2 wt-sp-form-grid2--display"> | |
| 130 | + <el-form-item label="货品主图" prop="spzt" class="wt-sp-form-item--media"> | |
| 131 | + <div class="wt-sp-form-media"> | |
| 132 | + <NCC-UploadImg v-model="dataForm.spzt" :fileSize="5" sizeUnit="MB" :limit="9" /> | |
| 133 | + </div> | |
| 134 | + </el-form-item> | |
| 135 | + <el-form-item prop="shgz" class="wt-sp-form-item--shgz"> | |
| 136 | + <span slot="label"> | |
| 137 | + 售后规则 | |
| 138 | + <el-tooltip content="收银台及出库单明细行会展示,提醒经办人与客户" placement="top"> | |
| 139 | + <i class="el-icon-question wt-sp-form-label-tip" /> | |
| 140 | + </el-tooltip> | |
| 141 | + </span> | |
| 142 | + <el-input | |
| 143 | + v-model="dataForm.shgz" | |
| 144 | + type="textarea" | |
| 145 | + :autosize="{ minRows: 4, maxRows: 6 }" | |
| 146 | + placeholder="例:质保 1 年(主机),配件 3 个月;7 天无理由退换" | |
| 147 | + class="wt-sp-form-textarea wt-sp-form__full" | |
| 148 | + /> | |
| 149 | + </el-form-item> | |
| 150 | + </div> | |
| 151 | + </div> | |
| 152 | + </section> | |
| 153 | + | |
| 154 | + <!-- 销售范围 --> | |
| 155 | + <section class="wt-sp-form-section"> | |
| 156 | + <header class="wt-sp-form-section__head"> | |
| 157 | + <span class="wt-sp-form-section__bar" /> | |
| 158 | + <span class="wt-sp-form-section__title">销售范围</span> | |
| 159 | + </header> | |
| 160 | + <div class="wt-sp-form-section__body"> | |
| 161 | + <div class="wt-sp-form-grid2"> | |
| 162 | + <el-form-item prop="xsmd"> | |
| 163 | + <span slot="label"> | |
| 164 | + 渠道分组 | |
| 165 | + <el-tooltip content="导购提成请在「提成设置」维护" placement="top"> | |
| 166 | + <i class="el-icon-question wt-sp-form-label-tip" /> | |
| 167 | + </el-tooltip> | |
| 168 | + </span> | |
| 169 | + <el-checkbox-group v-model="dataForm.xsmd" class="wt-sp-form-checkbox-group"> | |
| 170 | + <el-checkbox v-for="(item, index) in mdfzOptions" :key="index" :label="item.id">{{ item.fzmc }}</el-checkbox> | |
| 171 | + </el-checkbox-group> | |
| 172 | + </el-form-item> | |
| 173 | + <el-form-item prop="hyxz"> | |
| 174 | + <span slot="label"> | |
| 175 | + 关联权益卡 | |
| 176 | + <el-tooltip content="不选表示全员可购" placement="top"> | |
| 177 | + <i class="el-icon-question wt-sp-form-label-tip" /> | |
| 178 | + </el-tooltip> | |
| 179 | + </span> | |
| 180 | + <el-checkbox-group v-model="hyxzArray" class="wt-sp-form-checkbox-group"> | |
| 181 | + <el-checkbox v-for="card in hyxzCardOptions" :key="card.id" :label="card.id">{{ card.kjmc }}</el-checkbox> | |
| 182 | + </el-checkbox-group> | |
| 183 | + </el-form-item> | |
| 184 | + </div> | |
| 185 | + </div> | |
| 186 | + </section> | |
| 187 | + </template> | |
| 188 | + </el-form> | |
| 189 | + <span slot="footer" class="dialog-footer wt-sp-form-footer"> | |
| 151 | 190 | <el-button @click="visible = false">取 消</el-button> |
| 152 | 191 | <el-button v-if="!isDetail && !isKjqyVirtual" type="primary" @click="dataFormSubmit()">确 定</el-button> |
| 153 | 192 | </span> |
| ... | ... | @@ -170,7 +209,7 @@ |
| 170 | 209 | pl: [], |
| 171 | 210 | pp: undefined, |
| 172 | 211 | spbm: undefined, |
| 173 | - spxlhType: undefined, | |
| 212 | + spxlhType: '3', | |
| 174 | 213 | spzt: [], |
| 175 | 214 | lsj: 0, |
| 176 | 215 | zg: undefined, |
| ... | ... | @@ -415,6 +454,7 @@ |
| 415 | 454 | } else { |
| 416 | 455 | const plDefault = defaultPlId ? [String(defaultPlId).trim()] : [] |
| 417 | 456 | this.$set(this.dataForm, 'pl', plDefault.filter(Boolean)) |
| 457 | + this.$set(this.dataForm, 'spxlhType', '3') | |
| 418 | 458 | this.$set(this.dataForm, 'sfkjf', 1) |
| 419 | 459 | this.$set(this.dataForm, 'sfCyfgzk', 1) |
| 420 | 460 | this.originalXsqd = [] |
| ... | ... | @@ -600,15 +640,142 @@ |
| 600 | 640 | .wt-sp-form__full { |
| 601 | 641 | width: 100%; |
| 602 | 642 | } |
| 603 | -.wt-sp-checkbox-group >>> .el-checkbox { | |
| 604 | - margin-right: 16px; | |
| 605 | - margin-left: 0; | |
| 606 | - margin-bottom: 4px; | |
| 643 | + | |
| 644 | +/* 弹窗 */ | |
| 645 | +.wt-sp-form-dialog >>> .el-dialog__body { | |
| 646 | + max-height: calc(100vh - 180px); | |
| 647 | + overflow-y: auto; | |
| 648 | + padding: 16px 20px 8px; | |
| 649 | +} | |
| 650 | +.wt-sp-form-footer .el-button + .el-button { | |
| 651 | + margin-left: 12px; | |
| 652 | +} | |
| 653 | + | |
| 654 | +/* 表单整体 */ | |
| 655 | +.wt-sp-form { | |
| 656 | + display: flex; | |
| 657 | + flex-direction: column; | |
| 658 | + gap: 16px; | |
| 659 | +} | |
| 660 | + | |
| 661 | +/* 分区卡片 */ | |
| 662 | +.wt-sp-form-section { | |
| 663 | + background: #fafbfc; | |
| 664 | + border: 1px solid #ebeef5; | |
| 665 | + border-radius: 10px; | |
| 666 | + padding: 16px; | |
| 667 | +} | |
| 668 | +.wt-sp-form-section__head { | |
| 669 | + display: flex; | |
| 670 | + align-items: center; | |
| 671 | + gap: 8px; | |
| 672 | + margin-bottom: 14px; | |
| 673 | +} | |
| 674 | +.wt-sp-form-section__bar { | |
| 675 | + display: inline-block; | |
| 676 | + width: 3px; | |
| 677 | + height: 14px; | |
| 678 | + border-radius: 2px; | |
| 679 | + background: #409eff; | |
| 680 | + flex-shrink: 0; | |
| 681 | +} | |
| 682 | +.wt-sp-form-section__title { | |
| 683 | + font-size: 14px; | |
| 684 | + font-weight: 600; | |
| 685 | + color: #303133; | |
| 686 | + line-height: 1; | |
| 607 | 687 | } |
| 608 | -.ncc-form-hint { | |
| 609 | - color: #999; | |
| 688 | +.wt-sp-form-section__body { | |
| 689 | + margin: 0; | |
| 690 | +} | |
| 691 | +.wt-sp-form-alert { | |
| 692 | + margin-bottom: 12px; | |
| 693 | +} | |
| 694 | + | |
| 695 | +/* 两列 Grid 布局 */ | |
| 696 | +.wt-sp-form-grid2 { | |
| 697 | + display: grid; | |
| 698 | + grid-template-columns: 1fr 1fr; | |
| 699 | + column-gap: 16px; | |
| 700 | +} | |
| 701 | +.wt-sp-form-grid2 >>> .el-form-item { | |
| 702 | + margin-bottom: 18px; | |
| 703 | + width: 100%; | |
| 704 | +} | |
| 705 | +.wt-sp-form-grid2 >>> .el-form-item__content { | |
| 706 | + line-height: 32px; | |
| 707 | +} | |
| 708 | +.wt-sp-form-grid2 >>> .el-input, | |
| 709 | +.wt-sp-form-grid2 >>> .el-select, | |
| 710 | +.wt-sp-form-grid2 >>> .el-input-number, | |
| 711 | +.wt-sp-form-grid2 >>> .wt-sp-form__full { | |
| 712 | + width: 100% !important; | |
| 713 | +} | |
| 714 | + | |
| 715 | +/* label 旁说明图标 */ | |
| 716 | +.wt-sp-form-label-tip { | |
| 717 | + margin-left: 4px; | |
| 718 | + color: #909399; | |
| 719 | + cursor: pointer; | |
| 720 | + font-size: 14px; | |
| 721 | + vertical-align: middle; | |
| 722 | +} | |
| 723 | +.wt-sp-form-label-tip:hover { | |
| 724 | + color: #606266; | |
| 725 | +} | |
| 726 | + | |
| 727 | +/* 同行控件 + 小号链接(编辑态改价) */ | |
| 728 | +.wt-sp-form-inline { | |
| 729 | + display: flex; | |
| 730 | + align-items: center; | |
| 731 | + gap: 8px; | |
| 732 | + width: 100%; | |
| 733 | +} | |
| 734 | +.wt-sp-form-inline >>> .el-input-number { | |
| 735 | + flex: 1; | |
| 736 | + min-width: 0; | |
| 737 | +} | |
| 738 | +.wt-sp-form-inline__link { | |
| 739 | + flex-shrink: 0; | |
| 610 | 740 | font-size: 12px; |
| 611 | - line-height: 18px; | |
| 612 | - margin-top: 4px; | |
| 741 | + white-space: nowrap; | |
| 742 | +} | |
| 743 | + | |
| 744 | +/* 展示与售后:主图 + 售后规则顶对齐、控件区等高 */ | |
| 745 | +.wt-sp-form-grid2--display { | |
| 746 | + align-items: start; | |
| 747 | +} | |
| 748 | +.wt-sp-form-grid2--display >>> .el-form-item { | |
| 749 | + margin-bottom: 0; | |
| 750 | +} | |
| 751 | +.wt-sp-form-item--media >>> .el-form-item__content, | |
| 752 | +.wt-sp-form-item--shgz >>> .el-form-item__content { | |
| 753 | + min-height: 168px; | |
| 754 | +} | |
| 755 | +.wt-sp-form-media { | |
| 756 | + min-height: 168px; | |
| 757 | + display: flex; | |
| 758 | + align-items: flex-start; | |
| 759 | + padding: 4px 0; | |
| 760 | +} | |
| 761 | +.wt-sp-form-textarea >>> textarea { | |
| 762 | + min-height: 120px !important; | |
| 763 | + resize: vertical; | |
| 764 | +} | |
| 765 | + | |
| 766 | +/* checkbox 组 */ | |
| 767 | +.wt-sp-form-checkbox-group { | |
| 768 | + display: flex; | |
| 769 | + flex-wrap: wrap; | |
| 770 | + gap: 8px 16px; | |
| 771 | +} | |
| 772 | +.wt-sp-form-checkbox-group >>> .el-checkbox { | |
| 773 | + margin-right: 0; | |
| 774 | + margin-left: 0; | |
| 775 | + margin-bottom: 0; | |
| 776 | +} | |
| 777 | +.wt-sp-form-checkbox-group >>> .el-checkbox__label { | |
| 778 | + padding-left: 6px; | |
| 779 | + color: #606266; | |
| 613 | 780 | } |
| 614 | 781 | </style> | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/views/wtTjdbd/index.vue
| 1 | 1 | <template> |
| 2 | 2 | <div class="NCC-common-layout"> |
| 3 | 3 | <div class="NCC-common-layout-center"> |
| 4 | - <div class="NCC-common-search-box"> | |
| 4 | + <div class="NCC-common-search-box tjd-search"> | |
| 5 | 5 | <el-form @submit.native.prevent> |
| 6 | 6 | <el-row :gutter="16"> |
| 7 | - <el-col :span="4"> | |
| 7 | + <el-col :span="6"> | |
| 8 | 8 | <el-form-item label="单据编号"> |
| 9 | 9 | <el-input v-model="query.id" placeholder="单据编号" clearable /> |
| 10 | 10 | </el-form-item> |
| 11 | 11 | </el-col> |
| 12 | - <el-col :span="5"> | |
| 13 | - <el-form-item label="单据日期"> | |
| 14 | - <el-date-picker v-model="query.djrq" type="daterange" value-format="timestamp" format="yyyy-MM-dd" start-placeholder="开始日期" end-placeholder="结束日期" /> | |
| 12 | + <el-col :span="6"> | |
| 13 | + <el-form-item label="单据时间"> | |
| 14 | + <el-date-picker | |
| 15 | + v-model="query.djrq" | |
| 16 | + type="daterange" | |
| 17 | + value-format="timestamp" | |
| 18 | + format="yyyy-MM-dd" | |
| 19 | + start-placeholder="开始日期" | |
| 20 | + end-placeholder="结束日期" | |
| 21 | + style="width: 100%" | |
| 22 | + /> | |
| 15 | 23 | </el-form-item> |
| 16 | 24 | </el-col> |
| 17 | - <el-col :span="4"> | |
| 25 | + <el-col :span="6"> | |
| 18 | 26 | <el-form-item label="出库仓库"> |
| 19 | - <el-select v-model="query.cjck" placeholder="出库仓库" clearable> | |
| 27 | + <el-select v-model="query.cjck" placeholder="出库仓库" clearable filterable style="width: 100%"> | |
| 20 | 28 | <el-option v-for="(item, index) in cjckOptions" :key="index" :label="item.F_mdmc" :value="item.F_Id" /> |
| 21 | 29 | </el-select> |
| 22 | 30 | </el-form-item> |
| 23 | 31 | </el-col> |
| 24 | - <el-col :span="4"> | |
| 32 | + <el-col :span="6"> | |
| 33 | + <el-form-item label="入库仓库"> | |
| 34 | + <el-select v-model="query.rkck" placeholder="入库仓库" clearable filterable style="width: 100%"> | |
| 35 | + <el-option v-for="(item, index) in rkckOptions" :key="index" :label="item.F_mdmc" :value="item.F_Id" /> | |
| 36 | + </el-select> | |
| 37 | + </el-form-item> | |
| 38 | + </el-col> | |
| 39 | + </el-row> | |
| 40 | + <el-row :gutter="16"> | |
| 41 | + <el-col :span="6"> | |
| 25 | 42 | <el-form-item label="审核状态"> |
| 26 | - <el-select v-model="query.djzt" placeholder="审核状态" clearable> | |
| 43 | + <el-select v-model="query.djzt" placeholder="审核状态" clearable style="width: 100%"> | |
| 27 | 44 | <el-option label="草稿" value="草稿" /> |
| 28 | 45 | <el-option label="待审核" value="待审核" /> |
| 29 | 46 | <el-option label="已审核" value="已审核" /> |
| ... | ... | @@ -31,66 +48,22 @@ |
| 31 | 48 | </el-select> |
| 32 | 49 | </el-form-item> |
| 33 | 50 | </el-col> |
| 34 | - <el-col :span="7" class="NCC-common-search-btns"> | |
| 51 | + <el-col :span="6"> | |
| 52 | + <el-form-item label="经手人"> | |
| 53 | + <userSelect v-model="query.jsr" placeholder="请选择经手人" /> | |
| 54 | + </el-form-item> | |
| 55 | + </el-col> | |
| 56 | + <el-col :span="6"> | |
| 57 | + <el-form-item label="审核人"> | |
| 58 | + <userSelect v-model="query.shr" placeholder="请选择审核人" /> | |
| 59 | + </el-form-item> | |
| 60 | + </el-col> | |
| 61 | + <el-col :span="6" class="NCC-common-search-btns search-btns-col"> | |
| 35 | 62 | <el-form-item label-width="0"> |
| 36 | - <el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button> | |
| 37 | - <el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button> | |
| 38 | - <el-button type="text" icon="el-icon-arrow-down" @click="showAll=true" v-if="!showAll">展开</el-button> | |
| 39 | - <el-button type="text" icon="el-icon-arrow-up" @click="showAll=false" v-else>收起</el-button> | |
| 63 | + <el-button type="primary" size="small" icon="el-icon-search" @click="search()">查询</el-button> | |
| 64 | + <el-button size="small" icon="el-icon-refresh-right" @click="reset()">重置</el-button> | |
| 40 | 65 | </el-form-item> |
| 41 | 66 | </el-col> |
| 42 | - <template v-if="showAll"> | |
| 43 | - <el-col :span="6"> | |
| 44 | - <el-form-item label="经手人"> | |
| 45 | - <userSelect v-model="query.jsr" placeholder="请选择经手人" /> | |
| 46 | - </el-form-item> | |
| 47 | - </el-col> | |
| 48 | - <el-col :span="6"> | |
| 49 | - <el-form-item label="优惠金额"> | |
| 50 | - <el-input v-model="query.ysje" placeholder="优惠金额" clearable /> | |
| 51 | - </el-form-item> | |
| 52 | - </el-col> | |
| 53 | - <el-col :span="6"> | |
| 54 | - <el-form-item label="收款账户"> | |
| 55 | - <el-select v-model="query.skzh" placeholder="收款账户" clearable> | |
| 56 | - <el-option v-for="(item, index) in skzhOptions" :key="index" :label="item.fullName" :value="item.id" /> | |
| 57 | - </el-select> | |
| 58 | - </el-form-item> | |
| 59 | - </el-col> | |
| 60 | - <el-col :span="6"> | |
| 61 | - <el-form-item label="制单人"> | |
| 62 | - <userSelect v-model="query.zdr" placeholder="请选择制单人" /> | |
| 63 | - </el-form-item> | |
| 64 | - </el-col> | |
| 65 | - <el-col :span="6"> | |
| 66 | - <el-form-item label="审核人"> | |
| 67 | - <userSelect v-model="query.shr" placeholder="请选择审核人" /> | |
| 68 | - </el-form-item> | |
| 69 | - </el-col> | |
| 70 | - <el-col :span="6"> | |
| 71 | - <el-form-item label="过账人"> | |
| 72 | - <userSelect v-model="query.gzr" placeholder="请选择过账人" /> | |
| 73 | - </el-form-item> | |
| 74 | - </el-col> | |
| 75 | - <el-col :span="6"> | |
| 76 | - <el-form-item label="备注"> | |
| 77 | - <el-input v-model="query.bz" placeholder="备注" /> | |
| 78 | - </el-form-item> | |
| 79 | - </el-col> | |
| 80 | - <el-col :span="6"> | |
| 81 | - <el-form-item label="单据类型"> | |
| 82 | - <el-input v-model="query.djlx" placeholder="单据类型" clearable /> | |
| 83 | - </el-form-item> | |
| 84 | - </el-col> | |
| 85 | - <el-col :span="6"> | |
| 86 | - <el-form-item label="单据来源"> | |
| 87 | - <el-select v-model="query.ly" placeholder="单据来源" clearable> | |
| 88 | - <el-option label="门店" value="门店" /> | |
| 89 | - <el-option label="抖音抓单" value="抖音抓单" /> | |
| 90 | - </el-select> | |
| 91 | - </el-form-item> | |
| 92 | - </el-col> | |
| 93 | - </template> | |
| 94 | 67 | </el-row> |
| 95 | 68 | </el-form> |
| 96 | 69 | </div> |
| ... | ... | @@ -189,7 +162,6 @@ |
| 189 | 162 | import DetailView from './detail-view' |
| 190 | 163 | import ExportBox from './ExportBox' |
| 191 | 164 | import { previewDataInterface } from '@/api/systemData/dataInterface' |
| 192 | - import { getAccountSelector } from '@/api/extend/wtAccount' | |
| 193 | 165 | import { canWtBillEdit, canWtBillDelete } from '@/utils/wtDjztDisplay' |
| 194 | 166 | import editDjrqListMixin from '@/mixins/editDjrqListMixin' |
| 195 | 167 | export default { |
| ... | ... | @@ -198,21 +170,15 @@ |
| 198 | 170 | editDjrqListViewKey: 'wtTjdbd', |
| 199 | 171 | data() { |
| 200 | 172 | return { |
| 201 | - showAll: false, | |
| 202 | 173 | query: { |
| 203 | - id:undefined, | |
| 204 | - djrq:undefined, | |
| 205 | - cjck:undefined, | |
| 206 | - jsr:undefined, | |
| 207 | - ysje:undefined, | |
| 208 | - skzh:undefined, | |
| 209 | - zdr:undefined, | |
| 210 | - shr:undefined, | |
| 211 | - gzr:undefined, | |
| 212 | - bz:undefined, | |
| 213 | - djlx:'同价调拨单', | |
| 214 | - djzt: undefined, | |
| 215 | - ly:undefined | |
| 174 | + id: undefined, | |
| 175 | + djrq: undefined, | |
| 176 | + cjck: undefined, | |
| 177 | + rkck: undefined, | |
| 178 | + jsr: undefined, | |
| 179 | + shr: undefined, | |
| 180 | + djlx: '同价调拨单', | |
| 181 | + djzt: undefined | |
| 216 | 182 | }, |
| 217 | 183 | list: [], |
| 218 | 184 | listLoading: true, |
| ... | ... | @@ -242,8 +208,7 @@ |
| 242 | 208 | { prop: 'djlx', label: '单据类型' }, |
| 243 | 209 | ], |
| 244 | 210 | cjckOptions : [], |
| 245 | - rkckOptions : [], | |
| 246 | - skzhOptions : [], | |
| 211 | + rkckOptions : [] | |
| 247 | 212 | } |
| 248 | 213 | }, |
| 249 | 214 | computed: { |
| ... | ... | @@ -256,7 +221,6 @@ |
| 256 | 221 | this.initData() |
| 257 | 222 | this.getcjckOptions(); |
| 258 | 223 | this.getrkckOptions(); |
| 259 | - this.getskzhOptions(); | |
| 260 | 224 | }, |
| 261 | 225 | mounted() { |
| 262 | 226 | this.tryOpenDetailFromQuery() |
| ... | ... | @@ -309,11 +273,6 @@ |
| 309 | 273 | this.rkckOptions = res.data |
| 310 | 274 | }); |
| 311 | 275 | }, |
| 312 | - getskzhOptions(){ | |
| 313 | - getAccountSelector().then(res => { | |
| 314 | - this.skzhOptions = res.data.list | |
| 315 | - }); | |
| 316 | - }, | |
| 317 | 276 | initData() { |
| 318 | 277 | this.listLoading = true; |
| 319 | 278 | let _query = { |
| ... | ... | @@ -497,6 +456,18 @@ |
| 497 | 456 | } |
| 498 | 457 | </script> |
| 499 | 458 | <style scoped lang="scss"> |
| 459 | +.tjd-search ::v-deep .search-btns-col .el-form-item__content { | |
| 460 | + display: flex; | |
| 461 | + justify-content: flex-end; | |
| 462 | + flex-wrap: wrap; | |
| 463 | + gap: 0 8px; | |
| 464 | +} | |
| 465 | +.tjd-search ::v-deep .NCC-common-search-btns .el-button--small { | |
| 466 | + height: 32px; | |
| 467 | + line-height: 30px; | |
| 468 | + padding-top: 0; | |
| 469 | + padding-bottom: 0; | |
| 470 | +} | |
| 500 | 471 | .tjd-table ::v-deep .el-table .cell { |
| 501 | 472 | white-space: nowrap; |
| 502 | 473 | } | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/views/wtXsckd/Form.vue
| ... | ... | @@ -444,6 +444,7 @@ |
| 444 | 444 | spbhOptions : [], |
| 445 | 445 | skzhOptions : [], |
| 446 | 446 | currentBarcodeRow: null, |
| 447 | + virtualProductIdSet: new Set(), | |
| 447 | 448 | // 添加商品信息缓存 |
| 448 | 449 | productCache: new Map(), // 缓存商品信息,避免重复API调用 |
| 449 | 450 | /** 抖音单明细「购买/赠送」快照,编辑保存时不可改 */ |
| ... | ... | @@ -936,6 +937,9 @@ |
| 936 | 937 | // 正确处理API返回结构 |
| 937 | 938 | if (response.code === 200 && response.data) { |
| 938 | 939 | const product = response.data; |
| 940 | + if (String(product.splx1 || '').trim() === '虚拟') { | |
| 941 | + this.markVirtualProductId(key) | |
| 942 | + } | |
| 939 | 943 | const rawType = (product.spxlhType != null) |
| 940 | 944 | ? product.spxlhType |
| 941 | 945 | : (mxRow && mxRow.spxlhType); |
| ... | ... | @@ -1139,6 +1143,7 @@ |
| 1139 | 1143 | getspbhOptions(){ |
| 1140 | 1144 | previewDataInterface('675937572047815941').then(res => { |
| 1141 | 1145 | this.spbhOptions = res.data |
| 1146 | + this.seedVirtualProductIdsFromOptions() | |
| 1142 | 1147 | console.log('商品选项数据:', this.spbhOptions); |
| 1143 | 1148 | |
| 1144 | 1149 | // 检查是否有序列号类型信息 |
| ... | ... | @@ -1729,21 +1734,23 @@ |
| 1729 | 1734 | this.currentBarcodeRow = row |
| 1730 | 1735 | this.$refs.barcodeSelect.open() |
| 1731 | 1736 | }, |
| 1732 | - handleBarcodeSelect(barcodeData) { | |
| 1733 | - if (this.currentBarcodeRow) { | |
| 1734 | - this.currentBarcodeRow.sptm = barcodeData.barcode | |
| 1735 | - this.currentBarcodeRow.spmc = barcodeData.productName | |
| 1736 | - this.currentBarcodeRow.spbh = barcodeData.productCode | |
| 1737 | - if (!this.currentBarcodeRow.ckck && this.dataForm.cjck) { | |
| 1738 | - this.currentBarcodeRow.ckck = this.dataForm.cjck | |
| 1737 | + async handleBarcodeSelect(barcodeData) { | |
| 1738 | + if (!this.currentBarcodeRow) return | |
| 1739 | + const row = this.currentBarcodeRow | |
| 1740 | + const isVirtual = await this.checkVirtualProductById(barcodeData.productCode, barcodeData.productName) | |
| 1741 | + if (isVirtual) return | |
| 1742 | + row.sptm = barcodeData.barcode | |
| 1743 | + row.spmc = barcodeData.productName | |
| 1744 | + row.spbh = barcodeData.productCode | |
| 1745 | + if (!row.ckck && this.dataForm.cjck) { | |
| 1746 | + row.ckck = this.dataForm.cjck | |
| 1747 | + } | |
| 1748 | + // 与下拉选商品一致:拉序列号类型、账面库存(销售单价仍手工录入) | |
| 1749 | + this.$nextTick(() => { | |
| 1750 | + if (row && row.spbh) { | |
| 1751 | + this.handleProductChange(row) | |
| 1739 | 1752 | } |
| 1740 | - // 与下拉选商品一致:拉序列号类型、账面库存(销售单价仍手工录入) | |
| 1741 | - this.$nextTick(() => { | |
| 1742 | - if (this.currentBarcodeRow && this.currentBarcodeRow.spbh) { | |
| 1743 | - this.handleProductChange(this.currentBarcodeRow) | |
| 1744 | - } | |
| 1745 | - }) | |
| 1746 | - } | |
| 1753 | + }) | |
| 1747 | 1754 | }, |
| 1748 | 1755 | |
| 1749 | 1756 | // 打开序列号选择弹窗 |
| ... | ... | @@ -2270,6 +2277,59 @@ |
| 2270 | 2277 | const base = ((item.spbm || '') + ' ' + (item.F_Spmc || '')).trim() |
| 2271 | 2278 | return base |
| 2272 | 2279 | }, |
| 2280 | + // 与后端 WtXsckdService.IsVirtualProduct 一致:wt_sp.F_Splx1 = 虚拟 | |
| 2281 | + resolveSplx1FromSpItem(item) { | |
| 2282 | + if (!item) return '' | |
| 2283 | + return String(item.splx1 || item.F_Splx1 || item.Splx1 || '').trim() | |
| 2284 | + }, | |
| 2285 | + markVirtualProductId(productId) { | |
| 2286 | + if (productId != null && String(productId).trim()) { | |
| 2287 | + this.virtualProductIdSet.add(String(productId).trim()) | |
| 2288 | + } | |
| 2289 | + }, | |
| 2290 | + seedVirtualProductIdsFromOptions() { | |
| 2291 | + (this.spbhOptions || []).forEach(item => { | |
| 2292 | + if (this.isVirtualSpItem(item)) { | |
| 2293 | + this.markVirtualProductId(item.F_Id) | |
| 2294 | + } | |
| 2295 | + }) | |
| 2296 | + }, | |
| 2297 | + isVirtualSpItem(item) { | |
| 2298 | + if (!item) return false | |
| 2299 | + if (this.resolveSplx1FromSpItem(item) === '虚拟') return true | |
| 2300 | + const id = item.F_Id != null ? String(item.F_Id) : '' | |
| 2301 | + if (id && this.virtualProductIdSet.has(id)) return true | |
| 2302 | + // 商品下拉数据接口不含 F_Splx1,权益卡编码前缀与后端建档口径一致 | |
| 2303 | + const spbm = String(item.spbm || item.F_Spbm || '').trim() | |
| 2304 | + return spbm.startsWith('KJQY-') | |
| 2305 | + }, | |
| 2306 | + rejectVirtualProductOnRow(row, productName) { | |
| 2307 | + const name = productName ? `「${productName}」` : '' | |
| 2308 | + this.$message.warning(`虚拟商品${name}不可选择,请改选实物商品`) | |
| 2309 | + this.$set(row, 'spbh', undefined) | |
| 2310 | + this.$set(row, 'spmc', '') | |
| 2311 | + this.$set(row, 'productQuery', '') | |
| 2312 | + this.handleProductChange(row) | |
| 2313 | + }, | |
| 2314 | + async checkVirtualProductById(productId, productName) { | |
| 2315 | + const id = productId != null ? String(productId).trim() : '' | |
| 2316 | + if (!id) return false | |
| 2317 | + const option = this.spbhOptions.find(item => String(item.F_Id) === id) | |
| 2318 | + if (option && this.resolveSplx1FromSpItem(option)) { | |
| 2319 | + if (this.isVirtualSpItem(option)) { | |
| 2320 | + this.$message.warning(`虚拟商品「${productName || option.F_Spmc || ''}」不可选择,请改选实物商品`) | |
| 2321 | + return true | |
| 2322 | + } | |
| 2323 | + return false | |
| 2324 | + } | |
| 2325 | + const info = await this.getProductInfo(id) | |
| 2326 | + if (info && String(info.splx1 || '').trim() === '虚拟') { | |
| 2327 | + this.markVirtualProductId(id) | |
| 2328 | + this.$message.warning(`虚拟商品「${productName || info.spmc || ''}」不可选择,请改选实物商品`) | |
| 2329 | + return true | |
| 2330 | + } | |
| 2331 | + return false | |
| 2332 | + }, | |
| 2273 | 2333 | handleProductChange(row) { |
| 2274 | 2334 | if (!row.spbh) { |
| 2275 | 2335 | this.$set(row, 'cbdj', undefined) |
| ... | ... | @@ -2290,8 +2350,32 @@ |
| 2290 | 2350 | this.calculateTotalAmount(true) |
| 2291 | 2351 | return |
| 2292 | 2352 | } |
| 2353 | + const product = this.spbhOptions.find(item => String(item.F_Id) === String(row.spbh)) | |
| 2354 | + if (product && this.isVirtualSpItem(product)) { | |
| 2355 | + this.rejectVirtualProductOnRow(row, product.F_Spmc) | |
| 2356 | + return | |
| 2357 | + } | |
| 2358 | + if (!product || !this.resolveSplx1FromSpItem(product)) { | |
| 2359 | + const capturedSpbh = row.spbh | |
| 2360 | + this.getProductInfo(capturedSpbh).then(info => { | |
| 2361 | + if (String(row.spbh || '') !== String(capturedSpbh)) return | |
| 2362 | + if (info && String(info.splx1 || '').trim() === '虚拟') { | |
| 2363 | + this.markVirtualProductId(capturedSpbh) | |
| 2364 | + this.rejectVirtualProductOnRow(row, info.spmc || (product && product.F_Spmc)) | |
| 2365 | + return | |
| 2366 | + } | |
| 2367 | + this.doHandleProductChange(row, product) | |
| 2368 | + }) | |
| 2369 | + return | |
| 2370 | + } | |
| 2371 | + this.doHandleProductChange(row, product) | |
| 2372 | + }, | |
| 2373 | + doHandleProductChange(row, product) { | |
| 2374 | + if (!row.spbh) return | |
| 2293 | 2375 | // 选中商品后可自动回填商品名称等信息 |
| 2294 | - const product = this.spbhOptions.find(item => item.F_Id === row.spbh); | |
| 2376 | + if (!product) { | |
| 2377 | + product = this.spbhOptions.find(item => item.F_Id === row.spbh) | |
| 2378 | + } | |
| 2295 | 2379 | if (product) { |
| 2296 | 2380 | row.spmc = product.F_Spmc || ''; |
| 2297 | 2381 | const isDouyinNewGift = this.isDouyinSource() && !row._douyinIsOriginalPaid |
| ... | ... | @@ -2348,7 +2432,7 @@ |
| 2348 | 2432 | this.getStockQuantity(row) |
| 2349 | 2433 | } |
| 2350 | 2434 | }, |
| 2351 | - | |
| 2435 | + | |
| 2352 | 2436 | // 清空商品名称(点击 el-input 的 ×)时:等价于解除该行商品选择,需要清空整行数据 |
| 2353 | 2437 | handleProductNameClear(row) { |
| 2354 | 2438 | if (!row) return |
| ... | ... | @@ -2364,13 +2448,14 @@ |
| 2364 | 2448 | |
| 2365 | 2449 | // 获取过滤后的商品选项(为每一行独立过滤) |
| 2366 | 2450 | getFilteredSpbhOptions(query) { |
| 2367 | - if (!query) return this.spbhOptions; | |
| 2368 | - const q = query.toLowerCase(); | |
| 2369 | - return this.spbhOptions.filter(item => { | |
| 2370 | - const code = (item.spbm || '').toLowerCase(); | |
| 2371 | - const name = (item.F_Spmc || '').toLowerCase(); | |
| 2372 | - return code.includes(q) || name.includes(q); | |
| 2373 | - }); | |
| 2451 | + const physicalOptions = this.spbhOptions.filter(item => !this.isVirtualSpItem(item)) | |
| 2452 | + if (!query) return physicalOptions | |
| 2453 | + const q = query.toLowerCase() | |
| 2454 | + return physicalOptions.filter(item => { | |
| 2455 | + const code = (item.spbm || '').toLowerCase() | |
| 2456 | + const name = (item.F_Spmc || '').toLowerCase() | |
| 2457 | + return code.includes(q) || name.includes(q) | |
| 2458 | + }) | |
| 2374 | 2459 | } |
| 2375 | 2460 | } |
| 2376 | 2461 | } | ... | ... |
Antis.Erp.Plat/antis-ncc-admin/src/views/wtYsckd/Form.vue
| ... | ... | @@ -312,6 +312,8 @@ |
| 312 | 312 | gzr:undefined, |
| 313 | 313 | bz:undefined, |
| 314 | 314 | djlx:undefined, |
| 315 | + // 与销售出库单一致:ERP 后台录入固定为「后台」,否则门店角色数据权限(ly∈门店/后台)会把空 ly 单据滤掉 | |
| 316 | + ly: '后台', | |
| 315 | 317 | djzt: '', // 单据状态 |
| 316 | 318 | }, |
| 317 | 319 | rules: { |
| ... | ... | @@ -325,6 +327,7 @@ |
| 325 | 327 | spbhOptions : [], |
| 326 | 328 | skzhOptions : [], |
| 327 | 329 | currentBarcodeRow: null, |
| 330 | + virtualProductIdSet: new Set(), | |
| 328 | 331 | // 添加商品信息缓存 |
| 329 | 332 | productCache: new Map(), // 缓存商品信息,避免重复API调用 |
| 330 | 333 | } |
| ... | ... | @@ -402,6 +405,9 @@ |
| 402 | 405 | // 正确处理API返回结构 |
| 403 | 406 | if (response.code === 200 && response.data) { |
| 404 | 407 | const product = response.data; |
| 408 | + if (String(product.splx1 || '').trim() === '虚拟') { | |
| 409 | + this.markVirtualProductId(key) | |
| 410 | + } | |
| 405 | 411 | product.spxlhType = String(product.spxlhType); |
| 406 | 412 | this.productCache.set(key, product); |
| 407 | 413 | console.log('[getProductInfo] 商品信息已缓存:', key, product); |
| ... | ... | @@ -589,6 +595,7 @@ |
| 589 | 595 | getspbhOptions(){ |
| 590 | 596 | previewDataInterface('675937572047815941').then(res => { |
| 591 | 597 | this.spbhOptions = res.data |
| 598 | + this.seedVirtualProductIdsFromOptions() | |
| 592 | 599 | console.log('商品选项数据:', this.spbhOptions); |
| 593 | 600 | |
| 594 | 601 | // 检查是否有序列号类型信息 |
| ... | ... | @@ -688,6 +695,7 @@ |
| 688 | 695 | async saveDraft() { |
| 689 | 696 | // 确保单据类型字段赋值 |
| 690 | 697 | this.dataForm.djlx = '预售出库单'; |
| 698 | + this.dataForm.ly = '后台'; | |
| 691 | 699 | this.$refs['elForm'].validate(async (valid) => { |
| 692 | 700 | if (valid) { |
| 693 | 701 | try { |
| ... | ... | @@ -759,6 +767,8 @@ |
| 759 | 767 | if (!valid) return; |
| 760 | 768 | // 确保单据类型字段赋值 |
| 761 | 769 | this.dataForm.djlx = '预售出库单'; |
| 770 | + // ERP 表单提交一律标记为「后台」,与销售出库单/数据权限口径一致 | |
| 771 | + this.dataForm.ly = '后台'; | |
| 762 | 772 | // 确保单据状态为待审核 |
| 763 | 773 | this.dataForm.djzt = '待审核'; |
| 764 | 774 | // 检查是否有明细数据 |
| ... | ... | @@ -1031,13 +1041,19 @@ |
| 1031 | 1041 | this.currentBarcodeRow = row |
| 1032 | 1042 | this.$refs.barcodeSelect.open() |
| 1033 | 1043 | }, |
| 1034 | - handleBarcodeSelect(barcodeData) { | |
| 1035 | - if (this.currentBarcodeRow) { | |
| 1036 | - this.currentBarcodeRow.sptm = barcodeData.barcode | |
| 1037 | - this.currentBarcodeRow.spmc = barcodeData.productName | |
| 1038 | - this.currentBarcodeRow.spbh = barcodeData.productCode | |
| 1039 | - // 可根据需要回填其他字段 | |
| 1040 | - } | |
| 1044 | + async handleBarcodeSelect(barcodeData) { | |
| 1045 | + if (!this.currentBarcodeRow) return | |
| 1046 | + const row = this.currentBarcodeRow | |
| 1047 | + const isVirtual = await this.checkVirtualProductById(barcodeData.productCode, barcodeData.productName) | |
| 1048 | + if (isVirtual) return | |
| 1049 | + row.sptm = barcodeData.barcode | |
| 1050 | + row.spmc = barcodeData.productName | |
| 1051 | + row.spbh = barcodeData.productCode | |
| 1052 | + this.$nextTick(() => { | |
| 1053 | + if (row && row.spbh) { | |
| 1054 | + this.handleProductChange(row) | |
| 1055 | + } | |
| 1056 | + }) | |
| 1041 | 1057 | }, |
| 1042 | 1058 | |
| 1043 | 1059 | // 打开序列号选择弹窗 |
| ... | ... | @@ -1442,6 +1458,59 @@ |
| 1442 | 1458 | const label = (option.label || '').toLowerCase(); |
| 1443 | 1459 | return label.includes(query.toLowerCase()); |
| 1444 | 1460 | }, |
| 1461 | + // 与后端 WtXsckdService.IsVirtualProduct 一致:wt_sp.F_Splx1 = 虚拟 | |
| 1462 | + resolveSplx1FromSpItem(item) { | |
| 1463 | + if (!item) return '' | |
| 1464 | + return String(item.splx1 || item.F_Splx1 || item.Splx1 || '').trim() | |
| 1465 | + }, | |
| 1466 | + markVirtualProductId(productId) { | |
| 1467 | + if (productId != null && String(productId).trim()) { | |
| 1468 | + this.virtualProductIdSet.add(String(productId).trim()) | |
| 1469 | + } | |
| 1470 | + }, | |
| 1471 | + seedVirtualProductIdsFromOptions() { | |
| 1472 | + (this.spbhOptions || []).forEach(item => { | |
| 1473 | + if (this.isVirtualSpItem(item)) { | |
| 1474 | + this.markVirtualProductId(item.F_Id) | |
| 1475 | + } | |
| 1476 | + }) | |
| 1477 | + }, | |
| 1478 | + isVirtualSpItem(item) { | |
| 1479 | + if (!item) return false | |
| 1480 | + if (this.resolveSplx1FromSpItem(item) === '虚拟') return true | |
| 1481 | + const id = item.F_Id != null ? String(item.F_Id) : '' | |
| 1482 | + if (id && this.virtualProductIdSet.has(id)) return true | |
| 1483 | + // 商品下拉数据接口不含 F_Splx1,权益卡编码前缀与后端建档口径一致 | |
| 1484 | + const spbm = String(item.spbm || item.F_Spbm || '').trim() | |
| 1485 | + return spbm.startsWith('KJQY-') | |
| 1486 | + }, | |
| 1487 | + rejectVirtualProductOnRow(row, productName) { | |
| 1488 | + const name = productName ? `「${productName}」` : '' | |
| 1489 | + this.$message.warning(`虚拟商品${name}不可选择,请改选实物商品`) | |
| 1490 | + this.$set(row, 'spbh', undefined) | |
| 1491 | + this.$set(row, 'spmc', '') | |
| 1492 | + this.$set(row, 'productQuery', '') | |
| 1493 | + this.handleProductChange(row) | |
| 1494 | + }, | |
| 1495 | + async checkVirtualProductById(productId, productName) { | |
| 1496 | + const id = productId != null ? String(productId).trim() : '' | |
| 1497 | + if (!id) return false | |
| 1498 | + const option = this.spbhOptions.find(item => String(item.F_Id) === id) | |
| 1499 | + if (option && this.resolveSplx1FromSpItem(option)) { | |
| 1500 | + if (this.isVirtualSpItem(option)) { | |
| 1501 | + this.$message.warning(`虚拟商品「${productName || option.F_Spmc || ''}」不可选择,请改选实物商品`) | |
| 1502 | + return true | |
| 1503 | + } | |
| 1504 | + return false | |
| 1505 | + } | |
| 1506 | + const info = await this.getProductInfo(id) | |
| 1507 | + if (info && String(info.splx1 || '').trim() === '虚拟') { | |
| 1508 | + this.markVirtualProductId(id) | |
| 1509 | + this.$message.warning(`虚拟商品「${productName || info.spmc || ''}」不可选择,请改选实物商品`) | |
| 1510 | + return true | |
| 1511 | + } | |
| 1512 | + return false | |
| 1513 | + }, | |
| 1445 | 1514 | handleProductChange(row) { |
| 1446 | 1515 | if (!row.spbh) { |
| 1447 | 1516 | this.$set(row, 'spmc', '') |
| ... | ... | @@ -1454,8 +1523,32 @@ |
| 1454 | 1523 | this.$set(row, 'xlhList', []) |
| 1455 | 1524 | return |
| 1456 | 1525 | } |
| 1526 | + const product = this.spbhOptions.find(item => String(item.F_Id) === String(row.spbh)) | |
| 1527 | + if (product && this.isVirtualSpItem(product)) { | |
| 1528 | + this.rejectVirtualProductOnRow(row, product.F_Spmc) | |
| 1529 | + return | |
| 1530 | + } | |
| 1531 | + if (!product || !this.resolveSplx1FromSpItem(product)) { | |
| 1532 | + const capturedSpbh = row.spbh | |
| 1533 | + this.getProductInfo(capturedSpbh).then(info => { | |
| 1534 | + if (String(row.spbh || '') !== String(capturedSpbh)) return | |
| 1535 | + if (info && String(info.splx1 || '').trim() === '虚拟') { | |
| 1536 | + this.markVirtualProductId(capturedSpbh) | |
| 1537 | + this.rejectVirtualProductOnRow(row, info.spmc || (product && product.F_Spmc)) | |
| 1538 | + return | |
| 1539 | + } | |
| 1540 | + this.doHandleProductChange(row, product) | |
| 1541 | + }) | |
| 1542 | + return | |
| 1543 | + } | |
| 1544 | + this.doHandleProductChange(row, product) | |
| 1545 | + }, | |
| 1546 | + doHandleProductChange(row, product) { | |
| 1547 | + if (!row.spbh) return | |
| 1548 | + if (!product) { | |
| 1549 | + product = this.spbhOptions.find(item => item.F_Id === row.spbh) | |
| 1550 | + } | |
| 1457 | 1551 | // 选中商品后可自动回填商品名称等信息 |
| 1458 | - const product = this.spbhOptions.find(item => item.F_Id === row.spbh); | |
| 1459 | 1552 | if (product) { |
| 1460 | 1553 | row.spmc = product.F_Spmc || ''; |
| 1461 | 1554 | // 选中商品后,立即加载商品信息(如序列号类型) |
| ... | ... | @@ -1491,13 +1584,14 @@ |
| 1491 | 1584 | |
| 1492 | 1585 | // 获取过滤后的商品选项(为每一行独立过滤) |
| 1493 | 1586 | getFilteredSpbhOptions(query) { |
| 1494 | - if (!query) return this.spbhOptions; | |
| 1495 | - const q = query.toLowerCase(); | |
| 1496 | - return this.spbhOptions.filter(item => { | |
| 1497 | - const code = (item.spbm || '').toLowerCase(); | |
| 1498 | - const name = (item.F_Spmc || '').toLowerCase(); | |
| 1499 | - return code.includes(q) || name.includes(q); | |
| 1500 | - }); | |
| 1587 | + const physicalOptions = this.spbhOptions.filter(item => !this.isVirtualSpItem(item)) | |
| 1588 | + if (!query) return physicalOptions | |
| 1589 | + const q = query.toLowerCase() | |
| 1590 | + return physicalOptions.filter(item => { | |
| 1591 | + const code = (item.spbm || '').toLowerCase() | |
| 1592 | + const name = (item.F_Spmc || '').toLowerCase() | |
| 1593 | + return code.includes(q) || name.includes(q) | |
| 1594 | + }) | |
| 1501 | 1595 | } |
| 1502 | 1596 | } |
| 1503 | 1597 | } | ... | ... |
Antis.Erp.Plat/netcore/src/Application/NCC.API/appsettings.Development.json
Antis.Erp.Plat/netcore/src/Application/NCC.API/appsettings.json
| ... | ... | @@ -29,14 +29,14 @@ |
| 29 | 29 | "AllowedHosts": "*", |
| 30 | 30 | "ConnectionStrings": { |
| 31 | 31 | "ConfigId": "db", |
| 32 | - "DBName": "ncc_wutong", | |
| 32 | + "DBName": "ponggame_test_db", | |
| 33 | 33 | "DBType": "MySql", //MySql;SqlServer;Oracle;PostgreSQL;Dm;Kdbndp; |
| 34 | 34 | //SqlServer |
| 35 | 35 | // "DefaultConnection": "Data Source=localhost;Initial Catalog={0};User ID=sqladmin;Password=P@ssw0rd;MultipleActiveResultSets=true" |
| 36 | - "DefaultConnection": "Database={0};Data Source=rm-bp19ohrgc6111ynzh1o.mysql.rds.aliyuncs.com;Port=3306;User Id=netteam;Password=netteam;Charset=utf8;TreatTinyAsBoolean=true;" | |
| 36 | + "DefaultConnection": "Database={0};Data Source=mysql-3e725c5c7aad-public.rds.volces.com;Port=3306;User Id=PongGameAdmin;Password=P0ngG@me_2026;Charset=utf8;TreatTinyAsBoolean=true;" | |
| 37 | 37 | }, |
| 38 | 38 | "DouyinLogistics": { |
| 39 | - "DatabaseName": "ncc_wutong", | |
| 39 | + "DatabaseName": "ponggame_test_db", | |
| 40 | 40 | "FallbackApiOrigin": "" |
| 41 | 41 | }, |
| 42 | 42 | "Sf": { | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.DouyinLogistics/Controllers/OrdersController.cs
| ... | ... | @@ -1003,8 +1003,10 @@ public class OrdersController : ControllerBase |
| 1003 | 1003 | /// <summary> |
| 1004 | 1004 | /// 手动创建运单(使用订单中已存储的手机号和地址) |
| 1005 | 1005 | /// </summary> |
| 1006 | + /// <param name="id">订单主键</param> | |
| 1007 | + /// <param name="productType">顺丰快递产品:1特快、2标快、247电商标快;不传默认电商标快</param> | |
| 1006 | 1008 | [HttpPost("{id}/waybill")] |
| 1007 | - public async Task<ActionResult> CreateWaybill(int id) | |
| 1009 | + public async Task<ActionResult> CreateWaybill(int id, [FromQuery] string? productType = null) | |
| 1008 | 1010 | { |
| 1009 | 1011 | try |
| 1010 | 1012 | { |
| ... | ... | @@ -1029,14 +1031,22 @@ public class OrdersController : ControllerBase |
| 1029 | 1031 | return BadRequest(new { message = "订单已锁定物流,请先解锁后再创建运单" }); |
| 1030 | 1032 | } |
| 1031 | 1033 | |
| 1034 | + var resolvedProductType = DouyinService.NormalizeSfProductType(productType); | |
| 1032 | 1035 | // 调试日志 |
| 1033 | - Console.WriteLine($"🔍 [控制器] 创建运单请求: orderId={id}, 使用订单中的手机号: {order.ReceiverPhone}"); | |
| 1034 | - _logger.LogInformation($"创建运单请求: orderId={id}, 使用订单中的手机号: {order.ReceiverPhone}"); | |
| 1036 | + Console.WriteLine($"🔍 [控制器] 创建运单请求: orderId={id}, productType={resolvedProductType}, 使用订单中的手机号: {order.ReceiverPhone}"); | |
| 1037 | + _logger.LogInformation("创建运单请求: orderId={Id}, productType={ProductType}, 使用订单中的手机号: {Phone}", | |
| 1038 | + id, resolvedProductType, order.ReceiverPhone); | |
| 1035 | 1039 | |
| 1036 | - var result = await _orderService.CreateWaybillForOrderAsync(order); | |
| 1040 | + var result = await _orderService.CreateWaybillForOrderAsync(order, resolvedProductType); | |
| 1037 | 1041 | if (result) |
| 1038 | 1042 | { |
| 1039 | - return Ok(new { message = "运单创建成功", trackingNumber = order.TrackingNumber }); | |
| 1043 | + return Ok(new | |
| 1044 | + { | |
| 1045 | + message = "运单创建成功", | |
| 1046 | + trackingNumber = order.TrackingNumber, | |
| 1047 | + productType = resolvedProductType, | |
| 1048 | + productTypeName = DouyinService.GetSfProductTypeDisplayName(resolvedProductType) | |
| 1049 | + }); | |
| 1040 | 1050 | } |
| 1041 | 1051 | else |
| 1042 | 1052 | { | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.DouyinLogistics/Services/DouyinService.cs
| ... | ... | @@ -1399,6 +1399,27 @@ public class DouyinService |
| 1399 | 1399 | } |
| 1400 | 1400 | |
| 1401 | 1401 | /// <summary> |
| 1402 | + /// 顺丰抖店产品类型:1=特快,2=标快,247=电商标快;非法或空值回退电商标快。 | |
| 1403 | + /// </summary> | |
| 1404 | + public static string NormalizeSfProductType(string? productType) | |
| 1405 | + { | |
| 1406 | + var t = (productType ?? "").Trim(); | |
| 1407 | + if (t == "1" || t == "2" || t == "247") return t; | |
| 1408 | + return "247"; | |
| 1409 | + } | |
| 1410 | + | |
| 1411 | + /// <summary>顺丰产品类型展示名(打印/日志)。</summary> | |
| 1412 | + public static string GetSfProductTypeDisplayName(string? productType) | |
| 1413 | + { | |
| 1414 | + return NormalizeSfProductType(productType) switch | |
| 1415 | + { | |
| 1416 | + "1" => "顺丰特快", | |
| 1417 | + "2" => "顺丰标快", | |
| 1418 | + _ => "电商标快" | |
| 1419 | + }; | |
| 1420 | + } | |
| 1421 | + | |
| 1422 | + /// <summary> | |
| 1402 | 1423 | /// 识别并规范抖音/顺丰隐私号(安心购虚拟号,带分机号)。 |
| 1403 | 1424 | /// 抖店解密后的虚拟号格式形如「15784053503-0363」或「15784053503_0363」, |
| 1404 | 1425 | /// 主号 11 位 + 分隔符 + 分机号;直接去掉非数字会错误拼成 15 位导致校验失败。 |
| ... | ... | @@ -1440,10 +1461,12 @@ public class DouyinService |
| 1440 | 1461 | /// <param name="encryptReceiver">收货人姓名密文(优先使用,如果为空则使用 receiverName)</param> |
| 1441 | 1462 | /// <param name="encryptTel">收货人电话密文(优先使用,如果为空则使用 receiverPhone)</param> |
| 1442 | 1463 | /// <param name="encryptDetail">收货地址详情密文(优先使用,如果为空则从 receiverAddress 解析)</param> |
| 1464 | + /// <param name="productType">顺丰快递产品类型(抖店 order_infos.product_type):1特快、2标快、247电商标快;空则默认电商标快</param> | |
| 1443 | 1465 | public async Task<string?> CreateSFWaybillAsync(string orderId, string receiverName, string receiverPhone, |
| 1444 | 1466 | string receiverAddress, string province, string city, string district, |
| 1445 | 1467 | string productName, int itemCount, |
| 1446 | - string? encryptReceiver = null, string? encryptTel = null, string? encryptDetail = null, string? street = null) | |
| 1468 | + string? encryptReceiver = null, string? encryptTel = null, string? encryptDetail = null, string? street = null, | |
| 1469 | + string? productType = null) | |
| 1447 | 1470 | { |
| 1448 | 1471 | try |
| 1449 | 1472 | { |
| ... | ... | @@ -1463,6 +1486,7 @@ public class DouyinService |
| 1463 | 1486 | |
| 1464 | 1487 | var timestamp = DateTimeOffset.Now.ToUnixTimeSeconds().ToString(); |
| 1465 | 1488 | const string logisticsCode = "shunfeng"; |
| 1489 | + var resolvedProductType = NormalizeSfProductType(productType); | |
| 1466 | 1490 | var shopNetsite = await TryResolveShopNetsiteAsync(logisticsCode); |
| 1467 | 1491 | |
| 1468 | 1492 | // 是否已有抖店密文电话:有密文时一律走密文创建运单,明文仅作兜底 |
| ... | ... | @@ -1695,6 +1719,8 @@ public class DouyinService |
| 1695 | 1719 | { "pack_id", packId }, |
| 1696 | 1720 | // pay_method 抖店取号仅支持 1-寄付月结、2-寄付现结;传其它值(如 3)会被判为到付并返回 4006。 |
| 1697 | 1721 | // 不传该字段时按商家与物流商网点约定的支付方式结算,避免与实际协议不符。 |
| 1722 | + // 顺丰快递产品:1=特快,2=标快,247=电商标快(默认)。 | |
| 1723 | + { "product_type", resolvedProductType }, | |
| 1698 | 1724 | { "receiver_info", receiverInfo }, |
| 1699 | 1725 | { "total_weight", "500" } |
| 1700 | 1726 | }; |
| ... | ... | @@ -1750,7 +1776,9 @@ public class DouyinService |
| 1750 | 1776 | |
| 1751 | 1777 | var paramJson = JsonConvert.SerializeObject(paramObj, Newtonsoft.Json.Formatting.None); |
| 1752 | 1778 | |
| 1753 | - _logger.LogInformation("创建运单请求参数: {ParamJson}", paramJson); | |
| 1779 | + _logger.LogInformation( | |
| 1780 | + "创建运单请求参数: ProductType={ProductType}, ParamJson={ParamJson}", | |
| 1781 | + resolvedProductType, paramJson); | |
| 1754 | 1782 | |
| 1755 | 1783 | var request = new |
| 1756 | 1784 | { | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.DouyinLogistics/Services/OrderService.cs
| ... | ... | @@ -1812,7 +1812,8 @@ public class OrderService |
| 1812 | 1812 | /// 为订单创建运单(使用抖音接口,使用订单中已存储的手机号) |
| 1813 | 1813 | /// </summary> |
| 1814 | 1814 | /// <param name="order">订单</param> |
| 1815 | - public async Task<bool> CreateWaybillForOrderAsync(Order order) | |
| 1815 | + /// <param name="productType">顺丰快递产品类型:1特快、2标快、247电商标快;空则默认电商标快</param> | |
| 1816 | + public async Task<bool> CreateWaybillForOrderAsync(Order order, string? productType = null) | |
| 1816 | 1817 | { |
| 1817 | 1818 | try |
| 1818 | 1819 | { |
| ... | ... | @@ -1823,8 +1824,8 @@ public class OrderService |
| 1823 | 1824 | return false; |
| 1824 | 1825 | } |
| 1825 | 1826 | |
| 1826 | - _logger.LogInformation("开始为订单创建运单: OrderId={OrderId}, ReceiverName={ReceiverName}", | |
| 1827 | - order.OrderId, order.ReceiverName); | |
| 1827 | + _logger.LogInformation("开始为订单创建运单: OrderId={OrderId}, ReceiverName={ReceiverName}, ProductType={ProductType}", | |
| 1828 | + order.OrderId, order.ReceiverName, DouyinService.NormalizeSfProductType(productType)); | |
| 1828 | 1829 | |
| 1829 | 1830 | // 使用订单中的手机号 |
| 1830 | 1831 | string phoneToUse = order.ReceiverPhone ?? ""; |
| ... | ... | @@ -1853,7 +1854,8 @@ public class OrderService |
| 1853 | 1854 | encryptReceiver: order.EncryptReceiver, // 优先使用密文姓名 |
| 1854 | 1855 | encryptTel: order.EncryptTel, // 优先使用密文电话 |
| 1855 | 1856 | encryptDetail: order.EncryptDetail, // 优先使用密文地址详情 |
| 1856 | - street: order.Street // 街道信息 | |
| 1857 | + street: order.Street, // 街道信息 | |
| 1858 | + productType: productType | |
| 1857 | 1859 | ); |
| 1858 | 1860 | |
| 1859 | 1861 | if (!string.IsNullOrEmpty(trackingNumber)) |
| ... | ... | @@ -3556,6 +3558,8 @@ public class OrderService |
| 3556 | 3558 | var skuId = ReadFirstNonEmptyString(item, "sku_id", "SkuId", "skuid", "SkuID", "skuId"); |
| 3557 | 3559 | var outSkuId = ReadFirstNonEmptyString(item, "out_sku_id", "outSkuId", "outer_sku_id", "outerSkuId", "outer_skuid"); |
| 3558 | 3560 | var spbm = ReadFirstNonEmptyString(item, "spbm", "Spbm", "product_code", "ProductCode", "spCode", "spbmCode"); |
| 3561 | + var spId = ReadFirstNonEmptyString(item, "spId", "SpId", "erpSpbh", "ErpSpbh", "spbh", "Spbh", "productId", "ProductId"); | |
| 3562 | + var productKey = !string.IsNullOrEmpty(spbm) ? spbm : spId; | |
| 3559 | 3563 | var finalSkuId = !string.IsNullOrEmpty(skuId) ? skuId : outSkuId; |
| 3560 | 3564 | |
| 3561 | 3565 | var productName = item["product_name"]?.ToString() ?? ""; |
| ... | ... | @@ -3568,10 +3572,10 @@ public class OrderService |
| 3568 | 3572 | productInfo = await GetProductInfoByDouyinSkuAsync(finalSkuId); |
| 3569 | 3573 | } |
| 3570 | 3574 | |
| 3571 | - if ((productInfo == null || string.IsNullOrEmpty(productInfo.Id)) && !string.IsNullOrEmpty(spbm)) | |
| 3575 | + if ((productInfo == null || string.IsNullOrEmpty(productInfo.Id)) && !string.IsNullOrEmpty(productKey)) | |
| 3572 | 3576 | { |
| 3573 | - _logger.LogInformation("验证商品档案(by 商品编码) - 商品: {ProductName}, 商品编码: {Spbm}", productName, spbm); | |
| 3574 | - productInfo = await GetProductInfoByProductCodeAsync(spbm); | |
| 3577 | + _logger.LogInformation("验证商品档案(by 商品编码/主键) - 商品: {ProductName}, Key: {Key}", productName, productKey); | |
| 3578 | + productInfo = await GetProductInfoByProductCodeAsync(productKey); | |
| 3575 | 3579 | } |
| 3576 | 3580 | |
| 3577 | 3581 | if (productInfo == null || string.IsNullOrEmpty(productInfo.Id)) |
| ... | ... | @@ -3579,8 +3583,9 @@ public class OrderService |
| 3579 | 3583 | var identifiers = new List<string>(); |
| 3580 | 3584 | if (!string.IsNullOrEmpty(finalSkuId)) identifiers.Add($"SKUID: {finalSkuId}"); |
| 3581 | 3585 | if (!string.IsNullOrEmpty(spbm)) identifiers.Add($"商品编码: {spbm}"); |
| 3586 | + if (!string.IsNullOrEmpty(spId)) identifiers.Add($"商品主键: {spId}"); | |
| 3582 | 3587 | if (identifiers.Count == 0) |
| 3583 | - result.MissingProducts.Add($"{productName}(缺少SKU与商品编码,sku_id: {skuId}, out_sku_id: {outSkuId})"); | |
| 3588 | + result.MissingProducts.Add($"{productName}(缺少SKU、商品编码与商品主键,sku_id: {skuId}, out_sku_id: {outSkuId})"); | |
| 3584 | 3589 | else |
| 3585 | 3590 | result.MissingProducts.Add($"{productName}({string.Join(",", identifiers)},未找到对应的商品档案)"); |
| 3586 | 3591 | } |
| ... | ... | @@ -3782,6 +3787,8 @@ public class OrderService |
| 3782 | 3787 | var skuId = ReadFirstNonEmptyString(item, "sku_id", "SkuId", "skuid", "SkuID", "skuId"); |
| 3783 | 3788 | var outSkuId = ReadFirstNonEmptyString(item, "out_sku_id", "outSkuId", "outer_sku_id", "outerSkuId", "outer_skuid"); |
| 3784 | 3789 | var spbm = ReadFirstNonEmptyString(item, "spbm", "Spbm", "product_code", "ProductCode", "spCode", "spbmCode"); |
| 3790 | + var spId = ReadFirstNonEmptyString(item, "spId", "SpId", "erpSpbh", "ErpSpbh", "spbh", "Spbh", "productId", "ProductId"); | |
| 3791 | + var productKey = !string.IsNullOrEmpty(spbm) ? spbm : spId; | |
| 3785 | 3792 | var finalSkuId = !string.IsNullOrEmpty(skuId) ? skuId : outSkuId; |
| 3786 | 3793 | |
| 3787 | 3794 | var productName = item["product_name"]?.ToString() ?? ""; |
| ... | ... | @@ -3796,10 +3803,10 @@ public class OrderService |
| 3796 | 3803 | productInfo = await GetProductInfoByDouyinSkuAsync(finalSkuId); |
| 3797 | 3804 | } |
| 3798 | 3805 | |
| 3799 | - if ((productInfo == null || string.IsNullOrEmpty(productInfo.Id)) && !string.IsNullOrEmpty(spbm)) | |
| 3806 | + if ((productInfo == null || string.IsNullOrEmpty(productInfo.Id)) && !string.IsNullOrEmpty(productKey)) | |
| 3800 | 3807 | { |
| 3801 | - _logger.LogInformation("查询商品档案(by 商品编码) - 商品: {ProductName}, 商品编码: {Spbm}", productName, spbm); | |
| 3802 | - productInfo = await GetProductInfoByProductCodeAsync(spbm); | |
| 3808 | + _logger.LogInformation("查询商品档案(by 商品编码/主键) - 商品: {ProductName}, Key: {Key}", productName, productKey); | |
| 3809 | + productInfo = await GetProductInfoByProductCodeAsync(productKey); | |
| 3803 | 3810 | } |
| 3804 | 3811 | |
| 3805 | 3812 | if (productInfo == null || string.IsNullOrEmpty(productInfo.Id)) |
| ... | ... | @@ -3807,7 +3814,11 @@ public class OrderService |
| 3807 | 3814 | var identifiers = new List<string>(); |
| 3808 | 3815 | if (!string.IsNullOrEmpty(finalSkuId)) identifiers.Add($"SKUID: {finalSkuId}"); |
| 3809 | 3816 | if (!string.IsNullOrEmpty(spbm)) identifiers.Add($"商品编码: {spbm}"); |
| 3810 | - missingProducts.Add($"{productName}({string.Join(",", identifiers)},未找到对应的商品档案)"); | |
| 3817 | + if (!string.IsNullOrEmpty(spId)) identifiers.Add($"商品主键: {spId}"); | |
| 3818 | + if (identifiers.Count == 0) | |
| 3819 | + missingProducts.Add($"{productName}(缺少SKU、商品编码与商品主键,未找到对应的商品档案)"); | |
| 3820 | + else | |
| 3821 | + missingProducts.Add($"{productName}({string.Join(",", identifiers)},未找到对应的商品档案)"); | |
| 3811 | 3822 | continue; |
| 3812 | 3823 | } |
| 3813 | 3824 | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/WtBillRecycle/WtBillRecycleListOutput.cs
0 → 100644
| 1 | +using System; | |
| 2 | + | |
| 3 | +namespace NCC.Extend.Entitys.Dto.WtBillRecycle | |
| 4 | +{ | |
| 5 | + /// <summary> | |
| 6 | + /// 单据回收站列表行 | |
| 7 | + /// </summary> | |
| 8 | + public class WtBillRecycleListOutput | |
| 9 | + { | |
| 10 | + public string billSource { get; set; } | |
| 11 | + public string id { get; set; } | |
| 12 | + public string billNo { get; set; } | |
| 13 | + public string djlx { get; set; } | |
| 14 | + public DateTime? djrq { get; set; } | |
| 15 | + public string djzt { get; set; } | |
| 16 | + public DateTime? deleteTime { get; set; } | |
| 17 | + public string deleteUserId { get; set; } | |
| 18 | + public string deleteUser { get; set; } | |
| 19 | + } | |
| 20 | +} | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/WtBillRecycle/WtBillRecycleListQueryInput.cs
0 → 100644
| 1 | +using NCC.Common.Filter; | |
| 2 | + | |
| 3 | +namespace NCC.Extend.Entitys.Dto.WtBillRecycle | |
| 4 | +{ | |
| 5 | + /// <summary> | |
| 6 | + /// 单据回收站列表查询 | |
| 7 | + /// </summary> | |
| 8 | + public class WtBillRecycleListQueryInput : PageInputBase | |
| 9 | + { | |
| 10 | + /// <summary>关键字(单据编号)</summary> | |
| 11 | + public string keyword { get; set; } | |
| 12 | + | |
| 13 | + /// <summary>单据来源:WtXsckd / WtCwdj 等</summary> | |
| 14 | + public string billSource { get; set; } | |
| 15 | + | |
| 16 | + /// <summary>单据类型 djlx</summary> | |
| 17 | + public string djlx { get; set; } | |
| 18 | + | |
| 19 | + /// <summary>删除时间起(Unix 毫秒)</summary> | |
| 20 | + public long? deleteTimeStart { get; set; } | |
| 21 | + | |
| 22 | + /// <summary>删除时间止(Unix 毫秒)</summary> | |
| 23 | + public long? deleteTimeEnd { get; set; } | |
| 24 | + | |
| 25 | + /// <summary>删除时间范围(兼容旧参数,逗号分隔)</summary> | |
| 26 | + public string deleteTimeRange { get; set; } | |
| 27 | + } | |
| 28 | +} | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/WtHy/WtHyUpdateBzInput.cs
0 → 100644
| 1 | +namespace NCC.Extend.Entitys.Dto.WtHy | |
| 2 | +{ | |
| 3 | + /// <summary> | |
| 4 | + /// 客户档案仅修改备注入参 | |
| 5 | + /// </summary> | |
| 6 | + public class WtHyUpdateBzInput | |
| 7 | + { | |
| 8 | + /// <summary>客户档案主键</summary> | |
| 9 | + public string id { get; set; } | |
| 10 | + | |
| 11 | + /// <summary>备注(可空,表示清空)</summary> | |
| 12 | + public string bz { get; set; } | |
| 13 | + } | |
| 14 | +} | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/WtPdDtos.cs
| ... | ... | @@ -191,6 +191,27 @@ namespace NCC.Extend.Entitys.Dto |
| 191 | 191 | |
| 192 | 192 | /// <summary>盘点期间销售退货累计数量(>0 表示该已盘明细在盘点期间发生过退货入库,账面/实盘已同步上调)</summary> |
| 193 | 193 | public decimal? saleReturnQty { get; set; } |
| 194 | + | |
| 195 | + /// <summary>盘点期间销售出库/零售关联单据(与 <see cref="saleOutQty"/> 口径一致,按单据编号汇总数量)</summary> | |
| 196 | + public List<WtPdPeriodBillItem> saleOutBills { get; set; } | |
| 197 | + | |
| 198 | + /// <summary>盘点期间销售退货关联单据(与 <see cref="saleReturnQty"/> 口径一致,按单据编号汇总数量)</summary> | |
| 199 | + public List<WtPdPeriodBillItem> saleReturnBills { get; set; } | |
| 200 | + } | |
| 201 | + | |
| 202 | + /// <summary> | |
| 203 | + /// 盘点期间进出单据摘要(详情明细「期间变动」复核用) | |
| 204 | + /// </summary> | |
| 205 | + public class WtPdPeriodBillItem | |
| 206 | + { | |
| 207 | + /// <summary>单据编号(<c>wt_xsckd.F_Id</c>,前端可跳转)</summary> | |
| 208 | + public string id { get; set; } | |
| 209 | + | |
| 210 | + /// <summary>单据类型(销售出库单/零售单/销售退货单)</summary> | |
| 211 | + public string djlx { get; set; } | |
| 212 | + | |
| 213 | + /// <summary>该单对本商品的出入数量合计(来自明细 <c>sl</c> 汇总,非序列号条数)</summary> | |
| 214 | + public decimal sl { get; set; } | |
| 194 | 215 | } |
| 195 | 216 | |
| 196 | 217 | /// <summary> |
| ... | ... | @@ -286,6 +307,12 @@ namespace NCC.Extend.Entitys.Dto |
| 286 | 307 | |
| 287 | 308 | /// <summary>商品主键 wt_sp.F_Id(精确)</summary> |
| 288 | 309 | public string spbh { get; set; } |
| 310 | + | |
| 311 | + /// <summary> | |
| 312 | + /// 是否仅有期间变动:<c>true</c> 仅 <see cref="WtPdMxInfoRow.saleOutQty"/> 或 | |
| 313 | + /// <see cref="WtPdMxInfoRow.saleReturnQty"/> > 0;<c>false</c> 仅无期间变动;不传不限。 | |
| 314 | + /// </summary> | |
| 315 | + public bool? hasPeriodChange { get; set; } | |
| 289 | 316 | } |
| 290 | 317 | |
| 291 | 318 | /// <summary> | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtCwdjEntity.cs
| ... | ... | @@ -131,5 +131,17 @@ namespace NCC.Extend.Entitys |
| 131 | 131 | [SugarColumn(ColumnName = "gdzcfl_id", IsNullable = true)] |
| 132 | 132 | public string GdzcflId { get; set; } |
| 133 | 133 | |
| 134 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 135 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 136 | + public int? DeleteMark { get; set; } | |
| 137 | + | |
| 138 | + /// <summary>删除时间</summary> | |
| 139 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 140 | + public DateTime? DeleteTime { get; set; } | |
| 141 | + | |
| 142 | + /// <summary>删除人(用户 Id)</summary> | |
| 143 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 144 | + public string DeleteUserId { get; set; } | |
| 145 | + | |
| 134 | 146 | } |
| 135 | 147 | } |
| 136 | 148 | \ No newline at end of file | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtCwdjmxEntity.cs
| ... | ... | @@ -83,5 +83,17 @@ namespace NCC.Extend.Entitys |
| 83 | 83 | [SugarColumn(ColumnName = "djlx")] |
| 84 | 84 | public string Djlx { get; set; } |
| 85 | 85 | |
| 86 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 87 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 88 | + public int? DeleteMark { get; set; } | |
| 89 | + | |
| 90 | + /// <summary>删除时间</summary> | |
| 91 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 92 | + public DateTime? DeleteTime { get; set; } | |
| 93 | + | |
| 94 | + /// <summary>删除人(用户 Id)</summary> | |
| 95 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 96 | + public string DeleteUserId { get; set; } | |
| 97 | + | |
| 86 | 98 | } |
| 87 | 99 | } |
| 88 | 100 | \ No newline at end of file | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtCzdEntity.cs
| ... | ... | @@ -113,5 +113,17 @@ namespace NCC.Extend.Entitys |
| 113 | 113 | [SugarColumn(ColumnName = "shr2")] |
| 114 | 114 | public string Shr2 { get; set; } |
| 115 | 115 | |
| 116 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 117 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 118 | + public int? DeleteMark { get; set; } | |
| 119 | + | |
| 120 | + /// <summary>删除时间</summary> | |
| 121 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 122 | + public DateTime? DeleteTime { get; set; } | |
| 123 | + | |
| 124 | + /// <summary>删除人(用户 Id)</summary> | |
| 125 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 126 | + public string DeleteUserId { get; set; } | |
| 127 | + | |
| 116 | 128 | } |
| 117 | 129 | } |
| 118 | 130 | \ No newline at end of file | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtCzdmx2Entity.cs
| ... | ... | @@ -71,5 +71,17 @@ namespace NCC.Extend.Entitys |
| 71 | 71 | [SugarColumn(ColumnName = "djbh")] |
| 72 | 72 | public string Djbh { get; set; } |
| 73 | 73 | |
| 74 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 75 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 76 | + public int? DeleteMark { get; set; } | |
| 77 | + | |
| 78 | + /// <summary>删除时间</summary> | |
| 79 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 80 | + public DateTime? DeleteTime { get; set; } | |
| 81 | + | |
| 82 | + /// <summary>删除人(用户 Id)</summary> | |
| 83 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 84 | + public string DeleteUserId { get; set; } | |
| 85 | + | |
| 74 | 86 | } |
| 75 | 87 | } |
| 76 | 88 | \ No newline at end of file | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtCzdmxEntity.cs
| ... | ... | @@ -78,5 +78,17 @@ namespace NCC.Extend.Entitys |
| 78 | 78 | [SugarColumn(IsIgnore = true)] |
| 79 | 79 | public List<string> SelectedSerialNumbers { get; set; } |
| 80 | 80 | |
| 81 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 82 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 83 | + public int? DeleteMark { get; set; } | |
| 84 | + | |
| 85 | + /// <summary>删除时间</summary> | |
| 86 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 87 | + public DateTime? DeleteTime { get; set; } | |
| 88 | + | |
| 89 | + /// <summary>删除人(用户 Id)</summary> | |
| 90 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 91 | + public string DeleteUserId { get; set; } | |
| 92 | + | |
| 81 | 93 | } |
| 82 | 94 | } |
| 83 | 95 | \ No newline at end of file | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtFpsqEntity.cs
| ... | ... | @@ -83,5 +83,17 @@ namespace NCC.Extend.Entitys |
| 83 | 83 | /// <summary>购买商品摘要(调用原单带入,可选)</summary> |
| 84 | 84 | [SugarColumn(ColumnName = "gmsp", IsNullable = true, ColumnDataType = "text")] |
| 85 | 85 | public string Gmsp { get; set; } |
| 86 | + | |
| 87 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 88 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 89 | + public int? DeleteMark { get; set; } | |
| 90 | + | |
| 91 | + /// <summary>删除时间</summary> | |
| 92 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 93 | + public DateTime? DeleteTime { get; set; } | |
| 94 | + | |
| 95 | + /// <summary>删除人(用户 Id)</summary> | |
| 96 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 97 | + public string DeleteUserId { get; set; } | |
| 86 | 98 | } |
| 87 | 99 | } | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtFysrdEntity.cs
| ... | ... | @@ -125,5 +125,17 @@ namespace NCC.Extend.Entitys |
| 125 | 125 | [SugarColumn(ColumnName = "shr2", IsNullable = true)] |
| 126 | 126 | public string Shr2 { get; set; } |
| 127 | 127 | |
| 128 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 129 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 130 | + public int? DeleteMark { get; set; } | |
| 131 | + | |
| 132 | + /// <summary>删除时间</summary> | |
| 133 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 134 | + public DateTime? DeleteTime { get; set; } | |
| 135 | + | |
| 136 | + /// <summary>删除人(用户 Id)</summary> | |
| 137 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 138 | + public string DeleteUserId { get; set; } | |
| 139 | + | |
| 128 | 140 | } |
| 129 | 141 | } |
| 130 | 142 | \ No newline at end of file | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtFysrdMxEntity.cs
| ... | ... | @@ -47,5 +47,17 @@ namespace NCC.Extend.Entitys |
| 47 | 47 | [SugarColumn(ColumnName = "djbh")] |
| 48 | 48 | public string Djbh { get; set; } |
| 49 | 49 | |
| 50 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 51 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 52 | + public int? DeleteMark { get; set; } | |
| 53 | + | |
| 54 | + /// <summary>删除时间</summary> | |
| 55 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 56 | + public DateTime? DeleteTime { get; set; } | |
| 57 | + | |
| 58 | + /// <summary>删除人(用户 Id)</summary> | |
| 59 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 60 | + public string DeleteUserId { get; set; } | |
| 61 | + | |
| 50 | 62 | } |
| 51 | 63 | } |
| 52 | 64 | \ No newline at end of file | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtHydqtkEntity.cs
| ... | ... | @@ -77,5 +77,17 @@ namespace NCC.Extend.Entitys |
| 77 | 77 | [SugarColumn(ColumnName = "F_Fjtp")] |
| 78 | 78 | public string Fjtp { get; set; } |
| 79 | 79 | |
| 80 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 81 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 82 | + public int? DeleteMark { get; set; } | |
| 83 | + | |
| 84 | + /// <summary>删除时间</summary> | |
| 85 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 86 | + public DateTime? DeleteTime { get; set; } | |
| 87 | + | |
| 88 | + /// <summary>删除人(用户 Id)</summary> | |
| 89 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 90 | + public string DeleteUserId { get; set; } | |
| 91 | + | |
| 80 | 92 | } |
| 81 | 93 | } |
| 82 | 94 | \ No newline at end of file | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtKfbfbEntity.cs
| ... | ... | @@ -167,5 +167,17 @@ namespace NCC.Extend.Entitys |
| 167 | 167 | [SugarColumn(ColumnName = "jsdwmc", IsNullable = true, Length = 200)] |
| 168 | 168 | public string Jsdwmc { get; set; } |
| 169 | 169 | |
| 170 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 171 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 172 | + public int? DeleteMark { get; set; } | |
| 173 | + | |
| 174 | + /// <summary>删除时间</summary> | |
| 175 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 176 | + public DateTime? DeleteTime { get; set; } | |
| 177 | + | |
| 178 | + /// <summary>删除人(用户 Id)</summary> | |
| 179 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 180 | + public string DeleteUserId { get; set; } | |
| 181 | + | |
| 170 | 182 | } |
| 171 | 183 | } | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtPdEntity.cs
| ... | ... | @@ -125,6 +125,14 @@ namespace NCC.Extend.Entitys |
| 125 | 125 | [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] |
| 126 | 126 | public int? DeleteMark { get; set; } |
| 127 | 127 | |
| 128 | + /// <summary>删除时间</summary> | |
| 129 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 130 | + public DateTime? DeleteTime { get; set; } | |
| 131 | + | |
| 132 | + /// <summary>删除人(用户 Id)</summary> | |
| 133 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 134 | + public string DeleteUserId { get; set; } | |
| 135 | + | |
| 128 | 136 | /// <summary> |
| 129 | 137 | /// 创建时间 |
| 130 | 138 | /// </summary> |
| ... | ... | @@ -149,4 +157,4 @@ namespace NCC.Extend.Entitys |
| 149 | 157 | [SugarColumn(ColumnName = "F_LastModifyUserId", IsNullable = true)] |
| 150 | 158 | public string LastModifyUserId { get; set; } |
| 151 | 159 | } |
| 152 | 160 | -} |
| 161 | +} | |
| 153 | 162 | \ No newline at end of file | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtPdMxEntity.cs
| ... | ... | @@ -121,6 +121,14 @@ namespace NCC.Extend.Entitys |
| 121 | 121 | [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] |
| 122 | 122 | public int? DeleteMark { get; set; } |
| 123 | 123 | |
| 124 | + /// <summary>删除时间</summary> | |
| 125 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 126 | + public DateTime? DeleteTime { get; set; } | |
| 127 | + | |
| 128 | + /// <summary>删除人(用户 Id)</summary> | |
| 129 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 130 | + public string DeleteUserId { get; set; } | |
| 131 | + | |
| 124 | 132 | /// <summary> |
| 125 | 133 | /// 创建时间 |
| 126 | 134 | /// </summary> |
| ... | ... | @@ -145,4 +153,4 @@ namespace NCC.Extend.Entitys |
| 145 | 153 | [SugarColumn(ColumnName = "F_LastModifyUserId", IsNullable = true)] |
| 146 | 154 | public string LastModifyUserId { get; set; } |
| 147 | 155 | } |
| 148 | 156 | -} |
| 157 | +} | |
| 149 | 158 | \ No newline at end of file | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtSfkEntity.cs
| ... | ... | @@ -77,5 +77,17 @@ namespace NCC.Extend.Entitys |
| 77 | 77 | [SugarColumn(ColumnName = "djlx")] |
| 78 | 78 | public string Djlx { get; set; } |
| 79 | 79 | |
| 80 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 81 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 82 | + public int? DeleteMark { get; set; } | |
| 83 | + | |
| 84 | + /// <summary>删除时间</summary> | |
| 85 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 86 | + public DateTime? DeleteTime { get; set; } | |
| 87 | + | |
| 88 | + /// <summary>删除人(用户 Id)</summary> | |
| 89 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 90 | + public string DeleteUserId { get; set; } | |
| 91 | + | |
| 80 | 92 | } |
| 81 | 93 | } |
| 82 | 94 | \ No newline at end of file | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtTjdEntity.cs
| ... | ... | @@ -76,5 +76,17 @@ namespace NCC.Extend.Entitys |
| 76 | 76 | /// </summary> |
| 77 | 77 | [SugarColumn(ColumnName = "shr2", IsNullable = true)] |
| 78 | 78 | public string Shr2 { get; set; } |
| 79 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 80 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 81 | + public int? DeleteMark { get; set; } | |
| 82 | + | |
| 83 | + /// <summary>删除时间</summary> | |
| 84 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 85 | + public DateTime? DeleteTime { get; set; } | |
| 86 | + | |
| 87 | + /// <summary>删除人(用户 Id)</summary> | |
| 88 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 89 | + public string DeleteUserId { get; set; } | |
| 90 | + | |
| 79 | 91 | } |
| 80 | 92 | } | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtTjdMxEntity.cs
| ... | ... | @@ -88,5 +88,17 @@ namespace NCC.Extend.Entitys |
| 88 | 88 | /// </summary> |
| 89 | 89 | [SugarColumn(ColumnName = "bz")] |
| 90 | 90 | public string Bz { get; set; } |
| 91 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 92 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 93 | + public int? DeleteMark { get; set; } | |
| 94 | + | |
| 95 | + /// <summary>删除时间</summary> | |
| 96 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 97 | + public DateTime? DeleteTime { get; set; } | |
| 98 | + | |
| 99 | + /// <summary>删除人(用户 Id)</summary> | |
| 100 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 101 | + public string DeleteUserId { get; set; } | |
| 102 | + | |
| 91 | 103 | } |
| 92 | 104 | } | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtXsckdEntity.cs
| ... | ... | @@ -263,5 +263,23 @@ namespace NCC.Extend.Entitys |
| 263 | 263 | /// </summary> |
| 264 | 264 | [SugarColumn(ColumnName = "jsdwmc", IsNullable = true, Length = 200)] |
| 265 | 265 | public string Jsdwmc { get; set; } |
| 266 | + | |
| 267 | + /// <summary> | |
| 268 | + /// 删除标记(0 或 null 未删,1 已删进回收站) | |
| 269 | + /// </summary> | |
| 270 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 271 | + public int? DeleteMark { get; set; } | |
| 272 | + | |
| 273 | + /// <summary> | |
| 274 | + /// 删除时间 | |
| 275 | + /// </summary> | |
| 276 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 277 | + public DateTime? DeleteTime { get; set; } | |
| 278 | + | |
| 279 | + /// <summary> | |
| 280 | + /// 删除人(用户 Id) | |
| 281 | + /// </summary> | |
| 282 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 283 | + public string DeleteUserId { get; set; } | |
| 266 | 284 | } |
| 267 | 285 | } |
| 268 | 286 | \ No newline at end of file | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtXsckdMxEntity.cs
| ... | ... | @@ -126,5 +126,17 @@ namespace NCC.Extend.Entitys |
| 126 | 126 | [SugarColumn(ColumnName = "rk_xlh_preset", IsNullable = true)] |
| 127 | 127 | public string RkXlhPreset { get; set; } |
| 128 | 128 | |
| 129 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 130 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 131 | + public int? DeleteMark { get; set; } | |
| 132 | + | |
| 133 | + /// <summary>删除时间</summary> | |
| 134 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 135 | + public DateTime? DeleteTime { get; set; } | |
| 136 | + | |
| 137 | + /// <summary>删除人(用户 Id)</summary> | |
| 138 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 139 | + public string DeleteUserId { get; set; } | |
| 140 | + | |
| 129 | 141 | } |
| 130 | 142 | } | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtYskzjjsEntity.cs
| ... | ... | @@ -125,5 +125,17 @@ namespace NCC.Extend.Entitys |
| 125 | 125 | [SugarColumn(ColumnName = "jsdwmc", IsNullable = true, Length = 200)] |
| 126 | 126 | public string Jsdwmc { get; set; } |
| 127 | 127 | |
| 128 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 129 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 130 | + public int? DeleteMark { get; set; } | |
| 131 | + | |
| 132 | + /// <summary>删除时间</summary> | |
| 133 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 134 | + public DateTime? DeleteTime { get; set; } | |
| 135 | + | |
| 136 | + /// <summary>删除人(用户 Id)</summary> | |
| 137 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 138 | + public string DeleteUserId { get; set; } | |
| 139 | + | |
| 128 | 140 | } |
| 129 | 141 | } |
| 130 | 142 | \ No newline at end of file | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtYskzjjsMxEntity.cs
| ... | ... | @@ -89,5 +89,17 @@ namespace NCC.Extend.Entitys |
| 89 | 89 | [SugarColumn(ColumnName = "djbh")] |
| 90 | 90 | public string Djbh { get; set; } |
| 91 | 91 | |
| 92 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 93 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 94 | + public int? DeleteMark { get; set; } | |
| 95 | + | |
| 96 | + /// <summary>删除时间</summary> | |
| 97 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 98 | + public DateTime? DeleteTime { get; set; } | |
| 99 | + | |
| 100 | + /// <summary>删除人(用户 Id)</summary> | |
| 101 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 102 | + public string DeleteUserId { get; set; } | |
| 103 | + | |
| 92 | 104 | } |
| 93 | 105 | } |
| 94 | 106 | \ No newline at end of file | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/WtZkdEntity.cs
| ... | ... | @@ -89,5 +89,17 @@ namespace NCC.Extend.Entitys |
| 89 | 89 | [SugarColumn(ColumnName = "zy")] |
| 90 | 90 | public string Zy { get; set; } |
| 91 | 91 | |
| 92 | + /// <summary>删除标记(0/null 未删,1 已删)</summary> | |
| 93 | + [SugarColumn(ColumnName = "F_DeleteMark", IsNullable = true)] | |
| 94 | + public int? DeleteMark { get; set; } | |
| 95 | + | |
| 96 | + /// <summary>删除时间</summary> | |
| 97 | + [SugarColumn(ColumnName = "F_DeleteTime", IsNullable = true)] | |
| 98 | + public DateTime? DeleteTime { get; set; } | |
| 99 | + | |
| 100 | + /// <summary>删除人(用户 Id)</summary> | |
| 101 | + [SugarColumn(ColumnName = "F_DeleteUserId", IsNullable = true, Length = 64)] | |
| 102 | + public string DeleteUserId { get; set; } | |
| 103 | + | |
| 92 | 104 | } |
| 93 | 105 | } |
| 94 | 106 | \ No newline at end of file | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Interfaces/IWtBillRecycleOperations.cs
0 → 100644
| 1 | +using System.Threading.Tasks; | |
| 2 | + | |
| 3 | +namespace NCC.Extend.Interfaces | |
| 4 | +{ | |
| 5 | + /// <summary> | |
| 6 | + /// 业务单据回收站:恢复与物理删除(由各单据 Service 实现)。 | |
| 7 | + /// </summary> | |
| 8 | + public interface IWtBillRecycleOperations | |
| 9 | + { | |
| 10 | + /// <summary>回收站来源标识</summary> | |
| 11 | + WtBillRecycleBillSource BillSource { get; } | |
| 12 | + | |
| 13 | + /// <summary>从回收站恢复(F_DeleteMark 须为 1)</summary> | |
| 14 | + Task RestoreFromRecycleBinAsync(string id); | |
| 15 | + | |
| 16 | + /// <summary>物理删除(F_DeleteMark 须为 1,含副作用回滚)</summary> | |
| 17 | + Task PurgePhysicalAsync(string id); | |
| 18 | + } | |
| 19 | +} | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend.Interfaces/WtBillRecycleBillSource.cs
0 → 100644
| 1 | +namespace NCC.Extend.Interfaces | |
| 2 | +{ | |
| 3 | + /// <summary> | |
| 4 | + /// 回收站业务来源(与各 Extend Service 控制器名一致)。 | |
| 5 | + /// </summary> | |
| 6 | + public enum WtBillRecycleBillSource | |
| 7 | + { | |
| 8 | + WtXsckd, | |
| 9 | + WtCwdj, | |
| 10 | + WtYskzjjs, | |
| 11 | + WtFysrd, | |
| 12 | + WtTjd, | |
| 13 | + WtCzd, | |
| 14 | + WtFpsq, | |
| 15 | + WtKfbfb, | |
| 16 | + WtZkd, | |
| 17 | + WtPd, | |
| 18 | + WtHydqtk, | |
| 19 | + WtSfk | |
| 20 | + } | |
| 21 | +} | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtBillRecycle/WtBillRecycleService.cs
0 → 100644
| 1 | +using NCC.Common.Core.Manager; | |
| 2 | +using NCC.Common.Extension; | |
| 3 | +using NCC.Common.Filter; | |
| 4 | +using NCC.Dependency; | |
| 5 | +using NCC.DynamicApiController; | |
| 6 | +using NCC.Extend.Entitys.Dto.WtBillRecycle; | |
| 7 | +using NCC.Extend.Interfaces; | |
| 8 | +using NCC.Extend.Interfaces; | |
| 9 | +using NCC.Extend.WtBillSoftDelete; | |
| 10 | +using NCC.FriendlyException; | |
| 11 | +using NCC.System.Entitys.Permission; | |
| 12 | +using Microsoft.AspNetCore.Mvc; | |
| 13 | +using SqlSugar; | |
| 14 | +using System; | |
| 15 | +using System.Collections.Generic; | |
| 16 | +using System.Linq; | |
| 17 | +using System.Threading.Tasks; | |
| 18 | + | |
| 19 | +namespace NCC.Extend.WtBillRecycle | |
| 20 | +{ | |
| 21 | + /// <summary> | |
| 22 | + /// 业务单据统一回收站 | |
| 23 | + /// </summary> | |
| 24 | + [ApiDescriptionSettings(Tag = "Extend", Name = "WtBillRecycle", Order = 200)] | |
| 25 | + [Route("api/Extend/[controller]")] | |
| 26 | + public class WtBillRecycleService : IDynamicApiController, ITransient | |
| 27 | + { | |
| 28 | + private readonly ISqlSugarClient _db; | |
| 29 | + private readonly IUserManager _userManager; | |
| 30 | + private readonly IBusinessOperationLogService _businessOperationLogService; | |
| 31 | + private readonly Dictionary<WtBillRecycleBillSource, IWtBillRecycleOperations> _handlers; | |
| 32 | + | |
| 33 | + private static bool _columnsEnsured; | |
| 34 | + | |
| 35 | + /// <summary> | |
| 36 | + /// 初始化回收站服务 | |
| 37 | + /// </summary> | |
| 38 | + public WtBillRecycleService( | |
| 39 | + ISqlSugarClient db, | |
| 40 | + IUserManager userManager, | |
| 41 | + IBusinessOperationLogService businessOperationLogService, | |
| 42 | + IEnumerable<IWtBillRecycleOperations> recycleHandlers) | |
| 43 | + { | |
| 44 | + _db = db; | |
| 45 | + _userManager = userManager; | |
| 46 | + _businessOperationLogService = businessOperationLogService; | |
| 47 | + _handlers = (recycleHandlers ?? Enumerable.Empty<IWtBillRecycleOperations>()) | |
| 48 | + .GroupBy(h => h.BillSource) | |
| 49 | + .ToDictionary(g => g.Key, g => g.First()); | |
| 50 | + } | |
| 51 | + | |
| 52 | + /// <summary> | |
| 53 | + /// 回收站分页列表(UNION 各业务表已删记录) | |
| 54 | + /// </summary> | |
| 55 | + /// <param name="input">keyword、billSource、djlx、deleteTimeRange、分页</param> | |
| 56 | + /// <returns>分页列表</returns> | |
| 57 | + [HttpGet("")] | |
| 58 | + public async Task<dynamic> GetList([FromQuery] WtBillRecycleListQueryInput input) | |
| 59 | + { | |
| 60 | + EnsureColumns(); | |
| 61 | + input ??= new WtBillRecycleListQueryInput(); | |
| 62 | + var pageIndex = input.currentPage <= 0 ? 1 : input.currentPage; | |
| 63 | + var pageSize = input.pageSize <= 0 ? 50 : input.pageSize; | |
| 64 | + | |
| 65 | + DateTime? delStart = null; | |
| 66 | + DateTime? delEnd = null; | |
| 67 | + if (input.deleteTimeStart.HasValue && input.deleteTimeStart > 0) | |
| 68 | + delStart = DateTimeOffset.FromUnixTimeMilliseconds(input.deleteTimeStart.Value).LocalDateTime; | |
| 69 | + if (input.deleteTimeEnd.HasValue && input.deleteTimeEnd > 0) | |
| 70 | + delEnd = DateTimeOffset.FromUnixTimeMilliseconds(input.deleteTimeEnd.Value).LocalDateTime; | |
| 71 | + if (!string.IsNullOrWhiteSpace(input.deleteTimeRange)) | |
| 72 | + { | |
| 73 | + var parts = input.deleteTimeRange.Split(','); | |
| 74 | + if (parts.Length > 0) | |
| 75 | + delStart = Ext.GetDateTime(parts[0].Trim()); | |
| 76 | + if (parts.Length > 1) | |
| 77 | + delEnd = Ext.GetDateTime(parts[1].Trim()); | |
| 78 | + } | |
| 79 | + | |
| 80 | + var sources = ResolveSources(input.billSource); | |
| 81 | + var unionParts = new List<string>(); | |
| 82 | + foreach (var src in sources) | |
| 83 | + { | |
| 84 | + if (RecycleSqlFragments.TryGetValue(src, out var frag)) | |
| 85 | + unionParts.Add(frag); | |
| 86 | + } | |
| 87 | + | |
| 88 | + if (unionParts.Count == 0) | |
| 89 | + return new { pagination = new { pageIndex, pageSize, total = 0 }, list = new List<WtBillRecycleListOutput>() }; | |
| 90 | + | |
| 91 | + var innerSql = string.Join(" UNION ALL ", unionParts); | |
| 92 | + var where = new List<string> { "1=1" }; | |
| 93 | + var ps = new List<SugarParameter>(); | |
| 94 | + | |
| 95 | + if (!string.IsNullOrWhiteSpace(input.keyword)) | |
| 96 | + { | |
| 97 | + where.Add("(t.billId LIKE @kw OR t.djlx LIKE @kw)"); | |
| 98 | + ps.Add(new SugarParameter("@kw", "%" + input.keyword.Trim() + "%")); | |
| 99 | + } | |
| 100 | + | |
| 101 | + if (!string.IsNullOrWhiteSpace(input.djlx)) | |
| 102 | + { | |
| 103 | + where.Add("t.djlx LIKE @djlx"); | |
| 104 | + ps.Add(new SugarParameter("@djlx", "%" + input.djlx.Trim() + "%")); | |
| 105 | + } | |
| 106 | + | |
| 107 | + if (delStart != null) | |
| 108 | + { | |
| 109 | + where.Add("t.deleteTime >= @delStart"); | |
| 110 | + ps.Add(new SugarParameter("@delStart", delStart)); | |
| 111 | + } | |
| 112 | + | |
| 113 | + if (delEnd != null) | |
| 114 | + { | |
| 115 | + where.Add("t.deleteTime <= @delEndEnd"); | |
| 116 | + ps.Add(new SugarParameter("@delEndEnd", | |
| 117 | + new DateTime(delEnd.Value.Year, delEnd.Value.Month, delEnd.Value.Day, 23, 59, 59))); | |
| 118 | + } | |
| 119 | + | |
| 120 | + var whereSql = string.Join(" AND ", where); | |
| 121 | + var countSql = $"SELECT COUNT(1) FROM ({innerSql}) t WHERE {whereSql}"; | |
| 122 | + var total = await _db.Ado.GetIntAsync(countSql, ps); | |
| 123 | + | |
| 124 | + var offset = (pageIndex - 1) * pageSize; | |
| 125 | + var listSql = | |
| 126 | + $"SELECT t.billSource, t.billId AS id, t.billId AS billNo, t.djlx, t.billDate AS djrq, t.djzt, t.deleteTime, t.deleteUserId " + | |
| 127 | + $"FROM ({innerSql}) t WHERE {whereSql} ORDER BY t.deleteTime DESC LIMIT {offset},{pageSize}"; | |
| 128 | + var rows = await _db.Ado.SqlQueryAsync<WtBillRecycleListOutput>(listSql, ps); | |
| 129 | + | |
| 130 | + await FillDeleteUserNamesAsync(rows); | |
| 131 | + | |
| 132 | + return new | |
| 133 | + { | |
| 134 | + pagination = new { pageIndex, pageSize, total }, | |
| 135 | + list = rows | |
| 136 | + }; | |
| 137 | + } | |
| 138 | + | |
| 139 | + /// <summary> | |
| 140 | + /// 恢复已删除单据 | |
| 141 | + /// </summary> | |
| 142 | + /// <param name="billSource">业务来源</param> | |
| 143 | + /// <param name="id">单据主键</param> | |
| 144 | + [HttpPost("{billSource}/{id}/Actions/Restore")] | |
| 145 | + public async Task<dynamic> Restore(string billSource, string id) | |
| 146 | + { | |
| 147 | + EnsureColumns(); | |
| 148 | + var src = ParseBillSource(billSource); | |
| 149 | + if (!_handlers.TryGetValue(src, out var handler)) | |
| 150 | + throw NCCException.Bah("不支持的业务来源"); | |
| 151 | + | |
| 152 | + await handler.RestoreFromRecycleBinAsync(id); | |
| 153 | + await _businessOperationLogService.WriteAsync( | |
| 154 | + BillSourceModuleName(src), "回收站恢复", billSource, id, $"回收站恢复单据 {id}"); | |
| 155 | + return new { msg = "恢复成功" }; | |
| 156 | + } | |
| 157 | + | |
| 158 | + /// <summary> | |
| 159 | + /// 物理删除(仅已进回收站记录) | |
| 160 | + /// </summary> | |
| 161 | + /// <param name="billSource">业务来源</param> | |
| 162 | + /// <param name="id">单据主键</param> | |
| 163 | + [HttpDelete("{billSource}/{id}/Actions/Purge")] | |
| 164 | + public async Task<dynamic> Purge(string billSource, string id) | |
| 165 | + { | |
| 166 | + EnsureColumns(); | |
| 167 | + var src = ParseBillSource(billSource); | |
| 168 | + if (!_handlers.TryGetValue(src, out var handler)) | |
| 169 | + throw NCCException.Bah("不支持的业务来源"); | |
| 170 | + | |
| 171 | + await handler.PurgePhysicalAsync(id); | |
| 172 | + await _businessOperationLogService.WriteAsync( | |
| 173 | + BillSourceModuleName(src), "彻底删除", billSource, id, $"回收站彻底删除单据 {id}"); | |
| 174 | + return new { msg = "已彻底删除" }; | |
| 175 | + } | |
| 176 | + | |
| 177 | + private void EnsureColumns() | |
| 178 | + { | |
| 179 | + if (_columnsEnsured) return; | |
| 180 | + WtBillSoftDeleteHelper.EnsureAllBillSoftDeleteColumnsAsync(_db).GetAwaiter().GetResult(); | |
| 181 | + _columnsEnsured = true; | |
| 182 | + } | |
| 183 | + | |
| 184 | + private static WtBillRecycleBillSource ParseBillSource(string billSource) | |
| 185 | + { | |
| 186 | + if (string.IsNullOrWhiteSpace(billSource)) | |
| 187 | + throw NCCException.Bah("billSource 必填"); | |
| 188 | + if (!Enum.TryParse<WtBillRecycleBillSource>(billSource.Trim(), true, out var src)) | |
| 189 | + throw NCCException.Bah($"无效 billSource: {billSource}"); | |
| 190 | + return src; | |
| 191 | + } | |
| 192 | + | |
| 193 | + private static IEnumerable<WtBillRecycleBillSource> ResolveSources(string billSourceFilter) | |
| 194 | + { | |
| 195 | + if (string.IsNullOrWhiteSpace(billSourceFilter)) | |
| 196 | + return Enum.GetValues(typeof(WtBillRecycleBillSource)).Cast<WtBillRecycleBillSource>(); | |
| 197 | + var src = ParseBillSource(billSourceFilter); | |
| 198 | + return new[] { src }; | |
| 199 | + } | |
| 200 | + | |
| 201 | + private async Task FillDeleteUserNamesAsync(List<WtBillRecycleListOutput> rows) | |
| 202 | + { | |
| 203 | + if (rows == null || rows.Count == 0) return; | |
| 204 | + var userIds = rows.Select(r => r.deleteUserId).Where(x => !string.IsNullOrWhiteSpace(x)).Distinct().ToList(); | |
| 205 | + if (userIds.Count == 0) return; | |
| 206 | + | |
| 207 | + var users = await _db.Queryable<UserEntity>() | |
| 208 | + .Where(u => userIds.Contains(u.Id)) | |
| 209 | + .Select(u => new { u.Id, u.RealName, u.Account }) | |
| 210 | + .ToListAsync(); | |
| 211 | + var map = users.ToDictionary( | |
| 212 | + u => u.Id, | |
| 213 | + u => string.IsNullOrWhiteSpace(u.RealName) ? u.Account : u.RealName, | |
| 214 | + StringComparer.OrdinalIgnoreCase); | |
| 215 | + foreach (var row in rows) | |
| 216 | + { | |
| 217 | + if (!string.IsNullOrWhiteSpace(row.deleteUserId) | |
| 218 | + && map.TryGetValue(row.deleteUserId, out var name)) | |
| 219 | + row.deleteUser = name; | |
| 220 | + else | |
| 221 | + row.deleteUser = string.IsNullOrWhiteSpace(row.deleteUserId) ? "无" : row.deleteUserId; | |
| 222 | + } | |
| 223 | + } | |
| 224 | + | |
| 225 | + private static string BillSourceModuleName(WtBillRecycleBillSource src) => src switch | |
| 226 | + { | |
| 227 | + WtBillRecycleBillSource.WtXsckd => "销售出库单", | |
| 228 | + WtBillRecycleBillSource.WtCwdj => "财务单据", | |
| 229 | + WtBillRecycleBillSource.WtYskzjjs => "应收款增减", | |
| 230 | + WtBillRecycleBillSource.WtFysrd => "费用收入单", | |
| 231 | + WtBillRecycleBillSource.WtTjd => "调价单", | |
| 232 | + WtBillRecycleBillSource.WtCzd => "拆装单", | |
| 233 | + WtBillRecycleBillSource.WtFpsq => "发票申请", | |
| 234 | + WtBillRecycleBillSource.WtKfbfb => "客服补发", | |
| 235 | + WtBillRecycleBillSource.WtZkd => "转款单", | |
| 236 | + WtBillRecycleBillSource.WtPd => "盘点单", | |
| 237 | + WtBillRecycleBillSource.WtHydqtk => "会员到期退款", | |
| 238 | + WtBillRecycleBillSource.WtSfk => "收付款单", | |
| 239 | + _ => src.ToString() | |
| 240 | + }; | |
| 241 | + | |
| 242 | + private static readonly Dictionary<WtBillRecycleBillSource, string> RecycleSqlFragments = | |
| 243 | + new Dictionary<WtBillRecycleBillSource, string> | |
| 244 | + { | |
| 245 | + [WtBillRecycleBillSource.WtXsckd] = | |
| 246 | + "SELECT 'WtXsckd' AS billSource, IFNULL(djlx,'') AS djlx, F_Id AS billId, djrq AS billDate, IFNULL(djzt,'') AS djzt, F_DeleteTime AS deleteTime, F_DeleteUserId AS deleteUserId FROM wt_xsckd WHERE IFNULL(F_DeleteMark,0)=1", | |
| 247 | + [WtBillRecycleBillSource.WtCwdj] = | |
| 248 | + "SELECT 'WtCwdj' AS billSource, IFNULL(djlx,'') AS djlx, F_Id AS billId, ldrq AS billDate, IFNULL(djzt,'') AS djzt, F_DeleteTime AS deleteTime, F_DeleteUserId AS deleteUserId FROM wt_cwdj WHERE IFNULL(F_DeleteMark,0)=1", | |
| 249 | + [WtBillRecycleBillSource.WtYskzjjs] = | |
| 250 | + "SELECT 'WtYskzjjs' AS billSource, IFNULL(djlx,'') AS djlx, F_Id AS billId, djrq AS billDate, IFNULL(djzt,'') AS djzt, F_DeleteTime AS deleteTime, F_DeleteUserId AS deleteUserId FROM wt_yskzjjs WHERE IFNULL(F_DeleteMark,0)=1", | |
| 251 | + [WtBillRecycleBillSource.WtFysrd] = | |
| 252 | + "SELECT 'WtFysrd' AS billSource, IFNULL(djlx,'') AS djlx, F_Id AS billId, djrq AS billDate, IFNULL(djzt,'') AS djzt, F_DeleteTime AS deleteTime, F_DeleteUserId AS deleteUserId FROM wt_fysrd WHERE IFNULL(F_DeleteMark,0)=1", | |
| 253 | + [WtBillRecycleBillSource.WtTjd] = | |
| 254 | + "SELECT 'WtTjd' AS billSource, '商品调价单' AS djlx, F_Id AS billId, djrq AS billDate, IFNULL(djzt,'') AS djzt, F_DeleteTime AS deleteTime, F_DeleteUserId AS deleteUserId FROM wt_tjd WHERE IFNULL(F_DeleteMark,0)=1", | |
| 255 | + [WtBillRecycleBillSource.WtCzd] = | |
| 256 | + "SELECT 'WtCzd' AS billSource, '拆装单' AS djlx, F_Id AS billId, djrq AS billDate, IFNULL(djzt,'') AS djzt, F_DeleteTime AS deleteTime, F_DeleteUserId AS deleteUserId FROM wt_czd WHERE IFNULL(F_DeleteMark,0)=1", | |
| 257 | + [WtBillRecycleBillSource.WtFpsq] = | |
| 258 | + "SELECT 'WtFpsq' AS billSource, '发票申请' AS djlx, F_Id AS billId, djrq AS billDate, IFNULL(djzt,'') AS djzt, F_DeleteTime AS deleteTime, F_DeleteUserId AS deleteUserId FROM wt_fpsq WHERE IFNULL(F_DeleteMark,0)=1", | |
| 259 | + [WtBillRecycleBillSource.WtKfbfb] = | |
| 260 | + "SELECT 'WtKfbfb' AS billSource, IFNULL(F_Ywlx,'客服补发') AS djlx, F_Id AS billId, djrq AS billDate, IFNULL(F_Djzt,'') AS djzt, F_DeleteTime AS deleteTime, F_DeleteUserId AS deleteUserId FROM wt_kfbfb WHERE IFNULL(F_DeleteMark,0)=1", | |
| 261 | + [WtBillRecycleBillSource.WtZkd] = | |
| 262 | + "SELECT 'WtZkd' AS billSource, '转款单' AS djlx, F_Id AS billId, djrq AS billDate, '' AS djzt, F_DeleteTime AS deleteTime, F_DeleteUserId AS deleteUserId FROM wt_zkd WHERE IFNULL(F_DeleteMark,0)=1", | |
| 263 | + [WtBillRecycleBillSource.WtPd] = | |
| 264 | + "SELECT 'WtPd' AS billSource, '盘点单' AS djlx, F_Id AS billId, FROM_UNIXTIME(F_Djrq/1000) AS billDate, IFNULL(F_Status,'') AS djzt, F_DeleteTime AS deleteTime, F_DeleteUserId AS deleteUserId FROM wt_pd WHERE IFNULL(F_DeleteMark,0)=1", | |
| 265 | + [WtBillRecycleBillSource.WtHydqtk] = | |
| 266 | + "SELECT 'WtHydqtk' AS billSource, '会员到期退款' AS djlx, F_Id AS billId, NULL AS billDate, IFNULL(F_Zt,'') AS djzt, F_DeleteTime AS deleteTime, F_DeleteUserId AS deleteUserId FROM wt_hydqtk WHERE IFNULL(F_DeleteMark,0)=1", | |
| 267 | + [WtBillRecycleBillSource.WtSfk] = | |
| 268 | + "SELECT 'WtSfk' AS billSource, IFNULL(djlx,'') AS djlx, F_Id AS billId, djrq AS billDate, '' AS djzt, F_DeleteTime AS deleteTime, F_DeleteUserId AS deleteUserId FROM wt_sfk WHERE IFNULL(F_DeleteMark,0)=1" | |
| 269 | + }; | |
| 270 | + } | |
| 271 | +} | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtBillSoftDelete/WtBillSoftDeleteHelper.cs
0 → 100644
| 1 | +using SqlSugar; | |
| 2 | +using System; | |
| 3 | +using System.Collections.Generic; | |
| 4 | +using System.Linq.Expressions; | |
| 5 | +using System.Threading.Tasks; | |
| 6 | + | |
| 7 | +namespace NCC.Extend.WtBillSoftDelete | |
| 8 | +{ | |
| 9 | + /// <summary> | |
| 10 | + /// 业务单据统一标记删除(软删)辅助:列 Ensure、标记/恢复、过滤。 | |
| 11 | + /// </summary> | |
| 12 | + public static class WtBillSoftDeleteHelper | |
| 13 | + { | |
| 14 | + public const int DeletedMark = 1; | |
| 15 | + public const int NotDeletedMark = 0; | |
| 16 | + | |
| 17 | + /// <summary>业务主表及明细表(需 F_DeleteMark / F_DeleteTime / F_DeleteUserId)。</summary> | |
| 18 | + public static readonly string[] BillSoftDeleteTables = | |
| 19 | + { | |
| 20 | + "wt_xsckd", "wt_xsckd_mx", | |
| 21 | + "wt_cwdj", "wt_cwdjmx", | |
| 22 | + "wt_yskzjjs", "wt_yskzjjs_mx", | |
| 23 | + "wt_fysrd", "wt_fysrd_mx", | |
| 24 | + "wt_tjd", "wt_tjd_mx", | |
| 25 | + "wt_czd", "wt_czdmx", "wt_czdmx_2", | |
| 26 | + "wt_fpsq", | |
| 27 | + "wt_kfbfb", | |
| 28 | + "wt_zkd", | |
| 29 | + "wt_pd", "wt_pd_mx", | |
| 30 | + "wt_hydqtk", | |
| 31 | + "wt_sfk" | |
| 32 | + }; | |
| 33 | + | |
| 34 | + public static bool IsDeleted(int? deleteMark) => deleteMark == DeletedMark; | |
| 35 | + | |
| 36 | + /// <summary> | |
| 37 | + /// 内存判断「未删除」。禁止写入 SqlSugar Where/Any 等表达式树(会报 IsNotDeleted 不可解析); | |
| 38 | + /// 查询条件请写 <c>p.DeleteMark == null || p.DeleteMark == 0</c>。 | |
| 39 | + /// </summary> | |
| 40 | + public static bool IsNotDeleted(int? deleteMark) => !IsDeleted(deleteMark); | |
| 41 | + | |
| 42 | + /// <summary> | |
| 43 | + /// 确保表含软删三列(幂等)。 | |
| 44 | + /// </summary> | |
| 45 | + public static async Task EnsureBillSoftDeleteColumnsAsync(ISqlSugarClient db, params string[] tableNames) | |
| 46 | + { | |
| 47 | + if (db == null || tableNames == null || tableNames.Length == 0) return; | |
| 48 | + foreach (var table in tableNames) | |
| 49 | + { | |
| 50 | + if (string.IsNullOrWhiteSpace(table)) continue; | |
| 51 | + var t = table.Trim(); | |
| 52 | + await EnsureColumnAsync(db, t, "F_DeleteMark", | |
| 53 | + "ALTER TABLE `" + t + "` ADD COLUMN `F_DeleteMark` int NULL DEFAULT 0 COMMENT '0未删 1已删'"); | |
| 54 | + await EnsureColumnAsync(db, t, "F_DeleteTime", | |
| 55 | + "ALTER TABLE `" + t + "` ADD COLUMN `F_DeleteTime` datetime NULL COMMENT '删除时间'"); | |
| 56 | + await EnsureColumnAsync(db, t, "F_DeleteUserId", | |
| 57 | + "ALTER TABLE `" + t + "` ADD COLUMN `F_DeleteUserId` varchar(64) NULL COMMENT '删除人ID'"); | |
| 58 | + } | |
| 59 | + } | |
| 60 | + | |
| 61 | + /// <summary> | |
| 62 | + /// 确保全部业务单据表含软删列。 | |
| 63 | + /// </summary> | |
| 64 | + public static Task EnsureAllBillSoftDeleteColumnsAsync(ISqlSugarClient db) | |
| 65 | + => EnsureBillSoftDeleteColumnsAsync(db, BillSoftDeleteTables); | |
| 66 | + | |
| 67 | + private static async Task EnsureColumnAsync(ISqlSugarClient db, string table, string column, string alterSql) | |
| 68 | + { | |
| 69 | + var cols = db.DbMaintenance.GetColumnInfosByTableName(table, false); | |
| 70 | + if (cols == null) return; | |
| 71 | + foreach (var c in cols) | |
| 72 | + { | |
| 73 | + if (string.Equals(c.DbColumnName, column, StringComparison.OrdinalIgnoreCase)) | |
| 74 | + return; | |
| 75 | + } | |
| 76 | + | |
| 77 | + try | |
| 78 | + { | |
| 79 | + await db.Ado.ExecuteCommandAsync(alterSql); | |
| 80 | + } | |
| 81 | + catch | |
| 82 | + { | |
| 83 | + // 并发建列时忽略重复 | |
| 84 | + } | |
| 85 | + } | |
| 86 | + | |
| 87 | + /// <summary> | |
| 88 | + /// 标记主表及按 djbh 关联的明细表为已删。 | |
| 89 | + /// </summary> | |
| 90 | + public static async Task SoftDeleteHeadAndMxAsync( | |
| 91 | + ISqlSugarClient db, | |
| 92 | + string headTable, | |
| 93 | + string mxTable, | |
| 94 | + string billId, | |
| 95 | + string deleteUserId, | |
| 96 | + string mxDjbhColumn = "djbh") | |
| 97 | + { | |
| 98 | + if (db == null || string.IsNullOrWhiteSpace(headTable) || string.IsNullOrWhiteSpace(billId)) return; | |
| 99 | + var now = DateTime.Now; | |
| 100 | + var uid = deleteUserId ?? ""; | |
| 101 | + await db.Ado.ExecuteCommandAsync( | |
| 102 | + "UPDATE `" + headTable + "` SET F_DeleteMark=@m, F_DeleteTime=@t, F_DeleteUserId=@u WHERE F_Id=@id", | |
| 103 | + new List<SugarParameter> | |
| 104 | + { | |
| 105 | + new SugarParameter("@m", DeletedMark), | |
| 106 | + new SugarParameter("@t", now), | |
| 107 | + new SugarParameter("@u", uid), | |
| 108 | + new SugarParameter("@id", billId) | |
| 109 | + }); | |
| 110 | + if (!string.IsNullOrWhiteSpace(mxTable)) | |
| 111 | + { | |
| 112 | + await db.Ado.ExecuteCommandAsync( | |
| 113 | + "UPDATE `" + mxTable + "` SET F_DeleteMark=@m, F_DeleteTime=@t, F_DeleteUserId=@u WHERE `" + | |
| 114 | + mxDjbhColumn + "`=@id", | |
| 115 | + new List<SugarParameter> | |
| 116 | + { | |
| 117 | + new SugarParameter("@m", DeletedMark), | |
| 118 | + new SugarParameter("@t", now), | |
| 119 | + new SugarParameter("@u", uid), | |
| 120 | + new SugarParameter("@id", billId) | |
| 121 | + }); | |
| 122 | + } | |
| 123 | + } | |
| 124 | + | |
| 125 | + /// <summary> | |
| 126 | + /// 恢复主表及明细表软删标记。 | |
| 127 | + /// </summary> | |
| 128 | + public static async Task RestoreHeadAndMxAsync( | |
| 129 | + ISqlSugarClient db, | |
| 130 | + string headTable, | |
| 131 | + string mxTable, | |
| 132 | + string billId, | |
| 133 | + string mxDjbhColumn = "djbh") | |
| 134 | + { | |
| 135 | + if (db == null || string.IsNullOrWhiteSpace(headTable) || string.IsNullOrWhiteSpace(billId)) return; | |
| 136 | + await db.Ado.ExecuteCommandAsync( | |
| 137 | + "UPDATE `" + headTable + "` SET F_DeleteMark=@m, F_DeleteTime=NULL, F_DeleteUserId=NULL WHERE F_Id=@id", | |
| 138 | + new List<SugarParameter> | |
| 139 | + { | |
| 140 | + new SugarParameter("@m", NotDeletedMark), | |
| 141 | + new SugarParameter("@id", billId) | |
| 142 | + }); | |
| 143 | + if (!string.IsNullOrWhiteSpace(mxTable)) | |
| 144 | + { | |
| 145 | + await db.Ado.ExecuteCommandAsync( | |
| 146 | + "UPDATE `" + mxTable + "` SET F_DeleteMark=@m, F_DeleteTime=NULL, F_DeleteUserId=NULL WHERE `" + | |
| 147 | + mxDjbhColumn + "`=@id", | |
| 148 | + new List<SugarParameter> | |
| 149 | + { | |
| 150 | + new SugarParameter("@m", NotDeletedMark), | |
| 151 | + new SugarParameter("@id", billId) | |
| 152 | + }); | |
| 153 | + } | |
| 154 | + } | |
| 155 | + | |
| 156 | + /// <summary> | |
| 157 | + /// 仅标记主表(无明细或明细随主表逻辑单独处理)。 | |
| 158 | + /// </summary> | |
| 159 | + public static Task SoftDeleteHeadAsync(ISqlSugarClient db, string headTable, string billId, string deleteUserId) | |
| 160 | + => SoftDeleteHeadAndMxAsync(db, headTable, null, billId, deleteUserId); | |
| 161 | + | |
| 162 | + /// <summary> | |
| 163 | + /// 仅恢复主表。 | |
| 164 | + /// </summary> | |
| 165 | + public static Task RestoreHeadAsync(ISqlSugarClient db, string headTable, string billId) | |
| 166 | + => RestoreHeadAndMxAsync(db, headTable, null, billId); | |
| 167 | + | |
| 168 | + /// <summary> | |
| 169 | + /// 未删除条件表达式(IFNULL(F_DeleteMark,0)=0)。 | |
| 170 | + /// </summary> | |
| 171 | + public static Expression<Func<T, bool>> IsNotDeletedExpression<T>() | |
| 172 | + where T : IWtBillSoftDeleteColumns, new() | |
| 173 | + { | |
| 174 | + return x => x.DeleteMark == null || x.DeleteMark == NotDeletedMark; | |
| 175 | + } | |
| 176 | + | |
| 177 | + /// <summary> | |
| 178 | + /// 查询默认过滤未删除记录。 | |
| 179 | + /// </summary> | |
| 180 | + public static ISugarQueryable<T> FilterNotDeleted<T>(this ISugarQueryable<T> query) | |
| 181 | + where T : IWtBillSoftDeleteColumns, new() | |
| 182 | + { | |
| 183 | + return query.Where(IsNotDeletedExpression<T>()); | |
| 184 | + } | |
| 185 | + } | |
| 186 | + | |
| 187 | + /// <summary> | |
| 188 | + /// 业务单据软删三列(实体实现后可 FilterNotDeleted)。 | |
| 189 | + /// </summary> | |
| 190 | + public interface IWtBillSoftDeleteColumns | |
| 191 | + { | |
| 192 | + int? DeleteMark { get; set; } | |
| 193 | + DateTime? DeleteTime { get; set; } | |
| 194 | + string DeleteUserId { get; set; } | |
| 195 | + } | |
| 196 | +} | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtCwdjService.cs
| ... | ... | @@ -30,6 +30,7 @@ using NCC.Extend.BillSummary; |
| 30 | 30 | using NCC.System.Entitys.Permission; |
| 31 | 31 | using NCC.Extend; |
| 32 | 32 | using NCC.Extend.Cw; |
| 33 | +using NCC.Extend.WtBillSoftDelete; | |
| 33 | 34 | |
| 34 | 35 | namespace NCC.Extend.WtCwdj |
| 35 | 36 | { |
| ... | ... | @@ -38,7 +39,7 @@ namespace NCC.Extend.WtCwdj |
| 38 | 39 | /// </summary> |
| 39 | 40 | [ApiDescriptionSettings(Tag = "Extend",Name = "WtCwdj", Order = 200)] |
| 40 | 41 | [Route("api/Extend/[controller]")] |
| 41 | - public class WtCwdjService : IWtCwdjService, IDynamicApiController, ITransient | |
| 42 | + public class WtCwdjService : IWtCwdjService, IDynamicApiController, ITransient, IWtBillRecycleOperations | |
| 42 | 43 | { |
| 43 | 44 | private readonly ISqlSugarRepository<WtCwdjEntity> _wtCwdjRepository; |
| 44 | 45 | private readonly ISqlSugarRepository<WtCwdjmxEntity> _wtCwdjmxRepository; |
| ... | ... | @@ -46,6 +47,11 @@ namespace NCC.Extend.WtCwdj |
| 46 | 47 | private readonly IUserManager _userManager; |
| 47 | 48 | private readonly WtDjzyService _wtDjzyService; |
| 48 | 49 | private readonly WtBillSummaryService _billSummaryService; |
| 50 | + private readonly IBusinessOperationLogService _businessOperationLogService; | |
| 51 | + private static bool _softDeleteColumnsEnsured; | |
| 52 | + | |
| 53 | + /// <inheritdoc /> | |
| 54 | + public WtBillRecycleBillSource BillSource => WtBillRecycleBillSource.WtCwdj; | |
| 49 | 55 | |
| 50 | 56 | private static bool _wtCwdjGlXsckdColumnEnsured; |
| 51 | 57 | private static bool _wtCwdjMxGlXsckdColumnEnsured; |
| ... | ... | @@ -160,7 +166,8 @@ namespace NCC.Extend.WtCwdj |
| 160 | 166 | ISqlSugarRepository<WtCwdjmxEntity> wtCwdjmxRepository, |
| 161 | 167 | IUserManager userManager, |
| 162 | 168 | WtDjzyService wtDjzyService, |
| 163 | - WtBillSummaryService billSummaryService) | |
| 169 | + WtBillSummaryService billSummaryService, | |
| 170 | + IBusinessOperationLogService businessOperationLogService) | |
| 164 | 171 | { |
| 165 | 172 | _wtCwdjRepository = wtCwdjRepository; |
| 166 | 173 | _db = _wtCwdjRepository.Context; |
| ... | ... | @@ -168,6 +175,14 @@ namespace NCC.Extend.WtCwdj |
| 168 | 175 | _userManager = userManager; |
| 169 | 176 | _wtDjzyService = wtDjzyService; |
| 170 | 177 | _billSummaryService = billSummaryService; |
| 178 | + _businessOperationLogService = businessOperationLogService; | |
| 179 | + } | |
| 180 | + | |
| 181 | + private void EnsureSoftDeleteColumns() | |
| 182 | + { | |
| 183 | + if (_softDeleteColumnsEnsured) return; | |
| 184 | + WtBillSoftDeleteHelper.EnsureBillSoftDeleteColumnsAsync(_db, "wt_cwdj", "wt_cwdjmx").GetAwaiter().GetResult(); | |
| 185 | + _softDeleteColumnsEnsured = true; | |
| 171 | 186 | } |
| 172 | 187 | |
| 173 | 188 | /// <summary> |
| ... | ... | @@ -328,20 +343,34 @@ namespace NCC.Extend.WtCwdj |
| 328 | 343 | } |
| 329 | 344 | |
| 330 | 345 | /// <summary> |
| 331 | - /// 获取财务单据 | |
| 346 | + /// 获取财务单据详情 | |
| 332 | 347 | /// </summary> |
| 333 | - /// <param name="id">参数</param> | |
| 334 | - /// <returns></returns> | |
| 348 | + /// <remarks> | |
| 349 | + /// 默认仅未软删;回收站只读详情传 <c>includeDeleted=true</c> 可读主表及明细。 | |
| 350 | + /// </remarks> | |
| 351 | + /// <param name="id">单据编号</param> | |
| 352 | + /// <param name="includeDeleted">为 true 时包含已软删主表及明细</param> | |
| 353 | + /// <returns>财务单据详情</returns> | |
| 354 | + /// <response code="200">成功</response> | |
| 355 | + /// <response code="404">单据不存在</response> | |
| 356 | + /// <response code="500">服务异常</response> | |
| 335 | 357 | [HttpGet("{id}")] |
| 336 | - public async Task<dynamic> GetInfo(string id) | |
| 358 | + public async Task<dynamic> GetInfo(string id, [FromQuery] bool includeDeleted = false) | |
| 337 | 359 | { |
| 360 | + EnsureSoftDeleteColumns(); | |
| 338 | 361 | EnsureWtCwdjJsdwColumns(); |
| 339 | - var entity = await _db.Queryable<WtCwdjEntity>().FirstAsync(p => p.Id == id); | |
| 362 | + var entity = await _db.Queryable<WtCwdjEntity>() | |
| 363 | + .Where(p => p.Id == id) | |
| 364 | + .WhereIF(!includeDeleted, p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 365 | + .FirstAsync(); | |
| 340 | 366 | if (entity == null) |
| 341 | 367 | throw NCCException.Oh(ErrorCode.COM1005); |
| 342 | 368 | var output = entity.Adapt<WtCwdjInfoOutput>(); |
| 343 | 369 | |
| 344 | - var wtCwdjmxList = await _db.Queryable<WtCwdjmxEntity>().Where(w => w.Djbh == entity.Id).ToListAsync(); | |
| 370 | + var wtCwdjmxList = await _db.Queryable<WtCwdjmxEntity>() | |
| 371 | + .Where(w => w.Djbh == entity.Id) | |
| 372 | + .WhereIF(!includeDeleted, w => WtBillSoftDeleteHelper.IsNotDeleted(w.DeleteMark)) | |
| 373 | + .ToListAsync(); | |
| 345 | 374 | output.wtCwdjmxList = wtCwdjmxList.Adapt<List<WtCwdjmxInfoOutput>>(); |
| 346 | 375 | HydrateExpenseMxGlXsckdFromHeader(output); |
| 347 | 376 | // 固定资产折旧:取消系统自动拼接的备注标记(仅展示用户备注) |
| ... | ... | @@ -454,6 +483,7 @@ namespace NCC.Extend.WtCwdj |
| 454 | 483 | [HttpGet("")] |
| 455 | 484 | public async Task<dynamic> GetList([FromQuery] WtCwdjListQueryInput input) |
| 456 | 485 | { |
| 486 | + EnsureSoftDeleteColumns(); | |
| 457 | 487 | EnsureWtCwdjJsdwColumns(); |
| 458 | 488 | var sidx = string.IsNullOrWhiteSpace(input.sidx) ? "id" : input.sidx.Trim(); |
| 459 | 489 | var sort = string.IsNullOrWhiteSpace(input.sort) ? "desc" : input.sort.Trim(); |
| ... | ... | @@ -462,6 +492,7 @@ namespace NCC.Extend.WtCwdj |
| 462 | 492 | DateTime? startLdrq = queryLdrq != null ? Ext.GetDateTime(queryLdrq.First()) : null; |
| 463 | 493 | DateTime? endLdrq = queryLdrq != null ? Ext.GetDateTime(queryLdrq.Last()) : null; |
| 464 | 494 | var baseQuery = _db.Queryable<WtCwdjEntity>() |
| 495 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 465 | 496 | .WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id)) |
| 466 | 497 | .WhereIF(queryLdrq != null, p => p.Ldrq >= new DateTime(startLdrq.ToDate().Year, startLdrq.ToDate().Month, startLdrq.ToDate().Day, 0, 0, 0)) |
| 467 | 498 | .WhereIF(queryLdrq != null, p => p.Ldrq <= new DateTime(endLdrq.ToDate().Year, endLdrq.ToDate().Month, endLdrq.ToDate().Day, 23, 59, 59)) |
| ... | ... | @@ -750,6 +781,7 @@ namespace NCC.Extend.WtCwdj |
| 750 | 781 | [NonAction] |
| 751 | 782 | public async Task<dynamic> GetNoPagingList([FromQuery] WtCwdjListQueryInput input) |
| 752 | 783 | { |
| 784 | + EnsureSoftDeleteColumns(); | |
| 753 | 785 | EnsureWtCwdjJsdwColumns(); |
| 754 | 786 | var sidx = string.IsNullOrWhiteSpace(input.sidx) ? "id" : input.sidx.Trim(); |
| 755 | 787 | var sort = string.IsNullOrWhiteSpace(input.sort) ? "desc" : input.sort.Trim(); |
| ... | ... | @@ -758,6 +790,7 @@ namespace NCC.Extend.WtCwdj |
| 758 | 790 | DateTime? startLdrq = queryLdrq != null ? Ext.GetDateTime(queryLdrq.First()) : null; |
| 759 | 791 | DateTime? endLdrq = queryLdrq != null ? Ext.GetDateTime(queryLdrq.Last()) : null; |
| 760 | 792 | var baseQuery = _db.Queryable<WtCwdjEntity>() |
| 793 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 761 | 794 | .WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id)) |
| 762 | 795 | .WhereIF(queryLdrq != null, p => p.Ldrq >= new DateTime(startLdrq.ToDate().Year, startLdrq.ToDate().Month, startLdrq.ToDate().Day, 0, 0, 0)) |
| 763 | 796 | .WhereIF(queryLdrq != null, p => p.Ldrq <= new DateTime(endLdrq.ToDate().Year, endLdrq.ToDate().Month, endLdrq.ToDate().Day, 23, 59, 59)) |
| ... | ... | @@ -880,33 +913,20 @@ namespace NCC.Extend.WtCwdj |
| 880 | 913 | [HttpPost("batchRemove")] |
| 881 | 914 | public async Task BatchRemove([FromBody] List<string> ids) |
| 882 | 915 | { |
| 883 | - var entitys = await _db.Queryable<WtCwdjEntity>().In(it => it.Id, ids).ToListAsync(); | |
| 884 | - if (entitys.Count > 0) | |
| 916 | + EnsureSoftDeleteColumns(); | |
| 917 | + var entitys = await _db.Queryable<WtCwdjEntity>() | |
| 918 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 919 | + .In(it => it.Id, ids).ToListAsync(); | |
| 920 | + foreach (var e in entitys) | |
| 885 | 921 | { |
| 886 | - foreach (var e in entitys) | |
| 887 | - { | |
| 888 | - ThrowIfCwdjDraftOnlyFiveFamilyCannotDelete(e, includeBillIdInMessage: true); | |
| 889 | - ThrowIfDeferredAmortizationCannotDelete(e); | |
| 890 | - } | |
| 891 | - try | |
| 892 | - { | |
| 893 | - //开启事务 | |
| 894 | - _db.BeginTran(); | |
| 895 | - await _wtDjzyService.DeleteByCwdjAsync(ids); | |
| 896 | - //批量删除财务单据 | |
| 897 | - await _db.Deleteable<WtCwdjEntity>().In(d => d.Id,ids).ExecuteCommandAsync(); | |
| 898 | - | |
| 899 | - //清空子表数据 | |
| 900 | - await _db.Deleteable<WtCwdjmxEntity>().In(u => u.Djbh,ids).ExecuteCommandAsync(); | |
| 901 | - //关闭事务 | |
| 902 | - _db.CommitTran(); | |
| 903 | - } | |
| 904 | - catch (Exception) | |
| 905 | - { | |
| 906 | - //回滚事务 | |
| 907 | - _db.RollbackTran(); | |
| 908 | - throw NCCException.Oh(ErrorCode.COM1002); | |
| 909 | - } | |
| 922 | + ThrowIfCwdjDraftOnlyFiveFamilyCannotDelete(e, includeBillIdInMessage: true); | |
| 923 | + ThrowIfDeferredAmortizationCannotDelete(e); | |
| 924 | + } | |
| 925 | + var uid = _userManager.UserId ?? ""; | |
| 926 | + foreach (var e in entitys) | |
| 927 | + { | |
| 928 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAndMxAsync(_db, "wt_cwdj", "wt_cwdjmx", e.Id, uid); | |
| 929 | + await _businessOperationLogService.WriteAsync("财务单据", "标记删除", "WtCwdj", e.Id, $"标记删除 {e.Id}"); | |
| 910 | 930 | } |
| 911 | 931 | } |
| 912 | 932 | |
| ... | ... | @@ -1079,32 +1099,15 @@ namespace NCC.Extend.WtCwdj |
| 1079 | 1099 | [HttpDelete("{id}")] |
| 1080 | 1100 | public async Task Delete(string id) |
| 1081 | 1101 | { |
| 1082 | - var entity = await _db.Queryable<WtCwdjEntity>().FirstAsync(p => p.Id == id); | |
| 1102 | + EnsureSoftDeleteColumns(); | |
| 1103 | + var entity = await _db.Queryable<WtCwdjEntity>() | |
| 1104 | + .Where(p => p.Id == id && WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 1105 | + .FirstAsync(); | |
| 1083 | 1106 | _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005); |
| 1084 | 1107 | ThrowIfCwdjDraftOnlyFiveFamilyCannotDelete(entity, includeBillIdInMessage: false); |
| 1085 | 1108 | ThrowIfDeferredAmortizationCannotDelete(entity); |
| 1086 | - try | |
| 1087 | - { | |
| 1088 | - //开启事务 | |
| 1089 | - _db.BeginTran(); | |
| 1090 | - | |
| 1091 | - await _wtDjzyService.DeleteByCwdjAsync(id); | |
| 1092 | - | |
| 1093 | - //删除财务单据记录 | |
| 1094 | - await _db.Deleteable<WtCwdjEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); | |
| 1095 | - | |
| 1096 | - //清空子表数据 | |
| 1097 | - await _db.Deleteable<WtCwdjmxEntity>().Where(u => u.Djbh == id).ExecuteCommandAsync(); | |
| 1098 | - | |
| 1099 | - //关闭事务 | |
| 1100 | - _db.CommitTran(); | |
| 1101 | - } | |
| 1102 | - catch (Exception) | |
| 1103 | - { | |
| 1104 | - //回滚事务 | |
| 1105 | - _db.RollbackTran(); | |
| 1106 | - throw NCCException.Oh(ErrorCode.COM1002); | |
| 1107 | - } | |
| 1109 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAndMxAsync(_db, "wt_cwdj", "wt_cwdjmx", id, _userManager.UserId ?? ""); | |
| 1110 | + await _businessOperationLogService.WriteAsync("财务单据", "标记删除", "WtCwdj", id, $"标记删除 {id}"); | |
| 1108 | 1111 | } |
| 1109 | 1112 | |
| 1110 | 1113 | /// <summary>费用单 / 收款单 / 付款单等:已审核或审核进行中的非可重提状态不可整单改(草稿/待审核/审核不通过可保存并提交)。</summary> |
| ... | ... | @@ -2784,5 +2787,40 @@ namespace NCC.Extend.WtCwdj |
| 2784 | 2787 | if (myRoles.Count == 0) return false; |
| 2785 | 2788 | return cfgRoles.Overlaps(myRoles); |
| 2786 | 2789 | } |
| 2790 | + | |
| 2791 | + /// <inheritdoc /> | |
| 2792 | + [NonAction] | |
| 2793 | + public async Task RestoreFromRecycleBinAsync(string id) | |
| 2794 | + { | |
| 2795 | + EnsureSoftDeleteColumns(); | |
| 2796 | + var entity = await _db.Queryable<WtCwdjEntity>().FirstAsync(p => p.Id == id); | |
| 2797 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 2798 | + throw NCCException.Bah("单据不存在或未在回收站"); | |
| 2799 | + await WtBillSoftDeleteHelper.RestoreHeadAndMxAsync(_db, "wt_cwdj", "wt_cwdjmx", id); | |
| 2800 | + } | |
| 2801 | + | |
| 2802 | + /// <inheritdoc /> | |
| 2803 | + [NonAction] | |
| 2804 | + public async Task PurgePhysicalAsync(string id) | |
| 2805 | + { | |
| 2806 | + EnsureSoftDeleteColumns(); | |
| 2807 | + var entity = await _db.Queryable<WtCwdjEntity>().FirstAsync(p => p.Id == id); | |
| 2808 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 2809 | + throw NCCException.Bah("仅可彻底删除回收站中的单据"); | |
| 2810 | + try | |
| 2811 | + { | |
| 2812 | + _db.BeginTran(); | |
| 2813 | + await _wtDjzyService.DeleteByCwdjAsync(id); | |
| 2814 | + await _db.Deleteable<WtCwdjmxEntity>().Where(u => u.Djbh == id).ExecuteCommandAsync(); | |
| 2815 | + var isOk = await _db.Deleteable<WtCwdjEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); | |
| 2816 | + if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1002); | |
| 2817 | + _db.CommitTran(); | |
| 2818 | + } | |
| 2819 | + catch (Exception) | |
| 2820 | + { | |
| 2821 | + _db.RollbackTran(); | |
| 2822 | + throw; | |
| 2823 | + } | |
| 2824 | + } | |
| 2787 | 2825 | } |
| 2788 | 2826 | } | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtCzdService.cs
| ... | ... | @@ -28,6 +28,7 @@ using NCC.DataEncryption; |
| 28 | 28 | using NCC.ClayObject; |
| 29 | 29 | using NCC.System.Entitys.Permission; |
| 30 | 30 | using NCC.Extend; |
| 31 | +using NCC.Extend.WtBillSoftDelete; | |
| 31 | 32 | |
| 32 | 33 | namespace NCC.Extend.WtCzd |
| 33 | 34 | { |
| ... | ... | @@ -37,7 +38,7 @@ namespace NCC.Extend.WtCzd |
| 37 | 38 | /// <remarks>TODO:盘点仓库锁与 <c>WtXsckdService.EnsureWarehouseNotLockedByPdAsync</c> 一致集成(出入库仓库校验)。</remarks> |
| 38 | 39 | [ApiDescriptionSettings(Tag = "Extend",Name = "WtCzd", Order = 200)] |
| 39 | 40 | [Route("api/Extend/[controller]")] |
| 40 | - public class WtCzdService : IWtCzdService, IDynamicApiController, ITransient | |
| 41 | + public class WtCzdService : IWtCzdService, IDynamicApiController, ITransient, IWtBillRecycleOperations | |
| 41 | 42 | { |
| 42 | 43 | private readonly ISqlSugarRepository<WtCzdEntity> _wtCzdRepository; |
| 43 | 44 | private readonly ISqlSugarRepository<WtCzdmxEntity> _wtCzdmxRepository; |
| ... | ... | @@ -47,7 +48,12 @@ namespace NCC.Extend.WtCzd |
| 47 | 48 | private readonly IUserManager _userManager; |
| 48 | 49 | private readonly WtDjzyService _wtDjzyService; |
| 49 | 50 | private readonly WtBillSummaryService _billSummaryService; |
| 51 | + private readonly IBusinessOperationLogService _businessOperationLogService; | |
| 50 | 52 | private static bool _czdAuditColsEnsured; |
| 53 | + private static bool _softDeleteColumnsEnsured; | |
| 54 | + | |
| 55 | + /// <inheritdoc /> | |
| 56 | + public WtBillRecycleBillSource BillSource => WtBillRecycleBillSource.WtCzd; | |
| 51 | 57 | |
| 52 | 58 | private const string CzdShryszDjmc = "拆装单"; |
| 53 | 59 | |
| ... | ... | @@ -78,7 +84,8 @@ namespace NCC.Extend.WtCzd |
| 78 | 84 | ISqlSugarRepository<WtSerialNumberEntity> wtSerialNumberRepository, |
| 79 | 85 | IUserManager userManager, |
| 80 | 86 | WtDjzyService wtDjzyService, |
| 81 | - WtBillSummaryService billSummaryService) | |
| 87 | + WtBillSummaryService billSummaryService, | |
| 88 | + IBusinessOperationLogService businessOperationLogService) | |
| 82 | 89 | { |
| 83 | 90 | _wtCzdRepository = wtCzdRepository; |
| 84 | 91 | _wtCzdmxRepository = wtCzdmxRepository; |
| ... | ... | @@ -88,6 +95,34 @@ namespace NCC.Extend.WtCzd |
| 88 | 95 | _userManager = userManager; |
| 89 | 96 | _wtDjzyService = wtDjzyService; |
| 90 | 97 | _billSummaryService = billSummaryService; |
| 98 | + _businessOperationLogService = businessOperationLogService; | |
| 99 | + } | |
| 100 | + | |
| 101 | + private void EnsureSoftDeleteColumns() | |
| 102 | + { | |
| 103 | + if (_softDeleteColumnsEnsured) return; | |
| 104 | + WtBillSoftDeleteHelper.EnsureBillSoftDeleteColumnsAsync(_db, | |
| 105 | + "wt_czd", "wt_czdmx", "wt_czdmx_2").GetAwaiter().GetResult(); | |
| 106 | + _softDeleteColumnsEnsured = true; | |
| 107 | + } | |
| 108 | + | |
| 109 | + private async Task SoftDeleteCzdHeadAndMxAsync(string billId, string deleteUserId) | |
| 110 | + { | |
| 111 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAndMxAsync(_db, "wt_czd", "wt_czdmx", billId, deleteUserId); | |
| 112 | + var now = DateTime.Now; | |
| 113 | + await _db.Updateable<WtCzdmx2Entity>() | |
| 114 | + .SetColumns(m => new WtCzdmx2Entity { DeleteMark = 1, DeleteTime = now, DeleteUserId = deleteUserId }) | |
| 115 | + .Where(m => m.Djbh == billId) | |
| 116 | + .ExecuteCommandAsync(); | |
| 117 | + } | |
| 118 | + | |
| 119 | + private async Task RestoreCzdHeadAndMxAsync(string billId) | |
| 120 | + { | |
| 121 | + await WtBillSoftDeleteHelper.RestoreHeadAndMxAsync(_db, "wt_czd", "wt_czdmx", billId); | |
| 122 | + await _db.Updateable<WtCzdmx2Entity>() | |
| 123 | + .SetColumns(m => new WtCzdmx2Entity { DeleteMark = 0, DeleteTime = null, DeleteUserId = null }) | |
| 124 | + .Where(m => m.Djbh == billId) | |
| 125 | + .ExecuteCommandAsync(); | |
| 91 | 126 | } |
| 92 | 127 | |
| 93 | 128 | /// <summary> |
| ... | ... | @@ -233,15 +268,28 @@ namespace NCC.Extend.WtCzd |
| 233 | 268 | } |
| 234 | 269 | |
| 235 | 270 | /// <summary> |
| 236 | - /// 获取拆装单 | |
| 271 | + /// 获取拆装单详情 | |
| 237 | 272 | /// </summary> |
| 238 | - /// <param name="id">参数</param> | |
| 239 | - /// <returns></returns> | |
| 273 | + /// <remarks> | |
| 274 | + /// 默认仅未软删;回收站只读详情传 <c>includeDeleted=true</c> 可读主表及出/入库明细。 | |
| 275 | + /// </remarks> | |
| 276 | + /// <param name="id">单据编号</param> | |
| 277 | + /// <param name="includeDeleted">为 true 时包含已软删主表及明细</param> | |
| 278 | + /// <returns>拆装单详情</returns> | |
| 279 | + /// <response code="200">成功</response> | |
| 280 | + /// <response code="404">单据不存在</response> | |
| 281 | + /// <response code="500">服务异常</response> | |
| 240 | 282 | [HttpGet("{id}")] |
| 241 | - public async Task<dynamic> GetInfo(string id) | |
| 283 | + public async Task<dynamic> GetInfo(string id, [FromQuery] bool includeDeleted = false) | |
| 242 | 284 | { |
| 285 | + EnsureSoftDeleteColumns(); | |
| 243 | 286 | EnsureCzdAuditColumns(); |
| 244 | - var entity = await _db.Queryable<WtCzdEntity>().FirstAsync(p => p.Id == id); | |
| 287 | + var entity = await _db.Queryable<WtCzdEntity>() | |
| 288 | + .Where(p => p.Id == id) | |
| 289 | + .WhereIF(!includeDeleted, p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 290 | + .FirstAsync(); | |
| 291 | + if (entity == null) | |
| 292 | + throw NCCException.Oh(ErrorCode.COM1005); | |
| 245 | 293 | var output = entity.Adapt<WtCzdInfoOutput>(); |
| 246 | 294 | output.id = entity.Id; |
| 247 | 295 | output.djzt = NormalizeCzdDjztForApi(entity.Djzt); |
| ... | ... | @@ -252,11 +300,17 @@ namespace NCC.Extend.WtCzd |
| 252 | 300 | output.billZy = await _billSummaryService.ComputeWtCzdZyByBillIdAsync(entity.Id); |
| 253 | 301 | |
| 254 | 302 | // 获取出库明细 |
| 255 | - var wtCzdmxList = await _db.Queryable<WtCzdmxEntity>().Where(w => w.Djbh == entity.Id).ToListAsync(); | |
| 303 | + var wtCzdmxList = await _db.Queryable<WtCzdmxEntity>() | |
| 304 | + .Where(w => w.Djbh == entity.Id) | |
| 305 | + .WhereIF(!includeDeleted, w => WtBillSoftDeleteHelper.IsNotDeleted(w.DeleteMark)) | |
| 306 | + .ToListAsync(); | |
| 256 | 307 | output.wtCzdmxList = wtCzdmxList.Adapt<List<WtCzdmxInfoOutput>>(); |
| 257 | 308 | |
| 258 | 309 | // 获取入库明细 |
| 259 | - var wtCzdmx2List = await _db.Queryable<WtCzdmx2Entity>().Where(w => w.Djbh == entity.Id).ToListAsync(); | |
| 310 | + var wtCzdmx2List = await _db.Queryable<WtCzdmx2Entity>() | |
| 311 | + .Where(w => w.Djbh == entity.Id) | |
| 312 | + .WhereIF(!includeDeleted, w => WtBillSoftDeleteHelper.IsNotDeleted(w.DeleteMark)) | |
| 313 | + .ToListAsync(); | |
| 260 | 314 | output.wtCzdmx2List = wtCzdmx2List.Adapt<List<WtCzdmx2InfoOutput>>(); |
| 261 | 315 | |
| 262 | 316 | // 为出库明细添加序列号信息 |
| ... | ... | @@ -288,12 +342,14 @@ namespace NCC.Extend.WtCzd |
| 288 | 342 | [HttpGet("")] |
| 289 | 343 | public async Task<dynamic> GetList([FromQuery] WtCzdListQueryInput input) |
| 290 | 344 | { |
| 345 | + EnsureSoftDeleteColumns(); | |
| 291 | 346 | EnsureCzdAuditColumns(); |
| 292 | 347 | var sidx = input.sidx == null ? "id" : input.sidx; |
| 293 | 348 | List<string> queryDjrq = input.djrq != null ? input.djrq.Split(',').ToObeject<List<string>>() : null; |
| 294 | 349 | DateTime? startDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.First()) : null; |
| 295 | 350 | DateTime? endDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.Last()) : null; |
| 296 | 351 | var data = await _db.Queryable<WtCzdEntity>() |
| 352 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 297 | 353 | .WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id)) |
| 298 | 354 | .WhereIF(queryDjrq != null, |
| 299 | 355 | p => p.Djrq >= new DateTime(startDjrq.ToDate().Year, startDjrq.ToDate().Month, |
| ... | ... | @@ -467,12 +523,14 @@ namespace NCC.Extend.WtCzd |
| 467 | 523 | [NonAction] |
| 468 | 524 | public async Task<dynamic> GetNoPagingList([FromQuery] WtCzdListQueryInput input) |
| 469 | 525 | { |
| 526 | + EnsureSoftDeleteColumns(); | |
| 470 | 527 | EnsureCzdAuditColumns(); |
| 471 | 528 | var sidx = input.sidx == null ? "id" : input.sidx; |
| 472 | 529 | List<string> queryDjrq = input.djrq != null ? input.djrq.Split(',').ToObeject<List<string>>() : null; |
| 473 | 530 | DateTime? startDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.First()) : null; |
| 474 | 531 | DateTime? endDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.Last()) : null; |
| 475 | 532 | var data = await _db.Queryable<WtCzdEntity>() |
| 533 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 476 | 534 | .WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id)) |
| 477 | 535 | .WhereIF(queryDjrq != null, p => p.Djrq >= new DateTime(startDjrq.ToDate().Year, startDjrq.ToDate().Month, startDjrq.ToDate().Day, 0, 0, 0)) |
| 478 | 536 | .WhereIF(queryDjrq != null, p => p.Djrq <= new DateTime(endDjrq.ToDate().Year, endDjrq.ToDate().Month, endDjrq.ToDate().Day, 23, 59, 59)) |
| ... | ... | @@ -573,33 +631,17 @@ namespace NCC.Extend.WtCzd |
| 573 | 631 | [HttpPost("batchRemove")] |
| 574 | 632 | public async Task BatchRemove([FromBody] List<string> ids) |
| 575 | 633 | { |
| 634 | + EnsureSoftDeleteColumns(); | |
| 576 | 635 | EnsureCzdAuditColumns(); |
| 577 | - var entitys = await _db.Queryable<WtCzdEntity>().In(it => it.Id, ids).ToListAsync(); | |
| 578 | - if (entitys.Count > 0) | |
| 636 | + var entitys = await _db.Queryable<WtCzdEntity>() | |
| 637 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 638 | + .In(it => it.Id, ids).ToListAsync(); | |
| 639 | + var uid = _userManager.UserId ?? ""; | |
| 640 | + foreach (var entity in entitys) | |
| 579 | 641 | { |
| 580 | - try | |
| 581 | - { | |
| 582 | - _db.BeginTran(); | |
| 583 | - | |
| 584 | - foreach (var entity in entitys) | |
| 585 | - { | |
| 586 | - ThrowIfCzdCannotDelete(entity); | |
| 587 | - } | |
| 588 | - | |
| 589 | - await _db.Deleteable<WtCzdEntity>().In(d => d.Id, ids).ExecuteCommandAsync(); | |
| 590 | - await _db.Deleteable<WtCzdmxEntity>().In(u => u.Djbh, ids).ExecuteCommandAsync(); | |
| 591 | - await _db.Deleteable<WtCzdmx2Entity>().In(u => u.Djbh, ids).ExecuteCommandAsync(); | |
| 592 | - | |
| 593 | - foreach (var id in ids) | |
| 594 | - await _wtDjzyService.DeleteByCzdAsync(id); | |
| 595 | - | |
| 596 | - _db.CommitTran(); | |
| 597 | - } | |
| 598 | - catch (Exception) | |
| 599 | - { | |
| 600 | - _db.RollbackTran(); | |
| 601 | - throw NCCException.Oh(ErrorCode.COM1002); | |
| 602 | - } | |
| 642 | + ThrowIfCzdCannotDelete(entity); | |
| 643 | + await SoftDeleteCzdHeadAndMxAsync(entity.Id, uid); | |
| 644 | + await _businessOperationLogService.WriteAsync("拆装单", "标记删除", "WtCzd", entity.Id, $"标记删除 {entity.Id}"); | |
| 603 | 645 | } |
| 604 | 646 | } |
| 605 | 647 | |
| ... | ... | @@ -722,26 +764,15 @@ namespace NCC.Extend.WtCzd |
| 722 | 764 | [HttpDelete("{id}")] |
| 723 | 765 | public async Task Delete(string id) |
| 724 | 766 | { |
| 767 | + EnsureSoftDeleteColumns(); | |
| 725 | 768 | EnsureCzdAuditColumns(); |
| 726 | - var entity = await _db.Queryable<WtCzdEntity>().FirstAsync(p => p.Id == id); | |
| 769 | + var entity = await _db.Queryable<WtCzdEntity>() | |
| 770 | + .Where(p => p.Id == id && WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 771 | + .FirstAsync(); | |
| 727 | 772 | _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005); |
| 728 | 773 | ThrowIfCzdCannotDelete(entity); |
| 729 | - try | |
| 730 | - { | |
| 731 | - _db.BeginTran(); | |
| 732 | - | |
| 733 | - await _db.Deleteable<WtCzdEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); | |
| 734 | - await _db.Deleteable<WtCzdmxEntity>().Where(u => u.Djbh == id).ExecuteCommandAsync(); | |
| 735 | - await _db.Deleteable<WtCzdmx2Entity>().Where(u => u.Djbh == id).ExecuteCommandAsync(); | |
| 736 | - await _wtDjzyService.DeleteByCzdAsync(id); | |
| 737 | - | |
| 738 | - _db.CommitTran(); | |
| 739 | - } | |
| 740 | - catch (Exception) | |
| 741 | - { | |
| 742 | - _db.RollbackTran(); | |
| 743 | - throw NCCException.Oh(ErrorCode.COM1002); | |
| 744 | - } | |
| 774 | + await SoftDeleteCzdHeadAndMxAsync(id, _userManager.UserId ?? ""); | |
| 775 | + await _businessOperationLogService.WriteAsync("拆装单", "标记删除", "WtCzd", id, $"标记删除 {id}"); | |
| 745 | 776 | } |
| 746 | 777 | |
| 747 | 778 | /// <summary> |
| ... | ... | @@ -1736,5 +1767,41 @@ namespace NCC.Extend.WtCzd |
| 1736 | 1767 | _ => "未知状态" |
| 1737 | 1768 | }; |
| 1738 | 1769 | } |
| 1770 | + | |
| 1771 | + /// <inheritdoc /> | |
| 1772 | + [NonAction] | |
| 1773 | + public async Task RestoreFromRecycleBinAsync(string id) | |
| 1774 | + { | |
| 1775 | + EnsureSoftDeleteColumns(); | |
| 1776 | + var entity = await _db.Queryable<WtCzdEntity>().FirstAsync(p => p.Id == id); | |
| 1777 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 1778 | + throw NCCException.Bah("单据不存在或未在回收站"); | |
| 1779 | + await RestoreCzdHeadAndMxAsync(id); | |
| 1780 | + } | |
| 1781 | + | |
| 1782 | + /// <inheritdoc /> | |
| 1783 | + [NonAction] | |
| 1784 | + public async Task PurgePhysicalAsync(string id) | |
| 1785 | + { | |
| 1786 | + EnsureSoftDeleteColumns(); | |
| 1787 | + var entity = await _db.Queryable<WtCzdEntity>().FirstAsync(p => p.Id == id); | |
| 1788 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 1789 | + throw NCCException.Bah("仅可彻底删除回收站中的单据"); | |
| 1790 | + try | |
| 1791 | + { | |
| 1792 | + _db.BeginTran(); | |
| 1793 | + await _db.Deleteable<WtCzdmxEntity>().Where(u => u.Djbh == id).ExecuteCommandAsync(); | |
| 1794 | + await _db.Deleteable<WtCzdmx2Entity>().Where(u => u.Djbh == id).ExecuteCommandAsync(); | |
| 1795 | + var isOk = await _db.Deleteable<WtCzdEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); | |
| 1796 | + if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1002); | |
| 1797 | + await _wtDjzyService.DeleteByCzdAsync(id); | |
| 1798 | + _db.CommitTran(); | |
| 1799 | + } | |
| 1800 | + catch (Exception) | |
| 1801 | + { | |
| 1802 | + _db.RollbackTran(); | |
| 1803 | + throw NCCException.Oh(ErrorCode.COM1002); | |
| 1804 | + } | |
| 1805 | + } | |
| 1739 | 1806 | } |
| 1740 | 1807 | } | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtFpsqService.cs
| 1 | 1 | using NCC.Common.Core.Manager; |
| 2 | +using NCC.Common.Enum; | |
| 2 | 3 | using NCC.Common.Extension; |
| 3 | 4 | using NCC.Common.Filter; |
| 4 | 5 | using NCC.Dependency; |
| ... | ... | @@ -6,7 +7,9 @@ using NCC.DynamicApiController; |
| 6 | 7 | using NCC.FriendlyException; |
| 7 | 8 | using NCC.Extend.Entitys; |
| 8 | 9 | using NCC.Extend.Entitys.Dto.WtFpsq; |
| 10 | +using NCC.Extend.Interfaces; | |
| 9 | 11 | using NCC.Extend.Interfaces.WtFpsq; |
| 12 | +using NCC.Extend.WtBillSoftDelete; | |
| 10 | 13 | using NCC.System.Entitys.Permission; |
| 11 | 14 | using NCC.Extend; |
| 12 | 15 | using NCC.Extend.Entitys.Dto; |
| ... | ... | @@ -25,12 +28,17 @@ namespace NCC.Extend.WtFpsq |
| 25 | 28 | /// </summary> |
| 26 | 29 | [ApiDescriptionSettings(Tag = "Extend", Name = "WtFpsq", Order = 200)] |
| 27 | 30 | [Route("api/Extend/[controller]")] |
| 28 | - public class WtFpsqService : IWtFpsqService, IDynamicApiController, ITransient | |
| 31 | + public class WtFpsqService : IWtFpsqService, IDynamicApiController, ITransient, IWtBillRecycleOperations | |
| 29 | 32 | { |
| 30 | 33 | private readonly ISqlSugarRepository<WtFpsqEntity> _repo; |
| 31 | 34 | private readonly SqlSugarScope _db; |
| 32 | 35 | private readonly IUserManager _userManager; |
| 33 | 36 | private readonly WtFpsqWorkflowHelper _workflow; |
| 37 | + private readonly IBusinessOperationLogService _businessOperationLogService; | |
| 38 | + private static bool _softDeleteColumnsEnsured; | |
| 39 | + | |
| 40 | + /// <inheritdoc /> | |
| 41 | + public WtBillRecycleBillSource BillSource => WtBillRecycleBillSource.WtFpsq; | |
| 34 | 42 | |
| 35 | 43 | private static bool _fpsqJsdwChecked; |
| 36 | 44 | private static bool _fpsqJsdwmcChecked; |
| ... | ... | @@ -76,12 +84,21 @@ namespace NCC.Extend.WtFpsq |
| 76 | 84 | public WtFpsqService( |
| 77 | 85 | ISqlSugarRepository<WtFpsqEntity> repo, |
| 78 | 86 | IUserManager userManager, |
| 79 | - WtFpsqWorkflowHelper workflow) | |
| 87 | + WtFpsqWorkflowHelper workflow, | |
| 88 | + IBusinessOperationLogService businessOperationLogService) | |
| 80 | 89 | { |
| 81 | 90 | _repo = repo; |
| 82 | 91 | _db = _repo.Context; |
| 83 | 92 | _userManager = userManager; |
| 84 | 93 | _workflow = workflow; |
| 94 | + _businessOperationLogService = businessOperationLogService; | |
| 95 | + } | |
| 96 | + | |
| 97 | + private void EnsureSoftDeleteColumns() | |
| 98 | + { | |
| 99 | + if (_softDeleteColumnsEnsured) return; | |
| 100 | + WtBillSoftDeleteHelper.EnsureBillSoftDeleteColumnsAsync(_db, "wt_fpsq").GetAwaiter().GetResult(); | |
| 101 | + _softDeleteColumnsEnsured = true; | |
| 85 | 102 | } |
| 86 | 103 | |
| 87 | 104 | /// <summary> |
| ... | ... | @@ -254,12 +271,25 @@ namespace NCC.Extend.WtFpsq |
| 254 | 271 | /// <summary> |
| 255 | 272 | /// 发票申请详情 |
| 256 | 273 | /// </summary> |
| 274 | + /// <remarks> | |
| 275 | + /// 默认仅未软删;回收站只读详情传 <c>includeDeleted=true</c>。 | |
| 276 | + /// </remarks> | |
| 277 | + /// <param name="id">单据编号</param> | |
| 278 | + /// <param name="includeDeleted">为 true 时允许读取已软删单据</param> | |
| 279 | + /// <returns>发票申请详情</returns> | |
| 280 | + /// <response code="200">成功</response> | |
| 281 | + /// <response code="404">单据不存在</response> | |
| 282 | + /// <response code="500">服务异常</response> | |
| 257 | 283 | [HttpGet("{id}")] |
| 258 | - public async Task<dynamic> GetInfo(string id) | |
| 284 | + public async Task<dynamic> GetInfo(string id, [FromQuery] bool includeDeleted = false) | |
| 259 | 285 | { |
| 286 | + EnsureSoftDeleteColumns(); | |
| 260 | 287 | _workflow.EnsureFpsqAuditColumns(); |
| 261 | 288 | EnsureFpsqJsdwColumns(); |
| 262 | - var entity = await _db.Queryable<WtFpsqEntity>().FirstAsync(p => p.Id == id); | |
| 289 | + var entity = await _db.Queryable<WtFpsqEntity>() | |
| 290 | + .Where(p => p.Id == id) | |
| 291 | + .WhereIF(!includeDeleted, p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 292 | + .FirstAsync(); | |
| 263 | 293 | if (entity == null) |
| 264 | 294 | throw NCCException.Bah("发票申请不存在"); |
| 265 | 295 | |
| ... | ... | @@ -283,6 +313,7 @@ namespace NCC.Extend.WtFpsq |
| 283 | 313 | [HttpGet("")] |
| 284 | 314 | public async Task<dynamic> GetList([FromQuery] WtFpsqListQueryInput input) |
| 285 | 315 | { |
| 316 | + EnsureSoftDeleteColumns(); | |
| 286 | 317 | _workflow.EnsureFpsqAuditColumns(); |
| 287 | 318 | EnsureFpsqJsdwColumns(); |
| 288 | 319 | var sidx = string.IsNullOrEmpty(input.sidx) ? "id" : input.sidx; |
| ... | ... | @@ -300,6 +331,7 @@ namespace NCC.Extend.WtFpsq |
| 300 | 331 | var hasDjrqRange = startDjrq != null && endDjrq != null; |
| 301 | 332 | |
| 302 | 333 | var data = await _db.Queryable<WtFpsqEntity>() |
| 334 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 303 | 335 | .WhereIF(!string.IsNullOrEmpty(input.keyword), |
| 304 | 336 | p => p.Id.Contains(input.keyword) || SqlFunc.Contains(p.Gmfmc, input.keyword) |
| 305 | 337 | || SqlFunc.Contains(p.Nsrsbh, input.keyword)) |
| ... | ... | @@ -513,9 +545,12 @@ namespace NCC.Extend.WtFpsq |
| 513 | 545 | [HttpDelete("{id}")] |
| 514 | 546 | public async Task Delete(string id) |
| 515 | 547 | { |
| 548 | + EnsureSoftDeleteColumns(); | |
| 516 | 549 | _workflow.EnsureFpsqAuditColumns(); |
| 517 | 550 | EnsureFpsqJsdwColumns(); |
| 518 | - var existing = await _db.Queryable<WtFpsqEntity>().FirstAsync(p => p.Id == id); | |
| 551 | + var existing = await _db.Queryable<WtFpsqEntity>() | |
| 552 | + .Where(p => p.Id == id && WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 553 | + .FirstAsync(); | |
| 519 | 554 | if (existing == null) |
| 520 | 555 | throw NCCException.Bah("发票申请不存在"); |
| 521 | 556 | |
| ... | ... | @@ -526,7 +561,31 @@ namespace NCC.Extend.WtFpsq |
| 526 | 561 | if (existing.Djzt != "草稿" && existing.Djzt != "审核不通过") |
| 527 | 562 | throw NCCException.Bah("仅草稿或审核不通过状态可删除"); |
| 528 | 563 | |
| 529 | - await _db.Deleteable<WtFpsqEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); | |
| 564 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAsync(_db, "wt_fpsq", id, _userManager.UserId ?? ""); | |
| 565 | + await _businessOperationLogService.WriteAsync("发票申请", "标记删除", "WtFpsq", id, $"标记删除 {id}"); | |
| 566 | + } | |
| 567 | + | |
| 568 | + /// <inheritdoc /> | |
| 569 | + [NonAction] | |
| 570 | + public async Task RestoreFromRecycleBinAsync(string id) | |
| 571 | + { | |
| 572 | + EnsureSoftDeleteColumns(); | |
| 573 | + var entity = await _db.Queryable<WtFpsqEntity>().FirstAsync(p => p.Id == id); | |
| 574 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 575 | + throw NCCException.Bah("单据不存在或未在回收站"); | |
| 576 | + await WtBillSoftDeleteHelper.RestoreHeadAsync(_db, "wt_fpsq", id); | |
| 577 | + } | |
| 578 | + | |
| 579 | + /// <inheritdoc /> | |
| 580 | + [NonAction] | |
| 581 | + public async Task PurgePhysicalAsync(string id) | |
| 582 | + { | |
| 583 | + EnsureSoftDeleteColumns(); | |
| 584 | + var entity = await _db.Queryable<WtFpsqEntity>().FirstAsync(p => p.Id == id); | |
| 585 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 586 | + throw NCCException.Bah("仅可彻底删除回收站中的单据"); | |
| 587 | + var isOk = await _db.Deleteable<WtFpsqEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); | |
| 588 | + if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1002); | |
| 530 | 589 | } |
| 531 | 590 | |
| 532 | 591 | /// <summary> | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtFysrdService.cs
| ... | ... | @@ -5,7 +5,9 @@ using NCC.Common.Filter; |
| 5 | 5 | using NCC.Dependency; |
| 6 | 6 | using NCC.DynamicApiController; |
| 7 | 7 | using NCC.FriendlyException; |
| 8 | +using NCC.Extend.Interfaces; | |
| 8 | 9 | using NCC.Extend.Interfaces.WtFysrd; |
| 10 | +using NCC.Extend.WtBillSoftDelete; | |
| 9 | 11 | using Mapster; |
| 10 | 12 | using Microsoft.AspNetCore.Mvc; |
| 11 | 13 | using SqlSugar; |
| ... | ... | @@ -33,13 +35,18 @@ namespace NCC.Extend.WtFysrd |
| 33 | 35 | /// </summary> |
| 34 | 36 | [ApiDescriptionSettings(Tag = "Extend",Name = "WtFysrd", Order = 200)] |
| 35 | 37 | [Route("api/Extend/[controller]")] |
| 36 | - public class WtFysrdService : IWtFysrdService, IDynamicApiController, ITransient | |
| 38 | + public class WtFysrdService : IWtFysrdService, IDynamicApiController, ITransient, IWtBillRecycleOperations | |
| 37 | 39 | { |
| 38 | 40 | private readonly ISqlSugarRepository<WtFysrdEntity> _wtFysrdRepository; |
| 39 | 41 | private readonly ISqlSugarRepository<WtFysrdMxEntity> _wtFysrdMxRepository; |
| 40 | 42 | private readonly SqlSugarScope _db; |
| 41 | 43 | private readonly IUserManager _userManager; |
| 42 | 44 | private readonly WtFysrdWorkflowHelper _fysrdWorkflow; |
| 45 | + private readonly IBusinessOperationLogService _businessOperationLogService; | |
| 46 | + private static bool _softDeleteColumnsEnsured; | |
| 47 | + | |
| 48 | + /// <inheritdoc /> | |
| 49 | + public WtBillRecycleBillSource BillSource => WtBillRecycleBillSource.WtFysrd; | |
| 43 | 50 | |
| 44 | 51 | /// <summary> |
| 45 | 52 | /// 初始化一个<see cref="WtFysrdService"/>类型的新实例 |
| ... | ... | @@ -48,13 +55,22 @@ namespace NCC.Extend.WtFysrd |
| 48 | 55 | ISqlSugarRepository<WtFysrdEntity> wtFysrdRepository, |
| 49 | 56 | ISqlSugarRepository<WtFysrdMxEntity> wtFysrdMxRepository, |
| 50 | 57 | IUserManager userManager, |
| 51 | - WtFysrdWorkflowHelper fysrdWorkflow) | |
| 58 | + WtFysrdWorkflowHelper fysrdWorkflow, | |
| 59 | + IBusinessOperationLogService businessOperationLogService) | |
| 52 | 60 | { |
| 53 | 61 | _wtFysrdRepository = wtFysrdRepository; |
| 54 | 62 | _db = _wtFysrdRepository.Context; |
| 55 | 63 | _wtFysrdMxRepository = wtFysrdMxRepository; |
| 56 | 64 | _userManager = userManager; |
| 57 | 65 | _fysrdWorkflow = fysrdWorkflow; |
| 66 | + _businessOperationLogService = businessOperationLogService; | |
| 67 | + } | |
| 68 | + | |
| 69 | + private void EnsureSoftDeleteColumns() | |
| 70 | + { | |
| 71 | + if (_softDeleteColumnsEnsured) return; | |
| 72 | + WtBillSoftDeleteHelper.EnsureBillSoftDeleteColumnsAsync(_db, "wt_fysrd", "wt_fysrd_mx").GetAwaiter().GetResult(); | |
| 73 | + _softDeleteColumnsEnsured = true; | |
| 58 | 74 | } |
| 59 | 75 | |
| 60 | 76 | private static bool IsLockedForEdit(string djzt) |
| ... | ... | @@ -146,15 +162,27 @@ namespace NCC.Extend.WtFysrd |
| 146 | 162 | } |
| 147 | 163 | |
| 148 | 164 | /// <summary> |
| 149 | - /// 获取费用单 | |
| 165 | + /// 获取费用单详情 | |
| 150 | 166 | /// </summary> |
| 151 | - /// <param name="id">参数</param> | |
| 152 | - /// <returns></returns> | |
| 167 | + /// <remarks> | |
| 168 | + /// 默认仅未软删;回收站只读详情传 <c>includeDeleted=true</c> 可读主表及明细。 | |
| 169 | + /// </remarks> | |
| 170 | + /// <param name="id">单据编号</param> | |
| 171 | + /// <param name="includeDeleted">为 true 时包含已软删主表及明细</param> | |
| 172 | + /// <returns>费用单详情</returns> | |
| 173 | + /// <response code="200">成功</response> | |
| 174 | + /// <response code="404">单据不存在</response> | |
| 175 | + /// <response code="500">服务异常</response> | |
| 153 | 176 | [HttpGet("{id}")] |
| 154 | - public async Task<dynamic> GetInfo(string id) | |
| 177 | + public async Task<dynamic> GetInfo(string id, [FromQuery] bool includeDeleted = false) | |
| 155 | 178 | { |
| 179 | + EnsureSoftDeleteColumns(); | |
| 156 | 180 | _fysrdWorkflow.EnsureFysrdAuditColumns(); |
| 157 | - var entity = await _db.Queryable<WtFysrdEntity>().FirstAsync(p => p.Id == id); | |
| 181 | + var entity = await _db.Queryable<WtFysrdEntity>() | |
| 182 | + .Where(p => p.Id == id) | |
| 183 | + .WhereIF(!includeDeleted, p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 184 | + .FirstAsync(); | |
| 185 | + if (entity == null) throw NCCException.Oh(ErrorCode.COM1005); | |
| 158 | 186 | var output = entity.Adapt<WtFysrdInfoOutput>(); |
| 159 | 187 | output.djlx = WtFysrdWorkflowHelper.NormalizeOtherIncomeDjlx(entity.Djlx) ?? entity.Djlx; |
| 160 | 188 | output.wldw = string.IsNullOrWhiteSpace(entity.Wldw) ? entity.Fkdw : entity.Wldw; |
| ... | ... | @@ -169,7 +197,10 @@ namespace NCC.Extend.WtFysrd |
| 169 | 197 | var w = await _db.Queryable<WtWldwEntity>().FirstAsync(x => x.Id == wldwId); |
| 170 | 198 | output.wldwmc = w?.Dwmc; |
| 171 | 199 | } |
| 172 | - var wtFysrdMxList = await _db.Queryable<WtFysrdMxEntity>().Where(w => w.Djbh == entity.Id).ToListAsync(); | |
| 200 | + var wtFysrdMxList = await _db.Queryable<WtFysrdMxEntity>() | |
| 201 | + .Where(w => w.Djbh == entity.Id) | |
| 202 | + .WhereIF(!includeDeleted, w => WtBillSoftDeleteHelper.IsNotDeleted(w.DeleteMark)) | |
| 203 | + .ToListAsync(); | |
| 173 | 204 | output.wtFysrdMxList = wtFysrdMxList.Adapt<List<WtFysrdMxInfoOutput>>(); |
| 174 | 205 | WtFysrdMxCwHelper.EnrichMxInfoOutput(output.wtFysrdMxList, wtFysrdMxList); |
| 175 | 206 | return output; |
| ... | ... | @@ -193,12 +224,14 @@ namespace NCC.Extend.WtFysrd |
| 193 | 224 | [HttpGet("")] |
| 194 | 225 | public async Task<dynamic> GetList([FromQuery] WtFysrdListQueryInput input) |
| 195 | 226 | { |
| 227 | + EnsureSoftDeleteColumns(); | |
| 196 | 228 | _fysrdWorkflow.EnsureFysrdAuditColumns(); |
| 197 | 229 | var orderBy = ResolveFysrdListOrderBy(input.sidx, input.sort); |
| 198 | 230 | List<string> queryDjrq = input.djrq != null ? input.djrq.Split(',').ToObeject<List<string>>() : null; |
| 199 | 231 | DateTime? startDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.First()) : null; |
| 200 | 232 | DateTime? endDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.Last()) : null; |
| 201 | 233 | var data = await _db.Queryable<WtFysrdEntity>() |
| 234 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 202 | 235 | .WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id)) |
| 203 | 236 | .WhereIF(queryDjrq != null, p => p.Djrq >= new DateTime(startDjrq.ToDate().Year, startDjrq.ToDate().Month, startDjrq.ToDate().Day, 0, 0, 0)) |
| 204 | 237 | .WhereIF(queryDjrq != null, p => p.Djrq <= new DateTime(endDjrq.ToDate().Year, endDjrq.ToDate().Month, endDjrq.ToDate().Day, 23, 59, 59)) |
| ... | ... | @@ -300,12 +333,14 @@ namespace NCC.Extend.WtFysrd |
| 300 | 333 | [NonAction] |
| 301 | 334 | public async Task<dynamic> GetNoPagingList([FromQuery] WtFysrdListQueryInput input) |
| 302 | 335 | { |
| 336 | + EnsureSoftDeleteColumns(); | |
| 303 | 337 | _fysrdWorkflow.EnsureFysrdAuditColumns(); |
| 304 | 338 | var orderBy = ResolveFysrdListOrderBy(input.sidx, input.sort); |
| 305 | 339 | List<string> queryDjrq = input.djrq != null ? input.djrq.Split(',').ToObeject<List<string>>() : null; |
| 306 | 340 | DateTime? startDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.First()) : null; |
| 307 | 341 | DateTime? endDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.Last()) : null; |
| 308 | 342 | var data = await _db.Queryable<WtFysrdEntity>() |
| 343 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 309 | 344 | .WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id)) |
| 310 | 345 | .WhereIF(queryDjrq != null, p => p.Djrq >= new DateTime(startDjrq.ToDate().Year, startDjrq.ToDate().Month, startDjrq.ToDate().Day, 0, 0, 0)) |
| 311 | 346 | .WhereIF(queryDjrq != null, p => p.Djrq <= new DateTime(endDjrq.ToDate().Year, endDjrq.ToDate().Month, endDjrq.ToDate().Day, 23, 59, 59)) |
| ... | ... | @@ -392,40 +427,29 @@ namespace NCC.Extend.WtFysrd |
| 392 | 427 | } |
| 393 | 428 | |
| 394 | 429 | /// <summary> |
| 395 | - /// 批量删除费用单 | |
| 430 | + /// 批量删除费用单(标记删除) | |
| 396 | 431 | /// </summary> |
| 397 | 432 | /// <param name="ids">主键数组</param> |
| 398 | 433 | /// <returns></returns> |
| 399 | 434 | [HttpPost("batchRemove")] |
| 400 | 435 | public async Task BatchRemove([FromBody] List<string> ids) |
| 401 | 436 | { |
| 402 | - var entitys = await _db.Queryable<WtFysrdEntity>().In(it => it.Id, ids).ToListAsync(); | |
| 437 | + EnsureSoftDeleteColumns(); | |
| 438 | + var entitys = await _db.Queryable<WtFysrdEntity>() | |
| 439 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 440 | + .In(it => it.Id, ids) | |
| 441 | + .ToListAsync(); | |
| 403 | 442 | foreach (var e in entitys) |
| 404 | 443 | { |
| 405 | 444 | EnsureDraftOnlyDeleteForOtherIncomeBill(e); |
| 406 | 445 | if (!IsDeletableState(e.Djzt)) |
| 407 | 446 | throw NCCException.Bah($"单据 {e.Id} 当前状态不允许删除"); |
| 408 | 447 | } |
| 409 | - if (entitys.Count > 0) | |
| 448 | + var uid = _userManager.UserId ?? ""; | |
| 449 | + foreach (var id in entitys.Select(e => e.Id)) | |
| 410 | 450 | { |
| 411 | - try | |
| 412 | - { | |
| 413 | - //开启事务 | |
| 414 | - _db.BeginTran(); | |
| 415 | - //批量删除费用单 | |
| 416 | - await _db.Deleteable<WtFysrdEntity>().In(d => d.Id,ids).ExecuteCommandAsync(); | |
| 417 | - | |
| 418 | - //清空子表数据 | |
| 419 | - await _db.Deleteable<WtFysrdMxEntity>().In(u => u.Djbh,ids).ExecuteCommandAsync(); | |
| 420 | - //关闭事务 | |
| 421 | - _db.CommitTran(); | |
| 422 | - } | |
| 423 | - catch (Exception) | |
| 424 | - { | |
| 425 | - //回滚事务 | |
| 426 | - _db.RollbackTran(); | |
| 427 | - throw NCCException.Oh(ErrorCode.COM1002); | |
| 428 | - } | |
| 451 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAndMxAsync(_db, "wt_fysrd", "wt_fysrd_mx", id, uid); | |
| 452 | + await _businessOperationLogService.WriteAsync("费用收入单", "标记删除", "WtFysrd", id, $"标记删除费用收入单 {id}"); | |
| 429 | 453 | } |
| 430 | 454 | } |
| 431 | 455 | |
| ... | ... | @@ -506,36 +530,55 @@ namespace NCC.Extend.WtFysrd |
| 506 | 530 | } |
| 507 | 531 | |
| 508 | 532 | /// <summary> |
| 509 | - /// 删除费用单 | |
| 533 | + /// 删除费用单(标记删除,进回收站) | |
| 510 | 534 | /// </summary> |
| 511 | 535 | /// <returns></returns> |
| 512 | 536 | [HttpDelete("{id}")] |
| 513 | 537 | public async Task Delete(string id) |
| 514 | 538 | { |
| 515 | - var entity = await _db.Queryable<WtFysrdEntity>().FirstAsync(p => p.Id == id); | |
| 539 | + EnsureSoftDeleteColumns(); | |
| 540 | + var entity = await _db.Queryable<WtFysrdEntity>() | |
| 541 | + .Where(p => p.Id == id && WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 542 | + .FirstAsync(); | |
| 516 | 543 | _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005); |
| 517 | 544 | EnsureDraftOnlyDeleteForOtherIncomeBill(entity); |
| 518 | 545 | if (!IsDeletableState(entity.Djzt)) |
| 519 | 546 | throw NCCException.Bah("当前单据状态不允许删除"); |
| 547 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAndMxAsync(_db, "wt_fysrd", "wt_fysrd_mx", id, _userManager.UserId ?? ""); | |
| 548 | + await _businessOperationLogService.WriteAsync("费用收入单", "标记删除", "WtFysrd", id, $"标记删除费用收入单 {id}"); | |
| 549 | + } | |
| 550 | + | |
| 551 | + /// <inheritdoc /> | |
| 552 | + [NonAction] | |
| 553 | + public async Task RestoreFromRecycleBinAsync(string id) | |
| 554 | + { | |
| 555 | + EnsureSoftDeleteColumns(); | |
| 556 | + var entity = await _db.Queryable<WtFysrdEntity>().FirstAsync(p => p.Id == id); | |
| 557 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 558 | + throw NCCException.Bah("单据不存在或未在回收站"); | |
| 559 | + await WtBillSoftDeleteHelper.RestoreHeadAndMxAsync(_db, "wt_fysrd", "wt_fysrd_mx", id); | |
| 560 | + } | |
| 561 | + | |
| 562 | + /// <inheritdoc /> | |
| 563 | + [NonAction] | |
| 564 | + public async Task PurgePhysicalAsync(string id) | |
| 565 | + { | |
| 566 | + EnsureSoftDeleteColumns(); | |
| 567 | + var entity = await _db.Queryable<WtFysrdEntity>().FirstAsync(p => p.Id == id); | |
| 568 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 569 | + throw NCCException.Bah("仅可彻底删除回收站中的单据"); | |
| 520 | 570 | try |
| 521 | 571 | { |
| 522 | - //开启事务 | |
| 523 | 572 | _db.BeginTran(); |
| 524 | - | |
| 525 | - //删除费用单记录 | |
| 526 | - await _db.Deleteable<WtFysrdEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); | |
| 527 | - | |
| 528 | - //清空子表数据 | |
| 529 | 573 | await _db.Deleteable<WtFysrdMxEntity>().Where(u => u.Djbh == id).ExecuteCommandAsync(); |
| 530 | - | |
| 531 | - //关闭事务 | |
| 574 | + var isOk = await _db.Deleteable<WtFysrdEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); | |
| 575 | + if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1002); | |
| 532 | 576 | _db.CommitTran(); |
| 533 | 577 | } |
| 534 | 578 | catch (Exception) |
| 535 | 579 | { |
| 536 | - //回滚事务 | |
| 537 | 580 | _db.RollbackTran(); |
| 538 | - throw NCCException.Oh(ErrorCode.COM1002); | |
| 581 | + throw; | |
| 539 | 582 | } |
| 540 | 583 | } |
| 541 | 584 | } | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtHyService.cs
| ... | ... | @@ -47,6 +47,8 @@ namespace NCC.Extend.WtHy |
| 47 | 47 | private static int _hyLegacyArchiveMigrationDone; |
| 48 | 48 | private static readonly object AdjustExpireButtonLock = new object(); |
| 49 | 49 | private static bool _adjustExpireButtonReady; |
| 50 | + private static readonly object EditBzButtonLock = new object(); | |
| 51 | + private static bool _editBzButtonReady; | |
| 50 | 52 | |
| 51 | 53 | /// <summary>客户档案菜单模块 ID(base_module.F_Id)</summary> |
| 52 | 54 | public const string HyModuleId = "673429743055406341"; |
| ... | ... | @@ -54,6 +56,9 @@ namespace NCC.Extend.WtHy |
| 54 | 56 | /// <summary>调整权益期限按钮编码</summary> |
| 55 | 57 | public const string BtnAdjustKjqyExpire = "btn_adjustKjqyExpire"; |
| 56 | 58 | |
| 59 | + /// <summary>修改备注按钮编码</summary> | |
| 60 | + public const string BtnEditBz = "btn_editBz"; | |
| 61 | + | |
| 57 | 62 | private readonly ISqlSugarRepository<WtHyEntity> _wtHyRepository; |
| 58 | 63 | private readonly SqlSugarScope _db; |
| 59 | 64 | private readonly IUserManager _userManager; |
| ... | ... | @@ -77,6 +82,7 @@ namespace NCC.Extend.WtHy |
| 77 | 82 | EnsureHyArchiveColumns(); |
| 78 | 83 | EnsureHyLegacyArchiveData(); |
| 79 | 84 | EnsureAdjustKjqyExpireButton(); |
| 85 | + EnsureEditBzButton(); | |
| 80 | 86 | } |
| 81 | 87 | |
| 82 | 88 | private void EnsureHyLegacyArchiveData() |
| ... | ... | @@ -427,6 +433,7 @@ namespace NCC.Extend.WtHy |
| 427 | 433 | sr=it.Sr, |
| 428 | 434 | qd=it.Qd, |
| 429 | 435 | dgy=it.Dgy, |
| 436 | + dgy_xm = SqlFunc.Subqueryable<UserEntity>().Where(u => u.Id == it.Dgy).Select(u => u.RealName), | |
| 430 | 437 | wldwmc=it.Wldwmc, |
| 431 | 438 | hm=it.Hm, |
| 432 | 439 | skzh=it.Skzh, |
| ... | ... | @@ -463,14 +470,15 @@ namespace NCC.Extend.WtHy |
| 463 | 470 | { |
| 464 | 471 | exportData = await this.GetNoPagingList(input); |
| 465 | 472 | } |
| 466 | - List<ParamsModel> paramList = "[{\"value\":\"客户编号\",\"field\":\"khbh\"},{\"value\":\"建档日期\",\"field\":\"jdrq\"},{\"value\":\"渠道\",\"field\":\"qd\"},{\"value\":\"手机号\",\"field\":\"sjh\"},{\"value\":\"姓名\",\"field\":\"xm\"},{\"value\":\"性别\",\"field\":\"xb\"},{\"value\":\"生日\",\"field\":\"sr\"},{\"value\":\"导购员\",\"field\":\"dgy\"},{\"value\":\"企业名称\",\"field\":\"wldwmc\"},{\"value\":\"企业电话\",\"field\":\"hm\"},{\"value\":\"企业税号\",\"field\":\"skzh\"},{\"value\":\"企业地址\",\"field\":\"shdz\"},{\"value\":\"开户银行\",\"field\":\"khyh\"},{\"value\":\"银行账户\",\"field\":\"yhzh\"},]".ToList<ParamsModel>(); | |
| 473 | + PrepareHyExportRows(exportData); | |
| 474 | + List<ParamsModel> paramList = "[{\"value\":\"客户编号\",\"field\":\"khbh\"},{\"value\":\"建档日期\",\"field\":\"jdrq\"},{\"value\":\"渠道\",\"field\":\"qd\"},{\"value\":\"手机号\",\"field\":\"sjh\"},{\"value\":\"姓名\",\"field\":\"xm\"},{\"value\":\"会员权益\",\"field\":\"kjqyMc\"},{\"value\":\"备注\",\"field\":\"bz\"},{\"value\":\"性别\",\"field\":\"xb\"},{\"value\":\"生日\",\"field\":\"sr\"},{\"value\":\"导购员\",\"field\":\"dgy\"},{\"value\":\"企业名称\",\"field\":\"wldwmc\"},{\"value\":\"企业电话\",\"field\":\"hm\"},{\"value\":\"企业税号\",\"field\":\"skzh\"},{\"value\":\"企业地址\",\"field\":\"shdz\"},{\"value\":\"开户银行\",\"field\":\"khyh\"},{\"value\":\"银行账户\",\"field\":\"yhzh\"},]".ToList<ParamsModel>(); | |
| 467 | 475 | ExcelConfig excelconfig = new ExcelConfig(); |
| 468 | 476 | excelconfig.FileName = "客户信息.xls"; |
| 469 | 477 | excelconfig.HeadFont = "微软雅黑"; |
| 470 | 478 | excelconfig.HeadPoint = 10; |
| 471 | 479 | excelconfig.IsAllSizeColumn = true; |
| 472 | 480 | excelconfig.ColumnModel = new List<ExcelColumnModel>(); |
| 473 | - List<string> selectKeyList = input.selectKey.Split(',').ToList(); | |
| 481 | + List<string> selectKeyList = (input.selectKey ?? "").Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); | |
| 474 | 482 | foreach (var item in selectKeyList) |
| 475 | 483 | { |
| 476 | 484 | var isExist = paramList.Find(p => p.field == item); |
| ... | ... | @@ -491,6 +499,51 @@ namespace NCC.Extend.WtHy |
| 491 | 499 | } |
| 492 | 500 | |
| 493 | 501 | /// <summary> |
| 502 | + /// 导出前整理:导购员输出姓名;会员权益输出有效卡名称+到期日文本。 | |
| 503 | + /// </summary> | |
| 504 | + private static void PrepareHyExportRows(List<WtHyListOutput> rows) | |
| 505 | + { | |
| 506 | + if (rows == null || rows.Count == 0) return; | |
| 507 | + var now = DateTime.Now; | |
| 508 | + foreach (var row in rows) | |
| 509 | + { | |
| 510 | + if (!string.IsNullOrWhiteSpace(row.dgy_xm)) | |
| 511 | + row.dgy = row.dgy_xm.Trim(); | |
| 512 | + else if (!string.IsNullOrWhiteSpace(row.dgy) && row.dgy.All(char.IsDigit) && row.dgy.Length >= 15) | |
| 513 | + row.dgy = ""; | |
| 514 | + | |
| 515 | + row.kjqyMc = FormatKjqyExportText(row, now); | |
| 516 | + } | |
| 517 | + } | |
| 518 | + | |
| 519 | + /// <summary> | |
| 520 | + /// 将列表中的有效权益卡拼成导出文本,口径与列表展示一致。 | |
| 521 | + /// </summary> | |
| 522 | + private static string FormatKjqyExportText(WtHyListOutput row, DateTime now) | |
| 523 | + { | |
| 524 | + if (row == null) return ""; | |
| 525 | + var list = row.kjqyList; | |
| 526 | + if (list != null && list.Count > 0) | |
| 527 | + { | |
| 528 | + var parts = new List<string>(); | |
| 529 | + foreach (var item in list) | |
| 530 | + { | |
| 531 | + if (item == null) continue; | |
| 532 | + var name = string.IsNullOrWhiteSpace(item.kjmc) ? "无" : item.kjmc.Trim(); | |
| 533 | + if (!item.dqsj.HasValue) | |
| 534 | + { | |
| 535 | + parts.Add(name); | |
| 536 | + continue; | |
| 537 | + } | |
| 538 | + var dateText = item.dqsj.Value.ToString("yyyy-MM-dd"); | |
| 539 | + parts.Add(item.dqsj.Value < now ? $"{name}(已到期·{dateText})" : $"{name}(至{dateText})"); | |
| 540 | + } | |
| 541 | + if (parts.Count > 0) return string.Join(";", parts); | |
| 542 | + } | |
| 543 | + return string.IsNullOrWhiteSpace(row.kjqyMc) ? "" : row.kjqyMc.Trim(); | |
| 544 | + } | |
| 545 | + | |
| 546 | + /// <summary> | |
| 494 | 547 | /// 批量删除客户信息 |
| 495 | 548 | /// </summary> |
| 496 | 549 | /// <param name="ids">主键数组</param> |
| ... | ... | @@ -1135,6 +1188,122 @@ namespace NCC.Extend.WtHy |
| 1135 | 1188 | } |
| 1136 | 1189 | } |
| 1137 | 1190 | |
| 1191 | + /// <summary> | |
| 1192 | + /// 仅修改客户档案备注 | |
| 1193 | + /// </summary> | |
| 1194 | + /// <remarks> | |
| 1195 | + /// 列表「修改备注」专用接口:只更新 F_Bz,不改动其它档案字段。 | |
| 1196 | + /// 需客户档案模块按钮权限 btn_editBz。 | |
| 1197 | + /// | |
| 1198 | + /// 示例请求: | |
| 1199 | + /// ```json | |
| 1200 | + /// { | |
| 1201 | + /// "id": "848008503996974341", | |
| 1202 | + /// "bz": "租赁还卡联系张三" | |
| 1203 | + /// } | |
| 1204 | + /// ``` | |
| 1205 | + /// | |
| 1206 | + /// 参数说明: | |
| 1207 | + /// - id: 客户档案主键 | |
| 1208 | + /// - bz: 备注内容(可空,表示清空) | |
| 1209 | + /// </remarks> | |
| 1210 | + /// <param name="input">修改备注入参</param> | |
| 1211 | + /// <returns>更新后的备注</returns> | |
| 1212 | + /// <response code="200">修改成功</response> | |
| 1213 | + /// <response code="400">参数非法或无权限</response> | |
| 1214 | + /// <response code="500">服务器内部错误</response> | |
| 1215 | + [HttpPost("Actions/UpdateBz")] | |
| 1216 | + public async Task<dynamic> UpdateBz([FromBody] WtHyUpdateBzInput input) | |
| 1217 | + { | |
| 1218 | + EnsureHyArchiveColumns(); | |
| 1219 | + EnsureEditBzButton(); | |
| 1220 | + await WtTjdbdButtonAuthorizeHelper.EnsureAsync( | |
| 1221 | + _db, | |
| 1222 | + _userManager, | |
| 1223 | + HyModuleId, | |
| 1224 | + BtnEditBz, | |
| 1225 | + "无修改备注权限"); | |
| 1226 | + | |
| 1227 | + if (input == null || string.IsNullOrWhiteSpace(input.id)) | |
| 1228 | + throw NCCException.Bah("客户ID不能为空"); | |
| 1229 | + | |
| 1230 | + var id = input.id.Trim(); | |
| 1231 | + var entity = await _db.Queryable<WtHyEntity>().FirstAsync(p => p.Id == id); | |
| 1232 | + _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005); | |
| 1233 | + | |
| 1234 | + var oldBz = entity.Bz ?? ""; | |
| 1235 | + var newBz = input.bz == null ? "" : input.bz.Trim(); | |
| 1236 | + if (newBz.Length > 500) | |
| 1237 | + throw NCCException.Bah("备注最多500字"); | |
| 1238 | + | |
| 1239 | + var affected = await _db.Updateable<WtHyEntity>() | |
| 1240 | + .SetColumns(h => new WtHyEntity { Bz = newBz }) | |
| 1241 | + .Where(h => h.Id == id) | |
| 1242 | + .ExecuteCommandAsync(); | |
| 1243 | + if (affected != 1) | |
| 1244 | + throw NCCException.Bah("修改备注失败,请刷新后重试"); | |
| 1245 | + | |
| 1246 | + var memberLabel = string.IsNullOrWhiteSpace(entity.Xm) | |
| 1247 | + ? (entity.Khbh ?? entity.Sjh ?? id) | |
| 1248 | + : entity.Xm.Trim(); | |
| 1249 | + var detailJson = JsonConvert.SerializeObject(new | |
| 1250 | + { | |
| 1251 | + before = new { bz = oldBz }, | |
| 1252 | + after = new { bz = newBz }, | |
| 1253 | + memberName = entity.Xm, | |
| 1254 | + memberNo = entity.Khbh, | |
| 1255 | + sjh = entity.Sjh | |
| 1256 | + }); | |
| 1257 | + await _businessOperationLogService.WriteAsync( | |
| 1258 | + "客户档案", | |
| 1259 | + "修改备注", | |
| 1260 | + "wt_hy", | |
| 1261 | + id, | |
| 1262 | + $"修改客户{memberLabel}备注", | |
| 1263 | + detailJson); | |
| 1264 | + | |
| 1265 | + return new { id, bz = newBz }; | |
| 1266 | + } | |
| 1267 | + | |
| 1268 | + /// <summary> | |
| 1269 | + /// 幂等注册「修改备注」按钮到客户档案模块,便于角色权限勾选。 | |
| 1270 | + /// </summary> | |
| 1271 | + private void EnsureEditBzButton() | |
| 1272 | + { | |
| 1273 | + if (_editBzButtonReady) return; | |
| 1274 | + lock (EditBzButtonLock) | |
| 1275 | + { | |
| 1276 | + if (_editBzButtonReady) return; | |
| 1277 | + try | |
| 1278 | + { | |
| 1279 | + var exists = _db.Queryable<ModuleButtonEntity>() | |
| 1280 | + .Any(b => b.ModuleId == HyModuleId && b.EnCode == BtnEditBz && b.DeleteMark == null); | |
| 1281 | + if (!exists) | |
| 1282 | + { | |
| 1283 | + var entity = new ModuleButtonEntity | |
| 1284 | + { | |
| 1285 | + Id = YitIdHelper.NextId().ToString(), | |
| 1286 | + ParentId = "-1", | |
| 1287 | + FullName = "修改备注", | |
| 1288 | + EnCode = BtnEditBz, | |
| 1289 | + ModuleId = HyModuleId, | |
| 1290 | + SortCode = 55, | |
| 1291 | + EnabledMark = 1, | |
| 1292 | + CreatorTime = DateTime.Now, | |
| 1293 | + CreatorUserId = _userManager?.UserId | |
| 1294 | + }; | |
| 1295 | + _db.Insertable(entity).ExecuteCommand(); | |
| 1296 | + } | |
| 1297 | + } | |
| 1298 | + catch (Exception ex) | |
| 1299 | + { | |
| 1300 | + Console.WriteLine($"EnsureEditBzButton: {ex.Message}"); | |
| 1301 | + } | |
| 1302 | + | |
| 1303 | + _editBzButtonReady = true; | |
| 1304 | + } | |
| 1305 | + } | |
| 1306 | + | |
| 1138 | 1307 | private static bool IsRefundedKkjl(string zt) |
| 1139 | 1308 | { |
| 1140 | 1309 | return !string.IsNullOrEmpty(zt) && zt.IndexOf("退", StringComparison.Ordinal) >= 0; | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtHydqtkService.cs
| ... | ... | @@ -5,7 +5,9 @@ using NCC.Common.Filter; |
| 5 | 5 | using NCC.Dependency; |
| 6 | 6 | using NCC.DynamicApiController; |
| 7 | 7 | using NCC.FriendlyException; |
| 8 | +using NCC.Extend.Interfaces; | |
| 8 | 9 | using NCC.Extend.Interfaces.WtHydqtk; |
| 10 | +using NCC.Extend.WtBillSoftDelete; | |
| 9 | 11 | using Mapster; |
| 10 | 12 | using Microsoft.AspNetCore.Mvc; |
| 11 | 13 | using SqlSugar; |
| ... | ... | @@ -30,33 +32,59 @@ namespace NCC.Extend.WtHydqtk |
| 30 | 32 | /// </summary> |
| 31 | 33 | [ApiDescriptionSettings(Tag = "Extend",Name = "WtHydqtk", Order = 200)] |
| 32 | 34 | [Route("api/Extend/[controller]")] |
| 33 | - public class WtHydqtkService : IWtHydqtkService, IDynamicApiController, ITransient | |
| 35 | + public class WtHydqtkService : IWtHydqtkService, IDynamicApiController, ITransient, IWtBillRecycleOperations | |
| 34 | 36 | { |
| 35 | 37 | private readonly ISqlSugarRepository<WtHydqtkEntity> _wtHydqtkRepository; |
| 36 | 38 | private readonly SqlSugarScope _db; |
| 37 | 39 | private readonly IUserManager _userManager; |
| 40 | + private readonly IBusinessOperationLogService _businessOperationLogService; | |
| 41 | + private static bool _softDeleteColumnsEnsured; | |
| 42 | + | |
| 43 | + /// <inheritdoc /> | |
| 44 | + public WtBillRecycleBillSource BillSource => WtBillRecycleBillSource.WtHydqtk; | |
| 38 | 45 | |
| 39 | 46 | /// <summary> |
| 40 | 47 | /// 初始化一个<see cref="WtHydqtkService"/>类型的新实例 |
| 41 | 48 | /// </summary> |
| 42 | 49 | public WtHydqtkService( |
| 43 | 50 | ISqlSugarRepository<WtHydqtkEntity> wtHydqtkRepository, |
| 44 | - IUserManager userManager) | |
| 51 | + IUserManager userManager, | |
| 52 | + IBusinessOperationLogService businessOperationLogService) | |
| 45 | 53 | { |
| 46 | 54 | _wtHydqtkRepository = wtHydqtkRepository; |
| 47 | 55 | _db = _wtHydqtkRepository.Context; |
| 48 | 56 | _userManager = userManager; |
| 57 | + _businessOperationLogService = businessOperationLogService; | |
| 58 | + } | |
| 59 | + | |
| 60 | + private void EnsureSoftDeleteColumns() | |
| 61 | + { | |
| 62 | + if (_softDeleteColumnsEnsured) return; | |
| 63 | + WtBillSoftDeleteHelper.EnsureBillSoftDeleteColumnsAsync(_db, "wt_hydqtk").GetAwaiter().GetResult(); | |
| 64 | + _softDeleteColumnsEnsured = true; | |
| 49 | 65 | } |
| 50 | 66 | |
| 51 | 67 | /// <summary> |
| 52 | - /// 获取会员到期退款 | |
| 68 | + /// 获取会员到期退款详情 | |
| 53 | 69 | /// </summary> |
| 54 | - /// <param name="id">参数</param> | |
| 55 | - /// <returns></returns> | |
| 70 | + /// <remarks> | |
| 71 | + /// 默认仅未软删;回收站只读详情传 <c>includeDeleted=true</c>。 | |
| 72 | + /// </remarks> | |
| 73 | + /// <param name="id">单据编号</param> | |
| 74 | + /// <param name="includeDeleted">为 true 时允许读取已软删单据</param> | |
| 75 | + /// <returns>会员到期退款详情</returns> | |
| 76 | + /// <response code="200">成功</response> | |
| 77 | + /// <response code="404">单据不存在</response> | |
| 78 | + /// <response code="500">服务异常</response> | |
| 56 | 79 | [HttpGet("{id}")] |
| 57 | - public async Task<dynamic> GetInfo(string id) | |
| 80 | + public async Task<dynamic> GetInfo(string id, [FromQuery] bool includeDeleted = false) | |
| 58 | 81 | { |
| 59 | - var entity = await _db.Queryable<WtHydqtkEntity>().FirstAsync(p => p.Id == id); | |
| 82 | + EnsureSoftDeleteColumns(); | |
| 83 | + var entity = await _db.Queryable<WtHydqtkEntity>() | |
| 84 | + .Where(p => p.Id == id) | |
| 85 | + .WhereIF(!includeDeleted, p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 86 | + .FirstAsync(); | |
| 87 | + if (entity == null) throw NCCException.Oh(ErrorCode.COM1005); | |
| 60 | 88 | var output = entity.Adapt<WtHydqtkInfoOutput>(); |
| 61 | 89 | return output; |
| 62 | 90 | } |
| ... | ... | @@ -69,11 +97,13 @@ namespace NCC.Extend.WtHydqtk |
| 69 | 97 | [HttpGet("")] |
| 70 | 98 | public async Task<dynamic> GetList([FromQuery] WtHydqtkListQueryInput input) |
| 71 | 99 | { |
| 100 | + EnsureSoftDeleteColumns(); | |
| 72 | 101 | var sidx = input.sidx == null ? "id" : input.sidx; |
| 73 | 102 | List<object> queryTkje = input.tkje != null ? input.tkje.Split(',').ToObeject<List<object>>() : null; |
| 74 | 103 | var startTkje = input.tkje != null && !string.IsNullOrEmpty(queryTkje.First().ToString()) ? queryTkje.First() : decimal.MinValue; |
| 75 | 104 | var endTkje = input.tkje != null && !string.IsNullOrEmpty(queryTkje.Last().ToString()) ? queryTkje.Last() : decimal.MaxValue; |
| 76 | 105 | var data = await _db.Queryable<WtHydqtkEntity>() |
| 106 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 77 | 107 | .WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id)) |
| 78 | 108 | .WhereIF(!string.IsNullOrEmpty(input.fyd), p => p.Fyd.Equals(input.fyd)) |
| 79 | 109 | .WhereIF(!string.IsNullOrEmpty(input.kh), p => p.Kh.Equals(input.kh)) |
| ... | ... | @@ -123,11 +153,13 @@ namespace NCC.Extend.WtHydqtk |
| 123 | 153 | [NonAction] |
| 124 | 154 | public async Task<dynamic> GetNoPagingList([FromQuery] WtHydqtkListQueryInput input) |
| 125 | 155 | { |
| 156 | + EnsureSoftDeleteColumns(); | |
| 126 | 157 | var sidx = input.sidx == null ? "id" : input.sidx; |
| 127 | 158 | List<object> queryTkje = input.tkje != null ? input.tkje.Split(',').ToObeject<List<object>>() : null; |
| 128 | 159 | var startTkje = input.tkje != null && !string.IsNullOrEmpty(queryTkje.First().ToString()) ? queryTkje.First() : decimal.MinValue; |
| 129 | 160 | var endTkje = input.tkje != null && !string.IsNullOrEmpty(queryTkje.Last().ToString()) ? queryTkje.Last() : decimal.MaxValue; |
| 130 | 161 | var data = await _db.Queryable<WtHydqtkEntity>() |
| 162 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 131 | 163 | .WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id)) |
| 132 | 164 | .WhereIF(!string.IsNullOrEmpty(input.fyd), p => p.Fyd.Equals(input.fyd)) |
| 133 | 165 | .WhereIF(!string.IsNullOrEmpty(input.kh), p => p.Kh.Equals(input.kh)) |
| ... | ... | @@ -208,24 +240,15 @@ namespace NCC.Extend.WtHydqtk |
| 208 | 240 | [HttpPost("batchRemove")] |
| 209 | 241 | public async Task BatchRemove([FromBody] List<string> ids) |
| 210 | 242 | { |
| 211 | - var entitys = await _db.Queryable<WtHydqtkEntity>().In(it => it.Id, ids).ToListAsync(); | |
| 212 | - if (entitys.Count > 0) | |
| 243 | + EnsureSoftDeleteColumns(); | |
| 244 | + var entitys = await _db.Queryable<WtHydqtkEntity>() | |
| 245 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 246 | + .In(it => it.Id, ids).ToListAsync(); | |
| 247 | + var uid = _userManager.UserId ?? ""; | |
| 248 | + foreach (var e in entitys) | |
| 213 | 249 | { |
| 214 | - try | |
| 215 | - { | |
| 216 | - //开启事务 | |
| 217 | - _db.BeginTran(); | |
| 218 | - //批量删除会员到期退款 | |
| 219 | - await _db.Deleteable<WtHydqtkEntity>().In(d => d.Id,ids).ExecuteCommandAsync(); | |
| 220 | - //关闭事务 | |
| 221 | - _db.CommitTran(); | |
| 222 | - } | |
| 223 | - catch (Exception) | |
| 224 | - { | |
| 225 | - //回滚事务 | |
| 226 | - _db.RollbackTran(); | |
| 227 | - throw NCCException.Oh(ErrorCode.COM1002); | |
| 228 | - } | |
| 250 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAsync(_db, "wt_hydqtk", e.Id, uid); | |
| 251 | + await _businessOperationLogService.WriteAsync("会员到期退款", "标记删除", "WtHydqtk", e.Id, $"标记删除 {e.Id}"); | |
| 229 | 252 | } |
| 230 | 253 | } |
| 231 | 254 | |
| ... | ... | @@ -250,8 +273,34 @@ namespace NCC.Extend.WtHydqtk |
| 250 | 273 | [HttpDelete("{id}")] |
| 251 | 274 | public async Task Delete(string id) |
| 252 | 275 | { |
| 253 | - var entity = await _db.Queryable<WtHydqtkEntity>().FirstAsync(p => p.Id == id); | |
| 276 | + EnsureSoftDeleteColumns(); | |
| 277 | + var entity = await _db.Queryable<WtHydqtkEntity>() | |
| 278 | + .Where(p => p.Id == id && WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 279 | + .FirstAsync(); | |
| 254 | 280 | _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005); |
| 281 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAsync(_db, "wt_hydqtk", id, _userManager.UserId ?? ""); | |
| 282 | + await _businessOperationLogService.WriteAsync("会员到期退款", "标记删除", "WtHydqtk", id, $"标记删除 {id}"); | |
| 283 | + } | |
| 284 | + | |
| 285 | + /// <inheritdoc /> | |
| 286 | + [NonAction] | |
| 287 | + public async Task RestoreFromRecycleBinAsync(string id) | |
| 288 | + { | |
| 289 | + EnsureSoftDeleteColumns(); | |
| 290 | + var entity = await _db.Queryable<WtHydqtkEntity>().FirstAsync(p => p.Id == id); | |
| 291 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 292 | + throw NCCException.Bah("单据不存在或未在回收站"); | |
| 293 | + await WtBillSoftDeleteHelper.RestoreHeadAsync(_db, "wt_hydqtk", id); | |
| 294 | + } | |
| 295 | + | |
| 296 | + /// <inheritdoc /> | |
| 297 | + [NonAction] | |
| 298 | + public async Task PurgePhysicalAsync(string id) | |
| 299 | + { | |
| 300 | + EnsureSoftDeleteColumns(); | |
| 301 | + var entity = await _db.Queryable<WtHydqtkEntity>().FirstAsync(p => p.Id == id); | |
| 302 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 303 | + throw NCCException.Bah("仅可彻底删除回收站中的单据"); | |
| 255 | 304 | var isOk = await _db.Deleteable<WtHydqtkEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); |
| 256 | 305 | if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1002); |
| 257 | 306 | } | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtKfbfbService.cs
| ... | ... | @@ -27,6 +27,7 @@ using NCC.ClayObject; |
| 27 | 27 | using NCC.DataEncryption; |
| 28 | 28 | using NCC.Extend; |
| 29 | 29 | using NCC.Extend.Entitys.Dto; |
| 30 | +using NCC.Extend.WtBillSoftDelete; | |
| 30 | 31 | |
| 31 | 32 | namespace NCC.Extend.WtKfbfb |
| 32 | 33 | { |
| ... | ... | @@ -35,7 +36,7 @@ namespace NCC.Extend.WtKfbfb |
| 35 | 36 | /// </summary> |
| 36 | 37 | [ApiDescriptionSettings(Tag = "Extend", Name = "WtKfbfb", Order = 200)] |
| 37 | 38 | [Route("api/Extend/[controller]")] |
| 38 | - public class WtKfbfbService : IWtKfbfbService, IDynamicApiController, ITransient | |
| 39 | + public class WtKfbfbService : IWtKfbfbService, IDynamicApiController, ITransient, IWtBillRecycleOperations | |
| 39 | 40 | { |
| 40 | 41 | private class OrderOptionOutput |
| 41 | 42 | { |
| ... | ... | @@ -48,6 +49,11 @@ namespace NCC.Extend.WtKfbfb |
| 48 | 49 | private readonly SqlSugarScope _db; |
| 49 | 50 | private readonly IUserManager _userManager; |
| 50 | 51 | private readonly WtKfbfbWorkflowHelper _kfbfbWorkflowHelper; |
| 52 | + private readonly IBusinessOperationLogService _businessOperationLogService; | |
| 53 | + private static bool _softDeleteColumnsEnsured; | |
| 54 | + | |
| 55 | + /// <inheritdoc /> | |
| 56 | + public WtBillRecycleBillSource BillSource => WtBillRecycleBillSource.WtKfbfb; | |
| 51 | 57 | |
| 52 | 58 | private static bool _kfbfbJsdwColumnChecked; |
| 53 | 59 | private static bool _kfbfbJsdwmcColumnChecked; |
| ... | ... | @@ -90,29 +96,49 @@ namespace NCC.Extend.WtKfbfb |
| 90 | 96 | public WtKfbfbService( |
| 91 | 97 | ISqlSugarRepository<WtKfbfbEntity> wtKfbfbRepository, |
| 92 | 98 | IUserManager userManager, |
| 93 | - WtKfbfbWorkflowHelper kfbfbWorkflowHelper) | |
| 99 | + WtKfbfbWorkflowHelper kfbfbWorkflowHelper, | |
| 100 | + IBusinessOperationLogService businessOperationLogService) | |
| 94 | 101 | { |
| 95 | 102 | _wtKfbfbRepository = wtKfbfbRepository; |
| 96 | 103 | _db = _wtKfbfbRepository.Context; |
| 97 | 104 | _userManager = userManager; |
| 98 | 105 | _kfbfbWorkflowHelper = kfbfbWorkflowHelper; |
| 106 | + _businessOperationLogService = businessOperationLogService; | |
| 99 | 107 | // 启动即补全 wt_kfbfb 缺失列(如 F_Ywlx),避免 SQL Unknown column |
| 100 | 108 | _kfbfbWorkflowHelper.EnsureKfbfbAuditColumns(); |
| 101 | 109 | } |
| 102 | 110 | |
| 111 | + private void EnsureSoftDeleteColumns() | |
| 112 | + { | |
| 113 | + if (_softDeleteColumnsEnsured) return; | |
| 114 | + WtBillSoftDeleteHelper.EnsureBillSoftDeleteColumnsAsync(_db, "wt_kfbfb").GetAwaiter().GetResult(); | |
| 115 | + _softDeleteColumnsEnsured = true; | |
| 116 | + } | |
| 117 | + | |
| 103 | 118 | /// <summary> |
| 104 | 119 | /// 获取客服补发单详情 |
| 105 | 120 | /// </summary> |
| 121 | + /// <remarks> | |
| 122 | + /// 默认仅未软删;回收站只读详情传 <c>includeDeleted=true</c>,并跳过漏发补发业务范围校验。 | |
| 123 | + /// </remarks> | |
| 106 | 124 | /// <param name="id">主键</param> |
| 125 | + /// <param name="includeDeleted">为 true 时允许读取已软删单据(回收站详情)</param> | |
| 107 | 126 | /// <returns>详情数据</returns> |
| 108 | 127 | /// <response code="200">成功</response> |
| 128 | + /// <response code="404">单据不存在</response> | |
| 129 | + /// <response code="400">非漏发补发业务范围且未传 includeDeleted</response> | |
| 130 | + /// <response code="500">服务异常</response> | |
| 109 | 131 | [HttpGet("{id}")] |
| 110 | - public async Task<dynamic> GetInfo(string id) | |
| 132 | + public async Task<dynamic> GetInfo(string id, [FromQuery] bool includeDeleted = false) | |
| 111 | 133 | { |
| 134 | + EnsureSoftDeleteColumns(); | |
| 112 | 135 | EnsureKfbfbJsdwAndDjrqColumns(); |
| 113 | - var entity = await _db.Queryable<WtKfbfbEntity>().FirstAsync(p => p.Id == id); | |
| 136 | + var entity = await _db.Queryable<WtKfbfbEntity>() | |
| 137 | + .Where(p => p.Id == id) | |
| 138 | + .WhereIF(!includeDeleted, p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 139 | + .FirstAsync(); | |
| 114 | 140 | if (entity == null) throw NCCException.Oh(ErrorCode.COM1005); |
| 115 | - if (!WtKfbfbWorkflowHelper.IsLouFaBuFaScope(entity.Ywlx)) | |
| 141 | + if (!includeDeleted && !WtKfbfbWorkflowHelper.IsLouFaBuFaScope(entity.Ywlx)) | |
| 116 | 142 | throw NCCException.Bah("该单据为历史「赠送」类型数据,请在「赠送单」菜单查看;本模块仅展示漏发补发单。"); |
| 117 | 143 | |
| 118 | 144 | WtXsckdEntity genXsckd = null; |
| ... | ... | @@ -164,10 +190,12 @@ namespace NCC.Extend.WtKfbfb |
| 164 | 190 | [HttpGet("")] |
| 165 | 191 | public async Task<dynamic> GetList([FromQuery] WtKfbfbListQueryInput input) |
| 166 | 192 | { |
| 193 | + EnsureSoftDeleteColumns(); | |
| 167 | 194 | EnsureKfbfbJsdwAndDjrqColumns(); |
| 168 | 195 | var sidx = string.IsNullOrEmpty(input.sidx) ? "creatorTime" : input.sidx; |
| 169 | 196 | var sort = string.IsNullOrEmpty(input.sort) ? "desc" : input.sort; |
| 170 | 197 | var data = await _db.Queryable<WtKfbfbEntity>() |
| 198 | + .Where(kf => WtBillSoftDeleteHelper.IsNotDeleted(kf.DeleteMark)) | |
| 171 | 199 | .Where(kf => kf.Ywlx == null || kf.Ywlx == "" || kf.Ywlx == WtKfbfbBizKindTexts.LouFaBuFa) |
| 172 | 200 | .WhereIF(!string.IsNullOrEmpty(input.id), kf => kf.Id.Contains(input.id)) |
| 173 | 201 | .WhereIF(!string.IsNullOrEmpty(input.ddh), kf => kf.Ddh.Contains(input.ddh)) |
| ... | ... | @@ -462,10 +490,12 @@ namespace NCC.Extend.WtKfbfb |
| 462 | 490 | [NonAction] |
| 463 | 491 | public async Task<dynamic> GetNoPagingList([FromQuery] WtKfbfbListQueryInput input) |
| 464 | 492 | { |
| 493 | + EnsureSoftDeleteColumns(); | |
| 465 | 494 | EnsureKfbfbJsdwAndDjrqColumns(); |
| 466 | 495 | var sidx = string.IsNullOrEmpty(input.sidx) ? "creatorTime" : input.sidx; |
| 467 | 496 | var sort = string.IsNullOrEmpty(input.sort) ? "desc" : input.sort; |
| 468 | 497 | var data = await _db.Queryable<WtKfbfbEntity>() |
| 498 | + .Where(kf => WtBillSoftDeleteHelper.IsNotDeleted(kf.DeleteMark)) | |
| 469 | 499 | .Where(kf => kf.Ywlx == null || kf.Ywlx == "" || kf.Ywlx == WtKfbfbBizKindTexts.LouFaBuFa) |
| 470 | 500 | .WhereIF(!string.IsNullOrEmpty(input.id), kf => kf.Id.Contains(input.id)) |
| 471 | 501 | .WhereIF(!string.IsNullOrEmpty(input.ddh), kf => kf.Ddh.Contains(input.ddh)) |
| ... | ... | @@ -600,5 +630,53 @@ namespace NCC.Extend.WtKfbfb |
| 600 | 630 | }; |
| 601 | 631 | return output; |
| 602 | 632 | } |
| 633 | + | |
| 634 | + /// <summary> | |
| 635 | + /// 删除客服补发单(标记删除,进回收站) | |
| 636 | + /// </summary> | |
| 637 | + /// <param name="id">主键</param> | |
| 638 | + /// <returns></returns> | |
| 639 | + /// <response code="200">成功</response> | |
| 640 | + [HttpDelete("{id}")] | |
| 641 | + public async Task Delete(string id) | |
| 642 | + { | |
| 643 | + EnsureSoftDeleteColumns(); | |
| 644 | + EnsureKfbfbJsdwAndDjrqColumns(); | |
| 645 | + var entity = await _db.Queryable<WtKfbfbEntity>() | |
| 646 | + .Where(p => p.Id == id && WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 647 | + .FirstAsync(); | |
| 648 | + if (entity == null) | |
| 649 | + throw NCCException.Oh(ErrorCode.COM1005); | |
| 650 | + if (!WtKfbfbWorkflowHelper.IsLouFaBuFaScope(entity.Ywlx)) | |
| 651 | + throw NCCException.Bah("该单据为历史「赠送」类型,不可在本模块删除"); | |
| 652 | + if (!WtBillCommonHelpers.IsDeletableDraftState(entity.Djzt, entity.Spbz)) | |
| 653 | + throw NCCException.Bah("仅草稿或审核不通过状态可删除"); | |
| 654 | + | |
| 655 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAsync(_db, "wt_kfbfb", id, _userManager.UserId ?? ""); | |
| 656 | + await _businessOperationLogService.WriteAsync("客服补发单", "标记删除", "WtKfbfb", id, $"标记删除客服补发单 {id}"); | |
| 657 | + } | |
| 658 | + | |
| 659 | + /// <inheritdoc /> | |
| 660 | + [NonAction] | |
| 661 | + public async Task RestoreFromRecycleBinAsync(string id) | |
| 662 | + { | |
| 663 | + EnsureSoftDeleteColumns(); | |
| 664 | + var entity = await _db.Queryable<WtKfbfbEntity>().FirstAsync(p => p.Id == id); | |
| 665 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 666 | + throw NCCException.Bah("单据不存在或未在回收站"); | |
| 667 | + await WtBillSoftDeleteHelper.RestoreHeadAsync(_db, "wt_kfbfb", id); | |
| 668 | + } | |
| 669 | + | |
| 670 | + /// <inheritdoc /> | |
| 671 | + [NonAction] | |
| 672 | + public async Task PurgePhysicalAsync(string id) | |
| 673 | + { | |
| 674 | + EnsureSoftDeleteColumns(); | |
| 675 | + var entity = await _db.Queryable<WtKfbfbEntity>().FirstAsync(p => p.Id == id); | |
| 676 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 677 | + throw NCCException.Bah("仅可彻底删除回收站中的单据"); | |
| 678 | + var isOk = await _db.Deleteable<WtKfbfbEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); | |
| 679 | + if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1002); | |
| 680 | + } | |
| 603 | 681 | } |
| 604 | 682 | } | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtPdService.cs
| ... | ... | @@ -15,6 +15,8 @@ using System.Threading.Tasks; |
| 15 | 15 | using NCC.Extend.Entitys; |
| 16 | 16 | using NCC.Extend.Entitys.Dto; |
| 17 | 17 | using NCC.Extend.Entitys.Dto.WtXsckd; |
| 18 | +using NCC.Extend.Interfaces; | |
| 19 | +using NCC.Extend.WtBillSoftDelete; | |
| 18 | 20 | using NCC.Extend.WtPl; |
| 19 | 21 | using NCC.Extend.WtXsckd; |
| 20 | 22 | using NCC.System.Entitys.Permission; |
| ... | ... | @@ -28,10 +30,14 @@ namespace NCC.Extend.WtPd |
| 28 | 30 | /// </summary> |
| 29 | 31 | [ApiDescriptionSettings(Tag = "Extend", Name = "WtPd", Order = 200)] |
| 30 | 32 | [Route("api/Extend/[controller]")] |
| 31 | - public class WtPdService : IDynamicApiController, ITransient | |
| 33 | + public class WtPdService : IDynamicApiController, ITransient, IWtBillRecycleOperations | |
| 32 | 34 | { |
| 33 | 35 | private static bool _wtPdTablesEnsured; |
| 34 | 36 | private static bool _wtPdMxColsEnsured; |
| 37 | + private static bool _softDeleteColumnsEnsured; | |
| 38 | + | |
| 39 | + /// <inheritdoc /> | |
| 40 | + public WtBillRecycleBillSource BillSource => WtBillRecycleBillSource.WtPd; | |
| 35 | 41 | |
| 36 | 42 | private static class PdStatus |
| 37 | 43 | { |
| ... | ... | @@ -45,18 +51,28 @@ namespace NCC.Extend.WtPd |
| 45 | 51 | private readonly SqlSugarScope _db; |
| 46 | 52 | private readonly IUserManager _userManager; |
| 47 | 53 | private readonly WtXsckdService _wtXsckdService; |
| 54 | + private readonly IBusinessOperationLogService _businessOperationLogService; | |
| 48 | 55 | |
| 49 | 56 | public WtPdService( |
| 50 | 57 | ISqlSugarRepository<WtPdEntity> pdRepo, |
| 51 | 58 | ISqlSugarRepository<WtPdMxEntity> mxRepo, |
| 52 | 59 | IUserManager userManager, |
| 53 | - WtXsckdService wtXsckdService) | |
| 60 | + WtXsckdService wtXsckdService, | |
| 61 | + IBusinessOperationLogService businessOperationLogService) | |
| 54 | 62 | { |
| 55 | 63 | _pdRepo = pdRepo; |
| 56 | 64 | _mxRepo = mxRepo; |
| 57 | 65 | _db = pdRepo.Context; |
| 58 | 66 | _userManager = userManager; |
| 59 | 67 | _wtXsckdService = wtXsckdService; |
| 68 | + _businessOperationLogService = businessOperationLogService; | |
| 69 | + } | |
| 70 | + | |
| 71 | + private void EnsureSoftDeleteColumns() | |
| 72 | + { | |
| 73 | + if (_softDeleteColumnsEnsured) return; | |
| 74 | + WtBillSoftDeleteHelper.EnsureBillSoftDeleteColumnsAsync(_db, "wt_pd", "wt_pd_mx").GetAwaiter().GetResult(); | |
| 75 | + _softDeleteColumnsEnsured = true; | |
| 60 | 76 | } |
| 61 | 77 | |
| 62 | 78 | private void EnsureWtPdTables() |
| ... | ... | @@ -494,24 +510,33 @@ CREATE TABLE `wt_pd_mx` ( |
| 494 | 510 | /// <summary> |
| 495 | 511 | /// 盘点单详情(含全部明细) |
| 496 | 512 | /// </summary> |
| 513 | + /// <remarks> | |
| 514 | + /// 默认仅返回未软删单据;单据回收站只读详情请传 <c>includeDeleted=true</c>,主表与明细均含 F_DeleteMark=1 的记录。 | |
| 515 | + /// | |
| 516 | + /// 示例:GET /api/Extend/WtPd/{id}?includeDeleted=true | |
| 517 | + /// </remarks> | |
| 497 | 518 | /// <param name="id">主键</param> |
| 519 | + /// <param name="includeDeleted">为 true 时允许读取已软删盘点单及明细(回收站详情)</param> | |
| 498 | 520 | /// <returns>主表+明细</returns> |
| 499 | 521 | /// <response code="200">成功</response> |
| 500 | - /// <response code="404">不存在</response> | |
| 522 | + /// <response code="404">单据不存在</response> | |
| 523 | + /// <response code="500">服务异常</response> | |
| 501 | 524 | [HttpGet("{id}")] |
| 502 | - public async Task<WtPdInfoOutput> GetInfo(string id) | |
| 525 | + public async Task<WtPdInfoOutput> GetInfo(string id, [FromQuery] bool includeDeleted = false) | |
| 503 | 526 | { |
| 504 | 527 | EnsureWtPdTables(); |
| 505 | 528 | var head = await _db.Queryable<WtPdEntity>() |
| 506 | - .Where(p => p.Id == id && (p.DeleteMark == null || p.DeleteMark == 0)) | |
| 529 | + .Where(p => p.Id == id) | |
| 530 | + .WhereIF(!includeDeleted, p => p.DeleteMark == null || p.DeleteMark == 0) | |
| 507 | 531 | .FirstAsync(); |
| 508 | 532 | if (head == null) |
| 509 | 533 | throw NCCException.Oh(ErrorCode.COM1005); |
| 510 | 534 | var ckmc = await _db.Queryable<WtCkEntity>().Where(c => c.Id == head.Ck).Select(c => c.Mdmc).FirstAsync(); |
| 511 | - var mx = await LoadOrderedPdMxAsync(id); | |
| 535 | + var mx = await LoadOrderedPdMxAsync(id, includeDeleted); | |
| 512 | 536 | var spxlhMap = await ResolveSpxlhTypeMapAsync(mx.Select(x => x.Spbh)); |
| 513 | 537 | var spArchiveMap = await ResolveSpArchiveMapForMxAsync(mx); |
| 514 | 538 | var spPlMap = await ResolveSpPlMapForMxAsync(mx); |
| 539 | + var (saleOutBillMap, saleReturnBillMap) = await LoadPdPeriodBillMapsAsync(head, mx); | |
| 515 | 540 | return new WtPdInfoOutput |
| 516 | 541 | { |
| 517 | 542 | id = head.Id, |
| ... | ... | @@ -536,6 +561,9 @@ CREATE TABLE `wt_pd_mx` ( |
| 536 | 561 | mxList = mx.Select(m => |
| 537 | 562 | { |
| 538 | 563 | spxlhMap.TryGetValue((m.Spbh ?? "").Trim(), out var lx); |
| 564 | + var spKey = (m.Spbh ?? "").Trim(); | |
| 565 | + saleOutBillMap.TryGetValue(spKey, out var outBills); | |
| 566 | + saleReturnBillMap.TryGetValue(spKey, out var returnBills); | |
| 539 | 567 | return new WtPdMxInfoRow |
| 540 | 568 | { |
| 541 | 569 | id = m.Id, |
| ... | ... | @@ -554,7 +582,9 @@ CREATE TABLE `wt_pd_mx` ( |
| 554 | 582 | serialNumbers = DeserializePdMxSerialNumbers(m.SerialNumbers), |
| 555 | 583 | spxlhType = string.IsNullOrWhiteSpace(m.Spbh) ? null : lx, |
| 556 | 584 | saleOutQty = m.SaleOutQty, |
| 557 | - saleReturnQty = m.SaleReturnQty | |
| 585 | + saleReturnQty = m.SaleReturnQty, | |
| 586 | + saleOutBills = outBills ?? new List<WtPdPeriodBillItem>(), | |
| 587 | + saleReturnBills = returnBills ?? new List<WtPdPeriodBillItem>() | |
| 558 | 588 | }; |
| 559 | 589 | }).ToList() |
| 560 | 590 | }; |
| ... | ... | @@ -572,6 +602,7 @@ CREATE TABLE `wt_pd_mx` ( |
| 572 | 602 | /// - plId: 商品分类节点 Id(可选,含子分类) |
| 573 | 603 | /// - keyword: 编码/名称模糊(可选) |
| 574 | 604 | /// - spbh: 商品主键精确(可选) |
| 605 | + /// - hasPeriodChange: 是否仅有期间变动(可选;true=SaleOutQty 或 SaleReturnQty > 0,false=两者皆 ≤ 0) | |
| 575 | 606 | /// </remarks> |
| 576 | 607 | /// <param name="id">盘点单 Id</param> |
| 577 | 608 | /// <param name="input">筛选条件</param> |
| ... | ... | @@ -598,11 +629,12 @@ CREATE TABLE `wt_pd_mx` ( |
| 598 | 629 | var plId = input.plId?.Trim(); |
| 599 | 630 | var keyword = input.keyword?.Trim(); |
| 600 | 631 | var spbhFilter = input.spbh?.Trim(); |
| 632 | + var hasPeriodChange = input.hasPeriodChange; | |
| 601 | 633 | var hasPl = !string.IsNullOrEmpty(plId); |
| 602 | 634 | var hasKw = !string.IsNullOrEmpty(keyword); |
| 603 | 635 | var hasSpbh = !string.IsNullOrEmpty(spbhFilter); |
| 604 | 636 | |
| 605 | - if (!hasPl && !hasKw && !hasSpbh) | |
| 637 | + if (!hasPl && !hasKw && !hasSpbh && !hasPeriodChange.HasValue) | |
| 606 | 638 | { |
| 607 | 639 | var allIds = mx.Select(m => m.Id).ToList(); |
| 608 | 640 | return new WtPdFilterMxOutput { total = allIds.Count, mxIds = allIds }; |
| ... | ... | @@ -649,16 +681,24 @@ CREATE TABLE `wt_pd_mx` ( |
| 649 | 681 | continue; |
| 650 | 682 | } |
| 651 | 683 | |
| 684 | + if (hasPeriodChange.HasValue) | |
| 685 | + { | |
| 686 | + var changed = (m.SaleOutQty ?? 0m) > 0m || (m.SaleReturnQty ?? 0m) > 0m; | |
| 687 | + if (hasPeriodChange.Value != changed) | |
| 688 | + continue; | |
| 689 | + } | |
| 690 | + | |
| 652 | 691 | mxIds.Add(m.Id); |
| 653 | 692 | } |
| 654 | 693 | |
| 655 | 694 | return new WtPdFilterMxOutput { total = mxIds.Count, mxIds = mxIds }; |
| 656 | 695 | } |
| 657 | 696 | |
| 658 | - private async Task<List<WtPdMxEntity>> LoadOrderedPdMxAsync(string pdId) | |
| 697 | + private async Task<List<WtPdMxEntity>> LoadOrderedPdMxAsync(string pdId, bool includeDeleted = false) | |
| 659 | 698 | { |
| 660 | 699 | return (await _db.Queryable<WtPdMxEntity>() |
| 661 | - .Where(m => m.PdId == pdId && (m.DeleteMark == null || m.DeleteMark == 0)) | |
| 700 | + .Where(m => m.PdId == pdId) | |
| 701 | + .WhereIF(!includeDeleted, m => m.DeleteMark == null || m.DeleteMark == 0) | |
| 662 | 702 | .ToListAsync()) |
| 663 | 703 | .OrderBy(m => m.Spbh ?? "") |
| 664 | 704 | .ThenBy(m => m.Spbm ?? "") |
| ... | ... | @@ -918,10 +958,11 @@ WHERE c.ck = @ck AND c.sl > 0"; |
| 918 | 958 | } |
| 919 | 959 | |
| 920 | 960 | /// <summary> |
| 921 | - /// 录入实盘:更新实盘数量;支持表内行、有档案的表外追加、无档案的「系统外」明细 | |
| 961 | + /// 录入实盘:更新实盘数量;支持表内行、有档案的表外追加;允许部分未盘中途保存 | |
| 922 | 962 | /// </summary> |
| 923 | 963 | /// <remarks> |
| 924 | - /// 系统外:<c>isUnknown=true</c> 已禁止。入1出1(spxlhType=<c>1</c>)须通过 <c>serialNumbers</c> 录入,且 <c>sjsl</c> 必须与序列号条数一致; | |
| 964 | + /// 空白实盘表示未盘,保存录入不要求全部录完(完成盘点才校验)。 | |
| 965 | + /// 系统外:<c>isUnknown=true</c> 已禁止。入1出1(spxlhType=<c>1</c>)须通过 <c>serialNumbers</c> 录入,且已录行的 <c>sjsl</c> 必须与序列号条数一致; | |
| 925 | 966 | /// 同单序列号全局不可重复。 |
| 926 | 967 | /// </remarks> |
| 927 | 968 | /// <param name="input">主键与明细</param> |
| ... | ... | @@ -1076,10 +1117,8 @@ WHERE c.ck = @ck AND c.sl > 0"; |
| 1076 | 1117 | var working = await _db.Queryable<WtPdMxEntity>() |
| 1077 | 1118 | .Where(m => m.PdId == head.Id && (m.DeleteMark == null || m.DeleteMark == 0)) |
| 1078 | 1119 | .ToListAsync(); |
| 1079 | - var pendingSave = working.Count(m => m.Sjsl == null); | |
| 1080 | - if (pendingSave > 0) | |
| 1081 | - throw NCCException.Bah( | |
| 1082 | - $"还有 {pendingSave} 项未录入实盘数量,无法保存。空白表示未盘,请补全后再保存(实盘为 0 请填写 0)"); | |
| 1120 | + // 保存录入允许部分未盘(Sjsl 为空表示未盘),便于中途存档后继续; | |
| 1121 | + // 「全部录完」仅在 Complete(盘点完成)时校验。 | |
| 1083 | 1122 | await ValidateWorkingMxListAsync(head, working); |
| 1084 | 1123 | |
| 1085 | 1124 | // 首次录实盘刷新账面导致的账面总额变动,同步回写盘点主表,保持完成盘点 Ykje 口径一致 |
| ... | ... | @@ -1425,6 +1464,7 @@ WHERE c.ck = @ck AND c.sl > 0"; |
| 1425 | 1464 | public async Task<dynamic> Delete(string id) |
| 1426 | 1465 | { |
| 1427 | 1466 | EnsureWtPdTables(); |
| 1467 | + EnsureSoftDeleteColumns(); | |
| 1428 | 1468 | var head = await _db.Queryable<WtPdEntity>() |
| 1429 | 1469 | .Where(p => p.Id == id && (p.DeleteMark == null || p.DeleteMark == 0)) |
| 1430 | 1470 | .FirstAsync(); |
| ... | ... | @@ -1435,12 +1475,9 @@ WHERE c.ck = @ck AND c.sl > 0"; |
| 1435 | 1475 | |
| 1436 | 1476 | if (head.Status == PdStatus.Cancelled) |
| 1437 | 1477 | { |
| 1438 | - head.DeleteMark = 1; | |
| 1439 | - await _db.Updateable(head).ExecuteCommandAsync(); | |
| 1440 | - await _db.Updateable<WtPdMxEntity>() | |
| 1441 | - .SetColumns(m => new WtPdMxEntity { DeleteMark = 1 }) | |
| 1442 | - .Where(m => m.PdId == id) | |
| 1443 | - .ExecuteCommandAsync(); | |
| 1478 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAndMxAsync( | |
| 1479 | + _db, "wt_pd", "wt_pd_mx", id, _userManager.UserId ?? "", "F_PdId"); | |
| 1480 | + await _businessOperationLogService.WriteAsync("盘点单", "标记删除", "WtPd", id, $"标记删除盘点单 {id}"); | |
| 1444 | 1481 | return new { msg = "删除成功" }; |
| 1445 | 1482 | } |
| 1446 | 1483 | |
| ... | ... | @@ -1450,18 +1487,49 @@ WHERE c.ck = @ck AND c.sl > 0"; |
| 1450 | 1487 | .AnyAsync(m => m.PdId == id && (m.DeleteMark == null || m.DeleteMark == 0) && m.Sjsl != null); |
| 1451 | 1488 | if (anyCounted) |
| 1452 | 1489 | throw NCCException.Bah("已录入实盘的盘点单请先取消再删除"); |
| 1453 | - head.DeleteMark = 1; | |
| 1454 | - await _db.Updateable(head).ExecuteCommandAsync(); | |
| 1455 | - await _db.Updateable<WtPdMxEntity>() | |
| 1456 | - .SetColumns(m => new WtPdMxEntity { DeleteMark = 1 }) | |
| 1457 | - .Where(m => m.PdId == id) | |
| 1458 | - .ExecuteCommandAsync(); | |
| 1490 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAndMxAsync( | |
| 1491 | + _db, "wt_pd", "wt_pd_mx", id, _userManager.UserId ?? "", "F_PdId"); | |
| 1492 | + await _businessOperationLogService.WriteAsync("盘点单", "标记删除", "WtPd", id, $"标记删除盘点单 {id}"); | |
| 1459 | 1493 | return new { msg = "删除成功" }; |
| 1460 | 1494 | } |
| 1461 | 1495 | |
| 1462 | 1496 | throw NCCException.Bah("当前状态不可删除"); |
| 1463 | 1497 | } |
| 1464 | 1498 | |
| 1499 | + /// <inheritdoc /> | |
| 1500 | + [NonAction] | |
| 1501 | + public async Task RestoreFromRecycleBinAsync(string id) | |
| 1502 | + { | |
| 1503 | + EnsureSoftDeleteColumns(); | |
| 1504 | + var entity = await _db.Queryable<WtPdEntity>().FirstAsync(p => p.Id == id); | |
| 1505 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 1506 | + throw NCCException.Bah("单据不存在或未在回收站"); | |
| 1507 | + await WtBillSoftDeleteHelper.RestoreHeadAndMxAsync(_db, "wt_pd", "wt_pd_mx", id, "F_PdId"); | |
| 1508 | + } | |
| 1509 | + | |
| 1510 | + /// <inheritdoc /> | |
| 1511 | + [NonAction] | |
| 1512 | + public async Task PurgePhysicalAsync(string id) | |
| 1513 | + { | |
| 1514 | + EnsureSoftDeleteColumns(); | |
| 1515 | + var entity = await _db.Queryable<WtPdEntity>().FirstAsync(p => p.Id == id); | |
| 1516 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 1517 | + throw NCCException.Bah("仅可彻底删除回收站中的单据"); | |
| 1518 | + try | |
| 1519 | + { | |
| 1520 | + _db.BeginTran(); | |
| 1521 | + await _db.Deleteable<WtPdMxEntity>().Where(m => m.PdId == id).ExecuteCommandAsync(); | |
| 1522 | + var isOk = await _db.Deleteable<WtPdEntity>().Where(p => p.Id == id).ExecuteCommandAsync(); | |
| 1523 | + if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1002); | |
| 1524 | + _db.CommitTran(); | |
| 1525 | + } | |
| 1526 | + catch (Exception) | |
| 1527 | + { | |
| 1528 | + _db.RollbackTran(); | |
| 1529 | + throw; | |
| 1530 | + } | |
| 1531 | + } | |
| 1532 | + | |
| 1465 | 1533 | /// <summary> |
| 1466 | 1534 | /// 扫码:优先按本仓在库序列号解析;入1出1 走序列号盘点(<c>appendSerial</c>);否则按商品编码。 |
| 1467 | 1535 | /// </summary> |
| ... | ... | @@ -1649,6 +1717,263 @@ WHERE c.ck = @ck AND c.sl > 0"; |
| 1649 | 1717 | } |
| 1650 | 1718 | |
| 1651 | 1719 | /// <summary> |
| 1720 | + /// 批量查询盘点期间销售进出单据,按商品分组返回出库/退货单据摘要(与 <see cref="WtXsckdService"/> 盘点回写口径对齐)。 | |
| 1721 | + /// </summary> | |
| 1722 | + private async Task<(Dictionary<string, List<WtPdPeriodBillItem>> saleOut, | |
| 1723 | + Dictionary<string, List<WtPdPeriodBillItem>> saleReturn)> | |
| 1724 | + LoadPdPeriodBillMapsAsync(WtPdEntity head, List<WtPdMxEntity> mx) | |
| 1725 | + { | |
| 1726 | + var emptyOut = new Dictionary<string, List<WtPdPeriodBillItem>>(StringComparer.Ordinal); | |
| 1727 | + var emptyReturn = new Dictionary<string, List<WtPdPeriodBillItem>>(StringComparer.Ordinal); | |
| 1728 | + if (head == null || mx == null || mx.Count == 0) | |
| 1729 | + return (emptyOut, emptyReturn); | |
| 1730 | + | |
| 1731 | + var pdCk = head.Ck?.Trim(); | |
| 1732 | + if (string.IsNullOrEmpty(pdCk)) | |
| 1733 | + return (emptyOut, emptyReturn); | |
| 1734 | + | |
| 1735 | + var spbhList = mx | |
| 1736 | + .Where(m => !string.IsNullOrWhiteSpace(m.Spbh)) | |
| 1737 | + .Select(m => m.Spbh.Trim()) | |
| 1738 | + .Distinct(StringComparer.Ordinal) | |
| 1739 | + .ToList(); | |
| 1740 | + if (spbhList.Count == 0) | |
| 1741 | + return (emptyOut, emptyReturn); | |
| 1742 | + | |
| 1743 | + var virtualSet = await GetVirtualSpbhSetForPdAsync(spbhList); | |
| 1744 | + spbhList = spbhList.Where(s => !virtualSet.Contains(s)).ToList(); | |
| 1745 | + if (spbhList.Count == 0) | |
| 1746 | + return (emptyOut, emptyReturn); | |
| 1747 | + | |
| 1748 | + var periodStart = head.Zdrq ?? head.CreatorTime ?? FromUnixMs(head.Djrq); | |
| 1749 | + var periodEnd = head.Wcrq ?? DateTime.Now; | |
| 1750 | + | |
| 1751 | + var rawRows = await _db.Queryable<WtXsckdEntity, WtXsckdMxEntity>((h, m) => | |
| 1752 | + new JoinQueryInfos(JoinType.Inner, h.Id == m.Djbh)) | |
| 1753 | + .Where((h, m) => spbhList.Contains(m.Spbh) | |
| 1754 | + && (h.DeleteMark == null || h.DeleteMark == 0) | |
| 1755 | + && (h.Djlx == "销售出库单" || h.Djlx == "零售单" || h.Djlx == "销售退货单") | |
| 1756 | + && h.Djrq >= periodStart && h.Djrq <= periodEnd) | |
| 1757 | + .Select((h, m) => new PdPeriodBillRawRow | |
| 1758 | + { | |
| 1759 | + BillId = h.Id, | |
| 1760 | + Djlx = h.Djlx, | |
| 1761 | + Djzt = h.Djzt, | |
| 1762 | + Spbh = m.Spbh, | |
| 1763 | + Sl = m.Sl, | |
| 1764 | + Ckck = m.Ckck, | |
| 1765 | + Rkck = m.Rkck, | |
| 1766 | + Cjck = h.Cjck, | |
| 1767 | + HeadRkck = h.Rkck | |
| 1768 | + }) | |
| 1769 | + .ToListAsync(); | |
| 1770 | + | |
| 1771 | + if (rawRows.Count == 0) | |
| 1772 | + return (emptyOut, emptyReturn); | |
| 1773 | + | |
| 1774 | + var storeOrCkValues = new HashSet<string>(StringComparer.OrdinalIgnoreCase); | |
| 1775 | + foreach (var row in rawRows) | |
| 1776 | + { | |
| 1777 | + if (!MatchesPdPeriodBillDjzt(row.Djlx, row.Djzt)) continue; | |
| 1778 | + var storeOrCk = ResolvePdPeriodBillStoreOrCk(row); | |
| 1779 | + if (!string.IsNullOrWhiteSpace(storeOrCk)) | |
| 1780 | + storeOrCkValues.Add(storeOrCk.Trim()); | |
| 1781 | + } | |
| 1782 | + | |
| 1783 | + var whMatchMap = await BuildStoreOrCkMatchesPdWarehouseMapAsync(storeOrCkValues, pdCk); | |
| 1784 | + var saleOutAgg = new Dictionary<string, Dictionary<string, WtPdPeriodBillItem>>(StringComparer.Ordinal); | |
| 1785 | + var saleReturnAgg = new Dictionary<string, Dictionary<string, WtPdPeriodBillItem>>(StringComparer.Ordinal); | |
| 1786 | + | |
| 1787 | + foreach (var row in rawRows) | |
| 1788 | + { | |
| 1789 | + if (!MatchesPdPeriodBillDjzt(row.Djlx, row.Djzt)) continue; | |
| 1790 | + if (string.IsNullOrWhiteSpace(row.Spbh)) continue; | |
| 1791 | + var spbh = row.Spbh.Trim(); | |
| 1792 | + if (virtualSet.Contains(spbh)) continue; | |
| 1793 | + if (!decimal.TryParse(row.Sl, out var qty) || qty <= 0m) continue; | |
| 1794 | + | |
| 1795 | + var lx = (row.Djlx ?? "").Trim(); | |
| 1796 | + var isReturn = lx == "销售退货单"; | |
| 1797 | + if (lx != "销售出库单" && lx != "零售单" && !isReturn) continue; | |
| 1798 | + | |
| 1799 | + var storeOrCk = ResolvePdPeriodBillStoreOrCk(row); | |
| 1800 | + if (string.IsNullOrWhiteSpace(storeOrCk)) continue; | |
| 1801 | + storeOrCk = storeOrCk.Trim(); | |
| 1802 | + if (!whMatchMap.TryGetValue(storeOrCk, out var matched) || !matched) continue; | |
| 1803 | + | |
| 1804 | + var billId = row.BillId?.Trim(); | |
| 1805 | + if (string.IsNullOrEmpty(billId)) continue; | |
| 1806 | + | |
| 1807 | + var targetAgg = isReturn ? saleReturnAgg : saleOutAgg; | |
| 1808 | + if (!targetAgg.TryGetValue(spbh, out var billMap)) | |
| 1809 | + { | |
| 1810 | + billMap = new Dictionary<string, WtPdPeriodBillItem>(StringComparer.Ordinal); | |
| 1811 | + targetAgg[spbh] = billMap; | |
| 1812 | + } | |
| 1813 | + | |
| 1814 | + if (billMap.TryGetValue(billId, out var item)) | |
| 1815 | + item.sl += qty; | |
| 1816 | + else | |
| 1817 | + billMap[billId] = new WtPdPeriodBillItem { id = billId, djlx = lx, sl = qty }; | |
| 1818 | + } | |
| 1819 | + | |
| 1820 | + return (ToPeriodBillListMap(saleOutAgg), ToPeriodBillListMap(saleReturnAgg)); | |
| 1821 | + } | |
| 1822 | + | |
| 1823 | + private sealed class PdPeriodBillRawRow | |
| 1824 | + { | |
| 1825 | + public string BillId { get; set; } | |
| 1826 | + public string Djlx { get; set; } | |
| 1827 | + public string Djzt { get; set; } | |
| 1828 | + public string Spbh { get; set; } | |
| 1829 | + public string Sl { get; set; } | |
| 1830 | + public string Ckck { get; set; } | |
| 1831 | + public string Rkck { get; set; } | |
| 1832 | + public string Cjck { get; set; } | |
| 1833 | + public string HeadRkck { get; set; } | |
| 1834 | + } | |
| 1835 | + | |
| 1836 | + /// <summary> | |
| 1837 | + /// 与 <see cref="WtXsckdService"/> 盘点回写取仓口径一致:出库取出库仓,退货取入库仓。 | |
| 1838 | + /// </summary> | |
| 1839 | + private static string ResolvePdPeriodBillStoreOrCk(PdPeriodBillRawRow row) | |
| 1840 | + { | |
| 1841 | + if (row == null) return null; | |
| 1842 | + var lx = (row.Djlx ?? "").Trim(); | |
| 1843 | + if (lx == "销售出库单" || lx == "零售单") | |
| 1844 | + return !string.IsNullOrWhiteSpace(row.Ckck) ? row.Ckck : row.Cjck; | |
| 1845 | + if (lx == "销售退货单") | |
| 1846 | + { | |
| 1847 | + return !string.IsNullOrWhiteSpace(row.Rkck) ? row.Rkck | |
| 1848 | + : (!string.IsNullOrWhiteSpace(row.Ckck) ? row.Ckck | |
| 1849 | + : (!string.IsNullOrWhiteSpace(row.HeadRkck) ? row.HeadRkck : row.Cjck)); | |
| 1850 | + } | |
| 1851 | + return null; | |
| 1852 | + } | |
| 1853 | + | |
| 1854 | + /// <summary> | |
| 1855 | + /// 与 <see cref="WtXsckdService.ShouldWritebackPdForSales"/> 单据状态口径一致(不含运行时 SuppressOutboundStockMutation)。 | |
| 1856 | + /// </summary> | |
| 1857 | + private static bool MatchesPdPeriodBillDjzt(string djlx, string djzt) | |
| 1858 | + { | |
| 1859 | + var lx = (djlx ?? "").Trim(); | |
| 1860 | + if (lx != "销售出库单" && lx != "零售单" && lx != "销售退货单") return false; | |
| 1861 | + var st = (djzt ?? "").Trim(); | |
| 1862 | + if (lx == "销售退货单") | |
| 1863 | + { | |
| 1864 | + if (string.IsNullOrEmpty(st) || string.Equals(st, "草稿", StringComparison.Ordinal)) return false; | |
| 1865 | + if (string.Equals(st, "审核不通过", StringComparison.Ordinal)) return false; | |
| 1866 | + return true; | |
| 1867 | + } | |
| 1868 | + return string.Equals(st, "已审核", StringComparison.Ordinal); | |
| 1869 | + } | |
| 1870 | + | |
| 1871 | + private static Dictionary<string, List<WtPdPeriodBillItem>> ToPeriodBillListMap( | |
| 1872 | + Dictionary<string, Dictionary<string, WtPdPeriodBillItem>> agg) | |
| 1873 | + { | |
| 1874 | + var result = new Dictionary<string, List<WtPdPeriodBillItem>>(StringComparer.Ordinal); | |
| 1875 | + if (agg == null) return result; | |
| 1876 | + foreach (var kv in agg) | |
| 1877 | + result[kv.Key] = kv.Value.Values.OrderBy(v => v.id, StringComparer.Ordinal).ToList(); | |
| 1878 | + return result; | |
| 1879 | + } | |
| 1880 | + | |
| 1881 | + /// <summary>批量判定虚拟商品(<c>wt_sp.F_Splx1=虚拟</c>),与盘点回写跳过虚拟商品一致。</summary> | |
| 1882 | + private async Task<HashSet<string>> GetVirtualSpbhSetForPdAsync(IEnumerable<string> spbhKeys) | |
| 1883 | + { | |
| 1884 | + var keys = spbhKeys? | |
| 1885 | + .Where(k => !string.IsNullOrWhiteSpace(k)) | |
| 1886 | + .Select(k => k.Trim()) | |
| 1887 | + .Distinct(StringComparer.Ordinal) | |
| 1888 | + .ToList() ?? new List<string>(); | |
| 1889 | + var result = new HashSet<string>(StringComparer.Ordinal); | |
| 1890 | + if (keys.Count == 0) return result; | |
| 1891 | + var rows = await _db.Queryable<WtSpEntity>() | |
| 1892 | + .Where(s => keys.Contains(s.Id) && s.Splx1 == "虚拟") | |
| 1893 | + .Select(s => s.Id) | |
| 1894 | + .ToListAsync(); | |
| 1895 | + foreach (var id in rows.Where(x => !string.IsNullOrWhiteSpace(x))) | |
| 1896 | + result.Add(id.Trim()); | |
| 1897 | + return result; | |
| 1898 | + } | |
| 1899 | + | |
| 1900 | + private async Task<Dictionary<string, bool>> BuildStoreOrCkMatchesPdWarehouseMapAsync( | |
| 1901 | + IEnumerable<string> storeOrCkValues, string pdCk) | |
| 1902 | + { | |
| 1903 | + var map = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase); | |
| 1904 | + if (string.IsNullOrWhiteSpace(pdCk)) return map; | |
| 1905 | + var pdCkTrim = pdCk.Trim(); | |
| 1906 | + foreach (var raw in storeOrCkValues.Where(v => !string.IsNullOrWhiteSpace(v)).Select(v => v.Trim()) | |
| 1907 | + .Distinct(StringComparer.OrdinalIgnoreCase)) | |
| 1908 | + { | |
| 1909 | + if (string.Equals(raw, pdCkTrim, StringComparison.OrdinalIgnoreCase)) | |
| 1910 | + { | |
| 1911 | + map[raw] = true; | |
| 1912 | + continue; | |
| 1913 | + } | |
| 1914 | + var ids = await ResolveWarehouseIdsForPdPeriodBillAsync(raw); | |
| 1915 | + map[raw] = ids.Any(id => string.Equals(id, pdCkTrim, StringComparison.OrdinalIgnoreCase)); | |
| 1916 | + } | |
| 1917 | + return map; | |
| 1918 | + } | |
| 1919 | + | |
| 1920 | + /// <summary> | |
| 1921 | + /// 门店/仓库主键展开为仓库 Id 列表(与 <c>WtXsckdService.ResolveWarehouseIdsForSpCostFromStoreOrCkAsync</c> 口径一致)。 | |
| 1922 | + /// </summary> | |
| 1923 | + private async Task<List<string>> ResolveWarehouseIdsForPdPeriodBillAsync(string storeOrWarehouseId) | |
| 1924 | + { | |
| 1925 | + if (string.IsNullOrWhiteSpace(storeOrWarehouseId)) return new List<string>(); | |
| 1926 | + var raw = storeOrWarehouseId.Trim(); | |
| 1927 | + | |
| 1928 | + string grp = null; | |
| 1929 | + var mdRow = await _db.Queryable<WtMdEntity>() | |
| 1930 | + .Where(m => m.Id == raw) | |
| 1931 | + .Select(m => new { m.MdfzId }) | |
| 1932 | + .FirstAsync(); | |
| 1933 | + if (mdRow != null) grp = mdRow.MdfzId; | |
| 1934 | + | |
| 1935 | + List<string> ids; | |
| 1936 | + if (!string.IsNullOrEmpty(grp)) | |
| 1937 | + { | |
| 1938 | + ids = await _db.Ado.SqlQueryAsync<string>( | |
| 1939 | + "SELECT F_Id FROM wt_ck WHERE F_Id = @sid " + | |
| 1940 | + "OR (`F_ssmd` = @sid OR FIND_IN_SET(@sid, `F_ssmd`) > 0) " + | |
| 1941 | + "OR (`F_ssmd` = @grp OR FIND_IN_SET(@grp, `F_ssmd`) > 0)", | |
| 1942 | + new { sid = raw, grp }); | |
| 1943 | + } | |
| 1944 | + else | |
| 1945 | + { | |
| 1946 | + ids = await _db.Ado.SqlQueryAsync<string>( | |
| 1947 | + "SELECT F_Id FROM wt_ck WHERE F_Id = @sid " + | |
| 1948 | + "OR `F_ssmd` = @sid OR FIND_IN_SET(@sid, `F_ssmd`) > 0", | |
| 1949 | + new { sid = raw }); | |
| 1950 | + } | |
| 1951 | + | |
| 1952 | + var list = ids? | |
| 1953 | + .Where(x => !string.IsNullOrWhiteSpace(x)) | |
| 1954 | + .Select(x => x.Trim()) | |
| 1955 | + .Distinct(StringComparer.OrdinalIgnoreCase) | |
| 1956 | + .ToList() ?? new List<string>(); | |
| 1957 | + if (list.Count == 0) | |
| 1958 | + { | |
| 1959 | + var wid = await ResolveWarehouseIdForPdPeriodBillAsync(raw); | |
| 1960 | + if (!string.IsNullOrWhiteSpace(wid)) | |
| 1961 | + list.Add(wid.Trim()); | |
| 1962 | + } | |
| 1963 | + return list; | |
| 1964 | + } | |
| 1965 | + | |
| 1966 | + private async Task<string> ResolveWarehouseIdForPdPeriodBillAsync(string rkckOrId) | |
| 1967 | + { | |
| 1968 | + if (string.IsNullOrWhiteSpace(rkckOrId)) return rkckOrId; | |
| 1969 | + var t = rkckOrId.Trim(); | |
| 1970 | + var byId = await _db.Queryable<WtCkEntity>().Where(c => c.Id == t).Take(1).Select(c => c.Id).ToListAsync(); | |
| 1971 | + if (byId.Count > 0) return byId[0]; | |
| 1972 | + var byName = await _db.Queryable<WtCkEntity>().Where(c => c.Mdmc == t).Take(1).Select(c => c.Id).ToListAsync(); | |
| 1973 | + return byName.Count > 0 ? byName[0] : t; | |
| 1974 | + } | |
| 1975 | + | |
| 1976 | + /// <summary> | |
| 1652 | 1977 | /// 查询仓库是否被盘点锁定 |
| 1653 | 1978 | /// </summary> |
| 1654 | 1979 | /// <param name="ck">仓库 Id</param> | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtSfkService.cs
| ... | ... | @@ -5,7 +5,9 @@ using NCC.Common.Filter; |
| 5 | 5 | using NCC.Dependency; |
| 6 | 6 | using NCC.DynamicApiController; |
| 7 | 7 | using NCC.FriendlyException; |
| 8 | +using NCC.Extend.Interfaces; | |
| 8 | 9 | using NCC.Extend.Interfaces.WtSfk; |
| 10 | +using NCC.Extend.WtBillSoftDelete; | |
| 9 | 11 | using Mapster; |
| 10 | 12 | using Microsoft.AspNetCore.Mvc; |
| 11 | 13 | using SqlSugar; |
| ... | ... | @@ -32,13 +34,18 @@ namespace NCC.Extend.WtSfk |
| 32 | 34 | /// </summary> |
| 33 | 35 | [ApiDescriptionSettings(Tag = "Extend",Name = "WtSfk", Order = 200)] |
| 34 | 36 | [Route("api/Extend/[controller]")] |
| 35 | - public class WtSfkService : IWtSfkService, IDynamicApiController, ITransient | |
| 37 | + public class WtSfkService : IWtSfkService, IDynamicApiController, ITransient, IWtBillRecycleOperations | |
| 36 | 38 | { |
| 37 | 39 | private readonly ISqlSugarRepository<WtSfkEntity> _wtSfkRepository; |
| 38 | 40 | private readonly SqlSugarScope _db; |
| 39 | 41 | private readonly IUserManager _userManager; |
| 40 | 42 | private readonly WtDjzyService _wtDjzyService; |
| 41 | 43 | private readonly WtBillSummaryService _billSummaryService; |
| 44 | + private readonly IBusinessOperationLogService _businessOperationLogService; | |
| 45 | + private static bool _softDeleteColumnsEnsured; | |
| 46 | + | |
| 47 | + /// <inheritdoc /> | |
| 48 | + public WtBillRecycleBillSource BillSource => WtBillRecycleBillSource.WtSfk; | |
| 42 | 49 | |
| 43 | 50 | /// <summary> |
| 44 | 51 | /// 初始化一个<see cref="WtSfkService"/>类型的新实例 |
| ... | ... | @@ -47,24 +54,45 @@ namespace NCC.Extend.WtSfk |
| 47 | 54 | ISqlSugarRepository<WtSfkEntity> wtSfkRepository, |
| 48 | 55 | IUserManager userManager, |
| 49 | 56 | WtDjzyService wtDjzyService, |
| 50 | - WtBillSummaryService billSummaryService) | |
| 57 | + WtBillSummaryService billSummaryService, | |
| 58 | + IBusinessOperationLogService businessOperationLogService) | |
| 51 | 59 | { |
| 52 | 60 | _wtSfkRepository = wtSfkRepository; |
| 53 | 61 | _db = _wtSfkRepository.Context; |
| 54 | 62 | _userManager = userManager; |
| 55 | 63 | _wtDjzyService = wtDjzyService; |
| 56 | 64 | _billSummaryService = billSummaryService; |
| 65 | + _businessOperationLogService = businessOperationLogService; | |
| 66 | + } | |
| 67 | + | |
| 68 | + private void EnsureSoftDeleteColumns() | |
| 69 | + { | |
| 70 | + if (_softDeleteColumnsEnsured) return; | |
| 71 | + WtBillSoftDeleteHelper.EnsureBillSoftDeleteColumnsAsync(_db, "wt_sfk").GetAwaiter().GetResult(); | |
| 72 | + _softDeleteColumnsEnsured = true; | |
| 57 | 73 | } |
| 58 | 74 | |
| 59 | 75 | /// <summary> |
| 60 | - /// 获取收付款单 | |
| 76 | + /// 获取收付款单详情 | |
| 61 | 77 | /// </summary> |
| 62 | - /// <param name="id">参数</param> | |
| 63 | - /// <returns></returns> | |
| 78 | + /// <remarks> | |
| 79 | + /// 默认仅未软删;回收站只读详情传 <c>includeDeleted=true</c>。 | |
| 80 | + /// </remarks> | |
| 81 | + /// <param name="id">单据编号</param> | |
| 82 | + /// <param name="includeDeleted">为 true 时允许读取已软删单据</param> | |
| 83 | + /// <returns>收付款单详情</returns> | |
| 84 | + /// <response code="200">成功</response> | |
| 85 | + /// <response code="404">单据不存在</response> | |
| 86 | + /// <response code="500">服务异常</response> | |
| 64 | 87 | [HttpGet("{id}")] |
| 65 | - public async Task<dynamic> GetInfo(string id) | |
| 88 | + public async Task<dynamic> GetInfo(string id, [FromQuery] bool includeDeleted = false) | |
| 66 | 89 | { |
| 67 | - var entity = await _db.Queryable<WtSfkEntity>().FirstAsync(p => p.Id == id); | |
| 90 | + EnsureSoftDeleteColumns(); | |
| 91 | + var entity = await _db.Queryable<WtSfkEntity>() | |
| 92 | + .Where(p => p.Id == id) | |
| 93 | + .WhereIF(!includeDeleted, p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 94 | + .FirstAsync(); | |
| 95 | + if (entity == null) throw NCCException.Oh(ErrorCode.COM1005); | |
| 68 | 96 | var output = entity.Adapt<WtSfkInfoOutput>(); |
| 69 | 97 | output.billZy = await _billSummaryService.ComputeWtSfkZyByBillIdAsync(entity.Id); |
| 70 | 98 | return output; |
| ... | ... | @@ -78,11 +106,13 @@ namespace NCC.Extend.WtSfk |
| 78 | 106 | [HttpGet("")] |
| 79 | 107 | public async Task<dynamic> GetList([FromQuery] WtSfkListQueryInput input) |
| 80 | 108 | { |
| 109 | + EnsureSoftDeleteColumns(); | |
| 81 | 110 | var sidx = input.sidx == null ? "id" : input.sidx; |
| 82 | 111 | List<string> queryDjrq = input.djrq != null ? input.djrq.Split(',').ToObeject<List<string>>() : null; |
| 83 | 112 | DateTime? startDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.First()) : null; |
| 84 | 113 | DateTime? endDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.Last()) : null; |
| 85 | 114 | var data = await _db.Queryable<WtSfkEntity>() |
| 115 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 86 | 116 | .WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id)) |
| 87 | 117 | .WhereIF(queryDjrq != null, p => p.Djrq >= new DateTime(startDjrq.ToDate().Year, startDjrq.ToDate().Month, startDjrq.ToDate().Day, 0, 0, 0)) |
| 88 | 118 | .WhereIF(queryDjrq != null, p => p.Djrq <= new DateTime(endDjrq.ToDate().Year, endDjrq.ToDate().Month, endDjrq.ToDate().Day, 23, 59, 59)) |
| ... | ... | @@ -148,11 +178,13 @@ namespace NCC.Extend.WtSfk |
| 148 | 178 | [NonAction] |
| 149 | 179 | public async Task<dynamic> GetNoPagingList([FromQuery] WtSfkListQueryInput input) |
| 150 | 180 | { |
| 181 | + EnsureSoftDeleteColumns(); | |
| 151 | 182 | var sidx = input.sidx == null ? "id" : input.sidx; |
| 152 | 183 | List<string> queryDjrq = input.djrq != null ? input.djrq.Split(',').ToObeject<List<string>>() : null; |
| 153 | 184 | DateTime? startDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.First()) : null; |
| 154 | 185 | DateTime? endDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.Last()) : null; |
| 155 | 186 | var data = await _db.Queryable<WtSfkEntity>() |
| 187 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 156 | 188 | .WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id)) |
| 157 | 189 | .WhereIF(queryDjrq != null, p => p.Djrq >= new DateTime(startDjrq.ToDate().Year, startDjrq.ToDate().Month, startDjrq.ToDate().Day, 0, 0, 0)) |
| 158 | 190 | .WhereIF(queryDjrq != null, p => p.Djrq <= new DateTime(endDjrq.ToDate().Year, endDjrq.ToDate().Month, endDjrq.ToDate().Day, 23, 59, 59)) |
| ... | ... | @@ -237,25 +269,15 @@ namespace NCC.Extend.WtSfk |
| 237 | 269 | [HttpPost("batchRemove")] |
| 238 | 270 | public async Task BatchRemove([FromBody] List<string> ids) |
| 239 | 271 | { |
| 240 | - var entitys = await _db.Queryable<WtSfkEntity>().In(it => it.Id, ids).ToListAsync(); | |
| 241 | - if (entitys.Count > 0) | |
| 272 | + EnsureSoftDeleteColumns(); | |
| 273 | + var entitys = await _db.Queryable<WtSfkEntity>() | |
| 274 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 275 | + .In(it => it.Id, ids).ToListAsync(); | |
| 276 | + var uid = _userManager.UserId ?? ""; | |
| 277 | + foreach (var e in entitys) | |
| 242 | 278 | { |
| 243 | - try | |
| 244 | - { | |
| 245 | - //开启事务 | |
| 246 | - _db.BeginTran(); | |
| 247 | - await _wtDjzyService.DeleteBySfkAsync(ids); | |
| 248 | - //批量删除收付款单 | |
| 249 | - await _db.Deleteable<WtSfkEntity>().In(d => d.Id,ids).ExecuteCommandAsync(); | |
| 250 | - //关闭事务 | |
| 251 | - _db.CommitTran(); | |
| 252 | - } | |
| 253 | - catch (Exception) | |
| 254 | - { | |
| 255 | - //回滚事务 | |
| 256 | - _db.RollbackTran(); | |
| 257 | - throw NCCException.Oh(ErrorCode.COM1002); | |
| 258 | - } | |
| 279 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAsync(_db, "wt_sfk", e.Id, uid); | |
| 280 | + await _businessOperationLogService.WriteAsync("收付款单", "标记删除", "WtSfk", e.Id, $"标记删除 {e.Id}"); | |
| 259 | 281 | } |
| 260 | 282 | } |
| 261 | 283 | |
| ... | ... | @@ -291,8 +313,35 @@ namespace NCC.Extend.WtSfk |
| 291 | 313 | [HttpDelete("{id}")] |
| 292 | 314 | public async Task Delete(string id) |
| 293 | 315 | { |
| 294 | - var entity = await _db.Queryable<WtSfkEntity>().FirstAsync(p => p.Id == id); | |
| 316 | + EnsureSoftDeleteColumns(); | |
| 317 | + var entity = await _db.Queryable<WtSfkEntity>() | |
| 318 | + .Where(p => p.Id == id && WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 319 | + .FirstAsync(); | |
| 295 | 320 | _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005); |
| 321 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAsync(_db, "wt_sfk", id, _userManager.UserId ?? ""); | |
| 322 | + await _businessOperationLogService.WriteAsync("收付款单", "标记删除", "WtSfk", id, $"标记删除 {id}"); | |
| 323 | + } | |
| 324 | + | |
| 325 | + /// <inheritdoc /> | |
| 326 | + [NonAction] | |
| 327 | + public async Task RestoreFromRecycleBinAsync(string id) | |
| 328 | + { | |
| 329 | + EnsureSoftDeleteColumns(); | |
| 330 | + var entity = await _db.Queryable<WtSfkEntity>().FirstAsync(p => p.Id == id); | |
| 331 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 332 | + throw NCCException.Bah("单据不存在或未在回收站"); | |
| 333 | + await WtBillSoftDeleteHelper.RestoreHeadAsync(_db, "wt_sfk", id); | |
| 334 | + await _wtDjzyService.UpsertFromSfkAsync(id); | |
| 335 | + } | |
| 336 | + | |
| 337 | + /// <inheritdoc /> | |
| 338 | + [NonAction] | |
| 339 | + public async Task PurgePhysicalAsync(string id) | |
| 340 | + { | |
| 341 | + EnsureSoftDeleteColumns(); | |
| 342 | + var entity = await _db.Queryable<WtSfkEntity>().FirstAsync(p => p.Id == id); | |
| 343 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 344 | + throw NCCException.Bah("仅可彻底删除回收站中的单据"); | |
| 296 | 345 | try |
| 297 | 346 | { |
| 298 | 347 | _db.BeginTran(); | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtTjdService.cs
| ... | ... | @@ -4,7 +4,9 @@ using NCC.Common.Filter; |
| 4 | 4 | using NCC.Dependency; |
| 5 | 5 | using NCC.DynamicApiController; |
| 6 | 6 | using NCC.FriendlyException; |
| 7 | +using NCC.Extend.Interfaces; | |
| 7 | 8 | using NCC.Extend.Interfaces.WtTjd; |
| 9 | +using NCC.Extend.WtBillSoftDelete; | |
| 8 | 10 | using Mapster; |
| 9 | 11 | using Microsoft.AspNetCore.Mvc; |
| 10 | 12 | using SqlSugar; |
| ... | ... | @@ -28,7 +30,7 @@ namespace NCC.Extend.WtTjd |
| 28 | 30 | /// </summary> |
| 29 | 31 | [ApiDescriptionSettings(Tag = "Extend", Name = "WtTjd", Order = 200)] |
| 30 | 32 | [Route("api/Extend/[controller]")] |
| 31 | - public class WtTjdService : IWtTjdService, IDynamicApiController, ITransient | |
| 33 | + public class WtTjdService : IWtTjdService, IDynamicApiController, ITransient, IWtBillRecycleOperations | |
| 32 | 34 | { |
| 33 | 35 | private readonly ISqlSugarRepository<WtTjdEntity> _wtTjdRepository; |
| 34 | 36 | private readonly ISqlSugarRepository<WtTjdMxEntity> _wtTjdMxRepository; |
| ... | ... | @@ -36,6 +38,11 @@ namespace NCC.Extend.WtTjd |
| 36 | 38 | private readonly SqlSugarScope _db; |
| 37 | 39 | private readonly IUserManager _userManager; |
| 38 | 40 | private readonly WtTjdWorkflowHelper _tjdWorkflow; |
| 41 | + private readonly IBusinessOperationLogService _businessOperationLogService; | |
| 42 | + private static bool _softDeleteColumnsEnsured; | |
| 43 | + | |
| 44 | + /// <inheritdoc /> | |
| 45 | + public WtBillRecycleBillSource BillSource => WtBillRecycleBillSource.WtTjd; | |
| 39 | 46 | |
| 40 | 47 | /// <summary> |
| 41 | 48 | /// 初始化一个<see cref="WtTjdService"/>类型的新实例 |
| ... | ... | @@ -45,7 +52,8 @@ namespace NCC.Extend.WtTjd |
| 45 | 52 | ISqlSugarRepository<WtTjdMxEntity> wtTjdMxRepository, |
| 46 | 53 | ISqlSugarRepository<WtSpCostEntity> wtSpCostRepository, |
| 47 | 54 | IUserManager userManager, |
| 48 | - WtTjdWorkflowHelper tjdWorkflow) | |
| 55 | + WtTjdWorkflowHelper tjdWorkflow, | |
| 56 | + IBusinessOperationLogService businessOperationLogService) | |
| 49 | 57 | { |
| 50 | 58 | _wtTjdRepository = wtTjdRepository; |
| 51 | 59 | _wtTjdMxRepository = wtTjdMxRepository; |
| ... | ... | @@ -53,6 +61,14 @@ namespace NCC.Extend.WtTjd |
| 53 | 61 | _db = _wtTjdRepository.Context; |
| 54 | 62 | _userManager = userManager; |
| 55 | 63 | _tjdWorkflow = tjdWorkflow; |
| 64 | + _businessOperationLogService = businessOperationLogService; | |
| 65 | + } | |
| 66 | + | |
| 67 | + private void EnsureSoftDeleteColumns() | |
| 68 | + { | |
| 69 | + if (_softDeleteColumnsEnsured) return; | |
| 70 | + WtBillSoftDeleteHelper.EnsureBillSoftDeleteColumnsAsync(_db, "wt_tjd", "wt_tjd_mx").GetAwaiter().GetResult(); | |
| 71 | + _softDeleteColumnsEnsured = true; | |
| 56 | 72 | } |
| 57 | 73 | |
| 58 | 74 | #region 基础 CRUD |
| ... | ... | @@ -60,19 +76,33 @@ namespace NCC.Extend.WtTjd |
| 60 | 76 | /// <summary> |
| 61 | 77 | /// 获取调价单详情 |
| 62 | 78 | /// </summary> |
| 79 | + /// <remarks> | |
| 80 | + /// 默认仅未软删;回收站只读详情传 <c>includeDeleted=true</c> 可读主表及明细。 | |
| 81 | + /// </remarks> | |
| 63 | 82 | /// <param name="id">单据编号</param> |
| 83 | + /// <param name="includeDeleted">为 true 时包含已软删主表及明细</param> | |
| 64 | 84 | /// <returns>调价单主表及明细</returns> |
| 85 | + /// <response code="200">成功</response> | |
| 86 | + /// <response code="404">单据不存在</response> | |
| 87 | + /// <response code="500">服务异常</response> | |
| 65 | 88 | [HttpGet("{id}")] |
| 66 | - public async Task<dynamic> GetInfo(string id) | |
| 89 | + public async Task<dynamic> GetInfo(string id, [FromQuery] bool includeDeleted = false) | |
| 67 | 90 | { |
| 68 | - var entity = await _db.Queryable<WtTjdEntity>().FirstAsync(p => p.Id == id); | |
| 91 | + EnsureSoftDeleteColumns(); | |
| 92 | + var entity = await _db.Queryable<WtTjdEntity>() | |
| 93 | + .Where(p => p.Id == id) | |
| 94 | + .WhereIF(!includeDeleted, p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 95 | + .FirstAsync(); | |
| 69 | 96 | if (entity == null) |
| 70 | 97 | throw NCCException.Bah("调价单不存在"); |
| 71 | 98 | |
| 72 | 99 | var output = entity.Adapt<WtTjdInfoOutput>(); |
| 73 | 100 | output.spbz = entity.Spbz; |
| 74 | 101 | |
| 75 | - var mxList = await _db.Queryable<WtTjdMxEntity>().Where(w => w.Djbh == id).ToListAsync(); | |
| 102 | + var mxList = await _db.Queryable<WtTjdMxEntity>() | |
| 103 | + .Where(w => w.Djbh == id) | |
| 104 | + .WhereIF(!includeDeleted, w => WtBillSoftDeleteHelper.IsNotDeleted(w.DeleteMark)) | |
| 105 | + .ToListAsync(); | |
| 76 | 106 | output.wtTjdMxList = mxList.Adapt<List<WtTjdMxInfoOutput>>(); |
| 77 | 107 | |
| 78 | 108 | return output; |
| ... | ... | @@ -86,12 +116,14 @@ namespace NCC.Extend.WtTjd |
| 86 | 116 | [HttpGet("")] |
| 87 | 117 | public async Task<dynamic> GetList([FromQuery] WtTjdListQueryInput input) |
| 88 | 118 | { |
| 119 | + EnsureSoftDeleteColumns(); | |
| 89 | 120 | var sidx = input.sidx == null ? "id" : input.sidx; |
| 90 | 121 | List<string> queryDjrq = input.djrq != null ? input.djrq.Split(',').ToObeject<List<string>>() : null; |
| 91 | 122 | DateTime? startDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.First()) : null; |
| 92 | 123 | DateTime? endDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.Last()) : null; |
| 93 | 124 | |
| 94 | 125 | var data = await _db.Queryable<WtTjdEntity>() |
| 126 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 95 | 127 | .WhereIF(!string.IsNullOrEmpty(input.code), p => p.Id.Contains(input.code)) |
| 96 | 128 | .WhereIF(queryDjrq != null, |
| 97 | 129 | p => p.Djrq >= new DateTime(startDjrq.ToDate().Year, startDjrq.ToDate().Month, |
| ... | ... | @@ -284,19 +316,44 @@ namespace NCC.Extend.WtTjd |
| 284 | 316 | [HttpDelete("{id}")] |
| 285 | 317 | public async Task Delete(string id) |
| 286 | 318 | { |
| 287 | - var existing = await _db.Queryable<WtTjdEntity>().FirstAsync(p => p.Id == id); | |
| 319 | + EnsureSoftDeleteColumns(); | |
| 320 | + var existing = await _db.Queryable<WtTjdEntity>() | |
| 321 | + .Where(p => p.Id == id && WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 322 | + .FirstAsync(); | |
| 288 | 323 | if (existing == null) |
| 289 | 324 | throw NCCException.Bah("调价单不存在"); |
| 290 | 325 | if (!WtBillCommonHelpers.IsDeletableDraftState(existing.Djzt, existing.Spbz)) |
| 291 | 326 | throw NCCException.Bah("只有草稿或审核不通过状态的调价单才能删除"); |
| 292 | 327 | |
| 328 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAndMxAsync(_db, "wt_tjd", "wt_tjd_mx", id, _userManager.UserId ?? ""); | |
| 329 | + await _businessOperationLogService.WriteAsync("调价单", "标记删除", "WtTjd", id, $"标记删除 {id}"); | |
| 330 | + } | |
| 331 | + | |
| 332 | + /// <inheritdoc /> | |
| 333 | + [NonAction] | |
| 334 | + public async Task RestoreFromRecycleBinAsync(string id) | |
| 335 | + { | |
| 336 | + EnsureSoftDeleteColumns(); | |
| 337 | + var entity = await _db.Queryable<WtTjdEntity>().FirstAsync(p => p.Id == id); | |
| 338 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 339 | + throw NCCException.Bah("单据不存在或未在回收站"); | |
| 340 | + await WtBillSoftDeleteHelper.RestoreHeadAndMxAsync(_db, "wt_tjd", "wt_tjd_mx", id); | |
| 341 | + } | |
| 342 | + | |
| 343 | + /// <inheritdoc /> | |
| 344 | + [NonAction] | |
| 345 | + public async Task PurgePhysicalAsync(string id) | |
| 346 | + { | |
| 347 | + EnsureSoftDeleteColumns(); | |
| 348 | + var entity = await _db.Queryable<WtTjdEntity>().FirstAsync(p => p.Id == id); | |
| 349 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 350 | + throw NCCException.Bah("仅可彻底删除回收站中的单据"); | |
| 293 | 351 | try |
| 294 | 352 | { |
| 295 | 353 | _db.BeginTran(); |
| 296 | - | |
| 297 | - await _db.Deleteable<WtTjdEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); | |
| 298 | 354 | await _db.Deleteable<WtTjdMxEntity>().Where(u => u.Djbh == id).ExecuteCommandAsync(); |
| 299 | - | |
| 355 | + var isOk = await _db.Deleteable<WtTjdEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); | |
| 356 | + if (!(isOk > 0)) throw NCCException.Bah("删除失败"); | |
| 300 | 357 | _db.CommitTran(); |
| 301 | 358 | } |
| 302 | 359 | catch (Exception) | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtXsckdService.cs
| ... | ... | @@ -47,6 +47,7 @@ using NCC.Extend.WtXsckd; |
| 47 | 47 | using NCC.Extend.WtPl; |
| 48 | 48 | using NCC.Extend.WtHyKjqy; |
| 49 | 49 | using NCC.Extend.WtProductPrice; |
| 50 | +using NCC.Extend.WtBillSoftDelete; | |
| 50 | 51 | using NCC.System.Interfaces.Permission; |
| 51 | 52 | |
| 52 | 53 | namespace NCC.Extend.WtXsckd |
| ... | ... | @@ -56,9 +57,12 @@ namespace NCC.Extend.WtXsckd |
| 56 | 57 | /// </summary> |
| 57 | 58 | [ApiDescriptionSettings(Tag = "Extend",Name = "WtXsckd", Order = 200)] |
| 58 | 59 | [Route("api/Extend/[controller]")] |
| 59 | - public class WtXsckdService : IWtXsckdService, IDynamicApiController, ITransient | |
| 60 | + public class WtXsckdService : IWtXsckdService, IDynamicApiController, ITransient, IWtBillRecycleOperations | |
| 60 | 61 | { |
| 61 | 62 | private const string MemberPointsRuleConfigKey = "WT_MEMBER_POINTS_RULE"; |
| 63 | + | |
| 64 | + /// <summary>采购/报溢等入库明细单次允许自动生成的最大序列号条数(防止数量误填导致爆量生成)。</summary> | |
| 65 | + private const int MaxInboundSerialGeneratePerMxLine = 9999; | |
| 62 | 66 | private readonly ISqlSugarRepository<WtXsckdEntity> _wtXsckdRepository; |
| 63 | 67 | private readonly ISqlSugarRepository<WtXsckdMxEntity> _wtXsckdMxRepository; |
| 64 | 68 | private readonly SqlSugarScope _db; |
| ... | ... | @@ -71,6 +75,9 @@ namespace NCC.Extend.WtXsckd |
| 71 | 75 | private readonly IServiceProvider _serviceProvider; |
| 72 | 76 | private readonly IAuthorizeService _authorizeService; |
| 73 | 77 | private readonly IBusinessOperationLogService _businessOperationLogService; |
| 78 | + | |
| 79 | + /// <inheritdoc /> | |
| 80 | + public WtBillRecycleBillSource BillSource => WtBillRecycleBillSource.WtXsckd; | |
| 74 | 81 | |
| 75 | 82 | // 序列号生成信号量,确保线程安全 |
| 76 | 83 | private static readonly SemaphoreSlim _serialNumberSemaphore = new SemaphoreSlim(1, 1); |
| ... | ... | @@ -450,20 +457,62 @@ LIMIT 1"; |
| 450 | 457 | |
| 451 | 458 | /// <summary> |
| 452 | 459 | /// 盘点期间销售类单据是否需要回写盘点明细(仅「已过账、实际改动 wt_sp_cost.sl 的销售/退货」需要)。 |
| 453 | - /// 采用「已审核 + 非草稿」口径:收银台/门店销售出库、零售、销售退货均为免审即已审核,覆盖盘点期间的主要场景; | |
| 454 | - /// 预售出库/退货不动实物库存,无需回写(仅放行锁)。销售出库/零售在客服补发-漏发场景不扣库存(<see cref="SuppressOutboundStockMutation"/>)时同样不回写。 | |
| 460 | + /// <list type="bullet"> | |
| 461 | + /// <item>销售出库/零售:仅「已审核」回写(待审不过账库存)。</item> | |
| 462 | + /// <item>销售退货:创建时即过账加回库存(含待审核),故「待审核/已审核」均回写,避免后台进审退货漏进盘点表。</item> | |
| 463 | + /// </list> | |
| 464 | + /// 预售出库/退货不动实物库存,无需回写。客服补发-漏发(<see cref="SuppressOutboundStockMutation"/>)不回写。 | |
| 455 | 465 | /// </summary> |
| 456 | 466 | private static bool ShouldWritebackPdForSales(string djlx, WtXsckdEntity entity) |
| 457 | 467 | { |
| 458 | 468 | if (entity == null) return false; |
| 459 | 469 | var lx = (djlx ?? entity.Djlx ?? "").Trim(); |
| 460 | 470 | if (lx != "销售出库单" && lx != "零售单" && lx != "销售退货单") return false; |
| 461 | - if (!string.Equals(entity.Djzt, "已审核", StringComparison.Ordinal)) return false; | |
| 471 | + var djzt = (entity.Djzt ?? "").Trim(); | |
| 472 | + if (lx == "销售退货单") | |
| 473 | + { | |
| 474 | + // 退货 Create 时 UpdateSpCostOnCreate 对「待审核」也会加回库存,回写须与过账同步 | |
| 475 | + if (string.Equals(djzt, "草稿", StringComparison.Ordinal) || string.IsNullOrEmpty(djzt)) | |
| 476 | + return false; | |
| 477 | + if (string.Equals(djzt, "审核不通过", StringComparison.Ordinal)) | |
| 478 | + return false; | |
| 479 | + } | |
| 480 | + else if (!string.Equals(djzt, "已审核", StringComparison.Ordinal)) | |
| 481 | + { | |
| 482 | + return false; | |
| 483 | + } | |
| 462 | 484 | if ((lx == "销售出库单" || lx == "零售单") && SuppressOutboundStockMutation.Value) return false; |
| 463 | 485 | return true; |
| 464 | 486 | } |
| 465 | 487 | |
| 466 | 488 | /// <summary> |
| 489 | + /// 终审通过后按已落库明细回写盘点(销售出库/零售);无进行中盘点时内部 no-op。 | |
| 490 | + /// 销售退货不在此回写:退货在 Create/Update 过账时(待审核/已审核)已同步回写,终审再调会把 Ckc/SaleReturnQty 重复加一遍。 | |
| 491 | + /// </summary> | |
| 492 | + private async Task TryWritebackPdAfterSalesFinalApprovalAsync(WtXsckdEntity entity, string documentId) | |
| 493 | + { | |
| 494 | + if (entity == null || string.IsNullOrWhiteSpace(documentId)) return; | |
| 495 | + var lx = (entity.Djlx ?? "").Trim(); | |
| 496 | + if (lx != "销售出库单" && lx != "零售单") return; | |
| 497 | + // 调用方应已将 Djzt 置为已审核;再保险一次 | |
| 498 | + var djztBefore = entity.Djzt; | |
| 499 | + entity.Djzt = "已审核"; | |
| 500 | + try | |
| 501 | + { | |
| 502 | + if (!ShouldWritebackPdForSales(lx, entity)) return; | |
| 503 | + var mxList = await _db.Queryable<WtXsckdMxEntity>() | |
| 504 | + .Where(d => d.Djbh == documentId) | |
| 505 | + .ToListAsync(); | |
| 506 | + if (mxList.Count == 0) return; | |
| 507 | + await ApplyPdSalesWritebackAsync(lx, entity, mxList); | |
| 508 | + } | |
| 509 | + finally | |
| 510 | + { | |
| 511 | + entity.Djzt = djztBefore; | |
| 512 | + } | |
| 513 | + } | |
| 514 | + | |
| 515 | + /// <summary> | |
| 467 | 516 | /// 查询候选仓(已归一为仓库 Id)中当前存在的「进行中」盘点单 Id;不存在返回 null。 |
| 468 | 517 | /// </summary> |
| 469 | 518 | private async Task<string> FindActivePdIdForWarehousesAsync(List<string> warehouseIds) |
| ... | ... | @@ -488,10 +537,11 @@ LIMIT 1"; |
| 488 | 537 | /// <summary> |
| 489 | 538 | /// 盘点期间销售出库/退货过账成功后,对涉及仓库存在「进行中」盘点的商品回写盘点明细: |
| 490 | 539 | /// <list type="bullet"> |
| 491 | - /// <item>未盘明细(Sjsl 为 NULL):跳过,不改数(其首次录入实盘时会把账面刷新为当时实时值)。</item> | |
| 540 | + /// <item>快照内未盘明细(Sjsl 为 NULL 且非表外):出库/退货跳过账面改数(首次录入实盘时会把账面刷新为当时实时值)。</item> | |
| 541 | + /// <item>快照外销售退货:自动追加表外明细(Sjsl=NULL,Ckc=当前 wt_sp_cost.sl,SaleReturnQty=本次数量,IsExtra=true);表外未盘行后续出库/再退货须同步改 Ckc 与审计数,否则账面会卡住退货后的瞬时值。</item> | |
| 492 | 542 | /// <item>已盘明细:同步调整账面 Ckc 与实盘 Sjsl(出库 −数量、退货 +数量),保持差异 Cy=实盘−账面 仍只反映真正盘差,并累计「盘点期间已出库/退货」审计数量,避免完成盘点时重复扣减。</item> |
| 493 | 543 | /// </list> |
| 494 | - /// 仅处理非串码商品(库存以 wt_sp_cost.sl 为准);串码(入1出1/入0出1)商品的盘亏在完成盘点时按「当前在库序列号」实时计算,天然已扣除期间销售,无需回写。 | |
| 544 | + /// 串码(入1出1/入0出1)已盘明细在完成盘点时按「当前在库序列号」实时计算,无需回写 Ckc/Sjsl;快照外串码退货仍会追加未盘明细供盘点可见。 | |
| 495 | 545 | /// </summary> |
| 496 | 546 | /// <param name="djlx">单据类型(销售出库单/零售单/销售退货单)</param> |
| 497 | 547 | /// <param name="entity">单据主表</param> |
| ... | ... | @@ -511,11 +561,13 @@ LIMIT 1"; |
| 511 | 561 | |
| 512 | 562 | // 汇总:pdId -> (spbh -> 净变动数量)。同单多行同商品累加,串码商品跳过。 |
| 513 | 563 | var agg = new Dictionary<string, Dictionary<string, decimal>>(StringComparer.Ordinal); |
| 564 | + var virtualSpbhSet = await GetVirtualMxSpbhSetAsync(mxList.Select(m => m?.Spbh)); | |
| 514 | 565 | foreach (var detail in mxList) |
| 515 | 566 | { |
| 516 | 567 | if (detail == null || string.IsNullOrWhiteSpace(detail.Spbh)) continue; |
| 517 | 568 | if (!decimal.TryParse(detail.Sl, out var qty) || qty <= 0) continue; |
| 518 | 569 | var spbh = detail.Spbh.Trim(); |
| 570 | + if (virtualSpbhSet.Contains(spbh)) continue; | |
| 519 | 571 | // 与 UpdateSpCostOnCreate 取仓口径一致:出库取出库仓,退货取入库仓 |
| 520 | 572 | var storeOrCk = baseSign < 0 |
| 521 | 573 | ? (!string.IsNullOrWhiteSpace(detail.Ckck) ? detail.Ckck : entity.Cjck) |
| ... | ... | @@ -549,7 +601,10 @@ LIMIT 1"; |
| 549 | 601 | } |
| 550 | 602 | |
| 551 | 603 | /// <summary> |
| 552 | - /// 回写单个盘点明细:仅对「已盘」明细调整账面/实盘并累计审计数量;同步维护盘点主表账面总额 F_Zmzje。 | |
| 604 | + /// 回写单个盘点明细:已盘明细同步调整账面/实盘并累计审计数量; | |
| 605 | + /// 快照外销售退货正向过账时自动追加表外明细(<see cref="InsertExtraPdMxForSaleReturnAsync"/>); | |
| 606 | + /// 表外未盘行后续出库/再退货/冲回同步改账面与审计数(<see cref="WritebackUncountedExtraPdMxAsync"/>)。 | |
| 607 | + /// 同步维护盘点主表账面总额 F_Zmzje。 | |
| 553 | 608 | /// </summary> |
| 554 | 609 | /// <param name="pdId">盘点单 Id</param> |
| 555 | 610 | /// <param name="spbh">商品 Id</param> |
| ... | ... | @@ -560,14 +615,29 @@ LIMIT 1"; |
| 560 | 615 | bool isReturnBill) |
| 561 | 616 | { |
| 562 | 617 | if (delta == 0m) return; |
| 563 | - // 商品不在盘点快照内时跳过,禁止 FirstAsync 抛异常影响销售单据落库 | |
| 564 | 618 | var mxRows = await _db.Queryable<WtPdMxEntity>() |
| 565 | 619 | .Where(m => m.PdId == pdId && m.Spbh == spbh && (m.DeleteMark == null || m.DeleteMark == 0)) |
| 566 | 620 | .Take(1) |
| 567 | 621 | .ToListAsync(); |
| 568 | 622 | var mx = mxRows.FirstOrDefault(); |
| 569 | - if (mx == null) return; | |
| 570 | - if (mx.Sjsl == null) return; // 未盘:不改数(首次录实盘时刷新账面) | |
| 623 | + | |
| 624 | + // 快照外退货入库:自动追加表外明细(Sjsl=NULL,Ckc=当前实时账面,SaleReturnQty=本次数量) | |
| 625 | + if (mx == null) | |
| 626 | + { | |
| 627 | + if (isReturnBill && !reverse && delta > 0m) | |
| 628 | + await InsertExtraPdMxForSaleReturnAsync(pdId, spbh, delta); | |
| 629 | + return; | |
| 630 | + } | |
| 631 | + | |
| 632 | + // 未盘明细: | |
| 633 | + // - 快照内未盘:跳过改数(首次录实盘时按实时 wt_sp_cost 刷新账面) | |
| 634 | + // - 表外未盘(IsExtra,盘点期间退货追加):Ckc 已按退货后实时库存写入,后续出库/再退货/冲回必须同步改 Ckc 与审计数 | |
| 635 | + if (mx.Sjsl == null) | |
| 636 | + { | |
| 637 | + if (mx.IsExtra) | |
| 638 | + await WritebackUncountedExtraPdMxAsync(pdId, mx, delta, reverse, isReturnBill); | |
| 639 | + return; | |
| 640 | + } | |
| 571 | 641 | |
| 572 | 642 | var oldCkc = mx.Ckc; |
| 573 | 643 | var newCkc = oldCkc + delta; |
| ... | ... | @@ -596,9 +666,128 @@ LIMIT 1"; |
| 596 | 666 | // 账面变动同步盘点主表账面总额,保持完成盘点时 Ykje=实盘合计−账面合计口径一致 |
| 597 | 667 | var deltaZmje = Math.Round((newCkc - oldCkc) * mx.Cbj, 4); |
| 598 | 668 | if (deltaZmje != 0m) |
| 599 | - await _db.Ado.ExecuteCommandAsync( | |
| 600 | - "UPDATE wt_pd SET F_Zmzje = IFNULL(F_Zmzje,0) + @d, F_LastModifyTime = NOW() WHERE F_Id = @id", | |
| 601 | - new { d = deltaZmje, id = pdId }); | |
| 669 | + await AdjustPdZmzjeAsync(pdId, deltaZmje); | |
| 670 | + } | |
| 671 | + | |
| 672 | + /// <summary> | |
| 673 | + /// 盘点期间快照外销售退货正向过账:向进行中盘点单追加表外明细行。 | |
| 674 | + /// 新建行 Sjsl=NULL(未盘),Ckc=当前 wt_sp_cost.sl(与首次录实盘刷新口径一致),SaleReturnQty=本次退货数量。 | |
| 675 | + /// </summary> | |
| 676 | + private async Task InsertExtraPdMxForSaleReturnAsync(string pdId, string spbh, decimal returnQty) | |
| 677 | + { | |
| 678 | + if (returnQty <= 0m) return; | |
| 679 | + var spbhTrim = spbh?.Trim(); | |
| 680 | + if (string.IsNullOrWhiteSpace(spbhTrim)) return; | |
| 681 | + | |
| 682 | + if (await _db.Queryable<WtPdMxEntity>().AnyAsync(m => | |
| 683 | + m.PdId == pdId && m.Spbh == spbhTrim && (m.DeleteMark == null || m.DeleteMark == 0))) | |
| 684 | + return; | |
| 685 | + | |
| 686 | + var pdRows = await _db.Queryable<WtPdEntity>() | |
| 687 | + .Where(p => p.Id == pdId && p.Status == "进行中" && (p.DeleteMark == null || p.DeleteMark == 0)) | |
| 688 | + .Select(p => new { p.Id, p.Ck }) | |
| 689 | + .Take(1) | |
| 690 | + .ToListAsync(); | |
| 691 | + var pd = pdRows.FirstOrDefault(); | |
| 692 | + if (pd == null || string.IsNullOrWhiteSpace(pd.Ck)) return; | |
| 693 | + | |
| 694 | + var spRows = await _db.Queryable<WtSpEntity>() | |
| 695 | + .Where(s => s.Id == spbhTrim) | |
| 696 | + .Select(s => new { s.Id, s.Spbm, s.Spmc, s.Splx1 }) | |
| 697 | + .Take(1) | |
| 698 | + .ToListAsync(); | |
| 699 | + var sp = spRows.FirstOrDefault(); | |
| 700 | + if (sp == null) return; | |
| 701 | + if (string.Equals(sp.Splx1?.Trim(), "虚拟", StringComparison.Ordinal)) return; | |
| 702 | + | |
| 703 | + var ck = pd.Ck.Trim(); | |
| 704 | + var warehouseIds = new List<string> { ck }; | |
| 705 | + var currentCkc = await QueryWtSpCostTotalQtyForWarehousesAsync(spbhTrim, warehouseIds); | |
| 706 | + var cbj = await QueryWtSpCostCbjForWarehouseCandidatesAsync(spbhTrim, warehouseIds); | |
| 707 | + var ckcDec = Convert.ToDecimal(currentCkc); | |
| 708 | + var now = DateTime.Now; | |
| 709 | + | |
| 710 | + var mxNew = new WtPdMxEntity | |
| 711 | + { | |
| 712 | + Id = YitIdHelper.NextId().ToString(), | |
| 713 | + PdId = pdId, | |
| 714 | + Spbh = spbhTrim, | |
| 715 | + Spbm = sp.Spbm, | |
| 716 | + Spmc = sp.Spmc, | |
| 717 | + Ckc = ckcDec, | |
| 718 | + Cbj = cbj, | |
| 719 | + Sjsl = null, | |
| 720 | + Cy = null, | |
| 721 | + Cyje = null, | |
| 722 | + IsExtra = true, | |
| 723 | + IsUnknown = false, | |
| 724 | + SaleReturnQty = returnQty, | |
| 725 | + CreatorTime = now, | |
| 726 | + LastModifyTime = now | |
| 727 | + }; | |
| 728 | + | |
| 729 | + await _db.Insertable(mxNew).ExecuteCommandAsync(); | |
| 730 | + var deltaZmje = Math.Round(ckcDec * cbj, 4); | |
| 731 | + if (deltaZmje != 0m) | |
| 732 | + await AdjustPdZmzjeAsync(pdId, deltaZmje); | |
| 733 | + } | |
| 734 | + | |
| 735 | + /// <summary> | |
| 736 | + /// 未盘表外追加行(IsExtra)同步账面与审计: | |
| 737 | + /// 出库/退货正向改 Ckc,并累计 SaleOutQty / SaleReturnQty;冲回则反向扣减。 | |
| 738 | + /// 账面与两侧审计均归零时软删行(避免残留 0 行)。 | |
| 739 | + /// </summary> | |
| 740 | + private async Task WritebackUncountedExtraPdMxAsync(string pdId, WtPdMxEntity mx, decimal delta, | |
| 741 | + bool reverse, bool isReturnBill) | |
| 742 | + { | |
| 743 | + if (mx == null || delta == 0m) return; | |
| 744 | + var oldCkc = mx.Ckc; | |
| 745 | + var newCkc = oldCkc + delta; | |
| 746 | + if (newCkc < 0) newCkc = 0; | |
| 747 | + | |
| 748 | + var absQty = Math.Abs(delta); | |
| 749 | + if (isReturnBill) | |
| 750 | + mx.SaleReturnQty = Math.Max(0m, (mx.SaleReturnQty ?? 0m) + (reverse ? -absQty : absQty)); | |
| 751 | + else | |
| 752 | + mx.SaleOutQty = Math.Max(0m, (mx.SaleOutQty ?? 0m) + (reverse ? -absQty : absQty)); | |
| 753 | + | |
| 754 | + mx.Ckc = newCkc; | |
| 755 | + mx.LastModifyTime = DateTime.Now; | |
| 756 | + | |
| 757 | + var saleOut = mx.SaleOutQty ?? 0m; | |
| 758 | + var saleRet = mx.SaleReturnQty ?? 0m; | |
| 759 | + if (newCkc <= 0m && saleOut <= 0m && saleRet <= 0m) | |
| 760 | + { | |
| 761 | + mx.DeleteMark = 1; | |
| 762 | + await _db.Updateable(mx) | |
| 763 | + .UpdateColumns(m => new | |
| 764 | + { | |
| 765 | + m.Ckc, m.SaleOutQty, m.SaleReturnQty, m.DeleteMark, m.LastModifyTime | |
| 766 | + }) | |
| 767 | + .ExecuteCommandAsync(); | |
| 768 | + var deltaZmje = Math.Round(-oldCkc * mx.Cbj, 4); | |
| 769 | + if (deltaZmje != 0m) | |
| 770 | + await AdjustPdZmzjeAsync(pdId, deltaZmje); | |
| 771 | + return; | |
| 772 | + } | |
| 773 | + | |
| 774 | + await _db.Updateable(mx) | |
| 775 | + .UpdateColumns(m => new { m.Ckc, m.SaleOutQty, m.SaleReturnQty, m.LastModifyTime }) | |
| 776 | + .ExecuteCommandAsync(); | |
| 777 | + var zmjeDelta = Math.Round((newCkc - oldCkc) * mx.Cbj, 4); | |
| 778 | + if (zmjeDelta != 0m) | |
| 779 | + await AdjustPdZmzjeAsync(pdId, zmjeDelta); | |
| 780 | + } | |
| 781 | + | |
| 782 | + /// <summary> | |
| 783 | + /// 增量调整盘点主表账面总额 F_Zmzje。 | |
| 784 | + /// </summary> | |
| 785 | + private async Task AdjustPdZmzjeAsync(string pdId, decimal deltaZmje) | |
| 786 | + { | |
| 787 | + if (deltaZmje == 0m) return; | |
| 788 | + await _db.Ado.ExecuteCommandAsync( | |
| 789 | + "UPDATE wt_pd SET F_Zmzje = IFNULL(F_Zmzje,0) + @d, F_LastModifyTime = NOW() WHERE F_Id = @id", | |
| 790 | + new { d = deltaZmje, id = pdId }); | |
| 602 | 791 | } |
| 603 | 792 | |
| 604 | 793 | /// <summary> |
| ... | ... | @@ -655,10 +844,12 @@ LIMIT 1"; |
| 655 | 844 | |
| 656 | 845 | var insufficient = new List<string>(); |
| 657 | 846 | var outStoreId = entity.Cjck; |
| 847 | + var virtualSpbhSet = await GetVirtualMxSpbhSetAsync(mxList.Select(m => m.Spbh)); | |
| 658 | 848 | foreach (var detail in mxList) |
| 659 | 849 | { |
| 660 | 850 | if (string.IsNullOrEmpty(detail.Spbh)) continue; |
| 661 | 851 | if (!int.TryParse(detail.Sl, out int qty) || qty <= 0) continue; |
| 852 | + if (virtualSpbhSet.Contains(detail.Spbh.Trim())) continue; | |
| 662 | 853 | |
| 663 | 854 | var spName = string.IsNullOrWhiteSpace(detail.Spmc) ? detail.Spbh.Trim() : detail.Spmc.Trim(); |
| 664 | 855 | var detailStoreOrWarehouseId = !string.IsNullOrEmpty(detail.Ckck) ? detail.Ckck : outStoreId; |
| ... | ... | @@ -1175,12 +1366,23 @@ WHERE d.djlx IN ('销售退货单','预售退货单','委托代销退货单') |
| 1175 | 1366 | .Select(s => s.Trim()) |
| 1176 | 1367 | .Distinct(StringComparer.Ordinal) |
| 1177 | 1368 | .ToList(); |
| 1369 | + if (!TryParseMxSlForSerialQty(mxEntities[i].Sl, out var presetQty)) | |
| 1370 | + { | |
| 1371 | + mxEntities[i].RkXlhPreset = null; | |
| 1372 | + continue; | |
| 1373 | + } | |
| 1374 | + | |
| 1178 | 1375 | var sns = (fromSel != null && fromSel.Count > 0) ? fromSel : fromSnProp; |
| 1179 | 1376 | if (sns != null && sns.Count > 0 && !_mxRkXlhPresetColumnReady) |
| 1180 | 1377 | throw NCCException.Bah( |
| 1181 | 1378 | "数据库表 wt_xsckd_mx 缺少列 rk_xlh_preset,无法保存采购入库预填序列号。请使用有 ALTER 权限的账号执行:ALTER TABLE `wt_xsckd_mx` ADD COLUMN `rk_xlh_preset` text NULL COMMENT '采购入库预填序列号JSON数组';"); |
| 1182 | 1379 | if (sns != null && sns.Count > 0) |
| 1380 | + { | |
| 1381 | + if (sns.Count != presetQty) | |
| 1382 | + throw NCCException.Bah( | |
| 1383 | + $"第 {i + 1} 行预填序列号条数({sns.Count})须等于数量({presetQty})"); | |
| 1183 | 1384 | mxEntities[i].RkXlhPreset = Newtonsoft.Json.JsonConvert.SerializeObject(sns); |
| 1385 | + } | |
| 1184 | 1386 | else |
| 1185 | 1387 | mxEntities[i].RkXlhPreset = null; |
| 1186 | 1388 | } |
| ... | ... | @@ -1755,6 +1957,86 @@ WHERE d.djlx IN ('销售退货单','预售退货单','委托代销退货单') |
| 1755 | 1957 | } |
| 1756 | 1958 | |
| 1757 | 1959 | /// <summary> |
| 1960 | + /// 虚拟商品(<c>wt_sp.F_Splx1=虚拟</c>)无库存概念,不参与 <c>wt_sp_cost</c> 数量进出与库存不足校验。 | |
| 1961 | + /// </summary> | |
| 1962 | + private static bool IsVirtualProduct(WtSpEntity sp) | |
| 1963 | + => sp != null && string.Equals(sp.Splx1?.Trim(), "虚拟", StringComparison.Ordinal); | |
| 1964 | + | |
| 1965 | + /// <summary> | |
| 1966 | + /// 判定明细 <c>spbh</c>(可为 <c>wt_sp.F_Id</c> 或 <c>F_Spbm</c>)是否虚拟商品。 | |
| 1967 | + /// </summary> | |
| 1968 | + private async Task<bool> IsVirtualMxSpbhAsync(string spbh) | |
| 1969 | + { | |
| 1970 | + if (string.IsNullOrWhiteSpace(spbh)) return false; | |
| 1971 | + var dict = await BuildWtSpDictByMxSpbhAsync(new[] { spbh }); | |
| 1972 | + return IsVirtualProduct(ResolveSpForMxSpbh(spbh, dict)); | |
| 1973 | + } | |
| 1974 | + | |
| 1975 | + /// <summary> | |
| 1976 | + /// 批量判定明细 <c>spbh</c> 中哪些为虚拟商品(返回与入参一致的 spbh 键集合)。 | |
| 1977 | + /// </summary> | |
| 1978 | + private async Task<HashSet<string>> GetVirtualMxSpbhSetAsync(IEnumerable<string> spbhKeys) | |
| 1979 | + { | |
| 1980 | + var keys = spbhKeys? | |
| 1981 | + .Where(k => !string.IsNullOrWhiteSpace(k)) | |
| 1982 | + .Select(k => k.Trim()) | |
| 1983 | + .Distinct(StringComparer.Ordinal) | |
| 1984 | + .ToList() ?? new List<string>(); | |
| 1985 | + var result = new HashSet<string>(StringComparer.Ordinal); | |
| 1986 | + if (keys.Count == 0) return result; | |
| 1987 | + var dict = await BuildWtSpDictByMxSpbhAsync(keys); | |
| 1988 | + foreach (var key in keys) | |
| 1989 | + { | |
| 1990 | + if (IsVirtualProduct(ResolveSpForMxSpbh(key, dict))) | |
| 1991 | + result.Add(key); | |
| 1992 | + } | |
| 1993 | + return result; | |
| 1994 | + } | |
| 1995 | + | |
| 1996 | + /// <summary> | |
| 1997 | + /// 将明细 <see cref="WtXsckdMxEntity.Sl"/> 解析为可用于序列号生成的正整数数量;小数或 <= 0 不参与生成。 | |
| 1998 | + /// </summary> | |
| 1999 | + private static bool TryParseMxSlForSerialQty(string? sl, out int qty, bool throwIfExceedsMax = false) | |
| 2000 | + { | |
| 2001 | + qty = 0; | |
| 2002 | + if (string.IsNullOrWhiteSpace(sl)) return false; | |
| 2003 | + if (!decimal.TryParse(sl.Trim(), NumberStyles.Any, CultureInfo.InvariantCulture, out var dec)) | |
| 2004 | + return false; | |
| 2005 | + if (dec <= 0m) return false; | |
| 2006 | + if (dec != decimal.Truncate(dec)) return false; | |
| 2007 | + if (dec > MaxInboundSerialGeneratePerMxLine) | |
| 2008 | + { | |
| 2009 | + if (throwIfExceedsMax) | |
| 2010 | + throw NCCException.Bah( | |
| 2011 | + $"明细数量 {dec:0.##} 超出单次入库序列号生成上限 {MaxInboundSerialGeneratePerMxLine},请核对数量是否正确"); | |
| 2012 | + return false; | |
| 2013 | + } | |
| 2014 | + | |
| 2015 | + qty = (int)dec; | |
| 2016 | + return qty > 0; | |
| 2017 | + } | |
| 2018 | + | |
| 2019 | + /// <summary> | |
| 2020 | + /// 采购/报溢入库是否自动生成序列号台账。 | |
| 2021 | + /// <list type="bullet"> | |
| 2022 | + /// <item>仅明确「入1出1」(1) 按数量生成。</item> | |
| 2023 | + /// <item>「入0出1」(2):入库不要求人工录码,但仍自动生成占位码,供出库扫真机身码时 FIFO 核销。</item> | |
| 2024 | + /// <item>「入0出0」(3)、未配置类型(null/空)、虚拟品:不生成(未配置按入0出0口径)。</item> | |
| 2025 | + /// </list> | |
| 2026 | + /// </summary> | |
| 2027 | + private static bool IsInboundSerialProduct(WtSpEntity? sp) | |
| 2028 | + { | |
| 2029 | + if (sp == null) return false; | |
| 2030 | + if (IsVirtualProduct(sp)) return false; | |
| 2031 | + var t = sp.SpxlhType?.Trim(); | |
| 2032 | + if (string.IsNullOrEmpty(t)) return false; // 未配置 = 入0出0 | |
| 2033 | + if (string.Equals(t, "3", StringComparison.Ordinal)) return false; | |
| 2034 | + // 1=入1出1;2=入0出1(占位码) | |
| 2035 | + return string.Equals(t, "1", StringComparison.Ordinal) | |
| 2036 | + || string.Equals(t, "2", StringComparison.Ordinal); | |
| 2037 | + } | |
| 2038 | + | |
| 2039 | + /// <summary> | |
| 1758 | 2040 | /// 可参与会员积分(送分基数、积分抵扣金额上限)的明细金额合计。 |
| 1759 | 2041 | /// </summary> |
| 1760 | 2042 | private async Task<decimal> SumMemberPointsEligibleJeAsync(List<WtXsckdMxEntity> details) |
| ... | ... | @@ -3845,12 +4127,22 @@ WHERE d.djlx IN ('销售退货单','预售退货单','委托代销退货单') |
| 3845 | 4127 | WtXsckdDataAuthorizeFilter.ResolveAsync(_db, _userManager, _authorizeService); |
| 3846 | 4128 | |
| 3847 | 4129 | /// <summary> |
| 3848 | - /// 获取销售出库单 | |
| 4130 | + /// 获取销售出库单详情 | |
| 3849 | 4131 | /// </summary> |
| 4132 | + /// <remarks> | |
| 4133 | + /// 主表与明细按 Id 查询,不按 F_DeleteMark 过滤,已软删单据亦可返回完整详情(含明细)。 | |
| 4134 | + /// 参数 <c>includeDeleted</c> 与其它单据接口对齐,供回收站调用;对本接口无额外过滤影响。 | |
| 4135 | + /// | |
| 4136 | + /// 示例:GET /api/Extend/WtXsckd/{id}?includeDeleted=true | |
| 4137 | + /// </remarks> | |
| 3850 | 4138 | /// <param name="id">单据编号</param> |
| 3851 | - /// <returns>详情数据;单据不存在或已删除时返回 COM1005</returns> | |
| 4139 | + /// <param name="includeDeleted">回收站只读详情时传 true(与本接口查询行为一致,保留参数便于前端统一调用)</param> | |
| 4140 | + /// <returns>主表及明细等完整详情</returns> | |
| 4141 | + /// <response code="200">成功</response> | |
| 4142 | + /// <response code="404">单据不存在(COM1005)</response> | |
| 4143 | + /// <response code="500">服务异常</response> | |
| 3852 | 4144 | [HttpGet("{id}")] |
| 3853 | - public async Task<dynamic> GetInfo(string id) | |
| 4145 | + public async Task<dynamic> GetInfo(string id, [FromQuery] bool includeDeleted = false) | |
| 3854 | 4146 | { |
| 3855 | 4147 | EnsureBjsxColumn(); |
| 3856 | 4148 | EnsureBjhcbColumn(); |
| ... | ... | @@ -4624,6 +4916,7 @@ WHERE d.djlx IN ('销售退货单','预售退货单','委托代销退货单') |
| 4624 | 4916 | .WhereIF(ctx.QueryDjrq != null, |
| 4625 | 4917 | (xsckd, hy) => xsckd.Djrq <= new DateTime(ctx.EndDjrq.ToDate().Year, ctx.EndDjrq.ToDate().Month, ctx.EndDjrq.ToDate().Day, 23, |
| 4626 | 4918 | 59, 59)) |
| 4919 | + .Where((xsckd, hy) => xsckd.DeleteMark == null || xsckd.DeleteMark == 0) | |
| 4627 | 4920 | .WhereIF(!string.IsNullOrEmpty(input.cjck), (xsckd, hy) => xsckd.Cjck.Equals(input.cjck)) |
| 4628 | 4921 | .WhereIF(!string.IsNullOrEmpty(input.xsmd), (xsckd, hy) => xsckd.Xsmd.Equals(input.xsmd)) |
| 4629 | 4922 | .WhereIF(!string.IsNullOrEmpty(input.rkck), (xsckd, hy) => xsckd.Rkck.Equals(input.rkck)) |
| ... | ... | @@ -7068,80 +7361,17 @@ WHERE d.djlx IN ('销售退货单','预售退货单','委托代销退货单') |
| 7068 | 7361 | } |
| 7069 | 7362 | foreach (var entity in entitys) |
| 7070 | 7363 | { |
| 7071 | - if (string.Equals(entity.Djlx, "采购入库单", StringComparison.Ordinal)) | |
| 7072 | - { | |
| 7073 | - var z = entity.Djzt?.Trim() ?? ""; | |
| 7074 | - if (!WtBillCommonHelpers.IsDeletableDraftState(z, entity.Spbz)) | |
| 7075 | - throw NCCException.Bah($"采购入库单 {entity.Id} 在「{entity.Djzt}」状态下不可删除,仅草稿状态可删除"); | |
| 7076 | - } | |
| 7077 | - if (string.Equals(entity.Djlx, "采购退货单", StringComparison.Ordinal)) | |
| 7078 | - { | |
| 7079 | - var z = entity.Djzt?.Trim() ?? ""; | |
| 7080 | - if (!WtBillCommonHelpers.IsDeletableDraftState(z, entity.Spbz)) | |
| 7081 | - throw NCCException.Bah($"采购退货单 {entity.Id} 在「{entity.Djzt}」状态下不可删除,仅草稿状态可删除"); | |
| 7082 | - } | |
| 7083 | - EnsureDraftOnlyDeleteForXsckdInventoryAdjustFamily(entity, includeBillIdInMessage: true); | |
| 7084 | - if (string.Equals(entity.Djlx, "销售出库单", StringComparison.Ordinal)) | |
| 7085 | - { | |
| 7086 | - var z = entity.Djzt?.Trim() ?? ""; | |
| 7087 | - if (!WtBillCommonHelpers.IsDeletableDraftState(z, entity.Spbz)) | |
| 7088 | - throw NCCException.Bah($"销售出库单 {entity.Id} 在「{entity.Djzt}」状态下不可删除,仅草稿状态可删除"); | |
| 7089 | - } | |
| 7090 | - EnsureDraftStateForDraftOnlySalesFlowDelete(entity, includeBillIdInMessage: true); | |
| 7091 | - var thCsv = await GetLinkedReturnBillIdsCsvAsync(entity.Id, entity.Djlx); | |
| 7092 | - if (!string.IsNullOrEmpty(thCsv)) | |
| 7093 | - throw NCCException.Bah($"单据 {entity.Id} 已存在关联退货单({thCsv}),无法删除"); | |
| 7364 | + if (WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) continue; | |
| 7365 | + await ValidateXsckdDeletePreconditionsAsync(entity, includeBillIdInMessage: true); | |
| 7094 | 7366 | } |
| 7095 | 7367 | if (entitys.Count > 0) |
| 7096 | 7368 | { |
| 7097 | - try | |
| 7369 | + await WtBillSoftDeleteHelper.EnsureBillSoftDeleteColumnsAsync(_db, "wt_xsckd", "wt_xsckd_mx"); | |
| 7370 | + var uid = _userManager.UserId; | |
| 7371 | + foreach (var entity in entitys) | |
| 7098 | 7372 | { |
| 7099 | - foreach (var entity in entitys) | |
| 7100 | - await EnsureXsckdWarehousesNotLockedForHeaderAsync(entity); | |
| 7101 | - | |
| 7102 | - _db.BeginTran(); | |
| 7103 | - | |
| 7104 | - // 逐单回退成本/积分/余额/提成/序列号 | |
| 7105 | - foreach (var entity in entitys) | |
| 7106 | - { | |
| 7107 | - var skipSideEffectRollback = WtBillCommonHelpers.ShouldSkipSideEffectRollbackOnDelete(entity.Djzt, entity.Spbz); | |
| 7108 | - | |
| 7109 | - if (!skipSideEffectRollback) | |
| 7110 | - { | |
| 7111 | - if (entity.Djlx == "销售退货单" || entity.Djlx == "预售退货单") | |
| 7112 | - await TryReverseReturnMemberRefundAsync(entity, "删除单据"); | |
| 7113 | - | |
| 7114 | - await TryReverseSalesOutboundMemberAndCommissionAsync(entity, "删除单据"); | |
| 7115 | - | |
| 7116 | - if (IsStockOutboundDocumentForSerialRevert(entity.Djlx)) | |
| 7117 | - await RevertSerialNumbersForDeletedOutboundAsync(entity.Id); | |
| 7118 | - | |
| 7119 | - await RevertSerialNumbersForDeletedReturnAsync(entity); | |
| 7120 | - var skipRollbackCostDel = (entity.Djlx != null && (entity.Djlx.Contains("报损单") || entity.Djlx.Contains("报溢单"))) | |
| 7121 | - && !string.Equals(entity.Djzt?.Trim(), "已审核", StringComparison.Ordinal); | |
| 7122 | - if (!skipRollbackCostDel) | |
| 7123 | - await RollbackSpCostOnDelete(entity); | |
| 7124 | - } | |
| 7125 | - | |
| 7126 | - await DeleteWtXlhTrackingForDocumentAsync(entity.Id); | |
| 7127 | - } | |
| 7128 | - | |
| 7129 | - await _wtDjzyService.DeleteByXsckdAsync(ids); | |
| 7130 | - | |
| 7131 | - await _db.Deleteable<WtXsckdEntity>().In(d => d.Id, ids).ExecuteCommandAsync(); | |
| 7132 | - await _db.Deleteable<WtXsckdMxEntity>().In(u => u.Djbh, ids).ExecuteCommandAsync(); | |
| 7133 | - | |
| 7134 | - _db.CommitTran(); | |
| 7135 | - } | |
| 7136 | - catch (AppFriendlyException) | |
| 7137 | - { | |
| 7138 | - _db.RollbackTran(); | |
| 7139 | - throw; | |
| 7140 | - } | |
| 7141 | - catch (Exception) | |
| 7142 | - { | |
| 7143 | - _db.RollbackTran(); | |
| 7144 | - throw NCCException.Oh(ErrorCode.COM1002); | |
| 7373 | + if (WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) continue; | |
| 7374 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAndMxAsync(_db, "wt_xsckd", "wt_xsckd_mx", entity.Id, uid); | |
| 7145 | 7375 | } |
| 7146 | 7376 | } |
| 7147 | 7377 | } |
| ... | ... | @@ -7689,25 +7919,17 @@ WHERE d.djlx IN ('销售退货单','预售退货单','委托代销退货单') |
| 7689 | 7919 | } |
| 7690 | 7920 | |
| 7691 | 7921 | /// <summary> |
| 7692 | - /// 删除销售出库单(含成本回退) | |
| 7693 | - /// 采购入库单(已审核):检查序列号→删除→回退成本 | |
| 7694 | - /// 销售/预售出库单:恢复 wt_sp_cost.sl | |
| 7695 | - /// 销售退货单:减少 wt_sp_cost.sl | |
| 7922 | + /// 删除/标记删除前校验(权限、状态、关联退货等)。 | |
| 7696 | 7923 | /// </summary> |
| 7697 | - /// <returns></returns> | |
| 7698 | - [HttpDelete("{id}")] | |
| 7699 | - public async Task Delete(string id) | |
| 7924 | + private async Task ValidateXsckdDeletePreconditionsAsync(WtXsckdEntity entity, bool includeBillIdInMessage) | |
| 7700 | 7925 | { |
| 7701 | - var entity = await _db.Queryable<WtXsckdEntity>().FirstAsync(p => p.Id == id); | |
| 7702 | - _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005); | |
| 7703 | - // 同价调拨单删除按钮权限校验(全局按钮权限检查已停用,需业务层补校验,避免未勾选删除权限的角色仍可删除) | |
| 7926 | + if (entity == null) throw NCCException.Oh(ErrorCode.COM1005); | |
| 7704 | 7927 | if (string.Equals(entity.Djlx, "同价调拨单", StringComparison.Ordinal)) |
| 7705 | 7928 | { |
| 7706 | 7929 | await WtTjdbdButtonAuthorizeHelper.EnsureAsync( |
| 7707 | 7930 | _db, _userManager, WtTjdbdButtonAuthorizeHelper.TjdbdModuleId, WtTjdbdButtonAuthorizeHelper.BtnRemove, |
| 7708 | 7931 | "无删除权限,请联系管理员在「角色管理-授权」中为当前角色勾选同价调拨单的删除按钮权限"); |
| 7709 | 7932 | } |
| 7710 | - // 变价调拨单删除按钮权限校验(全局按钮权限检查已停用,需业务层补校验,避免未勾选删除权限的角色仍可删除) | |
| 7711 | 7933 | if (string.Equals(entity.Djlx, "变价调拨单", StringComparison.Ordinal)) |
| 7712 | 7934 | { |
| 7713 | 7935 | await WtTjdbdButtonAuthorizeHelper.EnsureAsync( |
| ... | ... | @@ -7726,20 +7948,69 @@ WHERE d.djlx IN ('销售退货单','预售退货单','委托代销退货单') |
| 7726 | 7948 | if (!WtBillCommonHelpers.IsDeletableDraftState(z, entity.Spbz)) |
| 7727 | 7949 | throw NCCException.Bah($"采购退货单在「{entity.Djzt}」状态下不可删除,仅草稿状态可删除"); |
| 7728 | 7950 | } |
| 7729 | - EnsureDraftOnlyDeleteForXsckdInventoryAdjustFamily(entity, includeBillIdInMessage: false); | |
| 7730 | - // 销售出库单页面要求:仅草稿可删;待审核/已审核等均不可删 | |
| 7951 | + EnsureDraftOnlyDeleteForXsckdInventoryAdjustFamily(entity, includeBillIdInMessage); | |
| 7731 | 7952 | if (string.Equals(entity.Djlx, "销售出库单", StringComparison.Ordinal)) |
| 7732 | 7953 | { |
| 7733 | 7954 | var z = entity.Djzt?.Trim() ?? ""; |
| 7734 | 7955 | if (!WtBillCommonHelpers.IsDeletableDraftState(z, entity.Spbz)) |
| 7735 | 7956 | throw NCCException.Bah($"销售出库单在「{entity.Djzt}」状态下不可删除,仅草稿状态可删除"); |
| 7736 | 7957 | } |
| 7737 | - EnsureDraftStateForDraftOnlySalesFlowDelete(entity, includeBillIdInMessage: false); | |
| 7958 | + EnsureDraftStateForDraftOnlySalesFlowDelete(entity, includeBillIdInMessage); | |
| 7738 | 7959 | await EnsureXsckdWarehousesNotLockedForHeaderAsync(entity); |
| 7739 | 7960 | await EnsurePresaleNotConvertedForMutationAsync(entity, "删除"); |
| 7740 | 7961 | var thCsv = await GetLinkedReturnBillIdsCsvAsync(entity.Id, entity.Djlx); |
| 7741 | 7962 | if (!string.IsNullOrEmpty(thCsv)) |
| 7742 | - throw NCCException.Bah($"该单据已存在关联退货单({thCsv}),无法删除"); | |
| 7963 | + throw NCCException.Bah(includeBillIdInMessage | |
| 7964 | + ? $"单据 {entity.Id} 已存在关联退货单({thCsv}),无法删除" | |
| 7965 | + : $"该单据已存在关联退货单({thCsv}),无法删除"); | |
| 7966 | + } | |
| 7967 | + | |
| 7968 | + /// <summary> | |
| 7969 | + /// 标记删除销售出库单(移入回收站,不物理删、不回滚库存)。 | |
| 7970 | + /// </summary> | |
| 7971 | + [HttpDelete("{id}")] | |
| 7972 | + public async Task Delete(string id) | |
| 7973 | + { | |
| 7974 | + var entity = await _db.Queryable<WtXsckdEntity>().FirstAsync(p => p.Id == id); | |
| 7975 | + _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005); | |
| 7976 | + if (WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 7977 | + throw NCCException.Bah("单据已在回收站"); | |
| 7978 | + await ValidateXsckdDeletePreconditionsAsync(entity, includeBillIdInMessage: false); | |
| 7979 | + await WtBillSoftDeleteHelper.EnsureBillSoftDeleteColumnsAsync(_db, "wt_xsckd", "wt_xsckd_mx"); | |
| 7980 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAndMxAsync(_db, "wt_xsckd", "wt_xsckd_mx", id, _userManager.UserId); | |
| 7981 | + try | |
| 7982 | + { | |
| 7983 | + await _businessOperationLogService.WriteAsync( | |
| 7984 | + "进销存单据", "标记删除", "wt_xsckd", id, | |
| 7985 | + $"标记删除单据 {id}({entity.Djlx})", null); | |
| 7986 | + } | |
| 7987 | + catch { } | |
| 7988 | + } | |
| 7989 | + | |
| 7990 | + /// <summary> | |
| 7991 | + /// 回收站恢复销售出库单 | |
| 7992 | + /// </summary> | |
| 7993 | + [NonAction] | |
| 7994 | + public async Task RestoreFromRecycleBinAsync(string id) | |
| 7995 | + { | |
| 7996 | + var entity = await _db.Queryable<WtXsckdEntity>().FirstAsync(p => p.Id == id); | |
| 7997 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 7998 | + throw NCCException.Bah("单据不存在或未在回收站"); | |
| 7999 | + await WtBillSoftDeleteHelper.EnsureBillSoftDeleteColumnsAsync(_db, "wt_xsckd", "wt_xsckd_mx"); | |
| 8000 | + await WtBillSoftDeleteHelper.RestoreHeadAndMxAsync(_db, "wt_xsckd", "wt_xsckd_mx", id); | |
| 8001 | + } | |
| 8002 | + | |
| 8003 | + /// <summary> | |
| 8004 | + /// 回收站彻底删除(物理删,含成本/序列号等副作用回退)。 | |
| 8005 | + /// </summary> | |
| 8006 | + [NonAction] | |
| 8007 | + public async Task PurgePhysicalAsync(string id) | |
| 8008 | + { | |
| 8009 | + var entity = await _db.Queryable<WtXsckdEntity>().FirstAsync(p => p.Id == id); | |
| 8010 | + _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005); | |
| 8011 | + if (!WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 8012 | + throw NCCException.Bah("仅回收站内的单据可彻底删除"); | |
| 8013 | + await ValidateXsckdDeletePreconditionsAsync(entity, includeBillIdInMessage: false); | |
| 7743 | 8014 | try |
| 7744 | 8015 | { |
| 7745 | 8016 | _db.BeginTran(); |
| ... | ... | @@ -12270,6 +12541,26 @@ LIMIT {offset}, {pageSize}"; |
| 12270 | 12541 | } |
| 12271 | 12542 | try |
| 12272 | 12543 | { |
| 12544 | + if (input.Quantity <= 0) | |
| 12545 | + { | |
| 12546 | + return new GenerateSerialNumberOutput | |
| 12547 | + { | |
| 12548 | + Success = false, | |
| 12549 | + SerialNumbers = new List<string>(), | |
| 12550 | + Message = "数量须大于 0 才能生成序列号" | |
| 12551 | + }; | |
| 12552 | + } | |
| 12553 | + | |
| 12554 | + if (input.Quantity > MaxInboundSerialGeneratePerMxLine) | |
| 12555 | + { | |
| 12556 | + return new GenerateSerialNumberOutput | |
| 12557 | + { | |
| 12558 | + Success = false, | |
| 12559 | + SerialNumbers = new List<string>(), | |
| 12560 | + Message = $"单次生成数量不能超过 {MaxInboundSerialGeneratePerMxLine},请核对明细数量" | |
| 12561 | + }; | |
| 12562 | + } | |
| 12563 | + | |
| 12273 | 12564 | // 检查是否已经为该单据生成过序列号 |
| 12274 | 12565 | var existingSerialNumbers = await _db.Queryable<WtSerialNumberEntity>() |
| 12275 | 12566 | .Where(s => s.InDjbh == input.DocumentId && s.Spbh == input.ProductCode) |
| ... | ... | @@ -12346,6 +12637,12 @@ LIMIT {offset}, {pageSize}"; |
| 12346 | 12637 | /// <returns>生成的序列号列表</returns> |
| 12347 | 12638 | private async Task<List<string>> GenerateBatchSerialNumbers(int quantity) |
| 12348 | 12639 | { |
| 12640 | + if (quantity <= 0) | |
| 12641 | + return new List<string>(); | |
| 12642 | + if (quantity > MaxInboundSerialGeneratePerMxLine) | |
| 12643 | + throw NCCException.Bah( | |
| 12644 | + $"单次生成序列号数量 {quantity} 超出上限 {MaxInboundSerialGeneratePerMxLine},请核对明细数量是否正确"); | |
| 12645 | + | |
| 12349 | 12646 | var serialNumbers = new List<string>(quantity); |
| 12350 | 12647 | |
| 12351 | 12648 | await _serialNumberSemaphore.WaitAsync(); |
| ... | ... | @@ -13445,6 +13742,10 @@ LIMIT {offset}, {pageSize}"; |
| 13445 | 13742 | { |
| 13446 | 13743 | if (item.Quantity <= 0 || string.IsNullOrEmpty(item.ProductCode)) |
| 13447 | 13744 | continue; |
| 13745 | + | |
| 13746 | + if (item.Quantity > MaxInboundSerialGeneratePerMxLine) | |
| 13747 | + throw NCCException.Bah( | |
| 13748 | + $"商品 {item.ProductCode} 入库数量 {item.Quantity} 超出单次序列号生成上限 {MaxInboundSerialGeneratePerMxLine},请核对数量"); | |
| 13448 | 13749 | |
| 13449 | 13750 | if (existingBySpbh.TryGetValue(item.ProductCode, out var existingSerials) && existingSerials.Count > 0) |
| 13450 | 13751 | { |
| ... | ... | @@ -14207,6 +14508,9 @@ LIMIT {offset}, {pageSize}"; |
| 14207 | 14508 | if (IsSaleBelowCostWarningDjlx(entity.Djlx)) |
| 14208 | 14509 | await RefreshSaleBelowCostFlagAsync(id, entity.Djlx); |
| 14209 | 14510 | |
| 14511 | + // 销售出库/退货终审后回写盘点(快照外退货自动进表;出库已盘行同步数量) | |
| 14512 | + await TryWritebackPdAfterSalesFinalApprovalAsync(entity, id); | |
| 14513 | + | |
| 14210 | 14514 | _db.CommitTran(); |
| 14211 | 14515 | await TryEnsureSalesOutboundMemberBenefitsAsync(entity); |
| 14212 | 14516 | await TryApplyReturnMemberRefundAsync(entity); |
| ... | ... | @@ -14296,6 +14600,9 @@ LIMIT {offset}, {pageSize}"; |
| 14296 | 14600 | if (IsSaleBelowCostWarningDjlx(entity.Djlx)) |
| 14297 | 14601 | await RefreshSaleBelowCostFlagAsync(id, entity.Djlx); |
| 14298 | 14602 | |
| 14603 | + // 销售出库/退货终审后回写盘点(快照外退货自动进表;出库已盘行同步数量) | |
| 14604 | + await TryWritebackPdAfterSalesFinalApprovalAsync(entity, id); | |
| 14605 | + | |
| 14299 | 14606 | _db.CommitTran(); |
| 14300 | 14607 | await TryEnsureSalesOutboundMemberBenefitsAsync(entity); |
| 14301 | 14608 | await TryApplyReturnMemberRefundAsync(entity); |
| ... | ... | @@ -14340,49 +14647,64 @@ LIMIT {offset}, {pageSize}"; |
| 14340 | 14647 | var detailList = await _db.Queryable<WtXsckdMxEntity>() |
| 14341 | 14648 | .Where(d => d.Djbh == id).ToListAsync(); |
| 14342 | 14649 | |
| 14650 | + var spbhKeys = detailList | |
| 14651 | + .Where(d => !string.IsNullOrWhiteSpace(d.Spbh)) | |
| 14652 | + .Select(d => d.Spbh.Trim()) | |
| 14653 | + .Distinct(StringComparer.Ordinal) | |
| 14654 | + .ToList(); | |
| 14655 | + var spDict = await BuildWtSpDictByMxSpbhAsync(spbhKeys); | |
| 14656 | + | |
| 14343 | 14657 | var items = new List<BatchGenerateSerialNumberItem>(); |
| 14344 | 14658 | foreach (var detail in detailList) |
| 14345 | 14659 | { |
| 14346 | - if (!string.IsNullOrEmpty(detail.Spbh) && int.TryParse(detail.Sl, out int quantity) && quantity > 0) | |
| 14660 | + if (string.IsNullOrEmpty(detail.Spbh)) continue; | |
| 14661 | + if (!TryParseMxSlForSerialQty(detail.Sl, out int quantity, throwIfExceedsMax: true)) continue; | |
| 14662 | + | |
| 14663 | + var sp = ResolveSpForMxSpbh(detail.Spbh, spDict); | |
| 14664 | + if (!IsInboundSerialProduct(sp)) | |
| 14347 | 14665 | { |
| 14348 | - var warehouseId = !string.IsNullOrEmpty(detail.Rkck) ? detail.Rkck : entity.Rkck; | |
| 14349 | - if (string.IsNullOrEmpty(warehouseId)) continue; | |
| 14666 | + Console.WriteLine( | |
| 14667 | + $"GenerateSerialNumbersForApproval 跳过商品 {detail.Spbh}(虚拟品/入0出0/未配置序列号类型,不生成入库序列号)"); | |
| 14668 | + continue; | |
| 14669 | + } | |
| 14350 | 14670 | |
| 14351 | - var item = new BatchGenerateSerialNumberItem | |
| 14352 | - { | |
| 14353 | - ProductCode = detail.Spbh, | |
| 14354 | - ProductName = detail.Spmc, | |
| 14355 | - Quantity = quantity, | |
| 14356 | - RowIndex = 0 | |
| 14357 | - }; | |
| 14358 | - if (!string.IsNullOrWhiteSpace(detail.RkXlhPreset)) | |
| 14671 | + var warehouseId = !string.IsNullOrEmpty(detail.Rkck) ? detail.Rkck : entity.Rkck; | |
| 14672 | + if (string.IsNullOrEmpty(warehouseId)) continue; | |
| 14673 | + | |
| 14674 | + var item = new BatchGenerateSerialNumberItem | |
| 14675 | + { | |
| 14676 | + ProductCode = detail.Spbh, | |
| 14677 | + ProductName = detail.Spmc, | |
| 14678 | + Quantity = quantity, | |
| 14679 | + RowIndex = 0 | |
| 14680 | + }; | |
| 14681 | + if (!string.IsNullOrWhiteSpace(detail.RkXlhPreset)) | |
| 14682 | + { | |
| 14683 | + try | |
| 14359 | 14684 | { |
| 14360 | - try | |
| 14361 | - { | |
| 14362 | - var preset = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(detail.RkXlhPreset); | |
| 14363 | - var cleaned = preset?.Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => s.Trim()).ToList() | |
| 14364 | - ?? new List<string>(); | |
| 14365 | - if (cleaned.Count > 0) | |
| 14366 | - { | |
| 14367 | - if (cleaned.Count != quantity) | |
| 14368 | - throw NCCException.Bah($"明细「{detail.Spmc ?? detail.Spbh}」预填序列号条数须等于数量 {quantity}"); | |
| 14369 | - if (cleaned.Count != cleaned.Distinct(StringComparer.OrdinalIgnoreCase).Count()) | |
| 14370 | - throw NCCException.Bah($"明细「{detail.Spmc ?? detail.Spbh}」预填序列号存在重复"); | |
| 14371 | - item.PresetSerialNumbers = cleaned; | |
| 14372 | - } | |
| 14373 | - } | |
| 14374 | - catch (AppFriendlyException) | |
| 14375 | - { | |
| 14376 | - throw; | |
| 14377 | - } | |
| 14378 | - catch | |
| 14685 | + var preset = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(detail.RkXlhPreset); | |
| 14686 | + var cleaned = preset?.Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => s.Trim()).ToList() | |
| 14687 | + ?? new List<string>(); | |
| 14688 | + if (cleaned.Count > 0) | |
| 14379 | 14689 | { |
| 14380 | - throw NCCException.Bah($"明细「{detail.Spmc ?? detail.Spbh}」预填序列号格式错误"); | |
| 14690 | + if (cleaned.Count != quantity) | |
| 14691 | + throw NCCException.Bah($"明细「{detail.Spmc ?? detail.Spbh}」预填序列号条数须等于数量 {quantity}"); | |
| 14692 | + if (cleaned.Count != cleaned.Distinct(StringComparer.OrdinalIgnoreCase).Count()) | |
| 14693 | + throw NCCException.Bah($"明细「{detail.Spmc ?? detail.Spbh}」预填序列号存在重复"); | |
| 14694 | + item.PresetSerialNumbers = cleaned; | |
| 14381 | 14695 | } |
| 14382 | 14696 | } |
| 14383 | - | |
| 14384 | - items.Add(item); | |
| 14697 | + catch (AppFriendlyException) | |
| 14698 | + { | |
| 14699 | + throw; | |
| 14700 | + } | |
| 14701 | + catch | |
| 14702 | + { | |
| 14703 | + throw NCCException.Bah($"明细「{detail.Spmc ?? detail.Spbh}」预填序列号格式错误"); | |
| 14704 | + } | |
| 14385 | 14705 | } |
| 14706 | + | |
| 14707 | + items.Add(item); | |
| 14386 | 14708 | } |
| 14387 | 14709 | |
| 14388 | 14710 | if (items.Any()) |
| ... | ... | @@ -14411,11 +14733,18 @@ LIMIT {offset}, {pageSize}"; |
| 14411 | 14733 | { |
| 14412 | 14734 | var detailList = await _db.Queryable<WtXsckdMxEntity>() |
| 14413 | 14735 | .Where(d => d.Djbh == id).ToListAsync(); |
| 14736 | + var spbhKeys = detailList | |
| 14737 | + .Where(d => !string.IsNullOrWhiteSpace(d.Spbh)) | |
| 14738 | + .Select(d => d.Spbh.Trim()) | |
| 14739 | + .Distinct(StringComparer.Ordinal) | |
| 14740 | + .ToList(); | |
| 14741 | + var spDict = await BuildWtSpDictByMxSpbhAsync(spbhKeys); | |
| 14414 | 14742 | var groups = new Dictionary<string, List<BatchGenerateSerialNumberItem>>(StringComparer.Ordinal); |
| 14415 | 14743 | foreach (var detail in detailList) |
| 14416 | 14744 | { |
| 14417 | - if (string.IsNullOrEmpty(detail.Spbh) || !int.TryParse(detail.Sl, out int quantity) || quantity <= 0) | |
| 14418 | - continue; | |
| 14745 | + if (string.IsNullOrEmpty(detail.Spbh)) continue; | |
| 14746 | + if (!TryParseMxSlForSerialQty(detail.Sl, out int quantity, throwIfExceedsMax: true)) continue; | |
| 14747 | + if (!IsInboundSerialProduct(ResolveSpForMxSpbh(detail.Spbh, spDict))) continue; | |
| 14419 | 14748 | var warehouseId = !string.IsNullOrEmpty(detail.Rkck) ? detail.Rkck |
| 14420 | 14749 | : (!string.IsNullOrEmpty(detail.Ckck) ? detail.Ckck |
| 14421 | 14750 | : (!string.IsNullOrEmpty(entity.Rkck) ? entity.Rkck : entity.Cjck)); |
| ... | ... | @@ -14747,10 +15076,12 @@ LIMIT {offset}, {pageSize}"; |
| 14747 | 15076 | if (mxList == null || mxList.Count == 0) return; |
| 14748 | 15077 | |
| 14749 | 15078 | var insufficient = new List<string>(); |
| 15079 | + var virtualSpbhSet = await GetVirtualMxSpbhSetAsync(mxList.Select(m => m?.spbh)); | |
| 14750 | 15080 | foreach (var mx in mxList) |
| 14751 | 15081 | { |
| 14752 | 15082 | if (string.IsNullOrWhiteSpace(mx?.spbh)) continue; |
| 14753 | 15083 | if (!int.TryParse(mx.sl, out int qty) || qty <= 0) continue; |
| 15084 | + if (virtualSpbhSet.Contains(mx.spbh.Trim())) continue; | |
| 14754 | 15085 | |
| 14755 | 15086 | var spName = string.IsNullOrWhiteSpace(mx.spmc) ? mx.spbh.Trim() : mx.spmc.Trim(); |
| 14756 | 15087 | var detailStoreOrWarehouseId = !string.IsNullOrEmpty(mx.ckck) ? mx.ckck : headerCjck; |
| ... | ... | @@ -14813,10 +15144,12 @@ LIMIT {offset}, {pageSize}"; |
| 14813 | 15144 | |
| 14814 | 15145 | var insufficient = new List<string>(); |
| 14815 | 15146 | var outStoreId = entity.Cjck; |
| 15147 | + var virtualSpbhSet = await GetVirtualMxSpbhSetAsync(mxList.Select(m => m.Spbh)); | |
| 14816 | 15148 | foreach (var detail in mxList) |
| 14817 | 15149 | { |
| 14818 | 15150 | if (string.IsNullOrEmpty(detail.Spbh)) continue; |
| 14819 | 15151 | if (!int.TryParse(detail.Sl, out int qty) || qty <= 0) continue; |
| 15152 | + if (virtualSpbhSet.Contains(detail.Spbh.Trim())) continue; | |
| 14820 | 15153 | |
| 14821 | 15154 | var spName = string.IsNullOrWhiteSpace(detail.Spmc) ? detail.Spbh.Trim() : detail.Spmc.Trim(); |
| 14822 | 15155 | var detailStoreOrWarehouseId = !string.IsNullOrEmpty(detail.Ckck) ? detail.Ckck : outStoreId; |
| ... | ... | @@ -15468,12 +15801,19 @@ LIMIT {offset}, {pageSize}"; |
| 15468 | 15801 | } |
| 15469 | 15802 | await DeleteWtXlhTrackingForDocumentAsync(row.Id); |
| 15470 | 15803 | } |
| 15471 | - // 退货单:冲回 wt_sp_cost / 序列号还原 / wt_xlh / 会员退回 | |
| 15804 | + // 退货单:冲回 wt_sp_cost / 序列号还原 / wt_xlh / 会员退回 / 盘点回写 | |
| 15472 | 15805 | else if (rowDjlx == "销售退货单" || rowDjlx == "预售退货单" || rowDjlx.Contains("委托代销退货单")) |
| 15473 | 15806 | { |
| 15474 | 15807 | await RevertSerialNumbersForDeletedReturnAsync(row); |
| 15475 | 15808 | await DeleteWtXlhTrackingForDocumentAsync(row.Id); |
| 15476 | 15809 | await RollbackSpCostOnDelete(row); |
| 15810 | + if (rowDjlx == "销售退货单") | |
| 15811 | + { | |
| 15812 | + // 待审阶段已过账并可能已追加盘点表外行,驳回须对称冲回 | |
| 15813 | + var pdRevMx = await _db.Queryable<WtXsckdMxEntity>() | |
| 15814 | + .Where(d => d.Djbh == row.Id).ToListAsync(); | |
| 15815 | + await ApplyPdSalesWritebackAsync(rowDjlx, row, pdRevMx, reverse: true); | |
| 15816 | + } | |
| 15477 | 15817 | if (rowDjlx == "销售退货单" || rowDjlx == "预售退货单") |
| 15478 | 15818 | await TryReverseReturnMemberRefundAsync(row, "审核不通过"); |
| 15479 | 15819 | } |
| ... | ... | @@ -16178,11 +16518,13 @@ LIMIT {offset}, {pageSize}"; |
| 16178 | 16518 | // 串码商品按在库序列号数校验;非串码商品按 wt_sp_cost 账面数量校验 |
| 16179 | 16519 | var insufficientStock = new List<string>(); |
| 16180 | 16520 | var outStoreId = presaleOrder.Cjck; |
| 16521 | + var virtualSpbhSet = await GetVirtualMxSpbhSetAsync(presaleDetails.Select(d => d.Spbh)); | |
| 16181 | 16522 | |
| 16182 | 16523 | foreach (var detail in presaleDetails) |
| 16183 | 16524 | { |
| 16184 | 16525 | if (string.IsNullOrEmpty(detail.Spbh) || !int.TryParse(detail.Sl, out int requiredQty) || requiredQty <= 0) |
| 16185 | 16526 | continue; |
| 16527 | + if (virtualSpbhSet.Contains(detail.Spbh.Trim())) continue; | |
| 16186 | 16528 | |
| 16187 | 16529 | var detailOutStoreId = !string.IsNullOrEmpty(detail.Ckck) ? detail.Ckck : outStoreId; |
| 16188 | 16530 | |
| ... | ... | @@ -17076,10 +17418,12 @@ LIMIT {offset}, {pageSize}"; |
| 17076 | 17418 | |
| 17077 | 17419 | /// <summary> |
| 17078 | 17420 | /// 非序列号商品:在门店下各仓库成本行上依次扣减 sl,直至扣满出库数量。 |
| 17421 | + /// 虚拟商品(<c>F_Splx1=虚拟</c>)无库存概念,直接跳过。 | |
| 17079 | 17422 | /// </summary> |
| 17080 | 17423 | private async Task DeductWtSpCostNonSerialOutboundAsync(string spbh, List<string> warehouseIds, int qty) |
| 17081 | 17424 | { |
| 17082 | 17425 | if (string.IsNullOrWhiteSpace(spbh) || qty <= 0 || warehouseIds == null || warehouseIds.Count == 0) return; |
| 17426 | + if (await IsVirtualMxSpbhAsync(spbh)) return; | |
| 17083 | 17427 | var remaining = qty; |
| 17084 | 17428 | foreach (var whId in warehouseIds) |
| 17085 | 17429 | { |
| ... | ... | @@ -17102,10 +17446,12 @@ LIMIT {offset}, {pageSize}"; |
| 17102 | 17446 | |
| 17103 | 17447 | /// <summary> |
| 17104 | 17448 | /// 删除销售类出库单时,非序列号商品将数量加回 wt_sp_cost(与扣减镜像)。 |
| 17449 | + /// 虚拟商品(<c>F_Splx1=虚拟</c>)无库存概念,直接跳过。 | |
| 17105 | 17450 | /// </summary> |
| 17106 | 17451 | private async Task RestoreWtSpCostNonSerialOutboundAsync(string spbh, List<string> warehouseIds, int qty) |
| 17107 | 17452 | { |
| 17108 | 17453 | if (string.IsNullOrWhiteSpace(spbh) || qty <= 0 || warehouseIds == null || warehouseIds.Count == 0) return; |
| 17454 | + if (await IsVirtualMxSpbhAsync(spbh)) return; | |
| 17109 | 17455 | string target = null; |
| 17110 | 17456 | foreach (var whId in warehouseIds) |
| 17111 | 17457 | { |
| ... | ... | @@ -17147,10 +17493,12 @@ LIMIT {offset}, {pageSize}"; |
| 17147 | 17493 | /// 委托代销结算单:实物库存已在委托代销发货单出库时扣减,此处不再重复扣减 wt_sp_cost,避免双减 |
| 17148 | 17494 | /// 变价调拨单 → 调出仓按原成本加权减少,调入仓按变价后单价加权增加(草稿/ isDraft 不过账) |
| 17149 | 17495 | /// 同价调拨单 → 调出/调入同一成本单价移仓(草稿/ isDraft 不过账) |
| 17496 | + /// 虚拟商品(<c>wt_sp.F_Splx1=虚拟</c>)无库存概念,不读写 <c>wt_sp_cost.sl</c>(成本快照仍可回写)。 | |
| 17150 | 17497 | /// </summary> |
| 17151 | 17498 | private async Task UpdateSpCostOnCreate(string djlx, WtXsckdEntity entity, List<WtXsckdMxEntity> mxList, bool isDraft = false) |
| 17152 | 17499 | { |
| 17153 | 17500 | if (mxList == null || mxList.Count == 0) return; |
| 17501 | + var virtualSpbhSet = await GetVirtualMxSpbhSetAsync(mxList.Select(m => m.Spbh)); | |
| 17154 | 17502 | var affectedSpbh = mxList |
| 17155 | 17503 | .Where(m => !string.IsNullOrWhiteSpace(m.Spbh)) |
| 17156 | 17504 | .Select(m => m.Spbh.Trim()) |
| ... | ... | @@ -17297,6 +17645,7 @@ LIMIT {offset}, {pageSize}"; |
| 17297 | 17645 | { |
| 17298 | 17646 | if (string.IsNullOrEmpty(detail.Spbh)) continue; |
| 17299 | 17647 | if (!int.TryParse(detail.Sl, out int qty) || qty <= 0) continue; |
| 17648 | + if (virtualSpbhSet.Contains(detail.Spbh.Trim())) continue; | |
| 17300 | 17649 | |
| 17301 | 17650 | decimal returnPrice = detail.Thdj.HasValue && detail.Thdj.Value > 0 ? detail.Thdj.Value : detail.Dj; |
| 17302 | 17651 | |
| ... | ... | @@ -17346,6 +17695,7 @@ LIMIT {offset}, {pageSize}"; |
| 17346 | 17695 | { |
| 17347 | 17696 | if (string.IsNullOrEmpty(detail.Spbh)) continue; |
| 17348 | 17697 | if (!int.TryParse(detail.Sl, out int qty) || qty <= 0) continue; |
| 17698 | + if (virtualSpbhSet.Contains(detail.Spbh.Trim())) continue; | |
| 17349 | 17699 | |
| 17350 | 17700 | var detailWarehouse = !string.IsNullOrEmpty(detail.Rkck) ? detail.Rkck : entity.Rkck; |
| 17351 | 17701 | if (string.IsNullOrWhiteSpace(detailWarehouse)) continue; |
| ... | ... | @@ -17537,6 +17887,7 @@ LIMIT {offset}, {pageSize}"; |
| 17537 | 17887 | /// 采购入库单(已审核):检查序列号→删除→回退成本 |
| 17538 | 17888 | /// 销售/零售/预售出库单:恢复sl |
| 17539 | 17889 | /// 销售退货单:减少sl |
| 17890 | + /// 虚拟商品(<c>wt_sp.F_Splx1=虚拟</c>)无库存概念,不读写 <c>wt_sp_cost.sl</c>。 | |
| 17540 | 17891 | /// </summary> |
| 17541 | 17892 | private async Task RollbackSpCostOnDelete(WtXsckdEntity entity) |
| 17542 | 17893 | { |
| ... | ... | @@ -17619,11 +17970,13 @@ LIMIT {offset}, {pageSize}"; |
| 17619 | 17970 | |
| 17620 | 17971 | var mxList = await _db.Queryable<WtXsckdMxEntity>() |
| 17621 | 17972 | .Where(d => d.Djbh == id).ToListAsync(); |
| 17973 | + var virtualSpbhSet = await GetVirtualMxSpbhSetAsync(mxList.Select(m => m.Spbh)); | |
| 17622 | 17974 | |
| 17623 | 17975 | foreach (var detail in mxList) |
| 17624 | 17976 | { |
| 17625 | 17977 | if (string.IsNullOrEmpty(detail.Spbh)) continue; |
| 17626 | 17978 | if (!int.TryParse(detail.Sl, out int qty) || qty <= 0) continue; |
| 17979 | + if (virtualSpbhSet.Contains(detail.Spbh.Trim())) continue; | |
| 17627 | 17980 | |
| 17628 | 17981 | decimal returnPrice = detail.Thdj.HasValue && detail.Thdj.Value > 0 ? detail.Thdj.Value : detail.Dj; |
| 17629 | 17982 | |
| ... | ... | @@ -17690,11 +18043,13 @@ LIMIT {offset}, {pageSize}"; |
| 17690 | 18043 | |
| 17691 | 18044 | var giftMxList = await _db.Queryable<WtXsckdMxEntity>() |
| 17692 | 18045 | .Where(d => d.Djbh == id).ToListAsync(); |
| 18046 | + var virtualGiftSpbhSet = await GetVirtualMxSpbhSetAsync(giftMxList.Select(m => m.Spbh)); | |
| 17693 | 18047 | |
| 17694 | 18048 | foreach (var detail in giftMxList) |
| 17695 | 18049 | { |
| 17696 | 18050 | if (string.IsNullOrEmpty(detail.Spbh)) continue; |
| 17697 | 18051 | if (!int.TryParse(detail.Sl, out int qty) || qty <= 0) continue; |
| 18052 | + if (virtualGiftSpbhSet.Contains(detail.Spbh.Trim())) continue; | |
| 17698 | 18053 | |
| 17699 | 18054 | var detailWarehouse = !string.IsNullOrEmpty(detail.Rkck) ? detail.Rkck : entity.Rkck; |
| 17700 | 18055 | if (string.IsNullOrWhiteSpace(detailWarehouse)) continue; | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtYskzjjsService.cs
| ... | ... | @@ -5,8 +5,9 @@ using NCC.Common.Filter; |
| 5 | 5 | using NCC.Dependency; |
| 6 | 6 | using NCC.DynamicApiController; |
| 7 | 7 | using NCC.FriendlyException; |
| 8 | -using NCC.Extend.Interfaces.WtYskzjjs; | |
| 9 | 8 | using NCC.Extend.Interfaces; |
| 9 | +using NCC.Extend.Interfaces.WtYskzjjs; | |
| 10 | +using NCC.Extend.WtBillSoftDelete; | |
| 10 | 11 | using Mapster; |
| 11 | 12 | using Microsoft.AspNetCore.Mvc; |
| 12 | 13 | using SqlSugar; |
| ... | ... | @@ -38,7 +39,7 @@ namespace NCC.Extend.WtYskzjjs |
| 38 | 39 | /// </summary> |
| 39 | 40 | [ApiDescriptionSettings(Tag = "Extend",Name = "WtYskzjjs", Order = 200)] |
| 40 | 41 | [Route("api/Extend/[controller]")] |
| 41 | - public class WtYskzjjsService : IWtYskzjjsService, IDynamicApiController, ITransient | |
| 42 | + public class WtYskzjjsService : IWtYskzjjsService, IDynamicApiController, ITransient, IWtBillRecycleOperations | |
| 42 | 43 | { |
| 43 | 44 | private readonly ISqlSugarRepository<WtYskzjjsEntity> _wtYskzjjsRepository; |
| 44 | 45 | private readonly ISqlSugarRepository<WtYskzjjsMxEntity> _wtYskzjjsMxRepository; |
| ... | ... | @@ -46,9 +47,14 @@ namespace NCC.Extend.WtYskzjjs |
| 46 | 47 | private readonly IUserManager _userManager; |
| 47 | 48 | private readonly WtDjzyService _wtDjzyService; |
| 48 | 49 | private readonly WtBillSummaryService _billSummaryService; |
| 50 | + private readonly IBusinessOperationLogService _businessOperationLogService; | |
| 49 | 51 | private static bool _yskAuditColsEnsured; |
| 50 | 52 | private static bool _yskJsdwColEnsured; |
| 51 | 53 | private static bool _yskJsdwmcColEnsured; |
| 54 | + private static bool _softDeleteColumnsEnsured; | |
| 55 | + | |
| 56 | + /// <inheritdoc /> | |
| 57 | + public WtBillRecycleBillSource BillSource => WtBillRecycleBillSource.WtYskzjjs; | |
| 52 | 58 | |
| 53 | 59 | private void EnsureYskzjjsJsdwColumn() |
| 54 | 60 | { |
| ... | ... | @@ -79,7 +85,8 @@ namespace NCC.Extend.WtYskzjjs |
| 79 | 85 | ISqlSugarRepository<WtYskzjjsMxEntity> wtYskzjjsMxRepository, |
| 80 | 86 | IUserManager userManager, |
| 81 | 87 | WtDjzyService wtDjzyService, |
| 82 | - WtBillSummaryService billSummaryService) | |
| 88 | + WtBillSummaryService billSummaryService, | |
| 89 | + IBusinessOperationLogService businessOperationLogService) | |
| 83 | 90 | { |
| 84 | 91 | _wtYskzjjsRepository = wtYskzjjsRepository; |
| 85 | 92 | _db = _wtYskzjjsRepository.Context; |
| ... | ... | @@ -87,6 +94,14 @@ namespace NCC.Extend.WtYskzjjs |
| 87 | 94 | _userManager = userManager; |
| 88 | 95 | _wtDjzyService = wtDjzyService; |
| 89 | 96 | _billSummaryService = billSummaryService; |
| 97 | + _businessOperationLogService = businessOperationLogService; | |
| 98 | + } | |
| 99 | + | |
| 100 | + private void EnsureSoftDeleteColumns() | |
| 101 | + { | |
| 102 | + if (_softDeleteColumnsEnsured) return; | |
| 103 | + WtBillSoftDeleteHelper.EnsureBillSoftDeleteColumnsAsync(_db, "wt_yskzjjs", "wt_yskzjjs_mx").GetAwaiter().GetResult(); | |
| 104 | + _softDeleteColumnsEnsured = true; | |
| 90 | 105 | } |
| 91 | 106 | |
| 92 | 107 | /// <summary> |
| ... | ... | @@ -123,16 +138,28 @@ namespace NCC.Extend.WtYskzjjs |
| 123 | 138 | } |
| 124 | 139 | |
| 125 | 140 | /// <summary> |
| 126 | - /// 获取应收款增加减少 | |
| 141 | + /// 获取应收款增加减少详情 | |
| 127 | 142 | /// </summary> |
| 128 | - /// <param name="id">参数</param> | |
| 129 | - /// <returns></returns> | |
| 143 | + /// <remarks> | |
| 144 | + /// 默认仅未软删;回收站只读详情传 <c>includeDeleted=true</c> 可读主表及明细。 | |
| 145 | + /// </remarks> | |
| 146 | + /// <param name="id">单据编号</param> | |
| 147 | + /// <param name="includeDeleted">为 true 时包含已软删主表及明细</param> | |
| 148 | + /// <returns>应收款增加减少详情</returns> | |
| 149 | + /// <response code="200">成功</response> | |
| 150 | + /// <response code="404">单据不存在</response> | |
| 151 | + /// <response code="500">服务异常</response> | |
| 130 | 152 | [HttpGet("{id}")] |
| 131 | - public async Task<dynamic> GetInfo(string id) | |
| 153 | + public async Task<dynamic> GetInfo(string id, [FromQuery] bool includeDeleted = false) | |
| 132 | 154 | { |
| 155 | + EnsureSoftDeleteColumns(); | |
| 133 | 156 | EnsureYskzjjsJsdwColumns(); |
| 134 | 157 | WtYskzjjsMxSrlxHelper.EnsureMxColumns(_db); |
| 135 | - var entity = await _db.Queryable<WtYskzjjsEntity>().FirstAsync(p => p.Id == id); | |
| 158 | + var entity = await _db.Queryable<WtYskzjjsEntity>() | |
| 159 | + .Where(p => p.Id == id) | |
| 160 | + .WhereIF(!includeDeleted, p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 161 | + .FirstAsync(); | |
| 162 | + if (entity == null) throw NCCException.Oh(ErrorCode.COM1005); | |
| 136 | 163 | var output = entity.Adapt<WtYskzjjsInfoOutput>(); |
| 137 | 164 | // 显式回写审核字段:Mapster 在 Entity(Djzt)→Output(djzt) 上偶发未映射时,待办/列表会缺少 djzt,导致前端不显示审核按钮 |
| 138 | 165 | output.id = entity.Id; |
| ... | ... | @@ -141,7 +168,10 @@ namespace NCC.Extend.WtYskzjjs |
| 141 | 168 | output.pendingAuditLevel = ComputeYskzjjsPendingAuditLevel(entity.Djzt); |
| 142 | 169 | output.jsrmc = await ResolveUserRealNameAsync(output.jsr); |
| 143 | 170 | |
| 144 | - var wtYskzjjsMxList = await _db.Queryable<WtYskzjjsMxEntity>().Where(w => w.Djbh == entity.Id).ToListAsync(); | |
| 171 | + var wtYskzjjsMxList = await _db.Queryable<WtYskzjjsMxEntity>() | |
| 172 | + .Where(w => w.Djbh == entity.Id) | |
| 173 | + .WhereIF(!includeDeleted, w => WtBillSoftDeleteHelper.IsNotDeleted(w.DeleteMark)) | |
| 174 | + .ToListAsync(); | |
| 145 | 175 | output.wtYskzjjsMxList = wtYskzjjsMxList.Adapt<List<WtYskzjjsMxInfoOutput>>(); |
| 146 | 176 | WtYskzjjsMxSrlxHelper.EnrichMxInfoOutput(output.wtYskzjjsMxList, wtYskzjjsMxList); |
| 147 | 177 | output.billZy = await _billSummaryService.ComputeWtYskzjjsZyByBillIdAsync(entity.Id); |
| ... | ... | @@ -167,6 +197,7 @@ namespace NCC.Extend.WtYskzjjs |
| 167 | 197 | [HttpGet("")] |
| 168 | 198 | public async Task<dynamic> GetList([FromQuery] WtYskzjjsListQueryInput input) |
| 169 | 199 | { |
| 200 | + EnsureSoftDeleteColumns(); | |
| 170 | 201 | EnsureYskzjjsJsdwColumns(); |
| 171 | 202 | var orderBy = ResolveYskzjjsListOrderBy(input.sidx, input.sort); |
| 172 | 203 | List<string> queryDjrq = input.djrq != null ? input.djrq.Split(',').ToObeject<List<string>>() : null; |
| ... | ... | @@ -177,6 +208,7 @@ namespace NCC.Extend.WtYskzjjs |
| 177 | 208 | JoinType.Left, d.Wldw == w.Id, |
| 178 | 209 | JoinType.Left, d.Wldw == h.Id, |
| 179 | 210 | JoinType.Left, d.Wldw == g.Id)) |
| 211 | + .Where((d, w, h, g) => WtBillSoftDeleteHelper.IsNotDeleted(d.DeleteMark)) | |
| 180 | 212 | .WhereIF(!string.IsNullOrEmpty(input.id), d => d.Id.Contains(input.id)) |
| 181 | 213 | .WhereIF(!string.IsNullOrEmpty(input.djlx), d => d.Djlx.Contains(input.djlx)) |
| 182 | 214 | .WhereIF(queryDjrq != null, d => d.Djrq >= new DateTime(startDjrq.ToDate().Year, startDjrq.ToDate().Month, startDjrq.ToDate().Day, 0, 0, 0)) |
| ... | ... | @@ -380,6 +412,7 @@ namespace NCC.Extend.WtYskzjjs |
| 380 | 412 | [NonAction] |
| 381 | 413 | public async Task<dynamic> GetNoPagingList([FromQuery] WtYskzjjsListQueryInput input) |
| 382 | 414 | { |
| 415 | + EnsureSoftDeleteColumns(); | |
| 383 | 416 | var orderBy = ResolveYskzjjsListOrderBy(input.sidx, input.sort); |
| 384 | 417 | List<string> queryDjrq = input.djrq != null ? input.djrq.Split(',').ToObeject<List<string>>() : null; |
| 385 | 418 | DateTime? startDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.First()) : null; |
| ... | ... | @@ -389,6 +422,7 @@ namespace NCC.Extend.WtYskzjjs |
| 389 | 422 | JoinType.Left, d.Wldw == w.Id, |
| 390 | 423 | JoinType.Left, d.Wldw == h.Id, |
| 391 | 424 | JoinType.Left, d.Wldw == g.Id)) |
| 425 | + .Where((d, w, h, g) => WtBillSoftDeleteHelper.IsNotDeleted(d.DeleteMark)) | |
| 392 | 426 | .WhereIF(!string.IsNullOrEmpty(input.id), d => d.Id.Contains(input.id)) |
| 393 | 427 | .WhereIF(!string.IsNullOrEmpty(input.djlx), d => d.Djlx.Contains(input.djlx)) |
| 394 | 428 | .WhereIF(queryDjrq != null, d => d.Djrq >= new DateTime(startDjrq.ToDate().Year, startDjrq.ToDate().Month, startDjrq.ToDate().Day, 0, 0, 0)) |
| ... | ... | @@ -513,39 +547,25 @@ namespace NCC.Extend.WtYskzjjs |
| 513 | 547 | } |
| 514 | 548 | |
| 515 | 549 | /// <summary> |
| 516 | - /// 批量删除应收款增加减少 | |
| 550 | + /// 批量删除应收款增加减少(标记删除) | |
| 517 | 551 | /// </summary> |
| 518 | 552 | /// <param name="ids">主键数组</param> |
| 519 | 553 | /// <returns></returns> |
| 520 | 554 | [HttpPost("batchRemove")] |
| 521 | 555 | public async Task BatchRemove([FromBody] List<string> ids) |
| 522 | 556 | { |
| 523 | - var entitys = await _db.Queryable<WtYskzjjsEntity>().In(it => it.Id, ids).ToListAsync(); | |
| 524 | - if (entitys.Count > 0) | |
| 557 | + EnsureSoftDeleteColumns(); | |
| 558 | + var entitys = await _db.Queryable<WtYskzjjsEntity>() | |
| 559 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 560 | + .In(it => it.Id, ids) | |
| 561 | + .ToListAsync(); | |
| 562 | + foreach (var e in entitys) | |
| 563 | + EnsureDraftOnlyDeleteForTargetYskzjjsBill(e); | |
| 564 | + var uid = _userManager.UserId ?? ""; | |
| 565 | + foreach (var id in entitys.Select(e => e.Id)) | |
| 525 | 566 | { |
| 526 | - foreach (var e in entitys) | |
| 527 | - { | |
| 528 | - EnsureDraftOnlyDeleteForTargetYskzjjsBill(e); | |
| 529 | - } | |
| 530 | - try | |
| 531 | - { | |
| 532 | - //开启事务 | |
| 533 | - _db.BeginTran(); | |
| 534 | - await _wtDjzyService.DeleteByYskzjjsAsync(ids); | |
| 535 | - //批量删除应收款增加减少 | |
| 536 | - await _db.Deleteable<WtYskzjjsEntity>().In(d => d.Id,ids).ExecuteCommandAsync(); | |
| 537 | - | |
| 538 | - //清空子表数据 | |
| 539 | - await _db.Deleteable<WtYskzjjsMxEntity>().In(u => u.Djbh,ids).ExecuteCommandAsync(); | |
| 540 | - //关闭事务 | |
| 541 | - _db.CommitTran(); | |
| 542 | - } | |
| 543 | - catch (Exception) | |
| 544 | - { | |
| 545 | - //回滚事务 | |
| 546 | - _db.RollbackTran(); | |
| 547 | - throw NCCException.Oh(ErrorCode.COM1002); | |
| 548 | - } | |
| 567 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAndMxAsync(_db, "wt_yskzjjs", "wt_yskzjjs_mx", id, uid); | |
| 568 | + await _businessOperationLogService.WriteAsync("应收款增减", "标记删除", "WtYskzjjs", id, $"标记删除应收款增减 {id}"); | |
| 549 | 569 | } |
| 550 | 570 | } |
| 551 | 571 | |
| ... | ... | @@ -660,36 +680,54 @@ namespace NCC.Extend.WtYskzjjs |
| 660 | 680 | } |
| 661 | 681 | |
| 662 | 682 | /// <summary> |
| 663 | - /// 删除应收款增加减少 | |
| 683 | + /// 删除应收款增加减少(标记删除,进回收站) | |
| 664 | 684 | /// </summary> |
| 665 | 685 | /// <returns></returns> |
| 666 | 686 | [HttpDelete("{id}")] |
| 667 | 687 | public async Task Delete(string id) |
| 668 | 688 | { |
| 669 | - var entity = await _db.Queryable<WtYskzjjsEntity>().FirstAsync(p => p.Id == id); | |
| 689 | + EnsureSoftDeleteColumns(); | |
| 690 | + var entity = await _db.Queryable<WtYskzjjsEntity>() | |
| 691 | + .Where(p => p.Id == id && WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 692 | + .FirstAsync(); | |
| 670 | 693 | _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005); |
| 671 | 694 | EnsureDraftOnlyDeleteForTargetYskzjjsBill(entity); |
| 695 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAndMxAsync(_db, "wt_yskzjjs", "wt_yskzjjs_mx", id, _userManager.UserId ?? ""); | |
| 696 | + await _businessOperationLogService.WriteAsync("应收款增减", "标记删除", "WtYskzjjs", id, $"标记删除应收款增减 {id}"); | |
| 697 | + } | |
| 698 | + | |
| 699 | + /// <inheritdoc /> | |
| 700 | + [NonAction] | |
| 701 | + public async Task RestoreFromRecycleBinAsync(string id) | |
| 702 | + { | |
| 703 | + EnsureSoftDeleteColumns(); | |
| 704 | + var entity = await _db.Queryable<WtYskzjjsEntity>().FirstAsync(p => p.Id == id); | |
| 705 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 706 | + throw NCCException.Bah("单据不存在或未在回收站"); | |
| 707 | + await WtBillSoftDeleteHelper.RestoreHeadAndMxAsync(_db, "wt_yskzjjs", "wt_yskzjjs_mx", id); | |
| 708 | + } | |
| 709 | + | |
| 710 | + /// <inheritdoc /> | |
| 711 | + [NonAction] | |
| 712 | + public async Task PurgePhysicalAsync(string id) | |
| 713 | + { | |
| 714 | + EnsureSoftDeleteColumns(); | |
| 715 | + var entity = await _db.Queryable<WtYskzjjsEntity>().FirstAsync(p => p.Id == id); | |
| 716 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 717 | + throw NCCException.Bah("仅可彻底删除回收站中的单据"); | |
| 672 | 718 | try |
| 673 | 719 | { |
| 674 | - //开启事务 | |
| 675 | 720 | _db.BeginTran(); |
| 676 | - | |
| 677 | 721 | await _wtDjzyService.DeleteByYskzjjsAsync(id); |
| 678 | - | |
| 679 | - //删除应收款增加减少记录 | |
| 680 | - await _db.Deleteable<WtYskzjjsEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); | |
| 681 | - | |
| 682 | - //清空子表数据 | |
| 683 | 722 | await _db.Deleteable<WtYskzjjsMxEntity>().Where(u => u.Djbh == id).ExecuteCommandAsync(); |
| 684 | - | |
| 685 | - //关闭事务 | |
| 723 | + var isOk = await _db.Deleteable<WtYskzjjsEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); | |
| 724 | + if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1002); | |
| 686 | 725 | _db.CommitTran(); |
| 687 | 726 | } |
| 688 | 727 | catch (Exception) |
| 689 | 728 | { |
| 690 | - //回滚事务 | |
| 691 | 729 | _db.RollbackTran(); |
| 692 | - throw NCCException.Oh(ErrorCode.COM1002); | |
| 730 | + throw; | |
| 693 | 731 | } |
| 694 | 732 | } |
| 695 | 733 | ... | ... |
Antis.Erp.Plat/netcore/src/Modularity/Extend/NCC.Extend/WtZkdService.cs
| ... | ... | @@ -5,7 +5,9 @@ using NCC.Common.Filter; |
| 5 | 5 | using NCC.Dependency; |
| 6 | 6 | using NCC.DynamicApiController; |
| 7 | 7 | using NCC.FriendlyException; |
| 8 | +using NCC.Extend.Interfaces; | |
| 8 | 9 | using NCC.Extend.Interfaces.WtZkd; |
| 10 | +using NCC.Extend.WtBillSoftDelete; | |
| 9 | 11 | using Mapster; |
| 10 | 12 | using Microsoft.AspNetCore.Mvc; |
| 11 | 13 | using SqlSugar; |
| ... | ... | @@ -31,33 +33,59 @@ namespace NCC.Extend.WtZkd |
| 31 | 33 | /// </summary> |
| 32 | 34 | [ApiDescriptionSettings(Tag = "Extend",Name = "WtZkd", Order = 200)] |
| 33 | 35 | [Route("api/Extend/[controller]")] |
| 34 | - public class WtZkdService : IWtZkdService, IDynamicApiController, ITransient | |
| 36 | + public class WtZkdService : IWtZkdService, IDynamicApiController, ITransient, IWtBillRecycleOperations | |
| 35 | 37 | { |
| 36 | 38 | private readonly ISqlSugarRepository<WtZkdEntity> _wtZkdRepository; |
| 37 | 39 | private readonly SqlSugarScope _db; |
| 38 | 40 | private readonly IUserManager _userManager; |
| 41 | + private readonly IBusinessOperationLogService _businessOperationLogService; | |
| 42 | + private static bool _softDeleteColumnsEnsured; | |
| 43 | + | |
| 44 | + /// <inheritdoc /> | |
| 45 | + public WtBillRecycleBillSource BillSource => WtBillRecycleBillSource.WtZkd; | |
| 39 | 46 | |
| 40 | 47 | /// <summary> |
| 41 | 48 | /// 初始化一个<see cref="WtZkdService"/>类型的新实例 |
| 42 | 49 | /// </summary> |
| 43 | 50 | public WtZkdService( |
| 44 | 51 | ISqlSugarRepository<WtZkdEntity> wtZkdRepository, |
| 45 | - IUserManager userManager) | |
| 52 | + IUserManager userManager, | |
| 53 | + IBusinessOperationLogService businessOperationLogService) | |
| 46 | 54 | { |
| 47 | 55 | _wtZkdRepository = wtZkdRepository; |
| 48 | 56 | _db = _wtZkdRepository.Context; |
| 49 | 57 | _userManager = userManager; |
| 58 | + _businessOperationLogService = businessOperationLogService; | |
| 59 | + } | |
| 60 | + | |
| 61 | + private void EnsureSoftDeleteColumns() | |
| 62 | + { | |
| 63 | + if (_softDeleteColumnsEnsured) return; | |
| 64 | + WtBillSoftDeleteHelper.EnsureBillSoftDeleteColumnsAsync(_db, "wt_zkd").GetAwaiter().GetResult(); | |
| 65 | + _softDeleteColumnsEnsured = true; | |
| 50 | 66 | } |
| 51 | 67 | |
| 52 | 68 | /// <summary> |
| 53 | - /// 获取转款单 | |
| 69 | + /// 获取转款单详情 | |
| 54 | 70 | /// </summary> |
| 55 | - /// <param name="id">参数</param> | |
| 56 | - /// <returns></returns> | |
| 71 | + /// <remarks> | |
| 72 | + /// 默认仅未软删;回收站只读详情传 <c>includeDeleted=true</c>。 | |
| 73 | + /// </remarks> | |
| 74 | + /// <param name="id">单据编号</param> | |
| 75 | + /// <param name="includeDeleted">为 true 时允许读取已软删单据</param> | |
| 76 | + /// <returns>转款单详情</returns> | |
| 77 | + /// <response code="200">成功</response> | |
| 78 | + /// <response code="404">单据不存在</response> | |
| 79 | + /// <response code="500">服务异常</response> | |
| 57 | 80 | [HttpGet("{id}")] |
| 58 | - public async Task<dynamic> GetInfo(string id) | |
| 81 | + public async Task<dynamic> GetInfo(string id, [FromQuery] bool includeDeleted = false) | |
| 59 | 82 | { |
| 60 | - var entity = await _db.Queryable<WtZkdEntity>().FirstAsync(p => p.Id == id); | |
| 83 | + EnsureSoftDeleteColumns(); | |
| 84 | + var entity = await _db.Queryable<WtZkdEntity>() | |
| 85 | + .Where(p => p.Id == id) | |
| 86 | + .WhereIF(!includeDeleted, p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 87 | + .FirstAsync(); | |
| 88 | + if (entity == null) throw NCCException.Oh(ErrorCode.COM1005); | |
| 61 | 89 | var output = entity.Adapt<WtZkdInfoOutput>(); |
| 62 | 90 | return output; |
| 63 | 91 | } |
| ... | ... | @@ -70,11 +98,13 @@ namespace NCC.Extend.WtZkd |
| 70 | 98 | [HttpGet("")] |
| 71 | 99 | public async Task<dynamic> GetList([FromQuery] WtZkdListQueryInput input) |
| 72 | 100 | { |
| 101 | + EnsureSoftDeleteColumns(); | |
| 73 | 102 | var sidx = input.sidx == null ? "id" : input.sidx; |
| 74 | 103 | List<string> queryDjrq = input.djrq != null ? input.djrq.Split(',').ToObeject<List<string>>() : null; |
| 75 | 104 | DateTime? startDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.First()) : null; |
| 76 | 105 | DateTime? endDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.Last()) : null; |
| 77 | 106 | var data = await _db.Queryable<WtZkdEntity>() |
| 107 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 78 | 108 | .WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id)) |
| 79 | 109 | .WhereIF(queryDjrq != null, p => p.Djrq >= new DateTime(startDjrq.ToDate().Year, startDjrq.ToDate().Month, startDjrq.ToDate().Day, 0, 0, 0)) |
| 80 | 110 | .WhereIF(queryDjrq != null, p => p.Djrq <= new DateTime(endDjrq.ToDate().Year, endDjrq.ToDate().Month, endDjrq.ToDate().Day, 23, 59, 59)) |
| ... | ... | @@ -148,11 +178,13 @@ namespace NCC.Extend.WtZkd |
| 148 | 178 | [NonAction] |
| 149 | 179 | public async Task<dynamic> GetNoPagingList([FromQuery] WtZkdListQueryInput input) |
| 150 | 180 | { |
| 181 | + EnsureSoftDeleteColumns(); | |
| 151 | 182 | var sidx = input.sidx == null ? "id" : input.sidx; |
| 152 | 183 | List<string> queryDjrq = input.djrq != null ? input.djrq.Split(',').ToObeject<List<string>>() : null; |
| 153 | 184 | DateTime? startDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.First()) : null; |
| 154 | 185 | DateTime? endDjrq = queryDjrq != null ? Ext.GetDateTime(queryDjrq.Last()) : null; |
| 155 | 186 | var data = await _db.Queryable<WtZkdEntity>() |
| 187 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 156 | 188 | .WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id)) |
| 157 | 189 | .WhereIF(queryDjrq != null, p => p.Djrq >= new DateTime(startDjrq.ToDate().Year, startDjrq.ToDate().Month, startDjrq.ToDate().Day, 0, 0, 0)) |
| 158 | 190 | .WhereIF(queryDjrq != null, p => p.Djrq <= new DateTime(endDjrq.ToDate().Year, endDjrq.ToDate().Month, endDjrq.ToDate().Day, 23, 59, 59)) |
| ... | ... | @@ -233,31 +265,23 @@ namespace NCC.Extend.WtZkd |
| 233 | 265 | } |
| 234 | 266 | |
| 235 | 267 | /// <summary> |
| 236 | - /// 批量删除转款单 | |
| 268 | + /// 批量删除转款单(标记删除) | |
| 237 | 269 | /// </summary> |
| 238 | 270 | /// <param name="ids">主键数组</param> |
| 239 | 271 | /// <returns></returns> |
| 240 | 272 | [HttpPost("batchRemove")] |
| 241 | 273 | public async Task BatchRemove([FromBody] List<string> ids) |
| 242 | 274 | { |
| 243 | - var entitys = await _db.Queryable<WtZkdEntity>().In(it => it.Id, ids).ToListAsync(); | |
| 244 | - if (entitys.Count > 0) | |
| 275 | + EnsureSoftDeleteColumns(); | |
| 276 | + var entitys = await _db.Queryable<WtZkdEntity>() | |
| 277 | + .Where(p => WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 278 | + .In(it => it.Id, ids) | |
| 279 | + .ToListAsync(); | |
| 280 | + var uid = _userManager.UserId ?? ""; | |
| 281 | + foreach (var id in entitys.Select(e => e.Id)) | |
| 245 | 282 | { |
| 246 | - try | |
| 247 | - { | |
| 248 | - //开启事务 | |
| 249 | - _db.BeginTran(); | |
| 250 | - //批量删除转款单 | |
| 251 | - await _db.Deleteable<WtZkdEntity>().In(d => d.Id,ids).ExecuteCommandAsync(); | |
| 252 | - //关闭事务 | |
| 253 | - _db.CommitTran(); | |
| 254 | - } | |
| 255 | - catch (Exception) | |
| 256 | - { | |
| 257 | - //回滚事务 | |
| 258 | - _db.RollbackTran(); | |
| 259 | - throw NCCException.Oh(ErrorCode.COM1002); | |
| 260 | - } | |
| 283 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAsync(_db, "wt_zkd", id, uid); | |
| 284 | + await _businessOperationLogService.WriteAsync("转款单", "标记删除", "WtZkd", id, $"标记删除转款单 {id}"); | |
| 261 | 285 | } |
| 262 | 286 | } |
| 263 | 287 | |
| ... | ... | @@ -276,14 +300,40 @@ namespace NCC.Extend.WtZkd |
| 276 | 300 | } |
| 277 | 301 | |
| 278 | 302 | /// <summary> |
| 279 | - /// 删除转款单 | |
| 303 | + /// 删除转款单(标记删除,进回收站) | |
| 280 | 304 | /// </summary> |
| 281 | 305 | /// <returns></returns> |
| 282 | 306 | [HttpDelete("{id}")] |
| 283 | 307 | public async Task Delete(string id) |
| 284 | 308 | { |
| 285 | - var entity = await _db.Queryable<WtZkdEntity>().FirstAsync(p => p.Id == id); | |
| 309 | + EnsureSoftDeleteColumns(); | |
| 310 | + var entity = await _db.Queryable<WtZkdEntity>() | |
| 311 | + .Where(p => p.Id == id && WtBillSoftDeleteHelper.IsNotDeleted(p.DeleteMark)) | |
| 312 | + .FirstAsync(); | |
| 286 | 313 | _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005); |
| 314 | + await WtBillSoftDeleteHelper.SoftDeleteHeadAsync(_db, "wt_zkd", id, _userManager.UserId ?? ""); | |
| 315 | + await _businessOperationLogService.WriteAsync("转款单", "标记删除", "WtZkd", id, $"标记删除转款单 {id}"); | |
| 316 | + } | |
| 317 | + | |
| 318 | + /// <inheritdoc /> | |
| 319 | + [NonAction] | |
| 320 | + public async Task RestoreFromRecycleBinAsync(string id) | |
| 321 | + { | |
| 322 | + EnsureSoftDeleteColumns(); | |
| 323 | + var entity = await _db.Queryable<WtZkdEntity>().FirstAsync(p => p.Id == id); | |
| 324 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 325 | + throw NCCException.Bah("单据不存在或未在回收站"); | |
| 326 | + await WtBillSoftDeleteHelper.RestoreHeadAsync(_db, "wt_zkd", id); | |
| 327 | + } | |
| 328 | + | |
| 329 | + /// <inheritdoc /> | |
| 330 | + [NonAction] | |
| 331 | + public async Task PurgePhysicalAsync(string id) | |
| 332 | + { | |
| 333 | + EnsureSoftDeleteColumns(); | |
| 334 | + var entity = await _db.Queryable<WtZkdEntity>().FirstAsync(p => p.Id == id); | |
| 335 | + if (entity == null || !WtBillSoftDeleteHelper.IsDeleted(entity.DeleteMark)) | |
| 336 | + throw NCCException.Bah("仅可彻底删除回收站中的单据"); | |
| 287 | 337 | var isOk = await _db.Deleteable<WtZkdEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); |
| 288 | 338 | if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1002); |
| 289 | 339 | } | ... | ... |
Antis.Erp.Plat/项目文档相关/docs/数据库说明.md
| ... | ... | @@ -81,10 +81,25 @@ |
| 81 | 81 | **盘点期间销售出库/退货业务口径** |
| 82 | 82 | |
| 83 | 83 | - 盘点进行中放行的销售类单据:`销售出库单`、`零售单`、`销售退货单`、`预售出库单`、`预售退货单`(`EnsureWarehouseNotLockedByPdAsync` 白名单);采购入库/退货、同价/变价调拨、拆装、手工报损/报溢仍锁定。 |
| 84 | -- **未盘明细**(`F_Sjsl` 为 NULL):销售照常改 `wt_sp_cost.sl`,盘点明细不动数;首次录入实盘时把 `F_Ckc` 刷新为当时实时账面(`wt_sp_cost.sl`)再算差异,避免把期间正常销售算成盘亏。 | |
| 84 | +- **未盘明细**(`F_Sjsl` 为 NULL):销售照常改 `wt_sp_cost.sl`;**快照内**未盘行盘点明细账面不改数,首次录入实盘时把 `F_Ckc` 刷新为当时实时账面(`wt_sp_cost.sl`)再算差异。**表外**未盘行(盘点期间退货追加、`F_IsExtra=1`)的 `F_Ckc` 在追加时已按退货后实时库存写入,后续出库/再退货须同步改 `F_Ckc` 与 `F_SaleOutQty`/`F_SaleReturnQty`,否则账面会停在退货后的瞬时值。 | |
| 85 | 85 | - **已盘明细**(`F_Sjsl` 非 NULL):销售出库过账成功后同步 `F_Ckc`、`F_Sjsl` 各减出库数量(退货各加退货数量),并累计 `F_SaleOutQty` / `F_SaleReturnQty`,使差异 `F_Cy` 仍只反映真正盘差;完成盘点按调整后的明细生成报损/报溢,避免期间已卖货再被重复扣减。 |
| 86 | +- **销售退货回写时机**:退货在 Create/Update 过账时(待审核/已审核)回写一次即可;终审 `ApproveGeneric` **不得再回写**,否则 `F_Ckc`/`F_SaleReturnQty` 会按单据数量翻倍虚增。 | |
| 86 | 87 | - 串码(入1出1/入0出1)商品的盘亏在完成盘点时按「当前在库序列号」实时计算,天然已扣除期间销售,无需回写(`F_SaleOutQty`/`F_SaleReturnQty` 仅对非串码商品累计)。 |
| 87 | 88 | |
| 88 | 89 | **DDL 脚本** |
| 89 | 90 | |
| 90 | 91 | - `wt_pd`、`wt_pd_mx` 由 `WtPdService.EnsureWtPdTables()` CodeFirst 建表;新增列 `F_SaleOutQty`、`F_SaleReturnQty` 由 `EnsurePdMxUnknownColumn()` 幂等补列。 |
| 92 | + | |
| 93 | +## 业务单据统一标记删除(回收站) | |
| 94 | + | |
| 95 | +以下业务主表及明细表(启动或首次访问时由 `WtBillSoftDeleteHelper.EnsureAllBillSoftDeleteColumnsAsync` 幂等补列)统一增加: | |
| 96 | + | |
| 97 | +| 字段名 | 类型 | 可空 | 说明 | | |
| 98 | +|--------|------|------|------| | |
| 99 | +| F_DeleteMark | int | 是 | 0 或 NULL=未删;1=已删(进回收站) | | |
| 100 | +| F_DeleteTime | datetime | 是 | 标记删除时间 | | |
| 101 | +| F_DeleteUserId | varchar(64) | 是 | 删除人用户 Id | | |
| 102 | + | |
| 103 | +**涉及表**:`wt_xsckd` / `wt_xsckd_mx`、`wt_cwdj` / `wt_cwdjmx`、`wt_yskzjjs` / `wt_yskzjjs_mx`、`wt_fysrd` / `wt_fysrd_mx`、`wt_tjd` / `wt_tjd_mx`、`wt_czd` / `wt_czdmx` / `wt_czdmx_2`、`wt_fpsq`、`wt_kfbfb`、`wt_zkd`、`wt_pd` / `wt_pd_mx`、`wt_hydqtk`、`wt_sfk`。 | |
| 104 | + | |
| 105 | +**行为**:列表/统计默认 `IFNULL(F_DeleteMark,0)=0`;用户「删除」为标记删除;回收站 `GET /api/Extend/WtBillRecycle` 可查已删记录;恢复/彻底删除见同接口 `Restore` / `Purge`。 | ... | ... |
Antis.Erp.Plat/项目文档相关/sql/add_btn_editBz_permissions.sql
0 → 100644
| 1 | +-- ============================================================================= | |
| 2 | +-- 客户档案「修改备注」按钮权限 btn_editBz(幂等) | |
| 3 | +-- 模块:客户档案 wtHy | moduleId=673429743055406341 | |
| 4 | +-- 1) base_modulebutton 插入按钮 | |
| 5 | +-- 2) 对已拥有同模块 btn_edit 的角色,自动授权 btn_editBz(避免前端 v-has 后按钮全消失) | |
| 6 | +-- 执行后:用户重新登录(或清权限缓存)生效;亦可在【角色授权】中微调 | |
| 7 | +-- ============================================================================= | |
| 8 | + | |
| 9 | +INSERT INTO base_modulebutton ( | |
| 10 | + F_Id, F_ParentId, F_ModuleId, F_FullName, F_EnCode, F_SortCode, | |
| 11 | + F_EnabledMark, F_DeleteMark, F_CreatorTime | |
| 12 | +) | |
| 13 | +SELECT REPLACE(UUID(), '-', ''), '-1', '673429743055406341', '修改备注', 'btn_editBz', 55, 1, NULL, NOW() | |
| 14 | +FROM DUAL | |
| 15 | +WHERE NOT EXISTS ( | |
| 16 | + SELECT 1 FROM base_modulebutton | |
| 17 | + WHERE F_ModuleId = '673429743055406341' | |
| 18 | + AND F_EnCode = 'btn_editBz' | |
| 19 | + AND (F_DeleteMark IS NULL OR F_DeleteMark = 0) | |
| 20 | +); | |
| 21 | + | |
| 22 | +-- 角色授权:已有同模块「编辑」权限的角色,补授权「修改备注」 | |
| 23 | +INSERT INTO base_authorize ( | |
| 24 | + F_Id, F_ItemType, F_ItemId, F_ObjectType, F_ObjectId, F_SortCode, F_CreatorTime | |
| 25 | +) | |
| 26 | +SELECT | |
| 27 | + REPLACE(UUID(), '-', ''), | |
| 28 | + 'button', | |
| 29 | + bz.F_Id, | |
| 30 | + 'Role', | |
| 31 | + ae.F_ObjectId, | |
| 32 | + 0, | |
| 33 | + NOW() | |
| 34 | +FROM base_modulebutton bz | |
| 35 | +INNER JOIN base_modulebutton edit | |
| 36 | + ON edit.F_ModuleId = bz.F_ModuleId | |
| 37 | + AND edit.F_EnCode = 'btn_edit' | |
| 38 | + AND (edit.F_DeleteMark IS NULL OR edit.F_DeleteMark = 0) | |
| 39 | +INNER JOIN base_authorize ae | |
| 40 | + ON ae.F_ItemId = edit.F_Id | |
| 41 | + AND ae.F_ItemType = 'button' | |
| 42 | + AND ae.F_ObjectType = 'Role' | |
| 43 | +WHERE bz.F_ModuleId = '673429743055406341' | |
| 44 | + AND bz.F_EnCode = 'btn_editBz' | |
| 45 | + AND (bz.F_DeleteMark IS NULL OR bz.F_DeleteMark = 0) | |
| 46 | + AND NOT EXISTS ( | |
| 47 | + SELECT 1 FROM base_authorize ax | |
| 48 | + WHERE ax.F_ItemId = bz.F_Id | |
| 49 | + AND ax.F_ItemType = 'button' | |
| 50 | + AND ax.F_ObjectType = 'Role' | |
| 51 | + AND ax.F_ObjectId = ae.F_ObjectId | |
| 52 | + ); | ... | ... |
Antis.Erp.Plat/项目文档相关/sql/init_wt_modulebutton_permissions.sql
| ... | ... | @@ -4157,6 +4157,9 @@ INSERT INTO base_modulebutton (F_Id, F_ParentId, F_ModuleId, F_FullName, F_EnCod |
| 4157 | 4157 | SELECT REPLACE(UUID(), '-', ''), '-1', '673429743055406341', '编辑', 'btn_edit', 50, 1, NULL, NOW() FROM DUAL |
| 4158 | 4158 | WHERE NOT EXISTS (SELECT 1 FROM base_modulebutton WHERE F_ModuleId = '673429743055406341' AND F_EnCode = 'btn_edit' AND (F_DeleteMark IS NULL OR F_DeleteMark = 0)); |
| 4159 | 4159 | INSERT INTO base_modulebutton (F_Id, F_ParentId, F_ModuleId, F_FullName, F_EnCode, F_SortCode, F_EnabledMark, F_DeleteMark, F_CreatorTime) |
| 4160 | +SELECT REPLACE(UUID(), '-', ''), '-1', '673429743055406341', '修改备注', 'btn_editBz', 55, 1, NULL, NOW() FROM DUAL | |
| 4161 | +WHERE NOT EXISTS (SELECT 1 FROM base_modulebutton WHERE F_ModuleId = '673429743055406341' AND F_EnCode = 'btn_editBz' AND (F_DeleteMark IS NULL OR F_DeleteMark = 0)); | |
| 4162 | +INSERT INTO base_modulebutton (F_Id, F_ParentId, F_ModuleId, F_FullName, F_EnCode, F_SortCode, F_EnabledMark, F_DeleteMark, F_CreatorTime) | |
| 4160 | 4163 | SELECT REPLACE(UUID(), '-', ''), '-1', '673429743055406341', '删除', 'btn_remove', 60, 1, NULL, NOW() FROM DUAL |
| 4161 | 4164 | WHERE NOT EXISTS (SELECT 1 FROM base_modulebutton WHERE F_ModuleId = '673429743055406341' AND F_EnCode = 'btn_remove' AND (F_DeleteMark IS NULL OR F_DeleteMark = 0)); |
| 4162 | 4165 | ... | ... |