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.
 
 
 
 
 
 

257 lines
7.9 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.VID">
  12. <view class="customlist-item-field">
  13. <text class="customlist-item-field-title">学年:</text>
  14. {{ displayListItem(item, 'AcademicYearNo') }}
  15. </view>
  16. <view class="customlist-item-field">
  17. <text class="customlist-item-field-title">学期:</text>
  18. {{ displayListItem(item, 'Semester') }}
  19. </view>
  20. <view class="customlist-item-field">
  21. <text class="customlist-item-field-title">教师姓名:</text>
  22. {{ displayListItem(item, 'EmpName') }}
  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, 'UID') }}
  31. </view>
  32. <l-customlist-action @view="action('view', item)" />
  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. <!-- 重置查询条件按钮 -->
  45. <view class="padding-tb">
  46. <l-button @click="reset" line="orange" class="block" block>重置查询条件</l-button>
  47. </view>
  48. </view>
  49. </scroll-view>
  50. </view>
  51. </template>
  52. <script>
  53. /*
  54. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  55. * Copyright (c) 2013-2020 上海力软信息技术有限公司
  56. * 创建人:超级管理员
  57. * 日 期:2020-10-16 15:39
  58. * 描 述:掌上评教
  59. */
  60. /**
  61. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  62. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  63. * { "path": "pages/EducationalAdministration/EvaluationTeach/list", "style": { "navigationBarTitleText": "表单列表页" } }
  64. *
  65. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  66. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  67. */
  68. import moment from 'moment'
  69. import get from 'lodash/get'
  70. import set from 'lodash/set'
  71. import pickBy from 'lodash/pickBy'
  72. import mapValues from 'lodash/mapValues'
  73. export default {
  74. data() {
  75. return {
  76. // 数据项的数据类型、结构
  77. scheme: {
  78. AcademicYearNo: { type: 'text' },
  79. Semester: { type: 'text'},
  80. EmpName: { type: 'text'},
  81. LessonName: { type: 'text' },
  82. UID: { type: 'bit' },
  83. },
  84. // 查询条件
  85. searchData: {},
  86. defaultQueryData: {},
  87. queryData: {
  88. },
  89. // 数据源
  90. dataSource: {
  91. },
  92. // 页面相关参数
  93. ready: false,
  94. tips: '加载中...',
  95. loadState: '向下翻以加载更多',
  96. sideOpen: false,
  97. // 列表与分页信息
  98. page: 1,
  99. total: 2,
  100. list: []
  101. }
  102. },
  103. async onLoad() {
  104. await this.init()
  105. },
  106. onUnload() {
  107. this.OFF('EducationalAdministrationEvaluationTeach-list-change')
  108. },
  109. methods: {
  110. // 页面初始化
  111. async init() {
  112. this.ON('EducationalAdministrationEvaluationTeach-list-change', this.refreshList)
  113. // 拉取加载列表和数据源
  114. await Promise.all([
  115. () => {}
  116. ])
  117. await this.fetchList()
  118. // 初始化查询条件
  119. this.defaultQueryData = this.COPY(this.queryData)
  120. this.ready = true
  121. },
  122. // 拉取列表
  123. async fetchList() {
  124. if (this.page > this.total) { return }
  125. const result = await this.HTTP_GET(
  126. 'learun/adms/eval/studentlist',
  127. {
  128. // 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
  129. // 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
  130. pagination: { rows: 10, page: this.page, sidx: '', sord: 'DESC' },
  131. queryJson: JSON.stringify(this.searchData)
  132. },
  133. '加载数据时出错'
  134. )
  135. if (!result) { return }
  136. this.total = result.total
  137. this.page = result.page + 1
  138. this.list = this.list.concat(result.rows)
  139. this.tips = `已加载 ${Math.min(result.page, result.total)} / ${result.total} 页,共 ${result.records} 项`
  140. this.loadState = result.page >= result.total ? '已加载所有项目' : '向下翻以加载更多'
  141. },
  142. // 刷新清空列表
  143. async refreshList() {
  144. this.page = 1
  145. this.total = 2
  146. this.list = []
  147. await this.fetchList()
  148. },
  149. // 列表下拉
  150. pullDown() {
  151. this.refreshList().then(() => {
  152. this.$refs.list.stopPullDown()
  153. })
  154. },
  155. // 设置搜索条件
  156. async searchChange() {
  157. const result = {}
  158. // 将其他查询项添加到查询 JSON 中
  159. const queryObj = pickBy(this.queryData, t => (Array.isArray(t) ? t.length > 0 : t))
  160. Object.assign(result, mapValues(queryObj, t => (Array.isArray(t) ? t.join(',') : t)))
  161. this.searchData = result
  162. await this.refreshList()
  163. },
  164. // 点击「清空查询条件」按钮
  165. reset() {
  166. this.queryData = this.COPY(this.defaultQueryData)
  167. this.searchChange()
  168. },
  169. // 点击「编辑」、「查看」、「添加」、「删除」按钮
  170. async action(type, item) {
  171. if (item.UID != undefined && item.UID !== '') {
  172. this.TOAST("当前项目已评教!");
  173. return;
  174. }
  175. this.NAV_TO(`./single?type=view&id=${item.VID}&EmpNo=${item.EmpNo}&LessonNo=${item.LessonNo}`)
  176. },
  177. // 显示列表中的标题项
  178. displayListItem(item, field) {
  179. const fieldItem = this.scheme[field]
  180. const value = item[field]
  181. switch (fieldItem.type) {
  182. case 'currentInfo':
  183. case 'organize':
  184. return fieldItem.dataType === 'time' ? value : get(this.GET_GLOBAL(fieldItem.dataType), `${value}.name`, '')
  185. case 'radio':
  186. case 'select':
  187. const selectItem = this.dataSource[field].find(t => t.value === String(value))
  188. return get(selectItem, 'text', '')
  189. case 'checkbox':
  190. if (!value || value.split(',').length <= 0) { return '' }
  191. const checkboxItems = value.split(',')
  192. return this.dataSource[field].filter(t => checkboxItems.includes(t.value)).map(t => t.text).join(',')
  193. case 'datetime':
  194. if (!value) { return '' }
  195. return moment(value).format(Number(fieldItem.dateformat) === 0 ? 'YYYY年 M月 D日' : 'YYYY-MM-DD HH:mm')
  196. case 'bit':
  197. return (value != undefined && value!== '') ? "已评" : "未评"
  198. default: return value === null || value === undefined ? '' : value
  199. }
  200. }
  201. }
  202. }
  203. </script>
  204. <style lang="less" scoped>
  205. @import '~@/common/css/sidepage.less';
  206. @import '~@/common/css/customlist.less';
  207. </style>