applyCreditEdit.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
  1. <template>
  2. <div class="app-container">
  3. <el-form ref="form" :model="form" :rules="rules" :inline="true" style="margin-top: 10px" label-width="auto" >
  4. <el-row>
  5. <el-col :span="8">
  6. <el-form-item label="融信编号" prop="zfiNumber">
  7. <el-input v-model="form.zfiNumber" style="width: 200px" disabled/>
  8. </el-form-item>
  9. </el-col>
  10. <el-col :span="8">
  11. <el-form-item label="创建时间" prop="createTime">
  12. <el-date-picker disabled size="small" style="width: 200px" v-model="form.createTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss">
  13. </el-date-picker>
  14. </el-form-item>
  15. </el-col>
  16. <el-col :span="8">
  17. <el-form-item label="创建人" prop="createName">
  18. <el-input v-model="form.createName" style="width: 200px" disabled/>
  19. </el-form-item>
  20. </el-col>
  21. </el-row>
  22. <el-row>
  23. <el-divider content-position="left" >应收账款</el-divider>
  24. <el-form-item style="margin-left: 100px">
  25. <el-button size="mini" type="success" @click="addPay">新增应收账款</el-button>
  26. <el-button size="mini" type="primary" @click="openTicket">选择</el-button>
  27. <el-button size="mini" @click="deleteTicekt">清空全部</el-button>
  28. <el-form-item label="合计金额:">
  29. <span>{{checkTotalAmt}}</span>
  30. </el-form-item>
  31. <el-form-item label="金额大写:">
  32. <span>{{checkTotalBigAmt}}</span>
  33. </el-form-item>
  34. <el-table :data="ticketList" style="width: 1100px">
  35. <el-table-column label="账款名称" align="center" prop="zbiName" show-overflow-tooltip />
  36. <el-table-column label="应收企业" align="center" prop="receiveName"/>
  37. <el-table-column label="应付企业" align="center" prop="payName" />
  38. <el-table-column label="预计还款期" align="center" prop="zbiPayDate" show-overflow-tooltip />
  39. <el-table-column label="金额" align="center" prop="zbiAmount" />
  40. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="250">
  41. <template slot-scope="scope">
  42. <el-button
  43. size="mini"
  44. type="text"
  45. icon="el-icon-delete"
  46. @click="handleDelete(scope.$index, ticketList)"
  47. >删除</el-button>
  48. </template>
  49. </el-table-column>
  50. </el-table>
  51. </el-form-item>
  52. <!-- <el-col :span="8">
  53. <el-form-item label="授信额度" prop="zfiSupplierQuotaId">
  54. <el-select
  55. style="width: 200px"
  56. v-model="form.zfiSupplierQuotaId"
  57. filterable
  58. clearable
  59. remote
  60. >
  61. <el-option
  62. v-for="item in creditLineList"
  63. :key="item.value"
  64. :label="item.label"
  65. :value="item.value">
  66. </el-option>
  67. </el-select>
  68. </el-form-item>
  69. </el-col>
  70. <el-col :span="8">
  71. <span>可用额度:</span>
  72. <span>{{availableAmt}}</span>
  73. <br>
  74. <span>有效期:</span>
  75. <span>{{validityDate}}</span>
  76. </el-col> -->
  77. </el-row>
  78. <!-- <el-row>
  79. <el-col :span="8">
  80. <el-form-item label="接收方" prop="receiveName">
  81. <el-input v-model="form.receiveName" style="width: 200px" disabled />
  82. </el-form-item>
  83. </el-col>
  84. <el-col :span="8">
  85. <el-form-item label="签发有效期" prop="zfiEffectiveDate">
  86. <el-date-picker clearable size="small" style="width: 200px"
  87. v-model="form.zfiEffectiveDate"
  88. type="date"
  89. value-format="yyyy-MM-dd"
  90. placeholder="选择签发有效期">
  91. </el-date-picker>
  92. </el-form-item>
  93. </el-col>
  94. <el-col :span="8">
  95. <el-form-item label="承诺还款日" prop="zfiExpireDate">
  96. <el-date-picker clearable size="small" style="width: 200px"
  97. v-model="form.zfiExpireDate"
  98. type="date"
  99. value-format="yyyy-MM-dd"
  100. placeholder="选择承诺还款日">
  101. </el-date-picker>
  102. </el-form-item>
  103. </el-col>
  104. </el-row> -->
  105. <el-row>
  106. <el-col :span="8">
  107. <el-form-item label="签发金额" prop="zfiAmount">
  108. <el-input v-model="form.zfiAmount" style="width: 200px" @input="getBigSmall" @input.native="changeRate($event,form.zfiAmount)" />
  109. </el-form-item>
  110. </el-col>
  111. <el-col :span="8">
  112. <el-form-item label="开立方" prop="openName">
  113. <el-input v-model="form.openName" style="width: 200px" disabled />
  114. </el-form-item>
  115. </el-col>
  116. <!-- <el-col :span="8">
  117. <el-form-item label="收款账号" prop="zfiCollectionAccount" v-if="zfpcrLoanType != '0'">
  118. <el-input v-model="form.zfiCollectionAccount" style="width: 200px" />
  119. </el-form-item>
  120. </el-col> -->
  121. </el-row>
  122. <el-row>
  123. <el-col :span="8">
  124. <el-form-item label="金额大写" prop="issuedAmount">
  125. {{issuedAmount}}
  126. </el-form-item>
  127. </el-col>
  128. </el-row>
  129. </el-form>
  130. <!-- 发票附件 -->
  131. <el-divider content-position="left">发票附件</el-divider>
  132. <el-table :data="invoiceFileList" style="width: 100%">
  133. <el-table-column label="文件名称" align="center" prop="pfiFileName" show-overflow-tooltip />
  134. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width='300' fixed="right" >
  135. <template slot-scope="scope">
  136. <el-button
  137. size="mini"
  138. type="text"
  139. icon="el-icon-view"
  140. @click="handleDownload(scope.row)"
  141. >下载</el-button>
  142. <el-button
  143. size="mini"
  144. type="text"
  145. icon="el-icon-view"
  146. @click="handlePreview(scope.row)"
  147. >预览</el-button>
  148. </template>
  149. </el-table-column>
  150. </el-table>
  151. <!-- 合同附件 -->
  152. <el-divider content-position="left">合同附件</el-divider>
  153. <el-table :data="contractFileList" style="width: 100%">
  154. <el-table-column label="文件名称" align="center" prop="pfiFileName" show-overflow-tooltip />
  155. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width='300' fixed="right" >
  156. <template slot-scope="scope">
  157. <el-button
  158. size="mini"
  159. type="text"
  160. icon="el-icon-view"
  161. @click="handleDownload(scope.row)"
  162. >下载</el-button>
  163. <el-button
  164. size="mini"
  165. type="text"
  166. icon="el-icon-view"
  167. @click="handlePreview(scope.row)"
  168. >预览</el-button>
  169. </template>
  170. </el-table-column>
  171. </el-table>
  172. <!-- 其他附件 -->
  173. <el-divider content-position="left">其他附件</el-divider>
  174. <el-table :data="otherFileList" style="width: 100%">
  175. <el-table-column label="文件名称" align="center" prop="pfiFileName" show-overflow-tooltip />
  176. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width='300' fixed="right" >
  177. <template slot-scope="scope">
  178. <el-button
  179. size="mini"
  180. type="text"
  181. icon="el-icon-view"
  182. @click="handleDownload(scope.row)"
  183. >下载</el-button>
  184. <el-button
  185. size="mini"
  186. type="text"
  187. icon="el-icon-view"
  188. @click="handlePreview(scope.row)"
  189. >预览</el-button>
  190. </template>
  191. </el-table-column>
  192. </el-table>
  193. <div class="footer" style="float: right;
  194. margin-bottom:2px;">
  195. <el-button type="primary" @click="submitForm">确 定</el-button>
  196. <el-button @click="cancel">取 消</el-button>
  197. </div>
  198. <!-- 应付账款信息 -->
  199. <el-dialog :title="payTitle" :visible.sync="open" width="1120px" append-to-body>
  200. <el-form :model="queryParamsPay" ref="formQuery" :inline="true" label-width="68px" style="margin-bottom: -21px">
  201. <el-form-item label="账款名称" prop="zbiName">
  202. <el-input
  203. v-model="queryParamsPay.zbiName"
  204. placeholder="请输入账款名称"
  205. clearable
  206. size="small"
  207. maxlength="11"
  208. @keyup.enter.native="handleQuerys"/>
  209. </el-form-item>
  210. <el-form-item label="应付企业" prop="payName">
  211. <el-input
  212. v-model="queryParamsPay.payName"
  213. placeholder="请输入应付企业"
  214. clearable
  215. size="small"
  216. maxlength="11"
  217. @keyup.enter.native="handleQuerys"/>
  218. </el-form-item>
  219. <el-form-item>
  220. <el-button
  221. type="cyan"
  222. icon="el-icon-search"
  223. size="mini"
  224. @click="handleQuerys"
  225. >搜索</el-button>
  226. <el-button icon="el-icon-refresh" size="mini" @click="resetQuerys"
  227. >重置</el-button>
  228. </el-form-item>
  229. </el-form>
  230. <el-table :data="payList"
  231. ref="tablePay"
  232. class="single-select-table"
  233. @selection-change="handleSelectionChange"
  234. :row-key="rowkey">
  235. <el-table-column
  236. type="selection"
  237. :reserve-selection="true"
  238. width="50"
  239. align="center"/>
  240. <el-table-column label="序号" type="index" width="50" align="center">
  241. <template slot-scope="scope">
  242. <span>{{ (queryParamsPay.pageNum - 1) * queryParamsPay.pageSize + scope.$index + 1}}</span>
  243. </template>
  244. </el-table-column>
  245. <el-table-column label="账款名称" align="center" prop="zbiName" show-overflow-tooltip />
  246. <el-table-column label="应收企业" align="center" prop="receiveName"/>
  247. <el-table-column label="应付企业" align="center" prop="payName" />
  248. <el-table-column label="预计还款期" align="center" prop="zbiPayDate" show-overflow-tooltip />
  249. <el-table-column label="金额" align="center" prop="zbiAmount" />
  250. </el-table>
  251. <pagination
  252. v-show="total > 0"
  253. :total="total"
  254. :page.sync="queryParamsPay.pageNum"
  255. :limit.sync="queryParamsPay.pageSize"
  256. @pagination="getAccountsCollection" />
  257. <span slot="footer" class="dialog-footer">
  258. <el-button size="mini" @click="cancelTicket">取消</el-button>
  259. <el-button size="mini" type="primary" @click="closeTicket">确认</el-button>
  260. </span>
  261. </el-dialog>
  262. <!-- 新增往来账款 -->
  263. <el-dialog title="新增往来账款" :visible.sync="openAddBill" width="1120px" append-to-body>
  264. <add-bill :companyId="form.zfiCoreId" companyType="01" @addClick="emitAddClick" v-if="openAddBill"></add-bill>
  265. </el-dialog>
  266. <!--预览-->
  267. <el-dialog :visible.sync="openFile" width="1000px" append-to-body>
  268. <img :src="wordUrl" v-if="show" width='450px' height='500px'/>
  269. <iframe :src="wordUrl" width='800px' height='600px' frameborder='1' v-if="heid"/>
  270. </el-dialog>
  271. </div>
  272. </template>
  273. <script>
  274. import {getFile,getCreditDetail,getAccountsCollection,updateCredit} from "@/api/service/credit/credit";
  275. import {accAdd} from "@/utils/calculation";
  276. import {getToken} from "@/utils/auth";
  277. import AddBill from "@/views/service/bill/addBill";
  278. export default {
  279. name: "addCredit",
  280. components: {AddBill},
  281. data() {
  282. return {
  283. // 总条数
  284. total: 0,
  285. // 查询参数
  286. queryParams: {
  287. pageNum: 1,
  288. pageSize: 10,
  289. },
  290. creditParams: {
  291. zfsqId:null
  292. },
  293. supplierCreditParams: {
  294. zfsqId:null
  295. },
  296. queryParamsPay: {
  297. pageNum: 1,
  298. pageSize: 10,
  299. payName:null,
  300. zbiName:null
  301. },
  302. // 表单参数
  303. form: {
  304. },
  305. // 表单校验
  306. rules: {
  307. //授信额度
  308. zfiSupplierQuotaId: [
  309. {
  310. required: true,
  311. message: "请选择授信额度",
  312. trigger: ["blur", "change"],
  313. },
  314. ],
  315. //接收方
  316. zfiSupplierId: [
  317. {
  318. required: true,
  319. message: "请选择接收方",
  320. trigger: ["blur", "change"],
  321. },
  322. ],
  323. //签发有效期
  324. zfiEffectiveDate: [
  325. {
  326. required: true,
  327. message: "请选择签发有效期",
  328. trigger: ["blur", "change"],
  329. },
  330. ],
  331. //签发金额
  332. zfiAmount: [
  333. {
  334. required: true,
  335. message: "请输入签发金额",
  336. trigger: ["blur", "change"],
  337. },
  338. {
  339. pattern: /^(?:0|[1-9]\d{0,8})(?:\.\d{1,2})?$/,
  340. message: "请输入正确的签发金额",
  341. trigger: ["blur", "change"],
  342. },
  343. ],
  344. //承诺还款日
  345. zfiExpireDate: [
  346. {
  347. required: true,
  348. message: "请选择承诺还款日",
  349. trigger: ["blur", "change"],
  350. },
  351. ],
  352. },
  353. // 是否显示弹出层
  354. open: false,
  355. openAddBill: false,
  356. //授信
  357. creditLineList:[],
  358. //接收方
  359. supplierList:[],
  360. //应付账款
  361. payList:[],
  362. //应付账款表格数据
  363. ticketList: [],
  364. //应付标题
  365. payTitle:"",
  366. //可用额度
  367. availableAmt:"0.00",
  368. //有效期
  369. validityDate:"",
  370. //有效期类型
  371. zfpcrDateType:"" ,
  372. //合计选中的应付账款的金额
  373. checkTotalAmt:"0.00",
  374. //合计选中的应付账款的大写金额
  375. checkTotalBigAmt:"零元整",
  376. //签发金额大写
  377. issuedAmount:"零元整",
  378. //产品是否可拆分
  379. zfpSplit:"",
  380. //融资放款方式
  381. zfpcrLoanType:"",
  382. //产品编号
  383. zfpId:"",
  384. //利率
  385. zfpcrRate:'',
  386. //合同附件
  387. contractFileList:[],
  388. //发票附件
  389. invoiceFileList:[],
  390. //其他文件
  391. otherFileList:[],
  392. openFile:false,
  393. wordUrl: "",
  394. show:false,
  395. heid:false,
  396. chooseTicket:[]
  397. };
  398. },
  399. watch:{
  400. 'form.zfiSupplierQuotaId':'change'
  401. },
  402. created() {
  403. const zfiId = this.$route.params && this.$route.params.zfiId;
  404. getCreditDetail(zfiId).then((response) => {
  405. if(response.data){
  406. this.form = response.data.financeInf;
  407. //接收方
  408. this.form.receiveName = response.data.receiveName;
  409. //开立方
  410. this.form.openName = response.data.openName;
  411. //开立方
  412. this.form.zfiCoreId = response.data.zfiCoreId;
  413. //创建人
  414. this.form.createName = response.data.createName;
  415. //签发金额大写
  416. this.issuedAmount = this.smallToBig(this.form.zfiAmount);
  417. }
  418. if(response.data.payList){
  419. this.ticketList = response.data.payList.records;
  420. this.getReTotal(this.ticketList);
  421. //附件
  422. this.getFile(this.ticketList);
  423. }
  424. })
  425. },
  426. methods: {
  427. // 取消按钮
  428. cancel() {
  429. this.$store.dispatch("tagsView/delView", this.$route);
  430. this.$router.go(-1);
  431. },
  432. //应收账款查询列表
  433. getAccountsCollection() {
  434. return getAccountsCollection(this.queryParamsPay).then((response) => {
  435. this.payList = response.data.records;
  436. this.selectChecked();
  437. this.total = response.data.total;
  438. return Promise.resolve(response)
  439. });
  440. },
  441. //获取附件信息
  442. getFile(datas){
  443. var queryParamsFile = {};
  444. queryParamsFile.ticketList = datas;
  445. getFile(queryParamsFile).then((response) => {
  446. if(response.data){
  447. //获取发票文件
  448. this.invoiceFileList = response.data.invoiceFileList;
  449. //获取合同文件
  450. this.contractFileList = response.data.contractFileList;
  451. //获取其他文件
  452. this.otherFileList = response.data.otherFileList;
  453. }
  454. });
  455. },
  456. //文件下载
  457. handleDownload(row){
  458. const pfiUrl = row.pfiUrl;
  459. if(pfiUrl != null && pfiUrl != ''){
  460. window.open(pfiUrl +"/"+ getToken());
  461. }else{
  462. this.$message({
  463. message: '该附件不存在!',
  464. type: 'warning'
  465. });
  466. return;
  467. }
  468. },
  469. resetQuerys() {
  470. this.resetForm("formQuery");
  471. this.handleQuerys();
  472. },
  473. handleQuerys() {
  474. this.queryParamsPay.pageNum = 1;
  475. this.getAccountsCollection();
  476. },
  477. //打开应付账款选择列表
  478. openTicket() {
  479. //清空搜索条件
  480. this.queryParamsPay.zbiName = "";
  481. this.queryParamsPay.payName = "";
  482. this.getAccountsCollection();
  483. this.open = true;
  484. this.payTitle = "应收账款";
  485. },
  486. //获取签发金额大写
  487. getBigSmall(){
  488. this.issuedAmount = this.smallToBig(this.form.zfiAmount);
  489. },
  490. selectChecked() {
  491. //清空选择
  492.             this.$refs.tablePay && this.$refs.tablePay.clearSelection();
  493. this.ticketList.forEach((item) => {
  494. this.payList.forEach(row => {
  495. if (row.zbiId == item.zbiId) {
  496. this.$nextTick(() => {
  497. this.$refs.tablePay && this.$refs.tablePay.toggleRowSelection(row, true);
  498. })
  499. }
  500. });
  501. });
  502. //合计
  503. this.getReTotal(this.ticketList);
  504. //附件
  505. this.getFile(this.ticketList);
  506. },
  507. /* 多选框跨页 */
  508. rowkey(row) {
  509. return row.zbiId;
  510. },
  511. // 多选框选中数据
  512. handleSelectionChange(val) {
  513. this.chooseTicket = val
  514. },
  515. // 确认选择
  516. closeTicket() {
  517. if(this.chooseTicket){
  518. var flag = true;
  519. //如果长度大于1,则需要进行对比应收企业和预计还款日期是否一致
  520. if(this.chooseTicket.length > 0){
  521. //获取选中第一个的应付企业
  522. var payName = this.chooseTicket[0].payName;
  523. //获取选中第一个的预计还款日期
  524. var zbiPayDate = this.chooseTicket[0].zbiPayDate;
  525. for(var i = 0 ;i < this.chooseTicket.length;i++){
  526. if(payName != this.chooseTicket[i].payName){
  527. flag = false
  528. this.$message({
  529. message: '请选择应付企业相同的应付账款',
  530. type: 'warning'
  531. });
  532. break;
  533. }else if(zbiPayDate != this.chooseTicket[i].zbiPayDate){
  534. flag = false
  535. this.chooseTicket.splice(i, 1)
  536. this.$message({
  537. message: '请选择预计还款日期相同的应付账款',
  538. type: 'warning'
  539. });
  540. break;
  541. }
  542. }
  543. if(flag){
  544. //合计
  545. this.getReTotal(this.chooseTicket);
  546. this.ticketList = this.chooseTicket;
  547. //更新附件信息
  548. this.getFile(this.ticketList);
  549. this.open = false;
  550. //开立方赋值
  551. this.$set(this.form, "openName",this.chooseTicket[0].payName);
  552. }
  553. }
  554. }else{
  555. this.$message({
  556. message: '请选择应收账款',
  557. type: 'warning'
  558. });
  559. }
  560. },
  561. //重新合计
  562. getReTotal(chooseTicket){
  563. //合计
  564. this.checkTotalAmt = "0.00";
  565. for(var i = 0; i < chooseTicket.length;i++){
  566. this.checkTotalAmt = accAdd(this.checkTotalAmt,chooseTicket[i].zbiAmount,2);
  567. }
  568. this.checkTotalBigAmt = this.smallToBig(this.checkTotalAmt);
  569. this.checkTotalAmt = this.amtFormat(this.checkTotalAmt);
  570. },
  571. //取消选择按钮
  572. cancelTicket(){
  573. /* this.ticketList = [];
  574. if(this.$refs.tablePay){
  575. this.$refs.tablePay.clearSelection();
  576. } */
  577. this.open = false;
  578. },
  579. /** 清空选择信息 */
  580. deleteTicekt() {
  581. this.ticketList = [];
  582. this.checkTotalAmt = "0.00";
  583. this.checkTotalBigAmt = this.smallToBig(this.checkTotalAmt);
  584. //开立方清空
  585. this.$set(this.form, "openName","");
  586. if(this.$refs.tablePay){
  587. this.$refs.tablePay.clearSelection();
  588. }
  589. this.getFile(this.ticketList);
  590. },
  591. /* 删除按钮 */
  592. handleDelete(index, rows) {
  593. rows.splice(index, 1);
  594. if(this.$refs.tablePay){
  595. this.$refs.tablePay.clearSelection();
  596. }
  597. this.selectChecked();
  598. },
  599. onSelectAll() {
  600. if(this.$refs.tablePay){
  601. this.$refs.tablePay.clearSelection();
  602. }
  603. },
  604. //格式化金额
  605. amtFormat(cellValue) {
  606. if(cellValue == null || cellValue== undefined || cellValue == ''){
  607. cellValue = '0.00'
  608. }
  609. cellValue += '';
  610.       if (!cellValue.includes('.')) {
  611. cellValue += '.00';
  612. }
  613. console.log(cellValue);
  614.       return cellValue.replace(/(\d)(?=(\d{3})+\.)/g, function ($0, $1) {
  615.         return $1 + ',';
  616.       }).replace(/\.$/, '');
  617. },
  618. /* // 将数字金额转换为大写金额 */
  619. smallToBig(money) {
  620. // 将数字金额转换为大写金额
  621. var cnNums = new Array(
  622. "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" ); //汉字的数字
  623. var cnIntRadice = new Array("", "拾", "佰", "仟"); //基本单位
  624. var cnIntUnits = new Array("", "万", "亿", "兆"); //对应整数部分扩展单位
  625. var cnDecUnits = new Array("角", "分", "毫", "厘"); //对应小数部分单位
  626. var cnInteger = "整"; //整数金额时后面跟的字符
  627. var cnIntLast = "元"; //整数完以后的单位
  628. //最大处理的数字
  629. var maxNum = 999999999999999.9999;
  630. var integerNum; //金额整数部分
  631. var decimalNum; //金额小数部分
  632. //输出的中文金额字符串
  633. var chineseStr = "";
  634. var parts; //分离金额后用的数组,预定义
  635. if (money == "" || money == null || money == undefined) {
  636. return "零元零角零分";
  637. }
  638. money = parseFloat(money);
  639. if (money >= maxNum) {
  640. //超出最大处理数字
  641. return "超出最大处理数字";
  642. }
  643. if (money == 0) {
  644. chineseStr = cnNums[0] + cnIntLast + cnInteger;
  645. return chineseStr;
  646. }
  647. //四舍五入保留两位小数,转换为字符串
  648. money = Math.round(money * 100).toString();
  649. integerNum = money.substr(0, money.length - 2);
  650. decimalNum = money.substr(money.length - 2);
  651. //获取整型部分转换
  652. if (parseInt(integerNum, 10) > 0) {
  653. var zeroCount = 0;
  654. var IntLen = integerNum.length;
  655. for (var i = 0; i < IntLen; i++) {
  656. var n = integerNum.substr(i, 1);
  657. var p = IntLen - i - 1;
  658. var q = p / 4;
  659. var m = p % 4;
  660. if (n == "0") {
  661. zeroCount++;
  662. } else {
  663. if (zeroCount > 0) {
  664. chineseStr += cnNums[0];
  665. }
  666. //归零
  667. zeroCount = 0;
  668. chineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
  669. }
  670. if (m == 0 && zeroCount < 4) {
  671. chineseStr += cnIntUnits[q];
  672. }
  673. }
  674. chineseStr += cnIntLast;
  675. }
  676. //小数部分
  677. if (decimalNum != "") {
  678. var decLen = decimalNum.length;
  679. for (var i = 0; i < decLen; i++) {
  680. var n = decimalNum.substr(i, 1);
  681. if (n != "0") {
  682. chineseStr += cnNums[Number(n)] + cnDecUnits[i];
  683. }
  684. }
  685. }
  686. if (chineseStr == "") {
  687. chineseStr += cnNums[0] + cnIntLast + cnInteger;
  688. } else if (decimalNum == "" || /^0*$/.test(decimalNum)) {
  689. chineseStr += cnInteger;
  690. }
  691. return chineseStr;
  692. },
  693. //新增
  694. submitForm(){
  695. if(this.ticketList.length < 1){
  696. this.$message({
  697. message: '请选择应收账款',
  698. type: 'warning'
  699. });
  700. return;
  701. }
  702. if(parseFloat(this.form.zfiAmount) > parseFloat(this.moneyDelete(this.checkTotalAmt))){
  703. this.$message({
  704. message: '签发金额不可大于合计金额',
  705. type: 'warning'
  706. });
  707. return;
  708. }
  709. this.$refs["form"].validate(valid => {
  710. if (valid) {
  711. const loading = this.$loading({
  712. lock: true,
  713. text: 'Loading',
  714. background: 'rgba(0, 0, 0,0)'
  715. });
  716. //如果签发金额小于合计金额
  717. if((parseFloat(this.form.zfiAmount)) < (parseFloat(this.moneyDelete(this.checkTotalAmt)))){
  718. var _this = this;
  719. this.$confirm('签发金额小于应付金额合计,是否确认提交', "警告", {
  720. confirmButtonText: "确定",
  721. cancelButtonText: "取消",
  722. type: "warning"
  723. }).then(function() {
  724. //应收账款
  725. _this.form.ticketList = _this.ticketList;
  726. //融信类型
  727. _this.form.type = "0";
  728. //合计金额
  729. _this.form.checkTotalAmt = _this.moneyDelete(_this.checkTotalAmt);
  730. updateCredit(_this.form).then(response => {
  731. loading.close();
  732. _this.msgSuccess("修改成功");
  733. _this.$store.dispatch("tagsView/delView", _this.$route);
  734. _this.$router.go(-1);
  735. }).catch((response)=>{
  736. loading.close();
  737. });
  738. }).catch((e) => {
  739. loading.close();
  740. });
  741. }else{
  742. //应收账款
  743. this.form.ticketList = this.ticketList;
  744. //融信类型
  745. this.form.type = "0";
  746. //合计金额
  747. this.form.checkTotalAmt = this.moneyDelete(this.checkTotalAmt);
  748. updateCredit(this.form).then(response => {
  749. loading.close();
  750. this.msgSuccess("修改成功");
  751. this.$store.dispatch("tagsView/delView", this.$route);
  752. this.$router.go(-1);
  753. }).catch((response)=>{
  754. loading.close();
  755. });
  756. }
  757. }
  758. });
  759. },
  760. //金额去掉千分位
  761. moneyDelete(num){
  762. if(num &&num != undefined && num != null){
  763. let _num = num;
  764. _num = _num.toString();
  765. _num = _num.replace(/,/gi,'');
  766. return _num;
  767. }else{
  768. return num;
  769. }
  770. },
  771. //预览
  772. handlePreview(row) {
  773. const pfiUrl = row.pfiUrl;
  774. const pfiFileName = row.pfiFileName;
  775. if (row.pfiUrl) {
  776. console.log(pfiFileName.substr(-3));
  777. if (pfiFileName.substr(-3) == "pdf") {
  778. this.wordUrl = pfiUrl + "/" + getToken();
  779. this.show=false;
  780. this.heid=true;
  781. } else if (
  782. pfiFileName.substr(-3) == "jpg" ||
  783. pfiFileName.substr(-3) == "png" ||
  784. pfiFileName.substr(-3) == "JPG" ||
  785. pfiFileName.substr(-3) == "PNG" ||
  786. pfiFileName.substr(-4) == "jpeg" ||
  787. pfiFileName.substr(-3) == "JPEG"
  788. ) {
  789. this.wordUrl =
  790. pfiUrl +
  791. "/" +
  792. getToken();
  793. this.show=true;
  794. this.heid=false;
  795. console.log("====>",this.wordUrl);
  796. } else if (
  797. pfiFileName.substr(-3) == "doc" ||
  798. pfiFileName.substr(-3) == "DOC"||
  799. pfiFileName.substr(-4) == "docx" ||
  800. pfiFileName.substr(-3) == "DOCX"
  801. ) {
  802. this.wordUrl =
  803. "https://view.officeapps.live.com/op/view.aspx?src=" +
  804. pfiUrl +
  805. "/" +
  806. getToken() +
  807. "/" +
  808. pfiFileName;
  809. this.show=false;
  810. this.heid=true;
  811. console.log("====>",this.wordUrl);
  812. } else {
  813. this.$message({
  814. message: "暂不支持该类型文件预览",
  815. type: "warning",
  816. });
  817. return;
  818. }
  819. }
  820. this.openFile = true;
  821. },
  822. changeRate(e,input){
  823.       e.target.value=(e.target.value.match(/^\d*(\.?\d{0,2})/g)[0]) || null
  824.       this.input=e.target.value
  825.       this.form.zfiAmount=this.input
  826.     },
  827. //新增应付
  828. addPay(){
  829. if(this.form.zfiCoreId){
  830. this.openAddBill = true
  831. }else{
  832. this.$message({
  833. message: "开立方不能为空",
  834. type: "warning",
  835. });
  836. }
  837. },
  838. //新增账款回调
  839. emitAddClick(val){
  840. var self = this
  841. this.getAccountsCollection().then((response) => {
  842. //新增付款返回id直接选中
  843. if (val) {
  844. self.payList.forEach(element => {
  845. if(element.zbiId == val){
  846. // 将当前点击项选中
  847. self.chooseTicket.push(element)
  848. self.closeTicket()
  849. }
  850. });
  851. }
  852. })
  853. self.openAddBill = false
  854. }
  855. }
  856. };
  857. </script>
  858. <style lang="scss">
  859. .uoloadfj .el-upload--picture-card{
  860. width:110px;
  861. height:110px;
  862. line-height:110px;
  863. }
  864. .fjUoloadSty .el-upload--picture-card{
  865. display:none;
  866. }
  867. table th.star div::before {
  868. content: '*';
  869. color: red;
  870. }
  871. </style>