main.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. <template>
  2. <div>
  3. <containerTitle title="费用明细"></containerTitle>
  4. <basic-container>
  5. <avue-crud
  6. ref="feeCrud"
  7. :data="feeData"
  8. :option="feeOption"
  9. @saveColumn="saveColumn"
  10. @selection-change="selectionChange"
  11. :summary-method="summaryMethod"
  12. :cell-style="cellStyle"
  13. >
  14. <template slot="menuLeft">
  15. <el-tabs v-model="activeName" @tab-click="handleClick">
  16. <el-tab-pane label="应收" name="first" :key="'first'">
  17. </el-tab-pane>
  18. <el-tab-pane label="应付" name="second" :key="'second'">
  19. </el-tab-pane>
  20. </el-tabs>
  21. <el-button
  22. type="primary"
  23. icon="el-icon-plus"
  24. size="small"
  25. @click.stop="rowAdd"
  26. :loading="buttonLoading"
  27. :disabled="disabled"
  28. >录入明细</el-button
  29. >
  30. <el-button
  31. type="warning"
  32. size="small"
  33. @click.stop="billingDetails('收费')"
  34. :loading="buttonLoading"
  35. :disabled="disabled || selectionList.length == 0"
  36. v-if="selectTab === 1"
  37. >生成账单</el-button>
  38. <!-- <el-button
  39. type="info"
  40. size="small"
  41. @click.stop="rowAdd"
  42. :disabled="disabled || selectionList.length == 0"
  43. v-if="selectTab === 1"
  44. >查看生成记录</el-button>-->
  45. <el-button
  46. type="warning"
  47. size="small"
  48. @click.stop="billingDetails('申请')"
  49. :loading="buttonLoading"
  50. :disabled="disabled || selectionList.length == 0"
  51. v-if="selectTab === 2"
  52. >申请付费</el-button>
  53. <!-- <el-button
  54. type="info"
  55. size="small"
  56. @click.stop="rowAdd"
  57. :disabled="disabled || selectionList.length == 0"
  58. v-if="selectTab === 2"
  59. >查看申请记录</el-button>-->
  60. </template>
  61. <template slot="menu" slot-scope="{ row, index }">
  62. <el-button
  63. size="small"
  64. icon="el-icon-edit"
  65. type="text"
  66. @click="rowCell(row, index)"
  67. :disabled="disabled"
  68. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button
  69. >
  70. <el-button
  71. size="small"
  72. icon="el-icon-delete"
  73. type="text"
  74. @click="rowDel(row, index)"
  75. :disabled="disabled"
  76. >删 除</el-button
  77. >
  78. </template>
  79. <template slot="corpId" slot-scope="{ row, index }">
  80. <span v-if="row.$cellEdit" class="required_fields">*</span>
  81. <crop-select
  82. style="width: 90% !important;display: inline-block"
  83. v-if="row.$cellEdit"
  84. v-model="row.corpId"
  85. :cropIndex="index"
  86. @getCorpData="getCorpData"
  87. corpType="KH"
  88. ></crop-select>
  89. <span v-else>{{ row.corpName }}</span>
  90. </template>
  91. <template slot="feeName" slot-scope="{ row, index }">
  92. <span v-if="row.$cellEdit" class="required_fields">*</span>
  93. <breakdown-select
  94. style="width: 90% !important;"
  95. v-if="row.$cellEdit"
  96. v-model="row.itemId"
  97. @selectValue="(value) => selectValue(value,row)"
  98. :configuration="breakConfiguration"
  99. >
  100. </breakdown-select>
  101. <span v-else>{{ row.feeName }}</span>
  102. </template>
  103. <template slot="price" slot-scope="{ row }">
  104. <el-input
  105. v-if="row.$cellEdit"
  106. v-model="row.price"
  107. size="small"
  108. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  109. @input="countChange(row)"
  110. ></el-input>
  111. <span v-else>{{ row.price | micrometerFormat }}</span>
  112. </template>
  113. <template slot="quantity" slot-scope="{ row }">
  114. <el-input
  115. v-if="row.$cellEdit"
  116. v-model="row.quantity"
  117. size="small"
  118. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  119. @input="countChange(row)"
  120. ></el-input>
  121. <span v-else>{{ row.quantity }}</span>
  122. </template>
  123. <template slot="amount" slot-scope="{ row }">
  124. <span>{{ row.amount | micrometerFormat }}</span>
  125. </template>
  126. <template slot="exchangeRate" slot-scope="{ row }">
  127. <el-input
  128. v-if="row.$cellEdit"
  129. v-model="row.exchangeRate"
  130. size="small"
  131. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  132. @change="rateChange(row)"
  133. placeholder="请输入"
  134. ></el-input>
  135. <span v-else>{{ row.exchangeRate }}</span>
  136. </template>
  137. <template slot="currency" slot-scope="{ row }">
  138. <el-select
  139. v-if="row.$cellEdit"
  140. v-model="row.currency"
  141. filterable
  142. allow-create
  143. default-first-option
  144. placeholder="请输入"
  145. size="small"
  146. @change="currencyChange(row)"
  147. >
  148. <el-option
  149. v-for="(item, index) in currencyList"
  150. :key="index"
  151. :label="item.dictValue"
  152. :value="item.dictValue"
  153. >
  154. </el-option>
  155. </el-select>
  156. <span v-else>{{ row.currency }}</span>
  157. </template>
  158. <template slot="unit" slot-scope="{ row }">
  159. <el-select
  160. v-if="row.$cellEdit"
  161. v-model="row.unit"
  162. filterable
  163. placeholder="请输入"
  164. size="small"
  165. >
  166. <el-option
  167. v-for="(item, index) in unitList"
  168. :key="index"
  169. :label="item.dictValue"
  170. :value="item.dictValue"
  171. >
  172. </el-option>
  173. </el-select>
  174. <span v-else>{{ row.unit }}</span>
  175. </template>
  176. </avue-crud>
  177. </basic-container>
  178. <el-dialog
  179. title="导入费用"
  180. append-to-body
  181. :visible.sync="feeDialog"
  182. top="5vh"
  183. width="60%"
  184. :close-on-click-modal="false"
  185. @closed="feeClose"
  186. class="el-dialogDeep"
  187. v-dialog-drag
  188. >
  189. <el-row style="height: 0;">
  190. <el-col :span="5">
  191. <div style="margin-top:45px">
  192. <el-scrollbar>
  193. <basic-container>
  194. <avue-tree
  195. :option="treeOption"
  196. :data="treeData"
  197. @node-click="nodeClick"
  198. />
  199. </basic-container>
  200. </el-scrollbar>
  201. </div>
  202. </el-col>
  203. <el-col :span="19">
  204. <avue-crud
  205. :option="option"
  206. :table-loading="loading"
  207. :data="data"
  208. ref="crud"
  209. @refresh-change="refreshChange"
  210. @selection-change="selectionChange"
  211. @current-change="currentChange"
  212. @size-change="sizeChange"
  213. :page.sync="page"
  214. @on-load="onLoad"
  215. :cell-style="cellStyle"
  216. >
  217. </avue-crud>
  218. </el-col>
  219. </el-row>
  220. <span slot="footer" class="dialog-footer">
  221. <el-button @click="feeDialog = false">取 消</el-button>
  222. <el-button
  223. type="primary"
  224. @click="importData"
  225. :disabled="this.selectionList.length == 0"
  226. >
  227. 导入
  228. </el-button>
  229. </span>
  230. </el-dialog>
  231. <crop-dialog ref="cropDialog" @importCorp="importCorp"></crop-dialog>
  232. </div>
  233. </template>
  234. <script>
  235. import feeOption from "./config/feeInfo.json";
  236. import option from "./config/feeList.json";
  237. import { getDeptLazyTree, customerList } from "@/api/basicData/basicFeesDesc";
  238. import { delItem } from "@/api/feeInfo/fee-info";
  239. import { isPercentage, micrometerFormat } from "@/util/validate";
  240. // import customerDialog from "@/components/customer-dialog/main";
  241. import cropDialog from "@/components/crop-dialog/main";
  242. import _ from "lodash";
  243. import ApplyPayment from "../finance/applyPayment";
  244. import {applyLoan,paymentApply} from "@/api/financialManagement/paymentRequest";
  245. export default {
  246. name: "feeInfo",
  247. data() {
  248. return {
  249. option: option,
  250. feeOption: {},
  251. feeDialog: false,
  252. buttonLoading:false,
  253. treeOption: {
  254. nodeKey: "id",
  255. lazy: true,
  256. treeLoad: function(node, resolve) {
  257. const parentId = node.level === 0 ? 0 : node.data.id;
  258. getDeptLazyTree(parentId).then(res => {
  259. resolve(
  260. res.data.data.map(item => {
  261. return {
  262. ...item,
  263. leaf: !item.hasChildren
  264. };
  265. })
  266. );
  267. });
  268. },
  269. addBtn: false,
  270. menu: false,
  271. size: "small",
  272. props: {
  273. labelText: "标题",
  274. label: "title",
  275. value: "value",
  276. children: "children"
  277. }
  278. },
  279. page: {
  280. pageSize: 10,
  281. currentPage: 1,
  282. total: 0
  283. },
  284. treeDeptId: null,
  285. loading: false,
  286. receivableButton: "primary",
  287. copeWithButton: "",
  288. data: [],
  289. feeData: [],
  290. selectionList: [],
  291. reData: null,
  292. currencyList: [],
  293. unitList:[],
  294. breakConfiguration:{
  295. multipleChoices:false,
  296. multiple:false,
  297. disabled:false,
  298. searchShow:true,
  299. collapseTags:false,
  300. clearable:true,
  301. placeholder:'请点击右边按钮选择',
  302. dicData:[]
  303. },
  304. isUpdata:true,//是否需要触发监听
  305. allData:[],
  306. data_one:[],
  307. data_two:[],
  308. selectTab:1,
  309. activeName:"first",
  310. tab1:true,
  311. tab2:false,
  312. };
  313. },
  314. props: {
  315. orderFeesList: {
  316. type: Array
  317. },
  318. disabled: {
  319. type: Boolean
  320. },
  321. feeUrl: {
  322. type: String
  323. },
  324. billUrl: {
  325. type: String
  326. },
  327. optionType:{
  328. type: String
  329. },
  330. itemType: {
  331. type: String
  332. }
  333. },
  334. filters: {
  335. isPercentage(val) {
  336. return isPercentage(val);
  337. },
  338. micrometerFormat(val) {
  339. return micrometerFormat(val);
  340. }
  341. },
  342. async created() {
  343. this.feeOption = await this.getColumnData(
  344. this.getColumnName(33),
  345. feeOption
  346. );
  347. this.getWorkDicts("currency").then(res => {
  348. this.currencyList = res.data.data;
  349. });
  350. this.getWorkDicts("unit").then(res =>{
  351. this.unitList = res.data.data
  352. })
  353. },
  354. components: {
  355. cropDialog,
  356. ApplyPayment
  357. },
  358. methods: {
  359. //选择费用
  360. selectValue(value,row){
  361. this.$set(row,"feeName",value.cname)
  362. this.currencyChange(row)
  363. },
  364. //选择应收应付
  365. handleClick(tab){
  366. if(tab.name == "first") {
  367. this.tab1 = true;
  368. this.tab2 = false;
  369. //将上一个tab页数据放到 对应data上
  370. this.data_two = this.feeData
  371. this.selectTab = 1
  372. this.feeData = this.data_one //切换数据
  373. // this.selectionList = [];
  374. } else if(tab.name == "second") {
  375. this.tab1 = false;
  376. this.tab2 = true;
  377. if(this.selectTab === 1){
  378. this.data_one = this.feeData
  379. }
  380. this.selectTab = 2
  381. this.feeData = this.data_two
  382. // this.selectionList = [];
  383. }
  384. },
  385. cellStyle() {
  386. return "padding:0;height:40px;";
  387. },
  388. importCorp(row) {
  389. this.feeData.push({
  390. itemId: null,
  391. corpId: row.id,
  392. corpName: row.name,
  393. feeName: null,
  394. price: null,
  395. unit: null,
  396. quantity: null,
  397. amount: null,
  398. currency:'CNY',
  399. exchangeRate: 1,
  400. remarks: null,
  401. $cellEdit: true,
  402. feesType:this.selectTab
  403. });
  404. },
  405. //带出汇率
  406. currencyChange(row){
  407. this.currencyList.forEach(item =>{
  408. if(item.dictValue === row.currency){
  409. this.$set(row,"exchangeRate",item.remark)
  410. }
  411. })
  412. },
  413. rowDel(row, index) {
  414. this.$confirm("确定删除数据?", {
  415. confirmButtonText: "确定",
  416. cancelButtonText: "取消",
  417. type: "warning"
  418. }).then(() => {
  419. //费用判断是否需要调用删除接口
  420. if (row.id) {
  421. delItem(row.id, this.feeUrl).then(res => {
  422. this.$message({
  423. type: "success",
  424. message: "删除成功!"
  425. });
  426. this.feeData.splice(index, 1);
  427. });
  428. } else {
  429. this.$message({
  430. type: "success",
  431. message: "删除成功!"
  432. });
  433. this.feeData.splice(index, 1);
  434. }
  435. });
  436. },
  437. getCorpData(row) {
  438. this.feeData[row.index].corpName = row.cname;
  439. },
  440. countChange(row) {
  441. if (row.price && row.quantity) {
  442. row.amount = _.multiply(row.quantity, row.price).toFixed(2);
  443. }
  444. },
  445. rateChange(row) {
  446. if (row.exchangeRate >= 100) {
  447. row.exchangeRate = 0;
  448. this.$message.error("汇率不能超过100%");
  449. }
  450. },
  451. currentChange(val) {
  452. this.page.currentPage = val;
  453. },
  454. sizeChange(val) {
  455. this.page.currentPage = 1;
  456. this.page.pageSize = val;
  457. },
  458. //刷新
  459. refreshChange() {
  460. this.page.currentPage = 1;
  461. this.onLoad(this.page);
  462. },
  463. //多选
  464. selectionChange(list) {
  465. this.selectionList = list;
  466. },
  467. rePick(row, index) {
  468. this.reData = {
  469. ...row,
  470. index: index
  471. };
  472. this.feeDialog = true;
  473. this.onLoad(this.page);
  474. },
  475. //费用编辑
  476. rowCell(row, index) {
  477. if (row.$cellEdit == true) {
  478. this.$set(row, "$cellEdit", false);
  479. } else {
  480. this.$set(row, "$cellEdit", true);
  481. }
  482. },
  483. //新增
  484. rowAdd() {
  485. this.$refs.cropDialog.init();
  486. },
  487. onLoad(page) {
  488. this.loading = true;
  489. let data = {
  490. size: page.pageSize,
  491. current: page.currentPage,
  492. parentId: 0,
  493. feesTypeId: this.treeDeptId
  494. };
  495. customerList(data).then(res => {
  496. const data = res.data.data;
  497. this.page.total = data.total;
  498. this.data = data.records;
  499. this.loading = false;
  500. if (this.page.total) {
  501. this.option.height = window.innerHeight - 350;
  502. }
  503. });
  504. },
  505. //导入页左费用类型查询
  506. nodeClick(data) {
  507. this.treeDeptId = data.id;
  508. this.page.currentPage = 1;
  509. this.onLoad(this.page);
  510. },
  511. feeClose() {
  512. this.selectionList = [];
  513. this.page = {
  514. pageSize: 10,
  515. currentPage: 1,
  516. total: 0
  517. };
  518. this.treeDeptId = null;
  519. this.loading = false;
  520. this.data = [];
  521. this.reData = null;
  522. },
  523. importData() {
  524. if (this.reData) {
  525. this.selectionList.length;
  526. if (this.selectionList.length != 1) {
  527. return this.$message.error("重新选择的时候只能选择一条数据");
  528. } else {
  529. this.selectionList.forEach(e => {
  530. this.feeData.forEach((item, index) => {
  531. if (index == this.reData.index) {
  532. item.itemId = e.id;
  533. item.corpId = this.reData.corpId;
  534. item.feeName = e.cname;
  535. item.price = this.reData.price;
  536. // item.unit = e.unitno;
  537. item.quantity = this.reData.quantity;
  538. item.amount = this.reData.amount;
  539. item.remarks = this.reData.remarks;
  540. item.$cellEdit = true;
  541. }
  542. });
  543. });
  544. }
  545. } else {
  546. this.selectionList.forEach(e => {
  547. this.feeData.push({
  548. itemId: e.id,
  549. corpId: null,
  550. feeName: e.cname,
  551. price: 0,
  552. // unit: e.unitno,
  553. quantity: 0,
  554. amount: 0,
  555. remarks: null,
  556. $cellEdit: true,
  557. });
  558. });
  559. }
  560. this.feeDialog = false;
  561. },
  562. submitData() {
  563. this.allData = []
  564. //保存时 将所出的tab页数据赋值到相应 data上
  565. if(this.selectTab == 1){
  566. this.data_one = this.feeData
  567. this.data_one.map(item =>{
  568. delete item.$cellEdit
  569. delete item.$index
  570. })
  571. }else{
  572. this.data_two = this.feeData
  573. this.data_two.map(item =>{
  574. delete item.$cellEdit
  575. delete item.$index
  576. })
  577. }
  578. this.allData.push(...this.data_one,...this.data_two)
  579. return this.allData;
  580. },
  581. billingDetails(type){
  582. //查看是否改动过数据
  583. this.$emit("beforeFinance",this.submitData(),(params)=>{
  584. if(params.valid){
  585. for(let i=0;i<this.selectionList.length;i++){
  586. if(this.selectionList[i].corpId != this.selectionList[0].corpId){
  587. return this.$message.error('批量操作结算单位必须一致')
  588. }
  589. }
  590. this.isUpdata = false
  591. this.selectionList.map(item =>{
  592. // item.url = this.billUrl
  593. item.srcOrderno = params.srcOrderno
  594. item.srcParentId = params.parentId
  595. item.corpsName = item.corpName
  596. item.srcFeesId = item.id
  597. item.costType = item.itemId
  598. item.itemType = this.itemType
  599. item.optionType = this.optionType
  600. item.srcType = 2 //费用明细申请
  601. item.tradeType = this.optionType
  602. })
  603. let data = {
  604. billType: type,
  605. itemsList : this.selectionList,
  606. }
  607. if(type === '申请'){
  608. this.$confirm("您确定申请付费吗?", "提示", {
  609. confirmButtonText: "确定",
  610. cancelButtonText: "取消",
  611. type: "warning",
  612. }).then(()=>{
  613. this.buttonLoading = true
  614. applyLoan(data).then(res=>{
  615. if(res.data.success){
  616. this.$message.success("操作成功!")
  617. }
  618. }).finally(()=>{
  619. this.isUpdata = true
  620. this.buttonLoading = false
  621. })
  622. })
  623. }else{
  624. this.$confirm("您确定生成账单吗?", "提示", {
  625. confirmButtonText: "确定",
  626. cancelButtonText: "取消",
  627. type: "warning",
  628. }).then(()=>{
  629. this.buttonLoading = true
  630. paymentApply(data).then(res=>{
  631. if(res.data.success){
  632. this.$message.success("操作成功!")
  633. }
  634. }).finally(()=>{
  635. this.isUpdata = true
  636. this.buttonLoading = false
  637. })
  638. })
  639. }
  640. }
  641. })
  642. },
  643. summaryMethod({ columns, data }) {
  644. const sums = [];
  645. if (columns.length > 0) {
  646. columns.forEach((item, index) => {
  647. sums[0] = "合计";
  648. if (item.property == "quantity" || item.property == "amount") {
  649. let qtySum = 0;
  650. let amountSum = 0;
  651. data.forEach(e => {
  652. qtySum = _.add(qtySum, Number(e.quantity));
  653. amountSum = _.add(amountSum, Number(e.amount));
  654. });
  655. //数量总计
  656. if (item.property == "quantity") {
  657. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  658. }
  659. //金额总计
  660. if (item.property == "amount") {
  661. sums[index] = micrometerFormat(amountSum);
  662. }
  663. }
  664. });
  665. }
  666. return sums;
  667. },
  668. async saveColumn() {
  669. const inSave = await this.saveColumnData(
  670. this.getColumnName(33),
  671. this.feeOption
  672. );
  673. if (inSave) {
  674. this.$message.success("保存成功");
  675. //关闭窗口
  676. this.$refs.feeCrud.$refs.dialogColumn.columnBox = false;
  677. }
  678. }
  679. },
  680. watch: {
  681. orderFeesList: function(rows) {
  682. this.allData = rows ? rows : [];
  683. if(this.allData.length !=0){
  684. this.data_one=this.allData.filter(item=>item.feesType === 1) //应收
  685. this.data_two=this.allData.filter(item=>item.feesType === 2) //应付
  686. if(this.isUpdata){
  687. if(this.selectTab == 1){
  688. this.feeData = this.data_one
  689. }else{
  690. this.feeData = this.data_two
  691. }
  692. }
  693. }
  694. },
  695. }
  696. };
  697. </script>
  698. <style lang="scss" scoped>
  699. .required_fields{
  700. color: #F56C6C;
  701. display:inline-block;
  702. width: 7%
  703. }
  704. </style>