gaojs
5 months ago
9 changed files with 989 additions and 9 deletions
@ -0,0 +1,63 @@ |
|||||
|
import request from '@/config/axios' |
||||
|
|
||||
|
export interface BasicSpotCheckOptionVO { |
||||
|
id: number |
||||
|
code: string |
||||
|
name: string |
||||
|
selectId: number |
||||
|
describing: string |
||||
|
isUpdated: boolean |
||||
|
departmentCode: string |
||||
|
remark: string |
||||
|
siteId: string |
||||
|
available: string |
||||
|
deletionTime: Date |
||||
|
deleterId: byte[] |
||||
|
concurrencyStamp: number |
||||
|
} |
||||
|
|
||||
|
// 查询点检方案列表
|
||||
|
export const getBasicSpotCheckOptionPage = async (params) => { |
||||
|
if (params.isSearch) { |
||||
|
delete params.isSearch |
||||
|
const data = {...params} |
||||
|
return await request.post({ url: '/eam/basic-spotCheck-option/senior', data }) |
||||
|
} else { |
||||
|
return await request.get({ url: `/eam/basic-spotCheck-option/page`, params }) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 查询点检方案详情
|
||||
|
export const getBasicSpotCheckOption = async (id: number) => { |
||||
|
return await request.get({ url: `/eam/basic-spotCheck-option/get?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 新增点检方案
|
||||
|
export const createBasicSpotCheckOption = async (data: BasicSpotCheckOptionVO) => { |
||||
|
return await request.post({ url: `/eam/basic-spotCheck-option/create`, data }) |
||||
|
} |
||||
|
|
||||
|
// 修改点检方案
|
||||
|
export const updateBasicSpotCheckOption = async (data: BasicSpotCheckOptionVO) => { |
||||
|
return await request.put({ url: `/eam/basic-spotCheck-option/update`, data }) |
||||
|
} |
||||
|
|
||||
|
// 删除点检方案
|
||||
|
export const deleteBasicSpotCheckOption = async (id: number) => { |
||||
|
return await request.delete({ url: `/eam/basic-spotCheck-option/delete?id=` + id }) |
||||
|
} |
||||
|
|
||||
|
// 导出点检方案 Excel
|
||||
|
export const exportBasicSpotCheckOption = async (params) => { |
||||
|
return await request.download({ url: `/eam/basic-spotCheck-option/export-excel`, params }) |
||||
|
} |
||||
|
|
||||
|
// 下载用户导入模板
|
||||
|
export const importTemplate = () => { |
||||
|
return request.download({ url: '/eam/basic-spotCheck-option/get-import-template' }) |
||||
|
} |
||||
|
|
||||
|
// 启用 / 禁用
|
||||
|
export const updateEnableCode = async (data: BasicSpotCheckOptionVO) => { |
||||
|
return await request.post({ url: `/eam/basic-spotCheck-option/ables` , data }) |
||||
|
} |
@ -0,0 +1,201 @@ |
|||||
|
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' |
||||
|
import { dateFormatter } from '@/utils/formatTime' |
||||
|
import * as ItemApi from "@/api/eam/spotCheckSelectSet"; |
||||
|
import {BasicSpotCheckSelectSet} from "@/views/eam/spotCheckSelectSet/spotCheckSelectSet.data"; |
||||
|
import {getBasicSpotCheckSelectSetPage} from "@/api/eam/spotCheckSelectSet"; |
||||
|
|
||||
|
// 表单校验
|
||||
|
export const BasicSpotCheckOptionRules = reactive({ |
||||
|
code: [required], |
||||
|
selectId: [required], |
||||
|
}) |
||||
|
|
||||
|
export const BasicSpotCheckOption = useCrudSchemas(reactive<CrudSchema[]>([ |
||||
|
{ |
||||
|
label: 'id', |
||||
|
field: 'id', |
||||
|
sort: 'custom', |
||||
|
isSearch: false, |
||||
|
isTable: false, |
||||
|
isForm: false, |
||||
|
isDetail:false, |
||||
|
}, |
||||
|
{ |
||||
|
label: '编号', |
||||
|
field: 'code', |
||||
|
sort: 'custom', |
||||
|
isSearch: true, |
||||
|
}, |
||||
|
{ |
||||
|
label: '方案名称', |
||||
|
field: 'name', |
||||
|
sort: 'custom', |
||||
|
isSearch: true, |
||||
|
}, |
||||
|
{ |
||||
|
label: '选择集ID', |
||||
|
field: 'selectId', |
||||
|
sort: 'custom', |
||||
|
isDetail: true, |
||||
|
form: { |
||||
|
componentProps: { |
||||
|
isSearchList: true, // 开启查询弹窗
|
||||
|
searchTitle: '点检选择集信息', // 查询弹窗标题
|
||||
|
searchAllSchemas: BasicSpotCheckSelectSet.allSchemas, // 查询弹窗所需类
|
||||
|
searchField: 'id', // 查询弹窗赋值字段
|
||||
|
searchPage: ItemApi.getBasicSpotCheckSelectSetPage, // 查询弹窗所需分页方法
|
||||
|
multiple:true, |
||||
|
searchCondition: [{ |
||||
|
key: 'available', |
||||
|
value: 'TRUE', |
||||
|
action: '==', |
||||
|
isSearch: true, |
||||
|
isMainValue: false |
||||
|
}] |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
label: '描述', |
||||
|
field: 'describing', |
||||
|
sort: 'custom', |
||||
|
isSearch: true, |
||||
|
}, |
||||
|
{ |
||||
|
label: '项是否可修改', |
||||
|
field: 'isUpdated', |
||||
|
sort: 'custom', |
||||
|
dictType: DICT_TYPE.IS_UPDATED, |
||||
|
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
||||
|
isTable: true, |
||||
|
isDetail: false, |
||||
|
isSearch: true, |
||||
|
isTableForm: false, |
||||
|
isForm: true, |
||||
|
form: { |
||||
|
component: 'Switch', |
||||
|
value: 'TRUE', |
||||
|
componentProps: { |
||||
|
inactiveValue: 'FALSE', |
||||
|
activeValue: 'TRUE' |
||||
|
} |
||||
|
}, |
||||
|
}, |
||||
|
// {
|
||||
|
// label: '保养项',
|
||||
|
// field: 'type',
|
||||
|
// sort: 'custom',
|
||||
|
// isSearch: true,
|
||||
|
// },
|
||||
|
{ |
||||
|
label: '创建时间', |
||||
|
field: 'createTime', |
||||
|
sort: 'custom', |
||||
|
formatter: dateFormatter, |
||||
|
isSearch: false, |
||||
|
isTable: false, |
||||
|
isForm: false, |
||||
|
isDetail:false, |
||||
|
search: { |
||||
|
component: 'DatePicker', |
||||
|
componentProps: { |
||||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss', |
||||
|
type: 'daterange', |
||||
|
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] |
||||
|
} |
||||
|
}, |
||||
|
isForm: false, |
||||
|
}, |
||||
|
{ |
||||
|
label: '部门id', |
||||
|
field: 'departmentCode', |
||||
|
sort: 'custom', |
||||
|
isSearch: false, |
||||
|
isTable: false, |
||||
|
isForm: false, |
||||
|
isDetail:false, |
||||
|
}, |
||||
|
{ |
||||
|
label: '备注', |
||||
|
field: 'remark', |
||||
|
sort: 'custom', |
||||
|
isSearch: true, |
||||
|
}, |
||||
|
{ |
||||
|
label: '地点ID', |
||||
|
field: 'siteId', |
||||
|
sort: 'custom', |
||||
|
isSearch: false, |
||||
|
isTable: false, |
||||
|
isForm: false, |
||||
|
isDetail:false, |
||||
|
}, |
||||
|
{ |
||||
|
label: '是否可用', |
||||
|
field: 'available', |
||||
|
sort: 'custom', |
||||
|
dictType: DICT_TYPE.TRUE_FALSE, |
||||
|
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
||||
|
isTable: true, |
||||
|
isDetail: false, |
||||
|
isSearch: false, |
||||
|
isTableForm: false, |
||||
|
isForm: false, |
||||
|
}, |
||||
|
{ |
||||
|
label: '删除时间', |
||||
|
field: 'deletionTime', |
||||
|
sort: 'custom', |
||||
|
formatter: dateFormatter, |
||||
|
isSearch: false, |
||||
|
isTable: false, |
||||
|
isForm: false, |
||||
|
isDetail:false, |
||||
|
search: { |
||||
|
component: 'DatePicker', |
||||
|
componentProps: { |
||||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss', |
||||
|
type: 'daterange', |
||||
|
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] |
||||
|
} |
||||
|
}, |
||||
|
form: { |
||||
|
component: 'DatePicker', |
||||
|
componentProps: { |
||||
|
type: 'datetime', |
||||
|
valueFormat: 'x' |
||||
|
} |
||||
|
}, |
||||
|
}, |
||||
|
{ |
||||
|
label: '删除人id', |
||||
|
field: 'deleterId', |
||||
|
sort: 'custom', |
||||
|
isSearch: false, |
||||
|
isTable: false, |
||||
|
isForm: false, |
||||
|
isDetail:false, |
||||
|
}, |
||||
|
{ |
||||
|
label: '并发乐观锁', |
||||
|
field: 'concurrencyStamp', |
||||
|
sort: 'custom', |
||||
|
isSearch: false, |
||||
|
isTable: false, |
||||
|
isForm: false, |
||||
|
isDetail:false, |
||||
|
form: { |
||||
|
component: 'InputNumber', |
||||
|
value: 0 |
||||
|
}, |
||||
|
}, |
||||
|
{ |
||||
|
label: '操作', |
||||
|
field: 'action', |
||||
|
isForm: false, |
||||
|
table: { |
||||
|
width: 150, |
||||
|
fixed: 'right' |
||||
|
} |
||||
|
} |
||||
|
])) |
@ -0,0 +1,300 @@ |
|||||
|
<template> |
||||
|
<ContentWrap> |
||||
|
<!-- 搜索工作栏 --> |
||||
|
<Search :schema="BasicSpotCheckOption.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> |
||||
|
</ContentWrap> |
||||
|
|
||||
|
<!-- 列表头部 --> |
||||
|
<TableHead |
||||
|
:HeadButttondata="HeadButttondata" |
||||
|
@button-base-click="buttonBaseClick" |
||||
|
:routeName="routeName" |
||||
|
@updataTableColumns="updataTableColumns" |
||||
|
@searchFormClick="searchFormClick" |
||||
|
:allSchemas="BasicSpotCheckOption.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="BasicSpotCheckOptionRules"--> |
||||
|
<!-- :formAllSchemas="BasicSpotCheckOption.allSchemas"--> |
||||
|
<!-- :apiUpdate="BasicSpotCheckOptionApi.updateBasicSpotCheckOption"--> |
||||
|
<!-- :apiCreate="BasicSpotCheckOptionApi.createBasicSpotCheckOption"--> |
||||
|
<!-- @searchTableSuccess="searchTableSuccess"--> |
||||
|
<!-- :isBusiness="false"--> |
||||
|
<!-- />--> |
||||
|
<ItemForm ref="basicFormRef" @success="getData"/> |
||||
|
|
||||
|
<!-- 详情 --> |
||||
|
<Detail ref="detailRef" :isBasic="true" :allSchemas="BasicSpotCheckOption.allSchemas" /> |
||||
|
|
||||
|
<!-- 导入 --> |
||||
|
<ImportForm ref="importFormRef" url="/eam/basic-spot-check-option/import" :importTemplateData="importTemplateData" @success="importSuccess" /> |
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"> |
||||
|
import download from '@/utils/download' |
||||
|
import { BasicSpotCheckOption,BasicSpotCheckOptionRules } from './basicSpotCheckOption.data' |
||||
|
import * as BasicSpotCheckOptionApi from '@/api/eam/basicSpotCheckOption' |
||||
|
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' |
||||
|
import ItemForm from "@/views/eam/basicSpotCheckOption/itemSelectSetForm.vue"; |
||||
|
|
||||
|
defineOptions({ name: 'BasicSpotCheckOption' }) |
||||
|
|
||||
|
const message = useMessage() // 消息弹窗 |
||||
|
const { t } = useI18n() // 国际化 |
||||
|
|
||||
|
const route = useRoute() // 路由信息 |
||||
|
const routeName = ref() |
||||
|
routeName.value = route.name |
||||
|
const tableColumns = ref(BasicSpotCheckOption.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 { tableObject, tableMethods } = useTable({ |
||||
|
getListApi: BasicSpotCheckOptionApi.getBasicSpotCheckOptionPage // 分页接口 |
||||
|
}) |
||||
|
|
||||
|
// 获得表格的各种操作 |
||||
|
const { getList, setSearchParams } = tableMethods |
||||
|
|
||||
|
// 列表头部按钮 |
||||
|
const HeadButttondata = [ |
||||
|
defaultButtons.defaultAddBtn({hasPermi:'eam:basicSpotCheckOption:create'}), // 新增 |
||||
|
defaultButtons.defaultImportBtn({hasPermi:'eam:basicSpotCheckOption:import'}), // 导入 |
||||
|
defaultButtons.defaultExportBtn({hasPermi:'eam:basicSpotCheckOption: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 isShowMainButton = (row,val) => { |
||||
|
if (val.indexOf(row.available) > -1) { |
||||
|
return false |
||||
|
} else { |
||||
|
return true |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 列表-操作按钮 |
||||
|
const butttondata = (row) => { |
||||
|
return [ |
||||
|
defaultButtons.mainListEditBtn({hasPermi:'eam:basicSpotCheckOption:update'}), // 编辑 |
||||
|
//defaultButtons.mainListDeleteBtn({hasPermi:'eam:basicSpotCheckOption:delete'}), // 删除 |
||||
|
defaultButtons.mainListEnableBtn({hide:isShowMainButton(row,['FALSE']),hasPermi:'eam:basicSpotCheckOption:update'}), |
||||
|
defaultButtons.mainListDisableBtn({hide:isShowMainButton(row,['TRUE']),hasPermi:'eam:basicSpotCheckOption:update'}), |
||||
|
] |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
// 列表-操作按钮事件 |
||||
|
const buttonTableClick = async (val, row) => { |
||||
|
if (val == 'edit') { // 编辑 |
||||
|
openForm('update', row) |
||||
|
} else if (val == 'delete') { // 删除 |
||||
|
handleDelete(row.id) |
||||
|
} else if (val == 'enable') { |
||||
|
handleEnable(row.id) |
||||
|
}else if (val == 'disable') { |
||||
|
handleDisable(row.id) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 添加/修改操作 */ |
||||
|
const basicFormRef = ref() |
||||
|
const openForm = (type: string, row?: any) => { |
||||
|
basicFormRef.value.open(type, row) |
||||
|
} |
||||
|
|
||||
|
// form表单提交 |
||||
|
const formsSuccess = async (formType,data) => { |
||||
|
var isHave =BasicSpotCheckOption.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 BasicSpotCheckOptionApi.createBasicSpotCheckOption(data) |
||||
|
message.success(t('common.createSuccess')) |
||||
|
} else { |
||||
|
await BasicSpotCheckOptionApi.updateBasicSpotCheckOption(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, 'basicBasicSpotCheckOption') |
||||
|
} |
||||
|
|
||||
|
/** 删除按钮操作 */ |
||||
|
const handleDelete = async (id: number) => { |
||||
|
try { |
||||
|
// 删除的二次确认 |
||||
|
await message.delConfirm() |
||||
|
// 发起删除 |
||||
|
await BasicSpotCheckOptionApi.deleteBasicSpotCheckOption(id) |
||||
|
message.success(t('common.delSuccess')) |
||||
|
// 刷新列表 |
||||
|
await getList() |
||||
|
} catch {} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** 启用 */ |
||||
|
const handleEnable = async (id: number) => { |
||||
|
try { |
||||
|
const params = ref({ |
||||
|
id: '', |
||||
|
available:'', |
||||
|
}) |
||||
|
params.value.id = id |
||||
|
params.value.available = 'TRUE' |
||||
|
await BasicSpotCheckOptionApi.updateEnableCode(params.value) |
||||
|
message.success(t('common.updateSuccess')) |
||||
|
// 刷新列表 |
||||
|
await getList() |
||||
|
} catch {} |
||||
|
} |
||||
|
/** 禁用 */ |
||||
|
const handleDisable = async (id: number) => { |
||||
|
try { |
||||
|
const params = ref({ |
||||
|
id: '', |
||||
|
available:'', |
||||
|
}) |
||||
|
params.value.id = id |
||||
|
params.value.available = 'FALSE' |
||||
|
await BasicSpotCheckOptionApi.updateEnableCode(params.value) |
||||
|
message.success(t('common.updateSuccess')) |
||||
|
// 刷新列表 |
||||
|
await getList() |
||||
|
} catch {} |
||||
|
} |
||||
|
|
||||
|
//刷新页面 |
||||
|
const getData = async() => { |
||||
|
getList(); |
||||
|
} |
||||
|
|
||||
|
/** 导出按钮操作 */ |
||||
|
const exportLoading = ref(false) // 导出的加载中 |
||||
|
const handleExport = async () => { |
||||
|
try { |
||||
|
// 导出的二次确认 |
||||
|
await message.exportConfirm() |
||||
|
// 发起导出 |
||||
|
exportLoading.value = true |
||||
|
const data = await BasicSpotCheckOptionApi.exportBasicSpotCheckOption(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() // 刷新当前列表 |
||||
|
} |
||||
|
|
||||
|
/** 初始化 **/ |
||||
|
onMounted(async () => { |
||||
|
getList() |
||||
|
}) |
||||
|
|
||||
|
</script> |
@ -0,0 +1,387 @@ |
|||||
|
<template> |
||||
|
<Dialog v-model="dialogVisible" :title="dialogTitle"> |
||||
|
<el-form |
||||
|
ref="basicFormRef" |
||||
|
v-loading="formLoading" |
||||
|
:model="formData" |
||||
|
:rules="formRules" |
||||
|
label-width="100px" |
||||
|
> |
||||
|
<el-row> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="方案编号" prop="code"> |
||||
|
<el-input v-model="formData.code" placeholder="方案编号" :disabled="isDisabled"/> |
||||
|
</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="isUpdated"> |
||||
|
<el-select v-model="formData.isUpdated" style="width: 200px"> |
||||
|
<el-option label="是" value="TRUE"></el-option> |
||||
|
<el-option label="否" value="FALSE"></el-option> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="描述" prop="describing"> |
||||
|
<el-input v-model="formData.describing" placeholder="请输入描述" /> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
<el-row> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="是否可用" prop="available"> |
||||
|
<el-select v-model="formData.available" style="width: 200px"> |
||||
|
<el-option label="是" value="TRUE"></el-option> |
||||
|
<el-option label="否" value="FALSE"></el-option> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
<el-col :span="12"> |
||||
|
<el-form-item label="备注" prop="remark"> |
||||
|
<el-input v-model="formData.remark" placeholder="请输入备注" /> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
<el-row> |
||||
|
<el-col :span="11"> |
||||
|
<el-form-item label="选择集ID" prop="selectId"> |
||||
|
<div class="tag-container flex gap-2"> |
||||
|
<el-tag v-for="ent in tags" :key="ent.selectId" closable :disable-transitions="false" @close="handleClose(ent.selectId)"> |
||||
|
{{ ent.selectId}} |
||||
|
</el-tag> |
||||
|
<el-input v-if="inputVisible" ref="InputRef" v-model="inputValue" class="w-20" size="small"/> |
||||
|
<el-button v-else class="button-new-tag" size="small" @click="addItem"> |
||||
|
添加点检选择集 |
||||
|
</el-button> |
||||
|
</div> |
||||
|
</el-form-item> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
</el-form> |
||||
|
<el-table :data="spotCheckItemData" style="width: 100%; height: 80%"> |
||||
|
<el-table-column prop="itemCode" label="点检项ID" /> |
||||
|
<el-table-column prop="itemName" label="点检名称" /> |
||||
|
<el-table-column prop="isSelectd" label="" width="150" > |
||||
|
<template #header> |
||||
|
<span>是否必选(默认是)</span> |
||||
|
</template> |
||||
|
<template #default="scope"> |
||||
|
<el-switch |
||||
|
v-model="scope.row.isSelectd" |
||||
|
active-color="#13ce66" |
||||
|
inactive-color="#ff4949" |
||||
|
active-text="是" |
||||
|
inactive-text="否" |
||||
|
/> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
</el-table> |
||||
|
<template #footer> |
||||
|
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button> |
||||
|
<el-button @click="dialogVisible = false">取 消</el-button> |
||||
|
</template> |
||||
|
</Dialog> |
||||
|
|
||||
|
<!--添加巡检项弹窗--> |
||||
|
<SearchTable ref="searchTableRef" @searchTableSuccess="searchTableSuccess" /> |
||||
|
|
||||
|
</template> |
||||
|
<script lang="ts" setup> |
||||
|
import request from "@/config/axios"; |
||||
|
import { SearchTable } from '@/components/SearchTable' |
||||
|
import { BasicSpotCheckSelectSet} from "@/views/eam/spotCheckSelectSet/spotCheckSelectSet.data"; |
||||
|
import * as SpotCheckSelectSetApi from "@/api/eam/spotCheckSelectSet"; |
||||
|
import * as BasicSpotCheckOptionApi from "@/api/eam/basicSpotCheckOption"; |
||||
|
import {ElInput} from "element-plus"; |
||||
|
|
||||
|
|
||||
|
defineOptions({ name: 'TeamForm' }) |
||||
|
|
||||
|
const { t } = useI18n() // 国际化 |
||||
|
const message = useMessage() // 消息弹窗 |
||||
|
|
||||
|
const dialogVisible = ref(false) // 弹窗的是否展示 |
||||
|
const dialogTitle = ref('') // 弹窗的标题 |
||||
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 |
||||
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改 |
||||
|
const tags=ref([]) |
||||
|
|
||||
|
const inputValue = ref('') |
||||
|
const inputVisible = ref(false) |
||||
|
const isDisabled = ref(false) |
||||
|
const InputRef = ref<InstanceType<typeof ElInput>>() |
||||
|
//点检项相关参数 |
||||
|
const spotCheckItemData = ref([]) |
||||
|
|
||||
|
const itemData = ref({ |
||||
|
id: '', |
||||
|
content: '', |
||||
|
selectId:'' |
||||
|
}) |
||||
|
|
||||
|
const formData = ref({ |
||||
|
code: '', |
||||
|
name: '', |
||||
|
describing: '', |
||||
|
isUpdated: '', |
||||
|
remark: '', |
||||
|
available: '', |
||||
|
selectId: '', |
||||
|
optionItem:[] |
||||
|
}) |
||||
|
const formRules = reactive({ |
||||
|
code: [ |
||||
|
{ required: true, message: '方案编号不能为空', trigger: 'blur' }, |
||||
|
{ max: 50, message: '不得超过50个字符', trigger: 'blur' } |
||||
|
], |
||||
|
name: [ |
||||
|
{ required: true, message: '方案名称不能为空', trigger: 'blur' }, |
||||
|
{ max: 50, message: '不得超过50个字符', trigger: 'blur' } |
||||
|
], |
||||
|
isUpdated: [ |
||||
|
{ required: true, message: '不能为空', trigger: 'blur' }, |
||||
|
], |
||||
|
available: [ |
||||
|
{ required: true, message: '不能为空', trigger: 'blur' }, |
||||
|
], |
||||
|
remark: [ |
||||
|
{ max: 50, message: '不得超过50个字符', trigger: 'blur' } |
||||
|
], |
||||
|
}) |
||||
|
const basicFormRef = ref() // 表单 Ref |
||||
|
|
||||
|
/** 删除巡检项 */ |
||||
|
const handleClose = (id: string) => { |
||||
|
console.log(id) |
||||
|
console.log(tags) |
||||
|
const index = tags.value.findIndex(tag => tag.selectId === id); |
||||
|
if (index !== -1) { |
||||
|
tags.value.splice(index, 1); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 弹窗相关参数 */ |
||||
|
const searchTableRef = ref(); |
||||
|
const _searchTableTitle = ref(); |
||||
|
const _searchTableAllSchemas = ref(); |
||||
|
const _searchTablePage = ref(); |
||||
|
const _formField = ref(); |
||||
|
const _searchField = ref(); |
||||
|
const _multiple = ref(); |
||||
|
const _type = ref(); |
||||
|
const _row = ref(); |
||||
|
const _searchCondition = ref({}) |
||||
|
|
||||
|
|
||||
|
const addItem = () =>{ |
||||
|
addItemCommon(true,'dianJianItem') |
||||
|
} |
||||
|
|
||||
|
/** 选择巡检项弹窗 */ |
||||
|
const addItemCommon = (multiple,field) => { |
||||
|
_searchCondition.value = {} |
||||
|
const filters: any[] = [] |
||||
|
filters.push({ |
||||
|
action: "==", |
||||
|
column: 'available', |
||||
|
value: 'TRUE' |
||||
|
}) |
||||
|
// 参数整理 |
||||
|
_searchCondition.value.isSearch = true |
||||
|
_searchCondition.value.filters = filters |
||||
|
_searchTableTitle.value = '选择点检项' |
||||
|
//_multiple.value = multiple |
||||
|
_formField.value = field |
||||
|
_searchField.value = field |
||||
|
_searchTablePage.value = SpotCheckSelectSetApi.getBasicSpotCheckSelectSetPage |
||||
|
_searchTableAllSchemas.value = BasicSpotCheckSelectSet.allSchemas |
||||
|
openCommon() |
||||
|
} |
||||
|
|
||||
|
/** 弹窗选择之后 回调函数 添加选择集 */ |
||||
|
const searchTableSuccess = (formField, searchField, val, formRef, type, row ) => { |
||||
|
nextTick?.(async () => { |
||||
|
if (formField === 'dianJianItem') { |
||||
|
let itemsId = ''; |
||||
|
//选择集ID赋值 |
||||
|
val.forEach(item => { |
||||
|
const isExist = tags.value.some(tag => tag.id === item.id); |
||||
|
if (!isExist) { |
||||
|
const newItem = {}; |
||||
|
newItem['itemCode'] = item.itemCode; |
||||
|
newItem['selectId'] = item.id; |
||||
|
tags.value = []; |
||||
|
tags.value.push(newItem); |
||||
|
} |
||||
|
itemsId = item.itemCode; |
||||
|
}); |
||||
|
//点检项赋值 |
||||
|
try { |
||||
|
formLoading.value = true; |
||||
|
spotCheckItemData.value = []; |
||||
|
for (const item of itemsId.split(",")) { |
||||
|
let res = await request.get({url: `/eam/basic/spot-check-item/get?id=` + item}) |
||||
|
const newItem = {}; |
||||
|
newItem['itemCode'] = res.id; |
||||
|
newItem['itemName'] = res.name; |
||||
|
newItem['equipmentParts'] = res.equipmentParts; |
||||
|
newItem['isSelectd'] = true; |
||||
|
spotCheckItemData.value.push(newItem); |
||||
|
} |
||||
|
} finally { |
||||
|
formLoading.value = false; |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
/*打开弹窗*/ |
||||
|
const openCommon = () => { |
||||
|
searchTableRef.value.open( |
||||
|
_searchTableTitle.value, |
||||
|
_searchTableAllSchemas.value, |
||||
|
_searchTablePage.value, |
||||
|
_formField.value, |
||||
|
_searchField.value, |
||||
|
_multiple.value, |
||||
|
_type.value, |
||||
|
_row.value, |
||||
|
_searchCondition.value |
||||
|
) |
||||
|
} |
||||
|
/** 初始化弹窗 */ |
||||
|
const open = async (type: string, row?: object) => { |
||||
|
dialogVisible.value = true |
||||
|
dialogTitle.value = t('action.' + type) |
||||
|
formType.value = type |
||||
|
// 修改时,设置数据 |
||||
|
if (row) { |
||||
|
isDisabled.value = true; |
||||
|
formLoading.value = true |
||||
|
formData.value = row; |
||||
|
//添加点检选择集 |
||||
|
let item = (row.id.toString()).split(",") |
||||
|
try { |
||||
|
tags.value=[]; |
||||
|
for (var i = 0; i < item.length; i++) { |
||||
|
itemData.value = await request.get({ url: `/eam/basic-spotCheck-option/get?id=` + item[i] }); |
||||
|
tags.value.push(itemData.value); |
||||
|
} |
||||
|
} finally { |
||||
|
formLoading.value = false |
||||
|
} |
||||
|
//添加点检项 |
||||
|
let res = await request.get({url: `/eam/relation-spotCheck-option-item/getList?optionCode=` + row.code}) |
||||
|
try { |
||||
|
spotCheckItemData.value = []; |
||||
|
formLoading.value = true; |
||||
|
for (const item of res) { |
||||
|
const newItem = {}; |
||||
|
newItem['id'] = item.id; |
||||
|
newItem['itemCode'] = item.itemCode; |
||||
|
newItem['itemName'] = item.itemName; |
||||
|
newItem['isSelectd'] = item.isSelectd; |
||||
|
spotCheckItemData.value.push(newItem); |
||||
|
} |
||||
|
} finally { |
||||
|
formLoading.value = false; |
||||
|
} |
||||
|
} |
||||
|
// 新增时 |
||||
|
else { |
||||
|
resetForm() |
||||
|
isDisabled.value = false; |
||||
|
} |
||||
|
} |
||||
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗 |
||||
|
|
||||
|
/** 提交表单 */ |
||||
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 |
||||
|
const submitForm = async () => { |
||||
|
// 校验表单 |
||||
|
if (!basicFormRef) return |
||||
|
const valid = await basicFormRef.value.validate() |
||||
|
if (!valid) return |
||||
|
if (spotCheckItemData.value.length > 10 ){ |
||||
|
message.warning('点检项最多10个'); |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
//赋值 点检选择集ID |
||||
|
formData.value.selectId = tags.value[0].selectId |
||||
|
// 提交请求 |
||||
|
formLoading.value = true |
||||
|
//formData.value.members = JSON.stringify(tags.value) |
||||
|
try { |
||||
|
if (formType.value === 'create') { |
||||
|
for (var i = 0; i < spotCheckItemData.value.length; i++) { |
||||
|
spotCheckItemData.value[i].optionCode = formData.value.code |
||||
|
} |
||||
|
formData.value.optionItem = spotCheckItemData.value |
||||
|
//新增点检方案 及 方案与项关系 |
||||
|
await BasicSpotCheckOptionApi.createBasicSpotCheckOption(formData.value) |
||||
|
message.success(t('common.createSuccess')) |
||||
|
} else { |
||||
|
for (var i = 0; i < spotCheckItemData.value.length; i++) { |
||||
|
spotCheckItemData.value[i].optionCode = formData.value.code |
||||
|
} |
||||
|
formData.value.optionItem = spotCheckItemData.value |
||||
|
console.log(formData.value) |
||||
|
await BasicSpotCheckOptionApi.updateBasicSpotCheckOption(formData.value) |
||||
|
message.success(t('common.updateSuccess')) |
||||
|
} |
||||
|
dialogVisible.value = false |
||||
|
// 发送操作成功的事件 |
||||
|
emit('success') |
||||
|
} finally { |
||||
|
formLoading.value = false |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 重置表单 */ |
||||
|
const resetForm = () => { |
||||
|
formData.value = { |
||||
|
code: '', |
||||
|
name: '', |
||||
|
describing: '', |
||||
|
isUpdated: '', |
||||
|
remark: '', |
||||
|
available: '', |
||||
|
selectId: '' |
||||
|
} |
||||
|
tags.value=[]; |
||||
|
spotCheckItemData.value = []; |
||||
|
basicFormRef.value?.resetFields() |
||||
|
} |
||||
|
|
||||
|
</script> |
||||
|
|
||||
|
<style scoped> |
||||
|
.tag-container { |
||||
|
margin-top: 10px; /* 可根据需要调整标签容器与表单项之间的间距 */ |
||||
|
border: 1px solid #ccc; /* 添加边框样式 */ |
||||
|
padding: 10px; /* 可根据需要调整容器内边距 */ |
||||
|
width: 950px; /* 设置固定宽度为 950px */ |
||||
|
overflow-y: auto; /* 当内容溢出容器高度时显示滚动条 */ |
||||
|
word-wrap: break-word; /* 使用 word-wrap 属性实现超出范围换行 */ |
||||
|
overflow-wrap: break-word; /* 兼容性更好的写法 */ |
||||
|
flex-wrap: wrap; |
||||
|
} |
||||
|
.input-with-button { |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
width: 100%; |
||||
|
} |
||||
|
|
||||
|
.input-with-button > .el-input { |
||||
|
flex: 1; |
||||
|
/*margin-right: 10px;*/ |
||||
|
} |
||||
|
|
||||
|
</style> |
Loading…
Reference in new issue