main.vue 30 KB

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