main.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871
  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. corpIds:'',
  150. invoiceOption: {
  151. border: true,
  152. align: 'center',
  153. header: false,
  154. menu: false,
  155. column: [
  156. {
  157. label: '日期',
  158. prop: 'invoice_time'
  159. },
  160. {
  161. label: '金额',
  162. prop: 'amount'
  163. },
  164. ]
  165. },
  166. option: option,
  167. feeOption: {},
  168. feeDialog: false,
  169. buttonLoading: false,
  170. treeOption: {
  171. nodeKey: "id",
  172. lazy: true,
  173. treeLoad: function (node, resolve) {
  174. const parentId = node.level === 0 ? 0 : node.data.id;
  175. getDeptLazyTree(parentId).then(res => {
  176. resolve(
  177. res.data.data.map(item => {
  178. return {
  179. ...item,
  180. leaf: !item.hasChildren
  181. };
  182. })
  183. );
  184. });
  185. },
  186. addBtn: false,
  187. menu: false,
  188. size: "small",
  189. props: {
  190. labelText: "标题",
  191. label: "title",
  192. value: "value",
  193. children: "children"
  194. }
  195. },
  196. page: {
  197. pageSize: 10,
  198. currentPage: 1,
  199. total: 0
  200. },
  201. treeDeptId: null,
  202. loading: false,
  203. receivableButton: "primary",
  204. copeWithButton: "",
  205. data: [],
  206. feeData: [],
  207. selectionList: [],
  208. reData: null,
  209. currencyList: [],
  210. unitList: [],
  211. breakConfiguration: {
  212. multipleChoices: false,
  213. multiple: false,
  214. disabled: false,
  215. searchShow: true,
  216. collapseTags: false,
  217. clearable: true,
  218. placeholder: "请点击右边按钮选择",
  219. dicData: []
  220. },
  221. allData: [],
  222. data_one: [],
  223. data_two: [],
  224. selectTab: 1,
  225. enableName: "first",
  226. tab1: true,
  227. tab2: false,
  228. corpList: [],
  229. invoiceData: [],
  230. };
  231. },
  232. props: {
  233. orderFeesList: {
  234. type: Array
  235. },
  236. disabled: {
  237. type: Boolean
  238. },
  239. feeUrl: {
  240. type: String
  241. },
  242. typeName: {
  243. type: String
  244. },
  245. billUrl: {
  246. type: String
  247. },
  248. optionType: {
  249. type: String
  250. },
  251. itemType: {
  252. type: String
  253. },
  254. srcType: {
  255. type: Number,
  256. default: 2
  257. },
  258. corpId: {
  259. type: String
  260. },
  261. billNoList: {
  262. type: Array
  263. },
  264. financeDisabled: {
  265. type: Boolean,
  266. default: true
  267. },
  268. inCropId: {
  269. type: Boolean,
  270. default: false
  271. },
  272. // 1.显示全部 2.收费 3.付费
  273. tabShow: {
  274. type: Number,
  275. default: 1
  276. },
  277. activeName: {
  278. type: String,
  279. default: 'first'
  280. },
  281. // 1.贸易 2.泽兴
  282. delType: {
  283. type: Number,
  284. default: 1
  285. },
  286. isDecimal: {
  287. type: Boolean,
  288. default: false
  289. },
  290. billingShow: {
  291. type: Boolean,
  292. default: true
  293. },
  294. },
  295. filters: {
  296. isPercentage(val) {
  297. return isPercentage(val);
  298. },
  299. micrometerFormat(val) {
  300. return micrometerFormat(val);
  301. },
  302. decimalFormat(num) {
  303. return num ? Number(num).toFixed(6) : "0.00";
  304. },
  305. IntegerFormat(num) {
  306. return IntegerFormat(num);
  307. }
  308. },
  309. async created() {
  310. // 判断tabShow的activeName默认的显示
  311. this.activeName = this.tabShow == 1 ? "first" : this.tabShow == 2 ? "first" : "second";
  312. this.feeOption = await this.getColumnData(this.getColumnName(33), this.typeName === "wood" ? woodOption : feeOption);
  313. if (this.$store.getters.userInfo.tenant_id === "888390") {
  314. this.feeOption.column.forEach(item => {
  315. if (item.prop === "billNo") {
  316. item.hide = false;
  317. }
  318. });
  319. }
  320. this.getWorkDicts("currency").then(res => {
  321. this.currencyList = res.data.data;
  322. });
  323. this.getWorkDicts("unit").then(res => {
  324. this.unitList = res.data.data;
  325. });
  326. allCropList({
  327. corpType: getCustomerCode("KG")
  328. }).then(res => {
  329. this.corpList = res.data.data;
  330. });
  331. if (localStorage.getItem("roleName") == "贸易") {
  332. this.findObject(this.feeOption.column, "corpId").hide = true;
  333. this.findObject(this.feeOption.column, "corpId").showColumn = false;
  334. }
  335. },
  336. components: {
  337. cropDialog,
  338. ApplyPayment
  339. },
  340. watch: {
  341. disabled: function () {
  342. this.$refs.feeCrud.refreshTable();
  343. },
  344. orderFeesList(newVla, oldVal) {
  345. if (newVla !== oldVal) {
  346. this.allData = newVla;
  347. this.data_one = newVla.filter(item => item.feesType === 1); //应收
  348. this.data_two = newVla.filter(item => item.feesType === 2); //应付
  349. if (this.selectTab === 1) {
  350. this.feeData = this.data_one;
  351. } else {
  352. this.feeData = this.data_two;
  353. }
  354. }
  355. },
  356. activeName(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. invoiceShow(row) {
  397. getfeesDetails({ id: row.id }).then(res => {
  398. this.invoiceData = res.data.data
  399. })
  400. },
  401. invoiceHide() {
  402. this.invoiceData = []
  403. },
  404. //选择费用
  405. selectValue(value, row) {
  406. this.$set(row, "feeName", value.cname);
  407. this.$set(row, "ename", value.ename);
  408. if (this.optionType == "GN") {
  409. if (!row.currency) {
  410. getParities({
  411. currency: "CNY",
  412. businesDate: dateFormat(new Date(), "yyyy-MM-dd") + " 00:00:00"
  413. }).then(res => {
  414. const data = res.data.data;
  415. row.exchangeRate = data.receivableParities;
  416. });
  417. }
  418. } else {
  419. this.currencyChange(row);
  420. }
  421. },
  422. //选择应收应付
  423. // handleClick(tab){
  424. // if(tab.name === "first"){
  425. // this.tab1 = true;
  426. // this.tab2 = false;
  427. //
  428. // this.data_two = this.feeData
  429. //
  430. // this.selectTab = 1
  431. // this.feeData = this.data_one
  432. // }else{
  433. // this.tab1 = false;
  434. // this.tab2 = true;
  435. //
  436. // this.data_one = this.feeData
  437. //
  438. // this.selectTab = 2
  439. // this.feeData = this.data_two
  440. // }
  441. // },
  442. cellStyle() {
  443. return "padding:0;height:40px;";
  444. },
  445. importCorp(row) {
  446. this.feeData.push({
  447. itemId: null,
  448. corpId: row.id,
  449. corpName: row.name,
  450. ename: null,
  451. feeName: null,
  452. price: null,
  453. unit: null,
  454. quantity: null,
  455. amount: null,
  456. currency: "CNY",
  457. exchangeRate: 1,
  458. remarks: null,
  459. $cellEdit: true,
  460. feesType: this.selectTab
  461. });
  462. },
  463. //带出汇率
  464. currencyChange(row) {
  465. getParities({
  466. currency: row.currency,
  467. businesDate: dateFormat(new Date(), "yyyy-MM-dd") + " 00:00:00"
  468. }).then(res => {
  469. const data = res.data.data;
  470. row.exchangeRate = data.receivableParities;
  471. });
  472. },
  473. rowDel(row, index) {
  474. this.$confirm("确定删除数据?", {
  475. confirmButtonText: "确定",
  476. cancelButtonText: "取消",
  477. type: "warning"
  478. }).then(() => {
  479. //费用判断是否需要调用删除接口
  480. if (row.id) {
  481. if (this.delType == 1) {
  482. delItem(row.id, this.feeUrl).then(res => {
  483. this.$message({
  484. type: "success",
  485. message: "删除成功!"
  486. });
  487. this.feeData.splice(index, 1);
  488. });
  489. } else {
  490. let data = {
  491. srcParentId: row.id,
  492. billType: this.itemType,
  493. tradeType: this.optionType
  494. }
  495. delItem2(data, this.feeUrl).then(res => {
  496. this.$message({
  497. type: "success",
  498. message: "删除成功!"
  499. });
  500. this.feeData.splice(index, 1);
  501. });
  502. }
  503. } else {
  504. this.$message({
  505. type: "success",
  506. message: "删除成功!"
  507. });
  508. this.feeData.splice(index, 1);
  509. }
  510. });
  511. },
  512. getCorpData(row) {
  513. console.log(row);
  514. console.log(' this.feeData', this.feeData);
  515. this.feeData[row.index].corpName = row.cname;
  516. this.feeData[row.index].corpId = row.corpId;
  517. this.corpIds = row.id
  518. },
  519. countChange(row) {
  520. if (row.price && row.quantity) {
  521. row.amount = _.multiply(row.quantity, row.price).toFixed(2);
  522. }
  523. },
  524. rateChange(row) {
  525. if (row.exchangeRate >= 100) {
  526. row.exchangeRate = 0;
  527. this.$message.error("汇率不能超过100%");
  528. }
  529. },
  530. currentChange(val) {
  531. this.page.currentPage = val;
  532. },
  533. sizeChange(val) {
  534. this.page.currentPage = 1;
  535. this.page.pageSize = val;
  536. },
  537. //刷新
  538. refreshChange() {
  539. this.page.currentPage = 1;
  540. this.onLoad(this.page);
  541. },
  542. //多选
  543. selectionChange(list) {
  544. this.selectionList = list;
  545. },
  546. rePick(row, index) {
  547. this.reData = {
  548. ...row,
  549. index: index
  550. };
  551. this.feeDialog = true;
  552. this.onLoad(this.page);
  553. },
  554. //费用编辑
  555. rowCell(row, index) {
  556. if (row.$cellEdit == true) {
  557. this.$set(row, "$cellEdit", false);
  558. } else {
  559. this.$set(row, "$cellEdit", true);
  560. }
  561. },
  562. //新增
  563. rowAdd() {
  564. // console.log(this.$parent.$data.form.corpId);
  565. // console.log(this.corpList.find(item => this.$parent.$data.form.corpId == item.id).cname);
  566. if (this.inCropId) {
  567. let corpName = ''
  568. if (!this.corpId) {
  569. corpName = this.corpList.find(item => this.$parent.$data.form.corpId == item.id).cname;
  570. console.log('1',corpName);
  571. }
  572. if (this.corpId) {
  573. corpName = this.corpList.find(item => this.corpId == item.id).cname;
  574. console.log('2',corpName);
  575. }
  576. const params = {
  577. feesType: this.selectTab,
  578. corpId: this.corpId ? this.corpId : this.$parent.$data.form.corpId,
  579. // corpId: this.corpId ? this.corpId : '',
  580. corpName: this.corpId ? corpName : '',
  581. quantity:"1.000000",
  582. currency:this.$parent.$data.form.currency,
  583. exchangeRate:this.$parent.$data.form.exchangeRate
  584. };
  585. if (this.typeName === "wood") params.corpId = this.corpId
  586. this.$refs.feeCrud.rowCellAdd(params);
  587. } else {
  588. if (!this.corpId) return this.$message.error("请选择往来单位");
  589. if (this.$store.getters.userInfo.tenant_id === "888390") {
  590. this.$emit("getBillNo");
  591. }
  592. let corpName = this.corpList.find(item => this.corpId == item.id).cname;
  593. const params = {
  594. feesType: this.selectTab,
  595. corpId: this.corpId,
  596. corpName: corpName
  597. };
  598. if (this.optionType == "GN") {
  599. getParities({
  600. currency: "CNY",
  601. businesDate: dateFormat(new Date(), "yyyy-MM-dd") + " 00:00:00"
  602. }).then(res => {
  603. const data = res.data.data;
  604. params.exchangeRate = data.receivableParities;
  605. this.$refs.feeCrud.rowCellAdd(params);
  606. });
  607. } else if (this.optionType == "JK") {
  608. getParities({
  609. currency: "USD",
  610. businesDate: dateFormat(new Date(), "yyyy-MM-dd") + " 00:00:00"
  611. }).then(res => {
  612. const data = res.data.data;
  613. params.exchangeRate = data.receivableParities;
  614. this.$refs.feeCrud.rowCellAdd(params);
  615. });
  616. }
  617. }
  618. },
  619. addRow() {
  620. this.rowAdd();
  621. },
  622. onLoad(page) {
  623. this.loading = true;
  624. let data = {
  625. size: page.pageSize,
  626. current: page.currentPage,
  627. parentId: 0,
  628. feesTypeId: this.treeDeptId
  629. };
  630. customerList(data).then(res => {
  631. const data = res.data.data;
  632. this.page.total = data.total;
  633. this.data = data.records;
  634. this.loading = false;
  635. if (this.page.total) {
  636. this.option.height = window.innerHeight - 350;
  637. }
  638. });
  639. },
  640. //导入页左费用类型查询
  641. nodeClick(data) {
  642. this.treeDeptId = data.id;
  643. this.page.currentPage = 1;
  644. this.onLoad(this.page);
  645. },
  646. feeClose() {
  647. this.selectionList = [];
  648. this.page = {
  649. pageSize: 10,
  650. currentPage: 1,
  651. total: 0
  652. };
  653. this.treeDeptId = null;
  654. this.loading = false;
  655. this.data = [];
  656. this.reData = null;
  657. },
  658. importData() {
  659. console.log(123213);
  660. if (this.reData) {
  661. this.selectionList.length;
  662. if (this.selectionList.length != 1) {
  663. return this.$message.error("重新选择的时候只能选择一条数据");
  664. } else {
  665. this.selectionList.forEach(e => {
  666. this.feeData.forEach((item, index) => {
  667. if (index == this.reData.index) {
  668. item.itemId = e.id;
  669. item.corpId = this.reData.corpId;
  670. item.feeName = e.cname;
  671. item.price = this.reData.price;
  672. // item.unit = e.unitno;
  673. item.quantity = this.reData.quantity;
  674. item.amount = this.reData.amount;
  675. item.remarks = this.reData.remarks;
  676. item.$cellEdit = true;
  677. }
  678. });
  679. });
  680. }
  681. } else {
  682. this.selectionList.forEach(e => {
  683. this.feeData.push({
  684. itemId: e.id,
  685. corpId: null,
  686. feeName: e.cname,
  687. price: 0,
  688. // unit: e.unitno,
  689. quantity: 0,
  690. amount: 0,
  691. remarks: null,
  692. $cellEdit: true
  693. });
  694. });
  695. }
  696. this.feeDialog = false;
  697. },
  698. submitData() {
  699. let list = [];
  700. //保存时 将所出的tab页数据赋值到相应 data上
  701. if (this.selectTab === 1) {
  702. this.data_one = this.feeData;
  703. } else {
  704. this.data_two = this.feeData;
  705. }
  706. list.push(...this.data_one, ...this.data_two);
  707. console.log(list);
  708. console.log(this.feeData);
  709. return list;
  710. },
  711. billingDetails(type) {
  712. //查看是否改动过数据
  713. this.$emit("beforeFinance", this.submitData(), params => {
  714. if (params.valid) {
  715. for (let i = 0; i < this.selectionList.length; i++) {
  716. if (this.selectionList[i].corpId != this.selectionList[0].corpId) {
  717. return this.$message.error("批量操作结算单位必须一致");
  718. }
  719. if (this.selectionList[i].isCheck == 1) {
  720. return this.$message.error(
  721. "选中的数据已" + type + ",请勿重复操作!"
  722. );
  723. }
  724. }
  725. this.selectionList.map(item => {
  726. // item.url = this.billUrl
  727. item.srcOrderno = params.srcOrderno;
  728. item.srcParentId = params.parentId;
  729. item.corpsName = item.corpName;
  730. item.srcFeesId = item.id;
  731. item.costType = item.itemId;
  732. item.itemType = this.itemType;
  733. item.optionType = this.optionType;
  734. item.srcType = this.srcType; //费用明细申请
  735. item.tradeType = this.optionType;
  736. });
  737. let data = {
  738. billType: type,
  739. itemsList: this.selectionList
  740. };
  741. if (type === "申请") {
  742. this.$confirm("您确定申请付费吗?", "提示", {
  743. confirmButtonText: "确定",
  744. cancelButtonText: "取消",
  745. type: "warning"
  746. }).then(() => {
  747. this.buttonLoading = true;
  748. data.checkType = "ffsq";
  749. data.url = "/financialManagement/paymentRequest/index";
  750. data.pageStatus = "this.$store.getters.pqStatus";
  751. data.pageLabel = "付费申请";
  752. applyLoan(data)
  753. .then(res => {
  754. if (res.data.success) {
  755. this.$message.success("操作成功!");
  756. this.$emit("afterFinance");
  757. //跳转付费申请页面
  758. // if(this.$store.getters.pqStatus){
  759. // this.$alert("无法自动跳转,因为付费申请页面已存在!", "温馨提示", {
  760. // confirmButtonText: "确定",
  761. // type: 'warning',
  762. // callback: action => {
  763. // }
  764. // });
  765. // }else{
  766. // //关闭一下存在的列表页 跳转
  767. // this.$router.$avueRouter.closeTag('/financialManagement/paymentRequest/index');
  768. // this.$router.push({
  769. // path: "/financialManagement/paymentRequest/index",
  770. // query: {params: res.data.data.id},
  771. // });
  772. // }
  773. }
  774. })
  775. .finally(() => {
  776. this.buttonLoading = false;
  777. });
  778. });
  779. } else {
  780. this.$confirm("您确定生成账单吗?", "提示", {
  781. confirmButtonText: "确定",
  782. cancelButtonText: "取消",
  783. type: "warning"
  784. }).then(() => {
  785. this.buttonLoading = true;
  786. paymentApply(data)
  787. .then(res => {
  788. if (res.data.success) {
  789. this.$message.success("操作成功!");
  790. this.$emit("afterFinance");
  791. }
  792. })
  793. .finally(() => {
  794. this.buttonLoading = false;
  795. });
  796. });
  797. }
  798. }
  799. });
  800. },
  801. summaryMethod({ columns, data }) {
  802. const sums = [];
  803. if (columns.length > 0) {
  804. columns.forEach((item, index) => {
  805. sums[0] = "合计";
  806. if (item.property == "quantity" || item.property == "amount") {
  807. let qtySum = 0;
  808. let amountSum = 0;
  809. data.forEach(e => {
  810. qtySum = _.add(qtySum, Number(e.quantity));
  811. amountSum = _.add(amountSum, Number(e.amount));
  812. });
  813. //数量总计
  814. if (item.property == "quantity") {
  815. sums[index] = qtySum ? qtySum.toFixed(6) : "0.00";
  816. }
  817. //金额总计
  818. if (item.property == "amount") {
  819. sums[index] = micrometerFormat(amountSum);
  820. }
  821. }
  822. });
  823. }
  824. return sums;
  825. },
  826. async saveColumn() {
  827. const inSave = await this.saveColumnData(this.getColumnName(33), this.feeOption);
  828. if (inSave) {
  829. this.$message.success("保存成功");
  830. //关闭窗口
  831. this.$refs.feeCrud.$refs.dialogColumn.columnBox = false;
  832. }
  833. },
  834. async resetColumn() {
  835. const inSave = await this.delColumnData(this.getColumnName(33), this.typeName === "wood" ? woodOption : feeOption);
  836. if (inSave) {
  837. this.$message.success("重置成功");
  838. this.feeOption = this.typeName === "wood" ? woodOption : feeOption;
  839. //关闭窗口
  840. this.$refs.feeCrud.$refs.dialogColumn.columnBox = false;
  841. }
  842. },
  843. tabHandle(data) {
  844. // if (data.name == this.enableName) return
  845. // this.enableName = data.name
  846. }
  847. }
  848. };
  849. </script>
  850. <style lang="scss" scoped>
  851. .required_fields {
  852. color: #f56c6c;
  853. display: inline-block;
  854. width: 7%;
  855. }
  856. </style>