Browse Source

备件管理 备件台账添加图片

master
songguoqiang 7 months ago
parent
commit
d943bd6112
  1. 472
      src/views/eam/basic/item/index.vue
  2. 33
      src/views/eam/basic/item/item.data.ts
  3. 541
      src/views/eam/item/itemAccounts/index.vue

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

@ -1,250 +1,326 @@
<template> <template>
<ContentWrap> <ContentWrap>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<Search :schema="Item.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> <Search
:schema="Item.allSchemas.searchSchema"
@search="setSearchParams"
@reset="setSearchParams"
/>
</ContentWrap> </ContentWrap>
<!-- 列表头部 --> <!-- 列表头部 -->
<TableHead :HeadButttondata="HeadButttondata" @button-base-click="buttonBaseClick" :routeName="routeName" <TableHead
@updataTableColumns="updataTableColumns" @searchFormClick="searchFormClick" :allSchemas="Item.allSchemas" /> :HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="Item.allSchemas"
/>
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<Table :columns="tableColumns" :data="tableObject.tableList" :loading="tableObject.loading" :pagination="{ <Table
: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:sort="tableObject.sort"> v-model:pageSize="tableObject.pageSize"
<template #code="{row}"> v-model:currentPage="tableObject.currentPage"
v-model:sort="tableObject.sort"
>
<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>
</el-button> </el-button>
</template> </template>
<template #action="{ row }"> <template #action="{ row }">
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" /> <ButtonBase :Butttondata="butttondata(row)" @button-base-click="buttonTableClick($event, row)" />
</template> </template>
</Table> </Table>
</ContentWrap> </ContentWrap>
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<BasicForm ref="basicFormRef" @success="formsSuccess" :rules="ItemRules" :formAllSchemas="Item.allSchemas" <BasicForm
:apiUpdate="ItemApi.updateItem" :apiCreate="ItemApi.createItem" @searchTableSuccess="searchTableSuccess" ref="basicFormRef"
:isBusiness="false" /> @success="formsSuccess"
:rules="ItemRules"
:formAllSchemas="Item.allSchemas"
:apiUpdate="ItemApi.updateItem"
:apiCreate="ItemApi.createItem"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/>
<SearchTable ref="searchTableRef" @searchTableSuccess="submitItem" /> <SearchTable ref="searchTableRef" @searchTableSuccess="submitItem" />
<!-- 详情 --> <!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="Item.allSchemas" /> <Detail ref="detailRef" :isBasic="true" :allSchemas="Item.allSchemas" />
<Dialog
ref="basicFormViewRef"
v-model="showView"
:key="viewKey"
:closeOnClickModal="true"
:title="viewTitle"
>
<el-image v-for="url in urls" :key="url" :src="url" lazy />
</Dialog>
</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 { createDeviceItemBatch, getDeviceItemPage, getDeviceItemNoPage } from '@/api/eam/basic/rel' import { createDeviceItemBatch, getDeviceItemPage, getDeviceItemNoPage } from '@/api/eam/basic/rel'
import { DeviceAccounts, DeviceAccountsRules } from '@/views/eam/device/deviceAccounts/deviceAccounts.data' import {
import * as DeviceAccountsApi from '@/api/eam/device/deviceAccounts' DeviceAccounts,
import * as defaultButtons from '@/utils/disposition/defaultButtons' DeviceAccountsRules
import TableHead from '@/components/TableHead/src/TableHead.vue' } from '@/views/eam/device/deviceAccounts/deviceAccounts.data'
// import ImportForm from '@/components/ImportForm/src/ImportForm.vue' import * as DeviceAccountsApi from '@/api/eam/device/deviceAccounts'
import Detail from '@/components/Detail/src/Detail.vue' import * as defaultButtons from '@/utils/disposition/defaultButtons'
import { SearchTable } from '@/components/SearchTable' 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'
import { SearchTable } from '@/components/SearchTable'
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 searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
})
}
// defineOptions({ name: 'Item' })
const updataTableColumns = (val) => {
tableColumns.value = val
}
const { tableObject, tableMethods } = useTable({ const message = useMessage() //
getListApi: ItemApi.getItemPage // const { t } = useI18n() //
const route = useRoute() //
const routeName = ref()
routeName.value = route.name
const itemNumber = ref()
const tableColumns = ref(Item.allSchemas.tableColumns)
const showView = ref(false)
const viewTitle = ref('图片预览')
const urls = ref([])
const viewKey = ref(0)
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
}) })
}
// //
const { getList, setSearchParams } = tableMethods const updataTableColumns = (val) => {
tableColumns.value = val
// }
const HeadButttondata = [
defaultButtons.defaultAddBtn({hasPermi:'basic:item:create'}), //
defaultButtons.defaultExportBtn({hasPermi:'basic:item:export'}), //
defaultButtons.defaultFreshBtn(null), //
defaultButtons.defaultFilterBtn(null), //
defaultButtons.defaultSetBtn(null), //
]
//
const buttonBaseClick = (val, 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 { tableObject, tableMethods } = useTable({
const butttondata = [ getListApi: ItemApi.getItemPage //
defaultButtons.mainListEditBtn({hasPermi:'basic:item:update'}), // })
defaultButtons.chooseDeviceBtn({hasPermi:'basic:item:choose'}),//
defaultButtons.mainListDeleteBtn({hasPermi:'basic:item:delete'}), // //
] const { getList, setSearchParams } = tableMethods
// - //
const buttonTableClick = async (val, row) => { const HeadButttondata =[
if (val == 'edit') { // defaultButtons.defaultAddBtn({ hasPermi: 'basic:item:create' }), //
openForm('update', row) defaultButtons.defaultExportBtn({ hasPermi: 'basic:item:export' }), //
} else if (val == 'chooseDevice') { defaultButtons.defaultFreshBtn(null), //
openItem(row.number) defaultButtons.defaultFilterBtn(null), //
} else if (val == 'delete') { // defaultButtons.defaultSetBtn(null) //
handleDelete(row.id) ]
}
//
const buttonBaseClick = (val, 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 butttondataView = (row) => {
return [defaultButtons.viewBtn(null)]
}
// -
const butttondata =(row)=>{
return [
defaultButtons.mainListEditBtn({ hasPermi: 'basic:item:update' }), //
defaultButtons.chooseDeviceBtn({ hasPermi: 'basic:item:choose' }), //
defaultButtons.mainListDeleteBtn({ hasPermi: 'basic:item:delete' }), //
defaultButtons.viewBtn({hide: !(row.filePathList != null && row.filePathList.length != 0 )})
]}
const searchTableRef = ref() // -
/** 绑定备件操作 */ const buttonTableClick = async (val, row) => {
const openItem = async (number : String) => { if (val == 'edit') {
itemNumber.value = number //
await CallBack1() openForm('update', row)
searchTableRef.value.open( } else if (val == 'chooseDevice') {
'选择设备', openItem(row.number)
DeviceAccounts.allSchemas, } else if (val == 'delete') {
DeviceAccountsApi.getDeviceAccountsPage, //
null, handleDelete(row.id)
DeviceAccounts.allSchemas.searchSchema, } else if (val == 'view') {
true, //
null, openForm('view', row)
null,
null,
null,
searchTableSelections.value
)
} }
}
const searchTableRef = ref()
/** 绑定备件操作 */
const openItem = async (number: String) => {
itemNumber.value = number
await CallBack1()
searchTableRef.value.open(
'选择设备',
DeviceAccounts.allSchemas,
DeviceAccountsApi.getDeviceAccountsPage,
null,
DeviceAccounts.allSchemas.searchSchema,
true,
null,
null,
null,
null,
searchTableSelections.value
)
}
const searchTableSelections = ref([]) const searchTableSelections = ref([])
const CallBack1 = async () => { const CallBack1 = async () => {
await getDeviceItemNoPage({ itemNumber: itemNumber.value }).then(async (res) => { await getDeviceItemNoPage({ itemNumber: itemNumber.value }).then(async (res) => {
await DeviceAccountsApi.getDeviceAccountsAllNoPage({}).then(response => { await DeviceAccountsApi.getDeviceAccountsAllNoPage({}).then((response) => {
searchTableSelections.value = response.filter(element => { searchTableSelections.value = response.filter((element) => {
let flag = false; let flag = false
res.forEach(item => { res.forEach((item) => {
if (element.number == item.deviceNumber) { if (element.number == item.deviceNumber) {
flag = true; flag = true
} }
}); })
return flag; return flag
}); })
});
});
};
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 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 basicFormRef = ref()
const openForm = (type : string, row ?: any) => { const openForm = (type: string, row?: any) => {
console.log(row)
if (type == 'view') {
showView.value = true
urls.value = row.filePathList
viewKey.value += 1
} else {
if (row && row.filePathList && row.filePathList.length > 0) {
row.filePathListView = row.filePathList.map((item) => {
return {
name: item,
url: item
}
})
}
basicFormRef.value.open(type, row) basicFormRef.value.open(type, row)
} }
}
// form // form
const formsSuccess = async (formType, data) => { const formsSuccess = async (formType, data) => {
var isHave = Item.allSchemas.formSchema.some(function (item) { var isHave = Item.allSchemas.formSchema.some(function (item) {
return item.field === 'activeTime' || item.field === 'expireTime'; return item.field === 'activeTime' || item.field === 'expireTime'
}); })
if (isHave) { if (isHave) {
if (data.activeTime && data.expireTime && data.activeTime >= data.expireTime) { if (data.activeTime && data.expireTime && data.activeTime >= data.expireTime) {
message.error('失效时间要大于生效时间') message.error('失效时间要大于生效时间')
return; 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
const detailRef = ref() data.filePathList = []
const openDetail = (row : any, titleName : any, titleValue : any) => { for (let i = 0; i < data.filePathListView.length; i++) {
detailRef.value.openDetail(row, titleName, titleValue, 'basicItem') data.filePathList.push(data.filePathListView[i].url)
} }
if (formType === 'create') {
/** 删除按钮操作 */ await ItemApi.createItem(data)
const handleDelete = async (id : number) => { message.success(t('common.createSuccess'))
try { } else {
// await ItemApi.updateItem(data)
await message.delConfirm() message.success(t('common.updateSuccess'))
//
await ItemApi.deleteItem(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch { }
} }
basicFormRef.value.dialogVisible = false
getList()
}
/** 导出按钮操作 */ /** 详情操作 */
const exportLoading = ref(false) // const detailRef = ref()
const handleExport = async () => { const openDetail = (row: any, titleName: any, titleValue: any) => {
try { detailRef.value.openDetail(row, titleName, titleValue, 'basicItem')
// }
await message.exportConfirm()
// /** 删除按钮操作 */
exportLoading.value = true const handleDelete = async (id: number) => {
const data = await ItemApi.exportItem(tableObject.params) try {
download.excel(data, '备件.xlsx') //
} catch { await message.delConfirm()
} finally { //
exportLoading.value = false 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 searchFormClick = (searchData) => {
tableObject.params = { tableObject.params = {
isSearch: true, isSearch: true,
filters: searchData.filters filters: searchData.filters
}
getList() //
} }
getList() //
}
/** 初始化 **/ /** 初始化 **/
onMounted(async () => { onMounted(async () => {
getList() getList()
}) })
</script> </script>

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

@ -274,6 +274,39 @@ export const Item = useCrudSchemas(reactive<CrudSchema[]>([
field: 'describes', field: 'describes',
sort: 'custom', sort: 'custom',
}, },
{
label: '图片',
field: 'upload',
isTable: true,
},
{
label: '文件',
field: 'filePathListView',
sort: 'custom',
isTable: false,
table: {
},
form: {
component: 'UploadFile',
componentProps: {
}
}
},
{
label: '文件',
field: 'filePathList',
sort: 'custom',
isTable: false,
isForm: false,
table: {
},
form: {
component: 'UploadFile',
componentProps: {
}
}
},
{ {
label: '操作', label: '操作',
field: 'action', field: 'action',

541
src/views/eam/item/itemAccounts/index.vue

@ -1,34 +1,65 @@
<template> <template>
<ContentWrap> <ContentWrap>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<Search :schema="ItemAccounts.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> <Search
:schema="ItemAccounts.allSchemas.searchSchema"
@search="setSearchParams"
@reset="setSearchParams"
/>
</ContentWrap> </ContentWrap>
<!-- 列表头部 --> <!-- 列表头部 -->
<TableHead :HeadButttondata="HeadButttondata" @button-base-click="buttonBaseClick" :routeName="routeName" <TableHead
@updataTableColumns="updataTableColumns" @searchFormClick="searchFormClick" :allSchemas="ItemAccounts.allSchemas" /> :HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="ItemAccounts.allSchemas"
/>
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<Table :columns="tableColumns" :data="tableObject.tableList" :loading="tableObject.loading" :pagination="{ <Table
: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:sort="tableObject.sort"> v-model:pageSize="tableObject.pageSize"
<template #code="{row}"> v-model:currentPage="tableObject.currentPage"
v-model:sort="tableObject.sort"
>
<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>
</el-button> </el-button>
</template> </template>
<template #action="{ row }"> <template #action="{ row }">
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" /> <ButtonBase :Butttondata="butttondata(row)" @button-base-click="buttonTableClick($event, row)" />
</template> </template>
<!-- <template #upload="{ row }">
<ButtonBase
v-if="row.filePathList != null && row.filePathList.length != 0"
:Butttondata="butttondataView(row)"
@button-base-click="buttonTableClick($event, row)"
/>
</template> -->
</Table> </Table>
</ContentWrap> </ContentWrap>
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<BasicForm ref="basicFormRef" @success="formsSuccess" :rules="ItemAccountsRules" <BasicForm
:formAllSchemas="ItemAccounts.allSchemas" :apiUpdate="ItemAccountsApi.updateItemAccounts" ref="basicFormRef"
:apiCreate="ItemAccountsApi.createItemAccounts" @searchTableSuccess="searchTableSuccess" :isBusiness="false" /> @success="formsSuccess"
:rules="ItemAccountsRules"
:formAllSchemas="ItemAccounts.allSchemas"
:apiUpdate="ItemAccountsApi.updateItemAccounts"
:apiCreate="ItemAccountsApi.createItemAccounts"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/>
<SearchTable ref="searchTableRef" @searchTableSuccess="submitItem" /> <SearchTable ref="searchTableRef" @searchTableSuccess="submitItem" />
@ -36,253 +67,305 @@
<Detail ref="detailRef" :isBasic="true" :allSchemas="ItemAccounts.allSchemas" /> <Detail ref="detailRef" :isBasic="true" :allSchemas="ItemAccounts.allSchemas" />
<!-- 导入 --> <!-- 导入 -->
<ImportForm ref="importFormRef" url="/eam/item-accounts/import" :importTemplateData="importTemplateData" <ImportForm
@success="importSuccess" /> ref="importFormRef"
url="/eam/item-accounts/import"
:importTemplateData="importTemplateData"
@success="importSuccess"
/>
<Dialog
ref="basicFormViewRef"
v-model="showView"
:key="viewKey"
:closeOnClickModal="true"
:title="viewTitle"
>
<el-image v-for="url in urls" :key="url" :src="url" lazy />
</Dialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import download from '@/utils/download' import download from '@/utils/download'
import { ItemAccounts, ItemAccountsRules } from './itemAccounts.data' import { ItemAccounts, ItemAccountsRules } from './itemAccounts.data'
import * as ItemAccountsApi from '@/api/eam/item/itemAccounts' import * as ItemAccountsApi from '@/api/eam/item/itemAccounts'
import { Item } from '@/views/eam/basic/item/item.data' import { Item } from '@/views/eam/basic/item/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 * as defaultButtons from '@/utils/disposition/defaultButtons'
import TableHead from '@/components/TableHead/src/TableHead.vue' import TableHead from '@/components/TableHead/src/TableHead.vue'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue' import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
import Detail from '@/components/Detail/src/Detail.vue' import Detail from '@/components/Detail/src/Detail.vue'
defineOptions({ name: 'ItemAccounts' })
const message = useMessage() //
const { t } = useI18n() //
const route = useRoute() //
const routeName = ref()
const locationNumber = ref()
const wantId1 = ref()
routeName.value = route.name
const tableColumns = ref(ItemAccounts.allSchemas.tableColumns)
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
})
}
// defineOptions({ name: 'ItemAccounts' })
const updataTableColumns = (val) => {
tableColumns.value = val const message = useMessage() //
} const { t } = useI18n() //
const route = useRoute() //
const routeName = ref()
const locationNumber = ref()
const wantId1 = ref()
routeName.value = route.name
const tableColumns = ref(ItemAccounts.allSchemas.tableColumns)
const { tableObject, tableMethods } = useTable({ const showView = ref(false)
getListApi: ItemAccountsApi.getItemAccountsPage // const viewTitle = ref('图片预览')
const urls = ref([])
const viewKey = ref(0)
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
}) })
}
// //
const { getList, setSearchParams } = tableMethods const updataTableColumns = (val) => {
tableColumns.value = val
// }
const HeadButttondata = [
defaultButtons.defaultAddBtn({ hasPermi: 'item:itemAccounts:create' }), //
defaultButtons.defaultImportBtn({ hasPermi: 'item:itemAccounts:import' }), //
defaultButtons.defaultExportBtn({ hasPermi: 'item:itemAccounts:export' }), //
defaultButtons.defaultFreshBtn(null), //
defaultButtons.defaultFilterBtn(null), //
defaultButtons.defaultSetBtn(null), //
// {
// label: '',
// name: 'zdy',
// hide: false,
// type: 'primary',
// icon: 'Select',
// color: ''
// },
]
// const { tableObject, tableMethods } = useTable({
const buttonBaseClick = (val, item) => { getListApi: ItemAccountsApi.getItemAccountsPage //
if (val == 'add') { // })
openForm('create')
} else if (val == 'import') { // //
handleImport() const { getList, setSearchParams } = tableMethods
} else if (val == 'export') { //
handleExport() //
} else if (val == 'refresh') { // const HeadButttondata = [
getList() defaultButtons.defaultAddBtn({ hasPermi: 'item:itemAccounts:create' }), //
} else if (val == 'filtrate') { // defaultButtons.defaultImportBtn({ hasPermi: 'item:itemAccounts:import' }), //
} else { // defaultButtons.defaultExportBtn({ hasPermi: 'item:itemAccounts:export' }), //
console.log('其他按钮', item) 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: 'item:itemAccounts:update' }), //
// defaultButtons.replaceLocation({ hasPermi: 'item:itemAccounts:replaceLocation' }), //
// defaultButtons.mainListDeleteBtn({ hasPermi: 'item:itemAccounts:delete' }) //
// ]
// -
const butttondata = (row) => {
return [
defaultButtons.mainListEditBtn({ hasPermi: 'item:itemAccounts:update' }), //
defaultButtons.replaceLocation({ hasPermi: 'item:itemAccounts:replaceLocation' }), //
defaultButtons.mainListDeleteBtn({ hasPermi: 'item:itemAccounts:delete' }), //
defaultButtons.viewBtn({hide: !(row.filePathList != null && row.filePathList.length != 0 )})
//defaultButtons.backoutBtn({hasPermi:'eam:device-repair-request:cancel', hide: !(row.result == 'PENDING' && row.declarer == userStore.getUser.id )}), //
// -
const butttondata = [
defaultButtons.mainListEditBtn({ hasPermi: 'item:itemAccounts:update' }), //
defaultButtons.replaceLocation({ hasPermi: 'item:itemAccounts:replaceLocation' }), //
defaultButtons.mainListDeleteBtn({ hasPermi: 'item:itemAccounts:delete' }), //
] ]
}
// - // -
const buttonTableClick = async (val, row) => { const butttondataView = (row) => {
if (val == 'edit') { // return [defaultButtons.viewBtn(null)]
openForm('update', row) }
} else if (val == 'delete') { //
handleDelete(row.id)
} else if (val == 'replaceLocation') {
openItem(row.locationNumber, row.id)
}
}
const searchTableRef = ref() // -
/** 绑定备件操作 */ const buttonTableClick = async (val, row) => {
const openItem = async (number : String, wantId : number) => { if (val == 'edit') {
locationNumber.value = number //
wantId1.value = wantId openForm('update', row)
searchTableRef.value.open( } else if (val == 'delete') {
'选择备件', //
Item.allSchemas, handleDelete(row.id)
ItemApi.getItemPage, } else if (val == 'replaceLocation') {
null, openItem(row.locationNumber, row.id)
Item.allSchemas.searchSchema, } else if (val == 'view') {
true, //
null, openForm('view', row)
null,
null,
null
)
}
const submitItem = async (formFieldRef, searchFieldRef, selections, typeRef, rowRef) => {
const deviceItemRelList = selections.map((element) => ({
id: wantId1.value,
locationNumber: locationNumber.value,
itemNumber: element.number,
}))
ItemAccountsApi.replaceLocation(deviceItemRelList).then((res) => {
message.success(t('更换成功'))
//
getList()
})
} }
}
const getItemWithOutBind = async () => { const searchTableRef = ref()
try { /** 绑定备件操作 */
const res = await ItemApi.getItemPage({ const openItem = async (number: String, wantId: number) => {
...Item.allSchemas.searchSchema, locationNumber.value = number
available: "TRUE" wantId1.value = wantId
searchTableRef.value.open(
}) '选择备件',
if (res.list?.length > 0) { Item.allSchemas,
// const response = await getDeviceItemPage(DeviceAccounts.allSchemas.searchSchema); ItemApi.getItemPage,
// const filteredList = res.list.filter(item => { null,
// return !response.list?.some(element => { Item.allSchemas.searchSchema,
// return item.number === element.itemNumber true,
// }); null,
// }); null,
// console.log('filteredList',filteredList); null,
const filteredList = res.list null
return filteredList // )
} }
return [] // const submitItem = async (formFieldRef, searchFieldRef, selections, typeRef, rowRef) => {
} catch (error) { const deviceItemRelList = selections.map((element) => ({
console.error(error) id: wantId1.value,
throw error // locationNumber: locationNumber.value,
itemNumber: element.number
}))
ItemAccountsApi.replaceLocation(deviceItemRelList).then((res) => {
message.success(t('更换成功'))
//
getList()
})
}
const getItemWithOutBind = async () => {
try {
const res = await ItemApi.getItemPage({
...Item.allSchemas.searchSchema,
available: 'TRUE'
})
if (res.list?.length > 0) {
// const response = await getDeviceItemPage(DeviceAccounts.allSchemas.searchSchema);
// const filteredList = res.list.filter(item => {
// return !response.list?.some(element => {
// return item.number === element.itemNumber
// });
// });
// console.log('filteredList',filteredList);
const filteredList = res.list
return filteredList //
} }
return [] //
} catch (error) {
console.error(error)
throw error //
} }
}
/** 添加/修改操作 */ /** 添加/修改操作 */
const basicFormRef = ref() const basicFormRef = ref()
const openForm = (type : string, row ?: any) => { const openForm = (type: string, row?: any) => {
if (type == 'view') {
showView.value = true
urls.value = row.filePathList
viewKey.value += 1
} else {
basicFormRef.value.open(type, row) basicFormRef.value.open(type, row)
} }
}
// form // form
const formsSuccess = async (formType, data) => { const formsSuccess = async (formType, data) => {
var isHave = ItemAccounts.allSchemas.formSchema.some(function (item) { var isHave = ItemAccounts.allSchemas.formSchema.some(function (item) {
return item.field === 'activeTime' || item.field === 'expireTime'; return item.field === 'activeTime' || item.field === 'expireTime'
}); })
if (isHave) { if (isHave) {
if (data.activeTime && data.expireTime && data.activeTime >= data.expireTime) { if (data.activeTime && data.expireTime && data.activeTime >= data.expireTime) {
message.error('失效时间要大于生效时间') message.error('失效时间要大于生效时间')
return; return
}
}
if (data.activeTime == 0) data.activeTime = null;
if (data.expireTime == 0) data.expireTime = null;
if (formType === 'create') {
await ItemAccountsApi.createItemAccounts(data)
message.success(t('common.createSuccess'))
} else {
await ItemAccountsApi.updateItemAccounts(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
const detailRef = ref() if (formType === 'create') {
const openDetail = (row : any, titleName : any, titleValue : any) => { await ItemAccountsApi.createItemAccounts(data)
detailRef.value.openDetail(row, titleName, titleValue, 'basicItemAccounts') message.success(t('common.createSuccess'))
} else {
await ItemAccountsApi.updateItemAccounts(data)
message.success(t('common.updateSuccess'))
} }
basicFormRef.value.dialogVisible = false
getList()
}
/** 删除按钮操作 */ /** 详情操作 */
const handleDelete = async (id : number) => { const detailRef = ref()
try { const openDetail = (row: any, titleName: any, titleValue: any) => {
// detailRef.value.openDetail(row, titleName, titleValue, 'basicItemAccounts')
await message.delConfirm() }
//
await ItemAccountsApi.deleteItemAccounts(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch { }
}
/** 导出按钮操作 */ /** 删除按钮操作 */
const exportLoading = ref(false) // const handleDelete = async (id: number) => {
const handleExport = async () => { try {
try { //
// await message.delConfirm()
await message.exportConfirm() //
// await ItemAccountsApi.deleteItemAccounts(id)
exportLoading.value = true message.success(t('common.delSuccess'))
const data = await ItemAccountsApi.exportItemAccounts(tableObject.params) //
download.excel(data, '备件台账.xlsx') await getList()
} catch { } catch {}
} finally { }
exportLoading.value = false
}
}
/** 导入 */ /** 导出按钮操作 */
const importFormRef = ref() const exportLoading = ref(false) //
const handleImport = () => { const handleExport = async () => {
importFormRef.value.open() try {
} //
// await message.exportConfirm()
const importTemplateData = reactive({ //
templateUrl: '', exportLoading.value = true
templateTitle: '备件台账导入模版.xlsx' const data = await ItemAccountsApi.exportItemAccounts(tableObject.params)
}) download.excel(data, '备件台账.xlsx')
// } catch {
const importSuccess = () => { } finally {
getList() exportLoading.value = false
} }
}
// /** 导入 */
const searchFormClick = (searchData) => { const importFormRef = ref()
tableObject.params = { const handleImport = () => {
isSearch: true, importFormRef.value.open()
filters: searchData.filters }
} //
getList() // const importTemplateData = reactive({
templateUrl: '',
templateTitle: '备件台账导入模版.xlsx'
})
//
const importSuccess = () => {
getList()
}
//
const searchFormClick = (searchData) => {
tableObject.params = {
isSearch: true,
filters: searchData.filters
} }
getList() //
}
/** 初始化 **/ /** 初始化 **/
onMounted(async () => { onMounted(async () => {
getList() getList()
importTemplateData.templateUrl = await ItemAccountsApi.importTemplate() importTemplateData.templateUrl = await ItemAccountsApi.importTemplate()
}) })
</script> </script>

Loading…
Cancel
Save