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.
 
 
 
 
 
 

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