addbill.vue 27 KB

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