addOrEditDialogNew.vue 53 KB

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