addbill.vue 28 KB

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