This commit is contained in:
aihe 2024-04-26 14:37:16 +08:00
parent 4ca72eabcd
commit bd526f80d2
4 changed files with 101 additions and 24 deletions

View File

@ -7,8 +7,8 @@
:status="loadedAll ? 'nomore' : 'loading'" /> :status="loadedAll ? 'nomore' : 'loading'" />
<!-- 空数据页 --> <!-- 空数据页 -->
<view v-if="resObject.list.length == 0" style="padding-top: 100rpx;"> <view v-if="resObject.list.length == 0" :style="`padding: ${kongSizeMap[size].pdTB}rpx 0;`">
<u-empty text="无数据" :icon="getCdnUrl('kong.png')" textSize="28" width="86" height="97"> <u-empty text="无数据" :icon="getCdnUrl('kong.png')" textSize="28" :width="kongSizeMap[size].width" :height="kongSizeMap[size].height">
</u-empty> </u-empty>
</view> </view>
</scroll-view> </scroll-view>
@ -16,7 +16,18 @@
<script> <script>
import { debounce } from "@/common/util" import { debounce } from "@/common/util"
const kongSizeMap = {
dfl: {
width: 86,
height: 97,
pdTB: 100,
},
sm: {
width: 42,
height: 48,
pdTB: 30,
}
}
export default { export default {
watch: { watch: {
searchParam: { searchParam: {
@ -33,9 +44,19 @@
return {} return {}
} }
}, },
showLoadedAll: {
default () {
return true
}
},
getListFun: { getListFun: {
default () { default () {
return () => {} return null
}
},
getListFun: {
default () {
return null
} }
}, },
resObject: { resObject: {
@ -44,10 +65,16 @@
list: [] list: []
} }
} }
},
size: {
default () {
return 'dfl'
}
} }
}, },
data() { data() {
return { return {
kongSizeMap,
reqLoading: false, reqLoading: false,
page: { // 分页参数 page: { // 分页参数
pageNum: 1, pageNum: 1,
@ -77,6 +104,9 @@
this.showLoadMore = false this.showLoadMore = false
}, },
async getDataList(reload) { async getDataList(reload) {
if(!this.getListFun) {
return
}
if (reload) { if (reload) {
this.page.pageNum = 1 this.page.pageNum = 1
this.showLoading() this.showLoading()
@ -93,21 +123,25 @@
} else { } else {
list = this.resObject.list.concat(list) list = this.resObject.list.concat(list)
} }
if(this.showLoadedAll) {
this.loadedAll = res.total <= list.length this.loadedAll = res.total <= list.length
}
this.updateRes({ this.updateRes({
list, list,
total: res.total total: res.total
}) })
}, },
updateRes(obj) { updateRes(obj) {
this.$emit('update:resObject', { const res = {
...this.resObject, ...this.resObject,
page: this.page, page: this.page,
showLoadMore: this.showLoadMore, showLoadMore: this.showLoadMore,
loadedAll: this.loadedAll, loadedAll: this.loadedAll,
reqLoading: this.reqLoading, reqLoading: this.reqLoading,
...obj, ...obj,
}) }
this.$emit('update:resObject', res)
this.$emit('onListChange', res)
} }
} }
} }

View File

@ -2,22 +2,26 @@
<view class="" style="position: relative;"> <view class="" style="position: relative;">
<view @click.stop="handleSelectSwitch"> <view @click.stop="handleSelectSwitch">
<slot v-if="customInput"></slot> <slot v-if="customInput"></slot>
<default-select-input v-if="!customInput" :placeholder="placeholder" :show="show" :list="list" :value="value" :isWhite="isWhite" :customStyle="customStyle"></default-select-input> <default-select-input v-if="!customInput" :placeholder="placeholder" :show="show" :list="filDataList" :value="value" :isWhite="isWhite" :customStyle="customStyle"></default-select-input>
</view> </view>
<view v-if="mode == modeEnum.sheet"> <view v-if="mode == modeEnum.sheet">
<tpx-dialog :show="show" :title="placeholder" @onClose="handleSelectSwitch"> <tpx-dialog :show="show" :title="placeholder" @onClose="handleSelectSwitch">
<content-items :value="value" :list="list" :minChecked="minChecked" :type="type" <tpx-scroll-view :resObject="filResObject" :searchParam="searchParam" :getListFun="getListFun" size="sm" :showLoadedAll="false" @onListChange="onListChange">
<content-items :value="value" :list="filDataList" :minChecked="minChecked" :type="type"
@onChange="handleDataItemChange" @onChange="handleDataItemChange"
></content-items> ></content-items>
</tpx-scroll-view>
</tpx-dialog> </tpx-dialog>
</view> </view>
<view v-if="mode == modeEnum.drop && show" class="md-drop-cont"> <view v-if="mode == modeEnum.drop && show" class="md-drop-cont">
<content-items :value="value" :list="list" :minChecked="minChecked" :type="type" <tpx-scroll-view :resObject="filResObject" :searchParam="searchParam" :getListFun="getListFun" size="sm" :showLoadedAll="false" @onListChange="onListChange">
<content-items :value="value" :list="filDataList" :minChecked="minChecked" :type="type"
@onChange="handleDataItemChange" @onChange="handleDataItemChange"
></content-items> ></content-items>
</tpx-scroll-view>
</view> </view>
</view> </view>
@ -26,17 +30,26 @@
<script> <script>
import ContentItems from "./content-items" import ContentItems from "./content-items"
import DefaultSelectInput from "./default-select-input" import DefaultSelectInput from "./default-select-input"
import { transListKeyTitle } from "@/common/util"
const modeEnum = { const modeEnum = {
sheet: 'sheet', sheet: 'sheet',
drop: 'drop' drop: 'drop'
} }
export default { export default {
// computed: { computed: {
// filDataList() { filDataList() {
// return [] let list = (this.getListFun ? this.resObject.list : this.list) || []
// }, if(this.transKeyVal) {
// }, list = transListKeyTitle({ ...this.transKeyVal, list: list })
}
return list
},
filResObject() {
let res = this.getListFun ? this.resObject : { list: this.list, total: this.list.length }
return res
}
},
components: { components: {
ContentItems, DefaultSelectInput ContentItems, DefaultSelectInput
}, },
@ -86,6 +99,32 @@
default () { default () {
return [] return []
} }
},
searchParam: {
default () {
return {}
}
},
getListFun: {
default () {
return null
}
},
resObject: {
default () {
return {
list: []
}
}
},
transKeyVal: {
default () {
return null
// {
// // valKey: '',
// // titleKey: ''
// }
}
} }
}, },
data() { data() {
@ -116,6 +155,9 @@
if(this.type == "single") { if(this.type == "single") {
this.handleSelectSwitch() this.handleSelectSwitch()
} }
},
onListChange(val){
this.$emit('update:resObject', val)
} }
} }
} }
@ -130,6 +172,7 @@
top: calc(100% + 8px); top: calc(100% + 8px);
left: 0; left: 0;
right: 0; right: 0;
max-height: 600rpx;
z-index: 10; z-index: 10;
padding: 20rpx; padding: 20rpx;
box-sizing: border-box; box-sizing: border-box;

View File

@ -48,7 +48,7 @@
data() { data() {
return { return {
submitParams: { submitParams: {
username: 'libing', username: '25001108',
password: '123456' password: '123456'
}, },
remberPassport: [true] remberPassport: [true]

View File

@ -17,7 +17,7 @@
<u-row justify="between" custom-style="margin-top:20rpx;"> <u-row justify="between" custom-style="margin-top:20rpx;">
<view style="width: 130rpx;">客户</view> <view style="width: 130rpx;">客户</view>
<view style="flex:1;"> <view style="flex:1;">
<tpx-select :list="kehuList" v-model:value="submitParam.userId" customStyle="" :isWhite="true"></tpx-select> <tpx-select v-model:resObject="kehuRes" :getListFun="getCustomerUserList" :transKeyVal="{valKey: 'id',titleKey: 'customerFullName'}" v-model:value="submitParam.userId" customStyle="" :isWhite="true"></tpx-select>
</view> </view>
</u-row> </u-row>
</view> </view>
@ -323,8 +323,8 @@
}, },
data() { data() {
return { return {
kehuList: [{title: '李先生', val: '11'}],
...(JSON.parse(JSON.stringify({ qingguanList, baoguanList, sendTypeEnum, sendTypeList }))), ...(JSON.parse(JSON.stringify({ qingguanList, baoguanList, sendTypeEnum, sendTypeList }))),
kehuRes: { list: [] },
tipsList: [ tipsList: [
], ],
@ -364,13 +364,13 @@
}, },
methods: { methods: {
getCustomerUserList: apiService.getCustomerUserList,
async initData() { async initData() {
// uni.showLoading({ // uni.showLoading({
// title: '加载中' // title: '加载中'
// }); // });
this.showLoading() this.showLoading()
const res = await apiService.getCustomerUserList()
this.kehuList = transListKeyTitle({ valKey: 'id', titleKey: 'customerFullName', list: res.rows })
this.hideLoading() this.hideLoading()
}, },