From d52ec7402b75d2ef7f5a133c7ea51447f24d9591 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 31 May 2024 11:27:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AD=9B=E9=80=89=E9=97=A8?= =?UTF-8?q?=E5=BA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/home/components/store-down.vue | 27 ++++++++++++++++++------ src/pages/revert/admin.vue | 2 +- 2 files changed, 22 insertions(+), 7 deletions(-) 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'])" > - +