Browse Source

MES--工位管理--详情子页面添加SearchTable

master_hella_20240701
yufei0306 8 months ago
parent
commit
ef0d559612
  1. 104
      src/views/mes/workstation/components/Detail.vue
  2. 12
      src/views/mes/workstation/index.vue

104
src/views/mes/workstation/components/Detail.vue

@ -138,6 +138,8 @@
@onBlur="onBlur" @onBlur="onBlur"
@formFormDateChange="formFormDateChange" @formFormDateChange="formFormDateChange"
/> />
<!-- 表格弹窗 -->
<SearchTable ref="searchTableRef" @search-table-success="searchTableSuccess1" />
</div> </div>
</template> </template>
@ -299,7 +301,18 @@ const props = defineProps({
type: Boolean, type: Boolean,
required: false, required: false,
default: true default: true
} },
//
isOpenSearchTable:{
type: Boolean,
required: false,
default: false
},
searchTableSchema: {
type: Array,
required: false,
default: null
},
}) })
const isShowDrawer = ref(false) const isShowDrawer = ref(false)
const detailLoading = ref(false) const detailLoading = ref(false)
@ -381,6 +394,79 @@ const HeadButttondata = ref()
// - // -
const buttondata = ref() const buttondata = ref()
/** isOpenSearchTable 对应 表格弹窗 */
const initModel = (schema: FormSchema[], formModel: Recordable) => {
const model: Recordable = { ...formModel }
schema.map((v) => {
// hidden
if (v.hidden) {
delete model[v.field]
} else if (v.component && v.component !== 'Divider') {
const hasField = Reflect.has(model, v.field)
//
model[v.field] = hasField ? model[v.field] : v.value !== void 0 ? v.value : ''
}
})
return model
}
const searchTableRef = ref()
const searchTableFormModel = ref<Recordable>({})
if(props.isOpenSearchTable){
searchTableFormModel.value = initModel(props.searchTableSchema.formSchema, unref(searchTableFormModel))
}
const searchTableFormType = ref('') // create - update -
// --> isOpenSearchTable === true
const opensearchTable = (
formField,
searchField,
searchTitle,
searchAllSchemas,
searchPage,
searchCondition,
multiple,
type,
row
) => {
const _searchCondition = {}
//
if (searchCondition && searchCondition.length > 0) {
//
for (var i=0; i< searchCondition.length; i++ ) {
// row
if (searchCondition[i].isMainValue) {
_searchCondition[searchCondition[i].key] = detailData
? detailData.value[searchCondition[i].value]
: ''
}else{
_searchCondition[searchCondition[i].key] = searchCondition[i].value
}
}
}
console.log(searchCondition)
console.log(_searchCondition)
searchTableRef.value.open(
searchTitle,
searchAllSchemas,
searchPage,
formField,
searchField,
multiple,
type,
row,
_searchCondition
)
}
const searchTableSuccess1 = (formField, searchField, val, formRef) => {
console.log('searchTableSuccess1',val)
searchTableFormModel.value[formField] = val.map(item=>item[searchField]).join(',')
console.log('searchTableSuccess1',searchTableFormModel)
submitForm(searchTableFormType.value,searchTableFormModel.value)
emit('searchTableSuccessDetail', formField, searchField, val, formRef)
}
/** 打开弹窗 */ /** 打开弹窗 */
const formRef = ref() const formRef = ref()
const titleNameRef = ref() const titleNameRef = ref()
@ -512,7 +598,22 @@ const { getList } = tableMethodsRef.value
const buttonBaseClick = (val, item) => { const buttonBaseClick = (val, item) => {
if (val == 'add') { if (val == 'add') {
// //
if(props.isOpenSearchTable){
searchTableFormType.value = 'create'
//
const item = props.searchTableSchema.formSchema[0]
opensearchTable(
item.field, item?.componentProps?.searchField,
item?.componentProps?.searchTitle,
item?.componentProps?.searchAllSchemas,
item?.componentProps?.searchPage,
item?.componentProps?.searchCondition,
item?.componentProps?.multiple,
undefined,undefined
)
}else{
openForm('create') openForm('create')
}
} else if (val == 'import') { } else if (val == 'import') {
// //
handleImport() handleImport()
@ -554,6 +655,7 @@ const openForm = async (type: string, row?: number) => {
} }
// form // form
const submitForm = async (formType, data) => { const submitForm = async (formType, data) => {
console.log('submitForm',data)
try { try {
// detailValidate // detailValidate
const rs = (await props.detailValidate) ? await props.detailValidate(data) : true const rs = (await props.detailValidate) ? await props.detailValidate(data) : true

12
src/views/mes/workstation/index.vue

@ -53,12 +53,15 @@
<!-- 详情 --> <!-- 详情 -->
<Detail ref="detailRef" <Detail ref="detailRef"
:isBasic="false" :isBasic="false"
:isOpenSearchTable="true"
:apiCreate="tabsCreateApi"
:apiDelete="tabsDeleteApi"
:allSchemas="Workstation.allSchemas" :allSchemas="Workstation.allSchemas"
:detailAllSchemas="detailAllSchemas" :detailAllSchemas="detailAllSchemas"
:searchTableSchema="popList.allSchemas"
:detailAllSchemasRules="WorkstationRules" :detailAllSchemasRules="WorkstationRules"
:apiPage="apiPage" :apiPage="apiPage"
:tabs="TabsList" :tabs="TabsList"
:apiDelete=tabsDeleteApi
@changeTabs="changeTabs" @changeTabs="changeTabs"
:detailButtonIsShowAdd="true" :detailButtonIsShowAdd="true"
:detailButtonIsShowDelete="true" :detailButtonIsShowDelete="true"
@ -95,6 +98,7 @@ import {
import Detail from './components/Detail.vue' import Detail from './components/Detail.vue'
defineOptions({ name: 'Workstation' }) defineOptions({ name: 'Workstation' })
let tabsDeleteApi = WorkstationApi.deleteTeamRelation let tabsDeleteApi = WorkstationApi.deleteTeamRelation
let tabsCreateApi = WorkstationApi.createTeamRelation
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() // const { t } = useI18n() //
const teamRef = ref() const teamRef = ref()
@ -277,18 +281,24 @@ const changeTabs = (data) =>{
apiPage.value = WorkstationApi.getTeamPage apiPage.value = WorkstationApi.getTeamPage
detailAllSchemas.value = Team.allSchemas detailAllSchemas.value = Team.allSchemas
tabsDeleteApi = WorkstationApi.deleteTeamRelation tabsDeleteApi = WorkstationApi.deleteTeamRelation
tabsCreateApi = WorkstationApi.createTeamRelation
}else if(data.prop == 'Equipment'){ }else if(data.prop == 'Equipment'){
apiPage.value = WorkstationApi.getEquipmentPage apiPage.value = WorkstationApi.getEquipmentPage
detailAllSchemas.value = Equipment.allSchemas detailAllSchemas.value = Equipment.allSchemas
tabsDeleteApi = WorkstationApi.deleteEquipmentRelation tabsDeleteApi = WorkstationApi.deleteEquipmentRelation
tabsCreateApi = WorkstationApi.createEquipmentRelation
}else if(data.prop == 'Process'){ }else if(data.prop == 'Process'){
apiPage.value = WorkstationApi.getProcessPage apiPage.value = WorkstationApi.getProcessPage
detailAllSchemas.value = Process.allSchemas detailAllSchemas.value = Process.allSchemas
tabsDeleteApi = WorkstationApi.deleteProcessRelation tabsDeleteApi = WorkstationApi.deleteProcessRelation
tabsCreateApi = WorkstationApi.createProcessRelation
}else if(data.prop == 'Opersteps'){ }else if(data.prop == 'Opersteps'){
apiPage.value = WorkstationApi.getOperstepsPage apiPage.value = WorkstationApi.getOperstepsPage
detailAllSchemas.value = Opersteps.allSchemas detailAllSchemas.value = Opersteps.allSchemas
tabsDeleteApi = WorkstationApi.deleteOperstepsRelation tabsDeleteApi = WorkstationApi.deleteOperstepsRelation
tabsCreateApi = WorkstationApi.createOperstepsRelation
} }
} }
const teamListRef = ref() const teamListRef = ref()

Loading…
Cancel
Save