feat:添加设备关键件页面
parent
e503df9a23
commit
18889cce5b
@ -0,0 +1,33 @@
|
|||||||
|
import request from '@/config/axios'
|
||||||
|
|
||||||
|
export interface CriticalComponentVO {
|
||||||
|
id: number
|
||||||
|
code: string
|
||||||
|
name: string
|
||||||
|
description?: string
|
||||||
|
remark?: string
|
||||||
|
createTime?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const CriticalComponentApi = {
|
||||||
|
getCriticalComponentPage: async (params: any) => {
|
||||||
|
return await request.get({ url: `/mes/critical-component/page`, params })
|
||||||
|
},
|
||||||
|
|
||||||
|
createCriticalComponent: async (data: Partial<CriticalComponentVO>) => {
|
||||||
|
return await request.post({ url: `/mes/critical-component/create`, data })
|
||||||
|
},
|
||||||
|
|
||||||
|
updateCriticalComponent: async (data: Partial<CriticalComponentVO>) => {
|
||||||
|
return await request.put({ url: `/mes/critical-component/update`, data })
|
||||||
|
},
|
||||||
|
|
||||||
|
deleteCriticalComponent: async (ids: string) => {
|
||||||
|
return await request.delete({ url: `/mes/critical-component/delete?ids=` + ids })
|
||||||
|
},
|
||||||
|
|
||||||
|
exportCriticalComponent: async (params: any) => {
|
||||||
|
return await request.download({ url: `/mes/critical-component/export-excel`, params })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,100 @@
|
|||||||
|
<template>
|
||||||
|
<Dialog :title="dialogTitle" v-model="dialogVisible" width="720px">
|
||||||
|
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="90px" v-loading="formLoading">
|
||||||
|
<el-form-item label="编码" prop="code">
|
||||||
|
<el-input v-model="formData.code" placeholder="请输入编码" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="名称" prop="name">
|
||||||
|
<el-input v-model="formData.name" placeholder="请输入名称" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="描述" prop="description">
|
||||||
|
<el-input v-model="formData.description" placeholder="请输入描述" clearable type="textarea" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="formData.remark" placeholder="请输入备注" clearable type="textarea" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="submitForm" :disabled="formLoading">保 存</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { CriticalComponentApi, CriticalComponentVO } from '@/api/mes/criticalComponent'
|
||||||
|
|
||||||
|
defineOptions({ name: 'CriticalComponentForm' })
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
const message = useMessage()
|
||||||
|
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
const dialogTitle = ref('')
|
||||||
|
const formLoading = ref(false)
|
||||||
|
const formType = ref<'create' | 'update'>('create')
|
||||||
|
const formRef = ref()
|
||||||
|
|
||||||
|
const formData = ref<Partial<CriticalComponentVO>>({
|
||||||
|
id: undefined,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
description: undefined,
|
||||||
|
remark: undefined
|
||||||
|
})
|
||||||
|
|
||||||
|
const formRules = reactive({
|
||||||
|
code: [{ required: true, message: '编码不能为空', trigger: 'blur' }],
|
||||||
|
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }]
|
||||||
|
})
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.value = {
|
||||||
|
id: undefined,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
description: undefined,
|
||||||
|
remark: undefined
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields?.()
|
||||||
|
}
|
||||||
|
|
||||||
|
const open = (type: 'create' | 'update', row?: Partial<CriticalComponentVO>) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
dialogTitle.value = t('action.' + type)
|
||||||
|
formType.value = type
|
||||||
|
resetForm()
|
||||||
|
if (type === 'update' && row) {
|
||||||
|
formData.value = {
|
||||||
|
id: row.id,
|
||||||
|
code: row.code,
|
||||||
|
name: row.name,
|
||||||
|
description: row.description,
|
||||||
|
remark: row.remark
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ open })
|
||||||
|
|
||||||
|
const emit = defineEmits(['success'])
|
||||||
|
|
||||||
|
const submitForm = async () => {
|
||||||
|
await formRef.value.validate()
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
if (formType.value === 'create') {
|
||||||
|
await CriticalComponentApi.createCriticalComponent(formData.value)
|
||||||
|
message.success(t('common.createSuccess'))
|
||||||
|
} else {
|
||||||
|
await CriticalComponentApi.updateCriticalComponent(formData.value)
|
||||||
|
message.success(t('common.updateSuccess'))
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
emit('success')
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
@ -0,0 +1,189 @@
|
|||||||
|
<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="description">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.description"
|
||||||
|
placeholder="请输入描述"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="queryParams.remark" placeholder="请输入备注" clearable @keyup.enter="handleQuery" class="!w-240px" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="创建时间" prop="createTime">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="queryParams.createTime"
|
||||||
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
type="daterange"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||||
|
class="!w-220px"
|
||||||
|
/>
|
||||||
|
</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:critical-component:create']">
|
||||||
|
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
@click="handleBatchDelete"
|
||||||
|
:disabled="!selectedIds.length"
|
||||||
|
v-hasPermi="['mes:critical-component:delete']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:delete" class="mr-5px" /> 删除
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
@click="handleExport"
|
||||||
|
:loading="exportLoading"
|
||||||
|
v-hasPermi="['mes:critical-component: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" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" />
|
||||||
|
<el-table-column label="编码" align="center" prop="code" min-width="140" />
|
||||||
|
<el-table-column label="名称" align="center" prop="name" min-width="140" />
|
||||||
|
<el-table-column label="描述" align="center" prop="description" min-width="180" />
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" min-width="180" />
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" :formatter="dateFormatter" width="180" />
|
||||||
|
<el-table-column label="操作" align="center" width="140" fixed="right">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button link type="primary" @click="openForm('update', scope.row)" v-hasPermi="['mes:critical-component:update']">
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button link type="danger" @click="handleDelete(scope.row.id)" v-hasPermi="['mes:critical-component: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>
|
||||||
|
|
||||||
|
<CriticalComponentForm ref="formRef" @success="getList" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
|
import download from '@/utils/download'
|
||||||
|
import { CriticalComponentApi, CriticalComponentVO } from '@/api/mes/criticalComponent'
|
||||||
|
import CriticalComponentForm from './CriticalComponentForm.vue'
|
||||||
|
|
||||||
|
defineOptions({ name: 'CriticalComponent' })
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
const loading = ref(true)
|
||||||
|
const list = ref<CriticalComponentVO[]>([])
|
||||||
|
const total = ref(0)
|
||||||
|
const exportLoading = ref(false)
|
||||||
|
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
code: undefined as string | undefined,
|
||||||
|
name: undefined as string | undefined,
|
||||||
|
description: undefined as string | undefined,
|
||||||
|
remark: undefined as string | undefined,
|
||||||
|
createTime: [] as string[]
|
||||||
|
})
|
||||||
|
|
||||||
|
const queryFormRef = ref()
|
||||||
|
const selectedIds = ref<number[]>([])
|
||||||
|
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const data = await CriticalComponentApi.getCriticalComponentPage(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 handleSelectionChange = (rows: CriticalComponentVO[]) => {
|
||||||
|
selectedIds.value = rows.map((r) => r.id).filter((id): id is number => typeof id === 'number')
|
||||||
|
}
|
||||||
|
|
||||||
|
const formRef = ref()
|
||||||
|
const openForm = (type: 'create' | 'update', row?: Partial<CriticalComponentVO>) => {
|
||||||
|
formRef.value.open(type, row)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDelete = async (id?: number) => {
|
||||||
|
if (!id) return
|
||||||
|
try {
|
||||||
|
await message.delConfirm()
|
||||||
|
await CriticalComponentApi.deleteCriticalComponent(String(id))
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
await getList()
|
||||||
|
} catch {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleBatchDelete = async () => {
|
||||||
|
if (!selectedIds.value.length) return
|
||||||
|
try {
|
||||||
|
await message.delConfirm()
|
||||||
|
await CriticalComponentApi.deleteCriticalComponent(selectedIds.value.join(','))
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
selectedIds.value = []
|
||||||
|
await getList()
|
||||||
|
} catch {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleExport = async () => {
|
||||||
|
try {
|
||||||
|
await message.exportConfirm()
|
||||||
|
exportLoading.value = true
|
||||||
|
const params = {
|
||||||
|
...queryParams,
|
||||||
|
ids: selectedIds.value.length ? selectedIds.value.join(',') : undefined
|
||||||
|
}
|
||||||
|
const data = await CriticalComponentApi.exportCriticalComponent(params)
|
||||||
|
download.excel(data, '设备关键件.xls')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
exportLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
Loading…
Reference in New Issue