ljlong_2630
6 months ago
8 changed files with 908 additions and 9 deletions
@ -0,0 +1,63 @@ |
|||
import request from '@/config/axios' |
|||
|
|||
export interface EquipmentManufacturerVO { |
|||
id: number |
|||
number: string |
|||
name: string |
|||
shortName: string |
|||
address: string |
|||
country: string |
|||
city: string |
|||
phone: string |
|||
fax: string |
|||
postId: string |
|||
contacts: string |
|||
departmentCode: string |
|||
remark: string |
|||
siteId: string |
|||
available: string |
|||
deletionTime: Date |
|||
deleterId: byte[] |
|||
concurrencyStamp: number |
|||
} |
|||
|
|||
// 查询设备制造商列表
|
|||
export const getEquipmentManufacturerPage = async (params) => { |
|||
if (params.isSearch) { |
|||
delete params.isSearch |
|||
const data = {...params} |
|||
return await request.post({ url: '/eam/basic/equipment-manufacturer/senior', data }) |
|||
} else { |
|||
return await request.get({ url: `/eam/basic/equipment-manufacturer/page`, params }) |
|||
} |
|||
} |
|||
|
|||
// 查询设备制造商详情
|
|||
export const getEquipmentManufacturer = async (id: number) => { |
|||
return await request.get({ url: `/eam/basic/equipment-manufacturer/get?id=` + id }) |
|||
} |
|||
|
|||
// 新增设备制造商
|
|||
export const createEquipmentManufacturer = async (data: EquipmentManufacturerVO) => { |
|||
return await request.post({ url: `/eam/basic/equipment-manufacturer/create`, data }) |
|||
} |
|||
|
|||
// 修改设备制造商
|
|||
export const updateEquipmentManufacturer = async (data: EquipmentManufacturerVO) => { |
|||
return await request.put({ url: `/eam/basic/equipment-manufacturer/update`, data }) |
|||
} |
|||
|
|||
// 删除设备制造商
|
|||
export const deleteEquipmentManufacturer = async (id: number) => { |
|||
return await request.delete({ url: `/eam/basic/equipment-manufacturer/delete?id=` + id }) |
|||
} |
|||
|
|||
// 导出设备制造商 Excel
|
|||
export const exportEquipmentManufacturer = async (params) => { |
|||
return await request.download({ url: `/eam/basic/equipment-manufacturer/export-excel`, params }) |
|||
} |
|||
|
|||
// 下载用户导入模板
|
|||
export const importTemplate = () => { |
|||
return request.download({ url: '/eam/basic/equipment-manufacturer/get-import-template' }) |
|||
} |
@ -0,0 +1,63 @@ |
|||
import request from '@/config/axios' |
|||
|
|||
export interface EquipmentSupplierVO { |
|||
id: number |
|||
number: string |
|||
name: string |
|||
shortName: string |
|||
address: string |
|||
country: string |
|||
city: string |
|||
phone: string |
|||
fax: string |
|||
postId: string |
|||
contacts: string |
|||
departmentCode: string |
|||
remark: string |
|||
siteId: string |
|||
available: string |
|||
deletionTime: Date |
|||
deleterId: byte[] |
|||
concurrencyStamp: number |
|||
} |
|||
|
|||
// 查询供应商列表
|
|||
export const getEquipmentSupplierPage = async (params) => { |
|||
if (params.isSearch) { |
|||
delete params.isSearch |
|||
const data = {...params} |
|||
return await request.post({ url: '/eam/basic/equipment-supplier/senior', data }) |
|||
} else { |
|||
return await request.get({ url: `/eam/basic/equipment-supplier/page`, params }) |
|||
} |
|||
} |
|||
|
|||
// 查询供应商详情
|
|||
export const getEquipmentSupplier = async (id: number) => { |
|||
return await request.get({ url: `/eam/basic/equipment-supplier/get?id=` + id }) |
|||
} |
|||
|
|||
// 新增供应商
|
|||
export const createEquipmentSupplier = async (data: EquipmentSupplierVO) => { |
|||
return await request.post({ url: `/eam/basic/equipment-supplier/create`, data }) |
|||
} |
|||
|
|||
// 修改供应商
|
|||
export const updateEquipmentSupplier = async (data: EquipmentSupplierVO) => { |
|||
return await request.put({ url: `/eam/basic/equipment-supplier/update`, data }) |
|||
} |
|||
|
|||
// 删除供应商
|
|||
export const deleteEquipmentSupplier = async (id: number) => { |
|||
return await request.delete({ url: `/eam/basic/equipment-supplier/delete?id=` + id }) |
|||
} |
|||
|
|||
// 导出供应商 Excel
|
|||
export const exportEquipmentSupplier = async (params) => { |
|||
return await request.download({ url: `/eam/basic/equipment-supplier/export-excel`, params }) |
|||
} |
|||
|
|||
// 下载用户导入模板
|
|||
export const importTemplate = () => { |
|||
return request.download({ url: '/eam/basic/equipment-supplier/get-import-template' }) |
|||
} |
@ -0,0 +1,139 @@ |
|||
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 EquipmentManufacturerRules = reactive({ |
|||
number: [required], |
|||
name: [required], |
|||
concurrencyStamp: [required] |
|||
}) |
|||
|
|||
export const EquipmentManufacturer = useCrudSchemas(reactive<CrudSchema[]>([ |
|||
|
|||
{ |
|||
label: '设备厂商编号', |
|||
field: 'number', |
|||
sort: 'custom', |
|||
isSearch: true, |
|||
fixed: 'left', |
|||
isForm: false, |
|||
}, |
|||
{ |
|||
label: '名称', |
|||
field: 'name', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '简称', |
|||
field: 'shortName', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '地址', |
|||
field: 'address', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '国家', |
|||
field: 'country', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '城市', |
|||
field: 'city', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '电话', |
|||
field: 'phone', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '传真', |
|||
field: 'fax', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '邮编', |
|||
field: 'postId', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '联系人', |
|||
field: 'contacts', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '部门', |
|||
field: 'departmentCode', |
|||
sort: 'custom', |
|||
isSearch: true, |
|||
form: { |
|||
component: 'TreeSelect', |
|||
componentProps: { // 假设deptList是部门数据列表
|
|||
data: deptList, |
|||
placeholder: "请选择部门", |
|||
filterable: true, |
|||
// multiple: true,
|
|||
} |
|||
} |
|||
}, |
|||
{ |
|||
label: '备注', |
|||
field: 'remark', |
|||
sort: 'custom', |
|||
isSearch: true, |
|||
form: { |
|||
component: 'Input', |
|||
componentProps: { |
|||
type: 'textarea' |
|||
} |
|||
} |
|||
}, |
|||
{ |
|||
label: '是否可用', |
|||
field: 'available', |
|||
sort: 'custom', |
|||
dictType: DICT_TYPE.TRUE_FALSE, |
|||
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
|||
isSearch: true, |
|||
form: { |
|||
component: 'Switch', |
|||
value: 'TRUE', |
|||
componentProps: { |
|||
inactiveValue: 'FALSE', |
|||
activeValue: 'TRUE' |
|||
} |
|||
}, |
|||
search: { |
|||
component: 'Select', |
|||
}, |
|||
table: { |
|||
width: 110 |
|||
} |
|||
}, |
|||
{ |
|||
label: '操作', |
|||
field: 'action', |
|||
isForm: false, |
|||
table: { |
|||
width: 150, |
|||
fixed: 'right' |
|||
} |
|||
} |
|||
])) |
@ -0,0 +1,244 @@ |
|||
<template> |
|||
<ContentWrap> |
|||
<!-- 搜索工作栏 --> |
|||
<Search :schema="EquipmentManufacturer.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> |
|||
</ContentWrap> |
|||
|
|||
<!-- 列表头部 --> |
|||
<TableHead |
|||
:HeadButttondata="HeadButttondata" |
|||
@button-base-click="buttonBaseClick" |
|||
:routeName="routeName" |
|||
@updataTableColumns="updataTableColumns" |
|||
@searchFormClick="searchFormClick" |
|||
:allSchemas="EquipmentManufacturer.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" @button-base-click="buttonTableClick($event,row)" /> |
|||
</template> |
|||
</Table> |
|||
</ContentWrap> |
|||
|
|||
<!-- 表单弹窗:添加/修改 --> |
|||
<BasicForm |
|||
ref="basicFormRef" |
|||
@success="formsSuccess" |
|||
:rules="EquipmentManufacturerRules" |
|||
:formAllSchemas="EquipmentManufacturer.allSchemas" |
|||
:apiUpdate="EquipmentManufacturerApi.updateEquipmentManufacturer" |
|||
:apiCreate="EquipmentManufacturerApi.createEquipmentManufacturer" |
|||
@searchTableSuccess="searchTableSuccess" |
|||
:isBusiness="false" |
|||
/> |
|||
|
|||
<!-- 详情 --> |
|||
<Detail ref="detailRef" :isBasic="true" :allSchemas="EquipmentManufacturer.allSchemas" /> |
|||
|
|||
<!-- 导入 --> |
|||
<ImportForm ref="importFormRef" url="/eam/basic/equipment-manufacturer/import" :importTemplateData="importTemplateData" @success="importSuccess" /> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import download from '@/utils/download' |
|||
import { EquipmentManufacturer,EquipmentManufacturerRules } from './equipmentManufacturer.data' |
|||
import * as EquipmentManufacturerApi from '@/api/eam/equipmentManufacturer' |
|||
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: 'EquipmentManufacturer' }) |
|||
|
|||
const message = useMessage() // 消息弹窗 |
|||
const { t } = useI18n() // 国际化 |
|||
|
|||
const route = useRoute() // 路由信息 |
|||
const routeName = ref() |
|||
routeName.value = route.name |
|||
const tableColumns = ref(EquipmentManufacturer.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: EquipmentManufacturerApi.getEquipmentManufacturerPage // 分页接口 |
|||
}) |
|||
|
|||
// 获得表格的各种操作 |
|||
const { getList, setSearchParams } = tableMethods |
|||
|
|||
// 列表头部按钮 |
|||
const HeadButttondata = [ |
|||
defaultButtons.defaultAddBtn({hasPermi:'eam:equipment-manufacturer:create'}), // 新增 |
|||
defaultButtons.defaultImportBtn({hasPermi:'eam:equipment-manufacturer:import'}), // 导入 |
|||
defaultButtons.defaultExportBtn({hasPermi:'eam:equipment-manufacturer: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 = [ |
|||
defaultButtons.mainListEditBtn({hasPermi:'eam:equipment-manufacturer:update'}), // 编辑 |
|||
// defaultButtons.mainListDeleteBtn({hasPermi:'eam:equipment-manufacturer:delete'}), // 删除 |
|||
] |
|||
|
|||
// 列表-操作按钮事件 |
|||
const buttonTableClick = async (val, row) => { |
|||
if (val == 'edit') { // 编辑 |
|||
openForm('update', row) |
|||
} else if (val == 'delete') { // 删除 |
|||
handleDelete(row.id) |
|||
} |
|||
} |
|||
|
|||
/** 添加/修改操作 */ |
|||
const basicFormRef = ref() |
|||
const openForm = (type: string, row?: any) => { |
|||
basicFormRef.value.open(type, row) |
|||
} |
|||
|
|||
// form表单提交 |
|||
const formsSuccess = async (formType,data) => { |
|||
var isHave =EquipmentManufacturer.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 EquipmentManufacturerApi.createEquipmentManufacturer(data) |
|||
message.success(t('common.createSuccess')) |
|||
} else { |
|||
await EquipmentManufacturerApi.updateEquipmentManufacturer(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, 'basicEquipmentManufacturer') |
|||
} |
|||
|
|||
/** 删除按钮操作 */ |
|||
const handleDelete = async (id: number) => { |
|||
try { |
|||
// 删除的二次确认 |
|||
await message.delConfirm() |
|||
// 发起删除 |
|||
await EquipmentManufacturerApi.deleteEquipmentManufacturer(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 EquipmentManufacturerApi.exportEquipmentManufacturer(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() |
|||
importTemplateData.templateUrl = await EquipmentManufacturerApi.importTemplate() |
|||
}) |
|||
|
|||
</script> |
@ -0,0 +1,145 @@ |
|||
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' |
|||
import { dateFormatter } from '@/utils/formatTime' |
|||
import { validateHanset,validateNumDot, validateEmail } from '@/utils/validator' |
|||
import { handleTreeToComponentOptions } from '@/utils/tree' |
|||
import * as DeptApi from '@/api/system/dept' |
|||
const deptList = ref<Tree[]>([]) // 树形结构
|
|||
|
|||
// 加载部门树(默认格式)
|
|||
deptList.value = handleTreeToComponentOptions(await DeptApi.getSimpleDeptList()) |
|||
|
|||
// 表单校验
|
|||
export const EquipmentSupplierRules = reactive({ |
|||
number: [required], |
|||
name: [required], |
|||
concurrencyStamp: [required], |
|||
phone: [ |
|||
{ validator:validateHanset, message: '手机号格式不正确', trigger: 'blur'} |
|||
], |
|||
postId: [ |
|||
{validator:validateNumDot, message: '邮编格式不正确', trigger: 'blur'} |
|||
] |
|||
}) |
|||
|
|||
export const EquipmentSupplier = useCrudSchemas(reactive<CrudSchema[]>([ |
|||
{ |
|||
label: '供应商编号', |
|||
field: 'number', |
|||
sort: 'custom', |
|||
isSearch: true, |
|||
fixed: 'left', |
|||
isForm: false, |
|||
}, |
|||
{ |
|||
label: '名称', |
|||
field: 'name', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '简称', |
|||
field: 'shortName', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '地址', |
|||
field: 'address', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '国家', |
|||
field: 'country', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '城市', |
|||
field: 'city', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '电话', |
|||
field: 'phone', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '传真', |
|||
field: 'fax', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '邮编', |
|||
field: 'postId', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '联系人', |
|||
field: 'contacts', |
|||
sort: 'custom', |
|||
isSearch: true |
|||
}, |
|||
{ |
|||
label: '部门', |
|||
field: 'departmentCode', |
|||
sort: 'custom', |
|||
isSearch: true, |
|||
form: { |
|||
component: 'TreeSelect', |
|||
componentProps: { // 假设deptList是部门数据列表
|
|||
data: deptList, |
|||
placeholder: "请选择部门", |
|||
filterable: true, |
|||
// multiple: true,
|
|||
} |
|||
} |
|||
}, |
|||
{ |
|||
label: '备注', |
|||
field: 'remark', |
|||
sort: 'custom', |
|||
isSearch: true, |
|||
form: { |
|||
component: 'Input', |
|||
componentProps: { |
|||
type: 'textarea' |
|||
} |
|||
} |
|||
}, |
|||
{ |
|||
label: '是否可用', |
|||
field: 'available', |
|||
sort: 'custom', |
|||
dictType: DICT_TYPE.TRUE_FALSE, |
|||
dictClass: 'string', // 默认都是字符串类型其他暂不考虑
|
|||
isSearch: true, |
|||
form: { |
|||
component: 'Switch', |
|||
value: 'TRUE', |
|||
componentProps: { |
|||
inactiveValue: 'FALSE', |
|||
activeValue: 'TRUE' |
|||
} |
|||
}, |
|||
search: { |
|||
component: 'Select', |
|||
}, |
|||
table: { |
|||
width: 110 |
|||
} |
|||
}, |
|||
{ |
|||
label: '操作', |
|||
field: 'action', |
|||
isForm: false, |
|||
table: { |
|||
width: 150, |
|||
fixed: 'right' |
|||
} |
|||
} |
|||
])) |
@ -0,0 +1,244 @@ |
|||
<template> |
|||
<ContentWrap> |
|||
<!-- 搜索工作栏 --> |
|||
<Search :schema="EquipmentSupplier.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> |
|||
</ContentWrap> |
|||
|
|||
<!-- 列表头部 --> |
|||
<TableHead |
|||
:HeadButttondata="HeadButttondata" |
|||
@button-base-click="buttonBaseClick" |
|||
:routeName="routeName" |
|||
@updataTableColumns="updataTableColumns" |
|||
@searchFormClick="searchFormClick" |
|||
:allSchemas="EquipmentSupplier.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" @button-base-click="buttonTableClick($event,row)" /> |
|||
</template> |
|||
</Table> |
|||
</ContentWrap> |
|||
|
|||
<!-- 表单弹窗:添加/修改 --> |
|||
<BasicForm |
|||
ref="basicFormRef" |
|||
@success="formsSuccess" |
|||
:rules="EquipmentSupplierRules" |
|||
:formAllSchemas="EquipmentSupplier.allSchemas" |
|||
:apiUpdate="EquipmentSupplierApi.updateEquipmentSupplier" |
|||
:apiCreate="EquipmentSupplierApi.createEquipmentSupplier" |
|||
@searchTableSuccess="searchTableSuccess" |
|||
:isBusiness="false" |
|||
/> |
|||
|
|||
<!-- 详情 --> |
|||
<Detail ref="detailRef" :isBasic="true" :allSchemas="EquipmentSupplier.allSchemas" /> |
|||
|
|||
<!-- 导入 --> |
|||
<ImportForm ref="importFormRef" url="/eam/basic/equipment-supplier/import" :importTemplateData="importTemplateData" @success="importSuccess" /> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import download from '@/utils/download' |
|||
import { EquipmentSupplier,EquipmentSupplierRules } from './equipmentSupplier.data' |
|||
import * as EquipmentSupplierApi from '@/api/eam/equipmentSupplier' |
|||
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: 'EquipmentSupplier' }) |
|||
|
|||
const message = useMessage() // 消息弹窗 |
|||
const { t } = useI18n() // 国际化 |
|||
|
|||
const route = useRoute() // 路由信息 |
|||
const routeName = ref() |
|||
routeName.value = route.name |
|||
const tableColumns = ref(EquipmentSupplier.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: EquipmentSupplierApi.getEquipmentSupplierPage // 分页接口 |
|||
}) |
|||
|
|||
// 获得表格的各种操作 |
|||
const { getList, setSearchParams } = tableMethods |
|||
|
|||
// 列表头部按钮 |
|||
const HeadButttondata = [ |
|||
defaultButtons.defaultAddBtn({hasPermi:'eam:equipment-supplier:create'}), // 新增 |
|||
defaultButtons.defaultImportBtn({hasPermi:'eam:equipment-supplier:import'}), // 导入 |
|||
defaultButtons.defaultExportBtn({hasPermi:'eam:equipment-supplier: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 = [ |
|||
defaultButtons.mainListEditBtn({hasPermi:'eam:equipment-supplier:update'}), // 编辑 |
|||
// defaultButtons.mainListDeleteBtn({hasPermi:'eam:equipment-supplier:delete'}), // 删除 |
|||
] |
|||
|
|||
// 列表-操作按钮事件 |
|||
const buttonTableClick = async (val, row) => { |
|||
if (val == 'edit') { // 编辑 |
|||
openForm('update', row) |
|||
} else if (val == 'delete') { // 删除 |
|||
handleDelete(row.id) |
|||
} |
|||
} |
|||
|
|||
/** 添加/修改操作 */ |
|||
const basicFormRef = ref() |
|||
const openForm = (type: string, row?: any) => { |
|||
basicFormRef.value.open(type, row) |
|||
} |
|||
|
|||
// form表单提交 |
|||
const formsSuccess = async (formType,data) => { |
|||
var isHave =EquipmentSupplier.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 EquipmentSupplierApi.createEquipmentSupplier(data) |
|||
message.success(t('common.createSuccess')) |
|||
} else { |
|||
await EquipmentSupplierApi.updateEquipmentSupplier(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, 'basicEquipmentSupplier') |
|||
} |
|||
|
|||
/** 删除按钮操作 */ |
|||
const handleDelete = async (id: number) => { |
|||
try { |
|||
// 删除的二次确认 |
|||
await message.delConfirm() |
|||
// 发起删除 |
|||
await EquipmentSupplierApi.deleteEquipmentSupplier(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 EquipmentSupplierApi.exportEquipmentSupplier(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() |
|||
importTemplateData.templateUrl = await EquipmentSupplierApi.importTemplate() |
|||
}) |
|||
|
|||
</script> |
Loading…
Reference in new issue