🎨 style(mes/wm): 对齐注释风格、修复 TODO、重构冗余代码
- warehouse/index.vue:补充变量行内注释;将 chargeUserId 展示内联到模板 - WarehouseForm.vue:删除非标准 DONE @AI 注释;补充变量注释、defineExpose/defineEmits 注释、submitForm 步骤注释 - location/index.vue:补充变量行内注释;修复 warehouseId 类型;使用具名路由跳转 - location/LocationForm.vue:补充注释;修复 warehouseId 类型;补充新增时默认值注释 - area/index.vue:合并 parseQueryId 到 loadLocationContext;将 4 个散 ref 合并为 currentLocation 对象;补充变量行内注释 - area/AreaForm.vue:修复 locationId 类型;简化 open 方法中逐字段赋值为直接赋值;补充注释 - md/workstation/WorkstationForm.vue:补充 JSDoc 注释、变量注释、submitForm 步骤注释 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>pull/871/MERGE
parent
47fd8b6018
commit
5289b8b3bd
|
|
@ -43,7 +43,63 @@
|
|||
<el-input v-model="formData.address" placeholder="请输入工作站地点" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- TODO @芋艿:所属工序,等工序模块完成后对接 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="线边库" prop="warehouseId">
|
||||
<el-select
|
||||
v-model="formData.warehouseId"
|
||||
placeholder="请选择线边库"
|
||||
clearable
|
||||
class="!w-1/1"
|
||||
@change="handleWarehouseChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="warehouse in warehouseList"
|
||||
:key="warehouse.id"
|
||||
:label="warehouse.name"
|
||||
:value="warehouse.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="库区" prop="locationId">
|
||||
<el-select
|
||||
v-model="formData.locationId"
|
||||
placeholder="请选择库区"
|
||||
clearable
|
||||
class="!w-1/1"
|
||||
:disabled="!formData.warehouseId"
|
||||
@change="handleLocationChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="location in locationList"
|
||||
:key="location.id"
|
||||
:label="location.name"
|
||||
:value="location.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="库位" prop="areaId">
|
||||
<el-select
|
||||
v-model="formData.areaId"
|
||||
placeholder="请选择库位"
|
||||
clearable
|
||||
class="!w-1/1"
|
||||
:disabled="!formData.locationId"
|
||||
>
|
||||
<el-option
|
||||
v-for="area in areaList"
|
||||
:key="area.id"
|
||||
:label="area.name"
|
||||
:value="area.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="formData.status">
|
||||
|
|
@ -88,6 +144,9 @@
|
|||
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import { MdWorkstationApi, MdWorkstationVO } from '@/api/mes/md/workstation'
|
||||
import { MdWorkshopApi, MdWorkshopVO } from '@/api/mes/md/workstation/workshop'
|
||||
import { WmWarehouseApi, WmWarehouseVO } from '@/api/mes/wm/warehouse'
|
||||
import { WmWarehouseLocationApi, WmWarehouseLocationVO } from '@/api/mes/wm/warehouse/location'
|
||||
import { WmWarehouseAreaApi, WmWarehouseAreaVO } from '@/api/mes/wm/warehouse/area'
|
||||
import { CommonStatusEnum } from '@/utils/constants'
|
||||
import { generateRandomStr } from '@/utils'
|
||||
import WorkstationMachinePanel from './WorkstationMachinePanel.vue'
|
||||
|
|
@ -105,6 +164,9 @@ const formLoading = ref(false) // 表单的加载中:1)修改时的数据加
|
|||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const activeTab = ref('machine') // 当前激活的资源 Tab
|
||||
const workshopList = ref<MdWorkshopVO[]>([]) // 车间下拉列表
|
||||
const warehouseList = ref<WmWarehouseVO[]>([]) // 仓库下拉列表
|
||||
const locationList = ref<WmWarehouseLocationVO[]>([]) // 库区下拉列表
|
||||
const areaList = ref<WmWarehouseAreaVO[]>([]) // 库位下拉列表
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
|
|
@ -124,13 +186,45 @@ const formRules = reactive({
|
|||
workshopId: [{ required: true, message: '所在车间不能为空', trigger: 'change' }],
|
||||
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }]
|
||||
}) // 表单校验规则
|
||||
const formRef = ref()
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 生成工作站编码 */
|
||||
const generateCode = () => {
|
||||
formData.value.code = 'WS' + generateRandomStr(12)
|
||||
}
|
||||
|
||||
/** 加载库区列表 */
|
||||
const loadLocationList = async (warehouseId?: number) => {
|
||||
if (!warehouseId) {
|
||||
locationList.value = []
|
||||
return
|
||||
}
|
||||
locationList.value = await WmWarehouseLocationApi.getWarehouseLocationSimpleList(warehouseId)
|
||||
}
|
||||
|
||||
/** 加载库位列表 */
|
||||
const loadAreaList = async (locationId?: number) => {
|
||||
if (!locationId) {
|
||||
areaList.value = []
|
||||
return
|
||||
}
|
||||
areaList.value = await WmWarehouseAreaApi.getWarehouseAreaSimpleList(locationId)
|
||||
}
|
||||
|
||||
/** 仓库改变时,重置库区和库位 */
|
||||
const handleWarehouseChange = async (warehouseId?: number) => {
|
||||
formData.value.locationId = undefined
|
||||
formData.value.areaId = undefined
|
||||
areaList.value = []
|
||||
await loadLocationList(warehouseId)
|
||||
}
|
||||
|
||||
/** 库区改变时,重置库位 */
|
||||
const handleLocationChange = async (locationId?: number) => {
|
||||
formData.value.areaId = undefined
|
||||
await loadAreaList(locationId)
|
||||
}
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
|
|
@ -139,22 +233,29 @@ const open = async (type: string, id?: number) => {
|
|||
resetForm()
|
||||
// 加载车间列表
|
||||
workshopList.value = await MdWorkshopApi.getWorkshopSimpleList()
|
||||
// 加载仓库列表
|
||||
warehouseList.value = await WmWarehouseApi.getWarehouseSimpleList()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await MdWorkstationApi.getWorkstation(id)
|
||||
// 加载库区和库位列表(因为修改时会回显仓库和库区,所以需要加载对应的列表)
|
||||
await loadLocationList(formData.value.warehouseId)
|
||||
await loadAreaList(formData.value.locationId)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open })
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success'])
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as MdWorkstationVO
|
||||
|
|
@ -166,6 +267,7 @@ const submitForm = async () => {
|
|||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
|
|
@ -187,6 +289,8 @@ const resetForm = () => {
|
|||
status: CommonStatusEnum.ENABLE,
|
||||
remark: undefined
|
||||
}
|
||||
locationList.value = []
|
||||
areaList.value = []
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
>
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<!-- DONE @AI:字段布局按 WM 表单统一为三列 -->
|
||||
<el-form-item label="仓库编码" prop="code">
|
||||
<el-input v-model="formData.code" placeholder="请输入仓库编码" />
|
||||
</el-form-item>
|
||||
|
|
@ -71,7 +70,6 @@
|
|||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<!-- DONE @AI:本版不接入条码预览,保留简化弹窗操作区 -->
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
|
|
@ -84,14 +82,14 @@ import * as UserApi from '@/api/system/user'
|
|||
|
||||
defineOptions({ name: 'WarehouseForm' })
|
||||
|
||||
const { t } = useI18n()
|
||||
const message = useMessage()
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('')
|
||||
const formLoading = ref(false)
|
||||
const formType = ref('')
|
||||
const userList = ref<UserApi.UserVO[]>([])
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const userList = ref<UserApi.UserVO[]>([]) // 用户列表
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
|
|
@ -101,13 +99,13 @@ const formData = ref({
|
|||
chargeUserId: undefined,
|
||||
frozen: false,
|
||||
remark: undefined
|
||||
})
|
||||
}) // 表单数据
|
||||
const formRules = reactive({
|
||||
code: [{ required: true, message: '仓库编码不能为空', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '仓库名称不能为空', trigger: 'blur' }],
|
||||
frozen: [{ required: true, message: '是否冻结不能为空', trigger: 'change' }]
|
||||
})
|
||||
const formRef = ref()
|
||||
}) // 表单校验规则
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
|
|
@ -115,7 +113,9 @@ const open = async (type: string, id?: number) => {
|
|||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 加载用户列表
|
||||
userList.value = await UserApi.getSimpleUserList()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
|
|
@ -125,12 +125,14 @@ const open = async (type: string, id?: number) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open })
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success'])
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as WmWarehouseVO
|
||||
|
|
@ -142,6 +144,7 @@ const submitForm = async () => {
|
|||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
|
|
|
|||
|
|
@ -156,21 +156,21 @@ import { WmWarehouseAreaApi, WmWarehouseAreaVO } from '@/api/mes/wm/warehouse/ar
|
|||
|
||||
defineOptions({ name: 'AreaForm' })
|
||||
|
||||
const { t } = useI18n()
|
||||
const message = useMessage()
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('')
|
||||
const formLoading = ref(false)
|
||||
const formType = ref('')
|
||||
const selectedWarehouseId = ref<number | undefined>(undefined)
|
||||
const warehouseList = ref<WmWarehouseVO[]>([])
|
||||
const locationList = ref<WmWarehouseLocationVO[]>([])
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const selectedWarehouseId = ref<number | undefined>(undefined) // 当前选中的仓库 ID
|
||||
const warehouseList = ref<WmWarehouseVO[]>([]) // 仓库列表
|
||||
const locationList = ref<WmWarehouseLocationVO[]>([]) // 库区列表
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
locationId: undefined,
|
||||
locationId: undefined as number | undefined,
|
||||
area: undefined,
|
||||
maxLoad: undefined,
|
||||
positionX: undefined,
|
||||
|
|
@ -191,7 +191,7 @@ const formRules = reactive({
|
|||
allowItemMixing: [{ required: true, message: '物料混放开关不能为空', trigger: 'change' }],
|
||||
allowBatchMixing: [{ required: true, message: '批次混放开关不能为空', trigger: 'change' }]
|
||||
})
|
||||
const formRef = ref()
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 加载库区列表 */
|
||||
const loadLocationList = async (warehouseId?: number) => {
|
||||
|
|
@ -215,39 +215,25 @@ const open = async (
|
|||
defaultLocationId?: number,
|
||||
defaultWarehouseId?: number
|
||||
) => {
|
||||
// TODO @AI:注释的风格,参考下别的模块的 form;
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
warehouseList.value = await WmWarehouseApi.getWarehouseSimpleList()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = await WmWarehouseAreaApi.getWarehouseArea(id)
|
||||
selectedWarehouseId.value = data.warehouseId
|
||||
await loadLocationList(selectedWarehouseId.value)
|
||||
formData.value = {
|
||||
id: data.id,
|
||||
code: data.code,
|
||||
name: data.name,
|
||||
locationId: data.locationId,
|
||||
area: data.area,
|
||||
maxLoad: data.maxLoad,
|
||||
positionX: data.positionX,
|
||||
positionY: data.positionY,
|
||||
positionZ: data.positionZ,
|
||||
enabled: data.enabled,
|
||||
frozen: data.frozen,
|
||||
allowItemMixing: data.allowItemMixing,
|
||||
allowBatchMixing: data.allowBatchMixing,
|
||||
remark: data.remark
|
||||
}
|
||||
formData.value = data
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
return
|
||||
}
|
||||
// 新增时,设置默认仓库和库区(从列表页跳转过来时传入)
|
||||
if (defaultWarehouseId) {
|
||||
selectedWarehouseId.value = defaultWarehouseId
|
||||
await loadLocationList(defaultWarehouseId)
|
||||
|
|
@ -258,16 +244,17 @@ const open = async (
|
|||
selectedWarehouseId.value = location.warehouseId
|
||||
await loadLocationList(selectedWarehouseId.value)
|
||||
}
|
||||
// TODO @linter:修复
|
||||
formData.value.locationId = defaultLocationId
|
||||
}
|
||||
}
|
||||
defineExpose({ open })
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success'])
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as WmWarehouseAreaVO
|
||||
|
|
@ -279,6 +266,7 @@ const submitForm = async () => {
|
|||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
|
|
@ -293,7 +281,7 @@ const resetForm = () => {
|
|||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
locationId: undefined,
|
||||
locationId: undefined as number | undefined,
|
||||
area: undefined,
|
||||
maxLoad: undefined,
|
||||
positionX: undefined,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<template>
|
||||
<ContentWrap>
|
||||
<el-alert
|
||||
v-if="currentLocationId"
|
||||
:title="`当前仓库/库区:${currentWarehouseName || `#${currentWarehouseId || '-'}`} / ${currentLocationName || `#${currentLocationId}`}`"
|
||||
v-if="currentLocation.id"
|
||||
:title="`当前仓库/库区:${currentLocation.warehouseName || `#${currentLocation.warehouseId || '-'}`} / ${currentLocation.name || `#${currentLocation.id}`}`"
|
||||
type="info"
|
||||
show-icon
|
||||
:closable="false"
|
||||
|
|
@ -140,51 +140,44 @@ import AreaForm from './AreaForm.vue'
|
|||
|
||||
defineOptions({ name: 'MesWmArea' })
|
||||
|
||||
const message = useMessage()
|
||||
const { t } = useI18n()
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
const route = useRoute()
|
||||
|
||||
const loading = ref(true)
|
||||
const list = ref<WmWarehouseAreaVO[]>([])
|
||||
const total = ref(0)
|
||||
const currentWarehouseId = ref<number | undefined>(undefined)
|
||||
const currentWarehouseName = ref('')
|
||||
const currentLocationId = ref<number | undefined>(undefined)
|
||||
const currentLocationName = ref('')
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<WmWarehouseAreaVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const currentLocation = ref<{ id: number; name: string; warehouseId: number; warehouseName: string }>({
|
||||
id: 0,
|
||||
name: '',
|
||||
warehouseId: 0,
|
||||
warehouseName: ''
|
||||
}) // 当前库区上下文
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
locationId: undefined,
|
||||
locationId: undefined as number | undefined,
|
||||
positionX: undefined,
|
||||
positionY: undefined,
|
||||
positionZ: undefined
|
||||
})
|
||||
const queryFormRef = ref()
|
||||
|
||||
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
|
||||
}
|
||||
}) // 查询参数
|
||||
const queryFormRef = ref() // 查询表单 Ref
|
||||
|
||||
/** 加载库区上下文(从 URL query 参数获取 locationId,并加载库区和仓库名称) */
|
||||
const loadLocationContext = async () => {
|
||||
const locationId = parseQueryId(route.query.locationId as string | string[] | undefined)
|
||||
if (!locationId) {
|
||||
const locationId = Number(route.query.locationId)
|
||||
if (!Number.isInteger(locationId) || locationId <= 0) {
|
||||
return
|
||||
}
|
||||
currentLocationId.value = locationId
|
||||
// TODO @AI:linter 报错
|
||||
currentLocation.value.id = locationId
|
||||
queryParams.locationId = locationId
|
||||
try {
|
||||
const location = await WmWarehouseLocationApi.getWarehouseLocation(locationId)
|
||||
currentLocationName.value = location.name
|
||||
currentWarehouseId.value = location.warehouseId
|
||||
currentWarehouseName.value = location.warehouseName
|
||||
currentLocation.value.name = location.name
|
||||
currentLocation.value.warehouseId = location.warehouseId
|
||||
currentLocation.value.warehouseName = location.warehouseName
|
||||
} catch {
|
||||
// 忽略上级名称加载异常,不影响列表查询
|
||||
}
|
||||
|
|
@ -211,14 +204,14 @@ const handleQuery = () => {
|
|||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
queryParams.locationId = currentLocationId.value
|
||||
queryParams.locationId = currentLocation.value.id || undefined
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const formRef = ref() // 表单 Ref
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id, currentLocationId.value, currentWarehouseId.value)
|
||||
formRef.value.open(type, id, currentLocation.value.id || undefined, currentLocation.value.warehouseId || undefined)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
|
|
|
|||
|
|
@ -54,7 +54,11 @@
|
|||
<el-table-column label="面积(㎡)" align="center" prop="area" min-width="100" />
|
||||
<el-table-column label="负责人" align="center" prop="chargeUserId" min-width="100">
|
||||
<template #default="scope">
|
||||
{{ getChargeUserName(scope.row.chargeUserId) }}
|
||||
{{
|
||||
scope.row.chargeUserId
|
||||
? userList.find((user) => user.id === scope.row.chargeUserId)?.nickname || '-'
|
||||
: '-'
|
||||
}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="冻结" align="center" prop="frozen" min-width="80">
|
||||
|
|
@ -119,36 +123,28 @@ import WarehouseForm from './WarehouseForm.vue'
|
|||
|
||||
defineOptions({ name: 'MesWmWarehouse' })
|
||||
|
||||
const message = useMessage()
|
||||
const { t } = useI18n()
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
const router = useRouter()
|
||||
|
||||
const loading = ref(true)
|
||||
const list = ref<WmWarehouseVO[]>([])
|
||||
const userList = ref<UserApi.UserVO[]>([])
|
||||
const total = ref(0)
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<WmWarehouseVO[]>([]) // 列表的数据
|
||||
const userList = ref<UserApi.UserVO[]>([]) // 用户列表
|
||||
const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
frozen: undefined
|
||||
})
|
||||
const queryFormRef = ref()
|
||||
}) // 查询参数
|
||||
const queryFormRef = ref() // 查询表单 Ref
|
||||
|
||||
/** 加载用户列表 */
|
||||
const loadUserList = async () => {
|
||||
userList.value = await UserApi.getSimpleUserList()
|
||||
}
|
||||
|
||||
// TODO @AI:直接在上面的模块,渲染;html 里;
|
||||
const getChargeUserName = (userId?: number) => {
|
||||
if (!userId) {
|
||||
return '-'
|
||||
}
|
||||
return userList.value.find((user) => user.id === userId)?.nickname || '-'
|
||||
}
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
|
|
@ -174,16 +170,15 @@ const resetQuery = () => {
|
|||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const formRef = ref() // 表单 Ref
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
|
||||
/** 打开库区页面 */
|
||||
const openLocation = (warehouseId: number) => {
|
||||
// TODO @AI:使用 name 跳转
|
||||
router.push({
|
||||
path: '/mes/wm/warehouse/location',
|
||||
name: 'MesWmLocation',
|
||||
query: { warehouseId: String(warehouseId) }
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,20 +73,19 @@ import { WmWarehouseLocationApi, WmWarehouseLocationVO } from '@/api/mes/wm/ware
|
|||
|
||||
defineOptions({ name: 'LocationForm' })
|
||||
|
||||
// TODO @AI:变量注释,模仿下别的模块
|
||||
const { t } = useI18n()
|
||||
const message = useMessage()
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('')
|
||||
const formLoading = ref(false)
|
||||
const formType = ref('')
|
||||
const warehouseList = ref<WmWarehouseVO[]>([])
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const warehouseList = ref<WmWarehouseVO[]>([]) // 仓库列表
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
warehouseId: undefined,
|
||||
warehouseId: undefined as number | undefined,
|
||||
area: undefined,
|
||||
areaEnabled: true,
|
||||
frozen: false,
|
||||
|
|
@ -98,16 +97,16 @@ const formRules = reactive({
|
|||
warehouseId: [{ required: true, message: '所属仓库不能为空', trigger: 'change' }],
|
||||
frozen: [{ required: true, message: '是否冻结不能为空', trigger: 'change' }]
|
||||
})
|
||||
const formRef = ref()
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number, defaultWarehouseId?: number) => {
|
||||
// TODO @AI:注释的风格,参考下别的模块的 form;
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
warehouseList.value = await WmWarehouseApi.getWarehouseSimpleList()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
|
|
@ -117,18 +116,19 @@ const open = async (type: string, id?: number, defaultWarehouseId?: number) => {
|
|||
}
|
||||
return
|
||||
}
|
||||
// TODO @linter:修复
|
||||
// 新增时,设置默认仓库(从列表页跳转过来时传入)
|
||||
if (defaultWarehouseId) {
|
||||
formData.value.warehouseId = defaultWarehouseId
|
||||
}
|
||||
}
|
||||
defineExpose({ open })
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success'])
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// TODO @AI:注释的风格,参考下别的模块的 form;
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as WmWarehouseLocationVO
|
||||
|
|
@ -140,6 +140,7 @@ const submitForm = async () => {
|
|||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
|
|
@ -152,7 +153,7 @@ const resetForm = () => {
|
|||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
warehouseId: undefined,
|
||||
warehouseId: undefined as number | undefined,
|
||||
area: undefined,
|
||||
areaEnabled: true,
|
||||
frozen: false,
|
||||
|
|
|
|||
|
|
@ -115,26 +115,28 @@ import LocationForm from './LocationForm.vue'
|
|||
|
||||
defineOptions({ name: 'MesWmLocation' })
|
||||
|
||||
const message = useMessage()
|
||||
const { t } = useI18n()
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const loading = ref(true)
|
||||
const list = ref<WmWarehouseLocationVO[]>([])
|
||||
const total = ref(0)
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<WmWarehouseLocationVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const currentWarehouse = ref<{ id: number; name: string }>({
|
||||
id: 0,
|
||||
name: ''
|
||||
})
|
||||
}) // 当前仓库上下文
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
warehouseId: undefined
|
||||
})
|
||||
const queryFormRef = ref()
|
||||
warehouseId: undefined as number | undefined
|
||||
}) // 查询参数
|
||||
const queryFormRef = ref() // 查询表单 Ref
|
||||
|
||||
/** 加载仓库上下文(从 URL query 参数获取 warehouseId,并加载仓库名称) */
|
||||
const loadWarehouseContext = async () => {
|
||||
const warehouseId = Number(route.query.warehouseId)
|
||||
if (!Number.isInteger(warehouseId) || warehouseId <= 0) {
|
||||
|
|
@ -178,13 +180,13 @@ const resetQuery = () => {
|
|||
/** 打开库位页面 */
|
||||
const openArea = (locationId: number) => {
|
||||
router.push({
|
||||
path: '/mes/wm/warehouse/area',
|
||||
name: 'MesWmArea',
|
||||
query: { locationId: String(locationId) }
|
||||
})
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const formRef = ref() // 表单 Ref
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id, currentWarehouse.value.id || undefined)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue