feat(mes): 新增车间管理、工位管理模块前端
- API 接口:workstation/index.ts、workshop.ts - 车间:列表页 + 表单弹窗 - 工位:列表页 + 表单弹窗(含设备/工具/人员三个子资源 Tab 面板) - 共 9 个 Vue/TS 文件pull/871/MERGE
parent
15dd4dce76
commit
8a3e33952b
|
|
@ -0,0 +1,156 @@
|
|||
import request from '@/config/axios'
|
||||
|
||||
// TODO @AI:是不是每个 VO 独立文件;例如说 tool/ 、worker/、machine/ 等等
|
||||
|
||||
// MES 工位 VO
|
||||
export interface MdWorkstationVO {
|
||||
id: number // 工位编号
|
||||
code: string // 工位编码
|
||||
name: string // 工位名称
|
||||
address: string // 工位地点
|
||||
workshopId: number // 所在车间 ID
|
||||
workshopName: string // 所在车间名称
|
||||
processId: number // 工序 ID
|
||||
warehouseId: number // 线边库 ID
|
||||
locationId: number // 库区 ID
|
||||
areaId: number // 库位 ID
|
||||
status: number // 状态
|
||||
remark: string // 备注
|
||||
attribute1: string
|
||||
attribute2: string
|
||||
attribute3: number
|
||||
attribute4: number
|
||||
}
|
||||
|
||||
// MES 工位设备 VO
|
||||
export interface MdWorkstationMachineVO {
|
||||
id: number
|
||||
workstationId: number // 工位 ID
|
||||
machineryId: number // 设备 ID
|
||||
machineryName: string // 设备名称
|
||||
machineryCode: string // 设备编码
|
||||
quantity: number // 数量
|
||||
remark: string // 备注
|
||||
}
|
||||
|
||||
// MES 工位工具 VO
|
||||
export interface MdWorkstationToolVO {
|
||||
id: number
|
||||
workstationId: number // 工位 ID
|
||||
toolTypeId: number // 工具类型 ID
|
||||
toolTypeName: string // 工具类型名称
|
||||
quantity: number // 数量
|
||||
remark: string // 备注
|
||||
}
|
||||
|
||||
// MES 工位人员 VO
|
||||
export interface MdWorkstationWorkerVO {
|
||||
id: number
|
||||
workstationId: number // 工位 ID
|
||||
postId: number // 岗位 ID
|
||||
postName: string // 岗位名称
|
||||
quantity: number // 数量
|
||||
remark: string // 备注
|
||||
}
|
||||
|
||||
// MES 工位 API
|
||||
export const MdWorkstationApi = {
|
||||
// 查询工位分页
|
||||
getWorkstationPage: async (params: any) => {
|
||||
return await request.get({ url: `/mes/md-workstation/page`, params })
|
||||
},
|
||||
|
||||
// 查询工位精简列表
|
||||
getWorkstationSimpleList: async () => {
|
||||
return await request.get({ url: `/mes/md-workstation/simple-list` })
|
||||
},
|
||||
|
||||
// 查询工位详情
|
||||
getWorkstation: async (id: number) => {
|
||||
return await request.get({ url: `/mes/md-workstation/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增工位
|
||||
createWorkstation: async (data: MdWorkstationVO) => {
|
||||
return await request.post({ url: `/mes/md-workstation/create`, data })
|
||||
},
|
||||
|
||||
// 修改工位
|
||||
updateWorkstation: async (data: MdWorkstationVO) => {
|
||||
return await request.put({ url: `/mes/md-workstation/update`, data })
|
||||
},
|
||||
|
||||
// 删除工位
|
||||
deleteWorkstation: async (id: number) => {
|
||||
return await request.delete({ url: `/mes/md-workstation/delete?id=` + id })
|
||||
},
|
||||
|
||||
// 导出工位 Excel
|
||||
exportWorkstation: async (params: any) => {
|
||||
return await request.download({ url: `/mes/md-workstation/export-excel`, params })
|
||||
}
|
||||
}
|
||||
|
||||
// MES 工位设备 API
|
||||
export const MdWorkstationMachineApi = {
|
||||
// 查询工位设备列表
|
||||
getWorkstationMachineList: async (workstationId: number) => {
|
||||
return await request.get({ url: `/mes/md-workstation-machine/list-by-workstation?workstationId=` + workstationId })
|
||||
},
|
||||
|
||||
// 新增工位设备
|
||||
createWorkstationMachine: async (data: MdWorkstationMachineVO) => {
|
||||
return await request.post({ url: `/mes/md-workstation-machine/create`, data })
|
||||
},
|
||||
|
||||
// 删除工位设备
|
||||
deleteWorkstationMachine: async (id: number) => {
|
||||
return await request.delete({ url: `/mes/md-workstation-machine/delete?id=` + id })
|
||||
}
|
||||
}
|
||||
|
||||
// MES 工位工具 API
|
||||
export const MdWorkstationToolApi = {
|
||||
// 查询工位工具列表
|
||||
getWorkstationToolList: async (workstationId: number) => {
|
||||
return await request.get({ url: `/mes/md-workstation-tool/list-by-workstation?workstationId=` + workstationId })
|
||||
},
|
||||
|
||||
// 新增工位工具
|
||||
createWorkstationTool: async (data: MdWorkstationToolVO) => {
|
||||
return await request.post({ url: `/mes/md-workstation-tool/create`, data })
|
||||
},
|
||||
|
||||
// 修改工位工具
|
||||
updateWorkstationTool: async (data: MdWorkstationToolVO) => {
|
||||
return await request.put({ url: `/mes/md-workstation-tool/update`, data })
|
||||
},
|
||||
|
||||
// 删除工位工具
|
||||
deleteWorkstationTool: async (id: number) => {
|
||||
return await request.delete({ url: `/mes/md-workstation-tool/delete?id=` + id })
|
||||
}
|
||||
}
|
||||
|
||||
// MES 工位人员 API
|
||||
export const MdWorkstationWorkerApi = {
|
||||
// 查询工位人员列表
|
||||
getWorkstationWorkerList: async (workstationId: number) => {
|
||||
return await request.get({ url: `/mes/md-workstation-worker/list-by-workstation?workstationId=` + workstationId })
|
||||
},
|
||||
|
||||
// 新增工位人员
|
||||
createWorkstationWorker: async (data: MdWorkstationWorkerVO) => {
|
||||
return await request.post({ url: `/mes/md-workstation-worker/create`, data })
|
||||
},
|
||||
|
||||
// 修改工位人员
|
||||
updateWorkstationWorker: async (data: MdWorkstationWorkerVO) => {
|
||||
return await request.put({ url: `/mes/md-workstation-worker/update`, data })
|
||||
},
|
||||
|
||||
// 删除工位人员
|
||||
deleteWorkstationWorker: async (id: number) => {
|
||||
return await request.delete({ url: `/mes/md-workstation-worker/delete?id=` + id })
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
import request from '@/config/axios'
|
||||
|
||||
// TODO @AI:是不是独立文件夹
|
||||
|
||||
// MES 车间 VO
|
||||
export interface MdWorkshopVO {
|
||||
id: number // 车间编号
|
||||
code: string // 车间编码
|
||||
name: string // 车间名称
|
||||
area: number // 面积
|
||||
chargeUserId: number // 负责人用户编号
|
||||
chargeUserName: string // 负责人名称
|
||||
status: number // 状态
|
||||
remark: string // 备注
|
||||
attribute1: string // 预留字段1
|
||||
attribute2: string // 预留字段2
|
||||
attribute3: number // 预留字段3
|
||||
attribute4: number // 预留字段4
|
||||
}
|
||||
|
||||
// MES 车间 API
|
||||
export const MdWorkshopApi = {
|
||||
// 查询车间分页
|
||||
getWorkshopPage: async (params: any) => {
|
||||
return await request.get({ url: `/mes/md-workshop/page`, params })
|
||||
},
|
||||
|
||||
// 查询车间精简列表
|
||||
getWorkshopSimpleList: async () => {
|
||||
return await request.get({ url: `/mes/md-workshop/simple-list` })
|
||||
},
|
||||
|
||||
// 查询车间详情
|
||||
getWorkshop: async (id: number) => {
|
||||
return await request.get({ url: `/mes/md-workshop/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增车间
|
||||
createWorkshop: async (data: MdWorkshopVO) => {
|
||||
return await request.post({ url: `/mes/md-workshop/create`, data })
|
||||
},
|
||||
|
||||
// 修改车间
|
||||
updateWorkshop: async (data: MdWorkshopVO) => {
|
||||
return await request.put({ url: `/mes/md-workshop/update`, data })
|
||||
},
|
||||
|
||||
// 删除车间
|
||||
deleteWorkshop: async (id: number) => {
|
||||
return await request.delete({ url: `/mes/md-workshop/delete?id=` + id })
|
||||
},
|
||||
|
||||
// 导出车间 Excel
|
||||
exportWorkshop: async (params: any) => {
|
||||
return await request.download({ url: `/mes/md-workshop/export-excel`, params })
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
<template>
|
||||
<!-- TODO @AI:工序字段 -->
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="960px">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<!-- TODO @AI:一行 3 个,和别的模块一样; -->
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<!-- TODO @AI:编号生成 -->
|
||||
<el-form-item label="工位编码" prop="code">
|
||||
<el-input v-model="formData.code" placeholder="请输入工位编码" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="工位名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入工位名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="所在车间" prop="workshopId">
|
||||
<el-select v-model="formData.workshopId" placeholder="请选择车间" class="!w-1/1">
|
||||
<el-option
|
||||
v-for="workshop in workshopList"
|
||||
:key="workshop.id"
|
||||
:label="workshop.name"
|
||||
:value="workshop.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="工位地点" prop="address">
|
||||
<el-input v-model="formData.address" placeholder="请输入工位地点" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="formData.status">
|
||||
<el-radio
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||
:key="dict.value"
|
||||
:value="dict.value"
|
||||
>
|
||||
{{ dict.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="formData.remark" type="textarea" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<!-- 编辑时显示子资源 Tab -->
|
||||
<el-tabs v-if="formType === 'update'" v-model="activeTab" class="mt-10px">
|
||||
<el-tab-pane label="设备资源" name="machine">
|
||||
<WorkstationMachinePanel :workstation-id="formData.id!" />
|
||||
</el-tab-pane>
|
||||
<!-- TODO @AI:工装夹具 -->
|
||||
<el-tab-pane label="工具资源" name="tool">
|
||||
<WorkstationToolPanel :workstation-id="formData.id!" />
|
||||
</el-tab-pane>
|
||||
<!-- TODO @AI:人力资源 -->
|
||||
<el-tab-pane label="人员资源" name="worker">
|
||||
<WorkstationWorkerPanel :workstation-id="formData.id!" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
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 { CommonStatusEnum } from '@/utils/constants'
|
||||
import WorkstationMachinePanel from './components/WorkstationMachinePanel.vue'
|
||||
import WorkstationToolPanel from './components/WorkstationToolPanel.vue'
|
||||
import WorkstationWorkerPanel from './components/WorkstationWorkerPanel.vue'
|
||||
|
||||
defineOptions({ name: 'WorkstationForm' })
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('')
|
||||
const formLoading = ref(false)
|
||||
const formType = ref('')
|
||||
const activeTab = ref('machine')
|
||||
const workshopList = ref<MdWorkshopVO[]>([]) // 车间列表
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
address: undefined,
|
||||
workshopId: undefined,
|
||||
processId: undefined,
|
||||
warehouseId: undefined,
|
||||
locationId: undefined,
|
||||
areaId: undefined,
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
remark: undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
code: [{ required: true, message: '工位编码不能为空', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '工位名称不能为空', trigger: 'blur' }],
|
||||
workshopId: [{ required: true, message: '所在车间不能为空', trigger: 'change' }],
|
||||
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }]
|
||||
})
|
||||
const formRef = ref()
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 加载车间列表
|
||||
workshopList.value = await MdWorkshopApi.getWorkshopSimpleList()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await MdWorkstationApi.getWorkstation(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open })
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success'])
|
||||
const submitForm = async () => {
|
||||
await formRef.value.validate()
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as MdWorkstationVO
|
||||
if (formType.value === 'create') {
|
||||
await MdWorkstationApi.createWorkstation(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await MdWorkstationApi.updateWorkstation(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
address: undefined,
|
||||
workshopId: undefined,
|
||||
processId: undefined,
|
||||
warehouseId: undefined,
|
||||
locationId: undefined,
|
||||
areaId: undefined,
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
remark: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-button type="primary" plain size="small" @click="openAddForm" class="mb-10px">
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 添加设备
|
||||
</el-button>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" border>
|
||||
<el-table-column label="设备编号" align="center" prop="machineryId" />
|
||||
<el-table-column label="设备名称" align="center" prop="machineryName" />
|
||||
<el-table-column label="数量" align="center" prop="quantity" width="100" />
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" width="80">
|
||||
<template #default="scope">
|
||||
<el-button link type="danger" @click="handleDelete(scope.row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 添加设备弹窗 -->
|
||||
<Dialog title="添加设备" v-model="addDialogVisible" width="500px">
|
||||
<el-form ref="addFormRef" :model="addFormData" :rules="addFormRules" label-width="80px">
|
||||
<el-form-item label="设备" prop="machineryId">
|
||||
<!-- TODO @芋艿:对接设备下拉列表,等 DV 设备模块完成后对接 -->
|
||||
<el-input-number v-model="addFormData.machineryId" placeholder="请输入设备编号" class="!w-1/1" />
|
||||
</el-form-item>
|
||||
<el-form-item label="数量" prop="quantity">
|
||||
<el-input-number v-model="addFormData.quantity" :min="1" controls-position="right" class="!w-1/1" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="addFormData.remark" type="textarea" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitAddForm" type="primary">确 定</el-button>
|
||||
<el-button @click="addDialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { MdWorkstationMachineApi, MdWorkstationMachineVO } from '@/api/mes/md/workstation'
|
||||
|
||||
const props = defineProps<{
|
||||
workstationId: number
|
||||
}>()
|
||||
|
||||
const message = useMessage()
|
||||
const loading = ref(false)
|
||||
const list = ref<MdWorkstationMachineVO[]>([])
|
||||
|
||||
/** 加载列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
list.value = await MdWorkstationMachineApi.getWorkstationMachineList(props.workstationId)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 添加弹窗 */
|
||||
const addDialogVisible = ref(false)
|
||||
const addFormRef = ref()
|
||||
const addFormData = ref({
|
||||
workstationId: undefined as number | undefined,
|
||||
machineryId: undefined as number | undefined,
|
||||
quantity: 1,
|
||||
remark: undefined as string | undefined
|
||||
})
|
||||
const addFormRules = reactive({
|
||||
machineryId: [{ required: true, message: '设备不能为空', trigger: 'blur' }],
|
||||
quantity: [{ required: true, message: '数量不能为空', trigger: 'blur' }]
|
||||
})
|
||||
|
||||
const openAddForm = () => {
|
||||
addDialogVisible.value = true
|
||||
addFormData.value = {
|
||||
workstationId: props.workstationId,
|
||||
machineryId: undefined,
|
||||
quantity: 1,
|
||||
remark: undefined
|
||||
}
|
||||
addFormRef.value?.resetFields()
|
||||
}
|
||||
|
||||
const submitAddForm = async () => {
|
||||
await addFormRef.value.validate()
|
||||
await MdWorkstationMachineApi.createWorkstationMachine(addFormData.value as unknown as MdWorkstationMachineVO)
|
||||
message.success('添加成功')
|
||||
addDialogVisible.value = false
|
||||
await getList()
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
await message.delConfirm()
|
||||
await MdWorkstationMachineApi.deleteWorkstationMachine(id)
|
||||
message.success('删除成功')
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 监听 workstationId 变化 */
|
||||
watch(
|
||||
() => props.workstationId,
|
||||
(val) => {
|
||||
if (val) {
|
||||
getList()
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-button type="primary" plain size="small" @click="openAddForm" class="mb-10px">
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 添加工具
|
||||
</el-button>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" border>
|
||||
<el-table-column label="工具类型编号" align="center" prop="toolTypeId" />
|
||||
<el-table-column label="工具类型名称" align="center" prop="toolTypeName" />
|
||||
<el-table-column label="数量" align="center" prop="quantity" width="100" />
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" width="120">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" @click="openEditForm(scope.row)">编辑</el-button>
|
||||
<el-button link type="danger" @click="handleDelete(scope.row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 添加/编辑弹窗 -->
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="500px">
|
||||
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="80px">
|
||||
<el-form-item label="工具类型" prop="toolTypeId">
|
||||
<!-- TODO @芋艿:对接工具类型下拉列表,等 TM 工具模块完成后对接 -->
|
||||
<el-input-number v-model="formData.toolTypeId" placeholder="请输入工具类型编号" class="!w-1/1" :disabled="isEdit" />
|
||||
</el-form-item>
|
||||
<el-form-item label="数量" prop="quantity">
|
||||
<el-input-number v-model="formData.quantity" :min="1" controls-position="right" class="!w-1/1" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="formData.remark" type="textarea" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { MdWorkstationToolApi, MdWorkstationToolVO } from '@/api/mes/md/workstation'
|
||||
|
||||
const props = defineProps<{
|
||||
workstationId: number
|
||||
}>()
|
||||
|
||||
const message = useMessage()
|
||||
const loading = ref(false)
|
||||
const list = ref<MdWorkstationToolVO[]>([])
|
||||
|
||||
/** 加载列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
list.value = await MdWorkstationToolApi.getWorkstationToolList(props.workstationId)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 弹窗 */
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('')
|
||||
const isEdit = ref(false)
|
||||
const formRef = ref()
|
||||
const formData = ref({
|
||||
id: undefined as number | undefined,
|
||||
workstationId: undefined as number | undefined,
|
||||
toolTypeId: undefined as number | undefined,
|
||||
quantity: 1,
|
||||
remark: undefined as string | undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
toolTypeId: [{ required: true, message: '工具类型不能为空', trigger: 'blur' }],
|
||||
quantity: [{ required: true, message: '数量不能为空', trigger: 'blur' }]
|
||||
})
|
||||
|
||||
const openAddForm = () => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = '添加工具'
|
||||
isEdit.value = false
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
workstationId: props.workstationId,
|
||||
toolTypeId: undefined,
|
||||
quantity: 1,
|
||||
remark: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
const openEditForm = (row: MdWorkstationToolVO) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = '编辑工具'
|
||||
isEdit.value = true
|
||||
formData.value = { ...row }
|
||||
}
|
||||
|
||||
const submitForm = async () => {
|
||||
await formRef.value.validate()
|
||||
if (isEdit.value) {
|
||||
await MdWorkstationToolApi.updateWorkstationTool(formData.value as unknown as MdWorkstationToolVO)
|
||||
message.success('编辑成功')
|
||||
} else {
|
||||
await MdWorkstationToolApi.createWorkstationTool(formData.value as unknown as MdWorkstationToolVO)
|
||||
message.success('添加成功')
|
||||
}
|
||||
dialogVisible.value = false
|
||||
await getList()
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
await message.delConfirm()
|
||||
await MdWorkstationToolApi.deleteWorkstationTool(id)
|
||||
message.success('删除成功')
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.workstationId,
|
||||
(val) => {
|
||||
if (val) {
|
||||
getList()
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-button type="primary" plain size="small" @click="openAddForm" class="mb-10px">
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 添加人员
|
||||
</el-button>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" border>
|
||||
<el-table-column label="岗位编号" align="center" prop="postId" />
|
||||
<el-table-column label="岗位名称" align="center" prop="postName" />
|
||||
<el-table-column label="数量" align="center" prop="quantity" width="100" />
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" width="120">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" @click="openEditForm(scope.row)">编辑</el-button>
|
||||
<el-button link type="danger" @click="handleDelete(scope.row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 添加/编辑弹窗 -->
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="500px">
|
||||
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="80px">
|
||||
<el-form-item label="岗位" prop="postId">
|
||||
<el-select v-model="formData.postId" placeholder="请选择岗位" class="!w-1/1" :disabled="isEdit">
|
||||
<el-option
|
||||
v-for="post in postList"
|
||||
:key="post.id"
|
||||
:label="post.name"
|
||||
:value="post.id!"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="数量" prop="quantity">
|
||||
<el-input-number v-model="formData.quantity" :min="1" controls-position="right" class="!w-1/1" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="formData.remark" type="textarea" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { MdWorkstationWorkerApi, MdWorkstationWorkerVO } from '@/api/mes/md/workstation'
|
||||
import * as PostApi from '@/api/system/post'
|
||||
|
||||
const props = defineProps<{
|
||||
workstationId: number
|
||||
}>()
|
||||
|
||||
const message = useMessage()
|
||||
const loading = ref(false)
|
||||
const list = ref<MdWorkstationWorkerVO[]>([])
|
||||
const postList = ref<PostApi.PostVO[]>([]) // 岗位列表
|
||||
|
||||
/** 加载列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
list.value = await MdWorkstationWorkerApi.getWorkstationWorkerList(props.workstationId)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 弹窗 */
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('')
|
||||
const isEdit = ref(false)
|
||||
const formRef = ref()
|
||||
const formData = ref({
|
||||
id: undefined as number | undefined,
|
||||
workstationId: undefined as number | undefined,
|
||||
postId: undefined as number | undefined,
|
||||
quantity: 1,
|
||||
remark: undefined as string | undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
postId: [{ required: true, message: '岗位不能为空', trigger: 'change' }],
|
||||
quantity: [{ required: true, message: '数量不能为空', trigger: 'blur' }]
|
||||
})
|
||||
|
||||
const openAddForm = async () => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = '添加人员'
|
||||
isEdit.value = false
|
||||
// 加载岗位列表
|
||||
postList.value = await PostApi.getSimplePostList()
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
workstationId: props.workstationId,
|
||||
postId: undefined,
|
||||
quantity: 1,
|
||||
remark: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
const openEditForm = async (row: MdWorkstationWorkerVO) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = '编辑人员'
|
||||
isEdit.value = true
|
||||
// 加载岗位列表
|
||||
postList.value = await PostApi.getSimplePostList()
|
||||
formData.value = { ...row }
|
||||
}
|
||||
|
||||
const submitForm = async () => {
|
||||
await formRef.value.validate()
|
||||
if (isEdit.value) {
|
||||
await MdWorkstationWorkerApi.updateWorkstationWorker(formData.value as unknown as MdWorkstationWorkerVO)
|
||||
message.success('编辑成功')
|
||||
} else {
|
||||
await MdWorkstationWorkerApi.createWorkstationWorker(formData.value as unknown as MdWorkstationWorkerVO)
|
||||
message.success('添加成功')
|
||||
}
|
||||
dialogVisible.value = false
|
||||
await getList()
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
await message.delConfirm()
|
||||
await MdWorkstationWorkerApi.deleteWorkstationWorker(id)
|
||||
message.success('删除成功')
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.workstationId,
|
||||
(val) => {
|
||||
if (val) {
|
||||
getList()
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
|
@ -0,0 +1,214 @@
|
|||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="工位编码" prop="code">
|
||||
<el-input
|
||||
v-model="queryParams.code"
|
||||
placeholder="请输入工位编码"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="工位名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
placeholder="请输入工位名称"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="所在车间" prop="workshopId">
|
||||
<el-select v-model="queryParams.workshopId" placeholder="请选择车间" clearable class="!w-240px">
|
||||
<el-option
|
||||
v-for="workshop in workshopList"
|
||||
:key="workshop.id"
|
||||
:label="workshop.name"
|
||||
:value="workshop.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable class="!w-240px">
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
@click="openForm('create')"
|
||||
v-hasPermi="['mes:md-workstation:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['mes:md-workstation:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||
<!-- TODO @AI:应该是“应该是工作站”;然后字段在对齐下; -->
|
||||
<el-table-column label="工位编码" align="center" prop="code" />
|
||||
<el-table-column label="工位名称" align="center" prop="name" width="150" />
|
||||
<el-table-column label="工位地点" align="center" prop="address" />
|
||||
<el-table-column label="所在车间" align="center" prop="workshopName" />
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
:formatter="dateFormatter"
|
||||
width="180px"
|
||||
/>
|
||||
<el-table-column label="操作" align="center" width="150">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
v-hasPermi="['mes:md-workstation:update']"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['mes:md-workstation:delete']"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<WorkstationForm ref="formRef" @success="getList" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import { MdWorkstationApi, MdWorkstationVO } from '@/api/mes/md/workstation'
|
||||
import { MdWorkshopApi, MdWorkshopVO } from '@/api/mes/md/workstation/workshop'
|
||||
import WorkstationForm from './WorkstationForm.vue'
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
|
||||
defineOptions({ name: 'MesMdWorkstation' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<MdWorkstationVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const workshopList = ref<MdWorkshopVO[]>([]) // 车间列表
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
workshopId: undefined,
|
||||
status: undefined
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await MdWorkstationApi.getWorkstationPage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
await message.delConfirm()
|
||||
await MdWorkstationApi.deleteWorkstation(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
await message.exportConfirm()
|
||||
exportLoading.value = true
|
||||
const data = await MdWorkstationApi.exportWorkstation(queryParams)
|
||||
download.excel(data, '工位.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(async () => {
|
||||
await getList()
|
||||
// 加载车间列表
|
||||
workshopList.value = await MdWorkshopApi.getWorkshopSimpleList()
|
||||
})
|
||||
</script>
|
||||
|
|
@ -0,0 +1,159 @@
|
|||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="700px">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="车间编码" prop="code">
|
||||
<el-input v-model="formData.code" placeholder="请输入车间编码" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="车间名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入车间名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="面积" prop="area">
|
||||
<el-input-number v-model="formData.area" :precision="2" :min="0" controls-position="right" class="!w-1/1" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="负责人" prop="chargeUserId">
|
||||
<el-select v-model="formData.chargeUserId" placeholder="请选择负责人" clearable class="!w-1/1">
|
||||
<el-option
|
||||
v-for="user in userList"
|
||||
:key="user.id"
|
||||
:label="user.nickname"
|
||||
:value="user.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="formData.status">
|
||||
<el-radio
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||
:key="dict.value"
|
||||
:value="dict.value"
|
||||
>
|
||||
{{ dict.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="formData.remark" type="textarea" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import { MdWorkshopApi, MdWorkshopVO } from '@/api/mes/md/workstation/workshop'
|
||||
import { CommonStatusEnum } from '@/utils/constants'
|
||||
import * as UserApi from '@/api/system/user'
|
||||
|
||||
defineOptions({ name: 'WorkshopForm' })
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const userList = ref<UserApi.UserVO[]>([]) // 用户列表
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
area: undefined,
|
||||
chargeUserId: undefined,
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
remark: undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
code: [{ required: true, message: '车间编码不能为空', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '车间名称不能为空', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }]
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 加载用户列表
|
||||
userList.value = await UserApi.getSimpleUserList()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await MdWorkshopApi.getWorkshop(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as MdWorkshopVO
|
||||
if (formType.value === 'create') {
|
||||
await MdWorkshopApi.createWorkshop(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await MdWorkshopApi.updateWorkshop(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
area: undefined,
|
||||
chargeUserId: undefined,
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
remark: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
|
|
@ -0,0 +1,205 @@
|
|||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="车间编码" prop="code">
|
||||
<el-input
|
||||
v-model="queryParams.code"
|
||||
placeholder="请输入车间编码"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="车间名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
placeholder="请输入车间名称"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable class="!w-240px">
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
@click="openForm('create')"
|
||||
v-hasPermi="['mes:md-workshop:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<!-- TODO @AI:不用导出 -->
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['mes:md-workshop:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||
<el-table-column label="车间编码" align="center" prop="code" />
|
||||
<el-table-column label="车间名称" align="center" prop="name" width="150" />
|
||||
<el-table-column label="面积" align="center" prop="area" />
|
||||
<el-table-column label="负责人" align="center" prop="chargeUserName" />
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- TODO @AI:不用时间,展示备注 -->
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
:formatter="dateFormatter"
|
||||
width="180px"
|
||||
/>
|
||||
<el-table-column label="操作" align="center" width="150">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
v-hasPermi="['mes:md-workshop:update']"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['mes:md-workshop:delete']"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<WorkshopForm ref="formRef" @success="getList" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import { MdWorkshopApi, MdWorkshopVO } from '@/api/mes/md/workstation/workshop'
|
||||
import WorkshopForm from './WorkshopForm.vue'
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
|
||||
defineOptions({ name: 'MesMdWorkshop' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<MdWorkshopVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
status: undefined
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await MdWorkshopApi.getWorkshopPage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
// 删除的二次确认
|
||||
await message.delConfirm()
|
||||
// 发起删除
|
||||
await MdWorkshopApi.deleteWorkshop(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await MdWorkshopApi.exportWorkshop(queryParams)
|
||||
download.excel(data, '车间.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
Loading…
Reference in New Issue