main.vue 21 KB

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