You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

353 lines
9.7 KiB

  1. <template>
  2. <view class="page">
  3. <!-- 主列表页 -->
  4. <view :class="sideOpen ? 'show' : ''" class="mainpage" style="padding-top: 80rpx;">
  5. <!-- 顶部条目/分页信息栏 -->
  6. <l-customlist-banner @buttonClick="sideOpen = true">{{ tips }}</l-customlist-banner>
  7. <!-- 滚动列表,跨端支持上拉/下拉 -->
  8. <l-scroll-list v-if="ready" @pullDown="pullDown" @toBottom="fetchList()" ref="list">
  9. <l-customlist :tips="loadState" showTips>
  10. <!-- 单条记录 -->
  11. <view class="customlist-item" v-for="item of list" :key="item.EPIId">
  12. <view class="customlist-item-field">
  13. <text class="customlist-item-field-title">考试日期:</text>
  14. {{ displayListItem(item, 'ExamDate') }}
  15. </view>
  16. <view class="customlist-item-field">
  17. <text class="customlist-item-field-title">考试时间:</text>
  18. {{ displayListItem(item, 'ExamTime') }}
  19. </view>
  20. <view class="customlist-item-field">
  21. <text class="customlist-item-field-title">课程编号:</text>
  22. {{ displayListItem(item, 'LessonNo') }}
  23. </view>
  24. <view class="customlist-item-field">
  25. <text class="customlist-item-field-title">课程名称:</text>
  26. {{ displayListItem(item, 'LessonName') }}
  27. </view>
  28. <view class="customlist-item-field">
  29. <text class="customlist-item-field-title">教室名称:</text>
  30. {{ displayListItem(item, 'ClassroomName') }}
  31. </view>
  32. <!-- <l-customlist-action showEdit @edit="action('edit', item.EPIId)" showDelete @delete="action('delete', item.EPIId)" @view="action('view', item.EPIId)" /> -->
  33. </view>
  34. </l-customlist>
  35. </l-scroll-list>
  36. </view>
  37. <!-- 关闭侧边抽屉按钮 -->
  38. <view @click="sideOpen = false" :class="sideOpen ? 'show' : ''" class="sideclose">
  39. <l-icon type="pullright" color="blue" />
  40. </view>
  41. <!-- 侧边栏,用于设置查询条件 -->
  42. <scroll-view :class="sideOpen ? 'show' : ''" class="sidepage" scroll-y>
  43. <view v-if="ready" class="padding">
  44. <l-customlist-sidepage-datefilter v-model="dateRange" @change="searchChange" title="按时间日期查询: "
  45. ref="datefilter" class="margin-bottom" />
  46. <l-input v-model="queryData.LessonName" @change="searchChange" title="课程" placeholder="按课程查询" />
  47. <!-- 重置查询条件按钮 -->
  48. <view class="padding-tb">
  49. <l-button @click="reset" line="orange" class="block" block>重置查询条件</l-button>
  50. </view>
  51. </view>
  52. </scroll-view>
  53. <!-- <l-customlist-add v-if="!sideOpen" @click="action('add')" /> -->
  54. </view>
  55. </template>
  56. <script>
  57. /*
  58. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  59. * Copyright (c) 2013-2020 上海力软信息技术有限公司
  60. * 创建人:超级管理员
  61. * 日 期:2020-10-14 11:43
  62. * 描 述:1111
  63. */
  64. /**
  65. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  66. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  67. * { "path": "pages/EducationalAdministration/ArrangeExamTermNew/list", "style": { "navigationBarTitleText": "表单列表页" } }
  68. *
  69. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  70. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  71. */
  72. import moment from 'moment'
  73. import get from 'lodash/get'
  74. import set from 'lodash/set'
  75. import pickBy from 'lodash/pickBy'
  76. import mapValues from 'lodash/mapValues'
  77. import common from '@/common/js/common.js'
  78. export default {
  79. data() {
  80. return {
  81. semester:'',
  82. // 数据项的数据类型、结构
  83. scheme: {
  84. ClassroomName: {
  85. type: 'text'
  86. },
  87. ClassroomNo: {
  88. type: 'text'
  89. },
  90. EPIId: {
  91. type: 'text'
  92. },
  93. EPId: {
  94. type: 'text'
  95. },
  96. EmpName: {
  97. type: 'text'
  98. },
  99. EmpNo: {
  100. type: 'text'
  101. },
  102. ExamDate: {
  103. type: 'datetime',dateformat: '0'
  104. },
  105. ExamTime: {
  106. type: 'text'
  107. },
  108. F_SchoolId: {
  109. type: 'text'
  110. },
  111. LessonName: {
  112. type: 'text'
  113. },
  114. LessonNo: {
  115. type: 'text'
  116. },
  117. },
  118. // 查询条件
  119. searchData: {
  120. EmpNo: this.GET_GLOBAL('loginUser').account
  121. },
  122. defaultQueryData: {},
  123. queryData: {
  124. //查询条件的文本框
  125. EmpNo: this.GET_GLOBAL('loginUser').account,
  126. LessonName:'',
  127. },
  128. // 数据源
  129. dataSource: {
  130. // LessonNo: [],
  131. },
  132. // 时间查询参数
  133. dateRange: null,
  134. // 页面相关参数
  135. ready: false,
  136. tips: '加载中...',
  137. loadState: '向下翻以加载更多',
  138. sideOpen: false,
  139. // 列表与分页信息
  140. page: 1,
  141. total: 2,
  142. list: []
  143. }
  144. },
  145. async onLoad() {
  146. this.semester = common.judgeDate();
  147. await this.init()
  148. },
  149. onUnload() {
  150. this.OFF('EducationalAdministrationArrangeExamTermNew-list-change')
  151. },
  152. methods: {
  153. // 页面初始化
  154. async init() {
  155. let _this = this;
  156. _this.searchData.EmpNo = this.GET_GLOBAL('loginUser').account;
  157. this.ON('EducationalAdministrationArrangeExamTermNew-list-change', this.refreshList)
  158. // 拉取加载列表和数据源
  159. await Promise.all([
  160. // this.FETCH_DATASOURCE('LessonInfo').then(result => {
  161. // this.dataSource.LessonNo = result.data.sort((a,b)=>{return b.lessonno.lessonno}).map(t => ({ text: t.lessonname, value: t.lessonno }))
  162. // }),
  163. () => {}
  164. ])
  165. await this.fetchList()
  166. // 初始化查询条件
  167. this.defaultQueryData = this.COPY(this.queryData)
  168. this.ready = true
  169. },
  170. // 拉取列表
  171. async fetchList(isConcat = true) {
  172. // if (this.page > this.total) { return }
  173. let AcademicYearNo = '',Semester = '';
  174. if(this.semester){
  175. console.log(this.semester)
  176. AcademicYearNo = this.semester.substring(2,4) + '-' +this.semester.substring(7,9)
  177. Semester = this.semester.substring(12,13) == '二'?'2':'1'
  178. }
  179. const result = await this.HTTP_GET(
  180. 'learun/ask/testlist', {
  181. // 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
  182. // 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
  183. pagination: {
  184. rows: 10,
  185. page: this.page,
  186. sidx: 'ExamDate desc,ExamTime asc,LessonNo asc,ClassroomNo asc',
  187. sord: 'DESC'
  188. },
  189. queryJson: JSON.stringify({...this.searchData,AcademicYearNo,Semester})
  190. },
  191. '加载数据时出错'
  192. )
  193. if (!result) {
  194. return
  195. }
  196. this.total = result.total
  197. this.page = result.page + 1
  198. this.list = isConcat?this.list.concat(result.rows):result.rows
  199. this.tips = `已加载 ${Math.min(result.page, result.total)} / ${result.total} 页,共 ${result.records} 项`
  200. this.loadState = result.page >= result.total ? '已加载所有项目' : '向下翻以加载更多'
  201. },
  202. // 刷新清空列表
  203. async refreshList() {
  204. this.page = 1
  205. this.total = 2
  206. this.list = []
  207. await this.fetchList(false)
  208. },
  209. // 列表下拉
  210. pullDown() {
  211. this.refreshList().then(() => {
  212. this.$refs.list.stopPullDown()
  213. })
  214. },
  215. // 设置搜索条件
  216. async searchChange() {
  217. const result = {}
  218. //
  219. // 时间查询相关参数
  220. if (this.dateRange) {
  221. result.StartTime = this.dateRange.start
  222. result.EndTime = this.dateRange.end
  223. }
  224. // 将其他查询项添加到查询 JSON 中
  225. const queryObj = pickBy(this.queryData, t => (Array.isArray(t) ? t.length > 0 : t))
  226. Object.assign(result, mapValues(queryObj, t => (Array.isArray(t) ? t.join(',') : t)))
  227. this.searchData = result
  228. await this.refreshList()
  229. },
  230. // 点击「清空查询条件」按钮
  231. reset() {
  232. this.$refs.datefilter.changeDateRange('all')
  233. this.queryData = this.COPY(this.defaultQueryData)
  234. this.searchChange()
  235. },
  236. // 点击「编辑」、「查看」、「添加」、「删除」按钮
  237. async action(type, id = '') {
  238. switch (type) {
  239. case 'view':
  240. this.NAV_TO(`./single?type=view&id=${id}`)
  241. return
  242. case 'add':
  243. this.NAV_TO('./single?type=create')
  244. return
  245. case 'edit':
  246. this.NAV_TO(`./single?type=edit&id=${id}`)
  247. return
  248. case 'delete':
  249. if (!(await this.CONFIRM('删除项目', '确定要删除该项吗?', true))) {
  250. return
  251. }
  252. this.HTTP_POST('learun/adms/EducationalAdministration/ArrangeExamTermNew/delete', id, '删除失败')
  253. .then(success => {
  254. if (!success) {
  255. return
  256. }
  257. this.TOAST('删除成功', 'success')
  258. this.refreshList()
  259. })
  260. return
  261. default:
  262. return
  263. }
  264. },
  265. // 显示列表中的标题项
  266. displayListItem(item, field) {
  267. const fieldItem = this.scheme[field]
  268. const value = item[field]
  269. switch (fieldItem.type) {
  270. case 'currentInfo':
  271. case 'organize':
  272. return fieldItem.dataType === 'time' ? value : get(this.GET_GLOBAL(fieldItem.dataType),
  273. `${value}.name`, '')
  274. case 'radio':
  275. case 'select':
  276. const selectItem = this.dataSource[field].find(t => t.value === String(value))
  277. return get(selectItem, 'text', '')
  278. case 'checkbox':
  279. if (!value || value.split(',').length <= 0) {
  280. return ''
  281. }
  282. const checkboxItems = value.split(',')
  283. return this.dataSource[field].filter(t => checkboxItems.includes(t.value)).map(t => t.text).join(
  284. ',')
  285. case 'datetime':
  286. if (!value) {
  287. return ''
  288. }
  289. return moment(value).format(Number(fieldItem.dateformat) === 0 ? 'YYYY年 M月 D日' :
  290. 'YYYY-MM-DD HH:mm')
  291. default:
  292. return value === null || value === undefined ? '' : value
  293. }
  294. }
  295. }
  296. }
  297. </script>
  298. <style lang="less" scoped>
  299. @import '~@/common/css/sidepage.less';
  300. @import '~@/common/css/customlist.less';
  301. </style>