main.vue 29 KB

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