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.

list.vue 8.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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,index) of list" :key="index">
  12. <view v-for="item_ in item" class="customlist-item-field">
  13. <text class="customlist-item-field-title">{{item_.Item1}}:</text>
  14. {{item_.Item2}}
  15. </view>
  16. <view class="customlist-banner-action">
  17. <view @click="action('view', item)"
  18. class="customlist-banner-action-btn line-blue text-sm"
  19. style="border: currentColor 1px solid">
  20. <l-icon type="search" />
  21. 查看
  22. </view>
  23. </view>
  24. </view>
  25. </l-customlist>
  26. </l-scroll-list>
  27. </view>
  28. <!-- 关闭侧边抽屉按钮 -->
  29. <view @click="sideOpen = false" :class="sideOpen ? 'show' : ''" class="sideclose">
  30. <l-icon type="pullright" color="blue" />
  31. </view>
  32. <!-- 侧边栏,用于设置查询条件 -->
  33. <scroll-view :class="sideOpen ? 'show' : ''" class="sidepage" scroll-y>
  34. <view v-if="ready" class="padding">
  35. <l-date-picker
  36. @input="setSearchValue(`time`, $event)"
  37. :value="queryData.time"
  38. fields="month"
  39. title="发放月份"
  40. />
  41. <!-- 重置查询条件按钮 -->
  42. <view class="padding-tb">
  43. <!-- <l-button @click="reset" line="orange" class="block" block>重置查询条件</l-button> -->
  44. </view>
  45. </view>
  46. </scroll-view>
  47. <!-- <l-customlist-add v-if="!sideOpen" @click="action('add')" /> -->
  48. </view>
  49. </template>
  50. <script>
  51. /*
  52. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  53. * Copyright (c) 2013-2020 上海力软信息技术有限公司
  54. * 创建人:超级管理员
  55. * 日 期:2020-10-16 15:39
  56. * 描 述:工作日志
  57. */
  58. /**
  59. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  60. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  61. * { "path": "pages/EducationalAdministration/Journal/list", "style": { "navigationBarTitleText": "表单列表页" } }
  62. *
  63. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  64. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  65. */
  66. import moment from 'moment'
  67. import get from 'lodash/get'
  68. import set from 'lodash/set'
  69. import pickBy from 'lodash/pickBy'
  70. import mapValues from 'lodash/mapValues'
  71. export default {
  72. data() {
  73. return {
  74. // 数据项的数据类型、结构
  75. scheme: {
  76. SendDate: { type: 'text' },
  77. TotalDeduction: { type: 'text'},
  78. TotalSend: { type: 'text'},
  79. },
  80. // 查询条件
  81. searchData: {},
  82. defaultQueryData: {},
  83. queryData: {
  84. },
  85. // 数据源
  86. dataSource: {
  87. // Status: [{text:'已提交',value:'1'},{text:'未提交',value:'0'}],
  88. },
  89. // 页面相关参数
  90. ready: false,
  91. // tips: '加载中...',
  92. tips: '请按月份进行搜索...',
  93. loadState: '向下翻以加载更多',
  94. sideOpen: false,
  95. // 列表与分页信息
  96. page: 1,
  97. total: 2,
  98. list: []
  99. }
  100. },
  101. async onLoad() {
  102. await this.init()
  103. },
  104. onUnload() {
  105. this.OFF('LogisticsManagement-Purchase_Work-list-change')
  106. },
  107. methods: {
  108. // 页面初始化
  109. async init() {
  110. this.ON('LogisticsManagement-Purchase_Work-list-change', this.reset)
  111. // 拉取加载列表和数据源
  112. await Promise.all([
  113. () => {}
  114. ])
  115. const result = await this.HTTP_GET(
  116. '/Learun/adms/PersonnelManagement/GzAmount/curr',
  117. {
  118. // 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
  119. // 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
  120. pagination: { rows: 10, page: this.page, sidx: '', sord: '' },
  121. queryJson: JSON.stringify(this.searchData)
  122. },
  123. '加载数据时出错'
  124. )
  125. if (result) {
  126. this.queryData.time = result.year + '-' + (result.month.length == '1'? '0' + result.month : result.month)
  127. await this.searchChange()
  128. }else{
  129. await this.fetchList()
  130. }
  131. // 初始化查询条件
  132. this.defaultQueryData = this.COPY(this.queryData)
  133. this.ready = true
  134. },
  135. // 拉取列表
  136. async fetchList(isConcat = true) {
  137. if (this.page > this.total) { return }
  138. const result = await this.HTTP_GET(
  139. '/Learun/adms/PersonnelManagement/GzAmount/my',
  140. {
  141. // 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
  142. // 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
  143. pagination: { rows: 10, page: this.page, sidx: '', sord: '' },
  144. queryJson: JSON.stringify(this.searchData)
  145. },
  146. '加载数据时出错'
  147. )
  148. if (!result) { return }
  149. this.total = result.total
  150. this.page = result.page + 1
  151. // this.list = isConcat ? this.list.concat(result.rows) : result.rows;
  152. if(result.rows.length)this.list = result.rows
  153. // this.tips = `已加载 ${Math.min(result.page, result.total)} / ${result.total} 页,共 ${result.records} 项`
  154. this.tips = this.searchData.year?this.searchData.year+'年'+this.searchData.month+'月':'请按月份进行搜索...'
  155. this.loadState = result.page >= result.total ? '已加载所有项目' : '向下翻以加载更多'
  156. },
  157. // 刷新清空列表
  158. async refreshList(isConcat = true) {
  159. this.page = 1
  160. this.total = 2
  161. this.list = []
  162. await this.fetchList(isConcat)
  163. },
  164. // 列表下拉
  165. pullDown() {
  166. this.refreshList().then(() => {
  167. this.$refs.list.stopPullDown()
  168. })
  169. },
  170. // 设置搜索条件
  171. async searchChange() {
  172. const result = {}
  173. // 将其他查询项添加到查询 JSON 中
  174. const queryObj = pickBy(this.queryData, t => (Array.isArray(t) ? t.length > 0 : t))
  175. Object.assign(result, mapValues(queryObj, t => (Array.isArray(t) ? t.join(',') : t)))
  176. if(result.time){
  177. result.year = result.time.split('-')[0]
  178. result.month = result.time.split('-')[1]
  179. }
  180. delete result['time']
  181. this.searchData = result
  182. await this.refreshList(false)
  183. },
  184. // 点击「清空查询条件」按钮
  185. reset() {
  186. this.queryData = this.COPY(this.defaultQueryData)
  187. this.searchChange()
  188. },
  189. // 点击「编辑」、「查看」、「添加」、「删除」按钮
  190. async action(type, item) {
  191. switch (type) {
  192. case 'view':
  193. let obj = item.find(e=>e.Item1 == '发放次数')
  194. this.NAV_TO(`./single?year=${this.searchData.year}&month=${this.searchData.month}&cs=${obj?obj.Item2:''}`, item, true)
  195. return
  196. default:
  197. return
  198. }
  199. },
  200. // 设置表单数据的方法
  201. setSearchValue(path, value) {
  202. this.$set(this.queryData, path, value)
  203. this.searchChange()
  204. },
  205. // 显示列表中的标题项
  206. displayListItem(item, field) {
  207. const fieldItem = this.scheme[field]
  208. const value = item[field]
  209. switch (fieldItem.type) {
  210. case 'currentInfo':
  211. case 'organize':
  212. return fieldItem.dataType === 'time' ? value : get(this.GET_GLOBAL(fieldItem.dataType), `${value}.name`, '')
  213. case 'radio':
  214. case 'select':
  215. const selectItem = this.dataSource[field].find(t => t.value === String(value))
  216. return get(selectItem, 'text', '')
  217. case 'checkbox':
  218. if (!value || value.split(',').length <= 0) { return '' }
  219. const checkboxItems = value.split(',')
  220. return this.dataSource[field].filter(t => checkboxItems.includes(t.value)).map(t => t.text).join(',')
  221. case 'datetime':
  222. if (!value) { return '' }
  223. return moment(value).format(Number(fieldItem.dateformat) === 0 ? 'YYYY年 M月 D日' : 'YYYY-MM-DD HH:mm')
  224. default: return value === null || value === undefined ? '' : value
  225. }
  226. }
  227. }
  228. }
  229. </script>
  230. <style lang="less" scoped>
  231. @import '~@/common/css/sidepage.less';
  232. @import '~@/common/css/customlist.less';
  233. .customlist-banner-action {
  234. margin-top: 20rpx;
  235. text-align: right;
  236. .customlist-banner-action-btn {
  237. display: inline-block;
  238. padding: 4px 6px;
  239. margin: 0 3px;
  240. border-radius: 3px;
  241. text-align: center;
  242. }
  243. }
  244. </style>