|
|
@ -30,18 +30,18 @@ |
|
|
|
:apiUpdate="ItemApi.updateItem" :apiCreate="ItemApi.createItem" @searchTableSuccess="searchTableSuccess" |
|
|
|
:isBusiness="false" /> |
|
|
|
|
|
|
|
<SearchTable ref="searchTableRef" @searchTableSuccess="submitItem" /> |
|
|
|
|
|
|
|
<!-- 详情 --> |
|
|
|
<Detail ref="detailRef" :isBasic="true" :allSchemas="Item.allSchemas" /> |
|
|
|
|
|
|
|
<!-- 选择设备 --> |
|
|
|
<SearchTable ref="searchTableRef" @success="formsSuccess" :formAllSchemas="Item.allSchemas" |
|
|
|
@searchTableSuccess="searchTableSuccess" /> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup lang="ts"> |
|
|
|
import download from '@/utils/download' |
|
|
|
import { Item, ItemRules } from './item.data' |
|
|
|
import * as ItemApi from '@/api/eam/basic/item' |
|
|
|
import { createDeviceItemBatch, getDeviceItemPage } from '@/api/eam/basic/rel' |
|
|
|
import { DeviceAccounts, DeviceAccountsRules } from '@/views/eam/device/deviceAccounts/deviceAccounts.data' |
|
|
|
import * as DeviceAccountsApi from '@/api/eam/device/deviceAccounts' |
|
|
|
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|
|
@ -54,34 +54,19 @@ |
|
|
|
|
|
|
|
const message = useMessage() // 消息弹窗 |
|
|
|
const { t } = useI18n() // 国际化 |
|
|
|
|
|
|
|
const route = useRoute() // 路由信息 |
|
|
|
const routeName = ref() |
|
|
|
routeName.value = route.name |
|
|
|
const itemNumber = ref(); |
|
|
|
const tableColumns = ref(Item.allSchemas.tableColumns) |
|
|
|
|
|
|
|
|
|
|
|
const paramNumber = ref([]) |
|
|
|
// 查询页面返回 |
|
|
|
const searchTableSuccess = (formField, searchField, val, formRef) => { |
|
|
|
// console.log(formField); |
|
|
|
// console.log(val); |
|
|
|
let dataResult = []; |
|
|
|
let param = []; |
|
|
|
val.forEach((element) => { |
|
|
|
dataResult.push(element.number); |
|
|
|
nextTick(() => { |
|
|
|
const setV = {} |
|
|
|
setV[formField] = val[0][searchField] |
|
|
|
formRef.setValues(setV) |
|
|
|
}) |
|
|
|
paramNumber.value.push(formField, dataResult); |
|
|
|
ItemApi.genDevice(paramNumber.value); |
|
|
|
message.success(t('common.delSuccess ')) |
|
|
|
// 刷新列表 |
|
|
|
getList() |
|
|
|
|
|
|
|
// nextTick(() => { |
|
|
|
// const setV = {} |
|
|
|
// setV[formField] = val[0][searchField] |
|
|
|
// formRef.setValues(setV) |
|
|
|
// }) |
|
|
|
} |
|
|
|
|
|
|
|
// 字段设置 更新主列表字段 |
|
|
@ -100,18 +85,9 @@ |
|
|
|
const HeadButttondata = [ |
|
|
|
// defaultButtons.defaultAddBtn(null), // 新增 |
|
|
|
defaultButtons.defaultExportBtn(null), // 导出 |
|
|
|
|
|
|
|
defaultButtons.defaultFreshBtn(null), // 刷新 |
|
|
|
defaultButtons.defaultFilterBtn(null), // 筛选 |
|
|
|
defaultButtons.defaultSetBtn(null), // 设置 |
|
|
|
// { |
|
|
|
// label: '自定义扩展按钮', |
|
|
|
// name: 'zdy', |
|
|
|
// hide: false, |
|
|
|
// type: 'primary', |
|
|
|
// icon: 'Select', |
|
|
|
// color: '' |
|
|
|
// }, |
|
|
|
] |
|
|
|
|
|
|
|
// 头部按钮事件 |
|
|
@ -131,7 +107,7 @@ |
|
|
|
// 列表-操作按钮 |
|
|
|
const butttondata = [ |
|
|
|
defaultButtons.mainListEditBtn(null), // 编辑 |
|
|
|
defaultButtons.selectDeviceBtn(null), // 选择设备 |
|
|
|
defaultButtons.chooseDeviceBtn(null),//备件 |
|
|
|
defaultButtons.mainListDeleteBtn(null), // 删除 |
|
|
|
] |
|
|
|
|
|
|
@ -139,21 +115,30 @@ |
|
|
|
const buttonTableClick = async (val, row) => { |
|
|
|
if (val == 'edit') { // 编辑 |
|
|
|
openForm('update', row) |
|
|
|
} else if (val == 'selectDevice') { // 筛选 |
|
|
|
selectDevice(row) |
|
|
|
} else if (val == 'chooseDevice') { |
|
|
|
openItem(row.number) |
|
|
|
} else if (val == 'delete') { // 删除 |
|
|
|
handleDelete(row.id) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** 添加设备操作 */ |
|
|
|
// (titleName: any, allSchemas: any,getApiPage: any, formField: any, searchField: any,multiple: any, type: any, row: any, searchCondition:any , isCountRequestRe:any ) |
|
|
|
const searchTableRef = ref() |
|
|
|
const selectDevice = (row) => { |
|
|
|
searchTableRef.value.open('设备列表11', DeviceAccounts.allSchemas, DeviceAccountsApi.getDeviceAccountsPage, row.number, '', true, '', ''); |
|
|
|
// ItemApi.createItem(row) |
|
|
|
const openItem = (number : String) => { |
|
|
|
itemNumber.value = number; |
|
|
|
searchTableRef.value.open('设备列表', DeviceAccounts.allSchemas, DeviceAccountsApi.getDeviceAccountsPage, null, Item.allSchemas.searchSchema, true, null, null, null, null); |
|
|
|
} |
|
|
|
|
|
|
|
const submitItem = async (formFieldRef, searchFieldRef, selections, typeRef, rowRef) => { |
|
|
|
const deviceItemRelList = selections.map(element => ({ |
|
|
|
itemNumber: itemNumber.value, |
|
|
|
deviceNumber: element.number, |
|
|
|
})); |
|
|
|
createDeviceItemBatch(deviceItemRelList).then(res => { |
|
|
|
message.success(t('common.createSuccess')) |
|
|
|
}) |
|
|
|
}; |
|
|
|
|
|
|
|
/** 添加/修改操作 */ |
|
|
|
const basicFormRef = ref() |
|
|
|
const openForm = (type : string, row ?: any) => { |
|
|
|