selectOrderDetailList.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <div>
  3. <avue-crud :option="option" :table-loading="loading" :data="data" :search.sync="search" ref="crud"
  4. @refresh-change="refreshChange" @selection-change="selectionChange" @search-change="searchChange"
  5. @search-reset="searchReset" @saveColumn="saveColumn" @current-change="currentChange" @size-change="sizeChange"
  6. :summaryMethod="summaryMethod" :page.sync="page" @on-load="onLoad">
  7. <template slot="costTypeSearch">
  8. <breakdown-select v-model="search.costType" :configuration="breakConfiguration"></breakdown-select>
  9. </template>
  10. <template slot="menuLeft">
  11. <el-tabs v-model="activeName" @tab-click="tabHandle">
  12. <el-tab-pane label="查询结果" name="searchList"></el-tab-pane>
  13. <el-tab-pane label="已选定数据" name="importStaging"></el-tab-pane>
  14. </el-tabs>
  15. </template>
  16. <template slot-scope="scope" slot="menu">
  17. <el-button type="text" icon="el-icon-edit" size="small" @click.stop="importStagList(scope.row, scope.index)"
  18. v-if="activeName == 'searchList'" :disabled="goodsListSave.findIndex(item => item.id == scope.row.id) !== -1">选择
  19. </el-button>
  20. <el-button type="text" icon="el-icon-delete" size="small" @click.stop="removeStagList(scope.row, scope.index)"
  21. v-else>移除
  22. </el-button>
  23. </template>
  24. </avue-crud>
  25. <div class="dialogButton">
  26. <span slot="footer" class="dialog-footer">
  27. <el-button @click="$emit('closeFun')">取 消</el-button>
  28. <el-button type="primary" @click="importProMent" :disabled="goodsListSave.length == 0">导入</el-button>
  29. </span>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import option from './config/mainLists.json'
  35. import { getListOrder, orderListBySettlement } from "@/api/financialManagement/paymentRequest";
  36. export default {
  37. name: "index",
  38. props: {
  39. billType: {
  40. type: String
  41. },
  42. flag: {
  43. type: Number
  44. },
  45. params: {
  46. type: Object
  47. },
  48. itemId: {
  49. type: String
  50. },
  51. closeFun: {
  52. type: Function
  53. }
  54. },
  55. data() {
  56. return {
  57. activeName: "searchList",
  58. option: option,
  59. loading: false,
  60. search: {},
  61. data: [],
  62. selectList: [],
  63. page: {
  64. pageSize: 20,
  65. currentPage: 1,
  66. total: 0,
  67. pageSizes: [20, 200, 300, 500, 700, 1000]
  68. },
  69. breakConfiguration: {
  70. multipleChoices: false,
  71. multiple: false,
  72. disabled: false,
  73. searchShow: true,
  74. collapseTags: false,
  75. clearable: true,
  76. placeholder: '请点击右边按钮选择',
  77. dicData: []
  78. },
  79. goodsListShow: [],
  80. goodsListSave: []
  81. }
  82. },
  83. watch: {
  84. 'params.corpId'(newVal, oldVal) {
  85. console.log(newVal, 87)
  86. if (newVal != oldVal) {
  87. this.onLoad(this.page, this.search)
  88. }
  89. },
  90. },
  91. async created() {
  92. // this.option = await this.getColumnData(this.getColumnName(281), option);
  93. },
  94. mounted() {
  95. this.onLoad(this.page, this.params)
  96. },
  97. methods: {
  98. importStagList(row, index) {
  99. // this.goodsListSave.push(row);
  100. this.$refs.crud.toggleSelection([row]);
  101. },
  102. removeStagList(row, index) {
  103. this.goodsListSave.splice(row.$index, 1);
  104. },
  105. // 标签页切换
  106. tabHandle(data) {
  107. if (data.name == "searchList") {
  108. this.goodsListSave = this.data;
  109. this.data = this.goodsListShow;
  110. this.page.total = this.page.totalTwo
  111. } else if (data.name == "importStaging") {
  112. this.goodsListShow = this.data;
  113. this.data = this.goodsListSave;
  114. this.page.totalTwo = this.page.total;
  115. this.page.total = 0;
  116. }
  117. },
  118. refreshChange() {
  119. this.onLoad(this.page);
  120. },
  121. searchReset() {
  122. this.onLoad(this.page, this.params);
  123. },
  124. searchChange(params, done) {
  125. if (params.createStart) {
  126. params.createStartDate = params.createStart[0]
  127. params.createEndDate = params.createStart[1]
  128. }
  129. params = {
  130. ...this.params,
  131. ...params,
  132. }
  133. this.onLoad(this.page, params);
  134. done()
  135. },
  136. selectionChange(row) {
  137. // this.selectList = row
  138. this.goodsListSave = row
  139. },
  140. summaryMethod({ columns, data }) {
  141. const sums = [];
  142. if (columns.length > 0) {
  143. columns.forEach((column, index) => {
  144. let prop = column.property
  145. if (['goodsTotalNum', 'totalMoney', 'returnsNumber', 'returnsAmount', 'balanceAmount', 'returnsBalanceAmount'].includes(prop)) {
  146. if (this.goodsListSave.length > 0) {
  147. let values = this.goodsListSave.map(item => Number(item[prop] || 0));
  148. let all = values.length !== 0 ? sums[index] = values.reduce((a, b) => {
  149. return a + b;
  150. }) : 0
  151. if (prop == 'goodsTotalNum' || prop == 'totalMoney' || prop == 'returnsNumber' || prop == 'returnsAmount' || prop == 'balanceAmount' || prop == 'returnsBalanceAmount') {
  152. sums[index] = all
  153. }
  154. } else {
  155. let values = this.data.map(item => Number(item[prop] || 0));
  156. let all = values.length !== 0 ? sums[index] = values.reduce((a, b) => {
  157. return a + b;
  158. }) : 0
  159. if (prop == 'goodsTotalNum' || prop == 'totalMoney' || prop == 'returnsNumber' || prop == 'returnsAmount' || prop == 'balanceAmount' || prop == 'returnsBalanceAmount') {
  160. sums[index] = all
  161. }
  162. }
  163. } else {
  164. sums[index] = ''
  165. }
  166. });
  167. }
  168. return sums;
  169. },
  170. currentChange(currentPage) {
  171. this.page.currentPage = currentPage;
  172. },
  173. sizeChange(pageSize) {
  174. this.page.pageSize = pageSize;
  175. },
  176. onLoad(page, params) {
  177. params = {
  178. ...this.params,
  179. ...params,
  180. }
  181. if (params && params.rentStartDate) {
  182. params.createStartDate = params.rentStartDate[0] + " " + "00:00:00" ? params.rentStartDate[0] + " " + "00:00:00" : '';
  183. params.createEndDate = params.rentStartDate[1] + " " + "23:59:59" ? params.rentStartDate[1] + " " + "23:59:59" : '';
  184. this.$delete(params, 'rentStartDate')
  185. }
  186. this.loading = true;
  187. // 把老数据进行更新 从父组件调用的子组件方法
  188. if (params.customerId != this.params.customerId) {
  189. this.params = params
  190. }
  191. // params = {
  192. // // ...params,
  193. // ...page,
  194. // ...this.params
  195. // }
  196. // ...this.params 使用之前的老数据 回请求之前的ID造成数据不对
  197. params.billType = this.billType
  198. if (this.$store.getters.userInfo.tenant_id === "673511") {
  199. params.type = "CMY"
  200. }
  201. params.flag = this.flag
  202. if (this.params.bsType == 'XS,TKXS') {
  203. params.settlementType = 'd'
  204. } else {
  205. params.settlementType = 'c'
  206. }
  207. orderListBySettlement(page.currentPage, page.pageSize, params).then(res => {
  208. this.data = res.data.data.records
  209. this.page.total = res.data.data.total
  210. }).finally(() => {
  211. this.loading = false;
  212. })
  213. // getListOrder(page.currentPage, page.pageSize, params).then(res => {
  214. // console.log(res,155)
  215. // this.data = res.data.data.records
  216. // this.page.total = res.data.data.total
  217. // }).finally(() => {
  218. // this.loading = false;
  219. // })
  220. },
  221. importProMent() {
  222. this.$emit('importProMent', this.goodsListSave);
  223. },
  224. //列保存触发
  225. async saveColumn() {
  226. const inSave = await this.saveColumnData(
  227. this.getColumnName(281),
  228. this.option
  229. );
  230. if (inSave) {
  231. this.$message.success("保存成功");
  232. //关闭窗口
  233. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  234. }
  235. },
  236. }
  237. }
  238. </script>
  239. <style scoped></style>