马宇豪
2025-03-07 db905ecd14f63dba9337b4f4715584ef2d7e8c7e
src/views/specialOperationsPay/notCoalPay/components/studentDialog.vue
@@ -26,12 +26,12 @@
        <el-row :gutter="24">
          <el-col :span="12" v-if="stuInfo.payType === 1 || stuInfo.payType === 3 || stuInfo.payType === 4">
            <el-form-item label="理论类别:">
              <span>{{stuInfo.nonCoalPayCategoryList.find(i=>i.categoryType == 1).subjectName}}</span>
              <span>{{stuInfo.nonCoalPayCategoryList.find(i => i.categoryType == 1) && stuInfo.nonCoalPayCategoryList.find(i => i.categoryType == 1).subjectName }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="stuInfo.payType === 2 || stuInfo.payType === 3">
            <el-form-item label="实操类别:">
              <span>{{stuInfo.nonCoalPayCategoryList.find(i=>i.categoryType == 2).subjectName}}</span>
              <span>{{stuInfo.nonCoalPayCategoryList.find(i => i.categoryType == 2) && stuInfo.nonCoalPayCategoryList.find(i => i.categoryType == 2).subjectName }}</span>
            </el-form-item>
          </el-col>
        </el-row>
@@ -77,18 +77,21 @@
      </el-form>
  <!--    表格-->
      <div style="margin: 20px 15px;display: flex">
        <el-button size="small"  type="primary" @click="handleAddStu('add',{})">添加学员</el-button>
        <el-button size="small"  type="primary" @click="importDialog = true">批量导入</el-button>
      <div style="margin: 20px 15px;display: flex;justify-content: space-between">
        <div>
          <el-button size="small" type="primary" @click="handleAddStu('add',{})">添加学员</el-button>
          <el-button size="small" type="primary" @click="importDialog = true">批量导入</el-button>
        </div>
        <el-button type="text" @click="exportExcel">导出清单</el-button>
      </div>
      <el-table v-loading="loading" :data="stuList">
      <el-table v-loading="loading" :data="stuList" id="table_excel">
        <el-table-column label="序号" align="center" type="index" />
        <el-table-column label="姓名" align="center" prop="name" />
        <el-table-column label="身份证号" align="center" prop="idCard" />
        <el-table-column label="手机号" align="center" prop="phone" />
        <el-table-column label="性别" align="center" prop="sex">
          <template #default="scope">
            {{scope.row.sex == 0?'男':scope.row.sex == 1?'女':'未知'}}
            {{(parseInt(scope.row.idCard.substr(16, 1))) % 2 === 0 ? "女" : "男"}}
          </template>
        </el-table-column>
        <el-table-column label="财政缴款码" align="center" prop="payCode">
@@ -98,9 +101,11 @@
        </el-table-column>
        <el-table-column label="是否已缴" align="center" prop="payStatus">
          <template #default="scope">
            {{scope.row.payStatus == 0?'未缴':scope.row.payStatus == 1?'已缴':''}}
            <span v-if="scope.row.payStatus == 1" style="color: green">已缴</span>
            <span v-else style="color: red">未缴</span>
          </template>
        </el-table-column>
        <el-table-column label="培训机构" align="center" prop="train" />
        <el-table-column label="类别" align="center" prop="payType">
          <template #default="scope">
            {{scope.row.payType == 1?'个人':scope.row.payType == 2?'集体':''}}
@@ -108,19 +113,13 @@
        </el-table-column>
        <el-table-column label="操作" align="center">
          <template #default="scope">
            <el-button size="mini" type="text" v-if="scope.row.payStatus == 1" style="color: #1890ff">查看票据</el-button>
            <el-button size="mini" type="text" style="color: #1890ff" @click="handleAddStu('edit',scope.row)">修改</el-button>
            <el-button size="mini" type="text" style="color:lightcoral" @click="handleDelete(scope.row)">删除</el-button>
            <el-button size="mini" type="text" v-if="scope.row.payStatus == 1" style="color: #1890ff" @click="checkTicket">查看票据</el-button>
            <el-button size="mini" type="text" v-if="scope.row.payStatus == 0" style="color: #1890ff" @click="goPay(scope.row)">去缴费</el-button>
            <el-button size="mini" type="text" style="color: #1890ff" v-if="!(scope.row.payCode && scope.row.payCode!=='')" @click="handleAddStu('edit',scope.row)">修改</el-button>
            <el-button size="mini" type="text" style="color:lightcoral" v-if="!(scope.row.payCode && scope.row.payCode!=='')" @click="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getStuList"
      />
    </el-dialog>
    <el-dialog
      :title="dialogStatus==='add'?'新增':'编辑'"
@@ -139,6 +138,9 @@
            <el-radio :label="0">男</el-radio>
            <el-radio :label="1">女</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="培训机构:">
          <el-input v-model.trim="dataForm.train"/>
        </el-form-item>
        <el-form-item label="身份证号:" prop="idCard">
          <el-input v-model.trim="dataForm.idCard"/>
@@ -205,15 +207,18 @@
<script>
import {verifyIdCard, verifySimplePhone} from "@/utils/validate";
import {verifyIdCard, verifySimplePhone} from "@/utils/validate"
import * as XLSX from 'xlsx';
import { saveAs } from 'file-saver';
import {
  addNonCoalStu, delNonCalStu, delNonCoalPay,
  editNonCoalStu,
  getNonCoalPayStudents,
  getPayTypeInfo
  getPayTypeInfo, nonCoalPersonPay
} from "@/api/specialOperationsPay/notCoalPay";
import exampleFile from '@/assets/studentInfo.xlsx'
import {getToken} from "@/utils/auth";
import {coalPersonPay} from "@/api/specialOperationsPay/coalPay";
export default {
  name: 'addStu',
  components: {},
@@ -270,6 +275,38 @@
    };
  },
  methods: {
    exportExcel() {
      var xlsxParam = { raw: true }
      let tables = document.getElementById('table_excel')
      let clonedTable = tables.cloneNode(true); // 深度克隆
      // 删除克隆表格中的最后一列
      const allRows = clonedTable.querySelectorAll('tr');
      allRows.forEach((row,index) => {
        const cells = row.querySelectorAll('th,td');
        if (cells.length > 0) {
          if(index == 0){
            row.removeChild(cells[cells.length - 2]); // 表头行要特殊处理
          }else{
            row.removeChild(cells[cells.length - 1]); // 移除最后一个单元格
          }
        }
      })
      let table_book = this.$XLSX.utils.table_to_book(clonedTable, xlsxParam);
      const table_write = this.$XLSX.write(table_book, {
        bookType: 'xlsx',
        bookSST: true,
        type: 'array'
      });
      try {
        this.$FileSaver.saveAs(
          new Blob([table_write], { type: 'application/octet-stream' }),
          `${this.stuInfo.batchName}批次学员缴费清单.xlsx`
        );
      } catch (e) {
        if (typeof console !== 'undefined') console.log(e, table_write);
      }
      return table_write
    },
    openDialog(id) {
      this.getStuList(id)
      this.id = id
@@ -292,7 +329,6 @@
        const {id,nonCoalPayId,name,idCard,sex,phone} = data
        this.dataForm = {id,nonCoalPayId,name,idCard,sex,phone}
      }
      console.log(this.dataForm,'form')
      this.dialogStatus = type
    },
@@ -395,6 +431,28 @@
        }
      })
    },
    checkTicket(){
      window.open('http://finpt.xjcz.gov.cn/fs-public/index.do')
    },
    async goPay(item){
      if(item.payCode && item.payCode !== ''){
        window.open(`http://finpt.xjcz.gov.cn/fs-public/billQuery/findByOrderId.do?orderId=${item.orderId}&deviceType=1`)
      }else{
        const query = {
          id: item.id,
          payType: 1
        }
        const res = await nonCoalPersonPay(query)
        if(res.code == 200) {
          window.open(`http://finpt.xjcz.gov.cn/fs-public/billQuery/findByOrderId.do?orderId=${res.msg}&deviceType=1`)
        }else{
          this.$message({
            type:'warning',
            message: res.msg
          })
        }
      }
    },
    handleDelete(row){
      this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
        confirmButtonText: '确定',