index.vue 9.8 KB

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