addOrEditDialogNew.vue 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425
  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. @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. isAccountstatement() {
  552. return this.form?.relatedList?.[0].sourceType == 1;
  553. },
  554. sourceTypeOp() {
  555. if(this.$route.path.includes('invoiceManage') && !this.isAccountstatement) {
  556. return [{
  557. label: '其他无订单无合同',
  558. value: 99
  559. }];
  560. }
  561. return this.form.type == 1 ? [
  562. {
  563. label: '对账单',
  564. value: 1
  565. },
  566. {
  567. label: '合同',
  568. value: 2
  569. },
  570. {
  571. label: '订单',
  572. value: 3
  573. },
  574. {
  575. label: '已收',
  576. value: 5
  577. },
  578. {
  579. label: '其他无订单无合同',
  580. value: 99
  581. }
  582. ] : [
  583. {
  584. label: '对账单',
  585. value: 1
  586. },
  587. {
  588. label: '合同',
  589. value: 2
  590. },
  591. {
  592. label: '订单',
  593. value: 3
  594. },
  595. {
  596. label: '已付',
  597. value: 4
  598. },
  599. {
  600. label: '其他无订单无合同',
  601. value: 99
  602. }
  603. ]
  604. },
  605. isDisabledType() {
  606. return this.isAccountstatement;
  607. },
  608. columns() {
  609. return [
  610. {
  611. width: 45,
  612. type: 'index',
  613. columnKey: 'index',
  614. align: 'center',
  615. fixed: 'left'
  616. },
  617. {
  618. minWidth: 150,
  619. prop: 'sourceCode',
  620. label: '来源编码',
  621. align: 'center'
  622. },
  623. // {
  624. // width: 150,
  625. // prop: 'relatedOrderNo',
  626. // label: '来源编号',
  627. // align: 'center'
  628. // },
  629. {
  630. minWidth: 120,
  631. prop: 'sourceType',
  632. label: '来源类型',
  633. align: 'center',
  634. formatter: (row) => {
  635. return this.sourceTypeList.find(item => item.value == row.sourceType)?.label || ''
  636. }
  637. },
  638. // {
  639. // width: 170,
  640. // prop: 'planPaymentAmount',
  641. // label: this.form.type == 1 ? '计划收款金额' : '计划付款金额',
  642. // align: 'center',
  643. // slot: 'planPaymentAmount'
  644. // },
  645. {
  646. minWidth: 150,
  647. prop: 'unInvoiceAmount',
  648. label: '未开票金额',
  649. align: 'center'
  650. },
  651. {
  652. minWidth: 150,
  653. prop: 'invoicedAmount',
  654. label: '已开票金额',
  655. align: 'center'
  656. },
  657. {
  658. minWidth: 160,
  659. prop: 'invoiceAmount',
  660. label: '本次开票金额',
  661. align: 'center',
  662. // slot: 'invoiceAmount',
  663. fixed: 'right'
  664. }
  665. ];
  666. },
  667. },
  668. data() {
  669. return {
  670. cacheKeyUrl: 'eom-202608251804-inventoryTable',
  671. // 1-对账单,2-合同,3-订单,4-应付,5-应收,99-其他无订单无合同
  672. sourceTypeList: [
  673. {
  674. label: '对账单',
  675. value: 1
  676. },
  677. {
  678. label: '合同',
  679. value: 2
  680. },
  681. {
  682. label: '订单',
  683. value: 3
  684. },
  685. {
  686. label: '已付',
  687. value: 4
  688. },
  689. {
  690. label: '已收',
  691. value: 5
  692. },
  693. {
  694. label: '其他无订单无合同',
  695. value: 99
  696. }
  697. ],
  698. businessId: '',
  699. paymentTypeOp,
  700. fullscreen: false,
  701. receivableDialogFlag: false,
  702. dialogType: '',
  703. title: '',
  704. isOtherSourceFlag: false,
  705. processSubmitDialogFlag: false,
  706. collectionPlanDialogFlag: false,
  707. paymentListDialogFlag: false,
  708. accountStatementDialogFlag: false,
  709. enterprisePage: [],
  710. totalInvoiceAmount: 0,
  711. form: {
  712. applyDeptId: '',
  713. applyDeptName: '',
  714. applyUserId: '',
  715. applyUserName: '',
  716. type: 1,
  717. id: '',
  718. ...defForm
  719. },
  720. feeTypeList: [],
  721. accountingSubjectList: [],
  722. deptList: [],
  723. deptTreeList: [],
  724. rules: {
  725. applyDeptId: { required: true, message: '请选择', trigger: 'change' },
  726. applyUserId: { required: true, message: '请选择', trigger: 'change' },
  727. accountingSubjectId: {
  728. required: true,
  729. message: '请选择',
  730. trigger: 'change'
  731. },
  732. feeTypeId: { required: true, message: '请选择', trigger: 'change' },
  733. // amount: { required: true, message: '请输入', trigger: 'blur' },
  734. companyName: { required: true, message: '请输入', trigger: 'blur' },
  735. type: { required: true, message: '请选择', trigger: 'change' },
  736. sourceType: { required: true, message: '请选择', trigger: 'change' }
  737. },
  738. };
  739. },
  740. created() {
  741. this.getClassifyList(24, 'accountingSubjectList');
  742. this.getDeptList();
  743. },
  744. methods: {
  745. //从发票管理新增发票初始化
  746. async init(row = {}, type) {
  747. this.businessId = row.id || '';
  748. this.title = type == 'add' ? '新增' : '修改';
  749. console.log('row', row, type);
  750. this.dialogType = type;
  751. if (type == 'add') {
  752. this.form.applyDeptId = this.user.info.groupId;
  753. this.form.applyDeptName = this.user.info.groupName;
  754. this.form.applyUserId = this.user.info.userId;
  755. this.form.applyUserName = this.user.info.name;
  756. enterprisePage({
  757. pageNum: 1,
  758. size: 200
  759. }).then((res) => {
  760. this.enterprisePage = [];
  761. this.enterprisePage.push(...res.list);
  762. this.enterpriseChange(this.enterprisePage[0]?.name);
  763. });
  764. } else {
  765. await this.getInfo(row.id);
  766. }
  767. this.$nextTick(async () => {
  768. // await this.getUser List(this.form.applyDeptId);
  769. });
  770. },
  771. updateInvoiceAmount(row) {
  772. // row.invoiceAmount = Number(row.invoiceAmount).toFixed(2);
  773. this.form.amount = this.form.relatedList.reduce((pre, cur) => {
  774. return pre + Number(cur.invoiceAmount);
  775. }, 0);
  776. // this.$refs.tableInfoRef.setSinglePrice(row, this.form.relatedList);
  777. },
  778. //来源类型
  779. async handleSelectAccount(val) {
  780. if (val == 6 || val == 7) {
  781. this.collectionPlanDialogFlag = true;
  782. }
  783. if (val == 1) {
  784. this.accountStatementDialogFlag = true;
  785. }
  786. if (val == 2) {
  787. this.$refs.selectContractRef.open({}, 1, 1);
  788. }
  789. if (val == 3 && this.form.type == 2) {
  790. this.$refs.orderListDialogRef.open({}, 1, true);
  791. }
  792. if (val == 3 && this.form.type == 1) {
  793. this.$refs.saleOrderListDialogref.open({}, 1, true);
  794. }
  795. if (val == 5) {
  796. this.receivableDialogFlag = true;
  797. }
  798. if (val == 4) {
  799. this.paymentListDialogFlag = true;
  800. }
  801. },
  802. //合同回调
  803. async changeContract(data) {
  804. console.log('changeOrder~~~', data);
  805. // 子组件在单选/多选路径下 emit 的形态不一致,归一化为数组
  806. const list = Array.isArray(data) ? data : data ? [data] : [];
  807. if (!list.length) return;
  808. const tempIds = list.map((item) => item.id);
  809. const tempNames = list.map((item) => item.contractNo);
  810. this.getPlanData(tempIds, tempNames);
  811. // const res = await getDetail(data.id);
  812. // this.$set(this.form, 'sourceId', data.id);
  813. // this.$set(this.form, 'sourceCode', data.contractNo);
  814. // this.$set(
  815. // this.form,
  816. // 'amount',
  817. // res.contractVO?.discountTotalPrice - res.contractVO?.invoiceAmount
  818. // );
  819. // this.$set(this.form, 'invoiceAmount', res.contractVO?.invoiceAmount);
  820. // this.getContactDetail(
  821. // this.form.type == 2
  822. // ? res.contractVO?.partbId
  823. // : res.contractVO?.partaId,
  824. // res.contractVO
  825. // );
  826. // res.productList.forEach((item) => {
  827. // item.singlePrice =
  828. // (item.discountSinglePrice &&
  829. // Number(item.discountSinglePrice).toFixed(2)) ||
  830. // item.singlePrice;
  831. // item.totalPrice =
  832. // (item.discountTotalPrice &&
  833. // Number(item.discountTotalPrice).toFixed(2)) ||
  834. // item.totalPrice;
  835. // item.typeName = this.form.type == 1 ? '销售合同' : '采购合同';
  836. // item.type = this.form.type == 1 ? '101' : '102';
  837. // });
  838. // this.$nextTick(() => {
  839. // this.$refs.table.setValue(res.productList);
  840. // });
  841. this.$forceUpdate();
  842. },
  843. async getContactDetail(id, data) {
  844. let contactValue = {};
  845. if (id) {
  846. this.form.contactId = id;
  847. contactValue = await contactDetail(id);
  848. }
  849. const { base, other, bankList, linkList } = contactValue;
  850. if (this.form.type == 1) {
  851. this.form.companyName = base.name;
  852. this.form.companyUsc = base.unifiedSocialCreditCode;
  853. this.form.companyAddress = other?.addressName + other?.address;
  854. this.form.companyTel =
  855. data.partbTel ||
  856. linkList.find((item) => item.ifChief == 1)?.mobilePhone;
  857. this.form.companyBankAccount = bankList[0]?.accountNo;
  858. this.form.companyBankBranchNo = bankList[0]?.bankName;
  859. this.enterpriseChange(data.partbName);
  860. } else {
  861. this.form.receiverName = base.name;
  862. this.form.receiverAddress = base?.addressName + other?.address;
  863. this.form.receiverTel =
  864. data.partaTel ||
  865. linkList.find((item) => item.ifChief == 1)?.mobilePhone;
  866. this.form.salesCompanyUsc = base.unifiedSocialCreditCode;
  867. this.form.salesCompanyBankAccount = bankList[0]?.accountNo;
  868. this.form.salesCompanyBankBranchNo = bankList[0]?.bankName;
  869. this.enterpriseChange(data.partaName);
  870. }
  871. },
  872. setCompanyBankAccount(base) {
  873. console.log('base~~~', base);
  874. if (this.form.type == 1) {
  875. console.log('base~~~111', base.companyName);
  876. this.form.companyName = base.companyName;
  877. this.form.companyUsc = base.companyUsc;
  878. this.form.companyAddress = base.companyAddress;
  879. this.form.companyTel = base.companyTel;
  880. this.form.companyContactName = base.companyContactName;
  881. this.form.companyBankAccount = base.companyBankAccount;
  882. this.form.companyBankBranchNo = base.companyBankBranchNo;
  883. // this.enterpriseChange(base.companyName);
  884. } else {
  885. this.form.receiverName = base.receiverName;
  886. this.form.receiverAddress = base.receiverAddress;
  887. this.form.receiverTel = base.receiverTel;
  888. this.form.receiverContactName = base.receiverContactName;
  889. this.form.salesCompanyUsc = base.salesCompanyUsc;
  890. this.form.salesCompanyBankAccount = base.salesCompanyBankAccount;
  891. this.form.salesCompanyBankBranchNo = base.salesCompanyBankBranchNo;
  892. // this.enterpriseChange(base.receiverName);
  893. }
  894. },
  895. //订单回调
  896. async changeOrder(data) {
  897. console.log('changeOrder~~~', data);
  898. // 子组件在单选/多选路径下 emit 的形态不一致,归一化为数组
  899. const list = Array.isArray(data) ? data : data ? [data] : [];
  900. if (!list.length) return;
  901. const tempIds = list.map((item) => item.id);
  902. const tempNames = list.map((item) => item.orderNo);
  903. this.getPlanData(tempIds, tempNames);
  904. // this.$set(this.form, 'sourceId', data.id);
  905. // this.$set(this.form, 'sourceCode', data.orderNo);
  906. // let res = {};
  907. // if (this.form.type == 2) {
  908. // res = await getpurchaseorderDetail(data.id);
  909. // } else {
  910. // res = await getSaleOrderDetail(data.id);
  911. // }
  912. // this.$set(this.form, 'amount', res.payAmount - res.invoiceAmount);
  913. // this.$set(this.form, 'invoiceAmount', res.invoiceAmount);
  914. // this.getContactDetail(
  915. // this.form.type == 2 ? res.partbId : res.partaId,
  916. // res
  917. // );
  918. // res.productList.forEach((item) => {
  919. // item.singlePrice =
  920. // (item.discountSinglePrice &&
  921. // Number(item.discountSinglePrice).toFixed(2)) ||
  922. // item.singlePrice;
  923. // item.totalPrice =
  924. // (item.discountTotalPrice &&
  925. // Number(item.discountTotalPrice).toFixed(2)) ||
  926. // item.totalPrice;
  927. // item.typeName = this.form.type == 1 ? '销售订单' : '采购订单';
  928. // item.type = this.form.type == 1 ? '201' : '202';
  929. // });
  930. // this.$nextTick(() => {
  931. // this.$refs.table.setValue(res.productList);
  932. // });
  933. // this.$forceUpdate();
  934. // console.log(res);
  935. },
  936. //应收应付回调
  937. async payableManage(data) {
  938. const { row, form } = data;
  939. console.log(data);
  940. this.$set(this.form, 'sourceId', row.id);
  941. this.$set(this.form, 'sourceCode', row.code);
  942. // this.$set(
  943. // this.form,
  944. // 'amount',
  945. // row.receivedTotalPrice || row.paidTotalPrice
  946. // );
  947. // this.$set(this.form, 'invoiceAmount', row.invoiceAmount);
  948. // this.getContactDetail(form.contactId, {});
  949. },
  950. receivableDone(data) {
  951. // this.$set(this.form, 'type', Number(data.type));
  952. // this.$set(this.form, 'sourceType', data.sourceType);
  953. // this.payableManage(data.data);
  954. const tempIds = data.map((item) => item.detailId);
  955. const tempNames = data.map((item) => item.detailCode);
  956. console.log(data)
  957. this.getPlanData(tempIds, tempNames)
  958. },
  959. // 收/付款计划回调
  960. async getPlanData(tempIds, tempNames) {
  961. console.log('getPlanDatadata~~~', tempIds, tempNames);
  962. // let tempIds = [];
  963. // let tempNames = [];
  964. // if(this.form.sourceType == 4 || this.form.sourceType == 5) {
  965. // tempIds = data.map((item) => item.receiptPlanOrderId);
  966. // tempNames = data.map((item) => item.code);
  967. // } else {
  968. // tempIds = data.map((item) => item.id);
  969. // tempNames = data.map((item) => item.statementNo);
  970. // }
  971. this.form.sourceCode = tempNames.join(',');
  972. const res = await initInvoiceByStatementId(
  973. {
  974. sourceIds: tempIds,
  975. sourceType: this.form.sourceType,
  976. type: this.form.type
  977. }
  978. )
  979. res.relatedList = res.relatedList.map((item) => {
  980. item.invoiceAmount = item.unInvoiceAmount;
  981. return item
  982. })
  983. this.form.sourceId = res.sourceId;
  984. this.form.relatedList = res.relatedList;
  985. this.form.productMap = res.productMap;
  986. const amount = this.form.relatedList.reduce((prev, cur) => prev +
  987. +cur.invoiceAmount, 0) || 0;
  988. this.form.amount = amount;
  989. console.log('form~~~', this.form);
  990. this.setCompanyBankAccount(res)
  991. // this.form.detailList = res.detailList;
  992. this.$nextTick(() => {
  993. this.$refs.tableInfoRef.setValue(this.form);
  994. })
  995. console.log('getPlanData~~~', res);
  996. // console.log('detailList~~~', res.detailList);
  997. },
  998. //对账单回调
  999. async getAccountData(tableInfo) {
  1000. // let res = {};
  1001. // if (this.form.type == 2) {
  1002. // res = await getpurchaseorderDetail(tableInfo?.children?.orderId);
  1003. // } else {
  1004. // res = await getSaleOrderDetail(tableInfo?.children?.orderId);
  1005. // }
  1006. // this.getContactDetail(tableInfo.contactId, res);
  1007. // this.$nextTick(() => {
  1008. // this.$set(this.form, 'sourceId', tableInfo?.children?.id);
  1009. // this.$set(this.form, 'sourceCode', tableInfo?.statementNo);
  1010. // this.$set(
  1011. // this.form,
  1012. // 'invoiceAmount',
  1013. // tableInfo?.children?.invoiceAmount
  1014. // );
  1015. // this.$refs.table.getAccountData(tableInfo);
  1016. // });
  1017. const tempIds = tableInfo.map((item) => item.id);
  1018. const tempNames = tableInfo.map((item) => item.statementNo);
  1019. this.getPlanData(tempIds, tempNames);
  1020. console.log(tableInfo);
  1021. // this.getPlanData(tableInfo)
  1022. },
  1023. //订单、合同列表
  1024. async createInvoice1(data, type, sourceType) {
  1025. console.log('createInvoice1~~~', data);
  1026. this.$set(this.form, 'type', Number(type));
  1027. this.$set(this.form, 'sourceType', sourceType);
  1028. // this.$set(this.form, 'sourceCode', tempIds);
  1029. await this.init({}, 'add');
  1030. let tempIds = []
  1031. let tempNames = []
  1032. if(sourceType == 5) {
  1033. tempIds = data.map((item) => item.detailId);
  1034. tempNames = data.map((item) => item.detailCode);
  1035. } else {
  1036. tempIds = data.map((item) => item.id);
  1037. tempNames = data.map((item) => item.statementNo);
  1038. }
  1039. this.getPlanData(tempIds, tempNames);
  1040. // if (sourceType == 2) {
  1041. // this.changeContract(data);
  1042. // }
  1043. // if (sourceType == 3) {
  1044. // this.changeOrder(data);
  1045. // }
  1046. // if (sourceType == 4 || sourceType == 5) {
  1047. // this.payableManage(data);
  1048. // }
  1049. },
  1050. //对账单列表
  1051. createInvoice(
  1052. row = {},
  1053. invoiceType,
  1054. tableInfo = {},
  1055. isOtherSourceFlag = true,
  1056. dialogType = 'add'
  1057. ) {
  1058. this.dialogType = dialogType;
  1059. this.init(row, dialogType);
  1060. this.form.type = tableInfo.type;
  1061. this.$set(this.form, 'sourceType', invoiceType);
  1062. // this.form.sourceType=invoiceType
  1063. setTimeout(() => {
  1064. this.getAccountData(tableInfo);
  1065. }, 400);
  1066. },
  1067. //获取详情
  1068. async getInfo(id) {
  1069. this.form = await invoiceApplyInfoV2API(id);
  1070. this.form.type = Number(this.form.type);
  1071. this.$nextTick(() => {
  1072. // 根据来源类型设置数据源:99 用 tableInfo(setValue),非 99 用 tableInfoNew(putValue)
  1073. if (this.form.sourceType == 99) {
  1074. this.$refs.tableInfoNoOrderRef?.setValue(this.form);
  1075. } else {
  1076. this.$refs.tableInfoRef?.putValue(this.form);
  1077. }
  1078. })
  1079. },
  1080. //获取分类管理中的数据
  1081. async getClassifyList(id, listName) {
  1082. let res = await getTreeByPid(id);
  1083. this[listName] = res.data;
  1084. },
  1085. //获取费用类别选中数据
  1086. changeFeeTypeInfo(val) {
  1087. if (!val) {
  1088. this.form.feeTypeName = '';
  1089. this.form.feeTypeCode = '';
  1090. }
  1091. let data = this.$refs.feeTypeTree?.$refs?.tree?.getCurrentNode() || {};
  1092. this.form.feeTypeName = data.name;
  1093. this.form.feeTypeCode = data.code;
  1094. },
  1095. //获取会计科目选中数据
  1096. changeSubjectInfo(val) {
  1097. if (!val) return (this.form.accountingSubjectName = '');
  1098. let data = this.$refs.treeSelect?.$refs?.tree?.getCurrentNode() || {};
  1099. this.form.accountingSubjectName = data.name;
  1100. },
  1101. // 获取部门数据
  1102. getDeptList() {
  1103. listOrganizations().then((list) => {
  1104. this.deptList = list;
  1105. this.deptTreeList = this.$util.toTreeData({
  1106. data: list,
  1107. idField: 'id',
  1108. parentIdField: 'parentId'
  1109. });
  1110. });
  1111. },
  1112. // 选择负责人部门
  1113. changeDeptInfo(id) {
  1114. const info = this.deptList.find((e) => e.id == id) || {};
  1115. this.form.applyDeptName = info.name;
  1116. this.form.applyUserId = '';
  1117. this.form.applyUserName = '';
  1118. this.getUserList(id);
  1119. },
  1120. // 获取人员数据
  1121. getUserList(deptId) {
  1122. if (deptId) {
  1123. this.$refs.directorRef.getList({ deptId });
  1124. }
  1125. },
  1126. //选择人员数据
  1127. changeUserInfo(val, info) {
  1128. this.form.applyUserName = info.name;
  1129. },
  1130. //
  1131. handleSelType(val) {
  1132. console.log('val~~~', val);
  1133. this.form = Object.assign({}, this.form, defForm);
  1134. if (val == 'isType') {
  1135. this.$set(this.form, 'sourceType', '');
  1136. }
  1137. if(val == 'sourceType') {
  1138. this.$nextTick(() => {
  1139. this.$refs.tableInfoNoOrderRef?.setValue(this.form);
  1140. })
  1141. }
  1142. this.form.relatedList = [];
  1143. this.$refs.tableInfoRef?.clearTable();
  1144. this.$refs.tableInfoNoOrderRef?.clearTable();
  1145. this.enterpriseChange(this.enterprisePage[0]?.name);
  1146. },
  1147. setPrice(val) {
  1148. this.form.amount = val;
  1149. },
  1150. //系统公司信息
  1151. enterpriseChange(name) {
  1152. let data = this.enterprisePage.find((item) => item.name == name);
  1153. if (this.form.type == 2) {
  1154. this.form.companyName = data?.name;
  1155. this.form.companyUsc = data?.unifiedSocialCreditCode;
  1156. this.form.companyAddress = data?.address;
  1157. this.form.companyTel = data?.tel;
  1158. this.form.companyContactName = data?.contact;
  1159. } else {
  1160. this.form.receiverName = data?.name;
  1161. this.form.receiverAddress = data?.address;
  1162. this.form.salesCompanyUsc = data?.unifiedSocialCreditCode;
  1163. this.form.receiverTel = data?.tel;
  1164. this.form.receiverContactName = data?.contact;
  1165. }
  1166. this.$forceUpdate();
  1167. },
  1168. invoiceAmountChange(item, sum) {
  1169. console.log('item~~~', item, sum);
  1170. const sameKeyItems = this.form.relatedList.filter((d) => d.sourceCode === item.key);
  1171. console.log('sameKeyItems~~~', sameKeyItems);
  1172. let remainingTotal = sum;
  1173. const lastIndex = sameKeyItems.length - 1;
  1174. // 从上到下分配 sum 给相同订单号的数据,多余数量放在最后一个
  1175. // paymentItem.unInvoiceAmount 直接使用接口返回值,不再被关联物品清单覆盖
  1176. sameKeyItems.forEach((paymentItem, index) => {
  1177. if (remainingTotal <= 0) {
  1178. paymentItem.invoiceAmount = 0;
  1179. } else if (index === lastIndex) {
  1180. // 最后一个分配所有剩余
  1181. paymentItem.invoiceAmount = remainingTotal.toFixed(2);
  1182. } else {
  1183. const unInvoiceAmount = parseFloat(paymentItem.unInvoiceAmount) || 0;
  1184. const allocateAmount = Math.min(remainingTotal, unInvoiceAmount);
  1185. paymentItem.invoiceAmount = allocateAmount.toFixed(2);
  1186. remainingTotal -= allocateAmount;
  1187. }
  1188. });
  1189. this.updateInvoiceAmount();
  1190. console.log('分配完成后的 sameKeyItems:', sameKeyItems);
  1191. },
  1192. updatePlanPaymentAmount(item) {
  1193. console.log('item~~~', item);
  1194. // unInvoiceAmount 不再本地计算,直接使用接口返回的值
  1195. // 更新关联物品清单中的 defaultAmountTotalPrice
  1196. const tableInfoRef = this.$refs.tableInfoRef;
  1197. if (tableInfoRef && item.sourceCode) {
  1198. const key = item.sourceCode;
  1199. const newTotal = this.form.relatedList
  1200. .filter((d) => d.sourceCode === key)
  1201. .reduce((sum, d) => sum + (parseFloat(d.unInvoiceAmount) || 0), 0);
  1202. tableInfoRef.tableForm.detailList.forEach((detail) => {
  1203. if (detail.key === key) {
  1204. this.$set(detail, 'defaultAmountTotalPrice', newTotal.toFixed(2));
  1205. }
  1206. });
  1207. }
  1208. },
  1209. getValidate() {
  1210. console.log(this.form);
  1211. let arr = [
  1212. new Promise((resolve, reject) => {
  1213. this.$refs.form.validate((valid) => {
  1214. if (!valid) {
  1215. reject(false);
  1216. } else {
  1217. resolve(true);
  1218. }
  1219. });
  1220. })
  1221. ];
  1222. // this.$refs.tableInfoRef.tableForm.detailList.forEach((item, index) => {
  1223. // arr.push(
  1224. // new Promise((resolve, reject) => {
  1225. // this.$refs.tableInfoRef.$ref['form'+index].validateForm((valid) => {
  1226. // if (!valid) {
  1227. // reject(false);
  1228. // } else {
  1229. // resolve(true);
  1230. // }
  1231. // });
  1232. // })
  1233. // );
  1234. // })
  1235. return Promise.all(arr);
  1236. },
  1237. async handleSave(flag) {
  1238. // this.$refs.form.validate(async (valid) => {
  1239. try {
  1240. const valid = await this.getValidate();
  1241. console.log('valid~~~',valid);
  1242. // if (!valid) return this.$message.warning('有必填项未填,请检查');
  1243. // if (this.form.sourceType != 4 || this.form.sourceType != 5) {
  1244. // tableData = await this.$refs.table.getTableValidate();
  1245. // }
  1246. // // 校验表格数据
  1247. // const tableValid = await new Promise((resolve) => {
  1248. // this.$refs.table.validateForm((valid) => {
  1249. // resolve(valid);
  1250. // });
  1251. // });
  1252. // 根据来源类型选择对应表格:99 用 tableInfo(tableInfoNoOrderRef),非 99 用 tableInfoNew(tableInfoRef)
  1253. const tableRef =
  1254. this.form.sourceType == 99
  1255. ? this.$refs.tableInfoNoOrderRef
  1256. : this.$refs.tableInfoRef;
  1257. const tableValid = await tableRef.getTableValidate();
  1258. console.log('tableValid~~~',tableValid);
  1259. // if (!tableValid) {
  1260. // return;
  1261. // }
  1262. let tableData = tableRef.getTableData();
  1263. // this.form.link = tableData.link;
  1264. this.form.productMap = tableData;
  1265. console.log('commitData~~~',this.form);
  1266. const API =
  1267. this.dialogType == 'add'
  1268. ? invoiceApplyCreateAPI
  1269. : invoiceApplyUpdateV2API;
  1270. const id = await API(this.form);
  1271. if (this.form.sourceType == 2) {
  1272. const idArr = this.form.sourceId?.split(',') || [];
  1273. updateContractStatus(idArr);
  1274. }
  1275. if (flag) {
  1276. await this.handleSub(id);
  1277. return;
  1278. }
  1279. this.$message.success('操作成功');
  1280. this.done();
  1281. this.cancel();
  1282. // });
  1283. } catch (error) {
  1284. // this.$message.warning('有必填项未填,请检查');
  1285. }
  1286. },
  1287. //
  1288. handleSave1(flag) {
  1289. this.$refs.form.validate(async (valid) => {
  1290. if (!valid) return this.$message.warning('有必填项未填,请检查');
  1291. let tableData = {};
  1292. if (this.form.sourceType != 4 || this.form.sourceType != 5) {
  1293. tableData = await this.$refs.table.getTableValidate();
  1294. }
  1295. // 校验表格数据
  1296. const tableValid = await new Promise((resolve) => {
  1297. this.$refs.table.validateForm((valid) => {
  1298. resolve(valid);
  1299. });
  1300. });
  1301. if (!tableValid) {
  1302. return;
  1303. }
  1304. this.form.link = tableData.link;
  1305. this.form.detailList = tableData.detailList;
  1306. const API =
  1307. this.dialogType == 'add'
  1308. ? invoiceApplySaveAPI
  1309. : invoiceApplyUpdateV2API;
  1310. const id = await API(this.form);
  1311. if (this.form.sourceType == 2) {
  1312. const idArr = this.form.sourceId?.split(',') || [];
  1313. updateContractStatus(idArr);
  1314. }
  1315. if (flag) {
  1316. await this.handleSub(id);
  1317. return;
  1318. }
  1319. this.$message.success('操作成功');
  1320. this.done();
  1321. this.cancel();
  1322. });
  1323. },
  1324. //提交-开启流程
  1325. async handleSub(id = '') {
  1326. let data = await invoiceApplyInfoV2API(this.businessId || id);
  1327. this.processSubmitDialogFlag = true;
  1328. let key =
  1329. data.type == 1 ? 'fin_invoice_apply' : 'fin_invoice_receive_apply';
  1330. this.$nextTick(() => {
  1331. let params = {
  1332. businessId: data.id,
  1333. businessKey: key,
  1334. formCreateUserId: data.createUserId,
  1335. variables: {
  1336. type: data.type,
  1337. businessCode: data.orderNo,
  1338. businessName: data.companyName,
  1339. businessType: data.type == 1 ? '开票' : '收票'
  1340. }
  1341. // callBackMethodType : '1',
  1342. // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
  1343. // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
  1344. // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
  1345. // miniHandle : '',
  1346. // miniView : '',
  1347. };
  1348. this.$refs.processSubmitDialogRef.init(params);
  1349. });
  1350. // try {
  1351. // await invoiceApplySubmit({
  1352. // businessId: id || this.form.id,
  1353. // type: this.form.type
  1354. // });
  1355. // } catch (e) {
  1356. // this.$message.error(e.message);
  1357. // }
  1358. },
  1359. reload() {
  1360. this.done();
  1361. this.cancel();
  1362. },
  1363. //刷新主列表数据
  1364. done() {
  1365. this.$emit('reload');
  1366. },
  1367. //关闭弹窗
  1368. cancel() {
  1369. this.$emit('update:addOrEditDialogFlag', false);
  1370. }
  1371. }
  1372. };
  1373. </script>
  1374. <style scoped lang="scss">
  1375. .el-form-box .el-table .el-table__row .el-table__cell {
  1376. padding: 10px 0;
  1377. }
  1378. .payinfo .el-form-item {
  1379. margin-bottom: 0!important;
  1380. }
  1381. </style>