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.
 
 
 
 
 
 

233 lines
5.8 KiB

  1. <template>
  2. <view class="page">
  3. <l-customlist-sidepage-datefilter v-model="dateRange" @change="searchChange" title="按申请时间查询: "
  4. ref="datefilter" class="margin-bottom" />
  5. <next-table ref="table" :show-header="true" :columns="column" :stripe="true" :fit="false"
  6. @toggleRowSelection="toggleRowSelection" :showPaging="true" :pageIndex="page" :pageTotal="pageTotal"
  7. @toggleAllSelection="toggleAllSelection" :border="true" :data="data" @pageChange="pageChange"
  8. :highlight="true" @currentChange="currentChange">
  9. </next-table>
  10. <l-customform-table :value="currentRowDetail" :item="Purchase_Edu_Details" :edit="false" />
  11. <view class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;">
  12. <l-button @click="action('save')" size="lg" color="green" class="block margin-top" block>
  13. 确定新增
  14. </l-button>
  15. <l-button @click="action('cancel')" size="lg" line="red" class="block margin-top" block>
  16. 取消新增
  17. </l-button>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import get from 'lodash/get'
  23. import set from 'lodash/set'
  24. import customPageMixins from '@/common/custompage.js'
  25. import pickBy from 'lodash/pickBy'
  26. import mapValues from 'lodash/mapValues'
  27. export default {
  28. mixins: [customPageMixins],
  29. data() {
  30. return {
  31. queryData:{},
  32. searchData:{},
  33. dateRange:null,
  34. Purchase_Edu_Details: {
  35. type: 'girdtable',
  36. title: '劳务维修详情',
  37. __defaultItem__: {},
  38. fieldsData: [
  39. { field:'ServiceContent', type:'input', name:'维修内容' },
  40. { field:'Price', type:'input', name:'价格' },
  41. { field:'Peoplecount', type:'input', name:'人数' },
  42. { field:'Days', type:'input', name:'天数' },
  43. { field:'Standar', type:'input', name:'标准' },
  44. ]
  45. },
  46. // 采购数据
  47. column: [{
  48. type: 'selection',
  49. fixed: true,
  50. width: 60
  51. },
  52. {
  53. name: 'CreatorName',
  54. label: '申请人',
  55. width: 80,
  56. emptyString: '--'
  57. },
  58. {
  59. name: 'TotalAmount',
  60. label: '采购总价',
  61. fixed: false,
  62. width: 86,
  63. emptyString: '--'
  64. },
  65. {
  66. name: 'DepartmentName',
  67. label: '部门',
  68. fixed: false,
  69. width: 200,
  70. emptyString: '--'
  71. },
  72. {
  73. name: 'Remark',
  74. label: '备注',
  75. fixed: false,
  76. width: 156,
  77. emptyString: '--'
  78. },
  79. {
  80. name: 'SubmitTime',
  81. label: '提交时间',
  82. fixed: false,
  83. width: 146,
  84. emptyString: '--'
  85. },
  86. {
  87. name: 'CheckTime',
  88. label: '审核时间',
  89. fixed: false,
  90. width: 146,
  91. emptyString: '--'
  92. },
  93. ],
  94. formHasData:[],
  95. checkedObj: {},
  96. data: [],
  97. page: 1,
  98. total: 2,
  99. rows: 8,
  100. list: [],
  101. currentRowDetail: [],
  102. }
  103. },
  104. computed: {
  105. pageTotal() {
  106. if (this.total > this.rows) {
  107. return Math.ceil(this.total / this.rows)
  108. } else {
  109. return 1
  110. }
  111. }
  112. },
  113. mounted() {
  114. this.init()
  115. },
  116. methods: {
  117. init() {
  118. // let params = this.GET_PARAM()
  119. // this.formHasData = params || []
  120. this.fetchList()
  121. },
  122. // 采购列表
  123. async fetchList() {
  124. if (this.page > this.total) {
  125. return
  126. }
  127. const result = await this.HTTP_GET(
  128. 'learun/adms/purchaseservice/pagelist', {
  129. // 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
  130. // 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
  131. pagination: {
  132. rows: this.rows,
  133. page: this.page,
  134. sidx: 'CreateTime',
  135. sord: 'DESC'
  136. },
  137. queryJson: JSON.stringify({
  138. ...this.searchData,
  139. ApplyStatus: 0,
  140. CheckStatus: 2,
  141. CreatorId:this.GET_GLOBAL('loginUser').userId
  142. })
  143. },
  144. '加载数据时出错'
  145. )
  146. if (!result) {
  147. return
  148. }
  149. this.total = result.records
  150. this.page = result.page
  151. this.data = result.rows.map(e => {
  152. if (this.checkedObj[this.page] && this.checkedObj[this.page].find(e1=>e.Id == e1.Id)) {
  153. e.checked = true
  154. }
  155. return e
  156. });
  157. },
  158. toggleAllSelection(_, list) {
  159. this.checkedObj[this.page] = list
  160. },
  161. toggleRowSelection(bool, list) {
  162. this.checkedObj[this.page] = list
  163. },
  164. pageChange(index) {
  165. this.$refs.table.resetHighlight()
  166. this.currentRowDetail = []
  167. this.page = index
  168. this.fetchList()
  169. },
  170. async currentChange(row) {
  171. this.currentRowDetail = []
  172. const result = await this.HTTP_GET('learun/adms/purchaseservice/formdetail', row.Id)
  173. if (!result) return
  174. this.currentRowDetail = result
  175. },
  176. async action(type) {
  177. switch (type) {
  178. case 'save':
  179. let arr = []
  180. for(let key in this.checkedObj){
  181. arr = arr.concat(this.checkedObj[key] || [])
  182. }
  183. this.EMIT('details-change',arr)
  184. this.NAV_BACK()
  185. break
  186. case 'cancel':
  187. this.NAV_BACK()
  188. break
  189. default:
  190. break
  191. }
  192. },
  193. // 设置搜索条件
  194. async searchChange() {
  195. const result = {}
  196. // 时间查询相关参数
  197. if (this.dateRange) {
  198. result.StartTime = this.dateRange.start
  199. result.EndTime = this.dateRange.end
  200. }
  201. // 将其他查询项添加到查询 JSON 中
  202. const queryObj = pickBy(this.queryData, t => (Array.isArray(t) ? t.length > 0 : t))
  203. Object.assign(result, mapValues(queryObj, t => (Array.isArray(t) ? t.join(',') : t)))
  204. this.searchData = result
  205. await this.refreshList(false)
  206. },
  207. // 刷新清空列表
  208. async refreshList(isConcat = true) {
  209. this.page = 1
  210. this.total = 2
  211. this.list = []
  212. this.currentRowDetail = []
  213. this.checkedObj = {}
  214. this.$refs.table.resetHighlight()
  215. await this.fetchList(isConcat)
  216. },
  217. // 设置表单值
  218. setValue(path, val) {
  219. set(this.current, path, val)
  220. },
  221. }
  222. }
  223. </script>
  224. <style>
  225. </style>