|
@ -4,29 +4,16 @@ |
|
|
<Search :schema="Item.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> |
|
|
<Search :schema="Item.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> |
|
|
</ContentWrap> |
|
|
</ContentWrap> |
|
|
|
|
|
|
|
|
<!-- 列表头部 --> |
|
|
<!-- 列表头部 --> |
|
|
<TableHead |
|
|
<TableHead :HeadButttondata="HeadButttondata" @button-base-click="buttonBaseClick" :routeName="routeName" |
|
|
:HeadButttondata="HeadButttondata" |
|
|
@updataTableColumns="updataTableColumns" @searchFormClick="searchFormClick" :allSchemas="Item.allSchemas" /> |
|
|
@button-base-click="buttonBaseClick" |
|
|
|
|
|
:routeName="routeName" |
|
|
|
|
|
@updataTableColumns="updataTableColumns" |
|
|
|
|
|
@searchFormClick="searchFormClick" |
|
|
|
|
|
:allSchemas="Item.allSchemas" |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<!-- 列表 --> |
|
|
<!-- 列表 --> |
|
|
<ContentWrap> |
|
|
<ContentWrap> |
|
|
<Table |
|
|
<Table :columns="tableColumns" :data="tableObject.tableList" :loading="tableObject.loading" :pagination="{ |
|
|
:columns="tableColumns" |
|
|
|
|
|
:data="tableObject.tableList" |
|
|
|
|
|
:loading="tableObject.loading" |
|
|
|
|
|
:pagination="{ |
|
|
|
|
|
total: tableObject.total |
|
|
total: tableObject.total |
|
|
}" |
|
|
}" v-model:pageSize="tableObject.pageSize" v-model:currentPage="tableObject.currentPage" |
|
|
v-model:pageSize="tableObject.pageSize" |
|
|
v-model:sort="tableObject.sort"> |
|
|
v-model:currentPage="tableObject.currentPage" |
|
|
|
|
|
v-model:sort="tableObject.sort" |
|
|
|
|
|
> |
|
|
|
|
|
<template #code="{row}"> |
|
|
<template #code="{row}"> |
|
|
<el-button type="primary" link @click="openDetail(row, '代码', row.code)"> |
|
|
<el-button type="primary" link @click="openDetail(row, '代码', row.code)"> |
|
|
<span>{{ row.code }}</span> |
|
|
<span>{{ row.code }}</span> |
|
@ -39,187 +26,199 @@ |
|
|
</ContentWrap> |
|
|
</ContentWrap> |
|
|
|
|
|
|
|
|
<!-- 表单弹窗:添加/修改 --> |
|
|
<!-- 表单弹窗:添加/修改 --> |
|
|
<BasicForm |
|
|
<BasicForm ref="basicFormRef" @success="formsSuccess" :rules="ItemRules" :formAllSchemas="Item.allSchemas" |
|
|
ref="basicFormRef" |
|
|
:apiUpdate="ItemApi.updateItem" :apiCreate="ItemApi.createItem" @searchTableSuccess="searchTableSuccess" |
|
|
@success="formsSuccess" |
|
|
:isBusiness="false" /> |
|
|
:rules="ItemRules" |
|
|
|
|
|
:formAllSchemas="Item.allSchemas" |
|
|
|
|
|
:apiUpdate="ItemApi.updateItem" |
|
|
|
|
|
:apiCreate="ItemApi.createItem" |
|
|
|
|
|
@searchTableSuccess="searchTableSuccess" |
|
|
|
|
|
:isBusiness="false" |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<!-- 详情 --> |
|
|
<!-- 详情 --> |
|
|
<Detail ref="detailRef" :isBasic="true" :allSchemas="Item.allSchemas" /> |
|
|
<Detail ref="detailRef" :isBasic="true" :allSchemas="Item.allSchemas" /> |
|
|
|
|
|
|
|
|
<!-- 导入 --> |
|
|
<!-- 选择设备 --> |
|
|
<ImportForm ref="importFormRef" url="/eam/item/import" :importTemplateData="importTemplateData" @success="importSuccess" /> |
|
|
<SearchTable ref="searchTableRef" @success="formsSuccess" @searchTableSuccess="searchTableSuccess" /> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script setup lang="ts"> |
|
|
<script setup lang="ts"> |
|
|
import download from '@/utils/download' |
|
|
import download from '@/utils/download' |
|
|
import { Item,ItemRules } from './item.data' |
|
|
import { Item, ItemRules } from './item.data' |
|
|
import * as ItemApi from '@/api/eam/basic/item' |
|
|
import * as ItemApi from '@/api/eam/basic/item' |
|
|
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|
|
import { DeviceAccounts, DeviceAccountsRules } from '@/views/eam/device/deviceAccounts/deviceAccounts.data' |
|
|
import TableHead from '@/components/TableHead/src/TableHead.vue' |
|
|
import * as DeviceAccountsApi from '@/api/eam/device/deviceAccounts' |
|
|
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' |
|
|
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|
|
import Detail from '@/components/Detail/src/Detail.vue' |
|
|
import TableHead from '@/components/TableHead/src/TableHead.vue' |
|
|
|
|
|
// import ImportForm from '@/components/ImportForm/src/ImportForm.vue' |
|
|
defineOptions({ name: 'Item' }) |
|
|
import Detail from '@/components/Detail/src/Detail.vue' |
|
|
|
|
|
|
|
|
const message = useMessage() // 消息弹窗 |
|
|
import { SearchTable } from '@/components/SearchTable' |
|
|
const { t } = useI18n() // 国际化 |
|
|
|
|
|
|
|
|
defineOptions({ name: 'Item' }) |
|
|
const route = useRoute() // 路由信息 |
|
|
|
|
|
const routeName = ref() |
|
|
const message = useMessage() // 消息弹窗 |
|
|
routeName.value = route.name |
|
|
const { t } = useI18n() // 国际化 |
|
|
const tableColumns = ref(Item.allSchemas.tableColumns) |
|
|
|
|
|
|
|
|
const route = useRoute() // 路由信息 |
|
|
// 查询页面返回 |
|
|
const routeName = ref() |
|
|
const searchTableSuccess = (formField, searchField, val, formRef) => { |
|
|
routeName.value = route.name |
|
|
nextTick(() => { |
|
|
const tableColumns = ref(Item.allSchemas.tableColumns) |
|
|
const setV = {} |
|
|
|
|
|
setV[formField] = val[0][searchField] |
|
|
|
|
|
formRef.setValues(setV) |
|
|
|
|
|
|
|
|
// 查询页面返回 |
|
|
|
|
|
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: ItemApi.getItemPage // 分页接口 |
|
|
}) |
|
|
}) |
|
|
} |
|
|
|
|
|
|
|
|
// 获得表格的各种操作 |
|
|
// 字段设置 更新主列表字段 |
|
|
const { getList, setSearchParams } = tableMethods |
|
|
const updataTableColumns = (val) => { |
|
|
|
|
|
tableColumns.value = val |
|
|
// 列表头部按钮 |
|
|
} |
|
|
const HeadButttondata = [ |
|
|
|
|
|
defaultButtons.defaultAddBtn(null), // 新增 |
|
|
const { tableObject, tableMethods } = useTable({ |
|
|
defaultButtons.defaultExportBtn(null), // 导出 |
|
|
getListApi: ItemApi.getItemPage // 分页接口 |
|
|
|
|
|
}) |
|
|
defaultButtons.defaultFreshBtn(null), // 刷新 |
|
|
|
|
|
defaultButtons.defaultFilterBtn(null), // 筛选 |
|
|
// 获得表格的各种操作 |
|
|
defaultButtons.defaultSetBtn(null), // 设置 |
|
|
const { getList, setSearchParams } = tableMethods |
|
|
// { |
|
|
|
|
|
// label: '自定义扩展按钮', |
|
|
// 列表头部按钮 |
|
|
// name: 'zdy', |
|
|
const HeadButttondata = [ |
|
|
// hide: false, |
|
|
defaultButtons.defaultAddBtn(null), // 新增 |
|
|
// type: 'primary', |
|
|
defaultButtons.defaultExportBtn(null), // 导出 |
|
|
// icon: 'Select', |
|
|
defaultButtons.defaultFreshBtn(null), // 刷新 |
|
|
// color: '' |
|
|
defaultButtons.defaultFilterBtn(null), // 筛选 |
|
|
// }, |
|
|
defaultButtons.defaultSetBtn(null), // 设置 |
|
|
] |
|
|
// { |
|
|
|
|
|
// label: '自定义扩展按钮', |
|
|
// 头部按钮事件 |
|
|
// name: 'zdy', |
|
|
const buttonBaseClick = (val, item) => { |
|
|
// hide: false, |
|
|
if (val == 'add') { // 新增 |
|
|
// type: 'primary', |
|
|
openForm('create') |
|
|
// icon: 'Select', |
|
|
} else if (val == 'export') { // 导出 |
|
|
// color: '' |
|
|
handleExport() |
|
|
// }, |
|
|
} else if (val == 'refresh') { // 刷新 |
|
|
] |
|
|
getList() |
|
|
|
|
|
} else if (val == 'filtrate') { // 筛选 |
|
|
// 头部按钮事件 |
|
|
} else { // 其他按钮 |
|
|
const buttonBaseClick = (val, item) => { |
|
|
console.log('其他按钮', item) |
|
|
if (val == 'add') { // 新增 |
|
|
} |
|
|
openForm('create') |
|
|
|
|
|
} else if (val == 'export') { // 导出 |
|
|
|
|
|
handleExport() |
|
|
|
|
|
} else if (val == 'refresh') { // 刷新 |
|
|
|
|
|
getList() |
|
|
|
|
|
} else if (val == 'filtrate') { // 筛选 |
|
|
|
|
|
} else { // 其他按钮 |
|
|
|
|
|
console.log('其他按钮', item) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 列表-操作按钮 |
|
|
// 列表-操作按钮 |
|
|
const butttondata = [ |
|
|
const butttondata = [ |
|
|
defaultButtons.mainListEditBtn(null), // 编辑 |
|
|
defaultButtons.mainListEditBtn(null), // 编辑 |
|
|
|
|
|
defaultButtons.selectDeviceBtn(null), // 选择设备 |
|
|
defaultButtons.mainListDeleteBtn(null), // 删除 |
|
|
defaultButtons.mainListDeleteBtn(null), // 删除 |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
// 列表-操作按钮事件 |
|
|
// 列表-操作按钮事件 |
|
|
const buttonTableClick = async (val, row) => { |
|
|
const buttonTableClick = async (val, row) => { |
|
|
if (val == 'edit') { // 编辑 |
|
|
if (val == 'edit') { // 编辑 |
|
|
openForm('update', row) |
|
|
openForm('update', row) |
|
|
} else if (val == 'delete') { // 删除 |
|
|
} else if (val == 'selectDevice') { // 筛选 |
|
|
handleDelete(row.id) |
|
|
selectDevice(row) |
|
|
|
|
|
} else if (val == 'delete') { // 删除 |
|
|
|
|
|
handleDelete(row.id) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** 添加设备操作 */ |
|
|
/** 添加/修改操作 */ |
|
|
|
|
|
const basicFormRef = ref() |
|
|
// (titleName: any, allSchemas: any,getApiPage: any, formField: any, searchField: any,multiple: any, type: any, row: any, searchCondition:any , isCountRequestRe:any ) |
|
|
const openForm = (type: string, row?: any) => { |
|
|
const searchTableRef = ref() |
|
|
basicFormRef.value.open(type, row) |
|
|
const selectDevice = (type : string, row ?: any) => { |
|
|
} |
|
|
searchTableRef.value.open('设备列表', DeviceAccounts.allSchemas, DeviceAccountsApi.getDeviceAccountsPage, '', '', '', '', ''); |
|
|
|
|
|
|
|
|
// form表单提交 |
|
|
// ItemApi.createItem(row) |
|
|
const formsSuccess = async (formType,data) => { |
|
|
} |
|
|
var isHave =Item.allSchemas.formSchema.some(function (item) { |
|
|
|
|
|
return item.field === 'activeTime' || item.field === 'expireTime'; |
|
|
/** 添加/修改操作 */ |
|
|
}); |
|
|
const basicFormRef = ref() |
|
|
if(isHave){ |
|
|
const openForm = (type : string, row ?: any) => { |
|
|
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){ |
|
|
basicFormRef.value.open(type, row) |
|
|
message.error('失效时间要大于生效时间') |
|
|
} |
|
|
return; |
|
|
|
|
|
|
|
|
// form表单提交 |
|
|
|
|
|
const formsSuccess = async (formType, data) => { |
|
|
|
|
|
var isHave = Item.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 ItemApi.createItem(data) |
|
|
|
|
|
message.success(t('common.createSuccess')) |
|
|
|
|
|
} else { |
|
|
|
|
|
await ItemApi.updateItem(data) |
|
|
|
|
|
message.success(t('common.updateSuccess')) |
|
|
|
|
|
} |
|
|
|
|
|
basicFormRef.value.dialogVisible = false |
|
|
|
|
|
getList() |
|
|
} |
|
|
} |
|
|
if(data.activeTime==0)data.activeTime = null; |
|
|
|
|
|
if(data.expireTime==0)data.expireTime = null; |
|
|
/** 详情操作 */ |
|
|
if (formType === 'create') { |
|
|
const detailRef = ref() |
|
|
await ItemApi.createItem(data) |
|
|
const openDetail = (row : any, titleName : any, titleValue : any) => { |
|
|
message.success(t('common.createSuccess')) |
|
|
detailRef.value.openDetail(row, titleName, titleValue, 'basicItem') |
|
|
} else { |
|
|
|
|
|
await ItemApi.updateItem(data) |
|
|
|
|
|
message.success(t('common.updateSuccess')) |
|
|
|
|
|
} |
|
|
} |
|
|
basicFormRef.value.dialogVisible = false |
|
|
|
|
|
getList() |
|
|
/** 删除按钮操作 */ |
|
|
} |
|
|
const handleDelete = async (id : number) => { |
|
|
|
|
|
try { |
|
|
/** 详情操作 */ |
|
|
// 删除的二次确认 |
|
|
const detailRef = ref() |
|
|
await message.delConfirm() |
|
|
const openDetail = (row: any, titleName: any, titleValue: any) => { |
|
|
// 发起删除 |
|
|
detailRef.value.openDetail(row, titleName, titleValue, 'basicItem') |
|
|
await ItemApi.deleteItem(id) |
|
|
} |
|
|
message.success(t('common.delSuccess')) |
|
|
|
|
|
// 刷新列表 |
|
|
/** 删除按钮操作 */ |
|
|
await getList() |
|
|
const handleDelete = async (id: number) => { |
|
|
} catch { } |
|
|
try { |
|
|
|
|
|
// 删除的二次确认 |
|
|
|
|
|
await message.delConfirm() |
|
|
|
|
|
// 发起删除 |
|
|
|
|
|
await ItemApi.deleteItem(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 ItemApi.exportItem(tableObject.params) |
|
|
|
|
|
download.excel(data, '备件.xlsx') |
|
|
|
|
|
} catch { |
|
|
|
|
|
} finally { |
|
|
|
|
|
exportLoading.value = false |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 筛选提交 |
|
|
/** 导出按钮操作 */ |
|
|
const searchFormClick = (searchData) => { |
|
|
const exportLoading = ref(false) // 导出的加载中 |
|
|
tableObject.params = { |
|
|
const handleExport = async () => { |
|
|
isSearch: true, |
|
|
try { |
|
|
filters: searchData.filters |
|
|
// 导出的二次确认 |
|
|
|
|
|
await message.exportConfirm() |
|
|
|
|
|
// 发起导出 |
|
|
|
|
|
exportLoading.value = true |
|
|
|
|
|
const data = await ItemApi.exportItem(tableObject.params) |
|
|
|
|
|
download.excel(data, '备件.xlsx') |
|
|
|
|
|
} catch { |
|
|
|
|
|
} finally { |
|
|
|
|
|
exportLoading.value = false |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
getList() // 刷新当前列表 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 初始化 **/ |
|
|
// 筛选提交 |
|
|
onMounted(async () => { |
|
|
const searchFormClick = (searchData) => { |
|
|
getList() |
|
|
tableObject.params = { |
|
|
}) |
|
|
isSearch: true, |
|
|
|
|
|
filters: searchData.filters |
|
|
|
|
|
} |
|
|
|
|
|
getList() // 刷新当前列表 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 初始化 **/ |
|
|
|
|
|
onMounted(async () => { |
|
|
|
|
|
getList() |
|
|
|
|
|
}) |
|
|
</script> |
|
|
</script> |
|
|