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.
 
 
 
 
 
 

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