diff --git a/src/pages/home/components/store-down.vue b/src/pages/home/components/store-down.vue index d5bd5a5..f601a3a 100644 --- a/src/pages/home/components/store-down.vue +++ b/src/pages/home/components/store-down.vue @@ -42,11 +42,16 @@ import { http } from '@/utils/request' import { onMounted, ref, reactive, computed, toRaw } from 'vue' import debounce from '@climblee/uv-ui/libs/function/debounce' +import { empty } from '@climblee/uv-ui/libs/function/test' const props = defineProps({ color: { type: String, default: '#fff', }, + isAll: { + type: Boolean, + default: true, + }, }) onMounted(() => { getData() @@ -93,15 +98,14 @@ const storeText = computed(() => { } }) - function truncateString(str, maxLength) { if (str.length <= maxLength) { - return str; + return str } if (maxLength <= 3) { - return str.substring(0, maxLength) + '...'; + return str.substring(0, maxLength) + '...' } - return str.substring(0, maxLength - 3) + '...'; + return str.substring(0, maxLength - 3) + '...' } const selectMenu = (e) => { @@ -116,6 +120,9 @@ const selectMenu = (e) => { debounce( () => { + const obj = toRaw(arrayToObject(result.value)) + if (!props.isAll && empty(obj.store_id)) return + emit('change', toRaw(arrayToObject(result.value))) }, 500, @@ -134,7 +141,11 @@ function arrayToObject(arr) { const getData = async () => { http.get('/region').then((res) => { regions.value = res - provinces.value = [{ name: '全部区域', code: null }].concat(res.province) + let _all = [] + + _all = [{ name: '全部区域', code: null }] + + provinces.value = _all.concat(res.province) citys.value = getCityByCode() regionsConfirm({ value: [provinces.value[0], citys.value[0]], @@ -172,7 +183,11 @@ const getStoreData = () => { params: params, }) .then((res) => { - store.value = [{ title: '全部门店', id: null }].concat(res) + let _all = [] + if (props.isAll) { + _all = [{ title: '全部门店', id: null }] + } + store.value = _all.concat(res) storeConfirm({ value: [store.value[0]] }) }) } diff --git a/src/pages/revert/admin.vue b/src/pages/revert/admin.vue index e74fb20..c647934 100644 --- a/src/pages/revert/admin.vue +++ b/src/pages/revert/admin.vue @@ -7,7 +7,7 @@ bgColor="#fff" v-if="checkPermission(['admin'])" > - +