index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. <template>
  2. <div id="examNum">
  3. <table-list
  4. :tableSets="tableSet"
  5. :tableData="tableData"
  6. :navText="navText"
  7. @addClick="addClick"
  8. :loading="loading"
  9. @editInfo="editInfo"
  10. >
  11. <template slot="btn" slot-scope="props">
  12. <el-button type="text" @click="addClick(props.scope.row, 0)"
  13. >修改</el-button
  14. >
  15. <el-button type="text" @click="del(props.scope.row)">删除</el-button>
  16. </template>
  17. </table-list>
  18. <pagination
  19. :total="total"
  20. :pageSize="pageSize"
  21. :currentPage="currentPage"
  22. @handleSizeChange="handleSizeChange"
  23. @handleCurrentChange="handleCurrentChange"
  24. />
  25. <el-dialog
  26. @closed="loadingClose"
  27. :visible.sync="dialogVisible"
  28. width="560px"
  29. :show-close="false"
  30. :close-on-click-modal="false"
  31. >
  32. <div slot="title" class="hearders">
  33. <div class="leftTitle">
  34. {{ statusPop === 1 ? "添加" : statusPop === 0 ? "修改" : "详情" }}
  35. </div>
  36. <div class="rightBoxs">
  37. <img src="@/assets/images/Close@2x.png" alt="" @click="close" />
  38. </div>
  39. </div>
  40. <div>
  41. <el-form
  42. label-position="right"
  43. label-width="150px"
  44. :model="listData"
  45. :rules="rules"
  46. ref="listData"
  47. >
  48. <el-form-item label="商品类型" prop="goodsType">
  49. <el-select
  50. v-model="listData.goodsType"
  51. placeholder="请选择"
  52. disabled
  53. >
  54. <el-option
  55. v-for="item in options"
  56. :key="item.value"
  57. :label="item.label"
  58. :value="item.value"
  59. >
  60. </el-option>
  61. </el-select>
  62. </el-form-item>
  63. <el-form-item label="业务层级" prop="educationTypeId">
  64. <el-select
  65. v-model="listData.educationTypeId"
  66. placeholder="选择教育类型"
  67. @change="listData.businessId = ''"
  68. :disabled="statusPop === 0"
  69. >
  70. <el-option
  71. v-for="item in educationType"
  72. :key="item.id"
  73. :label="item.educationName"
  74. :value="item.id"
  75. >
  76. </el-option>
  77. </el-select>
  78. </el-form-item>
  79. <el-form-item
  80. label=""
  81. prop="businessId"
  82. v-if="listData.educationTypeId"
  83. >
  84. <el-select
  85. v-model="listData.businessId"
  86. :disabled="statusPop === 0"
  87. placeholder="选择业务层次"
  88. >
  89. <el-option
  90. v-for="item in businessList"
  91. :key="item.id"
  92. :label="item.projectName + '-' + item.businessName"
  93. :value="item.id"
  94. >
  95. </el-option>
  96. </el-select>
  97. </el-form-item>
  98. <el-form-item label="适用商品" prop="goodsId">
  99. <span v-if="!listData.businessId" style="color: #f56c6c"
  100. >请先选择业务层级</span
  101. >
  102. <el-checkbox-group
  103. v-model="listData.goodsId"
  104. v-else-if="listData.businessId && goodsList.length"
  105. >
  106. <el-checkbox
  107. v-for="(item, index) in goodsList"
  108. :key="index"
  109. :label="item.goodsId"
  110. :disabled="
  111. item.goodsStatus === 0 &&
  112. bfListData.goodsId.indexOf(item.goodsId) === -1
  113. "
  114. >{{ item.code + "-" + item.goodsName + "-" }}
  115. <span
  116. :style="
  117. item.goodsStatus === 0 &&
  118. bfListData.goodsId.indexOf(item.goodsId) === -1
  119. ? ''
  120. : 'color:#F56C6C'
  121. "
  122. >¥{{ item.standPrice }}</span
  123. ></el-checkbox
  124. >
  125. </el-checkbox-group>
  126. <span style="color: #f56c6c" v-else>该业务层级下,无适用商品</span>
  127. </el-form-item>
  128. <el-form-item label="考试次数" prop="examNumber"
  129. ><el-input-number
  130. :controls="false"
  131. :disabled="statusPop === 2"
  132. v-model="listData.examNumber"
  133. :precision="0"
  134. ></el-input-number
  135. ></el-form-item>
  136. <el-form-item label="前培(刷题)次数" prop="doNumber"
  137. ><el-input-number
  138. :controls="false"
  139. :disabled="statusPop === 2"
  140. v-model="listData.doNumber"
  141. :precision="0"
  142. ></el-input-number
  143. ></el-form-item>
  144. <el-form-item label="状态" prop="">
  145. <el-radio-group v-model="listData.status">
  146. <el-radio
  147. v-for="(item, index) in statusOptions"
  148. :key="index"
  149. :label="item.value"
  150. :disabled="statusPop === 2"
  151. >{{ item.label }}</el-radio
  152. >
  153. </el-radio-group>
  154. </el-form-item>
  155. </el-form>
  156. </div>
  157. <span slot="footer" class="dialog-footer">
  158. <el-button @click="close">取 消</el-button>
  159. <el-button
  160. type="primary"
  161. :loading="disabledBtn"
  162. v-if="statusPop !== 2"
  163. @click="submit('listData')"
  164. >确 定</el-button
  165. >
  166. </span>
  167. </el-dialog>
  168. </div>
  169. </template>
  170. <script>
  171. import { mapGetters } from "vuex";
  172. import searchBox from "@/components/searchBox";
  173. import tableList from "@/components/tableList";
  174. import pagination from "@/components/pagination";
  175. export default {
  176. name: "ExamNum",
  177. components: { searchBox, tableList, pagination },
  178. data() {
  179. return {
  180. disabledBtn: false,
  181. loading: false, //当前表单加载是否加载动画
  182. navText: {
  183. title: "配置考试次数前培次数",
  184. index: 0,
  185. ch: "条",
  186. num: true,
  187. choice: false,
  188. border: true,
  189. addHide: false,
  190. backFatherBtn: {
  191. status: false,
  192. title: "未定义",
  193. },
  194. },
  195. // 表单
  196. tableSet: [
  197. {
  198. label: "考次编码",
  199. prop: "code",
  200. hidden: true,
  201. },
  202. {
  203. label: "商品类型",
  204. prop: "goodsType",
  205. hidden: true,
  206. scope: "isOptions",
  207. options: [
  208. {
  209. label: "视频",
  210. value: 1,
  211. },
  212. {
  213. label: "题库",
  214. value: 2,
  215. },
  216. {
  217. label: "补考",
  218. value: 3,
  219. },
  220. {
  221. label: "前培",
  222. value: 4,
  223. },
  224. ],
  225. },
  226. {
  227. label: "教育类型",
  228. prop: "educationName",
  229. hidden: true,
  230. },
  231. {
  232. label: "业务层次",
  233. prop1: "projectName",
  234. prop2: "businessName",
  235. scope: "InfoMore",
  236. hidden: true,
  237. },
  238. {
  239. label: "适配商品",
  240. prop: "examNumberGoodsVos",
  241. prop1: "code",
  242. prop2: "goodsName",
  243. prop3: "standPrice",
  244. hidden: true,
  245. scope: "moreGoodsList",
  246. },
  247. {
  248. label: "考试次数",
  249. prop: "examNumber",
  250. hidden: true,
  251. },
  252. {
  253. label: "前培(刷题)次数",
  254. prop: "doNumber",
  255. hidden: true,
  256. },
  257. {
  258. label: "状态",
  259. prop: "status",
  260. hidden: true,
  261. scope: "status",
  262. },
  263. ],
  264. tableData: [], //表单数据
  265. total: 0, //一共多少条
  266. pageSize: 10, //每页多少条数据
  267. currentPage: 1, //当前页码
  268. // 弹窗数据
  269. listData: {
  270. examNumber: 0,
  271. doNumber: 0,
  272. },
  273. statusPop: -1,
  274. dialogVisible: false,
  275. options: [
  276. {
  277. label: "视频",
  278. value: 1,
  279. },
  280. {
  281. label: "题库",
  282. value: 2,
  283. },
  284. {
  285. label: "补考",
  286. value: 3,
  287. },
  288. {
  289. label: "前培",
  290. value: 4,
  291. },
  292. ],
  293. statusOptions: [
  294. {
  295. label: "启用",
  296. value: 1,
  297. },
  298. {
  299. label: "关闭",
  300. value: 0,
  301. },
  302. ],
  303. //表单验证
  304. rules: {
  305. goodsType: [
  306. { required: true, message: "请选择商品类型", trigger: "change" },
  307. ],
  308. educationTypeId: [
  309. { required: true, message: "请选择教育类型", trigger: "change" },
  310. ],
  311. businessId: [
  312. { required: true, message: "请选择业务层次", trigger: "change" },
  313. ],
  314. goodsId: [
  315. {
  316. type: "array",
  317. required: true,
  318. message: "请至少选择一个商品",
  319. trigger: "change",
  320. },
  321. ],
  322. examNumber: [
  323. {
  324. required: true,
  325. type: "number",
  326. min: 0,
  327. message: "请重新输入考试次数",
  328. trigger: "blur",
  329. },
  330. ],
  331. doNumber: [
  332. {
  333. required: true,
  334. type: "number",
  335. min: 0,
  336. message: "请重新输入前培(刷题)次数",
  337. trigger: "blur",
  338. },
  339. ],
  340. status: [{ required: true, message: "请选择状态", trigger: "change" }],
  341. },
  342. busList: [],
  343. businessList: [],
  344. goodsList: [],
  345. bfListData: {},
  346. examNumber: 0,
  347. doNumber: 0,
  348. };
  349. },
  350. computed: { ...mapGetters(["educationType"]) },
  351. mounted() {
  352. this.getDict();
  353. this.search();
  354. },
  355. activated() {
  356. this.getDict();
  357. this.search();
  358. },
  359. watch: {
  360. "listData.educationTypeId"(value) {
  361. this.businessList = this.busList.filter((item) => {
  362. return item.educationId == value;
  363. });
  364. },
  365. "listData.businessId"(value) {
  366. if (value) {
  367. if (this.statusPop === 1) {
  368. this.listData.goodsId = [];
  369. }
  370. this.$api
  371. .inquiresystemnumberlistGoods({ businessId: value, goodsType: 1 })
  372. .then((res) => {
  373. this.goodsList = res.rows;
  374. });
  375. }
  376. },
  377. },
  378. methods: {
  379. loadingClose() {
  380. this.disabledBtn = false;
  381. },
  382. getDict() {
  383. this.$api.inquirebusinessList({ status: 1 }).then((res) => {
  384. this.busList = res.rows;
  385. });
  386. },
  387. editInfo(v) {
  388. this.addClick(v, 0);
  389. },
  390. search(v) {
  391. this.loading = true;
  392. var data = {
  393. status: "0,1",
  394. pageSize: this.pageSize,
  395. pageNum: this.currentPage,
  396. };
  397. this.$api
  398. .inquiresystemnumber(data)
  399. .then((res) => {
  400. this.tableData = res.rows;
  401. this.total = res.total;
  402. this.navText.index = res.total;
  403. })
  404. .finally(() => {
  405. this.loading = false;
  406. });
  407. },
  408. init() {
  409. this.search();
  410. },
  411. del(v) {
  412. this.$alert(
  413. "确定删除此内容?<br />内容删除后将无法恢复,请慎重考虑",
  414. "提示",
  415. {
  416. dangerouslyUseHTMLString: true,
  417. }
  418. )
  419. .then(() => {
  420. var data = {
  421. examNumberId: v.examNumberId,
  422. status: -1,
  423. };
  424. this.$api.editsystemnumber(data).then((res) => {
  425. this.$message.success("删除成功");
  426. this.search();
  427. });
  428. })
  429. .catch(() => {
  430. this.$message({
  431. type: "info",
  432. message: "已取消删除",
  433. });
  434. });
  435. },
  436. addClick(v, int) {
  437. if (v === undefined) {
  438. this.goodsList = [];
  439. this.statusPop = 1;
  440. this.examNumber = 0;
  441. this.doNumber = 0;
  442. this.bfListData = {
  443. goodsId: [],
  444. };
  445. this.listData = {
  446. goodsType: 1,
  447. status: 1,
  448. businessId: "",
  449. goodsId: [],
  450. examNumber: 0,
  451. doNumber: 0,
  452. };
  453. this.rules.examNumber[0].min = 0;
  454. this.rules.doNumber[0].min = 0;
  455. this.rules.examNumber[0].message = "考试次数不得小于" + 0 + "次";
  456. this.rules.doNumber[0].message = "前培次数不得小于" + 0 + "次";
  457. this.$nextTick(() => {
  458. this.$refs.listData.clearValidate();
  459. });
  460. this.dialogVisible = true;
  461. } else {
  462. this.statusPop = int;
  463. this.$api.obtainsystemnumber(v.examNumberId).then((res) => {
  464. this.$api
  465. .inquiresystemnumberlistGoods({
  466. businessId: res.data.businessId,
  467. goodsType: 1,
  468. })
  469. .then((result) => {
  470. this.goodsList = result.rows;
  471. });
  472. this.bfListData = JSON.parse(JSON.stringify(res.data));
  473. this.rules.examNumber[0].min = this.bfListData.examNumber;
  474. this.rules.examNumber[0].message =
  475. "考试次数不得小于" + this.bfListData.examNumber + "次";
  476. this.rules.doNumber[0].min = this.bfListData.doNumber;
  477. this.rules.doNumber[0].message =
  478. "前培次数不得小于" + this.bfListData.doNumber + "次";
  479. this.examNumber = this.bfListData.examNumber;
  480. this.doNumber = this.bfListData.doNumber;
  481. this.listData = res.data;
  482. this.$nextTick(() => {
  483. this.$refs.listData.clearValidate();
  484. });
  485. this.dialogVisible = true;
  486. });
  487. }
  488. },
  489. submit(formName) {
  490. this.$refs[formName].validate((valid) => {
  491. if (valid) {
  492. this.rulesTableSumbit();
  493. } else {
  494. return false;
  495. }
  496. });
  497. },
  498. rulesTableSumbit() {
  499. this.disabledBtn = true;
  500. var data = JSON.parse(JSON.stringify(this.listData));
  501. this.busList.map((item) => {
  502. if (item.id === data.businessId) {
  503. data.projectId = item.projectId;
  504. }
  505. });
  506. if (this.statusPop === 1) {
  507. this.$api
  508. .appsystemnumber(data)
  509. .then((res) => {
  510. this.$message.success("新增成功");
  511. this.dialogVisible = false;
  512. this.search();
  513. })
  514. .catch(() => {
  515. this.disabledBtn = false;
  516. });
  517. }
  518. if (this.statusPop === 0) {
  519. this.$api
  520. .editsystemnumber(data)
  521. .then((res) => {
  522. this.$message.success("修改成功");
  523. this.dialogVisible = false;
  524. this.search();
  525. })
  526. .catch(() => {
  527. this.disabledBtn = false;
  528. });
  529. }
  530. },
  531. close() {
  532. this.dialogVisible = false;
  533. },
  534. handleSizeChange(v) {
  535. this.pageSize = v;
  536. this.currentPage = 1;
  537. this.search();
  538. },
  539. handleCurrentChange(v) {
  540. this.currentPage = v;
  541. this.search();
  542. },
  543. },
  544. };
  545. </script>
  546. <style lang="less" scoped>
  547. /deep/ .el-checkbox-group {
  548. max-height: 260px;
  549. overflow-y: auto;
  550. border: 1px solid #eee;
  551. padding: 10px;
  552. }
  553. /deep/.el-button {
  554. border-radius: 8px;
  555. }
  556. /deep/.el-dialog {
  557. border-radius: 8px;
  558. .el-dialog__header {
  559. padding: 0;
  560. .hearders {
  561. height: 40px;
  562. display: flex;
  563. align-items: center;
  564. justify-content: space-between;
  565. padding: 0px 18px 0px 20px;
  566. border-bottom: 1px solid #e2e2e2;
  567. .leftTitle {
  568. font-size: 14px;
  569. font-weight: bold;
  570. color: #2f4378;
  571. }
  572. .rightBoxs {
  573. display: flex;
  574. align-items: center;
  575. img {
  576. width: 14px;
  577. height: 14px;
  578. margin-left: 13px;
  579. cursor: pointer;
  580. }
  581. }
  582. }
  583. }
  584. .el-dialog__footer {
  585. padding: 0;
  586. .dialog-footer {
  587. padding: 0px 40px;
  588. height: 70px;
  589. border-top: 1px solid #e2e2e2;
  590. display: flex;
  591. align-items: center;
  592. justify-content: flex-end;
  593. }
  594. }
  595. }
  596. .imgBox {
  597. width: 100%;
  598. // height: 210px;
  599. border: 1px solid #e2e2e2;
  600. border-radius: 8px;
  601. padding: 8px 8px 3px;
  602. display: flex;
  603. flex-direction: column;
  604. align-items: center;
  605. .imgLabel {
  606. flex: 1;
  607. width: 100%;
  608. border: 1px dotted #e2e2e2;
  609. color: #999;
  610. font-size: 14px;
  611. cursor: pointer;
  612. border-radius: 8px;
  613. .msPhoto {
  614. display: flex;
  615. justify-content: center;
  616. align-items: center;
  617. max-width: 100%;
  618. max-height: 270px;
  619. img {
  620. max-width: 100%;
  621. max-height: 270px;
  622. }
  623. }
  624. .imgbbx {
  625. display: flex;
  626. flex-direction: column;
  627. align-items: center;
  628. justify-content: center;
  629. width: 100%;
  630. height: 100%;
  631. i {
  632. font-weight: bold;
  633. margin: 14px 0;
  634. font-size: 24px;
  635. }
  636. }
  637. }
  638. p {
  639. margin: 5px 0px;
  640. }
  641. }
  642. </style>