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.
 
 
 
 
 
 

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