export function useDataSource(propsRef, { getPaginationInfo, setPagination, setLoading, tableData }, emit) { | export function useDataSource(propsRef, { getPaginationInfo, setPagination, setLoading, tableData }, emit) { | ||||
const dataSourceRef = ref([]) | const dataSourceRef = ref([]) | ||||
const paginationPage = ref(1) | |||||
async function fetch(opt) { | async function fetch(opt) { | ||||
try { | try { | ||||
/* 设置loading */ | /* 设置loading */ | ||||
pageParams = {} | pageParams = {} | ||||
} else { | } else { | ||||
pageParams[pageField] = (opt && opt[pageField]) || page | pageParams[pageField] = (opt && opt[pageField]) || page | ||||
paginationPage.value = pageParams[pageField] | |||||
pageParams[sizeField] = pageSize | pageParams[sizeField] = pageSize | ||||
} | } | ||||
const params = { | const params = { | ||||
await fetch(opt) | await fetch(opt) | ||||
} | } | ||||
async function reFetch(opt) { | |||||
async function reFetch(opt, reload = true) { | |||||
const { paginationSetting } = unref(propsRef) | const { paginationSetting } = unref(propsRef) | ||||
const pageField = paginationSetting.pageField | const pageField = paginationSetting.pageField | ||||
const sizeField = paginationSetting.sizeField | const sizeField = paginationSetting.sizeField | ||||
const pageSize = paginationSetting.pageSize | const pageSize = paginationSetting.pageSize | ||||
setPagination({ | setPagination({ | ||||
[pageField]: 1, | |||||
[pageField]: reload ? 1 : paginationPage.value, | |||||
[sizeField]: pageSize | [sizeField]: pageSize | ||||
}) | }) | ||||
await fetch(opt) | await fetch(opt) |
analyseRef.value?.disposeVideo() | analyseRef.value?.disposeVideo() | ||||
data.videoInfo.origin.status = 'init' | data.videoInfo.origin.status = 'init' | ||||
data.videoInfo.analyse.status = 'init' | data.videoInfo.analyse.status = 'init' | ||||
data.videoShow = 'back' | |||||
data.mapData = null | data.mapData = null | ||||
} | } | ||||
}, { deep: true }) | }, { deep: true }) |
</template> | </template> | ||||
</DataTable> | </DataTable> | ||||
<ConfirmModal v-if="confirmModal" v-model:visible="confirmModal" :data="pageData" :select-row="rowData" @update-data="handleSearch" /> | |||||
<ConfirmModal v-if="confirmModal" v-model:visible="confirmModal" :data="pageData" :select-row="rowData" @update-data="handleReload" /> | |||||
<!-- 图片位置 --> | <!-- 图片位置 --> | ||||
<position-drawer v-model:visible="positionDrawer" :data="rowData" /> | <position-drawer v-model:visible="positionDrawer" :data="rowData" /> | ||||
missionId: props.data.id, | missionId: props.data.id, | ||||
...res | ...res | ||||
} | } | ||||
if (_params.status === 'all') _params.status = '' | |||||
if (_params.type === 'all') _params.type = null | |||||
return await getQuestionList(_params) | return await getQuestionList(_params) | ||||
} | } | ||||
} | } | ||||
} | } | ||||
function handleReload() { | |||||
data.handleSearch(data.searchParams, false) | |||||
} | |||||
return { | return { | ||||
...toRefs(data), | ...toRefs(data), | ||||
loadDataTable, | loadDataTable, | ||||
handleRowsCheck, | handleRowsCheck, | ||||
handleIgnoreBatch, | handleIgnoreBatch, | ||||
handleConfirmBatch, | handleConfirmBatch, | ||||
handleReported | |||||
handleReported, | |||||
handleReload | |||||
} | } | ||||
} | } |
const data = reactive([ | const data = reactive([ | ||||
{ | { | ||||
label: '任务状态', | |||||
key: 'status', | |||||
label: '问题类型', | |||||
key: 'type', | |||||
type: 'select', | type: 'select', | ||||
value: 'all', | value: 'all', | ||||
props: { | props: { | ||||
placeholder: '请选择任务状态', | |||||
placeholder: '请选择问题类型', | |||||
options: [ | options: [ | ||||
{ label: '全部', value: 'all' }, | { label: '全部', value: 'all' }, | ||||
...QUESTION_TYPE | ...QUESTION_TYPE |
const tableRef = ref() | const tableRef = ref() | ||||
const searchParams = ref() | const searchParams = ref() | ||||
function handleSearch(params) { | |||||
function handleSearch(params, reload = true) { | |||||
searchParams.value = { ...params } | searchParams.value = { ...params } | ||||
tableRef.value.reFetch({ searchParams }) | |||||
tableRef.value.reFetch({ searchParams }, reload) | |||||
} | } | ||||
/* 问题忽略 */ | /* 问题忽略 */ | ||||
.then(res => { | .then(res => { | ||||
if (res.code === 0) { | if (res.code === 0) { | ||||
data.selectRowKeys = [] | data.selectRowKeys = [] | ||||
handleSearch() | |||||
handleSearch(searchParams.value, false) | |||||
} | } | ||||
}) | }) | ||||
} | } | ||||
.then(res => { | .then(res => { | ||||
if (res.code === 0) { | if (res.code === 0) { | ||||
data.selectRowKeys = [] | data.selectRowKeys = [] | ||||
handleSearch() | |||||
handleSearch(searchParams.value, false) | |||||
} | } | ||||
}) | }) | ||||
} | } |