diff --git a/src/apis/asset/api.js b/src/apis/asset/api.js index 4e2e7b5..51b9bb0 100644 --- a/src/apis/asset/api.js +++ b/src/apis/asset/api.js @@ -13,3 +13,4 @@ export const GET_ASSET_FLOOR_LIST_API = `/AssetManage/GetFloorList`; export const POST_ASSET_FLOOR_API = `/AssetManage/SaveFloor`; export const GET_ASSET_IOT_LIST_API = `/AssetManage/GetIOTList`; +export const GET_ASSET_SUB_POINT_API = `/AssetManage/GetSubPoint`; diff --git a/src/apis/asset/index.js b/src/apis/asset/index.js index 8f1bb10..61bc0f2 100644 --- a/src/apis/asset/index.js +++ b/src/apis/asset/index.js @@ -10,6 +10,7 @@ import { GET_ASSET_IOT_LIST_API, DELETE_ASSET_ITEM_API, POST_ASSET_SINGLE_API, + GET_ASSET_SUB_POINT_API, } from "./api"; import instance from "@/util/request"; import apihandler from "@/util/apihandler"; @@ -98,7 +99,8 @@ export const postAssetSingle = async (data) => { }); } else { value.forEach((element, index) => { - formData.append(`${key}[${index}].device_guid`, element); + formData.append(`sub_device[${index}].device_number`, element.device_number); + formData.append(`sub_device[${index}].points`, element.points); }); } } else { @@ -141,8 +143,22 @@ export const postAssetFloor = async (formData) => { }); }; -export const getAssetIOTList = async () => { - const res = await instance.post(GET_ASSET_IOT_LIST_API); +export const getAssetIOTList = async (sub_system_tag, points) => { + const res = await instance.post(GET_ASSET_IOT_LIST_API, { + sub_system_tag, + points, + }); + + return apihandler(res.code, res.data, { + msg: res.msg, + code: res.code, + }); +}; + +export const getAssetSubPoint = async (sub_system_tag) => { + const res = await instance.post(GET_ASSET_SUB_POINT_API, { + sub_system_tag, + }); return apihandler(res.code, res.data, { msg: res.msg, diff --git a/src/assets/index.css b/src/assets/index.css index 781725f..b6ae254 100644 --- a/src/assets/index.css +++ b/src/assets/index.css @@ -37,7 +37,7 @@ @layer utilities { .btn{ - @apply px-6 py-1; + @apply px-4 py-1; text-shadow: 0px 0px 5px rgba(0, 0, 0, 0.9); box-shadow: 0px 0px 5px rgba(255, 255, 255, 0.8); } diff --git a/src/components/customUI/DateGroup.vue b/src/components/customUI/DateGroup.vue index 20653f0..de479dc 100644 --- a/src/components/customUI/DateGroup.vue +++ b/src/components/customUI/DateGroup.vue @@ -3,9 +3,9 @@ import { defineProps, computed } from "vue"; import VueDatePicker from "@vuepic/vue-datepicker"; import "@vuepic/vue-datepicker/dist/main.css"; import { zhTW } from "date-fns/locale"; - import { twMerge } from "tailwind-merge"; - +import { useI18n } from "vue-i18n"; +const { t } = useI18n(); const props = defineProps({ items: Array, withLine: Boolean, @@ -62,13 +62,12 @@ const curWidth = computed(() => { showPreview: false, }" v-model="item.value" - locale="zh-TW" - :day-names="['一', '二', '三', '四', '五', '六', '日']" + locale='en-US' :format="item.dateFormat" :enable-time-picker="false" :time-picker="Boolean(item.timePicker)" :placeholder="item.placeholder" - selectText="確定" + :selectText="t('button.submit')" :input-class-name=" twMerge('dp-custom-input', 'btn border', inputClass) " diff --git a/src/components/customUI/Pagination.vue b/src/components/customUI/Pagination.vue index e075d4e..c7cb3fb 100644 --- a/src/components/customUI/Pagination.vue +++ b/src/components/customUI/Pagination.vue @@ -52,13 +52,19 @@ const changePageData = (currentPage) => { watch( () => [props.dataSource, props.sort], ([newVal, newVal2]) => { - // console.log(props.dataSource, newVal); - currentPage.value = 1; - totalPage.value = + const totalPageNumber = props.totalPages || Math.ceil(props.dataSource.length / props.pageSize); + if (currentPage.value > totalPageNumber) { + currentPage.value = 1; + } else { + // 若頁數在範圍內,則保持當前頁面 + currentPage.value = currentPage.value; + } + + totalPage.value = totalPageNumber; props.onPageChange ? current_table_data.updateDataSource(props.dataSource) - : changePageData(1); + : changePageData(currentPage.value || 1); }, { deep: true, @@ -99,7 +105,7 @@ const pageInput = computed(() => { :key="`page${page}`" :class=" twMerge( - 'w-10 h-10 mx-1 border-2 border-sub-success rounded-full flex items-center justify-center', + 'w-10 h-10 mx-1 border-2 border-sub-success rounded-full flex items-center justify-center cursor-pointer', currentPage === page ? 'bg-sub-success' : 'bg-transparent' ) " @@ -145,7 +151,7 @@ const pageInput = computed(() => { - {{ totalItems || dataSource.length }} {{ $t("table.in_otal") }}