ljlong_2630 7 months ago
parent
commit
3850ae7f51
  1. 320
      src/views/eam/basic/item/index.vue
  2. 33
      src/views/eam/basic/item/item.data.ts
  3. 311
      src/views/eam/item/itemAccounts/index.vue

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

@ -1,130 +1,187 @@
<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() // defineOptions({ name: 'Item' })
const route = useRoute() //
const routeName = ref() const message = useMessage() //
routeName.value = route.name const { t } = useI18n() //
const itemNumber = ref(); const route = useRoute() //
const tableColumns = ref(Item.allSchemas.tableColumns) const routeName = ref()
routeName.value = route.name
// const itemNumber = ref()
const searchTableSuccess = (formField, searchField, val, formRef) => { 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(() => { nextTick(() => {
const setV = {} const setV = {}
setV[formField] = val[0][searchField] setV[formField] = val[0][searchField]
formRef.setValues(setV) formRef.setValues(setV)
}) })
} }
// //
const updataTableColumns = (val) => { const updataTableColumns = (val) => {
tableColumns.value = val tableColumns.value = val
} }
const { tableObject, tableMethods } = useTable({ const { tableObject, tableMethods } = useTable({
getListApi: ItemApi.getItemPage // getListApi: ItemApi.getItemPage //
}) })
// //
const { getList, setSearchParams } = tableMethods const { getList, setSearchParams } = tableMethods
// //
const HeadButttondata = [ const HeadButttondata =[
defaultButtons.defaultAddBtn({hasPermi:'basic:item:create'}), // defaultButtons.defaultAddBtn({ hasPermi: 'basic:item:create' }), //
defaultButtons.defaultExportBtn({hasPermi:'basic:item:export'}), // defaultButtons.defaultExportBtn({ hasPermi: 'basic:item:export' }), //
defaultButtons.defaultFreshBtn(null), // defaultButtons.defaultFreshBtn(null), //
defaultButtons.defaultFilterBtn(null), // defaultButtons.defaultFilterBtn(null), //
defaultButtons.defaultSetBtn(null), // defaultButtons.defaultSetBtn(null) //
] ]
// //
const buttonBaseClick = (val, item) => { const buttonBaseClick = (val, item) => {
if (val == 'add') { // if (val == 'add') {
//
openForm('create') openForm('create')
} else if (val == 'export') { // } else if (val == 'export') {
//
handleExport() handleExport()
} else if (val == 'refresh') { // } else if (val == 'refresh') {
//
getList() getList()
} else if (val == 'filtrate') { // } else if (val == 'filtrate') {
} else { // //
} else {
//
console.log('其他按钮', item) console.log('其他按钮', item)
} }
} }
// - // -
const butttondata = [ const butttondataView = (row) => {
defaultButtons.mainListEditBtn({hasPermi:'basic:item:update'}), // return [defaultButtons.viewBtn(null)]
defaultButtons.chooseDeviceBtn({hasPermi:'basic:item:choose'}),// }
defaultButtons.mainListDeleteBtn({hasPermi:'basic:item:delete'}), // // -
] const butttondata =(row)=>{
// - return [
const buttonTableClick = async (val, row) => { defaultButtons.mainListEditBtn({ hasPermi: 'basic:item:update' }), //
if (val == 'edit') { // defaultButtons.chooseDeviceBtn({ hasPermi: 'basic:item:choose' }), //
defaultButtons.mainListDeleteBtn({ hasPermi: 'basic:item:delete' }), //
defaultButtons.viewBtn({hide: !(row.filePathList != null && row.filePathList.length != 0 )})
]}
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') {
//
openForm('update', row) openForm('update', row)
} else if (val == 'chooseDevice') { } else if (val == 'chooseDevice') {
openItem(row.number) openItem(row.number)
} else if (val == 'delete') { // } else if (val == 'delete') {
//
handleDelete(row.id) handleDelete(row.id)
} else if (val == 'view') {
//
openForm('view', row)
} }
} }
const searchTableRef = ref() const searchTableRef = ref()
/** 绑定备件操作 */ /** 绑定备件操作 */
const openItem = async (number : String) => { const openItem = async (number: String) => {
itemNumber.value = number itemNumber.value = number
await CallBack1() await CallBack1()
searchTableRef.value.open( searchTableRef.value.open(
@ -140,54 +197,73 @@
null, null,
searchTableSelections.value 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 submitItem = async (formFieldRef, searchFieldRef, selections, typeRef, rowRef) => {
const deviceItemRelList = selections.map(element => ({ const deviceItemRelList = selections.map((element) => ({
itemNumber: itemNumber.value, itemNumber: itemNumber.value,
deviceNumber: element.number, deviceNumber: element.number
})); }))
createDeviceItemBatch(deviceItemRelList).then(res => { createDeviceItemBatch(deviceItemRelList).then((res) => {
message.success(t('common.createSuccess')) 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.activeTime == 0) data.activeTime = null
if (data.expireTime == 0) data.expireTime = null; if (data.expireTime == 0) data.expireTime = null
data.filePathList = []
for (let i = 0; i < data.filePathListView.length; i++) {
data.filePathList.push(data.filePathListView[i].url)
}
if (formType === 'create') { if (formType === 'create') {
await ItemApi.createItem(data) await ItemApi.createItem(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
@ -197,16 +273,16 @@
} }
basicFormRef.value.dialogVisible = false basicFormRef.value.dialogVisible = false
getList() getList()
} }
/** 详情操作 */ /** 详情操作 */
const detailRef = ref() const detailRef = ref()
const openDetail = (row : any, titleName : any, titleValue : any) => { const openDetail = (row: any, titleName: any, titleValue: any) => {
detailRef.value.openDetail(row, titleName, titleValue, 'basicItem') detailRef.value.openDetail(row, titleName, titleValue, 'basicItem')
} }
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (id : number) => { const handleDelete = async (id: number) => {
try { try {
// //
await message.delConfirm() await message.delConfirm()
@ -215,12 +291,12 @@
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
// //
await getList() await getList()
} catch { } } catch {}
} }
/** 导出按钮操作 */ /** 导出按钮操作 */
const exportLoading = ref(false) // const exportLoading = ref(false) //
const handleExport = async () => { const handleExport = async () => {
try { try {
// //
await message.exportConfirm() await message.exportConfirm()
@ -232,19 +308,19 @@
} finally { } finally {
exportLoading.value = false 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',

311
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,61 +67,80 @@
<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' }) defineOptions({ name: 'ItemAccounts' })
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() // const { t } = useI18n() //
const route = useRoute() // const route = useRoute() //
const routeName = ref() const routeName = ref()
const locationNumber = ref() const locationNumber = ref()
const wantId1 = ref() const wantId1 = ref()
routeName.value = route.name routeName.value = route.name
const tableColumns = ref(ItemAccounts.allSchemas.tableColumns) const tableColumns = ref(ItemAccounts.allSchemas.tableColumns)
// const showView = ref(false)
const searchTableSuccess = (formField, searchField, val, formRef) => { const viewTitle = ref('图片预览')
const urls = ref([])
const viewKey = ref(0)
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => { nextTick(() => {
const setV = {} const setV = {}
setV[formField] = val[0][searchField] setV[formField] = val[0][searchField]
formRef.setValues(setV) formRef.setValues(setV)
}) })
} }
// //
const updataTableColumns = (val) => { const updataTableColumns = (val) => {
tableColumns.value = val tableColumns.value = val
} }
const { tableObject, tableMethods } = useTable({ const { tableObject, tableMethods } = useTable({
getListApi: ItemAccountsApi.getItemAccountsPage // getListApi: ItemAccountsApi.getItemAccountsPage //
}) })
// //
const { getList, setSearchParams } = tableMethods const { getList, setSearchParams } = tableMethods
// //
const HeadButttondata = [ const HeadButttondata = [
defaultButtons.defaultAddBtn({ hasPermi: 'item:itemAccounts:create' }), // defaultButtons.defaultAddBtn({ hasPermi: 'item:itemAccounts:create' }), //
defaultButtons.defaultImportBtn({ hasPermi: 'item:itemAccounts:import' }), // defaultButtons.defaultImportBtn({ hasPermi: 'item:itemAccounts:import' }), //
defaultButtons.defaultExportBtn({ hasPermi: 'item:itemAccounts:export' }), // defaultButtons.defaultExportBtn({ hasPermi: 'item:itemAccounts:export' }), //
defaultButtons.defaultFreshBtn(null), // defaultButtons.defaultFreshBtn(null), //
defaultButtons.defaultFilterBtn(null), // defaultButtons.defaultFilterBtn(null), //
defaultButtons.defaultSetBtn(null), // defaultButtons.defaultSetBtn(null) //
// { // {
// label: '', // label: '',
// name: 'zdy', // name: 'zdy',
@ -99,45 +149,73 @@
// icon: 'Select', // icon: 'Select',
// color: '' // color: ''
// }, // },
] ]
// //
const buttonBaseClick = (val, item) => { const buttonBaseClick = (val, item) => {
if (val == 'add') { // if (val == 'add') {
//
openForm('create') openForm('create')
} else if (val == 'import') { // } else if (val == 'import') {
//
handleImport() handleImport()
} else if (val == 'export') { // } else if (val == 'export') {
//
handleExport() handleExport()
} else if (val == 'refresh') { // } else if (val == 'refresh') {
//
getList() getList()
} else if (val == 'filtrate') { // } else if (val == 'filtrate') {
} else { // //
} else {
//
console.log('其他按钮', item) 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 = [ const butttondata = (row) => {
return [
defaultButtons.mainListEditBtn({ hasPermi: 'item:itemAccounts:update' }), // defaultButtons.mainListEditBtn({ hasPermi: 'item:itemAccounts:update' }), //
defaultButtons.replaceLocation({ hasPermi: 'item:itemAccounts:replaceLocation' }), // defaultButtons.replaceLocation({ hasPermi: 'item:itemAccounts:replaceLocation' }), //
defaultButtons.mainListDeleteBtn({ hasPermi: 'item:itemAccounts:delete' }), // 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 butttondataView = (row) => {
return [defaultButtons.viewBtn(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 == 'delete') {
//
handleDelete(row.id) handleDelete(row.id)
} else if (val == 'replaceLocation') { } else if (val == 'replaceLocation') {
openItem(row.locationNumber, row.id) openItem(row.locationNumber, row.id)
} else if (val == 'view') {
//
openForm('view', row)
} }
} }
const searchTableRef = ref() const searchTableRef = ref()
/** 绑定备件操作 */ /** 绑定备件操作 */
const openItem = async (number : String, wantId : number) => { const openItem = async (number: String, wantId: number) => {
locationNumber.value = number locationNumber.value = number
wantId1.value = wantId wantId1.value = wantId
searchTableRef.value.open( searchTableRef.value.open(
@ -152,26 +230,25 @@
null, null,
null null
) )
} }
const submitItem = async (formFieldRef, searchFieldRef, selections, typeRef, rowRef) => { const submitItem = async (formFieldRef, searchFieldRef, selections, typeRef, rowRef) => {
const deviceItemRelList = selections.map((element) => ({ const deviceItemRelList = selections.map((element) => ({
id: wantId1.value, id: wantId1.value,
locationNumber: locationNumber.value, locationNumber: locationNumber.value,
itemNumber: element.number, itemNumber: element.number
})) }))
ItemAccountsApi.replaceLocation(deviceItemRelList).then((res) => { ItemAccountsApi.replaceLocation(deviceItemRelList).then((res) => {
message.success(t('更换成功')) message.success(t('更换成功'))
// //
getList() getList()
}) })
} }
const getItemWithOutBind = async () => { const getItemWithOutBind = async () => {
try { try {
const res = await ItemApi.getItemPage({ const res = await ItemApi.getItemPage({
...Item.allSchemas.searchSchema, ...Item.allSchemas.searchSchema,
available: "TRUE" available: 'TRUE'
}) })
if (res.list?.length > 0) { if (res.list?.length > 0) {
// const response = await getDeviceItemPage(DeviceAccounts.allSchemas.searchSchema); // const response = await getDeviceItemPage(DeviceAccounts.allSchemas.searchSchema);
@ -189,27 +266,33 @@
console.error(error) console.error(error)
throw 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.activeTime == 0) data.activeTime = null
if (data.expireTime == 0) data.expireTime = null; if (data.expireTime == 0) data.expireTime = null
if (formType === 'create') { if (formType === 'create') {
await ItemAccountsApi.createItemAccounts(data) await ItemAccountsApi.createItemAccounts(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
@ -219,16 +302,16 @@
} }
basicFormRef.value.dialogVisible = false basicFormRef.value.dialogVisible = false
getList() getList()
} }
/** 详情操作 */ /** 详情操作 */
const detailRef = ref() const detailRef = ref()
const openDetail = (row : any, titleName : any, titleValue : any) => { const openDetail = (row: any, titleName: any, titleValue: any) => {
detailRef.value.openDetail(row, titleName, titleValue, 'basicItemAccounts') detailRef.value.openDetail(row, titleName, titleValue, 'basicItemAccounts')
} }
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (id : number) => { const handleDelete = async (id: number) => {
try { try {
// //
await message.delConfirm() await message.delConfirm()
@ -237,12 +320,12 @@
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
// //
await getList() await getList()
} catch { } } catch {}
} }
/** 导出按钮操作 */ /** 导出按钮操作 */
const exportLoading = ref(false) // const exportLoading = ref(false) //
const handleExport = async () => { const handleExport = async () => {
try { try {
// //
await message.exportConfirm() await message.exportConfirm()
@ -254,35 +337,35 @@
} finally { } finally {
exportLoading.value = false exportLoading.value = false
} }
} }
/** 导入 */ /** 导入 */
const importFormRef = ref() const importFormRef = ref()
const handleImport = () => { const handleImport = () => {
importFormRef.value.open() importFormRef.value.open()
} }
// //
const importTemplateData = reactive({ const importTemplateData = reactive({
templateUrl: '', templateUrl: '',
templateTitle: '备件台账导入模版.xlsx' templateTitle: '备件台账导入模版.xlsx'
}) })
// //
const importSuccess = () => { const importSuccess = () => {
getList() getList()
} }
// //
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()
importTemplateData.templateUrl = await ItemAccountsApi.importTemplate() importTemplateData.templateUrl = await ItemAccountsApi.importTemplate()
}) })
</script> </script>

Loading…
Cancel
Save