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.
 
 
 
 
 
 

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