addOrEditDialogNew.vue 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404
  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. :maxable="true"
  12. :resizable="true"
  13. >
  14. <el-form
  15. ref="form"
  16. :rules="rules"
  17. class="el-form-box-add"
  18. :model="form"
  19. label-width="160px"
  20. >
  21. <headerTitle title="基本信息"></headerTitle>
  22. <el-row :gutter="12">
  23. <el-col :span="8">
  24. <el-form-item label="发票类型" prop="type">
  25. <el-select
  26. v-model="form.type"
  27. @change="handleSelType('isType')"
  28. clearable
  29. :disabled="!isEditType"
  30. style="width: 100%"
  31. >
  32. <el-option label="开票" value="1"></el-option>
  33. <el-option label="收票" value="2"></el-option>
  34. </el-select>
  35. </el-form-item>
  36. </el-col>
  37. <el-col :span="8" v-if="form.type">
  38. <el-form-item label="来源类型" prop="sourceType">
  39. <el-select
  40. v-model="form.sourceType"
  41. @change="handleSelType('sourceType')"
  42. :disabled="!isEditType"
  43. clearable
  44. style="width: 100%"
  45. >
  46. <el-option v-for="item in sourceTypeOp" :label="item.label" :value="item.value" :key="item.value"></el-option>
  47. <!-- <el-option label="对账单" :value="1"></el-option>
  48. <el-option label="合同" :value="2"></el-option>
  49. <el-option label="订单" :value="3"></el-option> -->
  50. <!-- <el-option label="收款计划" :value="1"></el-option> -->
  51. <!-- <el-option
  52. label="已收"
  53. :value="5"
  54. v-if="form.type == 1"
  55. ></el-option>
  56. <el-option
  57. label="已付"
  58. :value="4"
  59. v-if="form.type == 2"
  60. ></el-option>
  61. <el-option label="其他无订单无合同" :value="99"></el-option> -->
  62. </el-select>
  63. </el-form-item>
  64. </el-col>
  65. <el-col :span="8" v-if="form.sourceType == 1">
  66. <el-form-item label="对账单" prop="sourceCode">
  67. <el-input
  68. v-model="form.sourceCode"
  69. readonly
  70. @click.native="handleSelectAccount(1)"
  71. ></el-input>
  72. </el-form-item>
  73. </el-col>
  74. <el-col :span="8" v-if="form.sourceType == 2">
  75. <el-form-item label="合同" prop="sourceCode">
  76. <el-input
  77. v-model="form.sourceCode"
  78. readonly
  79. @click.native="handleSelectAccount(2)"
  80. ></el-input>
  81. </el-form-item>
  82. </el-col>
  83. <el-col :span="8" v-if="form.sourceType == 3">
  84. <el-form-item label="订单" prop="sourceCode">
  85. <el-input
  86. v-model="form.sourceCode"
  87. readonly
  88. @click.native="handleSelectAccount(3)"
  89. ></el-input>
  90. </el-form-item>
  91. </el-col>
  92. <el-col :span="8" v-if="form.sourceType == 5">
  93. <el-form-item label="已收" prop="sourceCode">
  94. <el-input
  95. v-model="form.sourceCode"
  96. readonly
  97. @click.native="handleSelectAccount(5)"
  98. ></el-input>
  99. </el-form-item>
  100. </el-col>
  101. <el-col :span="8" v-if="form.sourceType == 4">
  102. <el-form-item label="已付" prop="sourceCode">
  103. <el-input
  104. v-model="form.sourceCode"
  105. readonly
  106. @click.native="handleSelectAccount(4)"
  107. ></el-input>
  108. </el-form-item>
  109. </el-col>
  110. <el-col :span="8">
  111. <el-form-item label="发票金额" prop="amount">
  112. <el-input
  113. type="number"
  114. v-model="form.amount"
  115. :precision="2"
  116. :controls="false"
  117. style="width: 100%"
  118. disabled
  119. :min="0"
  120. >
  121. <template slot="append">
  122. <span>元</span>
  123. </template>
  124. </el-input>
  125. </el-form-item>
  126. </el-col>
  127. <el-col :span="8">
  128. <el-form-item label="发票号" prop="invoiceNos">
  129. <el-input
  130. v-model="form.invoiceNos"
  131. ></el-input>
  132. </el-form-item>
  133. </el-col>
  134. <el-col :span="8">
  135. <el-form-item label="开票日期">
  136. <el-date-picker
  137. style="width: 100%"
  138. v-model="form.expectInvoiceDate"
  139. type="date"
  140. value-format="yyyy-MM-dd"
  141. placeholder="选择日期"
  142. >
  143. </el-date-picker>
  144. </el-form-item>
  145. </el-col>
  146. <el-col :span="8">
  147. <el-form-item label="申请部门" prop="applyDeptId">
  148. <ele-tree-select
  149. clearable
  150. :data="deptTreeList"
  151. v-model="form.applyDeptId"
  152. valueKey="id"
  153. labelKey="name"
  154. placeholder="请选择"
  155. @change="changeDeptInfo"
  156. default-expand-all
  157. />
  158. </el-form-item>
  159. </el-col>
  160. <el-col :span="8">
  161. <el-form-item label="申请人" prop="applyUserId">
  162. <personSelect
  163. ref="directorRef"
  164. v-model="form.applyUserId"
  165. @selfChange="changeUserInfo"
  166. />
  167. </el-form-item>
  168. </el-col>
  169. <el-col :span="8">
  170. <el-form-item label="发票种类" prop="category">
  171. <el-select
  172. v-model="form.category"
  173. clearable
  174. style="width: 100%"
  175. >
  176. <el-option label="增值税专用发票" :value="1"></el-option>
  177. <el-option label="增值税普通发票" :value="2"></el-option>
  178. </el-select>
  179. </el-form-item>
  180. </el-col>
  181. <el-col :span="8">
  182. <el-form-item prop="files" label="发票附件">
  183. <fileMain v-model="form.files"></fileMain>
  184. </el-form-item>
  185. </el-col>
  186. </el-row>
  187. <headerTitle title="发票信息"></headerTitle>
  188. <el-row :gutter="12">
  189. <el-col :span="12">
  190. <el-form-item label="购买方名称" prop="companyName">
  191. <el-input
  192. v-model="form.companyName"
  193. placeholder="请输入"
  194. v-if="enterprisePage.length <= 1 || form.type == 1"
  195. />
  196. <el-select
  197. v-if="enterprisePage.length > 1 && form.type == 2"
  198. style="width: 100%"
  199. v-model="form.companyName"
  200. placeholder="请选择"
  201. @change="enterpriseChange"
  202. >
  203. <el-option
  204. v-for="item in enterprisePage"
  205. :key="item.id"
  206. :label="item.name"
  207. :value="item.name"
  208. >
  209. </el-option>
  210. </el-select>
  211. </el-form-item>
  212. <el-form-item
  213. label="统一社会信用代码"
  214. prop="companyUsc"
  215. class="form_item_label"
  216. >
  217. <el-input v-model="form.companyUsc"></el-input>
  218. </el-form-item>
  219. <el-form-item label="联系人" prop="companyContactName">
  220. <el-input v-model="form.companyContactName"></el-input>
  221. </el-form-item>
  222. <el-form-item label="电话" prop="companyTel">
  223. <el-input v-model="form.companyTel"></el-input>
  224. </el-form-item>
  225. <el-form-item label="银行账号" prop="companyBankAccount">
  226. <el-input v-model="form.companyBankAccount"></el-input>
  227. </el-form-item>
  228. <el-form-item label="开户行" prop="companyBankBranchNo">
  229. <el-input v-model="form.companyBankBranchNo"></el-input>
  230. </el-form-item>
  231. <el-form-item label="地址" prop="companyAddress">
  232. <el-input v-model="form.companyAddress"></el-input>
  233. </el-form-item>
  234. </el-col>
  235. <el-col :span="12">
  236. <el-form-item label="销售方名称" prop="receiverName">
  237. <el-input
  238. v-model="form.receiverName"
  239. placeholder="请输入"
  240. v-if="enterprisePage.length <= 1 || form.type == 2"
  241. />
  242. <el-select
  243. v-if="enterprisePage.length > 1 && form.type == 1"
  244. style="width: 100%"
  245. v-model="form.receiverName"
  246. placeholder="请选择"
  247. @change="enterpriseChange"
  248. >
  249. <el-option
  250. v-for="item in enterprisePage"
  251. :key="item.id"
  252. :label="item.name"
  253. :value="item.name"
  254. >
  255. </el-option>
  256. </el-select>
  257. </el-form-item>
  258. <el-form-item
  259. label="统一社会信用代码"
  260. prop="salesCompanyUsc"
  261. class="form_item_label"
  262. >
  263. <el-input v-model="form.salesCompanyUsc"></el-input>
  264. </el-form-item>
  265. <el-form-item label="联系人" prop="receiverContactName">
  266. <el-input v-model="form.receiverContactName"></el-input>
  267. </el-form-item>
  268. <el-form-item label="电话" prop="receiverTel">
  269. <el-input v-model="form.receiverTel"></el-input>
  270. </el-form-item>
  271. <el-form-item label="银行账号" prop="salesCompanyBankAccount">
  272. <el-input v-model="form.salesCompanyBankAccount"></el-input>
  273. </el-form-item>
  274. <el-form-item label="开户行" prop="salesCompanyBankBranchNo">
  275. <el-input v-model="form.salesCompanyBankBranchNo"></el-input>
  276. </el-form-item>
  277. <el-form-item label="地址" prop="receiverAddress">
  278. <el-input v-model="form.receiverAddress"></el-input>
  279. </el-form-item>
  280. <!-- <el-form-item prop="files" label="发票附件">
  281. <fileMain v-model="form.files"></fileMain>
  282. </el-form-item> -->
  283. </el-col>
  284. </el-row>
  285. <div v-if="form.sourceType != 99" class="payinfo" style="margin-top: 20px;">
  286. <headerTitle title="来源清单"></headerTitle>
  287. <!-- <el-form ref="form" :model="tableForm"> -->
  288. <ele-pro-table
  289. ref="table"
  290. :needPage="false"
  291. :columns="columns"
  292. :datasource="form.relatedList"
  293. row-key="id"
  294. class="time-form"
  295. >
  296. <template v-slot:toolbar>
  297. <!-- <span>已开票金额:{{ totalInvoiceAmount }}</span> -->
  298. </template>
  299. <template v-slot:planPaymentAmount="scope">
  300. <el-form-item
  301. style="width: 100%;"
  302. label-width="0"
  303. :prop="'relatedList.' + scope.$index + '.planPaymentAmount'"
  304. :rules="[
  305. {
  306. required: false,
  307. message: '请输入计划金额',
  308. trigger: 'blur'
  309. }
  310. ]"
  311. >
  312. <span v-if="dialogType === 'view'">{{ scope.row.planPaymentAmount }}</span>
  313. <el-input v-else v-model="scope.row.planPaymentAmount" type="number" @input="updatePlanPaymentAmount(scope.row)"></el-input>
  314. </el-form-item>
  315. </template>
  316. <template v-slot:invoiceAmount="scope">
  317. <el-form-item
  318. style="width: 100%;"
  319. label-width="0"
  320. :prop="'relatedList.' + scope.$index + '.invoiceAmount'"
  321. :rules="[
  322. {
  323. required: false,
  324. message: '请输入开票金额',
  325. trigger: 'blur'
  326. },
  327. {
  328. required: false,
  329. validator: (rule, value, callback) => {
  330. if (value === undefined || value === null || value === '') {
  331. callback('请输入开票金额');
  332. } else if (parseFloat(value) <= 0 || parseFloat(value) > parseFloat(scope.row.unInvoiceAmount)) {
  333. callback('开票金额必须大于0且不超过未开票金额');
  334. } else {
  335. callback();
  336. }
  337. },
  338. trigger: 'blur'
  339. }
  340. ]"
  341. >
  342. <span v-if="dialogType === 'view'">{{ scope.row.invoiceAmount }}</span>
  343. <el-input v-else v-model="scope.row.invoiceAmount" type="number" @input="updateInvoiceAmount(scope.row)"></el-input>
  344. </el-form-item>
  345. </template>
  346. </ele-pro-table>
  347. <!-- </el-form> -->
  348. </div>
  349. </el-form>
  350. <div style="margin-top: 20px;">
  351. <headerTitle title="关联物品清单信息"></headerTitle>
  352. <table-info-new
  353. v-if="form.sourceType != 99"
  354. :dialogType="dialogType"
  355. :contactData="contactData"
  356. ref="tableInfoRef"
  357. :invoiceAmount="form.invoiceAmount"
  358. @invoiceAmountChange="invoiceAmountChange"
  359. ></table-info-new>
  360. <table-info
  361. v-else
  362. :dialogType="dialogType"
  363. :contactData="contactData"
  364. ref="tableInfoNoOrderRef"
  365. @setPrice="setPrice"
  366. ></table-info>
  367. </div>
  368. <div slot="footer">
  369. <el-button type="primary" v-click-once @click="handleSave(0)">保存</el-button>
  370. <el-button
  371. type="primary"
  372. v-if="isNeed_process_is_close"
  373. v-click-once
  374. @click="handleSave(1)"
  375. >提交</el-button
  376. >
  377. <el-button v-click-once @click="cancel">返回</el-button>
  378. </div>
  379. <process-submit-dialog
  380. api-fun-name="fininvoiceapplyStatusAPI"
  381. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  382. v-if="processSubmitDialogFlag"
  383. ref="processSubmitDialogRef"
  384. @reload="reload"
  385. ></process-submit-dialog>
  386. <!--对账单-->
  387. <account-statement-dialog
  388. ref="accountStatementDialogRef"
  389. :form="form"
  390. v-if="accountStatementDialogFlag"
  391. :accountstatement-dialog-flag.sync="accountStatementDialogFlag"
  392. @getAccountData="getAccountData"
  393. :contactData="contactData"
  394. :type="form.type"
  395. :multiple="true"
  396. >
  397. </account-statement-dialog>
  398. <!--采购订单-->
  399. <purchasinOrderListDialog
  400. ref="orderListDialogRef"
  401. @changeParent="changeOrder"
  402. ></purchasinOrderListDialog>
  403. <!--销售订单-->
  404. <saleOrderListDialog
  405. :isAll="true"
  406. ref="saleOrderListDialogref"
  407. @changeParent="changeOrder"
  408. ></saleOrderListDialog>
  409. <contractListDialog
  410. ref="selectContractRef"
  411. @changeParent="changeContract"
  412. :type="form.type"
  413. :multiple="true"
  414. ></contractListDialog>
  415. <!-- 应收 -->
  416. <receivableDialog
  417. ref="receivableRef"
  418. @receivableDone="receivableDone"
  419. v-if="receivableDialogFlag"
  420. :receivableDialogFlag.sync="receivableDialogFlag"
  421. :multiple="true"
  422. ></receivableDialog>
  423. <!-- 应付 -->
  424. <paymentListDialog
  425. ref="receivableRef1"
  426. @receivableDone="receivableDone"
  427. v-if="paymentListDialogFlag"
  428. :paymentListDialogFlag.sync="paymentListDialogFlag"
  429. ></paymentListDialog>
  430. <!-- 收款计划列表 -->
  431. <collectionPlanDialog
  432. ref="collectionPlanDialogRef"
  433. v-if="collectionPlanDialogFlag"
  434. :collectionPlanDialogFlag.sync="collectionPlanDialogFlag"
  435. @getPlanData="getPlanData"
  436. :type="form.type"
  437. ></collectionPlanDialog>
  438. </ele-modal>
  439. </template>
  440. <script>
  441. import personSelect from '@/components/CommomSelect/person-select.vue';
  442. import { listOrganizations } from '@/api/system/organization';
  443. import { mapGetters } from 'vuex';
  444. import fileUpload from '@/components/upload/fileUpload.vue';
  445. import tableInfoNew from './tableInfoNew.vue';
  446. import tableInfo from './tableInfo.vue';
  447. import { getTreeByPid } from '@/api/classifyManage';
  448. import {
  449. invoiceApplyInfoV2API,
  450. invoiceApplyCreateAPI,
  451. invoiceApplyUpdateV2API,
  452. initInvoiceByStatementId
  453. } from '@/api/financialManage/invoiceManage';
  454. import { getpurchaseorderDetail } from '@/api/purchasingManage/purchaseOrder';
  455. import { getSaleOrderDetail } from '@/api/saleManage/saleorder';
  456. import { getDetail } from '@/api/contractManage/contractBook';
  457. import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
  458. import accountStatementDialog from './accountstatementDialog.vue';
  459. import contractListDialog from '@/views/saleManage/saleOrder/components/contractListDialog.vue';
  460. import purchasinOrderListDialog from '@/views/purchasingManage/purchaseOrder/invoice/components/orderListDialog.vue'; //采购订单
  461. import saleOrderListDialog from '@/views/saleManage/saleOrder/invoice/components/orderListDialog.vue'; //销售订单
  462. import { enterprisePage } from '@/api/contractManage/contractBook';
  463. import { contactDetail } from '@/api/saleManage/contact';
  464. // import fileMain from '@/components/addDoc/index.vue';
  465. import receivableDialog from '@/views/financialManage/receivableManage/components/receivableDialog.vue'; //应收
  466. import paymentListDialog from '@/views/financialManage/payableManage/components/paymentListDialog.vue'; //应付
  467. import collectionPlanDialog from './collectionPlanDialog.vue' // 收款计划列表
  468. import { updateContractStatus } from '@/api/contractManage/contractBook';
  469. import { getMergeInvoiceInfoAPI } from '@/api/financialManage/payAndCollectPlan';
  470. import { paymentTypeOp } from '@/enum/dict';
  471. import inventoryTable from '@/BIZComponents/inventoryTable.vue';
  472. const defForm = {
  473. accountingSubjectCode: '',
  474. accountingSubjectId: '',
  475. accountingSubjectName: '',
  476. amount: undefined,
  477. contactId: '',
  478. companyAddress: '',
  479. companyBankAccount: '',
  480. companyUsc: '',
  481. expectInvoiceDate: '',
  482. companyBankBranchNo: '',
  483. companyName: '',
  484. receiverAddress: '',
  485. receiverName: '',
  486. receiverTel: '',
  487. receiverContactName: '',
  488. companyTel: '',
  489. companyContactName: '',
  490. detailList: [],
  491. drawerId: '',
  492. drawerName: '',
  493. files: [],
  494. invoiceStatus: '',
  495. link: [],
  496. remark: '',
  497. settlementAccountId: '',
  498. settlementAccountName: '',
  499. invoiceAmount: 0,
  500. getAccountData: '',
  501. sourceId: '',
  502. sourceCode: '',
  503. salesCompanyUsc: '',
  504. salesCompanyBankBranchNo: '',
  505. salesCompanyBankAccount: '',
  506. category: 1,
  507. relatedList: [],
  508. productMap: {}
  509. };
  510. export default {
  511. name: 'add-or-edit-dialog',
  512. components: {
  513. processSubmitDialog,
  514. fileUpload,
  515. personSelect,
  516. tableInfoNew,
  517. accountStatementDialog,
  518. contractListDialog,
  519. purchasinOrderListDialog,
  520. saleOrderListDialog,
  521. // fileMain,
  522. receivableDialog,
  523. paymentListDialog,
  524. collectionPlanDialog,
  525. tableInfo,
  526. inventoryTable
  527. },
  528. props: {
  529. isEditType: {
  530. type: Boolean,
  531. default: true
  532. },
  533. addOrEditDialogFlag: {
  534. type: Boolean,
  535. default: false
  536. },
  537. contactData: {
  538. type: Object,
  539. default: () => {
  540. return {};
  541. }
  542. }
  543. },
  544. provide() {
  545. return {
  546. invoiceType: () => this.form.type
  547. };
  548. },
  549. computed: {
  550. ...mapGetters(['user']),
  551. sourceTypeOp() {
  552. return this.form.type == 1 ? [
  553. {
  554. label: '对账单',
  555. value: 1
  556. },
  557. {
  558. label: '合同',
  559. value: 2
  560. },
  561. {
  562. label: '订单',
  563. value: 3
  564. },
  565. {
  566. label: '已收',
  567. value: 5
  568. },
  569. {
  570. label: '其他无订单无合同',
  571. value: 99
  572. }
  573. ] : [
  574. {
  575. label: '对账单',
  576. value: 1
  577. },
  578. {
  579. label: '合同',
  580. value: 2
  581. },
  582. {
  583. label: '订单',
  584. value: 3
  585. },
  586. {
  587. label: '已付',
  588. value: 4
  589. },
  590. {
  591. label: '其他无订单无合同',
  592. value: 99
  593. }
  594. ]
  595. },
  596. columns() {
  597. return [
  598. {
  599. width: 45,
  600. type: 'index',
  601. columnKey: 'index',
  602. align: 'center',
  603. fixed: 'left'
  604. },
  605. {
  606. minWidth: 150,
  607. prop: 'sourceCode',
  608. label: '来源编码',
  609. align: 'center'
  610. },
  611. // {
  612. // width: 150,
  613. // prop: 'relatedOrderNo',
  614. // label: '来源编号',
  615. // align: 'center'
  616. // },
  617. {
  618. minWidth: 120,
  619. prop: 'sourceType',
  620. label: '来源类型',
  621. align: 'center',
  622. formatter: (row) => {
  623. return this.sourceTypeList.find(item => item.value == row.sourceType)?.label || ''
  624. }
  625. },
  626. // {
  627. // width: 170,
  628. // prop: 'planPaymentAmount',
  629. // label: this.form.type == 1 ? '计划收款金额' : '计划付款金额',
  630. // align: 'center',
  631. // slot: 'planPaymentAmount'
  632. // },
  633. {
  634. minWidth: 150,
  635. prop: 'unInvoiceAmount',
  636. label: '未开票金额',
  637. align: 'center'
  638. },
  639. {
  640. minWidth: 150,
  641. prop: 'invoicedAmount',
  642. label: '已开票金额',
  643. align: 'center'
  644. },
  645. {
  646. minWidth: 160,
  647. prop: 'invoiceAmount',
  648. label: '本次开票金额',
  649. align: 'center',
  650. // slot: 'invoiceAmount',
  651. fixed: 'right'
  652. }
  653. ];
  654. },
  655. },
  656. data() {
  657. return {
  658. cacheKeyUrl: 'eom-202608251804-inventoryTable',
  659. // 1-对账单,2-合同,3-订单,4-应付,5-应收,99-其他无订单无合同
  660. sourceTypeList: [
  661. {
  662. label: '对账单',
  663. value: 1
  664. },
  665. {
  666. label: '合同',
  667. value: 2
  668. },
  669. {
  670. label: '订单',
  671. value: 3
  672. },
  673. {
  674. label: '已付',
  675. value: 4
  676. },
  677. {
  678. label: '已收',
  679. value: 5
  680. },
  681. {
  682. label: '其他无订单无合同',
  683. value: 99
  684. }
  685. ],
  686. businessId: '',
  687. paymentTypeOp,
  688. fullscreen: false,
  689. receivableDialogFlag: false,
  690. dialogType: '',
  691. title: '',
  692. isOtherSourceFlag: false,
  693. processSubmitDialogFlag: false,
  694. collectionPlanDialogFlag: false,
  695. paymentListDialogFlag: false,
  696. accountStatementDialogFlag: false,
  697. enterprisePage: [],
  698. totalInvoiceAmount: 0,
  699. form: {
  700. applyDeptId: '',
  701. applyDeptName: '',
  702. applyUserId: '',
  703. applyUserName: '',
  704. type: '1',
  705. id: '',
  706. ...defForm
  707. },
  708. feeTypeList: [],
  709. accountingSubjectList: [],
  710. deptList: [],
  711. deptTreeList: [],
  712. rules: {
  713. applyDeptId: { required: true, message: '请选择', trigger: 'change' },
  714. applyUserId: { required: true, message: '请选择', trigger: 'change' },
  715. accountingSubjectId: {
  716. required: true,
  717. message: '请选择',
  718. trigger: 'change'
  719. },
  720. feeTypeId: { required: true, message: '请选择', trigger: 'change' },
  721. // amount: { required: true, message: '请输入', trigger: 'blur' },
  722. companyName: { required: true, message: '请输入', trigger: 'blur' },
  723. type: { required: true, message: '请选择', trigger: 'change' },
  724. sourceType: { required: true, message: '请选择', trigger: 'change' }
  725. }
  726. };
  727. },
  728. created() {
  729. this.getClassifyList(24, 'accountingSubjectList');
  730. this.getDeptList();
  731. },
  732. methods: {
  733. //从发票管理新增发票初始化
  734. async init(row = {}, type) {
  735. this.businessId = row.id || '';
  736. this.title = type == 'add' ? '新增' : '修改';
  737. console.log('row', row, type);
  738. this.dialogType = type;
  739. if (type == 'add') {
  740. this.form.applyDeptId = this.user.info.groupId;
  741. this.form.applyDeptName = this.user.info.groupName;
  742. this.form.applyUserId = this.user.info.userId;
  743. this.form.applyUserName = this.user.info.name;
  744. enterprisePage({
  745. pageNum: 1,
  746. size: 200
  747. }).then((res) => {
  748. this.enterprisePage = [];
  749. this.enterprisePage.push(...res.list);
  750. this.enterpriseChange(this.enterprisePage[0]?.name);
  751. });
  752. } else {
  753. await this.getInfo(row.id);
  754. }
  755. this.$nextTick(async () => {
  756. // await this.getUser List(this.form.applyDeptId);
  757. });
  758. },
  759. updateInvoiceAmount(row) {
  760. // row.invoiceAmount = Number(row.invoiceAmount).toFixed(2);
  761. this.form.amount = this.form.relatedList.reduce((pre, cur) => {
  762. return pre + Number(cur.invoiceAmount);
  763. }, 0);
  764. // this.$refs.tableInfoRef.setSinglePrice(row, this.form.relatedList);
  765. },
  766. //来源类型
  767. async handleSelectAccount(val) {
  768. if (val == 6 || val == 7) {
  769. this.collectionPlanDialogFlag = true;
  770. }
  771. if (val == 1) {
  772. this.accountStatementDialogFlag = true;
  773. }
  774. if (val == 2) {
  775. this.$refs.selectContractRef.open({}, 1, 1);
  776. }
  777. if (val == 3 && this.form.type == 2) {
  778. this.$refs.orderListDialogRef.open({}, 1, true);
  779. }
  780. if (val == 3 && this.form.type == 1) {
  781. this.$refs.saleOrderListDialogref.open({}, 1, true);
  782. }
  783. if (val == 5) {
  784. this.receivableDialogFlag = true;
  785. }
  786. if (val == 4) {
  787. this.paymentListDialogFlag = true;
  788. }
  789. },
  790. //合同回调
  791. async changeContract(data) {
  792. console.log('changeOrder~~~', data);
  793. const tempIds = data.map((item) => item.id);
  794. const tempNames = data.map((item) => item.contractNo);
  795. this.getPlanData(tempIds, tempNames);
  796. // const res = await getDetail(data.id);
  797. // this.$set(this.form, 'sourceId', data.id);
  798. // this.$set(this.form, 'sourceCode', data.contractNo);
  799. // this.$set(
  800. // this.form,
  801. // 'amount',
  802. // res.contractVO?.discountTotalPrice - res.contractVO?.invoiceAmount
  803. // );
  804. // this.$set(this.form, 'invoiceAmount', res.contractVO?.invoiceAmount);
  805. // this.getContactDetail(
  806. // this.form.type == 2
  807. // ? res.contractVO?.partbId
  808. // : res.contractVO?.partaId,
  809. // res.contractVO
  810. // );
  811. // res.productList.forEach((item) => {
  812. // item.singlePrice =
  813. // (item.discountSinglePrice &&
  814. // Number(item.discountSinglePrice).toFixed(2)) ||
  815. // item.singlePrice;
  816. // item.totalPrice =
  817. // (item.discountTotalPrice &&
  818. // Number(item.discountTotalPrice).toFixed(2)) ||
  819. // item.totalPrice;
  820. // item.typeName = this.form.type == 1 ? '销售合同' : '采购合同';
  821. // item.type = this.form.type == 1 ? '101' : '102';
  822. // });
  823. // this.$nextTick(() => {
  824. // this.$refs.table.setValue(res.productList);
  825. // });
  826. this.$forceUpdate();
  827. },
  828. async getContactDetail(id, data) {
  829. let contactValue = {};
  830. if (id) {
  831. this.form.contactId = id;
  832. contactValue = await contactDetail(id);
  833. }
  834. const { base, other, bankList, linkList } = contactValue;
  835. if (this.form.type == 1) {
  836. this.form.companyName = base.name;
  837. this.form.companyUsc = base.unifiedSocialCreditCode;
  838. this.form.companyAddress = other?.addressName + other?.address;
  839. this.form.companyTel =
  840. data.partbTel ||
  841. linkList.find((item) => item.ifChief == 1)?.mobilePhone;
  842. this.form.companyBankAccount = bankList[0]?.accountNo;
  843. this.form.companyBankBranchNo = bankList[0]?.bankName;
  844. this.enterpriseChange(data.partbName);
  845. } else {
  846. this.form.receiverName = base.name;
  847. this.form.receiverAddress = base?.addressName + other?.address;
  848. this.form.receiverTel =
  849. data.partaTel ||
  850. linkList.find((item) => item.ifChief == 1)?.mobilePhone;
  851. this.form.salesCompanyUsc = base.unifiedSocialCreditCode;
  852. this.form.salesCompanyBankAccount = bankList[0]?.accountNo;
  853. this.form.salesCompanyBankBranchNo = bankList[0]?.bankName;
  854. this.enterpriseChange(data.partaName);
  855. }
  856. },
  857. setCompanyBankAccount(base) {
  858. console.log('base~~~', base);
  859. if (this.form.type == 1) {
  860. console.log('base~~~111', base.companyName);
  861. this.form.companyName = base.companyName;
  862. this.form.companyUsc = base.companyUsc;
  863. this.form.companyAddress = base.companyAddress;
  864. this.form.companyTel = base.companyTel;
  865. this.form.companyContactName = base.companyContactName;
  866. this.form.companyBankAccount = base.companyBankAccount;
  867. this.form.companyBankBranchNo = base.companyBankBranchNo;
  868. // this.enterpriseChange(base.companyName);
  869. } else {
  870. this.form.receiverName = base.receiverName;
  871. this.form.receiverAddress = base.receiverAddress;
  872. this.form.receiverTel = base.receiverTel;
  873. this.form.receiverContactName = base.receiverContactName;
  874. this.form.salesCompanyUsc = base.salesCompanyUsc;
  875. this.form.salesCompanyBankAccount = base.salesCompanyBankAccount;
  876. this.form.salesCompanyBankBranchNo = base.salesCompanyBankBranchNo;
  877. // this.enterpriseChange(base.receiverName);
  878. }
  879. },
  880. //订单回调
  881. async changeOrder(data) {
  882. console.log('changeOrder~~~', data);
  883. const tempIds = data.map((item) => item.id);
  884. const tempNames = data.map((item) => item.orderNo);
  885. this.getPlanData(tempIds, tempNames);
  886. // this.$set(this.form, 'sourceId', data.id);
  887. // this.$set(this.form, 'sourceCode', data.orderNo);
  888. // let res = {};
  889. // if (this.form.type == 2) {
  890. // res = await getpurchaseorderDetail(data.id);
  891. // } else {
  892. // res = await getSaleOrderDetail(data.id);
  893. // }
  894. // this.$set(this.form, 'amount', res.payAmount - res.invoiceAmount);
  895. // this.$set(this.form, 'invoiceAmount', res.invoiceAmount);
  896. // this.getContactDetail(
  897. // this.form.type == 2 ? res.partbId : res.partaId,
  898. // res
  899. // );
  900. // res.productList.forEach((item) => {
  901. // item.singlePrice =
  902. // (item.discountSinglePrice &&
  903. // Number(item.discountSinglePrice).toFixed(2)) ||
  904. // item.singlePrice;
  905. // item.totalPrice =
  906. // (item.discountTotalPrice &&
  907. // Number(item.discountTotalPrice).toFixed(2)) ||
  908. // item.totalPrice;
  909. // item.typeName = this.form.type == 1 ? '销售订单' : '采购订单';
  910. // item.type = this.form.type == 1 ? '201' : '202';
  911. // });
  912. // this.$nextTick(() => {
  913. // this.$refs.table.setValue(res.productList);
  914. // });
  915. // this.$forceUpdate();
  916. // console.log(res);
  917. },
  918. //应收应付回调
  919. async payableManage(data) {
  920. const { row, form } = data;
  921. console.log(data);
  922. this.$set(this.form, 'sourceId', row.id);
  923. this.$set(this.form, 'sourceCode', row.code);
  924. // this.$set(
  925. // this.form,
  926. // 'amount',
  927. // row.receivedTotalPrice || row.paidTotalPrice
  928. // );
  929. // this.$set(this.form, 'invoiceAmount', row.invoiceAmount);
  930. // this.getContactDetail(form.contactId, {});
  931. },
  932. receivableDone(data) {
  933. // this.$set(this.form, 'type', Number(data.type));
  934. // this.$set(this.form, 'sourceType', data.sourceType);
  935. // this.payableManage(data.data);
  936. const tempIds = data.map((item) => item.detailId);
  937. const tempNames = data.map((item) => item.detailCode);
  938. console.log(data)
  939. this.getPlanData(tempIds, tempNames)
  940. },
  941. // 收/付款计划回调
  942. async getPlanData(tempIds, tempNames) {
  943. console.log('getPlanDatadata~~~', tempIds, tempNames);
  944. // let tempIds = [];
  945. // let tempNames = [];
  946. // if(this.form.sourceType == 4 || this.form.sourceType == 5) {
  947. // tempIds = data.map((item) => item.receiptPlanOrderId);
  948. // tempNames = data.map((item) => item.code);
  949. // } else {
  950. // tempIds = data.map((item) => item.id);
  951. // tempNames = data.map((item) => item.statementNo);
  952. // }
  953. this.form.sourceCode = tempNames.join(',');
  954. const res = await initInvoiceByStatementId(
  955. {
  956. sourceIds: tempIds,
  957. sourceType: this.form.sourceType,
  958. type: this.form.type
  959. }
  960. )
  961. res.relatedList = res.relatedList.map((item) => {
  962. item.invoiceAmount = item.unInvoiceAmount;
  963. return item
  964. })
  965. this.form.sourceId = res.sourceId;
  966. this.form.relatedList = res.relatedList;
  967. this.form.productMap = res.productMap;
  968. const amount = this.form.relatedList.reduce((prev, cur) => prev +
  969. +cur.invoiceAmount, 0) || 0;
  970. this.form.amount = amount;
  971. console.log('form~~~', this.form);
  972. this.setCompanyBankAccount(res)
  973. // this.form.detailList = res.detailList;
  974. this.$nextTick(() => {
  975. this.$refs.tableInfoRef.setValue(this.form);
  976. })
  977. console.log('getPlanData~~~', res);
  978. // console.log('detailList~~~', res.detailList);
  979. },
  980. //对账单回调
  981. async getAccountData(tableInfo) {
  982. // let res = {};
  983. // if (this.form.type == 2) {
  984. // res = await getpurchaseorderDetail(tableInfo?.children?.orderId);
  985. // } else {
  986. // res = await getSaleOrderDetail(tableInfo?.children?.orderId);
  987. // }
  988. // this.getContactDetail(tableInfo.contactId, res);
  989. // this.$nextTick(() => {
  990. // this.$set(this.form, 'sourceId', tableInfo?.children?.id);
  991. // this.$set(this.form, 'sourceCode', tableInfo?.statementNo);
  992. // this.$set(
  993. // this.form,
  994. // 'invoiceAmount',
  995. // tableInfo?.children?.invoiceAmount
  996. // );
  997. // this.$refs.table.getAccountData(tableInfo);
  998. // });
  999. const tempIds = tableInfo.map((item) => item.id);
  1000. const tempNames = tableInfo.map((item) => item.statementNo);
  1001. this.getPlanData(tempIds, tempNames);
  1002. console.log(tableInfo);
  1003. // this.getPlanData(tableInfo)
  1004. },
  1005. //订单、合同列表
  1006. async createInvoice1(data, type, sourceType) {
  1007. console.log('createInvoice1~~~', data);
  1008. this.$set(this.form, 'type', type);
  1009. this.$set(this.form, 'sourceType', sourceType);
  1010. // this.$set(this.form, 'sourceCode', tempIds);
  1011. await this.init({}, 'add');
  1012. let tempIds = []
  1013. let tempNames = []
  1014. if(sourceType == 5) {
  1015. tempIds = data.map((item) => item.detailId);
  1016. tempNames = data.map((item) => item.detailCode);
  1017. } else {
  1018. tempIds = data.map((item) => item.id);
  1019. tempNames = data.map((item) => item.statementNo);
  1020. }
  1021. this.getPlanData(tempIds, tempNames);
  1022. // if (sourceType == 2) {
  1023. // this.changeContract(data);
  1024. // }
  1025. // if (sourceType == 3) {
  1026. // this.changeOrder(data);
  1027. // }
  1028. // if (sourceType == 4 || sourceType == 5) {
  1029. // this.payableManage(data);
  1030. // }
  1031. },
  1032. //对账单列表
  1033. createInvoice(
  1034. row = {},
  1035. invoiceType,
  1036. tableInfo = {},
  1037. isOtherSourceFlag = true,
  1038. dialogType = 'add'
  1039. ) {
  1040. this.dialogType = dialogType;
  1041. this.init(row, dialogType);
  1042. this.form.type = tableInfo.type;
  1043. this.$set(this.form, 'sourceType', invoiceType);
  1044. // this.form.sourceType=invoiceType
  1045. setTimeout(() => {
  1046. this.getAccountData(tableInfo);
  1047. }, 400);
  1048. },
  1049. //获取详情
  1050. async getInfo(id) {
  1051. this.form = await invoiceApplyInfoV2API(id);
  1052. this.$nextTick(() => {
  1053. // 根据来源类型设置数据源:99 用 tableInfo(setValue),非 99 用 tableInfoNew(putValue)
  1054. if (this.form.sourceType == 99) {
  1055. this.$refs.tableInfoNoOrderRef?.setValue(this.form);
  1056. } else {
  1057. this.$refs.tableInfoRef?.putValue(this.form);
  1058. }
  1059. })
  1060. },
  1061. //获取分类管理中的数据
  1062. async getClassifyList(id, listName) {
  1063. let res = await getTreeByPid(id);
  1064. this[listName] = res.data;
  1065. },
  1066. //获取费用类别选中数据
  1067. changeFeeTypeInfo(val) {
  1068. if (!val) {
  1069. this.form.feeTypeName = '';
  1070. this.form.feeTypeCode = '';
  1071. }
  1072. let data = this.$refs.feeTypeTree?.$refs?.tree?.getCurrentNode() || {};
  1073. this.form.feeTypeName = data.name;
  1074. this.form.feeTypeCode = data.code;
  1075. },
  1076. //获取会计科目选中数据
  1077. changeSubjectInfo(val) {
  1078. if (!val) return (this.form.accountingSubjectName = '');
  1079. let data = this.$refs.treeSelect?.$refs?.tree?.getCurrentNode() || {};
  1080. this.form.accountingSubjectName = data.name;
  1081. },
  1082. // 获取部门数据
  1083. getDeptList() {
  1084. listOrganizations().then((list) => {
  1085. this.deptList = list;
  1086. this.deptTreeList = this.$util.toTreeData({
  1087. data: list,
  1088. idField: 'id',
  1089. parentIdField: 'parentId'
  1090. });
  1091. });
  1092. },
  1093. // 选择负责人部门
  1094. changeDeptInfo(id) {
  1095. const info = this.deptList.find((e) => e.id == id) || {};
  1096. this.form.applyDeptName = info.name;
  1097. this.form.applyUserId = '';
  1098. this.form.applyUserName = '';
  1099. this.getUserList(id);
  1100. },
  1101. // 获取人员数据
  1102. getUserList(deptId) {
  1103. if (deptId) {
  1104. this.$refs.directorRef.getList({ deptId });
  1105. }
  1106. },
  1107. //选择人员数据
  1108. changeUserInfo(val, info) {
  1109. this.form.applyUserName = info.name;
  1110. },
  1111. //
  1112. handleSelType(val) {
  1113. console.log('val~~~', val);
  1114. this.form = Object.assign({}, this.form, defForm);
  1115. if (val == 'isType') {
  1116. this.$set(this.form, 'sourceType', '');
  1117. }
  1118. if(val == 'sourceType') {
  1119. this.$nextTick(() => {
  1120. this.$refs.tableInfoNoOrderRef?.setValue(this.form);
  1121. })
  1122. }
  1123. this.form.relatedList = [];
  1124. this.$refs.tableInfoRef?.clearTable();
  1125. this.$refs.tableInfoNoOrderRef?.clearTable();
  1126. this.enterpriseChange(this.enterprisePage[0]?.name);
  1127. },
  1128. setPrice(val) {
  1129. this.form.amount = val;
  1130. },
  1131. //系统公司信息
  1132. enterpriseChange(name) {
  1133. let data = this.enterprisePage.find((item) => item.name == name);
  1134. if (this.form.type == 2) {
  1135. this.form.companyName = data?.name;
  1136. this.form.companyUsc = data?.unifiedSocialCreditCode;
  1137. this.form.companyAddress = data?.address;
  1138. this.form.companyTel = data?.tel;
  1139. this.form.companyContactName = data?.contact;
  1140. } else {
  1141. this.form.receiverName = data?.name;
  1142. this.form.receiverAddress = data?.address;
  1143. this.form.salesCompanyUsc = data?.unifiedSocialCreditCode;
  1144. this.form.receiverTel = data?.tel;
  1145. this.form.receiverContactName = data?.contact;
  1146. }
  1147. this.$forceUpdate();
  1148. },
  1149. invoiceAmountChange(item, sum) {
  1150. console.log('item~~~', item, sum);
  1151. const sameKeyItems = this.form.relatedList.filter((d) => d.sourceCode === item.key)
  1152. console.log('sameKeyItems~~~', sameKeyItems);
  1153. let remainingTotal = sum;
  1154. const lastIndex = sameKeyItems.length - 1;
  1155. // 从上到下分配 sum 给相同订单号的数据,多余数量放在最后一个
  1156. sameKeyItems.forEach((paymentItem, index) => {
  1157. if (remainingTotal <= 0) {
  1158. paymentItem.invoiceAmount = 0;
  1159. } else if (index === lastIndex) {
  1160. // 最后一个分配所有剩余
  1161. paymentItem.invoiceAmount = remainingTotal.toFixed(2);
  1162. } else {
  1163. const unInvoiceAmount = parseFloat(paymentItem.unInvoiceAmount) || 0;
  1164. const allocateAmount = Math.min(remainingTotal, unInvoiceAmount);
  1165. paymentItem.invoiceAmount = allocateAmount.toFixed(2);
  1166. remainingTotal -= allocateAmount;
  1167. }
  1168. });
  1169. this.updateInvoiceAmount();
  1170. console.log('分配完成后的 sameKeyItems:', sameKeyItems);
  1171. },
  1172. updatePlanPaymentAmount(item) {
  1173. console.log('item~~~', item);
  1174. item.unInvoiceAmount = item.planPaymentAmount - item.invoicedAmount;
  1175. // 更新关联物品清单中的 defaultAmountTotalPrice
  1176. const tableInfoRef = this.$refs.tableInfoRef;
  1177. if (tableInfoRef && item.sourceCode) {
  1178. const key = item.sourceCode;
  1179. const newTotal = this.form.relatedList
  1180. .filter((d) => d.sourceCode === key)
  1181. .reduce((sum, d) => sum + (parseFloat(d.unInvoiceAmount) || 0), 0);
  1182. tableInfoRef.tableForm.detailList.forEach((detail) => {
  1183. if (detail.key === key) {
  1184. this.$set(detail, 'defaultAmountTotalPrice', newTotal.toFixed(2));
  1185. }
  1186. });
  1187. }
  1188. },
  1189. getValidate() {
  1190. console.log(this.form);
  1191. let arr = [
  1192. new Promise((resolve, reject) => {
  1193. this.$refs.form.validate((valid) => {
  1194. if (!valid) {
  1195. reject(false);
  1196. } else {
  1197. resolve(true);
  1198. }
  1199. });
  1200. })
  1201. ];
  1202. // this.$refs.tableInfoRef.tableForm.detailList.forEach((item, index) => {
  1203. // arr.push(
  1204. // new Promise((resolve, reject) => {
  1205. // this.$refs.tableInfoRef.$ref['form'+index].validateForm((valid) => {
  1206. // if (!valid) {
  1207. // reject(false);
  1208. // } else {
  1209. // resolve(true);
  1210. // }
  1211. // });
  1212. // })
  1213. // );
  1214. // })
  1215. return Promise.all(arr);
  1216. },
  1217. async handleSave(flag) {
  1218. // this.$refs.form.validate(async (valid) => {
  1219. try {
  1220. const valid = await this.getValidate();
  1221. console.log('valid~~~',valid);
  1222. // if (!valid) return this.$message.warning('有必填项未填,请检查');
  1223. // if (this.form.sourceType != 4 || this.form.sourceType != 5) {
  1224. // tableData = await this.$refs.table.getTableValidate();
  1225. // }
  1226. // // 校验表格数据
  1227. // const tableValid = await new Promise((resolve) => {
  1228. // this.$refs.table.validateForm((valid) => {
  1229. // resolve(valid);
  1230. // });
  1231. // });
  1232. // 根据来源类型选择对应表格:99 用 tableInfo(tableInfoNoOrderRef),非 99 用 tableInfoNew(tableInfoRef)
  1233. const tableRef =
  1234. this.form.sourceType == 99
  1235. ? this.$refs.tableInfoNoOrderRef
  1236. : this.$refs.tableInfoRef;
  1237. const tableValid = await tableRef.getTableValidate();
  1238. console.log('tableValid~~~',tableValid);
  1239. // if (!tableValid) {
  1240. // return;
  1241. // }
  1242. let tableData = tableRef.getTableData();
  1243. // this.form.link = tableData.link;
  1244. this.form.productMap = tableData;
  1245. console.log('commitData~~~',this.form);
  1246. const API =
  1247. this.dialogType == 'add'
  1248. ? invoiceApplyCreateAPI
  1249. : invoiceApplyUpdateV2API;
  1250. const id = await API(this.form);
  1251. if (this.form.sourceType == 2) {
  1252. const idArr = this.form.sourceId?.split(',') || [];
  1253. updateContractStatus(idArr);
  1254. }
  1255. if (flag) {
  1256. await this.handleSub(id);
  1257. return;
  1258. }
  1259. this.$message.success('操作成功');
  1260. this.done();
  1261. this.cancel();
  1262. // });
  1263. } catch (error) {
  1264. // this.$message.warning('有必填项未填,请检查');
  1265. }
  1266. },
  1267. //
  1268. handleSave1(flag) {
  1269. this.$refs.form.validate(async (valid) => {
  1270. if (!valid) return this.$message.warning('有必填项未填,请检查');
  1271. let tableData = {};
  1272. if (this.form.sourceType != 4 || this.form.sourceType != 5) {
  1273. tableData = await this.$refs.table.getTableValidate();
  1274. }
  1275. // 校验表格数据
  1276. const tableValid = await new Promise((resolve) => {
  1277. this.$refs.table.validateForm((valid) => {
  1278. resolve(valid);
  1279. });
  1280. });
  1281. if (!tableValid) {
  1282. return;
  1283. }
  1284. this.form.link = tableData.link;
  1285. this.form.detailList = tableData.detailList;
  1286. const API =
  1287. this.dialogType == 'add'
  1288. ? invoiceApplySaveAPI
  1289. : invoiceApplyUpdateV2API;
  1290. const id = await API(this.form);
  1291. if (this.form.sourceType == 2) {
  1292. const idArr = this.form.sourceId?.split(',') || [];
  1293. updateContractStatus(idArr);
  1294. }
  1295. if (flag) {
  1296. await this.handleSub(id);
  1297. return;
  1298. }
  1299. this.$message.success('操作成功');
  1300. this.done();
  1301. this.cancel();
  1302. });
  1303. },
  1304. //提交-开启流程
  1305. async handleSub(id = '') {
  1306. let data = await invoiceApplyInfoV2API(this.businessId || id);
  1307. this.processSubmitDialogFlag = true;
  1308. let key =
  1309. data.type == 1 ? 'fin_invoice_apply' : 'fin_invoice_receive_apply';
  1310. this.$nextTick(() => {
  1311. let params = {
  1312. businessId: data.id,
  1313. businessKey: key,
  1314. formCreateUserId: data.createUserId,
  1315. variables: {
  1316. type: data.type,
  1317. businessCode: data.orderNo,
  1318. businessName: data.companyName,
  1319. businessType: data.type == 1 ? '开票' : '收票'
  1320. }
  1321. // callBackMethodType : '1',
  1322. // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
  1323. // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
  1324. // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
  1325. // miniHandle : '',
  1326. // miniView : '',
  1327. };
  1328. this.$refs.processSubmitDialogRef.init(params);
  1329. });
  1330. // try {
  1331. // await invoiceApplySubmit({
  1332. // businessId: id || this.form.id,
  1333. // type: this.form.type
  1334. // });
  1335. // } catch (e) {
  1336. // this.$message.error(e.message);
  1337. // }
  1338. },
  1339. reload() {
  1340. this.done();
  1341. this.cancel();
  1342. },
  1343. //刷新主列表数据
  1344. done() {
  1345. this.$emit('reload');
  1346. },
  1347. //关闭弹窗
  1348. cancel() {
  1349. this.$emit('update:addOrEditDialogFlag', false);
  1350. }
  1351. }
  1352. };
  1353. </script>
  1354. <style scoped lang="scss">
  1355. .el-form-box .el-table .el-table__row .el-table__cell {
  1356. padding: 10px 0;
  1357. }
  1358. .payinfo .el-form-item {
  1359. margin-bottom: 0!important;
  1360. }
  1361. </style>