settlementDialog.vue 6.14 KB
<template>
  <el-dialog v-model="showDialog" :title="type==1?'级位考试费用明细':'段位考试费用明细'" class="beautified-dialog" destroy-on-close width="800">
    <div v-loading="loading" class="dialog-content">
      <!-- 统计卡片区 -->
      <div class="stats-grid">
        <div class="stat-card">
          <div class="stat-label">考试总人数</div>
          <div class="stat-value">{{ form.personCount }}<span class="stat-unit"></span></div>
        </div>
        <div class="stat-card">
          <div class="stat-label">费用合计</div>
          <div class="stat-value">{{ form.allFee }}<span class="stat-unit"></span></div>
        </div>
        <div class="stat-card">
          <div class="stat-label">服务费用</div>
          <div class="stat-value">{{ form.fee }}<span class="stat-unit"></span></div>
        </div>
      </div>
      
      <!-- 级别分布明细 -->
      <div class="level-section">
        <div class="section-title">{{ type==1?'级别分布明细':'段位分布明细' }}</div>
        <div class="level-tags">
          <span v-for="(val,inx) in form.count" :key="inx" :class="`level-${inx%3+1}`" class="level-tag">{{
            szToHz(inx)
          }}{{ type==1?'级':'段' }}{{ val }}</span>
        </div>
      </div>

    </div>
    
    <!-- 底部操作按钮 -->
    <template #footer>
      <div class="dialog-footer">
        <el-button round style="width: 160px;" @click="showDialog = false">取消</el-button>
        <el-button class="submit-btn" style="width: 160px;" type="primary" @click="handelSettlement">
          确定
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { getCurrentInstance, ref } from 'vue'
import { confirm, create } from '@/api/exam/payment'
import { szToHz } from '@/utils/ruoyi'

const emit = defineEmits(['handelSuccess'])
const loading = ref(false)
const showDialog = ref(false)
const form = ref({})
const { proxy } = getCurrentInstance()
const ids = ref([])
const type = ref(1)

function open(arr, status) {
  showDialog.value = true
  type.value = status ?? 1
  form.value = {}
  ids.value = []
  if (arr) {
    getConfirm(arr)
    ids.value = arr
  }
}

async function handelSettlement() {
  // if (!form.value.file) {
  //   proxy.$modal.msgError('请上传发票')
  //   return
  // }
  // const url = JSON.stringify(form.value.file)
  await create({
    ids: ids.value.join(',')
    // url: url
  })
  emit('handelSuccess', form.value)
  proxy.$modal.msgSuccess('操作成功')
}

async function getConfirm(ids) {
  loading.value = true
  const res = await confirm(ids)
  form.value = res.data
  loading.value = false
  console.log(res)
}

defineExpose({
  open
})
</script>

<style lang="scss" scoped>
.beautified-dialog :deep(.el-dialog__header) {
  border-bottom: 1px solid #eef2f6;
  padding: 20px 24px;
  margin: 0;
}

.beautified-dialog :deep(.el-dialog__title) {
  font-size: 18px;
  font-weight: 600;
  color: #1f2f3d;
}

.beautified-dialog :deep(.el-dialog__body) {
  padding: 24px;
}

.dialog-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 统计卡片网格 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.stat-card {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 16px;
  padding: 16px 20px;
  text-align: center;
  transition: all 0.3s ease;
  border: 1px solid #e9edf2;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
  border-color: #d0d7de;
}

.stat-label {
  font-size: 14px;
  color: #5a6874;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: #2c3e50;
  line-height: 1.2;
}

.stat-unit {
  font-size: 14px;
  font-weight: 400;
  color: #8a99a8;
  margin-left: 4px;
}

/* 级别分布区域 */
.level-section {
  background: rgba(175, 227, 251, 0.5);
  border-radius: 12px;
  padding: 16px 20px;
  border-left: 4px solid #27a9e7;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: #3b4a5c;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  width: 4px;
  height: 16px;
  background: #27a9e7;
  border-radius: 2px;
}

.level-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.level-tag {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  background: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.level-1 {
  background: linear-gradient(135deg, #fef2e8, #ffe4d6);
  color: #c2410c;
}

.level-2 {
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  color: #1e40af;
}

.level-3 {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  color: #065f46;
}

/* 上传区域 */
.upload-section {
  margin-top: 4px;
}

.upload-area {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: #fafcff;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px dashed #cbd5e1;
  transition: all 0.2s ease;
}

.upload-area:hover {
  border-color: #409eff;
  background: #f0f7ff;
}

.upload-btn {
  border-radius: 20px;
  padding: 8px 20px;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.upload-tip {
  font-size: 12px;
  color: #8a99a8;
}

/* 底部按钮 */
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 8px;
}

.submit-btn {
  padding: 15px 24px;
  font-weight: 500;
  border-radius: 24px;
  background: linear-gradient(135deg, #409eff, #2a9cf4);
  border: none;
  box-shadow: 0 2px 8px rgba(64, 158, 255, 0.3);
  transition: all 0.3s ease;
}

.submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.4);
  opacity: 0.95;
}

/* 分隔线样式 */
.beautified-dialog :deep(.el-divider) {
  margin: 8px 0;
  background-color: #eef2f6;
}

/* 响应式调整 */
@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .stat-card {
    padding: 12px 16px;
  }
  
  .stat-value {
    font-size: 28px;
  }
  
  .level-tags {
    justify-content: center;
  }
  
  .upload-area {
    flex-direction: column;
    align-items: flex-start;
  }
}
</style>