upcontract.vue 28 KB

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