addFinanceRecord.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <template>
  2. <div class="app-container">
  3. <!-- 添加或修改融资记录对话框 -->
  4. <el-form ref="form" :label-position="labelPosition" :model="form" :rules="rules" label-width="80px">
  5. <el-divider content-position="left">融资信息</el-divider>
  6. <el-row>
  7. <el-col :span="8">
  8. <el-form-item label="融信编号:" prop="zfrFinanceId">
  9. <el-select v-model="form.zfrFinanceId" style="width : 284px" clearable @clear="clearBoth">
  10. <el-option
  11. v-for="(item,index) in financeInfList"
  12. :key="index"
  13. :label="item.zfiNumber"
  14. :value="item.zfiId"
  15. @click.native="amount(item)"
  16. ></el-option>
  17. </el-select>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :span="8">
  21. <el-form-item label="融资金额:" prop="zfrAmount">
  22. <el-input v-model="form.zfrAmount" placeholder="请输入融资金额" style="width: 284px;" readonly>
  23. <template slot="append">元</template>
  24. </el-input>
  25. </el-form-item>
  26. </el-col>
  27. <el-col :span="8">
  28. <el-form-item label="融资账户:" prop="zfrCollectionAccount">
  29. <el-input v-model="form.zfrCollectionAccount" clearable placeholder="请输入融资账户" style="width: 284px;" maxlength="25" :readonly="readonly"/>
  30. </el-form-item>
  31. </el-col>
  32. </el-row>
  33. <el-row>
  34. <el-col :span="8">
  35. <el-form-item label="承诺还款日" prop="zfrRepaymentDate" v-if="false">
  36. <el-input v-model="form.zfrRepaymentDate" clearable placeholder="请输入承诺还款日" style="width: 284px;"/>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="8">
  40. <el-form-item label="融资利率" prop="zfrRate" v-if="false">
  41. <el-input v-model="form.zfrRate" clearable placeholder="请输入融资利率" style="width: 284px;"/>
  42. </el-form-item>
  43. </el-col>
  44. <el-col :span="8">
  45. <el-form-item label="融资放款方式" prop="zfpcrLoanType" label-width="90px" v-if="false">
  46. <el-input v-model="form.zfpcrLoanType" clearable placeholder="请输入融资账户" style="width: 284px;"/>
  47. </el-form-item>
  48. </el-col>
  49. </el-row>
  50. <el-row>
  51. <el-col :span="8">
  52. <el-form-item label="融资产品" prop="zfiProductId" v-if="false">
  53. <el-input v-model="form.zfiProductId" clearable placeholder="请输入融资产品" style="width: 284px;"/>
  54. </el-form-item>
  55. </el-col>
  56. <el-col :span="8">
  57. <el-form-item label="平台服务费收取费率" prop="zfpcrChargeRate" v-if="false">
  58. <el-input v-model="form.zfpcrChargeRate" clearable placeholder="请输入平台服务费收取费率" style="width: 284px;"/>
  59. </el-form-item>
  60. </el-col>
  61. </el-row>
  62. </el-form>
  63. <el-divider content-position="left">应收账款</el-divider>
  64. <span style="float: right; margin-right: 125px;">金额大写:{{ smallToBig(allAmount()) }}</span>
  65. <span style="float: right; margin-right: 125px;">消费金额:{{ allAmount() }} 元</span>
  66. <el-table :data="billInfList" >
  67. <el-table-column label="序号" type="index" width="50" align="center">
  68. <template slot-scope="scope">
  69. <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="编号" align="center" prop="zbiNumber" />
  73. <el-table-column label="账款名称" align="center" prop="zbiName" />
  74. <el-table-column label="应收企业" align="center" prop="payee" />
  75. <el-table-column label="应付企业" align="center" prop="payer" />
  76. <el-table-column label="还款时间" align="center" prop="zbiPayDate" />
  77. <el-table-column label="金额" align="center" prop="zbiAmount" />
  78. </el-table>
  79. <!-- 发票附件 -->
  80. <el-divider content-position="left">发票附件</el-divider>
  81. <el-table :data="invoiceFileList" border style="width: 100%">
  82. <el-table-column label="文件名称" align="center" prop="pfiFileName" show-overflow-tooltip />
  83. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width='300' fixed="right" >
  84. <template slot-scope="scope">
  85. <el-button
  86. size="mini"
  87. type="text"
  88. icon="el-icon-view"
  89. @click="handlePreview(scope.row)"
  90. >预览</el-button>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. <!-- 合同附件 -->
  95. <el-divider content-position="left">合同附件</el-divider>
  96. <el-table :data="contractFileList" border style="width: 100%">
  97. <el-table-column label="文件名称" align="center" prop="pfiFileName" show-overflow-tooltip />
  98. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width='300' fixed="right" >
  99. <template slot-scope="scope">
  100. <el-button
  101. size="mini"
  102. type="text"
  103. icon="el-icon-view"
  104. @click="handlePreview(scope.row)"
  105. >预览</el-button>
  106. </template>
  107. </el-table-column>
  108. </el-table>
  109. <!-- 其他附件 -->
  110. <el-divider content-position="left">其他附件</el-divider>
  111. <el-table :data="otherFileList" border style="width: 100%">
  112. <el-table-column label="文件名称" align="center" prop="pfiFileName" show-overflow-tooltip />
  113. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width='300' fixed="right" >
  114. <template slot-scope="scope">
  115. <el-button
  116. size="mini"
  117. type="text"
  118. icon="el-icon-view"
  119. @click="handlePreview(scope.row)"
  120. >预览</el-button>
  121. </template>
  122. </el-table-column>
  123. </el-table>
  124. <div slot="footer" class="dialog-footer">
  125. <el-button type="primary" @click="submitForm">确 定</el-button>
  126. <!-- <el-button @click="cancel">取 消</el-button> -->
  127. </div>
  128. <!--预览-->
  129. <el-dialog :visible.sync="openFile" width="1000px" append-to-body>
  130. <img :src="wordUrl" v-if="show" width='700px' height='500px'/>
  131. <iframe :src="wordUrl" width='800px' height='600px' frameborder='1' v-if="heid"/>
  132. </el-dialog>
  133. </div>
  134. </template>
  135. <script>
  136. import {addRecord,listBillInf,listAccInf} from "@/api/service/financeRecord/record";
  137. import { listFinanceInf } from "@/api/common/financeInf";
  138. import { getFile } from "@/api/service/credit/credit";
  139. import {getToken} from "@/utils/auth";
  140. export default {
  141. name: "financeRecord",
  142. components: {
  143. },
  144. data() {
  145. return {
  146. //融资账户是够编辑
  147. readonly:false,
  148. labelPosition: 'top',
  149. // 遮罩层
  150. loading: true,
  151. // 选中数组
  152. ids: [],
  153. // 非单个禁用
  154. single: true,
  155. // 非多个禁用
  156. multiple: true,
  157. // 显示搜索条件
  158. showSearch: true,
  159. // 总条数
  160. total: 0,
  161. // 全部融资记录表格数据
  162. recordList: [],
  163. //融信编号数据
  164. financeInfList: [],
  165. //应收账款
  166. billInfList: [],
  167. //合同附件
  168. contractFileList:[],
  169. //发票附件
  170. invoiceFileList:[],
  171. //其他文件
  172. otherFileList:[],
  173. // 弹出层标题
  174. title: "",
  175. // 是否显示弹出层
  176. open: false,
  177. // 查询参数
  178. queryParams: {
  179. pageNum: 1,
  180. pageSize: 10,
  181. zfrFinanceId: null,
  182. zfrNumber: null,
  183. zfrAmount: null,
  184. zfrRate: null,
  185. zfrHandler: null,
  186. zfrRepaymentDate: null,
  187. zfrApplyDate: null,
  188. zfrLoanDate: null,
  189. zfrApplyAmount: null,
  190. zfrApplyType: null,
  191. zfrStatus: null,
  192. zfrApproveStt: null,
  193. zfpcrLoanType: null,
  194. zfiProductId: null
  195. },
  196. // 表单参数
  197. form: {},
  198. // 表单校验
  199. rules: {
  200. zfrFinanceId: [
  201. { required: true, message: "融信编号不能为空", trigger: "blur" }
  202. ],
  203. zfrAmount: [
  204. { required: true, message: "融资金额不能为空", trigger: "blur" }
  205. ],
  206. },
  207. openFile:false,
  208. wordUrl: "",
  209. heid:false,
  210. show:false,
  211. };
  212. },
  213. created() {
  214. this.getFinanceInf();
  215. },
  216. methods: {
  217. /** 查询融信编号 */
  218. getFinanceInf(){
  219. this.loading = true;
  220. listFinanceInf().then(response => {
  221. this.financeInfList = response.data;
  222. this.loading = false;
  223. });
  224. },
  225. // 取消按钮
  226. cancel() {
  227. this.open = false;
  228. this.reset();
  229. },
  230. // 表单重置
  231. reset() {
  232. this.form = {
  233. zfrId: null,
  234. zfrFinanceId: null,
  235. zfrNumber: null,
  236. zfrAmount: null,
  237. zfrRate: null,
  238. zfrHandler: null,
  239. zfrRepaymentDate: null,
  240. zfrApplyDate: null,
  241. zfrLoanDate: null,
  242. zfrApplyAmount: null,
  243. zfrApplyType: null,
  244. zfrStatus: "00",
  245. zfrApproveStt: null,
  246. zfrProfitSpare1: null,
  247. zfrProfitSpare2: null,
  248. zfrProfitSpare3: null,
  249. zfrProfitSpare4: null,
  250. zfrProfitSpare5: null,
  251. zfrProfitSpare6: null,
  252. zfrProfitSpare7: null,
  253. zfrProfitSpare8: null,
  254. zfrProfitSpare9: null,
  255. createBy: null,
  256. createTime: null,
  257. updateBy: null,
  258. updateTime: null
  259. };
  260. this.resetForm("form");
  261. },
  262. /** 全部搜索按钮操作 */
  263. handleQuery() {
  264. this.queryParams.pageNum = 1;
  265. this.getList();
  266. },
  267. /** 全部重置按钮操作 */
  268. resetQuery() {
  269. this.resetForm("queryForm");
  270. this.handleQuery();
  271. },
  272. //全部 多选框选中数据
  273. handleSelectionChange(selection) {
  274. this.ids = selection.map(item => item.zfrId)
  275. this.single = selection.length!==1
  276. this.multiple = !selection.length
  277. },
  278. /* 融信编号赋值融资金额 */
  279. amount(item) {
  280. this.$set(this.form, "zfrAmount", item.zfiAmount);
  281. this.$set(this.form, "zfrRepaymentDate", item.zfiExpireDate);
  282. this.$set(this.form, "zfrRate", item.zfpcrRate);
  283. this.$set(this.form, "zfpcrLoanType", item.zfpcrLoanType);
  284. this.$set(this.form, "zfiProductId", item.zfiProductId);
  285. this.$set(this.form, "zfpcrChargeRate", item.zfpcrChargeRate);
  286. if(item.zfiId){
  287. this.loading = true;
  288. listBillInf(item.zfiId).then(response => {
  289. this.billInfList = response.data;
  290. this.loading = false;
  291. }).then(() =>{
  292. var queryParamsFile = {};
  293. queryParamsFile.ticketList = this.billInfList;
  294. getFile(queryParamsFile).then((response) => {
  295. if(response.data){
  296. //获取发票文件
  297. this.invoiceFileList = response.data.invoiceFileList;
  298. //获取合同文件
  299. this.contractFileList = response.data.contractFileList;
  300. //获取其他文件
  301. this.otherFileList = response.data.otherFileList;
  302. }
  303. });
  304. if(item.zfpcrLoanType == '0'){
  305. listAccInf(item.zfiProductId).then((response) => {
  306. this.$set(this.form, "zfrCollectionAccount", response.msg);
  307. this.readonly = true
  308. })
  309. }
  310. })
  311. }
  312. },
  313. /** 提交按钮 */
  314. submitForm() {
  315. this.$refs["form"].validate(valid => {
  316. if (valid) {
  317. const loading = this.$loading({
  318. lock: true,
  319. text: "Loading",
  320. spinner: "el-icon-loading",
  321. background: "rgba(0, 0, 0, 0.7)",
  322. });
  323. addRecord(this.form).then(response => {
  324. this.msgSuccess("融资申请成功");
  325. loading.close();
  326. this.$store.dispatch("tagsView/delView", this.$route);
  327. this.$router.go(-1);
  328. }).catch((response) => {
  329. loading.close();
  330. });
  331. }
  332. });
  333. },
  334. /* 清空 */
  335. clearBoth() {
  336. this.form.zfrAmount = '';
  337. this.form,zfrRepaymentDate = '';
  338. this.form.zfrRate = '';
  339. this.form.zfpcrLoanType = '';
  340. this.billInfList = [];
  341. this.contractFileList = [];
  342. this.invoiceFileList = [];
  343. this.otherFileList = [];
  344. },
  345. //预览
  346. handlePreview(row) {
  347. const pfiUrl = row.pfiUrl;
  348. const pfiFileName = row.pfiFileName;
  349. if (row.pfiUrl) {
  350. console.log(pfiFileName.substr(-3));
  351. if (pfiFileName.substr(-3) == "pdf") {
  352. this.wordUrl = pfiUrl + "/" + getToken();
  353. this.show=false;
  354. this.heid=true;
  355. } else if (
  356. pfiFileName.substr(-3) == "jpg" ||
  357. pfiFileName.substr(-3) == "png" ||
  358. pfiFileName.substr(-3) == "JPG" ||
  359. pfiFileName.substr(-3) == "PNG" ||
  360. pfiFileName.substr(-4) == "jpeg" ||
  361. pfiFileName.substr(-3) == "JPEG"
  362. ) {
  363. this.wordUrl =
  364. pfiUrl +
  365. "/" +
  366. getToken();
  367. this.show=true;
  368. this.heid=false;
  369. console.log("====>",this.wordUrl);
  370. } else if (
  371. pfiFileName.substr(-3) == "doc" ||
  372. pfiFileName.substr(-3) == "DOC"||
  373. pfiFileName.substr(-4) == "docx" ||
  374. pfiFileName.substr(-3) == "DOCX"
  375. ) {
  376. this.wordUrl =
  377. "https://view.officeapps.live.com/op/view.aspx?src=" +
  378. pfiUrl +
  379. "/" +
  380. getToken() +
  381. "/" +
  382. pfiFileName;
  383. this.show=false;
  384. this.heid=true;
  385. console.log("====>",this.wordUrl);
  386. } else {
  387. this.$message({
  388. message: "暂不支持该类型文件预览",
  389. type: "warning",
  390. });
  391. return;
  392. }
  393. }
  394. this.openFile = true;
  395. },
  396. //应收账款合计
  397. allAmount() {
  398. var strarr = [0.00];
  399. for (let i in this.billInfList) {
  400. strarr.push(this.billInfList[i]["zbiAmount"]);
  401. }
  402. return Math.floor(eval(strarr.join("+")) * 100) / 100; //结果
  403. },
  404. /* // 将数字金额转换为大写金额 */
  405. smallToBig(money) {
  406. // 将数字金额转换为大写金额
  407. var cnNums = new Array(
  408. "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" ); //汉字的数字
  409. var cnIntRadice = new Array("", "拾", "佰", "仟"); //基本单位
  410. var cnIntUnits = new Array("", "万", "亿", "兆"); //对应整数部分扩展单位
  411. var cnDecUnits = new Array("角", "分", "毫", "厘"); //对应小数部分单位
  412. var cnInteger = "整"; //整数金额时后面跟的字符
  413. var cnIntLast = "元"; //整数完以后的单位
  414. //最大处理的数字
  415. var maxNum = 999999999999999.9999;
  416. var integerNum; //金额整数部分
  417. var decimalNum; //金额小数部分
  418. //输出的中文金额字符串
  419. var chineseStr = "";
  420. var parts; //分离金额后用的数组,预定义
  421. if (money == "" || money == null || money == undefined) {
  422. return "零元零角零分";
  423. }
  424. money = parseFloat(money);
  425. if (money >= maxNum) {
  426. //超出最大处理数字
  427. return "超出最大处理数字";
  428. }
  429. if (money == 0) {
  430. chineseStr = cnNums[0] + cnIntLast + cnInteger;
  431. return chineseStr;
  432. }
  433. //四舍五入保留两位小数,转换为字符串
  434. money = Math.round(money * 100).toString();
  435. integerNum = money.substr(0, money.length - 2);
  436. decimalNum = money.substr(money.length - 2);
  437. //获取整型部分转换
  438. if (parseInt(integerNum, 10) > 0) {
  439. var zeroCount = 0;
  440. var IntLen = integerNum.length;
  441. for (var i = 0; i < IntLen; i++) {
  442. var n = integerNum.substr(i, 1);
  443. var p = IntLen - i - 1;
  444. var q = p / 4;
  445. var m = p % 4;
  446. if (n == "0") {
  447. zeroCount++;
  448. } else {
  449. if (zeroCount > 0) {
  450. chineseStr += cnNums[0];
  451. }
  452. //归零
  453. zeroCount = 0;
  454. chineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
  455. }
  456. if (m == 0 && zeroCount < 4) {
  457. chineseStr += cnIntUnits[q];
  458. }
  459. }
  460. chineseStr += cnIntLast;
  461. }
  462. //小数部分
  463. if (decimalNum != "") {
  464. var decLen = decimalNum.length;
  465. for (var i = 0; i < decLen; i++) {
  466. var n = decimalNum.substr(i, 1);
  467. if (n != "0") {
  468. chineseStr += cnNums[Number(n)] + cnDecUnits[i];
  469. }
  470. }
  471. }
  472. if (chineseStr == "") {
  473. chineseStr += cnNums[0] + cnIntLast + cnInteger;
  474. } else if (decimalNum == "" || /^0*$/.test(decimalNum)) {
  475. chineseStr += cnInteger;
  476. }
  477. return chineseStr;
  478. },
  479. /** 导出按钮操作 */
  480. handleExport() {
  481. this.download('sc-service/record/export', {
  482. ...this.queryParams
  483. }, `sc-service_record.xlsx`)
  484. }
  485. }
  486. };
  487. </script>