123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898 |
- <template>
- <view class="content">
- <view class="listitem">
- <text class="lys">合同名称</text>
- <view class="inbox">
- <input type="text" v-model="form.name" placeholder="请输入合同的名称" placeholder-style="color:#BEBDBB" />
- </view>
- </view>
- <!-- <view class="listitem">
- <text class="lys">合同编号</text>
- <view class="inbox flex2">
- <input type="text" v-model="form.tax_no" placeholder="请输入合同的编号" placeholder-style="color:#BEBDBB" />
- <view class="flex7">
- <text style="color: #E8E8E8;">|</text>
- <text style="padding-left: 20rpx;display: block;">待确认</text>
- </view>
- </view>
- </view> -->
- <view class="listitem">
- <view class="" style="display: flex;align-content: center;">
- <text class="lys">合同附件</text>
- <text
- style="font-size: 24rpx; color:#D05C39;padding-top: 45rpx;padding-left: 20rpx;">*支持上传pdf、jpg/jpeg、png格式</text>
- </view>
- <view class="inbox" style="border: none;padding-bottom: 0">
- <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
- :maxCount="10" width="100" height="100"></u-upload>
- </view>
- </view>
- <view class="listitem" style="border: none;">
- <view class="" style="display: flex;align-content: center;">
- <text class="lys">发票附件</text>
- <text
- style="font-size: 24rpx; color:#D05C39;padding-top: 45rpx;padding-left: 20rpx;">*支持上传pdf、jpg/jpeg、png格式</text>
- </view>
- <view class="inbox" style="border: none;padding-bottom: 0">
- <u-upload :fileList="fileList2" @afterRead="afterRead" @delete="deletePic" name="2" multiple
- :maxCount="10" width="100" height="100"></u-upload>
- </view>
- </view>
- <view class="listitem">
- <view class="" style="display: flex;align-content: center;">
- <text class="lys">贸易合同</text>
- <text
- style="font-size: 24rpx; color:#D05C39;padding-top: 45rpx;padding-left: 20rpx;">*支持上传pdf、jpg/jpeg、png格式</text>
- </view>
- <view class="inbox" style="border: none;padding-bottom: 0">
- <u-upload :fileList="fileList3" @afterRead="afterRead" @delete="deletePic" name="3" multiple
- :maxCount="10" width="100" height="100"></u-upload>
- </view>
- </view>
- <view v-for="(item,index) in form.contractDrafts" :key="index" v-if="!openhe">
- <view class="addtitle flex6">
- <text class="ty">汇票{{index+1}}</text>
- <text class="tde" @click="deleBill" v-if="index>0">删除</text>
- </view>
- <view class="listitem">
- <text class="lys">汇票名称</text>
- <view class="inbox">
- <input type="text" v-model="item.name" placeholder="请输入汇票的名称" placeholder-style="color:#BEBDBB" />
- </view>
- </view>
- <view class="listitem">
- <text class="lys">汇票号码</text>
- <view class="inbox">
- <input type="text" v-model="item.draftNo" placeholder="请输入汇票的号码"
- placeholder-style="color:#BEBDBB" />
- </view>
- </view>
- <view class="listitem">
- <text class="lys">承兑人</text>
- <view class="chosbox" @click="checkacptIndex(index)">
- <uni-data-select v-model="item.acceptor" :localdata="range1" @change="changeacPerson"
- :showas="false" :plname="'搜索兑换人名称'" @search="searchAcceptor"></uni-data-select>
- </view>
- </view>
- <view class="listitem">
- <text class="lys">出票人</text>
- <view class="chosbox" @click="checkldrwIndex(index)">
- <uni-data-select v-model="item.drawers" :localdata="range2" @change="changedrPerson"
- :plname="'搜索出票人名称'" @search="searchDrawers"></uni-data-select>
- </view>
- </view>
- <view class="listitem">
- <text class="lys">金额</text>
- <view class="inbox">
- <input type="digit" v-model="item.money" placeholder="请输入汇票的金额" placeholder-style="color:#BEBDBB"
- @input="getMoney" @blur="getMoneyIndex(index)" />
- </view>
- </view>
- <view class="listitem">
- <text class="lys">承兑日期</text>
- <view class="calender" @click="openTime(index,1)">
- <view class="canicon">
- <image src="../../static/img/canlen.png" mode="aspectFill"></image>
- </view>
- <text>{{item.acceptDate}}</text>
- </view>
- </view>
- <view class="listitem">
- <text class="lys">出票日期</text>
- <view class="calender" @click="openTime(index,2)">
- <view class="canicon">
- <image src="../../static/img/canlen.png" mode="aspectFill"></image>
- </view>
- <text>{{item.issueDate}}</text>
- </view>
- </view>
- <view class="listitem">
- <text class="lys">汇票到期日</text>
- <view class="calender" @click="openTime(index,3)">
- <view class="canicon">
- <image src="../../static/img/canlen.png" mode="aspectFill"></image>
- </view>
- <text>{{item.expireDate}}</text>
- </view>
- </view>
- <view class="listitem">
- <text class="lys">预计贴现日</text>
- <view class="calender" @click="openTime(index,4)">
- <view class="canicon">
- <image src="../../static/img/canlen.png" mode="aspectFill"></image>
- </view>
- <text>{{item.expectDiscountDate}}</text>
- </view>
- </view>
- <view class="listitem">
- <text class="lys">最高贷款额度</text>
- <view class="inbox">
- <input type="text" v-model="item.loanLimit" placeholder="自动计算得出" placeholder-style="color:#1F242A"
- disabled="true" />
- </view>
- </view>
- <view class="flex4">
- <view class="listitem">
- <text class="lys">服务费率</text>
- <view class="inbox">
- <input type="digit" v-model="item.serviceRate+'%'" placeholder="显示对于费率"
- placeholder-style="color:#BEBDBB" @blur="getserviceRate" @input="getserviceRateIndex(index)"
- disabled="true" />
- </view>
- </view>
- <view class="listitem">
- <text class="lys">服务费</text>
- <view class="inbox">
- <input type="text" v-model="item.serviceMoney" placeholder="自动计算得出"
- placeholder-style="color:#BEBDBB" disabled="true" />
- </view>
- </view>
- </view>
- <view class="flex4">
- <view class="listitem">
- <text class="lys">利率</text>
- <view class="inbox">
- <input type="digit" v-model="item.interestRate+'%'" placeholder="显示对于利率"
- placeholder-style="color:#BEBDBB" @blur="getinterestRate"
- @input="getinterestRateIndex(index)" disabled="true" />
- </view>
- </view>
- <view class="listitem">
- <text class="lys">利息</text>
- <view class="inbox">
- <input type="text" v-model="item.interest" placeholder="自动计算得出"
- placeholder-style="color:#BEBDBB" disabled="true" />
- </view>
- </view>
- </view>
- <view class="listitem">
- <view class="" style="display: flex;align-content: center;">
- <text class="lys">上传附件</text>
- <text
- style="font-size: 24rpx; color:#D05C39;padding-top: 45rpx;padding-left: 20rpx;">*支持上传pdf、jpg/jpeg、png格式</text>
- </view>
- <view class="inbox" style="border: none;padding-bottom: 0;" @click="checkIndex(index)">
- <u-upload :fileList="item.picUrling" @afterRead="afterRead" @delete="deletePic" :name="index+4"
- :checkedindex=index multiple :maxCount="10" width="100" height="100"></u-upload>
- </view>
- </view>
- </view>
- <view class="addnewbill" @click="addNewBill" v-if="!openhe">
- + 新增汇票
- </view>
- <view class="safebt"></view>
- <view class="newbill flex1" @click="upAll">
- <view class="newbillbtn">
- <text>确认上传</text>
- </view>
- </view>
- <u-datetime-picker :show="dateshow" mode="date" @confirm="confirm" @cancel="closeDate" v-model="start">
- </u-datetime-picker>
- </view>
- </template>
- <script>
- let that
- import {
- mainUrl
- } from '@/http/baseUrl.js';
- import calllips from "@/componet/calllips/calllips.vue"
- export default {
- components: {
- calllips
- },
- data() {
- return {
- editall: false,
- quan: false,
- dateshow: false,
- opdanum: '',
- state: '',
- index: 0,
- start: Number(new Date()),
- fileList1: [],
- fileList2: [],
- fileList3: [],
- fileList4: [],
- allindex: 0,
- seacept: '',
- seadra: '',
- form: {
- name: '',
- supplierId: '',
- invoicePics: [],
- pics: [],
- tradePics: [],
- contractDrafts: [{
- name: '',
- draftNo: '',
- acceptor: '',
- acceptorId: '',
- drawersId: '',
- drawers: '',
- money: '',
- acceptDate: '',
- issueDate: '',
- expireDate: '',
- loanLimit: '',
- expectDiscountDate: '',
- picUrls: [],
- picUrling: [],
- serviceRate: '',
- interestRate: '',
- interest: '',
- serviceMoney: '',
- limitTime: 0,
- expectDiscountDateTime: 0,
- acceptDateTime: 0
- }, ],
- },
- range1: [],
- range2: [],
- myindex: 0,
- sindex: 0,
- rindex: 0,
- acptIndex: 0,
- drwIndex: 0,
- openhe:false
- }
- },
- onLoad(o) {
- that = this
- this.form.supplierId = uni.getStorageSync('supplierId')
- // console.log(this.form.supplierId,778)
- this.loadTime()
- if (o.obj) {
- let form = JSON.parse(o.obj)
- this.openhe=true
- const newData1 = form.invoicePicList.map((item) => {
- return {
- url: item,
- }
- })
- this.fileList1=newData1
- const newData2 = form.picList.map((item) => {
- return {
- url: item,
- }
- })
- this.fileList2=newData2
- const newData3 = form.tradePicList.map((item) => {
- return {
- url: item,
- }
- })
- this.fileList3=newData3
- this.form.name = form.name
- this.form.id = form.id
- this.$delete(this.form,'contractDrafts')
- }
- },
- onShow() {
- this.initAcceptor()
- this.initDrawers()
- },
- methods: {
- loadTime() {
- let myDate = new Date()
- let wk = parseInt(Date.now() / 100000).toFixed(0) * 100000
- let yy = String(myDate.getFullYear())
- // let mm = myDate.getMonth() + 1
- let mm = String(myDate.getMonth() + 1 < 10 ? '0' + (myDate.getMonth() + 1) : myDate.getMonth() + 1)
- let dd = String(myDate.getDate() < 10 ? '0' + myDate.getDate() : myDate.getDate())
- let nowDate = yy + '-' + mm + '-' + dd
- this.form.contractDrafts.forEach(item => {
- item.acceptDate = nowDate
- item.issueDate = nowDate
- item.expireDate = nowDate
- item.expectDiscountDate = nowDate
- item.expectDiscountDateTime = wk
- item.acceptDateTime = wk
- let nTime = item.acceptDateTime - item.expectDiscountDateTime
- item.limitTime = Math.floor(nTime / 86400000);
- })
- },
- initAcceptor() {
- // 承兑人列表
- uni.$u.http.post('/api/Acceptor/search', {
- name: this.seacept
- }, {
- }, {
- custom: {
- auth: true
- }
- }).then((res) => {
- uni.hideLoading()
- this.range1 = res.result
- // for(let i in this.range1){
- // }
- this.range1.forEach((item, index) => {
- this.range1[index].value = index
- this.range1[index].text = item.name
- })
- }).catch((err) => {})
- },
- initDrawers() {
- // 出票人列表
- uni.$u.http.post('/api/Drawer/search', {
- name: this.seadra
- }, {
- custom: {
- auth: true
- }
- }).then((res) => {
- uni.hideLoading()
- this.range2 = res.result
- this.range2.forEach((item, index) => {
- this.range2[index].value = index
- this.range2[index].text = item.name
- })
- }).catch((err) => {})
- },
- searchAcceptor(e) {
- this.seacept = e
- this.initAcceptor()
- },
- searchDrawers(e) {
- this.seadra = e
- this.initDrawers()
- },
- checkacptIndex(index) {
- this.acptIndex = index
- },
- checkldrwIndex(index) {
- this.drwIndex = index
- },
- deleBill(index) {
- uni.showModal({
- title: "提示",
- content: "是否确认删除?",
- success: (res) => {
- if (res.confirm) {
- that.form.contractDrafts.splice(index, 1)
- }
- }
- })
- },
- getinterestRateIndex(index) {
- this.rindex = index
- },
- getinterestRate(event) {
- this.form.contractDrafts[this.rindex].interestRate = Number(event.detail.value)
- this.getloanLimt(this.rindex)
- this.getInterMoney(this.rindex)
- this.getSerMoney(this.rindex)
- },
- getserviceRateIndex(index) {
- this.sindex = index
- },
- getserviceRate(event) {
- this.form.contractDrafts[this.sindex].serviceRate = Number(event.detail.value)
- this.getloanLimt(this.sindex)
- this.getInterMoney(this.sindex)
- this.getSerMoney(this.sindex)
- },
- getMoneyIndex(index) {
- this.myindex = index
- },
- getMoney(event) {
- this.form.contractDrafts[this.myindex].money = Number(event.detail.value)
- this.getloanLimt(this.myindex)
- this.getSerMoney(this.myindex)
- this.getInterMoney(this.myindex)
- },
- getloanLimt(i) {
- if (this.form.contractDrafts[i].money && this.form.contractDrafts[i].serviceRate && this.form
- .contractDrafts[i].interestRate) {
- 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 + 1).toFixed(2)
- }
- },
- getSerMoney(i) {
- if (this.form.contractDrafts[i].money && this.form.contractDrafts[i].serviceRate && this.form
- .contractDrafts[i].interestRate) {
- 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 + 1) * this.form.contractDrafts[i].serviceRate * this
- .form.contractDrafts[i].limitTime / 360).toFixed(2)
- }
- },
- getInterMoney(i) {
- if (this.form.contractDrafts[i].money && this.form.contractDrafts[i].serviceRate && this.form
- .contractDrafts[i].interestRate) {
- 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 + 1) * this.form.contractDrafts[i].interestRate * this.form
- .contractDrafts[i].limitTime / 360).toFixed(2)
- }
- },
- upAll() {
- uni.showModal({
- title: '提示',
- content: '是否上传合同?',
- success: function(res) {
- if (res.confirm) {
- let form = that.form
- if (form.name.length == 0) {
- that.$toast('请输入合同名称')
- return
- }
- if (that.fileList1.length == 0) {
- that.$toast('请上传合同附件')
- return
- }
- if (that.fileList2.length == 0) {
- that.$toast('请上传发票附件')
- return
- }
- if (that.fileList3.length == 0) {
- that.$toast('请上传贸易合同')
- return
- }
- that.fileList1.forEach(item => {
- form.invoicePics.push(item.url)
- })
- that.fileList2.forEach(item => {
- form.pics.push(item.url)
- })
- that.fileList3.forEach(item => {
- form.tradePics.push(item.url)
- })
- if(!that.openhe){
- form.contractDrafts.forEach(i => {
- if (i.name.length == 0) {
- that.$toast('请输入汇票名称')
- return
- }
- if (i.draftNo.length == 0) {
- that.$toast('请输入汇票号码')
- return
- }
- if (i.acceptor.length == 0) {
- that.$toast('请选择承兑人')
- return
- }
- if (i.drawers.length == 0) {
- that.$toast('请选择出票人')
- return
- }
- if (i.money.length == 0) {
- that.$toast('请输入金额')
- return
- }
-
- if (i.serviceRate.length == 0) {
- that.$toast('请输入服务费率')
- return
- }
- if (i.interestRate.length == 0) {
- that.$toast('请输入利率')
- return
- }
- if (i.picUrls.length == 0) {
- that.$toast('请上传附件')
- return
- }
-
- })
-
- form.contractDrafts.forEach(item => {
- item.picUrling.forEach(i => {
- item.picUrls.push(i.url)
- })
- })
- }
-
- // that.range2.forEach(item => {
- // form.contractDrafts.forEach(i => {
- // if (that.range2[i.drawers].name == item.name) {
- // i.drawersId = item.id
- // }
- // })
- // })
- // that.range1.forEach(item => {
- // form.contractDrafts.forEach(i => {
- // if (that.range1[i.acceptor].name == item.name) {
- // i.acceptorId = item.id
- // }
- // })
- // })
-
-
- uni.showLoading()
- uni.$u.http.post('/api/Contract', form, {
- custom: {
- auth: true
- }
- }).then((res) => {
- uni.hideLoading()
- that.$toast("合同上传成功")
- that.form.invoicePics = []
- that.form.pics = []
- that.form.tradePics = []
- if(!that.openhe){
- that.form.contractDrafts.forEach(item => {
- item.picUrls = []
- })
- }
- setTimeout(()=>{
- uni.navigateBack({
- delta:1
- })
- },500)
- }).catch((err) => {
- uni.hideLoading()
- that.$toast(err.msg)
- that.form.invoicePics = []
- that.form.pics = []
- that.form.tradePics = []
- if(!that.openhe){
- that.form.contractDrafts.forEach(item => {
- item.picUrls = []
- })
- }
- console.log(err)
- })
-
-
- } else if (res.cancel) {}
- }
- });
- },
- addNewBill() {
- let form = [{
- name: '',
- draftNo: '',
- acceptor: '',
- acceptorId: '',
- drawersId: '',
- drawers: '',
- money: '',
- acceptDate: '',
- issueDate: '',
- expireDate: '',
- loanLimit: '',
- expectDiscountDate: '',
- picUrls: [],
- picUrling: [],
- serviceRate: '',
- interestRate: '',
- interest: '',
- serviceMoney: '',
- limitTime: 0,
- expectDiscountDateTime: 0,
- acceptDateTime: 0
- }]
- let myDate = new Date()
- // let wk = Date.parse(new Date());
- let wk = Date.parse(new Date())
- console.log(wk)
- let yy = String(myDate.getFullYear())
- // let mm = myDate.getMonth() + 1
- let mm = String(myDate.getMonth() + 1 < 10 ? '0' + (myDate.getMonth() + 1) : myDate.getMonth() + 1)
- let dd = String(myDate.getDate() < 10 ? '0' + myDate.getDate() : myDate.getDate())
- let nowDate = yy + '-' + mm + '-' + dd
- form.forEach(item => {
- item.acceptDate = nowDate
- item.issueDate = nowDate
- item.expireDate = nowDate
- item.expectDiscountDate = nowDate
- item.expectDiscountDateTime = wk
- item.acceptDateTime = wk
- let nTime = item.acceptDateTime - item.expectDiscountDateTime
- item.limitTime = Math.floor(nTime / 86400000);
- })
- this.form.contractDrafts.push(form[0])
- },
- changeacPerson(e) {
- console.log(e, 88)
- this.acceptor = e
- for (let i in this.range1) {
- if (i == e) {
- this.form.contractDrafts[this.acptIndex].acceptorId = this.range1[i].id
- this.form.contractDrafts[this.acptIndex].serviceRate = this.range1[i].serviceRate
- this.form.contractDrafts[this.acptIndex].interestRate = this.range1[i].interest
- this.form.contractDrafts[this.acptIndex].acceptor = this.range1[i].name
- }
- }
- this.range1.forEach(item => {
- if (item.id == e.id) {
- }
- })
- // console.log(e)
- },
- changedrPerson(e) {
- this.drawers = e
- for (let i in this.range2) {
- if (i == e) {
- this.form.contractDrafts[this.acptIndex].drawersId = this.range2[i].id
- this.form.contractDrafts[this.acptIndex].drawers = this.range2[i].name
- }
- }
- // this.range2.forEach(item=>{
- // if(item.id==e.id){
- // this.form.contractDrafts[this.drwIndex].drawersId=e.id
- // this.form.contractDrafts[this.drwIndex].drawers=e.name
- // }
- // })
- },
- openTime(index, value) {
- this.dateshow = true
- this.index = index
- this.opdanum = value
- },
- closeDate() {
- this.dateshow = false
- },
- confirm(e) {
- const timeFormat = uni.$u.timeFormat
- let form = this.form.contractDrafts
- if (this.opdanum == 1) {
- let ino = parseInt(e.value / 10000).toFixed(0) * 10000
- form[this.index].acceptDateTime = ino
- let nTime = form[this.index].acceptDateTime - form[this.index].expectDiscountDateTime
- let limitTime = Math.floor(nTime / 86400000)
- console.log(form[this.index].acceptDateTime, 88)
- console.log(form[this.index].expectDiscountDateTime, 88)
- console.log(limitTime, 88)
- if (limitTime <= -1) {
- this.$toast('承兑日期应该大于预计贴现日')
- return
- }
- form[this.index].limitTime = limitTime
- form[this.index].acceptDate = timeFormat(e.value, 'yyyy-mm-dd')
- this.getloanLimt(this.index)
- this.getSerMoney(this.index)
- this.getInterMoney(this.index)
- } else if (this.opdanum == 2) {
- form[this.index].issueDate = timeFormat(e.value, 'yyyy-mm-dd')
- } else if (this.opdanum == 3) {
- form[this.index].expireDate = timeFormat(e.value, 'yyyy-mm-dd')
- } else if (this.opdanum == 4) {
- form[this.index].expectDiscountDateTime = e.value
- let nTime = form[this.index].acceptDateTime - form[this.index].expectDiscountDateTime
- let limitTime = Math.floor(nTime / 86400000)
- if (limitTime <= -1) {
- this.$toast('预计贴现日应该小于承兑日期')
- return
- }
- form[this.index].limitTime = limitTime
- form[this.index].expectDiscountDate = timeFormat(e.value, 'yyyy-mm-dd')
- this.getloanLimt(this.index)
- this.getSerMoney(this.index)
- this.getInterMoney(this.index)
- }
- // console.log(this.index, this.opdanum)
- this.dateshow = false
- },
- change(e) {
- console.log("e:", e);
- },
- open(e) {
- // console.log('open', e)
- },
- close(e) {
- // console.log('close', e)
- },
- change(e) {
- // console.log('change', e)
- },
- checkIndex(index) {
- this.allindex = index
- console.log(index)
- },
- // 删除图片
- async deletePic(event) {
- // this.checkIndex(index)
- console.log(this.allindex, 789)
- if (event.name >= 4) {
- this.form.contractDrafts[this.allindex].picUrling.splice(event.index, 1)
- } else {
- this[`fileList${event.name}`].splice(event.index, 1)
- }
- },
- // 新增图片
- async afterRead(event) {
- // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
- if (event.name >= 4) {
- console.log(2222222222999)
- let lists = [].concat(event.file)
- let icurls = this.form.contractDrafts[this.allindex].picUrling
- let fileListLen = icurls.length
- lists.map((item) => {
- icurls.push({
- ...item,
- status: 'uploading',
- message: '上传中'
- })
- })
- for (let i = 0; i < lists.length; i++) {
- const result = await this.uploadFilePromise(lists[i].url)
- // this.form.contractDrafts[this.allindex].picUrls.push(result)
- let item = icurls[fileListLen]
- icurls.splice(fileListLen, 1, Object.assign(item, {
- status: 'success',
- message: '',
- url: result
- }))
- fileListLen++
- }
- } else {
- console.log(2222222222)
- let lists = [].concat(event.file)
- let fileListLen = this[`fileList${event.name}`].length
- lists.map((item) => {
- this[`fileList${event.name}`].push({
- ...item,
- status: 'uploading',
- message: '上传中'
- })
- })
- for (let i = 0; i < lists.length; i++) {
- const result = await this.uploadFilePromise(lists[i].url)
- let item = this[`fileList${event.name}`][fileListLen]
- this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
- status: 'success',
- message: '',
- url: result
- }))
- fileListLen++
- }
- }
- },
- uploadFilePromise(url) {
- return new Promise((resolve, reject) => {
- let a = uni.uploadFile({
- url: mainUrl + '/api/File', // 仅为示例,非真实的接口地址
- filePath: url,
- name: 'File',
- header: {
- "User-Agent": "apifox/1.0.0 (https://www.apifox.cn)"
- },
- formData: {
- File: JSON.stringify(url),
- },
- success: (res) => {
- let request = JSON.parse(res.data)
- setTimeout(() => {
- resolve(request.data.file)
- }, 1000)
- }
- });
- })
- },
- }
- }
- </script>
- <style lang="scss">
- .content {
- padding: 0 30rpx;
- box-sizing: border-box;
- }
- .addtitle {
- font-weight: 600;
- padding-top: 58rpx;
- font-size: 36rpx;
- .ty {
- color: #D8AB5A;
- }
- .tde {
- color: #D05C39;
- }
- }
- .listitem {
- .lys {
- display: block;
- font-size: 32rpx;
- font-weight: 600;
- padding-top: 40rpx;
- padding-bottom: 30rpx;
- }
- .inbox {
- padding-bottom: 20rpx;
- width: 100%;
- font-size: 30rpx;
- border-bottom: 1rpx solid #E8E8E8;
- }
- .chosbox {
- border-radius: 20rpx;
- // border: 1rpx solid #BEBDBB;
- }
- .calender {
- border-radius: 20rpx;
- width: 690rpx;
- height: 80rpx;
- border-radius: 20rpx;
- border: 1rpx solid #BEBDBB;
- display: flex;
- align-items: center;
- padding-left: 30rpx;
- font-size: 32rpx;
- box-sizing: border-box;
- .canicon {
- width: 34rpx;
- height: 34rpx;
- margin-right: 20rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- }
- }
- .addnewbill {
- width: 200rpx;
- height: 78rpx;
- border-radius: 45rpx;
- border: 1rpx solid #E8E8E8;
- line-height: 78rpx;
- text-align: center;
- margin-top: 50rpx;
- margin-bottom: 200rpx;
- }
- </style>
|