index.vue 15 KB

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