collectionPlanDialog.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <template>
  2. <el-dialog
  3. :title="type == 2 ? '选择付款计划' : '选择收款计划'"
  4. custom-class="ele-dialog-form long-dialog-form"
  5. :visible.sync="collectionPlanDialogFlag"
  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. <div>
  15. <el-form label-width="90px" :inline="true" ref="form" :rules="rules" labelWidth="120px" :model="searchForm">
  16. <el-form-item
  17. :label="type == 2 ? '供应商名称' : '客户名称'"
  18. prop="customerName"
  19. >
  20. <el-input
  21. clearable
  22. v-model="searchForm.customerName"
  23. @click.native="handParent"
  24. placeholder="请选择"
  25. readonly
  26. />
  27. </el-form-item>
  28. <el-form-item
  29. :label="type == 2 ? '购买方名称' : '销售方名称'"
  30. prop="initiatorId"
  31. >
  32. <el-select
  33. style="width: 100%"
  34. v-model="searchForm.initiatorId"
  35. placeholder="请选择"
  36. @change="getEnterprise()"
  37. >
  38. <el-option
  39. v-for="item in enterprisePage"
  40. :key="item.id"
  41. :label="item.name"
  42. :value="item.id"
  43. >
  44. </el-option>
  45. </el-select>
  46. </el-form-item>
  47. <el-form-item
  48. label="交易方式"
  49. prop="transactionMode"
  50. >
  51. <el-select
  52. style="width: 100%"
  53. v-model="searchForm.transactionMode"
  54. placeholder="请选择"
  55. disabled
  56. >
  57. <el-option
  58. v-for="item in transactionMethodsOp"
  59. :key="item.value"
  60. :label="item.label"
  61. :value="item.value"
  62. >
  63. </el-option>
  64. </el-select>
  65. </el-form-item>
  66. <el-form-item>
  67. <el-button
  68. type="primary"
  69. icon="el-icon-search"
  70. class="ele-btn-icon"
  71. @click="search"
  72. >
  73. 查询
  74. </el-button>
  75. <!-- <el-button @click="reset" icon="el-icon-refresh-left" type="primary"
  76. >重置</el-button
  77. > -->
  78. </el-form-item>
  79. </el-form>
  80. </div>
  81. <ele-pro-table
  82. ref="table"
  83. :columns="columns"
  84. :datasource="datasource"
  85. row-key="id"
  86. height="calc(100vh - 500px)"
  87. class="dict-table"
  88. :selection.sync="selection"
  89. @columns-change="handleColumnChange"
  90. :initLoad="false"
  91. >
  92. <!-- 表头工具栏 -->
  93. <template v-slot:action="{ row }">
  94. <el-button size="mini" type="text" @click="handleSelect(row)"
  95. >对账明细</el-button
  96. >
  97. </template>
  98. </ele-pro-table>
  99. </el-card>
  100. <div slot="footer">
  101. <el-button size="small" type="primary" @click="handleSelect">
  102. 选择
  103. </el-button>
  104. <el-button size="small" @click="handleClose">关闭</el-button>
  105. </div>
  106. <!-- 对账明细 -->
  107. <accountInfoDialog
  108. ref="accountInfoDialogRef"
  109. v-if="accountInfoDialogFlag"
  110. :account-info-dialog-flag.sync="accountInfoDialogFlag"
  111. @getAccountInfo="getAccountInfo"
  112. ></accountInfoDialog>
  113. <!-- 客户 -->
  114. <customerList ref="curtomerRef" @changeParent="changeParent"></customerList>
  115. <!-- 供应商 -->
  116. <supplierList
  117. ref="supplierRef"
  118. @changeParent="changeParent"
  119. :classType="2"
  120. ></supplierList>
  121. </el-dialog>
  122. </template>
  123. <script>
  124. import dictMixins from '@/mixins/dictMixins';
  125. import tabMixins from '@/mixins/tableColumnsMixin';
  126. import accountInfoDialog from './accountInfoDialog.vue';
  127. import { shippingModeOp, transactionMethodsOp, paymentStatus, paymentType, invoiceStatusOp, paymentTypeOp, shippingModePurchaseOp } from '@/enum/dict.js';
  128. import { receiptPaymentPlanPage } from '@/api/financialManage/payAndCollectPlan';
  129. import customerList from '@/views/saleManage/contact/components/parentList.vue';
  130. import supplierList from '@/views/purchasingManage/supplierManage/components/parentList.vue';
  131. import { enterprisePage } from '@/api/contractManage/contractBook';
  132. export default {
  133. mixins: [dictMixins, tabMixins],
  134. components: {
  135. accountInfoDialog,
  136. customerList,
  137. supplierList
  138. },
  139. props: {
  140. form: {
  141. type: Object,
  142. default: () => {
  143. return {};
  144. }
  145. },
  146. type: {
  147. type: String,
  148. default: '1'
  149. },
  150. collectionPlanDialogFlag: {
  151. default: false,
  152. type: Boolean
  153. },
  154. contactData: {
  155. type: Object,
  156. default: () => {
  157. return {};
  158. }
  159. }
  160. },
  161. computed: {
  162. shippingModeOptions() {
  163. return this.type == 2 ? shippingModePurchaseOp : shippingModeOp;
  164. },
  165. columns() {
  166. return [
  167. {
  168. width: 45,
  169. type: 'selection',
  170. columnKey: 'selection',
  171. align: 'center',
  172. fixed: 'left'
  173. },
  174. {
  175. columnKey: 'index',
  176. label: '序号',
  177. type: 'index',
  178. width: 55,
  179. align: 'center',
  180. showOverflowTooltip: true,
  181. fixed: 'left'
  182. },
  183. {
  184. prop: 'detailNo',
  185. label: this.type == 2 ? '付款计划编码' : '收款计划编码',
  186. align: 'center',
  187. sortable: true,
  188. slot: 'detailNo',
  189. showOverflowTooltip: true,
  190. minWidth: 200,
  191. },
  192. {
  193. prop: 'sourceOrderNo',
  194. label: '订单编码',
  195. align: 'center',
  196. sortable: true,
  197. slot: 'sourceOrderNo',
  198. showOverflowTooltip: true,
  199. minWidth: 200,
  200. },
  201. {
  202. prop: 'sourceOrderType',
  203. label: '订单类型',
  204. align: 'center',
  205. sortable: true,
  206. showOverflowTooltip: true,
  207. minWidth: 200,
  208. formatter: (row) => {
  209. return row.sourceOrderType == 2 ? '采购订单' : '销售订单';
  210. }
  211. },
  212. {
  213. prop: 'contractNo',
  214. label: '合同编码',
  215. align: 'center',
  216. sortable: true,
  217. showOverflowTooltip: true,
  218. minWidth: 200,
  219. },
  220. {
  221. prop: 'contractCode',
  222. label: '合同编号',
  223. align: 'center',
  224. sortable: true,
  225. showOverflowTooltip: true,
  226. minWidth: 200,
  227. },
  228. {
  229. prop: 'contractName',
  230. label: '合同名称',
  231. align: 'center',
  232. sortable: true,
  233. showOverflowTooltip: true,
  234. minWidth: 200,
  235. },
  236. {
  237. prop: 'invoiceOrderNo',
  238. label: '发票号',
  239. align: 'center',
  240. sortable: true,
  241. showOverflowTooltip: true,
  242. minWidth: 200,
  243. },
  244. {
  245. prop: 'relatedReceivableOrderNo',
  246. label: this.type == 2 ? '关联应付编码' : '关联应收编码',
  247. align: 'center',
  248. showOverflowTooltip: true,
  249. minWidth: 150
  250. },
  251. {
  252. prop: 'customerCode',
  253. label: '客户编号',
  254. align: 'center',
  255. slot: 'customerCode',
  256. showOverflowTooltip: true,
  257. minWidth: 250
  258. },
  259. {
  260. prop: 'customerName',
  261. label: '客户名称',
  262. align: 'center',
  263. showOverflowTooltip: true,
  264. minWidth: 200
  265. },
  266. {
  267. prop: 'initiatorName',
  268. label: this.type == 2 ? '购买方名称':'销售方名称',
  269. align: 'center',
  270. showOverflowTooltip: true,
  271. minWidth: 200
  272. },
  273. {
  274. prop: 'settlementMode',
  275. label: '结算方式',
  276. align: 'center',
  277. showOverflowTooltip: true,
  278. minWidth: 140,
  279. formatter: (row) => {
  280. return this.getDictValue('结算方式', row.settlementMode);
  281. }
  282. },
  283. {
  284. prop: 'transactionMode',
  285. label: '交易方式',
  286. align: 'center',
  287. showOverflowTooltip: true,
  288. minWidth: 200,
  289. formatter: (row) => {
  290. return this.transactionMethodsOp.find(item => item.value == row.transactionMode)?.label || '';
  291. }
  292. },
  293. {
  294. prop: 'deliveryMode',
  295. label: this.type == 2 ? '收货模式' : '发货模式',
  296. align: 'center',
  297. showOverflowTooltip: true,
  298. minWidth: 130,
  299. formatter: (row) => {
  300. return this.shippingModeOptions.find(item => item.value == row.deliveryMode)?.label || '';
  301. }
  302. },
  303. {
  304. prop: 'issueNumber',
  305. label: '期数',
  306. align: 'center',
  307. showOverflowTooltip: true,
  308. minWidth: 130
  309. },
  310. {
  311. prop: 'paymentType',
  312. label: '款项类型',
  313. align: 'center',
  314. showOverflowTooltip: true,
  315. minWidth: 200,
  316. formatter: (row) => {
  317. return this.paymentTypeOp.find(item => item.value == row.paymentType)?.label || '';
  318. }
  319. },
  320. {
  321. prop: 'moneyName',
  322. label: '款项名称',
  323. align: 'center',
  324. showOverflowTooltip: true,
  325. minWidth: 140
  326. },
  327. {
  328. prop: 'paymentRatio',
  329. label: '比例',
  330. align: 'center',
  331. showOverflowTooltip: true,
  332. minWidth: 140,
  333. formatter: (row) => {
  334. return row.paymentRatio + '%';
  335. }
  336. },
  337. {
  338. prop: 'planPaymentAmount',
  339. label: this.type == 2 ? '计划付款金额' : '计划收款金额',
  340. align: 'center',
  341. showOverflowTooltip: true,
  342. minWidth: 140
  343. },
  344. {
  345. prop: 'planPaymentDate',
  346. label: this.type == 2 ? '计划付款日期' : '计划收款日期',
  347. align: 'center',
  348. showOverflowTooltip: true,
  349. minWidth: 140
  350. },
  351. {
  352. prop: 'isInvoice',
  353. label: '是否已开票',
  354. align: 'center',
  355. showOverflowTooltip: true,
  356. minWidth: 150,
  357. formatter: (_row, _column, cellValue) => {
  358. return cellValue ? '是' : '否';
  359. }
  360. },
  361. {
  362. prop: 'invoiceAmount',
  363. label: '已开票金额',
  364. align: 'center',
  365. showOverflowTooltip: true,
  366. minWidth: 120
  367. },
  368. {
  369. prop: 'invoiceDate',
  370. label: '开票日期',
  371. align: 'center',
  372. showOverflowTooltip: true,
  373. minWidth: 130
  374. },
  375. {
  376. prop: 'isGenerateReceivablePayment',
  377. label: this.type == 2 ? '是否生成应付款项' : '是否生成应收款项',
  378. align: 'center',
  379. showOverflowTooltip: true,
  380. minWidth: 130,
  381. formatter: (_row, _column, cellValue) => {
  382. return cellValue == 1 ? '是' : '否';
  383. }
  384. },
  385. {
  386. prop: 'receivableAmount',
  387. label: this.type == 2 ? '应付金额' : '应收金额',
  388. align: 'center',
  389. showOverflowTooltip: true,
  390. minWidth: 140
  391. },
  392. {
  393. prop: 'receivedAmount',
  394. label: this.type == 2 ? '已付款金额' : '已收款金额',
  395. align: 'center',
  396. showOverflowTooltip: true,
  397. minWidth: 170
  398. },
  399. {
  400. prop: 'actualReceivablePaymentDate',
  401. label: this.type == 2 ? '实际付款日期' : '实际收款日期',
  402. align: 'center',
  403. showOverflowTooltip: true,
  404. minWidth: 170
  405. },
  406. {
  407. prop: 'deliveryStatus',
  408. label: this.type == 2 ? '收货状态' : '发货状态',
  409. align: 'center',
  410. showOverflowTooltip: true,
  411. formatter: (_row, _column, cellValue) => {
  412. let options = this.type == 2 ? [
  413. { value: 0, label: '待收货' },
  414. { value: 1, label: '部分收货' },
  415. { value: 2, label: '全部收货' }
  416. ] : [
  417. { value: 0, label: '待发货' },
  418. { value: 1, label: '部分发货' },
  419. { value: 2, label: '全部发货' }
  420. ];
  421. return options.find(item => item.value == cellValue)?.label || '';
  422. },
  423. minWidth: 120
  424. },
  425. {
  426. prop: 'reconciliationStatus',
  427. label: '对账状态',
  428. align: 'center',
  429. showOverflowTooltip: true,
  430. minWidth: 100,
  431. formatter: (_row, _column, cellValue) => {
  432. let options = [
  433. { value: 0, label: '未对账' },
  434. { value: 1, label: '部分对账' },
  435. { value: 2, label: '全部对账' }
  436. ];
  437. return options.find(item => item.value == cellValue)?.label || '';
  438. }
  439. },
  440. {
  441. prop: 'invoiceStatus',
  442. label: '开票状态',
  443. align: 'center',
  444. showOverflowTooltip: true,
  445. minWidth: 100,
  446. formatter: (_row, _column, cellValue) => {
  447. return this.invoiceStatusOp.find(item => item.value == cellValue)?.label || '';
  448. }
  449. },
  450. {
  451. prop: 'paymentStatus',
  452. label: this.type == 2 ? '付款状态' : '收款状态',
  453. align: 'center',
  454. showOverflowTooltip: true,
  455. minWidth: 100,
  456. formatter: (_row, _column, cellValue) => {
  457. let options = this.menu === 'purchase' ? this.paymentType : this.paymentStatus;
  458. return options.find(item => item.value == cellValue)?.label || '';
  459. }
  460. },
  461. {
  462. prop: 'overdueStatus',
  463. label: '逾期状态',
  464. align: 'center',
  465. showOverflowTooltip: true,
  466. minWidth: 100,
  467. formatter: (_row, _column, cellValue) => {
  468. return _row.overdueStatus == 1 ? '逾期中' : '未逾期';
  469. }
  470. },
  471. // {
  472. // columnKey: 'action',
  473. // label: '操作',
  474. // width: 180,
  475. // align: 'center',
  476. // resizable: false,
  477. // slot: 'action',
  478. // showOverflowTooltip: true,
  479. // fixed: 'right'
  480. // }
  481. ]
  482. },
  483. rules() {
  484. return {
  485. initiatorId: [
  486. { required: true, message: '请选择', trigger: 'blur' }
  487. ],
  488. customerName: [
  489. { required: true, message: '请选择', trigger: 'blur' }
  490. ],
  491. transactionMode: [
  492. { required: true, message: '请选择', trigger: 'blur' }
  493. ]
  494. }
  495. },
  496. },
  497. data() {
  498. return {
  499. enterprisePage: [],
  500. searchForm: {
  501. initiatorId: '',
  502. customerId: '',
  503. customerName: '',
  504. transactionMode: 1
  505. },
  506. currentIndex: null,
  507. accountInfoDialogFlag: false,
  508. currentRow: {},
  509. radio: null,
  510. shippingModeOp,
  511. transactionMethodsOp,
  512. selection: [],
  513. paymentStatus,
  514. paymentType,
  515. invoiceStatusOp,
  516. paymentTypeOp
  517. };
  518. },
  519. created() {
  520. this.requestDict('结算方式');
  521. this.getEnterprisePage();
  522. },
  523. methods: {
  524. handParent() {
  525. let item = {
  526. id: this.searchForm.customerId
  527. };
  528. if (this.type == 2) {
  529. this.$refs.supplierRef.open(item);
  530. } else {
  531. this.$refs.curtomerRef.open(item);
  532. }
  533. },
  534. search() {
  535. this.$refs.form.validate(async (valid) => {
  536. if (!valid) return this.$message.warning('请选择查询条件');
  537. this.reload(this.searchForm);
  538. });
  539. },
  540. reset() {
  541. this.searchForm = {
  542. initiatorId: '',
  543. customerId: '',
  544. customerName: '',
  545. transactionMode: 1
  546. };
  547. this.reload(this.searchForm);
  548. },
  549. changeParent(item) {
  550. this.searchForm.customerName = item.name;
  551. this.searchForm.customerId = item.id;
  552. },
  553. getEnterprisePage() {
  554. enterprisePage({
  555. pageNum: 1,
  556. size: 100
  557. }).then((res) => {
  558. this.enterprisePage = [];
  559. this.enterprisePage.push(...res.list);
  560. this.searchForm.initiatorId = this.enterprisePage[0].id;
  561. this.reload(this.searchForm);
  562. });
  563. },
  564. getEnterprise(val) {
  565. let data = this.enterprisePage.find(
  566. (item) => item.id == val
  567. );
  568. // this.searchForm.customerName = data.name;
  569. // this.searchForm.initiatorId = data.id;
  570. },
  571. init(item = {}, currentIndex = '') {
  572. this.currentIndex = currentIndex;
  573. // if (item.id) {
  574. // this.radio = item.id;
  575. // }
  576. },
  577. getAccountInfo(item) {
  578. this.currentRow.children = item;
  579. this.$emit('getAccountData', this.currentRow);
  580. this.handleClose();
  581. },
  582. /* 表格数据源 */
  583. datasource({ page, limit, where, order }) {
  584. return receiptPaymentPlanPage({
  585. pageNum: page,
  586. size: limit,
  587. ...where,
  588. invoiceStatus: '0,1',
  589. // reviewStatus: 2,
  590. sourceType: this.type
  591. });
  592. },
  593. /* 刷新表格 */
  594. reload(where) {
  595. this.$refs.table.reload({ pageNum: 1, where: where });
  596. },
  597. handleSelect(row, index) {
  598. if(this.selection.length == 0) {
  599. this.$message({
  600. message: '请选择计划',
  601. type: 'warning'
  602. });
  603. return;
  604. }
  605. let customerIds = this.selection.map((item) => item.customerId);
  606. let initiatorIds = this.selection.map((item) => item.initiatorId);
  607. let invoiceStatus = this.selection.map((item) => item.invoiceStatus);
  608. console.log(customerIds, initiatorIds);
  609. let flag = false
  610. // if(this.type == 2) {
  611. // this.selection.forEach(item => {
  612. // if(item.transactionMode == 2 && item.paymentStatus == 0) {
  613. // console.log('selection', item);
  614. // flag = true
  615. // }
  616. // })
  617. // }
  618. console.log(customerIds, initiatorIds, flag);
  619. // if(flag) {
  620. // this.$message.warning('先款后票的计划需要付款后再开票!');
  621. // return
  622. // }
  623. if(invoiceStatus.includes(2)) {
  624. this.$message.warning('请选择未开票的计划!');
  625. return
  626. }
  627. if(this.selection.length == 0 || new Set(customerIds).size != 1 || new Set(initiatorIds).size != 1) {
  628. this.$message.warning('请选择相同客户和销售方的计划!');
  629. return
  630. }
  631. this.$emit('getPlanData', this.selection)
  632. this.handleClose()
  633. // this.currentRow = row;
  634. // this.accountInfoDialogFlag = true;
  635. // this.$nextTick(() => {
  636. // this.$refs.accountInfoDialogRef.init(row, index);
  637. // });
  638. },
  639. handleClose() {
  640. this.$emit('update:collectionPlanDialogFlag', false);
  641. }
  642. }
  643. };
  644. </script>
  645. <style lang="scss" scoped>
  646. .tree_col {
  647. border: 1px solid #eee;
  648. padding: 10px 0;
  649. box-sizing: border-box;
  650. height: 500px;
  651. overflow: auto;
  652. }
  653. .table_col {
  654. padding-left: 10px;
  655. ::v-deep .el-table th.el-table__cell {
  656. background: #f2f2f2;
  657. }
  658. }
  659. .pagination {
  660. text-align: right;
  661. padding: 10px 0;
  662. }
  663. .btns {
  664. text-align: center;
  665. padding: 10px 0;
  666. }
  667. .topsearch {
  668. margin-bottom: 15px;
  669. }
  670. </style>