addbill.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  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">
  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;">*支持上传pdf、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">
  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. this.again = true
  264. let obj = JSON.parse(o.obj)
  265. console.log(obj, 7897489)
  266. this.contractId = obj.contractId
  267. let form = obj.contractDrafts
  268. let inform = this.form.contractDrafts[0]
  269. inform.contractId = obj.contractId
  270. if (obj.contractDrafts) {
  271. let form = obj.contractDrafts
  272. let inform = this.form.contractDrafts[0]
  273. inform.name = form[0].name
  274. inform.id = form[0].id
  275. inform.contractId = obj.contractId
  276. inform.acceptorId = form[0].acceptorId
  277. inform.drawersId = form[0].drawersId
  278. inform.money = form[0].money
  279. inform.draftNo = form[0].draftNo
  280. inform.loanLimit = form[0].loanLimit
  281. inform.serviceRate = form[0].serviceRate
  282. inform.interestRate = form[0].interestRate
  283. inform.interest = form[0].interest
  284. inform.serviceMoney = form[0].serviceMoney
  285. inform.expectDiscountDate = form[0].expectDiscountDate
  286. inform.acceptDate = form[0].acceptDate
  287. inform.issueDate = form[0].issueDate
  288. inform.expireDate = form[0].expireDate
  289. form.forEach(item => {
  290. item.picList.forEach(i => {
  291. item.picUrling = []
  292. item.picUrling.push({
  293. "url": i
  294. })
  295. })
  296. })
  297. inform.picUrling = form[0].picUrling
  298. console.log((new Date('form[0].expectDiscountDate').getTime() / 100000).toFixed(0) * 100000, 556)
  299. console.log((new Date(form[0].expectDiscountDate).getTime() / 100000).toFixed(0) * 100000, 556)
  300. inform.expectDiscountDateTime = (new Date(form[0].expectDiscountDate).getTime() / 100000).toFixed(0) *
  301. 100000
  302. inform.acceptDateTime = (new Date(form[0].acceptDate).getTime() / 100000).toFixed(0) * 100000
  303. let nTime = inform.acceptDateTime - inform.expectDiscountDateTime
  304. inform.limitTime = Math.floor(nTime / 86400000)
  305. }
  306. console.log(this.form.contractDrafts[0], 778)
  307. }
  308. // this.initAcceptor()
  309. // this.initDrawers()
  310. },
  311. onShow() {
  312. this.initAcceptor()
  313. this.initDrawers()
  314. },
  315. methods: {
  316. loadTime() {
  317. let myDate = new Date()
  318. let wk = parseInt(Date.now() / 100000).toFixed(0) * 100000
  319. let yy = String(myDate.getFullYear())
  320. // let mm = myDate.getMonth() + 1
  321. let mm = String(myDate.getMonth() + 1 < 10 ? '0' + (myDate.getMonth() + 1) : myDate.getMonth() + 1)
  322. let dd = String(myDate.getDate() < 10 ? '0' + myDate.getDate() : myDate.getDate())
  323. let nowDate = yy + '-' + mm + '-' + dd
  324. this.form.contractDrafts.forEach(item => {
  325. item.acceptDate = nowDate
  326. item.issueDate = nowDate
  327. item.expireDate = nowDate
  328. item.expectDiscountDate = nowDate
  329. item.expectDiscountDateTime = wk
  330. item.acceptDateTime = wk
  331. let nTime = item.acceptDateTime - item.expectDiscountDateTime
  332. item.limitTime = Math.floor(nTime / 86400000);
  333. })
  334. },
  335. initAcceptor() {
  336. // 承兑人列表
  337. uni.$u.http.post('/api/Acceptor/search', {
  338. pageIndex:1,
  339. pageSize: 200,
  340. name: this.seacept
  341. }, {
  342. }, {
  343. custom: {
  344. auth: true
  345. }
  346. }).then((res) => {
  347. uni.hideLoading()
  348. this.range1 = res.result
  349. this.range1.forEach((item, index) => {
  350. this.range1[index].value = index
  351. this.range1[index].text = item.name
  352. })
  353. if (this.again) {
  354. that.range1.forEach((item, index) => {
  355. console.log(that.form.contractDrafts[0], item)
  356. if (item.id == that.form.contractDrafts[0].acceptorId) {
  357. that.form.contractDrafts[0].acceptor = index
  358. }
  359. })
  360. }
  361. }).catch((err) => {})
  362. },
  363. initDrawers() {
  364. // 出票人列表
  365. uni.$u.http.post('/api/Drawer/search', {
  366. pageIndex:1,
  367. pageSize: 200,
  368. name: this.seadra
  369. }, {
  370. custom: {
  371. auth: true
  372. }
  373. }).then((res) => {
  374. uni.hideLoading()
  375. this.range2 = res.result
  376. this.range2.forEach((item, index) => {
  377. this.range2[index].value = index
  378. this.range2[index].text = item.name
  379. })
  380. if (this.again) {
  381. that.range2.forEach((item, index) => {
  382. if (item.id == that.form.contractDrafts[0].drawersId) {
  383. that.form.contractDrafts[0].drawers = index
  384. }
  385. })
  386. }
  387. }).catch((err) => {})
  388. },
  389. searchAcceptor(e) {
  390. this.seacept = e
  391. this.initAcceptor()
  392. },
  393. searchDrawers(e) {
  394. this.seadra = e
  395. this.initDrawers()
  396. },
  397. checkacptIndex(index) {
  398. this.acptIndex = index
  399. },
  400. checkldrwIndex(index) {
  401. this.drwIndex = index
  402. },
  403. deleBill(index) {
  404. uni.showModal({
  405. title: "提示",
  406. content: "是否确认删除?",
  407. success: (res) => {
  408. if (res.confirm) {
  409. that.form.contractDrafts.splice(index)
  410. }
  411. }
  412. })
  413. },
  414. getinterestRateIndex(index) {
  415. this.rindex = index
  416. },
  417. getinterestRate(event) {
  418. this.form.contractDrafts[this.rindex].interestRate = Number(event.detail.value)
  419. this.getloanLimt(this.rindex)
  420. this.getInterMoney(this.rindex)
  421. this.getSerMoney(this.rindex)
  422. },
  423. getserviceRateIndex(index) {
  424. this.sindex = index
  425. },
  426. getserviceRate(event) {
  427. this.form.contractDrafts[this.sindex].serviceRate = Number(event.detail.value)
  428. this.getloanLimt(this.sindex)
  429. this.getInterMoney(this.sindex)
  430. this.getSerMoney(this.sindex)
  431. },
  432. getMoneyIndex(index) {
  433. this.myindex = index
  434. },
  435. getMoney(event) {
  436. this.form.contractDrafts[this.myindex].money = Number(event.detail.value)
  437. this.getloanLimt(this.myindex)
  438. this.getSerMoney(this.myindex)
  439. this.getInterMoney(this.myindex)
  440. },
  441. getloanLimt(i) {
  442. if (this.form.contractDrafts[i].money && this.form.contractDrafts[i].serviceRate && this.form
  443. .contractDrafts[i].interestRate) {
  444. this.form.contractDrafts[i].loanLimit = ((this.form.contractDrafts[i].money / (this.form
  445. .contractDrafts[
  446. i].serviceRate + this.form.contractDrafts[i].interestRate) * this.form
  447. .contractDrafts[i]
  448. .limitTime / 360) + 1).toFixed(2)
  449. }
  450. },
  451. getSerMoney(i) {
  452. if (this.form.contractDrafts[i].money && this.form.contractDrafts[i].serviceRate && this.form
  453. .contractDrafts[i].interestRate) {
  454. this.form.contractDrafts[i].serviceMoney = (((this.form.contractDrafts[i].money / (this.form
  455. .contractDrafts[i].serviceRate + this.form.contractDrafts[i].interestRate) * this
  456. .form
  457. .contractDrafts[i].limitTime / 360) + 1) * this.form.contractDrafts[i].serviceRate * this
  458. .form.contractDrafts[i].limitTime / 360).toFixed(2)
  459. }
  460. },
  461. getInterMoney(i) {
  462. if (this.form.contractDrafts[i].money && this.form.contractDrafts[i].serviceRate && this.form
  463. .contractDrafts[i].interestRate) {
  464. this.form.contractDrafts[i].interest = (((this.form.contractDrafts[i].money / (this.form
  465. .contractDrafts[
  466. i].serviceRate + this.form.contractDrafts[i].interestRate) * this.form
  467. .contractDrafts[
  468. i].limitTime / 360) + 1) * this.form.contractDrafts[i].interestRate * this.form
  469. .contractDrafts[i].limitTime / 360).toFixed(2)
  470. }
  471. },
  472. upAll() {
  473. uni.showModal({
  474. title: '提示',
  475. content: '是否上传汇票?',
  476. success: function(res) {
  477. if (res.confirm) {
  478. let form = that.form
  479. // if (form.name.length == 0) {
  480. // that.$toast('请输入合同名称')
  481. // return
  482. // }
  483. // if (that.fileList1.length == 0) {
  484. // that.$toast('请上传合同附件')
  485. // return
  486. // }
  487. // if (that.fileList2.length == 0) {
  488. // that.$toast('请上传发票附件')
  489. // return
  490. // }
  491. // if (that.fileList3.length == 0) {
  492. // that.$toast('请上贸易合同')
  493. // return
  494. // }
  495. form.contractDrafts.forEach(i => {
  496. if (i.name.length == 0) {
  497. that.$toast('请输入汇票名称')
  498. return
  499. }
  500. if (i.draftNo.length == 0) {
  501. that.$toast('请输入汇票号码')
  502. return
  503. }
  504. if (i.acceptor.length == 0) {
  505. that.$toast('请选择承兑人')
  506. return
  507. }
  508. if (i.drawers.length == 0) {
  509. that.$toast('请选择出票人')
  510. return
  511. }
  512. if (i.money.length == 0) {
  513. that.$toast('请输入金额')
  514. return
  515. }
  516. if (i.serviceRate.length == 0) {
  517. that.$toast('请输入服务费率')
  518. return
  519. }
  520. if (i.interestRate.length == 0) {
  521. that.$toast('请输入利率')
  522. return
  523. }
  524. if (i.picUrls.length == 0) {
  525. that.$toast('请上传附件')
  526. return
  527. }
  528. })
  529. // that.range2.forEach(item => {
  530. // form.contractDrafts.forEach(i => {
  531. // if (that.range2[i.drawers].name == item.name) {
  532. // i.drawersId = item.id
  533. // }
  534. // })
  535. // })
  536. // that.range1.forEach(item => {
  537. // form.contractDrafts.forEach(i => {
  538. // if (that.range1[i.acceptor].name == item.name) {
  539. // i.acceptorId = item.id
  540. // }
  541. // })
  542. // })
  543. // that.fileList1.forEach(item => {
  544. // form.invoicePics.push(item.url)
  545. // })
  546. // that.fileList2.forEach(item => {
  547. // form.pics.push(item.url)
  548. // })
  549. // that.fileList3.forEach(item => {
  550. // form.tradePics.push(item.url)
  551. // })
  552. form.contractDrafts.forEach(item => {
  553. // that.$delete(item,'expectDiscountDateTime')
  554. // that.$delete(item,'acceptDateTime')
  555. item.picUrling.forEach(i => {
  556. item.picUrls.push(i.url)
  557. })
  558. })
  559. let copyform = Object.assign([], form.contractDrafts);
  560. that.$delete(copyform, 'expectDiscountDateTime')
  561. that.$delete(copyform, 'acceptDateTime')
  562. console.log(copyform, 999)
  563. uni.showLoading()
  564. uni.$u.http.post('/api/Contract/addContractDraft', copyform, {
  565. custom: {
  566. auth: true
  567. }
  568. }).then((res) => {
  569. uni.hideLoading()
  570. that.$toast("汇票上传成功")
  571. // that.form.invoicePics = []
  572. // that.form.pics = []
  573. // that.form.tradePics = []
  574. that.form.contractDrafts.forEach(item => {
  575. item.picUrls = []
  576. })
  577. setTimeout(() => {
  578. uni.navigateBack({
  579. delta: 1
  580. })
  581. }, 500)
  582. }).catch((err) => {
  583. uni.hideLoading()
  584. that.$toast(err.msg)
  585. // that.form.invoicePics=[]
  586. // that.form.pics=[]
  587. // that.form.tradePics=[]
  588. that.form.contractDrafts.forEach(item => {
  589. item.picUrls = []
  590. })
  591. console.log(err)
  592. })
  593. } else if (res.cancel) {}
  594. }
  595. });
  596. },
  597. addNewBill() {
  598. let form = [{
  599. contractId: that.contractId,
  600. name: '',
  601. draftNo: '',
  602. acceptor: '',
  603. acceptorId: '',
  604. drawersId: '',
  605. drawers: '',
  606. money: '',
  607. acceptDate: '',
  608. issueDate: '',
  609. expireDate: '',
  610. loanLimit: '',
  611. expectDiscountDate: '',
  612. picUrls: [],
  613. picUrling: [],
  614. serviceRate: '',
  615. interestRate: '',
  616. interest: '',
  617. serviceMoney: '',
  618. limitTime: 0,
  619. expectDiscountDateTime: 0,
  620. acceptDateTime: 0
  621. }]
  622. let myDate = new Date()
  623. // let wk = Date.parse(new Date());
  624. let wk = Date.parse(new Date())
  625. let yy = String(myDate.getFullYear())
  626. // let mm = myDate.getMonth() + 1
  627. let mm = String(myDate.getMonth() + 1 < 10 ? '0' + (myDate.getMonth() + 1) : myDate.getMonth() + 1)
  628. let dd = String(myDate.getDate() < 10 ? '0' + myDate.getDate() : myDate.getDate())
  629. let nowDate = yy + '-' + mm + '-' + dd
  630. form.forEach(item => {
  631. item.acceptDate = nowDate
  632. item.issueDate = nowDate
  633. item.expireDate = nowDate
  634. item.expectDiscountDate = nowDate
  635. item.expectDiscountDateTime = wk
  636. item.acceptDateTime = wk
  637. let nTime = item.acceptDateTime - item.expectDiscountDateTime
  638. item.limitTime = Math.floor(nTime / 86400000);
  639. })
  640. this.form.contractDrafts.push(form[0])
  641. },
  642. clearValac(e) {
  643. this.form.contractDrafts[this.acptIndex].acceptorId = ''
  644. this.form.contractDrafts[this.acptIndex].serviceRate = ''
  645. this.form.contractDrafts[this.acptIndex].interestRate = ''
  646. this.form.contractDrafts[this.acptIndex].acceptor = ''
  647. },
  648. clearValdr(e) {
  649. this.form.contractDrafts[this.acptIndex].drawersId = ''
  650. this.form.contractDrafts[this.acptIndex].drawers = ''
  651. },
  652. changeacPerson(e) {
  653. this.acceptor = e
  654. if (e == "clearall") {
  655. this.form.contractDrafts[this.acptIndex].acceptorId = ''
  656. this.form.contractDrafts[this.acptIndex].serviceRate = ''
  657. this.form.contractDrafts[this.acptIndex].interestRate = ''
  658. this.form.contractDrafts[this.acptIndex].acceptor = ''
  659. } else {
  660. for (let i in this.range1) {
  661. if (i == e) {
  662. this.form.contractDrafts[this.acptIndex].acceptorId = this.range1[i].id
  663. this.form.contractDrafts[this.acptIndex].serviceRate = this.range1[i].serviceRate
  664. this.form.contractDrafts[this.acptIndex].interestRate = this.range1[i].interest
  665. this.form.contractDrafts[this.acptIndex].acceptor = this.range1[i].name
  666. }
  667. }
  668. }
  669. },
  670. changedrPerson(e) {
  671. this.drawers = e
  672. if (e == "clearall") {
  673. this.form.contractDrafts[this.acptIndex].drawersId = ''
  674. this.form.contractDrafts[this.acptIndex].drawers = ''
  675. } else {
  676. for (let i in this.range2) {
  677. if (i == e) {
  678. this.form.contractDrafts[this.acptIndex].drawersId = this.range2[i].id
  679. this.form.contractDrafts[this.acptIndex].drawers = this.range2[i].name
  680. }
  681. }
  682. }
  683. },
  684. openTime(index, value) {
  685. this.dateshow = true
  686. this.index = index
  687. this.opdanum = value
  688. },
  689. closeDate() {
  690. this.dateshow = false
  691. },
  692. confirm(e) {
  693. const timeFormat = uni.$u.timeFormat
  694. let form = this.form.contractDrafts
  695. if (this.opdanum == 1) {
  696. let ino = parseInt(e.value / 10000).toFixed(0) * 10000
  697. form[this.index].acceptDateTime = ino
  698. let nTime = form[this.index].acceptDateTime - form[this.index].expectDiscountDateTime
  699. let limitTime = Math.floor(nTime / 86400000)
  700. console.log(form[this.index].acceptDateTime, 88)
  701. console.log(form[this.index].expectDiscountDateTime, 88)
  702. console.log(limitTime, 88)
  703. if (limitTime <= -1) {
  704. this.$toast('承兑日期应该大于预计贴现日')
  705. return
  706. }
  707. form[this.index].limitTime = limitTime
  708. form[this.index].acceptDate = timeFormat(e.value, 'yyyy-mm-dd')
  709. this.getloanLimt(this.index)
  710. this.getSerMoney(this.index)
  711. this.getInterMoney(this.index)
  712. } else if (this.opdanum == 2) {
  713. form[this.index].issueDate = timeFormat(e.value, 'yyyy-mm-dd')
  714. } else if (this.opdanum == 3) {
  715. form[this.index].expireDate = timeFormat(e.value, 'yyyy-mm-dd')
  716. } else if (this.opdanum == 4) {
  717. form[this.index].expectDiscountDateTime = e.value
  718. let nTime = form[this.index].acceptDateTime - form[this.index].expectDiscountDateTime
  719. let limitTime = Math.floor(nTime / 86400000)
  720. if (limitTime <= -1) {
  721. this.$toast('预计贴现日应该小于承兑日期')
  722. return
  723. }
  724. form[this.index].limitTime = limitTime
  725. form[this.index].expectDiscountDate = timeFormat(e.value, 'yyyy-mm-dd')
  726. this.getloanLimt(this.index)
  727. this.getSerMoney(this.index)
  728. this.getInterMoney(this.index)
  729. }
  730. // console.log(this.index, this.opdanum)
  731. this.dateshow = false
  732. },
  733. change(e) {
  734. console.log("e:", e);
  735. },
  736. open(e) {
  737. // console.log('open', e)
  738. },
  739. close(e) {
  740. // console.log('close', e)
  741. },
  742. change(e) {
  743. // console.log('change', e)
  744. },
  745. checkIndex(index) {
  746. this.allindex = index
  747. },
  748. // 删除图片
  749. async deletePic(event) {
  750. // this.checkIndex(index)
  751. console.log(this.allindex, 789)
  752. if (event.name >= 4) {
  753. this.form.contractDrafts[this.allindex].picUrling.splice(event.index, 1)
  754. } else {
  755. this[`fileList${event.name}`].splice(event.index, 1)
  756. }
  757. },
  758. // 新增图片
  759. async afterRead(event) {
  760. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  761. if (event.name >= 4) {
  762. let lists = [].concat(event.file)
  763. let icurls = this.form.contractDrafts[this.allindex].picUrling
  764. let fileListLen = icurls.length
  765. lists.map((item) => {
  766. icurls.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. // this.form.contractDrafts[this.allindex].picUrls.push(result)
  775. let item = icurls[fileListLen]
  776. icurls.splice(fileListLen, 1, Object.assign(item, {
  777. status: 'success',
  778. message: '',
  779. url: result
  780. }))
  781. fileListLen++
  782. }
  783. } else {
  784. let lists = [].concat(event.file)
  785. let fileListLen = this[`fileList${event.name}`].length
  786. lists.map((item) => {
  787. this[`fileList${event.name}`].push({
  788. ...item,
  789. status: 'uploading',
  790. message: '上传中'
  791. })
  792. })
  793. for (let i = 0; i < lists.length; i++) {
  794. const result = await this.uploadFilePromise(lists[i].url)
  795. let item = this[`fileList${event.name}`][fileListLen]
  796. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  797. status: 'success',
  798. message: '',
  799. url: result
  800. }))
  801. fileListLen++
  802. }
  803. }
  804. },
  805. uploadFilePromise(url) {
  806. return new Promise((resolve, reject) => {
  807. let a = uni.uploadFile({
  808. url: mainUrl + '/api/File', // 仅为示例,非真实的接口地址
  809. filePath: url,
  810. name: 'File',
  811. header: {
  812. "User-Agent": "apifox/1.0.0 (https://www.apifox.cn)"
  813. },
  814. formData: {
  815. File: JSON.stringify(url),
  816. },
  817. success: (res) => {
  818. let request = JSON.parse(res.data)
  819. setTimeout(() => {
  820. resolve(request.data.file)
  821. }, 1000)
  822. }
  823. });
  824. })
  825. },
  826. }
  827. }
  828. </script>
  829. <style lang="scss">
  830. .content {
  831. padding: 0 30rpx;
  832. box-sizing: border-box;
  833. }
  834. .addtitle {
  835. font-weight: 600;
  836. padding-top: 58rpx;
  837. font-size: 36rpx;
  838. .ty {
  839. color: #D8AB5A;
  840. }
  841. .tde {
  842. color: #D05C39;
  843. }
  844. }
  845. .listitem {
  846. .lys {
  847. display: block;
  848. font-size: 32rpx;
  849. font-weight: 600;
  850. padding-top: 40rpx;
  851. padding-bottom: 30rpx;
  852. }
  853. .inbox {
  854. padding-bottom: 20rpx;
  855. width: 100%;
  856. font-size: 30rpx;
  857. border-bottom: 1rpx solid #E8E8E8;
  858. }
  859. .chosbox {
  860. border-radius: 20rpx;
  861. // border: 1rpx solid #BEBDBB;
  862. }
  863. .calender {
  864. border-radius: 20rpx;
  865. width: 690rpx;
  866. height: 80rpx;
  867. border-radius: 20rpx;
  868. border: 1rpx solid #BEBDBB;
  869. display: flex;
  870. align-items: center;
  871. padding-left: 30rpx;
  872. font-size: 32rpx;
  873. box-sizing: border-box;
  874. .canicon {
  875. width: 34rpx;
  876. height: 34rpx;
  877. margin-right: 20rpx;
  878. image {
  879. width: 100%;
  880. height: 100%;
  881. }
  882. }
  883. }
  884. }
  885. .addnewbill {
  886. width: 200rpx;
  887. height: 78rpx;
  888. border-radius: 45rpx;
  889. border: 1rpx solid #E8E8E8;
  890. line-height: 78rpx;
  891. text-align: center;
  892. margin-top: 50rpx;
  893. margin-bottom: 200rpx;
  894. }
  895. </style>