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.
 
 
 
 
 
 

251 rivejä
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">
  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: 'Name',
  40. type: 'input',
  41. name: '采购物品名称'
  42. },
  43. {
  44. field: 'Price',
  45. type: 'input',
  46. name: '价格'
  47. },
  48. {
  49. field: 'Quantity',
  50. type: 'input',
  51. name: '采购数量'
  52. },
  53. {
  54. field: 'Unit',
  55. type: 'input',
  56. name: '单位'
  57. },
  58. {
  59. field: 'UseTo',
  60. type: 'input',
  61. name: '用途'
  62. },
  63. ]
  64. },
  65. // 采购数据
  66. column: [{
  67. type: 'selection',
  68. fixed: true,
  69. width: 60
  70. },
  71. {
  72. name: 'CreatorName',
  73. label: '申请人',
  74. width: 80,
  75. emptyString: '--'
  76. },
  77. {
  78. name: 'TotalAmount',
  79. label: '采购总价',
  80. fixed: false,
  81. width: 86,
  82. emptyString: '--'
  83. },
  84. {
  85. name: 'DepartmentName',
  86. label: '部门',
  87. fixed: false,
  88. width: 200,
  89. emptyString: '--'
  90. },
  91. {
  92. name: 'Remark',
  93. label: '备注',
  94. fixed: false,
  95. width: 156,
  96. emptyString: '--'
  97. },
  98. {
  99. name: 'SubmitTime',
  100. label: '提交时间',
  101. fixed: false,
  102. width: 146,
  103. emptyString: '--'
  104. },
  105. {
  106. name: 'CheckTime',
  107. label: '审核时间',
  108. fixed: false,
  109. width: 146,
  110. emptyString: '--'
  111. },
  112. ],
  113. formHasData:[],
  114. checkedObj: {},
  115. data: [],
  116. page: 1,
  117. total: 2,
  118. rows: 8,
  119. list: [],
  120. currentRowDetail: [],
  121. }
  122. },
  123. computed: {
  124. pageTotal() {
  125. if (this.total > this.rows) {
  126. return Math.ceil(this.total / this.rows)
  127. } else {
  128. return 1
  129. }
  130. }
  131. },
  132. mounted() {
  133. this.init()
  134. },
  135. methods: {
  136. init() {
  137. // let params = this.GET_PARAM()
  138. // this.formHasData = params || []
  139. this.fetchList()
  140. },
  141. // 采购列表
  142. async fetchList() {
  143. if (this.page > this.total) {
  144. return
  145. }
  146. const result = await this.HTTP_GET(
  147. 'learun/adms/purchasetravel/pagelist', {
  148. // 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
  149. // 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
  150. pagination: {
  151. rows: this.rows,
  152. page: this.page,
  153. sidx: 'CreateTime',
  154. sord: 'DESC'
  155. },
  156. queryJson: JSON.stringify({
  157. ...this.searchData,
  158. ApplyStatus: 0,
  159. CheckStatus: 2
  160. })
  161. },
  162. '加载数据时出错'
  163. )
  164. if (!result) {
  165. return
  166. }
  167. this.total = result.records
  168. this.page = result.page
  169. this.data = result.rows.map(e => {
  170. if (this.checkedObj[this.page] && this.checkedObj[this.page].find(e1=>e.Id == e1.Id)) {
  171. e.checked = true
  172. }
  173. return e
  174. });
  175. },
  176. toggleAllSelection(_, list) {
  177. this.checkedObj[this.page] = list
  178. },
  179. toggleRowSelection(bool, list) {
  180. this.checkedObj[this.page] = list
  181. },
  182. pageChange(index) {
  183. this.$refs.table.resetHighlight()
  184. this.currentRowDetail = []
  185. this.page = index
  186. this.fetchList()
  187. },
  188. async currentChange(row) {
  189. this.currentRowDetail = []
  190. const result = await this.HTTP_GET('learun/adms/purchasetravel/formdetail', row.Id)
  191. if (!result) return
  192. this.currentRowDetail = result
  193. },
  194. async action(type) {
  195. switch (type) {
  196. case 'save':
  197. let arr = []
  198. for(let key in this.checkedObj){
  199. arr = arr.concat(this.checkedObj[key] || [])
  200. }
  201. this.EMIT('details-change',arr)
  202. this.NAV_BACK()
  203. break
  204. case 'cancel':
  205. this.NAV_BACK()
  206. break
  207. default:
  208. break
  209. }
  210. },
  211. // 设置搜索条件
  212. async searchChange() {
  213. const result = {}
  214. // 时间查询相关参数
  215. if (this.dateRange) {
  216. result.StartTime = this.dateRange.start
  217. result.EndTime = this.dateRange.end
  218. }
  219. // 将其他查询项添加到查询 JSON 中
  220. const queryObj = pickBy(this.queryData, t => (Array.isArray(t) ? t.length > 0 : t))
  221. Object.assign(result, mapValues(queryObj, t => (Array.isArray(t) ? t.join(',') : t)))
  222. this.searchData = result
  223. await this.refreshList(false)
  224. },
  225. // 刷新清空列表
  226. async refreshList(isConcat = true) {
  227. this.page = 1
  228. this.total = 2
  229. this.list = []
  230. this.currentRowDetail = []
  231. this.checkedObj = {}
  232. this.$refs.table.resetHighlight()
  233. await this.fetchList(isConcat)
  234. },
  235. // 设置表单值
  236. setValue(path, val) {
  237. set(this.current, path, val)
  238. },
  239. }
  240. }
  241. </script>
  242. <style>
  243. </style>