main.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  1. <template>
  2. <div>
  3. <trade-card title="费用明细">
  4. <avue-crud ref="feeCrud" :data="feeData" :option="feeOption" @saveColumn="saveColumn" @resetColumn="resetColumn"
  5. @selection-change="selectionChange" :summary-method="summaryMethod" :cell-style="cellStyle">
  6. <template slot="menuLeft">
  7. <el-tabs v-model="activeName" @tab-click="tabHandle">
  8. <el-tab-pane label="应收" name="first" :key="'first'" v-if="tabShow == 1 || tabShow == 2">
  9. </el-tab-pane>
  10. <el-tab-pane label="应付" name="second" :key="'second'" v-if="tabShow == 1 || tabShow == 3">
  11. </el-tab-pane>
  12. </el-tabs>
  13. <el-button type="primary" icon="el-icon-plus" size="small" @click.stop="rowAdd" :loading="buttonLoading"
  14. :disabled="disabled">录入明细</el-button>
  15. <el-button type="warning" size="small" @click.stop="billingDetails('收费')" :loading="buttonLoading" :disabled="
  16. (financeDisabled && disabled) || selectionList.length == 0
  17. " v-if="selectTab === 1&&billingShow">生成账单</el-button>
  18. <el-button type="warning" size="small" @click.stop="billingDetails('申请')" :loading="buttonLoading" :disabled="
  19. (financeDisabled && disabled) || selectionList.length == 0
  20. " v-if="selectTab === 2&&billingShow">申请付费</el-button>
  21. </template>
  22. <template slot="menu" slot-scope="{ row, index }">
  23. <el-button size="small" icon="el-icon-edit" type="text" @click="rowCell(row, index)" :disabled="disabled">{{
  24. row.$cellEdit ? "保存" : "修改"
  25. }}</el-button>
  26. <el-button size="small" icon="el-icon-delete" type="text" @click="rowDel(row, index)" :disabled="disabled">删 除
  27. </el-button>
  28. </template>
  29. <template slot="headerSerial">
  30. <el-button type="primary" icon="el-icon-plus" size="mini" @click.stop="addRow" :disabled="disabled" circle>
  31. </el-button>
  32. </template>
  33. <template slot="corpId" slot-scope="{ row, index }">
  34. <crop-select ref="corp" v-if="row.$cellEdit" v-model="row.corpId" :cropIndex="index"
  35. @getCorpData="getCorpData" corpType="KG"></crop-select>
  36. <span v-else>{{ row.corpName }}</span>
  37. </template>
  38. <template slot="feeName" slot-scope="{ row }">
  39. <breakdown-select v-if="row.$cellEdit" v-model="row.itemId" @selectValue="value => selectValue(value, row)"
  40. :configuration="breakConfiguration">
  41. </breakdown-select>
  42. <span v-else>{{ row.feeName }}</span>
  43. </template>
  44. <template slot="billNo" slot-scope="{ row }">
  45. <el-select v-if="row.$cellEdit" v-model="row.billNo" size="small" filterable allow-create default-first-option
  46. clearable>
  47. <el-option v-for="(item, index) in billNoList" :key="index" :label="item" :value="item">
  48. </el-option>
  49. </el-select>
  50. <span v-else>{{ row.billNo }}</span>
  51. </template>
  52. <template slot="price" slot-scope="{ row }">
  53. <el-input-number v-if="row.$cellEdit" v-model="row.price" placeholder="请输入" size="small" :controls="false"
  54. :precision="2" @input="countChange(row)" style="width: 100%"></el-input-number>
  55. <span v-else>{{ row.price | micrometerFormat }}</span>
  56. </template>
  57. <template slot="quantity" slot-scope="{ row }">
  58. <el-input-number v-if="row.$cellEdit && !isDecimal" v-model="row.quantity" size="small" placeholder="请输入"
  59. :controls="false" :precision="0" @input="countChange(row)" style="width: 100%"></el-input-number>
  60. <el-input-number v-if="row.$cellEdit && isDecimal" v-model="row.quantity" size="small" placeholder="请输入"
  61. :controls="false" :precision="6" @input="countChange(row)" style="width: 100%"></el-input-number>
  62. <span v-else>{{ row.quantity | decimalFormat }}</span>
  63. </template>
  64. <template slot="amount" slot-scope="{ row }">
  65. <span>{{ row.amount | micrometerFormat }}</span>
  66. </template>
  67. <template slot="exchangeRate" slot-scope="{ row }">
  68. <el-input-number v-if="row.$cellEdit" v-model="row.exchangeRate" size="small" :controls="false" :precision="6"
  69. @change="rateChange(row)" style="width: 100%" placeholder="请输入"></el-input-number>
  70. <span v-else>{{ row.exchangeRate }}</span>
  71. </template>
  72. <template slot="currency" slot-scope="{ row }">
  73. <el-select v-if="row.$cellEdit" v-model="row.currency" filterable allow-create default-first-option
  74. placeholder="请选择" size="small" @change="currencyChange(row)">
  75. <el-option v-for="(item, index) in currencyList" :key="index" :label="item.dictValue"
  76. :value="item.dictValue">
  77. </el-option>
  78. </el-select>
  79. <span v-else>{{ row.currency }}</span>
  80. </template>
  81. <template slot="invoiceAmount" slot-scope="{ row }">
  82. <el-popover placement="right" width="400" trigger="click" @show="invoiceShow(row)" @hide="invoiceHide">
  83. <avue-crud :data="invoiceData" :option="invoiceOption"></avue-crud>
  84. <!-- <el-button slot="reference">click 激活</el-button> -->
  85. <span style="color: #409EFF;cursor: pointer" slot="reference">{{ row.invoiceAmount }}</span>
  86. </el-popover>
  87. </template>
  88. <template slot="unit" slot-scope="{ row }">
  89. <el-select v-if="row.$cellEdit" v-model="row.unit" filterable placeholder="请选择" size="small">
  90. <el-option v-for="(item, index) in unitList" :key="index" :label="item.dictValue" :value="item.dictValue">
  91. </el-option>
  92. </el-select>
  93. <span v-else>{{ row.unit }}</span>
  94. </template>
  95. </avue-crud>
  96. </trade-card>
  97. <el-dialog title="导入费用" append-to-body :visible.sync="feeDialog" top="5vh" width="60%" :close-on-click-modal="false"
  98. @closed="feeClose" class="el-dialogDeep" v-dialog-drag>
  99. <el-row style="height: 0;">
  100. <el-col :span="5">
  101. <div style="margin-top:45px">
  102. <el-scrollbar>
  103. <basic-container>
  104. <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" />
  105. </basic-container>
  106. </el-scrollbar>
  107. </div>
  108. </el-col>
  109. <el-col :span="19">
  110. <avue-crud :option="option" :table-loading="loading" :data="data" ref="crud" @refresh-change="refreshChange"
  111. @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
  112. :page.sync="page" @on-load="onLoad" :cell-style="cellStyle">
  113. </avue-crud>
  114. </el-col>
  115. </el-row>
  116. <div class="dialogButton">
  117. <el-button @click="feeDialog = false">取 消</el-button>
  118. <el-button type="primary" @click="importData" :disabled="this.selectionList.length == 0">
  119. 导入
  120. </el-button>
  121. </div>
  122. </el-dialog>
  123. <crop-dialog ref="cropDialog" @importCorp="importCorp"></crop-dialog>
  124. </div>
  125. </template>
  126. <script>
  127. import feeOption from "./config/feeInfo.json";
  128. import woodOption from "./config/wood.json";
  129. import option from "./config/feeList.json";
  130. import { getDeptLazyTree, customerList } from "@/api/basicData/basicFeesDesc";
  131. import { delItem, delItem2, getfeesDetails } from "@/api/feeInfo/fee-info";
  132. import { isPercentage, micrometerFormat, IntegerFormat } from "@/util/validate";
  133. import cropDialog from "@/components/crop-dialog/main";
  134. import _ from "lodash";
  135. import ApplyPayment from "../finance/applyPayment";
  136. import {
  137. applyLoan,
  138. paymentApply
  139. } from "@/api/financialManagement/paymentRequest";
  140. import { contrastList } from "@/util/contrastData";
  141. import { allCropList } from "@/api/basicData/customerInformation";
  142. import { getCustomerCode, getCustomerName } from "@/enums/management-type";
  143. import { getParities } from "@/api/basicData/customerInquiry";
  144. import { dateFormat } from "@/util/date";
  145. export default {
  146. name: "feeInfo",
  147. data() {
  148. return {
  149. invoiceOption: {
  150. border: true,
  151. align: 'center',
  152. header: false,
  153. menu: false,
  154. column: [
  155. {
  156. label: '日期',
  157. prop: 'invoice_time'
  158. },
  159. {
  160. label: '金额',
  161. prop: 'amount'
  162. },
  163. ]
  164. },
  165. option: option,
  166. feeOption: {},
  167. feeDialog: false,
  168. buttonLoading: false,
  169. treeOption: {
  170. nodeKey: "id",
  171. lazy: true,
  172. treeLoad: function (node, resolve) {
  173. const parentId = node.level === 0 ? 0 : node.data.id;
  174. getDeptLazyTree(parentId).then(res => {
  175. resolve(
  176. res.data.data.map(item => {
  177. return {
  178. ...item,
  179. leaf: !item.hasChildren
  180. };
  181. })
  182. );
  183. });
  184. },
  185. addBtn: false,
  186. menu: false,
  187. size: "small",
  188. props: {
  189. labelText: "标题",
  190. label: "title",
  191. value: "value",
  192. children: "children"
  193. }
  194. },
  195. page: {
  196. pageSize: 10,
  197. currentPage: 1,
  198. total: 0
  199. },
  200. treeDeptId: null,
  201. loading: false,
  202. receivableButton: "primary",
  203. copeWithButton: "",
  204. data: [],
  205. feeData: [],
  206. selectionList: [],
  207. reData: null,
  208. currencyList: [],
  209. unitList: [],
  210. breakConfiguration: {
  211. multipleChoices: false,
  212. multiple: false,
  213. disabled: false,
  214. searchShow: true,
  215. collapseTags: false,
  216. clearable: true,
  217. placeholder: "请点击右边按钮选择",
  218. dicData: []
  219. },
  220. allData: [],
  221. data_one: [],
  222. data_two: [],
  223. selectTab: 1,
  224. enableName: "first",
  225. tab1: true,
  226. tab2: false,
  227. corpList: [],
  228. invoiceData: [],
  229. };
  230. },
  231. props: {
  232. orderFeesList: {
  233. type: Array
  234. },
  235. disabled: {
  236. type: Boolean
  237. },
  238. feeUrl: {
  239. type: String
  240. },
  241. typeName: {
  242. type: String
  243. },
  244. billUrl: {
  245. type: String
  246. },
  247. optionType: {
  248. type: String
  249. },
  250. itemType: {
  251. type: String
  252. },
  253. srcType: {
  254. type: Number,
  255. default: 2
  256. },
  257. corpId: {
  258. type: String
  259. },
  260. billNoList: {
  261. type: Array
  262. },
  263. financeDisabled: {
  264. type: Boolean,
  265. default: true
  266. },
  267. inCropId: {
  268. type: Boolean,
  269. default: false
  270. },
  271. // 1.显示全部 2.收费 3.付费
  272. tabShow: {
  273. type: Number,
  274. default: 1
  275. },
  276. activeName: {
  277. type: String,
  278. default: 'first'
  279. },
  280. // 1.贸易 2.泽兴
  281. delType: {
  282. type: Number,
  283. default: 1
  284. },
  285. isDecimal: {
  286. type: Boolean,
  287. default: false
  288. },
  289. billingShow: {
  290. type: Boolean,
  291. default: true
  292. },
  293. },
  294. filters: {
  295. isPercentage(val) {
  296. return isPercentage(val);
  297. },
  298. micrometerFormat(val) {
  299. return micrometerFormat(val);
  300. },
  301. decimalFormat(num) {
  302. return num ? Number(num).toFixed(6) : "0.00";
  303. },
  304. IntegerFormat(num) {
  305. return IntegerFormat(num);
  306. }
  307. },
  308. async created() {
  309. // 判断tabShow的activeName默认的显示
  310. this.activeName = this.tabShow == 1 ? "first" : this.tabShow == 2 ? "first" : "second";
  311. this.feeOption = await this.getColumnData(this.getColumnName(33), this.typeName === "wood" ? woodOption : feeOption);
  312. if (this.$store.getters.userInfo.tenant_id === "888390") {
  313. this.feeOption.column.forEach(item => {
  314. if (item.prop === "billNo") {
  315. item.hide = false;
  316. }
  317. });
  318. }
  319. this.getWorkDicts("currency").then(res => {
  320. this.currencyList = res.data.data;
  321. });
  322. this.getWorkDicts("unit").then(res => {
  323. this.unitList = res.data.data;
  324. });
  325. allCropList({
  326. corpType: getCustomerCode("KG")
  327. }).then(res => {
  328. this.corpList = res.data.data;
  329. });
  330. if (localStorage.getItem("roleName") == "贸易") {
  331. this.findObject(this.feeOption.column, "corpId").hide = true;
  332. this.findObject(this.feeOption.column, "corpId").showColumn = false;
  333. }
  334. },
  335. components: {
  336. cropDialog,
  337. ApplyPayment
  338. },
  339. watch: {
  340. disabled: function () {
  341. this.$refs.feeCrud.refreshTable();
  342. },
  343. orderFeesList(newVla, oldVal) {
  344. if (newVla !== oldVal) {
  345. this.allData = newVla;
  346. this.data_one = newVla.filter(item => item.feesType === 1); //应收
  347. this.data_two = newVla.filter(item => item.feesType === 2); //应付
  348. if (this.selectTab === 1) {
  349. this.feeData = this.data_one;
  350. } else {
  351. this.feeData = this.data_two;
  352. }
  353. }
  354. },
  355. activeName(newVla, oldVal) {
  356. if (newVla !== oldVal) {
  357. if (newVla === "first") {
  358. this.tab1 = true;
  359. this.tab2 = false;
  360. this.data_two = this.feeData;
  361. this.selectTab = 1;
  362. this.feeData = this.data_one;
  363. } else {
  364. this.tab1 = false;
  365. this.tab2 = true;
  366. this.data_one = this.feeData;
  367. this.selectTab = 2;
  368. this.feeData = this.data_two;
  369. }
  370. }
  371. }
  372. },
  373. methods: {
  374. async imporData(rows, type) {
  375. await this.tabs2()
  376. await this.allDel(type)
  377. rows.forEach(row => {
  378. this.$refs.feeCrud.rowCellAdd(row)
  379. })
  380. },
  381. async allDel(type) {
  382. this.feeData.forEach(e => {
  383. if (type == e.srcType) {
  384. if (e.id) {
  385. delItem(e.id, this.feeUrl)
  386. }
  387. }
  388. })
  389. let newData = this.feeData.filter(e => e.srcType != type)
  390. this.feeData = newData
  391. },
  392. async tabs2() {
  393. this.activeName = 'second'
  394. },
  395. invoiceShow(row) {
  396. getfeesDetails({ id: row.id }).then(res => {
  397. this.invoiceData = res.data.data
  398. })
  399. },
  400. invoiceHide() {
  401. this.invoiceData = []
  402. },
  403. //选择费用
  404. selectValue(value, row) {
  405. this.$set(row, "feeName", value.cname);
  406. this.$set(row, "ename", value.ename);
  407. if (this.optionType == "GN") {
  408. if (!row.currency) {
  409. getParities({
  410. currency: "CNY",
  411. businesDate: dateFormat(new Date(), "yyyy-MM-dd") + " 00:00:00"
  412. }).then(res => {
  413. const data = res.data.data;
  414. row.exchangeRate = data.receivableParities;
  415. });
  416. }
  417. } else {
  418. this.currencyChange(row);
  419. }
  420. },
  421. //选择应收应付
  422. // handleClick(tab){
  423. // if(tab.name === "first"){
  424. // this.tab1 = true;
  425. // this.tab2 = false;
  426. //
  427. // this.data_two = this.feeData
  428. //
  429. // this.selectTab = 1
  430. // this.feeData = this.data_one
  431. // }else{
  432. // this.tab1 = false;
  433. // this.tab2 = true;
  434. //
  435. // this.data_one = this.feeData
  436. //
  437. // this.selectTab = 2
  438. // this.feeData = this.data_two
  439. // }
  440. // },
  441. cellStyle() {
  442. return "padding:0;height:40px;";
  443. },
  444. importCorp(row) {
  445. this.feeData.push({
  446. itemId: null,
  447. corpId: row.id,
  448. corpName: row.name,
  449. ename: null,
  450. feeName: null,
  451. price: null,
  452. unit: null,
  453. quantity: null,
  454. amount: null,
  455. currency: "CNY",
  456. exchangeRate: 1,
  457. remarks: null,
  458. $cellEdit: true,
  459. feesType: this.selectTab
  460. });
  461. },
  462. //带出汇率
  463. currencyChange(row) {
  464. getParities({
  465. currency: row.currency,
  466. businesDate: dateFormat(new Date(), "yyyy-MM-dd") + " 00:00:00"
  467. }).then(res => {
  468. const data = res.data.data;
  469. row.exchangeRate = data.receivableParities;
  470. });
  471. },
  472. rowDel(row, index) {
  473. this.$confirm("确定删除数据?", {
  474. confirmButtonText: "确定",
  475. cancelButtonText: "取消",
  476. type: "warning"
  477. }).then(() => {
  478. //费用判断是否需要调用删除接口
  479. if (row.id) {
  480. if (this.delType == 1) {
  481. delItem(row.id, this.feeUrl).then(res => {
  482. this.$message({
  483. type: "success",
  484. message: "删除成功!"
  485. });
  486. this.feeData.splice(index, 1);
  487. });
  488. } else {
  489. let data = {
  490. srcParentId: row.id,
  491. billType: this.itemType,
  492. tradeType: this.optionType
  493. }
  494. delItem2(data, this.feeUrl).then(res => {
  495. this.$message({
  496. type: "success",
  497. message: "删除成功!"
  498. });
  499. this.feeData.splice(index, 1);
  500. });
  501. }
  502. } else {
  503. this.$message({
  504. type: "success",
  505. message: "删除成功!"
  506. });
  507. this.feeData.splice(index, 1);
  508. }
  509. });
  510. },
  511. getCorpData(row) {
  512. this.feeData[row.index].corpName = row.cname;
  513. },
  514. countChange(row) {
  515. if (row.price && row.quantity) {
  516. row.amount = _.multiply(row.quantity, row.price).toFixed(2);
  517. }
  518. },
  519. rateChange(row) {
  520. if (row.exchangeRate >= 100) {
  521. row.exchangeRate = 0;
  522. this.$message.error("汇率不能超过100%");
  523. }
  524. },
  525. currentChange(val) {
  526. this.page.currentPage = val;
  527. },
  528. sizeChange(val) {
  529. this.page.currentPage = 1;
  530. this.page.pageSize = val;
  531. },
  532. //刷新
  533. refreshChange() {
  534. this.page.currentPage = 1;
  535. this.onLoad(this.page);
  536. },
  537. //多选
  538. selectionChange(list) {
  539. this.selectionList = list;
  540. },
  541. rePick(row, index) {
  542. this.reData = {
  543. ...row,
  544. index: index
  545. };
  546. this.feeDialog = true;
  547. this.onLoad(this.page);
  548. },
  549. //费用编辑
  550. rowCell(row, index) {
  551. if (row.$cellEdit == true) {
  552. this.$set(row, "$cellEdit", false);
  553. } else {
  554. this.$set(row, "$cellEdit", true);
  555. }
  556. },
  557. //新增
  558. rowAdd() {
  559. if (this.inCropId) {
  560. let corpName = ''
  561. if (this.corpId) {
  562. corpName = this.corpList.find(item => this.corpId == item.id).cname;
  563. }
  564. const params = {
  565. feesType: this.selectTab,
  566. corpId: this.corpId ? this.corpId : '',
  567. corpName: this.corpId ? corpName : ''
  568. };
  569. if (this.typeName === "wood") params.corpId = this.corpId
  570. this.$refs.feeCrud.rowCellAdd(params);
  571. } else {
  572. if (!this.corpId) return this.$message.error("请选择往来单位");
  573. if (this.$store.getters.userInfo.tenant_id === "888390") {
  574. this.$emit("getBillNo");
  575. }
  576. let corpName = this.corpList.find(item => this.corpId == item.id).cname;
  577. const params = {
  578. feesType: this.selectTab,
  579. corpId: this.corpId,
  580. corpName: corpName
  581. };
  582. if (this.optionType == "GN") {
  583. getParities({
  584. currency: "CNY",
  585. businesDate: dateFormat(new Date(), "yyyy-MM-dd") + " 00:00:00"
  586. }).then(res => {
  587. const data = res.data.data;
  588. params.exchangeRate = data.receivableParities;
  589. this.$refs.feeCrud.rowCellAdd(params);
  590. });
  591. } else if (this.optionType == "JK") {
  592. getParities({
  593. currency: "USD",
  594. businesDate: dateFormat(new Date(), "yyyy-MM-dd") + " 00:00:00"
  595. }).then(res => {
  596. const data = res.data.data;
  597. params.exchangeRate = data.receivableParities;
  598. this.$refs.feeCrud.rowCellAdd(params);
  599. });
  600. }
  601. }
  602. },
  603. addRow() {
  604. this.rowAdd();
  605. },
  606. onLoad(page) {
  607. this.loading = true;
  608. let data = {
  609. size: page.pageSize,
  610. current: page.currentPage,
  611. parentId: 0,
  612. feesTypeId: this.treeDeptId
  613. };
  614. customerList(data).then(res => {
  615. const data = res.data.data;
  616. this.page.total = data.total;
  617. this.data = data.records;
  618. this.loading = false;
  619. if (this.page.total) {
  620. this.option.height = window.innerHeight - 350;
  621. }
  622. });
  623. },
  624. //导入页左费用类型查询
  625. nodeClick(data) {
  626. this.treeDeptId = data.id;
  627. this.page.currentPage = 1;
  628. this.onLoad(this.page);
  629. },
  630. feeClose() {
  631. this.selectionList = [];
  632. this.page = {
  633. pageSize: 10,
  634. currentPage: 1,
  635. total: 0
  636. };
  637. this.treeDeptId = null;
  638. this.loading = false;
  639. this.data = [];
  640. this.reData = null;
  641. },
  642. importData() {
  643. if (this.reData) {
  644. this.selectionList.length;
  645. if (this.selectionList.length != 1) {
  646. return this.$message.error("重新选择的时候只能选择一条数据");
  647. } else {
  648. this.selectionList.forEach(e => {
  649. this.feeData.forEach((item, index) => {
  650. if (index == this.reData.index) {
  651. item.itemId = e.id;
  652. item.corpId = this.reData.corpId;
  653. item.feeName = e.cname;
  654. item.price = this.reData.price;
  655. // item.unit = e.unitno;
  656. item.quantity = this.reData.quantity;
  657. item.amount = this.reData.amount;
  658. item.remarks = this.reData.remarks;
  659. item.$cellEdit = true;
  660. }
  661. });
  662. });
  663. }
  664. } else {
  665. this.selectionList.forEach(e => {
  666. this.feeData.push({
  667. itemId: e.id,
  668. corpId: null,
  669. feeName: e.cname,
  670. price: 0,
  671. // unit: e.unitno,
  672. quantity: 0,
  673. amount: 0,
  674. remarks: null,
  675. $cellEdit: true
  676. });
  677. });
  678. }
  679. this.feeDialog = false;
  680. },
  681. submitData() {
  682. let list = [];
  683. //保存时 将所出的tab页数据赋值到相应 data上
  684. if (this.selectTab === 1) {
  685. this.data_one = this.feeData;
  686. } else {
  687. this.data_two = this.feeData;
  688. }
  689. list.push(...this.data_one, ...this.data_two);
  690. return list;
  691. },
  692. billingDetails(type) {
  693. //查看是否改动过数据
  694. this.$emit("beforeFinance", this.submitData(), params => {
  695. if (params.valid) {
  696. for (let i = 0; i < this.selectionList.length; i++) {
  697. if (this.selectionList[i].corpId != this.selectionList[0].corpId) {
  698. return this.$message.error("批量操作结算单位必须一致");
  699. }
  700. if (this.selectionList[i].isCheck == 1) {
  701. return this.$message.error(
  702. "选中的数据已" + type + ",请勿重复操作!"
  703. );
  704. }
  705. }
  706. this.selectionList.map(item => {
  707. // item.url = this.billUrl
  708. item.srcOrderno = params.srcOrderno;
  709. item.srcParentId = params.parentId;
  710. item.corpsName = item.corpName;
  711. item.srcFeesId = item.id;
  712. item.costType = item.itemId;
  713. item.itemType = this.itemType;
  714. item.optionType = this.optionType;
  715. item.srcType = this.srcType; //费用明细申请
  716. item.tradeType = this.optionType;
  717. });
  718. let data = {
  719. billType: type,
  720. itemsList: this.selectionList
  721. };
  722. if (type === "申请") {
  723. this.$confirm("您确定申请付费吗?", "提示", {
  724. confirmButtonText: "确定",
  725. cancelButtonText: "取消",
  726. type: "warning"
  727. }).then(() => {
  728. this.buttonLoading = true;
  729. data.checkType = "ffsq";
  730. data.url = "/financialManagement/paymentRequest/index";
  731. data.pageStatus = "this.$store.getters.pqStatus";
  732. data.pageLabel = "付费申请";
  733. applyLoan(data)
  734. .then(res => {
  735. if (res.data.success) {
  736. this.$message.success("操作成功!");
  737. this.$emit("afterFinance");
  738. //跳转付费申请页面
  739. // if(this.$store.getters.pqStatus){
  740. // this.$alert("无法自动跳转,因为付费申请页面已存在!", "温馨提示", {
  741. // confirmButtonText: "确定",
  742. // type: 'warning',
  743. // callback: action => {
  744. // }
  745. // });
  746. // }else{
  747. // //关闭一下存在的列表页 跳转
  748. // this.$router.$avueRouter.closeTag('/financialManagement/paymentRequest/index');
  749. // this.$router.push({
  750. // path: "/financialManagement/paymentRequest/index",
  751. // query: {params: res.data.data.id},
  752. // });
  753. // }
  754. }
  755. })
  756. .finally(() => {
  757. this.buttonLoading = false;
  758. });
  759. });
  760. } else {
  761. this.$confirm("您确定生成账单吗?", "提示", {
  762. confirmButtonText: "确定",
  763. cancelButtonText: "取消",
  764. type: "warning"
  765. }).then(() => {
  766. this.buttonLoading = true;
  767. paymentApply(data)
  768. .then(res => {
  769. if (res.data.success) {
  770. this.$message.success("操作成功!");
  771. this.$emit("afterFinance");
  772. }
  773. })
  774. .finally(() => {
  775. this.buttonLoading = false;
  776. });
  777. });
  778. }
  779. }
  780. });
  781. },
  782. summaryMethod({ columns, data }) {
  783. const sums = [];
  784. if (columns.length > 0) {
  785. columns.forEach((item, index) => {
  786. sums[0] = "合计";
  787. if (item.property == "quantity" || item.property == "amount") {
  788. let qtySum = 0;
  789. let amountSum = 0;
  790. data.forEach(e => {
  791. qtySum = _.add(qtySum, Number(e.quantity));
  792. amountSum = _.add(amountSum, Number(e.amount));
  793. });
  794. //数量总计
  795. if (item.property == "quantity") {
  796. sums[index] = qtySum ? qtySum.toFixed(6) : "0.00";
  797. }
  798. //金额总计
  799. if (item.property == "amount") {
  800. sums[index] = micrometerFormat(amountSum);
  801. }
  802. }
  803. });
  804. }
  805. return sums;
  806. },
  807. async saveColumn() {
  808. const inSave = await this.saveColumnData(this.getColumnName(33), this.feeOption);
  809. if (inSave) {
  810. this.$message.success("保存成功");
  811. //关闭窗口
  812. this.$refs.feeCrud.$refs.dialogColumn.columnBox = false;
  813. }
  814. },
  815. async resetColumn() {
  816. const inSave = await this.delColumnData(this.getColumnName(33), this.typeName === "wood" ? woodOption : feeOption);
  817. if (inSave) {
  818. this.$message.success("重置成功");
  819. this.feeOption = this.typeName === "wood" ? woodOption : feeOption;
  820. //关闭窗口
  821. this.$refs.feeCrud.$refs.dialogColumn.columnBox = false;
  822. }
  823. },
  824. tabHandle(data) {
  825. // if (data.name == this.enableName) return
  826. // this.enableName = data.name
  827. }
  828. }
  829. };
  830. </script>
  831. <style lang="scss" scoped>
  832. .required_fields {
  833. color: #f56c6c;
  834. display: inline-block;
  835. width: 7%;
  836. }
  837. </style>