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

View File

@ -2,22 +2,26 @@
<view class="" style="position: relative;">
<view @click.stop="handleSelectSwitch">
<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 v-if="mode == modeEnum.sheet">
<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"
></content-items>
</tpx-scroll-view>
</tpx-dialog>
</view>
<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"
></content-items>
</tpx-scroll-view>
</view>
</view>
@ -26,17 +30,26 @@
<script>
import ContentItems from "./content-items"
import DefaultSelectInput from "./default-select-input"
import { transListKeyTitle } from "@/common/util"
const modeEnum = {
sheet: 'sheet',
drop: 'drop'
}
export default {
// computed: {
// filDataList() {
// return []
// },
// },
computed: {
filDataList() {
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: {
ContentItems, DefaultSelectInput
},
@ -86,6 +99,32 @@
default () {
return []
}
},
searchParam: {
default () {
return {}
}
},
getListFun: {
default () {
return null
}
},
resObject: {
default () {
return {
list: []
}
}
},
transKeyVal: {
default () {
return null
// {
// // valKey: '',
// // titleKey: ''
// }
}
}
},
data() {
@ -116,6 +155,9 @@
if(this.type == "single") {
this.handleSelectSwitch()
}
},
onListChange(val){
this.$emit('update:resObject', val)
}
}
}
@ -130,6 +172,7 @@
top: calc(100% + 8px);
left: 0;
right: 0;
max-height: 600rpx;
z-index: 10;
padding: 20rpx;
box-sizing: border-box;

View File

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

View File

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