Parcourir la source

feat: 应收应付支持对账异常来源(10/11),异常来源允许对账明细为空并支持预收确认式收款,应付明细新增冲抵处置方式与冲抵单据选择

lucw il y a 6 jours
Parent
commit
2f27ce3622
20 fichiers modifiés avec 2068 ajouts et 66 suppressions
  1. 32 7
      src/BIZComponents/collectTableForm/index.vue
  2. 102 0
      src/api/saleManage/finoffset.js
  3. 9 0
      src/enum/dict.js
  4. 135 0
      src/views/financialManage/finoffset/components/offsetDetailDialog.vue
  5. 313 0
      src/views/financialManage/finoffset/index.vue
  6. 165 0
      src/views/financialManage/offsetDetail/index.vue
  7. 128 0
      src/views/financialManage/offsetLedger/index.vue
  8. 69 0
      src/views/financialManage/offsetParam/index.vue
  9. 115 2
      src/views/financialManage/payableManage/components/paymentDialog1.vue
  10. 17 5
      src/views/financialManage/receivableManage/components/addReceivableDialog.vue
  11. 117 9
      src/views/financialManage/receivableManage/components/collectionDialog.vue
  12. 8 2
      src/views/financialManage/receivableManage/components/detailDialog.vue
  13. 2 3
      src/views/purchasingManage/purchaseOrder/accountstatement/components/addAccountDialog.vue
  14. 269 6
      src/views/purchasingManage/purchaseOrder/accountstatement/components/payablesInfo.vue
  15. 27 14
      src/views/saleManage/saleOrder/accountstatement/components/accountDetailTable.vue
  16. 2 2
      src/views/saleManage/saleOrder/accountstatement/components/addAccountDialog.vue
  17. 17 6
      src/views/saleManage/saleOrder/accountstatement/components/inventoryTable.vue
  18. 229 0
      src/views/saleManage/saleOrder/accountstatement/components/offsetOrderDialog.vue
  19. 271 6
      src/views/saleManage/saleOrder/accountstatement/components/receivableInfo.vue
  20. 41 4
      src/views/saleManage/saleOrder/exceptionManagement/exceptionList/index.vue

+ 32 - 7
src/BIZComponents/collectTableForm/index.vue

@@ -6,8 +6,8 @@
     <headerTitle :title="title"></headerTitle>
     <div style="margin: 10px 0; font-size: 14px; color: #606266">
       <span>{{ totalLabel }}:{{ totalPrice || 0 }} 元</span>
-      <span style="margin-left: 20px">已收金额:{{ receivedAmount }} 元</span>
-      <span style="margin-left: 20px">未收金额:{{ unreceivedAmount }} 元</span>
+      <span style="margin-left: 20px">{{ receivedLabel }}:{{ receivedAmount }} 元</span>
+      <span style="margin-left: 20px">{{ unreceivedLabel }}:{{ unreceivedAmount }} 元</span>
     </div>
 
     <el-button
@@ -37,7 +37,7 @@
             :prop="`tableData.${$index}.receivedDate`"
             :rules="{
               required: true,
-              message: '请选择收款时间',
+              message: '请选择' + dateLabel,
               trigger: 'change'
             }"
             class="table-form-item"
@@ -62,7 +62,7 @@
             :prop="`tableData.${$index}.receivedTotalPrice`"
             :rules="{
               required: true,
-              message: '请输入已收金额',
+              message: '请输入' + amountLabel,
               trigger: 'blur'
             }"
             class="table-form-item"
@@ -176,6 +176,31 @@
       dialogType: {
         type: String,
         default: 'update'
+      },
+      // 时间列标题(收款时间/付款时间)
+      dateLabel: {
+        type: String,
+        default: '收款时间'
+      },
+      // 金额列标题(已收金额/已付金额)
+      amountLabel: {
+        type: String,
+        default: '已收金额'
+      },
+      // 汇总区「已收金额」标签(应付场景传「已付金额」)
+      receivedLabel: {
+        type: String,
+        default: '已收金额'
+      },
+      // 汇总区「未收金额」标签(应付场景传「未付金额」)
+      unreceivedLabel: {
+        type: String,
+        default: '未收金额'
+      },
+      // 记录名称,用于「请至少添加一条xx」提示(收款记录/付款记录)
+      recordName: {
+        type: String,
+        default: '收款记录'
       }
     },
     data() {
@@ -201,7 +226,7 @@
           {
             prop: 'receivedDate',
             headerSlot: 'columnRequired',
-            label: '收款时间',
+            label: this.dateLabel,
             align: 'center',
             minWidth: 160,
             slot: 'receivedDate'
@@ -209,7 +234,7 @@
           {
             prop: 'receivedTotalPrice',
             headerSlot: 'columnRequired',
-            label: '已收金额',
+            label: this.amountLabel,
             align: 'center',
             minWidth: 140,
             slot: 'receivedTotalPrice'
@@ -292,7 +317,7 @@
             return;
           }
           if (this.form.tableData.length === 0) {
-            this.$message.warning('请至少添加一条收款记录');
+            this.$message.warning('请至少添加一条' + this.recordName);
             reject(false);
             return;
           }

+ 102 - 0
src/api/saleManage/finoffset.js

@@ -0,0 +1,102 @@
+import request from '@/utils/request';
+
+/**
+ * 冲抵结算单分页列表
+ */
+export async function offsetPage(params) {
+  const res = await request.post(`/eom/finoffset/page`, params);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+/**
+ * 冲抵核销流水分页列表
+ */
+export async function offsetDetailPage(params) {
+  const res = await request.post(`/eom/finoffset/detail/page`, params);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+/**
+ * 冲抵台账聚合查询(往来单位+结算主体+币种维度)
+ */
+export async function offsetLedger(params) {
+  const res = await request.get(`/eom/finoffset/ledger`, { params });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+/**
+ * 可用冲抵结算单列表(对账单「本期冲抵」源单选择)
+ */
+export async function offsetAvailable(params) {
+  const res = await request.get(`/eom/finoffset/available`, { params });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+/**
+ * 可用冲抵结算单列表(明细维度核销:按方向 + 往来单位id 过滤)
+ */
+export async function offsetAvailableByContact(params) {
+  const res = await request.get(`/eom/finoffset/availableByContact`, {
+    params
+  });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+/**
+ * 单笔确认生效(待确认 -> 可用)
+ */
+export async function offsetConfirm(id) {
+  const res = await request.post(`/eom/finoffset/confirm/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+/**
+ * 批量确认生效
+ */
+export async function offsetConfirmBatch(ids) {
+  const res = await request.post(`/eom/finoffset/confirmBatch`, ids);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+/**
+ * 作废
+ */
+export async function offsetVoid(id) {
+  const res = await request.post(`/eom/finoffset/void/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+/**
+ * 到期退款
+ */
+export async function offsetRefund(id) {
+  const res = await request.post(`/eom/finoffset/refund/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 9 - 0
src/enum/dict.js

@@ -740,6 +740,15 @@ export const payAndReceiveEnum = [
     label: '发票',
     value: 9
   },
+  // 对账异常来源:异常处置(收款/退款)自动生成的应收/应付单
+  {
+    label: '销售订单-对账异常',
+    value: 10
+  },
+  {
+    label: '采购订单-对账异常',
+    value: 11
+  },
   {
     label: '其他',
     value: 99

+ 135 - 0
src/views/financialManage/finoffset/components/offsetDetailDialog.vue

@@ -0,0 +1,135 @@
+<template>
+  <el-dialog
+    :visible.sync="visible"
+    title="冲抵结算单详情"
+    width="760px"
+    append-to-body
+    :close-on-click-modal="false"
+  >
+    <el-descriptions :column="2" border size="small">
+      <el-descriptions-item label="结算单编号">{{ data.code || '-' }}</el-descriptions-item>
+      <el-descriptions-item label="业务类型">{{ bizTypeText }}</el-descriptions-item>
+      <el-descriptions-item label="结转方向">{{ directionText }}</el-descriptions-item>
+      <el-descriptions-item label="状态">
+        <el-tag :type="statusTagType" size="small">{{ statusText }}</el-tag>
+      </el-descriptions-item>
+      <el-descriptions-item label="订单编码">{{ data.bizOrderNo || '-' }}</el-descriptions-item>
+      <el-descriptions-item label="结转金额">{{ data.carryAmt != null ? data.carryAmt : '-' }}</el-descriptions-item>
+      <el-descriptions-item label="剩余可用">{{ data.remainAmt != null ? data.remainAmt : '-' }}</el-descriptions-item>
+      <el-descriptions-item label="来源类型">{{ sourceTypeText }}</el-descriptions-item>
+      <el-descriptions-item label="来源单号">{{ data.sourceNo || '-' }}</el-descriptions-item>
+      <el-descriptions-item label="来源对账单">{{ data.sourceStatementNo || '-' }}</el-descriptions-item>
+      <el-descriptions-item label="生效日期">{{ formatDate(data.effectiveDate) }}</el-descriptions-item>
+      <el-descriptions-item label="有效期至">{{ formatDate(data.expireDate) }}</el-descriptions-item>
+      <el-descriptions-item label="确认人id">{{ data.confirmUserId || '-' }}</el-descriptions-item>
+      <el-descriptions-item label="确认时间">{{ formatDate(data.confirmTime) }}</el-descriptions-item>
+      <el-descriptions-item label="异常说明" :span="2">{{ data.remark || '-' }}</el-descriptions-item>
+      <el-descriptions-item label="创建时间" :span="2">{{ formatDate(data.createTime) }}</el-descriptions-item>
+    </el-descriptions>
+
+    <headerTitle title="核销流水" style="margin-top: 20px" />
+    <el-table :data="detailList" border size="small" max-height="240" empty-text="暂无核销流水">
+      <el-table-column prop="code" label="流水编号" min-width="150" show-overflow-tooltip />
+      <el-table-column prop="targetStatementNo" label="目标对账单" min-width="150" show-overflow-tooltip />
+      <el-table-column prop="writeoffAmt" label="核销金额" width="110" align="right" />
+      <el-table-column label="状态" width="90" align="center">
+        <template slot-scope="scope">{{ statusOfDetail(scope.row.status) }}</template>
+      </el-table-column>
+      <el-table-column label="核销时间" width="110" align="center">
+        <template slot-scope="scope">{{ formatDate(scope.row.writeoffTime) }}</template>
+      </el-table-column>
+    </el-table>
+
+    <div slot="footer">
+      <el-button @click="visible = false">关闭</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+  import { offsetPage, offsetDetailPage } from '@/api/saleManage/finoffset';
+
+  const STATUS_MAP = {
+    0: { text: '待确认', tag: 'info' },
+    1: { text: '可用', tag: 'success' },
+    2: { text: '部分冲抵', tag: 'warning' },
+    3: { text: '已结清', tag: '' },
+    4: { text: '已到期', tag: 'danger' },
+    5: { text: '转退款中', tag: 'warning' },
+    6: { text: '已退款', tag: '' },
+    7: { text: '已作废', tag: 'info' }
+  };
+
+  const SOURCE_TYPE_MAP = {
+    1: '对账异常',
+    2: '返利结算单',
+    3: '索赔单',
+    4: '预收单',
+    5: '红字发票',
+    6: '退货单'
+  };
+
+  const DETAIL_STATUS_MAP = { 0: '待生效', 1: '生效', 2: '红冲' };
+
+  export default {
+    name: 'offsetDetailDialog',
+    data() {
+      return {
+        visible: false,
+        data: {},
+        detailList: []
+      };
+    },
+    computed: {
+      bizTypeText() {
+        return this.data.bizType === 1 ? '销售' : this.data.bizType === 2 ? '采购' : '-';
+      },
+      directionText() {
+        return this.data.direction === 1
+          ? '贷向结转(应退未退)'
+          : this.data.direction === 2
+          ? '借向结转(应补未补)'
+          : '-';
+      },
+      statusText() {
+        const s = STATUS_MAP[this.data.status];
+        return s ? s.text : '-';
+      },
+      statusTagType() {
+        const s = STATUS_MAP[this.data.status];
+        return s ? s.tag : '';
+      },
+      sourceTypeText() {
+        return SOURCE_TYPE_MAP[this.data.sourceType] || '-';
+      }
+    },
+    methods: {
+      formatDate(val) {
+        return val ? String(val).slice(0, 10) : '-';
+      },
+      statusOfDetail(status) {
+        return DETAIL_STATUS_MAP[status] || '-';
+      },
+      /**
+       * 打开详情
+       * @param {Object} row 列表行(含 id/code)
+       */
+      async open(row) {
+        this.data = row || {};
+        this.detailList = [];
+        this.visible = true;
+        if (!row || !row.id) return;
+        try {
+          const res = await offsetDetailPage({
+            pageNum: 1,
+            size: 200,
+            offsetId: row.id
+          });
+          this.detailList = (res && res.list) || [];
+        } catch (e) {
+          this.detailList = [];
+        }
+      }
+    }
+  };
+</script>

+ 313 - 0
src/views/financialManage/finoffset/index.vue

@@ -0,0 +1,313 @@
+<template>
+  <div class="ele-body">
+    <el-card shadow="never" v-loading="loading">
+      <!-- 搜索区 -->
+      <el-form :inline="true" size="small" class="offset-search" @submit.native.prevent>
+        <el-form-item label="结算单编号">
+          <el-input
+            v-model="searchForm.code"
+            placeholder="请输入结算单编号"
+            clearable
+            style="width: 220px"
+            @keyup.enter.native="reload()"
+          />
+        </el-form-item>
+        <el-form-item label="状态">
+          <el-select v-model="searchForm.status" placeholder="全部" clearable style="width: 140px">
+            <el-option
+              v-for="item in statusOp"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" icon="el-icon-search" @click="reload()">查询</el-button>
+          <el-button icon="el-icon-refresh-right" @click="resetSearch">重置</el-button>
+        </el-form-item>
+      </el-form>
+
+      <ele-pro-table
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        height="calc(100vh - 300px)"
+        full-height="calc(100vh - 116px)"
+        tool-class="ele-toolbar-form"
+        :selection.sync="selection"
+        :cache-key="cacheKeyUrl"
+        @header-dragend="handleHeaderDragend"
+      >
+        <!-- 表头工具栏:批量确认 -->
+        <template v-slot:toolbar>
+          <el-button
+            size="small"
+            type="primary"
+            icon="el-icon-check"
+            class="ele-btn-icon"
+            :disabled="!selection.length"
+            @click="confirmBatch"
+          >
+            批量确认生效
+          </el-button>
+        </template>
+
+        <template v-slot:code="{ row }">
+          <el-link type="primary" :underline="false" @click="openDetail(row)">
+            {{ row.code }}
+          </el-link>
+        </template>
+
+        <template v-slot:action="{ row }">
+          <el-link
+            v-if="row.status === 0"
+            type="success"
+            :underline="false"
+            @click="confirmOne(row)"
+          >
+            确认
+          </el-link>
+          <el-popconfirm
+            v-if="[0, 1, 2].includes(row.status)"
+            class="ele-action"
+            title="确定要作废此冲抵结算单吗?"
+            @confirm="voidOne(row)"
+          >
+            <template v-slot:reference>
+              <el-link type="danger" :underline="false">作废</el-link>
+            </template>
+          </el-popconfirm>
+          <span v-if="![0, 1, 2].includes(row.status) && row.status !== 0">--</span>
+        </template>
+      </ele-pro-table>
+    </el-card>
+    <!-- 结算单详情(异常列表「处置单据号」跳转后展示) -->
+    <offset-detail-dialog ref="offsetDetailDialogRef" />
+  </div>
+</template>
+
+<script>
+  import tabMixins from '@/mixins/tableColumnsMixin';
+  import { offsetPage, offsetConfirm, offsetConfirmBatch, offsetVoid } from '@/api/saleManage/finoffset';
+  import offsetDetailDialog from './components/offsetDetailDialog.vue';
+
+  export default {
+    name: 'finOffset',
+    mixins: [tabMixins],
+    components: { offsetDetailDialog },
+    data() {
+      return {
+        cacheKeyUrl: 'eom-finoffset-list',
+        loading: false,
+        selection: [],
+        // 查询条件(结算单编号 / 状态)
+        searchForm: {
+          code: '',
+          status: null
+        },
+        statusOp: [
+          { value: 0, label: '待确认' },
+          { value: 1, label: '可用' },
+          { value: 2, label: '部分冲抵' },
+          { value: 3, label: '已结清' },
+          { value: 4, label: '已到期' },
+          { value: 5, label: '转退款中' },
+          { value: 6, label: '已退款' },
+          { value: 7, label: '已作废' }
+        ],
+        directionOp: [
+          { value: 1, label: '贷向结转' },
+          { value: 2, label: '借向结转' }
+        ],
+        bizTypeOp: [
+          { value: 1, label: '销售' },
+          { value: 2, label: '采购' }
+        ],
+        columns: [
+          {
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            align: 'center',
+            selectable: (row) => row.status === 0
+          },
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            fixed: 'left'
+          },
+          {
+            prop: 'code',
+            label: '结算单编号',
+            align: 'center',
+            slot: 'code',
+            showOverflowTooltip: true,
+            minWidth: 180
+          },
+          {
+            prop: 'bizType',
+            label: '业务类型',
+            align: 'center',
+            minWidth: 90,
+            formatter: (_row, _col, val) => this.bizTypeOp.find((i) => i.value === val)?.label || ''
+          },
+          {
+            prop: 'direction',
+            label: '结转方向',
+            align: 'center',
+            minWidth: 110,
+            formatter: (_row, _col, val) => this.directionOp.find((i) => i.value === val)?.label || ''
+          },
+          {
+            prop: 'carryAmt',
+            label: '结转金额',
+            align: 'right',
+            minWidth: 120
+          },
+          {
+            prop: 'remainAmt',
+            label: '剩余可用',
+            align: 'right',
+            minWidth: 120
+          },
+          {
+            prop: 'status',
+            label: '状态',
+            align: 'center',
+            minWidth: 100,
+            formatter: (_row, _col, val) => this.statusOp.find((i) => i.value === val)?.label || ''
+          },
+          {
+            prop: 'effectiveDate',
+            label: '生效日期',
+            align: 'center',
+            minWidth: 110,
+            formatter: (_row, _col, val) => (val ? String(val).slice(0, 10) : '')
+          },
+          {
+            prop: 'expireDate',
+            label: '有效期至',
+            align: 'center',
+            minWidth: 110,
+            formatter: (_row, _col, val) => (val ? String(val).slice(0, 10) : '')
+          },
+          {
+            prop: 'sourceNo',
+            label: '来源异常编号',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 150
+          },
+          {
+            prop: 'remark',
+            label: '异常说明',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 150
+          },
+          {
+            prop: 'createTime',
+            label: '创建时间',
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 130,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            fixed: 'right'
+          }
+        ]
+      };
+    },
+    methods: {
+      datasource({ page, limit, where }) {
+        return offsetPage({
+          pageNum: page,
+          size: limit,
+          code: this.searchForm.code || undefined,
+          status: this.searchForm.status == null ? undefined : this.searchForm.status,
+          ...where
+        });
+      },
+      reload(where) {
+        this.$refs.table.reload({ page: 1, where });
+      },
+      resetSearch() {
+        this.searchForm.code = '';
+        this.searchForm.status = null;
+        this.reload();
+      },
+      openDetail(row) {
+        this.$refs.offsetDetailDialogRef.open(row);
+      },
+      confirmOne(row) {
+        this.$confirm(`确定确认结算单[${row.code}]生效吗?`, '提示', { type: 'warning' })
+          .then(async () => {
+            await offsetConfirm(row.id);
+            this.$message.success('确认成功');
+            this.reload();
+          })
+          .catch(() => {});
+      },
+      confirmBatch() {
+        const ids = this.selection.map((r) => r.id);
+        this.$confirm(`确定批量确认选中的 ${ids.length} 张结算单吗?`, '提示', { type: 'warning' })
+          .then(async () => {
+            await offsetConfirmBatch(ids);
+            this.$message.success('批量确认完成');
+            this.reload();
+          })
+          .catch(() => {});
+      },
+      voidOne(row) {
+        this.$confirm(`确定作废结算单[${row.code}]吗?作废后余额清零、关联异常退回待处置。`, '提示', { type: 'warning' })
+          .then(async () => {
+            await offsetVoid(row.id);
+            this.$message.success('作废成功');
+            this.reload();
+          })
+          .catch(() => {});
+      },
+      /**
+       * 处理外部跳转带来的 code 参数(异常列表「处置单据号」链接)。
+       * 有 code 时回填查询条件并只显示该结算单,同时自动打开详情。
+       */
+      async applyRouteQuery() {
+        const code = this.$route && this.$route.query && this.$route.query.code;
+        if (!code) return;
+        this.searchForm.code = code;
+        this.reload();
+        try {
+          const res = await offsetPage({ pageNum: 1, size: 1, code });
+          const row = res && res.list && res.list[0];
+          if (row) {
+            this.openDetail(row);
+          }
+        } catch (e) {
+          // 查询失败不阻断列表展示
+        }
+      }
+    },
+    mounted() {
+      // 需在 mounted 中执行:applyRouteQuery 会调用表格 reload,此时 $refs.table 才可用
+      this.applyRouteQuery();
+    },
+    watch: {
+      // 支持同一页面内再次点击链接(query 变化)时刷新
+      '$route.query.code'(val) {
+        if (val) {
+          this.searchForm.code = val;
+          this.reload();
+        }
+      }
+    }
+  };
+</script>

+ 165 - 0
src/views/financialManage/offsetDetail/index.vue

@@ -0,0 +1,165 @@
+<template>
+  <div class="ele-body">
+    <el-card shadow="never" v-loading="loading">
+      <!-- 搜索区 -->
+      <el-form :inline="true" size="small" class="offset-search" @submit.native.prevent>
+        <el-form-item label="流水编号">
+          <el-input
+            v-model="searchForm.code"
+            placeholder="请输入流水编号"
+            clearable
+            style="width: 220px"
+            @keyup.enter.native="reload()"
+          />
+        </el-form-item>
+        <el-form-item label="状态">
+          <el-select v-model="searchForm.status" placeholder="全部" clearable style="width: 140px">
+            <el-option
+              v-for="item in statusOp"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" icon="el-icon-search" @click="reload()">查询</el-button>
+          <el-button icon="el-icon-refresh-right" @click="resetSearch">重置</el-button>
+        </el-form-item>
+      </el-form>
+
+      <ele-pro-table
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        height="calc(100vh - 300px)"
+        full-height="calc(100vh - 116px)"
+        tool-class="ele-toolbar-form"
+        :cache-key="cacheKeyUrl"
+        @header-dragend="handleHeaderDragend"
+      >
+        <template v-slot:code="{ row }">
+          <span>{{ row.code }}</span>
+        </template>
+      </ele-pro-table>
+    </el-card>
+  </div>
+</template>
+
+<script>
+  import tabMixins from '@/mixins/tableColumnsMixin';
+  import { offsetDetailPage } from '@/api/saleManage/finoffset';
+
+  export default {
+    name: 'offsetDetail',
+    mixins: [tabMixins],
+    data() {
+      return {
+        cacheKeyUrl: 'eom-finoffset-detail-list',
+        loading: false,
+        // 查询条件(流水编号 / 状态)
+        searchForm: {
+          code: '',
+          status: null
+        },
+        statusOp: [
+          { value: 0, label: '待生效' },
+          { value: 1, label: '生效' },
+          { value: 2, label: '红冲' }
+        ],
+        columns: [
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            fixed: 'left'
+          },
+          {
+            prop: 'code',
+            label: '流水编号',
+            align: 'center',
+            slot: 'code',
+            showOverflowTooltip: true,
+            minWidth: 180
+          },
+          {
+            prop: 'offsetCode',
+            label: '结算单编号',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 180
+          },
+          {
+            prop: 'targetStatementNo',
+            label: '目标对账单编号',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 180
+          },
+          {
+            prop: 'writeoffAmt',
+            label: '核销金额',
+            align: 'right',
+            minWidth: 120
+          },
+          {
+            prop: 'status',
+            label: '状态',
+            align: 'center',
+            minWidth: 100,
+            formatter: (_row, _col, val) => this.statusOp.find((i) => i.value === val)?.label || ''
+          },
+          {
+            prop: 'writeoffTime',
+            label: '核销时间',
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'createTime',
+            label: '创建时间',
+            align: 'center',
+            minWidth: 110
+          }
+        ]
+      };
+    },
+    methods: {
+      datasource({ page, limit, where }) {
+        return offsetDetailPage({
+          pageNum: page,
+          size: limit,
+          code: this.searchForm.code || undefined,
+          status: this.searchForm.status == null ? undefined : this.searchForm.status,
+          ...where
+        });
+      },
+      reload(where) {
+        this.$refs.table.reload({ page: 1, where });
+      },
+      resetSearch() {
+        this.searchForm.code = '';
+        this.searchForm.status = null;
+        this.reload();
+      }
+    },
+    mounted() {
+      // 异常列表「处置单据号」跳转:带上流水编号(mounted 后 $refs.table 才可用)
+      const code = this.$route && this.$route.query && this.$route.query.code;
+      if (code) {
+        this.searchForm.code = code;
+        this.reload();
+      }
+    },
+    watch: {
+      '$route.query.code'(val) {
+        if (val) {
+          this.searchForm.code = val;
+          this.reload();
+        }
+      }
+    }
+  };
+</script>

+ 128 - 0
src/views/financialManage/offsetLedger/index.vue

@@ -0,0 +1,128 @@
+<template>
+  <div class="ele-body">
+    <el-card shadow="never" v-loading="loading">
+      <div class="ele-border-lighter form-content" style="padding: 10px 16px; margin-bottom: 12px;">
+        <el-alert
+          v-if="expiringCount > 0"
+          type="warning"
+          :closable="false"
+          show-icon
+          :title="`有 ${expiringCount} 个往来单位存在 30 天内到期的冲抵余额,请及时处理`"
+        />
+      </div>
+      <ele-pro-table
+        ref="table"
+        :columns="columns"
+        :datasource="ledgerList"
+        :need-page="false"
+        height="calc(100vh - 300px)"
+        :cache-key="cacheKeyUrl"
+        @header-dragend="handleHeaderDragend"
+      >
+        <template v-slot:earliestExpireDate="{ row }">
+          <span :class="{ 'expire-warn': isExpiring(row.earliestExpireDate) }">
+            {{ formatDate(row.earliestExpireDate) }}
+            <el-tag v-if="isExpiring(row.earliestExpireDate)" size="mini" type="warning">即将到期</el-tag>
+          </span>
+        </template>
+      </ele-pro-table>
+    </el-card>
+  </div>
+</template>
+
+<script>
+  import tabMixins from '@/mixins/tableColumnsMixin';
+  import { offsetLedger } from '@/api/saleManage/finoffset';
+
+  export default {
+    name: 'offsetLedger',
+    mixins: [tabMixins],
+    data() {
+      return {
+        cacheKeyUrl: 'eom-finoffset-ledger',
+        loading: false,
+        ledgerList: [],
+        columns: [
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            fixed: 'left'
+          },
+          {
+            prop: 'contactId',
+            label: '往来单位ID',
+            align: 'center',
+            minWidth: 120
+          },
+          {
+            prop: 'currency',
+            label: '币种',
+            align: 'center',
+            minWidth: 90,
+            formatter: (_row, _col, val) => val || 'CNY'
+          },
+          {
+            prop: 'carryTotalAmt',
+            label: '累计结转金额',
+            align: 'right',
+            minWidth: 140
+          },
+          {
+            prop: 'remainTotalAmt',
+            label: '剩余可用金额',
+            align: 'right',
+            minWidth: 140
+          },
+          {
+            prop: 'availableCount',
+            label: '可用笔数',
+            align: 'center',
+            minWidth: 100
+          },
+          {
+            prop: 'earliestExpireDate',
+            label: '最早到期日',
+            align: 'center',
+            minWidth: 160,
+            slot: 'earliestExpireDate'
+          }
+        ]
+      };
+    },
+    computed: {
+      expiringCount() {
+        return this.ledgerList.filter((r) => this.isExpiring(r.earliestExpireDate)).length;
+      }
+    },
+    methods: {
+      async loadData() {
+        this.loading = true;
+        try {
+          this.ledgerList = (await offsetLedger()) || [];
+        } finally {
+          this.loading = false;
+        }
+      },
+      formatDate(val) {
+        return val ? String(val).slice(0, 10) : '-';
+      },
+      isExpiring(val) {
+        if (!val) return false;
+        const days = (new Date(String(val).slice(0, 10)).getTime() - Date.now()) / 86400000;
+        return days >= 0 && days <= 30;
+      }
+    },
+    created() {
+      this.loadData();
+    }
+  };
+</script>
+
+<style scoped>
+  .expire-warn {
+    color: #e6a23c;
+  }
+</style>

+ 69 - 0
src/views/financialManage/offsetParam/index.vue

@@ -0,0 +1,69 @@
+<template>
+  <div class="ele-body">
+    <el-card shadow="never" v-loading="loading">
+      <el-alert
+        type="info"
+        :closable="false"
+        show-icon
+        title="冲抵下期相关参数请在「系统参数管理」中维护(模块编码 eom_),本页仅作只读展示。"
+        style="margin-bottom: 16px;"
+      />
+      <el-table :data="paramList" border size="medium">
+        <el-table-column prop="code" label="参数编码" min-width="200" />
+        <el-table-column prop="name" label="参数名称" min-width="180" />
+        <el-table-column prop="value" label="当前值" width="120" align="center">
+          <template slot-scope="scope">
+            <el-tag v-if="scope.row.code === 'offset_debit_enable'" :type="scope.row.value === '1' ? 'success' : 'info'">
+              {{ scope.row.value === '1' ? '开启' : '关闭' }}
+            </el-tag>
+            <span v-else>{{ scope.row.value || '(未配置)' }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column prop="remark" label="说明" min-width="260" show-overflow-tooltip />
+      </el-table>
+    </el-card>
+  </div>
+</template>
+
+<script>
+  import { parameterGetByCode } from '@/api/main';
+
+  export default {
+    name: 'offsetParam',
+    data() {
+      return {
+        loading: false,
+        paramList: []
+      };
+    },
+    methods: {
+      async loadData() {
+        this.loading = true;
+        const defs = [
+          { code: 'offset_expire_months', name: '冲抵结转有效期(月)', remark: '结算单确认生效后,有效期至 = 生效日 + 该月数;未配置默认 6 个月' },
+          { code: 'offset_writeoff_mode', name: '冲抵模式', remark: 'AUTO 自动冲抵(FIFO)/ MANUAL 手动冲抵' },
+          { code: 'offset_debit_enable', name: '借向结转开关', remark: '1 开启 / 0 关闭;关闭时禁止选择借向结转' },
+          { code: 'offset_tolerance_amt', name: '冲抵容差金额阈值', remark: '冲抵差异在容差金额内自动平账' },
+          { code: 'offset_tolerance_rate', name: '冲抵容差比例阈值', remark: '冲抵差异在容差比例内自动平账' }
+        ];
+        try {
+          this.paramList = await Promise.all(
+            defs.map(async (d) => {
+              try {
+                const res = await parameterGetByCode({ code: d.code });
+                return { code: d.code, name: d.name, value: res && res.value, remark: d.remark };
+              } catch (e) {
+                return { code: d.code, name: d.name, value: null, remark: d.remark };
+              }
+            })
+          );
+        } finally {
+          this.loading = false;
+        }
+      }
+    },
+    created() {
+      this.loadData();
+    }
+  };
+</script>

+ 115 - 2
src/views/financialManage/payableManage/components/paymentDialog1.vue

@@ -11,6 +11,26 @@
     :maxable="true"
     :resizable="true"
   >
+    <!-- 对账异常来源(10/11):没有产品清单/对账明细,付款界面参考【预收管理-确收】按行录入付款信息 -->
+    <template v-if="isExceptionSource">
+      <div style="margin: 10px 0; font-size: 14px; color: #606266;">
+        <span>历史已付金额:{{ row.paidTotalPrice || 0 }} 元</span>
+        <span style="margin-left: 20px;">未付金额:{{ unpaidAmount }} 元</span>
+      </div>
+      <collect-table-form
+        ref="collectTableFormRef"
+        :form.sync="collectForm"
+        :total-price="selectedPayableAmount"
+        total-label="应付金额"
+        title="付款详情"
+        date-label="付款时间"
+        amount-label="已付金额"
+        received-label="已付金额"
+        unreceived-label="未付金额"
+        record-name="付款记录"
+      ></collect-table-form>
+    </template>
+    <template v-else>
     <div style="margin: 10px 0; font-size: 14px; color: #606266;">
       <span>应付金额:{{ selectedPayableAmount }} 元</span>
       <span style="margin-left: 20px;">本次付款金额:{{ paidAmount }} 元</span>
@@ -109,6 +129,7 @@
         </template>
       </ele-pro-table>
     </el-form>
+    </template>
 
     <div slot="footer">
       <el-button type="primary" @click="save()">保存</el-button>
@@ -120,11 +141,12 @@
 import { pricingWayList } from '@/enum/dict.js';
 import { finPayableSaveSingleDetailAPI, getFinPayableInfoAPI } from "@/api/financialManage/payableManage";
 import tabMixins from '@/mixins/tableColumnsMixin';
+import collectTableForm from '@/BIZComponents/collectTableForm/index.vue';
 
 export default {
   mixins: [tabMixins],
   name: "paymentDialog1",
-  components: {},
+  components: { collectTableForm },
   props: {
     paymentDialogFlag: {
       type: Boolean,
@@ -135,6 +157,11 @@ export default {
     isView() {
       return this.dialogType === 'view';
     },
+    // 来源类型为对账异常(10销售订单-对账异常 / 11采购订单-对账异常):
+    // 该类应付由异常处置自动生成,产品清单与对账明细允许为空,付款界面参考预收管理-确收录入
+    isExceptionSource() {
+      return [10, 11].includes(Number(this.sourceTypeValue));
+    },
     // 应付金额 = 接口下发的 row.payableTotalPrice
     selectedPayableAmount() {
       return this.row.payableTotalPrice || 0;
@@ -342,6 +369,12 @@ export default {
       title: '',
       loading: false,
       info: {},
+      // 来源类型(接口下发,兜底列表行):10/11 为对账异常来源
+      sourceTypeValue: '',
+      // 对账异常来源的付款记录表单(参考预收管理-确收)
+      collectForm: {
+        tableData: []
+      },
       form: {
         id: '',
         queryDimension: 1,
@@ -383,7 +416,13 @@ export default {
     // 获取详情
     async getInfo(id) {
       const data = await getFinPayableInfoAPI(id);
-      this.datasource = Array.isArray(data) ? data : (data?.productList || []);
+      // 来源类型:接口下发优先,兜底列表行数据
+      this.sourceTypeValue =
+        data?.sourceType != null
+          ? data.sourceType
+          : this.row.sourceType != null
+          ? this.row.sourceType
+          : '';
       // 把接口返回的已付/未付金额回填到 row,供顶部汇总和表单展示
       this.row = {
         ...this.row,
@@ -399,6 +438,23 @@ export default {
         files: data?.files || [],
         remark: data?.remark || ''
       };
+      // 对账异常来源:没有产品清单/对账明细,按预收确认方式录入付款记录
+      if (this.isExceptionSource) {
+        this.datasource = [];
+        this.collectForm = {
+          tableData: [
+            {
+              receivedDate: '',
+              receivedTotalPrice: '',
+              paymentType: '',
+              files: [],
+              remark: ''
+            }
+          ]
+        };
+        return;
+      }
+      this.datasource = Array.isArray(data) ? data : data?.productList || [];
     },
 
     // 构建单行派生字段
@@ -555,6 +611,10 @@ export default {
     },
 
     async save() {
+      // 对账异常来源:按【预收管理-确收】方式逐行保存付款记录(无产品明细)
+      if (this.isExceptionSource) {
+        return this.saveExceptionPayment();
+      }
       // 1. 校验付款信息表单
       const formValid = await new Promise((resolve) => {
         this.$refs.form.validate((valid) => resolve(valid));
@@ -606,6 +666,59 @@ export default {
         });
     },
 
+    // 对账异常来源付款保存:参考【预收管理-确收】,按行录入付款时间/已付金额/支付类型/附件/备注
+    async saveExceptionPayment() {
+      const formRef = this.$refs.collectTableFormRef;
+      if (!formRef) {
+        return this.$message.warning('付款信息加载失败,请重新打开');
+      }
+      const valid = await formRef.validate().catch(() => false);
+      if (!valid) return;
+      const tableData = this.collectForm.tableData || [];
+      if (!tableData.length) {
+        return this.$message.warning('请至少添加一条付款记录');
+      }
+      // 本次付款金额合计不能大于历史未付金额(用「分」做整数比较,避开浮点精度)
+      const totalAmount = tableData.reduce(
+        (pre, item) => pre + (+item.receivedTotalPrice || 0),
+        0
+      );
+      const totalCents = Math.round(totalAmount * 100);
+      const unpaidCents = Math.round((+this.unpaidAmount || 0) * 100);
+      if (totalCents > unpaidCents) {
+        return this.$message.warning(
+          `本次付款金额之和(${totalAmount.toFixed(2)} 元)不能大于未付金额(${this.unpaidAmount} 元)`
+        );
+      }
+      this.loading = true;
+      try {
+        // 逐条提交,避免并发重算应付已付/未付金额互相覆盖
+        for (const item of tableData) {
+          await finPayableSaveSingleDetailAPI({
+            payableId: this.row.id,
+            payableCode: this.row.code,
+            paidDate: item.receivedDate,
+            paidTotalPrice: +item.receivedTotalPrice || 0,
+            paymentType:
+              item.paymentType === '' || item.paymentType == null
+                ? null
+                : Number(item.paymentType),
+            files: item.files || [],
+            remark: item.remark || '',
+            // 对账异常来源应付没有产品清单
+            productList: []
+          });
+        }
+        this.$message.success('付款成功');
+        this.cancel();
+        this.done();
+      } catch (error) {
+        // 错误提示已由请求拦截器统一处理
+      } finally {
+        this.loading = false;
+      }
+    },
+
     // 刷新主列表数据
     done() {
       this.$emit('reload');

+ 17 - 5
src/views/financialManage/receivableManage/components/addReceivableDialog.vue

@@ -386,6 +386,11 @@
         if (!this.isManual) return options;
         return options.filter((item) => item.value === manualReceivableSourceType);
       },
+      // 来源类型为对账异常(10销售订单-对账异常 / 11采购订单-对账异常):
+      // 应收单由异常处置自动生成,允许产品清单与对账明细为空
+      isExceptionSource() {
+        return [10, 11].includes(Number(this.dataForm.sourceType));
+      },
       // 无来源应收没有源单带出客户,客户、款项类型必须手工填
       formRules() {
         if (!this.isManual) return this.rules;
@@ -546,8 +551,9 @@
         } else if (this.dialogType !== 'add') {
           this.businessId = row.id;
           await this.getInfo(row);
-          // 没有对账单的就是手工新增的(来源类型可能被改成了别的,按有没有对账单判断)
-          if (!this.statReceipt && !this.receivableList.length) {
+          // 只有「来源类型缺失」的历史数据才按有没有对账单兜底判断为手工新增;
+          // 异常列表(10/11)等有明确来源类型的应收允许产品清单/对账明细为空,不能按手工单处理
+          if (!this.dataForm.sourceType && !this.statReceipt && !this.receivableList.length) {
             this.isManual = true;
             this.$nextTick(() => {
               this.$refs.form && this.$refs.form.clearValidate();
@@ -752,7 +758,8 @@
       },
       //保存
       async save(is) {
-        if (!this.isManual && !this.datasource.length)
+        // 对账异常来源的应收没有对账明细,允许为空
+        if (!this.isManual && !this.isExceptionSource && !this.datasource.length)
           return this.$message.warning('暂无对账信息');
 
         if (this.isManual) {
@@ -769,10 +776,15 @@
             }
           }
         }
+        if (this.isExceptionSource) {
+          // 对账异常来源:对账明细、产品清单允许为空,只校验基本信息
+          const valid = await this.$refs.form.validate().catch(() => false);
+          if (!valid) return;
+        }
 
         try {
-          if (!this.isManual) {
-            // 校验明细表与应收信息表单(无来源应收没有这两块)
+          if (!this.isManual && !this.isExceptionSource) {
+            // 校验明细表与应收信息表单(无来源应收、对账异常来源没有这两块数据)
             await this.$refs.accountDetailTableRef.getValidForm();
             await this.$refs.receivableInfoRef.validate();
           }

+ 117 - 9
src/views/financialManage/receivableManage/components/collectionDialog.vue

@@ -11,6 +11,20 @@
     :maxable="true"
     :resizable="true"
   >
+    <!-- 对账异常来源(10/11):没有产品清单/对账明细,收款界面参考【预收管理-确收】按行录入收款信息 -->
+    <template v-if="isExceptionSource">
+      <div style="margin: 10px 0; font-size: 14px; color: #606266;">
+        <span>历史已收金额:{{ row.receivedTotalPrice || 0 }} 元</span>
+        <span style="margin-left: 20px;">未收金额:{{ unreceivedAmount }} 元</span>
+      </div>
+      <collect-table-form
+        ref="collectTableFormRef"
+        :form.sync="collectForm"
+        :total-price="selectedReceivableAmount"
+        total-label="应收金额"
+      ></collect-table-form>
+    </template>
+    <template v-else>
     <div style="margin: 10px 0; font-size: 14px; color: #606266;">
       <span>应收金额:{{ selectedReceivableAmount }} 元</span>
       <span style="margin-left: 20px;">本次收款金额:{{ receivedAmount }} 元</span>
@@ -109,6 +123,7 @@
         </template>
       </ele-pro-table>
     </el-form>
+    </template>
 
     <div slot="footer">
       <el-button type="primary" @click="save()">保存</el-button>
@@ -120,11 +135,12 @@
 import { pricingWayList } from '@/enum/dict.js';
 import { finReceivableSaveAPI, getProductListForReceiptAPI } from "@/api/financialManage/receivableManage";
 import tabMixins from '@/mixins/tableColumnsMixin';
+import collectTableForm from '@/BIZComponents/collectTableForm/index.vue';
 
 export default {
   mixins: [tabMixins],
   name: "collectionDialog",
-  components: {},
+  components: { collectTableForm },
   props: {
     collectionDialogFlag: {
       type: Boolean,
@@ -145,6 +161,11 @@ export default {
     isView() {
       return this.dialogType === 'view';
     },
+    // 来源类型为对账异常(10销售订单-对账异常 / 11采购订单-对账异常):
+    // 该类应收由异常处置自动生成,产品清单与对账明细允许为空,收款界面参考预收管理-确收录入
+    isExceptionSource() {
+      return [10, 11].includes(Number(this.sourceTypeValue));
+    },
     // 应收金额 = 接口下发的 row.receivableTotalPrice
     selectedReceivableAmount() {
       return this.row.receivableTotalPrice || 0;
@@ -352,6 +373,12 @@ export default {
       title: '',
       loading: false,
       info: {},
+      // 来源类型(接口下发,兜底列表行):10/11 为对账异常来源
+      sourceTypeValue: '',
+      // 对账异常来源的收款记录表单(参考预收管理-确收)
+      collectForm: {
+        tableData: []
+      },
       form: {
         id: '',
         queryDimension: 1,
@@ -393,14 +420,13 @@ export default {
     // 获取详情(收款专用接口:仅返回产品列表,不带表单主信息)
     async getInfo(id) {
       const data = await getProductListForReceiptAPI(id);
-      // 新接口只返回产品列表
-      this.datasource = Array.isArray(data) ? data : (data.productList || []);
-      // 明细为空(没有对账明细)时无法勾选收款行,直接拦掉
-      if (!this.datasource.length) {
-        this.$message.warning('该应收没有对账明细,不支持收款');
-        this.cancel();
-        return;
-      }
+      // 来源类型:接口下发优先,兜底列表行数据
+      this.sourceTypeValue =
+        data?.sourceType != null
+          ? data.sourceType
+          : this.row.sourceType != null
+          ? this.row.sourceType
+          : '';
       // 把接口返回的已收/未收金额回填到 row,供顶部汇总和表单展示
       this.row = {
         ...this.row,
@@ -416,6 +442,29 @@ export default {
         files: data?.files || [],
         remark: data?.remark || ''
       };
+      // 对账异常来源:没有产品清单/对账明细,按预收确认方式录入收款记录
+      if (this.isExceptionSource) {
+        this.datasource = [];
+        this.collectForm = {
+          tableData: [
+            {
+              receivedDate: '',
+              receivedTotalPrice: '',
+              paymentType: '',
+              files: [],
+              remark: ''
+            }
+          ]
+        };
+        return;
+      }
+      this.datasource = Array.isArray(data) ? data : data.productList || [];
+      // 明细为空(没有对账明细)时无法勾选收款行,直接拦掉
+      if (!this.datasource.length) {
+        this.$message.warning('该应收没有对账明细,不支持收款');
+        this.cancel();
+        return;
+      }
     },
 
     // 构建单行派生字段
@@ -521,6 +570,10 @@ export default {
     },
 
     async save() {
+      // 对账异常来源:按【预收管理-确收】方式逐行保存收款记录(无产品明细)
+      if (this.isExceptionSource) {
+        return this.saveExceptionCollection();
+      }
       // 1. 校验收款信息表单
       const formValid = await new Promise((resolve) => {
         this.$refs.form.validate((valid) => resolve(valid));
@@ -569,6 +622,61 @@ export default {
         });
     },
 
+    // 对账异常来源收款保存:参考【预收管理-确收】,按行录入收款时间/已收金额/支付类型/附件/备注
+    async saveExceptionCollection() {
+      const formRef = this.$refs.collectTableFormRef;
+      if (!formRef) {
+        return this.$message.warning('收款信息加载失败,请重新打开');
+      }
+      const valid = await formRef.validate().catch(() => false);
+      if (!valid) return;
+      const tableData = this.collectForm.tableData || [];
+      if (!tableData.length) {
+        return this.$message.warning('请至少添加一条收款记录');
+      }
+      // 本次收款金额合计不能大于历史未收金额(用「分」做整数比较,避开浮点精度)
+      const totalAmount = tableData.reduce(
+        (pre, item) => pre + (+item.receivedTotalPrice || 0),
+        0
+      );
+      const totalCents = Math.round(totalAmount * 100);
+      const unreceiveCents = Math.round((+this.unreceivedAmount || 0) * 100);
+      if (totalCents > unreceiveCents) {
+        return this.$message.warning(
+          `本次收款金额之和(${totalAmount.toFixed(2)} 元)不能大于未收金额(${
+            this.unreceivedAmount
+          } 元)`
+        );
+      }
+      this.loading = true;
+      try {
+        // 逐条提交,避免并发重算应收已收/未收金额互相覆盖
+        for (const item of tableData) {
+          await finReceivableSaveAPI({
+            receivableId: this.row.id,
+            receivableCode: this.row.code,
+            receivedDate: item.receivedDate,
+            receivedTotalPrice: +item.receivedTotalPrice || 0,
+            paymentType:
+              item.paymentType === '' || item.paymentType == null
+                ? null
+                : Number(item.paymentType),
+            files: item.files || [],
+            remark: item.remark || '',
+            // 对账异常来源应收没有产品清单
+            productList: []
+          });
+        }
+        this.$message.success('收款成功');
+        this.cancel();
+        this.done();
+      } catch (error) {
+        // 错误提示已由请求拦截器统一处理
+      } finally {
+        this.loading = false;
+      }
+    },
+
     // 刷新主列表数据
     done() {
       this.$emit('reload');

+ 8 - 2
src/views/financialManage/receivableManage/components/detailDialog.vue

@@ -233,10 +233,16 @@ import tabMixins from '@/mixins/tableColumnsMixin';
     computed: {
       // 无来源应收:没有对账单,不显示应收信息、对账明细
       isManual() {
-        if (Number(this.dataForm.sourceType) === manualReceivableSourceType) {
+        const sourceType = Number(this.dataForm.sourceType);
+        if (sourceType === manualReceivableSourceType) {
           return true;
         }
-        // 没有对账单也没有应收信息的,是手工新增的(来源类型可能被改成了别的)
+        // 已有明确来源类型(如异常列表 10/11)的应收,即使产品清单/对账单为空也不是手工新增,
+        // 异常列表来源允许产品清单为空,不能按「无来源」处理
+        if (sourceType) {
+          return false;
+        }
+        // 来源类型缺失的历史数据:没有对账单也没有应收信息的,按手工新增处理
         return !this.statReceipt && !this.receivableList.length;
       },
       // 手工新增的应收(无来源)来源类型只有「无来源」

+ 2 - 3
src/views/purchasingManage/purchaseOrder/accountstatement/components/addAccountDialog.vue

@@ -27,7 +27,7 @@
       :dialogType="dialogType"
       statementAdvanceTotalPriceTitle="总对账预付款确付金额"
       columnsTitle="预付款确付金额"
-    ></payables-info>
+    >    </payables-info>
     <headerTitle title="对账明细" style="margin-top: 30px"> </headerTitle>
     <account-detail-table
         ref="accountDetailTableRef"
@@ -265,7 +265,6 @@
           // 校验明细表与应付信息表单
           await this.$refs.accountDetailTableRef.getValidForm();
           await this.$refs.payablesInfoRef.validate();
-
           let api =
             this.dialogType == 'add'
               ? createAccountStatementAPI
@@ -279,7 +278,7 @@
               payablesData.statementAdvanceTotalPrice,
             receivedTotalPrice: payablesData.receivedTotalPrice,
             payableTotalPrice: payablesData.receivedTotalPrice,
-            statementPrepayTotalPrice: payablesData.statementAdvanceTotalPrice,
+            statementPrepayTotalPrice: payablesData.statementAdvanceTotalPrice
           };
           this.statPayable = statPayable;
 

+ 269 - 6
src/views/purchasingManage/purchaseOrder/accountstatement/components/payablesInfo.vue

@@ -143,7 +143,7 @@
               class="ele-block"
               clearable
               :disabled="isView"
-              @change="(val) => updateRowField(scope.$index, 'dealType', val)"
+              @change="(val) => onDealTypeChange(scope.$index, val)"
             >
               <el-option
                 v-for="item in dealTypeOp"
@@ -155,6 +155,72 @@
           </el-form-item>
         </template>
 
+        <template v-slot:offsetMode="scope">
+          <el-form-item
+            :prop="'payablesList.' + scope.$index + '.offsetMode'"
+            :rules="{
+              validator: (rule, value, cb) =>
+                validateOffsetMode(rule, value, cb, scope.row),
+              trigger: 'change'
+            }"
+            label-width="0"
+          >
+            <el-select
+              v-if="scope.row.dealType === 3"
+              v-model="scope.row.offsetMode"
+              placeholder="请选择"
+              class="ele-block"
+              clearable
+              :disabled="isView"
+              @change="(val) => onOffsetModeChange(scope.$index, val)"
+            >
+              <el-option
+                v-for="item in offsetModeOp"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+                :disabled="item.debit && !debitEnabled"
+              />
+            </el-select>
+            <span v-else class="ele-block diff-direction-empty">-</span>
+          </el-form-item>
+        </template>
+
+        <template v-slot:offsetRef="scope">
+          <span v-if="scope.row.dealType === 3 && isWriteoffMode(scope.row.offsetMode)">
+            <el-button
+              type="text"
+              :disabled="isView"
+              @click="openOffsetDialog(scope.$index)"
+            >
+              选择冲抵单据
+            </el-button>
+            <el-tag
+              v-if="(scope.row.writeoffList || []).length"
+              size="mini"
+              type="success"
+            >
+              已选{{ (scope.row.writeoffList || []).length }}张/合计{{ sumWriteoff(scope.row) }}
+            </el-tag>
+          </span>
+          <span v-else>-</span>
+        </template>
+
+        <template v-slot:exceptionRemark="scope">
+          <el-form-item
+            :prop="'payablesList.' + scope.$index + '.exceptionRemark'"
+            label-width="0"
+          >
+            <el-input
+              v-model="scope.row.exceptionRemark"
+              type="textarea"
+              :autosize="{ minRows: 1, maxRows: 3 }"
+              :disabled="isView || !scope.row.dealType"
+              :placeholder="isView ? '' : '选择异常处理方式后可填'"
+            />
+          </el-form-item>
+        </template>
+
         <template v-slot:action="scope">
           <el-link
             v-if="!isView"
@@ -177,6 +243,8 @@
       conditionType="rules"
       @changeParent="changeReceiveTerms"
     ></receiveTermsDialog>
+    <!-- 选择冲抵单据(明细维度核销) -->
+    <offset-order-dialog ref="offsetOrderDialogRef" @confirm="onOffsetConfirm" />
   </div>
 </template>
 
@@ -186,13 +254,15 @@
     transactionMethodsOp,
     paymentStatus
   } from '@/enum/dict';
+  import { parameterGetByCode } from '@/api/main';
   import receiveTermsDialog from '@/views/financialManage/advanceReceipt/components/receiveTermsDialog.vue';
+  import offsetOrderDialog from '@/views/saleManage/saleOrder/accountstatement/components/offsetOrderDialog.vue';
 import tabMixins from '@/mixins/tableColumnsMixin';
 
   export default {
   mixins: [tabMixins],
     name: 'payablesInfo',
-    components: { receiveTermsDialog },
+    components: { receiveTermsDialog, offsetOrderDialog },
     props: {
       dataForm: {
         type: Object,
@@ -218,11 +288,13 @@ import tabMixins from '@/mixins/tableColumnsMixin';
     },
     data() {
       return {
-        // 缓存键变更:强制重建列配置,确保「金额差异」「异常处理」新列在已缓存列设置的页面(详情/审批)也能显示
-        cacheKeyUrl: 'eom-202611161200-purchase-payables-table',
+        // 缓存键变更:强制重建列配置,确保新增列与「差异汇总金额」列名在已缓存列设置的页面也能生效
+        cacheKeyUrl: 'eom-202611172100-purchase-payables-table',
         paymentTypeOp,
         transactionMethodsOp,
         paymentStatusOp: paymentStatus,
+        // 当前打开「选择冲抵单据」弹窗的行索引
+        currentOffsetRowIndex: null,
         // 金额差异异常处理类型(与后端 FinStatDealTypeEnum 一致)
         dealTypeOp: [
           { value: 1, label: '收款' },
@@ -230,6 +302,16 @@ import tabMixins from '@/mixins/tableColumnsMixin';
           { value: 3, label: '冲抵下期' },
           { value: 4, label: '不处置' }
         ],
+        // 冲抵处置方式(与后端 FinOffsetModeEnum 一致)
+        // debit=true 表示借向,受借向开关控制
+        offsetModeOp: [
+          { value: 1, label: '借向结转(应补未补)', debit: true },
+          { value: 2, label: '贷向结转(应退未退)', debit: false },
+          { value: 3, label: '核销冲抵单据(借向)', debit: true },
+          { value: 4, label: '核销冲抵单据(贷向)', debit: false }
+        ],
+        // 借向结转开关(OFFSET_DEBIT_ENABLE=1 时开启,默认关闭)
+        debitEnabled: false,
         rules: {},
         // 本地维护的应付明细,避免每次编辑都同步回父组件
         localList: [],
@@ -341,7 +423,7 @@ import tabMixins from '@/mixins/tableColumnsMixin';
           {
             minWidth: 140,
             prop: 'amountDiff',
-            label: '金额差异',
+            label: '差异汇总金额',
             align: 'center',
             slot: 'amountDiff'
           },
@@ -351,6 +433,27 @@ import tabMixins from '@/mixins/tableColumnsMixin';
             label: '异常处理',
             align: 'center',
             slot: 'dealType'
+          },
+          {
+            minWidth: 180,
+            prop: 'offsetMode',
+            label: '冲抵处置方式',
+            align: 'center',
+            slot: 'offsetMode'
+          },
+          {
+            minWidth: 220,
+            prop: 'writeoffList',
+            label: '冲抵单据',
+            align: 'center',
+            slot: 'offsetRef'
+          },
+          {
+            minWidth: 160,
+            prop: 'exceptionRemark',
+            label: '异常说明',
+            align: 'center',
+            slot: 'exceptionRemark'
           }
         ]
       };
@@ -543,6 +646,97 @@ import tabMixins from '@/mixins/tableColumnsMixin';
           callback();
         }
       },
+      // 处置类型切换:非冲抵下期时清空冲抵处置方式与冲抵明细
+      onDealTypeChange(index, val) {
+        this.updateRowField(index, 'dealType', val);
+        if (val !== 3) {
+          this.updateRowField(index, 'offsetMode', null);
+          this.updateRowField(index, 'writeoffList', []);
+        }
+      },
+      // 冲抵处置方式切换:从核销模式切走时清空已选冲抵单据
+      onOffsetModeChange(index, val) {
+        this.updateRowField(index, 'offsetMode', val);
+        if (!this.isWriteoffMode(val)) {
+          this.updateRowField(index, 'writeoffList', []);
+        }
+      },
+      // 是否核销模式(3核销借向 / 4核销贷向)
+      isWriteoffMode(mode) {
+        return mode === 3 || mode === 4;
+      },
+      // 冲抵处置方式校验:仅处置类型=冲抵下期(3)时必填
+      validateOffsetMode(rule, value, callback, row) {
+        if (
+          row.dealType === 3 &&
+          (value === null || value === undefined || value === '')
+        ) {
+          callback(new Error('处置类型为冲抵下期,请选择冲抵处置方式'));
+        } else {
+          callback();
+        }
+      },
+      // 已选冲抵金额合计
+      sumWriteoff(row) {
+        const sum = (row.writeoffList || []).reduce(
+          (pre, cur) => pre + (+cur.writeoffAmt || 0),
+          0
+        );
+        return Math.round(sum * 100) / 100;
+      },
+      // 打开「选择冲抵单据」弹窗
+      openOffsetDialog(index) {
+        const row = this.localList[index];
+        if (!row) return;
+        if (!row.offsetMode) {
+          this.$message.warning('请先选择冲抵处置方式');
+          return;
+        }
+        // 核销选单按「供应商 + 业务类型」过滤(同一对账单内可跨订单核销同一结算单)
+        const contactId = this.dataForm && this.dataForm.contactId;
+        if (!contactId) {
+          this.$message.warning('当前对账单缺少供应商信息,无法选择冲抵单据');
+          return;
+        }
+        this.currentOffsetRowIndex = index;
+        // 核销借向(3)->direction=2;核销贷向(4)->direction=1
+        const direction = row.offsetMode === 3 ? 2 : 1;
+        this.$refs.offsetOrderDialogRef.open({
+          direction,
+          contactId,
+          bizType: 2,
+          diffAmount: Math.abs(+row.amountDiff || 0),
+          selected: row.writeoffList || [],
+          // 本单内其他明细已占用(排除当前行),用于计算「本期可用」并做单内超发判断
+          occupiedMap: this.buildOccupiedMap(index)
+        });
+      },
+      /**
+       * 汇总本对账单内「其他明细」已占用的结算单金额(排除当前编辑行)。
+       * @param {Number} excludeIndex 当前编辑行索引
+       * @return {Object} offsetId -> 已占用金额
+       */
+      buildOccupiedMap(excludeIndex) {
+        const map = {};
+        this.localList.forEach((row, idx) => {
+          if (idx === excludeIndex) return;
+          (row.writeoffList || []).forEach((w) => {
+            if (!w.offsetId) return;
+            const key = String(w.offsetId);
+            map[key] = (map[key] || 0) + (+w.writeoffAmt || 0);
+          });
+        });
+        Object.keys(map).forEach((k) => {
+          map[k] = Math.round(map[k] * 100) / 100;
+        });
+        return map;
+      },
+      // 弹窗确认回调:写回本行冲抵明细
+      onOffsetConfirm(list) {
+        const index = this.currentOffsetRowIndex;
+        if (index == null) return;
+        this.updateRowField(index, 'writeoffList', list || []);
+      },
       // 对账明细按采购订单编码汇总的金额差异 → 未手工覆盖的行自动填默认值
       syncAmountDiff(summaryMap) {
         const map = summaryMap || {};
@@ -610,10 +804,79 @@ import tabMixins from '@/mixins/tableColumnsMixin';
             promises.push(this.$refs.tableForm.validate());
           }
           Promise.all(promises)
-            .then(() => resolve(true))
+            .then(() => {
+              // 核销模式:本次使用金额合计必须等于本条差异金额
+              const err = this.validateWriteoffSum();
+              if (err) {
+                this.$message.error(err);
+                reject(false);
+                return;
+              }
+              resolve(true);
+            })
             .catch(() => reject(false));
         });
+      },
+      // 核销模式金额合计校验,返回错误信息(null 表示通过)
+      validateWriteoffSum() {
+        for (const row of this.localList) {
+          if (row.dealType !== 3 || !this.isWriteoffMode(row.offsetMode)) {
+            continue;
+          }
+          const diff = Math.abs(+row.amountDiff || 0);
+          const list = row.writeoffList || [];
+          if (!list.length) {
+            return `采购订单[${row.purchaseCode || ''}]处置方式为核销冲抵单据,请选择冲抵单据`;
+          }
+          const sum = Math.round(
+            list.reduce((pre, cur) => pre + (+cur.writeoffAmt || 0), 0) * 100
+          ) / 100;
+          if (sum !== Math.round(diff * 100) / 100) {
+            return `采购订单[${row.purchaseCode || ''}]本次使用金额合计 ${sum} 元与差异金额 ${diff} 元不相等,请调整金额或重新勾选冲抵单据`;
+          }
+        }
+        // 本单内超发校验:同一结算单被多条明细核销时,合计不得超过其剩余可用
+        return this.validateStatementWriteoffTotal();
+      },
+      /**
+       * 本对账单内同一结算单的核销金额合计不得超过剩余可用金额。
+       * 核销选单按供应商维度过滤,故同一结算单可能被本单多条明细分摊使用。
+       * @return {String|null} 错误信息(null 表示通过)
+       */
+      validateStatementWriteoffTotal() {
+        const map = {};
+        this.localList.forEach((row) => {
+          (row.writeoffList || []).forEach((w) => {
+            if (!w.offsetId) return;
+            const key = String(w.offsetId);
+            if (!map[key]) {
+              map[key] = { code: w.offsetCode || '', amt: 0, remain: null };
+            }
+            map[key].amt += +w.writeoffAmt || 0;
+            if (w.remainAmt != null) {
+              map[key].remain = +w.remainAmt;
+            }
+          });
+        });
+        for (const key of Object.keys(map)) {
+          const item = map[key];
+          const total = Math.round(item.amt * 100) / 100;
+          if (item.remain != null && total > item.remain) {
+            return `冲抵结算单[${item.code}]本单核销合计 ${total} 元超过剩余可用金额 ${item.remain} 元,请调整本次使用金额`;
+          }
+        }
+        return null;
       }
+    },
+    mounted() {
+      // 读取借向结转开关(OFFSET_DEBIT_ENABLE=1 时开启,默认关闭)
+      parameterGetByCode({ code: 'offset_debit_enable' })
+        .then((res) => {
+          this.debitEnabled = res && res.value === '1';
+        })
+        .catch(() => {
+          this.debitEnabled = false;
+        });
     }
   };
 </script>

+ 27 - 14
src/views/saleManage/saleOrder/accountstatement/components/accountDetailTable.vue

@@ -298,7 +298,9 @@ import tabMixins from '@/mixins/tableColumnsMixin';
     },
     data() {
       return {
-        cacheKeyUrl: 'eom-202608171423-account-detail-table',
+        // 缓存键变更:强制重建列配置,确保「差异数量/差异金额/处置类型/异常状态/异常说明」
+        // 五列处于最右侧的新列顺序在已缓存列设置的页面(新增、修改、详情)也能生效
+        cacheKeyUrl: 'eom-202611171800-account-detail-table',
         // 当前激活的页签:detail=单据明细(可编辑,提交依据),item=物品明细(只读汇总)
         activeTab: 'detail',
         isTaxRate: 0,
@@ -316,12 +318,23 @@ import tabMixins from '@/mixins/tableColumnsMixin';
     computed: {
       exceptionDetermineOptions() {
         const purchase = this.queryDimension == 3;
+        if (purchase) {
+          return [
+            { value: 1, label: '多收' },
+            { value: 2, label: '少收' },
+            { value: 3, label: '错收' },
+            { value: 5, label: '质量不良' },
+            { value: 6, label: '丢失' },
+            { value: 9, label: '不处置' }
+          ];
+        }
+        // 销售:文案带处置动作说明(仅展示用,value 不变)
         return [
-          { value: 1, label: purchase ? '多收' : '多发' },
-          { value: 2, label: purchase ? '少收' : '少发' },
-          { value: 3, label: purchase ? '错收' : '错发' },
-          { value: 5, label: '质量不良' },
-          { value: 6, label: '丢失' },
+          { value: 1, label: '多发·退回成品仓' },
+          { value: 2, label: '少发·补发' },
+          { value: 3, label: '错发·退回后重发' },
+          { value: 5, label: '质量不良·退回不良品仓' },
+          { value: 6, label: '丢失·报损核销' },
           { value: 9, label: '不处置' }
         ];
       },
@@ -550,19 +563,12 @@ import tabMixins from '@/mixins/tableColumnsMixin';
             slot: 'diffAmount'
           },
           {
-            minWidth: 150,
+            minWidth: 200,
             prop: 'exceptionDetermine',
             label: '处置类型',
             align: 'center',
             slot: 'exceptionDetermine'
           },
-          {
-            minWidth: 100,
-            prop: 'exceptionStatus',
-            label: '异常状态',
-            align: 'center',
-            slot: 'exceptionStatus'
-          },
           {
             minWidth: 180,
             prop: 'exceptionRemark',
@@ -570,6 +576,13 @@ import tabMixins from '@/mixins/tableColumnsMixin';
             align: 'center',
             slot: 'exceptionRemark'
           },
+          {
+            minWidth: 100,
+            prop: 'exceptionStatus',
+            label: '异常状态',
+            align: 'center',
+            slot: 'exceptionStatus'
+          },
         ]
         if(this.$route.path === '/receivableManage' || this.isShowDispatchDate){
           columns = columns.filter((item) => item.prop !== 'productOperateTime');

+ 2 - 2
src/views/saleManage/saleOrder/accountstatement/components/addAccountDialog.vue

@@ -29,7 +29,7 @@
         :dialogType="dialogType"
         @addAdvanceReceipt="addAdvanceReceipt"
         ref="receivableInfoRef"
-      ></receivable-info>
+      >      </receivable-info>
 
       <headerTitle title="对账明细" style="margin-top: 30px"></headerTitle>
       <account-detail-table
@@ -307,7 +307,7 @@
           return this.$message.warning('暂无对账信息');
 
         try {
-          // 校验明细表与应收信息表单
+          // 校验明细表与应收信息表单(含明细维度冲抵金额合计校验)
           await this.$refs.accountDetailTableRef.getValidForm();
           await this.$refs.receivableInfoRef.validate();
 

+ 17 - 6
src/views/saleManage/saleOrder/accountstatement/components/inventoryTable.vue

@@ -227,12 +227,23 @@ export default {
   computed: {
     exceptionDetermineOptions() {
       const purchase = this.type === 'purchase';
+      if (purchase) {
+        return [
+          { value: 1, label: '多收' },
+          { value: 2, label: '少收' },
+          { value: 3, label: '错收' },
+          { value: 5, label: '质量不良' },
+          { value: 6, label: '丢失' },
+          { value: 9, label: '不处置' }
+        ];
+      }
+      // 销售:文案带处置动作说明(仅展示用,value 不变)
       return [
-        { value: 1, label: purchase ? '多收' : '多发' },
-        { value: 2, label: purchase ? '少收' : '少发' },
-        { value: 3, label: purchase ? '错收' : '错发' },
-        { value: 5, label: '质量不良' },
-        { value: 6, label: '丢失' },
+        { value: 1, label: '多发·退回成品仓' },
+        { value: 2, label: '少发·补发' },
+        { value: 3, label: '错发·退回后重发' },
+        { value: 5, label: '质量不良·退回不良品仓' },
+        { value: 6, label: '丢失·报损核销' },
         { value: 9, label: '不处置' }
       ];
     },
@@ -571,7 +582,7 @@ export default {
             slot: 'diffAmount'
           },
           {
-            minWidth: 150,
+            minWidth: 200,
             prop: 'exceptionDetermine',
             label: '处置类型',
             align: 'center',

+ 229 - 0
src/views/saleManage/saleOrder/accountstatement/components/offsetOrderDialog.vue

@@ -0,0 +1,229 @@
+<template>
+  <el-dialog
+    :visible.sync="visible"
+    :title="title"
+    width="980px"
+    append-to-body
+    :close-on-click-modal="false"
+    @closed="onClosed"
+  >
+    <div v-loading="loading">
+      <el-alert
+        type="info"
+        :closable="false"
+        show-icon
+        :title="`需与本条明细差异金额 ${diffAmount} 元一致,已选合计 ${selectedTotalAmt} 元`"
+        style="margin-bottom: 12px;"
+      />
+      <el-table
+        ref="table"
+        :data="tableData"
+        border
+        size="small"
+        max-height="400"
+        row-key="id"
+        @selection-change="handleSelectionChange"
+      >
+        <el-table-column type="selection" width="50" align="center" />
+        <el-table-column prop="code" label="结算单编码" min-width="160" show-overflow-tooltip />
+        <el-table-column prop="bizOrderNo" label="订单编码" min-width="140" show-overflow-tooltip />
+        <el-table-column prop="sourceTypeName" label="来源类型" width="105" align="center" />
+        <el-table-column prop="sourceNo" label="来源单号" min-width="140" show-overflow-tooltip />
+        <el-table-column prop="remainAmt" label="剩余可用" width="100" align="right" />
+        <el-table-column label="本期可用" width="100" align="right">
+          <template slot-scope="scope">{{ scope.row.periodAvailableAmt }}</template>
+        </el-table-column>
+        <el-table-column label="生效日" width="100" align="center">
+          <template slot-scope="scope">{{ formatDate(scope.row.effectiveDate) }}</template>
+        </el-table-column>
+        <el-table-column label="有效期至" width="100" align="center">
+          <template slot-scope="scope">{{ formatDate(scope.row.expireDate) }}</template>
+        </el-table-column>
+        <el-table-column label="本次使用金额" width="140" align="center">
+          <template slot-scope="scope">
+            <el-input-number
+              v-model="scope.row.writeoffAmt"
+              :min="0"
+              :max="+scope.row.periodAvailableAmt || 0"
+              :precision="2"
+              :controls="false"
+              size="small"
+              @change="onAmountChange(scope.row)"
+            />
+          </template>
+        </el-table-column>
+      </el-table>
+    </div>
+    <div slot="footer">
+      <el-button @click="visible = false">取消</el-button>
+      <el-button type="primary" @click="confirm">确认</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+  import { offsetAvailableByContact } from '@/api/saleManage/finoffset';
+
+  const SOURCE_TYPE_MAP = {
+    1: '对账异常',
+    2: '返利结算单',
+    3: '索赔单',
+    4: '预收单',
+    5: '红字发票',
+    6: '退货单'
+  };
+
+  export default {
+    name: 'offsetOrderDialog',
+    data() {
+      return {
+        visible: false,
+        loading: false,
+        title: '选择冲抵单据',
+        tableData: [],
+        selection: [],
+        // 上下文
+        direction: null,
+        contactId: null,
+        bizType: 1,
+        diffAmount: 0,
+        // 上一次已勾选的结算单(回显用)
+        initSelected: [],
+        // 本对账单内其他明细已占用:offsetId -> 金额合计
+        occupiedMap: {}
+      };
+    },
+    computed: {
+      selectedTotalAmt() {
+        const sum = this.selection.reduce(
+          (pre, cur) => pre + (+cur.writeoffAmt || 0),
+          0
+        );
+        return Math.round(sum * 100) / 100;
+      }
+    },
+    methods: {
+      /**
+       * 打开弹窗
+       * @param {Object} ctx { direction, contactId, bizType, diffAmount, selected, occupiedMap }
+       */
+      open(ctx) {
+        this.direction = ctx.direction;
+        this.contactId = ctx.contactId;
+        this.bizType = ctx.bizType || 1;
+        this.diffAmount = +ctx.diffAmount || 0;
+        this.initSelected = ctx.selected || [];
+        this.occupiedMap = ctx.occupiedMap || {};
+        this.title =
+          this.direction === 2 ? '选择冲抵单据(借向)' : '选择冲抵单据(贷向)';
+        this.visible = true;
+        this.loadData();
+      },
+      async loadData() {
+        if (!this.contactId) {
+          this.tableData = [];
+          return;
+        }
+        this.loading = true;
+        try {
+          const list = await offsetAvailableByContact({
+            direction: this.direction,
+            contactId: this.contactId,
+            bizType: this.bizType
+          });
+          this.tableData = (list || []).map((row) => {
+            // 本期可用 = 剩余可用 - 本单其他明细已占用
+            const occupied = +(this.occupiedMap[row.id] || 0);
+            const period = Math.max(0, (+row.remainAmt || 0) - occupied);
+            return {
+              ...row,
+              sourceTypeName: SOURCE_TYPE_MAP[row.sourceType] || '',
+              occupiedAmt: occupied,
+              periodAvailableAmt: Math.round(period * 100) / 100,
+              writeoffAmt: 0,
+              _checked: false
+            };
+          });
+          this.applyInitSelected();
+        } catch (e) {
+          this.tableData = [];
+        } finally {
+          this.loading = false;
+        }
+      },
+      // 回显:上一次已勾选的结算单 + 金额
+      applyInitSelected() {
+        const init = this.initSelected || [];
+        if (!init.length) return;
+        this.$nextTick(() => {
+          init.forEach((sel) => {
+            const row = this.tableData.find(
+              (r) => String(r.id) === String(sel.offsetId)
+            );
+            if (row) {
+              row.writeoffAmt = +sel.writeoffAmt || 0;
+              row._checked = true;
+              this.$refs.table && this.$refs.table.toggleRowSelection(row, true);
+            }
+          });
+          this.selection = this.tableData.filter((r) => r._checked);
+        });
+      },
+      handleSelectionChange(rows) {
+        this.selection = rows;
+        this.tableData.forEach((row) => {
+          row._checked = rows.some((r) => r.id === row.id);
+        });
+      },
+      onAmountChange(row) {
+        const max = +row.periodAvailableAmt || 0;
+        if (+row.writeoffAmt > max) {
+          row.writeoffAmt = max;
+          this.$message.warning('本次使用金额不能超过本期可用金额');
+        }
+        // 手动改金额后强制刷新 selection 引用,保证合计实时更新
+        this.selection = this.tableData.filter((r) => r._checked);
+      },
+      confirm() {
+        const rows = this.tableData.filter(
+          (row) => row._checked && +row.writeoffAmt > 0
+        );
+        if (!rows.length) {
+          this.$message.warning('请勾选冲抵单据并填写本次使用金额');
+          return;
+        }
+        // 校验单笔不超过本期可用(已扣除本单其他明细占用)
+        for (const row of rows) {
+          if (+row.writeoffAmt > +row.periodAvailableAmt) {
+            this.$message.error(
+              `结算单[${row.code}]本次使用金额不能超过本期可用金额`
+            );
+            return;
+          }
+        }
+        const list = rows.map((row) => ({
+          offsetId: row.id,
+          offsetCode: row.code,
+          writeoffAmt: +row.writeoffAmt,
+          // 剩余可用:供保存前做本单内超发校验
+          remainAmt: +row.remainAmt || 0,
+          bizType: row.bizType,
+          bizOrderId: row.bizOrderId,
+          bizOrderNo: row.bizOrderNo,
+          direction: row.direction
+        }));
+        this.$emit('confirm', list);
+        this.visible = false;
+      },
+      formatDate(val) {
+        return val ? String(val).slice(0, 10) : '-';
+      },
+      onClosed() {
+        this.tableData = [];
+        this.selection = [];
+        this.initSelected = [];
+        this.occupiedMap = {};
+      }
+    }
+  };
+</script>

+ 271 - 6
src/views/saleManage/saleOrder/accountstatement/components/receivableInfo.vue

@@ -150,7 +150,7 @@
               class="ele-block"
               clearable
               :disabled="isView"
-              @change="(val) => updateRowField(scope.$index, 'dealType', val)"
+              @change="(val) => onDealTypeChange(scope.$index, val)"
             >
               <el-option
                 v-for="item in dealTypeOp"
@@ -162,6 +162,72 @@
           </el-form-item>
         </template>
 
+        <template v-slot:offsetMode="scope">
+          <el-form-item
+            :prop="'receivableList.' + scope.$index + '.offsetMode'"
+            :rules="{
+              validator: (rule, value, cb) =>
+                validateOffsetMode(rule, value, cb, scope.row),
+              trigger: 'change'
+            }"
+            label-width="0"
+          >
+            <el-select
+              v-if="scope.row.dealType === 3"
+              v-model="scope.row.offsetMode"
+              placeholder="请选择"
+              class="ele-block"
+              clearable
+              :disabled="isView"
+              @change="(val) => onOffsetModeChange(scope.$index, val)"
+            >
+              <el-option
+                v-for="item in offsetModeOp"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+                :disabled="item.debit && !debitEnabled"
+              />
+            </el-select>
+            <span v-else class="ele-block diff-direction-empty">-</span>
+          </el-form-item>
+        </template>
+
+        <template v-slot:offsetRef="scope">
+          <span v-if="scope.row.dealType === 3 && isWriteoffMode(scope.row.offsetMode)">
+            <el-button
+              type="text"
+              :disabled="isView"
+              @click="openOffsetDialog(scope.$index)"
+            >
+              选择冲抵单据
+            </el-button>
+            <el-tag
+              v-if="(scope.row.writeoffList || []).length"
+              size="mini"
+              type="success"
+            >
+              已选{{ (scope.row.writeoffList || []).length }}张/合计{{ sumWriteoff(scope.row) }}
+            </el-tag>
+          </span>
+          <span v-else>-</span>
+        </template>
+
+        <template v-slot:exceptionRemark="scope">
+          <el-form-item
+            :prop="'receivableList.' + scope.$index + '.exceptionRemark'"
+            label-width="0"
+          >
+            <el-input
+              v-model="scope.row.exceptionRemark"
+              type="textarea"
+              :autosize="{ minRows: 1, maxRows: 3 }"
+              :disabled="isView || !scope.row.dealType"
+              :placeholder="isView ? '' : '选择异常处理方式后可填'"
+            />
+          </el-form-item>
+        </template>
+
         <template v-slot:action="scope">
           <el-link
             v-if="!isView"
@@ -184,6 +250,8 @@
       conditionType="rules"
       @changeParent="changeReceiveTerms"
     ></receiveTermsDialog>
+    <!-- 选择冲抵单据(明细维度核销) -->
+    <offset-order-dialog ref="offsetOrderDialogRef" @confirm="onOffsetConfirm" />
   </div>
 </template>
 
@@ -193,14 +261,17 @@
     transactionMethodsOp,
     paymentStatus
   } from '@/enum/dict';
+  import { parameterGetByCode } from '@/api/main';
   import receiveTermsDialog from '@/views/financialManage/advanceReceipt/components/receiveTermsDialog.vue';
+  import offsetOrderDialog from './offsetOrderDialog.vue';
 import tabMixins from '@/mixins/tableColumnsMixin';
 
   export default {
   mixins: [tabMixins],
     name: 'receivableInfo',
     components: {
-      receiveTermsDialog
+      receiveTermsDialog,
+      offsetOrderDialog
     },
     props: {
       dataForm: {
@@ -219,8 +290,8 @@ import tabMixins from '@/mixins/tableColumnsMixin';
     },
     data() {
       return {
-        // 缓存键变更:强制重建列配置,确保「金额差异」「异常处理」新列在已缓存列设置的页面(详情/审批)也能显示
-        cacheKeyUrl: 'eom-202611161200-account-receivable-table',
+        // 缓存键变更:强制重建列配置,确保新增列与「差异汇总金额」列名在已缓存列设置的页面也能生效
+        cacheKeyUrl: 'eom-202611172100-account-receivable-table',
         paymentTypeOp,
         transactionMethodsOp,
         paymentStatusOp: paymentStatus,
@@ -231,11 +302,23 @@ import tabMixins from '@/mixins/tableColumnsMixin';
           { value: 3, label: '冲抵下期' },
           { value: 4, label: '不处置' }
         ],
+        // 冲抵处置方式(与后端 FinOffsetModeEnum 一致)
+        // debit=true 表示借向,受借向开关控制
+        offsetModeOp: [
+          { value: 1, label: '借向结转(应补未补)', debit: true },
+          { value: 2, label: '贷向结转(应退未退)', debit: false },
+          { value: 3, label: '核销冲抵单据(借向)', debit: true },
+          { value: 4, label: '核销冲抵单据(贷向)', debit: false }
+        ],
+        // 借向结转开关(OFFSET_DEBIT_ENABLE=1 时开启,默认关闭)
+        debitEnabled: false,
         rules: {},
         // 本地维护的应收明细,避免每次编辑都同步回父组件
         localList: [],
         // 当前打开收款条件选择器的行索引
         currentRowIndex: null,
+        // 当前打开「选择冲抵单据」弹窗的行索引
+        currentOffsetRowIndex: null,
         columns: [
           {
             width: 60,
@@ -329,7 +412,7 @@ import tabMixins from '@/mixins/tableColumnsMixin';
           {
             minWidth: 140,
             prop: 'amountDiff',
-            label: '金额差异',
+            label: '差异汇总金额',
             align: 'center',
             slot: 'amountDiff'
           },
@@ -339,6 +422,27 @@ import tabMixins from '@/mixins/tableColumnsMixin';
             label: '异常处理',
             align: 'center',
             slot: 'dealType'
+          },
+          {
+            minWidth: 180,
+            prop: 'offsetMode',
+            label: '冲抵处置方式',
+            align: 'center',
+            slot: 'offsetMode'
+          },
+          {
+            minWidth: 220,
+            prop: 'writeoffList',
+            label: '冲抵单据',
+            align: 'center',
+            slot: 'offsetRef'
+          },
+          {
+            minWidth: 160,
+            prop: 'exceptionRemark',
+            label: '异常说明',
+            align: 'center',
+            slot: 'exceptionRemark'
           }
         ]
       };
@@ -530,6 +634,98 @@ import tabMixins from '@/mixins/tableColumnsMixin';
           callback();
         }
       },
+      // 处置类型切换:非冲抵下期时清空冲抵处置方式与冲抵明细
+      onDealTypeChange(index, val) {
+        this.updateRowField(index, 'dealType', val);
+        if (val !== 3) {
+          this.updateRowField(index, 'offsetMode', null);
+          this.updateRowField(index, 'writeoffList', []);
+        }
+      },
+      // 冲抵处置方式切换:从核销模式切走时清空已选冲抵单据
+      onOffsetModeChange(index, val) {
+        this.updateRowField(index, 'offsetMode', val);
+        if (!this.isWriteoffMode(val)) {
+          this.updateRowField(index, 'writeoffList', []);
+        }
+      },
+      // 是否核销模式(3核销借向 / 4核销贷向)
+      isWriteoffMode(mode) {
+        return mode === 3 || mode === 4;
+      },
+      // 冲抵处置方式校验:仅处置类型=冲抵下期(3)时必填
+      validateOffsetMode(rule, value, callback, row) {
+        if (
+          row.dealType === 3 &&
+          (value === null || value === undefined || value === '')
+        ) {
+          callback(new Error('处置类型为冲抵下期,请选择冲抵处置方式'));
+        } else {
+          callback();
+        }
+      },
+      // 已选冲抵金额合计
+      sumWriteoff(row) {
+        const sum = (row.writeoffList || []).reduce(
+          (pre, cur) => pre + (+cur.writeoffAmt || 0),
+          0
+        );
+        return Math.round(sum * 100) / 100;
+      },
+      // 打开「选择冲抵单据」弹窗
+      openOffsetDialog(index) {
+        const row = this.localList[index];
+        if (!row) return;
+        if (!row.offsetMode) {
+          this.$message.warning('请先选择冲抵处置方式');
+          return;
+        }
+        // 核销选单按「客户 + 业务类型」过滤(同一对账单内可跨订单核销同一结算单)
+        const contactId = this.dataForm && this.dataForm.contactId;
+        if (!contactId) {
+          this.$message.warning('当前对账单缺少客户信息,无法选择冲抵单据');
+          return;
+        }
+        this.currentOffsetRowIndex = index;
+        // 核销借向(3)->direction=2;核销贷向(4)->direction=1
+        const direction = row.offsetMode === 3 ? 2 : 1;
+        this.$refs.offsetOrderDialogRef.open({
+          direction,
+          contactId,
+          bizType: 1,
+          diffAmount: Math.abs(+row.amountDiff || 0),
+          selected: row.writeoffList || [],
+          // 本单内其他明细已占用(排除当前行),用于计算「本期可用」并做单内超发判断
+          occupiedMap: this.buildOccupiedMap(index)
+        });
+      },
+      /**
+       * 汇总本对账单内「其他明细」已占用的结算单金额(排除当前编辑行)。
+       * @param {Number} excludeIndex 当前编辑行索引
+       * @return {Object} offsetId -> 已占用金额
+       */
+      buildOccupiedMap(excludeIndex) {
+        const map = {};
+        this.localList.forEach((row, idx) => {
+          if (idx === excludeIndex) return;
+          (row.writeoffList || []).forEach((w) => {
+            if (!w.offsetId) return;
+            const key = String(w.offsetId);
+            map[key] = (map[key] || 0) + (+w.writeoffAmt || 0);
+          });
+        });
+        // 统一保留两位小数,避免浮点误差
+        Object.keys(map).forEach((k) => {
+          map[k] = Math.round(map[k] * 100) / 100;
+        });
+        return map;
+      },
+      // 弹窗确认回调:写回本行冲抵明细
+      onOffsetConfirm(list) {
+        const index = this.currentOffsetRowIndex;
+        if (index == null) return;
+        this.updateRowField(index, 'writeoffList', list || []);
+      },
       // 对账明细按销售订单编码汇总的金额差异 → 未手工覆盖的行自动填默认值
       syncAmountDiff(summaryMap) {
         const map = summaryMap || {};
@@ -599,10 +795,79 @@ import tabMixins from '@/mixins/tableColumnsMixin';
             promises.push(this.$refs.tableForm.validate());
           }
           Promise.all(promises)
-            .then(() => resolve(true))
+            .then(() => {
+              // 核销模式:本次使用金额合计必须等于本条差异金额
+              const err = this.validateWriteoffSum();
+              if (err) {
+                this.$message.error(err);
+                reject(false);
+                return;
+              }
+              resolve(true);
+            })
             .catch(() => reject(false));
         });
+      },
+      // 核销模式金额合计校验,返回错误信息(null 表示通过)
+      validateWriteoffSum() {
+        for (const row of this.localList) {
+          if (row.dealType !== 3 || !this.isWriteoffMode(row.offsetMode)) {
+            continue;
+          }
+          const diff = Math.abs(+row.amountDiff || 0);
+          const list = row.writeoffList || [];
+          if (!list.length) {
+            return `销售订单[${row.salesCode || ''}]处置方式为核销冲抵单据,请选择冲抵单据`;
+          }
+          const sum = Math.round(
+            list.reduce((pre, cur) => pre + (+cur.writeoffAmt || 0), 0) * 100
+          ) / 100;
+          if (sum !== Math.round(diff * 100) / 100) {
+            return `销售订单[${row.salesCode || ''}]本次使用金额合计 ${sum} 元与差异金额 ${diff} 元不相等,请调整金额或重新勾选冲抵单据`;
+          }
+        }
+        // 本单内超发校验:同一结算单被多条明细核销时,合计不得超过其剩余可用
+        return this.validateStatementWriteoffTotal();
+      },
+      /**
+       * 本对账单内同一结算单的核销金额合计不得超过剩余可用金额。
+       * 核销选单按客户维度过滤,故同一结算单可能被本单多条明细分摊使用。
+       * @return {String|null} 错误信息(null 表示通过)
+       */
+      validateStatementWriteoffTotal() {
+        const map = {};
+        this.localList.forEach((row) => {
+          (row.writeoffList || []).forEach((w) => {
+            if (!w.offsetId) return;
+            const key = String(w.offsetId);
+            if (!map[key]) {
+              map[key] = { code: w.offsetCode || '', amt: 0, remain: null };
+            }
+            map[key].amt += +w.writeoffAmt || 0;
+            if (w.remainAmt != null) {
+              map[key].remain = +w.remainAmt;
+            }
+          });
+        });
+        for (const key of Object.keys(map)) {
+          const item = map[key];
+          const total = Math.round(item.amt * 100) / 100;
+          if (item.remain != null && total > item.remain) {
+            return `冲抵结算单[${item.code}]本单核销合计 ${total} 元超过剩余可用金额 ${item.remain} 元,请调整本次使用金额`;
+          }
+        }
+        return null;
       }
+    },
+    mounted() {
+      // 读取借向结转开关(OFFSET_DEBIT_ENABLE=1 时开启,默认关闭)
+      parameterGetByCode({ code: 'offset_debit_enable' })
+        .then((res) => {
+          this.debitEnabled = res && res.value === '1';
+        })
+        .catch(() => {
+          this.debitEnabled = false;
+        });
     }
   };
 </script>

+ 41 - 4
src/views/saleManage/saleOrder/exceptionManagement/exceptionList/index.vue

@@ -26,6 +26,18 @@
             {{ row.code }}
           </el-link>
         </template>
+        <!-- 处置单据号:冲抵下期(判定=10)时展示为可跳转链接 -->
+        <template v-slot:disposalDocNo="{ row }">
+          <el-link
+            v-if="row.disposalDocNo && isOffsetDisposalDoc(row)"
+            type="primary"
+            :underline="false"
+            @click="jumpOffsetDoc(row)"
+          >
+            {{ offsetDocLabel(row) }}
+          </el-link>
+          <span v-else>{{ row.disposalDocNo || '--' }}</span>
+        </template>
         <!-- 操作列 -->
         <!-- 表头工具栏 -->
         <template v-slot:toolbar>
@@ -287,7 +299,8 @@
           {
             prop: 'disposalDocNo',
             label: '处置单据号',
-            align: 'center'
+            align: 'center',
+            slot: 'disposalDocNo'
           },
 
           {
@@ -350,8 +363,8 @@
         if (!code) return '--';
         const purchase = String(row.relationType) === '5';
         const map = purchase
-          ? { 1: '多收', 2: '少收', 3: '错收', 4: '损坏', 5: '质量不良', 6: '丢失', 7: '退款', 8: '收款', 9: '不处置' }
-          : { 1: '多发', 2: '少发', 3: '错发', 4: '损坏', 5: '质量不良', 6: '丢失', 7: '退款', 8: '收款', 9: '不处置' };
+          ? { 1: '多收', 2: '少收', 3: '错收', 4: '损坏', 5: '质量不良', 6: '丢失', 7: '退款', 8: '收款', 9: '不处置', 10: '冲抵下期' }
+          : { 1: '多发', 2: '少发', 3: '错发', 4: '损坏', 5: '质量不良', 6: '丢失', 7: '退款', 8: '收款', 9: '不处置', 10: '冲抵下期' };
         return map[code] || code;
       },
       // 处置方式
@@ -369,10 +382,34 @@
           9: '退回不良品仓',
           10: '报损核销',
           11: '生成应付单',
-          12: '生成应收单'
+          12: '生成应收单',
+          13: '生成冲抵结算单',
+          14: '生成冲抵核销流水'
         };
         return map[code] || code;
       },
+      // 是否冲抵下期产生的处置单据(判定=10)
+      isOffsetDisposalDoc(row) {
+        return String(row.exceptionDetermine) === '10';
+      },
+      // 冲抵下期处置单据链接文案:40 结算单 / 41 核销流水
+      offsetDocLabel(row) {
+        if (String(row.disposalDocType) === '41') {
+          return `冲抵下期 → 已生成核销流水 ${row.disposalDocNo}`;
+        }
+        return `冲抵下期 → 已生成结算单 ${row.disposalDocNo}`;
+      },
+      // 跳转冲抵结算单/核销流水详情
+      jumpOffsetDoc(row) {
+        const isWriteoff = String(row.disposalDocType) === '41';
+        const path = isWriteoff
+          ? '/financialManage/offsetDetail'
+          : '/financialManage/finoffset';
+        this.$router.push({
+          path,
+          query: { code: row.disposalDocNo }
+        });
+      },
       /* 表格数据源 */
       datasource({ page, limit, where }) {
         return getList({