outputInvoiceDetailsPage.vue 28 KB

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