upcontract.vue 29 KB

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