获取当前数据 上下移动

点击按钮  上下移动 当前数据

 

 代码

// 出国境管理  登记备案人员列表
<template>
	<a-row>
		<a-col span="24">
			<a-card :class="style['a-table-wrapper']">
				<!-- 出国境 登记备案人员列表 -->
				<a-table
					:rowKey="records => records.id"
					:columns="columns"
					:loading="tableLoading"
					v-model:data-source="checkInList"
					style="margin-top: 1em"
					:bordered="true"
					@change="onTableChange"
					:scroll="{ x: 2000 }"
					size="small"
					:pagination="tablePagination"
				>
					<!-- 序号 -->
					<template #index="{ index }">
						{{
							(tablePagination.current - 1) *
								tablePagination.pageSize +
							index +
							1
						}}
					</template>
					<template #operation="{ record, index }">
						<!-- 上移 -->
						<a-button
							type="link"
							:disabled="index == 0"
							@click="toUpButtonClick(record, index)"
						>
							{{ getI18n('common', 'Common_Up') }}
						</a-button>
						<!-- 下移 -->
						<a-button
							type="link"
							:disabled="index == checkInList.length - 1"
							@click="toDownButtonClick(record, index)"
						>
							{{ getI18n('common', 'Common_Down') }}
						</a-button>
					</template>
				</a-table>
			</a-card>
		</a-col>
	</a-row>
</template>
<script lang="ts">
import { defineComponent, reactive, ref, onMounted } from 'vue' // ,PropType computed watch

import {
	FrontierCheckinListSearchModal,
	FrontierCheckinEditModal,
} from '../components'
import { getI18n } from '@/utils/i18n'
import { getDayText, getButtonPermission } from '@/utils/tool/translateValue'
import { AntdPaginationType } from '@/types/antd'
import { PaginationData, RequestResult } from '@/utils/request/model'
import { CommonConstant } from '@/utils/constant'
import style from './index.module.less'
import {
	GetFrontierCheckInPageParamsModel,
	GetFrontierCheckInPageModel,
} from '@/api/system/frontier-checkIn/model'
import { getFrontierCheckInPageApi } from '@/api/system/frontier-checkIn'
import router from '@/router'

const columns = [
	// 姓名
	{
		title: getI18n('system', 'SYSTEM_Frontier_Name'),
		dataIndex: 'fullName',
		align: 'center',
		width: 150,
		fixed: 'left',
	},
	// 排序
	{
		title: getI18n('system', 'SYSTEM_Adjust_SortNo'),
		dataIndex: 'sort',
		align: 'center',
		slots: { customRender: 'sort' },
		width: '4%',
	},
	// 身份证号
	{
		title: getI18n('system', 'SYSTEM_Frontier_IdCard'),
		dataIndex: 'idcard',
		align: 'center',
		width: 200,
	},
	// 职务职级
	{
		title: getI18n('system', 'SYSTEM_Frontier_Postrank'),
		dataIndex: 'positionRank',
		align: 'center',
		width: 200,
	},
	// 备注
	{
		title: getI18n('system', 'SYSTEM_Frontier_Remarks'),
		dataIndex: 'notes',
		align: 'center',
	},

	// 操作
	{
		title: getI18n('common', 'Common_Action'),
		align: 'center',
		key: 'operation',
		width: 140,
		fixed: 'right',
		slots: { customRender: 'operation' },
	},
]

export default defineComponent({
	components: {
		FrontierCheckinListSearchModal,
		FrontierCheckinEditModal,
		// BasicSiderMenu,
	},
	setup() {
		// 列表loading
		const tableLoading = ref<boolean>(false)
		// 列表数据
		const checkInList = ref<GetFrontierCheckInPageModel[]>([])
		// 获取列表参数
		const secrecyListParams = reactive<GetFrontierCheckInPageParamsModel>({
			current: 1,
			size: 10,
		})

		// 列表分页
		const tablePagination = reactive<AntdPaginationType>({
			current: 1,
			pageSize: 10,
			total: 0,
			showSizeChanger: true,
			showQuickJumper: true,
			pageSizeOptions: ['10', '20', '30', '40', '50'],
			showTotal: (total: number) =>
				getI18n('common', 'Common_Table_Total', [total.toString()]),
		})

		// 获取表单列表数据
		const getFrontierCheckInList = async () => {
			tableLoading.value = true
			const res: RequestResult<
				PaginationData<GetFrontierCheckInPageModel>
			> = await getFrontierCheckInPageApi(secrecyListParams).finally(
				() => {
					tableLoading.value = false
					// searchLoading.value = false
				}
			)
			checkInList.value = res.data.records
			tablePagination.current = res.data.current
			tablePagination.pageSize = res.data.size
			tablePagination.total = res.data.total
		}

		onMounted(() => {
			getFrontierCheckInList()
		})

		// 上移
		const toUpButtonClick = async (data, index) => {
			if (index > 0) {
				const itemToMove = checkInList.value[index]
				checkInList.value.splice(index, 1) // 从数组中移除
				checkInList.value.splice(index - 1, 0, itemToMove) // 在前一个位置插入
			}
			console.log(checkInList.value[index - 1].id, '上一条')
			console.log(checkInList.value[index].id, '当前')
		}

		// 下移
		const toDownButtonClick = async (data, index) => {
			if (index < checkInList.value.length - 1) {
				const itemToMove = checkInList.value[index]
				checkInList.value.splice(index, 1) // 从数组中移除
				checkInList.value.splice(index + 1, 0, itemToMove) // 在后一个位置插入
			}
			console.log(checkInList.value[index].id, '当前')
			console.log(checkInList.value[index + 1].id, '下一条')
			// debugger
		}

		return {
			toUpButtonClick,
			toDownButtonClick,

			style,
			columns,
			tablePagination,
			tableLoading,
			checkInList,
			getDayText,
			getI18n,
			getFrontierCheckInList,

			CommonConstant,
			getButtonPermission,

			router,
		}
	},
})
</script>

// 出国境管理  登记备案人员列表
<template>
	<a-row>
		<a-col span="24">
			<a-card :class="style['a-table-wrapper']">
				<!-- 出国境 登记备案人员列表 -->
				<a-table
					:rowKey="records => records.id"
					:columns="columns"
					:loading="tableLoading"
					v-model:data-source="checkInList"
					style="margin-top: 1em"
					:bordered="true"
					@change="onTableChange"
					:scroll="{ x: 2000 }"
					size="small"
					:pagination="tablePagination"
				>
					<!-- 序号 -->
					<template #index="{ index }">
						{{
							(tablePagination.current - 1) *
								tablePagination.pageSize +
							index +
							1
						}}
					</template>
					<template #operation="{ record, index }">
						<!-- 上移 -->
						<a-button
							type="link"
							:disabled="index == 0"
							@click="toUpButtonClick(record, index)"
						>
							{{ getI18n('common', 'Common_Up') }}
						</a-button>
						<!-- 下移 -->
						<a-button
							type="link"
							:disabled="index == checkInList.length - 1"
							@click="toDownButtonClick(record, index)"
						>
							{{ getI18n('common', 'Common_Down') }}
						</a-button>
					</template>
				</a-table>
			</a-card>
		</a-col>
	</a-row>
</template>
<script lang="ts">
import { defineComponent, reactive, ref, onMounted } from 'vue' // ,PropType computed watch

import {
	FrontierCheckinListSearchModal,
	FrontierCheckinEditModal,
} from '../components'
import { getI18n } from '@/utils/i18n'
import { getDayText, getButtonPermission } from '@/utils/tool/translateValue'
import { AntdPaginationType } from '@/types/antd'
import { PaginationData, RequestResult } from '@/utils/request/model'
import { CommonConstant } from '@/utils/constant'
import style from './index.module.less'
import {
	GetFrontierCheckInPageParamsModel,
	GetFrontierCheckInPageModel,
} from '@/api/system/frontier-checkIn/model'
import { getFrontierCheckInPageApi } from '@/api/system/frontier-checkIn'
import router from '@/router'

const columns = [
	// 姓名
	{
		title: getI18n('system', 'SYSTEM_Frontier_Name'),
		dataIndex: 'fullName',
		align: 'center',
		width: 150,
		fixed: 'left',
	},
	// 排序
	{
		title: getI18n('system', 'SYSTEM_Adjust_SortNo'),
		dataIndex: 'sort',
		align: 'center',
		slots: { customRender: 'sort' },
		width: '4%',
	},
	// 身份证号
	{
		title: getI18n('system', 'SYSTEM_Frontier_IdCard'),
		dataIndex: 'idcard',
		align: 'center',
		width: 200,
	},
	// 职务职级
	{
		title: getI18n('system', 'SYSTEM_Frontier_Postrank'),
		dataIndex: 'positionRank',
		align: 'center',
		width: 200,
	},
	// 备注
	{
		title: getI18n('system', 'SYSTEM_Frontier_Remarks'),
		dataIndex: 'notes',
		align: 'center',
	},

	// 操作
	{
		title: getI18n('common', 'Common_Action'),
		align: 'center',
		key: 'operation',
		width: 140,
		fixed: 'right',
		slots: { customRender: 'operation' },
	},
]

export default defineComponent({
	components: {
		FrontierCheckinListSearchModal,
		FrontierCheckinEditModal,
		// BasicSiderMenu,
	},
	setup() {
		// 列表loading
		const tableLoading = ref<boolean>(false)
		// 列表数据
		const checkInList = ref<GetFrontierCheckInPageModel[]>([])
		// 获取列表参数
		const secrecyListParams = reactive<GetFrontierCheckInPageParamsModel>({
			current: 1,
			size: 10,
		})

		// 列表分页
		const tablePagination = reactive<AntdPaginationType>({
			current: 1,
			pageSize: 10,
			total: 0,
			showSizeChanger: true,
			showQuickJumper: true,
			pageSizeOptions: ['10', '20', '30', '40', '50'],
			showTotal: (total: number) =>
				getI18n('common', 'Common_Table_Total', [total.toString()]),
		})

		// 获取表单列表数据
		const getFrontierCheckInList = async () => {
			tableLoading.value = true
			const res: RequestResult<
				PaginationData<GetFrontierCheckInPageModel>
			> = await getFrontierCheckInPageApi(secrecyListParams).finally(
				() => {
					tableLoading.value = false
					// searchLoading.value = false
				}
			)
			checkInList.value = res.data.records
			tablePagination.current = res.data.current
			tablePagination.pageSize = res.data.size
			tablePagination.total = res.data.total
		}

		onMounted(() => {
			getFrontierCheckInList()
		})

		// // 上移
		// const toUpButtonClick = async (data, index) => {
		// 	if (index > 0) {
		// 		const itemToMove = checkInList.value[index]
		// 		checkInList.value.splice(index, 1) // 从数组中移除
		// 		checkInList.value.splice(index - 1, 0, itemToMove) // 在前一个位置插入
		// 	}
		// 	console.log(checkInList.value[index - 1].id, '上一条')
		// 	console.log(checkInList.value[index].id, '当前')
		// }

		// // 下移
		// const toDownButtonClick = async (data, index) => {
		// 	if (index < checkInList.value.length - 1) {
		// 		const itemToMove = checkInList.value[index]
		// 		checkInList.value.splice(index, 1) // 从数组中移除
		// 		checkInList.value.splice(index + 1, 0, itemToMove) // 在后一个位置插入
		// 	}
		// 	console.log(checkInList.value[index].id, '当前')
		// 	console.log(checkInList.value[index + 1].id, '下一条')
		// 	// debugger
		// }

		// 假设你有一个用于保存数据的API接口,其URL为'https://example.com/save-data'  
const apiUrl = 'https://example.com/save-data';  
  
  // 用于发送POST请求的函数  
  const postData = async (data) => {  
	try {  
	  const response = await fetch(apiUrl, {  
		method: 'POST',  
		headers: {  
		  'Content-Type': 'application/json',  
		},  
		body: JSON.stringify(data),  
	  });  
	
	  if (!response.ok) {  
		throw new Error(`HTTP error! status: ${response.status}`);  
	  }  
	
	  return response.json();  
	} catch (error) {  
	  console.error('Error:', error);  
	}  
  };  
	
  // 上移  
  const toUpButtonClick = async (data, index) => {  
	if (index > 0) {  
	  const itemToMove = checkInList.value[index];  
	  checkInList.value.splice(index, 1); // 从数组中移除  
	  checkInList.value.splice(index - 1, 0, itemToMove); // 在前一个位置插入  
	
	  // 调用接口保存数据  
	  await postData({  
		action: 'moveUp',  
		data: itemToMove,  
	  });  
	}  
	
	console.log(checkInList.value[index - 1].id, '上一条');  
	console.log(checkInList.value[index].id, '当前');  
  };  
	
  // 下移  
  const toDownButtonClick = async (data, index) => {  
	if (index < checkInList.value.length - 1) {  
	  const itemToMove = checkInList.value[index];  
	  checkInList.value.splice(index, 1); // 从数组中移除  
	  checkInList.value.splice(index + 1, 0, itemToMove); // 在后一个位置插入  
	
	  // 调用接口保存数据  
	  await postData({  
		action: 'moveDown',  
		data: itemToMove,  
	  });  
	}  
	
	console.log(checkInList.value[index].id, '当前');  
	console.log(checkInList.value[index + 1].id, '下一条');  
  };
		return {
			toUpButtonClick,
			toDownButtonClick,

			style,
			columns,
			tablePagination,
			tableLoading,
			checkInList,
			getDayText,
			getI18n,
			getFrontierCheckInList,

			CommonConstant,
			getButtonPermission,

			router,
		}
	},
})
</script>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/418717.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【Java】查看class文件的jdk编译版本的两种方式

一、使用文本编辑工具EditPlus 使用EditPlus打开该class文件&#xff0c;字符集选择16进制&#xff08;Hex viewer&#xff09;。 仅看第一行数据&#xff0c;前面8个字节CA FE BA BE是固定的。 之后4个字节00 00 是次版本。 次版本后面的4个字节00 34 就是jdk版本。 jdk版本…

Java代码块

Java代码块 普通代码块 普通代码块在对象创建时执行&#xff0c;创建一个对象就会执行一次&#xff0c;可把构造函数中的冗余代码放到普通代码块中 public class Test {public void method() {// 普通代码块{int x 10;System.out.println(x);}public method(){}} }普通代码块…

使用mininet快速入门ONOS路由交换技术与原理-路由篇

上篇文章 《使用mininet快速入门ONOS路由交换技术与原理-交换篇》 使用mininet搭建了一个简单的网络拓扑&#xff0c;并实现了同一交换机下同网段多主机的通信&#xff0c;其中涉及到的通信知识主要以二层mac地址通信为主。 但在芸芸网络的世界中&#xff0c;主机间的通信除了…

Education Codeforces Round 162(Div.2) A~E

A.Moving Chips (思维) 题意&#xff1a; 给一个长度为 n n n的数组 a a a&#xff0c; a i 1 a_i1 ai​1或者 a i 0 a_i0 ai​0&#xff0c;现在可以选择一个 1 1 1&#xff0c;然后将其与左侧最近的 0 0 0交换。询问使得所有的 1 1 1连在一起&#xff0c;中间没有 0 0 0…

Vue+SpringBoot打造不良邮件过滤系统

目录 一、摘要1.1 项目介绍1.2 项目录屏 二、功能模块2.1 系统用户模块2.2 收件箱模块2.3 发件箱模块2.4 垃圾箱模块2.5 回收站模块2.6 邮箱过滤设置模块 三、实体类设计3.1 系统用户3.2 邮件3.3 其他实体 四、系统展示五、核心代码5.1 查询收件箱档案5.2 查询回收站档案5.3 新…

js 面试 1判断变量是否是数组 2 检测数据类型方法

1 是否是数组 1) typeof 检测数据类型运算符 优点&#xff1a;使用简单 缺点&#xff1a;只能检测基本类型&#xff08;除null外&#xff09; console.log(typeof(10)) //Number console.log(typeof(false)) //boolean console.log(typeof(hello)) //string console.log(typeof…

LeetCode 刷题 [C++] 第236题.二叉树的最近公共祖先

题目描述 给定一个二叉树, 找到该树中两个指定节点的最近公共祖先。 百度百科中最近公共祖先的定义为&#xff1a;“对于有根树 T 的两个节点 p、q&#xff0c;最近公共祖先表示为一个节点 x&#xff0c;满足 x 是 p、q 的祖先且 x 的深度尽可能大&#xff08;一个节点也可以…

【网络编程】理解客户端和服务器并使用Java提供的api实现回显服务器

目录 一、网络编程 二、客户端和服务器 三、客户端和服务器的交互模式 四、TCP 和 UDP UDP socket api 的使用 1、DatagramSoket 2、DatagramPacket TCP socket api 的使用 1、ServerSocket 2、Socket 一、网络编程 本质上就是学习传输层给应用层提供的 api&#x…

MySQL之事务详解

华子目录 什么是事务银行转账案例方式1方式2具体操作 事务的四大特性并发事务问题脏读不可重复读幻读 事务的隔离级别查看事务隔离级别设置事务隔离级别 session与global的区别 什么是事务 事务&#xff08;transaction&#xff09;&#xff0c;一个最小的不可再分的工作单元&…

实例:NX二次开发抽取平面以及标准柱面中心线

一、概述 最近体验许多外挂&#xff0c;包括胡波外挂、星空外挂及模圣等都有抽取面的中心线&#xff0c;由于刚刚学习&#xff0c;我尝试看看能不能做出来&#xff0c;本博客代码没有封装函数&#xff0c;代码有待改进&#xff0c;但基本可以实现相应的功能。 二、案例实现的功…

Sora 原理与技术实战笔记一

b 站视频合集 【AIX组队学习】Sora原理与技术实战&#xff1a;Sora技术路径详解 Sora 技术报告&#xff08;OpenAI&#xff09; huggingsd 文生图视频系列的一个开源项目 最强视频生成模型Sora相关技术解析 https://github.com/lichao-sun/SoraReview 惊艳效果&#xff1a; 长…

Ps:路径面板

Ps菜单&#xff1a;窗口/路径 Window/Paths “路径”面板 Paths Panel提供了一系列功能&#xff0c;使用户能够创建、编辑、保存和利用路径。 ◆ ◆ ◆ 路径分类 在“路径”面板上的路径可分为五大类。 常规路径 Saved Path 也称“已保存的路径”&#xff0c;指的是已经存储在…

Python进阶学习:Pandas--DataFrame--如何把几列数据合并成新的一列

Python进阶学习&#xff1a;Pandas–DataFrame–如何把几列数据合并成新的一列 &#x1f308; 个人主页&#xff1a;高斯小哥 &#x1f525; 高质量专栏&#xff1a;Matplotlib之旅&#xff1a;零基础精通数据可视化、Python基础【高质量合集】、PyTorch零基础入门教程&#x1…

SpringMVC的配置2种(本质上还是一样的,实现的接口不同)

第一种SpringInitConfig extends AbstractAnnotationConfigDispatcherServletInitializer 看第一种配置 package com.xxx.config; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; public class SpringInitConfig ext…

减少页面加载时间:提升用户体验的关键

✨✨ 祝屏幕前的您天天开心&#xff0c;每天都有好运相伴。我们一起加油&#xff01;✨✨ &#x1f388;&#x1f388;作者主页&#xff1a; 喔的嘛呀&#x1f388;&#x1f388; 目录 引言 一、为什么页面加载时间重要&#xff1f; 二、如何减少页面加载时间&#xff1f; …

Google发布Genie硬杠Sora:通过大量无监督视频训练最终生成可交互虚拟世界

前言 Sora 问世才不到两个星期&#xff0c;谷歌的世界模型也来了&#xff0c;能力看似更强大(嗯&#xff0c;看似)&#xff1a;它生成的虚拟世界自主可控 第一部分 首个基础世界模型Genie 1.1 Genie是什么 Genie是第一个以无监督方式从未标记的互联网视频中训练的生成式交互…

UDP数据报套接字编程入门

目录 1.TCP和UDP的特点及区别 1.1TCP的特点 1.2UDP的特点 1.3区别 2.UDP Socket的api的介绍 2.1DatagramSocket API 2.2DatagramPacket API 3.回显客户端与服务器 3.1回显服务器 3.1.1UdpEchoServer类的创建 3.1.2服务器的运行方法start() 3.1.3main部分 3.1.4.完整…

nginx反向代理之缓存 客户端IP透传 负载均衡

一 缓存功能 缓存功能可以加速访问&#xff0c;如果没有缓存关闭后端服务器后&#xff0c;图片将无法访问&#xff0c;缓存功能默认关闭&#xff0c;需要开启。 相关选项&#xff1a; ​ proxy_cache zone_name | off; 默认off #指明调用的缓存&#xff0c;或关闭缓存机制;C…

【C++初阶】第四站:类和对象(下)(理解+详解)

前言&#xff1a; 本篇知识点&#xff1a;初始化列表、explicit关键字、static成员、友元、内部类、匿名对象、编译器的优化 专栏&#xff1a;C初阶 目录 再谈构造函数 1️⃣构造函数体赋值 2️⃣初始化列表 explicit关键字 static成员 1.static概念 2.static特性 面试…

Docker技术概论(4):Docker CLI 基本用法解析

Docker技术概论&#xff08;4&#xff09; Docker CLI 基本用法解析 - 文章信息 - Author: 李俊才 (jcLee95) Visit me at: https://jclee95.blog.csdn.netMy WebSite&#xff1a;http://thispage.tech/Email: 291148484163.com. Shenzhen ChinaAddress of this article:http…
最新文章