From 0f5bd3db43a7ea07d3373b38bd24126544de5e2f Mon Sep 17 00:00:00 2001 From: zhuguifei <zhuguifei@zhuguifeideiMac.local> Date: 星期一, 21 四月 2025 18:32:39 +0800 Subject: [PATCH] 完成设备点检 --- eims-ui-mobile/src/service/equ.d.ts | 124 +++++ eims-ui-mobile/env/.env | 2 eims-ui-mobile/src/static/menu/menu4.png | 0 eims-ui-mobile/src/static/menu/menu5.png | 0 eims-ui-mobile/src/pages/inspect/insp-add.vue | 222 +++++++++ eims-ui-mobile/src/service/inspect.ts | 29 + eims-ui-mobile/src/pages/login/index.vue | 29 + eims-ui-mobile/src/pages/inspect/insp-st.vue | 149 ++++++ eims-ui-mobile/src/static/menu/menu3.png | 0 eims-ui-mobile/src/service/inspect.d.ts | 150 ++++++ eims-ui-mobile/src/utils/http.ts | 33 + eims-ui-mobile/.eslintrc-auto-import.json | 17 eims-ui-mobile/src/pages/inspect/insp-record.vue | 298 ++++++++++++ eims-ui-mobile/src/types/uni-pages.d.ts | 4 eims-ui-mobile/src/style/index.scss | 10 eims-ui-mobile/src/static/menu/menu2.png | 0 eims-ui-mobile/src/types/auto-import.d.ts | 2 eims-ui-mobile/src/service/equ.ts | 9 eims-ui-mobile/src/static/menu/menu1.png | 0 eims-ui-mobile/src/static/images/camera.png | 0 eims-ui-mobile/src/static/ico/ico-ok.png | 0 eims-ui-mobile/src/pages.json | 33 + eims-ui-mobile/src/static/menu/menu0.png | 0 eims-ui-mobile/src/pages/equ/equ-list.vue | 149 ++++++ eims-ui-mobile/src/pages/home/index.vue | 90 ++- 25 files changed, 1,299 insertions(+), 51 deletions(-) diff --git a/eims-ui-mobile/.eslintrc-auto-import.json b/eims-ui-mobile/.eslintrc-auto-import.json index 27df73d..ca20d5b 100644 --- a/eims-ui-mobile/.eslintrc-auto-import.json +++ b/eims-ui-mobile/.eslintrc-auto-import.json @@ -3,11 +3,14 @@ "Component": true, "ComponentPublicInstance": true, "ComputedRef": true, + "DirectiveBinding": true, "EffectScope": true, "ExtractDefaultPropTypes": true, "ExtractPropTypes": true, "ExtractPublicPropTypes": true, "InjectionKey": true, + "MaybeRef": true, + "MaybeRefOrGetter": true, "PropType": true, "Ref": true, "VNode": true, @@ -65,6 +68,7 @@ "onUnload": true, "onUnmounted": true, "onUpdated": true, + "onWatcherCleanup": true, "provide": true, "reactive": true, "readonly": true, @@ -82,20 +86,15 @@ "useAttrs": true, "useCssModule": true, "useCssVars": true, + "useId": true, + "useModel": true, "useRequest": true, "useSlots": true, + "useTemplateRef": true, "useUpload": true, - "useUpload2": true, "watch": true, "watchEffect": true, "watchPostEffect": true, - "watchSyncEffect": true, - "DirectiveBinding": true, - "MaybeRef": true, - "MaybeRefOrGetter": true, - "onWatcherCleanup": true, - "useId": true, - "useModel": true, - "useTemplateRef": true + "watchSyncEffect": true } } diff --git a/eims-ui-mobile/env/.env b/eims-ui-mobile/env/.env index e404113..ba2fa4c 100644 --- a/eims-ui-mobile/env/.env +++ b/eims-ui-mobile/env/.env @@ -8,7 +8,7 @@ VITE_APP_PUBLIC_BASE=/ VITE_SERVER_BASEURL = 'http://192.168.12.33:8080' -VITE_UPLOAD_BASEURL = 'https://ukw0y1.laf.run/upload' +VITE_UPLOAD_BASEURL = 'http://192.168.12.33:8080/resource/oss/upload' # 鏈変簺鍚屽鍙兘闇�瑕佸湪寰俊灏忕▼搴忛噷闈㈡牴鎹� develop銆乼rial銆乺elease 鍒嗗埆璁剧疆涓婁紶鍦板潃锛屽弬鑰冧唬鐮佸涓嬨�� # 涓嬮潰鐨勫彉閲忓鏋滄病鏈夎缃紝浼氶粯璁や娇鐢� VITE_SERVER_BASEURL or VITE_UPLOAD_BASEURL diff --git a/eims-ui-mobile/src/pages.json b/eims-ui-mobile/src/pages.json index fc6eadb..5cfa519 100644 --- a/eims-ui-mobile/src/pages.json +++ b/eims-ui-mobile/src/pages.json @@ -64,6 +64,14 @@ } }, { + "path": "pages/equ/equ-list", + "type": "page", + "layout": "default", + "style": { + "navigationBarTitleText": "璁惧鍒楄〃" + } + }, + { "path": "pages/equ/index", "type": "page", "layout": "tabbar", @@ -73,6 +81,31 @@ } }, { + "path": "pages/inspect/insp-add", + "type": "page", + "layout": "default", + "style": { + "navigationBarTitleText": "璁惧鐐规" + } + }, + { + "path": "pages/inspect/insp-record", + "type": "page", + "style": { + "navigationBarTitleText": "鐐规璁板綍", + "navigationStyle": "custom", + "navigationBarBackgroundColor": "#4D80F0" + } + }, + { + "path": "pages/inspect/insp-st", + "type": "page", + "layout": "default", + "style": { + "navigationBarTitleText": "鐐规姹囨��" + } + }, + { "path": "pages/login/index", "type": "page", "layout": "default", diff --git a/eims-ui-mobile/src/pages/equ/equ-list.vue b/eims-ui-mobile/src/pages/equ/equ-list.vue new file mode 100644 index 0000000..4a72014 --- /dev/null +++ b/eims-ui-mobile/src/pages/equ/equ-list.vue @@ -0,0 +1,149 @@ +<route lang="json5" type="page"> +{ + layout: 'default', + style: { + navigationBarTitleText: '璁惧鍒楄〃', + }, +} +</route> +<template> + <z-paging ref="paging" v-model="dataList" @query="queryList" show-refresher-update-time> + <template #top> + <wd-drop-menu> + <wd-drop-menu-item v-model="equTypeId" :options="typeList" @change="handleEquType" /> + <wd-drop-menu-item v-model="status" :options="statusList" @change="handleEquStatu" /> + </wd-drop-menu> + </template> + + <view class="bg-base"> + <wd-card type="rectangle" v-for="(item, index) in dataList" :key="item.id"> + <template #title> + <view class="flex justify-between items-baseline"> + <view class="flex items-center menu-title-box"> + <view class="menu-indicator"></view> + <text class="ml-1 text-xs">{{ item.assetNo }}</text> + </view> + + <view> + <text class="icon-color-base">璇︽儏</text> + <wd-icon name="arrow-right" custom-class="icon-color-base"></wd-icon> + </view> + </view> + </template> + <view class="flex h-[80rpx]" @click.stop="itemClick(item)"> + <image class="slot-img text-center" src="/static/images/camera.png" /> + <view> + <view class="text-color-base"> + {{ item.equName }} + <text class="text-color-gray ml-2 text-mini">{{ item.modelNo }}</text> + </view> + <view class="text-color-gray text-xs mt-1"> + {{ item.location }} | {{ item.madeIn }} + </view> + </view> + </view> + </wd-card> + </view> + </z-paging> +</template> + +<script setup lang="ts"> +import { onMounted, getCurrentInstance, ref } from 'vue' + +import { getEquList } from '@/service/equ' + +// 璁惧绫诲瀷 +const equTypeId = ref<number>(0) +// 璁惧鐘舵�� +const status = ref<number>(0) + +const isSelectEqu = ref(false) + +const typeList = ref<Record<string, any>[]>([{ label: '鎵�鏈夎澶�', value: 0 }]) +const statusList = ref<Record<string, any>[]>([{ label: '鎵�鏈夌姸鎬�', value: 0 }]) +function handleEquType({ value }) { + console.log(value) +} +function handleEquStatu({ value }) { + console.log(value) +} + +const paging = ref(null) +const dataList = ref([]) + +const queryList = (pageNum?: number, pageSize?: number) => { + // 杩欓噷鐨刾ageNo鍜宲ageSize浼氳嚜鍔ㄨ绠楀ソ锛岀洿鎺ヤ紶缁欐湇鍔″櫒鍗冲彲 + // 杩欓噷鐨勮姹傚彧鏄紨绀猴紝璇锋浛鎹㈡垚鑷繁鐨勯」鐩殑缃戠粶璇锋眰锛屽苟鍦ㄧ綉缁滆姹傚洖璋冧腑閫氳繃paging.value.complete(璇锋眰鍥炴潵鐨勬暟缁�)灏嗚姹傜粨鏋滀紶缁檢-paging + getEquList({ pageNum, pageSize }) + .then((res: any) => { + // 璇峰嬁鍦ㄧ綉缁滆姹傚洖璋冧腑缁檇ataList璧嬪�硷紒锛佸彧闇�瑕佽皟鐢╟omplete灏卞彲浠ヤ簡 + console.log(res) + paging.value.complete(res.rows) + }) + .catch((res) => { + // 濡傛灉璇锋眰澶辫触鍐檖aging.value.complete(false)锛屼細鑷姩灞曠ず閿欒椤甸潰 + // 娉ㄦ剰锛屾瘡娆¢兘闇�瑕佸湪catch涓啓杩欏彞璇濆緢楹荤儲锛寊-paging鎻愪緵浜嗘柟妗堝彲浠ュ叏灞�缁熶竴澶勭悊 + // 鍦ㄥ簳灞傜殑缃戠粶璇锋眰鎶涘嚭寮傚父鏃讹紝鍐檜ni.$emit('z-paging-error-emit');鍗冲彲 + paging.value.complete(false) + }) +} + +/** + * 璁惧鏉$洰鐐瑰嚮浜嬩欢 + * @param item + */ +function itemClick(item: any) { + if (isSelectEqu.value) { + emitSelectEqu(item) + uni.navigateBack() + } +} + +/** + * 閫夋嫨璁惧鍥炶皟 + * @param equ + */ +function emitSelectEqu(equ: any) { + eventChannel.value.emit('selectEqu', { + data: equ, + }) +} + + +const eventChannel = ref<any>() +onMounted(() => { + const instance: any = getCurrentInstance().proxy + const event = instance.getOpenerEventChannel() + eventChannel.value = event + event.on('handleSelectEqu', function (data) { + isSelectEqu.value = true + console.log('handleSelectEqu', data) + }) +}) +</script> + +<style scoped lang="scss"> +.menu-title-box { + height: 30rpx; + line-height: 30rpx; +} + +.slot-img { + width: 72rpx; + height: 72rpx; + margin-right: 24rpx; +} +.text-mini { + font-size: 22rpx; +} + +.menu-indicator { + width: 6rpx; + height: 22rpx; + border-radius: 10rpx; + background-color: $uni-color-primary; +} +:deep(.wd-card__footer) { + padding: 10rpx !important; +} +</style> diff --git a/eims-ui-mobile/src/pages/home/index.vue b/eims-ui-mobile/src/pages/home/index.vue index cb1e18e..bd131e7 100644 --- a/eims-ui-mobile/src/pages/home/index.vue +++ b/eims-ui-mobile/src/pages/home/index.vue @@ -71,33 +71,18 @@ <template #title> <view class="flex items-center menu-title-box"> <view class="menu-indicator"></view> - <view class="ml-1 text-xs">鏁版嵁鎬昏</view> + <view class="ml-1 text-xs">璁惧绠$悊</view> </view> </template> <wd-grid :column="4"> - <wd-grid-item use-slot class="flex justify-center items-center"> - <image class="slot-img text-center" src="/static/menu/menu2.png" /> - <text>12</text> - </wd-grid-item> - <wd-grid-item use-slot class="flex justify-center items-center"> - <image class="slot-img text-center" src="/static/menu/menu2.png" /> - <text>12</text> - </wd-grid-item> - <wd-grid-item use-slot class="flex justify-center items-center"> - <image class="slot-img text-center" src="/static/menu/menu2.png" /> - <text>12</text> - </wd-grid-item> - <wd-grid-item use-slot is-dot class="flex justify-center items-center"> - <image class="slot-img text-center" src="/static/menu/menu2.png" /> - <text>12</text> - </wd-grid-item> - <wd-grid-item use-slot class="flex justify-center items-center"> - <image class="slot-img text-center" src="/static/menu/menu2.png" /> - <text>12</text> - </wd-grid-item> - <wd-grid-item use-slot class="flex justify-center items-center"> - <image class="slot-img text-center" src="/static/menu/menu2.png" /> - <text>12</text> + <wd-grid-item + use-slot + class="flex justify-center items-center" + v-for="(item, index) in equMenu" + @click.stop="goItemPage(item.path)" + > + <image class="slot-img text-center" :src="item.icon" /> + <text>{{ item.name }}</text> </wd-grid-item> </wd-grid> </wd-card> @@ -108,17 +93,18 @@ <template #title> <view class="flex items-center menu-title-box"> <view class="menu-indicator"></view> - <view class="ml-1 text-xs">鏁版嵁鎬昏</view> + <view class="ml-1 text-xs">璁惧鐐规</view> </view> </template> <wd-grid :column="4"> <wd-grid-item use-slot class="flex justify-center items-center" - v-for="(item, index) in menuList" + v-for="(item, index) in inspectMenu" :key="item.id" + @click.stop="goItemPage(item.path)" > - <image class="slot-img text-center" :src="item.url" /> + <image class="slot-img text-center" :src="item.icon" /> <text>{{ item.name }}</text> </wd-grid-item> </wd-grid> @@ -142,28 +128,62 @@ console.error(menuList) } +const goItemPage = (path: string) => { + const url = `/${path}` + uni.navigateTo({ + url, + }) +} + onLoad(() => { // getAllMenus() }) -const menuList = reactive([ +const equMenu = reactive([ { id: 1, - name: '娴嬭瘯', - url: '/static/menu/menu1.png', + name: '璁惧绠$悊', + icon: '/static/menu/menu1.png', + path: 'pages/equ/equ-list', + } +]) + +const inspectMenu = reactive([ + /* { + id: 0, + name: '璁惧鐐规', + icon: '/static/menu/menu0.png', + path: 'pages/inspect/insp-add', + }, */ + { + id: 1, + name: '鐐规姒傝', + icon: '/static/menu/menu1.png', + path: 'pages/inspect/insp-st', }, { id: 2, - name: '娴嬭瘯', - url: '/static/menu/menu1.png', + name: '鐐规姹囨��', + icon: '/static/menu/menu2.png', + path: 'pages/inspect/insp-st', + }, + { + id: 3, + name: '鐐规璁板綍', + icon: '/static/menu/menu3.png', + path: 'pages/inspect/insp-record', + }, + { + id: 4, + name: '鐐规璁″垝', + icon: '/static/menu/menu4.png', + path: 'pages/inspect/insp-add', }, ]) function handleUserInfo() { getAllMenus() } - - </script> <style lang="scss" scoped> @@ -201,6 +221,6 @@ .slot-img { width: 72rpx; height: 72rpx; - border-radius: 8rpx; + margin-left: 4rpx; } </style> diff --git a/eims-ui-mobile/src/pages/inspect/insp-add.vue b/eims-ui-mobile/src/pages/inspect/insp-add.vue new file mode 100644 index 0000000..7d513b3 --- /dev/null +++ b/eims-ui-mobile/src/pages/inspect/insp-add.vue @@ -0,0 +1,222 @@ +<route lang="json5" type="page"> +{ + layout: 'default', + style: { + navigationBarTitleText: '璁惧鐐规', + }, +} +</route> + +<template> + <view class="bg-base"> + <wd-form ref="form" :model="model" :rules="rules"> + <wd-cell-group custom-class="group" title="璁惧淇℃伅" border> + <wd-input + @click.stop="handleSelectEqu" + label="璁惧鍚嶇О" + label-width="200rpx" + prop="equId" + readonly + required + suffix-icon="arrow-right" + clearable + v-model="model.equId" + placeholder="璇烽�夋嫨璁惧" + @clicksuffixicon="handleSelectEqu" + /> + <!-- <wd-picker + label="璁惧鍚嶇О" + placeholder="璇烽�夎澶�" + label-width="200rpx" + prop="equId" + v-model="model.equId" + :columns="equList" + />--> + </wd-cell-group> + + <wd-cell-group custom-class="mt-2" title="鐐规淇℃伅" border> + <wd-picker + label="鐐规椤�" + placeholder="璇烽�夌偣妫�椤�" + label-width="200rpx" + prop="equId" + v-model="model.inspName" + :columns="equList" + /> + + <wd-input + label="鐐规缂栧彿" + placeholder="璇风敓鎴愮偣妫�缂栧彿" + label-width="200rpx" + v-model="model.inspCode" + prop="inspCode" + > + <template #suffix> + <wd-button size="small" @click.stop="handleInspCode">鐢熸垚</wd-button> + </template> + </wd-input> + + <wd-textarea + label="鐐规鎻忚堪" + label-width="200rpx" + type="textarea" + v-model="model.inspDesc" + auto-height + :maxlength="200" + show-word-limit + placeholder="璇疯緭鍏ョ偣妫�鎻忚堪" + clearable + prop="inspDesc" + /> + <wd-cell title="鐐规鍥剧墖" title-width="200rpx" prop="fileList"> + <wd-upload + :auto-upload="false" + :file-list="model.fileList" + :action="VITE_UPLOAD_BASEURL" + @change="handleFileChange" + ></wd-upload> + </wd-cell> + + <wd-calendar + label="璁″垝鏃ユ湡" + label-width="200rpx" + placeholder="璇烽�夋嫨鏃ユ湡" + prop="planTime" + v-model="model.planTime" + /> + <wd-datetime-picker + label="鐐规鏃堕棿" + label-width="200rpx" + placeholder="璇烽�夋嫨鏃堕棿" + prop="inspTime" + v-model="model.inspTime" + /> + </wd-cell-group> + + <view class="footer"> + <wd-button type="primary" size="large" @click="handleSubmit" block>鎻愪氦</wd-button> + </view> + </wd-form> + </view> +</template> +<script setup lang="ts"> +import { reactive, ref } from 'vue' +import { FormRules } from 'wot-design-uni/components/wd-form/types' +import { getEnvBaseUploadUrl } from '@/utils' + +const VITE_UPLOAD_BASEURL = `${getEnvBaseUploadUrl()}` + +const form = ref() +const model = reactive<{ + equId: string + inspName: string + inspCode: string + inspDesc: string + planTime: null | number + inspTime: number | string + fileList: [] +}>({ + equId: '', + inspName: '', + inspCode: '', + inspDesc: '', + planTime: null, + inspTime: '', + fileList: [], +}) +const rules: FormRules = { + equId: [ + { + required: true, + message: '璇烽�夋嫨璁惧', + }, + ], + inspName: [ + { + required: true, + message: '璇烽�夋嫨鐐规椤�', + }, + ], + inspCode: [ + { + required: true, + message: '璇疯緭鍏ョ偣妫�缂栫爜', + }, + ], + inspDesc: [ + { + required: true, + message: '璇疯緭鍏ョ偣妫�鎻忚堪', + }, + ], + fileList: [ + { + required: false, + message: '', + }, + ], +} + +const equList = ref<any[]>([ + { + value: '1', + label: '1#骞茬嚗鏈�', + }, + { + value: '2', + label: '1#骞茬嚗鏈�', + }, +]) + +/** + * 閫夋嫨璁惧 + */ +function handleSelectEqu() { + uni.navigateTo({ + url: '/pages/equ/equ-list', + events: { + // 涓烘寚瀹氫簨浠舵坊鍔犱竴涓洃鍚櫒锛岃幏鍙栬鎵撳紑椤甸潰浼犻�佸埌褰撳墠椤甸潰鐨勬暟鎹� + selectEqu: function (data) { + console.log(data) + }, + }, + success: function (res) { + // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹� + res.eventChannel.emit('handleSelectEqu', { data: '鐐规椤甸潰閫夋嫨璁惧' }) + }, + }) +} + +/** + * 鐢熸垚鐐规缂栧彿 + */ +function handleInspCode() { + console.error('鐢熸垚鐐规缂栫爜') +} + +/** + * 涓婁紶鐐规鍥剧墖 + * @param fileList + */ +function handleFileChange({ fileList }) { + model.fileList = fileList +} + +function handleSubmit() { + form.value + .validate() + .then(({ valid, errors }) => { + console.log(valid) + console.log(errors) + }) + .catch((error) => { + console.log(error, 'error') + }) +} +</script> +<style scoped lang="scss"> +.footer { + background: white; + padding: 60rpx 42rpx; +} +</style> diff --git a/eims-ui-mobile/src/pages/inspect/insp-record.vue b/eims-ui-mobile/src/pages/inspect/insp-record.vue new file mode 100644 index 0000000..f176fda --- /dev/null +++ b/eims-ui-mobile/src/pages/inspect/insp-record.vue @@ -0,0 +1,298 @@ +<route lang="json5"> +{ + style: { + navigationBarTitleText: '鐐规璁板綍', + navigationStyle: 'custom', + navigationBarBackgroundColor: '#4D80F0', + }, +} +</route> +<template> + <z-paging ref="paging" v-model="dataList" @query="queryList" show-refresher-update-time> + <template #top> + <wd-navbar + title="鐐规璁板綍" + left-arrow + @click-left="goBack" + right-text="鎻愪氦" + @click-right="handleClickRight" + custom-style="background: #4D80F0;" + safeAreaInsetTop + ></wd-navbar> + + <wd-card type="rectangle"> + <template #title> + <view class="flex justify-between"> + <view class="flex items-center menu-title-box"> + <view class="menu-indicator"></view> + <view class="ml-1 text-sm align-center">{{ inspSt.equName }}</view> + <view class="text-color-gray ml-2 text-mini">{{ inspSt.assetNo }}</view> + </view> + + <view class="flex items-center"> + <text class="text-color-gray text-mini">{{ inspSt.planTimeStr }}</text> + </view> + </view> + </template> + <view class="flex h-[100rpx]" items-center> + <image class="slot-img text-center" src="/static/images/camera.png" /> + <view class="flex-1"> + <view class="text-color-gray text-xs mt-1 flex"> + <text class="mr-3">鐐规鎬绘暟: {{ dataCount }}</text> + | + <text class="mx-3">宸茬偣妫�: {{ checkCount }}</text> + | + <text class="ml-3">鏈偣妫�: {{ dataCount - checkCount }}</text> + </view> + <view class="text-color-gray text-xs mt-2 flex"> + <text class="mr-3">姝e父: {{ normalNum }}</text> + | + <text class="mx-3">寮傚父: {{ abNormalNum }}</text> + </view> + <view class="text-color-gray text-xs mt-2 flex"> + <text>鐘舵�侊細</text> + <template v-if="dataCount > 0 && dataCount === checkCount"> + <wd-icon class="icon-color-success" name="check-outline" size="40rpx"></wd-icon> + <text class="ml-1">宸插畬鎴�</text> + </template> + <template v-else> + <wd-icon class="icon-color-base" name="detection" size="40rpx"></wd-icon> + <text class="ml-1">杩涜涓�</text> + </template> + </view> + </view> + </view> + </wd-card> + </template> + + <view class="bg-base"> + <view class="w-full h-[24rpx]"></view> + <wd-cell> + <template #title> + <text class="text-color-gray">鐐规椤�</text> + </template> + <wd-button size="small" type="text" @click.stop="toggleCollapse"> + {{ isAllExpanded ? '鍏ㄩ儴鎶樺彔' : '鍏ㄩ儴灞曞紑' }} + </wd-button> + </wd-cell> + <wd-collapse v-model="collSelects" title="鐐规椤�" ref="collapseRef"> + <wd-collapse-item :name="item.id" v-for="(item, index) in dataList"> + <template #title="{ expanded, disabled, isFirst }"> + <view class="flex justify-between"> + <view class="flex justify-center items-center"> + <text class="text-sm">{{ item.inspName }}</text> + </view> + + <view class="flex items-center"> + <wd-radio-group + v-model="item.inspResult" + inline + shape="dot" + @change="inspResultClick(item)" + > + <wd-radio value="1">姝e父</wd-radio> + <wd-radio value="2">寮傚父</wd-radio> + </wd-radio-group> + <wd-icon + v-if="expanded" + name="arrow-up" + size="30rpx" + class="icon-color-gray" + ></wd-icon> + <wd-icon v-else name="arrow-down" size="30rpx" class="icon-color-gray"></wd-icon> + </view> + </view> + </template> + <view class="text-color-gray text-xs flex justify-between"> + <text class="mr-3">鐐规浜�: {{ item.inspUserName }}</text> + <text class="mx-3">鐐规鏃堕棿: {{ item.inspTime }}</text> + </view> + </wd-collapse-item> + </wd-collapse> + </view> + </z-paging> +</template> + +<script setup lang="ts"> +import { ref } from 'vue' +import { useUserStore, useAccessStore, useSystemConfigStore } from '@/store' +import { getInspStRecordList, updateInspRecord, updateInspRecordBatch } from '@/service/inspect' +import { useToast, useMessage } from 'wot-design-uni' +import type { CollapseInstance } from 'wot-design-uni/components/wd-collapse/types' +const message = useMessage() +const toast = useToast() + +const collapseRef = ref<CollapseInstance>() +const isAllExpanded = ref(false) + +// 瀹氫箟鎺ュ彛 +interface QueryParams { + pageNum: number + pageSize: number + inspCode: string + status?: string +} + +interface InspSt { + inspCode: string + equName: string + assetNo: string + planTimeStr?: string +} + +const dataChange = ref(false) + +const userStore = useUserStore() + +const collSelects = ref<string[]>([]) + +// 鐐规姹囨�绘暟鎹�(涓婁釜椤甸潰浼犲��) +const inspSt = reactive<InspSt>({ + inspCode: '', + equName: '', + assetNo: '', + planTimeStr: '', +}) + +const paging = ref(null) +const dataList = ref([]) + +const queryList = (pageNum?: number, pageSize?: number) => { + // 杩欓噷鐨刾ageNo鍜宲ageSize浼氳嚜鍔ㄨ绠楀ソ锛岀洿鎺ヤ紶缁欐湇鍔″櫒鍗冲彲 + // 杩欓噷鐨勮姹傚彧鏄紨绀猴紝璇锋浛鎹㈡垚鑷繁鐨勯」鐩殑缃戠粶璇锋眰锛屽苟鍦ㄧ綉缁滆姹傚洖璋冧腑閫氳繃paging.value.complete(璇锋眰鍥炴潵鐨勬暟缁�)灏嗚姹傜粨鏋滀紶缁檢-paging + const params: QueryParams = { + pageNum, + pageSize, + inspCode: inspSt.inspCode, + } + + getInspStRecordList(params) + .then((res: any) => { + // 璇峰嬁鍦ㄧ綉缁滆姹傚洖璋冧腑缁檇ataList璧嬪�硷紒锛佸彧闇�瑕佽皟鐢╟omplete灏卞彲浠ヤ簡 + paging.value.complete(res.rows) + }) + .catch((res) => { + // 濡傛灉璇锋眰澶辫触鍐檖aging.value.complete(false)锛屼細鑷姩灞曠ず閿欒椤甸潰 + // 娉ㄦ剰锛屾瘡娆¢兘闇�瑕佸湪catch涓啓杩欏彞璇濆緢楹荤儲锛寊-paging鎻愪緵浜嗘柟妗堝彲浠ュ叏灞�缁熶竴澶勭悊 + // 鍦ㄥ簳灞傜殑缃戠粶璇锋眰鎶涘嚭寮傚父鏃讹紝鍐檜ni.$emit('z-paging-error-emit');鍗冲彲 + paging.value.complete(false) + }) +} + +function inspResultClick(item: any) { + // userStore?.userInfo?.realName +} + +const goBack = () => { + uni.navigateBack() +} +function handleClickRight() { + handleConfirm() +} + +const toggleCollapse = () => { + isAllExpanded.value = !isAllExpanded.value + collapseRef.value.toggleAll(isAllExpanded.value) +} + +function handleConfirm() { + if (!dataChange.value) { + message.alert('璇锋搷浣滃悗鎻愪氦!') + return false + } + message + .confirm({ + msg: '纭畾鎻愪氦锛�', + title: '鎻愮ず', + beforeConfirm: ({ resolve }) => { + updateData(resolve) + }, + }) + .then(() => {}) + .catch((error) => { + console.log(error) + }) +} + +function updateData(resolve: any) { + const params = { + inspRecordList: dataList.value, + } + updateInspRecordBatch(params) + .then((res: any) => { + paging.value.reload() + resolve(true) + }) + .catch((res) => { + console.error(res) + }) +} + +/** + * 鐐规璁板綍鏉$洰鐐瑰嚮浜嬩欢 + * @param item + */ +function itemClick(item: any) {} + +watch( + () => [...dataList.value], // 浣跨敤鎵╁睍杩愮畻绗﹀垱寤烘柊鏁扮粍浠ヨЕ鍙戠洃鍚� + (newVal, oldVal) => { + if (oldVal.length > 0) { + dataChange.value = true + } + }, + { deep: true }, +) +onLoad((options) => { + inspSt.inspCode = options.inspCode + inspSt.equName = options.equName + inspSt.assetNo = options.assetNo + inspSt.planTimeStr = options.planTimeStr +}) + +const dataCount = computed(() => dataList.value.length) +const checkCount = computed(() => dataList.value.filter((item) => item.status === '1').length) +const normalNum = computed(() => dataList.value.filter((item) => item.inspResult === '1').length) +const abNormalNum = computed(() => dataList.value.filter((item) => item.inspResult === '2').length) +</script> + +<style scoped lang="scss"> +.menu-title-box { + height: 30rpx; + line-height: 30rpx; +} + +.slot-img { + width: 72rpx; + height: 72rpx; + margin-right: 24rpx; +} +.text-mini { + font-size: 22rpx; +} + +.menu-indicator { + width: 6rpx; + height: 22rpx; + border-radius: 10rpx; + background-color: $uni-color-primary; +} +:deep(.wd-card__footer) { + padding: 10rpx !important; +} + +.col-title-box { +} +.bg-primary { + background: $uni-color-primary; +} +:deep(.wd-navbar__text) { + font-size: 26rpx; + color: white; +} +:deep(.wd-icon-arrow-left:before), +:deep(.wd-navbar__title) { + color: white; + font-weight: 0; +} +</style> diff --git a/eims-ui-mobile/src/pages/inspect/insp-st.vue b/eims-ui-mobile/src/pages/inspect/insp-st.vue new file mode 100644 index 0000000..d380724 --- /dev/null +++ b/eims-ui-mobile/src/pages/inspect/insp-st.vue @@ -0,0 +1,149 @@ +<route lang="json5" type="page"> +{ + layout: 'default', + style: { + navigationBarTitleText: '鐐规姹囨��', + }, +} +</route> + +<template> + <z-paging ref="paging" v-model="dataList" @query="queryList" show-refresher-update-time> + <template #top> + <wd-drop-menu> + <wd-drop-menu-item v-model="viewMode" :options="viewModeList" @change="handleViewMode" /> + <wd-drop-menu-item v-model="equName" :options="equList" @change="handleEquName" /> + </wd-drop-menu> + <wd-divider></wd-divider> + </template> + <view class="bg-base"> + <view class="w-full h-[24rpx]"></view> + <wd-card type="rectangle" v-for="(item, index) in dataList" :key="item.id"> + <template #title> + <view class="flex justify-between"> + <view class="flex items-center menu-title-box"> + <view class="menu-indicator"></view> + <view class="ml-1 text-sm align-center">{{ item.equName }}</view> + <view class="text-color-gray ml-2 text-mini">{{ item.assetNo }}</view> + </view> + + <view class="flex items-center"> + <text class="text-color-gray text-mini">{{ item.planTimeStr }}</text> + </view> + </view> + </template> + <view class="flex h-[100rpx]" items-center> + <image class="slot-img text-center" src="/static/images/camera.png" /> + <view class="flex-1"> + <view class="text-color-gray text-xs mt-1 flex"> + <text class="mr-3">鐐规鎬绘暟: {{ item.recordCount }}</text> + | + <text class="mx-3">宸茬偣妫�: {{ item.checkCount }}</text> + | + <text class="ml-3">鏈偣妫�: {{ item.unCheckCount }}</text> + </view> + <view class="text-color-gray text-xs mt-2 flex"> + <text class="mr-3">姝e父: {{ item.normalNum }}</text> + | + <text class="mx-3">寮傚父: {{ item.abNormalNum }}</text> + </view> + <view class="text-color-gray text-xs mt-2 flex"> + <text>鐘舵�侊細</text> + <template v-if="item.recordCount === item.checkCount"> + <wd-icon class="icon-color-success" name="check-outline" size="40rpx"></wd-icon> + <text class="ml-1">宸插畬鎴�</text> + </template> + <template v-else> + <wd-icon class="icon-color-base" name="detection" size="40rpx"></wd-icon> + <text class="ml-1">杩涜涓�</text> + </template> + </view> + </view> + <wd-button size="small" icon="edit-outline" @click.stop="itemClick(item)">鏄庣粏</wd-button> + </view> + </wd-card> + </view> + </z-paging> +</template> + +<script setup lang="ts"> +import { ref } from 'vue' +import { getInspStList } from '@/service/inspect' + +const viewMode = ref<string>('Day') +const equName = ref<string>('鎵�鏈夎澶�') + +const viewModeList = ref<Record<string, any>[]>([ + { label: '鏃ヨ鍥�', value: 'Day' }, + { label: '鏈堣鍥�', value: 'Month' }, +]) +const equList = ref<Record<string, any>[]>([{ label: '鎵�鏈夎澶�', value: '鎵�鏈夎澶�' }]) +function handleViewMode({ value }) { + console.log(value) +} +function handleEquName({ value }) { + console.log(value) +} + +const paging = ref(null) +const dataList = ref([]) + +const queryList = (pageNum?: number, pageSize?: number) => { + // 杩欓噷鐨刾ageNo鍜宲ageSize浼氳嚜鍔ㄨ绠楀ソ锛岀洿鎺ヤ紶缁欐湇鍔″櫒鍗冲彲 + // 杩欓噷鐨勮姹傚彧鏄紨绀猴紝璇锋浛鎹㈡垚鑷繁鐨勯」鐩殑缃戠粶璇锋眰锛屽苟鍦ㄧ綉缁滆姹傚洖璋冧腑閫氳繃paging.value.complete(璇锋眰鍥炴潵鐨勬暟缁�)灏嗚姹傜粨鏋滀紶缁檢-paging + getInspStList({ pageNum, pageSize }) + .then((res: any) => { + // 璇峰嬁鍦ㄧ綉缁滆姹傚洖璋冧腑缁檇ataList璧嬪�硷紒锛佸彧闇�瑕佽皟鐢╟omplete灏卞彲浠ヤ簡 + console.log(res) + paging.value.complete(res.rows) + }) + .catch((res) => { + // 濡傛灉璇锋眰澶辫触鍐檖aging.value.complete(false)锛屼細鑷姩灞曠ず閿欒椤甸潰 + // 娉ㄦ剰锛屾瘡娆¢兘闇�瑕佸湪catch涓啓杩欏彞璇濆緢楹荤儲锛寊-paging鎻愪緵浜嗘柟妗堝彲浠ュ叏灞�缁熶竴澶勭悊 + // 鍦ㄥ簳灞傜殑缃戠粶璇锋眰鎶涘嚭寮傚父鏃讹紝鍐檜ni.$emit('z-paging-error-emit');鍗冲彲 + paging.value.complete(false) + }) +} + +function itemClick(item) { + const inspCode = `${item.equId}_${item.planTime}_${viewMode.value}` + uni.navigateTo({ + url: `/pages/inspect/insp-record?inspCode=${inspCode}&equName=${item.equName}&assetNo=${item.assetNo}&planTimeStr=${item.planTimeStr}`, + }) +} + +onLoad(() => { + queryList() +}) +</script> + +<style scoped lang="scss"> +.menu-title-box { +} + +.slot-img { + width: 72rpx; + height: 72rpx; + margin-right: 24rpx; +} +.statu-img { + width: 60rpx; + height: 40rpx; +} +.text-mini { + font-size: 22rpx; +} + +.menu-indicator { + width: 6rpx; + height: 26rpx; + border-radius: 10rpx; + background-color: $uni-color-primary; +} +:deep(.wd-card__footer) { + padding: 10rpx !important; +} +:deep(.wd-card__title-content) { + padding: 24rpx 0 !important; +} +</style> diff --git a/eims-ui-mobile/src/pages/login/index.vue b/eims-ui-mobile/src/pages/login/index.vue index 46626e7..bc68841 100644 --- a/eims-ui-mobile/src/pages/login/index.vue +++ b/eims-ui-mobile/src/pages/login/index.vue @@ -32,14 +32,21 @@ /> </wd-cell-group> <view class="footer"> - <view class="w-full text-end"> - <wd-checkbox v-model="rember" shape="square" @change="handleChange"> - 璁颁綇瀵嗙爜 + <view> + <wd-checkbox v-model="rember" @change="handleChange"> + <text class="rember-text">璁颁綇瀵嗙爜</text> </wd-checkbox> </view> <wd-button class="mt-6" type="primary" size="large" @click="handleSubmit" block> 鎻愪氦 </wd-button> + + <view class="copyright-info"> + <text> + 涓婃捣鍏板疂浼犳劅绉戞妧鑲′唤鏈夐檺鍏徃 + </text> + + </view> </view> </wd-form> </template> @@ -128,6 +135,20 @@ <style scoped lang="scss"> .footer { - padding: 12px; + padding: 24rpx; +} +.rember-text { + font-size: 24rpx; + color: $uni-text-color-grey; +} + +.copyright-info { + position: absolute; + bottom: 20rpx; + width: 100%; + display: flex; + justify-content: center; + color: $uni-text-color-disable; + font-size: 24rpx; } </style> diff --git a/eims-ui-mobile/src/service/equ.d.ts b/eims-ui-mobile/src/service/equ.d.ts new file mode 100644 index 0000000..7807f19 --- /dev/null +++ b/eims-ui-mobile/src/service/equ.d.ts @@ -0,0 +1,124 @@ +export interface EquVO { + /** + * + */ + equId: number | string; + + /** + * 璧勪骇缂栧彿 + */ + assetNo: string; + /** + * 璁惧缂栫爜 + */ + equCode: string; + + /** + * 璁惧鍚嶇О + + */ + equName: string; + /** + * 璁惧绫诲瀷 + + */ + equTypeName: string; + + /** + * 鍨嬪彿 + */ + modelNo: string; + + /** + * 鍒堕�犲晢 + */ + madeIn: string; + + /** + * 棰濆害鍔熺巼 + */ + ratedPower: number; + + /** + * 閾墝淇℃伅 + */ + plateInfo: string; + + /** + * 閲囪喘鏃ユ湡 + */ + purchaseDate: string; + + /** + * 鐘舵�� + */ + status: string; + + /** + * 鎵�鍦ㄥ満鎵� + */ + location: string; + + /** + * 浣跨敤閮ㄩ棬锛堝叧鑱攊d锛� + */ + deptUsed: number; + /** + * 浣跨敤閮ㄩ棬鍚嶇О + */ + deptName: number; + + /** + * 璐d换浜�(鍏宠仈id) + */ + respPerson: number; + /** + * 璐d换浜� + */ + respPersonName: string; + + /** + * 鑱旂郴鐢佃瘽 + */ + contactPhone: string; + + /** + * 姝e紡浣跨敤鏃ユ湡 + */ + deployDate: string; + + /** + * 寮�濮嬭瘯鐢ㄦ棩鏈� + */ + trialDate: string; + + /** + * 璁″垝楠屾敹鏃ユ湡 + */ + planAcceptDate: string; + + /** + * 瀹為檯楠屾敹鏃ユ湡 + */ + actualAcceptDate: string; + + /** + * 瀵煎叆鐘舵�侊紙瀛楀吀锛� + */ + importStatus: number; + + /** + * 鐩樼偣鏍囧織 + */ + inventoryFlag: number; + + /** + * 涓婃鐩樼偣鏃ユ湡 + */ + inventoryDate: string; + + /** + * 浣跨敤骞撮檺 + */ + serviceLife: number; +} diff --git a/eims-ui-mobile/src/service/equ.ts b/eims-ui-mobile/src/service/equ.ts new file mode 100644 index 0000000..429e521 --- /dev/null +++ b/eims-ui-mobile/src/service/equ.ts @@ -0,0 +1,9 @@ +import { http } from '@/utils/http' +import type { EquVO } from './equ.d' + +/** + * 璁惧鍒楄〃 + */ +export const getEquList = (params: any) => { + return http.get<EquVO[]>('/eims/equ/list', params) +} diff --git a/eims-ui-mobile/src/service/inspect.d.ts b/eims-ui-mobile/src/service/inspect.d.ts new file mode 100644 index 0000000..69b0430 --- /dev/null +++ b/eims-ui-mobile/src/service/inspect.d.ts @@ -0,0 +1,150 @@ +/** + * 鐐规姹囨�� + */ +export interface InspectStVO { + /** + * + */ + id: number | string; + + /** + * + */ + title: string; + + /** + * + */ + equId: number | string; + status: string; + + /** + * + */ + planTime: string; + + /** + * 淇濆吇浜� + */ + maintUser: number; + + /** + * 楠岃瘉浜� + */ + verifyUser: number; + verifyTime: string; + + /** + * 鐗硅浜嬮」 + */ + specialNote: string; + + /** + * 澶囨敞 + */ + remark: string; +} + + +/** + * 鐐规璁板綍 + */ +export interface InspectRecordVO { + /** + * id + */ + id: string | number; + + /** + * 璁惧di + */ + equId: string | number; + /** + * 璁惧鍚嶇О + + */ + equName: string; + /** + * 璧勪骇缂栧彿 + + */ + assteNo: string; + + /** + * 鐐规鍚嶇О + */ + inspName: string; + + /** + * 鐐规鎻忚堪 + */ + inspDesc: string; + + /** + * 鐘舵�� + */ + status: string; + + /** + * 鐐规缂栫爜 + */ + inspCode: string; + + /** + * 鍊艰褰曟柟寮忥紙瀛楀吀锛� + */ + recordMode: string; + + /** + * 鍙傝�冨�� + */ + referenceValue: string; + + /** + * 涓婇檺 + */ + upperLimit: string; + + /** + * 涓嬮檺 + */ + lowLimit: string; + + /** + * 妫�鏌ュ�� + */ + checkValue: string; + + /** + * 鐐规缁撴灉锛堝瓧鍏革級 + */ + inspResult: string; + + /** + * 鐐规鏃堕棿 + */ + inspTime: string; + + /** + * 璁″垝鐐规鏃ユ湡 + */ + planTime: string; + + /** + * 楠岃瘉浜� + */ + verifyUser: number; + + /** + * 璁″垝id + */ + planId: string | number; + + /** + * 澶囨敞 + */ + remark: string; + +} + + diff --git a/eims-ui-mobile/src/service/inspect.ts b/eims-ui-mobile/src/service/inspect.ts new file mode 100644 index 0000000..55da5d3 --- /dev/null +++ b/eims-ui-mobile/src/service/inspect.ts @@ -0,0 +1,29 @@ +import { http } from '@/utils/http' +import type { InspectStVO, InspectRecordVO } from './inspect.d' + +/** + * 鐐规姹囨�诲垪琛� + */ +export const getInspStList = (params: any) => { + params.viewMode = 'Day' + return http.get<InspectStVO[]>('/eims/inspectSt/list', params) +} + +/** + * 鐐规姹囨�诲垪琛ㄤ笅鐐规璁板綍鍒楄〃 + */ +export const getInspStRecordList = (params: any) => { + return http.get<InspectRecordVO[]>('/eims/inspRecord/stList', params) +} + +/** + * 鏇存柊鐐规璁板綍 + * @param data + */ +export const updateInspRecord = (data: any) => { + return http.post<void>('/eims/inspRecord', data) +} + +export const updateInspRecordBatch = (data: any) => { + return http.put<void>('/eims/inspRecord/editBatch', data) +} diff --git a/eims-ui-mobile/src/static/ico/ico-ok.png b/eims-ui-mobile/src/static/ico/ico-ok.png new file mode 100644 index 0000000..8e4eddb --- /dev/null +++ b/eims-ui-mobile/src/static/ico/ico-ok.png Binary files differ diff --git a/eims-ui-mobile/src/static/images/camera.png b/eims-ui-mobile/src/static/images/camera.png new file mode 100644 index 0000000..cbe7fa2 --- /dev/null +++ b/eims-ui-mobile/src/static/images/camera.png Binary files differ diff --git a/eims-ui-mobile/src/static/menu/menu0.png b/eims-ui-mobile/src/static/menu/menu0.png new file mode 100644 index 0000000..9e978e4 --- /dev/null +++ b/eims-ui-mobile/src/static/menu/menu0.png Binary files differ diff --git a/eims-ui-mobile/src/static/menu/menu1.png b/eims-ui-mobile/src/static/menu/menu1.png index 6f2fa77..733c5b6 100644 --- a/eims-ui-mobile/src/static/menu/menu1.png +++ b/eims-ui-mobile/src/static/menu/menu1.png Binary files differ diff --git a/eims-ui-mobile/src/static/menu/menu2.png b/eims-ui-mobile/src/static/menu/menu2.png index 5720ac0..c9948fe 100644 --- a/eims-ui-mobile/src/static/menu/menu2.png +++ b/eims-ui-mobile/src/static/menu/menu2.png Binary files differ diff --git a/eims-ui-mobile/src/static/menu/menu3.png b/eims-ui-mobile/src/static/menu/menu3.png new file mode 100644 index 0000000..b9eb77d --- /dev/null +++ b/eims-ui-mobile/src/static/menu/menu3.png Binary files differ diff --git a/eims-ui-mobile/src/static/menu/menu4.png b/eims-ui-mobile/src/static/menu/menu4.png new file mode 100644 index 0000000..9cf1e31 --- /dev/null +++ b/eims-ui-mobile/src/static/menu/menu4.png Binary files differ diff --git a/eims-ui-mobile/src/static/menu/menu5.png b/eims-ui-mobile/src/static/menu/menu5.png new file mode 100644 index 0000000..9dbf0f6 --- /dev/null +++ b/eims-ui-mobile/src/static/menu/menu5.png Binary files differ diff --git a/eims-ui-mobile/src/style/index.scss b/eims-ui-mobile/src/style/index.scss index feed87c..ad6d70e 100644 --- a/eims-ui-mobile/src/style/index.scss +++ b/eims-ui-mobile/src/style/index.scss @@ -29,10 +29,20 @@ .icon-color-base { color: $uni-color-primary; } +.icon-color-gray { + color: $uni-text-color-grey; +} +.icon-color-success { + color: $uni-color-success; +} .bg-base { background: $uni-bg-color-grey; } +.bg-primary { + background: $uni-color-primary; +} + diff --git a/eims-ui-mobile/src/types/auto-import.d.ts b/eims-ui-mobile/src/types/auto-import.d.ts index 117a03d..5dedc7d 100644 --- a/eims-ui-mobile/src/types/auto-import.d.ts +++ b/eims-ui-mobile/src/types/auto-import.d.ts @@ -79,12 +79,10 @@ const useCssVars: typeof import('vue')['useCssVars'] const useId: typeof import('vue')['useId'] const useModel: typeof import('vue')['useModel'] - const useNavbarWeixin: (typeof import('../hooks/useNavbarWeixin'))['default'] const useRequest: typeof import('../hooks/useRequest')['default'] const useSlots: typeof import('vue')['useSlots'] const useTemplateRef: typeof import('vue')['useTemplateRef'] const useUpload: typeof import('../hooks/useUpload')['default'] - const useUpload2: typeof import('../hooks/useUpload2')['default'] const watch: typeof import('vue')['watch'] const watchEffect: typeof import('vue')['watchEffect'] const watchPostEffect: typeof import('vue')['watchPostEffect'] diff --git a/eims-ui-mobile/src/types/uni-pages.d.ts b/eims-ui-mobile/src/types/uni-pages.d.ts index 4e88f42..7b066d0 100644 --- a/eims-ui-mobile/src/types/uni-pages.d.ts +++ b/eims-ui-mobile/src/types/uni-pages.d.ts @@ -5,7 +5,11 @@ interface NavigateToOptions { url: "/pages/home/index" | + "/pages/equ/equ-list" | "/pages/equ/index" | + "/pages/inspect/insp-add" | + "/pages/inspect/insp-record" | + "/pages/inspect/insp-st" | "/pages/login/index" | "/pages/my/index" | "/pages/spare/index"; diff --git a/eims-ui-mobile/src/utils/http.ts b/eims-ui-mobile/src/utils/http.ts index 4106b0b..f1d74ce 100644 --- a/eims-ui-mobile/src/utils/http.ts +++ b/eims-ui-mobile/src/utils/http.ts @@ -2,6 +2,9 @@ import { useUserStore, useAccessStore } from '@/store' export const http = <T>(options: CustomRequestOptions) => { + uni.showLoading({ + title: '鍔犺浇涓�', + }) // 1. 杩斿洖 Promise 瀵硅薄 return new Promise<IResData<T>>((resolve, reject) => { uni.request({ @@ -12,11 +15,26 @@ // #endif // 鍝嶅簲鎴愬姛 success(res) { + uni.hideLoading() // 鐘舵�佺爜 2xx锛屽弬鑰� axios 鐨勮璁� if (res.statusCode >= 200 && res.statusCode < 300) { // 2.1 鎻愬彇鏍稿績鏁版嵁 res.data if ((res.data as IResData<T>).code === 200) { resolve(((res.data as IResData<T>).data || res.data) as IResData<T>) + } else if ((res.data as IResData<T>).code === 401) { + uni.showToast({ + icon: 'none', + title: '鐧诲綍瓒呮椂锛岃閲嶆柊鐧诲綍锛�', + }) + // 401閿欒 -> 娓呯悊鐢ㄦ埛淇℃伅锛岃烦杞埌鐧诲綍椤� + useAccessStore().clearAccessInfo() + useUserStore().clearUserInfo() + const loginRoute = '/pages/login/index' + // 閲嶆柊鐧诲綍鍚庤繑鍥為〉闈� + const url = '/pages/home/index' + const redirectRoute = `${loginRoute}?redirect=${encodeURIComponent(url)}` + uni.navigateTo({ url: redirectRoute }) + reject(res) } else { uni.showToast({ icon: 'none', @@ -46,6 +64,7 @@ title: '缃戠粶閿欒锛屾崲涓綉缁滆瘯璇�', }) reject(err) + uni.hideLoading() }, }) }) @@ -85,5 +104,19 @@ }) } +export const httpPut = <T>( + url: string, + data?: Record<string, any>, + query?: Record<string, any>, +) => { + return http<T>({ + url, + query, + data, + method: 'PUT', + }) +} + http.get = httpGet http.post = httpPost +http.put = httpPut -- Gitblit v1.9.3