addOrEditDialog.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. :visible.sync="addOrEditDialogFlag"
  6. :title="title"
  7. :append-to-body="true"
  8. :close-on-click-modal="false"
  9. width="70%"
  10. :before-close="cancel"
  11. :fullscreen="fullscreen"
  12. >
  13. <template slot="title">
  14. <modalTitle
  15. :title="title"
  16. @setFullscreen="fullscreen = !fullscreen"
  17. ></modalTitle>
  18. </template>
  19. <el-form
  20. ref="form"
  21. :rules="rules"
  22. class="el-form-box"
  23. :model="form"
  24. label-width="140px"
  25. >
  26. <headerTitle title="基本信息"></headerTitle>
  27. <el-row :gutter="12">
  28. <el-col :span="12">
  29. <el-form-item label="发票类型" prop="type">
  30. <el-select
  31. v-model="form.type"
  32. @change="handleSelType('isType')"
  33. clearable
  34. style="width: 100%"
  35. >
  36. <el-option label="开票" :value="1"></el-option>
  37. <el-option label="收票" :value="2"></el-option>
  38. </el-select>
  39. </el-form-item>
  40. </el-col>
  41. <el-col :span="12" v-if="form.type">
  42. <el-form-item label="来源类型" prop="sourceType">
  43. <el-select
  44. v-model="form.sourceType"
  45. @change="handleSelType()"
  46. :disabled="isOtherSourceFlag"
  47. clearable
  48. style="width: 100%"
  49. >
  50. <el-option label="对账单" :value="1"></el-option>
  51. <el-option label="合同" :value="2"></el-option>
  52. <el-option label="订单" :value="3"></el-option>
  53. <el-option
  54. label="应收"
  55. :value="5"
  56. v-if="form.type == 1"
  57. ></el-option>
  58. <el-option
  59. label="应付"
  60. :value="4"
  61. v-if="form.type == 2"
  62. ></el-option>
  63. </el-select>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="12" v-if="form.sourceType == 1">
  67. <el-form-item label="对账单" prop="sourceCode">
  68. <el-input
  69. v-model="form.sourceCode"
  70. readonly
  71. @click.native="handleSelectAccount(1)"
  72. ></el-input>
  73. </el-form-item>
  74. </el-col>
  75. <el-col :span="12" v-if="form.sourceType == 2">
  76. <el-form-item label="合同" prop="sourceCode">
  77. <el-input
  78. v-model="form.sourceCode"
  79. readonly
  80. @click.native="handleSelectAccount(2)"
  81. ></el-input>
  82. </el-form-item>
  83. </el-col>
  84. <el-col :span="12" v-if="form.sourceType == 3">
  85. <el-form-item label="订单" prop="sourceCode">
  86. <el-input
  87. v-model="form.sourceCode"
  88. readonly
  89. @click.native="handleSelectAccount(3)"
  90. ></el-input>
  91. </el-form-item>
  92. </el-col>
  93. <el-col :span="12" v-if="form.sourceType == 5">
  94. <el-form-item label="应收" prop="sourceCode">
  95. <el-input
  96. v-model="form.sourceCode"
  97. readonly
  98. @click.native="handleSelectAccount(5)"
  99. ></el-input>
  100. </el-form-item>
  101. </el-col>
  102. <el-col :span="12" v-if="form.sourceType == 4">
  103. <el-form-item label="应付" prop="sourceCode">
  104. <el-input
  105. v-model="form.sourceCode"
  106. readonly
  107. @click.native="handleSelectAccount(4)"
  108. ></el-input>
  109. </el-form-item>
  110. </el-col>
  111. <el-col :span="12">
  112. <el-form-item label="金额" prop="amount">
  113. <el-input-number
  114. v-model="form.amount"
  115. :precision="2"
  116. :controls="false"
  117. style="width: 100%"
  118. :min="0"
  119. ></el-input-number>
  120. </el-form-item>
  121. </el-col>
  122. <el-col :span="12">
  123. <el-form-item label="申请部门" prop="applyDeptId">
  124. <ele-tree-select
  125. clearable
  126. :data="deptTreeList"
  127. v-model="form.applyDeptId"
  128. valueKey="id"
  129. labelKey="name"
  130. placeholder="请选择"
  131. @change="changeDeptInfo"
  132. default-expand-all
  133. />
  134. </el-form-item>
  135. </el-col>
  136. <el-col :span="12">
  137. <el-form-item label="申请人" prop="applyUserId">
  138. <personSelect
  139. ref="directorRef"
  140. v-model="form.applyUserId"
  141. @selfChange="changeUserInfo"
  142. />
  143. </el-form-item>
  144. </el-col>
  145. <el-col :span="12">
  146. <el-form-item label="预计开票日期">
  147. <el-date-picker
  148. style="width: 100%"
  149. v-model="form.expectInvoiceDate"
  150. type="date"
  151. value-format="yyyy-MM-dd"
  152. placeholder="选择日期"
  153. >
  154. </el-date-picker>
  155. </el-form-item>
  156. </el-col>
  157. </el-row>
  158. <headerTitle title="开票信息"></headerTitle>
  159. <el-row :gutter="12">
  160. <el-col :span="12">
  161. <el-form-item label="公司名称" prop="companyName">
  162. <el-input
  163. v-model="form.companyName"
  164. placeholder="请输入"
  165. v-if="enterprisePage.length <= 1 || form.type == 2"
  166. />
  167. <el-select
  168. v-if="enterprisePage.length > 1 && form.type == 1"
  169. style="width: 100%"
  170. v-model="form.companyName"
  171. placeholder="请选择"
  172. >
  173. <el-option
  174. v-for="item in enterprisePage"
  175. :key="item.id"
  176. :label="item.name"
  177. :value="item.name"
  178. @click.native="enterpriseChange(item)"
  179. >
  180. </el-option>
  181. </el-select>
  182. </el-form-item>
  183. </el-col>
  184. <el-col :span="12">
  185. <el-form-item label="发票类型" prop="category">
  186. <el-radio v-model="form.category" :label="2"
  187. >增值税普通发票</el-radio
  188. >
  189. <el-radio v-model="form.category" :label="1"
  190. >增值税专用发票</el-radio
  191. >
  192. </el-form-item>
  193. </el-col>
  194. <el-col :span="12">
  195. <el-form-item
  196. label="统一社会信用代码"
  197. prop="companyUsc"
  198. class="form_item_label"
  199. >
  200. <el-input v-model="form.companyUsc"></el-input>
  201. </el-form-item>
  202. </el-col>
  203. <el-col :span="12">
  204. <el-form-item label="开户银行" prop="companyBankBranchNo">
  205. <el-input v-model="form.companyBankBranchNo"></el-input>
  206. </el-form-item>
  207. </el-col>
  208. <el-col :span="12">
  209. <el-form-item label="银行账户" prop="companyBankAccount">
  210. <el-input v-model="form.companyBankAccount"></el-input>
  211. </el-form-item>
  212. </el-col>
  213. <el-col :span="12">
  214. <el-form-item label="单位地址" prop="companyAddress">
  215. <el-input v-model="form.companyAddress"></el-input>
  216. </el-form-item>
  217. </el-col>
  218. <el-col :span="12">
  219. <el-form-item label="电话号码" prop="companyTel">
  220. <el-input v-model="form.companyTel"></el-input>
  221. </el-form-item>
  222. </el-col>
  223. </el-row>
  224. <headerTitle title="收票信息"></headerTitle>
  225. <el-row :gutter="12">
  226. <el-col :span="12">
  227. <el-form-item label="收票人" prop="receiverName">
  228. <el-input
  229. v-model="form.receiverName"
  230. placeholder="请输入"
  231. v-if="enterprisePage.length <= 1 || form.type == 1"
  232. />
  233. <el-select
  234. v-if="enterprisePage.length > 1 && form.type == 2"
  235. style="width: 100%"
  236. v-model="form.receiverName"
  237. placeholder="请选择"
  238. >
  239. <el-option
  240. v-for="item in enterprisePage"
  241. :key="item.id"
  242. :label="item.name"
  243. :value="item.name"
  244. @click.native="enterpriseChange(item)"
  245. >
  246. </el-option>
  247. </el-select>
  248. </el-form-item>
  249. </el-col>
  250. <el-col :span="12">
  251. <el-form-item label="收票人地址" prop="receiverAddress">
  252. <el-input v-model="form.receiverAddress"></el-input>
  253. </el-form-item>
  254. </el-col>
  255. </el-row>
  256. <el-row :gutter="12">
  257. <el-col :span="12">
  258. <el-form-item label="联系方式" prop="receiverTel">
  259. <el-input v-model="form.receiverTel"></el-input>
  260. </el-form-item>
  261. </el-col>
  262. </el-row>
  263. </el-form>
  264. <headerTitle title="关联信息"></headerTitle>
  265. <table-info
  266. :isOtherSourceFlag="isOtherSourceFlag"
  267. :dialogType="dialogType"
  268. :form="form"
  269. :contactData="contactData"
  270. ref="table"
  271. @setPrice="setPrice"
  272. :invoiceAmount="form.invoiceAmount"
  273. ></table-info>
  274. <div slot="footer">
  275. <el-button type="primary" @click="handleSave(0)">保存</el-button>
  276. <el-button
  277. type="primary"
  278. v-if="isNeed_process_is_close"
  279. @click="handleSave(1)"
  280. >提交</el-button
  281. >
  282. <el-button @click="cancel">返回</el-button>
  283. </div>
  284. <process-submit-dialog
  285. api-fun-name="fininvoiceapplyStatusAPI"
  286. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  287. v-if="processSubmitDialogFlag"
  288. ref="processSubmitDialogRef"
  289. @reload="reload"
  290. ></process-submit-dialog>
  291. <!--对账单-->
  292. <account-statement-dialog
  293. ref="accountStatementDialogRef"
  294. :form="form"
  295. v-if="accountStatementDialogFlag"
  296. :accountstatement-dialog-flag.sync="accountStatementDialogFlag"
  297. @getAccountData="getAccountData"
  298. :contactData="contactData"
  299. :type="form.type"
  300. >
  301. </account-statement-dialog>
  302. <!--采购订单-->
  303. <purchasinOrderListDialog
  304. ref="orderListDialogRef"
  305. @changeParent="changeOrder"
  306. ></purchasinOrderListDialog>
  307. <!--销售订单-->
  308. <saleOrderListDialog
  309. ref="saleOrderListDialogref"
  310. @changeParent="changeOrder"
  311. ></saleOrderListDialog>
  312. <contractListDialog
  313. ref="selectContractRef"
  314. @changeParent="changeContract"
  315. :type="form.type"
  316. ></contractListDialog>
  317. <!-- 应收 -->
  318. <receivableDialog
  319. ref="receivableRef"
  320. @receivableDone="receivableDone"
  321. v-if="receivableDialogFlag"
  322. :receivableDialogFlag.sync="receivableDialogFlag"
  323. ></receivableDialog>
  324. <!-- 应付 -->
  325. <paymentListDialog
  326. ref="receivableRef1"
  327. @receivableDone="receivableDone"
  328. v-if="paymentListDialogFlag"
  329. :paymentListDialogFlag.sync="paymentListDialogFlag"
  330. ></paymentListDialog>
  331. </ele-modal>
  332. </template>
  333. <script>
  334. import personSelect from '@/components/CommomSelect/person-select.vue';
  335. import { listOrganizations } from '@/api/system/organization';
  336. import { mapGetters } from 'vuex';
  337. import fileUpload from '@/components/upload/fileUpload.vue';
  338. import tableInfo from './tableInfo.vue';
  339. import { getTreeByPid } from '@/api/classifyManage';
  340. import {
  341. invoiceApplyInfoAPI,
  342. invoiceApplySaveAPI,
  343. invoiceApplyUpdateAPI
  344. } from '@/api/financialManage/invoiceManage';
  345. import { getpurchaseorderDetail } from '@/api/purchasingManage/purchaseOrder';
  346. import { getSaleOrderDetail } from '@/api/saleManage/saleorder';
  347. import { getDetail } from '@/api/contractManage/contractBook';
  348. import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
  349. import modalTitle from '@/BIZComponents/modalTitle.vue';
  350. import accountStatementDialog from './accountstatementDialog.vue';
  351. import contractListDialog from '@/views/saleManage/saleOrder/components/contractListDialog.vue';
  352. import purchasinOrderListDialog from '@/views/purchasingManage/purchaseOrder/invoice/components/orderListDialog.vue'; //采购订单
  353. import saleOrderListDialog from '@/views/saleManage/saleOrder/invoice/components/orderListDialog.vue'; //销售订单
  354. import { enterprisePage } from '@/api/contractManage/contractBook';
  355. import { contactDetail } from '@/api/saleManage/contact';
  356. import fileMain from '@/components/addDoc/index.vue';
  357. import receivableDialog from '@/views/financialManage/receivableManage/components/receivableDialog.vue'; //应收
  358. import paymentListDialog from '@/views/financialManage/payableManage/components/paymentListDialog.vue'; //应付
  359. import { updateContractStatus } from '@/api/contractManage/contractBook';
  360. const defForm = {
  361. accountingSubjectCode: '',
  362. accountingSubjectId: '',
  363. accountingSubjectName: '',
  364. amount: undefined,
  365. contactId: '',
  366. companyAddress: '',
  367. companyBankAccount: '',
  368. companyUsc: '',
  369. expectInvoiceDate: '',
  370. companyBankBranchNo: '',
  371. companyName: '',
  372. receiverAddress: '',
  373. receiverName: '',
  374. receiverTel: '',
  375. companyTel: '',
  376. detailList: [],
  377. drawerId: '',
  378. drawerName: '',
  379. files: [],
  380. invoiceStatus: '',
  381. link: [],
  382. remark: '',
  383. settlementAccountId: '',
  384. settlementAccountName: '',
  385. invoiceAmount: 0,
  386. getAccountData: '',
  387. sourceId: '',
  388. sourceCode: '',
  389. category: 1
  390. };
  391. export default {
  392. name: 'add-or-edit-dialog',
  393. components: {
  394. processSubmitDialog,
  395. fileUpload,
  396. personSelect,
  397. tableInfo,
  398. modalTitle,
  399. accountStatementDialog,
  400. contractListDialog,
  401. purchasinOrderListDialog,
  402. saleOrderListDialog,
  403. fileMain,
  404. receivableDialog,
  405. paymentListDialog
  406. },
  407. props: {
  408. addOrEditDialogFlag: {
  409. type: Boolean,
  410. default: false
  411. },
  412. contactData: {
  413. type: Object,
  414. default: () => {
  415. return {};
  416. }
  417. }
  418. },
  419. provide() {
  420. return {
  421. invoiceType: () => this.form.type
  422. };
  423. },
  424. computed: {
  425. ...mapGetters(['user'])
  426. },
  427. data() {
  428. return {
  429. fullscreen: false,
  430. receivableDialogFlag: false,
  431. dialogType: '',
  432. title: '',
  433. isOtherSourceFlag: false,
  434. processSubmitDialogFlag: false,
  435. accountStatementDialogFlag: false,
  436. paymentListDialogFlag:false,
  437. enterprisePage: [],
  438. form: {
  439. applyDeptId: '',
  440. applyDeptName: '',
  441. applyUserId: '',
  442. applyUserName: '',
  443. type: 1,
  444. id: '',
  445. ...defForm
  446. },
  447. feeTypeList: [],
  448. accountingSubjectList: [],
  449. deptList: [],
  450. deptTreeList: [],
  451. rules: {
  452. applyDeptId: { required: true, message: '请选择', trigger: 'change' },
  453. applyUserId: { required: true, message: '请选择', trigger: 'change' },
  454. accountingSubjectId: {
  455. required: true,
  456. message: '请选择',
  457. trigger: 'change'
  458. },
  459. feeTypeId: { required: true, message: '请选择', trigger: 'change' },
  460. amount: { required: true, message: '请输入', trigger: 'blur' },
  461. companyName: { required: true, message: '请输入', trigger: 'blur' },
  462. type: { required: true, message: '请选择', trigger: 'change' },
  463. sourceType: { required: true, message: '请选择', trigger: 'change' }
  464. }
  465. };
  466. },
  467. created() {
  468. this.getClassifyList(24, 'accountingSubjectList');
  469. this.getDeptList();
  470. },
  471. methods: {
  472. //从发票管理新增发票初始化
  473. async init(row = {}, type) {
  474. this.title = type == 'add' ? '新增' : '修改';
  475. this.dialogType = type;
  476. if (type == 'add') {
  477. this.form.applyDeptId = this.user.info.groupId;
  478. this.form.applyDeptName = this.user.info.groupName;
  479. this.form.applyUserId = this.user.info.userId;
  480. this.form.applyUserName = this.user.info.name;
  481. enterprisePage({
  482. pageNum: 1,
  483. size: 200
  484. }).then((res) => {
  485. this.enterprisePage = [];
  486. this.enterprisePage.push(...res.list);
  487. this.enterpriseChange(this.enterprisePage[0]);
  488. });
  489. } else {
  490. await this.getInfo(row.id);
  491. }
  492. this.$nextTick(async () => {
  493. await this.getUserList(this.form.applyDeptId);
  494. });
  495. },
  496. //来源类型
  497. async handleSelectAccount(val) {
  498. if (val == 1) {
  499. this.accountStatementDialogFlag = true;
  500. }
  501. if (val == 2) {
  502. this.$refs.selectContractRef.open({}, 1, 1);
  503. }
  504. if (val == 3 && this.form.type == 2) {
  505. this.$refs.orderListDialogRef.open({}, 1, true);
  506. }
  507. if (val == 3 && this.form.type == 1) {
  508. this.$refs.saleOrderListDialogref.open({}, 1, true);
  509. }
  510. if (val == 5) {
  511. this.receivableDialogFlag = true;
  512. }
  513. if (val == 4) {
  514. this.paymentListDialogFlag = true;
  515. }
  516. },
  517. //合同回调
  518. async changeContract(data) {
  519. const res = await getDetail(data.id);
  520. this.$set(this.form, 'sourceId', data.id);
  521. this.$set(this.form, 'sourceCode', data.contractNo);
  522. this.$set(
  523. this.form,
  524. 'amount',
  525. res.contractVO?.discountTotalPrice - res.contractVO?.invoiceAmount
  526. );
  527. this.$set(this.form, 'invoiceAmount', res.contractVO?.invoiceAmount);
  528. this.getContactDetail(
  529. this.form.type == 2
  530. ? res.contractVO?.partbId
  531. : res.contractVO?.partaId,
  532. res.contractVO
  533. );
  534. res.productList.forEach((item) => {
  535. item.singlePrice =
  536. (item.discountSinglePrice &&
  537. Number(item.discountSinglePrice).toFixed(2)) ||
  538. item.singlePrice;
  539. item.totalPrice =
  540. (item.discountTotalPrice &&
  541. Number(item.discountTotalPrice).toFixed(2)) ||
  542. item.totalPrice;
  543. item.typeName = this.form.type == 1 ? '销售合同' : '采购合同';
  544. item.type = this.form.type == 1 ? '101' : '102';
  545. });
  546. this.$nextTick(() => {
  547. this.$refs.table.setValue(res.productList);
  548. });
  549. this.$forceUpdate();
  550. },
  551. async getContactDetail(id, data) {
  552. if (!id) {
  553. return;
  554. }
  555. this.form.contactId = id;
  556. const { base, other, bankList, linkList } = await contactDetail(id);
  557. if (this.form.type == 2) {
  558. this.form.companyName = data.partbName || base.name;
  559. this.form.companyUsc =
  560. data.partbUnifiedSocialCreditCode || base.unifiedSocialCreditCode;
  561. this.form.companyAddress =
  562. data.partbAddress || other?.addressName + other?.address;
  563. this.form.companyTel =
  564. data.partbTel ||
  565. linkList.find((item) => item.ifChief == 1)?.mobilePhone;
  566. this.form.companyBankAccount = bankList[0]?.accountNo;
  567. this.form.companyBankBranchNo = bankList[0]?.bankName;
  568. } else {
  569. this.form.receiverName = data.partaName || base.name;
  570. this.form.receiverAddress =
  571. data.partaAddress || other?.addressName + other?.address;
  572. this.form.receiverTel =
  573. data.partaTel ||
  574. linkList.find((item) => item.ifChief == 1)?.mobilePhone;
  575. }
  576. },
  577. //订单回调
  578. async changeOrder(data) {
  579. this.$set(this.form, 'sourceId', data.id);
  580. this.$set(this.form, 'sourceCode', data.orderNo);
  581. let res = {};
  582. if (this.form.type == 2) {
  583. res = await getpurchaseorderDetail(data.id);
  584. } else {
  585. res = await getSaleOrderDetail(data.id);
  586. }
  587. this.$set(this.form, 'amount', res.payAmount - res.invoiceAmount);
  588. this.$set(this.form, 'invoiceAmount', res.invoiceAmount);
  589. this.getContactDetail(
  590. this.form.type == 2 ? res.partbId : res.partaId,
  591. res
  592. );
  593. res.productList.forEach((item) => {
  594. item.singlePrice =
  595. (item.discountSinglePrice &&
  596. Number(item.discountSinglePrice).toFixed(2)) ||
  597. item.singlePrice;
  598. item.totalPrice =
  599. (item.discountTotalPrice &&
  600. Number(item.discountTotalPrice).toFixed(2)) ||
  601. item.totalPrice;
  602. item.typeName = this.form.type == 1 ? '销售订单' : '采购订单';
  603. item.type = this.form.type == 1 ? '201' : '202';
  604. });
  605. this.$nextTick(() => {
  606. this.$refs.table.setValue(res.productList);
  607. });
  608. this.$forceUpdate();
  609. console.log(res);
  610. },
  611. //应收应付回调
  612. async payableManage(data) {
  613. const { row, form } = data;
  614. console.log(data);
  615. this.$set(this.form, 'sourceId', row.id);
  616. this.$set(this.form, 'sourceCode', row.code);
  617. this.$set(
  618. this.form,
  619. 'amount',
  620. row.receivedTotalPrice || row.paidTotalPrice
  621. );
  622. this.$set(this.form, 'invoiceAmount', row.invoiceAmount);
  623. this.getContactDetail(form.contactId, {});
  624. },
  625. receivableDone(data) {
  626. this.$set(this.form, 'type', Number(data.type));
  627. this.$set(this.form, 'sourceType', data.sourceType);
  628. this.payableManage(data.data);
  629. },
  630. //对账单回调
  631. getAccountData(tableInfo) {
  632. this.getContactDetail(tableInfo.contactId, {});
  633. this.$nextTick(() => {
  634. this.$set(this.form, 'sourceId', tableInfo?.children?.id);
  635. this.$set(this.form, 'sourceCode', tableInfo?.statementNo);
  636. this.$set(
  637. this.form,
  638. 'invoiceAmount',
  639. tableInfo?.children?.invoiceAmount
  640. );
  641. this.$refs.table.getAccountData(tableInfo);
  642. });
  643. },
  644. //订单、合同列表
  645. async createInvoice1(data, type, sourceType) {
  646. this.$set(this.form, 'type', Number(type));
  647. this.$set(this.form, 'sourceType', sourceType);
  648. await this.init({}, 'add');
  649. if (sourceType == 2) {
  650. this.changeContract(data);
  651. }
  652. if (sourceType == 3) {
  653. this.changeOrder(data);
  654. }
  655. if (sourceType == 4 || sourceType == 5) {
  656. this.payableManage(data);
  657. }
  658. },
  659. //对账单列表
  660. createInvoice(
  661. row = {},
  662. invoiceType,
  663. tableInfo = {},
  664. isOtherSourceFlag = true,
  665. dialogType = 'add'
  666. ) {
  667. this.dialogType = dialogType;
  668. this.init(row, dialogType);
  669. this.form.type = tableInfo.type;
  670. this.$set(this.form, 'sourceType', invoiceType);
  671. // this.form.sourceType=invoiceType
  672. setTimeout(() => {
  673. this.getAccountData(tableInfo);
  674. }, 400);
  675. },
  676. //获取详情
  677. async getInfo(id) {
  678. this.form = await invoiceApplyInfoAPI(id);
  679. },
  680. //获取分类管理中的数据
  681. async getClassifyList(id, listName) {
  682. let res = await getTreeByPid(id);
  683. this[listName] = res.data;
  684. },
  685. //获取费用类别选中数据
  686. changeFeeTypeInfo(val) {
  687. if (!val) {
  688. this.form.feeTypeName = '';
  689. this.form.feeTypeCode = '';
  690. }
  691. let data = this.$refs.feeTypeTree?.$refs?.tree?.getCurrentNode() || {};
  692. this.form.feeTypeName = data.name;
  693. this.form.feeTypeCode = data.code;
  694. },
  695. //获取会计科目选中数据
  696. changeSubjectInfo(val) {
  697. if (!val) return (this.form.accountingSubjectName = '');
  698. let data = this.$refs.treeSelect?.$refs?.tree?.getCurrentNode() || {};
  699. this.form.accountingSubjectName = data.name;
  700. },
  701. // 获取部门数据
  702. getDeptList() {
  703. listOrganizations().then((list) => {
  704. this.deptList = list;
  705. this.deptTreeList = this.$util.toTreeData({
  706. data: list,
  707. idField: 'id',
  708. parentIdField: 'parentId'
  709. });
  710. });
  711. },
  712. // 选择负责人部门
  713. changeDeptInfo(id) {
  714. const info = this.deptList.find((e) => e.id == id) || {};
  715. this.form.applyDeptName = info.name;
  716. this.form.applyUserId = '';
  717. this.form.applyUserName = '';
  718. this.getUserList(id);
  719. },
  720. // 获取人员数据
  721. getUserList(deptId) {
  722. if (deptId) {
  723. this.$refs.directorRef.getList({ deptId });
  724. }
  725. },
  726. //选择人员数据
  727. changeUserInfo(val, info) {
  728. this.form.applyUserName = info.name;
  729. },
  730. //选择人员数据
  731. changDrawerName(val, info) {
  732. this.form.drawerName = info.name;
  733. },
  734. //
  735. handleSelType(val) {
  736. this.form = Object.assign({}, this.form, defForm);
  737. if (val == 'isType') {
  738. this.$set(this.form, 'sourceType', '');
  739. }
  740. this.$refs.table.clearTable();
  741. this.enterpriseChange(this.enterprisePage[0] || {});
  742. },
  743. setPrice(val) {
  744. this.form.amount = val;
  745. },
  746. //系统公司信息
  747. enterpriseChange(data = {}) {
  748. if (this.form.type == 1) {
  749. this.form.companyName = data.name;
  750. this.form.companyUsc = data.unifiedSocialCreditCode;
  751. this.form.companyAddress = data.address;
  752. this.form.companyTel = data.tel;
  753. } else {
  754. this.form.receiverName = data.name;
  755. this.form.receiverAddress = data.address;
  756. this.form.receiverTel = data.tel;
  757. }
  758. this.$forceUpdate();
  759. },
  760. //
  761. handleSave(flag) {
  762. this.$refs.form.validate(async (valid) => {
  763. if (!valid) return this.$message.warning('有必填项未填,请检查');
  764. let tableData = {};
  765. if (this.form.sourceType != 4 || this.form.sourceType != 5) {
  766. tableData = await this.$refs.table.getTableValidate();
  767. }
  768. this.form.link = tableData.link;
  769. this.form.detailList = tableData.detailList;
  770. const API =
  771. this.dialogType == 'add'
  772. ? invoiceApplySaveAPI
  773. : invoiceApplyUpdateAPI;
  774. const id = await API(this.form);
  775. if (this.form.sourceType == 2) {
  776. updateContractStatus([this.form.sourceId]);
  777. }
  778. if (flag) {
  779. await this.handleSub(id);
  780. return;
  781. }
  782. this.$message.success('操作成功');
  783. this.done();
  784. this.cancel();
  785. });
  786. },
  787. //提交-开启流程
  788. async handleSub(id = '') {
  789. let data = await invoiceApplyInfoAPI(id);
  790. this.processSubmitDialogFlag = true;
  791. let key =
  792. data.type == 1 ? 'fin_invoice_apply' : 'fin_invoice_receive_apply';
  793. this.$nextTick(() => {
  794. let params = {
  795. businessId: data.id,
  796. businessKey: key,
  797. formCreateUserId: data.createUserId,
  798. variables: {
  799. type: data.type,
  800. businessCode: data.code
  801. }
  802. // callBackMethodType : '1',
  803. // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
  804. // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
  805. // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
  806. // miniHandle : '',
  807. // miniView : '',
  808. };
  809. this.$refs.processSubmitDialogRef.init(params);
  810. });
  811. // try {
  812. // await invoiceApplySubmit({
  813. // businessId: id || this.form.id,
  814. // type: this.form.type
  815. // });
  816. // } catch (e) {
  817. // this.$message.error(e.message);
  818. // }
  819. },
  820. reload() {
  821. this.done();
  822. this.cancel();
  823. },
  824. //刷新主列表数据
  825. done() {
  826. this.$emit('reload');
  827. },
  828. //关闭弹窗
  829. cancel() {
  830. this.$emit('update:addOrEditDialogFlag', false);
  831. }
  832. }
  833. };
  834. </script>
  835. <style scoped lang="scss"></style>