addbill.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906
  1. <template>
  2. <view class="content">
  3. <!-- <view class="listitem">
  4. <text class="lys">合同名称</text>
  5. <view class="inbox">
  6. <input type="text" v-model="form.name" placeholder="请输入合同的名称" placeholder-style="color:#BEBDBB" />
  7. </view>
  8. </view> -->
  9. <!-- <view class="listitem">
  10. <text class="lys">合同编号</text>
  11. <view class="inbox flex2">
  12. <input type="text" v-model="form.tax_no" placeholder="请输入合同的编号" placeholder-style="color:#BEBDBB" />
  13. <view class="flex7">
  14. <text style="color: #E8E8E8;">|</text>
  15. <text style="padding-left: 20rpx;display: block;">待确认</text>
  16. </view>
  17. </view>
  18. </view> -->
  19. <!-- <view class="listitem">
  20. <view class="" style="display: flex;align-content: center;">
  21. <text class="lys">合同附件</text>
  22. <text
  23. style="font-size: 24rpx; color:#D05C39;padding-top: 45rpx;padding-left: 20rpx;">*支持上传pdf、jpg/jpeg、png格式</text>
  24. </view>
  25. <view class="inbox" style="border: none;padding-bottom: 0">
  26. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
  27. :maxCount="10" width="100" height="100"></u-upload>
  28. </view>
  29. </view>
  30. <view class="listitem" style="border: none;">
  31. <view class="" style="display: flex;align-content: center;">
  32. <text class="lys">发票附件</text>
  33. <text
  34. style="font-size: 24rpx; color:#D05C39;padding-top: 45rpx;padding-left: 20rpx;">*支持上传pdf、jpg/jpeg、png格式</text>
  35. </view>
  36. <view class="inbox" style="border: none;padding-bottom: 0">
  37. <u-upload :fileList="fileList2" @afterRead="afterRead" @delete="deletePic" name="2" multiple
  38. :maxCount="10" width="100" height="100"></u-upload>
  39. </view>
  40. </view>
  41. <view class="listitem">
  42. <view class="" style="display: flex;align-content: center;">
  43. <text class="lys">贸易合同</text>
  44. <text
  45. style="font-size: 24rpx; color:#D05C39;padding-top: 45rpx;padding-left: 20rpx;">*支持上传pdf、jpg/jpeg、png格式</text>
  46. </view>
  47. <view class="inbox" style="border: none;padding-bottom: 0">
  48. <u-upload :fileList="fileList3" @afterRead="afterRead" @delete="deletePic" name="3" multiple
  49. :maxCount="10" width="100" height="100"></u-upload>
  50. </view>
  51. </view> -->
  52. <view v-for="(item,index) in form.contractDrafts" :key="index">
  53. <view class="addtitle flex6">
  54. <text class="ty">汇票{{index+1}}</text>
  55. <text class="tde" @click="deleBill" v-if="index>0">删除</text>
  56. </view>
  57. <view class="listitem">
  58. <text class="lys">汇票名称</text>
  59. <view class="inbox">
  60. <input type="text" v-model="item.name" placeholder="请输入汇票的名称" placeholder-style="color:#BEBDBB" />
  61. </view>
  62. </view>
  63. <view class="listitem">
  64. <text class="lys">汇票号码</text>
  65. <view class="inbox">
  66. <input type="text" v-model="item.draftNo" placeholder="请输入汇票的号码"
  67. placeholder-style="color:#BEBDBB"/>
  68. </view>
  69. </view>
  70. <view class="listitem">
  71. <text class="lys">承兑人</text>
  72. <view class="chosbox" @click="checkacptIndex(index)">
  73. <uni-data-select v-model="item.acceptor" :localdata="range1" @change="changeacPerson"
  74. :showas="false" :plname="'搜索兑换人名称'" @search="searchAcceptor"></uni-data-select>
  75. </view>
  76. </view>
  77. <view class="listitem">
  78. <text class="lys">出票人</text>
  79. <view class="chosbox" @click="checkldrwIndex(index)">
  80. <uni-data-select v-model="item.drawers" :localdata="range2" @change="changedrPerson"
  81. :plname="'搜索出票人名称'" @search="searchDrawers"></uni-data-select>
  82. </view>
  83. </view>
  84. <view class="listitem">
  85. <text class="lys">金额</text>
  86. <view class="inbox">
  87. <input type="digit" v-model="item.money" placeholder="请输入汇票的金额" placeholder-style="color:#BEBDBB"
  88. @input="getMoney" @blur="getMoneyIndex(index)" />
  89. </view>
  90. </view>
  91. <view class="listitem">
  92. <text class="lys">承兑日期</text>
  93. <view class="calender" @click="openTime(index,1)">
  94. <view class="canicon">
  95. <image src="../../static/img/canlen.png" mode="aspectFill"></image>
  96. </view>
  97. <text>{{item.acceptDate}}</text>
  98. </view>
  99. </view>
  100. <view class="listitem">
  101. <text class="lys">出票日期</text>
  102. <view class="calender" @click="openTime(index,2)">
  103. <view class="canicon">
  104. <image src="../../static/img/canlen.png" mode="aspectFill"></image>
  105. </view>
  106. <text>{{item.issueDate}}</text>
  107. </view>
  108. </view>
  109. <view class="listitem">
  110. <text class="lys">汇票到期日</text>
  111. <view class="calender" @click="openTime(index,3)">
  112. <view class="canicon">
  113. <image src="../../static/img/canlen.png" mode="aspectFill"></image>
  114. </view>
  115. <text>{{item.expireDate}}</text>
  116. </view>
  117. </view>
  118. <view class="listitem">
  119. <text class="lys">预计贴现日</text>
  120. <view class="calender" @click="openTime(index,4)">
  121. <view class="canicon">
  122. <image src="../../static/img/canlen.png" mode="aspectFill"></image>
  123. </view>
  124. <text>{{item.expectDiscountDate}}</text>
  125. </view>
  126. </view>
  127. <view class="listitem">
  128. <text class="lys">最高贷款额度</text>
  129. <view class="inbox">
  130. <input type="text" v-model="item.loanLimit" placeholder="自动计算得出" placeholder-style="color:#1F242A"
  131. disabled="true" />
  132. </view>
  133. </view>
  134. <view class="flex4">
  135. <view class="listitem">
  136. <text class="lys">服务费率</text>
  137. <view class="inbox">
  138. <input type="digit" v-model="item.serviceRate+'%'" placeholder="显示对于费率"
  139. placeholder-style="color:#BEBDBB" @blur="getserviceRate"
  140. @input="getserviceRateIndex(index)" disabled="true"/>
  141. </view>
  142. </view>
  143. <view class="listitem">
  144. <text class="lys">服务费</text>
  145. <view class="inbox">
  146. <input type="text" v-model="item.serviceMoney" placeholder="自动计算得出"
  147. placeholder-style="color:#BEBDBB" disabled="true" />
  148. </view>
  149. </view>
  150. </view>
  151. <view class="flex4">
  152. <view class="listitem">
  153. <text class="lys">利率</text>
  154. <view class="inbox">
  155. <input type="digit" v-model="item.interestRate+'%'" placeholder="显示对于利率"
  156. placeholder-style="color:#BEBDBB" @blur="getinterestRate"
  157. @input="getinterestRateIndex(index)" disabled="true"/>
  158. </view>
  159. </view>
  160. <view class="listitem">
  161. <text class="lys">利息</text>
  162. <view class="inbox">
  163. <input type="text" v-model="item.interest" placeholder="自动计算得出"
  164. placeholder-style="color:#BEBDBB" disabled="true" />
  165. </view>
  166. </view>
  167. </view>
  168. <view class="listitem">
  169. <view class="" style="display: flex;align-content: center;">
  170. <text class="lys">上传附件</text>
  171. <text
  172. style="font-size: 24rpx; color:#D05C39;padding-top: 45rpx;padding-left: 20rpx;">*支持上传pdf、jpg/jpeg、png格式</text>
  173. </view>
  174. <view class="inbox" style="border: none;padding-bottom: 0;" @click="checkIndex(index)">
  175. <u-upload :fileList="item.picUrling" @afterRead="afterRead" @delete="deletePic" :name="index+4"
  176. :checkedindex=index multiple :maxCount="10" width="100" height="100"></u-upload>
  177. </view>
  178. </view>
  179. </view>
  180. <view class="addnewbill" @click="addNewBill">
  181. + 新增汇票
  182. </view>
  183. <view class="safebt"></view>
  184. <view class="newbill flex1" @click="upAll">
  185. <view class="newbillbtn">
  186. <text>确认上传</text>
  187. </view>
  188. </view>
  189. <u-datetime-picker :show="dateshow" mode="date" @confirm="confirm" @cancel="closeDate" v-model="start">
  190. </u-datetime-picker>
  191. </view>
  192. </template>
  193. <script>
  194. let that
  195. import {
  196. mainUrl
  197. } from '@/http/baseUrl.js';
  198. import calllips from "@/componet/calllips/calllips.vue"
  199. export default {
  200. components: {
  201. calllips
  202. },
  203. data() {
  204. return {
  205. editall: false,
  206. quan: false,
  207. dateshow: false,
  208. opdanum: '',
  209. state: '',
  210. index: 0,
  211. start: Number(new Date()),
  212. fileList1: [],
  213. fileList2: [],
  214. fileList3: [],
  215. fileList4: [],
  216. allindex: 0,
  217. seacept:'',
  218. seadra:'',
  219. form: {
  220. id:'',
  221. contractDrafts: [{
  222. name: '',
  223. draftNo: '',
  224. acceptor:'',
  225. acceptorId: '',
  226. drawersId: '',
  227. drawers: '',
  228. money: '',
  229. acceptDate: '',
  230. issueDate: '',
  231. expireDate: '',
  232. loanLimit: '',
  233. expectDiscountDate: '',
  234. picUrls: [],
  235. picUrling:[],
  236. serviceRate: '',
  237. interestRate: '',
  238. interest: '',
  239. serviceMoney: '',
  240. limitTime: 0,
  241. expectDiscountDateTime: 0,
  242. acceptDateTime: 0
  243. }, ],
  244. },
  245. range1: [],
  246. range2: [],
  247. myindex: 0,
  248. sindex: 0,
  249. rindex: 0,
  250. acptIndex:0,
  251. drwIndex:0,
  252. again:false
  253. }
  254. },
  255. onLoad(o) {
  256. that = this
  257. this.form.supplierId = uni.getStorageSync('supplierId')
  258. this.loadTime()
  259. if(o.obj){
  260. this.again=true
  261. let obj=JSON.parse((o.obj))
  262. let form=obj.contractDrafts
  263. console.log(obj,9996)
  264. this.form.id=obj.id
  265. console.log(form,778)
  266. let inform=this.form.contractDrafts[0]
  267. inform.name=form[0].name
  268. inform.id=form[0].id
  269. inform.acceptorId=form[0].acceptorId
  270. inform.drawersId=form[0].drawersId
  271. inform.money=form[0].money
  272. inform.draftNo=form[0].draftNo
  273. inform.loanLimit=form[0].loanLimit
  274. inform.serviceRate=form[0].serviceRate
  275. inform.interestRate=form[0].interestRate
  276. inform.interest=form[0].interest
  277. inform.serviceMoney=form[0].serviceMoney
  278. inform.expectDiscountDate=form[0].expectDiscountDate
  279. inform.acceptDate=form[0].acceptDate
  280. inform.issueDate=form[0].issueDate
  281. inform.expireDate=form[0].expireDate
  282. form.forEach(item=>{
  283. item.picList.forEach(i=>{
  284. item.picUrling=[]
  285. item.picUrling.push({"url":i})
  286. })
  287. })
  288. inform.picUrling=form[0].picUrling
  289. }
  290. // this.initAcceptor()
  291. // this.initDrawers()
  292. },
  293. onShow(){
  294. this.initAcceptor()
  295. this.initDrawers()
  296. },
  297. methods: {
  298. loadTime() {
  299. let myDate = new Date()
  300. let wk =parseInt(Date.now()/100000).toFixed(0)*100000
  301. let yy = String(myDate.getFullYear())
  302. // let mm = myDate.getMonth() + 1
  303. let mm = String(myDate.getMonth() + 1 < 10 ? '0' + (myDate.getMonth() + 1) : myDate.getMonth() + 1)
  304. let dd = String(myDate.getDate() < 10 ? '0' + myDate.getDate() : myDate.getDate())
  305. let nowDate = yy + '-' + mm + '-' + dd
  306. this.form.contractDrafts.forEach(item => {
  307. item.acceptDate = nowDate
  308. item.issueDate = nowDate
  309. item.expireDate = nowDate
  310. item.expectDiscountDate = nowDate
  311. item.expectDiscountDateTime = wk
  312. item.acceptDateTime = wk
  313. let nTime = item.acceptDateTime-item.expectDiscountDateTime
  314. item.limitTime = Math.floor(nTime / 86400000);
  315. })
  316. },
  317. initAcceptor(){
  318. // 承兑人列表
  319. uni.$u.http.post('/api/Acceptor/search',{
  320. name:this.seacept
  321. },{
  322. }, {
  323. custom: {
  324. auth: true
  325. }
  326. }).then((res) => {
  327. uni.hideLoading()
  328. this.range1 = res.result
  329. this.range1.forEach((item, index) => {
  330. this.range1[index].value = index
  331. this.range1[index].text = item.name
  332. })
  333. if(this.again){
  334. that.range1.forEach((item,index)=>{
  335. console.log(that.form.contractDrafts[0],item)
  336. if(item.id==that.form.contractDrafts[0].acceptorId){
  337. console.log(555555555555555555555555)
  338. that.form.contractDrafts[0].acceptor=index
  339. console.log(that.form.contractDrafts[0].acceptor)
  340. }
  341. })
  342. }
  343. }).catch((err) => {})
  344. },
  345. initDrawers(){
  346. // 出票人列表
  347. uni.$u.http.post('/api/Drawer/search', {
  348. name:this.seadra
  349. }, {
  350. custom: {
  351. auth: true
  352. }
  353. }).then((res) => {
  354. uni.hideLoading()
  355. this.range2 = res.result
  356. this.range2.forEach((item, index) => {
  357. this.range2[index].value = index
  358. this.range2[index].text = item.name
  359. })
  360. if(this.again){
  361. that.range2.forEach((item,index)=>{
  362. if(item.id==that.form.contractDrafts[0].drawersId){
  363. that.form.contractDrafts[0].drawers=index
  364. }
  365. })
  366. }
  367. }).catch((err) => {})
  368. },
  369. searchAcceptor(e){
  370. this.seacept=e
  371. this.initAcceptor()
  372. },
  373. searchDrawers(e){
  374. this.seadra=e
  375. this.initDrawers()
  376. },
  377. checkacptIndex(index){
  378. this.acptIndex=index
  379. },
  380. checkldrwIndex(index){
  381. this.drwIndex=index
  382. },
  383. deleBill(index){
  384. uni.showModal({
  385. title:"提示",
  386. content:"是否确认删除?",
  387. success:(res)=>{
  388. if(res.confirm){
  389. that.form.contractDrafts.splice(index,1)
  390. }
  391. }
  392. })
  393. },
  394. getinterestRateIndex(index) {
  395. this.rindex = index
  396. },
  397. getinterestRate(event) {
  398. this.form.contractDrafts[this.rindex].interestRate = Number(event.detail.value)
  399. this.getloanLimt(this.rindex)
  400. this.getInterMoney(this.rindex)
  401. this.getSerMoney(this.rindex)
  402. },
  403. getserviceRateIndex(index) {
  404. this.sindex = index
  405. },
  406. getserviceRate(event) {
  407. this.form.contractDrafts[this.sindex].serviceRate = Number(event.detail.value)
  408. this.getloanLimt(this.sindex)
  409. this.getInterMoney(this.sindex)
  410. this.getSerMoney(this.sindex)
  411. },
  412. getMoneyIndex(index) {
  413. this.myindex = index
  414. },
  415. getMoney(event) {
  416. this.form.contractDrafts[this.myindex].money = Number(event.detail.value)
  417. this.getloanLimt(this.myindex)
  418. this.getSerMoney(this.myindex)
  419. this.getInterMoney(this.myindex)
  420. },
  421. getloanLimt(i) {
  422. if (this.form.contractDrafts[i].money && this.form.contractDrafts[i].serviceRate && this.form
  423. .contractDrafts[i].interestRate) {
  424. this.form.contractDrafts[i].loanLimit = (this.form.contractDrafts[i].money / (this.form.contractDrafts[
  425. i].serviceRate + this.form.contractDrafts[i].interestRate) * this.form.contractDrafts[i]
  426. .limitTime / 360 + 1).toFixed(2)
  427. }
  428. },
  429. getSerMoney(i) {
  430. if (this.form.contractDrafts[i].money && this.form.contractDrafts[i].serviceRate && this.form
  431. .contractDrafts[i].interestRate) {
  432. this.form.contractDrafts[i].serviceMoney = ((this.form.contractDrafts[i].money / (this.form
  433. .contractDrafts[i].serviceRate + this.form.contractDrafts[i].interestRate) * this.form
  434. .contractDrafts[i].limitTime / 360 + 1) * this.form.contractDrafts[i].serviceRate * this
  435. .form.contractDrafts[i].limitTime / 360).toFixed(2)
  436. }
  437. },
  438. getInterMoney(i) {
  439. if (this.form.contractDrafts[i].money && this.form.contractDrafts[i].serviceRate && this.form
  440. .contractDrafts[i].interestRate) {
  441. this.form.contractDrafts[i].interest = ((this.form.contractDrafts[i].money / (this.form.contractDrafts[
  442. i].serviceRate + this.form.contractDrafts[i].interestRate) * this.form.contractDrafts[
  443. i].limitTime / 360 + 1) * this.form.contractDrafts[i].interestRate * this.form
  444. .contractDrafts[i].limitTime / 360).toFixed(2)
  445. }
  446. },
  447. upAll() {
  448. uni.showModal({
  449. title: '提示',
  450. content: '是否上传汇票?',
  451. success: function(res) {
  452. if (res.confirm) {
  453. let form = that.form
  454. // if (form.name.length == 0) {
  455. // that.$toast('请输入合同名称')
  456. // return
  457. // }
  458. // if (that.fileList1.length == 0) {
  459. // that.$toast('请上传合同附件')
  460. // return
  461. // }
  462. // if (that.fileList2.length == 0) {
  463. // that.$toast('请上传发票附件')
  464. // return
  465. // }
  466. // if (that.fileList3.length == 0) {
  467. // that.$toast('请上贸易合同')
  468. // return
  469. // }
  470. form.contractDrafts.forEach(i => {
  471. if (i.name.length == 0) {
  472. that.$toast('请输入汇票名称')
  473. return
  474. }
  475. if (i.draftNo.length == 0) {
  476. that.$toast('请输入汇票号码')
  477. return
  478. }
  479. if (i.acceptor.length == 0) {
  480. that.$toast('请选择承兑人')
  481. return
  482. }
  483. if (i.drawers.length == 0) {
  484. that.$toast('请选择出票人')
  485. return
  486. }
  487. if (i.money.length == 0) {
  488. that.$toast('请输入金额')
  489. return
  490. }
  491. if (i.serviceRate.length == 0) {
  492. that.$toast('请输入服务费率')
  493. return
  494. }
  495. if (i.interestRate.length == 0) {
  496. that.$toast('请输入利率')
  497. return
  498. }
  499. if (i.picUrls.length == 0) {
  500. that.$toast('请上传附件')
  501. return
  502. }
  503. })
  504. // that.range2.forEach(item => {
  505. // form.contractDrafts.forEach(i => {
  506. // if (that.range2[i.drawers].name == item.name) {
  507. // i.drawersId = item.id
  508. // }
  509. // })
  510. // })
  511. // that.range1.forEach(item => {
  512. // form.contractDrafts.forEach(i => {
  513. // if (that.range1[i.acceptor].name == item.name) {
  514. // i.acceptorId = item.id
  515. // }
  516. // })
  517. // })
  518. // that.fileList1.forEach(item => {
  519. // form.invoicePics.push(item.url)
  520. // })
  521. // that.fileList2.forEach(item => {
  522. // form.pics.push(item.url)
  523. // })
  524. // that.fileList3.forEach(item => {
  525. // form.tradePics.push(item.url)
  526. // })
  527. form.contractDrafts.forEach(item=>{
  528. item.picUrling.forEach(i=>{
  529. item.picUrls.push(i.url)
  530. })
  531. })
  532. uni.showLoading()
  533. uni.$u.http.post('/api/Contract/addContractDraft', form, {
  534. custom: {
  535. auth: true
  536. }
  537. }).then((res) => {
  538. uni.hideLoading()
  539. that.$toast("汇票上传成功")
  540. that.form.invoicePics = []
  541. that.form.pics = []
  542. that.form.tradePics = []
  543. that.form.contractDrafts.forEach(item => {
  544. item.picUrls = []
  545. })
  546. setTimeout(()=>{
  547. uni.navigateBack({
  548. delta:1
  549. })
  550. },500)
  551. }).catch((err) => {
  552. uni.hideLoading()
  553. that.$toast(err.msg)
  554. that.form.invoicePics=[]
  555. that.form.pics=[]
  556. that.form.tradePics=[]
  557. that.form.contractDrafts.forEach(item=>{
  558. item.picUrls=[]
  559. })
  560. console.log(err)
  561. })
  562. } else if (res.cancel) {}
  563. }
  564. });
  565. },
  566. addNewBill() {
  567. let form = [{
  568. name: '',
  569. draftNo: '',
  570. acceptor: '',
  571. acceptorId: '',
  572. drawersId: '',
  573. drawers: '',
  574. money: '',
  575. acceptDate: '',
  576. issueDate: '',
  577. expireDate: '',
  578. loanLimit: '',
  579. expectDiscountDate: '',
  580. picUrls: [],
  581. picUrling:[],
  582. serviceRate: '',
  583. interestRate: '',
  584. interest: '',
  585. serviceMoney: '',
  586. limitTime: 0,
  587. expectDiscountDateTime: 0,
  588. acceptDateTime: 0
  589. }]
  590. let myDate = new Date()
  591. // let wk = Date.parse(new Date());
  592. let wk = Date.parse(new Date())
  593. let yy = String(myDate.getFullYear())
  594. // let mm = myDate.getMonth() + 1
  595. let mm = String(myDate.getMonth() + 1 < 10 ? '0' + (myDate.getMonth() + 1) : myDate.getMonth() + 1)
  596. let dd = String(myDate.getDate() < 10 ? '0' + myDate.getDate() : myDate.getDate())
  597. let nowDate = yy + '-' + mm + '-' + dd
  598. form.forEach(item => {
  599. item.acceptDate = nowDate
  600. item.issueDate = nowDate
  601. item.expireDate = nowDate
  602. item.expectDiscountDate = nowDate
  603. item.expectDiscountDateTime = wk
  604. item.acceptDateTime = wk
  605. let nTime =item.acceptDateTime- item.expectDiscountDateTime
  606. item.limitTime = Math.floor(nTime / 86400000) ;
  607. })
  608. this.form.contractDrafts.push(form[0])
  609. },
  610. changeacPerson(e) {
  611. this.acceptor = e
  612. for(let i in this.range1){
  613. if(i==e){
  614. this.form.contractDrafts[this.acptIndex].acceptorId=this.range1[i].id
  615. this.form.contractDrafts[this.acptIndex].serviceRate=this.range1[i].serviceRate
  616. this.form.contractDrafts[this.acptIndex].interestRate=this.range1[i].interest
  617. this.form.contractDrafts[this.acptIndex].acceptor=this.range1[i].name
  618. }
  619. }
  620. this.range1.forEach(item=>{
  621. if(item.id==e.id){
  622. }
  623. })
  624. // console.log(e)
  625. },
  626. changedrPerson(e) {
  627. this.drawers = e
  628. for(let i in this.range2){
  629. if(i==e){
  630. this.form.contractDrafts[this.acptIndex].drawersId=this.range2[i].id
  631. this.form.contractDrafts[this.acptIndex].drawers=this.range2[i].name
  632. }
  633. }
  634. // this.range2.forEach(item=>{
  635. // if(item.id==e.id){
  636. // this.form.contractDrafts[this.drwIndex].drawersId=e.id
  637. // this.form.contractDrafts[this.drwIndex].drawers=e.name
  638. // }
  639. // })
  640. },
  641. openTime(index, value) {
  642. this.dateshow = true
  643. this.index = index
  644. this.opdanum = value
  645. },
  646. closeDate() {
  647. this.dateshow = false
  648. },
  649. confirm(e) {
  650. const timeFormat = uni.$u.timeFormat
  651. let form = this.form.contractDrafts
  652. if (this.opdanum == 1) {
  653. let ino =parseInt(e.value/10000).toFixed(0)*10000
  654. form[this.index].acceptDateTime = ino
  655. let nTime =form[this.index].acceptDateTime- form[this.index].expectDiscountDateTime
  656. let limitTime=Math.floor(nTime / 86400000)
  657. console.log(form[this.index].acceptDateTime,88)
  658. console.log(form[this.index].expectDiscountDateTime,88)
  659. console.log(limitTime,88)
  660. if(limitTime<=-1){
  661. this.$toast('承兑日期应该大于预计贴现日')
  662. return
  663. }
  664. form[this.index].limitTime =limitTime
  665. form[this.index].acceptDate = timeFormat(e.value, 'yyyy-mm-dd')
  666. this.getloanLimt(this.index)
  667. this.getSerMoney(this.index)
  668. this.getInterMoney(this.index)
  669. } else if (this.opdanum == 2) {
  670. form[this.index].issueDate = timeFormat(e.value, 'yyyy-mm-dd')
  671. } else if (this.opdanum == 3) {
  672. form[this.index].expireDate = timeFormat(e.value, 'yyyy-mm-dd')
  673. } else if (this.opdanum == 4) {
  674. form[this.index].expectDiscountDateTime = e.value
  675. let nTime =form[this.index].acceptDateTime- form[this.index].expectDiscountDateTime
  676. let limitTime=Math.floor(nTime / 86400000)
  677. if(limitTime<=-1){
  678. this.$toast('预计贴现日应该小于承兑日期')
  679. return
  680. }
  681. form[this.index].limitTime =limitTime
  682. form[this.index].expectDiscountDate = timeFormat(e.value, 'yyyy-mm-dd')
  683. this.getloanLimt(this.index)
  684. this.getSerMoney(this.index)
  685. this.getInterMoney(this.index)
  686. }
  687. // console.log(this.index, this.opdanum)
  688. this.dateshow = false
  689. },
  690. change(e) {
  691. console.log("e:", e);
  692. },
  693. open(e) {
  694. // console.log('open', e)
  695. },
  696. close(e) {
  697. // console.log('close', e)
  698. },
  699. change(e) {
  700. // console.log('change', e)
  701. },
  702. checkIndex(index) {
  703. this.allindex = index
  704. console.log(index)
  705. },
  706. // 删除图片
  707. async deletePic(event) {
  708. // this.checkIndex(index)
  709. console.log(this.allindex,789)
  710. if (event.name >= 4) {
  711. this.form.contractDrafts[this.allindex].picUrling.splice(event.index, 1)
  712. } else {
  713. this[`fileList${event.name}`].splice(event.index, 1)
  714. }
  715. },
  716. // 新增图片
  717. async afterRead(event) {
  718. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  719. if (event.name >= 4) {
  720. let lists = [].concat(event.file)
  721. let icurls= this.form.contractDrafts[this.allindex].picUrling
  722. let fileListLen = icurls.length
  723. lists.map((item) => {
  724. icurls.push({
  725. ...item,
  726. status: 'uploading',
  727. message: '上传中'
  728. })
  729. })
  730. for (let i = 0; i < lists.length; i++) {
  731. const result = await this.uploadFilePromise(lists[i].url)
  732. // this.form.contractDrafts[this.allindex].picUrls.push(result)
  733. let item = icurls[fileListLen]
  734. icurls.splice(fileListLen, 1, Object.assign(item, {
  735. status: 'success',
  736. message: '',
  737. url: result
  738. }))
  739. fileListLen++
  740. }
  741. }else {
  742. console.log(2222222222)
  743. let lists = [].concat(event.file)
  744. let fileListLen = this[`fileList${event.name}`].length
  745. lists.map((item) => {
  746. this[`fileList${event.name}`].push({
  747. ...item,
  748. status: 'uploading',
  749. message: '上传中'
  750. })
  751. })
  752. for (let i = 0; i < lists.length; i++) {
  753. const result = await this.uploadFilePromise(lists[i].url)
  754. let item = this[`fileList${event.name}`][fileListLen]
  755. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  756. status: 'success',
  757. message: '',
  758. url: result
  759. }))
  760. fileListLen++
  761. }
  762. }
  763. },
  764. uploadFilePromise(url) {
  765. return new Promise((resolve, reject) => {
  766. let a = uni.uploadFile({
  767. url: mainUrl + '/api/File', // 仅为示例,非真实的接口地址
  768. filePath: url,
  769. name: 'File',
  770. header: {
  771. "User-Agent": "apifox/1.0.0 (https://www.apifox.cn)"
  772. },
  773. formData: {
  774. File: JSON.stringify(url),
  775. },
  776. success: (res) => {
  777. let request = JSON.parse(res.data)
  778. setTimeout(() => {
  779. resolve(request.data.file)
  780. }, 1000)
  781. }
  782. });
  783. })
  784. },
  785. }
  786. }
  787. </script>
  788. <style lang="scss">
  789. .content {
  790. padding: 0 30rpx;
  791. box-sizing: border-box;
  792. }
  793. .addtitle {
  794. font-weight: 600;
  795. padding-top: 58rpx;
  796. font-size: 36rpx;
  797. .ty {
  798. color: #D8AB5A;
  799. }
  800. .tde {
  801. color: #D05C39;
  802. }
  803. }
  804. .listitem {
  805. .lys {
  806. display: block;
  807. font-size: 32rpx;
  808. font-weight: 600;
  809. padding-top: 40rpx;
  810. padding-bottom: 30rpx;
  811. }
  812. .inbox {
  813. padding-bottom: 20rpx;
  814. width: 100%;
  815. font-size: 30rpx;
  816. border-bottom: 1rpx solid #E8E8E8;
  817. }
  818. .chosbox {
  819. border-radius: 20rpx;
  820. // border: 1rpx solid #BEBDBB;
  821. }
  822. .calender {
  823. border-radius: 20rpx;
  824. width: 690rpx;
  825. height: 80rpx;
  826. border-radius: 20rpx;
  827. border: 1rpx solid #BEBDBB;
  828. display: flex;
  829. align-items: center;
  830. padding-left: 30rpx;
  831. font-size: 32rpx;
  832. box-sizing: border-box;
  833. .canicon {
  834. width: 34rpx;
  835. height: 34rpx;
  836. margin-right: 20rpx;
  837. image {
  838. width: 100%;
  839. height: 100%;
  840. }
  841. }
  842. }
  843. }
  844. .addnewbill {
  845. width: 200rpx;
  846. height: 78rpx;
  847. border-radius: 45rpx;
  848. border: 1rpx solid #E8E8E8;
  849. line-height: 78rpx;
  850. text-align: center;
  851. margin-top: 50rpx;
  852. margin-bottom: 200rpx;
  853. }
  854. </style>