index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. <template>
  2. <div id="baseAddPaper">
  3. <div class="boxWidth">
  4. <el-form
  5. label-position="right"
  6. label-width="120px"
  7. :model="listDataIns"
  8. :rules="rules"
  9. ref="listDataIns"
  10. >
  11. <el-form-item label="适用业务层级" :required="true">
  12. <el-select
  13. disabled
  14. v-model="eduType"
  15. placeholder="请选择教育类型"
  16. @change="changeEduType"
  17. >
  18. <el-option
  19. v-for="(item, index) in eduTypeOptions"
  20. :key="index"
  21. :label="item.educationName"
  22. :value="item.id"
  23. >
  24. </el-option>
  25. </el-select>
  26. <el-select
  27. disabled
  28. v-model="courType"
  29. placeholder="请选择业务层次"
  30. @change="changecourseType"
  31. >
  32. <el-option
  33. v-for="(item, index) in newCourTypeOptions"
  34. :key="index"
  35. :label="item.projectName + '-' + item.businessName"
  36. :value="item.id"
  37. >
  38. </el-option>
  39. </el-select>
  40. <el-popover
  41. ref="popovers"
  42. placement="bottom"
  43. trigger="click"
  44. @show="showHandle"
  45. @hide="hideHandle"
  46. :disabled="courType && newSujectOption.length ? false : true"
  47. >
  48. <el-radio-group v-model="sujectApis" class="dis_flexbox">
  49. <el-radio
  50. disabled
  51. v-for="(item, index) in newSujectOption"
  52. :label="item.newId"
  53. :key="index"
  54. >{{ item.subjectName }}</el-radio
  55. >
  56. </el-radio-group>
  57. <div style="display: block; text-align: center; margin-top: 10px">
  58. <el-button
  59. size="mini"
  60. type="primary"
  61. @click="submitSujectArray"
  62. v-if="false"
  63. >确定</el-button
  64. >
  65. </div>
  66. <el-button
  67. disabled
  68. slot="reference"
  69. style="margin-left: 12px"
  70. @click="getMessage"
  71. >请选择科目</el-button
  72. >
  73. </el-popover>
  74. </el-form-item>
  75. <el-form-item label="">
  76. <!-- <span v-if="Object.keys(newSujectApis).length == 0"
  77. >未选项目类型</span
  78. > -->
  79. <div
  80. v-if="Object.keys(newSujectApis).length !== 0"
  81. style="display: flex"
  82. >
  83. <div class="listBoxStys">
  84. {{
  85. newSujectApis.educationName +
  86. " - " +
  87. newSujectApis.projectName +
  88. " - " +
  89. newSujectApis.businessName +
  90. " - " +
  91. newSujectApis.subjectName
  92. }}
  93. <i
  94. class="el-icon-error closeIcons"
  95. @click="closeType"
  96. v-if="false"
  97. ></i>
  98. </div>
  99. </div>
  100. </el-form-item>
  101. <el-form-item label="试卷类型" prop="examPaperId">
  102. <el-select
  103. v-model="listDataIns.examPaperId"
  104. placeholder="请选择试卷类型"
  105. >
  106. <el-option
  107. v-for="item in paperexam"
  108. :key="item.paperId"
  109. :label="item.paperName"
  110. :value="item.paperId"
  111. >
  112. </el-option>
  113. </el-select>
  114. </el-form-item>
  115. <el-form-item label="地域(省)" prop="provinceId">
  116. <el-select
  117. v-model="listDataIns.provinceId"
  118. placeholder="请选择省"
  119. @change="changeCity"
  120. >
  121. <el-option
  122. v-for="item in areas"
  123. :key="item.areaId"
  124. :label="item.areaName"
  125. :value="item.areaId"
  126. >
  127. </el-option>
  128. </el-select>
  129. </el-form-item>
  130. <el-form-item
  131. label="地域(市)"
  132. prop="cityId"
  133. v-if="listDataIns.provinceId"
  134. >
  135. <el-select v-model="listDataIns.cityId" placeholder="请选择市">
  136. <el-option
  137. v-for="item in optionsCity"
  138. :key="item.areaId"
  139. :label="item.areaName"
  140. :value="item.areaId"
  141. >
  142. </el-option>
  143. </el-select>
  144. </el-form-item>
  145. <el-form-item label="年份" prop="year">
  146. <el-date-picker
  147. v-model="listDataIns.year"
  148. type="year"
  149. value-format="yyyy"
  150. placeholder="请选择年份"
  151. >
  152. </el-date-picker>
  153. </el-form-item>
  154. <el-form-item label="标题前缀" prop="prefixName">
  155. <el-input v-model="listDataIns.prefixName"></el-input>
  156. </el-form-item>
  157. <el-form-item label="试卷名称" prop="examName">
  158. <el-input v-model="listDataIns.examName"></el-input>
  159. </el-form-item>
  160. <el-form-item label="是否发布" prop="publishStatus">
  161. <el-radio-group v-model="listDataIns.publishStatus">
  162. <el-radio :label="1">是</el-radio>
  163. <el-radio :label="0">否</el-radio>
  164. </el-radio-group>
  165. </el-form-item>
  166. <el-form-item>
  167. <el-button @click="backPage">取消</el-button>
  168. <el-button
  169. type="primary"
  170. @click="submitIns('listDataIns')"
  171. :disabled="!noStudent"
  172. >确定</el-button
  173. >
  174. </el-form-item>
  175. </el-form>
  176. </div>
  177. </div>
  178. </template>
  179. <script>
  180. import tableList from "@/components/tableList";
  181. import { mapGetters } from "vuex";
  182. export default {
  183. components: { tableList },
  184. data() {
  185. return {
  186. listDataIns: {
  187. publishStatus: 1,
  188. year: "",
  189. }, // 弹窗数据
  190. eduTypeOptions: [], //教育类型数据
  191. projectTypeOptions: [], //项目类型数据
  192. courTypeOptions: [], //业务层次数据
  193. newCourTypeOptions: [], //当前业务层次数据
  194. sujectOption: [], //科目数据
  195. newSujectOption: [], //当前科目数据数据
  196. eduType: "", //当前选中教育类型
  197. courType: "", //当前选中业务层次
  198. newSujectApis: {},
  199. sujectApis: "", //当前存在的科目 例如'19-2'
  200. optionsCity: [],
  201. noStudent: true,
  202. //表单验证
  203. rules: {
  204. examPaperId: [
  205. {
  206. required: true,
  207. message: "请选择试卷类型",
  208. trigger: ["change", "blur"],
  209. },
  210. ],
  211. examName: [
  212. { required: true, message: "请输入试卷名称", trigger: "blur" },
  213. ],
  214. publishStatus: [
  215. { required: true, message: "请选择是否发布", trigger: "change" },
  216. ],
  217. },
  218. };
  219. },
  220. computed: {
  221. ...mapGetters(["paperexam", "areas"]),
  222. },
  223. mounted() {
  224. this.$modal.loading("正在导入数据,请稍后...");
  225. this.$api
  226. .gradecheckGoodsChange({ examId: this.$route.query.id })
  227. .then((res) => {
  228. console.log(res.data);
  229. if (res.data > 0) {
  230. this.noStudent = false;
  231. }
  232. });
  233. this.getDict();
  234. // this.search();
  235. },
  236. // watch: {
  237. // "listDataIns.provinceId": {
  238. // handler(newVal, oldVal) {
  239. // this.changeCity(newVal);
  240. // },
  241. // // 立即处理 进入页面就触发
  242. // immediate: true,
  243. // },
  244. // },
  245. methods: {
  246. getMessage() {
  247. if (!this.courType) {
  248. this.$message.warning("请先选择业务层级");
  249. } else if (!this.newSujectOption.length) {
  250. this.$message.warning("该业务层级暂无关联科目");
  251. }
  252. },
  253. search() {
  254. this.$api.obtainbankexam(this.$route.query.id).then((res) => {
  255. res.data.year = res.data.year + "";
  256. this.listDataIns = res.data;
  257. if (res.data.provinceId) {
  258. this.changeCity(res.data.provinceId, true);
  259. }
  260. });
  261. this.$api
  262. .inquirebankexamListbusiness({ type: 2, majorId: this.$route.query.id })
  263. .then((res) => {
  264. this.eduType = res.rows[0].educationTypeId;
  265. this.changeEduType();
  266. this.courType = res.rows[0].businessId;
  267. this.changecourseType();
  268. this.newSujectApis = res.rows[0];
  269. this.sujectApis =
  270. res.rows[0].businessId + "-" + res.rows[0].subjectId;
  271. })
  272. .finally(() => {
  273. this.$modal.closeLoading();
  274. });
  275. },
  276. changeCity(newVal, dray = false) {
  277. if (!dray) {
  278. this.listDataIns.cityId = "";
  279. }
  280. this.optionsCity = this.cityList.filter((item) => {
  281. return item.parentId === newVal;
  282. });
  283. },
  284. changeTypes() {
  285. var self = this;
  286. if (!this.sujectApis) {
  287. self.newSujectApis = {};
  288. return;
  289. }
  290. this.courTypeOptions.map((items) => {
  291. if (items.id === this.sujectApis.split("-").map(Number)[0]) {
  292. var obj = {
  293. type: 2,
  294. educationTypeId: items.educationId,
  295. educationName: items.educationName,
  296. projectId: items.projectId,
  297. projectName: items.projectName,
  298. businessId: items.id,
  299. businessName: items.businessName,
  300. };
  301. self.sujectOption.map((i) => {
  302. if (
  303. i.id === self.sujectApis.split("-").map(Number)[1] &&
  304. i.courseArrays.indexOf(items.projectId) !== -1
  305. ) {
  306. obj.subjectName = i.subjectName;
  307. obj.subjectId = i.id;
  308. }
  309. });
  310. self.newSujectApis = obj;
  311. }
  312. });
  313. },
  314. submitSujectArray() {
  315. this.changeTypes();
  316. this.$refs.popovers.doClose();
  317. },
  318. showHandle() {
  319. this.sujectApis = "";
  320. this.newSujectOption.map((item) => {
  321. item.newId = this.courType + "-" + item.id;
  322. if (item.newId === this.sujectApis) {
  323. console.log("成功");
  324. }
  325. });
  326. this.sujectApis =
  327. this.newSujectApis.businessId + "-" + this.newSujectApis.subjectId;
  328. },
  329. hideHandle() {},
  330. getDict() {
  331. new Promise((resolve, reject) => {
  332. this.$api.inquireCourseEducationType({ status: 1 }).then((res) => {
  333. this.eduTypeOptions = res.rows;
  334. });
  335. this.$api.inquireCourseProjectType({ status: 1 }).then((res) => {
  336. this.projectTypeOptions = res.rows;
  337. });
  338. this.$api
  339. .inquireapplyCityList({ areaType: 2, status: 1 })
  340. .then((res) => {
  341. this.cityList = res.rows;
  342. });
  343. this.$api.inquirebusinessList({ status: 1 }).then((res) => {
  344. this.courTypeOptions = res.rows;
  345. this.newCourTypeOptions = res.rows;
  346. });
  347. this.$api.inquireCourseSubject({ status: 1 }).then((res) => {
  348. res.rows.map((item, index) => {
  349. var array = [];
  350. item.courseProjectTypes.map((items, indexs) => {
  351. array.push(items.id);
  352. });
  353. item.courseArrays = array;
  354. });
  355. this.sujectOption = res.rows;
  356. resolve();
  357. });
  358. }).then((res) => {
  359. this.search();
  360. });
  361. },
  362. changeEduType() {
  363. if (!(this.courType === undefined || this.courType === "")) {
  364. this.courType = "";
  365. }
  366. var arrays = [];
  367. this.courTypeOptions.map((item) => {
  368. if (item.educationId === this.eduType) {
  369. arrays.push(item);
  370. }
  371. });
  372. this.newCourTypeOptions = arrays;
  373. },
  374. changecourseType() {
  375. this.newCourTypeOptions.map((item, index) => {
  376. if (item.id === this.courType) {
  377. this.eduType = item.educationId;
  378. var array = [];
  379. this.sujectOption.map((items, indexs) => {
  380. if (items.courseArrays.indexOf(item.projectId) !== -1) {
  381. array.push(items);
  382. }
  383. });
  384. this.newSujectOption = array;
  385. }
  386. });
  387. var arrays = [];
  388. this.courTypeOptions.map((item) => {
  389. if (item.educationId === this.eduType) {
  390. arrays.push(item);
  391. }
  392. });
  393. this.newCourTypeOptions = arrays;
  394. this.$refs.popovers.doClose();
  395. },
  396. submitIns(formName) {
  397. this.$refs[formName].validate((valid) => {
  398. if (valid) {
  399. if (JSON.stringify(this.newSujectApis) === "{}") {
  400. this.$message.error("请选择适用业务层级");
  401. return;
  402. }
  403. this.rulesTableSumbit();
  404. } else {
  405. return false;
  406. }
  407. });
  408. },
  409. async rulesTableSumbit() {
  410. var data1 = {
  411. examId: this.listDataIns.examId,
  412. examPaperId: this.listDataIns.examPaperId,
  413. examName: this.listDataIns.examName,
  414. publishStatus: this.listDataIns.publishStatus,
  415. prefixName: this.listDataIns.prefixName,
  416. businessList: [this.newSujectApis],
  417. provinceId: this.listDataIns.provinceId,
  418. cityId: this.listDataIns.cityId,
  419. year: this.listDataIns.year,
  420. };
  421. this.$api.editbankexam(data1).then((res) => {
  422. this.$message.success("修改成功");
  423. setTimeout(() => {
  424. this.$store.dispatch("tagsView/exitView", this.$route).then((res) => {
  425. this.$router.push({
  426. path: "testPaperManagement",
  427. });
  428. });
  429. }, 500);
  430. });
  431. },
  432. backPage() {
  433. this.$store.dispatch("tagsView/delView", this.$route).then((res) => {
  434. this.$router.push({
  435. path: "testPaperManagement",
  436. });
  437. });
  438. },
  439. closeType() {
  440. this.sujectApis = "";
  441. this.changeTypes();
  442. },
  443. },
  444. };
  445. </script>
  446. <style lang="less" scoped>
  447. .dis_flexbox {
  448. display: flex;
  449. flex-direction: column;
  450. }
  451. .boxWidth {
  452. width: 700px;
  453. }
  454. .numInputs {
  455. width: 150px;
  456. }
  457. .checkboxSty {
  458. max-height: 210px;
  459. overflow: auto;
  460. display: flex;
  461. flex-direction: column;
  462. }
  463. .listBoxStys {
  464. flex-shrink: 0;
  465. padding: 0px 10px;
  466. border-radius: 8px;
  467. border: 1px solid #eee;
  468. margin-right: 10px;
  469. margin-bottom: 6px;
  470. }
  471. .closeIcons {
  472. color: red;
  473. cursor: pointer;
  474. margin-left: 6px;
  475. }
  476. .ach {
  477. display: flex;
  478. align-items: center;
  479. overflow: hidden;
  480. }
  481. .clh {
  482. display: flex;
  483. align-items: center;
  484. flex-wrap: wrap;
  485. }
  486. .imgBoxins {
  487. width: 375px;
  488. height: 220px;
  489. text-align: center;
  490. img {
  491. height: 100%;
  492. }
  493. }
  494. .iconStsz {
  495. font-size: 40px;
  496. color: #67c23a;
  497. cursor: pointer;
  498. }
  499. .BusBoxs {
  500. min-height: 100px;
  501. border: 1px solid #a4a4a4;
  502. margin-bottom: 10px;
  503. border-radius: 8px;
  504. max-height: 280px;
  505. padding: 10px;
  506. overflow-y: auto;
  507. .fot_Le {
  508. border-radius: 12px;
  509. border: 1px solid yellowgreen;
  510. padding: 0px 10px;
  511. height: 30px;
  512. line-height: 30px;
  513. text-align: center;
  514. float: left;
  515. margin-right: 6px;
  516. margin-bottom: 6px;
  517. .icon_clear {
  518. margin-left: 2px;
  519. font-size: 15px;
  520. color: #f56c6c;
  521. cursor: pointer;
  522. }
  523. }
  524. }
  525. .marg_play {
  526. display: flex;
  527. margin-bottom: 15px;
  528. .spans {
  529. text-align: right;
  530. width: 80px;
  531. }
  532. }
  533. /deep/.el-button {
  534. border-radius: 8px;
  535. }
  536. /deep/.el-dialog {
  537. border-radius: 8px;
  538. .el-dialog__header {
  539. padding: 0;
  540. .hearders {
  541. height: 40px;
  542. display: flex;
  543. align-items: center;
  544. justify-content: space-between;
  545. padding: 0px 18px 0px 20px;
  546. border-bottom: 1px solid #e2e2e2;
  547. .leftTitle {
  548. font-size: 14px;
  549. font-weight: bold;
  550. color: #2f4378;
  551. }
  552. .rightBoxs {
  553. display: flex;
  554. align-items: center;
  555. img {
  556. width: 14px;
  557. height: 14px;
  558. margin-left: 13px;
  559. cursor: pointer;
  560. }
  561. }
  562. }
  563. }
  564. .el-dialog__footer {
  565. padding: 0;
  566. .dialog-footer {
  567. padding: 0px 40px;
  568. height: 70px;
  569. border-top: 1px solid #e2e2e2;
  570. display: flex;
  571. align-items: center;
  572. justify-content: center;
  573. }
  574. }
  575. }
  576. .centerStys {
  577. display: flex;
  578. align-items: center;
  579. justify-content: center;
  580. margin-top: 18px;
  581. }
  582. .dis_fos {
  583. align-items: flex-end;
  584. display: flex;
  585. justify-content: space-between;
  586. }
  587. .margin_bs {
  588. margin-bottom: 6px;
  589. }
  590. </style>