feat:添加工艺参数及工艺路线模块
parent
116063a695
commit
e2e7ee87cc
@ -0,0 +1,40 @@
|
|||||||
|
import request from '@/config/axios'
|
||||||
|
|
||||||
|
export interface ProcessParameterVO {
|
||||||
|
id?: number
|
||||||
|
code?: string
|
||||||
|
name?: string
|
||||||
|
isEnable?: boolean | string
|
||||||
|
remark?: string
|
||||||
|
createTime?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ProcessParameterApi = {
|
||||||
|
getProcessParameterPage: async (params: any) => {
|
||||||
|
return await request.get({ url: `/mes/process-parameter/page`, params })
|
||||||
|
},
|
||||||
|
|
||||||
|
getProcessParameterList: async (params?: any) => {
|
||||||
|
return await request.get({ url: `/mes/process-parameter/list`, params })
|
||||||
|
},
|
||||||
|
|
||||||
|
getProcessParameter: async (id: number) => {
|
||||||
|
return await request.get({ url: `/mes/process-parameter/get`, params: { id } })
|
||||||
|
},
|
||||||
|
|
||||||
|
createProcessParameter: async (params: ProcessParameterVO) => {
|
||||||
|
return await request.post({ url: `/mes/process-parameter/create`, data: params })
|
||||||
|
},
|
||||||
|
|
||||||
|
updateProcessParameter: async (params: ProcessParameterVO) => {
|
||||||
|
return await request.put({ url: `/mes/process-parameter/update`, data: params })
|
||||||
|
},
|
||||||
|
|
||||||
|
deleteProcessParameter: async (id: number) => {
|
||||||
|
return await request.delete({ url: `/mes/process-parameter/delete`, params: { id } })
|
||||||
|
},
|
||||||
|
|
||||||
|
exportProcessParameter: async (params: any) => {
|
||||||
|
return await request.download({ url: `/mes/process-parameter/export-excel`, params })
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
import request from '@/config/axios'
|
||||||
|
|
||||||
|
export interface ProcessRouteVO {
|
||||||
|
id?: number | string
|
||||||
|
code?: string
|
||||||
|
name?: string
|
||||||
|
isEnable?: boolean | string
|
||||||
|
remark?: string
|
||||||
|
items?: ProcessRouteItemVO[]
|
||||||
|
createTime?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProcessRouteItemVO {
|
||||||
|
id?: number
|
||||||
|
routeId?: number
|
||||||
|
sort?: number
|
||||||
|
processParameterId?: number
|
||||||
|
processParameterCode?: string
|
||||||
|
processParameterName?: string
|
||||||
|
remark?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ProcessRouteApi = {
|
||||||
|
getProcessRoutePage: async (params: any) => {
|
||||||
|
return await request.get({ url: `/mes/process-route/page`, params })
|
||||||
|
},
|
||||||
|
|
||||||
|
getProcessRouteList: async (params?: any) => {
|
||||||
|
return await request.get({ url: `/mes/process-route/list`, params })
|
||||||
|
},
|
||||||
|
|
||||||
|
getProcessRoute: async (id: number) => {
|
||||||
|
return await request.get({ url: `/mes/process-route/get`, params: { id } })
|
||||||
|
},
|
||||||
|
|
||||||
|
createProcessRoute: async (params: ProcessRouteVO) => {
|
||||||
|
return await request.post({ url: `/mes/process-route/create`, data: params })
|
||||||
|
},
|
||||||
|
|
||||||
|
updateProcessRoute: async (params: ProcessRouteVO) => {
|
||||||
|
return await request.put({ url: `/mes/process-route/update`, data: params })
|
||||||
|
},
|
||||||
|
|
||||||
|
deleteProcessRoute: async (id: number) => {
|
||||||
|
return await request.delete({ url: `/mes/process-route/delete`, params: { id } })
|
||||||
|
},
|
||||||
|
|
||||||
|
exportProcessRoute: async (params: any) => {
|
||||||
|
return await request.download({ url: `/mes/process-route/export-excel`, params })
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
<ProcessParameter />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import ProcessParameter from '../processparameter/index.vue'
|
||||||
|
</script>
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
<ProcessRoute />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import ProcessRoute from '../processroute/index.vue'
|
||||||
|
</script>
|
||||||
@ -0,0 +1,143 @@
|
|||||||
|
<template>
|
||||||
|
<Dialog :title="dialogTitle" v-model="dialogVisible" width="600px">
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
label-width="120px"
|
||||||
|
v-loading="formLoading"
|
||||||
|
>
|
||||||
|
<el-form-item label="编码" prop="code">
|
||||||
|
<div class="flex items-center gap-2 w-full">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.code"
|
||||||
|
placeholder="请输入编码"
|
||||||
|
:disabled="autoCode || formType === 'update'"
|
||||||
|
class="flex-1"
|
||||||
|
/>
|
||||||
|
<el-switch v-model="autoCode" :disabled="formType === 'update'" />
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="工艺参数名称" prop="name">
|
||||||
|
<el-input v-model="formData.name" placeholder="请输入工艺参数名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="是否启用" prop="isEnable">
|
||||||
|
<el-radio-group v-model="formData.isEnable">
|
||||||
|
<el-radio
|
||||||
|
v-for="dict in getStrDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.value"
|
||||||
|
>
|
||||||
|
{{ dict.label }}
|
||||||
|
</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.remark"
|
||||||
|
type="textarea"
|
||||||
|
:rows="3"
|
||||||
|
placeholder="请输入备注"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="submitForm" type="primary" :disabled="formLoading">
|
||||||
|
{{ t('common.ok') }}
|
||||||
|
</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">
|
||||||
|
{{ t('common.cancel') }}
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
|
||||||
|
import { ProcessParameterApi, ProcessParameterVO } from '@/api/mes/processparameter'
|
||||||
|
|
||||||
|
defineOptions({ name: 'ProcessParameterForm' })
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
const message = useMessage()
|
||||||
|
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
const dialogTitle = ref('')
|
||||||
|
const formLoading = ref(false)
|
||||||
|
const formType = ref('')
|
||||||
|
const autoCode = ref(true)
|
||||||
|
const formData = ref<ProcessParameterVO>({
|
||||||
|
id: undefined,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
isEnable: 'true',
|
||||||
|
remark: undefined
|
||||||
|
})
|
||||||
|
const formRef = ref()
|
||||||
|
|
||||||
|
const validateCode = (_: any, __: any, callback: any) => {
|
||||||
|
if (!autoCode.value && !formData.value.code) {
|
||||||
|
callback(new Error('编码不能为空'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
|
||||||
|
const formRules = reactive({
|
||||||
|
name: [{ required: true, message: '工艺参数名称不能为空', trigger: 'blur' }],
|
||||||
|
isEnable: [{ required: true, message: '是否启用不能为空', trigger: 'change' }],
|
||||||
|
code: [{ validator: validateCode, trigger: 'blur' }]
|
||||||
|
})
|
||||||
|
|
||||||
|
const open = async (type: string, id?: number) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
dialogTitle.value = t('action.' + type)
|
||||||
|
formType.value = type
|
||||||
|
resetForm()
|
||||||
|
if (id) {
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
const data = await ProcessParameterApi.getProcessParameter(id)
|
||||||
|
formData.value = {
|
||||||
|
...data,
|
||||||
|
isEnable: data.isEnable === undefined ? 'true' : String(data.isEnable)
|
||||||
|
}
|
||||||
|
autoCode.value = !formData.value.code
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defineExpose({ open })
|
||||||
|
|
||||||
|
const emit = defineEmits(['success'])
|
||||||
|
const submitForm = async () => {
|
||||||
|
await formRef.value.validate()
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
if (formType.value === 'create') {
|
||||||
|
await ProcessParameterApi.createProcessParameter(formData.value)
|
||||||
|
message.success(t('common.createSuccess'))
|
||||||
|
} else {
|
||||||
|
await ProcessParameterApi.updateProcessParameter(formData.value)
|
||||||
|
message.success(t('common.updateSuccess'))
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
emit('success')
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
autoCode.value = true
|
||||||
|
formData.value = {
|
||||||
|
id: undefined,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
isEnable: 'true',
|
||||||
|
remark: undefined
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -0,0 +1,231 @@
|
|||||||
|
<template>
|
||||||
|
<ContentWrap>
|
||||||
|
<el-form
|
||||||
|
class="-mb-15px"
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryFormRef"
|
||||||
|
:inline="true"
|
||||||
|
min-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="isEnable">
|
||||||
|
<el-select v-model="queryParams.isEnable" placeholder="请选择是否启用" clearable class="!w-180px">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getStrDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="创建时间" prop="createTime" v-show="showAllFilters">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="queryParams.createTime"
|
||||||
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
type="daterange"
|
||||||
|
:start-placeholder="t('common.startTimeText')"
|
||||||
|
:end-placeholder="t('common.endTimeText')"
|
||||||
|
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||||
|
class="!w-220px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-if="filterCount > 3">
|
||||||
|
<el-button type="text" class="text-primary" @click="toggleFilters">
|
||||||
|
<Icon :icon="showAllFilters ? 'ep:arrow-up' : 'ep:arrow-down'" class="mr-5px" />
|
||||||
|
{{ showAllFilters ? t('common.shrink') : t('common.expand') }}
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button @click="handleQuery">
|
||||||
|
<Icon icon="ep:search" class="mr-5px" /> {{ t('common.query') }}
|
||||||
|
</el-button>
|
||||||
|
<el-button @click="resetQuery">
|
||||||
|
<Icon icon="ep:refresh" class="mr-5px" /> {{ t('common.reset') }}
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
@click="openForm('create')"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:plus" class="mr-5px" /> {{ t('action.add') }}
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
@click="handleExport"
|
||||||
|
:loading="exportLoading"
|
||||||
|
v-hasPermi="['mes:process-parameter:export']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:download" class="mr-5px" /> {{ t('action.export') }}
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<ContentWrap>
|
||||||
|
<el-table
|
||||||
|
v-loading="loading"
|
||||||
|
:data="list"
|
||||||
|
:stripe="true"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
row-key="id"
|
||||||
|
@selection-change="handleSelectionChange"
|
||||||
|
>
|
||||||
|
<el-table-column type="selection" width="55" reserve-selection />
|
||||||
|
<el-table-column label="工艺参数编码" align="center" prop="code" sortable />
|
||||||
|
<el-table-column label="工艺参数名称" align="center" prop="name" sortable />
|
||||||
|
<el-table-column label="是否启用" align="center" prop="isEnable" width="100">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.isEnable" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" />
|
||||||
|
<el-table-column
|
||||||
|
label="创建时间"
|
||||||
|
align="center"
|
||||||
|
prop="createTime"
|
||||||
|
:formatter="dateFormatter"
|
||||||
|
width="180px"
|
||||||
|
sortable
|
||||||
|
/>
|
||||||
|
<el-table-column label="操作" align="center" min-width="120px">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="openForm('update', scope.row.id)"
|
||||||
|
v-hasPermi="['mes:process-parameter:update']"
|
||||||
|
>
|
||||||
|
{{ t('action.edit') }}
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(scope.row.id)"
|
||||||
|
v-hasPermi="['mes:process-parameter:delete']"
|
||||||
|
>
|
||||||
|
{{ t('action.del') }}
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<Pagination
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNo"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<ProcessParameterForm ref="formRef" @success="getList" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
|
||||||
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
|
import download from '@/utils/download'
|
||||||
|
import { ProcessParameterApi, ProcessParameterVO } from '@/api/mes/processparameter'
|
||||||
|
import ProcessParameterForm from './ProcessParameterForm.vue'
|
||||||
|
|
||||||
|
defineOptions({ name: 'ProcessParameter' })
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
const loading = ref(true)
|
||||||
|
const list = ref<ProcessParameterVO[]>([])
|
||||||
|
const total = ref(0)
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
code: undefined as string | undefined,
|
||||||
|
name: undefined as string | undefined,
|
||||||
|
isEnable: undefined as string | undefined,
|
||||||
|
createTime: [] as string[]
|
||||||
|
})
|
||||||
|
const queryFormRef = ref()
|
||||||
|
const exportLoading = ref(false)
|
||||||
|
const selectedIds = ref<number[]>([])
|
||||||
|
const showAllFilters = ref(false)
|
||||||
|
const filterCount = 4
|
||||||
|
|
||||||
|
const toggleFilters = () => {
|
||||||
|
showAllFilters.value = !showAllFilters.value
|
||||||
|
}
|
||||||
|
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const data = await ProcessParameterApi.getProcessParameterPage(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 ProcessParameterApi.deleteProcessParameter(id)
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSelectionChange = (rows: ProcessParameterVO[]) => {
|
||||||
|
selectedIds.value = rows?.map((row) => row.id).filter((id): id is number => id !== undefined) ?? []
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleExport = async () => {
|
||||||
|
try {
|
||||||
|
await message.exportConfirm()
|
||||||
|
exportLoading.value = true
|
||||||
|
const params = {
|
||||||
|
...queryParams,
|
||||||
|
ids: selectedIds.value.length ? selectedIds.value.join(',') : undefined
|
||||||
|
}
|
||||||
|
const data = await ProcessParameterApi.exportProcessParameter(params)
|
||||||
|
download.excel(data, '工艺参数.xls')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
exportLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@ -0,0 +1,261 @@
|
|||||||
|
<template>
|
||||||
|
<Dialog :title="dialogTitle" v-model="dialogVisible" width="900px">
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
label-width="120px"
|
||||||
|
v-loading="formLoading"
|
||||||
|
>
|
||||||
|
<el-form-item label="编码" prop="code">
|
||||||
|
<div class="flex items-center gap-2 w-full">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.code"
|
||||||
|
placeholder="请输入编码"
|
||||||
|
:disabled="autoCode || formType === 'update'"
|
||||||
|
class="flex-1"
|
||||||
|
/>
|
||||||
|
<el-switch v-model="autoCode" :disabled="formType === 'update'" />
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="工艺路线名称" prop="name">
|
||||||
|
<el-input v-model="formData.name" placeholder="请输入工艺路线名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="是否启用" prop="isEnable">
|
||||||
|
<el-radio-group v-model="formData.isEnable">
|
||||||
|
<el-radio
|
||||||
|
v-for="dict in getStrDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.value"
|
||||||
|
>
|
||||||
|
{{ dict.label }}
|
||||||
|
</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.remark"
|
||||||
|
type="textarea"
|
||||||
|
:rows="3"
|
||||||
|
placeholder="请输入备注"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="工艺参数明细" prop="items">
|
||||||
|
<div class="process-route-items">
|
||||||
|
<el-table :data="formData.items" border size="small" row-key="id">
|
||||||
|
<el-table-column label="工艺参数" min-width="260" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<div class="flex items-center gap-1">
|
||||||
|
<el-select
|
||||||
|
v-model="scope.row.processParameterId"
|
||||||
|
filterable
|
||||||
|
placeholder="请选择工艺参数"
|
||||||
|
class="flex-1"
|
||||||
|
clearable
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in parameterOptions"
|
||||||
|
:key="item.id"
|
||||||
|
:label="`${item.name}: ${item.code}`"
|
||||||
|
:value="item.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
<el-button
|
||||||
|
v-if="formData.items && formData.items.length > 1"
|
||||||
|
circle
|
||||||
|
size="small"
|
||||||
|
type="danger"
|
||||||
|
@click="removeItem(scope.$index)"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:minus" />
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="scope.$index === (formData.items?.length || 1) - 1"
|
||||||
|
circle
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
@click="addItem"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:plus" />
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="submitForm" type="primary" :disabled="formLoading">
|
||||||
|
{{ t('common.ok') }}
|
||||||
|
</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">
|
||||||
|
{{ t('common.cancel') }}
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
|
||||||
|
import { ProcessRouteApi, ProcessRouteItemVO, ProcessRouteVO } from '@/api/mes/processroute'
|
||||||
|
import { ProcessParameterApi, ProcessParameterVO } from '@/api/mes/processparameter'
|
||||||
|
|
||||||
|
defineOptions({ name: 'ProcessRouteForm' })
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
const message = useMessage()
|
||||||
|
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
const dialogTitle = ref('')
|
||||||
|
const formLoading = ref(false)
|
||||||
|
const formType = ref('')
|
||||||
|
const autoCode = ref(true)
|
||||||
|
const parameterOptions = ref<ProcessParameterVO[]>([])
|
||||||
|
const formData = ref<ProcessRouteVO>({
|
||||||
|
id: undefined,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
isEnable: 'true',
|
||||||
|
remark: undefined,
|
||||||
|
items: []
|
||||||
|
})
|
||||||
|
const formRef = ref()
|
||||||
|
|
||||||
|
const validateCode = (_: any, __: any, callback: any) => {
|
||||||
|
if (!autoCode.value && !formData.value.code) {
|
||||||
|
callback(new Error('编码不能为空'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
|
||||||
|
const formRules = reactive({
|
||||||
|
name: [{ required: true, message: '工艺路线名称不能为空', trigger: 'blur' }],
|
||||||
|
isEnable: [{ required: true, message: '是否启用不能为空', trigger: 'change' }],
|
||||||
|
code: [{ validator: validateCode, trigger: 'blur' }],
|
||||||
|
items: [{ validator: (_: any, __: any, callback: any) => validateItems(callback), trigger: 'change' }]
|
||||||
|
})
|
||||||
|
|
||||||
|
const loadParameterList = async () => {
|
||||||
|
try {
|
||||||
|
parameterOptions.value = await ProcessParameterApi.getProcessParameterList()
|
||||||
|
} catch {
|
||||||
|
parameterOptions.value = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const open = async (type: string, id?: number) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
dialogTitle.value = t('action.' + type)
|
||||||
|
formType.value = type
|
||||||
|
resetForm()
|
||||||
|
loadParameterList()
|
||||||
|
if (id) {
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
const data = await ProcessRouteApi.getProcessRoute(id)
|
||||||
|
formData.value = {
|
||||||
|
...data,
|
||||||
|
isEnable: data.isEnable === undefined ? 'true' : String(data.isEnable),
|
||||||
|
items: normalizeItems(data.items)
|
||||||
|
}
|
||||||
|
autoCode.value = !formData.value.code
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 新增时默认添加一行空数据
|
||||||
|
addItem()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defineExpose({ open })
|
||||||
|
|
||||||
|
const emit = defineEmits(['success'])
|
||||||
|
const submitForm = async () => {
|
||||||
|
await formRef.value.validate()
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
const data = {
|
||||||
|
id: formData.value.id,
|
||||||
|
code: formData.value.code,
|
||||||
|
name: formData.value.name,
|
||||||
|
isEnable: formData.value.isEnable,
|
||||||
|
remark: formData.value.remark,
|
||||||
|
items: formData.value.items?.map((item, index) => ({
|
||||||
|
sort: item.sort || index + 1,
|
||||||
|
processParameterId: item.processParameterId,
|
||||||
|
remark: item.remark
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
if (formType.value === 'create') {
|
||||||
|
await ProcessRouteApi.createProcessRoute(data)
|
||||||
|
message.success(t('common.createSuccess'))
|
||||||
|
} else {
|
||||||
|
await ProcessRouteApi.updateProcessRoute(data)
|
||||||
|
message.success(t('common.updateSuccess'))
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
emit('success')
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
autoCode.value = true
|
||||||
|
formData.value = {
|
||||||
|
id: undefined,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
isEnable: 'true',
|
||||||
|
remark: undefined,
|
||||||
|
items: []
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
|
||||||
|
const addItem = () => {
|
||||||
|
const nextSort = (formData.value.items?.length || 0) + 1
|
||||||
|
formData.value.items = [
|
||||||
|
...(formData.value.items || []),
|
||||||
|
{
|
||||||
|
sort: nextSort,
|
||||||
|
processParameterId: undefined,
|
||||||
|
remark: undefined
|
||||||
|
}
|
||||||
|
]
|
||||||
|
formRef.value?.clearValidate?.('items')
|
||||||
|
}
|
||||||
|
|
||||||
|
const removeItem = (index: number) => {
|
||||||
|
formData.value.items?.splice(index, 1)
|
||||||
|
formRef.value?.clearValidate?.('items')
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalizeItems = (items?: ProcessRouteItemVO[]) => {
|
||||||
|
if (!Array.isArray(items)) return []
|
||||||
|
return items.map((item, index) => ({
|
||||||
|
id: item.id,
|
||||||
|
sort: item.sort || index + 1,
|
||||||
|
processParameterId: item.processParameterId,
|
||||||
|
remark: item.remark
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
const validateItems = (callback: any) => {
|
||||||
|
const items = formData.value.items || []
|
||||||
|
const invalidItem = items.find((item) => !item.processParameterId)
|
||||||
|
if (invalidItem) {
|
||||||
|
callback(new Error('请完善工艺参数明细'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.process-route-items {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -0,0 +1,231 @@
|
|||||||
|
<template>
|
||||||
|
<ContentWrap>
|
||||||
|
<el-form
|
||||||
|
class="-mb-15px"
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryFormRef"
|
||||||
|
:inline="true"
|
||||||
|
min-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="isEnable">
|
||||||
|
<el-select v-model="queryParams.isEnable" placeholder="请选择是否启用" clearable class="!w-180px">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getStrDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="创建时间" prop="createTime" v-show="showAllFilters">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="queryParams.createTime"
|
||||||
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
type="daterange"
|
||||||
|
:start-placeholder="t('common.startTimeText')"
|
||||||
|
:end-placeholder="t('common.endTimeText')"
|
||||||
|
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||||
|
class="!w-220px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-if="filterCount > 3">
|
||||||
|
<el-button type="text" class="text-primary" @click="toggleFilters">
|
||||||
|
<Icon :icon="showAllFilters ? 'ep:arrow-up' : 'ep:arrow-down'" class="mr-5px" />
|
||||||
|
{{ showAllFilters ? t('common.shrink') : t('common.expand') }}
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button @click="handleQuery">
|
||||||
|
<Icon icon="ep:search" class="mr-5px" /> {{ t('common.query') }}
|
||||||
|
</el-button>
|
||||||
|
<el-button @click="resetQuery">
|
||||||
|
<Icon icon="ep:refresh" class="mr-5px" /> {{ t('common.reset') }}
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
@click="openForm('create')"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:plus" class="mr-5px" /> {{ t('action.add') }}
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
@click="handleExport"
|
||||||
|
:loading="exportLoading"
|
||||||
|
v-hasPermi="['mes:process-route:export']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:download" class="mr-5px" /> {{ t('action.export') }}
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<ContentWrap>
|
||||||
|
<el-table
|
||||||
|
v-loading="loading"
|
||||||
|
:data="list"
|
||||||
|
:stripe="true"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
row-key="id"
|
||||||
|
@selection-change="handleSelectionChange"
|
||||||
|
>
|
||||||
|
<el-table-column type="selection" width="55" reserve-selection />
|
||||||
|
<el-table-column label="工艺路线编码" align="center" prop="code" sortable />
|
||||||
|
<el-table-column label="工艺路线名称" align="center" prop="name" sortable />
|
||||||
|
<el-table-column label="是否启用" align="center" prop="isEnable" width="100">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.isEnable" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" />
|
||||||
|
<el-table-column
|
||||||
|
label="创建时间"
|
||||||
|
align="center"
|
||||||
|
prop="createTime"
|
||||||
|
:formatter="dateFormatter"
|
||||||
|
width="180px"
|
||||||
|
sortable
|
||||||
|
/>
|
||||||
|
<el-table-column label="操作" align="center" min-width="120px">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="openForm('update', scope.row.id)"
|
||||||
|
v-hasPermi="['mes:process-route:update']"
|
||||||
|
>
|
||||||
|
{{ t('action.edit') }}
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(scope.row.id)"
|
||||||
|
v-hasPermi="['mes:process-route:delete']"
|
||||||
|
>
|
||||||
|
{{ t('action.del') }}
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<Pagination
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNo"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<ProcessRouteForm ref="formRef" @success="getList" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
|
||||||
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
|
import download from '@/utils/download'
|
||||||
|
import { ProcessRouteApi, ProcessRouteVO } from '@/api/mes/processroute'
|
||||||
|
import ProcessRouteForm from './ProcessRouteForm.vue'
|
||||||
|
|
||||||
|
defineOptions({ name: 'ProcessRoute' })
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
const loading = ref(true)
|
||||||
|
const list = ref<ProcessRouteVO[]>([])
|
||||||
|
const total = ref(0)
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
isEnable: undefined,
|
||||||
|
createTime: []
|
||||||
|
})
|
||||||
|
const queryFormRef = ref()
|
||||||
|
const exportLoading = ref(false)
|
||||||
|
const selectedIds = ref<number[]>([])
|
||||||
|
const showAllFilters = ref(false)
|
||||||
|
const filterCount = 4
|
||||||
|
|
||||||
|
const toggleFilters = () => {
|
||||||
|
showAllFilters.value = !showAllFilters.value
|
||||||
|
}
|
||||||
|
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const data = await ProcessRouteApi.getProcessRoutePage(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 ProcessRouteApi.deleteProcessRoute(id)
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSelectionChange = (rows: ProcessRouteVO[]) => {
|
||||||
|
selectedIds.value = rows?.map((row) => row.id).filter((id): id is number => id !== undefined) ?? []
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleExport = async () => {
|
||||||
|
try {
|
||||||
|
await message.exportConfirm()
|
||||||
|
exportLoading.value = true
|
||||||
|
const params = {
|
||||||
|
...queryParams,
|
||||||
|
ids: selectedIds.value.length ? selectedIds.value.join(',') : undefined
|
||||||
|
}
|
||||||
|
const data = await ProcessRouteApi.exportProcessRoute(params)
|
||||||
|
download.excel(data, '工艺路线.xls')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
exportLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue