ljlong_2630
6 months ago
10 changed files with 882 additions and 47 deletions
@ -0,0 +1,57 @@ |
|||
import request from '@/config/axios' |
|||
|
|||
export interface InspectionItemVO { |
|||
id: number |
|||
content: string |
|||
equipmentParts: string |
|||
serialNumber: number |
|||
category: string |
|||
departmentCode: string |
|||
remark: string |
|||
siteId: string |
|||
available: string |
|||
deletionTime: Date |
|||
deleterId: byte[] |
|||
concurrencyStamp: number |
|||
} |
|||
|
|||
// 查询巡检项列表
|
|||
export const getInspectionItemPage = async (params) => { |
|||
if (params.isSearch) { |
|||
delete params.isSearch |
|||
const data = {...params} |
|||
return await request.post({ url: '/eam/basic/inspection-item/senior', data }) |
|||
} else { |
|||
return await request.get({ url: `/eam/basic/inspection-item/page`, params }) |
|||
} |
|||
} |
|||
|
|||
// 查询巡检项详情
|
|||
export const getInspectionItem = async (id: number) => { |
|||
return await request.get({ url: `/eam/basic/inspection-item/get?id=` + id }) |
|||
} |
|||
|
|||
// 新增巡检项
|
|||
export const createInspectionItem = async (data: InspectionItemVO) => { |
|||
return await request.post({ url: `/eam/basic/inspection-item/create`, data }) |
|||
} |
|||
|
|||
// 修改巡检项
|
|||
export const updateInspectionItem = async (data: InspectionItemVO) => { |
|||
return await request.put({ url: `/eam/basic/inspection-item/update`, data }) |
|||
} |
|||
|
|||
// 删除巡检项
|
|||
export const deleteInspectionItem = async (id: number) => { |
|||
return await request.delete({ url: `/eam/basic/inspection-item/delete?id=` + id }) |
|||
} |
|||
|
|||
// 导出巡检项 Excel
|
|||
export const exportInspectionItem = async (params) => { |
|||
return await request.download({ url: `/eam/basic/inspection-item/export-excel`, params }) |
|||
} |
|||
|
|||
// 下载用户导入模板
|
|||
export const importTemplate = () => { |
|||
return request.download({ url: '/eam/basic/inspection-item/get-import-template' }) |
|||
} |
@ -0,0 +1,56 @@ |
|||
import request from '@/config/axios' |
|||
|
|||
export interface SpotCheckItemVO { |
|||
id: number |
|||
content: string |
|||
equipmentParts: string |
|||
serialNumber: number |
|||
departmentCode: string |
|||
remark: string |
|||
siteId: string |
|||
available: string |
|||
deletionTime: Date |
|||
deleterId: byte[] |
|||
concurrencyStamp: number |
|||
} |
|||
|
|||
// 查询点检项列表
|
|||
export const getSpotCheckItemPage = async (params) => { |
|||
if (params.isSearch) { |
|||
delete params.isSearch |
|||
const data = {...params} |
|||
return await request.post({ url: '/eam/basic/spot-check-item/senior', data }) |
|||
} else { |
|||
return await request.get({ url: `/eam/basic/spot-check-item/page`, params }) |
|||
} |
|||
} |
|||
|
|||
// 查询点检项详情
|
|||
export const getSpotCheckItem = async (id: number) => { |
|||
return await request.get({ url: `/eam/basic/spot-check-item/get?id=` + id }) |
|||
} |
|||
|
|||
// 新增点检项
|
|||
export const createSpotCheckItem = async (data: SpotCheckItemVO) => { |
|||
return await request.post({ url: `/eam/basic/spot-check-item/create`, data }) |
|||
} |
|||
|
|||
// 修改点检项
|
|||
export const updateSpotCheckItem = async (data: SpotCheckItemVO) => { |
|||
return await request.put({ url: `/eam/basic/spot-check-item/update`, data }) |
|||
} |
|||
|
|||
// 删除点检项
|
|||
export const deleteSpotCheckItem = async (id: number) => { |
|||
return await request.delete({ url: `/eam/basic/spot-check-item/delete?id=` + id }) |
|||
} |
|||
|
|||
// 导出点检项 Excel
|
|||
export const exportSpotCheckItem = async (params) => { |
|||
return await request.download({ url: `/eam/basic/spot-check-item/export-excel`, params }) |
|||
} |
|||
|
|||
// 下载用户导入模板
|
|||
export const importTemplate = () => { |
|||
return request.download({ url: '/eam/basic/spot-check-item/get-import-template' }) |
|||
} |
@ -0,0 +1,272 @@ |
|||
<template> |
|||
<ContentWrap> |
|||
<!-- 搜索工作栏 --> |
|||
<Search :schema="InspectionItem.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> |
|||
</ContentWrap> |
|||
|
|||
<!-- 列表头部 --> |
|||
<TableHead |
|||
:HeadButttondata="HeadButttondata" |
|||
@button-base-click="buttonBaseClick" |
|||
:routeName="routeName" |
|||
@updataTableColumns="updataTableColumns" |
|||
@searchFormClick="searchFormClick" |
|||
:allSchemas="InspectionItem.allSchemas" |
|||
/> |
|||
|
|||
<!-- 列表 --> |
|||
<ContentWrap> |
|||
<Table |
|||
:columns="tableColumns" |
|||
:data="tableObject.tableList" |
|||
:loading="tableObject.loading" |
|||
:pagination="{ |
|||
total: tableObject.total |
|||
}" |
|||
v-model:pageSize="tableObject.pageSize" |
|||
v-model:currentPage="tableObject.currentPage" |
|||
v-model:sort="tableObject.sort" |
|||
> |
|||
<template #code="{row}"> |
|||
<el-button type="primary" link @click="openDetail(row, '代码', row.code)"> |
|||
<span>{{ row.code }}</span> |
|||
</el-button> |
|||
</template> |
|||
<template #action="{ row }"> |
|||
<ButtonBase :Butttondata="butttondata(row)" @button-base-click="buttonTableClick($event,row)" /> |
|||
</template> |
|||
</Table> |
|||
</ContentWrap> |
|||
|
|||
<!-- 表单弹窗:添加/修改 --> |
|||
<BasicForm |
|||
ref="basicFormRef" |
|||
@success="formsSuccess" |
|||
:rules="InspectionItemRules" |
|||
:formAllSchemas="InspectionItem.allSchemas" |
|||
:apiUpdate="InspectionItemApi.updateInspectionItem" |
|||
:apiCreate="InspectionItemApi.createInspectionItem" |
|||
@searchTableSuccess="searchTableSuccess" |
|||
:isBusiness="false" |
|||
/> |
|||
|
|||
<!-- 详情 --> |
|||
<Detail ref="detailRef" :isBasic="true" :allSchemas="InspectionItem.allSchemas" /> |
|||
|
|||
<!-- 导入 --> |
|||
<ImportForm ref="importFormRef" url="/eam/basic/inspection-item/import" :importTemplateData="importTemplateData" @success="importSuccess" /> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import download from '@/utils/download' |
|||
import { InspectionItem,InspectionItemRules } from './inspectionItem.data' |
|||
import * as InspectionItemApi from '@/api/eam/inspectionItem' |
|||
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|||
import TableHead from '@/components/TableHead/src/TableHead.vue' |
|||
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' |
|||
import Detail from '@/components/Detail/src/Detail.vue' |
|||
|
|||
defineOptions({ name: 'InspectionItem' }) |
|||
|
|||
const message = useMessage() // 消息弹窗 |
|||
const { t } = useI18n() // 国际化 |
|||
|
|||
const route = useRoute() // 路由信息 |
|||
const routeName = ref() |
|||
routeName.value = route.name |
|||
const tableColumns = ref(InspectionItem.allSchemas.tableColumns) |
|||
|
|||
// 查询页面返回 |
|||
const searchTableSuccess = (formField, searchField, val, formRef) => { |
|||
nextTick(() => { |
|||
const setV = {} |
|||
setV[formField] = val[0][searchField] |
|||
formRef.setValues(setV) |
|||
}) |
|||
} |
|||
|
|||
// 字段设置 更新主列表字段 |
|||
const updataTableColumns = (val) => { |
|||
tableColumns.value = val |
|||
} |
|||
|
|||
const judgeStatus = (row) =>{ |
|||
if(row.available === 'TRUE'){ |
|||
return true |
|||
}else{ |
|||
return false |
|||
} |
|||
} |
|||
|
|||
const { tableObject, tableMethods } = useTable({ |
|||
getListApi: InspectionItemApi.getInspectionItemPage // 分页接口 |
|||
}) |
|||
|
|||
// 获得表格的各种操作 |
|||
const { getList, setSearchParams } = tableMethods |
|||
|
|||
// 列表头部按钮 |
|||
const HeadButttondata = [ |
|||
defaultButtons.defaultAddBtn({hasPermi:'eam:inspection-item:create'}), // 新增 |
|||
defaultButtons.defaultImportBtn({hasPermi:'eam:inspection-item:import'}), // 导入 |
|||
defaultButtons.defaultExportBtn({hasPermi:'eam:inspection-item:export'}), // 导出 |
|||
defaultButtons.defaultFreshBtn(null), // 刷新 |
|||
defaultButtons.defaultFilterBtn(null), // 筛选 |
|||
defaultButtons.defaultSetBtn(null), // 设置 |
|||
// { |
|||
// label: '自定义扩展按钮', |
|||
// name: 'zdy', |
|||
// hide: false, |
|||
// type: 'primary', |
|||
// icon: 'Select', |
|||
// color: '' |
|||
// }, |
|||
] |
|||
|
|||
// 头部按钮事件 |
|||
const buttonBaseClick = (val, item) => { |
|||
if (val == 'add') { // 新增 |
|||
openForm('create') |
|||
} else if (val == 'import') { // 导入 |
|||
handleImport() |
|||
} else if (val == 'export') { // 导出 |
|||
handleExport() |
|||
} else if (val == 'refresh') { // 刷新 |
|||
getList() |
|||
} else if (val == 'filtrate') { // 筛选 |
|||
} else { // 其他按钮 |
|||
console.log('其他按钮', item) |
|||
} |
|||
} |
|||
|
|||
|
|||
// 列表-操作按钮 |
|||
const butttondata = (row) => { |
|||
return [ |
|||
defaultButtons.mainListEditBtn({hasPermi:'eam:inspection-item:update'}), // 编辑 |
|||
defaultButtons.mainListEnableBtn({hasPermi:'eam:inspection-item:enable',hide: judgeStatus(row)}), // 启用 |
|||
defaultButtons.mainListDisableBtn({hasPermi:'eam:inspection-item:disable',hide: !judgeStatus(row)}), // 禁用 |
|||
// defaultButtons.mainListDeleteBtn({hasPermi:'eam:inspection-item:delete'}), // 删除 |
|||
] |
|||
} |
|||
|
|||
// 列表-操作按钮事件 |
|||
const buttonTableClick = async (val, row) => { |
|||
if (val == 'edit') { // 编辑 |
|||
openForm('update', row) |
|||
} else if (val == 'delete') { // 删除 |
|||
handleDelete(row.id) |
|||
} else if (val == 'enable') { // 启用 |
|||
handleEnable(row,'TRUE') |
|||
}else if (val == 'disable') {// 禁用 |
|||
handleEnable(row,'FALSE') |
|||
} |
|||
} |
|||
|
|||
/** 添加/修改操作 */ |
|||
const basicFormRef = ref() |
|||
const openForm = (type: string, row?: any) => { |
|||
basicFormRef.value.open(type, row) |
|||
} |
|||
|
|||
// form表单提交 |
|||
const formsSuccess = async (formType,data) => { |
|||
var isHave =InspectionItem.allSchemas.formSchema.some(function (item) { |
|||
return item.field === 'activeTime' || item.field === 'expireTime'; |
|||
}); |
|||
if(isHave){ |
|||
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){ |
|||
message.error('失效时间要大于生效时间') |
|||
return; |
|||
} |
|||
} |
|||
if(data.activeTime==0)data.activeTime = null; |
|||
if(data.expireTime==0)data.expireTime = null; |
|||
if (formType === 'create') { |
|||
await InspectionItemApi.createInspectionItem(data) |
|||
message.success(t('common.createSuccess')) |
|||
} else { |
|||
await InspectionItemApi.updateInspectionItem(data) |
|||
message.success(t('common.updateSuccess')) |
|||
} |
|||
basicFormRef.value.dialogVisible = false |
|||
getList() |
|||
} |
|||
|
|||
/** 详情操作 */ |
|||
const detailRef = ref() |
|||
const openDetail = (row: any, titleName: any, titleValue: any) => { |
|||
detailRef.value.openDetail(row, titleName, titleValue, 'basicInspectionItem') |
|||
} |
|||
|
|||
/** 删除按钮操作 */ |
|||
const handleDelete = async (id: number) => { |
|||
try { |
|||
// 删除的二次确认 |
|||
await message.delConfirm() |
|||
// 发起删除 |
|||
await InspectionItemApi.deleteInspectionItem(id) |
|||
message.success(t('common.delSuccess')) |
|||
// 刷新列表 |
|||
await getList() |
|||
} catch {} |
|||
} |
|||
|
|||
/** 导出按钮操作 */ |
|||
const exportLoading = ref(false) // 导出的加载中 |
|||
const handleExport = async () => { |
|||
try { |
|||
// 导出的二次确认 |
|||
await message.exportConfirm() |
|||
// 发起导出 |
|||
exportLoading.value = true |
|||
const data = await InspectionItemApi.exportInspectionItem(tableObject.params) |
|||
download.excel(data, '巡检项.xlsx') |
|||
} catch { |
|||
} finally { |
|||
exportLoading.value = false |
|||
} |
|||
} |
|||
|
|||
/** 导入 */ |
|||
const importFormRef = ref() |
|||
const handleImport = () => { |
|||
importFormRef.value.open() |
|||
} |
|||
// 导入附件弹窗所需的参数 |
|||
const importTemplateData = reactive({ |
|||
templateUrl: '', |
|||
templateTitle: '巡检项导入模版.xlsx' |
|||
}) |
|||
// 导入成功之后 |
|||
const importSuccess = () => { |
|||
getList() |
|||
} |
|||
|
|||
// 筛选提交 |
|||
const searchFormClick = (searchData) => { |
|||
tableObject.params = { |
|||
isSearch: true, |
|||
filters: searchData.filters |
|||
} |
|||
getList() // 刷新当前列表 |
|||
} |
|||
|
|||
const handleEnable = (row,enable) =>{ |
|||
row.available = enable |
|||
InspectionItemApi.updateInspectionItem(row).then(res => { |
|||
message.success(t('common.updateSuccess')) |
|||
getList() |
|||
}) |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
/** 初始化 **/ |
|||
onMounted(async () => { |
|||
getList() |
|||
importTemplateData.templateUrl = await InspectionItemApi.importTemplate() |
|||
}) |
|||
|
|||
</script> |
@ -0,0 +1,110 @@ |
|||
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' |
|||
import { dateFormatter } from '@/utils/formatTime' |
|||
import { handleTreeToComponentOptions } from '@/utils/tree' |
|||
import * as DeptApi from '@/api/system/dept' |
|||
const deptList = ref<Tree[]>([]) // 树形结构
|
|||
|
|||
// 加载部门树(默认格式)
|
|||
deptList.value = handleTreeToComponentOptions(await DeptApi.getSimpleDeptList()) |
|||
|
|||
// 表单校验
|
|||
export const InspectionItemRules = reactive({ |
|||
content: [required], |
|||
serialNumber: [required], |
|||
concurrencyStamp: [required], |
|||
type: [required], |
|||
}) |
|||
|
|||
export const InspectionItem = useCrudSchemas(reactive<CrudSchema[]>([ |
|||
|
|||
{ |
|||
label: '巡检内容', |
|||
field: 'content', |
|||
sort: 'custom', |
|||
isSearch: true, |
|||
form: { |
|||
component: 'Input', |
|||
componentProps: { |
|||
type: 'textarea' |
|||
} |
|||
} |
|||
}, |
|||
{ |
|||
label: '保养部位', |
|||
field: 'equipmentParts', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '类别', |
|||
field: 'category', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '序号', |
|||
field: 'serialNumber', |
|||
sort: 'custom', |
|||
isSearch: true, |
|||
fixed: 'left', |
|||
form: { |
|||
component:'InputNumber' |
|||
}, |
|||
}, |
|||
{ |
|||
label: '来源于类型配置', |
|||
field: 'type', |
|||
sort: 'custom', |
|||
dictType: DICT_TYPE.DEVICE_TYPE, |
|||
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
|||
isSearch: true, |
|||
form: { |
|||
component: 'Select' |
|||
} |
|||
}, |
|||
{ |
|||
label: '部门', |
|||
field: 'departmentCode', |
|||
sort: 'custom', |
|||
isTable: false, |
|||
isDetail: false, |
|||
isSearch: false, |
|||
isTableForm: false, |
|||
form: { |
|||
component: 'TreeSelect', |
|||
componentProps: { // 假设deptList是部门数据列表
|
|||
data: deptList, |
|||
placeholder: "请选择部门", |
|||
filterable: true, |
|||
// multiple: true,
|
|||
} |
|||
} |
|||
}, |
|||
{ |
|||
label: '是否启用', |
|||
field: 'available', |
|||
sort: 'custom', |
|||
dictType: DICT_TYPE.TRUE_FALSE, |
|||
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
|||
isTable: true, |
|||
isDetail: false, |
|||
isSearch: false, |
|||
isTableForm: false, |
|||
isForm: false, |
|||
}, |
|||
{ |
|||
label: '备注', |
|||
field: 'remark', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '操作', |
|||
field: 'action', |
|||
isForm: false, |
|||
table: { |
|||
width: 150, |
|||
fixed: 'right' |
|||
} |
|||
} |
|||
])) |
@ -0,0 +1,268 @@ |
|||
<template> |
|||
<ContentWrap> |
|||
<!-- 搜索工作栏 --> |
|||
<Search :schema="SpotCheckItem.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> |
|||
</ContentWrap> |
|||
|
|||
<!-- 列表头部 --> |
|||
<TableHead |
|||
:HeadButttondata="HeadButttondata" |
|||
@button-base-click="buttonBaseClick" |
|||
:routeName="routeName" |
|||
@updataTableColumns="updataTableColumns" |
|||
@searchFormClick="searchFormClick" |
|||
:allSchemas="SpotCheckItem.allSchemas" |
|||
/> |
|||
|
|||
<!-- 列表 --> |
|||
<ContentWrap> |
|||
<Table |
|||
:columns="tableColumns" |
|||
:data="tableObject.tableList" |
|||
:loading="tableObject.loading" |
|||
:pagination="{ |
|||
total: tableObject.total |
|||
}" |
|||
v-model:pageSize="tableObject.pageSize" |
|||
v-model:currentPage="tableObject.currentPage" |
|||
v-model:sort="tableObject.sort" |
|||
> |
|||
<template #code="{row}"> |
|||
<el-button type="primary" link @click="openDetail(row, '代码', row.code)"> |
|||
<span>{{ row.code }}</span> |
|||
</el-button> |
|||
</template> |
|||
<template #action="{ row }"> |
|||
<ButtonBase :Butttondata="butttondata(row)" @button-base-click="buttonTableClick($event,row)" /> |
|||
</template> |
|||
</Table> |
|||
</ContentWrap> |
|||
|
|||
<!-- 表单弹窗:添加/修改 --> |
|||
<BasicForm |
|||
ref="basicFormRef" |
|||
@success="formsSuccess" |
|||
:rules="SpotCheckItemRules" |
|||
:formAllSchemas="SpotCheckItem.allSchemas" |
|||
:apiUpdate="SpotCheckItemApi.updateSpotCheckItem" |
|||
:apiCreate="SpotCheckItemApi.createSpotCheckItem" |
|||
@searchTableSuccess="searchTableSuccess" |
|||
:isBusiness="false" |
|||
/> |
|||
|
|||
<!-- 详情 --> |
|||
<Detail ref="detailRef" :isBasic="true" :allSchemas="SpotCheckItem.allSchemas" /> |
|||
|
|||
<!-- 导入 --> |
|||
<ImportForm ref="importFormRef" url="/eam/basic/spot-check-item/import" :importTemplateData="importTemplateData" @success="importSuccess" /> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import download from '@/utils/download' |
|||
import { SpotCheckItem,SpotCheckItemRules } from './spotCheckItem.data' |
|||
import * as SpotCheckItemApi from '@/api/eam/spotCheckItem' |
|||
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|||
import TableHead from '@/components/TableHead/src/TableHead.vue' |
|||
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' |
|||
import Detail from '@/components/Detail/src/Detail.vue' |
|||
|
|||
defineOptions({ name: 'SpotCheckItem' }) |
|||
|
|||
const message = useMessage() // 消息弹窗 |
|||
const { t } = useI18n() // 国际化 |
|||
|
|||
const route = useRoute() // 路由信息 |
|||
const routeName = ref() |
|||
routeName.value = route.name |
|||
const tableColumns = ref(SpotCheckItem.allSchemas.tableColumns) |
|||
|
|||
// 查询页面返回 |
|||
const searchTableSuccess = (formField, searchField, val, formRef) => { |
|||
nextTick(() => { |
|||
const setV = {} |
|||
setV[formField] = val[0][searchField] |
|||
formRef.setValues(setV) |
|||
}) |
|||
} |
|||
|
|||
// 字段设置 更新主列表字段 |
|||
const updataTableColumns = (val) => { |
|||
tableColumns.value = val |
|||
} |
|||
|
|||
const judgeStatus = (row) =>{ |
|||
if(row.available === 'TRUE'){ |
|||
return true |
|||
}else{ |
|||
return false |
|||
} |
|||
} |
|||
|
|||
const { tableObject, tableMethods } = useTable({ |
|||
getListApi: SpotCheckItemApi.getSpotCheckItemPage // 分页接口 |
|||
}) |
|||
|
|||
// 获得表格的各种操作 |
|||
const { getList, setSearchParams } = tableMethods |
|||
|
|||
// 列表头部按钮 |
|||
const HeadButttondata = [ |
|||
defaultButtons.defaultAddBtn({hasPermi:'eam:spot-check-item:create'}), // 新增 |
|||
defaultButtons.defaultImportBtn({hasPermi:'eam:spot-check-item:import'}), // 导入 |
|||
defaultButtons.defaultExportBtn({hasPermi:'eam:spot-check-item:export'}), // 导出 |
|||
defaultButtons.defaultFreshBtn(null), // 刷新 |
|||
defaultButtons.defaultFilterBtn(null), // 筛选 |
|||
defaultButtons.defaultSetBtn(null), // 设置 |
|||
// { |
|||
// label: '自定义扩展按钮', |
|||
// name: 'zdy', |
|||
// hide: false, |
|||
// type: 'primary', |
|||
// icon: 'Select', |
|||
// color: '' |
|||
// }, |
|||
] |
|||
|
|||
// 头部按钮事件 |
|||
const buttonBaseClick = (val, item) => { |
|||
if (val == 'add') { // 新增 |
|||
openForm('create') |
|||
} else if (val == 'import') { // 导入 |
|||
handleImport() |
|||
} else if (val == 'export') { // 导出 |
|||
handleExport() |
|||
} else if (val == 'refresh') { // 刷新 |
|||
getList() |
|||
} else if (val == 'filtrate') { // 筛选 |
|||
} else { // 其他按钮 |
|||
console.log('其他按钮', item) |
|||
} |
|||
} |
|||
|
|||
// 列表-操作按钮 |
|||
const butttondata = (row) => { |
|||
return [ |
|||
defaultButtons.mainListEditBtn({hasPermi:'eam:spot-check-item:update'}), // 编辑 |
|||
defaultButtons.mainListEnableBtn({hasPermi:'eam:spot-check-item:enable',hide: judgeStatus(row)}), // 启用 |
|||
defaultButtons.mainListDisableBtn({hasPermi:'eam:spot-check-item:disable',hide: !judgeStatus(row)}), // 禁用 |
|||
// defaultButtons.mainListDeleteBtn({hasPermi:'eam:spot-check-item:delete'}), // 删除 |
|||
]} |
|||
|
|||
// 列表-操作按钮事件 |
|||
const buttonTableClick = async (val, row) => { |
|||
if (val == 'edit') { // 编辑 |
|||
openForm('update', row) |
|||
} else if (val == 'delete') { // 删除 |
|||
handleDelete(row.id) |
|||
} else if (val == 'enable') { // 启用 |
|||
handleEnable(row,'TRUE') |
|||
}else if (val == 'disable') {// 禁用 |
|||
handleEnable(row,'FALSE') |
|||
} |
|||
} |
|||
|
|||
/** 添加/修改操作 */ |
|||
const basicFormRef = ref() |
|||
const openForm = (type: string, row?: any) => { |
|||
basicFormRef.value.open(type, row) |
|||
} |
|||
|
|||
// form表单提交 |
|||
const formsSuccess = async (formType,data) => { |
|||
var isHave =SpotCheckItem.allSchemas.formSchema.some(function (item) { |
|||
return item.field === 'activeTime' || item.field === 'expireTime'; |
|||
}); |
|||
if(isHave){ |
|||
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){ |
|||
message.error('失效时间要大于生效时间') |
|||
return; |
|||
} |
|||
} |
|||
if(data.activeTime==0)data.activeTime = null; |
|||
if(data.expireTime==0)data.expireTime = null; |
|||
if (formType === 'create') { |
|||
await SpotCheckItemApi.createSpotCheckItem(data) |
|||
message.success(t('common.createSuccess')) |
|||
} else { |
|||
await SpotCheckItemApi.updateSpotCheckItem(data) |
|||
message.success(t('common.updateSuccess')) |
|||
} |
|||
basicFormRef.value.dialogVisible = false |
|||
getList() |
|||
} |
|||
|
|||
/** 详情操作 */ |
|||
const detailRef = ref() |
|||
const openDetail = (row: any, titleName: any, titleValue: any) => { |
|||
detailRef.value.openDetail(row, titleName, titleValue, 'basicSpotCheckItem') |
|||
} |
|||
|
|||
/** 删除按钮操作 */ |
|||
const handleDelete = async (id: number) => { |
|||
try { |
|||
// 删除的二次确认 |
|||
await message.delConfirm() |
|||
// 发起删除 |
|||
await SpotCheckItemApi.deleteSpotCheckItem(id) |
|||
message.success(t('common.delSuccess')) |
|||
// 刷新列表 |
|||
await getList() |
|||
} catch {} |
|||
} |
|||
|
|||
/** 导出按钮操作 */ |
|||
const exportLoading = ref(false) // 导出的加载中 |
|||
const handleExport = async () => { |
|||
try { |
|||
// 导出的二次确认 |
|||
await message.exportConfirm() |
|||
// 发起导出 |
|||
exportLoading.value = true |
|||
const data = await SpotCheckItemApi.exportSpotCheckItem(tableObject.params) |
|||
download.excel(data, '点检项.xlsx') |
|||
} catch { |
|||
} finally { |
|||
exportLoading.value = false |
|||
} |
|||
} |
|||
|
|||
/** 导入 */ |
|||
const importFormRef = ref() |
|||
const handleImport = () => { |
|||
importFormRef.value.open() |
|||
} |
|||
// 导入附件弹窗所需的参数 |
|||
const importTemplateData = reactive({ |
|||
templateUrl: '', |
|||
templateTitle: '点检项导入模版.xlsx' |
|||
}) |
|||
// 导入成功之后 |
|||
const importSuccess = () => { |
|||
getList() |
|||
} |
|||
|
|||
// 筛选提交 |
|||
const searchFormClick = (searchData) => { |
|||
tableObject.params = { |
|||
isSearch: true, |
|||
filters: searchData.filters |
|||
} |
|||
getList() // 刷新当前列表 |
|||
} |
|||
|
|||
|
|||
const handleEnable = (row,enable) =>{ |
|||
row.available = enable |
|||
SpotCheckItemApi.updateSpotCheckItem(row).then(res => { |
|||
message.success(t('common.updateSuccess')) |
|||
getList() |
|||
}) |
|||
} |
|||
|
|||
/** 初始化 **/ |
|||
onMounted(async () => { |
|||
getList() |
|||
importTemplateData.templateUrl = await SpotCheckItemApi.importTemplate() |
|||
}) |
|||
|
|||
</script> |
@ -0,0 +1,104 @@ |
|||
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' |
|||
import { dateFormatter } from '@/utils/formatTime' |
|||
import { handleTreeToComponentOptions } from '@/utils/tree' |
|||
import * as DeptApi from '@/api/system/dept' |
|||
const deptList = ref<Tree[]>([]) // 树形结构
|
|||
|
|||
// 加载部门树(默认格式)
|
|||
deptList.value = handleTreeToComponentOptions(await DeptApi.getSimpleDeptList()) |
|||
|
|||
// 表单校验
|
|||
export const SpotCheckItemRules = reactive({ |
|||
content: [required], |
|||
serialNumber: [required], |
|||
concurrencyStamp: [required], |
|||
type: [required], |
|||
}) |
|||
|
|||
export const SpotCheckItem = useCrudSchemas(reactive<CrudSchema[]>([ |
|||
|
|||
{ |
|||
label: '点检内容', |
|||
field: 'content', |
|||
sort: 'custom', |
|||
isSearch: true, |
|||
form: { |
|||
component: 'Input', |
|||
componentProps: { |
|||
type: 'textarea' |
|||
} |
|||
} |
|||
}, |
|||
{ |
|||
label: '点检部位', |
|||
field: 'equipmentParts', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '序号', |
|||
field: 'serialNumber', |
|||
sort: 'custom', |
|||
isSearch: true, |
|||
fixed: 'left', |
|||
form: { |
|||
component:'InputNumber' |
|||
}, |
|||
}, |
|||
{ |
|||
label: '来源于类型配置', |
|||
field: 'type', |
|||
sort: 'custom', |
|||
dictType: DICT_TYPE.DEVICE_TYPE, |
|||
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
|||
isSearch: true, |
|||
form: { |
|||
component: 'Select' |
|||
} |
|||
}, |
|||
{ |
|||
label: '部门', |
|||
field: 'departmentCode', |
|||
sort: 'custom', |
|||
isTable: false, |
|||
isDetail: false, |
|||
isSearch: false, |
|||
isTableForm: false, |
|||
form: { |
|||
component: 'TreeSelect', |
|||
componentProps: { // 假设deptList是部门数据列表
|
|||
data: deptList, |
|||
placeholder: "请选择部门", |
|||
filterable: true, |
|||
// multiple: true,
|
|||
} |
|||
} |
|||
}, |
|||
{ |
|||
label: '是否启用', |
|||
field: 'available', |
|||
sort: 'custom', |
|||
dictType: DICT_TYPE.TRUE_FALSE, |
|||
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
|||
isTable: true, |
|||
isDetail: false, |
|||
isSearch: false, |
|||
isTableForm: false, |
|||
isForm: false, |
|||
}, |
|||
{ |
|||
label: '备注', |
|||
field: 'remark', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '操作', |
|||
field: 'action', |
|||
isForm: false, |
|||
table: { |
|||
width: 150, |
|||
fixed: 'right' |
|||
} |
|||
} |
|||
])) |
Loading…
Reference in new issue