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.
 
 
 
 
 
 

411 lines
13 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, 'CreateUserDeptNo') }}
  15. </view>
  16. <view class="customlist-item-field">
  17. <text class="customlist-item-field-title">班级:</text>
  18. {{ displayListItem(item, 'CreateUserClassNo') }}
  19. </view>
  20. <view class="customlist-item-field">
  21. <text class="customlist-item-field-title">申请用户:</text>
  22. {{ displayListItem(item, 'CreateUserName') }}
  23. </view>
  24. <view class="customlist-item-field">
  25. <text class="customlist-item-field-title">申请类型:</text>
  26. {{ displayListItem(item, 'LeaveType') }}
  27. </view>
  28. <view class="customlist-item-field">
  29. <text class="customlist-item-field-title">开始时间:</text>
  30. {{ displayListItem(item, 'BeginDate') }}
  31. </view>
  32. <view class="customlist-item-field">
  33. <text class="customlist-item-field-title">结束时间:</text>
  34. {{ displayListItem(item, 'EndDate') }}
  35. </view>
  36. <view class="customlist-item-field">
  37. <text class="customlist-item-field-title">申请理由:</text>
  38. {{ displayListItem(item, 'LeaveReason') }}
  39. </view>
  40. <view class="customlist-item-field">
  41. <text class="customlist-item-field-title">审核状态:</text>
  42. {{ item.FlowNo==0?'草稿':item.FlowNo ==1?'审批中':item.FlowNo==2?'请假中':item.FlowNo==3?'已销假':'' }}
  43. </view>
  44. <view class="customlist-banner-action">
  45. <!-- <view
  46. @click="action('cancel',item.Id,item)"
  47. class="customlist-banner-action-btn line-green text-sm"
  48. style="border: currentColor 1px solid"
  49. >
  50. <l-icon type="close" />
  51. 销假
  52. </view> -->
  53. <view
  54. @click="action('submit',item.Id,item)"
  55. class="customlist-banner-action-btn line-yellow text-sm"
  56. style="border: currentColor 1px solid"
  57. >
  58. <l-icon type="check" />
  59. 提交
  60. </view>
  61. <view
  62. @click="action('delete',item.Id,item)"
  63. class="customlist-banner-action-btn line-red text-sm"
  64. style="border: currentColor 1px solid"
  65. >
  66. <l-icon type="delete" />
  67. 删除
  68. </view>
  69. <view
  70. @click="action('edit', item.Id,item)"
  71. class="customlist-banner-action-btn line-blue text-sm"
  72. style="border: currentColor 1px solid"
  73. >
  74. <l-icon type="edit" />
  75. 编辑
  76. </view>
  77. <view
  78. @click="action('view', item.Id,item)"
  79. class="customlist-banner-action-btn line-blue text-sm"
  80. style="border: currentColor 1px solid; min-width: 160rpx"
  81. >
  82. 查看
  83. <l-icon type="right" />
  84. </view>
  85. </view>
  86. </view>
  87. </l-customlist>
  88. </l-scroll-list>
  89. </view>
  90. <!-- 关闭侧边抽屉按钮 -->
  91. <view @click="sideOpen = false" :class="sideOpen ? 'show' : ''" class="sideclose">
  92. <l-icon type="pullright" color="blue" />
  93. </view>
  94. <!-- 侧边栏,用于设置查询条件 -->
  95. <scroll-view :class="sideOpen ? 'show' : ''" class="sidepage" scroll-y>
  96. <view v-if="ready" class="padding">
  97. <!-- <l-customlist-sidepage-datefilter
  98. v-model="dateRange"
  99. @change="searchChange"
  100. title="按时间日期查询: "
  101. ref="datefilter"
  102. class="margin-bottom"
  103. /> -->
  104. <l-select v-model="queryData.CreateUserDeptNo" @change="searchChange" :range="dataSource.CreateUserDeptNo" title="所属系" placeholder="按所属系查询" />
  105. <l-select v-model="queryData.CreateUserClassNo" @change="searchChange" :range="dataSource.CreateUserClassNo" title="班级" placeholder="按班级查询" />
  106. <l-select v-model="queryData.LeaveType" @change="searchChange" :range="dataSource.LeaveType" title="申请类型" placeholder="按申请类型查询" />
  107. <!-- 重置查询条件按钮 -->
  108. <view class="padding-tb">
  109. <l-button @click="reset" line="orange" class="block" block>重置查询条件</l-button>
  110. </view>
  111. </view>
  112. </scroll-view>
  113. <l-customlist-add v-if="!sideOpen" @click="action('add')" />
  114. </view>
  115. </template>
  116. <script>
  117. /*
  118. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  119. * Copyright (c) 2013-2020 上海力软信息技术有限公司
  120. * 创建人:超级管理员
  121. * 日 期:2020-10-14 12:15
  122. * 描 述:学生请销假
  123. */
  124. /**
  125. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  126. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  127. * { "path": "pages/EducationalAdministration/DtStuLeave/list", "style": { "navigationBarTitleText": "表单列表页" } }
  128. *
  129. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  130. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  131. */
  132. import moment from 'moment'
  133. import get from 'lodash/get'
  134. import set from 'lodash/set'
  135. import pickBy from 'lodash/pickBy'
  136. import mapValues from 'lodash/mapValues'
  137. export default {
  138. data() {
  139. return {
  140. // 数据项的数据类型、结构
  141. scheme: {
  142. CreateUserDeptNo: { type: 'select', dataSource: '1', dataSourceId: 'CdDeptInfo,deptname,deptno' },
  143. CreateUserClassNo: { type: 'select', dataSource: '1', dataSourceId: 'bjsj,classname,classno' },
  144. CreateUserName: { type: 'organize',dataType:'user' },
  145. LeaveType: { type: 'select', dataSource: '1', dataSourceId: 'StuLeaveType,typename,typeno' },
  146. BeginDate: { type: 'datetime', dateformat: '1' },
  147. EndDate: { type: 'datetime', dateformat: '1' },
  148. LeaveReason: { type: 'text' },
  149. FlowNo: { type: 'text' },
  150. },
  151. // 查询条件
  152. searchData: {},
  153. defaultQueryData: {},
  154. queryData: {
  155. CreateUserDeptNo:'',
  156. CreateUserClassNo:'',
  157. LeaveType:'',
  158. },
  159. // 数据源
  160. dataSource: {
  161. CreateUserDeptNo:[],
  162. CreateUserClassNo:[],
  163. // LeaveType:Object.values(this.GET_GLOBAL('dataDictionary').LeaveType).map(t => ({ value: t.value, text: t.text })),
  164. LeaveType:[],
  165. },
  166. // 时间查询参数
  167. dateRange: null,
  168. // 页面相关参数
  169. ready: false,
  170. tips: '加载中...',
  171. loadState: '向下翻以加载更多',
  172. sideOpen: false,
  173. // 列表与分页信息
  174. page: 1,
  175. total: 2,
  176. list: []
  177. }
  178. },
  179. async onLoad() {
  180. await this.init()
  181. },
  182. onUnload() {
  183. this.OFF('EducationalAdministrationDtStuLeave-list-change')
  184. },
  185. methods: {
  186. // 页面初始化
  187. async init() {
  188. this.ON('EducationalAdministrationDtStuLeave-list-change', this.refreshList)
  189. // 拉取加载列表和数据源
  190. await Promise.all([
  191. this.FETCH_DATASOURCE('CdDeptInfo').then(result => {
  192. this.dataSource.CreateUserDeptNo = result.data.map(t => ({ text: t.deptname, value: t.deptno }));
  193. }),
  194. this.FETCH_DATASOURCE('bjsj').then(result => {
  195. this.dataSource.CreateUserClassNo = result.data.map(t => ({ text: t.classname, value: t.classno }));
  196. }),
  197. this.FETCH_DATASOURCE('StuLeaveType').then(result => {
  198. this.dataSource.LeaveType = result.data.map(t => ({ text: t.typename, value: t.typeno }));
  199. }),
  200. () => {}
  201. ])
  202. await this.fetchList()
  203. // 初始化查询条件
  204. this.defaultQueryData = this.COPY(this.queryData)
  205. this.ready = true
  206. },
  207. // 拉取列表
  208. async fetchList() {
  209. if (this.page > this.total) { return }
  210. const result = await this.HTTP_GET(
  211. 'learun/EducationalAdministration/DtStuLeave/pagelist',
  212. {
  213. // 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
  214. // 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
  215. pagination: { rows: 10, page: this.page, sidx: 'Id', sord: 'DESC' },
  216. queryJson: JSON.stringify(this.searchData)
  217. },
  218. '加载数据时出错'
  219. )
  220. if (!result) { return }
  221. this.total = result.total
  222. this.page = result.page + 1
  223. this.list = this.list.concat(result.rows)
  224. this.tips = `已加载 ${Math.min(result.page, result.total)} / ${result.total} 页,共 ${result.records} 项`
  225. this.loadState = result.page >= result.total ? '已加载所有项目' : '向下翻以加载更多'
  226. },
  227. // 刷新清空列表
  228. async refreshList() {
  229. this.page = 1
  230. this.total = 2
  231. this.list = []
  232. await this.fetchList()
  233. },
  234. // 列表下拉
  235. pullDown() {
  236. this.refreshList().then(() => {
  237. this.$refs.list.stopPullDown()
  238. })
  239. },
  240. // 设置搜索条件
  241. async searchChange() {
  242. const result = {}
  243. // 时间查询相关参数
  244. if (this.dateRange) {
  245. result.StartTime = this.dateRange.start
  246. result.EndTime = this.dateRange.end
  247. }
  248. // 将其他查询项添加到查询 JSON 中
  249. const queryObj = pickBy(this.queryData, t => (Array.isArray(t) ? t.length > 0 : t))
  250. Object.assign(result, mapValues(queryObj, t => (Array.isArray(t) ? t.join(',') : t)))
  251. this.searchData = result
  252. await this.refreshList()
  253. },
  254. // 点击「清空查询条件」按钮
  255. reset() {
  256. // this.$refs.datefilter.changeDateRange('all')
  257. this.queryData = this.COPY(this.defaultQueryData)
  258. this.searchChange()
  259. },
  260. // 点击「编辑」、「查看」、「添加」、「删除」、「提交」、「销假」按钮
  261. async action(type, id = '',item) {
  262. switch (type) {
  263. case 'view':
  264. this.NAV_TO(`./single?type=view&id=${id}&FlowNo=${item.FlowNo}`)
  265. return
  266. case 'add':
  267. this.NAV_TO('./single?type=create')
  268. return
  269. case 'edit':
  270. if(item.FlowNo != 0){
  271. this.TOAST("当前项已提交不可编辑!");
  272. return;
  273. }
  274. this.NAV_TO(`./single?type=edit&id=${id}&FlowNo=${item.FlowNo}`)
  275. return
  276. case 'delete':
  277. if(item.FlowNo != 2){
  278. this.TOAST("当前项目暂不能销假!");
  279. return;
  280. }
  281. if (!(await this.CONFIRM('删除项目', '确定要删除该笔数据吗?', true))) {
  282. return
  283. }
  284. this.HTTP_POST('learun/EducationalAdministration/DtStuLeave/delete', id, '删除失败').then(success => {
  285. if(!success) { return }
  286. this.TOAST('删除成功', 'success')
  287. this.refreshList()
  288. })
  289. return
  290. case 'submit':
  291. if(item.FlowNo != 0){
  292. this.TOAST("当前项目已提交,请勿重复提交!");
  293. return;
  294. }
  295. if (!(await this.CONFIRM('提交项目', '确定要提交该笔数据吗?', true))) {
  296. return
  297. }
  298. this.HTTP_POST('learun/EducationalAdministration/DtStuLeave/submit', id, '提交失败').then(success => {
  299. if(!success) { return }
  300. this.TOAST('提交成功', 'success')
  301. this.refreshList()
  302. })
  303. return
  304. case 'cancel':
  305. return
  306. default:
  307. return
  308. }
  309. },
  310. // 显示列表中的标题项
  311. displayListItem(item, field) {
  312. const fieldItem = this.scheme[field]
  313. const value = item[field]
  314. switch (fieldItem.type) {
  315. case 'currentInfo':
  316. case 'organize':
  317. return fieldItem.dataType === 'time' ? value : get(this.GET_GLOBAL(fieldItem.dataType), `${value}.name`, '')
  318. case 'radio':
  319. case 'select':
  320. const selectItem = this.dataSource[field].find(t => t.value === String(value))
  321. return get(selectItem, 'text', '')
  322. case 'checkbox':
  323. if (!value || value.split(',').length <= 0) { return '' }
  324. const checkboxItems = value.split(',')
  325. return this.dataSource[field].filter(t => checkboxItems.includes(t.value)).map(t => t.text).join(',')
  326. case 'datetime':
  327. if (!value) { return '' }
  328. return moment(value).format(Number(fieldItem.dateformat) === 0 ? 'YYYY年 M月 D日' : 'YYYY-MM-DD HH:mm')
  329. default: return value === null || value === undefined ? '' : value
  330. }
  331. }
  332. }
  333. }
  334. </script>
  335. <style lang="less" scoped>
  336. @import '~@/common/css/sidepage.less';
  337. @import '~@/common/css/customlist.less';
  338. .customlist-banner-action {
  339. margin-top: 20rpx;
  340. text-align: right;
  341. .customlist-banner-action-btn {
  342. display: inline-block;
  343. padding: 4px 6px;
  344. margin: 0 3px;
  345. border-radius: 3px;
  346. text-align: center;
  347. }
  348. }
  349. </style>