newRegister.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. <template>
  2. <div id="newRegister">
  3. <div style="margin-bottom: 12px">
  4. <span style="font-size: 14px">第一步:</span>
  5. <el-select
  6. :style="marSty"
  7. :size="size"
  8. filterable
  9. v-model="formData.applyId"
  10. placeholder="请选择考试计划(必填)"
  11. >
  12. <el-option
  13. v-for="item in examList"
  14. :key="item.applyId"
  15. :label="item.applyName"
  16. :value="item.applyId"
  17. >
  18. </el-option>
  19. </el-select>
  20. <el-select
  21. :style="marSty"
  22. :size="size"
  23. filterable
  24. v-model="formData.applySiteAddress"
  25. placeholder="请选择考试地点(必填)"
  26. >
  27. <el-option
  28. v-for="item in applySiteAddress"
  29. :key="item.siteId"
  30. :label="item.siteAddress"
  31. :value="item.siteAddress"
  32. >
  33. </el-option>
  34. </el-select>
  35. <el-button :size="size" type="info" @click="advanced">选择学员</el-button>
  36. <el-input
  37. v-if="formData.idCards"
  38. type="textarea"
  39. :size="size"
  40. readonly
  41. :rows="1"
  42. style="width: 180px; vertical-align: top; margin: 0px 10px"
  43. placeholder="请点击选择学员按钮上传学员名单"
  44. v-model="formData.idCards"
  45. >
  46. </el-input>
  47. <el-button :size="size" type="warning" @click="downModel"
  48. >下载模板</el-button
  49. >
  50. </div>
  51. <div style="margin-bottom: 12px">
  52. <span style="font-size: 14px">第二步:</span>
  53. <label
  54. for="mobles4"
  55. class="el-button el-button--success el-button--mini"
  56. style="margin-right: 10px"
  57. >批量导入</label
  58. ><input
  59. style="display: none"
  60. type="file"
  61. id="mobles4"
  62. ref="input4"
  63. @change="importMobleadd"
  64. />
  65. </div>
  66. <div>
  67. <el-badge
  68. :hidden="!tableDataSuccess.length"
  69. :value="tableDataSuccess.length"
  70. class="item"
  71. >
  72. <el-button
  73. :size="size"
  74. :type="active === 1 ? 'primary' : ''"
  75. @click="active = 1"
  76. >成功导入</el-button
  77. >
  78. </el-badge>
  79. <el-badge
  80. :hidden="!tableDataError.length"
  81. :value="tableDataError.length"
  82. class="item"
  83. >
  84. <el-button
  85. :size="size"
  86. :type="active === 2 ? 'primary' : ''"
  87. @click="active = 2"
  88. >失败导入</el-button
  89. >
  90. </el-badge>
  91. </div>
  92. <div v-show="active === 1" class="exportBox">
  93. <h4 class="h4Sty">
  94. 成功导入<strong style="color: red">{{ tableDataSuccess.length }}</strong
  95. >人
  96. </h4>
  97. <el-table
  98. max-height="600"
  99. :data="tableDataSuccess"
  100. style="width: 100%"
  101. border
  102. :header-cell-style="{
  103. 'background-color': '#eee',
  104. color: '#333',
  105. fontSize: '14px',
  106. }"
  107. >
  108. <af-table-column
  109. v-for="(item, index) in computedForm(tableSet, 1)"
  110. :key="index"
  111. :prop="item.prop"
  112. :label="item.label"
  113. :width="item.width"
  114. align="center"
  115. >
  116. <template slot-scope="scope">
  117. <div v-if="item.scope === 'time'">
  118. <div>{{ scope.row[item.prop1] }}</div>
  119. <div>{{ scope.row[item.prop2] }} {{ scope.row[item.prop3] }}</div>
  120. </div>
  121. <span v-else>{{ scope.row[item.prop] }}</span>
  122. </template>
  123. </af-table-column>
  124. </el-table>
  125. </div>
  126. <div v-show="active === 2" class="exportBox">
  127. <h4 class="h4Sty">
  128. 失败导入<strong style="color: red">{{ tableDataError.length }}</strong
  129. >人
  130. <el-button
  131. v-if="tableDataError.length"
  132. style="margin-left: 10px"
  133. :size="size"
  134. type="success"
  135. @click="dowmErrorData"
  136. >下载失败数据</el-button
  137. >
  138. </h4>
  139. <el-table
  140. max-height="600"
  141. :data="tableDataError"
  142. style="width: 100%"
  143. border
  144. :header-cell-style="{
  145. 'background-color': '#eee',
  146. color: '#333',
  147. fontSize: '14px',
  148. }"
  149. >
  150. <af-table-column
  151. v-for="(item, index) in computedForm(tableSet, 2)"
  152. :key="index"
  153. :prop="item.prop"
  154. :label="item.label"
  155. :width="item.width"
  156. align="center"
  157. >
  158. <template slot-scope="scope">
  159. <span v-if="item.scope === 'time'">
  160. {{ changeDatas(scope.row[item.prop]) }}
  161. </span>
  162. <span v-else>{{ scope.row[item.prop] }}</span>
  163. </template>
  164. </af-table-column>
  165. </el-table>
  166. </div>
  167. <el-dialog
  168. :visible.sync="dialogPLS"
  169. width="660px"
  170. :show-close="false"
  171. :close-on-click-modal="false"
  172. >
  173. <div slot="title" class="hearders">
  174. <div class="leftTitle">高级输入</div>
  175. <div class="rightBoxs">
  176. <img
  177. src="@/assets/images/Close@2x.png"
  178. alt=""
  179. @click="dialogPLS = false"
  180. />
  181. </div>
  182. </div>
  183. <el-row :gutter="20">
  184. <el-col :span="12"
  185. ><h4>请输入学员的身份证号码,换行隔开,每行一个</h4>
  186. <el-input
  187. type="textarea"
  188. :rows="10"
  189. placeholder="请输入身份证"
  190. v-model="idcordList"
  191. >
  192. </el-input>
  193. </el-col>
  194. <el-col :span="12">
  195. <h4>快捷导入</h4>
  196. <el-link type="primary" @click="getDowm">下载模板</el-link>
  197. <label
  198. for="mobles3"
  199. class="el-button el-button--primary"
  200. style="margin-left: 14px; padding: 10px 20px"
  201. >上传学员名单</label
  202. ><input
  203. style="display: none"
  204. type="file"
  205. id="mobles3"
  206. ref="input1"
  207. @change="importMobleadds"
  208. />
  209. </el-col>
  210. </el-row>
  211. <span slot="footer" class="dialog-footer">
  212. <el-button @click="dialogPLS = false">取消</el-button>
  213. <el-button type="primary" @click="submitChecksPals">确定</el-button>
  214. </span>
  215. </el-dialog>
  216. </div>
  217. </template>
  218. <script>
  219. import * as baseUrls from "@/utils/request.js";
  220. import { mapGetters } from "vuex";
  221. export default {
  222. data() {
  223. return {
  224. dialogPLS: false,
  225. active: 1,
  226. marSty: { marginRight: "10px" },
  227. size: "mini",
  228. formData: {
  229. applyId: "",
  230. applySiteAddress: "",
  231. idCards: "",
  232. },
  233. idcordList: "",
  234. tableDataSuccess: [],
  235. tableDataError: [],
  236. tableSet: [
  237. {
  238. label: "学员姓名",
  239. prop: "userName",
  240. },
  241. {
  242. label: "学员身份证",
  243. prop: "idCard",
  244. },
  245. {
  246. label: "考试标题",
  247. prop: "applyName",
  248. },
  249. {
  250. label: "考试地点",
  251. prop: "applySiteAddress",
  252. },
  253. {
  254. label: "考试日期",
  255. prop: "applySiteExamTime",
  256. scope: "time",
  257. },
  258. {
  259. label: "考试时间段",
  260. prop: "applySiteTime",
  261. },
  262. {
  263. label: "商品编码",
  264. prop: "code",
  265. },
  266. {
  267. label: "商品标题",
  268. prop: "goodsName",
  269. },
  270. {
  271. label: "预约登记",
  272. prop: "subscribeStatus",
  273. },
  274. {
  275. label: "考试登记",
  276. prop: "examStatus",
  277. },
  278. {
  279. label: "考试成绩",
  280. prop: "performance",
  281. },
  282. {
  283. label: "考试结果",
  284. prop: "result",
  285. },
  286. {
  287. label: "证书编号",
  288. prop: "certificateCode",
  289. },
  290. {
  291. label: "出错原因",
  292. prop: "cause",
  293. hidden: true,
  294. width:"260px"
  295. },
  296. ],
  297. };
  298. },
  299. computed: {
  300. ...mapGetters(["examList", "applySiteAddress"]),
  301. computedForm: function () {
  302. return function (tabs, int) {
  303. if (int === 1) {
  304. const ayst = tabs.filter((item) => {
  305. return !item.hidden;
  306. });
  307. return ayst;
  308. } else {
  309. return tabs;
  310. }
  311. };
  312. },
  313. },
  314. methods: {
  315. /**
  316. * 转换时间格式
  317. */
  318. changeDatas(time) {
  319. if (time) {
  320. var datas = this.$methodsTools.onlyForma(
  321. new Date(time).getTime() / 1000,
  322. false
  323. );
  324. return datas;
  325. } else {
  326. return "";
  327. }
  328. },
  329. importMobleadd(e) {
  330. var file = e.target.files[0];
  331. let formData = new FormData();
  332. formData.append("file", file);
  333. this.$api
  334. .editsystemimportUpdateData(formData)
  335. .then((res) => {
  336. this.tableDataSuccess = res.data.successList;
  337. this.tableDataError = res.data.errorList;
  338. this.$message.info("导入操作执行成功")
  339. })
  340. .finally(() => {
  341. e.target.value = "";
  342. });
  343. },
  344. advanced() {
  345. this.dialogPLS = true;
  346. this.idcordList = this.formData.idCards;
  347. },
  348. submitChecksPals() {
  349. this.formData.idCards = this.idcordList;
  350. this.dialogPLS = false;
  351. },
  352. /**
  353. * 窗口下载模板
  354. */
  355. getDowm() {
  356. let url = baseUrls.BASE_IMG_URL + "/oss/images/file/20220214.xls";
  357. let link = document.createElement("a");
  358. let fileName = "导入模板" + ".xlsx";
  359. document.body.appendChild(link);
  360. link.href = url;
  361. link.dowmload = fileName;
  362. link.click();
  363. link.remove();
  364. },
  365. /**
  366. * 导入
  367. */
  368. importMobleadds(e) {
  369. var self = this;
  370. var file = e.target.files[0];
  371. let formData = new FormData();
  372. formData.append("file", file);
  373. this.$api
  374. .inquiresystemsubscribeimportIdsDataFilter(formData)
  375. .then((res) => {
  376. if (!res.data.length) {
  377. this.$message.warning("未检测到上传学员数据,请检查上传文件");
  378. return;
  379. }
  380. let idList = res.data.map((item) => {
  381. return item.idCard.toString();
  382. });
  383. if (this.idcordList) {
  384. var arr = this.idcordList.split("\n");
  385. var arrs = arr.concat(idList);
  386. var newArr = arrs.filter(function (value, index, self) {
  387. return self.indexOf(value) === index;
  388. });
  389. this.idcordList = newArr.join("\n");
  390. } else {
  391. var newArr = idList.filter(function (value, index, self) {
  392. return self.indexOf(value) === index;
  393. });
  394. this.idcordList = newArr.join("\n");
  395. }
  396. this.$message.success("上传成功");
  397. })
  398. .finally(() => {
  399. e.target.value = "";
  400. });
  401. },
  402. /**下载模板 */
  403. downModel() {
  404. if (!this.formData.applyId) {
  405. this.$message.warning("请选择考试计划");
  406. return;
  407. }
  408. if (!this.formData.applySiteAddress) {
  409. this.$message.warning("请选择考试地点");
  410. return;
  411. }
  412. var data = JSON.parse(JSON.stringify(this.formData));
  413. if (this.formData.idCards) {
  414. data.idCards = this.formData.idCards.split("\n");
  415. } else {
  416. this.$message.warning("请选择学员");
  417. return;
  418. }
  419. const indexs = this.examList.findIndex((item) => {
  420. return item.applyId == data.applyId;
  421. });
  422. data.applyName = this.examList[indexs].applyName;
  423. this.$api.inquiresystemsubscribeexportRegister(data).then((res) => {
  424. let url = baseUrls.baseURL + "common/download?fileName=" + res.msg;
  425. let link = document.createElement("a");
  426. let fileName = "导入模板" + ".xlsx";
  427. document.body.appendChild(link);
  428. link.href = url;
  429. link.dowmload = fileName;
  430. link.click();
  431. link.remove();
  432. });
  433. },
  434. /**
  435. * 下载错误数据
  436. */
  437. dowmErrorData() {
  438. this.$api
  439. .inquiresystemsubscribeexportexportErrorUpdate(this.tableDataError)
  440. .then((res) => {
  441. let url = baseUrls.baseURL + "common/download?fileName=" + res.msg;
  442. let link = document.createElement("a");
  443. let fileName = "导入模板" + ".xlsx";
  444. document.body.appendChild(link);
  445. link.href = url;
  446. link.dowmload = fileName;
  447. link.click();
  448. link.remove();
  449. });
  450. },
  451. },
  452. };
  453. </script>
  454. <style lang="less" scoped>
  455. .h4Sty {
  456. margin: 6px;
  457. font-size: 14px;
  458. }
  459. .exportBox {
  460. border: 1px solid #999;
  461. padding: 10px;
  462. margin-top: 10px;
  463. border-radius: 4px;
  464. }
  465. /deep/.el-button {
  466. border-radius: 8px;
  467. }
  468. /deep/.el-dialog {
  469. border-radius: 8px;
  470. .el-dialog__header {
  471. padding: 0;
  472. .hearders {
  473. height: 40px;
  474. display: flex;
  475. align-items: center;
  476. justify-content: space-between;
  477. padding: 0px 18px 0px 20px;
  478. border-bottom: 1px solid #e2e2e2;
  479. .leftTitle {
  480. font-size: 14px;
  481. font-weight: bold;
  482. color: #2f4378;
  483. }
  484. .rightBoxs {
  485. display: flex;
  486. align-items: center;
  487. img {
  488. width: 14px;
  489. height: 14px;
  490. margin-left: 13px;
  491. cursor: pointer;
  492. }
  493. }
  494. }
  495. }
  496. .el-dialog__footer {
  497. padding: 0;
  498. .dialog-footer {
  499. padding: 0px 40px;
  500. height: 70px;
  501. border-top: 1px solid #e2e2e2;
  502. display: flex;
  503. align-items: center;
  504. justify-content: flex-end;
  505. }
  506. }
  507. }
  508. .imgBox {
  509. width: 100%;
  510. // height: 210px;
  511. border: 1px solid #e2e2e2;
  512. border-radius: 8px;
  513. padding: 8px 8px 3px;
  514. display: flex;
  515. flex-direction: column;
  516. align-items: center;
  517. .imgLabel {
  518. flex: 1;
  519. width: 100%;
  520. border: 1px dotted #e2e2e2;
  521. color: #999;
  522. font-size: 14px;
  523. cursor: pointer;
  524. border-radius: 8px;
  525. .msPhoto {
  526. display: flex;
  527. justify-content: center;
  528. align-items: center;
  529. max-width: 100%;
  530. max-height: 270px;
  531. img {
  532. max-width: 100%;
  533. max-height: 270px;
  534. }
  535. }
  536. .imgbbx {
  537. display: flex;
  538. flex-direction: column;
  539. align-items: center;
  540. justify-content: center;
  541. width: 100%;
  542. height: 100%;
  543. i {
  544. font-weight: bold;
  545. margin: 14px 0;
  546. font-size: 24px;
  547. }
  548. }
  549. }
  550. p {
  551. margin: 5px 0px;
  552. }
  553. }
  554. .item {
  555. margin-top: 10px;
  556. margin-right: 20px;
  557. }
  558. </style>