Browse Source

物料库区配置管理主子表页面展示

master_hella_20240701
chenfang 9 months ago
parent
commit
6416a680b5
  1. 179
      src/views/wms/basicDataManage/itemManage/itemarea/index.vue
  2. 50
      src/views/wms/basicDataManage/itemManage/itemarea/itemarea.data.ts

179
src/views/wms/basicDataManage/itemManage/itemarea/index.vue

@ -28,58 +28,71 @@
v-model:sort="tableObject.sort" v-model:sort="tableObject.sort"
> >
<template #itemCode="{row}"> <template #itemCode="{row}">
<el-button type="primary" link @click="openDetail(row, '代码', row.itemCode)"> <el-button type="primary" link @click="openDetail(row, '物料号', row.itemCode)">
<span>{{ row.itemCode }}</span> <span>{{ row.itemCode }}</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 <BasicForm
ref="basicFormRef" ref="formRef"
@success="formsSuccess" @success="getList"
:rules="ItemareaRules" :rules="ItemareaRules"
:formAllSchemas="Itemarea.allSchemas" :formAllSchemas="Itemarea.allSchemas"
:tableAllSchemas="ItemareaDetail.allSchemas"
:tableFormRules="ItemareaDetailRules"
:tableData="tableData"
:apiUpdate="ItemareaApi.updateItemarea" :apiUpdate="ItemareaApi.updateItemarea"
:apiCreate="ItemareaApi.createItemarea" :apiCreate="ItemareaApi.createItemarea"
:isBusiness="true"
@handleAddTable="handleAddTable"
@handleDeleteTable="handleDeleteTable"
@searchTableSuccess="searchTableSuccess" @searchTableSuccess="searchTableSuccess"
:isBusiness="false" @submitForm="submitForm"
:basicFormWidth="'60%'" :isShowButton = isShowButton
/> />
<!-- 详情 --> <!-- 详情 -->
<Detail <Detail
ref="detailRef" ref="detailRef"
:isBasic="true" :isBasic="false"
:allSchemas="Itemarea.allSchemas" :allSchemas="Itemarea.allSchemas"
:detailAllSchemas="ItemareaDetail.allSchemas" :detailAllSchemas="ItemareaDetail.allSchemas"
:detailAllSchemasRules="ItemareaDetailRules"
:apiCreate="ItemareaDetailApi.createItemareaDetail" :apiCreate="ItemareaDetailApi.createItemareaDetail"
:apiUpdate="ItemareaDetailApi.updateItemareaDetail" :apiUpdate="ItemareaDetailApi.updateItemareaDetail"
:apiPage="ItemareaDetailApi.getItemareaDetailPage" :apiPage="ItemareaDetailApi.getItemareaDetailPage"
:apiDelete="ItemareaDetailApi.deleteItemareaDetail" :apiDelete="ItemareaDetailApi.deleteItemareaDetail"
@searchTableSuccessDetail="searchTableSuccessDetail" @searchTableSuccessDetail="searchTableSuccessDetail"
:detailButtonIsShowAdd="true"
:detailButtonIsShowDelete="true"
@detailOpenForm="detailOpenForm"
/> />
<!-- 导入 --> <!-- 导入 -->
<ImportForm ref="importFormRef" url="/wms/itemarea/import" :importTemplateData="importTemplateData" @success="importSuccess" /> <ImportForm ref="importFormRef" url="/wms/itemarea/import" :importTemplateData="importTemplateData"
@success="importSuccess" :updateIsDisable="true" :coverIsDisable="true" :mode="2" />
</template> </template>
<script setup lang="ts">   <script setup lang="ts">
import download from '@/utils/download' import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import { Itemarea,ItemareaRules,ItemareaDetail } from './itemarea.data'   import download from '@/utils/download'
import * as ItemareaApi from '@/api/wms/itemarea'   import { Itemarea,ItemareaRules,ItemareaDetail,ItemareaDetailRules } from './itemarea.data'
import * as ItemareaDetailApi from '@/api/wms/itemareaDetail'   import * as ItemareaApi from '@/api/wms/itemarea'
import * as defaultButtons from '@/utils/disposition/defaultButtons'   import * as ItemareaDetailApi from '@/api/wms/itemareaDetail'
import TableHead from '@/components/TableHead/src/TableHead.vue'   import * as defaultButtons from '@/utils/disposition/defaultButtons'
import ImportForm from '@/components/ImportForm/src/ImportForm.vue'   import TableHead from '@/components/TableHead/src/TableHead.vue'
import Detail from '@/components/Detail/src/Detail.vue'   import ImportForm from '@/components/ImportForm/src/ImportForm.vue'
  import Detail from '@/components/Detail/src/Detail.vue'
 
//
defineOptions({ name: 'Itemarea' }) defineOptions({ name: 'Itemarea' })
const message = useMessage() // const message = useMessage() //
@ -90,15 +103,22 @@ const routeName = ref()
routeName.value = route.name routeName.value = route.name
const tableColumns = ref(Itemarea.allSchemas.tableColumns) const tableColumns = ref(Itemarea.allSchemas.tableColumns)
const isShowButton = ref(true)
//
const updataTableColumns = (val) => {
tableColumns.value = val
}
// //
const searchTableSuccess = (formField, searchField, val, formRef) => { const searchTableSuccess = (formField, searchField, val, formRef, type, row ) => {
nextTick(() => { nextTick(() => {
const setV = {} const setV = {}
setV[formField] = val[0][searchField] setV[formField] = val[0][searchField]
formRef.setValues(setV) formRef.setValues(setV)
}) })
} }
// //
const searchTableSuccessDetail = (formField, searchField, val, formRef ) => { const searchTableSuccessDetail = (formField, searchField, val, formRef ) => {
nextTick(() => { nextTick(() => {
@ -108,11 +128,6 @@ const searchTableSuccessDetail = (formField, searchField, val, formRef ) => {
}) })
} }
//
const updataTableColumns = (val) => {
tableColumns.value = val
}
const { tableObject, tableMethods } = useTable({ const { tableObject, tableMethods } = useTable({
getListApi: ItemareaApi.getItemareaPage // getListApi: ItemareaApi.getItemareaPage //
}) })
@ -147,18 +162,38 @@ const buttonBaseClick = (val, item) => {
} else if (val == 'export') { // } else if (val == 'export') { //
handleExport() handleExport()
} else if (val == 'refresh') { // } else if (val == 'refresh') { //
if (tableObject.params.filters && tableObject.params.filters.length > 0 ) {
searchFormClick({
filters: tableObject.params.filters
})
} else {
getList() getList()
}
} else if (val == 'filtrate') { // } else if (val == 'filtrate') { //
} else { // } else { //
console.log('其他按钮', item) console.log('其他按钮', item)
} }
} }
//
const isShowMainButton = (row,val) => {
if (val.indexOf(row.status) > -1) {
return false
} else {
return true
}
}
// - // -
const butttondata = [ const butttondata = (row) => {
defaultButtons.mainListEditBtn({hasPermi:'wms:itemarea:update'}), // row.status = "1"
defaultButtons.mainListDeleteBtn({hasPermi:'wms:itemarea:delete'}), // return [
defaultButtons.mainListEditBtn({hide:isShowMainButton(row,['1']),hasPermi:'wms:itemarea:update'}), //
// defaultButtons.mainListDeleteBtn({hasPermi:'wms:itemarea:delete'}), //
] ]
}
// - // -
const buttonTableClick = async (val, row) => { const buttonTableClick = async (val, row) => {
@ -170,39 +205,29 @@ const buttonTableClick = async (val, row) => {
} }
/** 添加/修改操作 */ /** 添加/修改操作 */
const basicFormRef = ref() const formRef = ref()
const openForm = (type: string, row?: any) => { const openForm =async (type: string, row?: number) => {
basicFormRef.value.open(type, row) tableData.value = [] //
formRef.value.open(type, row)
} }
// form /**
const formsSuccess = async (formType,data) => { * 详情 编辑页面打开
var isHave =Itemarea.allSchemas.formSchema.some(function (item) { * @param row
return item.field === 'activeTime' || item.field === 'expireTime'; */
}); const detailOpenForm = (type) => {
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 ItemareaApi.createItemarea(data)
message.success(t('common.createSuccess'))
} else {
await ItemareaApi.updateItemarea(data)
message.success(t('common.updateSuccess'))
}
basicFormRef.value.dialogVisible = false
getList()
} }
//
const { wsCache } = useCache()
/** 详情操作 */ /** 详情操作 */
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, 'basicItemarea') const departmentCode = wsCache.get(CACHE_KEY.DEPT).find((account) => account.id == row.departmentCode)?.name
if (departmentCode) row.departmentCode = JSON.parse(JSON.stringify(departmentCode))
row.status = "1";
detailRef.value.openDetail(row, titleName, titleValue,'itemarea')
} }
/** 删除按钮操作 */ /** 删除按钮操作 */
@ -210,8 +235,10 @@ const handleDelete = async (id: number) => {
try { try {
// //
await message.delConfirm() await message.delConfirm()
tableObject.loading = true
// //
await ItemareaApi.deleteItemarea(id) await ItemareaDetailApi.deleteItemareaDetail(id)
tableObject.loading = false
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
// //
await getList() await getList()
@ -227,23 +254,62 @@ const handleExport = async () => {
// //
exportLoading.value = true exportLoading.value = true
const data = await ItemareaApi.exportItemarea(tableObject.params) const data = await ItemareaApi.exportItemarea(tableObject.params)
download.excel(data, '物料库区配置.xlsx') download.excel(data, '发货申请主.xlsx')
} catch { } catch {
} finally { } finally {
exportLoading.value = false exportLoading.value = false
} }
} }
/**
* tableForm方法
*/
const tableFormKeys = {}
ItemareaDetail.allSchemas.tableFormColumns.forEach(item => {
tableFormKeys[item.field] = item.default ? item.default : ''
})
const tableData = ref([])
//
const handleAddTable = () => {
tableData.value.push(JSON.parse(JSON.stringify(tableFormKeys)))
}
//
const handleDeleteTable = (item, index) => {
tableData.value.splice(index, 1)
}
//
const submitForm = async (formType, data) => {
data.subList = tableData.value //
try {
if (formType === 'create') {
await ItemareaApi.createItemarea(data)
message.success(t('common.createSuccess'))
} else {
await ItemareaApi.updateItemarea(data)
message.success(t('common.updateSuccess'))
}
formRef.value.dialogVisible = false
//
getList()
} finally {
formRef.value.formLoading = 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()
@ -263,5 +329,4 @@ onMounted(async () => {
getList() getList()
importTemplateData.templateUrl = await ItemareaApi.importTemplate() importTemplateData.templateUrl = await ItemareaApi.importTemplate()
}) })
</script> </script>

50
src/views/wms/basicDataManage/itemManage/itemarea/itemarea.data.ts

@ -322,13 +322,31 @@ export const Itemarea = useCrudSchemas(reactive<CrudSchema[]>([
label: '出库后剩余库存自动转换为出库包装规格', label: '出库后剩余库存自动转换为出库包装规格',
field: 'surplusToOutpackunit', field: 'surplusToOutpackunit',
sort: 'custom', sort: 'custom',
isSearch: false, dictType: DICT_TYPE.TRUE_FALSE,
dictClass: 'string',
form: {
component: 'Switch',
value: 'FALSE',
componentProps: {
inactiveValue: 'FALSE',
activeValue: 'TRUE'
}
},
}, },
{ {
label: '超过高储是否允许叫料', label: '超过高储是否允许叫料',
field: 'allowIssueRequest', field: 'allowIssueRequest',
sort: 'custom', sort: 'custom',
isSearch: false, dictType: DICT_TYPE.TRUE_FALSE,
dictClass: 'string',
form: {
component: 'Switch',
value: 'FALSE',
componentProps: {
inactiveValue: 'FALSE',
activeValue: 'TRUE'
}
},
}, },
{ {
label: '优先空库位', label: '优先空库位',
@ -618,19 +636,14 @@ export const ItemareaRules = reactive({
*/ */
export const ItemareaDetail = useCrudSchemas(reactive<CrudSchema[]>([ export const ItemareaDetail = useCrudSchemas(reactive<CrudSchema[]>([
{ {
label: 'id', label: '库位组',
field: 'id', field: 'locationGroup',
sort: 'custom', sort: 'custom',
isForm: false,
}, },
{ {
label: '主表ID', label: '库位代码',
field: 'masterId', field: 'locationCode',
sort: 'custom', sort: 'custom',
form: {
component: 'InputNumber',
value: 0
},
}, },
{ {
label: '备注', label: '备注',
@ -663,16 +676,6 @@ export const ItemareaDetail = useCrudSchemas(reactive<CrudSchema[]>([
sort: 'custom', sort: 'custom',
isForm: false, isForm: false,
}, },
{
label: '库位组',
field: 'locationGroup',
sort: 'custom',
},
{
label: '库位代码',
field: 'locationCode',
sort: 'custom',
},
{ {
label: '操作', label: '操作',
field: 'action', field: 'action',
@ -683,3 +686,8 @@ export const ItemareaDetail = useCrudSchemas(reactive<CrudSchema[]>([
} }
} }
])) ]))
// 表单校验
export const ItemareaDetailRules = reactive({
})
Loading…
Cancel
Save