123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065 |
- <template>
- <view class="container">
- <view class="header">
- <view class="segmented-control-item" :class="{ 'active': activeTab === 0 }" @click="switchTab(0)">上传
- <view class="underline" v-show="activeTab === 0"></view>
- </view>
- <view class="segmented-control-item" :class="{ 'active': activeTab === 1 }" @click="switchTab(1)">已上传
- <view class="underline" v-show="activeTab === 1"></view>
- </view>
- </view>
- <!-- <view class="absolute-element"> -->
- <swiper class="scroll-view swiper" :current="activeTab" duration="0" @change="handleSwiperChange">
- <swiper-item>
- <scroll-view scroll-y="true" :style="{'height': clientHeight + 'px'}">
- <!-- <scroll-view scroll-y="true" style="height: 100%;" > -->
- <view class="content" v-show="activeTab === 0">
- <view class="list" v-for="(item, index) in list" :key="index">
- <view class="list-item">
- <view style="padding-top: 5px;">
- <checkbox-group @change="toggleSelect(index)">
- <checkbox
- style="transform: scale(0.6,0.6);activeBackgroundColor: #253a6f;iconColor: #253a6f;"
- v-model="selected[index]" :checked="selected[index]" :key="item.id" />
- </checkbox-group>
- </view>
- <view>
- <view class="item" @click="goDetailPage(item.uid)">
- <image class="icon" src="/static/meeting.png" />
- <text class="text">{{ item.exhibitionName }}</text>
- </view>
- <view class="item" @click="goDetailPage(item.uid)">
- <image class="icon" src="/static/customer.png" />
- <text class="text">{{ item.customerName }}</text>
- </view>
- <view class="item" @click="goDetailPage(item.uid)">
- <image class="icon" src="/static/receiver.png" />
- <text class="text">{{ item.receiver }}</text>
- </view>
- <view class="item1" style=""
- :style="{ 'flex-wrap': item.fileSavePath.length <= 2 ? 'nowrap' : 'wrap' }">
- <u--image class="image-item" v-for="(element, i) in item.fileSavePath" :key="i"
- :src="element" width="80px" height="80px"
- @click="previewImage(item,i)"></u--image>
- </view>
- <view class="item">
- <text class="text">备注信息:{{ item.exhibitionNote }}</text>
- </view>
- <!-- <view class="item">
- <button style="width:100%;background-color: #253a6f;color: white;height: 40px;font-size: 14px;line-height: 40px;
- text-align: center;margin-top: 50px;" @click="upload(index)">上传</button>
- </view> -->
- </view>
- </view>
- <button style="background-color: #253a6f;color: white;height: 40px;font-size: 14px;line-height: 40px;
- text-align: center;margin-top: 50px;margin-bottom: 10px;width: 90%;" :disabled="uploadingStatus[index]"
- @click="upload(index)"><span v-if="uploadingStatus[index]">上传中...</span>
- <span v-else>上传</span></button>
- </view>
- </view>
- </scroll-view>
- </swiper-item>
- <swiper-item>
- <!-- <scroll-view scroll-y="true" style="height: 100%;"> -->
- <scroll-view scroll-y="true" :style="{'height': clientHeight + 'px'}">
- <view class="content" v-show="activeTab === 1">
- <view class="list" v-for="(item, index) in uploadedList" :key="index">
- <view class="list-item">
- <view style="padding-top: 5px;">
- <checkbox-group @change="toggleSelect1(index)">
- <checkbox
- style="transform: scale(0.6,0.6);activeBackgroundColor: #253a6f;iconColor: #253a6f;"
- v-model="selected1[index]" :checked="selected1[index]" :key="item.id" />
- </checkbox-group>
- </view>
- <view>
- <view class="item" @click="goDetailPage(item.uid)">
- <image class="icon" src="/static/meeting.png" />
- <text class="text">{{ item.exhibitionName }}</text>
- </view>
- <view class="item" @click="goDetailPage(item.uid)">
- <image class="icon" src="/static/customer.png" />
- <text class="text">{{ item.customerName }}</text>
- </view>
- <view class="item" @click="goDetailPage(item.uid)">
- <image class="icon" src="/static/receiver.png" />
- <text class="text">{{ item.receiver }}</text>
- </view>
- <view class="item1"
- :style="{ 'flex-wrap': item.fileSavePath.length <= 2 ? 'nowrap' : 'wrap' }">
- <u--image class="image-item" v-for="(element, i) in item.fileSavePath" :key="i"
- :src="element" width="80px" height="80px"
- @click="previewImage(item,i)"></u--image>
- </view>
- <view class="item">
- <text class="text">备注信息:{{ item.exhibitionNote }}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </swiper-item>
- </swiper>
- <!-- 底部操作栏 -->
- <view class="bottom-bar" v-show="activeTab === 0">
- <view style="display: flex; width: 90%;margin: 0 auto;align-items: center;">
- <checkbox-group style="margin-left: 10px;" @change="toggleSelectAll">
- <view style="width: 300rpx;">
- <checkbox :value="selectAll" :checked="selectAll"
- style="transform: scale(0.5,0.5);activeBackgroundColor: #253a6f;iconColor: #253a6f;" />
- 全选 已选{{selectedCount}}项
- </view>
- </checkbox-group>
- <!-- <view style="margin-left:90px;align-items: center;border: solid 1px red;"> -->
- <view style="margin-right: 10px;margin-left:5px;">
- <button type="default"
- style="color:#ffffff;backgroundColor:#27DBBB; border-radius: 50px;width:150rpx; height:65rpx;font-size: unset;display: flex;justify-content: center; align-items:center"
- @click="changeListData"><span>删除</span></button>
- </view>
- <view>
- <button
- style="color:#ffffff;backgroundColor:#253a6f; border-radius: 50px;width:150rpx; height:65rpx;font-size: unset;display: flex;justify-content: center; align-items:center"
- @click="uploadSelect" :disabled="isSubmitting"><span v-if="isSubmitting">...</span>
- <span v-else>上传</span></button>
- </view>
- <!-- </view> -->
- </view>
- </view>
- <view class="bottom-bar" v-show="activeTab === 1">
- <view style="display: flex; width: 90%;margin: 0 auto;align-items: center;">
- <checkbox-group style="margin-left: 10px;" @change="toggleSelectAll1">
- <view style="width: 300rpx;">
- <checkbox :value="selectAll1" :checked="selectAll1"
- style="transform: scale(0.5,0.5);activeBackgroundColor: #253a6f;iconColor: #253a6f;" />
- 全选 已选{{selectedCount1}}项
- </view>
- </checkbox-group>
- <!-- <view style="display: flex;margin-left:70px;align-items: center;"> -->
- <view style="margin-right: 10px;">
- <button type="default"
- style="color:#ffffff;backgroundColor:#27DBBB; border-radius: 50px;width:150rpx; height:65rpx;font-size: unset;visibility: hidden;">删除</button>
- </view>
- <view>
- <button
- style="color:#ffffff;backgroundColor:#27DBBB; border-radius: 50px;width:150rpx; height:65rpx;font-size: unset;display: flex;justify-content: center; align-items:center"
- @click="deleteSelectedUploaded">删除</button>
- </view>
- <!-- </view> -->
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- getToken,
- setToken
- } from '@/utils/auth'
- import {
- openSqlite,
- executeSql,
- closedb,
- getTable,
- isTable,
- getAllField,
- insertAll,
- addSql,
- getPageList,
- selectList,
- deleteSql,
- updateSql,
- selectSql,
- batchUpdate
- } from "@/utils/database";
- export default {
- data() {
- return {
- tableName: "public",
- options: {
- current: 1, // 分页默认为第1页
- size: 10,
- },
- list: [],
- uploadedList: [],
- activeTab: 0, // 当前选中的页面索引
- selected: [], // 保存每个数据项是否被选中的状态
- selectAll: false, // 全选状态
- selected1: [], // 保存每个数据项是否被选中的状态
- selectAll1: false, // 全选状态
- selectedCount: 0,
- selectedCount1: 0,
- clientHeight: '',
- isSubmitting: false, // 控制提交按钮状态
- uploadingStatus: [], // 用于存储上传状态的对象
- // a:1,
- // b:1
- };
- },
- watch: {
- selected: {
- handler() {
- this.selectedCount = this.selected.filter(value => value === true).length;
- },
- deep: true,
- },
- selected1: {
- handler() {
- this.selectedCount1 = this.selected1.filter(value => value === true).length;
- },
- deep: true,
- },
- },
- onShow() {
- this.getToBeUploadedData()
- this.getUploadedData()
- this.selected = new Array(this.list.length).fill(false)
- this.selected1 = new Array(this.uploadedList.length).fill(false)
- plus.key.hideSoftKeybord();
- const res = uni.getSystemInfo({
- success: (res => {
- console.log(res.windowHeight)
- // console.log(getApp().globalData.navHeight)
- this.clientHeight = res.windowHeight - 120;
- })
- });
- console.log('res', this.clientHeight)
- },
- // onLoad() {
- // this.getToBeUploadedData()
- // this.getUploadedData()
- // },
- mounted() {
- this.selected = new Array(this.list.length).fill(false)
- this.selected1 = new Array(this.uploadedList.length).fill(false)
- plus.key.hideSoftKeybord();
- },
- methods: {
- handleSwiperChange(event) {
- console.log(event.detail.current)
- this.activeTab = event.detail.current;
- if (event.detail.current == 1) {
- console.log(event.detail.current)
- setTimeout(() => {
- console.log('隐藏')
- plus.key.hideSoftKeybord();
- // uni.hideKeyboard()
- }, 700)
- }
- },
- toggleSelectAll(e) {
- console.log(e.detail)
- console.log(this.selectAll = !this.selectAll)
- this.selectAll = e.detail.value[0] == false ? true : false
- // console.log(this.selectAll)
- this.selected = this.list.map(() => this.selectAll);
- // console.log(this.selected)
- },
- toggleSelect(index) {
- console.log(index)
- this.selected[index] = !this.selected[index];
- this.selectAll = this.selected.every(item => item);
- console.log(this.selectAll)
- this.selectedCount = this.selected.filter(value => value === true).length;
- },
- toggleSelectAll1(e) {
- console.log(e.detail)
- console.log(this.selectAll1 = !this.selectAll1)
- this.selectAll1 = e.detail.value[0] == false ? true : false
- // console.log(this.selectAll1)
- this.selected1 = this.uploadedList.map(() => this.selectAll1);
- // console.log(this.selected)
- },
- toggleSelect1(index) {
- console.log(index)
- this.selected1[index] = !this.selected1[index];
- this.selectAll1 = this.selected1.every(item => item);
- console.log(this.selectAll1)
- this.selectedCount1 = this.selected1.filter(value => value === true).length;
- },
- deleteSelectedUploaded() {
- const listToDelete1 = this.uploadedList.filter((item, index) => this.selected1[index]).map(item => {
- return {
- id: item.id,
- deleted: 1
- };
- });
- // console.log(idsToDelete1)
- if (this.isEmptyObject(listToDelete1)) {
- uni.showToast({
- title: "请选择删除条目",
- icon: "none"
- });
- return
- }
- console.log(listToDelete1)
- console.log('selected', this.selected1)
- let self = this
- uni.showModal({
- // title: '提示',
- content: '确认删除选中的条目?',
- success: async function(res) {
- if (res.confirm) {
- console.log('用户点击确定')
- try {
- // const self = this
- await batchUpdate(self.tableName, listToDelete1, "id")
- // 过滤掉arr1中对应arr2中值为true的索引的元素
- self.uploadedList = self.uploadedList.filter((item, index) => !self.selected1[
- index])
- self.selectAll1 = false
- console.log(self.uploadedList)
- uni.showToast({
- title: "删除成功",
- icon: "none",
- success: function() {}
- });
- } catch (e) {
- console.error("批量修改数据,报错", e)
- }
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- // 调用接口删除数据项
- // console.log('需要删除的数据项ID:', idsToDelete);
- // // 删除选中的数据项后,重新获取数据列表
- // this.getList();
- },
- async getToBeUploadedData() {
- let where = {
- "deleted": 0,
- "uploaded": 0
- }
- this.list = await this.getData(where)
- console.log(this.list)
- this.selected = new Array(this.list.length).fill(false)
- // this.list = this.getData(where)
- },
- async getUploadedData() {
- let where = {
- "deleted": 0,
- "uploaded": 1
- }
- this.uploadedList = await this.getData(where)
- console.log(this.uploadedList)
- this.selected1 = new Array(this.uploadedList.length).fill(false)
- plus.key.hideSoftKeybord();
- // this.list = this.getData(where)
- },
- // 获取数据
- async getData(where) {
- try {
- // let where = {
- // "deleted": 0,
- // "uploaded": 0
- // }
- let res = await selectList(this.tableName, where, "createTime desc")
- console.log("加载数据", res)
- const result = res.map(({
- fileSavePath,
- ...rest
- }) => ({
- fileSavePath: fileSavePath ? fileSavePath.split(',') : [],
- ...rest
- }));
- // 清空原先的数据
- // this.list = [];
- // console.log(result);
- // this.list = result
- return result
- } catch (e) {
- uni.showToast({
- title: "报错,请查看控制台",
- icon: "none"
- });
- console.error("报错", e)
- }
- },
- isEmptyObject(obj) {
- return Object.keys(obj).length === 0;
- },
- // 批量修改数据
- async changeListData() {
- const listToDelete = this.list.filter((item, index) => this.selected[index]).map(item => {
- return {
- id: item.id,
- deleted: 1
- };
- });
- if (this.isEmptyObject(listToDelete)) {
- uni.showToast({
- title: "请选择删除条目",
- icon: "none"
- });
- return
- }
- console.log(listToDelete)
- console.log('selected', this.selected)
- let self = this
- uni.showModal({
- // title: '提示',
- content: '确认删除选中的条目?',
- success: async function(res) {
- if (res.confirm) {
- console.log('用户点击确定')
- try {
- // const self = this
- await batchUpdate(self.tableName, listToDelete, "id")
- // 过滤掉arr1中对应arr2中值为true的索引的元素
- self.list = self.list.filter((item, index) => !self.selected[index])
- self.selectAll = false
- console.log(self.list)
- uni.showToast({
- title: "修改成功",
- icon: "none",
- success: function() {}
- });
- } catch (e) {
- console.error("批量修改数据,报错", e)
- }
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- },
- //图片预览
- previewImage(item, i) {
- uni.previewImage({
- current: i,
- urls: item.fileSavePath
- });
- },
- switchTab(index) {
- this.activeTab = index; // 切换页面
- },
- goDetailPage(uid) {
- console.log(uid)
- uni.navigateTo({
- url: '/pages/collections/sample-collection-detail?uid=' + uid
- });
- },
- uploadSelect() {
- // this.a++
- // console.log("aaaaaaaa",this.a)
-
- console.log(getToken())
- if (!getToken()) {
- uni.showToast({
- title: "请先登录",
- icon: "none"
- });
- uni.reLaunch({
- url: '/pages/login/index'
- })
- return
- }
- if (this.isSubmitting) return; // 如果正在提交中,则直接返回
- const trueIndexes = this.selected.reduce((acc, val, index) => {
- if (val === true) {
- acc.push(index);
- }
- return acc;
- }, []);
- console.log(trueIndexes)
- // const listToDelete = this.list.filter((item, index) => this.selected[index]).map(item => item.id);
- // console.log(listToDelete)
- // return
- if (this.isEmptyObject(trueIndexes)) {
- uni.showToast({
- title: "请选择上传条目",
- icon: "none"
- });
- return
- }
- let self = this
- uni.showModal({
- // title: '提示',
- content: '确认上传选中的条目?',
- success: function(res) {
- if (res.confirm) {
- self.isSubmitting = true; // 设置提交中状态
- console.log('用户点击确定')
- // try {
- const uploadPromises = trueIndexes.map((item) => self.uploadData(item));
- console.log(uploadPromises)
- Promise.all(uploadPromises)
- .then(async (result) => {
- console.log(result)
- for (const obj of result) {
- if (obj.code == 200) {
- console.log(obj.data.uid);
- try {
- await updateSql('public', {
- uploaded: 1,
- }, {
- uid: obj.data.uid
- })
- // const self = this
- console.log("上传成功")
- const filteredData = self.list.filter(item => item
- .uid !== obj.data.uid);
- console.log(filteredData);
- self.list = filteredData
- self.getUploadedData()
- // console.log(self.list)
- // arr.splice(2, 1);
- // self.list = self.list.filter((item, index) => !self.selected[index])
- uni.showToast({
- title: "上传成功",
- icon: "none",
- });
- } catch (e) {
- uni.showToast({
- title: "修改报错,请联系开发人员",
- icon: "none"
- });
- console.error("修改报错", e)
- }
- //修改状态
- } else {
- console.log("上传失败")
- console.log("上传失败")
- if (obj.msg == "token 无效" || obj.msg == "未能读取到有效 token") {
- uni.showModal({
- content: "请重新登录",
- showCancel: false
- });
- uni.reLaunch({
- url: '/pages/login/index'
- })
- }
- if (obj.status === 500) {
- uni.showModal({
- content: "上传失败:" + obj.error,
- showCancel: false
- });
- }
- }
- }
- self.selected = new Array(self.list.length).fill(false)
- self.selectAll = false
- await self.getUploadedData()
- self.isSubmitting = false; // 恢复按钮可用状态
- // 所有文件上传完成
- console.log('所有文件上传完成');
- }, (errorMessage) => {
- self.isSubmitting = false; // 恢复按钮可用状态
- console.error("操作失败:" + errorMessage.errMsg);
- uni.showModal({
- content: "请检查网络",
- showCancel: false
- });
- })
- .catch((error) => {
- console.error('文件上传出错:', error);
- self.isSubmitting = false; // 恢复按钮可用状态
- });
- // }
- // for (let i = 0; i < trueIndexes.length; i++) {
- // self.uploadData(trueIndexes[i])
- // }
- // self.selected = new Array(self.list.length).fill(false)
- // self.selectAll = false
- // await self.getUploadedData()
- // } catch (e) {
- // console.error("批量修改数据,报错", e)
- // }
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- // console.log(listToDelete)
- // console.log('selected', this.selected)
- // for (let i = 0; i < trueIndexes.length; i++) {
- // this.upload(trueIndexes[i])
- // }
- },
- upload(index) {
- if (!getToken()) {
- uni.showToast({
- title: "请先登录",
- icon: "none"
- });
- uni.reLaunch({
- url: '/pages/login/index'
- })
- return
- }
- if (this.uploadingStatus[index]) return; // 如果正在上传中,则直接返回
-
- console.log(this.uploadingStatus[index])
- let self = this
- // this.b++
- // console.log("bbbbbb",this.b)
- uni.showModal({
- // title: '提示',
- content: '确认上传选中的条目?',
- success: function(res) {
- if (res.confirm) {
- self.uploadingStatus[index] = true; // 设置上传中状态
- self.$forceUpdate();
- console.log('用户点击确定')
- // try {
- // self.uploadData(index)
- // self.selected = new Array(self.list.length).fill(false)
- // self.selectAll = false
- // // self.switchTab(1)
- // } catch (e) {
- // console.error("上传,报错", e)
- // }
- self.uploadData(index)
- .then(async (result) => {
- self.uploadingStatus[index] = false; // 恢复按钮可用状态
- console.log(result)
- console.log(result)
- // return
- if (result.code == 200) {
- console.log(result.data.uid);
- try {
- await updateSql('public', {
- uploaded: 1,
- }, {
- uid: result.data.uid
- })
- // const self = this
- console.log("上传成功")
- const filteredData = self.list.filter(item => item
- .uid !== result.data.uid);
- console.log(filteredData);
- self.list = filteredData
- self.getUploadedData()
- // console.log(self.list)
- // arr.splice(2, 1);
- // self.list = self.list.filter((item, index) => !self.selected[index])
- uni.showToast({
- title: "上传成功",
- icon: "none",
- });
- } catch (e) {
- uni.showToast({
- title: "修改报错,请联系开发人员",
- icon: "none"
- });
- console.error("修改报错", e)
- }
- //修改状态
- } else {
- console.log("上传失败")
- if (result.msg == "token 无效" || result.msg ==
- "未能读取到有效 token") {
- uni.showModal({
- content: "请重新登录",
- showCancel: false
- });
- uni.reLaunch({
- url: '/pages/login/index'
- })
- }
- if (result.status === 500) {
- uni.showModal({
- content: "上传失败:" + result.error,
- showCancel: false
- });
- }
- }
- }, (errorMessage) => {
- self.uploadingStatus[index] = false; // 恢复按钮可用状态
- self.$forceUpdate();
- console.log('aaaaaaaa',self.uploadingStatus[index])
- console.error("操作失败:" + errorMessage.errMsg);
- uni.showModal({
- content: "请检查网络",
- showCancel: false
- });
- })
- .catch((error) => {
- self.uploadingStatus[index] = false; // 恢复按钮可用状态
- self.$forceUpdate();
- console.error('文件上传出错:', error);
- });
- } else if (res.cancel) {
- console.log('用户点击取消')
- self.uploadingStatus[index] = false; // 恢复按钮可用状态
- self.$forceUpdate();
- }
- }
- })
- },
- async uploadData(index) {
- console.log(this.list[index])
- let fileSavePath = this.list[index].fileSavePath;
- console.log(fileSavePath)
- // console.log(fileSavePath.length === 0)
- let result = []
- if (fileSavePath.length === 0) {
- result = []
- } else {
- result = fileSavePath.map(function(path, index) {
- return {
- name: "public" + index,
- uri: path
- };
- });
- }
- console.log('result', result);
- let detailList = await this.getDetailListByUid(this.list[index].uid)
- console.log('detailList', detailList)
- if (detailList.length === 0) {
- console.log('数组为空');
- var files = result;
- } else {
- var result2 = detailList.map(function(item) {
- if (item.fileSavePath) {
- var fileSavePath = item.fileSavePath;
- var fileSavePathArray = fileSavePath.split(',');
- return fileSavePathArray.map(function(path, index) {
- return {
- name: "detail-" + item.id + "-" + index,
- uri: path
- };
- });
- } else {
- return []
- }
- });
- console.log('result2', result2)
- var result3 = result2.reduce(function(acc, cur) {
- return acc.concat(cur);
- }, []);
- console.log('result3', result3)
- var files = result.concat(result3);
- console.log('数组不为空');
- }
- if (files.length === 0) {
- files = [{
- "uri": 'a'
- }]
- }
- const {
- uid,
- exhibitionName,
- customerName,
- receiver,
- exhibitionNote
- } = this.list[index];
- const mainObj = {
- uid,
- exhibitionName,
- customerName,
- receiver,
- exhibitionNote
- };
- const detailArr = detailList.map(obj => {
- return {
- id: obj.id,
- publicId: obj.publicId,
- barCode: obj.barCode,
- bpQuantity: obj.bpQuantity,
- gyQuantity: obj.gyQuantity,
- myQuantity: obj.myQuantity,
- note: obj.note,
- };
- });
- const mainStr = JSON.stringify(mainObj);
- const detailStr = JSON.stringify(detailArr);
- console.log('mainStr', mainStr)
- console.log('detailStr', detailStr)
- console.log('files', files)
- let self = this
- return new Promise((resolve, reject) => {
- uni.uploadFile({
- url: 'https://xyxt.lttc.cn/samplescan/api/input', //仅为示例,非真实的接口地址
- // url: 'http://10.20.70.228:8028/samplescan/api/input', //仅为示例,非真实的接口地址
- files: files,
- header: {
- 'Content-Type': 'multipart/form-data',
- 'Authorization': getToken()
- },
- formData: {
- 'main': mainStr,
- 'detail': detailStr
- },
- success: (res) => {
- // JSON.parse(uploadFileRes.data)
- resolve(JSON.parse(res.data));
- // success: async (uploadFileRes) => {
- // console.log(uploadFileRes.data);
- // const obj = JSON.parse(uploadFileRes.data);
- // console.log(obj.code);
- // if (obj.code == 200) {
- // console.log(obj.data.uid);
- // try {
- // await updateSql('public', {
- // uploaded: 1,
- // }, {
- // uid: obj.data.uid
- // })
- // console.log("上传成功")
- // const filteredData = self.list.filter(item => item.uid !== obj.data.uid);
- // console.log(filteredData);
- // self.list = filteredData
- // self.getUploadedData()
- // uni.showToast({
- // title: "上传成功",
- // icon: "none",
- // });
- // } catch (e) {
- // uni.showToast({
- // title: "修改报错,请联系开发人员",
- // icon: "none"
- // });
- // console.error("修改报错", e)
- // }
- // //修改状态
- // } else {
- // console.log("上传失败")
- // if(obj.msg == "token 无效"){
- // uni.reLaunch({
- // url: '/pages/login/index'
- // })
- // }
- // uni.showModal({
- // content: "请重新登录",
- // showCancel: false
- // });
- // }
- },
- fail: (err) => {
- reject(err);
- console.log(err);
- // uni.showModal({
- // content: "请检查网络",
- // showCancel: false
- // });
- }
- });
- });
- // })
- },
- async getDetailListByUid(uid) {
- try {
- let where = {
- "publicId": uid,
- 'deleted': 0
- }
- // let res = await selectList(this.tableName, where)
- let res = await selectList('detail', where)
- console.log("加载数据", res)
- return res
- // this.total = res.data.data.total
- } catch (e) {
- uni.showToast({
- title: "报错,请查看控制台",
- icon: "none"
- });
- console.error("报错", e)
- }
- },
- },
- };
- </script>
- <style>
- button::after {
- border: 0; // 或者 border: none;
- }
- .container {
- position: relative;
- width: 100%;
- height: 100vh;
- overflow: hidden;
- background-color: #EDEDED
- /* 隐藏溢出内容,禁止滚动 */
- }
- .header {
- position: fixed;
- background-color: #253a6f;
- height: 170rpx;
- width: 100%;
- z-index: 1;
- display: flex;
- }
- .scroll-view {
- position: absolute;
- left: 50%;
- top: 60%;
- transform: translate(-50%, -50%);
- width: 90%;
- height: 100%;
- overflow: auto;
- /* 设置滚动 */
- background-color: white;
- border-radius: 5px;
- /* border: 1px solid red; */
- /* padding: 0 10px; */
- z-index: 998;
- }
- .content {
- width: 100%;
- margin-bottom: 150px;
- border-radius: 5px;
- background-color: #EDEDED;
- overflow-y: auto;
- z-index: 999;
- /* border: 1px solid blue; */
- /* 此处设置滚动区域的内容样式 */
- }
- .segmented-control-item {
- flex: 1;
- text-align: center;
- padding: 10px;
- color: white;
- }
- .underline {
- bottom: 0;
- left: 0;
- width: 20%;
- height: 1px;
- background-color: white;
- /* 设置下划线的颜色 */
- display: none;
- margin: 0 auto;
- }
- .segmented-control-item.active .underline {
- display: block;
- }
- .icon {
- width: 40rpx;
- height: 40rpx;
- margin-right: 20rpx;
- }
- .list {
- margin-bottom: 10px;
- border-radius: 5px;
- background-color: white;
- }
- .list-item {
- display: flex;
- margin-top: 2px;
- background-color: white;
- }
- .item {
- display: flex;
- align-items: center;
- padding-top: 10px;
- }
- .item1 {
- display: flex;
- /* flex-wrap: wrap; */
- justify-content: flex-start;
- }
- .upload-btn {
- justify-content: center;
- align-items: center;
- }
- .image-item {
- /* flex: 1; */
- /* width: 30%; */
- margin: 5px;
- border: solid 1px #dadbde;
- }
- .bottom-bar {
- position: fixed;
- /* 将底部操作栏固定在页面底部 */
- left: 0;
- bottom: 0;
- width: 100%;
- height: 80rpx;
- /* text-align: center; */
- background-color: white;
- /* color: #fff; */
- font-size: 32rpx;
- line-height: 80rpx;
- z-index: 999;
- }
- .text {
- color: #949494;
- margin-top: 3px;
- }
- uni-checkbox .uni-checkbox-input {
- border-radius: 80rpx !important;
- border: 2px solid #ccc;
- }
- /deep/ uni-checkbox .uni-checkbox-input.uni-checkbox-input-checked:before {
- font: normal normal normal 14px/1 uni;
- content: "EA08";
- font-size: 0;
- /* 重点使用这一步取消的默认样式 */
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -48%) scale(1);
- -webkit-transform: translate(-50%, -48%) scale(1);
- }
- /deep/ .uni-checkbox-input-checked::before {
- width: 19px;
- height: 19px;
- background: #253a6f;
- border-radius: 50%;
- /* background: url(../../static/img/seal.png) no-repeat center; */
- }
- </style>
|