feeRelatedInfoTable.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. <template>
  2. <div>
  3. <el-form ref="form" :model="form">
  4. <!-- 数据表格 -->
  5. <ele-pro-table
  6. ref="table"
  7. :columns="columns"
  8. :datasource="form.datasource"
  9. :needPage="false"
  10. :minHeight="100"
  11. tool-class="ele-toolbar-form"
  12. cache-key="eomContactPageTable"
  13. >
  14. <!-- 表头工具栏 -->
  15. <template v-slot:toolbar>
  16. <el-button
  17. v-if="dialogType !== 'view'"
  18. size="small"
  19. type="primary"
  20. icon="el-icon-plus"
  21. class="ele-btn-icon"
  22. @click="handleAddInfo"
  23. >
  24. 新增关联信息
  25. </el-button>
  26. </template>
  27. <template v-slot:action="{ row, $index }">
  28. <el-popconfirm
  29. class="ele-action"
  30. title="确定要删除此信息吗?"
  31. :disabled="form.datasource.length == 1"
  32. @confirm="handleDelInfo($index)"
  33. >
  34. <template v-slot:reference>
  35. <el-link
  36. :disabled="form.datasource.length == 1"
  37. type="danger"
  38. :underline="false"
  39. icon="el-icon-delete"
  40. >
  41. 删除
  42. </el-link>
  43. </template>
  44. </el-popconfirm>
  45. </template>
  46. <template
  47. v-slot:financeCostType="{ row, $index }"
  48. v-if="dialogType !== 'view'"
  49. >
  50. <el-form-item
  51. :prop="'datasource.' + $index + '.financeCostType'"
  52. :rules="{
  53. required: true,
  54. message: '请选择',
  55. trigger: ['blur', 'change']
  56. }"
  57. >
  58. <ele-tree-select
  59. clearable
  60. filterable
  61. :ref="'feeTypeTree' + $index"
  62. :data="feeTypeList"
  63. v-model="row.financeCostTypeName"
  64. valueKey="id"
  65. labelKey="name"
  66. placeholder="请选择"
  67. @change="(val) => changeFeeTypeInfo(val, row, $index)"
  68. default-expand-all
  69. />
  70. </el-form-item>
  71. </template>
  72. <template
  73. v-slot:linkType="{ row, $index }"
  74. v-if="dialogType !== 'view'"
  75. >
  76. <el-form-item :prop="'datasource.' + $index + '.linkType'">
  77. <el-select
  78. v-model="row.linkType"
  79. @change="(val) => handleChangeFinLink(val, row, $index)"
  80. clearable
  81. >
  82. <el-option
  83. v-for="item in getLinkTypeList"
  84. :key="item.value"
  85. :label="item.label"
  86. :value="item.value"
  87. ></el-option>
  88. </el-select>
  89. </el-form-item>
  90. </template>
  91. <template
  92. v-slot:linkName="{ row, $index }"
  93. v-if="dialogType !== 'view'"
  94. >
  95. <el-form-item :prop="'datasource.' + $index + '.linkName'">
  96. <el-input
  97. v-model="row.linkName"
  98. @click.native="(val) => handleSelectData(val, row, $index)"
  99. clearable
  100. ></el-input>
  101. </el-form-item>
  102. </template>
  103. <template v-slot:amount="{ row, $index }" v-if="dialogType !== 'view'">
  104. <el-form-item
  105. :prop="'datasource.' + $index + '.amount'"
  106. :rules="{
  107. required: true,
  108. message: '请选择',
  109. trigger: ['blur', 'change']
  110. }"
  111. >
  112. <el-input-number
  113. style="width: 100%"
  114. :controls="false"
  115. :min="0"
  116. v-model="row.amount"
  117. @change="handleChangeAmount"
  118. clearable
  119. ></el-input-number>
  120. </el-form-item>
  121. </template>
  122. <template v-slot:files="{ row, $index }">
  123. <el-form-item :prop="'datasource.' + $index + '.files'">
  124. <fileMain v-model="row.files" :type="dialogType"></fileMain>
  125. </el-form-item>
  126. </template>
  127. <template v-slot:remark="{ row, $index }" v-if="dialogType !== 'view'">
  128. <el-form-item>
  129. <el-input type="textarea" v-model="row.remark" clearable></el-input>
  130. </el-form-item>
  131. </template>
  132. <template v-slot:headerGLLXMC="{ column }">
  133. <span class="is-required">{{ column.label }}</span>
  134. </template>
  135. </ele-pro-table>
  136. </el-form>
  137. <!--选择客户/供应商-->
  138. <customer-list-dialog
  139. v-if="customerListDialogFlag"
  140. :customerListDialogFlag.sync="customerListDialogFlag"
  141. ref="customerListDialogRef"
  142. @changeParent="getCustomerData"
  143. ></customer-list-dialog>
  144. <!--选择合同-->
  145. <contract-list-dialog
  146. v-if="contractListDialogFlag"
  147. :contractListDialogFlag.sync="contractListDialogFlag"
  148. ref="contractListDialogRef"
  149. @changeParent="getContractData"
  150. :type="contractType"
  151. ></contract-list-dialog>
  152. <!--选择销售订单-->
  153. <sale-order-list-dialog
  154. ref="saleOrderListDialogRef"
  155. @changeParent="getOrderData"
  156. ></sale-order-list-dialog>
  157. <!--选择采购订单-->
  158. <purchase-order-list-dialog
  159. ref="purchaseOrderListDialogRef"
  160. @changeParent="getOrderData"
  161. ></purchase-order-list-dialog>
  162. <!--商机-->
  163. <opportunity-dialog
  164. ref="opportunityDialogRef"
  165. v-if="opportunityDialogFlag"
  166. :opportunityDialogFlag.sync="opportunityDialogFlag"
  167. @changeParent="getOpportunityData"
  168. >
  169. </opportunity-dialog>
  170. <!--对账单-->
  171. <account-statement-dialog
  172. ref="accountStatementDialogRef"
  173. v-if="accountStatementDialogFlag"
  174. :accountType="accountType"
  175. :accountstatement-dialog-flag.sync="accountStatementDialogFlag"
  176. @changeParent="getAccountData"
  177. >
  178. </account-statement-dialog>
  179. <!--采购计划 -->
  180. <plan-dialog
  181. v-if="planDialogFlag"
  182. :plan-dialog-flag.sync="planDialogFlag"
  183. ref="planDialogRef"
  184. @changeParent="getPlanData"
  185. :collectionId="collectionId"
  186. >
  187. </plan-dialog>
  188. </div>
  189. </template>
  190. <script>
  191. import contractListDialog from '@/views/financialManage/components/contractListDialog.vue';
  192. import customerListDialog from '@/views/financialManage/components/customerListDialog.vue';
  193. import saleOrderListDialog from '@/views/saleManage/saleOrder/invoice/components/orderListDialog.vue';
  194. import purchaseOrderListDialog from '@/views/purchasingManage/purchaseOrder/invoice/components/orderListDialog.vue';
  195. import opportunityDialog from '@/views/financialManage/components/opportunityDialog.vue';
  196. import accountStatementDialog from '@/views/financialManage/components/accountstatementDialog.vue';
  197. import planDialog from '@/views/financialManage/components/planDialog.vue';
  198. import { getTreeByPid } from '@/api/classifyManage';
  199. import { mapGetters } from 'vuex';
  200. import { getByCode } from '@/api/system/dictionary-data';
  201. import fileUpload from '@/components/upload/fileUpload.vue';
  202. import { getFile } from '@/api/system/file';
  203. // import fileMain from '@/components/addDoc/index.vue';
  204. export default {
  205. name: 'relatedInfoTable',
  206. components: {
  207. // fileMain,
  208. fileUpload,
  209. purchaseOrderListDialog,
  210. saleOrderListDialog,
  211. customerListDialog,
  212. contractListDialog,
  213. opportunityDialog,
  214. accountStatementDialog,
  215. planDialog
  216. },
  217. props: {
  218. link: {
  219. type: Array,
  220. default: () => []
  221. },
  222. documentType: {
  223. type: [String, Number],
  224. default: ''
  225. },
  226. dialogType: {
  227. type: String,
  228. default: ''
  229. },
  230. collectionId: {
  231. type: String,
  232. default: ''
  233. }
  234. },
  235. data() {
  236. return {
  237. editIndex: undefined, //当前修改数据的下标
  238. contractType: undefined, //选择关联类型为合同时区分销售合同和采购合同
  239. contractListDialogFlag: false,
  240. customerListDialogFlag: false,
  241. opportunityDialogFlag: false,
  242. accountStatementDialogFlag: false,
  243. planDialogFlag: false,
  244. accountType: 1,
  245. feeTypeList: [],
  246. fin_link_type: [],
  247. CBToDT: {
  248. 1: [900, 120, 100, 1000],
  249. 2: [900, 120, 100, 230, 250, 260, 290],
  250. 3: [230, 250, 260, 290],
  251. 4: []
  252. },
  253. form: {
  254. datasource: []
  255. }
  256. };
  257. },
  258. computed: {
  259. columns() {
  260. let list = [
  261. {
  262. columnKey: 'index',
  263. label: '序号',
  264. type: 'index',
  265. width: 55,
  266. align: 'center',
  267. showOverflowTooltip: true,
  268. fixed: 'left'
  269. },
  270. {
  271. prop: 'financeCostTypeName',
  272. label: '财务费用类型',
  273. align: 'center',
  274. showOverflowTooltip: true,
  275. minWidth: 180,
  276. slot: 'financeCostType',
  277. headerSlot: 'headerGLLXMC'
  278. },
  279. // {
  280. // prop: 'YWFYLX',
  281. // label: '业务费用类型',
  282. // align: 'center',
  283. // showOverflowTooltip: true,
  284. // minWidth: 150,
  285. // slot: 'YWFYLX',
  286. // headerSlot: 'headerGLLXMC',
  287. // },
  288. {
  289. prop: 'linkTypeName',
  290. label: '关联业务类型',
  291. align: 'center',
  292. showOverflowTooltip: true,
  293. minWidth: 120,
  294. slot: 'linkType'
  295. },
  296. {
  297. prop: 'linkName',
  298. label: '单据名称',
  299. align: 'center',
  300. showOverflowTooltip: true,
  301. minWidth: 130,
  302. slot: 'linkName'
  303. },
  304. {
  305. prop: 'amount',
  306. label: '金额',
  307. align: 'center',
  308. showOverflowTooltip: true,
  309. minWidth: 120,
  310. slot: 'amount',
  311. headerSlot: 'headerGLLXMC'
  312. },
  313. {
  314. prop: 'files',
  315. label: '附件凭证',
  316. align: 'center',
  317. showOverflowTooltip: true,
  318. minWidth: 120,
  319. slot: 'files'
  320. },
  321. {
  322. prop: 'remark',
  323. label: '备注',
  324. align: 'center',
  325. showOverflowTooltip: true,
  326. minWidth: 120,
  327. slot: 'remark'
  328. }
  329. ];
  330. let action = [
  331. {
  332. columnKey: 'action',
  333. slot: 'action',
  334. label: '操作',
  335. resizable: false,
  336. width: 80,
  337. align: 'center',
  338. showOverflowTooltip: true,
  339. fixed: 'right'
  340. }
  341. ];
  342. this.dialogType === 'view'
  343. ? (list = [...list])
  344. : (list = [...list, ...action]);
  345. return list;
  346. },
  347. getLinkTypeList() {
  348. if (
  349. this.documentType == 4 ||
  350. !this.documentType ||
  351. !this.CBToDT[this.documentType]
  352. )
  353. return this.fin_link_type;
  354. let data = [];
  355. this.CBToDT[this.documentType].forEach((item) => {
  356. let find = this.fin_link_type.find((i) => i.value == item) || {};
  357. find.value && data.push(find);
  358. });
  359. return data;
  360. }
  361. },
  362. async mounted() {
  363. this.form.datasource = this.link;
  364. await this.getClassifyList(25, 'feeTypeList');
  365. let { data } = await getByCode('fin_link_type');
  366. this.fin_link_type = data.map((item) => {
  367. let values = Object.keys(item);
  368. return {
  369. value: values[0],
  370. label: item[values[0]]
  371. };
  372. });
  373. },
  374. methods: {
  375. //获取分类管理中的数据
  376. async getClassifyList(id, listName) {
  377. let res = await getTreeByPid(id);
  378. this[listName] = res.data;
  379. },
  380. downloadFile(file) {
  381. getFile({ objectName: file.storePath }, file.name);
  382. },
  383. //新增关联信息数据
  384. handleAddInfo() {
  385. this.form.datasource.push({
  386. linkType: '',
  387. linkTypeName: '',
  388. financeCostTypeName: '',
  389. financeCostType: '',
  390. linkId: '',
  391. linkName: '',
  392. linkCode: ''
  393. });
  394. },
  395. //
  396. handleSelectData(val, row, index) {
  397. this.editIndex = index;
  398. if (val.target.nodeName == 'I') {
  399. row.linkId = '';
  400. row.linkName = '';
  401. row.linkCode = '';
  402. return;
  403. }
  404. switch (row.linkType) {
  405. case '100': //客户
  406. this.handleSelectContact(row);
  407. break;
  408. case '120': //商机
  409. this.getOpportunityList(row);
  410. break;
  411. case '130': //销售合同
  412. this.contractType = 1;
  413. this.handleSelectContract(row);
  414. break;
  415. case '140': //销售订单
  416. this.handleSelectSaleOrder(row);
  417. break;
  418. case '190': //销售对账单
  419. this.accountType = 1;
  420. this.handleSelectAccount(row);
  421. break;
  422. case '210': //供应商
  423. this.handleSelectContact(row);
  424. break;
  425. case '230': //采购计划
  426. this.handleSelectPlan(row);
  427. break;
  428. case '250': //采购合同
  429. this.contractType = 2;
  430. this.handleSelectContract(row);
  431. break;
  432. case '260': //采购订单
  433. this.handleSelectPurchaseOrder(row);
  434. break;
  435. case '290': //采购对账单
  436. this.accountType = 2;
  437. this.handleSelectAccount(row);
  438. break;
  439. case '900': //项目
  440. //this.handleSelectPurchaseOrder(row);
  441. break;
  442. }
  443. // // 客户/供应商
  444. // if (['100', '210'].includes(row.linkType)) {
  445. // this.handleSelectContact(row)
  446. // }else if(['130', '250'].includes(row.linkType)){
  447. // handleSelectContract
  448. // }
  449. },
  450. //获取费用类别选中数据
  451. changeFeeTypeInfo(val, row, index) {
  452. this.editIndex = index;
  453. if (!val) {
  454. this.$set(
  455. this.form.datasource[this.editIndex],
  456. 'financeCostTypeName',
  457. ''
  458. );
  459. this.$set(
  460. this.form.datasource[this.editIndex],
  461. 'financeCostType',
  462. ''
  463. );
  464. }
  465. this.$nextTick(() => {
  466. let data =
  467. this.$refs['feeTypeTree' + index]?.$refs?.tree?.getCurrentNode() ||
  468. {};
  469. this.$set(
  470. this.form.datasource[this.editIndex],
  471. 'financeCostTypeName',
  472. data.name
  473. );
  474. this.$set(
  475. this.form.datasource[this.editIndex],
  476. 'financeCostType',
  477. data.code
  478. );
  479. });
  480. },
  481. setSelectData(val) {
  482. console.log(val,'val')
  483. this.$set(this.form.datasource[this.editIndex], 'linkId', val.id);
  484. this.$set(this.form.datasource[this.editIndex], 'linkName', val.name);
  485. this.$set(this.form.datasource[this.editIndex], 'linkCode', val.code);
  486. this.$set(this.form.datasource[this.editIndex], 'amount', val.amount);
  487. },
  488. clearData() {
  489. this.form.datasource = [];
  490. },
  491. handleChangeAmount(val, row) {
  492. let totalPrice = this.form.datasource.reduce((total, item) => {
  493. total += item.amount;
  494. return total;
  495. }, 0);
  496. this.$emit('setTotalPrice', totalPrice);
  497. },
  498. //删除关联信息数据
  499. handleDelInfo(index) {
  500. this.form.datasource.splice(index, 1);
  501. this.handleChangeAmount();
  502. },
  503. //修改关联类型
  504. handleChangeFinLink(val, row, index) {
  505. this.editIndex = index;
  506. this.setSelectData({
  507. id: '',
  508. name: '',
  509. code: '',
  510. amount:''
  511. });
  512. this.$nextTick(() => {
  513. this.$refs.form.clearValidate('datasource.' + index + '.linkName');
  514. });
  515. if (!val) return (row.linkTypeName = '');
  516. row.linkTypeName = this.fin_link_type.find(
  517. (item) => item.value == val
  518. )?.label;
  519. // if (val.dictCode == 3) {
  520. // this.getOpportunityList()
  521. // }
  522. },
  523. //选择客户或者供应商
  524. handleSelectContact(row) {
  525. this.customerListDialogFlag = true;
  526. let params = {
  527. id: row.contactId,
  528. assetTreeId: row.linkType == 210 ? '19' : '17',
  529. classType: row.linkType == 210 ? 2 : 1,
  530. titleName: row.linkType == 210 ? '选择供应商' : '选择客户'
  531. };
  532. this.$nextTick(() => {
  533. this.$refs.customerListDialogRef.init(params);
  534. });
  535. },
  536. //获取选择 供应商/客户 数据
  537. getCustomerData(params) {
  538. this.setSelectData(params);
  539. },
  540. //获取商机
  541. async getOpportunityList() {
  542. this.opportunityDialogFlag = true;
  543. },
  544. //获取选择的商机数据
  545. getOpportunityData(params) {
  546. console.log(params);
  547. let row = {
  548. id: params.id,
  549. name: params.name,
  550. code: params.code,
  551. };
  552. this.setSelectData(row);
  553. },
  554. //对账单
  555. async handleSelectAccount() {
  556. this.accountStatementDialogFlag = true;
  557. },
  558. //获取选择的对账单数据
  559. getAccountData(params) {
  560. let row = {
  561. id: params.id,
  562. name: params.statementNo,
  563. code: params.statementNo
  564. };
  565. this.setSelectData(row);
  566. },
  567. //采购计划
  568. async handleSelectPlan() {
  569. this.planDialogFlag = true;
  570. },
  571. //获取选择的采购计划数据
  572. getPlanData(params) {
  573. let row = {
  574. id: params.id,
  575. name: params.planName,
  576. code: params.planCode
  577. };
  578. this.setSelectData(row);
  579. },
  580. //选择人员数据
  581. changeUserInfo(val, info) {
  582. this.form.applyUserName = info.name;
  583. },
  584. //选择合同
  585. handleSelectContract(val) {
  586. this.contractListDialogFlag = true;
  587. this.$nextTick(() => {
  588. this.$refs.contractListDialogRef.init();
  589. });
  590. },
  591. //获取合同数据
  592. getContractData(params) {
  593. let row = {
  594. id: params.id,
  595. name: params.contractName,
  596. code: params.contractNo,
  597. amount:params.discountTotalPrice
  598. };
  599. this.setSelectData(row);
  600. },
  601. //选择销售订单
  602. handleSelectSaleOrder(val) {
  603. this.$refs.saleOrderListDialogRef.open();
  604. },
  605. //选择采购订单
  606. handleSelectPurchaseOrder(val) {
  607. this.$refs.purchaseOrderListDialogRef.open();
  608. },
  609. //获取采购/销售订单数据
  610. getOrderData(params) {
  611. let row = {
  612. id: params.id,
  613. name: params.orderNo,
  614. code: params.orderNo,
  615. amount:params.payAmount
  616. };
  617. this.setSelectData(row);
  618. },
  619. getTableValidate() {
  620. return new Promise((resolve, reject) => {
  621. if (this.form.datasource.length == 0)
  622. return this.$message.warning('请填写关联信息');
  623. this.$refs.form.validate((valid) => {
  624. if (!valid) return this.$message.warning('请填写完整信息');
  625. resolve(this.form.datasource);
  626. });
  627. });
  628. }
  629. }
  630. };
  631. </script>
  632. <style scoped lang="scss">
  633. :deep(.el-form-item) {
  634. margin-bottom: 0;
  635. }
  636. </style>