...pageParams | ...pageParams | ||||
} | } | ||||
const response = await request(params) | const response = await request(params) | ||||
const res = noPagination ? response : response.data | |||||
const res = noPagination ? response.data : response.data | |||||
const resultTotal = res[totalField] || 0 | const resultTotal = res[totalField] || 0 | ||||
const currentPage = res[listPageField] | const currentPage = res[listPageField] | ||||
// 如果数据异常,需获取正确的页码再次执行 | // 如果数据异常,需获取正确的页码再次执行 | ||||
} | } | ||||
// 处理数据结构 | // 处理数据结构 | ||||
const resultInfo = res[listField] ? res[listField] : res | const resultInfo = res[listField] ? res[listField] : res | ||||
dataSourceRef.value = dataType === 'tree' ? dealTree(resultInfo.data) : resultInfo | |||||
dataSourceRef.value = dataType === 'tree' ? dealTree(resultInfo) : resultInfo | |||||
setPagination({ | setPagination({ | ||||
[pageField]: currentPage, | [pageField]: currentPage, | ||||
[totalField]: Math.ceil(resultTotal / pageSize), | [totalField]: Math.ceil(resultTotal / pageSize), |
:columns="columns" | :columns="columns" | ||||
:row-key="(row) => row.id" | :row-key="(row) => row.id" | ||||
:request="loadDataTable" | :request="loadDataTable" | ||||
:pagination="false" | |||||
size="large" | size="large" | ||||
> | > | ||||
<template #tableTitle> | <template #tableTitle> | ||||
import HeadSearch from '@/components/Search/index.vue' | import HeadSearch from '@/components/Search/index.vue' | ||||
import DataTable from '@/components/DataTable/index.vue' | import DataTable from '@/components/DataTable/index.vue' | ||||
import MaterialModal from './MaterialModal.vue' | import MaterialModal from './MaterialModal.vue' | ||||
import { defineComponent, reactive, unref, toRefs, computed, watch } from 'vue' | |||||
import { defineComponent, reactive, unref, toRefs, computed } from 'vue' | |||||
import { goodsList } from '@/api/basic/material.js' | import { goodsList } from '@/api/basic/material.js' | ||||
export default defineComponent({ | export default defineComponent({ |
import { h, ref, reactive } from 'vue' | import { h, ref, reactive } from 'vue' | ||||
import TableImage from '@/components/DataTable/tools/Image.vue' | |||||
import TableTags from '@/components/DataTable/tools/Tags.vue' | import TableTags from '@/components/DataTable/tools/Tags.vue' | ||||
import TableSwitch from '@/components/DataTable/tools/Switch.vue' | |||||
import TableAction from '@/components/DataTable/tools/Action.vue' | import TableAction from '@/components/DataTable/tools/Action.vue' | ||||
import { MATERIAL_TYPE } from '@/utils/dictionary.js' | |||||
import { deleteGoods } from '@/api/basic/material.js' | import { deleteGoods } from '@/api/basic/material.js' | ||||
/* 注册table */ | /* 注册table */ | ||||
{ | { | ||||
title: '物资类型', | title: '物资类型', | ||||
key: 'goodsType', | key: 'goodsType', | ||||
align: 'center' | |||||
align: 'center', | |||||
render(row) { | |||||
return h(TableTags, { | |||||
data: row.goodsType, | |||||
filters: MATERIAL_TYPE | |||||
}) | |||||
} | |||||
}, | }, | ||||
{ | { | ||||
title: '物资库存', | title: '物资库存', |