<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="银行编码" prop="bankCode">
        <el-input
          v-model="queryParams.bankCode"
          placeholder="请输入银行编码"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="银行名称" prop="bankName">
        <el-input
          v-model="queryParams.bankName"
          placeholder="请输入银行名称"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品名称" prop="productName">
        <el-input
          v-model="queryParams.productName"
          placeholder="请输入产品名称"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="银行类型" prop="bankType">
        <el-select v-model="queryParams.bankType" placeholder="请选择银行类型" clearable>
          <el-option
            v-for="dict in bank_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="合作状态" prop="cooperationStatus">
        <el-select v-model="queryParams.cooperationStatus" placeholder="请选择合作状态" clearable>
          <el-option label="合作中" value="ACTIVE" />
          <el-option label="暂停合作" value="SUSPENDED" />
          <el-option label="终止合作" value="TERMINATED" />
        </el-select>
      </el-form-item>
      <el-form-item label="风险评级" prop="riskRating">
        <el-select v-model="queryParams.riskRating" placeholder="请选择风险评级" clearable>
          <el-option label="AAA" value="AAA" />
          <el-option label="AA" value="AA" />
          <el-option label="A" value="A" />
          <el-option label="BBB" value="BBB" />
          <el-option label="BB" value="BB" />
          <el-option label="B" value="B" />
        </el-select>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
          <el-option label="正常" value="0" />
          <el-option label="停用" value="1" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="Plus"
          @click="handleAdd"
          v-hasPermi="['credit:bank:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="Edit"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['credit:bank:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="Delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['credit:bank:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['credit:bank:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="bankList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="银行ID" align="center" prop="bankId" width="80" />
      <el-table-column label="银行编码" align="center" prop="bankCode" width="100" />
      <el-table-column label="银行名称" align="center" prop="bankName" show-overflow-tooltip width="150" />
      <el-table-column label="银行类型" align="center" prop="bankType" width="100">
        <template #default="scope">
          <dict-tag :options="bank_type" :value="scope.row.bankType"/>
        </template>
      </el-table-column>
      <el-table-column label="产品名称" align="center" prop="productName" show-overflow-tooltip width="120" />
      <el-table-column label="产品利率" align="center" prop="productInterestRate" width="100">
        <template #default="scope">
          {{ scope.row.productInterestRate ? (scope.row.productInterestRate * 100).toFixed(2) + '%' : '-' }}
        </template>
      </el-table-column>
      <el-table-column label="基准利率" align="center" prop="baseInterestRate" width="100">
        <template #default="scope">
          {{ scope.row.baseInterestRate ? (scope.row.baseInterestRate * 100).toFixed(2) + '%' : '-' }}
        </template>
      </el-table-column>
      <el-table-column label="贷款金额范围" align="center" width="180">
        <template #default="scope">
          <div>
            <div>最低: ¥{{ scope.row.minLoanAmountDecimal ? scope.row.minLoanAmountDecimal.toLocaleString() : '0' }}</div>
            <div>最高: ¥{{ scope.row.maxLoanAmountDecimal ? scope.row.maxLoanAmountDecimal.toLocaleString() : '0' }}</div>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="期限范围(月)" align="center" width="120">
        <template #default="scope">
          <div>
            <div>{{ scope.row.minLoanTermMonths || 0 }}-{{ scope.row.maxLoanTermMonths || 0 }}月</div>
            <div class="text-info">产品: {{ scope.row.productTermMonths || 0 }}月</div>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="风险评级" align="center" prop="riskRating" width="100">
        <template #default="scope">
          <el-tag :type="getRiskRatingType(scope.row.riskRating)">
            {{ scope.row.riskRating }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="合作状态" align="center" prop="cooperationStatus" width="100">
        <template #default="scope">
          <el-tag :type="getCooperationStatusType(scope.row.cooperationStatus)">
            {{ getCooperationStatusLabel(scope.row.cooperationStatus) }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status" width="80">
        <template #default="scope">
          <el-tag :type="scope.row.status === '0' ? 'success' : 'danger'">
            {{ scope.row.status === '0' ? '正常' : '停用' }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="200" fixed="right">
        <template #default="scope">
          <el-button link type="primary" icon="View" @click="handleView(scope.row)" v-hasPermi="['credit:bank:query']">详情</el-button>
          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['credit:bank:edit']">修改</el-button>
          <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['credit:bank:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改银行机构对话框 -->
    <el-dialog :title="title" v-model="open" width="800px" append-to-body>
      <el-form ref="bankRef" :model="form" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="银行编码" prop="bankCode">
              <el-input v-model="form.bankCode" placeholder="请输入银行编码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="银行名称" prop="bankName">
              <el-input v-model="form.bankName" placeholder="请输入银行名称" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="银行类型" prop="bankType">
              <el-select v-model="form.bankType" placeholder="请选择银行类型">
                <el-option
                  v-for="dict in bank_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系人" prop="contactPerson">
              <el-input v-model="form.contactPerson" placeholder="请输入联系人" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="联系电话" prop="contactPhone">
              <el-input v-model="form.contactPhone" placeholder="请输入联系电话" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系邮箱" prop="contactEmail">
              <el-input v-model="form.contactEmail" placeholder="请输入联系邮箱" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="银行地址" prop="bankAddress">
          <el-input v-model="form.bankAddress" type="textarea" placeholder="请输入银行地址" />
        </el-form-item>
        <el-row>
          <el-col :span="8">
            <el-form-item label="产品名称" prop="productName">
              <el-input v-model="form.productName" placeholder="请输入产品名称" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="产品利率" prop="productInterestRate">
              <el-input-number
                v-model="form.productInterestRate"
                :precision="4"
                :step="0.0001"
                :max="1"
                :min="0"
                placeholder="请输入产品利率"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="产品期限(月)" prop="productTermMonths">
              <el-input-number
                v-model="form.productTermMonths"
                :min="1"
                :max="360"
                placeholder="请输入产品期限"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="基准利率" prop="baseInterestRate">
              <el-input-number
                v-model="form.baseInterestRate"
                :precision="4"
                :step="0.0001"
                :max="1"
                :min="0"
                placeholder="请输入基准利率"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="风险评级" prop="riskRating">
              <el-select v-model="form.riskRating" placeholder="请选择风险评级">
                <el-option label="AAA" value="AAA" />
                <el-option label="AA" value="AA" />
                <el-option label="A" value="A" />
                <el-option label="BBB" value="BBB" />
                <el-option label="BB" value="BB" />
                <el-option label="B" value="B" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="最低贷款金额" prop="minLoanAmount">
              <el-input-number
                v-model="form.minLoanAmount"
                :precision="2"
                :step="1000"
                :min="0"
                placeholder="请输入最低贷款金额"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="最高贷款金额" prop="maxLoanAmount">
              <el-input-number
                v-model="form.maxLoanAmount"
                :precision="2"
                :step="10000"
                :min="0"
                placeholder="请输入最高贷款金额"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="最短期限(月)" prop="minLoanTermMonths">
              <el-input-number
                v-model="form.minLoanTermMonths"
                :min="1"
                :max="360"
                placeholder="请输入最短贷款期限"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="最长期限(月)" prop="maxLoanTermMonths">
              <el-input-number
                v-model="form.maxLoanTermMonths"
                :min="1"
                :max="360"
                placeholder="请输入最长贷款期限"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="合作状态" prop="cooperationStatus">
              <el-select v-model="form.cooperationStatus" placeholder="请选择合作状态">
                <el-option label="合作中" value="ACTIVE" />
                <el-option label="暂停合作" value="SUSPENDED" />
                <el-option label="终止合作" value="TERMINATED" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="状态" prop="status">
              <el-radio-group v-model="form.status">
                <el-radio label="0">正常</el-radio>
                <el-radio label="1">停用</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="合作开始日期" prop="cooperationStartDate">
              <el-date-picker
                v-model="form.cooperationStartDate"
                type="date"
                placeholder="选择合作开始日期"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="合作结束日期" prop="cooperationEndDate">
              <el-date-picker
                v-model="form.cooperationEndDate"
                type="date"
                placeholder="选择合作结束日期"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="备注信息" prop="remarks">
          <el-input v-model="form.remarks" type="textarea" placeholder="请输入备注信息" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 银行机构详情对话框 -->
    <el-dialog title="银行机构详情" v-model="detailOpen" width="900px" append-to-body>
      <el-descriptions :column="2" border>
        <el-descriptions-item label="银行ID">{{ detailForm.bankId }}</el-descriptions-item>
        <el-descriptions-item label="银行编码">{{ detailForm.bankCode }}</el-descriptions-item>
        <el-descriptions-item label="银行名称">{{ detailForm.bankName }}</el-descriptions-item>
        <el-descriptions-item label="银行类型">
          <dict-tag :options="bank_type" :value="detailForm.bankType"/>
        </el-descriptions-item>
        <el-descriptions-item label="银行地址" :span="2">{{ detailForm.bankAddress }}</el-descriptions-item>
        
        <!-- 联系信息 -->
        <el-descriptions-item label="联系人">{{ detailForm.contactPerson }}</el-descriptions-item>
        <el-descriptions-item label="联系电话">{{ detailForm.contactPhone }}</el-descriptions-item>
        <el-descriptions-item label="联系邮箱" :span="2">{{ detailForm.contactEmail }}</el-descriptions-item>
        
        <!-- 产品信息 -->
        <el-descriptions-item label="产品名称">{{ detailForm.productName }}</el-descriptions-item>
        <el-descriptions-item label="产品期限">{{ detailForm.productTermMonths }}个月</el-descriptions-item>
        <el-descriptions-item label="产品利率">{{ detailForm.productInterestRate ? (detailForm.productInterestRate * 100).toFixed(2) + '%' : '-' }}</el-descriptions-item>
        <el-descriptions-item label="基准利率">{{ detailForm.baseInterestRate ? (detailForm.baseInterestRate * 100).toFixed(2) + '%' : '-' }}</el-descriptions-item>
        
        <!-- 贷款限额 -->
        <el-descriptions-item label="最低贷款金额">{{ formatCurrency(detailForm.minLoanAmountDecimal) }}</el-descriptions-item>
        <el-descriptions-item label="最高贷款金额">{{ formatCurrency(detailForm.maxLoanAmountDecimal) }}</el-descriptions-item>
        <el-descriptions-item label="最短期限">{{ detailForm.minLoanTermMonths }}个月</el-descriptions-item>
        <el-descriptions-item label="最长期限">{{ detailForm.maxLoanTermMonths }}个月</el-descriptions-item>
        
        <!-- 风险和状态 -->
        <el-descriptions-item label="风险评级">
          <el-tag :type="getRiskRatingType(detailForm.riskRating)">
            {{ detailForm.riskRating }}
          </el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="状态">
          <el-tag :type="detailForm.status === '0' ? 'success' : 'danger'">
            {{ detailForm.status === '0' ? '正常' : '停用' }}
          </el-tag>
        </el-descriptions-item>
        
        <!-- 合作信息 -->
        <el-descriptions-item label="合作状态">
          <el-tag :type="getCooperationStatusType(detailForm.cooperationStatus)">
            {{ getCooperationStatusLabel(detailForm.cooperationStatus) }}
          </el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="创建账户类型">{{ detailForm.creatorAccountType }}</el-descriptions-item>
        <el-descriptions-item label="合作开始日期">{{ parseTime(detailForm.cooperationStartDate, '{y}-{m}-{d}') }}</el-descriptions-item>
        <el-descriptions-item label="合作结束日期">{{ parseTime(detailForm.cooperationEndDate, '{y}-{m}-{d}') }}</el-descriptions-item>
        
        <!-- 备注信息 -->
        <el-descriptions-item label="备注信息" :span="2">{{ detailForm.remark }}</el-descriptions-item>
        <el-descriptions-item label="详细说明" :span="2">{{ detailForm.remarks }}</el-descriptions-item>
        
        <!-- 系统信息 -->
        <el-descriptions-item label="创建人">{{ detailForm.createBy }}</el-descriptions-item>
        <el-descriptions-item label="更新人">{{ detailForm.updateBy || '-' }}</el-descriptions-item>
        <el-descriptions-item label="创建时间">{{ parseTime(detailForm.createTime) }}</el-descriptions-item>
        <el-descriptions-item label="更新时间">{{ parseTime(detailForm.updateTime) }}</el-descriptions-item>
      </el-descriptions>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="detailOpen = false">关 闭</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="BankInstitution">
import { listBankInstitution, getBankInstitution, delBankInstitution, addBankInstitution, updateBankInstitution } from "@/api/digitalCredit/loan/bankInstitution";

const { proxy } = getCurrentInstance();
const { bank_type, sys_normal_disable } = proxy.useDict('bank_type', 'sys_normal_disable');

const bankList = ref([]);
const open = ref(false);
const detailOpen = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");

const data = reactive({
  form: {},
  detailForm: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    bankCode: null,
    bankName: null,
    productName: null,
    bankType: null,
    cooperationStatus: null,
    riskRating: null,
    status: null
  },
  rules: {
    bankCode: [
      { required: true, message: "银行编码不能为空", trigger: "blur" },
      { min: 2, max: 50, message: "银行编码长度必须介于 2 和 50 之间", trigger: "blur" }
    ],
    bankName: [
      { required: true, message: "银行名称不能为空", trigger: "blur" },
      { min: 2, max: 100, message: "银行名称长度必须介于 2 和 100 之间", trigger: "blur" }
    ],
    bankType: [
      { required: true, message: "银行类型不能为空", trigger: "change" }
    ],
    contactPerson: [
      { required: true, message: "联系人不能为空", trigger: "blur" }
    ],
    contactPhone: [
      { required: true, message: "联系电话不能为空", trigger: "blur" },
      { pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }
    ],
    contactEmail: [
      { required: true, message: "联系邮箱不能为空", trigger: "blur" },
      { type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }
    ],
    productName: [
      { required: true, message: "产品名称不能为空", trigger: "blur" },
      { min: 2, max: 100, message: "产品名称长度必须介于 2 和 100 之间", trigger: "blur" }
    ],
    productInterestRate: [
      { required: true, message: "产品利率不能为空", trigger: "blur" }
    ],
    productTermMonths: [
      { required: true, message: "产品期限不能为空", trigger: "blur" }
    ],
    baseInterestRate: [
      { required: true, message: "基准利率不能为空", trigger: "blur" }
    ],
    minLoanAmount: [
      { required: true, message: "最低贷款金额不能为空", trigger: "blur" }
    ],
    maxLoanAmount: [
      { required: true, message: "最高贷款金额不能为空", trigger: "blur" }
    ],
    minLoanTermMonths: [
      { required: true, message: "最短贷款期限不能为空", trigger: "blur" }
    ],
    maxLoanTermMonths: [
      { required: true, message: "最长贷款期限不能为空", trigger: "blur" }
    ],
    riskRating: [
      { required: true, message: "风险评级不能为空", trigger: "change" }
    ],
    cooperationStatus: [
      { required: true, message: "合作状态不能为空", trigger: "change" }
    ],
    status: [
      { required: true, message: "状态不能为空", trigger: "change" }
    ]
  }
});

const { queryParams, form, detailForm, rules } = toRefs(data);

/** 查询银行机构列表 */
function getList() {
  loading.value = true;
  listBankInstitution(queryParams.value).then(response => {
    bankList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}

// 取消按钮
function cancel() {
  open.value = false;
  reset();
}

// 表单重置
function reset() {
  form.value = {
    bankId: null,
    bankCode: null,
    bankName: null,
    bankType: null,
    contactPerson: null,
    contactPhone: null,
    contactEmail: null,
    bankAddress: null,
    productName: null,
    productInterestRate: null,
    productTermMonths: null,
    baseInterestRate: null,
    minLoanAmount: null,
    maxLoanAmount: null,
    minLoanTermMonths: null,
    maxLoanTermMonths: null,
    riskRating: null,
    cooperationStatus: "ACTIVE",
    cooperationStartDate: null,
    cooperationEndDate: null,
    status: "0",
    remarks: null
  };
  proxy.resetForm("bankRef");
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.bankId);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

/** 新增按钮操作 */
function handleAdd() {
  reset();
  open.value = true;
  title.value = "添加银行机构";
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const bankId = row.bankId || ids.value;
  getBankInstitution(bankId).then(response => {
    form.value = response.data;
    open.value = true;
    title.value = "修改银行机构";
  });
}

/** 查看详情按钮操作 */
function handleView(row) {
  getBankInstitution(row.bankId).then(response => {
    detailForm.value = response.data;
    detailOpen.value = true;
  });
}


/** 提交按钮 */
function submitForm() {
  proxy.$refs["bankRef"].validate(valid => {
    if (valid) {
      if (form.value.bankId != null) {
        updateBankInstitution(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        });
      } else {
        addBankInstitution(form.value).then(response => {
          proxy.$modal.msgSuccess("新增成功");
          open.value = false;
          getList();
        });
      }
    }
  });
}

/** 删除按钮操作 */
function handleDelete(row) {
  const bankIds = row.bankId || ids.value;
  proxy.$modal.confirm('是否确认删除银行机构编号为"' + bankIds + '"的数据项？').then(function() {
    return delBankInstitution(bankIds);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {});
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download('credit/bank-institution/export', {
    ...queryParams.value
  }, `bank_institution_${new Date().getTime()}.xlsx`)
}

/** 获取风险评级标签类型 */
function getRiskRatingType(rating) {
  const ratingMap = {
    'AAA': 'success',
    'AA': 'success',
    'A': 'primary',
    'BBB': 'warning',
    'BB': 'warning',
    'B': 'danger'
  };
  return ratingMap[rating] || 'info';
}

/** 获取合作状态标签类型 */
function getCooperationStatusType(status) {
  const statusMap = {
    'ACTIVE': 'success',
    'SUSPENDED': 'warning',
    'TERMINATED': 'danger'
  };
  return statusMap[status] || 'info';
}

/** 获取合作状态标签文本 */
function getCooperationStatusLabel(status) {
  const statusMap = {
    'ACTIVE': '合作中',
    'SUSPENDED': '暂停合作',
    'TERMINATED': '终止合作'
  };
  return statusMap[status] || status;
}

/** 格式化货币 */
function formatCurrency(amount) {
  if (!amount) return '0';
  return new Intl.NumberFormat('zh-CN', {
    style: 'currency',
    currency: 'CNY'
  }).format(amount);
}

onMounted(() => {
  getList();
});
</script>

<style scoped>
.text-info {
  font-size: 12px;
  color: #909399;
  margin-top: 2px;
}

.el-table .cell {
  line-height: 1.4;
}

.el-descriptions-item__content {
  word-break: break-all;
}
</style>