Browse Source

库区代码生成

master
songguoqiang 11 months ago
parent
commit
c22c2893c3
  1. 52
      src/api/eam/basic/locationArea/index.ts
  2. 231
      src/views/eam/basic/locationArea/index.vue
  3. 80
      src/views/eam/basic/locationArea/locationArea.data.ts

52
src/api/eam/basic/locationArea/index.ts

@ -0,0 +1,52 @@
import request from '@/config/axios'
export interface LocationAreaVO {
number: string
name: string
description: string
type: string
siteId: string
available: string
concurrencyStamp: number
}
// 查询库区列表
export const getLocationAreaPage = async (params) => {
if (params.isSearch) {
delete params.isSearch
const data = {...params}
return await request.post({ url: '/eam/location-area/senior', data })
} else {
return await request.get({ url: `/eam/location-area/page`, params })
}
}
// 查询库区详情
export const getLocationArea = async (id: number) => {
return await request.get({ url: `/eam/location-area/get?id=` + id })
}
// 新增库区
export const createLocationArea = async (data: LocationAreaVO) => {
return await request.post({ url: `/eam/location-area/create`, data })
}
// 修改库区
export const updateLocationArea = async (data: LocationAreaVO) => {
return await request.put({ url: `/eam/location-area/update`, data })
}
// 删除库区
export const deleteLocationArea = async (id: number) => {
return await request.delete({ url: `/eam/location-area/delete?id=` + id })
}
// 导出库区 Excel
export const exportLocationArea = async (params) => {
return await request.download({ url: `/eam/location-area/export-excel`, params })
}
// 下载用户导入模板
export const importTemplate = () => {
return request.download({ url: '/eam/location-area/get-import-template' })
}

231
src/views/eam/basic/locationArea/index.vue

@ -0,0 +1,231 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<Search :schema="LocationArea.allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
</ContentWrap>
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
@button-base-click="buttonBaseClick"
:routeName="routeName"
@updataTableColumns="updataTableColumns"
@searchFormClick="searchFormClick"
:allSchemas="LocationArea.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="getList"
:rules="LocationAreaRules"
:formAllSchemas="LocationArea.allSchemas"
:searchTableParams="searchTableParams"
:apiUpdate="LocationAreaApi.updateLocationArea"
:apiCreate="LocationAreaApi.createLocationArea"
@searchTableSuccess="searchTableSuccess"
:isBusiness="false"
/>
<!-- 详情 -->
<Detail ref="detailRef" :isBasic="true" :allSchemas="LocationArea.allSchemas" />
<!-- 导入 -->
<ImportForm ref="importFormRef" url="/eam/location-area/import" :importTemplateData="importTemplateData" @success="importSuccess" />
</template>
<script setup lang="ts">
import download from '@/utils/download'
import { LocationArea,LocationAreaRules } from './locationArea.data'
import * as LocationAreaApi from '@/api/eam/basic/locationArea'
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: 'LocationArea' })
const message = useMessage() //
const { t } = useI18n() //
const route = useRoute() //
const routeName = ref()
routeName.value = route.name
const tableColumns = ref(LocationArea.allSchemas.tableColumns)
//
const updataTableColumns = (val) => {
tableColumns.value = val
}
//
const searchTableParams = ref([
//{
// formField: 'productItemCode',
// searchTableTitle: '',
// searchTableAllSchemas: Itembasic.allSchemas,
// searchTablePage: ItembasicApi.getItembasicPage
//}
])
const { tableObject, tableMethods } = useTable({
getListApi: LocationAreaApi.getLocationAreaPage //
})
//
const { getList, setSearchParams } = tableMethods
//
const HeadButttondata = [
defaultButtons.defaultAddBtn({hasPermi:'wms:locationArea:create'}), //
defaultButtons.defaultImportBtn({hasPermi:'wms:locationArea:import'}), //
defaultButtons.defaultExportBtn({hasPermi:'wms:locationArea: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:'wms:locationArea:update'}), //
defaultButtons.mainListDeleteBtn({hasPermi:'wms:locationArea: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)
}
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
const setV = {}
setV[formField] = val[0][searchField]
formRef.setValues(setV)
})
}
/** 详情操作 */
const detailRef = ref()
const openDetail = (row: any, titleName: any, titleValue: any) => {
detailRef.value.openDetail(row, titleName, titleValue, 'basicLocationArea')
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await LocationAreaApi.deleteLocationArea(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 LocationAreaApi.exportLocationArea(setSearchParams)
download.excel(data, '库区.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 导入 */
const importFormRef = ref()
const handleImport = () => {
importFormRef.value.open()
}
//
const importTemplateData = reactive({
templateUrl: '',
templateTitle: '库区导入模版.xls'
})
//
const importSuccess = () => {
getList()
}
//
const searchFormClick = (searchData) => {
tableObject.params = {
isSearch: true,
filters: searchData.filters
}
getList() //
}
/** 初始化 **/
onMounted(async () => {
getList()
importTemplateData.templateUrl = await LocationAreaApi.importTemplate()
})
</script>

80
src/views/eam/basic/locationArea/locationArea.data.ts

@ -0,0 +1,80 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
// 表单校验
export const LocationAreaRules = reactive({
number: [required],
name: [required],
concurrencyStamp: [required],
})
export const LocationArea = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '编号',
field: 'number',
sort: 'custom',
isSearch: true,
},
{
label: '名称',
field: 'name',
sort: 'custom',
isSearch: true,
},
{
label: '描述',
field: 'description',
sort: 'custom',
form: {
component: 'Editor',
componentProps: {
valueHtml: '',
height: 200
}
},
},
{
label: '类型',
field: 'type',
sort: 'custom',
isSearch: true,
form: {
component: 'SelectV2'
},
},
{
label: '创建时间',
field: 'createTime',
sort: 'custom',
formatter: dateFormatter,
isForm: false,
},
{
label: '地点ID',
field: 'siteId',
sort: 'custom',
},
{
label: '是否可用',
field: 'available',
sort: 'custom',
},
{
label: '并发乐观锁',
field: 'concurrencyStamp',
sort: 'custom',
form: {
component: 'InputNumber',
value: 0
},
},
{
label: '操作',
field: 'action',
isForm: false,
table: {
width: 150,
fixed: 'right'
}
}
]))
Loading…
Cancel
Save