Commit f7899557 by qinjianhui

feat: 代码优化

parent d70f0b3f
...@@ -33,7 +33,7 @@ export interface SearchForm { ...@@ -33,7 +33,7 @@ export interface SearchForm {
size?: string size?: string
logisticsCompanyCode?: string logisticsCompanyCode?: string
blocking?: boolean blocking?: boolean
standardDesignImage?: boolean standardDesignImage?: number
} }
export interface FactoryOrderNewListData { export interface FactoryOrderNewListData {
...@@ -91,15 +91,29 @@ export interface LogListData { ...@@ -91,15 +91,29 @@ export interface LogListData {
export interface BatchManageData { export interface BatchManageData {
id: number id: number
batchNo?: string factoryId?: number
downloadStatus?: string batchArrangeNum?: string
orderCount?: number billType?: string
totalCount?: number url?: string
creator?: string tiffUrl?: string
syntheticStatus?: boolean
downloadStatus?: boolean
productNum?: number
materialNum?: number
craftType?: string craftType?: string
timesRange?: string employeeAccount?: string
employeeId?: number
createTime?: string createTime?: string
extractTimes?: number failReason?: string
failTime?: string
automaticComposing?: boolean
composingParam?: string
printProductOrder?: boolean
printPickOrder?: boolean
prnUrl?: string
prnDownloadStatus?: string
enableArrange?: boolean
standardDesignImage?: number
} }
export interface RestockData { export interface RestockData {
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<div class="restock-table"> <div class="restock-table">
<TableView <TableView
v-loading="loading" v-loading="loading"
:paginated-data="pageData" :paginated-data="data"
:columns="columns" :columns="columns"
serial-numberable serial-numberable
> >
...@@ -66,29 +66,52 @@ ...@@ -66,29 +66,52 @@
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"
:total="total" :total="total"
style="margin: 10px auto 0;" style="margin: 10px auto 0;"
@size-change="handlePageSizeChange" @size-change="onPageSizeChange"
@current-change="handleCurrentPageChange" @current-change="onCurrentPageChange"
/> />
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref, reactive, onMounted } from 'vue' import { reactive } from 'vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { getRestockListApi, restockCheckApi } from '@/api/factoryOrderNew' import { getRestockListApi, restockCheckApi } from '@/api/factoryOrderNew'
import type { RestockData } from '@/types/api/factoryOrderNew' import type { RestockData } from '@/types/api/factoryOrderNew'
import type { PaginationData } from '@/types/api'
import type { CustomColumn } from '@/types/table' import type { CustomColumn } from '@/types/table'
import TableView from '@/components/TableView.vue' import TableView from '@/components/TableView.vue'
import usePageList from '@/utils/hooks/usePageList'
const loading = ref(false) const filterForm = reactive({
const allData = ref<RestockData[]>([]) stockSku: '',
const currentPage = ref(1) styleNo: '',
const pageSize = ref(50) })
const total = ref(0)
const pageData = computed(() => { const {
const start = (currentPage.value - 1) * pageSize.value loading,
return allData.value.slice(start, start + pageSize.value) currentPage,
pageSize,
total,
data,
onCurrentPageChange,
onPageSizeChange,
refresh,
} = usePageList<RestockData>({
initPageSize: 50,
query: async (current, size) => {
const res = await getRestockListApi({
stockSku: filterForm.stockSku || undefined,
styleNo: filterForm.styleNo || undefined,
})
const records = res.data || []
const start = (current - 1) * size
return {
total: records.length,
size,
current,
records: records.slice(start, start + size),
} as PaginationData<RestockData>
},
}) })
const columns: CustomColumn<RestockData>[] = [ const columns: CustomColumn<RestockData>[] = [
...@@ -154,69 +177,27 @@ const columns: CustomColumn<RestockData>[] = [ ...@@ -154,69 +177,27 @@ const columns: CustomColumn<RestockData>[] = [
}, },
] ]
const filterForm = reactive({
stockSku: '',
styleNo: '',
})
const loadData = async () => {
loading.value = true
try {
const res = await getRestockListApi({
stockSku: filterForm.stockSku || undefined,
styleNo: filterForm.styleNo || undefined,
})
allData.value = res.data || []
total.value = allData.value.length
} catch (_e) {
allData.value = []
total.value = 0
} finally {
loading.value = false
}
}
const handleSearch = () => { const handleSearch = () => {
currentPage.value = 1 refresh()
loadData()
} }
const handleReset = () => { const handleReset = () => {
filterForm.stockSku = '' filterForm.stockSku = ''
filterForm.styleNo = '' filterForm.styleNo = ''
currentPage.value = 1 refresh()
loadData()
}
const handlePageSizeChange = (size: number) => {
pageSize.value = size
currentPage.value = 1
}
const handleCurrentPageChange = (page: number) => {
currentPage.value = page
} }
const handleRestockCheck = async (row: RestockData) => { const handleRestockCheck = async (row: RestockData) => {
try { try {
await restockCheckApi(row.id) await restockCheckApi(row.id)
ElMessage.success('补货校验成功') ElMessage.success('补货校验成功')
loadData() refresh()
} catch (e) { } catch (e) {
const err = e as Error & { message?: string } const err = e as Error & { message?: string }
ElMessage.error(err?.message || '补货校验失败') ElMessage.error(err?.message || '补货校验失败')
} }
} }
const refresh = () => {
currentPage.value = 1
loadData()
}
onMounted(() => {
loadData()
})
defineExpose({ refresh }) defineExpose({ refresh })
</script> </script>
......
...@@ -1310,10 +1310,9 @@ const handleStatusNodeClick = (node: StatusTreeNode) => { ...@@ -1310,10 +1310,9 @@ const handleStatusNodeClick = (node: StatusTreeNode) => {
currentRow.value = null currentRow.value = null
productList.value = [] productList.value = []
logList.value = [] logList.value = []
// if (!isSpecialLayout.value) { if (!isSpecialLayout.value) {
// onCurrentPageChange(1) refresh()
// refresh() }
// }
} }
const toggleExpand = (node: { expanded?: boolean }) => { const toggleExpand = (node: { expanded?: boolean }) => {
node.expanded = !node.expanded node.expanded = !node.expanded
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment