accountstatementDialog.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <el-dialog
  3. title="选择对账单"
  4. custom-class="ele-dialog-form long-dialog-form"
  5. :visible.sync="accountstatementDialogFlag"
  6. :before-close="handleClose"
  7. :close-on-click-modal="false"
  8. top="5vh"
  9. :close-on-press-escape="false"
  10. append-to-body
  11. width="70%"
  12. >
  13. <el-card shadow="never">
  14. <search @search="reload"></search>
  15. <ele-pro-table
  16. ref="table"
  17. :columns="columns"
  18. :datasource="datasource"
  19. row-key="id"
  20. height="calc(100vh - 500px)"
  21. class="dict-table"
  22. :selection.sync="selection"
  23. :row-click-checked="!multiple"
  24. :row-click-checked-intelligent="!multiple"
  25. @selection-change="handleSelectionChange"
  26. >
  27. <!-- 表头工具栏 -->
  28. <template v-slot:action="{ row }">
  29. <el-button size="mini" type="text" @click="handleSelect(row)"
  30. >对账明细</el-button
  31. >
  32. </template>
  33. </ele-pro-table>
  34. </el-card>
  35. <div slot="footer">
  36. <el-button size="small" @click="handleSubmit">选择</el-button>
  37. <el-button size="small" @click="handleClose">关闭</el-button>
  38. </div>
  39. <!-- 对账明细 -->
  40. <accountInfoDialog
  41. ref="accountInfoDialogRef"
  42. v-if="accountInfoDialogFlag"
  43. :account-info-dialog-flag.sync="accountInfoDialogFlag"
  44. @getAccountInfo="getAccountInfo"
  45. ></accountInfoDialog>
  46. </el-dialog>
  47. </template>
  48. <script>
  49. import search from './accountstatementSearch.vue';
  50. import { getAccountstatementList } from '@/api/saleManage/accountstatement';
  51. import accountInfoDialog from './accountInfoDialog.vue';
  52. export default {
  53. components: {
  54. search,
  55. accountInfoDialog
  56. },
  57. props: {
  58. form: {
  59. type: Object,
  60. default: () => {
  61. return {};
  62. }
  63. },
  64. type: {
  65. type: Number,
  66. default: 1
  67. },
  68. accountstatementDialogFlag: {
  69. default: false,
  70. type: Boolean
  71. },
  72. // 选择模式:true 多选(复选框列),false 单选(radio 列)
  73. multiple: {
  74. type: Boolean,
  75. default: false
  76. },
  77. contactData: {
  78. type: Object,
  79. default: () => {
  80. return {};
  81. }
  82. }
  83. },
  84. data() {
  85. return {
  86. currentIndex: null,
  87. accountInfoDialogFlag: false,
  88. selection: [],
  89. currentRow: {},
  90. radio: null
  91. };
  92. },
  93. computed: {
  94. columns() {
  95. // element-ui 原生不支持 type="radio",统一用 selection 复选框列,
  96. // 单选/多选通过 handleSelectionChange 约束选中数量实现
  97. const selectColumn = {
  98. type: 'selection',
  99. width: 55,
  100. align: 'center',
  101. fixed: 'left'
  102. };
  103. return [
  104. {
  105. columnKey: 'index',
  106. label: '序号',
  107. type: 'index',
  108. width: 55,
  109. align: 'center',
  110. showOverflowTooltip: true,
  111. fixed: 'left'
  112. },
  113. selectColumn,
  114. // {
  115. // action: 'action',
  116. // slot: 'action',
  117. // align: 'center',
  118. // label: '操作',
  119. // fixed: 'left'
  120. // },
  121. {
  122. prop: 'statementNo',
  123. label: '对账单编码',
  124. align: 'center',
  125. slot: 'statementNo',
  126. showOverflowTooltip: true,
  127. minWidth: 200
  128. },
  129. {
  130. prop: 'contactName',
  131. label: '客户名称',
  132. align: 'center',
  133. showOverflowTooltip: true,
  134. minWidth: 180
  135. },
  136. {
  137. prop: 'startDate',
  138. label: '对账开始日期',
  139. align: 'center',
  140. slot: 'startDate',
  141. showOverflowTooltip: true,
  142. minWidth: 200
  143. },
  144. {
  145. prop: 'endDate',
  146. label: '对账结束日期',
  147. align: 'center',
  148. slot: 'endDate',
  149. showOverflowTooltip: true,
  150. minWidth: 200
  151. },
  152. {
  153. prop: 'amountTotalPrice',
  154. label: '总金额',
  155. align: 'center',
  156. showOverflowTooltip: true,
  157. minWidth: 130
  158. },
  159. {
  160. prop: 'amountReceivablePrice',
  161. label: '应收金额',
  162. align: 'center',
  163. showOverflowTooltip: true,
  164. minWidth: 130
  165. },
  166. {
  167. prop: 'amountPayablePrice',
  168. label: '应付金额',
  169. align: 'center',
  170. showOverflowTooltip: true,
  171. minWidth: 130
  172. },
  173. {
  174. prop: 'createTime',
  175. label: '创建时间',
  176. align: 'center',
  177. showOverflowTooltip: true,
  178. minWidth: 170
  179. }
  180. ];
  181. }
  182. },
  183. methods: {
  184. init(item = {}, currentIndex = '') {
  185. this.currentIndex = currentIndex;
  186. // if (item.id) {
  187. // this.radio = item.id;
  188. // }
  189. },
  190. getAccountInfo(item) {
  191. this.currentRow.children = item;
  192. this.$emit('getAccountData', this.currentRow);
  193. this.handleClose();
  194. },
  195. /* 表格数据源 */
  196. datasource({ page, limit, where, order }) {
  197. if (this.contactData.id) {
  198. where['contactId'] = this.contactData.id;
  199. }
  200. return getAccountstatementList({
  201. pageNum: page,
  202. size: limit,
  203. ...where,
  204. reviewStatus: 2,
  205. type: String(this.type)
  206. });
  207. },
  208. /* 刷新表格 */
  209. reload(where) {
  210. this.$refs.table.reload({ pageNum: 1, where: where });
  211. },
  212. handleSelect(row, index) {
  213. this.currentRow = row;
  214. this.accountInfoDialogFlag = true;
  215. this.$nextTick(() => {
  216. this.$refs.accountInfoDialogRef.init(row, index);
  217. });
  218. },
  219. handleSubmit(){
  220. console.log(this.selection);
  221. this.$emit('getAccountData', this.selection);
  222. this.handleClose();
  223. },
  224. // 选择变化:多选直接透传;单选只保留最后选中的一项
  225. handleSelectionChange(selection) {
  226. let result = selection;
  227. if (!this.multiple && selection.length > 1) {
  228. // 单选模式:只保留最新选中的一项,回写表格勾选状态
  229. const last = selection[selection.length - 1];
  230. result = [last];
  231. this.$refs.table.clearSelection();
  232. this.$refs.table.toggleRowSelection(last, true);
  233. }
  234. this.selection = result;
  235. this.$emit('selectionChange', result);
  236. },
  237. handleClose() {
  238. this.$emit('update:accountstatementDialogFlag', false);
  239. }
  240. }
  241. };
  242. </script>
  243. <style lang="scss" scoped>
  244. .tree_col {
  245. border: 1px solid #eee;
  246. padding: 10px 0;
  247. box-sizing: border-box;
  248. height: 500px;
  249. overflow: auto;
  250. }
  251. .table_col {
  252. padding-left: 10px;
  253. ::v-deep .el-table th.el-table__cell {
  254. background: #f2f2f2;
  255. }
  256. }
  257. .pagination {
  258. text-align: right;
  259. padding: 10px 0;
  260. }
  261. .btns {
  262. text-align: center;
  263. padding: 10px 0;
  264. }
  265. .topsearch {
  266. margin-bottom: 15px;
  267. }
  268. </style>