diff --git a/src/router/modules/remaining.ts b/src/router/modules/remaining.ts
index 794778cad..c29848c8b 100644
--- a/src/router/modules/remaining.ts
+++ b/src/router/modules/remaining.ts
@@ -127,6 +127,42 @@ const remainingRouter: AppRouteRecordRaw[] = [
}
]
},
+ {
+ path: '/mes',
+ component: Layout,
+ name: 'MesWmRouter',
+ meta: {
+ hidden: true
+ },
+ children: [
+ {
+ path: 'wm/warehouse/location',
+ component: () => import('@/views/mes/wm/warehouse/location/index.vue'),
+ name: 'MesWmLocationRouter',
+ meta: {
+ noCache: true,
+ hidden: true,
+ canTo: true,
+ icon: '',
+ title: '库区设置',
+ activeMenu: '/mes/wm/warehouse'
+ }
+ },
+ {
+ path: 'wm/warehouse/area',
+ component: () => import('@/views/mes/wm/warehouse/area/index.vue'),
+ name: 'MesWmAreaRouter',
+ meta: {
+ noCache: true,
+ hidden: true,
+ canTo: true,
+ icon: '',
+ title: '库位设置',
+ activeMenu: '/mes/wm/warehouse'
+ }
+ }
+ ]
+ },
{
path: '/codegen',
diff --git a/src/views/mes/wm/warehouse/WarehouseForm.vue b/src/views/mes/wm/warehouse/WarehouseForm.vue
index 4f6a475dc..c186541c1 100644
--- a/src/views/mes/wm/warehouse/WarehouseForm.vue
+++ b/src/views/mes/wm/warehouse/WarehouseForm.vue
@@ -9,6 +9,7 @@
>
+
@@ -26,7 +27,12 @@
clearable
class="!w-1/1"
>
-
+
@@ -38,7 +44,7 @@
-
+
+
@@ -78,6 +85,7 @@
+
确 定
取 消
@@ -90,6 +98,8 @@ import { CommonStatusEnum } from '@/utils/constants'
import { WmWarehouseApi, WmWarehouseVO } from '@/api/mes/wm/warehouse'
import * as UserApi from '@/api/system/user'
+// TODO @AI:变量注释,模仿下别的模块
+
defineOptions({ name: 'WarehouseForm' })
const { t } = useI18n()
@@ -121,6 +131,7 @@ const formRef = ref()
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
+ // TODO @AI:注释的风格,参考下别的模块的 form;
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
@@ -140,6 +151,7 @@ defineExpose({ open })
/** 提交表单 */
const emit = defineEmits(['success'])
const submitForm = async () => {
+ // TODO @AI:注释的风格,参考下别的模块的 form;
await formRef.value.validate()
formLoading.value = true
try {
diff --git a/src/views/mes/wm/warehouse/area/AreaForm.vue b/src/views/mes/wm/warehouse/area/AreaForm.vue
index dc9a09bae..1ec8d242c 100644
--- a/src/views/mes/wm/warehouse/area/AreaForm.vue
+++ b/src/views/mes/wm/warehouse/area/AreaForm.vue
@@ -43,6 +43,7 @@
+
@@ -55,7 +56,7 @@
-
+
-
+
-
+
-
+
@@ -121,6 +137,7 @@
+
@@ -140,6 +157,7 @@
+
确 定
取 消
@@ -155,9 +173,11 @@ import { WmWarehouseAreaApi, WmWarehouseAreaVO } from '@/api/mes/wm/warehouse/ar
defineOptions({ name: 'AreaForm' })
+// TODO @AI:变量注释,模仿下别的模块
const { t } = useI18n()
const message = useMessage()
+// TODO @AI:变量注释,模仿下别的模块
const dialogVisible = ref(false)
const dialogTitle = ref('')
const formLoading = ref(false)
@@ -194,6 +214,7 @@ const formRules = reactive({
})
const formRef = ref()
+/** 加载库区列表 */
const loadLocationList = async (warehouseId?: number) => {
if (!warehouseId) {
locationList.value = []
@@ -202,13 +223,20 @@ const loadLocationList = async (warehouseId?: number) => {
locationList.value = await WmWarehouseLocationApi.getWarehouseLocationSimpleList(warehouseId)
}
+/** 仓库改变时,重置库区 */
const handleWarehouseChange = async (warehouseId?: number) => {
formData.value.locationId = undefined
await loadLocationList(warehouseId)
}
/** 打开弹窗 */
-const open = async (type: string, id?: number) => {
+const open = async (
+ type: string,
+ id?: number,
+ defaultLocationId?: number,
+ defaultWarehouseId?: number
+) => {
+ // TODO @AI:注释的风格,参考下别的模块的 form;
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
@@ -240,6 +268,20 @@ const open = async (type: string, id?: number) => {
} finally {
formLoading.value = false
}
+ return
+ }
+ if (defaultWarehouseId) {
+ selectedWarehouseId.value = defaultWarehouseId
+ await loadLocationList(defaultWarehouseId)
+ }
+ if (defaultLocationId) {
+ if (!selectedWarehouseId.value) {
+ const location = await WmWarehouseLocationApi.getWarehouseLocation(defaultLocationId)
+ selectedWarehouseId.value = location.warehouseId
+ await loadLocationList(selectedWarehouseId.value)
+ }
+ // TODO @linter:修复
+ formData.value.locationId = defaultLocationId
}
}
defineExpose({ open })
diff --git a/src/views/mes/wm/warehouse/area/index.vue b/src/views/mes/wm/warehouse/area/index.vue
index d677fa988..9a254df00 100644
--- a/src/views/mes/wm/warehouse/area/index.vue
+++ b/src/views/mes/wm/warehouse/area/index.vue
@@ -1,32 +1,21 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
搜索
重置
-
+ 返回库区
+
新增
导出
@@ -82,17 +80,20 @@
-
-
-
+
+
+
- {{ scope.row.enabled ? '是' : '否' }}
+ {{
+ scope.row.enabled ? '是' : '否'
+ }}
+
@@ -100,9 +101,12 @@
- {{ scope.row.frozen ? '是' : '否' }}
+ {{
+ scope.row.frozen ? '是' : '否'
+ }}
+
编辑
@@ -124,7 +128,7 @@
link
type="danger"
@click="handleDelete(scope.row.id)"
- v-hasPermi="['mes:wm-warehouse-area:delete']"
+ v-hasPermi="['mes:wm-warehouse:delete']"
>
删除
@@ -146,8 +150,7 @@
import { dateFormatter } from '@/utils/formatTime'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import download from '@/utils/download'
-import { WmWarehouseApi, WmWarehouseVO } from '@/api/mes/wm/warehouse'
-import { WmWarehouseLocationApi, WmWarehouseLocationVO } from '@/api/mes/wm/warehouse/location'
+import { WmWarehouseLocationApi } from '@/api/mes/wm/warehouse/location'
import { WmWarehouseAreaApi, WmWarehouseAreaVO } from '@/api/mes/wm/warehouse/area'
import AreaForm from './AreaForm.vue'
@@ -155,13 +158,16 @@ defineOptions({ name: 'MesWmArea' })
const message = useMessage()
const { t } = useI18n()
+const router = useRouter()
+const route = useRoute()
const loading = ref(true)
const list = ref([])
const total = ref(0)
-const warehouseList = ref([])
-const locationList = ref([])
-const queryWarehouseId = ref(undefined)
+const currentWarehouseId = ref(undefined)
+const currentWarehouseName = ref('')
+const currentLocationId = ref(undefined)
+const currentLocationName = ref('')
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
@@ -174,17 +180,30 @@ const queryParams = reactive({
const queryFormRef = ref()
const exportLoading = ref(false)
-const loadLocationList = async (warehouseId?: number) => {
- if (!warehouseId) {
- locationList.value = []
- return
+const parseQueryId = (queryValue: string | string[] | null | undefined): number | undefined => {
+ const value = Array.isArray(queryValue) ? queryValue[0] : queryValue
+ if (!value) {
+ return undefined
}
- locationList.value = await WmWarehouseLocationApi.getWarehouseLocationSimpleList(warehouseId)
+ const id = Number(value)
+ return Number.isInteger(id) && id > 0 ? id : undefined
}
-const handleWarehouseChange = async (warehouseId?: number) => {
- queryParams.locationId = undefined
- await loadLocationList(warehouseId)
+const loadLocationContext = async () => {
+ const locationId = parseQueryId(route.query.locationId as string | string[] | undefined)
+ if (!locationId) {
+ return
+ }
+ currentLocationId.value = locationId
+ queryParams.locationId = locationId
+ try {
+ const location = await WmWarehouseLocationApi.getWarehouseLocation(locationId)
+ currentLocationName.value = location.name
+ currentWarehouseId.value = location.warehouseId
+ currentWarehouseName.value = location.warehouseName
+ } catch {
+ // 忽略上级名称加载异常,不影响列表查询
+ }
}
/** 查询列表 */
@@ -207,16 +226,27 @@ const handleQuery = () => {
/** 重置按钮操作 */
const resetQuery = () => {
- queryWarehouseId.value = undefined
- locationList.value = []
queryFormRef.value.resetFields()
+ queryParams.locationId = currentLocationId.value
handleQuery()
}
+/** 返回库区页面 */
+const goBackToLocation = () => {
+ if (currentWarehouseId.value) {
+ router.push({
+ path: '/mes/wm/warehouse/location',
+ query: { warehouseId: String(currentWarehouseId.value) }
+ })
+ return
+ }
+ router.push('/mes/wm/warehouse/location')
+}
+
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
- formRef.value.open(type, id)
+ formRef.value.open(type, id, currentLocationId.value, currentWarehouseId.value)
}
/** 删除按钮操作 */
@@ -243,7 +273,7 @@ const handleExport = async () => {
}
onMounted(async () => {
+ await loadLocationContext()
await getList()
- warehouseList.value = await WmWarehouseApi.getWarehouseSimpleList()
})
diff --git a/src/views/mes/wm/warehouse/index.vue b/src/views/mes/wm/warehouse/index.vue
index b01aa428b..4d6b6ef65 100644
--- a/src/views/mes/wm/warehouse/index.vue
+++ b/src/views/mes/wm/warehouse/index.vue
@@ -1,6 +1,12 @@
-
+
+
+
@@ -38,7 +46,12 @@
搜索
重置
-
+
新增
-
-
-
-
-
-
+
+
+
- {{ scope.row.frozen ? '是' : '否' }}
+ {{
+ scope.row.frozen ? '是' : '否'
+ }}
+
-
+
+
+ 库区
+
+
([])
@@ -165,6 +188,14 @@ const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
+/** 打开库区页面 */
+const openLocation = (warehouseId: number) => {
+ router.push({
+ path: '/mes/wm/warehouse/location',
+ query: { warehouseId: String(warehouseId) }
+ })
+}
+
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
diff --git a/src/views/mes/wm/warehouse/location/LocationForm.vue b/src/views/mes/wm/warehouse/location/LocationForm.vue
index 4d92fcc15..dc747d55b 100644
--- a/src/views/mes/wm/warehouse/location/LocationForm.vue
+++ b/src/views/mes/wm/warehouse/location/LocationForm.vue
@@ -9,6 +9,7 @@
>
+
@@ -78,6 +79,7 @@
+
确 定
取 消
@@ -92,6 +94,7 @@ import { WmWarehouseLocationApi, WmWarehouseLocationVO } from '@/api/mes/wm/ware
defineOptions({ name: 'LocationForm' })
+// TODO @AI:变量注释,模仿下别的模块
const { t } = useI18n()
const message = useMessage()
@@ -122,7 +125,8 @@ const formRules = reactive({
const formRef = ref()
/** 打开弹窗 */
-const open = async (type: string, id?: number) => {
+const open = async (type: string, id?: number, defaultWarehouseId?: number) => {
+ // TODO @AI:注释的风格,参考下别的模块的 form;
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
@@ -135,6 +139,11 @@ const open = async (type: string, id?: number) => {
} finally {
formLoading.value = false
}
+ return
+ }
+ // TODO @linter:修复
+ if (defaultWarehouseId) {
+ formData.value.warehouseId = defaultWarehouseId
}
}
defineExpose({ open })
@@ -142,6 +151,7 @@ defineExpose({ open })
/** 提交表单 */
const emit = defineEmits(['success'])
const submitForm = async () => {
+ // TODO @AI:注释的风格,参考下别的模块的 form;
await formRef.value.validate()
formLoading.value = true
try {
diff --git a/src/views/mes/wm/warehouse/location/index.vue b/src/views/mes/wm/warehouse/location/index.vue
index 753927b0c..e121c182c 100644
--- a/src/views/mes/wm/warehouse/location/index.vue
+++ b/src/views/mes/wm/warehouse/location/index.vue
@@ -1,6 +1,21 @@
-
+
+
+
-
-
-
-
-
搜索
重置
+ 返回仓库
新增
@@ -61,7 +69,7 @@
plain
@click="handleExport"
:loading="exportLoading"
- v-hasPermi="['mes:wm-warehouse-location:export']"
+ v-hasPermi="['mes:wm-warehouse:export']"
>
导出
@@ -71,25 +79,32 @@
-
-
+
+
- {{ scope.row.areaEnabled ? '启用' : '关闭' }}
+ {{
+ scope.row.areaEnabled ? '启用' : '关闭'
+ }}
+
+
- {{ scope.row.frozen ? '是' : '否' }}
+ {{
+ scope.row.frozen ? '是' : '否'
+ }}
+
-
+
+
+ 库位
+
+
编辑
@@ -111,7 +135,7 @@
link
type="danger"
@click="handleDelete(scope.row.id)"
- v-hasPermi="['mes:wm-warehouse-location:delete']"
+ v-hasPermi="['mes:wm-warehouse:delete']"
>
删除
@@ -133,7 +157,7 @@
import { dateFormatter } from '@/utils/formatTime'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import download from '@/utils/download'
-import { WmWarehouseApi, WmWarehouseVO } from '@/api/mes/wm/warehouse'
+import { WmWarehouseApi } from '@/api/mes/wm/warehouse'
import { WmWarehouseLocationApi, WmWarehouseLocationVO } from '@/api/mes/wm/warehouse/location'
import LocationForm from './LocationForm.vue'
@@ -141,11 +165,15 @@ defineOptions({ name: 'MesWmLocation' })
const message = useMessage()
const { t } = useI18n()
+const router = useRouter()
+const route = useRoute()
const loading = ref(true)
const list = ref([])
const total = ref(0)
-const warehouseList = ref([])
+const currentWarehouseId = ref(undefined)
+// TODO @AI:搞个 currentWarehouse 对象;
+const currentWarehouseName = ref('')
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
@@ -158,6 +186,32 @@ const queryParams = reactive({
const queryFormRef = ref()
const exportLoading = ref(false)
+// TODO @AI:只考虑解析成 number,不要搞这么复杂;必须存在!
+const parseQueryId = (queryValue: string | string[] | null | undefined): number | undefined => {
+ const value = Array.isArray(queryValue) ? queryValue[0] : queryValue
+ if (!value) {
+ return undefined
+ }
+ const id = Number(value)
+ return Number.isInteger(id) && id > 0 ? id : undefined
+}
+
+// TODO @AI:这个逻辑简化下,别搞这么复杂;
+const loadWarehouseContext = async () => {
+ const warehouseId = parseQueryId(route.query.warehouseId as string | string[] | undefined)
+ if (!warehouseId) {
+ return
+ }
+ currentWarehouseId.value = warehouseId
+ queryParams.warehouseId = warehouseId
+ try {
+ const warehouse = await WmWarehouseApi.getWarehouse(warehouseId)
+ currentWarehouseName.value = warehouse.name
+ } catch {
+ // 忽略上级名称加载异常,不影响列表查询
+ }
+}
+
/** 查询列表 */
const getList = async () => {
loading.value = true
@@ -179,13 +233,27 @@ const handleQuery = () => {
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
+ queryParams.warehouseId = currentWarehouseId.value
handleQuery()
}
+/** 返回仓库页面 */
+const goBackToWarehouse = () => {
+ router.push('/mes/wm/warehouse')
+}
+
+/** 打开库位页面 */
+const openArea = (locationId: number) => {
+ router.push({
+ path: '/mes/wm/warehouse/area',
+ query: { locationId: String(locationId) }
+ })
+}
+
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
- formRef.value.open(type, id)
+ formRef.value.open(type, id, currentWarehouseId.value)
}
/** 删除按钮操作 */
@@ -212,7 +280,7 @@ const handleExport = async () => {
}
onMounted(async () => {
+ await loadWarehouseContext()
await getList()
- warehouseList.value = await WmWarehouseApi.getWarehouseSimpleList()
})