refactor(frontend): 优化基础数据页与文档,自动加载列表
1. 拆分基础数据帮助文档为区域维护和物料档案独立版本 2. 将onMounted加载列表改为watch immediate监听模式适配路由复用 3. 为盘点页添加页面自动加载历史盘点单 4. 为半成品页添加页面自动加载列表 5. 更新打包资源引用路径
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import request from '../utils/request'
|
||||
import PageHelp from '../components/PageHelp.vue'
|
||||
import { helpBaseData } from '../help'
|
||||
import { helpZone, helpMaterial } from '../help'
|
||||
|
||||
// mode: 'zone' = 区域维护;'material' = 物料档案(同一组件拆成两个独立菜单)
|
||||
const props = defineProps({
|
||||
mode: { type: String, default: 'zone' }
|
||||
})
|
||||
|
||||
// 帮助文档按菜单各自独立:区域维护 / 物料档案 分开展示
|
||||
const helpData = computed(() => (props.mode === 'material' ? helpMaterial : helpZone))
|
||||
|
||||
/* ---------- 区域维护 ---------- */
|
||||
const zones = ref([])
|
||||
const zoneTotal = ref(0)
|
||||
@@ -161,10 +164,13 @@ async function saveMaterial() {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (props.mode === 'material') loadMaterials()
|
||||
else loadZones()
|
||||
})
|
||||
// 区域维护 / 物料档案 共用同一组件:切换菜单时组件实例被复用,
|
||||
// onMounted 不会再次触发,故用 watch(mode, immediate) 保证进入即加载对应列表
|
||||
watch(
|
||||
() => props.mode,
|
||||
(m) => { if (m === 'material') loadMaterials(); else loadZones() },
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -303,7 +309,7 @@ onMounted(() => {
|
||||
</el-dialog>
|
||||
</template>
|
||||
</el-card>
|
||||
<PageHelp :data="helpBaseData" />
|
||||
<PageHelp :data="helpData" />
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -15,6 +15,7 @@ onMounted(async () => {
|
||||
const ms = await request.get('/material/list')
|
||||
materials.value = Array.isArray(ms) ? ms : ms?.list || []
|
||||
} catch { /* 字典加载失败不阻塞入库 */ }
|
||||
loadList()
|
||||
})
|
||||
|
||||
const operator = getRealName()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { nextTick, reactive, ref } from 'vue'
|
||||
import { nextTick, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import request from '../utils/request'
|
||||
import { fmtTime } from '../utils/format'
|
||||
@@ -113,6 +113,9 @@ async function loadHistory() {
|
||||
historyLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 进入页面即加载历史盘点单,无需手动点击查询
|
||||
onMounted(() => { loadHistory() })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user