kaihe-detail.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. <template>
  2. <div v-if="showDetail">
  3. <div style="display: flex; justify-content: space-between">
  4. <div style="display: flex; align-items: center">
  5. <el-breadcrumb separator="/">
  6. <el-breadcrumb-item
  7. ><span style="font-weight: 700">对账</span></el-breadcrumb-item
  8. >
  9. <el-breadcrumb-item
  10. ><span style="font-weight: 700"
  11. >对账详情页</span
  12. ></el-breadcrumb-item
  13. >
  14. </el-breadcrumb>
  15. <el-button
  16. style="margin-left: 10px"
  17. size="mini"
  18. icon="el-icon-arrow-left"
  19. @click="cancel"
  20. >返回列表
  21. </el-button>
  22. </div>
  23. <!-- <div v-if="showApproval == 0">
  24. 审核
  25. </div> -->
  26. </div>
  27. <br />
  28. <el-form ref="form" :model="form" label-width="80px">
  29. <el-row>
  30. <el-col :span="6">
  31. <el-form-item label="客户名称" prop="fCorpid">
  32. <el-select
  33. v-model="form.fCorpid"
  34. size="small"
  35. placeholder="请选择"
  36. clearable
  37. :disabled="
  38. form.fBillstatus >= 4 || readOnly == 0 || form.fId != null
  39. "
  40. style="width: 100%"
  41. filterable
  42. >
  43. <el-option
  44. v-for="item in corpList"
  45. :key="item.fId"
  46. :label="item.fName"
  47. :value="item.fId"
  48. />
  49. </el-select>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :span="6">
  53. <el-form-item label="开船日期">
  54. <el-date-picker
  55. v-model="form.date"
  56. type="daterange"
  57. size="small"
  58. placeholder="请选择日期"
  59. format="yyyy-MM-dd"
  60. value-format="yyyy-MM-dd"
  61. :disabled="form.fBillstatus >= 4 || readOnly == 0"
  62. style="width: 100%"
  63. />
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="6">
  67. <el-form-item label="船名">
  68. <el-select
  69. v-model="form.fVslid"
  70. size="small"
  71. placeholder="请选择"
  72. clearable
  73. @change="fvslChange"
  74. @clear="fvslClear"
  75. :disabled="form.fBillstatus >= 4 || readOnly == 0"
  76. style="width: 100%"
  77. >
  78. <el-option
  79. v-for="item in TVesselfs"
  80. :key="item.fId"
  81. :label="item.fName"
  82. :value="item.fId"
  83. />
  84. </el-select>
  85. </el-form-item>
  86. </el-col>
  87. <el-col :span="6">
  88. <el-form-item label="航次">
  89. <el-select
  90. v-model="form.fVoyid"
  91. size="small"
  92. placeholder="请选择"
  93. clearable
  94. :disabled="form.fBillstatus >= 4 || readOnly == 0"
  95. style="width: 100%"
  96. >
  97. <el-option
  98. v-for="item in TVoyagefs"
  99. :key="item.fId"
  100. :label="item.fNo"
  101. :value="item.fId"
  102. />
  103. </el-select>
  104. </el-form-item>
  105. </el-col>
  106. <el-col :span="6">
  107. <el-form-item label="提单号">
  108. <el-input
  109. v-model="form.tMblno"
  110. size="small"
  111. placeholder="请输入"
  112. :disabled="form.fBillstatus >= 4 || readOnly == 0"
  113. />
  114. </el-form-item>
  115. </el-col>
  116. <el-col :span="6">
  117. <el-form-item label="起运港">
  118. <el-select
  119. v-model="form.fLoadportid"
  120. size="small"
  121. placeholder="请选择"
  122. clearable
  123. :disabled="form.fBillstatus >= 4 || readOnly == 0"
  124. style="width: 100%"
  125. >
  126. <el-option
  127. v-for="item in portNames"
  128. :key="item.fId"
  129. :label="item.fName"
  130. :value="item.fId"
  131. />
  132. </el-select>
  133. </el-form-item>
  134. </el-col>
  135. <el-col :span="6">
  136. <el-form-item label="目的港">
  137. <el-select
  138. v-model="form.fDestportid"
  139. size="small"
  140. placeholder="请选择"
  141. clearable
  142. :disabled="form.fBillstatus >= 4 || readOnly == 0"
  143. style="width: 100%"
  144. >
  145. <el-option
  146. v-for="item in portNames"
  147. :key="item.fId"
  148. :label="item.fName"
  149. :value="item.fId"
  150. />
  151. </el-select>
  152. </el-form-item>
  153. </el-col>
  154. <el-col :span="6">
  155. <el-form-item label="是否对账" prop="fReconciliation">
  156. <el-select
  157. v-model="form.fReconciliation"
  158. size="small"
  159. clearable
  160. :disabled="form.fBillstatus >= 4 || readOnly == 0"
  161. style="width: 100%"
  162. >
  163. <el-option label="是" value="1" />
  164. <el-option label="否" value="0" />
  165. </el-select>
  166. </el-form-item>
  167. </el-col>
  168. <el-col :span="6">
  169. <el-form-item label="应收应付" prop="fDc">
  170. <el-select
  171. v-model="form.fDc"
  172. size="small"
  173. clearable
  174. :disabled="form.fBillstatus >= 4 || readOnly == 0"
  175. style="width: 100%"
  176. >
  177. <el-option label="应收" value="D" />
  178. <el-option label="应付" value="C" />
  179. </el-select>
  180. </el-form-item>
  181. </el-col>
  182. <el-col :span="6">
  183. <el-form-item label="系统编号">
  184. <el-input
  185. v-model="form.srcBillNo"
  186. size="small"
  187. placeholder="请输入"
  188. disabled
  189. ></el-input>
  190. </el-form-item>
  191. </el-col>
  192. <el-col :span="6">
  193. <el-form-item label="制单人">
  194. <el-input
  195. v-model="form.createBy"
  196. size="small"
  197. placeholder="请输入"
  198. disabled
  199. ></el-input>
  200. </el-form-item>
  201. </el-col>
  202. <el-col :span="6">
  203. <el-form-item label="制单日期">
  204. <el-date-picker
  205. v-model="form.createTime"
  206. size="small"
  207. placeholder="请选择"
  208. format="yyyy-MM-dd"
  209. value-format="yyyy-MM-dd 00:00:00"
  210. disabled
  211. style="width: 100%"
  212. />
  213. </el-form-item>
  214. </el-col>
  215. <el-col :span="6">
  216. <el-form-item label="备注">
  217. <el-input
  218. type="textarea"
  219. v-model="form.fRemarks"
  220. size="small"
  221. placeholder="请输入"
  222. ></el-input>
  223. </el-form-item>
  224. </el-col>
  225. <el-col :span="6">
  226. <el-form-item label="开票备注">
  227. <el-input
  228. type="textarea"
  229. v-model="form.invoiceRemarks"
  230. size="small"
  231. placeholder="请输入"
  232. ></el-input>
  233. </el-form-item>
  234. </el-col>
  235. </el-row>
  236. </el-form>
  237. <div class="head-but">
  238. <div>
  239. <el-button
  240. type="primary"
  241. size="mini"
  242. @click="submit"
  243. :disabled="form.fBillstatus >= 4 || readOnly == 0"
  244. :loading="subLoading"
  245. >
  246. 确认对账
  247. </el-button>
  248. <el-button
  249. type="success"
  250. size="mini"
  251. @click="backrRconciliation"
  252. v-if="form.fBillstatus === '6'"
  253. :loading="subLoading"
  254. v-hasPermi="['finance:contrast:revoke']"
  255. >撤销对账</el-button
  256. >
  257. <el-button
  258. type="danger"
  259. size="mini"
  260. v-if="form.fBillstatus == 4"
  261. @click="backApproval('f_billstatus')"
  262. >撤销审批</el-button
  263. >
  264. <el-button
  265. v-if="readOnly == 3"
  266. size="mini"
  267. @click="goApproval('f_billstatus')"
  268. >审批</el-button
  269. >
  270. <el-button
  271. type="primary"
  272. size="mini"
  273. v-if="form.fBillstatus >= '3'"
  274. @click="addOrUpdateHandle('f_billstatus')"
  275. >查看审批流</el-button
  276. >
  277. <el-button
  278. type="success"
  279. size="mini"
  280. @click="save"
  281. :loading="subLoading"
  282. >
  283. 保存
  284. </el-button>
  285. <el-button
  286. type="warning"
  287. size="mini"
  288. :disabled="!form.fId"
  289. @click="handleExport"
  290. >
  291. 导出
  292. </el-button>
  293. <el-button
  294. type="cyan"
  295. icon="el-icon-search"
  296. size="mini"
  297. @click="Search"
  298. :disabled="form.fBillstatus >= 4 || readOnly == 0"
  299. >
  300. 检索
  301. </el-button>
  302. </div>
  303. <div class="tabSetting">
  304. <div style="margin: 0 12px">
  305. <el-button
  306. icon="el-icon-setting"
  307. size="mini"
  308. circle
  309. @click="colSetting"
  310. ></el-button>
  311. </div>
  312. </div>
  313. </div>
  314. <el-table
  315. :data="tableData"
  316. style="width: 100%"
  317. show-summary
  318. :summary-method="getSummaries"
  319. >
  320. <el-table-column label="序号" type="index" width="50" />
  321. <el-table-column
  322. v-for="(item, index) in tableOption"
  323. :key="index"
  324. :label="item.name"
  325. :width="item.width"
  326. :prop="item.label"
  327. align="center"
  328. :fixed="item.fixed"
  329. sortable
  330. :show-overflow-tooltip="true"
  331. >
  332. <template slot-scope="scope">
  333. <span v-if="item.label == 'srcBillNo'">
  334. {{ scope.row.srcBillNo }}
  335. </span>
  336. <span v-if="item.label == 'fName'">
  337. {{ scope.row.fName }}
  338. </span>
  339. <span v-if="item.label == 'fFeeName'">
  340. {{ scope.row.fFeeName }}
  341. </span>
  342. <span v-if="item.label == 'goodName'">
  343. {{ scope.row.goodName }}
  344. </span>
  345. <span v-if="item.label == 'fFeeUnitName'">
  346. {{ scope.row.fFeeUnitName }}
  347. </span>
  348. <span v-if="item.label == 'fQty'">
  349. {{ scope.row.fQty }}
  350. </span>
  351. <span v-if="item.label == 'fUnitPrice'">
  352. {{ scope.row.fUnitPrice }}
  353. </span>
  354. <span v-if="item.label == 'fAmtdr'">
  355. {{ scope.row.fAmtdr }}
  356. </span>
  357. <span v-if="item.label == 'fAmt'">
  358. <el-input
  359. v-model="scope.row.fAmt"
  360. size="small"
  361. placeholder="请输入"
  362. :disabled="form.fBillstatus >= 4 || readOnly == 0"
  363. @change="fAmtChange(scope.row)"
  364. ></el-input>
  365. </span>
  366. <span v-if="item.label == 'fvslName'">
  367. {{ scope.row.fvslName }}
  368. </span>
  369. <span v-if="item.label == 'fvoyName'">
  370. {{ scope.row.fvoyName }}
  371. </span>
  372. <span v-if="item.label == 'fCntrCount'">
  373. {{ scope.row.fCntrCount }}
  374. </span>
  375. <span v-if="item.label == 'cntrName'">
  376. {{ scope.row.cntrName }}
  377. </span>
  378. <span v-if="item.label == 'fLoadPortName'">
  379. {{ scope.row.fLoadPortName }}
  380. </span>
  381. <span v-if="item.label == 'fDestPortName'">
  382. {{ scope.row.fDestPortName }}
  383. </span>
  384. <span v-if="item.label == 'fBillStatusName'">
  385. {{ scope.row.fBillStatusName }}
  386. </span>
  387. <span v-if="item.label == 'createBy'">
  388. {{ scope.row.createBy }}
  389. </span>
  390. <span v-if="item.label == 'createTime'">
  391. {{ scope.row.createTime }}
  392. </span>
  393. <span v-if="item.label == 'fRemarks'">
  394. <el-input
  395. v-model="scope.row.fRemarks"
  396. size="small"
  397. placeholder="请输入"
  398. :disabled="form.fBillstatus >= 4 || readOnly == 0"
  399. ></el-input>
  400. </span>
  401. </template>
  402. </el-table-column>
  403. <el-table-column
  404. label="操作"
  405. align="center"
  406. class-name="small-padding fixed-width"
  407. min-width="180"
  408. fixed="right"
  409. >
  410. <template slot-scope="scope">
  411. <el-button
  412. size="mini"
  413. type="text"
  414. icon="el-icon-delete"
  415. @click="rowDel(scope.row, scope.$index, tableData)"
  416. :disabled="form.fBillstatus >= 4 || readOnly == 0"
  417. >
  418. 删除
  419. </el-button>
  420. </template>
  421. </el-table-column>
  422. </el-table>
  423. <approval-comments
  424. v-if="addOrUpdateVisib"
  425. ref="ApprovalComments"
  426. @refreshDataList="returnData"
  427. />
  428. <add-or-update ref="addOrUpdate" @imporData="imporData" />
  429. <view-approval ref="viewApproval" />
  430. <column-setting
  431. ref="columnSetting"
  432. @reset="reset"
  433. @getRowdata="getRowdata"
  434. tableName="凯和对账详情页"
  435. />
  436. </div>
  437. </template>
  438. <script>
  439. import Cookies from "js-cookie";
  440. import { tableOption2 } from "./js/index";
  441. import {
  442. selectTVesself,
  443. selectTVoyagef,
  444. selectPortName,
  445. save,
  446. listCorps,
  447. confirm,
  448. RevocationApproval,
  449. getdetail,
  450. infoRemove,
  451. revoke,
  452. getExcelInfo,
  453. } from "@/api/finance/kaihe/contrast";
  454. import ApprovalComments from "@/views/startApproval";
  455. import addOrUpdate from "./add-or-update.vue";
  456. import viewApproval from "@/views/viewApproval";
  457. import columnSetting from "@/components/ColumnSetting/index";
  458. import _ from "lodash";
  459. export default {
  460. data() {
  461. return {
  462. form: {
  463. fReconciliation: "0",
  464. fDc: "D",
  465. fSystemType: Cookies.get("sysType"),
  466. fVoyid: null,
  467. },
  468. options: [],
  469. tableData: [],
  470. tableOption: tableOption2,
  471. TVesselfs: [],
  472. TVoyagefs: [],
  473. portNames: [],
  474. corpList: [],
  475. wRtions: [],
  476. approve: false,
  477. addOrUpdateVisib: false,
  478. readOnly: null,
  479. subLoading: false,
  480. };
  481. },
  482. components: {
  483. ApprovalComments,
  484. addOrUpdate,
  485. viewApproval,
  486. columnSetting,
  487. },
  488. props: {
  489. showDetail: {
  490. type: Boolean,
  491. },
  492. },
  493. created() {},
  494. methods: {
  495. fvslChange(id) {
  496. selectTVoyagef({ fPid: id }).then((res) => {
  497. this.TVoyagefs = res.rows;
  498. });
  499. this.form.fVoyid = null;
  500. },
  501. fvslClear() {
  502. selectTVoyagef().then((res) => {
  503. this.TVoyagefs = res.rows;
  504. });
  505. this.form.fVoyid = null;
  506. },
  507. /** 导出按钮操作 */
  508. handleExport() {
  509. if (this.form.fCorpid == null) {
  510. return this.$message.error("客户名称不能为空");
  511. }
  512. let _this = this;
  513. this.$confirm("是否确认导出明细数据?", "警告", {
  514. confirmButtonText: "确定",
  515. cancelButtonText: "取消",
  516. type: "warning",
  517. })
  518. .then(function () {
  519. return getExcelInfo(_this.form.fId);
  520. })
  521. .then((response) => {
  522. this.download(response.msg);
  523. });
  524. },
  525. getRowdata(list) {
  526. this.tableOption = list;
  527. },
  528. reset() {
  529. this.tableOption = this.$options.data().tableOption;
  530. },
  531. colSetting() {
  532. this.$refs.columnSetting.init(this.tableOption);
  533. },
  534. init() {
  535. selectTVesself().then((res) => {
  536. this.TVesselfs = res.rows;
  537. });
  538. selectTVoyagef().then((res) => {
  539. this.TVoyagefs = res.rows;
  540. });
  541. selectPortName().then((res) => {
  542. this.portNames = res.rows;
  543. });
  544. this.getDicts("whether_reconciliation").then((response) => {
  545. if (response.data) {
  546. this.wRtions = response.data;
  547. }
  548. });
  549. listCorps().then((res) => {
  550. this.corpList = res;
  551. });
  552. setTimeout((e) => {
  553. this.$refs.columnSetting.getRow(this.tableOption);
  554. }, 100);
  555. },
  556. fAmtChange(row) {
  557. if (Number(row.fAmt) > Number(row.fAmtdr)) {
  558. row.fAmt = row.fAmtdr;
  559. this.$message.error("实收金额不能超过应收金额");
  560. }
  561. if (Number(row.fAmt) <= 0) {
  562. row.fAmt = row.fAmtdr;
  563. this.$message.error("请正确输入金额");
  564. }
  565. },
  566. rowDel(row, index, rows) {
  567. console.log();
  568. if (row.fId) {
  569. infoRemove(row.fId).then((res) => {
  570. if (res.code == 200) {
  571. rows.splice(index, 1);
  572. this.$message.success("删除成功");
  573. }
  574. });
  575. } else {
  576. rows.splice(index, 1);
  577. this.$message.success("删除成功");
  578. }
  579. },
  580. getSummaries(param) {
  581. const { columns, data } = param;
  582. const sums = [];
  583. if (data.length > 0) {
  584. columns.forEach((column, index) => {
  585. if (index == 0) {
  586. sums[index] = "合计";
  587. }
  588. if (column.label == "应收金额" || column.label == "实收金额") {
  589. const values = data.map((item) => Number(item[column.property]));
  590. if (!values.every((value) => isNaN(value))) {
  591. sums[index] = values.reduce((prev, curr) => {
  592. const value = Number(curr);
  593. if (!isNaN(value)) {
  594. return prev + curr;
  595. } else {
  596. return prev;
  597. }
  598. }, 0);
  599. // sums[index] += "元";
  600. } else {
  601. sums[index] = "0";
  602. // sums[index] = "0元";
  603. }
  604. }
  605. });
  606. }
  607. return sums;
  608. },
  609. info(row, status) {
  610. this.init();
  611. this.readOnly = status;
  612. const id = row.fId ? row.fId : row;
  613. getdetail(id).then((res) => {
  614. if (res.data.tFee.fFromDate && res.data.tFee.fToDate) {
  615. const date = [];
  616. date.push(res.data.tFee.fFromDate, res.data.tFee.fToDate);
  617. res.data.tFee.date = date;
  618. }
  619. this.form = res.data.tFee;
  620. this.tableData = res.data.tFeeDo;
  621. });
  622. },
  623. copyData(id) {
  624. this.init();
  625. getdetail(id).then((res) => {
  626. if (res.data.tFee.fFromDate && res.data.tFee.fToDate) {
  627. const date = [];
  628. date.push(res.data.tFee.fFromDate, res.data.tFee.fToDate);
  629. res.data.tFee.date = date;
  630. }
  631. delete res.data.tFee.fId;
  632. delete res.data.tFee.fBillstatus;
  633. delete res.data.tFee.fBillno;
  634. delete res.data.tFee.srcBillNo;
  635. delete res.data.tFee.createBy;
  636. delete res.data.tFee.createTime;
  637. delete res.data.tFee.updateBy;
  638. delete res.data.tFee.updateTime;
  639. delete res.data.tFee.fRemarks;
  640. this.form = res.data.tFee;
  641. });
  642. },
  643. returnData() {
  644. this.addOrUpdateVisib = false;
  645. this.homepaGe();
  646. },
  647. homepaGe() {
  648. let view = {
  649. fullPath: "/finance/contrast",
  650. hash: "",
  651. matched: Array(2),
  652. meta: Object,
  653. name: "Contrast",
  654. params: Object,
  655. path: "/finance/contrast",
  656. query: Object,
  657. title: "对账",
  658. };
  659. this.$router.push({ path: "/index" });
  660. this.$store
  661. .dispatch("tagsView/delView", view)
  662. .then(({ visitedViews }) => {
  663. if (this.isActive(view)) {
  664. this.toLastView(visitedViews, view);
  665. }
  666. });
  667. Global.$emit("removeCache", "closeSelectedTag", view);
  668. },
  669. // 审批按钮
  670. goApproval(status) {
  671. this.addOrUpdateVisib = true;
  672. this.$nextTick(() => {
  673. this.$refs.ApprovalComments.init(this.form.fId, status, 430);
  674. });
  675. },
  676. // 撤销审批
  677. backApproval(status) {
  678. let data = {
  679. id: this.form.fId,
  680. actId: 430,
  681. billId: this.form.fId,
  682. fidStatus: status,
  683. };
  684. RevocationApproval(data).then((response) => {
  685. if (response.code === 200) {
  686. this.msgSuccess("撤销审批成功");
  687. this.open = false;
  688. }
  689. });
  690. },
  691. returnData() {
  692. this.$emit("goBack", false);
  693. },
  694. // 查看审批流
  695. addOrUpdateHandle(status) {
  696. this.addOrUpdateVisible = true;
  697. this.addOrUpdateVisib = false;
  698. let id = null;
  699. if (this.form.fId) {
  700. id = this.form.fId;
  701. } else {
  702. id = this.form.id;
  703. }
  704. this.$nextTick(() => {
  705. this.$refs.viewApproval.init(id, 430, status);
  706. });
  707. },
  708. // 撤销对账
  709. backrRconciliation() {
  710. this.form.fBillstatus = "1";
  711. this.subLoading = true;
  712. let formDate = new window.FormData();
  713. formDate.append("tFee", JSON.stringify(this.form));
  714. formDate.append("tFeeDo", JSON.stringify(this.tableData));
  715. revoke(formDate)
  716. .then((response) => {
  717. this.msgSuccess("撤回成功");
  718. Object.assign(this.$data, this.$options.data());
  719. this.$emit("goBack", false);
  720. })
  721. .finally(() => {
  722. this.subLoading = false;
  723. });
  724. },
  725. Search() {
  726. const data = {
  727. fReconciliation: this.form.fReconciliation,
  728. fDc: this.form.fDc,
  729. fSystemType: 3,
  730. fCorpid: this.form.fCorpid,
  731. fVslid: this.form.fVslid,
  732. fVoyid: this.form.fVoyid,
  733. fDestportid: this.form.fDestportid,
  734. fLoadportid: this.form.fLoadportid,
  735. fMblno: this.form.tMblno,
  736. fFromDate: this.form.date ? this.form.date[0] : null,
  737. fToDate: this.form.date ? this.form.date[1] : null,
  738. };
  739. this.$refs.addOrUpdate.init(data, this.tableData);
  740. },
  741. imporData(rows) {
  742. this.tableData = this.tableData.concat(rows);
  743. },
  744. lumpSum() {
  745. let fAmtdr = 0;
  746. let fAmtcr = 0;
  747. this.tableData.map((e) => {
  748. fAmtdr = _.add(fAmtdr, Number(e.fAmtdr));
  749. fAmtcr = _.add(fAmtcr, Number(e.fAmt));
  750. });
  751. this.form.fAmtdr = fAmtdr;
  752. this.form.fAmtcr = fAmtcr;
  753. },
  754. submit() {
  755. if (this.form.fCorpid == null) {
  756. return this.$message.error("客户名称不能为空");
  757. }
  758. this.corpList.forEach((e) => {
  759. if (this.form.fCorpid == e.fId) {
  760. this.form.fCtrlcorpid = e.fName;
  761. }
  762. });
  763. if (this.tableData.length == 0) {
  764. return this.$message.error("明细表不能为空");
  765. }
  766. if (this.form.date) {
  767. this.form.fFromDate = this.form.date[0];
  768. this.form.fToDate = this.form.date[1];
  769. }
  770. this.lumpSum();
  771. if (this.form.fId == null) {
  772. return this.$message.error("数据未保存,不能进行确认对账");
  773. }
  774. this.subLoading = true;
  775. let formDate = new window.FormData();
  776. formDate.append("tFee", JSON.stringify(this.form));
  777. formDate.append("tFeeDo", JSON.stringify(this.tableData));
  778. formDate.append("billsType", JSON.stringify("KHDZ"));
  779. confirm(formDate)
  780. .then((res) => {
  781. if (res.code == 200) {
  782. this.$message.success("对账成功");
  783. Object.assign(this.$data, this.$options.data());
  784. this.$emit("goBack", false);
  785. }
  786. })
  787. .finally(() => {
  788. this.subLoading = false;
  789. });
  790. },
  791. save(type) {
  792. if (this.form.fCorpid == null) {
  793. return this.$message.error("客户名称不能为空");
  794. }
  795. this.corpList.forEach((e) => {
  796. if (this.form.fCorpid == e.fId) {
  797. this.form.fCtrlcorpid = e.fName;
  798. }
  799. });
  800. if (this.form.date) {
  801. this.form.fFromDate = this.form.date[0];
  802. this.form.fToDate = this.form.date[1];
  803. }
  804. this.lumpSum();
  805. this.subLoading = true;
  806. let formDate = new window.FormData();
  807. formDate.append("tFee", JSON.stringify(this.form));
  808. formDate.append("tFeeDo", JSON.stringify(this.tableData));
  809. formDate.append("billsType", JSON.stringify("KHDZ"));
  810. save(formDate)
  811. .then((res) => {
  812. if (res.code == 200) {
  813. if (!type) {
  814. if (res.data.tFee.fFromDate && res.data.tFee.fToDate) {
  815. const date = [];
  816. date.push(res.data.tFee.fFromDate, res.data.tFee.fToDate);
  817. res.data.tFee.date = date;
  818. }
  819. }
  820. this.form = res.data.tFee;
  821. this.tableData = res.data.tFeeDo;
  822. this.$emit("refFresh");
  823. this.$message.success("保存成功");
  824. }
  825. })
  826. .finally(() => {
  827. this.subLoading = false;
  828. });
  829. },
  830. cancel() {
  831. if (this.readOnly != 0) {
  832. this.$confirm("返回列表,是否保存?", "提示", {
  833. confirmButtonText: "保存",
  834. cancelButtonText: "取消",
  835. type: "warning",
  836. })
  837. .then(() => {
  838. this.save("back");
  839. Object.assign(this.$data, this.$options.data());
  840. this.$emit("goBack", false);
  841. })
  842. .catch(() => {
  843. Object.assign(this.$data, this.$options.data());
  844. this.$emit("goDetail", false);
  845. });
  846. } else {
  847. Object.assign(this.$data, this.$options.data());
  848. this.$emit("goBack", false);
  849. }
  850. },
  851. },
  852. watch: {
  853. info: function (obj) {
  854. console.log(obj);
  855. },
  856. },
  857. };
  858. </script>
  859. <style lang="scss" scoped>
  860. .head-but {
  861. display: flex;
  862. justify-content: space-between;
  863. margin-bottom: 8px;
  864. }
  865. .tabSetting {
  866. display: flex;
  867. justify-content: flex-end;
  868. }
  869. </style>