From 1833dd6d7cac01c35840af52fadc1199821e5805 Mon Sep 17 00:00:00 2001 From: Houjie <714924425@qq.com> Date: 星期四, 15 五月 2025 09:28:16 +0800 Subject: [PATCH] 提交优化项 --- pages/baoZhou/baoZhouDetils/baoZhouDetils.vue | 123 +++++++++-------------------------------- 1 files changed, 27 insertions(+), 96 deletions(-) diff --git a/pages/baoZhou/baoZhouDetils/baoZhouDetils.vue b/pages/baoZhou/baoZhouDetils/baoZhouDetils.vue index b0b24c6..b75aff7 100644 --- a/pages/baoZhou/baoZhouDetils/baoZhouDetils.vue +++ b/pages/baoZhou/baoZhouDetils/baoZhouDetils.vue @@ -27,18 +27,9 @@ <uni-easyinput type="textarea" v-model="formData.remark" :disabled="true" /> </uni-forms-item> <uni-forms-item name="outNum" :label-width="80" label="淇濆吇鍥剧墖:"> - <view class="grid col-4 grid-square flex-sub"> - <view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" - :data-url="imgList[index]"> - <image :src="imgList[index]" mode="aspectFill"></image> - <view class="cu-tag bg-red radius" @tap.stop="DelImg" :data-index="index"> - <text class='cuIcon-close'></text> - </view> - </view> - <view class="solids" v-if="imgList.length<1"> - <text class='cuIcon-cameraadd'></text> - </view> - </view> + <uni-file-picker limit="9" :value="fileLists" :image-styles="imageStyles" + :sourceType="sourceType" @select="select" @progress="progress" @success="success" + @fail="fail" @delete="deletea" :readonly="true" /> </uni-forms-item> </uni-group> </uni-forms> @@ -59,23 +50,29 @@ </view> <view class="flex"> <view class="flex-sub text-light bg-white padding-xs margin-xs radius">瀛愪繚鍏婚」:</view> - <view class="flex-sub bg-white padding-xs margin-xs radius text-right" + <view class="flex-sub bg-white padding-xs margin-xs radius text-right"> + {{item.subItemName}} + </view> + <!-- <view class="flex-sub bg-white padding-xs margin-xs radius text-right" v-if="item.subItemName!=null && item.subItemName.length>10"> {{(item.subItemName).toString().substr(0,10)+'...'}} </view> <view class="flex-sub bg-white padding-xs margin-xs radius text-right" v-else> {{item.subItemName}} - </view> + </view> --> </view> <view class="flex"> <view class="flex-sub text-light bg-white padding-xs margin-xs radius">淇濆吇瑕佹眰:</view> - <view class="flex-sub bg-white padding-xs margin-xs radius text-right" + <!-- <view class="flex-sub bg-white padding-xs margin-xs radius text-right" v-if="item.itemDemand!=null && item.itemDemand.length>10"> {{(item.itemDemand).toString().substr(0,10)+'...'}} </view> <view class="flex-sub bg-white padding-xs margin-xs radius text-right" v-else> + {{item.itemDemand}} + </view> --> + <view class="flex-sub bg-white padding-xs margin-xs radius text-right"> {{item.itemDemand}} </view> </view> @@ -114,6 +111,14 @@ mixins: [MescrollMixin], // 浣跨敤mixin data() { return { + // 鍥剧墖鍥炴樉 + fileLists: [], + // 涓婁紶鍥剧墖鐨勬牱寮� + imageStyles: { + width: 90, + height: 90, + }, + sourceType: ['album', 'camera'], ipAndPort:configService.staticURL, scrollLeft: 0, searchValue: '', @@ -189,23 +194,6 @@ handleCode(e) { this.inspectionResult = e; }, - // getEquipment() { - // this.$http.get(this.url.getEquipmentList).then(res => { - // //璁剧疆鍒楄〃鏁版嵁 - // if (res.data.success) { - // this.equipmentList = res.data.result - // } else { - // uni.showToast({ - // icon: "error", - // title: res.data.message, - // duration: 2000 - // }); - - // } - // }).catch(() => { - // this.$tip.error("鑱旂綉澶辫触") - // }) - // }, getEquipment() { this.$http.get(this.url.getEquipmentList, { params: { @@ -249,71 +237,7 @@ //鑱旂綉澶辫触, 缁撴潫鍔犺浇 }) }, - ChooseImage() { - var that = this; - uni.chooseImage({ - count: 4, - sizeType: ['original', 'compressed'], // 鍙互鎸囧畾鏄師鍥捐繕鏄帇缂╁浘锛岄粯璁や簩鑰呴兘鏈� - sourceType: ['album'], // 浠庣浉鍐岄�夋嫨 - success: (res) => { - // 瀛樺偍閫夋嫨鐨勫浘鐗囪矾寰� - that.imgList = res.tempFilePaths; - // 鍒濆鍖� formData.avatar 涓虹┖瀛楃涓� - that.formData.avatar = ''; - - // 鍒涘缓涓婁紶浠诲姟鐨� Promise 鏁扮粍 - const uploadPromises = res.tempFilePaths.map((filePath, index) => { - return new Promise((resolve, reject) => { - that.$http.upload(that.url.upload, { - filePath: filePath, - name: 'file' - }) - .then(uploadRes => { - // 鍋囪鏈嶅姟鍣ㄨ繑鍥炵殑缁撴灉涓寘鍚枃浠惰矾寰� - const filePath = uploadRes.data.result[0]; - // 杩藉姞鍒� formData.avatar 涓紝骞剁敤閫楀彿鍒嗛殧 - this.formData.avatar.push(filePath); - resolve(filePath); - }) - .catch(err => { - console.error('鍥剧墖' + index + '涓婁紶澶辫触:', err); - reject(err); - }); - }); - }); - - // 骞跺彂鎵ц鎵�鏈変笂浼犱换鍔� - Promise.all(uploadPromises) - .then((uploadedFilePaths) => { - console.log('鎵�鏈夊浘鐗囦笂浼犳垚鍔�:', that.formData.avatar); - }) - .catch((err) => { - console.error('鍥剧墖涓婁紶澶辫触:', err); - that.$tip.error('鍥剧墖涓婁紶澶辫触'); - }); - } - }); - }, - ViewImage(e) { - uni.previewImage({ - urls: this.imgList, - current: e.currentTarget.dataset.url - }); - }, - DelImg(e) { - uni.showModal({ - title: '鎻愮ず', - content: '纭畾瑕佸垹闄よ繖娈靛洖蹇嗗悧锛�', - cancelText: '鍐嶇湅鐪�', - confirmText: '鍐嶈', - success: res => { - if (res.confirm) { - this.imgList.splice(e.currentTarget.dataset.index, 1) - } - } - }) - }, upCallback() { this.$http.get(this.url.stallList, { @@ -337,6 +261,13 @@ this.imgList = imageObjects.map(imageObj => { return `${this.ipAndPort}${imageObj.filePath}`; }); + + // 鏍规嵁 imgList 鏋勯�� fileLists + this.fileLists = this.imgList.map(url => ({ + url: url, + extname: 'png', + name: 'eam' + })); } }).catch(() => { //鑱旂綉澶辫触, 缁撴潫鍔犺浇 -- Gitblit v1.9.3