Browse Source

BUG修改

master
yejiaxing 10 months ago
parent
commit
45c9f6621a
  1. 13
      src/utils/disposition/defaultButtons.ts
  2. 361
      src/views/eam/basic/item/index.vue
  3. 2
      src/views/eam/basic/item/item.data.ts

13
src/utils/disposition/defaultButtons.ts

@ -735,6 +735,19 @@ export function mainThawRequesttBtn(option:any) {
hasPermi: '' hasPermi: ''
}) })
} }
// 主列表-选择设备
export function selectDeviceBtn(option:any) {
return __defaultBtnOption(option,{
label: '选择设备',
name: 'selectDevice',
hide: false,
type: 'primary',
color: '',
link: true, // 文本展现按钮
hasPermi: ''
})
}
// 默认按钮规则 // 默认按钮规则
function __defaultBtnOption(option:any,specific:any){ function __defaultBtnOption(option:any,specific:any){
return { return {

361
src/views/eam/basic/item/index.vue

@ -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>

2
src/views/eam/basic/item/item.data.ts

@ -169,7 +169,7 @@ export const Item = useCrudSchemas(reactive<CrudSchema[]>([
field: 'action', field: 'action',
isForm: false, isForm: false,
table: { table: {
width: 150, width: 180,
fixed: 'right' fixed: 'right'
} }
} }

Loading…
Cancel
Save