Browse Source

2024-04-28 新建特殊处理的searcheTable模版,并修正引用

master_hella_20240701
zhousq 5 months ago
parent
commit
0e1f24ce9d
  1. 4
      src/api/mes/productOffline/index.ts
  2. 2
      src/components/SearchTable/index.ts
  3. 3
      src/components/SearchTableV2/index.ts
  4. 187
      src/components/SearchTableV2/src/SearchTableV2.vue
  5. 2
      src/views/mes/orderDay/components/BasicFormV2.vue

4
src/api/mes/productOffline/index.ts

@ -64,8 +64,8 @@ export const getworkSchedulingPage = async (params) => {
if (params.isSearch) { if (params.isSearch) {
delete params.isSearch delete params.isSearch
const data = {...params} const data = {...params}
return await request.post({ url: '/mes/work-scheduling/senior', data }) return await request.post({ url: '/mes/workScheduling/senior', data })
} else { } else {
return await request.get({ url: `/mes/work-scheduling/page`, params }) return await request.get({ url: `/mes/workScheduling/page`, params })
} }
} }

2
src/components/SearchTable/index.ts

@ -1,3 +1,3 @@
import SearchTable from './src/SearchTable.vue' import SearchTable from './src/SearchTable.vue'
export { SearchTable } export { SearchTable}

3
src/components/SearchTableV2/index.ts

@ -0,0 +1,3 @@
import SearchTable from './src/SearchTableV2.vue'
export { SearchTable }

187
src/components/SearchTableV2/src/SearchTableV2.vue

@ -0,0 +1,187 @@
<template>
<Dialog :title="dialogTitle" v-model="searchDialogVisible" :width="'80%'">
<!-- 搜索工作栏 -->
<!-- <Search :schema="searchSchema" @search="setSearchParamsRef" @reset="setSearchParamsRef" /> -->
<!-- 列表头部 -->
<TableHead
:HeadButttondata="HeadButttondata"
:routeName="routeName"
@searchFormClick="searchFormClick"
:allSchemas="allSchemasRef"
/>
<ContentWrap>
<Table
ref="searchTableRef"
:columns="tableColumns"
:data="tableObjectRef.tableList"
:loading="tableObjectRef.loading"
:pagination="{
total: tableObjectRef.total
}"
v-model:pageSize="tableObjectRef.pageSize"
v-model:currentPage="tableObjectRef.currentPage"
v-model:sort="tableObjectRef.sort"
:selection="true"
:reserveSelection="true"
row-key="id"
/>
</ContentWrap>
<template #footer>
<div class="flex items-center">
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="searchDialogVisible = false"> </el-button>
</div>
</template>
</Dialog>
</template>
<script setup lang="ts">
import * as defaultButtons from '@/utils/disposition/defaultButtons'
// const { t } = useI18n() //
const message = useMessage() //
const route = useRoute() //
const routeName = ref()
routeName.value = route.name
const searchDialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
//
const HeadButttondata = [
defaultButtons.defaultFilterBtn(null), //
]
/** 打开弹窗 */
const getListRef = ref()
const setSearchParamsRef = ref()
const tableObjectRef = ref()
const getPage:any = ref()
const searchSchema = ref()
const tableColumns = ref()
const formFieldRef = ref()
const searchFieldRef = ref()
const typeRef = ref()
const rowRef = ref()
const allSchemasRef = ref()
const multipleBol = ref(false)
const searchConditionRef = ref()
const openData = (titleName: any, tableObject:any ,allSchemas: any,multiple: any) => {
dialogTitle.value = titleName
tableObjectRef.value = tableObject
searchDialogVisible.value = true
multipleBol.value = multiple
allSchemasRef.value = allSchemas
searchSchema.value = allSchemas.searchSchema
tableColumns.value = allSchemas.tableColumns
}
const open = (titleName: any, allSchemas: any,getApiPage: any, formField: any, searchField: any,multiple: any, type: any, row: any, searchCondition:any , isCountRequestRe:any ) => {
searchDialogVisible.value = true
formFieldRef.value = formField
searchFieldRef.value = searchField
allSchemasRef.value = allSchemas
searchSchema.value = allSchemas.searchSchema
tableColumns.value = allSchemas.tableColumns.filter(item => (item.field !== 'action'))
getPage.value = getApiPage
typeRef.value = type
rowRef.value = row
multipleBol.value = multiple
// dialogTitle.value = t('action.' + type)
dialogTitle.value = titleName
const {tableObject, tableMethods } = useTable({
getListApi: getPage.value //
})
tableObjectRef.value = tableObject
searchConditionRef.value = searchCondition
if (searchCondition) tableObjectRef.value.params = searchCondition;
//
const { getList } = tableMethods
// setSearchParamsRef.value = setSearchParams
setSearchParamsRef.value = tableObject.params
getListRef.value = getList
getList()
}
//
const searchFormClick = (searchData) => {
console.log(99, rowRef.value)
console.log(100, searchData)
console.log(101, searchConditionRef.value)
// 20240104 searchData.filters
// 20240321 searchData
if (searchData.filters) {
if (searchConditionRef.value.filters) {
Object.keys(searchConditionRef.value.filters).forEach(key => {
searchData.filters.push(searchConditionRef.value.filters[key])
});
} else {
Object.keys(searchConditionRef.value).forEach(key => {
searchData.filters.push({
action: "==",
column: key,
value: searchConditionRef.value[key]
})
});
}
} else {
if (searchConditionRef.value.filters) {
searchData.filters = searchConditionRef.value.filters
} else {
Object.keys(searchConditionRef.value).forEach(key => {
searchData.filters = [{
action: "==",
column: key,
value: searchConditionRef.value[key]
}]
});
}
}
tableObjectRef.value.params = {
isSearch: true,
filters: searchData.filters
}
getListRef.value() //
}
defineExpose({ open,openData }) // open
// Table ref
const searchTableRef = ref()
/** 提交表单 */
const emit = defineEmits(['searchTableSuccess']) // searchTableSuccess
const submitForm = async () => {
//
formLoading.value = true
const selections = searchTableRef.value.selections
//
if(!multipleBol.value){
if(selections.length > 1 || selections.length == 0) {
message.warning('请选择一条数据!')
formLoading.value = false
return
}
//
}else{
if(selections.length == 0) {
message.warning('至少选择一条数据!')
formLoading.value = false
return
}
}
try {
searchDialogVisible.value = false
//
emit('searchTableSuccess', formFieldRef.value, searchFieldRef.value, selections, typeRef.value, rowRef.value)
} finally {
formLoading.value = false
}
}
</script>
<style scoped lang="scss">
</style>

2
src/views/mes/orderDay/components/BasicFormV2.vue

@ -23,7 +23,7 @@
<SearchTable ref="searchTableRef" @searchTableSuccess="searchTableSuccess" /> <SearchTable ref="searchTableRef" @searchTableSuccess="searchTableSuccess" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { SearchTable } from '@/components/SearchTable' import { SearchTable } from '@/components/SearchTableV2'
import * as defaultButtons from '@/utils/disposition/defaultButtons' import * as defaultButtons from '@/utils/disposition/defaultButtons'
import ButtonBase from '@/components/XButton/src/ButtonBase.vue' import ButtonBase from '@/components/XButton/src/ButtonBase.vue'

Loading…
Cancel
Save