incomeInvoiceDetailsPage.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917
  1. <template>
  2. <div class="borderless">
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
  6. @click="backToList">返回列表
  7. </el-button>
  8. <div class="upper_right_button">
  9. <el-button type="primary"
  10. size="small"
  11. v-if="viewDisabled"
  12. class="el-button--small-yh"
  13. :loading="buttonLoading"
  14. @click.stop="openEdit()">编辑
  15. </el-button>
  16. <el-button class="el-button--small-yh"
  17. type="primary"
  18. size="small"
  19. :loading="buttonLoading"
  20. :disabled="!form.id || viewDisabled"
  21. @click.stop="makeInvoice"
  22. >{{cancelDisabled?'撤销开票':'确认开票'}}
  23. </el-button>
  24. <el-button class="el-button--small-yh"
  25. type="primary"
  26. size="small"
  27. :loading="buttonLoading"
  28. @click.stop="saveSettlement"
  29. >保存数据
  30. </el-button>
  31. </div>
  32. </div>
  33. </div>
  34. <el-tabs v-model="activeName" @tab-click="handleClick" style="padding: 3% 0 0 1%;background: #FFFFFF">
  35. <el-tab-pane label="费用明细" name="first" :key="'first'">
  36. </el-tab-pane>
  37. <el-tab-pane label="开票信息" name="second" :key="'second'">
  38. </el-tab-pane>
  39. </el-tabs>
  40. <div class="customer-main" style="margin-top: 1px" v-show="show">
  41. <containerTitle title="基础信息"></containerTitle>
  42. <basic-container>
  43. <avue-form class="trading-form" ref="form" v-model="form" :option="option">
  44. <template slot="corpId">
  45. <crop-select
  46. v-model="form.corpId"
  47. corpType="KG"
  48. :disabled="cancelDisabled || viewDisabled"
  49. @getCorpData="returnBack"
  50. style="width: 100%"
  51. ></crop-select>
  52. </template>
  53. <template slot="accountNo">
  54. <el-select v-model="form.accountNo"
  55. placeholder="请选择"
  56. @change="accountNoChange"
  57. :disabled="cancelDisabled || viewDisabled"
  58. clearable
  59. filterable>
  60. <el-option v-for="(item,index) in form.bankList"
  61. :key="index"
  62. :label="item.accountNo"
  63. :value="item.accountNo"
  64. >
  65. </el-option>
  66. </el-select>
  67. </template>
  68. </avue-form>
  69. </basic-container>
  70. <containerTitle title="明细列表"></containerTitle>
  71. <basic-container>
  72. <avue-crud :option="itemsOption"
  73. :data="dataList"
  74. ref="crud"
  75. v-model="itemsForm"
  76. :cell-style="cellStyle"
  77. @search-reset="searchReset"
  78. @row-update="rowUpdate"
  79. @selection-change="selectionChange"
  80. >
  81. <template slot="menuLeft">
  82. <el-button type="primary"
  83. size="small"
  84. :loading="buttonLoading"
  85. icon="el-icon-shopping-cart-2"
  86. :disabled="cancelDisabled || viewDisabled"
  87. @click="selectPurchase">选择采购合同
  88. </el-button>
  89. <el-button type="warning"
  90. size="small"
  91. :loading="buttonLoading"
  92. :disabled="selectionList.length === 0 || cancelDisabled || viewDisabled"
  93. @click="generate">生成开票
  94. </el-button>
  95. </template>
  96. <template slot-scope="scope" slot="menu">
  97. <el-button
  98. type="text"
  99. size="small"
  100. icon="el-icon-edit"
  101. :disabled="cancelDisabled || viewDisabled"
  102. @click.stop="rowCell(scope.row,scope.index)"
  103. > {{ scope.row.$cellEdit ? '修改完成' : '修改' }}
  104. </el-button>
  105. <el-button
  106. type="text"
  107. size="small"
  108. icon="el-icon-delete"
  109. :disabled="cancelDisabled || viewDisabled"
  110. @click.stop="rowDel(scope.row,scope.index)"
  111. >删除
  112. </el-button>
  113. </template>
  114. <template slot-scope="{ row }" slot="currency">
  115. <el-select v-if="row.$cellEdit" v-model="row.currency" size="small" placeholder="请选择 币别" clearable filterable>
  116. <el-option v-for="(item,index) in currencyDic" :key="index" :label="item.dictValue" :value="item.dictValue"></el-option>
  117. </el-select>
  118. <span v-else>{{ row.currency }}</span>
  119. </template>
  120. <template slot="thisAmount" slot-scope="{ row }">
  121. <span v-if="row.$cellEdit" class="required_fields">*</span>
  122. <el-input
  123. v-if="row.$cellEdit"
  124. v-model="row.thisAmount"
  125. style="width: 90%"
  126. placeholder="请输入"
  127. @change="amountChange"
  128. size="small"
  129. @input="thisAmountVerify(row)"
  130. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  131. ></el-input>
  132. <span v-else>{{ row.thisAmount }}</span>
  133. </template>
  134. </avue-crud>
  135. </basic-container>
  136. </div>
  137. <div class="customer-main" style="margin-top: 1px" v-show="!show">
  138. <containerTitle title="开票信息"></containerTitle>
  139. <basic-container>
  140. <avue-form class="trading-form" ref="form" v-model="form" :option="options">
  141. <template slot="remark">
  142. <el-input type="textarea"
  143. v-model="form.remark"
  144. size="small"
  145. :disabled="viewDisabled"
  146. rows="2"
  147. autocomplete="off"
  148. placeholder="">
  149. </el-input>
  150. </template>
  151. </avue-form>
  152. </basic-container>
  153. <containerTitle title="明细列表"></containerTitle>
  154. <basic-container>
  155. <avue-crud :option="itemsOptions"
  156. :data="dataLists"
  157. ref="cruds"
  158. v-model="itemsForms"
  159. :cell-style="cellStyle"
  160. @search-reset="searchReset"
  161. @row-update="rowUpdate"
  162. @selection-change="selectionChange"
  163. >
  164. <template slot="menuLeft">
  165. <el-button type="primary"
  166. size="small"
  167. :loading="buttonLoading"
  168. :disabled="viewDisabled"
  169. icon="el-icon-plus"
  170. @click="cellAdd">录入
  171. </el-button>
  172. </template>
  173. <template slot-scope="scope" slot="menu">
  174. <el-button
  175. type="text"
  176. size="small"
  177. icon="el-icon-edit"
  178. :disabled="viewDisabled"
  179. @click.stop="rowCells(scope.row,scope.index)"
  180. > {{ scope.row.$cellEdit ? '修改完成' : '修改' }}
  181. </el-button>
  182. <el-button
  183. type="text"
  184. size="small"
  185. icon="el-icon-delete"
  186. :disabled="viewDisabled"
  187. @click.stop="rowDels(scope.row,scope.index)"
  188. >删除
  189. </el-button>
  190. </template>
  191. <template slot-scope="{row,index}" slot="serverName">
  192. <span v-if="row.$cellEdit" class="required_fields">*</span>
  193. <breakdown-select
  194. v-if="row.$cellEdit"
  195. v-model="row.serverName"
  196. style="width: 90%"
  197. :configuration="configuration">
  198. </breakdown-select>
  199. <span v-else>{{ row.serverName }}</span>
  200. </template>
  201. <template slot="typeno" slot-scope="{ row, index }">
  202. <span v-if="row.$cellEdit" class="required_fields">*</span>
  203. <el-select
  204. v-if="row.$cellEdit"
  205. v-model="row.typeno"
  206. size="small"
  207. style="width:90% !important;"
  208. filterable
  209. allow-create
  210. default-first-option
  211. clearable
  212. >
  213. <el-option
  214. v-for="(item,index) in typenoList"
  215. :key="index"
  216. :label="item"
  217. :value="item"
  218. >
  219. </el-option>
  220. </el-select>
  221. <span v-else>{{ row.itemType }}</span>
  222. </template>
  223. <template slot-scope="{row,index}" slot="unit">
  224. <span v-if="row.$cellEdit" class="required_fields">*</span>
  225. <el-select v-if="row.$cellEdit" v-model="row.unit" size="small" placeholder="请选择 单位" style="width: 90%" clearable filterable>
  226. <el-option v-for="(item,index) in unitDic" :key="index" :label="item.dictValue" :value="item.dictValue"></el-option>
  227. </el-select>
  228. <span v-else>{{ row.unit }}</span>
  229. </template>
  230. <template slot="price" slot-scope="{row,index}">
  231. <span v-if="row.$cellEdit" class="required_fields">*</span>
  232. <el-input
  233. v-if="row.$cellEdit"
  234. v-model="row.price"
  235. style="width: 90%"
  236. placeholder="请输入 单价"
  237. size="small"
  238. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  239. ></el-input>
  240. <span v-else>{{ row.price }}</span>
  241. </template>
  242. <template slot="amount" slot-scope="{row,index}">
  243. <span v-if="row.$cellEdit" class="required_fields">*</span>
  244. <el-input
  245. v-if="row.$cellEdit"
  246. v-model="row.amount"
  247. style="width: 90%"
  248. placeholder="请输入 金额"
  249. size="small"
  250. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  251. ></el-input>
  252. <span v-else>{{ row.amount }}</span>
  253. </template>
  254. <template slot="amountRate" slot-scope="{row,index}">
  255. <span v-if="row.$cellEdit" class="required_fields">*</span>
  256. <el-input
  257. v-if="row.$cellEdit"
  258. v-model="row.amountRate"
  259. style="width: 90%"
  260. size="small"
  261. placeholder="请输入 税率"
  262. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d\d\d\d\d).*$/, "$1.$2")'
  263. autocomplete="off"
  264. >
  265. <i slot="suffix" style="margin-top:3px;margin-right: 10px;display:inline-block">%</i>
  266. </el-input>
  267. <span v-else>{{ row.amountRate }}</span>
  268. </template>
  269. </avue-crud>
  270. </basic-container>
  271. </div>
  272. <el-dialog
  273. title="导入采购"
  274. append-to-body
  275. class="el-dialogDeep"
  276. :visible.sync="billDetailDialog"
  277. width="60%"
  278. :close-on-click-modal="false"
  279. :destroy-on-close="true"
  280. :close-on-press-escape="false"
  281. top="10vh"
  282. v-dialog-drag>
  283. <bill-detail
  284. :params="params"
  285. :billType="billType"
  286. :flag="2"
  287. @closeFun="closeBillDetail"
  288. @importProMent="importProMent"
  289. >
  290. </bill-detail>
  291. </el-dialog>
  292. </div>
  293. </template>
  294. <script>
  295. import option from "./configuration/detailsPage.json";
  296. import options from "./configuration/invoicepage.json";
  297. import { getDetail,editFinance } from "@/api/financialManagement/financialManagement"
  298. import { saveOrEdit,getDetails } from "@/api/financialManagement/paymentRequest";
  299. import { createInvoiceItem,putFund,cancelFund } from "@/api/financialManagement/invoice";
  300. import { contrastObj,contrastList } from "@/util/contrastData";
  301. import billDetail from "@/components/bill/billDetailList";
  302. import { getlistBankBy } from "@/api/financialManagement/paymentRequest";
  303. import _ from "lodash";
  304. export default {
  305. name: "outputInvoiceDetailsPage",
  306. props: {
  307. detailData: {
  308. type: Object
  309. }
  310. },
  311. data() {
  312. return {
  313. show:true,
  314. cancelDisabled:false,
  315. viewDisabled:false,
  316. form: {},
  317. option: {
  318. menuBtn: false,
  319. labelWidth: 100,
  320. column: [
  321. {
  322. label: '系统号',
  323. prop: 'sysNo',
  324. span: 8,
  325. disabled: true
  326. },{
  327. label: '合同号',
  328. prop: 'srcOrderno',
  329. span: 8,
  330. rules: [
  331. {
  332. required: false,
  333. message: ' ',
  334. trigger: 'blur'
  335. }
  336. ]
  337. }, {
  338. label: '往来单位',
  339. prop: 'corpId',
  340. sort:true,
  341. span: 8,
  342. rules: [
  343. {
  344. required: false,
  345. message: ' ',
  346. trigger: 'blur'
  347. }
  348. ]
  349. },
  350. {
  351. label: '银行账号',
  352. prop: 'accountNo',
  353. span: 8,
  354. rules: [
  355. {
  356. required: false,
  357. message: ' ',
  358. trigger: 'blur'
  359. }
  360. ]
  361. },
  362. {
  363. label: '开户银行',
  364. prop: 'accountBank',
  365. span: 8,
  366. rules: [
  367. {
  368. required: false,
  369. message: ' ',
  370. trigger: 'blur'
  371. }
  372. ]
  373. }, {
  374. label: '银行户头',
  375. prop: 'accountName',
  376. span: 8,
  377. rules: [
  378. {
  379. required: false,
  380. message: ' ',
  381. trigger: 'blur'
  382. }
  383. ]
  384. },
  385. {
  386. label: '开票金额',
  387. prop: 'amount',
  388. span: 8,
  389. rules: [
  390. {
  391. pattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
  392. message: ' ',
  393. trigger: 'blur'
  394. },
  395. {
  396. required: false,
  397. message: ' ',
  398. trigger: 'blur'
  399. }
  400. ]
  401. },
  402. {
  403. label: '付款日期',
  404. prop: 'settlementDate',
  405. format:"yyyy-MM-dd",
  406. valueFormat:"yyyy-MM-dd 00:00:00",
  407. span: 8,
  408. type:"date",
  409. rules: [
  410. {
  411. required: false,
  412. message: ' ',
  413. trigger: 'blur'
  414. }
  415. ]
  416. }
  417. ],
  418. },
  419. itemsOption: option,
  420. itemsForm:{},
  421. dataList: [],
  422. options:{
  423. menuBtn: false,
  424. labelWidth: 100,
  425. column: [
  426. {
  427. label: '开票抬头',
  428. prop: 'invoiceTitle',
  429. sort:true,
  430. span: 8,
  431. rules: [
  432. {
  433. required: false,
  434. message: ' ',
  435. trigger: 'blur'
  436. }
  437. ]
  438. },
  439. {
  440. label: '开票日期',
  441. prop: 'invoiceTime',
  442. format: "yyyy-MM-dd",
  443. valueFormat: "yyyy-MM-dd HH:mm:ss",
  444. type:"date",
  445. span: 8,
  446. rules: [
  447. {
  448. required: false,
  449. message: ' ',
  450. trigger: 'blur'
  451. }
  452. ]
  453. },
  454. {
  455. label: '发票号',
  456. prop: 'invoiceNo',
  457. span: 8,
  458. },
  459. {
  460. label: '纳税人识别号',
  461. prop: 'taxpayerIdentificationNo',
  462. span: 8,
  463. rules: [
  464. {
  465. required: false,
  466. message: ' ',
  467. trigger: 'blur'
  468. }
  469. ]
  470. },
  471. {
  472. label: '开户行账号',
  473. prop: 'bankNo',
  474. span: 8,
  475. rules: [
  476. {
  477. required: false,
  478. message: ' ',
  479. trigger: 'blur'
  480. }
  481. ]
  482. },
  483. {
  484. label: '地址电话',
  485. prop: 'addressPhone',
  486. span: 8,
  487. rules: [
  488. {
  489. required: false,
  490. message: ' ',
  491. trigger: 'blur'
  492. }
  493. ]
  494. },
  495. {
  496. label: '备注',
  497. prop: 'remark',
  498. span:24,
  499. minRows: 2,
  500. rules: [
  501. {
  502. required: false,
  503. message: ' ',
  504. trigger: 'blur'
  505. }
  506. ]
  507. },
  508. ],
  509. },
  510. itemsOptions: options,
  511. dataLists:[],
  512. itemsForms:{},
  513. typenoList:['*'],
  514. configuration: {
  515. multipleChoices: false,
  516. multiple: false,
  517. disabled: true,
  518. searchShow: true,
  519. collapseTags: false,
  520. placeholder: '请点击右边按钮选择',
  521. dicData: []
  522. },
  523. billDetailDialog:false,
  524. buttonLoading:false,
  525. billType:"申请",
  526. params:{},
  527. id:"",
  528. unitDic:[],
  529. currencyDic:[],
  530. selectionList:[],
  531. activeName:'first',
  532. //顶部from数据
  533. oldForm:{},
  534. oldDataList:[],
  535. oldDataLists:[],
  536. }
  537. },
  538. components:{
  539. billDetail
  540. },
  541. created() {
  542. //币别
  543. this.getWorkDicts("currency").then(res =>{
  544. this.currencyDic = res.data.data
  545. })
  546. //单位
  547. this.getWorkDicts("unit").then(res => {
  548. this.unitDic = res.data.data
  549. });
  550. if (this.detailData.id) {
  551. this.buttonLoading = true
  552. this.id = this.detailData.id;//字符串转数字 超长用BigInt
  553. getDetail(this.id).then(res => {
  554. this.afterEcho(res.data.data)
  555. }).finally(()=>{
  556. this.buttonLoading = false
  557. })
  558. }
  559. if(this.detailData.view){
  560. this.viewDisabled = true
  561. this.option.disabled = true
  562. this.options.disabled = true
  563. }
  564. if(this.detailData.params){
  565. this.buttonLoading = true
  566. getDetails(this.detailData.params).then(res =>{
  567. delete res.data.data.id;
  568. delete res.data.data.sysNo;
  569. delete res.data.data.billType;
  570. res.data.data.itemsList.map((items)=>{
  571. delete items.id ;
  572. items.thisAmount = items.amount
  573. })
  574. this.afterEcho(res.data.data)
  575. }).finally(()=>{
  576. this.buttonLoading = false
  577. })
  578. }
  579. },
  580. mounted() {
  581. },
  582. methods: {
  583. handleClick(tab){
  584. if(tab.name === "first"){
  585. this.show = true
  586. }else{
  587. this.show = false
  588. }
  589. },
  590. //选择客户
  591. returnBack(corpValue){
  592. this.corpId = corpValue.id
  593. getlistBankBy(corpValue.id).then(res =>{
  594. this.$set(this.form,"bankList",res.data)
  595. })
  596. },
  597. //选择卡号
  598. accountNoChange(value){
  599. this.form.bankList.forEach(item =>{
  600. if(item.accountNo == value){
  601. this.$set(this.form,"accountBank",item.accountBank)
  602. this.$set(this.form,"accountName",item.accountName)
  603. }
  604. })
  605. },
  606. amountChange(){
  607. let thisAmountList = this.dataList.map(item => {
  608. if(item.thisAmount){
  609. return parseFloat(item.thisAmount);
  610. }else return 0
  611. });
  612. this.$set(this.form,"amount",thisAmountList.reduce((n,m) => n + m)) //数组内和
  613. },
  614. //本次金额验证
  615. thisAmountVerify(row){
  616. if(parseFloat(row.thisAmount) > parseFloat(row.amount)){
  617. this.$message.warning('本次开票金额不得大于金额!')
  618. this.$set(row,'thisAmount','')
  619. }
  620. },
  621. //生成开票
  622. generate(){
  623. let sum = 0
  624. this.selectionList.forEach(item =>{
  625. sum =_.add(sum, Number(item.thisAmount))
  626. })
  627. let params = {
  628. price:sum,
  629. amount:sum
  630. }
  631. this.$refs.cruds.rowCellAdd(params);
  632. this.activeName = 'second'
  633. this.show = false
  634. },
  635. selectPurchase(){
  636. if(!this.form.corpId){
  637. this.$message.warning("请先选择客户!")
  638. return
  639. }
  640. this.params = {
  641. corpId: this.form.corpId
  642. }
  643. this.billDetailDialog = true;
  644. },
  645. closeBillDetail(){
  646. this.billDetailDialog = false;
  647. },
  648. importProMent(list){
  649. list.forEach((item,index) =>{
  650. item.accId = item.id;
  651. item.srcOrderno = item.accSysNo
  652. item.billNo = item.srcBillNo
  653. item.thisAmount = item.amount
  654. item.$cellEdit = true
  655. delete item.id;
  656. this.$refs.crud.rowCellAdd(item);
  657. })
  658. this.$set(this.form,'srcOrderno',Array.from(new Set(this.dataList.map(item =>{ if(item.srcOrderno){return item.srcOrderno}}))).join(','))
  659. this.billDetailDialog = false;
  660. },
  661. rowUpdate(row, index, done) {
  662. done(row);
  663. },
  664. cellAdd(){
  665. this.$refs.cruds.rowCellAdd({typeno : '*'});
  666. },
  667. rowCell(row,index){
  668. this.$refs.crud.rowCell(row, index)
  669. },
  670. rowDel(row,index){
  671. this.$confirm("确定将选择数据删除?", {
  672. confirmButtonText: "确定",
  673. cancelButtonText: "取消",
  674. type: "warning"
  675. }).then(() => {
  676. this.dataList.splice(index, 1);
  677. });
  678. },
  679. rowCells(row,index){
  680. this.$refs.cruds.rowCell(row, index)
  681. },
  682. rowDels(row,index){
  683. this.$confirm("确定将选择数据删除?", {
  684. confirmButtonText: "确定",
  685. cancelButtonText: "取消",
  686. type: "warning"
  687. }).then(() => {
  688. this.dataLists.splice(index, 1);
  689. });
  690. },
  691. searchReset() {
  692. console.log('1')
  693. },
  694. selectionChange(row) {
  695. this.selectionList = row
  696. },
  697. makeInvoice(){
  698. if(this.verificationData()){
  699. this.$confirm(this.cancelDisabled?"是否撤销开票":"是否确认开票", "提示", {
  700. confirmButtonText: "确认",
  701. cancelButtonText: "取消",
  702. type: "warning",
  703. }).then(()=>{
  704. for (let i = 0; i < this.dataList.length; i++) {
  705. if (this.dataList[i].thisAmount == (null || "")) {
  706. return this.$message.error(`第输入费用明细${i + 1}行的本次金额`);
  707. }
  708. }
  709. for (let i = 0; i < this.dataLists.length; i++) {
  710. if (this.dataLists[i].serverName == (null || "") ||
  711. this.dataLists[i].typeno == (null || "") ||
  712. this.dataLists[i].unit == (null || "") ||
  713. this.dataLists[i].price == (null || "") ||
  714. this.dataLists[i].amount == (null || "") ||
  715. this.dataLists[i].amountRate == (null || "") ||
  716. this.dataLists[i].amountTax == (null || "")) {
  717. return this.$message.error(`第输入开票明细${i + 1}行的必填项`);
  718. }
  719. }
  720. this.buttonLoading = true
  721. this.form.billNo = this.dataList.map(item =>{return item.billNo}).join(",")
  722. const params = {
  723. ...this.form,
  724. billType:"付费",
  725. itemsList:this.dataList,
  726. invoiceItemList:this.dataLists,
  727. settlementType:2
  728. }
  729. if(!this.cancelDisabled){
  730. //确认开票
  731. putFund(params).then(res=>{
  732. if(res.data.success){
  733. this.$message.success("操作成功!")
  734. this.afterEcho(res.data.data)
  735. }
  736. }).finally(()=>{
  737. this.buttonLoading = false
  738. })
  739. }else{ //撤销开票
  740. cancelFund(params).then(res=>{
  741. if(res.data.success){
  742. this.$message.success("操作成功!")
  743. this.afterEcho(res.data.data)
  744. }
  745. }).finally(()=>{
  746. this.buttonLoading = false
  747. })
  748. }
  749. })
  750. }
  751. },
  752. saveSettlement(){
  753. this.$refs["form"].validate((valid,done) => {
  754. if(valid){
  755. for (let i = 0; i < this.dataList.length; i++) {
  756. if (this.dataList[i].thisAmount == (null || "")) {
  757. return this.$message.error(`第输入费用明细${i + 1}行的本次金额`);
  758. }
  759. }
  760. for (let i = 0; i < this.dataLists.length; i++) {
  761. if (this.dataLists[i].serverName == (null || "") ||
  762. this.dataLists[i].typeno == (null || "") ||
  763. this.dataLists[i].unit == (null || "") ||
  764. this.dataLists[i].price == (null || "") ||
  765. this.dataLists[i].amount == (null || "") ||
  766. this.dataLists[i].amountRate == (null || "") ||
  767. this.dataLists[i].amountTax == (null || "")) {
  768. return this.$message.error(`第输入开票明细${i + 1}行的必填项`);
  769. }
  770. }
  771. this.buttonLoading = true
  772. this.form.billNo = this.dataList.map(item =>{return item.billNo}).join(",")
  773. const params = {
  774. ...this.form,
  775. billType:"付费",
  776. itemsList:this.dataList,
  777. invoiceItemList:this.dataLists,
  778. settlementType:2
  779. }
  780. saveOrEdit(params).then(res=>{
  781. this.$message.success("操作成功!")
  782. this.afterEcho(res.data.data)
  783. }).finally(()=>{
  784. done();
  785. this.buttonLoading = false
  786. })
  787. }
  788. })
  789. },
  790. afterEcho(data){
  791. this.form = data;
  792. this.oldForm = Object.assign({},data);
  793. this.cancelDisabled = data.foundStatus === "核销完成"?true:false;
  794. this.option.column.forEach(item=>{
  795. this.$set(item,"disabled",this.cancelDisabled)
  796. })
  797. if(data.itemsList){
  798. this.dataList = data.itemsList
  799. this.oldDataList = this.deepClone(data.itemsList)
  800. }
  801. if(data.invoiceItemList){
  802. this.dataLists = data.invoiceItemList
  803. this.oldDataLists = this.deepClone(data.invoiceItemList)
  804. }
  805. },
  806. verificationData(){
  807. if(contrastObj(this.form,this.oldForm)
  808. || contrastList(this.dataList,this.oldDataList)
  809. || contrastList(this.dataLists,this.oldDataLists)
  810. ){
  811. this.$confirm("数据发生变化,请先提交保存!", "提示", {
  812. confirmButtonText: "保存",
  813. cancelButtonText: "取消",
  814. type: "warning",
  815. }).then(() => {
  816. this.saveSettlement()
  817. }).catch(()=>{
  818. return false
  819. })
  820. }else{
  821. return true
  822. }
  823. },
  824. async openEdit() {
  825. //标签页保存key
  826. this.inDetailsKey(this.$route.name,this.detailData.lockData);
  827. //单据是否锁定
  828. if(!await this.checkLocks(this.detailData.lockData)){
  829. this.onLock(this.detailData.lockData); //上锁
  830. this.viewDisabled = false
  831. this.option = this.$options.data().option;
  832. this.options = this.$options.data().options;
  833. }else{
  834. this.$message.warning('此单据已被锁定,请稍后再进行操作!')
  835. }
  836. },
  837. backToList() {
  838. //编辑按钮存在 或者为新单 新单是没有lockData的
  839. if(this.viewDisabled || !this.detailData.lockData){
  840. this.$emit("goBack");
  841. return
  842. }
  843. if(contrastObj(this.form,this.oldForm) || contrastList(this.dataList,this.oldDataList)
  844. ){
  845. this.$confirm("是否保存当前页面?", "提示", {
  846. confirmButtonText: "保存",
  847. cancelButtonText: "取消",
  848. type: "warning",
  849. }).then(() => {
  850. this.saveSettlement()
  851. }).catch(()=>{
  852. this.$emit("goBack");
  853. }).finally(()=>{
  854. if(this.form.id){
  855. this.unLock(this.detailData.lockData);
  856. this.leaveDetailsKey(this.$route.name);
  857. }
  858. })
  859. }else{
  860. this.$emit("goBack");
  861. if(this.form.id){
  862. this.unLock(this.detailData.lockData);
  863. this.leaveDetailsKey(this.$route.name);
  864. }
  865. }
  866. },
  867. cellStyle() {
  868. return "padding:0;height:40px;";
  869. },
  870. }
  871. }
  872. </script>
  873. <style lang="scss" scoped>
  874. ::v-deep .el-form-item {
  875. margin-bottom: 0;
  876. }
  877. .trading-form ::v-deep .el-form-item {
  878. margin-bottom: 8px !important;
  879. }
  880. .required_fields{
  881. color: #F56C6C;
  882. display:inline-block;
  883. width: 7%
  884. }
  885. .upper_right_button{
  886. display: flex;
  887. position: fixed;
  888. right: 12px;
  889. top: 47px;
  890. }
  891. </style>