From 1f478b4b033d518f6de21f931d828d2a175b2a3e Mon Sep 17 00:00:00 2001 From: wzp <2880584989@qq.com> Date: 星期二, 08 三月 2022 13:40:51 +0800 Subject: [PATCH] 最新版本,修复bug --- assetMgtH5/pages/assets/list.vue | 233 +++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 166 insertions(+), 67 deletions(-) diff --git a/assetMgtH5/pages/assets/list.vue b/assetMgtH5/pages/assets/list.vue index 2f4210e..31d3424 100644 --- a/assetMgtH5/pages/assets/list.vue +++ b/assetMgtH5/pages/assets/list.vue @@ -9,7 +9,8 @@ </view> <view class="search-box"> <view class="item"> - <u-search placeholder="璇疯緭鍏ュ叧閿瓧" v-model="keyword" :clearabled="true" :show-action="false" @search="onSearch"></u-search> + <u-search placeholder="璇疯緭鍏ュ叧閿瓧" v-model="keyword" :clearabled="true" :show-action="false" + @search="onSearch"></u-search> </view> </view> <view class=""> @@ -24,18 +25,17 @@ </u-picker> </view> - + <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"> <view class="cu-list menu-avatar "> <view class="cu-item" v-for="(item,index) in assetsList" :key="index"> - <view class="cu-avatar radius lg bg-white" - style="background-image:url(../../static/device.png)"> + <view class="cu-avatar radius lg bg-white" style="background-image:url(../../static/device.png)"> </view> <view class="content"> <view> <view class="text-cut text-bold text-xl">{{item.assets.name}}</view> <view class="cu-tag radius bg-orange sm">宸茬敵璇锋暟閲忥細{{item.quantity}}</view> - + </view> <view class="text-gray text-sm flex"> <view class="text-cut">瑙勬牸锛歿{item.model?item.model:'鏃�'}} 缂栫爜锛歿{item.serialNumber}}</view> @@ -49,12 +49,13 @@ <u-empty mode="search" icon="http://cdn.uviewui.com/uview/empty/search.png"> </u-empty> </view> --> + <u-toast ref="uToast"></u-toast> </view> </template> <script> import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js"; - + export default { mixins: [MescrollMixin], // 浣跨敤mixin data() { @@ -62,19 +63,20 @@ keyword: '', show: false, columns: [], - columnData: [ - ], - newColumnData:[], + columnData: [], + newColumnData: [], assetsList: [], - flag:false + flag: false, + category: null, + type: null, + resData:[] } }, - async onLoad() { - await this.getAssetsCategoryList(); + onLoad() { + this.getAssetsCategoryList(); }, - onReady() { - }, - + onReady() {}, + methods: { changeHandler(e) { const { @@ -85,6 +87,7 @@ // 寰俊灏忕▼搴忔棤娉曞皢picker瀹炰緥浼犲嚭鏉ワ紝鍙兘閫氳繃ref鎿嶄綔 picker = this.$refs.uPicker } = e + // console.log(e) // 褰撶涓�鍒楀�煎彂鐢熷彉鍖栨椂锛屽彉鍖栫浜屽垪(鍚庝竴鍒�)瀵瑰簲鐨勯�夐」 if (columnIndex === 0) { // picker涓洪�夋嫨鍣╰his瀹炰緥锛屽彉鍖栫浜屽垪瀵瑰簲鐨勯�夐」 @@ -93,8 +96,26 @@ }, // 鍥炶皟鍙傛暟涓哄寘鍚玞olumnIndex銆乿alue銆乿alues confirm(e) { - console.log('confirm', e) - this.show = false + const index0 = e.indexs[0]; //绗竴鍒� + const index1 = e.indexs[1]; //绗簩鍒� + console.log('confirm1', index0) + console.log('confirm2', index1) + + let item1 = index0; + let item2 = 0; + if (index1 !== undefined) { + item2 = index1; + } + this.show = false; + + this.category = this.columns[0][item1].id; + this.type = this.columnData[item1][item2].id; + + + this.page = 1; + let page = {}; + page.num = 1; + this.upCallback(page); }, cancel() { // console.log('cancel'); @@ -103,110 +124,188 @@ showPicker() { this.show = true; }, - + onSearch(e) { console.log("鎼滅储锛�" + this.keyword) this.page = 1; - let page ={}; - page.num =1; + let page = {}; + page.num = 1; this.upCallback(page); }, - + upCallback(page) { - + let pageNum = page.num; //椤电爜锛岄粯璁や粠1寮�濮� let pageSize = 10; //椤甸暱锛岄粯璁ゆ瘡椤�10鏉� + - console.log(pageNum) this.$http.get('/assets/approval/myAssets', { params: { pageNum: pageNum, pageSize: pageSize, - keyStr: this.keyword + keyStr: this.keyword, + category: this.category, + type: this.type } }) .then(res => { // debugger; if (res.data.code === 0) { let data = res.data.data; - console.log('鎬昏祫浜�'+ data.length) + // console.log('鎬昏祫浜�' + data.length) if (page.num == 1) this.assetsList = []; //濡傛灉鏄涓�椤碉紝闇�鎵嬪姩缃┖鍒楄〃 this.assetsList = this.assetsList.concat(data); //杩藉姞鏂版暟鎹� - console.log(this.assetsList.length) + // console.log(this.assetsList.length) this.mescroll.endBySize(this.assetsList.length, res.data.total); - } - else{ + } else { this.mescroll.endBySize(0, 0); } - + }) .catch(err => { this.mescroll.endErr(); console.log('寮傚父', err); }); }, - - + + + + + //璧勪骇绫诲埆 - async getAssetsCategoryList() { - await this.$http.get('/assets/approval/getAssetsCategory') - .then(res => { + getAssetsCategoryList() { + // await this.getTest(22); + this.$http.get('/assets/approval/getAssetsCategory') + .then(async res => { // debugger; - let tt=[] - if(res.data.code===0){ + let tt = [] + if (res.data.code === 0) { let data = res.data.data; - for(let i=0;i<data.length;i++){ - let jsonData={ - id:data[i].id, - name:data[i].name - } - tt.push(jsonData); - - this.getAssetsTypes(data[i].id); - } + + this.resData = data; + // for (let i = 0; i < data.length; i++) { + // let jsonData = { + // id: data[i].id, + // name: data[i].name + // } + // tt.push(jsonData); + // await this.getTest(data[i].id); + // } + + tt = data.map(item => ({id: item.id, name: item.name})); + // await Promise.all(data.map(item => this.getTest(item.id))) + this.dealth(); } + // this.dealth(); - let newCloumns=[]; - newCloumns.push(tt); - // newCloumns.push(this.newColumnData[0]); - - this.columns = newCloumns; - - + this.columns.push(tt); + console.log(this.columns); + console.log(this.columnData) }).catch(err => { console.log(err.data) }) }, - async getAssetsTypes(id) { - await this.$http.get('/assets/approval/getAssetsTypes',{params:{parentId:id}}) + async dealth(){ + let data = this.resData; + for (let i = 0; i < data.length; i++) { + await this.getTest(data[i].id); + } + }, + + + getTest(id) { + console.log("浼犲弬"+id) + // let Authorization="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NDYzNjY4NDgsInVzZXJuYW1lIjoiMTM2MTE0NTIxNzUifQ.3QLykIpMBJ__R2s5ReJp53mmPp3WLEWF0xZgvi0rL_I"; + let Authorization="" + try { + Authorization = uni.getStorageSync('token') + } catch (e) {} + return new Promise((resolve, reject) => { + // 灏佽涓讳綋锛氱綉缁滆姹� + uni.request({ + url: this.$ApiUrl+ '/assets/approval/getAssetsTypes', //浠呬负绀轰緥锛屽苟闈炵湡瀹炴帴鍙e湴鍧�銆� + data: { + parentId: id + }, + header: { + 'Authorization': Authorization //鑷畾涔夎姹傚ご淇℃伅 + }, + + success: (res) => { + console.log('杩旇繕:',id); // 鎺у埗鍙版樉绀烘暟鎹俊鎭� + // this.$refs.uToast.show({ + // type: 'success', + // message: "鑾峰彇鎴愬姛" + // }); + let typeData = [] + if (res.data.code === 0) { + let data = res.data.data; + for (let i = 0; i < data.length; i++) { + let jsonData = { + id: data[i].id, + name: data[i].name + } + typeData.push(jsonData); + } + } + // console.log('typeData=',typeData) + this.columnData.push(typeData); + + if (!this.flag) { + this.columns.push(typeData); + this.flag = true; + } + + // debugger; + resolve(res.data.data) + }, + fail: (err) => { + this.$refs.uToast.show({ + type: 'error', + message: "澶辫触锛�"+err + }); + // 杩斿洖閿欒娑堟伅 + reject(err) + } + }) + }) + }, + + //浣滃簾 + getAssetsTypes(id) { + console.log("浼犲弬=" + id) + this.$http.get('/assets/approval/getAssetsTypes', { + params: { + parentId: id + } + }) .then(res => { + console.log('杩斿洖锛�',id); // debugger; - let typeData=[] - if(res.data.code===0){ + let typeData = [] + if (res.data.code === 0) { let data = res.data.data; - for(let i=0;i<data.length;i++){ - let jsonData={ - id:data[i].id, - name:data[i].name + for (let i = 0; i < data.length; i++) { + let jsonData = { + id: data[i].id, + name: data[i].name } typeData.push(jsonData); } } // console.log('typeData=',typeData) this.columnData.push(typeData); - - if(!this.flag){ + + if (!this.flag) { this.columns.push(typeData); - this.flag=true; + this.flag = true; } - + }).catch(err => { - console.log('閿欒',err) + console.log('閿欒', err) }) } - - } -- Gitblit v1.9.1