download.vue 14.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
<template>
  <div v-show="showSearch" class="app-container">
    <div class="from-Card">
      <el-form ref="queryRef" label-position="top" size="small" :model="queryParams" :inline="true">
        <el-row style="width: 100%;">
          <el-col :span="4">
            <el-form-item label="结算编号" prop="payCode">
              <el-input
                v-model.trim="queryParams.payCode"
                placeholder="请输入结算编号"
                clearable
                style="width: 100%;"
                @keyup.enter="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col v-if="queryParams.type=='1'" :span="4">
            <el-form-item label="缴费编号" prop="examCode">
              <el-input
                v-model.trim="queryParams.examCode" placeholder="请输入缴费编号" clearable
                @keyup.enter="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="queryParams.type=='1'?'考级名称':'考段名称'" prop="name">
              <el-input
                v-model.trim="queryParams.name"
                :placeholder="queryParams.type=='1'?'请输入考级名称':'请输入考段名称'"
                clearable
                style="width: 100%;"
                @keyup.enter="handleQuery"
              />
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item label="证书是否发送" prop="certStatus">
              <el-select v-model="queryParams.certStatus" clearable style="width: 100%" placeholder="" @change="handleQuery">
                <el-option label="全部" value="" />
                <el-option label="已发放" value="2" />
                <el-option label="部分发放" value="1" />
                <el-option label="未发放" value="0" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="申请单位" prop="memberName">
              <el-input
                v-model.trim="queryParams.memberName"
                placeholder="请输入申请单位"
                clearable
                @keyup.enter="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col v-if="!showCollect" :span="8" style="display: flex">
            <el-form-item style="width: 100%;" label="证书发送日期" prop="certTimeRange">
              <el-date-picker
                v-model="queryParams.certTimeRange[0]" type="date" value-format="YYYY-MM-DD"
                placeholder="开始时间" style="width: 100%;"
              />
            </el-form-item>
            <el-form-item style="width: 100%;" label="证书发送日期" prop="certTimeRange">
              <el-date-picker
                v-model="queryParams.certTimeRange[1]" type="date" value-format="YYYY-MM-DD"
                placeholder="结束时间" style="width: 100%;"
              />
            </el-form-item>
          </el-col>
          <el-col :span="4" :hidden="showCollect">
            <el-form-item label="占位" style="opacity: 0" />
          </el-col>
          <div class="po-r-btns">
            <el-button size="small" type="primary" @click="handleQuery">搜索</el-button>
            <el-button size="small" @click="resetQuery">重置</el-button>
            <el-button
              v-if="showCollect" size="small" type="primary" link icon="ArrowDown"
              @click="showCollect=!showCollect"
            >展开</el-button>
            <el-button
              v-else size="small" type="primary" link icon="ArrowUp"
              @click="showCollect=!showCollect"
            >收起</el-button>
          </div>
        </el-row>
      </el-form>
      <el-row justify="space-between">
        <div>
          <el-button
            v-if="showDownload"
            type="primary" icon="Download"
            :disabled="multiple"
            @click="handleDownloadAll"
          >考试证书批量下载</el-button>
          <!--          <el-button size="small" type="warning" @click="handleExport">导出</el-button>-->
        </div>
      </el-row>
    </div>

    <div class="table">
      <el-table v-loading="loading" border :data="infoList" @selection-change="handleSelectionChange">
        <el-table-column v-if="showDownload" type="selection" width="55" align="center" :selectable="selectable" />
        <el-table-column type="index" width="55" align="center" label="序号" />
        <el-table-column label="结算编号" align="center" header-align="center" prop="payCode" min-width="120" />
        <el-table-column
          :label="queryParams.type=='1'?'考级名称':'考段名称'" :show-overflow-tooltip="true" min-width="220"
          header-align="center" align="center" prop="name"
        />
        <el-table-column
          label="申请单位" align="center" header-align="center" prop="memberName" min-width="140"
          :show-overflow-tooltip="true"
        />
        <el-table-column label="申请日期" align="center" prop="applyTime" min-width="100">
          <template #default="scope">
            <span>{{ parseTime(scope.row.submitTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="已发证书" align="center" prop="hasCerts" />
        <el-table-column label="待发证书" align="center" prop="noCerts" />
        <el-table-column label="提交日期" align="center" prop="submitTime" min-width="100">
          <template #default="scope">
            <span>{{ parseTime(scope.row.submitTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="证书是否已发" align="center" prop="certStatusStr" min-width="110" />
        <el-table-column label="证书发送时间" align="center" prop="certTime" min-width="110">
          <template #default="scope">
            <span>{{ parseTime(scope.row.certTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" min-width="160" fixed="right" align="center" class-name="small-padding fixed-width">
          <template #default="scope">
            <el-button :disabled="scope.row.certStatus == '0'" type="primary" @click="handleDownload(scope.row)">查看</el-button>
            <el-button color="#13B5B1" style="--el-color-black:#fff;" @click="handleSend(scope.row)">更新证书</el-button>
          </template>
        </el-table-column>
      </el-table>


      <pagination
        v-show="total>0"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        :total="total"
        @pagination="getList"
      />
    </div>

    <el-link ref="zipRef" :href="zipUrl" target="_blank" download="考试证书" />
    <exam-view ref="examRef" :show-download="showDownload" />

    <el-dialog v-model="dialog.show" title="系统提示" width="550">
      <el-icon size="20" color="#e6a23c"><WarningFilled /></el-icon>
      <span class="ml10"> {{ dialog.content }}</span>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="dialog.show = false">取消</el-button>
          <el-button type="waring" @click="dialog.download();dialog.show = false">下载没有照片的学员</el-button>
          <el-button type="primary" @click="dialog.sure();dialog.show = false">{{ dialog.btnSureName }}</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script>
let pageName
if (location.href.indexOf('/level/') > -1) {
  pageName = 'Level_Download'
} else if (location.href.indexOf('/rank/') > -1) {
  pageName = 'Rank_Download'
} else if (location.href.indexOf('/beyond/') > -1) {
  pageName = 'Beyond_Download'
}

export default {
  name: pageName
}
</script>

<script setup>
import { Download } from '@element-plus/icons-vue'
import { getCurrentInstance, reactive } from '@vue/runtime-core'
import { onMounted, ref, toRefs } from 'vue'
import { parseTime } from '@/utils/ruoyi'
import { certsLList, checkDownPermissionPayment, checkPersonByPayIds, submitCert2 } from '@/api/exam/cert'
import ExamView from './examList.vue'
import { useRoute, useRouter } from 'vue-router'

const router = useRouter()
const { proxy } = getCurrentInstance()
const route = useRoute()

const showCollect = ref(true)
const infoList = ref([])
const loading = ref(true)
const showSearch = ref(true)
const multiple = ref(true)
const total = ref(0)
let ids = []
const showDownload = ref(false)

const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    name: undefined,
    memberName: undefined,
    examiner: undefined,
    applyTimeRange: undefined,
    certTimeRange: [null, null],
    certStatus: ''
    // type: '1'
  },
  dialog: {
    show: false,
    content: '',
    sureName: '',
    sure: () => {
    },
    download: () => {
    },
    confirm: () => {
      return Promise.resolve()
    }
  }
})
const { queryParams, dialog } = toRefs(data)


onMounted(() => {
  if (route.path.indexOf('level') > -1) {
    showDownload.value = true
    queryParams.value.type = '1'
  } else if (route.path.indexOf('rank') > -1) {
    queryParams.value.type = '2'
  } else if (route.path.indexOf('beyond') > -1) {
    queryParams.value.type = '3'
  }

  getList()
})

/** 查询考级信息列表 */
function getList() {
  if ((queryParams.value.certTimeRange[0] == null && queryParams.value.certTimeRange[1] != null) || (queryParams.value.certTimeRange[1] == null && queryParams.value.certTimeRange[0] != null)) return proxy.$modal.msgError('请完善证书发送日期')

  loading.value = true
  certsLList(queryParams.value).then(response => {
    infoList.value = response.rows
    total.value = response.total
    loading.value = false
  })
}

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

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

function selectable(row) {
  if (row.certStatus == '2') {
    return true
  } else {
    return false
  }
}

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

/**
 * 一键发送
 */

function handleDownload(row) {
  proxy.$refs['examRef'].open(row, queryParams.value.type)
}

const zipUrl = ref('')
function handleDownloadAll() {
  if (ids.length <= 0) return proxy.msgError('请选择考试')
  return checkPersonByPayIds(ids).then(function(res) {
    if (res.data == 1) {
      sureFunc()
    } else if (res.data == 2) {
      dialog.value.show = true
      dialog.value.content = `存在学员没有照片,是否继续下载证书?`
      dialog.value.btnSureName = '下载证书'
      dialog.value.sure = () => {
        sureFunc()
      }
      dialog.value.download = () => {
        proxy.download(`/person/info/checkPersonByPayIdsAndExport/${ids}`, { }, `没有照片的人员${new Date().getTime()}.xlsx`)
      }
    } else if (res.data == 3) {
      return proxy.$modal.confirm(`所有考生都没有照片无法下载`)
    }
  })
}


async function sureFunc() {
  await handelCheckDownPermissionPayment(ids)
  const routerData = router.resolve({
    path: '/download',
    query: {
      arr: ids,
      type: 'examCert'
    }
  })
  window.open(routerData.href, '_blank')
}
// function handleExport() {
//   proxy.download('/exam/payment/certsList/export', {
//     ...queryParams.value
//   }, `考试证书${new Date().getTime()}.xlsx`)
// }

function handelCheckDownPermissionPayment(payIds) {
  return new Promise(async(resolve, reject) => {
    const res = await checkDownPermissionPayment(payIds)
    console.log(res)
    if (res.code == 200 && res.data.flag == 1) {
      return resolve()
    } else {
      proxy.$modal.msgError(res.data.info)
      return reject()
    }
  })
}

/**
 * 一键发送
 */

function handleSend(row) {
  checkCert(row.payId, () => {
    submitCert2([{
      id: row.payId
    }]).then(() => {
      proxy.$modal.msgSuccess('下发成功')
      getList()
    })
  }, true, () => {
    return proxy.$modal.confirm(`确定下发 ${row.name} 的证书?`)
  })
}

function checkCert(payIds, sureFunc, isCreate, confirmFunc) {
  isCreate = !!isCreate
  confirmFunc = confirmFunc || dialog.value.confirm

  let sureName
  if (isCreate) {
    sureName = '生成证书'
  } else {
    sureName = '下载证书'
  }
  // 级位
  if (queryParams.value.type == '1') {
    return checkPersonByPayIds(payIds).then(res => {
      if (res.data == 1) {
        confirmFunc().then(sureFunc)
      } else if (res.data == 2) {
        dialog.value.show = true
        dialog.value.content = `存在学员没有照片,是否继续${sureName}?`
        dialog.value.btnSureName = sureName
        dialog.value.sure = () => {
          sureFunc()
        }
        dialog.value.download = () => {
          proxy.download(`/person/info/checkPersonByPayIdsAndExport/${payIds}`, { }, `没有照片的人员${new Date().getTime()}.xlsx`)
        }
      } else if (res.data == 3) {
        if (isCreate) {
          dialog.value.show = true
          dialog.value.content = `存在学员没有照片,是否继续${sureName}?`
          dialog.value.btnSureName = sureName
          dialog.value.sure = () => {
            sureFunc()
          }
          dialog.value.download = () => {
            proxy.download(`/person/info/checkPersonByPayIdsAndExport/${payIds}`, { }, `没有照片的人员${new Date().getTime()}.xlsx`)
          }
        } else {
          return proxy.$modal.confirm(`所有考生都没有照片无法下载`)
        }
      }

      // if (!res.data) {
      //   dialog.value.show = true
      //   dialog.value.content = `存在学员没有照片,是否继续${sureName}?`
      //   dialog.value.btnSureName = sureName
      //   dialog.value.sure = () => {
      //     sureFunc()
      //   }
      //   dialog.value.download = () => {
      //     proxy.download(`/person/info/checkPersonByPayIdsAndExport/${payIds}`, { }, `没有照片的人员${new Date().getTime()}.xlsx`)
      //   }
      // } else {
      //   confirmFunc().then(sureFunc)
      // }
    })
  } else {
    // 段位
    confirmFunc().then(sureFunc)
  }
}
</script>

<style lang="scss" scoped >

</style>