Browse Source

天合修复bug

master
songguoqiang 6 months ago
parent
commit
abb5b0c22c
  1. 495
      src/views/eam/basic/item/index.vue
  2. 2
      src/views/eam/basic/item/item.data.ts
  3. 587
      src/views/eam/item/itemAccounts/index.vue
  4. 382
      src/views/eam/item/itemInLocation/index.vue
  5. 143
      src/views/eam/item/itemOutLocation/index.vue

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

@ -1,34 +1,58 @@
<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" @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" />
@ -36,164 +60,180 @@
<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" /> <ImportForm
ref="importFormRef"
url="/eam/item/import"
:importTemplateData="importTemplateData"
@success="importSuccess"
/>
</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()
const importFormRef = ref() routeName.value = route.name
const itemNumber = ref()
// const tableColumns = ref(Item.allSchemas.tableColumns)
const searchTableSuccess = (formField, searchField, val, formRef) => { const importFormRef = ref()
nextTick(() => {
const setV = {} //
setV[formField] = val[0][searchField] const searchTableSuccess = (formField, searchField, val, formRef) => {
formRef.setValues(setV) 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({ hasPermi: 'basic:item:create' }), //
defaultButtons.defaultImportBtn(null), // const { tableObject, tableMethods } = useTable({
defaultButtons.defaultExportBtn({ hasPermi: 'basic:item:export' }), // getListApi: ItemApi.getItemPage //
defaultButtons.defaultFreshBtn(null), // })
defaultButtons.defaultFilterBtn(null), //
defaultButtons.defaultSetBtn(null), // //
] const { getList, setSearchParams } = tableMethods
// //
const buttonBaseClick = (val, item) => { const HeadButttondata = [
if (val == 'add') { // defaultButtons.defaultAddBtn({ hasPermi: 'basic:item:create' }), //
openForm('create') defaultButtons.defaultImportBtn(null), //
}else if (val == 'import') { // defaultButtons.defaultExportBtn({ hasPermi: 'basic:item:export' }), //
handleImport() defaultButtons.defaultFreshBtn(null), //
} else if (val == 'export') { // defaultButtons.defaultFilterBtn(null), //
handleExport() defaultButtons.defaultSetBtn(null) //
} 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 == 'import') {
// - //
const butttondata = [ handleImport()
defaultButtons.mainListEditBtn({ hasPermi: 'basic:item:update' }), // } else if (val == 'export') {
defaultButtons.mainListDeleteBtn({ hasPermi: 'basic:item:delete' }), // //
] handleExport()
} else if (val == 'refresh') {
// - //
const buttonTableClick = async (val, row) => { getList()
if (val == 'edit') { // } else if (val == 'filtrate') {
openForm('update', row) //
} else if (val == 'chooseDevice') { } else {
openItem(row.number) //
} else if (val == 'delete') { // console.log('其他按钮', item)
handleDelete(row.id)
}
} }
}
const searchTableRef = ref()
/** 绑定备件操作 */ // -
const openItem = async (number : String) => { const butttondata = [
itemNumber.value = number defaultButtons.mainListEditBtn({ hasPermi: 'basic:item:update' }), //
await CallBack1() defaultButtons.mainListDeleteBtn({ hasPermi: 'basic:item:delete' }) //
searchTableRef.value.open( ]
'选择设备',
DeviceAccounts.allSchemas, // -
DeviceAccountsApi.getDeviceAccountsPage, const buttonTableClick = async (val, row) => {
null, if (val == 'edit') {
DeviceAccounts.allSchemas.searchSchema, //
true, openForm('update', row)
null, } else if (val == 'chooseDevice') {
null, openItem(row.number)
null, } else if (val == 'delete') {
null, //
searchTableSelections.value handleDelete(row.id)
)
} }
}
const searchTableSelections = ref([])
const CallBack1 = async () => { const searchTableRef = ref()
await getDeviceItemNoPage({ itemNumber: itemNumber.value }).then(async (res) => { /** 绑定备件操作 */
await DeviceAccountsApi.getDeviceAccountsAllNoPage({}).then(response => { const openItem = async (number: String) => {
searchTableSelections.value = response.filter(element => { itemNumber.value = number
let flag = false; await CallBack1()
res.forEach(item => { searchTableRef.value.open(
if (element.number == item.deviceNumber) { '选择设备',
flag = true; DeviceAccounts.allSchemas,
} DeviceAccountsApi.getDeviceAccountsPage,
}); null,
return flag; DeviceAccounts.allSchemas.searchSchema,
}); true,
}); null,
}); null,
}; null,
null,
const submitItem = async (formFieldRef, searchFieldRef, selections, typeRef, rowRef) => { searchTableSelections.value
const deviceItemRelList = selections.map(element => ({ )
itemNumber: itemNumber.value, }
deviceNumber: element.number,
})); const searchTableSelections = ref([])
createDeviceItemBatch(deviceItemRelList).then(res => { const CallBack1 = async () => {
message.success(t('common.createSuccess')) await getDeviceItemNoPage({ itemNumber: itemNumber.value }).then(async (res) => {
await DeviceAccountsApi.getDeviceAccountsAllNoPage({}).then((response) => {
searchTableSelections.value = response.filter((element) => {
let flag = false
res.forEach((item) => {
if (element.number == item.deviceNumber) {
flag = true
}
})
return flag
})
}) })
}; })
}
/** 添加/修改操作 */
const basicFormRef = ref() const submitItem = async (formFieldRef, searchFieldRef, selections, typeRef, rowRef) => {
const openForm = (type : string, row ?: any) => { const deviceItemRelList = selections.map((element) => ({
basicFormRef.value.open(type, row) itemNumber: itemNumber.value,
} deviceNumber: element.number
}))
// form createDeviceItemBatch(deviceItemRelList).then((res) => {
const formsSuccess = async (formType, data) => { message.success(t('common.createSuccess'))
var isHave = Item.allSchemas.formSchema.some(function (item) { })
return item.field === 'maxInventory' || item.field === 'minInventory'; }
});
if (isHave) { /** 添加/修改操作 */
if (data.minInventory && data.maxInventory && data.minInventory >= data.maxInventory) { const basicFormRef = ref()
message.error('最高库存要大于最低库存') const openForm = (type: string, row?: any) => {
return false; basicFormRef.value.open(type, row)
} }
// form
const formsSuccess = async (formType, data) => {
var isHave = Item.allSchemas.formSchema.some(function (item) {
return item.field === 'maxInventory' || item.field === 'minInventory'
})
if (isHave) {
if (data.minInventory && data.maxInventory && data.minInventory >= data.maxInventory) {
message.error('最高库存要大于最低库存')
return false
} }
if (data.maxInventory == 0) data.maxInventory = null; }
if (data.minInventory == 0) data.minInventory = null; if (data.maxInventory == 0) data.maxInventory = null
if (data.minInventory == 0) data.minInventory = null
try {
if (formType === 'create') { if (formType === 'create') {
await ItemApi.createItem(data) await ItemApi.createItem(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
@ -203,73 +243,76 @@
} }
basicFormRef.value.dialogVisible = false basicFormRef.value.dialogVisible = false
getList() getList()
} finally {
basicFormRef.value.formLoading = false
} }
}
/** 详情操作 */
const detailRef = ref() /** 详情操作 */
const openDetail = (row : any, titleName : any, titleValue : any) => { const detailRef = ref()
detailRef.value.openDetail(row, titleName, titleValue, 'basicItem') const openDetail = (row: any, titleName: any, titleValue: any) => {
} detailRef.value.openDetail(row, titleName, titleValue, 'basicItem')
}
/** 删除按钮操作 */
const handleDelete = async (id : number) => { /** 删除按钮操作 */
try { const handleDelete = async (id: number) => {
// try {
await message.delConfirm() //
// await message.delConfirm()
await ItemApi.deleteItem(id) //
message.success(t('common.delSuccess')) await ItemApi.deleteItem(id)
// message.success(t('common.delSuccess'))
await getList() //
} catch { } await getList()
} } catch {}
}
/** 导出按钮操作 */
const exportLoading = ref(false) // /** 导出按钮操作 */
const handleExport = async () => { const exportLoading = ref(false) //
try { const handleExport = async () => {
// try {
await message.exportConfirm() //
// await message.exportConfirm()
exportLoading.value = true //
const data = await ItemApi.exportItem(tableObject.params) exportLoading.value = true
download.excel(data, '备件.xlsx') const data = await ItemApi.exportItem(tableObject.params)
} catch { download.excel(data, '备件.xlsx')
} finally { } catch {
exportLoading.value = false } finally {
} exportLoading.value = false
}
onMounted(async () => {
importTemplateData.templateUrl = await ItemApi.importTemplate()
})
const handleImport = () => {
importFormRef.value.open()
}
//
const importTemplateData = reactive({
templateUrl: '',
templateTitle: '物料导入模版.xlsx'
})
//
const importSuccess = () => {
getList()
} }
}
//
const searchFormClick = (searchData) => { onMounted(async () => {
tableObject.params = { importTemplateData.templateUrl = await ItemApi.importTemplate()
isSearch: true, })
filters: searchData.filters
} const handleImport = () => {
getList() // importFormRef.value.open()
}
//
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()
}) })
</script> </script>

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

@ -10,6 +10,8 @@ export const ItemRules = reactive({
uom: [ uom: [
{ max: 50, message: '不得超过50个字符', trigger: 'blur' } { max: 50, message: '不得超过50个字符', trigger: 'blur' }
], ],
classification: [ { required: true, message: '请输入备件编号', trigger: 'blur' }
],
}) })
export const ItemSearchTable = useCrudSchemas(reactive<CrudSchema[]>([ export const ItemSearchTable = useCrudSchemas(reactive<CrudSchema[]>([

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

@ -1,38 +1,72 @@
<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(row)" @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="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"
/>
<BasicForm ref="basicFormRef1" @success="formsSuccess" :rules="ItemInRules" <BasicForm
:formAllSchemas="ItemIn.allSchemas" :apiUpdate="ItemAccountsApi.updateItemAccounts" ref="basicFormRef1"
:apiCreate="ItemAccountsApi.createItemAccounts" @searchTableSuccess="searchTableSuccess" :isBusiness="false" /> @success="formsSuccess"
:rules="ItemInRules"
:formAllSchemas="ItemIn.allSchemas"
:apiUpdate="ItemAccountsApi.updateItemAccounts"
:apiCreate="ItemAccountsApi.createItemAccounts"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/>
<SearchTable ref="searchTableRef" @searchTableSuccess="submitItem" /> <SearchTable ref="searchTableRef" @searchTableSuccess="submitItem" />
@ -40,39 +74,45 @@
<Detail ref="detailRef" :isBasic="true" :allSchemas="ItemAccounts.allSchemas" /> <Detail ref="detailRef" :isBasic="true" :allSchemas="ItemAccounts.allSchemas" />
<!-- 导入 --> <!-- 导入 -->
<ImportForm ref="importFormRef" url="/eam/item/item-accounts/import" :importTemplateData="importTemplateData" <ImportForm
@success="importSuccess" /> ref="importFormRef"
url="/eam/item/item-accounts/import"
:importTemplateData="importTemplateData"
@success="importSuccess"
/>
</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 { ItemIn, ItemInRules } from './itemIn.data' import { ItemIn, ItemInRules } from './itemIn.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 searchTableSuccess = async(formField, searchField, val, formRef) => {// const searchTableSuccess = async (formField, searchField, val, formRef) => {
if(formField=='itemNumber'){ //
const aa = await ItemAccountsApi.getByItemNumber(val[0][searchField]); if (formField == 'itemNumber') {
if(aa.locationNumber==null||aa.locationNumber==''){// const aa = await ItemAccountsApi.getByItemNumber(val[0][searchField])
nextTick(() => { if (aa.locationNumber == null || aa.locationNumber == '') {
//
nextTick(() => {
const setV = {} const setV = {}
setV[formField] = val[0][searchField] setV[formField] = val[0][searchField]
setV['itemName'] = val[0]['name'] setV['itemName'] = val[0]['name']
@ -80,275 +120,294 @@
setV['areaNumber'] = '' setV['areaNumber'] = ''
setV['locationName'] = '' setV['locationName'] = ''
setV['areaName'] = '' setV['areaName'] = ''
formRef.setValues(setV) formRef.setValues(setV)
}) })
}else{// } else {
nextTick(() => { //
nextTick(() => {
const setV = {} const setV = {}
setV[formField] = val[0][searchField] setV[formField] = val[0][searchField]
setV['itemName'] = val[0]['name'] setV['itemName'] = val[0]['name']
setV['locationNumber'] = aa.locationNumber setV['locationNumber'] = aa.locationNumber
setV['areaNumber'] =aa.areaNumber setV['areaNumber'] = aa.areaNumber
setV['locationName'] = aa.locationName setV['locationName'] = aa.locationName
setV['areaName'] =aa.areaName setV['areaName'] = aa.areaName
formRef.setValues(setV)
})
}
}if(formField=='locationNumber'){//
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
setV['areaNumber'] = val[0]['areaNumber']
formRef.setValues(setV)
})
}else{
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
formRef.setValues(setV) formRef.setValues(setV)
}) })
} }
} }
if (formField == 'locationNumber') {
// //
const updataTableColumns = (val) => { nextTick(() => {
tableColumns.value = val const setV = {}
setV[formField] = val[0][searchField]
setV['areaNumber'] = val[0]['areaNumber']
formRef.setValues(setV)
})
} else {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
})
} }
}
const { tableObject, tableMethods } = useTable({ //
getListApi: ItemAccountsApi.getItemAccountsPage // const updataTableColumns = (val) => {
}) tableColumns.value = val
}
// const { tableObject, tableMethods } = useTable({
const { getList, setSearchParams } = tableMethods getListApi: ItemAccountsApi.getItemAccountsPage //
})
// //
const HeadButttondata = [ const { getList, setSearchParams } = tableMethods
defaultButtons.defaultAddBtn({ hasPermi: 'item:itemAccounts:create' }), //
//defaultButtons.ItemInBtn({ hasPermi: 'item:itemAccounts:createIn' }), //
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 buttonBaseClick = (val, item) => { const HeadButttondata = [
if (val == 'add') { // defaultButtons.defaultAddBtn({ hasPermi: 'item:itemAccounts:create' }), //
openForm('create') //defaultButtons.ItemInBtn({ hasPermi: 'item:itemAccounts:createIn' }), //
} else if (val == 'import') { // defaultButtons.defaultImportBtn({ hasPermi: 'item:itemAccounts:import' }), //
handleImport() defaultButtons.defaultExportBtn({ hasPermi: 'item:itemAccounts:export' }), //
} else if (val == 'export') { // defaultButtons.defaultFreshBtn(null), //
handleExport() //defaultButtons.defaultFilterBtn(null), //
} else if (val == 'refresh') { // defaultButtons.defaultSetBtn(null) //
getList() // {
} else if (val == 'filtrate') { // // label: '',
} else if(val=='itemIn'){ // // name: 'zdy',
openForm('itemIn') // 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 if (val == 'itemIn') {
//
openForm('itemIn')
} }
}
// - // -
const butttondata =(row)=>{ const butttondata = (row) => {
return [ return [
//defaultButtons.mainListEditBtn({ hasPermi: 'item:itemAccounts:update' }), // //defaultButtons.mainListEditBtn({ hasPermi: 'item:itemAccounts:update' }), //
defaultButtons.replaceLocation({ hasPermi: 'item:itemAccounts:replaceLocation',hide:!(row.display)}), // defaultButtons.replaceLocation({
defaultButtons.newTurnIn({ hasPermi: 'item:itemAccounts:newTurnIn',hide:!(row.type=='2'&& row.qty>0)}), // hasPermi: 'item:itemAccounts:replaceLocation',
hide: !row.display
}), //
defaultButtons.newTurnIn({
hasPermi: 'item:itemAccounts:newTurnIn',
hide: !(row.type == '2' && row.qty > 0)
}) //
//defaultButtons.mainListDeleteBtn({ hasPermi: 'item:itemAccounts:delete' }), // //defaultButtons.mainListDeleteBtn({ hasPermi: 'item:itemAccounts:delete' }), //
] ]
} }
// - // -
const buttonTableClick = async (val, row) => { const buttonTableClick = async (val, row) => {
if (val == 'edit') { // if (val == 'edit') {
openForm('update', row) //
} else if (val == 'delete') { // openForm('update', row)
handleDelete(row.id) } else if (val == 'delete') {
} else if (val == 'replaceLocation') {// //
openItem(row.locationNumber, row.id) handleDelete(row.id)
}else if (val == 'newTurnIn') {// } else if (val == 'replaceLocation') {
openForm('newTurnIn', row); //
} openItem(row.locationNumber, row.id)
} else if (val == 'newTurnIn') {
//
openForm('newTurnIn', 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(
'选择备件', '选择备件',
Item.allSchemas, Item.allSchemas,
ItemApi.getNoAccountItemPage, ItemApi.getNoAccountItemPage,
null, null,
Item.allSchemas.searchSchema, Item.allSchemas.searchSchema,
true, true,
null, null,
null, null,
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 () => {
try {
const res = await ItemApi.getItemPage({
...Item.allSchemas.searchSchema,
available: "TRUE"
}) const getItemWithOutBind = async () => {
if (res.list?.length > 0) { try {
// const response = await getDeviceItemPage(DeviceAccounts.allSchemas.searchSchema); const res = await ItemApi.getItemPage({
// const filteredList = res.list.filter(item => { ...Item.allSchemas.searchSchema,
// return !response.list?.some(element => { available: 'TRUE'
// return item.number === element.itemNumber })
// }); if (res.list?.length > 0) {
// }); // const response = await getDeviceItemPage(DeviceAccounts.allSchemas.searchSchema);
// console.log('filteredList',filteredList); // const filteredList = res.list.filter(item => {
const filteredList = res.list // return !response.list?.some(element => {
return filteredList // // return item.number === element.itemNumber
} // });
return [] // // });
} catch (error) { // console.log('filteredList',filteredList);
console.error(error) const filteredList = res.list
throw error // return filteredList //
} }
return [] //
} catch (error) {
console.error(error)
throw error //
} }
}
/** 添加/修改操作 */ /** 添加/修改操作 */
const basicFormRef = ref() const basicFormRef = ref()
const basicFormRef1 = ref(); const basicFormRef1 = ref()
const openForm = (type : string, row ?: any) => { const openForm = (type: string, row?: any) => {
//debugger //debugger
// if(type=='itemIn'){ // if(type=='itemIn'){
// row?.type = null; // row?.type = null;
// row?.itemName=null; // row?.itemName=null;
// } // }
if(type=='newTurnIn'){// if (type == 'newTurnIn') {
// //
ItemIn.allSchemas.formSchema.find(item => item.field == 'qty').componentProps.max = row.qty// //
basicFormRef1.value.open(type, row) ItemIn.allSchemas.formSchema.find((item) => item.field == 'qty').componentProps.max = row.qty //
}else{ basicFormRef1.value.open(type, row)
basicFormRef.value.open(type, row) } else {
} 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 (data.activeTime == 0) data.activeTime = null
try{ if (data.expireTime == 0) data.expireTime = null
if (formType === 'create') { try {
if (formType === 'create') {
await ItemAccountsApi.createItemAccounts(data) await ItemAccountsApi.createItemAccounts(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
} if (formType === 'newTurnIn') {// }
if (formType === 'newTurnIn') {
//
await ItemAccountsApi.newTurnIn(data) await ItemAccountsApi.newTurnIn(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
} else { } else {
await ItemAccountsApi.updateItemAccounts(data) await ItemAccountsApi.updateItemAccounts(data)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
}
}finally{
basicFormRef.value.dialogVisible = false basicFormRef.value.dialogVisible = false
basicFormRef1.value.dialogVisible = false getList()
} }
getList() } finally {
basicFormRef.value.formLoading = false
} }
}
/** 详情操作 */ /** 详情操作 */
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()
// //
await ItemAccountsApi.deleteItemAccounts(id) await ItemAccountsApi.deleteItemAccounts(id)
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()
// //
exportLoading.value = true exportLoading.value = true
const data = await ItemAccountsApi.exportItemAccounts(tableObject.params) const data = await ItemAccountsApi.exportItemAccounts(tableObject.params)
download.excel(data, '备件台账.xlsx') download.excel(data, '备件台账.xlsx')
} catch { } catch {
} 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>

382
src/views/eam/item/itemInLocation/index.vue

@ -1,167 +1,202 @@
<template> <template>
<ContentWrap> <ContentWrap>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<Search :schema="ItemInLocation.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> <Search
:schema="ItemInLocation.allSchemas.searchSchema"
@search="setSearchParams"
@reset="setSearchParams"
/>
</ContentWrap> </ContentWrap>
<!-- 列表头部 --> <!-- 列表头部 -->
<TableHead :HeadButttondata="HeadButttondata" @button-base-click="buttonBaseClick" :routeName="routeName" <TableHead
@updataTableColumns="updataTableColumns" @searchFormClick="searchFormClick" :HeadButttondata="HeadButttondata"
:allSchemas="ItemInLocation.allSchemas" /> @button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="ItemInLocation.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" @button-base-click="buttonTableClick($event, row)" />
</template> </template>
</Table> </Table>
</ContentWrap> </ContentWrap>
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<BasicForm ref="basicFormRef" @success="formsSuccess" :rules="ItemInLocationRules" <BasicForm
:formAllSchemas="ItemInLocation.allSchemas" :apiUpdate="ItemInLocationApi.updateItemInLocation" ref="basicFormRef"
:apiCreate="ItemInLocationApi.createItemInLocation" @searchTableSuccess="searchTableSuccess" :isBusiness="false" /> @success="formsSuccess"
:rules="ItemInLocationRules"
:formAllSchemas="ItemInLocation.allSchemas"
:apiUpdate="ItemInLocationApi.updateItemInLocation"
:apiCreate="ItemInLocationApi.createItemInLocation"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/>
<!-- 详情 --> <!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="ItemInLocation.allSchemas" /> <Detail ref="detailRef" :isBasic="true" :allSchemas="ItemInLocation.allSchemas" />
<!-- 导入 --> <!-- 导入 -->
<ImportForm ref="importFormRef" url="/record/item-in-location/import" :importTemplateData="importTemplateData" <ImportForm
@success="importSuccess" /> ref="importFormRef"
url="/record/item-in-location/import"
:importTemplateData="importTemplateData"
@success="importSuccess"
/>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import download from '@/utils/download' import download from '@/utils/download'
import { ItemInLocation, ItemInLocationRules } from './itemInLocation.data' import { ItemInLocation, ItemInLocationRules } from './itemInLocation.data'
import * as ItemInLocationApi from '@/api/eam/item/itemInLocation' import * as ItemInLocationApi from '@/api/eam/item/itemInLocation'
import * as ItemAccountApi from '@/api/eam/item/itemAccounts' import * as ItemAccountApi from '@/api/eam/item/itemAccounts'
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: 'ItemInLocation' }) defineOptions({ name: 'ItemInLocation' })
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() // const { t } = useI18n() //
const route = useRoute() // const route = useRoute() //
const routeName = ref() const routeName = ref()
routeName.value = route.name routeName.value = route.name
const tableColumns = ref(ItemInLocation.allSchemas.tableColumns) const tableColumns = ref(ItemInLocation.allSchemas.tableColumns)
// //
const searchTableSuccess = async(formField, searchField, val, formRef) => { const searchTableSuccess = async (formField, searchField, val, formRef) => {
const ret = await ItemAccountApi.getByLocationNumber(val[0][searchField]); const ret = await ItemAccountApi.getByLocationNumber(val[0][searchField])
if(ret.itemNumber==null || ret.itemNumber=='' || !ret.itemNumber){ if (ret.itemNumber == null || ret.itemNumber == '' || !ret.itemNumber) {
nextTick(() => { nextTick(() => {
const setV = {} const setV = {}
setV[formField] = ''; setV[formField] = ''
setV[formField] = val[0][searchField] setV[formField] = val[0][searchField]
formRef.setValues(setV) formRef.setValues(setV)
message.info('该库位下无绑定的备件') message.info('该库位下无绑定的备件')
return; return
}) })
}else{ } else {
nextTick(() => { nextTick(() => {
const setV = {} const setV = {}
setV['itemNumber'] = ret.itemNumber setV['itemNumber'] = ret.itemNumber
setV['itemName'] = ret.itemName setV['itemName'] = ret.itemName
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: ItemInLocationApi.getItemInLocationPage // getListApi: ItemInLocationApi.getItemInLocationPage //
}) })
// //
const { getList, setSearchParams } = tableMethods const { getList, setSearchParams } = tableMethods
//
const HeadButttondata = [
defaultButtons.defaultAddBtn({ hasPermi: 'item:itemInLocation:create' }), //
defaultButtons.defaultExportBtn({ hasPermi: 'item:itemInLocation:export' }), //
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 = [ const HeadButttondata = [
defaultButtons.mainListEditBtn({ hasPermi: 'item:itemInLocation:update' }), // defaultButtons.defaultAddBtn({ hasPermi: 'item:itemInLocation:create' }), //
defaultButtons.mainListDeleteBtn({ hasPermi: 'item:itemInLocation:delete' }), // defaultButtons.defaultExportBtn({ hasPermi: 'item:itemInLocation:export' }), //
] defaultButtons.defaultFreshBtn(null), //
defaultButtons.defaultFilterBtn(null), //
// - defaultButtons.defaultSetBtn(null) //
const buttonTableClick = async (val, row) => { // {
if (val == 'edit') { // // label: '',
openForm('update', row) // name: 'zdy',
} else if (val == 'delete') { // // hide: false,
handleDelete(row.id) // 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:itemInLocation:update' }), //
defaultButtons.mainListDeleteBtn({ hasPermi: 'item:itemInLocation:delete' }) //
]
/** 添加/修改操作 */ // -
const basicFormRef = ref() const buttonTableClick = async (val, row) => {
const openForm = (type : string, row ?: any) => { if (val == 'edit') {
basicFormRef.value.open(type, row) //
openForm('update', row)
} else if (val == 'delete') {
//
handleDelete(row.id)
} }
}
// form /** 添加/修改操作 */
const formsSuccess = async (formType, data) => { const basicFormRef = ref()
var isHave = ItemInLocation.allSchemas.formSchema.some(function (item) { const openForm = (type: string, row?: any) => {
return item.field === 'activeTime' || item.field === 'expireTime'; basicFormRef.value.open(type, row)
}); }
if (isHave) {
if (data.activeTime && data.expireTime && data.activeTime >= data.expireTime) { // form
message.error('失效时间要大于生效时间') const formsSuccess = async (formType, data) => {
return; var isHave = ItemInLocation.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 (data.activeTime == 0) data.activeTime = null
if (data.expireTime == 0) data.expireTime = null
try {
if (formType === 'create') { if (formType === 'create') {
await ItemInLocationApi.createItemInLocation(data) await ItemInLocationApi.createItemInLocation(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
@ -171,70 +206,73 @@
} }
basicFormRef.value.dialogVisible = false basicFormRef.value.dialogVisible = false
getList() getList()
} finally {
basicFormRef.value.formLoading = false
} }
}
/** 详情操作 */ /** 详情操作 */
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, 'basicItemInLocation') detailRef.value.openDetail(row, titleName, titleValue, 'basicItemInLocation')
} }
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (id : number) => { const handleDelete = async (id: number) => {
try { try {
// //
await message.delConfirm() await message.delConfirm()
// //
await ItemInLocationApi.deleteItemInLocation(id) await ItemInLocationApi.deleteItemInLocation(id)
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()
// //
exportLoading.value = true exportLoading.value = true
const data = await ItemInLocationApi.exportItemInLocation(tableObject.params) const data = await ItemInLocationApi.exportItemInLocation(tableObject.params)
download.excel(data, '备件归还记录.xlsx') download.excel(data, '备件归还记录.xlsx')
} catch { } catch {
} 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 ItemInLocationApi.importTemplate() importTemplateData.templateUrl = await ItemInLocationApi.importTemplate()
}) })
</script> </script>

143
src/views/eam/item/itemOutLocation/index.vue

@ -1,18 +1,22 @@
<template> <template>
<ContentWrap> <ContentWrap>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<Search :schema="ItemOutLocation.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> <Search
:schema="ItemOutLocation.allSchemas.searchSchema"
@search="setSearchParams"
@reset="setSearchParams"
/>
</ContentWrap> </ContentWrap>
<!-- 列表头部 --> <!-- 列表头部 -->
<TableHead <TableHead
:HeadButttondata="HeadButttondata" :HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick" @button-base-click="buttonBaseClick"
:routeName="routeName" :routeName="routeName"
@updataTableColumns="updataTableColumns" @updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick" @searchFormClick="searchFormClick"
:allSchemas="ItemOutLocation.allSchemas" :allSchemas="ItemOutLocation.allSchemas"
/> />
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
@ -27,13 +31,13 @@
v-model:currentPage="tableObject.currentPage" v-model:currentPage="tableObject.currentPage"
v-model:sort="tableObject.sort" 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>
</el-button> </el-button>
</template> </template>
<template #action="{ row }"> <template #action="{ row }">
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" /> <ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event, row)" />
</template> </template>
</Table> </Table>
</ContentWrap> </ContentWrap>
@ -54,12 +58,17 @@
<Detail ref="detailRef" :isBasic="true" :allSchemas="ItemOutLocation.allSchemas" /> <Detail ref="detailRef" :isBasic="true" :allSchemas="ItemOutLocation.allSchemas" />
<!-- 导入 --> <!-- 导入 -->
<ImportForm ref="importFormRef" url="/record/item-out-location/import" :importTemplateData="importTemplateData" @success="importSuccess" /> <ImportForm
ref="importFormRef"
url="/record/item-out-location/import"
:importTemplateData="importTemplateData"
@success="importSuccess"
/>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import download from '@/utils/download' import download from '@/utils/download'
import { ItemOutLocation,ItemOutLocationRules } from './itemOutLocation.data' import { ItemOutLocation, ItemOutLocationRules } from './itemOutLocation.data'
import * as ItemOutLocationApi from '@/api/eam/item/itemOutLocation' import * as ItemOutLocationApi from '@/api/eam/item/itemOutLocation'
import * as ItemAccountsApi from '@/api/eam/item/itemAccounts' import * as ItemAccountsApi from '@/api/eam/item/itemAccounts'
import * as defaultButtons from '@/utils/disposition/defaultButtons' import * as defaultButtons from '@/utils/disposition/defaultButtons'
@ -78,25 +87,26 @@ routeName.value = route.name
const tableColumns = ref(ItemOutLocation.allSchemas.tableColumns) const tableColumns = ref(ItemOutLocation.allSchemas.tableColumns)
// //
const searchTableSuccess = async(formField, searchField, val, formRef) => { const searchTableSuccess = async (formField, searchField, val, formRef) => {
if(formField=='locationNumber'){// if (formField == 'locationNumber') {
let aa = await ItemAccountsApi.getByLocationNumber(val[0][searchField]); //
if(aa.id==null){ let aa = await ItemAccountsApi.getByLocationNumber(val[0][searchField])
message.info("该库位下无备件信息"); if (aa.id == null) {
return; message.info('该库位下无备件信息')
return
} }
nextTick(() => { nextTick(() => {
const setV = {} const setV = {}
setV[formField] = val[0][searchField] setV[formField] = val[0][searchField]
setV['locationName'] = val[0]['name'] setV['locationName'] = val[0]['name']
setV['itemName'] = aa.itemName setV['itemName'] = aa.itemName
setV['itemNumber'] = aa.itemNumber setV['itemNumber'] = aa.itemNumber
setV['qty'] = aa.qty setV['qty'] = aa.qty
ItemOutLocation.allSchemas.formSchema.find(item => item.field == 'qty').componentProps.max = aa.qty// ItemOutLocation.allSchemas.formSchema.find((item) => item.field == 'qty').componentProps.max =
formRef.setValues(setV) aa.qty //
}) formRef.setValues(setV)
})
} }
} }
// //
@ -113,11 +123,11 @@ const { getList, setSearchParams } = tableMethods
// //
const HeadButttondata = [ const HeadButttondata = [
defaultButtons.defaultAddBtn({hasPermi:'item:itemOutLocation:create'}), // defaultButtons.defaultAddBtn({ hasPermi: 'item:itemOutLocation:create' }), //
defaultButtons.defaultExportBtn({hasPermi:'item:itemOutLocation:export'}), // defaultButtons.defaultExportBtn({ hasPermi: 'item:itemOutLocation: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',
@ -130,31 +140,39 @@ const HeadButttondata = [
// //
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 = [ const butttondata = [
defaultButtons.mainListEditBtn({hasPermi:'item:itemOutLocation:update'}), // defaultButtons.mainListEditBtn({ hasPermi: 'item:itemOutLocation:update' }), //
defaultButtons.mainListDeleteBtn({hasPermi:'item:itemOutLocation:delete'}), // defaultButtons.mainListDeleteBtn({ hasPermi: 'item:itemOutLocation:delete' }) //
] ]
// - // -
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)
} }
} }
@ -166,27 +184,31 @@ const openForm = (type: string, row?: any) => {
} }
// form // form
const formsSuccess = async (formType,data) => { const formsSuccess = async (formType, data) => {
var isHave =ItemOutLocation.allSchemas.formSchema.some(function (item) { var isHave = ItemOutLocation.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') { try {
await ItemOutLocationApi.createItemOutLocation(data) if (formType === 'create') {
message.success(t('common.createSuccess')) await ItemOutLocationApi.createItemOutLocation(data)
} else { message.success(t('common.createSuccess'))
await ItemOutLocationApi.updateItemOutLocation(data) } else {
message.success(t('common.updateSuccess')) await ItemOutLocationApi.updateItemOutLocation(data)
message.success(t('common.updateSuccess'))
}
basicFormRef.value.dialogVisible = false
getList()
} finally {
basicFormRef.value.formLoading = false
} }
basicFormRef.value.dialogVisible = false
getList()
} }
/** 详情操作 */ /** 详情操作 */
@ -253,5 +275,4 @@ onMounted(async () => {
getList() getList()
importTemplateData.templateUrl = await ItemOutLocationApi.importTemplate() importTemplateData.templateUrl = await ItemOutLocationApi.importTemplate()
}) })
</script> </script>

Loading…
Cancel
Save