incomeInvoiceDetailsPage.vue 27 KB

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