Browse Source

设备台账开发中代码

master
ljlong_2630 10 months ago
parent
commit
0733bfcc89
  1. 61
      src/api/eam/basic/fixedAssets/index.ts
  2. 12
      src/api/eam/device/deviceAccounts/index.ts
  3. 2
      src/components/BasicForm/src/BasicForm.vue
  4. 26
      src/utils/disposition/defaultButtons.ts
  5. 146
      src/views/eam/basic/fixedAssets/fixedAssets.data.ts
  6. 244
      src/views/eam/basic/fixedAssets/index.vue
  7. 64
      src/views/eam/device/deviceAccounts/deviceAccounts.data.ts
  8. 124
      src/views/eam/device/deviceAccounts/index.vue

61
src/api/eam/basic/fixedAssets/index.ts

@ -0,0 +1,61 @@
import request from '@/config/axios'
export interface FixedAssetsVO {
number: string
name: string
accountingUnit: string
specifications: string
locationNumber: string
purchaseDate: Date
purchaseDept: string
supplierNumber: string
productionDate: Date
purchasePrice: number
manageDept: string
unit: string
qty: number
siteId: string
available: string
concurrencyStamp: number
}
// 查询固定资产列表
export const getFixedAssetsPage = async (params) => {
if (params.isSearch) {
delete params.isSearch
const data = {...params}
return await request.post({ url: '/eam/fixed-assets/senior', data })
} else {
return await request.get({ url: `/eam/fixed-assets/page`, params })
}
}
// 查询固定资产详情
export const getFixedAssets = async (id: number) => {
return await request.get({ url: `/eam/fixed-assets/get?id=` + id })
}
// 新增固定资产
export const createFixedAssets = async (data: FixedAssetsVO) => {
return await request.post({ url: `/eam/fixed-assets/create`, data })
}
// 修改固定资产
export const updateFixedAssets = async (data: FixedAssetsVO) => {
return await request.put({ url: `/eam/fixed-assets/update`, data })
}
// 删除固定资产
export const deleteFixedAssets = async (id: number) => {
return await request.delete({ url: `/eam/fixed-assets/delete?id=` + id })
}
// 导出固定资产 Excel
export const exportFixedAssets = async (params) => {
return await request.download({ url: `/eam/fixed-assets/export-excel`, params })
}
// 下载用户导入模板
export const importTemplate = () => {
return request.download({ url: '/eam/fixed-assets/get-import-template' })
}

12
src/api/eam/device/deviceAccounts/index.ts

@ -17,7 +17,7 @@ export interface DeviceAccountsVO {
concurrencyStamp: number
}
// 查询备台账列表
// 查询备台账列表
export const getDeviceAccountsPage = async (params) => {
if (params.isSearch) {
delete params.isSearch
@ -28,27 +28,27 @@ export const getDeviceAccountsPage = async (params) => {
}
}
// 查询备台账详情
// 查询备台账详情
export const getDeviceAccounts = async (id: number) => {
return await request.get({ url: `/eam/device-accounts/get?id=` + id })
}
// 新增备台账
// 新增备台账
export const createDeviceAccounts = async (data: DeviceAccountsVO) => {
return await request.post({ url: `/eam/device-accounts/create`, data })
}
// 修改备台账
// 修改备台账
export const updateDeviceAccounts = async (data: DeviceAccountsVO) => {
return await request.put({ url: `/eam/device-accounts/update`, data })
}
// 删除备台账
// 删除备台账
export const deleteDeviceAccounts = async (id: number) => {
return await request.delete({ url: `/eam/device-accounts/delete?id=` + id })
}
// 导出备台账 Excel
// 导出备台账 Excel
export const exportDeviceAccounts = async (params) => {
return await request.download({ url: `/eam/device-accounts/export-excel`, params })
}

2
src/components/BasicForm/src/BasicForm.vue

@ -355,7 +355,7 @@ const open = async (type: string, row?: any, masterParmas?: any) => {
console.log(8)
if (row?.id || row?.masterId) {
formLoading.value = true
console.log(99)
console.log(99)
try {
nextTick(() => {
formRef.value.setValues(row)

26
src/utils/disposition/defaultButtons.ts

@ -748,6 +748,32 @@ export function selectDeviceBtn(option:any) {
hasPermi: ''
})
}
// 主列表-二维码
export function selectQrCodeBtn(option:any) {
return __defaultBtnOption(option,{
label: '二维码',
name: 'selectQrCode',
hide: false,
type: 'primary',
color: '',
link: true, // 文本展现按钮
hasPermi: ''
})
}
// 主列表-备件
export function selectItemBtn(option:any) {
return __defaultBtnOption(option,{
label: '备件',
name: 'selectItem',
hide: false,
type: 'primary',
color: '',
link: true, // 文本展现按钮
hasPermi: ''
})
}
// 默认按钮规则
function __defaultBtnOption(option:any,specific:any){
return {

146
src/views/eam/basic/fixedAssets/fixedAssets.data.ts

@ -0,0 +1,146 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
// 表单校验
export const FixedAssetsRules = reactive({
number: [required],
name: [required],
locationNumber: [required],
supplierNumber: [required],
purchasePrice: [required],
qty: [required],
concurrencyStamp: [required],
})
export const FixedAssets = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '编号唯一标识',
field: 'number',
sort: 'custom',
isSearch: true,
},
{
label: '资产名称',
field: 'name',
sort: 'custom',
isSearch: true,
},
{
label: '会计单位',
field: 'accountingUnit',
sort: 'custom',
isSearch: true,
},
{
label: '规格型号',
field: 'specifications',
sort: 'custom',
},
{
label: '库位编号',
field: 'locationNumber',
sort: 'custom',
isSearch: true,
},
{
label: '购买时间',
field: 'purchaseDate',
sort: 'custom',
formatter: dateFormatter,
form: {
component: 'DatePicker',
componentProps: {
type: 'datetime',
valueFormat: 'x'
}
},
},
{
label: '采购部门',
field: 'purchaseDept',
sort: 'custom',
},
{
label: '供应商编号',
field: 'supplierNumber',
sort: 'custom',
},
{
label: '出厂日期',
field: 'productionDate',
sort: 'custom',
formatter: dateFormatter,
form: {
component: 'DatePicker',
componentProps: {
type: 'datetime',
valueFormat: 'x'
}
},
},
{
label: '购买价格',
field: 'purchasePrice',
sort: 'custom',
},
{
label: '管理部门',
field: 'manageDept',
sort: 'custom',
},
{
label: '单位',
field: 'unit',
sort: 'custom',
},
{
label: '数量',
field: 'qty',
sort: 'custom',
},
{
label: '创建时间',
field: 'createTime',
sort: 'custom',
formatter: dateFormatter,
isSearch: true,
search: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'daterange',
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
}
},
isForm: false,
},
{
label: '地点ID',
field: 'siteId',
sort: 'custom',
},
{
label: '是否可用',
field: 'available',
sort: 'custom',
isSearch: true,
},
{
label: '并发乐观锁',
field: 'concurrencyStamp',
sort: 'custom',
form: {
component: 'InputNumber',
value: 0
},
},
{
label: '操作',
field: 'action',
isForm: false,
table: {
width: 150,
fixed: 'right'
}
}
]))

244
src/views/eam/basic/fixedAssets/index.vue

@ -0,0 +1,244 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<Search :schema="FixedAssets.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="FixedAssets.allSchemas"
/>
<!-- 列表 -->
<ContentWrap>
<Table
:columns="tableColumns"
:data="tableObject.tableList"
:loading="tableObject.loading"
:pagination="{
total: tableObject.total
}"
v-model:pageSize="tableObject.pageSize"
v-model:currentPage="tableObject.currentPage"
v-model:sort="tableObject.sort"
>
<template #code="{row}">
<el-button type="primary" link @click="openDetail(row, '代码', row.code)">
<span>{{ row.code }}</span>
</el-button>
</template>
<template #action="{ row }">
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" />
</template>
</Table>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<BasicForm
ref="basicFormRef"
@success="formsSuccess"
:rules="FixedAssetsRules"
:formAllSchemas="FixedAssets.allSchemas"
:apiUpdate="FixedAssetsApi.updateFixedAssets"
:apiCreate="FixedAssetsApi.createFixedAssets"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/>
<!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="FixedAssets.allSchemas" />
<!-- 导入 -->
<ImportForm ref="importFormRef" url="/eam/fixed-assets/import" :importTemplateData="importTemplateData" @success="importSuccess" />
</template>
<script setup lang="ts">
import download from '@/utils/download'
import { FixedAssets,FixedAssetsRules } from './fixedAssets.data'
import * as FixedAssetsApi from '@/api/eam/fixedAssets'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import TableHead from '@/components/TableHead/src/TableHead.vue'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
import Detail from '@/components/Detail/src/Detail.vue'
defineOptions({ name: 'FixedAssets' })
const message = useMessage() //
const { t } = useI18n() //
const route = useRoute() //
const routeName = ref()
routeName.value = route.name
const tableColumns = ref(FixedAssets.allSchemas.tableColumns)
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
})
}
//
const updataTableColumns = (val) => {
tableColumns.value = val
}
const { tableObject, tableMethods } = useTable({
getListApi: FixedAssetsApi.getFixedAssetsPage //
})
//
const { getList, setSearchParams } = tableMethods
//
const HeadButttondata = [
defaultButtons.defaultAddBtn({hasPermi:'eam:fixedAssets:create'}), //
defaultButtons.defaultImportBtn({hasPermi:'eam:fixedAssets:import'}), //
defaultButtons.defaultExportBtn({hasPermi:'eam:fixedAssets: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 = [
defaultButtons.mainListEditBtn({hasPermi:'eam:fixedAssets:update'}), //
defaultButtons.mainListDeleteBtn({hasPermi:'eam:fixedAssets:delete'}), //
]
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') { //
openForm('update', row)
} else if (val == 'delete') { //
handleDelete(row.id)
}
}
/** 添加/修改操作 */
const basicFormRef = ref()
const openForm = (type: string, row?: any) => {
basicFormRef.value.open(type, row)
}
// form
const formsSuccess = async (formType,data) => {
var isHave =FixedAssets.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 (formType === 'create') {
await FixedAssetsApi.createFixedAssets(data)
message.success(t('common.createSuccess'))
} else {
await FixedAssetsApi.updateFixedAssets(data)
message.success(t('common.updateSuccess'))
}
basicFormRef.value.dialogVisible = false
getList()
}
/** 详情操作 */
const detailRef = ref()
const openDetail = (row: any, titleName: any, titleValue: any) => {
detailRef.value.openDetail(row, titleName, titleValue, 'basicFixedAssets')
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await FixedAssetsApi.deleteFixedAssets(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 FixedAssetsApi.exportFixedAssets(tableObject.params)
download.excel(data, '固定资产.xlsx')
} catch {
} finally {
exportLoading.value = false
}
}
/** 导入 */
const importFormRef = ref()
const handleImport = () => {
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 () => {
getList()
importTemplateData.templateUrl = await FixedAssetsApi.importTemplate()
})
</script>

64
src/views/eam/device/deviceAccounts/deviceAccounts.data.ts

@ -3,15 +3,14 @@ import { dateFormatter } from '@/utils/formatTime'
// 表单校验
export const DeviceAccountsRules = reactive({
number: [required],
// number: [required],
name: [required],
factoryAreaNumber: [required],
purchaseTime: [required],
deptId: [required],
purchaser: [required],
supplierNumber: [required],
siteId: [required],
concurrencyStamp: [required],
// factoryAreaNumber: [required],
// purchaseTime: [required],
// deptId: [required],
// purchaser: [required],
// supplierNumber: [required],
concurrencyStamp: [required]
})
export const DeviceAccounts = useCrudSchemas(reactive<CrudSchema[]>([
@ -20,17 +19,18 @@ export const DeviceAccounts = useCrudSchemas(reactive<CrudSchema[]>([
field: 'number',
sort: 'custom',
isSearch: true,
isForm: false,
},
{
label: '名称',
field: 'name',
sort: 'custom',
isSearch: true,
isSearch: true
},
{
label: '规格型号',
field: 'specification',
sort: 'custom',
sort: 'custom'
},
{
label: '设备类型',
@ -39,12 +39,12 @@ export const DeviceAccounts = useCrudSchemas(reactive<CrudSchema[]>([
isSearch: true,
form: {
component: 'Select'
},
}
},
{
label: '所属厂区编号',
field: 'factoryAreaNumber',
sort: 'custom',
sort: 'custom'
},
{
label: '采购时间',
@ -57,30 +57,28 @@ export const DeviceAccounts = useCrudSchemas(reactive<CrudSchema[]>([
type: 'datetime',
valueFormat: 'x'
}
},
}
},
{
label: '采购部门',
field: 'deptId',
sort: 'custom',
form: {
component: 'InputNumber',
value: 0
},
component: 'Input',
}
},
{
label: '采购人',
field: 'purchaser',
sort: 'custom',
form: {
component: 'InputNumber',
value: 0
},
component: 'Input',
}
},
{
label: '供应商编号',
field: 'supplierNumber',
sort: 'custom',
sort: 'custom'
},
{
label: '出厂日期',
@ -93,39 +91,27 @@ export const DeviceAccounts = useCrudSchemas(reactive<CrudSchema[]>([
type: 'datetime',
valueFormat: 'x'
}
},
}
},
{
label: '价格',
field: 'purchasePrice',
sort: 'custom',
sort: 'custom'
},
{
label: '创建时间',
field: 'createTime',
sort: 'custom',
formatter: dateFormatter,
isForm: false,
},
{
label: '地点ID',
field: 'siteId',
sort: 'custom',
isForm: false
},
{
label: '是否可用',
field: 'available',
sort: 'custom',
},
{
label: '并发乐观锁',
field: 'concurrencyStamp',
sort: 'custom',
form: {
component: 'InputNumber',
value: 0
},
sort: 'custom'
},
{
label: '操作',
field: 'action',
@ -135,4 +121,4 @@ export const DeviceAccounts = useCrudSchemas(reactive<CrudSchema[]>([
fixed: 'right'
}
}
]))
]))

124
src/views/eam/device/deviceAccounts/index.vue

@ -41,16 +41,22 @@
<!-- 表单弹窗添加/修改 -->
<BasicForm
ref="basicFormRef"
@success="getList"
@success="formsSuccess"
:rules="DeviceAccountsRules"
:formAllSchemas="DeviceAccounts.allSchemas"
:searchTableParams="searchTableParams"
:apiUpdate="DeviceAccountsApi.updateDeviceAccounts"
:apiCreate="DeviceAccountsApi.createDeviceAccounts"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/>
<SearchTable
ref="searchTableRef"
:searchFormConfig="DeviceAccounts.searchFormConfig"
:searchTableAction="DeviceAccounts.searchTableAction"
@success="searchTableSuccess"
/>
<!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="DeviceAccounts.allSchemas" />
@ -60,12 +66,13 @@
<script setup lang="ts">
import download from '@/utils/download'
import { DeviceAccounts,DeviceAccountsRules } from './deviceAccounts.data'
import { DeviceAccounts, DeviceAccountsRules } from './deviceAccounts.data'
import { getItemAccountsPage } from '@/api/eam/item/itemAccounts'
import * as DeviceAccountsApi from '@/api/eam/device/deviceAccounts'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
// import TableHead from '@/components/TableHead/src/TableHead.vue'
// import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
// import Detail from '@/components/Detail/src/Detail.vue'
import TableHead from '@/components/TableHead/src/TableHead.vue'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
import Detail from '@/components/Detail/src/Detail.vue'
defineOptions({ name: 'DeviceAccounts' })
@ -74,24 +81,24 @@ const { t } = useI18n() // 国际化
const route = useRoute() //
const routeName = ref()
const itemList = ref([])
routeName.value = route.name
const tableColumns = ref(DeviceAccounts.allSchemas.tableColumns)
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
})
}
//
const updataTableColumns = (val) => {
tableColumns.value = val
}
//
const searchTableParams = ref([
//{
// formField: 'productItemCode',
// searchTableTitle: '',
// searchTableAllSchemas: Itembasic.allSchemas,
// searchTablePage: ItembasicApi.getItembasicPage
//}
])
const { tableObject, tableMethods } = useTable({
getListApi: DeviceAccountsApi.getDeviceAccountsPage //
})
@ -101,9 +108,9 @@ const { getList, setSearchParams } = tableMethods
//
const HeadButttondata = [
defaultButtons.defaultAddBtn({hasPermi:'wms:deviceAccounts:create'}), //
defaultButtons.defaultImportBtn({hasPermi:'wms:deviceAccounts:import'}), //
defaultButtons.defaultExportBtn({hasPermi:'wms:deviceAccounts:export'}), //
defaultButtons.defaultAddBtn(null), //
defaultButtons.defaultImportBtn(null), //
defaultButtons.defaultExportBtn(null), //
defaultButtons.defaultFreshBtn(null), //
defaultButtons.defaultFilterBtn(null), //
defaultButtons.defaultSetBtn(null), //
@ -135,32 +142,52 @@ const buttonBaseClick = (val, item) => {
// -
const butttondata = [
defaultButtons.mainListEditBtn({hasPermi:'wms:deviceAccounts:update'}), //
defaultButtons.mainListDeleteBtn({hasPermi:'wms:deviceAccounts:delete'}), //
defaultButtons.mainListEditBtn(null), //
// defaultButtons.mainListDeleteBtn(null), //
defaultButtons.selectQrCodeBtn(null),//
defaultButtons.selectItemBtn(null),//
]
// -
const buttonTableClick = async (val, row) => {
if (val == 'edit') { //
openForm('update', row)
} else if (val == 'delete') { //
handleDelete(row.id)
} else if (val == 'selectQrCode') { //
openQrCode(row.number)
} else if (val == 'selectItem') {
openItem(row.number)
}
}
/** 添加/修改操作 */
const basicFormRef = ref()
const openForm = (type: string, row?: any) => {
basicFormRef.value.open(type, row)
}
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
})
// form
const formsSuccess = async (formType,data) => {
var isHave =DeviceAccounts.allSchemas.formSchema.some(function (item) {
return item.field === 'activeTime' || item.field === 'expireTime';
});
if(isHave){
if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){
message.error('失效时间要大于生效时间')
return;
}
}
if(data.activeTime==0)data.activeTime = null;
if(data.expireTime==0)data.expireTime = null;
if (formType === 'create') {
await DeviceAccountsApi.createDeviceAccounts(data)
message.success(t('common.createSuccess'))
} else {
await DeviceAccountsApi.updateDeviceAccounts(data)
message.success(t('common.updateSuccess'))
}
basicFormRef.value.dialogVisible = false
getList()
}
/** 详情操作 */
@ -190,8 +217,8 @@ const handleExport = async () => {
await message.exportConfirm()
//
exportLoading.value = true
const data = await DeviceAccountsApi.exportDeviceAccounts(setSearchParams)
download.excel(data, '备台账.xls')
const data = await DeviceAccountsApi.exportDeviceAccounts(tableObject.params)
download.excel(data, '备台账.xlsx')
} catch {
} finally {
exportLoading.value = false
@ -206,7 +233,7 @@ const handleImport = () => {
//
const importTemplateData = reactive({
templateUrl: '',
templateTitle: '备台账导入模版.xls'
templateTitle: '备台账导入模版.xlsx'
})
//
const importSuccess = () => {
@ -228,4 +255,35 @@ onMounted(async () => {
importTemplateData.templateUrl = await DeviceAccountsApi.importTemplate()
})
/** 二维码 */
const openQrCode = async (number: String) => {
// const data = await DeviceAccountsApi.getQrCode(number)
// const url = window.URL.createObjectURL(new Blob([data]))
// const link = document.createElement('a')
// link.style.display = 'none'
// link.href = url
// link.setAttribute('download', '.png')
// document.body.appendChild(link)
// link.click()
// try {
// //
// await message.delConfirm()
// //
// await DeviceAccountsApi.deleteDeviceAccounts(id)
// message.success(t('common.delSuccess'))
// //
// await getList()
// } catch {}
}
/** 绑定备件操作 */
const openItem = async (number: String) => {
let param = {
number: number
}
itemList.value = getItemAccountsPage(param); //
}
</script>

Loading…
Cancel
Save