main
wangqiujuan0808 2024-10-15 15:47:11 +08:00
parent 2730102450
commit 05c24ea38e
1 changed files with 53 additions and 5 deletions

View File

@ -28,6 +28,19 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div>
<el-pagination
style="float:right"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="listQuery.page"
:page-sizes="[10, 30, 50]"
:page-size="listQuery.pageNum"
layout="total, sizes, prev, pager, next, jumper"
:total="totalNum"
>
</el-pagination>
</div>
</div> </div>
<AddMb :type="type" :formData="formData" :templateData="templateData" :dialogVisible="dialogVisible" <AddMb :type="type" :formData="formData" :templateData="templateData" :dialogVisible="dialogVisible"
v-if="dialogVisible" @dialogClose="dialogClose" @dialogSuccess="dialogSuccess"> v-if="dialogVisible" @dialogClose="dialogClose" @dialogSuccess="dialogSuccess">
@ -39,7 +52,7 @@
</template> </template>
<script> <script>
import { onMounted, reactive, ref, toRefs } from "vue"; import { onMounted, reactive, ref, toRefs, computed } from "vue";
import { ElMessage, ElMessageBox } from "element-plus"; import { ElMessage, ElMessageBox } from "element-plus";
import AddMb from "@/components/AddMb.vue"; import AddMb from "@/components/AddMb.vue";
import infoApi from "@/api/infoApi.js"; import infoApi from "@/api/infoApi.js";
@ -55,7 +68,8 @@ export default {
const state = reactive({ const state = reactive({
dialogVisible: false, dialogVisible: false,
dialogVisible2: false, dialogVisible2: false,
tableData: [], // tableData: [],
tableData1:[],
formData: { formData: {
template_name: '', template_name: '',
template_description: '', template_description: '',
@ -63,9 +77,30 @@ export default {
}, },
formData1: {}, formData1: {},
type: 'I', type: 'I',
templateData: {} templateData: {},
listQuery: {
page: 1,
pageNum: 10
}
}); });
const tableData = computed(() => {
//
const startIndex = (state.listQuery.page - 1) * state.listQuery.pageNum;
//
const endIndex = startIndex + state.listQuery.pageNum;
//
return state.tableData1.slice(startIndex, endIndex);
});
const totalNum = computed(() => {
return state.tableData1.length;
})
const total = computed(() => {
return Math.ceil(state.tableData1.length / state.listQuery.pageNum);
})
onMounted(() => { onMounted(() => {
getTemplateType(); getTemplateType();
getTableData(); getTableData();
@ -84,7 +119,7 @@ export default {
const res = await infoApi.getMb(); const res = await infoApi.getMb();
if (res.code == 0) { if (res.code == 0) {
// //
state.tableData = res.data && res.data.length > 0 && res.data.sort((a,b) => { state.tableData1 = res.data && res.data.length > 0 && res.data.sort((a,b) => {
return (a.name > b.name ? 1 : -1) return (a.name > b.name ? 1 : -1)
}); });
} else { } else {
@ -141,6 +176,14 @@ export default {
state.dialogVisible2 = false; state.dialogVisible2 = false;
getTableData(); getTableData();
}; };
const handleSizeChange =(val) => {
state.listQuery.pageNum = val;
}
const handleCurrentChange = (val) => {
state.listQuery.page = val;
}
return { return {
...toRefs(state), ...toRefs(state),
editData, editData,
@ -149,7 +192,12 @@ export default {
addData, addData,
dialogSuccess, dialogSuccess,
dialogClose, dialogClose,
viewData viewData,
tableData,
totalNum,
total,
handleSizeChange,
handleCurrentChange
}; };
}, },
}; };