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.
 
 
 
 
 
 

345 lines
9.4 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. export default {
  78. data() {
  79. return {
  80. // 数据项的数据类型、结构
  81. scheme: {
  82. ClassroomName: {
  83. type: 'text'
  84. },
  85. ClassroomNo: {
  86. type: 'text'
  87. },
  88. EPIId: {
  89. type: 'text'
  90. },
  91. EPId: {
  92. type: 'text'
  93. },
  94. EmpName: {
  95. type: 'text'
  96. },
  97. EmpNo: {
  98. type: 'text'
  99. },
  100. ExamDate: {
  101. type: 'datetime',dateformat: '0'
  102. },
  103. ExamTime: {
  104. type: 'text'
  105. },
  106. F_SchoolId: {
  107. type: 'text'
  108. },
  109. LessonName: {
  110. type: 'text'
  111. },
  112. LessonNo: {
  113. type: 'text'
  114. },
  115. },
  116. // 查询条件
  117. searchData: {
  118. EmpNo: this.GET_GLOBAL('loginUser').account
  119. },
  120. defaultQueryData: {},
  121. queryData: {
  122. //查询条件的文本框
  123. EmpNo: this.GET_GLOBAL('loginUser').account,
  124. LessonName:'',
  125. },
  126. // 数据源
  127. dataSource: {
  128. // LessonNo: [],
  129. },
  130. // 时间查询参数
  131. dateRange: null,
  132. // 页面相关参数
  133. ready: false,
  134. tips: '加载中...',
  135. loadState: '向下翻以加载更多',
  136. sideOpen: false,
  137. // 列表与分页信息
  138. page: 1,
  139. total: 2,
  140. list: []
  141. }
  142. },
  143. async onLoad() {
  144. await this.init()
  145. },
  146. onUnload() {
  147. this.OFF('EducationalAdministrationArrangeExamTermNew-list-change')
  148. },
  149. methods: {
  150. // 页面初始化
  151. async init() {
  152. let _this = this;
  153. _this.searchData.EmpNo = this.GET_GLOBAL('loginUser').account;
  154. this.ON('EducationalAdministrationArrangeExamTermNew-list-change', this.refreshList)
  155. // 拉取加载列表和数据源
  156. await Promise.all([
  157. // this.FETCH_DATASOURCE('LessonInfo').then(result => {
  158. // this.dataSource.LessonNo = result.data.sort((a,b)=>{return b.lessonno.lessonno}).map(t => ({ text: t.lessonname, value: t.lessonno }))
  159. // }),
  160. () => {}
  161. ])
  162. await this.fetchList()
  163. // 初始化查询条件
  164. this.defaultQueryData = this.COPY(this.queryData)
  165. this.ready = true
  166. },
  167. // 拉取列表
  168. async fetchList(isConcat = true) {
  169. // if (this.page > this.total) { return }
  170. const result = await this.HTTP_GET(
  171. 'learun/ask/testlist', {
  172. // 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
  173. // 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
  174. pagination: {
  175. rows: 10,
  176. page: this.page,
  177. sidx: 'ExamDate desc,ExamTime asc,LessonNo asc,ClassroomNo asc',
  178. sord: 'DESC'
  179. },
  180. queryJson: JSON.stringify(this.searchData)
  181. },
  182. '加载数据时出错'
  183. )
  184. if (!result) {
  185. return
  186. }
  187. this.total = result.total
  188. this.page = result.page + 1
  189. this.list = isConcat?this.list.concat(result.rows):result.rows
  190. this.tips = `已加载 ${Math.min(result.page, result.total)} / ${result.total} 页,共 ${result.records} 项`
  191. this.loadState = result.page >= result.total ? '已加载所有项目' : '向下翻以加载更多'
  192. },
  193. // 刷新清空列表
  194. async refreshList() {
  195. this.page = 1
  196. this.total = 2
  197. this.list = []
  198. await this.fetchList(false)
  199. },
  200. // 列表下拉
  201. pullDown() {
  202. this.refreshList().then(() => {
  203. this.$refs.list.stopPullDown()
  204. })
  205. },
  206. // 设置搜索条件
  207. async searchChange() {
  208. const result = {}
  209. //
  210. // 时间查询相关参数
  211. if (this.dateRange) {
  212. result.StartTime = this.dateRange.start
  213. result.EndTime = this.dateRange.end
  214. }
  215. // 将其他查询项添加到查询 JSON 中
  216. const queryObj = pickBy(this.queryData, t => (Array.isArray(t) ? t.length > 0 : t))
  217. Object.assign(result, mapValues(queryObj, t => (Array.isArray(t) ? t.join(',') : t)))
  218. this.searchData = result
  219. await this.refreshList()
  220. },
  221. // 点击「清空查询条件」按钮
  222. reset() {
  223. this.$refs.datefilter.changeDateRange('all')
  224. this.queryData = this.COPY(this.defaultQueryData)
  225. this.searchChange()
  226. },
  227. // 点击「编辑」、「查看」、「添加」、「删除」按钮
  228. async action(type, id = '') {
  229. switch (type) {
  230. case 'view':
  231. this.NAV_TO(`./single?type=view&id=${id}`)
  232. return
  233. case 'add':
  234. this.NAV_TO('./single?type=create')
  235. return
  236. case 'edit':
  237. this.NAV_TO(`./single?type=edit&id=${id}`)
  238. return
  239. case 'delete':
  240. if (!(await this.CONFIRM('删除项目', '确定要删除该项吗?', true))) {
  241. return
  242. }
  243. this.HTTP_POST('learun/adms/EducationalAdministration/ArrangeExamTermNew/delete', id, '删除失败')
  244. .then(success => {
  245. if (!success) {
  246. return
  247. }
  248. this.TOAST('删除成功', 'success')
  249. this.refreshList()
  250. })
  251. return
  252. default:
  253. return
  254. }
  255. },
  256. // 显示列表中的标题项
  257. displayListItem(item, field) {
  258. const fieldItem = this.scheme[field]
  259. const value = item[field]
  260. switch (fieldItem.type) {
  261. case 'currentInfo':
  262. case 'organize':
  263. return fieldItem.dataType === 'time' ? value : get(this.GET_GLOBAL(fieldItem.dataType),
  264. `${value}.name`, '')
  265. case 'radio':
  266. case 'select':
  267. const selectItem = this.dataSource[field].find(t => t.value === String(value))
  268. return get(selectItem, 'text', '')
  269. case 'checkbox':
  270. if (!value || value.split(',').length <= 0) {
  271. return ''
  272. }
  273. const checkboxItems = value.split(',')
  274. return this.dataSource[field].filter(t => checkboxItems.includes(t.value)).map(t => t.text).join(
  275. ',')
  276. case 'datetime':
  277. if (!value) {
  278. return ''
  279. }
  280. return moment(value).format(Number(fieldItem.dateformat) === 0 ? 'YYYY年 M月 D日' :
  281. 'YYYY-MM-DD HH:mm')
  282. default:
  283. return value === null || value === undefined ? '' : value
  284. }
  285. }
  286. }
  287. }
  288. </script>
  289. <style lang="less" scoped>
  290. @import '~@/common/css/sidepage.less';
  291. @import '~@/common/css/customlist.less';
  292. </style>