sen
2025-12-23 35bc26ac5c83da943fd476235192abddb826eba4
ui/admin-ui3/src/components/GenerateBillDialog/index.vue
@@ -48,28 +48,28 @@
        <h3 class="section-title">账单明细</h3>
      </div>
      <el-table :data="detailList" border stripe height="300px" style="width: 100%">
        <el-table-column prop="systemNo" label="系统编号" width="120" />
        <el-table-column prop="sourceSystem" label="来源系统" width="120">
        <el-table-column prop="systemNo" align="center" label="系统编号" width="140" />
        <el-table-column prop="sourceSystem" align="center" label="来源系统" width="120">
          <template #default="scope">
            {{ dictFormat(sys_system, scope.row.sourceSystem) }}
          </template>
        </el-table-column><!-- sys_system -->
        <el-table-column prop="businessSector" label="业务板块" width="120">
        <el-table-column prop="businessSector" align="center" label="业务板块" width="120">
          <template #default="scope">
            {{ dictFormat(sys_business, scope.row.businessSector) }}
          </template>
        </el-table-column>
        <!-- sys_business -->
        <el-table-column prop="documentType" label="单据类型" width="120">
        <el-table-column prop="documentType" align="center" label="单据类型" width="120">
          <template #default="scope">
            {{ dictFormat(sys_receipts, scope.row.documentType) }}
          </template>
        </el-table-column><!-- sys_receipts -->
        <el-table-column prop="documentNo" label="单据编号" width="150" />
        <el-table-column prop="customerName" label="客户名称" width="150" />
        <el-table-column prop="projectName" label="项目名称" width="150" />
        <el-table-column prop="receivableAmount" label="应收金额" align="right" />
        <el-table-column prop="currency" label="币制" width="100">
        <el-table-column prop="documentNo" align="center" label="单据编号" width="150" />
        <el-table-column prop="customerName" align="center" label="客户名称" width="150" />
        <el-table-column prop="projectName" align="center" label="项目名称" width="150" />
        <el-table-column prop="receivableAmount" align="center" label="应收金额" />
        <el-table-column prop="currency" align="center" label="币制" width="100">
          <template #default="scope">
            {{ dictFormat(sys_currency, scope.row.currency) }}
          </template>
@@ -79,7 +79,7 @@
    <template #footer>
      <el-button @click="cancel">取消</el-button>
      <el-button type="primary" @click="handleConfirm" >确认生成</el-button>
      <el-button type="primary" @click="handleConfirm">确认生成</el-button>
    </template>
  </el-dialog>
</template>
@@ -127,15 +127,49 @@
const open = (data: any, selectionList: any[]) => {
  visible.value = true;
  if (data) {
    if (data) {
      // 假设 data 的结构就是 mainForm 需要的结构
      Object.assign(statistics.value, data);
      // 确保后端返回的明细字段名与此一致
      if (selectionList.length > 0) {
        detailList.value = [...selectionList];
      }
    }
    Object.assign(statistics.value, data);
    if (selectionList && selectionList.length > 0) {
      detailList.value = selectionList.flatMap(item => {
        if (!item.receivableAmountStr) return [item];
        // 1. 拆分多个币种字符串
        const amountParts = item.receivableAmountStr.trim().split(/\s+/);
        return amountParts.map(part => {
          // 2. 正则解析提取数值和币种名称
          // ([\d.]+) 匹配数字和小数点
          // ([\u4e00-\u9fa5]+) 匹配中文字符(币种)
          const match = part.match(/([\d.]+)([\u4e00-\u9fa5]+)/);
          let amount = item.receivableAmount; // 默认值
          let currencyValue = item.currency;   // 默认值
          if (match) {
            amount = parseFloat(match[1]); // 提取的数字
            const currencyName = match[2]; // 提取的币种文字,如 "港币"
            // 3. 根据提取的文字匹配字典中的 Value
            // 假设字典 sys_currency.value: 0 是人民币, 1 是港币 (请根据您实际字典值调整)
            if (currencyName.includes('人民币')) {
              currencyValue = 'RMB'; // 对应字典的人民币value
            } else if (currencyName.includes('港币')) {
              currencyValue = 'HKD'; // 对应字典的港币value
            }
          }
          // 4. 返回新对象,覆盖金额和币制
          return {
            ...item,
            receivableAmount: amount, // 赋值提取的数字
            currency: currencyValue,   // 赋值匹配到的字典ID
            receivableAmountStr: part  // 保持拆分后的文本
          };
        });
      });
    } else {
      detailList.value = [];
    }
  }
};
// 3. 确认生成按钮逻辑