index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <view>
  3. <view class="head" catchtouchmove="true" @touchmove.stop.prevent="() => { }">
  4. <My_search :value="content.where.condition" @onSearch="onSearch">
  5. <view class="filtrate" v-if="filtrateList.length" hover-class="navigator-hover" @click="openFiltrate">
  6. 筛选
  7. <text class="iconfont icon-shaixuan" />
  8. </view>
  9. </My_search>
  10. <view class="crumbs">
  11. <view class="crumb" v-for="item in crumbs" :key="item.classname">{{ item.classname }}</view>
  12. </view>
  13. <u-tabs :list="status" :activeStyle="{ fontWeight: 'bold', color: '#C30D23' }" lineColor="#C30D23"
  14. keyName="name" @change="statusChange" />
  15. </view>
  16. <view style="height: 1px;" />
  17. <filtrate ref="Filtrate" :filtrateList="filtrateList" @onFiltration="onFiltration" @onInterrupt="onInterrupt" />
  18. <My_listbox ref="List" @getlist="getList">
  19. <view class="list-box">
  20. <navigator class="item" v-for="item in list" :key="item.sat_courseware_testheadid"
  21. :url="'/packageA/exam/detail?id=' + item.sat_courseware_testheadid">
  22. <view class="title u-line-2">{{ item.title || '--' }}</view>
  23. <view class="hr" />
  24. <view class="bottom">
  25. <view>
  26. 分数:<text class="score">{{ item.score }}</text>
  27. </view>
  28. <view>
  29. 答题数:{{ item.answerinfo }}
  30. </view>
  31. </view>
  32. <view class="status" v-if="item.status == '未开始'" style="background:#E3041F;color: #FFFFFF;">
  33. 未开始
  34. </view>
  35. <view class="status" v-else-if="item.status == '进行中'" style="background: #FFF0F2;color: #E3041F;">
  36. 进行中
  37. </view>
  38. <view class="status" v-else-if="item.status == '已完成'" style="background: #EEEEEE;color: #999999;">
  39. 已完成
  40. </view>
  41. </navigator>
  42. </view>
  43. </My_listbox>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. crumbs: [],
  51. list: [],
  52. "content": {
  53. "where": {
  54. "condition": "",
  55. "status": "",
  56. "sat_courseware_classids": [[]]
  57. }
  58. },
  59. filtrateList: [],
  60. status: [{
  61. name: "全部"
  62. }, {
  63. name: "未开始"
  64. }, {
  65. name: "进行中"
  66. }, {
  67. name: "已完成"
  68. }]
  69. }
  70. },
  71. onLoad(options) {
  72. this.crumbs = [{
  73. classname: "考试",
  74. parentid: ""
  75. }, {
  76. classname: "全部",
  77. parentid: ''
  78. }]
  79. this.getType()
  80. this.getList(true)
  81. uni.setNavigationBarTitle({
  82. title: '考试',
  83. })
  84. },
  85. onShow() {
  86. this.updateList()
  87. },
  88. methods: {
  89. getType() {
  90. this.$Http.basic({
  91. "id": "20221102143302",
  92. content: {
  93. pageSize: 9999,
  94. parentid: "",
  95. "where": {
  96. "isenable": 1
  97. }
  98. }
  99. }).then(res => {
  100. console.log("获取分类列表", res)
  101. if (this.cutoff(res.msg)) return;
  102. this.filtrateList = [{
  103. title: "一级分类",
  104. key: '一级分类',//提交时返回的Key
  105. showKey: "classname",//显示的key
  106. selected: "sat_courseware_classid",//选择时选择的字段
  107. value: "",//提交时选中的value
  108. defaultVal: "",//返回的默认值
  109. isAll: true,
  110. interrupt: true,
  111. rang: [{ classname: "全部", sat_courseware_classid: "", children: [] }].concat(res.data),//选择的范围
  112. }]
  113. })
  114. },
  115. getList(init = false) {
  116. if (this.paging(this.content, init)) return;
  117. let ids = this.crumbs.map(v => v.parentid).filter(v => v);
  118. this.content.where.sat_courseware_classids = ids.length ? [[ids[ids.length - 1]]] : []
  119. this.$Http.basic({
  120. "id": 20240326133302,
  121. content: this.content
  122. }).then(res => {
  123. this.$refs.List.RefreshToComplete()
  124. console.log("获取试卷列表", res)
  125. if (this.cutoff(res.msg)) return;
  126. this.list = res.pageNumber == 1 ? res.data : this.list.concat(res.data);
  127. this.content = this.$refs.List.paging(this.content, res)
  128. })
  129. },
  130. updateList() {
  131. if (this.content.pageNumber && this.content.pageNumber >= 2) {
  132. let content = this.paging(this.content, true, true)
  133. this.$Http.basic({
  134. "id": "20240326133302",
  135. content
  136. }).then(res => {
  137. console.log("更新试卷列表", res)
  138. if (this.cutoff(res.msg)) return;
  139. this.list = res.data;
  140. this.$refs.List.paging(content, res, true)
  141. })
  142. }
  143. },
  144. openFiltrate() {
  145. this.$refs.Filtrate.changeShow();
  146. },
  147. onSearch(condition) {
  148. this.content.where.condition = condition;
  149. this.getList(true)
  150. },
  151. onInterrupt({ item, index, option }) {
  152. let filtrateList = this.$refs.Filtrate.list;
  153. const i = filtrateList.findIndex(v => v.title == '二级分类');
  154. if (option.children.length) {
  155. const obj = {
  156. title: "二级分类",
  157. key: '二级分类',
  158. showKey: "classname",
  159. selected: "sat_courseware_classid",
  160. value: "",
  161. defaultVal: "",
  162. isAll: true,
  163. rang: [{ classname: "全部", sat_courseware_classid: "" }].concat(option.children),
  164. };
  165. i == -1 ? filtrateList.push(obj) : filtrateList[i] = obj;
  166. } else {
  167. i == -1 ? '' : filtrateList.pop();
  168. }
  169. this.$refs.Filtrate.list = filtrateList || JSON.parse(JSON.stringify());
  170. },
  171. onFiltration(e) {
  172. let crumbs = [{
  173. classname: "考试",
  174. parentid: ""
  175. }]
  176. crumbs.push({
  177. classname: e.一级分类.classname,
  178. parentid: e.一级分类.sat_courseware_classid
  179. })
  180. if (e.二级分类) crumbs.push({
  181. classname: e.二级分类.classname,
  182. parentid: e.二级分类.sat_courseware_classid
  183. })
  184. this.crumbs = crumbs;
  185. this.getList(true)
  186. },
  187. statusChange({ name }) {
  188. this.content.where.status = name == '全部' ? '' : name;
  189. this.getList(true)
  190. }
  191. }
  192. }
  193. </script>
  194. <style lang="scss">
  195. .head {
  196. padding: 10px;
  197. width: 100%;
  198. background: #fff;
  199. box-sizing: border-box;
  200. .filtrate {
  201. line-height: 30px;
  202. padding: 0 10px;
  203. font-family: PingFang SC, PingFang SC;
  204. font-size: 14px;
  205. color: #333333;
  206. border-radius: 3px;
  207. margin-left: 10px;
  208. .iconfont {
  209. margin-left: 3px;
  210. color: #BBBBBB;
  211. }
  212. }
  213. }
  214. .crumbs {
  215. display: flex;
  216. line-height: 17px;
  217. font-family: PingFang SC, PingFang SC;
  218. font-size: 12px;
  219. flex-wrap: wrap;
  220. width: 100%;
  221. margin-top: 10px;
  222. .crumb {
  223. flex-shrink: 0;
  224. }
  225. .crumb::after {
  226. content: ">";
  227. padding: 0 2px;
  228. }
  229. .crumb:last-child {
  230. font-weight: bold;
  231. }
  232. .crumb:last-child::after {
  233. content: "";
  234. }
  235. }
  236. .list-box {
  237. width: 100vw;
  238. padding: 10px;
  239. padding-top: 0;
  240. box-sizing: border-box;
  241. .item {
  242. position: relative;
  243. background: #FFFFFF;
  244. border-radius: 8px;
  245. margin-top: 10px;
  246. padding: 10px;
  247. padding-top: 15px;
  248. .title {
  249. width: 280px;
  250. line-height: 20px;
  251. height: 40px;
  252. font-family: Source Han Sans SC, Source Han Sans SC;
  253. font-weight: bold;
  254. font-size: 14px;
  255. color: #333333;
  256. }
  257. .hr {
  258. width: 100%;
  259. height: 1px;
  260. background: #DDDDDD;
  261. margin-top: 15px;
  262. }
  263. .status {
  264. position: absolute;
  265. top: 10px;
  266. right: 0;
  267. width: 44px;
  268. height: 24px;
  269. line-height: 24px;
  270. border-radius: 12px 0px 0px 12px;
  271. text-align: center;
  272. font-family: Source Han Sans SC, Source Han Sans SC;
  273. font-size: 12px;
  274. color: #FFFFFF;
  275. }
  276. .bottom {
  277. display: flex;
  278. justify-content: space-between;
  279. line-height: 20px;
  280. font-family: Source Han Sans SC, Source Han Sans SC;
  281. font-size: 14px;
  282. color: #666666;
  283. margin-top: 10px;
  284. .score {
  285. color: #E3041F;
  286. font-weight: bold;
  287. }
  288. }
  289. }
  290. }
  291. </style>