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.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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.F_InvoiceId">
  12. <view class="customlist-item-field">
  13. <text class="customlist-item-field-title">姓名:</text>
  14. {{ displayListItem(item, 'EmpName') }}
  15. </view>
  16. <view class="customlist-item-field">
  17. <text class="customlist-item-field-title">人员类别:</text>
  18. {{ displayListItem(item, 'PeopleType') }}
  19. </view>
  20. <view class="customlist-item-field">
  21. <text class="customlist-item-field-title">发放年份:</text>
  22. {{ displayListItem(item, 'IssueYear') }}
  23. </view>
  24. <view class="customlist-item-field">
  25. <text class="customlist-item-field-title">发放月份:</text>
  26. {{ displayListItem(item, 'IssueMonth') }}
  27. </view>
  28. <view class="customlist-item-field">
  29. <text class="customlist-item-field-title">应发合计:</text>
  30. {{ displayListItem(item, 'TotalGrossPay') }}
  31. </view>
  32. <view class="customlist-item-field">
  33. <text class="customlist-item-field-title">实发合计:</text>
  34. {{ displayListItem(item, 'NetCombined') }}
  35. </view>
  36. <!-- 操作按钮组 -->
  37. <l-customlist-action @view="action('view', item)" @edit="action('edit', item)" :showEdit="false" />
  38. </view>
  39. </l-customlist>
  40. </l-scroll-list>
  41. </view>
  42. <!-- 关闭筛选栏按钮 -->
  43. <view @click="sideOpen = false" :class="sideOpen ? 'show' : ''" class="sideclose">
  44. <l-icon type="pullright" color="blue" />
  45. </view>
  46. <!-- 侧边栏 -->
  47. <scroll-view :class="sideOpen ? 'show' : ''" class="sidepage" scroll-y>
  48. <view v-if="ready" class="padding">
  49. <l-input v-model="queryData.IssueYear" @change="searchChange()" title="年份" placeholder="按年份筛选,例:2022" />
  50. <l-input v-model="queryData.IssueMonth" @change="searchChange()" title="月份" placeholder="按月份筛选,例:10" />
  51. <l-input v-model="queryData.EmpName" @change="searchChange()" title="姓名" placeholder="按姓名筛选" />
  52. <l-input v-model="queryData.PeopleType" @change="searchChange()" title="人员类别" placeholder="按人员类别筛选" />
  53. <view class="padding-tb">
  54. <l-button @click="reset" line="orange" class="block" block>重置筛选条件</l-button>
  55. </view>
  56. </view>
  57. </scroll-view>
  58. <!-- 添加按钮 -->
  59. <!-- <l-customlist-add v-if="!sideOpen" @click="action('create')" /> -->
  60. </view>
  61. </template>
  62. <script>
  63. import moment from 'moment'
  64. import get from 'lodash/get'
  65. import set from 'lodash/set'
  66. import pickBy from 'lodash/pickBy'
  67. import mapValues from 'lodash/mapValues'
  68. export default {
  69. data() {
  70. return {
  71. // 表单结构
  72. scheme: {
  73. // F_CustomerId: { type: 'select', dataSource: '1', dataSourceId: 'crmCustomer,f_fullname,f_customerid' },
  74. // F_InvoiceContent: { type: 'texteditor' },
  75. // 姓名EmpName
  76. EmpName: { type: 'text' },
  77. // 人员类别PeopleType
  78. PeopleType: { type: 'text' },
  79. // 发放年份IssueYear
  80. IssueYear: { type: 'text' },
  81. // 发放月份IssueMonth
  82. IssueMonth: { type: 'text' },
  83. // 应发合计TotalGrossPay
  84. TotalGrossPay: { type: 'text' },
  85. // 实发合计NetCombined
  86. NetCombined: { type: 'text' },
  87. },
  88. // 筛选菜单值
  89. searchData: {},
  90. defaultQueryData: {},
  91. queryData: {
  92. keyword: ''
  93. },
  94. // 数据源
  95. dataSource: {
  96. F_CustomerId: []
  97. },
  98. // 页面相关参数
  99. ready: false,
  100. tips: '加载中…',
  101. loadState: '向下翻以加载更多',
  102. sideOpen: false,
  103. // 列表条目与分页信息
  104. page: 1,
  105. total: 2,
  106. list: []
  107. }
  108. },
  109. async onLoad() {
  110. await this.init()
  111. },
  112. onUnload() {
  113. this.OFF('invoice-list-change')
  114. },
  115. methods: {
  116. // 页面初始化
  117. async init() {
  118. this.ON('invoice-list-change', this.refreshList)
  119. await Promise.all([
  120. // 加载 F_CustomerId 字段的数据源:客户信息
  121. // this.FETCH_DATASOURCE('crmCustomer').then(result => {
  122. // this.dataSource.F_CustomerId = result.data.map(t => ({ text: t.f_fullname, value: t.f_customerid }))
  123. // }),
  124. // 拉取列表信息
  125. this.fetchList()
  126. ])
  127. this.defaultQueryData = this.COPY(this.queryData)
  128. this.ready = true
  129. },
  130. // 拉取列表
  131. async fetchList(isConcat=true) {
  132. if (this.page > this.total) {
  133. return
  134. }
  135. const result = await this.HTTP_GET(
  136. 'learun/adms/Ououtsourcing/getlist',
  137. {
  138. pagination: { rows: 10, page: this.page, sidx: 'CreateTime', sord: 'DESC' },
  139. queryJson: JSON.stringify(this.searchData)
  140. },
  141. '加载数据时出错'
  142. )
  143. if (!result) {
  144. return
  145. }
  146. this.total = result.total
  147. this.page = result.page + 1
  148. this.list = isConcat?this.list.concat(result.rows):result.rows;
  149. this.tips = `已加载 ${Math.min(result.page, result.total)} / ${result.total} 页,共 ${result.records} 项`
  150. this.loadState = result.page >= result.total ? '已加载所有项目' : '向下翻以加载更多'
  151. },
  152. // 刷新清空列表
  153. async refreshList(isConcat=true) {
  154. this.page = 1
  155. this.total = 2
  156. this.list = []
  157. await this.fetchList(isConcat);
  158. },
  159. // 列表下拉
  160. pullDown() {
  161. this.refreshList().then(() => {
  162. this.$refs.list.stopPullDown()
  163. })
  164. },
  165. // 点击「编辑」、「查看」、「添加」、「删除」按钮
  166. action(type, item) {
  167. switch (type) {
  168. default:
  169. case 'create':
  170. this.NAV_TO('./single?type=create')
  171. return
  172. case 'view':
  173. this.NAV_TO('./single?type=view&&id='+item.WPID, item, true)
  174. return
  175. case 'edit':
  176. this.NAV_TO('./single?type=edit', item, true)
  177. return
  178. }
  179. },
  180. // 显示列表中的标题项
  181. displayListItem(item, field) {
  182. const fieldItem = this.scheme[field]
  183. const value = item[field]
  184. switch (fieldItem.type) {
  185. case 'currentInfo':
  186. case 'organize':
  187. switch (fieldItem.dataType) {
  188. case 'user':
  189. return get(this.GET_GLOBAL('user'), `${value}.name`, '')
  190. case 'department':
  191. return get(this.GET_GLOBAL('department'), `${value}.name`, '')
  192. case 'company':
  193. return get(this.GET_GLOBAL('company'), `${value}.name`, '')
  194. default:
  195. return value || ''
  196. }
  197. case 'radio':
  198. case 'select':
  199. const selectItem = this.dataSource[field].find(t => t.value === value)
  200. return get(selectItem, 'text', '')
  201. case 'checkbox':
  202. if (!value || value.split(',').length <= 0) {
  203. return ''
  204. }
  205. const checkboxItems = value.split(',')
  206. return this.dataSource[field]
  207. .filter(t => checkboxItems.includes(t.value))
  208. .map(t => t.text)
  209. .join(',')
  210. case 'datetime':
  211. if (!value) {
  212. return ''
  213. }
  214. return moment(value).format(Number(fieldItem.dateformat) === 0 ? 'YYYY年 M月 D日' : 'YYYY-MM-DD HH:mm')
  215. default:
  216. return value || ''
  217. }
  218. },
  219. // 设置搜索条件
  220. async searchChange() {
  221. const result = {}
  222. const queryObj = pickBy(this.queryData, t => (Array.isArray(t) ? t.length > 0 : t))
  223. Object.assign(result, mapValues(queryObj, t => (Array.isArray(t) ? t.join(',') : t)))
  224. this.searchData = result
  225. await this.refreshList(false);
  226. },
  227. // 点击「清空搜索条件」按钮
  228. reset() {
  229. this.queryData = this.COPY(this.defaultQueryData)
  230. this.searchChange()
  231. }
  232. }
  233. }
  234. </script>
  235. <style lang="less" scoped>
  236. @import '~@/common/css/sidepage.less';
  237. @import '~@/common/css/customlist.less';
  238. </style>