collectionPlanDialog.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  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 } 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. columns() {
  163. return [
  164. {
  165. width: 45,
  166. type: 'selection',
  167. columnKey: 'selection',
  168. align: 'center',
  169. fixed: 'left'
  170. },
  171. {
  172. columnKey: 'index',
  173. label: '序号',
  174. type: 'index',
  175. width: 55,
  176. align: 'center',
  177. showOverflowTooltip: true,
  178. fixed: 'left'
  179. },
  180. {
  181. prop: 'detailNo',
  182. label: this.type == 2 ? '付款计划编码' : '收款计划编码',
  183. align: 'center',
  184. sortable: true,
  185. slot: 'detailNo',
  186. showOverflowTooltip: true,
  187. minWidth: 200,
  188. },
  189. {
  190. prop: 'sourceOrderNo',
  191. label: '订单编码',
  192. align: 'center',
  193. sortable: true,
  194. slot: 'sourceOrderNo',
  195. showOverflowTooltip: true,
  196. minWidth: 200,
  197. },
  198. {
  199. prop: 'sourceOrderType',
  200. label: '订单类型',
  201. align: 'center',
  202. sortable: true,
  203. showOverflowTooltip: true,
  204. minWidth: 200,
  205. formatter: (row) => {
  206. return row.sourceOrderType == 2 ? '采购订单' : '销售订单';
  207. }
  208. },
  209. {
  210. prop: 'contractNo',
  211. label: '合同编码',
  212. align: 'center',
  213. sortable: true,
  214. showOverflowTooltip: true,
  215. minWidth: 200,
  216. },
  217. {
  218. prop: 'contractCode',
  219. label: '合同编号',
  220. align: 'center',
  221. sortable: true,
  222. showOverflowTooltip: true,
  223. minWidth: 200,
  224. },
  225. {
  226. prop: 'contractName',
  227. label: '合同名称',
  228. align: 'center',
  229. sortable: true,
  230. showOverflowTooltip: true,
  231. minWidth: 200,
  232. },
  233. {
  234. prop: 'invoiceOrderNo',
  235. label: '发票号',
  236. align: 'center',
  237. sortable: true,
  238. showOverflowTooltip: true,
  239. minWidth: 200,
  240. },
  241. {
  242. prop: 'relatedReceivableOrderNo',
  243. label: this.type == 2 ? '关联应付编码' : '关联应收编码',
  244. align: 'center',
  245. showOverflowTooltip: true,
  246. minWidth: 150
  247. },
  248. {
  249. prop: 'customerCode',
  250. label: '客户编号',
  251. align: 'center',
  252. slot: 'customerCode',
  253. showOverflowTooltip: true,
  254. minWidth: 250
  255. },
  256. {
  257. prop: 'customerName',
  258. label: '客户名称',
  259. align: 'center',
  260. showOverflowTooltip: true,
  261. minWidth: 200
  262. },
  263. {
  264. prop: 'initiatorName',
  265. label: this.type == 2 ? '购买方名称':'销售方名称',
  266. align: 'center',
  267. showOverflowTooltip: true,
  268. minWidth: 200
  269. },
  270. {
  271. prop: 'settlementMode',
  272. label: '结算方式',
  273. align: 'center',
  274. showOverflowTooltip: true,
  275. minWidth: 140,
  276. formatter: (row) => {
  277. return this.getDictValue('结算方式', row.settlementMode);
  278. }
  279. },
  280. {
  281. prop: 'transactionMode',
  282. label: '交易方式',
  283. align: 'center',
  284. showOverflowTooltip: true,
  285. minWidth: 200,
  286. formatter: (row) => {
  287. return this.transactionMethodsOp.find(item => item.value == row.transactionMode)?.label || '';
  288. }
  289. },
  290. {
  291. prop: 'deliveryMode',
  292. label: '发货模式',
  293. align: 'center',
  294. showOverflowTooltip: true,
  295. minWidth: 130,
  296. formatter: (row) => {
  297. return this.shippingModeOp.find(item => item.value == row.deliveryMode)?.label || '';
  298. }
  299. },
  300. {
  301. prop: 'issueNumber',
  302. label: '期数',
  303. align: 'center',
  304. showOverflowTooltip: true,
  305. minWidth: 130
  306. },
  307. {
  308. prop: 'paymentType',
  309. label: '款项类型',
  310. align: 'center',
  311. showOverflowTooltip: true,
  312. minWidth: 200
  313. },
  314. {
  315. prop: 'moneyName',
  316. label: '款项名称',
  317. align: 'center',
  318. showOverflowTooltip: true,
  319. minWidth: 140
  320. },
  321. {
  322. prop: 'paymentRatio',
  323. label: '比例',
  324. align: 'center',
  325. showOverflowTooltip: true,
  326. minWidth: 140
  327. },
  328. {
  329. prop: 'planPaymentAmount',
  330. label: this.type == 2 ? '计划付款金额' : '计划收款金额',
  331. align: 'center',
  332. showOverflowTooltip: true,
  333. minWidth: 140
  334. },
  335. {
  336. prop: 'planPaymentDate',
  337. label: this.type == 2 ? '计划付款日期' : '计划收款日期',
  338. align: 'center',
  339. showOverflowTooltip: true,
  340. minWidth: 140
  341. },
  342. {
  343. prop: 'isInvoice',
  344. label: '是否已开票',
  345. align: 'center',
  346. showOverflowTooltip: true,
  347. minWidth: 150,
  348. formatter: (_row, _column, cellValue) => {
  349. return cellValue ? '是' : '否';
  350. }
  351. },
  352. {
  353. prop: 'invoiceAmount',
  354. label: '已开票金额',
  355. align: 'center',
  356. showOverflowTooltip: true,
  357. minWidth: 120
  358. },
  359. {
  360. prop: 'invoiceDate',
  361. label: '开票日期',
  362. align: 'center',
  363. showOverflowTooltip: true,
  364. minWidth: 130
  365. },
  366. {
  367. prop: 'isGenerateReceivablePayment',
  368. label: this.type == 2 ? '是否生成应付款项' : '是否生成应收款项',
  369. align: 'center',
  370. showOverflowTooltip: true,
  371. minWidth: 130,
  372. formatter: (_row, _column, cellValue) => {
  373. return cellValue == 1 ? '是' : '否';
  374. }
  375. },
  376. {
  377. prop: 'receivableAmount',
  378. label: this.type == 2 ? '应付金额' : '应收金额',
  379. align: 'center',
  380. showOverflowTooltip: true,
  381. minWidth: 140
  382. },
  383. {
  384. prop: 'receivedAmount',
  385. label: this.type == 2 ? '已付款金额' : '已收款金额',
  386. align: 'center',
  387. showOverflowTooltip: true,
  388. minWidth: 170
  389. },
  390. {
  391. prop: 'actualReceivablePaymentDate',
  392. label: this.type == 2 ? '实际付款日期' : '实际收款日期',
  393. align: 'center',
  394. showOverflowTooltip: true,
  395. minWidth: 170
  396. },
  397. {
  398. prop: 'deliveryStatus',
  399. label: this.type == 2 ? '收货状态' : '发货状态',
  400. align: 'center',
  401. showOverflowTooltip: true,
  402. formatter: (_row, _column, cellValue) => {
  403. let options = this.menu === 'purchase' ? [
  404. { value: 0, label: '待收货' },
  405. { value: 1, label: '部分收货' },
  406. { value: 2, label: '全部收货' }
  407. ] : [
  408. { value: 0, label: '待发货' },
  409. { value: 1, label: '部分发货' },
  410. { value: 2, label: '全部发货' }
  411. ];
  412. return options.find(item => item.value == cellValue)?.label || '';
  413. },
  414. minWidth: 120
  415. },
  416. {
  417. prop: 'reconciliationStatus',
  418. label: '对账状态',
  419. align: 'center',
  420. showOverflowTooltip: true,
  421. minWidth: 100,
  422. formatter: (_row, _column, cellValue) => {
  423. let options = [
  424. { value: 0, label: '未对账' },
  425. { value: 1, label: '部分对账' },
  426. { value: 2, label: '全部对账' }
  427. ];
  428. return options.find(item => item.value == cellValue)?.label || '';
  429. }
  430. },
  431. {
  432. prop: 'invoiceStatus',
  433. label: '开票状态',
  434. align: 'center',
  435. showOverflowTooltip: true,
  436. minWidth: 100,
  437. formatter: (_row, _column, cellValue) => {
  438. return this.invoiceStatusOp.find(item => item.value == cellValue)?.label || '';
  439. }
  440. },
  441. {
  442. prop: 'paymentStatus',
  443. label: this.type == 2 ? '付款状态' : '收款状态',
  444. align: 'center',
  445. showOverflowTooltip: true,
  446. minWidth: 100,
  447. formatter: (_row, _column, cellValue) => {
  448. let options = this.menu === 'purchase' ? this.paymentType : this.paymentStatus;
  449. return options.find(item => item.value == cellValue)?.label || '';
  450. }
  451. },
  452. {
  453. prop: 'overdueStatus',
  454. label: '逾期状态',
  455. align: 'center',
  456. showOverflowTooltip: true,
  457. minWidth: 100,
  458. formatter: (_row, _column, cellValue) => {
  459. return _row.overdueStatus == 1 ? '逾期中' : '未逾期';
  460. }
  461. },
  462. // {
  463. // columnKey: 'action',
  464. // label: '操作',
  465. // width: 180,
  466. // align: 'center',
  467. // resizable: false,
  468. // slot: 'action',
  469. // showOverflowTooltip: true,
  470. // fixed: 'right'
  471. // }
  472. ]
  473. },
  474. rules() {
  475. return {
  476. initiatorId: [
  477. { required: true, message: '请选择', trigger: 'blur' }
  478. ],
  479. customerName: [
  480. { required: true, message: '请选择', trigger: 'blur' }
  481. ],
  482. transactionMode: [
  483. { required: true, message: '请选择', trigger: 'blur' }
  484. ]
  485. }
  486. },
  487. },
  488. data() {
  489. return {
  490. enterprisePage: [],
  491. searchForm: {
  492. initiatorId: '',
  493. customerId: '',
  494. customerName: '',
  495. transactionMode: 1
  496. },
  497. currentIndex: null,
  498. accountInfoDialogFlag: false,
  499. currentRow: {},
  500. radio: null,
  501. shippingModeOp,
  502. transactionMethodsOp,
  503. selection: [],
  504. paymentStatus,
  505. paymentType,
  506. invoiceStatusOp
  507. };
  508. },
  509. created() {
  510. this.requestDict('结算方式');
  511. this.getEnterprisePage();
  512. },
  513. methods: {
  514. handParent() {
  515. let item = {
  516. id: this.searchForm.customerId
  517. };
  518. if (this.type == 2) {
  519. this.$refs.supplierRef.open(item);
  520. } else {
  521. this.$refs.curtomerRef.open(item);
  522. }
  523. },
  524. search() {
  525. this.$refs.form.validate(async (valid) => {
  526. if (!valid) return this.$message.warning('请选择查询条件');
  527. this.reload(this.searchForm);
  528. });
  529. },
  530. reset() {
  531. this.searchForm = {
  532. initiatorId: '',
  533. customerId: '',
  534. customerName: '',
  535. transactionMode: 1
  536. };
  537. this.reload(this.searchForm);
  538. },
  539. changeParent(item) {
  540. this.searchForm.customerName = item.name;
  541. this.searchForm.customerId = item.id;
  542. },
  543. getEnterprisePage() {
  544. enterprisePage({
  545. pageNum: 1,
  546. size: 100
  547. }).then((res) => {
  548. this.enterprisePage = [];
  549. this.enterprisePage.push(...res.list);
  550. this.searchForm.initiatorId = this.enterprisePage[0].id;
  551. this.reload(this.searchForm);
  552. });
  553. },
  554. getEnterprise(val) {
  555. let data = this.enterprisePage.find(
  556. (item) => item.id == val
  557. );
  558. // this.searchForm.customerName = data.name;
  559. // this.searchForm.initiatorId = data.id;
  560. },
  561. init(item = {}, currentIndex = '') {
  562. this.currentIndex = currentIndex;
  563. // if (item.id) {
  564. // this.radio = item.id;
  565. // }
  566. },
  567. getAccountInfo(item) {
  568. this.currentRow.children = item;
  569. this.$emit('getAccountData', this.currentRow);
  570. this.handleClose();
  571. },
  572. /* 表格数据源 */
  573. datasource({ page, limit, where, order }) {
  574. return receiptPaymentPlanPage({
  575. pageNum: page,
  576. size: limit,
  577. ...where,
  578. invoiceStatus: '0,1',
  579. // reviewStatus: 2,
  580. sourceType: this.type
  581. });
  582. },
  583. /* 刷新表格 */
  584. reload(where) {
  585. this.$refs.table.reload({ pageNum: 1, where: where });
  586. },
  587. handleSelect(row, index) {
  588. if(this.selection.length == 0) {
  589. this.$message({
  590. message: '请选择计划',
  591. type: 'warning'
  592. });
  593. return;
  594. }
  595. let customerIds = this.selection.map((item) => item.customerId);
  596. let initiatorIds = this.selection.map((item) => item.initiatorId);
  597. let invoiceStatus = this.selection.map((item) => item.invoiceStatus);
  598. console.log(customerIds, initiatorIds);
  599. let flag = false
  600. // if(this.type == 2) {
  601. // this.selection.forEach(item => {
  602. // if(item.transactionMode == 2 && item.paymentStatus == 0) {
  603. // console.log('selection', item);
  604. // flag = true
  605. // }
  606. // })
  607. // }
  608. console.log(customerIds, initiatorIds, flag);
  609. // if(flag) {
  610. // this.$message.warning('先款后票的计划需要付款后再开票!');
  611. // return
  612. // }
  613. if(invoiceStatus.includes(2)) {
  614. this.$message.warning('请选择未开票的计划!');
  615. return
  616. }
  617. if(this.selection.length == 0 || new Set(customerIds).size != 1 || new Set(initiatorIds).size != 1) {
  618. this.$message.warning('请选择相同客户和销售方的计划!');
  619. return
  620. }
  621. this.$emit('getPlanData', this.selection)
  622. this.handleClose()
  623. // this.currentRow = row;
  624. // this.accountInfoDialogFlag = true;
  625. // this.$nextTick(() => {
  626. // this.$refs.accountInfoDialogRef.init(row, index);
  627. // });
  628. },
  629. handleClose() {
  630. this.$emit('update:collectionPlanDialogFlag', false);
  631. }
  632. }
  633. };
  634. </script>
  635. <style lang="scss" scoped>
  636. .tree_col {
  637. border: 1px solid #eee;
  638. padding: 10px 0;
  639. box-sizing: border-box;
  640. height: 500px;
  641. overflow: auto;
  642. }
  643. .table_col {
  644. padding-left: 10px;
  645. ::v-deep .el-table th.el-table__cell {
  646. background: #f2f2f2;
  647. }
  648. }
  649. .pagination {
  650. text-align: right;
  651. padding: 10px 0;
  652. }
  653. .btns {
  654. text-align: center;
  655. padding: 10px 0;
  656. }
  657. .topsearch {
  658. margin-bottom: 15px;
  659. }
  660. </style>