|
|
@ -1,7 +1,11 @@ |
|
|
|
<template> |
|
|
|
<ContentWrap> |
|
|
|
<!-- 搜索工作栏 --> |
|
|
|
<Search :schema="DeviceAccounts.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> |
|
|
|
<Search |
|
|
|
:schema="DeviceAccounts.allSchemas.searchSchema" |
|
|
|
@search="setSearchParams" |
|
|
|
@reset="setSearchParams" |
|
|
|
/> |
|
|
|
</ContentWrap> |
|
|
|
|
|
|
|
<!-- 列表头部 --> |
|
|
@ -27,13 +31,13 @@ |
|
|
|
v-model:currentPage="tableObject.currentPage" |
|
|
|
v-model:sort="tableObject.sort" |
|
|
|
> |
|
|
|
<template #number="{row}"> |
|
|
|
<template #number="{ row }"> |
|
|
|
<el-button type="primary" link @click="openDetail(row, '编号', row.number)"> |
|
|
|
<span>{{ row.number }}</span> |
|
|
|
</el-button> |
|
|
|
</template> |
|
|
|
<template #action="{ row }"> |
|
|
|
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" /> |
|
|
|
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event, row)" /> |
|
|
|
</template> |
|
|
|
</Table> |
|
|
|
</ContentWrap> |
|
|
@ -50,17 +54,13 @@ |
|
|
|
:isBusiness="false" |
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<SearchTable |
|
|
|
ref="searchTableRef" |
|
|
|
@searchTableSuccess="submitItem" |
|
|
|
|
|
|
|
/> |
|
|
|
<SearchTable ref="searchTableRef" @searchTableSuccess="submitItem" /> |
|
|
|
|
|
|
|
<!-- 详情 --> |
|
|
|
<DetailDeviceLedger |
|
|
|
ref="detailRef" |
|
|
|
:tabs="DeviceLedgerTabsList" |
|
|
|
:subTabs="DeviceLedgerSubTabsList" |
|
|
|
:isBasic="true" |
|
|
|
:allSchemas="allSchemas" |
|
|
|
@changeTabs="changeTabs" |
|
|
@ -68,24 +68,47 @@ |
|
|
|
:apiPage="apiPage" |
|
|
|
:tabsExtend="tabsExtend" |
|
|
|
:tableObjectExtend="tableObjectExtend" |
|
|
|
:imageFormAllSchemas="UpImage.allSchemas" |
|
|
|
:upImageRules="UpImageRules" |
|
|
|
:fileFormAllSchemas="UploadFile.allSchemas" |
|
|
|
:upFileRules="UpFileRules" |
|
|
|
@uploadImage="uploadImage" |
|
|
|
@subTabsChick="subTabsChick" |
|
|
|
@uploadFile="uploadFile" |
|
|
|
/> |
|
|
|
|
|
|
|
<!-- 导入 --> |
|
|
|
<ImportForm ref="importFormRef" url="/eam/device-accounts/import" :importTemplateData="importTemplateData" @success="importSuccess" /> |
|
|
|
<ImportForm |
|
|
|
ref="importFormRef" |
|
|
|
url="/eam/device-accounts/import" |
|
|
|
:importTemplateData="importTemplateData" |
|
|
|
@success="importSuccess" |
|
|
|
/> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup lang="ts"> |
|
|
|
import download from '@/utils/download' |
|
|
|
import { DeviceAccounts, DeviceAccountsRules } from './deviceAccounts.data' |
|
|
|
import { |
|
|
|
DeviceAccounts, |
|
|
|
DeviceAccountsRules, |
|
|
|
UpImage, |
|
|
|
UpImageRules, |
|
|
|
UploadFile, |
|
|
|
UpFileRules |
|
|
|
} from './deviceAccounts.data' |
|
|
|
import { Item } from '@/views/eam/basic/item/item.data' |
|
|
|
import { createDeviceItemBatch,getDeviceItemPage } from '@/api/eam/basic/rel' |
|
|
|
import * as ItemApi from '@/api/eam/basic/item' |
|
|
|
import { createDeviceItemBatch, getDeviceItemPage } from '@/api/eam/basic/rel' |
|
|
|
import * as DeviceAccountsApi from '@/api/eam/device/deviceAccounts' |
|
|
|
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|
|
|
import { DeviceLedgerTabsList } from '@/utils/disposition/tabsList' |
|
|
|
import TableHead from '@/components/TableHead/src/TableHead.vue' |
|
|
|
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' |
|
|
|
import DetailDeviceLedger from '@/components/Detail/src/DetailDeviceLedger.vue' |
|
|
|
import * as ItemApi from '@/api/eam/basic/item' |
|
|
|
import { DeviceRepair } from '@/views/eam/device/deviceRepair/deviceRepair.data' |
|
|
|
import * as deviceRepairApi from '@/api/eam/device/deviceRepair' |
|
|
|
import * as uploadApi from '@/api/eam/upload' |
|
|
|
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict' |
|
|
|
|
|
|
|
defineOptions({ name: 'DeviceAccounts' }) |
|
|
|
|
|
|
@ -94,13 +117,15 @@ const { t } = useI18n() // 国际化 |
|
|
|
|
|
|
|
const route = useRoute() // 路由信息 |
|
|
|
const routeName = ref() |
|
|
|
const deviceNumber = ref(); |
|
|
|
const deviceNumber = ref() |
|
|
|
routeName.value = route.name |
|
|
|
const tableColumns = ref(DeviceAccounts.allSchemas.tableColumns) |
|
|
|
|
|
|
|
const allSchemas = ref(Item.allSchemas) |
|
|
|
const allSchemas = ref(DeviceAccounts.allSchemas) |
|
|
|
const detailAllSchemas = ref() |
|
|
|
const apiPage = ref() |
|
|
|
const itemCodeRow = ref() |
|
|
|
const tableObjectExtend = ref() |
|
|
|
|
|
|
|
// 查询页面返回 |
|
|
|
const searchTableSuccess = (formField, searchField, val, formRef) => { |
|
|
@ -130,7 +155,7 @@ const HeadButttondata = [ |
|
|
|
defaultButtons.defaultExportBtn(null), // 导出 |
|
|
|
defaultButtons.defaultFreshBtn(null), // 刷新 |
|
|
|
defaultButtons.defaultFilterBtn(null), // 筛选 |
|
|
|
defaultButtons.defaultSetBtn(null), // 设置 |
|
|
|
defaultButtons.defaultSetBtn(null) // 设置 |
|
|
|
// { |
|
|
|
// label: '自定义扩展按钮', |
|
|
|
// name: 'zdy', |
|
|
@ -143,16 +168,22 @@ const HeadButttondata = [ |
|
|
|
|
|
|
|
// 头部按钮事件 |
|
|
|
const buttonBaseClick = (val, item) => { |
|
|
|
if (val == 'add') { // 新增 |
|
|
|
if (val == 'add') { |
|
|
|
// 新增 |
|
|
|
openForm('create') |
|
|
|
} else if (val == 'import') { // 导入 |
|
|
|
} else if (val == 'import') { |
|
|
|
// 导入 |
|
|
|
handleImport() |
|
|
|
} else if (val == 'export') { // 导出 |
|
|
|
} else if (val == 'export') { |
|
|
|
// 导出 |
|
|
|
handleExport() |
|
|
|
} else if (val == 'refresh') { // 刷新 |
|
|
|
} else if (val == 'refresh') { |
|
|
|
// 刷新 |
|
|
|
getList() |
|
|
|
} else if (val == 'filtrate') { // 筛选 |
|
|
|
} else { // 其他按钮 |
|
|
|
} else if (val == 'filtrate') { |
|
|
|
// 筛选 |
|
|
|
} else { |
|
|
|
// 其他按钮 |
|
|
|
console.log('其他按钮', item) |
|
|
|
} |
|
|
|
} |
|
|
@ -161,15 +192,17 @@ const buttonBaseClick = (val, item) => { |
|
|
|
const butttondata = [ |
|
|
|
defaultButtons.mainListEditBtn(null), // 编辑 |
|
|
|
// defaultButtons.mainListDeleteBtn(null), // 删除 |
|
|
|
defaultButtons.selectQrCodeBtn(null),//二维码 |
|
|
|
defaultButtons.selectItemBtn(null),//备件 |
|
|
|
defaultButtons.selectQrCodeBtn(null), //二维码 |
|
|
|
defaultButtons.selectItemBtn(null) //备件 |
|
|
|
] |
|
|
|
|
|
|
|
// 列表-操作按钮事件 |
|
|
|
const buttonTableClick = async (val, row) => { |
|
|
|
if (val == 'edit') { // 编辑 |
|
|
|
if (val == 'edit') { |
|
|
|
// 编辑 |
|
|
|
openForm('update', row) |
|
|
|
} else if (val == 'selectQrCode') { // 二维码 |
|
|
|
} else if (val == 'selectQrCode') { |
|
|
|
// 二维码 |
|
|
|
openQrCode(row.number) |
|
|
|
} else if (val == 'selectItem') { |
|
|
|
openItem(row.number) |
|
|
@ -179,23 +212,22 @@ const buttonTableClick = async (val, row) => { |
|
|
|
/** 添加/修改操作 */ |
|
|
|
const basicFormRef = ref() |
|
|
|
const openForm = (type: string, row?: any) => { |
|
|
|
|
|
|
|
basicFormRef.value.open(type, row) |
|
|
|
} |
|
|
|
|
|
|
|
// form表单提交 |
|
|
|
const formsSuccess = async (formType,data) => { |
|
|
|
var isHave =DeviceAccounts.allSchemas.formSchema.some(function (item) { |
|
|
|
return item.field === 'activeTime' || item.field === 'expireTime'; |
|
|
|
}); |
|
|
|
if(isHave){ |
|
|
|
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){ |
|
|
|
const formsSuccess = async (formType, data) => { |
|
|
|
var isHave = DeviceAccounts.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; |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
if(data.activeTime==0)data.activeTime = null; |
|
|
|
if(data.expireTime==0)data.expireTime = null; |
|
|
|
if (data.activeTime == 0) data.activeTime = null |
|
|
|
if (data.expireTime == 0) data.expireTime = null |
|
|
|
if (formType === 'create') { |
|
|
|
await DeviceAccountsApi.createDeviceAccounts(data) |
|
|
|
message.success(t('common.createSuccess')) |
|
|
@ -210,6 +242,7 @@ const formsSuccess = async (formType,data) => { |
|
|
|
/** 详情操作 */ |
|
|
|
const detailRef = ref() |
|
|
|
const openDetail = (row: any, titleName: any, titleValue: any) => { |
|
|
|
itemCodeRow.value = row.number |
|
|
|
detailRef.value.openDetail(row, titleName, titleValue, 'basicDeviceAccounts') |
|
|
|
} |
|
|
|
|
|
|
@ -266,13 +299,85 @@ const searchFormClick = (searchData) => { |
|
|
|
getList() // 刷新当前列表 |
|
|
|
} |
|
|
|
|
|
|
|
const DeviceLedgerSubTabsList = getStrDictOptions(DICT_TYPE.DEVICE_DOC_TYPE) |
|
|
|
const tabsExtend = ref() |
|
|
|
const funcCode = ref('device_mould_picture') |
|
|
|
// tabs 切换事件 |
|
|
|
const changeTabs = (item) => { |
|
|
|
if (item.prop == 'Image') { |
|
|
|
tabsExtend.value = 1 |
|
|
|
funcCode.value = 'device_mould_picture' |
|
|
|
// apiPage.value = CustomeritemApi.getCustomeritemPage |
|
|
|
// detailAllSchemas.value = Customeritem.allSchemas |
|
|
|
} else if (item.prop == 'Word') { |
|
|
|
tabsExtend.value = 2 |
|
|
|
funcCode.value = 'device_mould_attachment' |
|
|
|
apiPage.value = PurchaseDetailApi.getPurchaseDetailPage |
|
|
|
detailAllSchemas.value = PurchaseMain.allSchemas |
|
|
|
} else if (item.prop == 'Part') { |
|
|
|
tabsExtend.value = 3 |
|
|
|
apiPage.value = deviceRepairApi.getDeviceRepairPage |
|
|
|
detailAllSchemas.value = DeviceRepair.allSchemas |
|
|
|
} else if (item.prop == 'DeviceReportRecord') { |
|
|
|
tabsExtend.value = 3 |
|
|
|
apiPage.value = BalanceApi.getBalancePage |
|
|
|
detailAllSchemas.value = Balance.allSchemas |
|
|
|
} else if (item.prop == 'RepairRecord') { |
|
|
|
tabsExtend.value = 3 |
|
|
|
apiPage.value = ExpectinApi.getExpectinPage |
|
|
|
detailAllSchemas.value = Expectin.allSchemas |
|
|
|
} else if (item.prop == 'MaintenanceRecord') { |
|
|
|
tabsExtend.value = 3 |
|
|
|
apiPage.value = ExpectinApi.getExpectinPage |
|
|
|
detailAllSchemas.value = Expectin.allSchemas |
|
|
|
} |
|
|
|
detailAllSchemas.value.tableColumns.map((item, index) => { |
|
|
|
if (item.field == 'action') { |
|
|
|
detailAllSchemas.value.tableColumns.splice(index, 1) |
|
|
|
} |
|
|
|
}) |
|
|
|
// 当前物料代码作为条件 |
|
|
|
tableObjectExtend.value = [ |
|
|
|
{ |
|
|
|
key: 'itemCode', |
|
|
|
value: itemCodeRow.value |
|
|
|
} |
|
|
|
] |
|
|
|
} |
|
|
|
const uploadImage = (number, filePath, fileBusiType) => { |
|
|
|
let data = { |
|
|
|
number, |
|
|
|
filePathList: filePath, |
|
|
|
funcCode: funcCode.value, |
|
|
|
fileBusiType: fileBusiType ? fileBusiType : '' |
|
|
|
} |
|
|
|
uploadApi.uploadImage(data).then((res) => { |
|
|
|
console.log(res) |
|
|
|
}) |
|
|
|
} |
|
|
|
// 二级切换事件 |
|
|
|
const fileBusiType = ref() |
|
|
|
const subTabsChick = (e) => { |
|
|
|
fileBusiType.value = e |
|
|
|
} |
|
|
|
// 上传文件 |
|
|
|
const uploadFile = (number, filePath, fileBusiType) => { |
|
|
|
let data = { |
|
|
|
number, |
|
|
|
filePathList: filePath, |
|
|
|
funcCode: funcCode.value, |
|
|
|
fileBusiType: fileBusiType ? fileBusiType : '' |
|
|
|
} |
|
|
|
uploadApi.uploadImage(data).then((res) => { |
|
|
|
console.log(res) |
|
|
|
}) |
|
|
|
} |
|
|
|
/** 初始化 **/ |
|
|
|
onMounted(async () => { |
|
|
|
getList() |
|
|
|
importTemplateData.templateUrl = await DeviceAccountsApi.importTemplate() |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
/** 二维码 */ |
|
|
|
const openQrCode = async (number: String) => { |
|
|
|
// const data = await DeviceAccountsApi.getQrCode(number) |
|
|
@ -297,26 +402,37 @@ const openQrCode = async (number: String) => { |
|
|
|
const searchTableRef = ref() |
|
|
|
/** 绑定备件操作 */ |
|
|
|
const openItem = async (number: String) => { |
|
|
|
deviceNumber.value = number; |
|
|
|
searchTableRef.value.open("选择备件",Item.allSchemas,getDeviceItemList,null,Item.allSchemas.searchSchema,true,null, null, null, null); |
|
|
|
deviceNumber.value = number |
|
|
|
searchTableRef.value.open( |
|
|
|
'选择备件', |
|
|
|
Item.allSchemas, |
|
|
|
getDeviceItemList, |
|
|
|
null, |
|
|
|
Item.allSchemas.searchSchema, |
|
|
|
true, |
|
|
|
null, |
|
|
|
null, |
|
|
|
null, |
|
|
|
null |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
const submitItem = async (formFieldRef, searchFieldRef, selections, typeRef, rowRef) => { |
|
|
|
const deviceItemRelList = selections.map(element => ({ |
|
|
|
const deviceItemRelList = selections.map((element) => ({ |
|
|
|
deviceNumber: deviceNumber.value, |
|
|
|
itemNumber: element.number, |
|
|
|
})); |
|
|
|
createDeviceItemBatch(deviceItemRelList).then(res => { |
|
|
|
console.log('res', res); |
|
|
|
itemNumber: element.number |
|
|
|
})) |
|
|
|
createDeviceItemBatch(deviceItemRelList).then((res) => { |
|
|
|
console.log('res', res) |
|
|
|
}) |
|
|
|
console.log('deviceItemRelList', deviceItemRelList); |
|
|
|
}; |
|
|
|
console.log('deviceItemRelList', deviceItemRelList) |
|
|
|
} |
|
|
|
|
|
|
|
const getItemWithOutBind = async () => { |
|
|
|
try { |
|
|
|
const res = await ItemApi.getItemPage({ |
|
|
|
...Item.allSchemas.searchSchema |
|
|
|
}); |
|
|
|
}) |
|
|
|
if (res.list?.length > 0) { |
|
|
|
// const response = await getDeviceItemPage(DeviceAccounts.allSchemas.searchSchema); |
|
|
|
// const filteredList = res.list.filter(item => { |
|
|
@ -325,32 +441,30 @@ const getItemWithOutBind = async () => { |
|
|
|
// }); |
|
|
|
// }); |
|
|
|
// console.log('filteredList',filteredList); |
|
|
|
const filteredList = res.list; |
|
|
|
return filteredList; // 返回过滤后的列表 |
|
|
|
const filteredList = res.list |
|
|
|
return filteredList // 返回过滤后的列表 |
|
|
|
} |
|
|
|
return []; // 如果没有数据,返回空数组 |
|
|
|
return [] // 如果没有数据,返回空数组 |
|
|
|
} catch (error) { |
|
|
|
console.error(error); |
|
|
|
throw error; // 抛出错误 |
|
|
|
console.error(error) |
|
|
|
throw error // 抛出错误 |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
// 将 getListApi 替换为 getItemWithOutBind |
|
|
|
const getDeviceItemList = async () => { |
|
|
|
tableObject.loading = true; |
|
|
|
tableObject.loading = true |
|
|
|
try { |
|
|
|
const res = await getItemWithOutBind(); |
|
|
|
const res = await getItemWithOutBind() |
|
|
|
let result = { |
|
|
|
list : res, |
|
|
|
total : res.length, |
|
|
|
list: res, |
|
|
|
total: res.length |
|
|
|
} |
|
|
|
return result; |
|
|
|
return result |
|
|
|
} catch (error) { |
|
|
|
console.error(error); |
|
|
|
console.error(error) |
|
|
|
} finally { |
|
|
|
tableObject.loading = false; |
|
|
|
tableObject.loading = false |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
</script> |
|
|
|