applyCreditEdit.vue 38 KB

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