upcontract.vue 25 KB

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