index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <div id="Mybank">
  3. <div class="no-data" v-if="!bankData.goodsName">暂无可以学习的题库哦~</div>
  4. <div v-else>
  5. <h4 class="headerTitle">
  6. <span v-if="bankData.subjectNames">【{{ bankData.subjectNames }}】</span
  7. >{{ bankData.goodsName
  8. }}<el-button
  9. size="mini"
  10. type="primary"
  11. plain
  12. icon="el-icon-sort"
  13. style="margin-left: 14px"
  14. @click="changeBank"
  15. >切换题库</el-button
  16. >
  17. </h4>
  18. <bank-detail-copy ref="bankDetailCopy" />
  19. </div>
  20. <el-dialog title="切换题库" :visible.sync="dialogVisible" width="500px">
  21. <el-radio-group v-model="activeRadio">
  22. <el-radio
  23. v-for="(item, index) in list"
  24. :key="index"
  25. :label="item.goodsId"
  26. >{{ item.goodsName }}</el-radio
  27. >
  28. </el-radio-group>
  29. <span slot="footer" class="dialog-footer">
  30. <el-button @click="dialogVisible = false">取 消</el-button>
  31. <el-button type="primary" @click="activeFunc">确 定</el-button>
  32. </span>
  33. </el-dialog>
  34. </div>
  35. </template>
  36. <script>
  37. import bankDetailCopy from "../bank-detailCopy/index.vue";
  38. export default {
  39. name: "Mybank",
  40. components: { bankDetailCopy },
  41. data() {
  42. return {
  43. bankData: {},
  44. dialogVisible: false,
  45. list: [],
  46. activeRadio: "",
  47. };
  48. },
  49. mounted() {
  50. this.getList();
  51. },
  52. methods: {
  53. getInfoData(data) {
  54. return new Promise((resolve, reject) => {
  55. this.$request.goodsDetail(data.goodsId).then((res) => {
  56. res.data.orderGoodsId = data.orderGoodsId;
  57. resolve(res.data);
  58. });
  59. });
  60. },
  61. getList() {
  62. this.$request.examrecordgetUserDoLast().then(async (res) => {
  63. if (res.data.goodsId) {
  64. const result = await this.getInfoData(res.data);
  65. this.bankData = result;
  66. this.$nextTick(() => {
  67. this.$refs.bankDetailCopy.initData(this.bankData,res.data);
  68. });
  69. } else {
  70. this.$request
  71. .listGoodsUserQuestion({ pageNum: 1, pageSize: 1 })
  72. .then((res) => {
  73. if (res.rows.length > 0) {
  74. this.bankData = res.rows[0];
  75. this.$nextTick(() => {
  76. this.$refs.bankDetailCopy.initData(this.bankData);
  77. });
  78. }
  79. });
  80. }
  81. });
  82. },
  83. /**
  84. * 切换题库
  85. */
  86. changeBank() {
  87. this.activeRadio = this.bankData.goodsId || "";
  88. this.$request.listGoodsUserQuestion().then((res) => {
  89. this.list = res.rows;
  90. this.dialogVisible = true;
  91. });
  92. },
  93. /**
  94. * 确定选中
  95. */
  96. activeFunc() {
  97. for (let i = 0; i < this.list.length; i++) {
  98. if (this.list[i].goodsId == this.activeRadio) {
  99. this.$refs.bankDetailCopy.initData(this.list[i]);
  100. this.bankData = this.list[i];
  101. this.dialogVisible = false;
  102. }
  103. }
  104. },
  105. },
  106. };
  107. </script>
  108. <style lang="scss" scoped>
  109. .headerTitle {
  110. padding: 30px 0px;
  111. font-size: 24px;
  112. font-weight: bold;
  113. color: #222;
  114. }
  115. </style>