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.
 
 
 
 
 
 

322 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.Id">
  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, 'StuNo') }}
  23. </view>
  24. <view class="customlist-item-field">
  25. <text class="customlist-item-field-title">姓名:</text>
  26. {{ displayListItem(item, 'StuName') }}
  27. </view>
  28. <view class="customlist-item-field">
  29. <text class="customlist-item-field-title">年级:</text>
  30. {{ displayListItem(item, 'Grade') }}
  31. </view>
  32. <view class="customlist-item-field">
  33. <text class="customlist-item-field-title">系所码:</text>
  34. {{ displayListItem(item, 'DeptNo') }}
  35. </view>
  36. <view class="customlist-item-field">
  37. <text class="customlist-item-field-title">系名:</text>
  38. {{ displayListItem(item, 'DeptName') }}
  39. </view>
  40. <view class="customlist-item-field">
  41. <text class="customlist-item-field-title">专业码:</text>
  42. {{ displayListItem(item, 'MajorNo') }}
  43. </view>
  44. <view class="customlist-item-field">
  45. <text class="customlist-item-field-title">专业名:</text>
  46. {{ displayListItem(item, 'MajorName') }}
  47. </view>
  48. <view class="customlist-item-field">
  49. <text class="customlist-item-field-title">所在行政班号:</text>
  50. {{ displayListItem(item, 'ClassNo') }}
  51. </view>
  52. <l-customlist-action showButton buttonText="审核" @join="action('check',item.Id)" @view="action('view', item.Id)" />
  53. </view>
  54. </l-customlist>
  55. </l-scroll-list>
  56. </view>
  57. <!-- 关闭侧边抽屉按钮 -->
  58. <view @click="sideOpen = false" :class="sideOpen ? 'show' : ''" class="sideclose">
  59. <l-icon type="pullright" color="blue" />
  60. </view>
  61. <!-- 侧边栏,用于设置查询条件 -->
  62. <scroll-view :class="sideOpen ? 'show' : ''" class="sidepage" scroll-y>
  63. <view v-if="ready" class="padding">
  64. <l-input
  65. v-model="queryData.StuNo"
  66. @change="searchChange"
  67. title ="学号"
  68. placeholder="按学号查询"
  69. />
  70. <l-input
  71. v-model="queryData.StuName"
  72. @change="searchChange"
  73. title ="姓名"
  74. placeholder="按姓名查询"
  75. />
  76. <!-- 重置查询条件按钮 -->
  77. <view class="padding-tb">
  78. <l-button @click="reset" line="orange" class="block" block>重置查询条件</l-button>
  79. </view>
  80. </view>
  81. </scroll-view>
  82. <!-- <l-customlist-add v-if="!sideOpen" @click="action('add')" /> -->
  83. </view>
  84. </template>
  85. <script>
  86. /*
  87. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  88. * Copyright (c) 2013-2020 上海力软信息技术有限公司
  89. * 创建人:超级管理员
  90. * 日 期:2020-10-20 15:22
  91. * 描 述:aaa
  92. */
  93. /**
  94. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  95. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  96. * { "path": "pages/EducationalAdministration/StuAttendanceLeave/list", "style": { "navigationBarTitleText": "表单列表页" } }
  97. *
  98. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  99. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  100. */
  101. import moment from 'moment'
  102. import get from 'lodash/get'
  103. import set from 'lodash/set'
  104. import pickBy from 'lodash/pickBy'
  105. import mapValues from 'lodash/mapValues'
  106. export default {
  107. data() {
  108. return {
  109. // 数据项的数据类型、结构
  110. scheme: {
  111. AcademicYearNo: { type: 'text' },
  112. Semester: { type: 'text' },
  113. StuNo: { type: 'text' },
  114. StuName: { type: 'text' },
  115. Grade: { type: 'text' },
  116. DeptNo: { type: 'text' },
  117. DeptName: { type: 'text' },
  118. MajorNo: { type: 'text' },
  119. MajorName: { type: 'text' },
  120. ClassNo: { type: 'text' },
  121. },
  122. // 查询条件
  123. searchData: {},
  124. defaultQueryData: {},
  125. queryData: {
  126. StuNo: '',
  127. StuName: '',
  128. },
  129. // 数据源
  130. dataSource: {
  131. },
  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('EducationalAdministrationStuAttendanceLeave-list-change')
  148. },
  149. methods: {
  150. // 页面初始化
  151. async init() {
  152. this.ON('EducationalAdministrationStuAttendanceLeave-list-change', this.refreshList)
  153. // 拉取加载列表和数据源
  154. await Promise.all([
  155. () => {}
  156. ])
  157. await this.fetchList()
  158. // 初始化查询条件
  159. this.defaultQueryData = this.COPY(this.queryData)
  160. this.ready = true
  161. },
  162. // 拉取列表
  163. async fetchList() {
  164. if (this.page > this.total) { return }
  165. const result = await this.HTTP_GET(
  166. 'learun/adms/EducationalAdministration/StuAttendanceLeave/pagelist',
  167. {
  168. // 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
  169. // 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
  170. pagination: { rows: 10, page: this.page, sidx: 'Id', sord: 'DESC' },
  171. queryJson: JSON.stringify(this.searchData)
  172. },
  173. '加载数据时出错'
  174. )
  175. if (!result) { return }
  176. this.total = result.total
  177. this.page = result.page + 1
  178. this.list = this.list.concat(result.rows)
  179. this.tips = `已加载 ${Math.min(result.page, result.total)} / ${result.total} 页,共 ${result.records} 项`
  180. this.loadState = result.page >= result.total ? '已加载所有项目' : '向下翻以加载更多'
  181. },
  182. // 刷新清空列表
  183. async refreshList() {
  184. this.page = 1
  185. this.total = 2
  186. this.list = []
  187. await this.fetchList()
  188. },
  189. // 列表下拉
  190. pullDown() {
  191. this.refreshList().then(() => {
  192. this.$refs.list.stopPullDown()
  193. })
  194. },
  195. // 设置搜索条件
  196. async searchChange() {
  197. const result = {}
  198. // 将其他查询项添加到查询 JSON 中
  199. const queryObj = pickBy(this.queryData, t => (Array.isArray(t) ? t.length > 0 : t))
  200. Object.assign(result, mapValues(queryObj, t => (Array.isArray(t) ? t.join(',') : t)))
  201. this.searchData = result
  202. await this.refreshList()
  203. },
  204. // 点击「清空查询条件」按钮
  205. reset() {
  206. this.queryData = this.COPY(this.defaultQueryData)
  207. this.searchChange()
  208. },
  209. // 点击「编辑」、「查看」、「添加」、「删除」按钮
  210. async action(type, id = '') {
  211. switch (type) {
  212. case 'view':
  213. this.NAV_TO(`./single?type=view&id=${id}`)
  214. return
  215. case 'add':
  216. this.NAV_TO('./single?type=create')
  217. return
  218. case 'edit':
  219. this.NAV_TO(`./single?type=edit&id=${id}`)
  220. return
  221. case 'delete':
  222. if (!(await this.CONFIRM('删除项目', '确定要删除该项吗?', true))) {
  223. return
  224. }
  225. this.HTTP_POST('learun/adms/EducationalAdministration/StuAttendanceLeave/delete', id, '删除失败').then(success => {
  226. if(!success) { return }
  227. this.TOAST('删除成功', 'success')
  228. this.refreshList()
  229. })
  230. return
  231. default:
  232. return
  233. }
  234. },
  235. // 显示列表中的标题项
  236. displayListItem(item, field) {
  237. const fieldItem = this.scheme[field]
  238. const value = item[field]
  239. switch (fieldItem.type) {
  240. case 'currentInfo':
  241. case 'organize':
  242. return fieldItem.dataType === 'time' ? value : get(this.GET_GLOBAL(fieldItem.dataType), `${value}.name`, '')
  243. case 'radio':
  244. case 'select':
  245. const selectItem = this.dataSource[field].find(t => t.value === String(value))
  246. return get(selectItem, 'text', '')
  247. case 'checkbox':
  248. if (!value || value.split(',').length <= 0) { return '' }
  249. const checkboxItems = value.split(',')
  250. return this.dataSource[field].filter(t => checkboxItems.includes(t.value)).map(t => t.text).join(',')
  251. case 'datetime':
  252. if (!value) { return '' }
  253. return moment(value).format(Number(fieldItem.dateformat) === 0 ? 'YYYY年 M月 D日' : 'YYYY-MM-DD HH:mm')
  254. default: return value === null || value === undefined ? '' : value
  255. }
  256. }
  257. }
  258. }
  259. </script>
  260. <style lang="less" scoped>
  261. @import '~@/common/css/sidepage.less';
  262. @import '~@/common/css/customlist.less';
  263. </style>