diff --git a/README.md b/README.md index 237938dee..0e77af65b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ ## dev发布2024-06-01-002 **xxxx.data.ts 文件配置说明** +dictType: DICT_TYPE.INVENTORY_STATUS, +dictClass: 'string', +dictAllOption:true,// true 字典中--下拉框中展示全选按钮 +dictAllValue:'全选', // 全选按钮的value值 **form表单查询弹窗配置** form: { labelMessage: '信息提示说明!!!', diff --git a/src/hooks/web/useCrudSchemas.ts b/src/hooks/web/useCrudSchemas.ts index 541ca87b6..5f6c183f9 100644 --- a/src/hooks/web/useCrudSchemas.ts +++ b/src/hooks/web/useCrudSchemas.ts @@ -264,6 +264,10 @@ const filterFormSchema = (crudSchema: CrudSchema[], allSchemas: AllSchemas): For options.push(dict) }) } else { + if(schemaItem.dictAllOption){ + const allOptions: ComponentOptions = { label: '全选', value: schemaItem.dictAllValue||'' } + options.push(allOptions) + } getDictOptions(schemaItem.dictType).forEach((dict) => { options.push(dict) }) diff --git a/src/views/wms/basicDataManage/documentSetting/businesstype/businesstype.data.ts b/src/views/wms/basicDataManage/documentSetting/businesstype/businesstype.data.ts index d04cd3304..bdef4ffcb 100644 --- a/src/views/wms/basicDataManage/documentSetting/businesstype/businesstype.data.ts +++ b/src/views/wms/basicDataManage/documentSetting/businesstype/businesstype.data.ts @@ -45,6 +45,8 @@ export const Businesstype = useCrudSchemas(reactive([ field: 'itemTypes', dictType: DICT_TYPE.ITEM_TYPE, dictClass: 'string', + dictAllOption:true,// 全选按钮 + dictAllValue:'全选', isTable: true, sort: 'custom', table: { @@ -57,6 +59,7 @@ export const Businesstype = useCrudSchemas(reactive([ }, } }, + { label: '可用物料状态范围', field: 'itemStatuses', @@ -73,6 +76,8 @@ export const Businesstype = useCrudSchemas(reactive([ field: 'outAreaTypes', dictType: DICT_TYPE.AREA_TYPE, dictClass: 'string', + dictAllOption:true,// 全选按钮 + dictAllValue:'全选', isTable: true, sort: 'custom', table: { @@ -90,6 +95,8 @@ export const Businesstype = useCrudSchemas(reactive([ field: 'inAreaTypes', dictType: DICT_TYPE.AREA_TYPE, dictClass: 'string', + dictAllOption:true,// 全选按钮 + dictAllValue:'全选', isTable: true, sort: 'custom', table: { @@ -163,6 +170,8 @@ export const Businesstype = useCrudSchemas(reactive([ field: 'outInventoryStatuses', dictType: DICT_TYPE.INVENTORY_STATUS, dictClass: 'string', + dictAllOption:true,// 全选按钮 + dictAllValue:'全选', isTable: true, sort: 'custom', table: { @@ -180,6 +189,8 @@ export const Businesstype = useCrudSchemas(reactive([ field: 'inInventoryStatuses', dictType: DICT_TYPE.INVENTORY_STATUS, dictClass: 'string', + dictAllOption:true,// 全选按钮 + dictAllValue:'全选', isTable: true, sort: 'custom', table: { diff --git a/src/views/wms/basicDataManage/documentSetting/businesstype/index.vue b/src/views/wms/basicDataManage/documentSetting/businesstype/index.vue index 6813664dd..faff79448 100644 --- a/src/views/wms/basicDataManage/documentSetting/businesstype/index.vue +++ b/src/views/wms/basicDataManage/documentSetting/businesstype/index.vue @@ -53,6 +53,7 @@ @searchTableSuccess="searchTableSuccess" :isBusiness="false" :basicFormWidth="75" + @onChange="onChange" /> @@ -76,6 +77,7 @@ 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 { DICT_TYPE, getStrDictOptions } from '@/utils/dict' // 业务类型 defineOptions({ name: 'Businesstype' }) @@ -157,11 +159,44 @@ const buttonTableClick = async (val, row) => { if (val == 'edit') { // 编辑 const rowSplit = JSON.parse(JSON.stringify(row)) - rowSplit.itemTypes = rowSplit.itemTypes.split(',') - rowSplit.outAreaTypes = rowSplit.outAreaTypes.split(',') - rowSplit.inAreaTypes = rowSplit.inAreaTypes.split(',') - rowSplit.outInventoryStatuses = rowSplit.outInventoryStatuses.split(',') - rowSplit.inInventoryStatuses = rowSplit.inInventoryStatuses.split(',') + // rowSplit.itemTypes = rowSplit.itemTypes.split(',') + // 可用物料类型范围 + const allItemTypesValue = getStrDictOptions(DICT_TYPE.ITEM_TYPE).map(item=>(item.value)) + if(rowSplit.itemTypes == allItemTypesValue){ + rowSplit.itemTypes = ['全选'] + }else{ + rowSplit.itemTypes = rowSplit.itemTypes.split(',') + } + + // 出库库区类型范围 入库库区类型范围 + const allValue = getStrDictOptions(DICT_TYPE.AREA_TYPE).map(item=>(item.value)) + if(rowSplit.outAreaTypes == allValue){ + rowSplit.outAreaTypes = ['全选'] + }else{ + rowSplit.outAreaTypes = rowSplit.outAreaTypes.split(',') + } + + if(rowSplit.inAreaTypes == allValue){ + rowSplit.inAreaTypes = ['全选'] + }else{ + rowSplit.inAreaTypes = rowSplit.inAreaTypes.split(',') + } + // rowSplit.outAreaTypes = rowSplit.outAreaTypes.split(',') + // rowSplit.inAreaTypes = rowSplit.inAreaTypes.split(',') + + const allInventoryStatusesValue = getStrDictOptions(DICT_TYPE.INVENTORY_STATUS).map(item=>(item.value)) + if(rowSplit.outInventoryStatuses == allInventoryStatusesValue){ + rowSplit.outInventoryStatuses = ['全选'] + }else{ + rowSplit.outInventoryStatuses = rowSplit.outInventoryStatuses.split(',') + } + if(rowSplit.inInventoryStatuses == allInventoryStatusesValue){ + rowSplit.inInventoryStatuses = ['全选'] + }else{ + rowSplit.inInventoryStatuses = rowSplit.inInventoryStatuses.split(',') + } + // rowSplit.outInventoryStatuses = rowSplit.outInventoryStatuses.split(',') + // rowSplit.inInventoryStatuses = rowSplit.inInventoryStatuses.split(',') openForm('update', rowSplit) } else if (val == 'delete') { // 删除 @@ -176,7 +211,8 @@ const openForm = (type: string, row?: any) => { } // form表单提交 -const formsSuccess = async (formType, data) => { +const formsSuccess = async (formType, submitData) => { + let data = {...submitData} var isHave = Businesstype.allSchemas.formSchema.some(function (item) { return item.field === 'activeTime' || item.field === 'expireTime' }) @@ -188,11 +224,47 @@ const formsSuccess = async (formType, data) => { } if (data.activeTime == 0) data.activeTime = null if (data.expireTime == 0) data.expireTime = null - data.itemTypes = data.itemTypes.join(',') - data.outAreaTypes = data.outAreaTypes.join(',') - data.inAreaTypes = data.inAreaTypes.join(',') - data.outInventoryStatuses = data.outInventoryStatuses.join(',') - data.inInventoryStatuses = data.inInventoryStatuses.join(',') + // data.itemTypes = data.itemTypes.join(',') + const allItemTypesValue = getStrDictOptions(DICT_TYPE.ITEM_TYPE).map(item=>(item.value)) + if(data.itemTypes[data.itemTypes.length-1]=='全选'){ + data.itemTypes = allItemTypesValue.join(',') + }else{ + data.itemTypes = data.itemTypes.join(',') + } + + // data.outAreaTypes = data.outAreaTypes.join(',') + // data.inAreaTypes = data.inAreaTypes.join(',') + //全选的值 + const allValue = getStrDictOptions(DICT_TYPE.AREA_TYPE).map(item=>(item.value)) + if(data.outAreaTypes[data.outAreaTypes.length-1]=='全选'){ + data.outAreaTypes = allValue.join(',') + }else{ + data.outAreaTypes = data.outAreaTypes.join(',') + } + + if(data.inAreaTypes[data.inAreaTypes.length-1]=='全选'){ + data.inAreaTypes = allValue.join(',') + }else{ + data.inAreaTypes = data.inAreaTypes.join(',') + } + + + // 出库库存状态范围 入库库存状态范围 + // data.outInventoryStatuses = data.outInventoryStatuses.join(',') + // data.inInventoryStatuses = data.inInventoryStatuses.join(',') + const allInventoryStatusesValue = getStrDictOptions(DICT_TYPE.INVENTORY_STATUS).map(item=>(item.value)) + if(data.outInventoryStatuses[data.outInventoryStatuses.length-1]=='全选'){ + data.outInventoryStatuses = allInventoryStatusesValue.join(',') + }else{ + data.outInventoryStatuses = data.outInventoryStatuses.join(',') + } + if(data.inInventoryStatuses[data.inInventoryStatuses.length-1]=='全选'){ + data.inInventoryStatuses = allInventoryStatusesValue.join(',') + }else{ + data.inInventoryStatuses = data.inInventoryStatuses.join(',') + } + + if (formType === 'create') { await BusinesstypeApi.createBusinesstype(data) .then(async () => { @@ -224,6 +296,24 @@ const formsSuccess = async (formType, data) => { } } +const onChange = (field, value)=>{ + console.log('onChange',field,value) + if(field=='outAreaTypes'||field=='inAreaTypes'||field=='itemTypes'||field=='outInventoryStatuses'||field=='inInventoryStatuses'){ + //出库区类型范围 入库区类型范围 可用物料类型范围 出库库存状态范围 入库库存状态范围 + if(value.length>0){ + if(value[value.length-1]=='全选'){ + //全选 + basicFormRef.value.formRef.setValues({ + [field]:['全选'] + }) + }else{ + basicFormRef.value.formRef.setValues({ + [field]:value.filter(item=>item!='全选') + }) + } + } + } +} // 查询页面返回 const searchTableSuccess = (formField, searchField, val, formRef) => { nextTick(() => {