123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 |
- <template>
- <div id="newRegister">
- <div style="margin-bottom: 12px">
- <span style="font-size: 14px">第一步:</span>
- <el-select
- :style="marSty"
- :size="size"
- filterable
- v-model="formData.applyId"
- placeholder="请选择考试计划(必填)"
- @change="getSXAddress"
- >
- <el-option
- v-for="item in examLists"
- :key="item.applyId"
- :label="item.applyName"
- :value="item.applyId"
- >
- </el-option>
- </el-select>
- <el-select
- v-if="formData.applyId"
- :style="marSty"
- :size="size"
- filterable
- v-model="formData.applySiteAddress"
- placeholder="请选择考试地点(必填)"
- >
- <el-option
- v-for="item in applySiteAddress"
- :key="item.siteId"
- :label="item.siteAddress"
- :value="item.siteAddress"
- >
- </el-option>
- </el-select>
- <el-button :size="size" type="info" @click="advanced">选择学员</el-button>
- <el-input
- v-if="formData.idCards"
- type="textarea"
- :size="size"
- readonly
- :rows="1"
- style="width: 180px; vertical-align: top; margin: 0px 10px"
- placeholder="请点击选择学员按钮上传学员名单"
- v-model="formData.idCards"
- >
- </el-input>
- <el-button :size="size" type="warning" @click="downModel"
- >下载模板</el-button
- >
- </div>
- <div style="margin-bottom: 12px">
- <span style="font-size: 14px">第二步:</span>
- <label
- for="mobles4"
- class="el-button el-button--success el-button--mini"
- style="margin-right: 10px"
- >批量导入</label
- ><input
- style="display: none"
- type="file"
- id="mobles4"
- ref="input4"
- @change="importMobleadd"
- />
- </div>
- <div>
- <el-badge
- :hidden="!tableDataSuccess.length"
- :value="tableDataSuccess.length"
- class="item"
- >
- <el-button
- :size="size"
- :type="active === 1 ? 'primary' : ''"
- @click="active = 1"
- >成功导入</el-button
- >
- </el-badge>
- <el-badge
- :hidden="!tableDataError.length"
- :value="tableDataError.length"
- class="item"
- >
- <el-button
- :size="size"
- :type="active === 2 ? 'primary' : ''"
- @click="active = 2"
- >失败导入</el-button
- >
- </el-badge>
- </div>
- <div v-show="active === 1" class="exportBox" v-loading="loading">
- <h4 class="h4Sty">
- 成功导入<strong style="color: red">{{ tableDataSuccess.length }}</strong
- >人
- </h4>
- <el-table
- max-height="600"
- :data="tableDataSuccess"
- style="width: 100%"
- border
- :header-cell-style="{
- 'background-color': '#eee',
- color: '#333',
- fontSize: '14px',
- }"
- >
- <af-table-column
- v-for="(item, index) in computedForm(tableSet, 1)"
- :key="index"
- :prop="item.prop"
- :label="item.label"
- :width="item.width"
- align="center"
- >
- <template slot-scope="scope">
- <div v-if="item.scope === 'time'">
- <div>{{ scope.row[item.prop1] }}</div>
- <div>{{ scope.row[item.prop2] }} {{ scope.row[item.prop3] }}</div>
- </div>
- <span v-else>{{ scope.row[item.prop] }}</span>
- </template>
- </af-table-column>
- </el-table>
- </div>
- <div v-show="active === 2" class="exportBox" v-loading="loading">
- <h4 class="h4Sty">
- 失败导入<strong style="color: red">{{ tableDataError.length }}</strong
- >人
- <el-button
- v-if="tableDataError.length"
- style="margin-left: 10px"
- :size="size"
- type="success"
- @click="dowmErrorData"
- >下载失败数据</el-button
- >
- </h4>
- <el-table
- max-height="600"
- :data="tableDataError"
- style="width: 100%"
- border
- :header-cell-style="{
- 'background-color': '#eee',
- color: '#333',
- fontSize: '14px',
- }"
- >
- <af-table-column
- v-for="(item, index) in computedForm(tableSet, 2)"
- :key="index"
- :prop="item.prop"
- :label="item.label"
- :width="item.width"
- align="center"
- >
- <template slot-scope="scope">
- <span v-if="item.scope === 'time'">
- {{ changeDatas(scope.row[item.prop]) }}
- </span>
- <span v-else>{{ scope.row[item.prop] }}</span>
- </template>
- </af-table-column>
- </el-table>
- </div>
- <el-dialog
- :visible.sync="dialogPLS"
- width="660px"
- :show-close="false"
- :close-on-click-modal="false"
- >
- <div slot="title" class="hearders">
- <div class="leftTitle">高级输入</div>
- <div class="rightBoxs">
- <img
- src="@/assets/images/Close@2x.png"
- alt=""
- @click="dialogPLS = false"
- />
- </div>
- </div>
- <el-row :gutter="20">
- <el-col :span="12"
- ><h4>请输入学员的身份证号码,换行隔开,每行一个</h4>
- <el-input
- type="textarea"
- :rows="10"
- placeholder="请输入身份证"
- v-model="idcordList"
- >
- </el-input>
- </el-col>
- <el-col :span="12">
- <h4>快捷导入</h4>
- <el-link type="primary" @click="getDowm">下载模板</el-link>
- <label
- for="mobles3"
- class="el-button el-button--primary"
- style="margin-left: 14px; padding: 10px 20px"
- >上传学员名单</label
- ><input
- style="display: none"
- type="file"
- id="mobles3"
- ref="input1"
- @change="importMobleadds"
- />
- </el-col>
- </el-row>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogPLS = false">取消</el-button>
- <el-button type="primary" @click="submitChecksPals">确定</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import * as baseUrls from "@/utils/request.js";
- import { mapGetters } from "vuex";
- export default {
- data() {
- return {
- loading: false, // 加载效果
- dialogPLS: false,
- active: 1,
- marSty: { marginRight: "10px" },
- size: "mini",
- formData: {
- applyId: "",
- applySiteAddress: "",
- idCards: "",
- },
- applySiteAddress: [],
- idcordList: "",
- tableDataSuccess: [],
- tableDataError: [],
- tableSet: [
- {
- label: "学员姓名",
- prop: "userName",
- },
- {
- label: "学员身份证",
- prop: "idCard",
- },
- {
- label: "学员报名类型",
- prop: "studentTypeName",
- },
- {
- label: "考试标题",
- prop: "applyName",
- },
- {
- label: "考试地点",
- prop: "applySiteAddress",
- },
- {
- label: "考试日期",
- prop: "applySiteExamTime",
- // scope: "time",
- },
- {
- label: "考试时间段",
- prop: "applySiteTime",
- },
- {
- label: "商品编码",
- prop: "code",
- },
- {
- label: "商品标题",
- prop: "goodsName",
- },
- {
- label: "预约登记",
- prop: "subscribeStatus",
- },
- {
- label: "考试登记",
- prop: "examStatus",
- },
- {
- label: "考试成绩",
- prop: "performance",
- },
- {
- label: "考试结果",
- prop: "result",
- },
- {
- label: "证书编号",
- prop: "certificateCode",
- },
- {
- label: "出错原因",
- prop: "cause",
- hidden: true,
- width: "260px",
- },
- ],
- };
- },
- computed: {
- ...mapGetters(["examLists"]),
- computedForm: function () {
- return function (tabs, int) {
- if (int === 1) {
- const ayst = tabs.filter((item) => {
- return !item.hidden;
- });
- return ayst;
- } else {
- return tabs;
- }
- };
- },
- },
- methods: {
- getSXAddress(int) {
- this.formData.applySiteAddress = "";
- this.$api
- .inquirepayservesiteInfo({ applyId: int, addressStatus: 1 })
- .then((res) => {
- this.applySiteAddress = res.rows;
- });
- },
- /**
- * 转换时间格式
- */
- changeDatas(time) {
- if (time) {
- var datas = this.$methodsTools.onlyForma(
- new Date(time).getTime() / 1000,
- false
- );
- return datas;
- } else {
- return "";
- }
- },
- importMobleadd(e) {
- this.loading = true
- var file = e.target.files[0];
- let formData = new FormData();
- formData.append("file", file);
- this.$api
- .editsystemimportUpdateData(formData)
- .then((res) => {
- this.tableDataSuccess = res.data.successList;
- this.tableDataError = res.data.errorList;
- this.$message.info("导入操作执行成功");
- })
- .finally(() => {
- e.target.value = "";
- this.loading = false
- });
- },
- advanced() {
- if (!this.formData.applyId || !this.formData.applySiteAddress) {
- this.$message.warning("请先选择考试计划和考试地点");
- return;
- }
- this.dialogPLS = true;
- this.idcordList = this.formData.idCards;
- },
- submitChecksPals() {
- if (this.idcordList) {
- let as = this.idcordList.split("\n") || [];
- let newArr = [];
- var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
- for (let i = 0; i < as.length; i++) {
- if (newArr.indexOf(as[i]) === -1 && reg.test(as[i])) {
- newArr.push(as[i]);
- }
- }
- if (newArr.length) {
- let idCardObj = newArr.map((item) => {
- return { idCard: item };
- });
- let data = {
- applyId: this.formData.applyId,
- applySiteAddress: this.formData.applySiteAddress,
- list: idCardObj,
- };
- this.$api.inquiresystemsubscribecheckIdCardData(data).then((res) => {
- this.formData.idCards = newArr.join("\n");
- this.dialogPLS = false;
- });
- } else {
- this.idcordList = "";
- this.$message.warning(
- "已删除重复身份证号码和无效身份证号码,请重新输入有效身份证号码"
- );
- return;
- }
- } else {
- this.formData.idCards = this.idcordList;
- this.dialogPLS = false;
- }
- },
- /**
- * 窗口下载模板
- */
- getDowm() {
- let url = baseUrls.BASE_IMG_URL + "/oss/images/file/20220214.xls" +
- `?time=${this.$methodsTools.getNewTime()}`;;
- let link = document.createElement("a");
- let fileName = "导入模板" + ".xlsx";
- document.body.appendChild(link);
- link.href = url;
- link.dowmload = fileName;
- link.click();
- link.remove();
- },
- /**
- * 导入
- */
- importMobleadds(e) {
- var self = this;
- var file = e.target.files[0];
- let formData = new FormData();
- formData.append("file", file);
- this.$api
- .editsystemimportIdsData(formData)
- .then((res) => {
- if (!res.data.length) {
- this.$message.warning("未检测到上传学员数据,请检查上传文件");
- return;
- }
- let idList = res.data.map((item) => {
- return item.idCard.toString();
- });
- if (this.idcordList) {
- var arr = this.idcordList.split("\n");
- var arrs = arr.concat(idList);
- var newArr = arrs.filter(function (value, index, self) {
- return self.indexOf(value) === index;
- });
- this.idcordList = newArr.join("\n");
- } else {
- var newArr = idList.filter(function (value, index, self) {
- return self.indexOf(value) === index;
- });
- this.idcordList = newArr.join("\n");
- }
- this.$message.success("上传成功");
- })
- .finally(() => {
- e.target.value = "";
- });
- },
- /**下载模板 */
- downModel() {
- if (!this.formData.applyId) {
- this.$message.warning("请选择考试计划");
- return;
- }
- if (!this.formData.applySiteAddress) {
- this.$message.warning("请选择考试地点");
- return;
- }
- var data = JSON.parse(JSON.stringify(this.formData));
- if (this.formData.idCards) {
- data.idCards = this.formData.idCards.split("\n");
- }
- // else {
- // this.$message.warning("请选择学员");
- // return;
- // }
- const indexs = this.examLists.findIndex((item) => {
- return item.applyId == data.applyId;
- });
- data.applyName = this.examLists[indexs].applyName;
- this.$api.inquiresystemsubscribeexportRegister(data).then((res) => {
- let url = baseUrls.baseURL + "common/download?fileName=" + res.msg;
- let link = document.createElement("a");
- let fileName = "导入模板" + ".xlsx";
- document.body.appendChild(link);
- link.href = url;
- link.dowmload = fileName;
- link.click();
- link.remove();
- });
- },
- /**
- * 下载错误数据
- */
- dowmErrorData() {
- this.$api
- .inquiresystemsubscribeexportexportErrorUpdate(this.tableDataError)
- .then((res) => {
- let url = baseUrls.baseURL + "common/download?fileName=" + res.msg;
- let link = document.createElement("a");
- let fileName = "导入模板" + ".xlsx";
- document.body.appendChild(link);
- link.href = url;
- link.dowmload = fileName;
- link.click();
- link.remove();
- });
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .h4Sty {
- margin: 6px;
- font-size: 14px;
- }
- .exportBox {
- border: 1px solid #999;
- padding: 10px;
- margin-top: 10px;
- border-radius: 4px;
- }
- /deep/.el-button {
- border-radius: 8px;
- }
- /deep/.el-dialog {
- border-radius: 8px;
- .el-dialog__header {
- padding: 0;
- .hearders {
- height: 40px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0px 18px 0px 20px;
- border-bottom: 1px solid #e2e2e2;
- .leftTitle {
- font-size: 14px;
- font-weight: bold;
- color: #2f4378;
- }
- .rightBoxs {
- display: flex;
- align-items: center;
- img {
- width: 14px;
- height: 14px;
- margin-left: 13px;
- cursor: pointer;
- }
- }
- }
- }
- .el-dialog__footer {
- padding: 0;
- .dialog-footer {
- padding: 0px 40px;
- height: 70px;
- border-top: 1px solid #e2e2e2;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- }
- }
- }
- .imgBox {
- width: 100%;
- // height: 210px;
- border: 1px solid #e2e2e2;
- border-radius: 8px;
- padding: 8px 8px 3px;
- display: flex;
- flex-direction: column;
- align-items: center;
- .imgLabel {
- flex: 1;
- width: 100%;
- border: 1px dotted #e2e2e2;
- color: #999;
- font-size: 14px;
- cursor: pointer;
- border-radius: 8px;
- .msPhoto {
- display: flex;
- justify-content: center;
- align-items: center;
- max-width: 100%;
- max-height: 270px;
- img {
- max-width: 100%;
- max-height: 270px;
- }
- }
- .imgbbx {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- width: 100%;
- height: 100%;
- i {
- font-weight: bold;
- margin: 14px 0;
- font-size: 24px;
- }
- }
- }
- p {
- margin: 5px 0px;
- }
- }
- .item {
- margin-top: 10px;
- margin-right: 20px;
- }
- </style>
|