a-table单元格指定合并以及表格双击编辑以及未填写指定验证功能

文章目录

  • a-table单元格指定合并以及表格双击编辑以及未填写指定验证功能
    • 一、 a-table单元格指定合并
      • 1. a-table
      • 2. columns
      • 3. 图例
    • 二、a-table 表格双击编辑以及未填写验证
      • 1. a-table
      • 2. js
      • 3. 图例

a-table单元格指定合并以及表格双击编辑以及未填写指定验证功能

一、 a-table单元格指定合并

1. a-table

				<a-tableref="table":pagination="{position: ['none']}":columns="columns":dataSource="tableData":alert="false":row-key="(record) => record.id"bordered></a-table>

2. columns

columns.value = [{title: '序号',dataIndex: 'index',align: 'center',width: '300px',customRender: function ({ text, record, index }) {if (record.objectName === '单元测评结果(符合/部分符合/不符合/不适用)') {return record.objectName} else {return index + 1}},customCell: (data, index) => {if (data.objectName === '单元测评结果(符合/部分符合/不符合/不适用)') {return {colSpan: 2}} else {return { colSpan: 1 }}}},{title: '测评对象',dataIndex: 'objectName',align: 'center',width: '300px',customCell: (data, index) => {if (data.objectName === '单元测评结果(符合/部分符合/不符合/不适用)') {return {colSpan: 0}} else {return { colSpan: 1 }}}},{title: '测评指标符合情况(符合/部分符合/不符合/不适用)',dataIndex: 'content1',align: 'center',width: '300px',children: [{title: '身份鉴别',dataIndex: '9',align: 'center',width: '300px'},{title: '远程管理通道安全',dataIndex: '10',align: 'center',width: '300px'},{title: '系统资源访问控制信息完整性',dataIndex: '11',align: 'center',width: '300px'},{title: '重要信息资源安全标记完整性',dataIndex: '12',align: 'center',width: '300px'},{title: '日志记录完整性',dataIndex: '13',align: 'center',width: '300px'},{title: '重要可执行程序完整性、重要可执行程序来源真实性',dataIndex: '14',align: 'center',width: '300px'}]}]

3. 图例

在这里插入图片描述

二、a-table 表格双击编辑以及未填写验证

1. a-table

		<a-tablestyle="width: 100%"bordered:dataSource="tableData"ref="selection":pagination="false":columns="columns":customRow="Rowclick":row-key="(record) => record.evaluationEnvironmentId":class="{ 'no-hover': disableHover }"><template #bodyCell="{ column, index, record }"><template v-if="column.key === 'handle'"><a-space><a-button type="primary" danger @click="onDelete(record, index)" :disabled="isReview"> 删除 </a-button><a-buttontype="primary"@click="getModifications(record, index)":disabled="isReview"v-if="record.checkState == '0' || !record.checkState"style="background: rgb(183 175 175); border: none">后续修改</a-button><a-buttontype="primary"@click="getModifications(record, index)":disabled="isReview"v-if="record.checkState == '1'"style="background: #f88f5e; border: none">后续修改<CloseCircleFilled /></a-button></a-space></template></template></a-table>

2. js

子组件内容

//双击编辑

const Rowclick = (columns, index, record) => {return {onClick: (event) => {if (!isReview) {//isReview为验证在什么条件下可以编辑/不可以编辑if (currentRowIndex.value != undefined) {if (currentRowIndex.value != index) {lastRowIndex.value = currentRowIndex.value}}currentRowIndex.value = indexconst cellElement = event.target.closest('td')if (cellElement) {currentColumnIndex.value = cellElement.cellIndex}}},onDblclick: (event) => {console.log(isReview,'isReview')if (!isReview) {if (lastRowIndex.value != undefined) {if (lastRowIndex.value != index) {if (cloneDataList.value[index]) {cloneDataList.value[index].editting = {}}}}const cellElement = event.target.closest('td')const dataIndex = props.columns[cellElement.cellIndex].keycloneDataList.value[index].editting = {}cloneDataList.value[index].editting[dataIndex] = truepasteStatus.value = false}}}}

//可以复制

const pasteInfo = (e) => {if (!isReview) {try {if (pasteStatus.value) {//获得粘贴的文字var data = nullvar clipboardData = e.clipboardData // IEif (!clipboardData) {//chromeclipboardData = e.originalEvent.clipboardData}data = clipboardData.getData('Text')var rowStrArray = data.split('\n')rowsInfo.value = []for (var i = 0; i < rowStrArray.length - 1; i++) {var row = []var tdStrArray = rowStrArray[i].split('\t')for (var j = 0; j < tdStrArray.length; j++) {row.push(tdStrArray[j].replace('\r', ''))}rowsInfo.value.push(row)}let tableLength = props.tableData.lengthfor (var j = 0; j < rowsInfo.value.length; j++) {if (currentRowIndex.value + j >= tableLength) {addLine()}temp.value = JSON.parse(JSON.stringify(props.tableData[currentRowIndex.value + j]))let num = 0let numFlag = 0for (var key in props.emptyObj) {if (!rowsInfo.value[j][num]) {break}if (currentColumnIndex.value - 2 <= numFlag) {temp.value[key] = rowsInfo.value[j][num]if (temp.value.cellClassName && temp.value.cellClassName[key]) {delete temp.value.cellClassName[key]}num = num + 1}numFlag = numFlag + 1}// this.$set(tableData.value, currentRowIndex.value+j, temp.value)props.tableData[currentRowIndex.value + j] = temp.value}window.localStorage.setItem('editTableLength', props.tableData.length)cloneDataList.value = JSON.parse(JSON.stringify(props.tableData)).map((item) => {item.editting = falsereturn item})}} catch (err) {message.error({content: '请选择复制位置'})}}}

//获取tableData

	const init = () => {cloneDataList.value = JSON.parse(JSON.stringify(props.tableData)).map((item, index) => {item.editting = falsereturn item})props.columns.forEach((item, index) => {// if (item.editable) {// $set(item, 'renderHeader', (h, params) => {// return h('div', [h('span', {//   domProps: {//     innerHTML: item.title//   },// }),// ])// });// }//如果含有editable属性并且为trueif (item.editable) {item.customRender = function ({ text, record, index, column }) {var currentRow = cloneDataList.value[index]if (!currentRow.editting[item.key]) {if (item.date) {return h('span', currentRow[item.key])}// 下拉类型中value与label不一致时单独渲染if (item.option) {// 我这里为了简单的判断了第一个元素为object的情况,其实最好用every来判断所有元素if (typeof item.option[0] === 'object') {if (item.multiple) {let arr1 = [],arrif (typeof currentRow[item.key] == 'string' && currentRow[item.key])arr = currentRow[item.key].split(',')else arr = currentRow[item.key]arr &&arr.length > 0 &&arr.forEach((optionItem) => {// arr1.push(item.option.find(findObjectInOption(optionItem)).label)arr1.push(item.option.find(findObjectInOption(optionItem))? item.option.find(findObjectInOption(optionItem)).label: optionItem)})return h('span', {}, arr1.join())} else {// let params = item.option.find(findObjectInOption(currentRow[item.key])) ? item.option.find(findObjectInOption(currentRow[item.key])).label : '请选择'let params = item.option.find(findObjectInOption(currentRow[item.key]))? item.option.find(findObjectInOption(currentRow[item.key])).label: currentRow[item.key]return h('span', {}, params)}}}return h('span', currentRow[item.key])} else {if (item.option) {//  && typeof currentRow[column.key] == 'string'if (item.multiple) {// let arr = currentRow[column.key].split(',')let arr = currentRow[column.key]if (arr == '请选择') {arr = undefined}return h(Select, {placeholder: '请选择',value: arr,options: item.option,mode: 'multiple',style: { width: '100%' },onChange: (value) => {// if(!value){//   currentRow[column.key] ='请选择'// }else{//   currentRow[column.key] = value// }currentRow[column.key] = valuesaveData(currentRow, index, column.key, value)},onClear: function () {}})} else {return h(Select, {placeholder: '请选择',value: currentRow[column.key],options: item.option,style: { width: '100%' },onChange: (value) => {if (value.length == 0) {currentRow[column.key] = '请选择'} else {currentRow[column.key] = value}saveData(currentRow, index, column.key, value)}})}} else if (item.date) {//如果含有date属性return h('DatePicker', {props: {type: item.date.split('_')[0] || 'date',clearable: false,value: currentRow[params.column.key]},on: {'on-change': function (value) {self.$set(currentRow, params.column.key, value)}}})} else {return h(Input, {placeholder: '请输入',// value: currentRow[column.key] = '未填写'? undefined:currentRow[column.key],value: currentRow[column.key],onChange: (event) => {currentRow[column.key] = event.target.valuesaveData(currentRow, index, column.key, event.target.value)},onBlur: (event) => {cloneDataList.value[index].editting = {}if (event.target.value == '') {currentRow[column.key] = '未填写'}saveData(currentRow, index, column.key, event.target.value)}})}}}} else {if (item.key == 'orderNum') {item.customRender = function ({ text, record, index }) {return index + 1}}}// 使用$set 可以触发视图更新// 如果含有titleHtml属性 将其值填入表头if (item.children) {item.children.forEach((child) => {if (child.editable) {child.render = function (h, params) {var currentRow = self.cloneDataList[params.index]// 非编辑状态if (!currentRow.editting) {// 日期类型单独 渲染(利用工具暴力的formatDate格式化日期)if (child.date) {// return h('span', self.utils.formatDate(currentRow[item.key], item.date.split('_')[1]))return h('span', currentRow[child.key])}// 下拉类型中value与label不一致时单独渲染if (child.option) {// 我这里为了简单的判断了第一个元素为object的情况,其实最好用every来判断所有元素if (typeof child.option[0] === 'object') {let params = child.option.find(findObjectInOption(currentRow[child.key]))? child.option.find(findObjectInOption(currentRow[child.key])).label: currentRow[child.key]return h('span', {}, params)}}return h('span', currentRow[child.key])} else {// 编辑状态//如果含有option属性if (child.option) {return h('Select',{props: {// ***重点***:  这里要写currentRow[params.column.key],绑定的是cloneDataList里的数据value: currentRow[params.column.key],transfer: true,filterable: true},on: {'on-change': function (value) {self.$set(currentRow, params.column.key, value)}}},child.option.map(function (child) {return h('Option',{props: {value: child.value,label: child.label}},child.label)}))} else if (child.date) {//如果含有date属性return h('DatePicker', {props: {type: child.date.split('_')[0] || 'date',clearable: false,value: currentRow[params.column.key]},on: {'on-change': function (value) {self.$set(currentRow, params.column.key, value)}}})} else {return h('input', {props: {// type类型也是自定的属性type: child.input || 'text',// rows只有在input 为textarea时才会起作用rows: 3,// disabled: (params.row.type == '1' || params.row.type == '2') && (child.key == 'evaluationtDocumentsName' || child.key == 'content') ? true : false,value: currentRow[params.column.key],placeholder: child.placeholder ? item.placeholder : ''},on: {'on-change'(event) {self.$set(currentRow, params.column.key, event.target.value)}}})}}}}})}})}

中间组件
//editTable

		<editTable:emptyObj="emptyObj":columns="columns"ref="editTables":tableData="tableData":reviewShow="reviewShow"v-if="refresh_2"></editTable>

//消息保存验证

	const getFormData = async () => {let flag = falsesubDataList.value = []let saveFlag = true// 创建一个 Promise 数组来处理异步操作const promises = []tableData.value.forEach((item, index) => {//判断多出来的一行保存的时候不保存最后一行if (tableData.value.length - 1 == index && JSON.stringify(item) == JSON.stringify(emptyObj.value)) {console.log('空白行')} else {item.cellClassName = {};item.evaluationId = route.query.evaluationIditem.evaluationInformationId = route.query.evaluationInformationIdfor (var key in item) {if (emptyObj.value.hasOwnProperty(key)) {if ((item[key] === '' || item[key] === '未填写' || item[key] === '请选择') && key != 'remark') {item.cellClassName[key] = 'demo-table-info-cell-name'columns.value.forEach((item_1, index_1) => {if (item_1.key == key)columns.value[index_1].customCell = (record, rowIndex) => {return {class:record[item_1.key] == '请选择' || record[item_1.key] == '未填写'? 'demo-table-info-cell-name': ''}}})}// 重要程度if (key === 'levels') {let levelsFlag = falsefor (var i = 0; i < columns.value[3].option.length; i++) {if (columns.value[3].option[i].label == item[key] || columns.value[3].option[i].value == item[key]) {item[key] = columns.value[3].option[i].valuelevelsFlag = truebreak}}if (!levelsFlag) {columns.value.forEach((item_1, index_1) => {if (item_1.option) {columns.value[index_1].customCell = (record, rowIndex) => {// 遍历 item_1.option 数组的每一项for (let i = 0; i < item_1.option.length; i++) {const currentOption = item_1.option[i]// 检查条件并返回相应的 classif (record.levels == currentOption.label || record.levels == currentOption.value) {levelsFlag = trueitem[key] = currentOption.valuereturn {class: ''}}}// 如果没有匹配项,返回默认的 classreturn { class: 'demo-table-info-cell-name' }}}})saveFlag = false}}}}if (Object.keys(item.cellClassName).length == 0) {delete item.cellClassNamelet processData = JSON.parse(JSON.stringify(item))subDataList.value.push(processData)} else {saveFlag = false}}})console.log(saveFlag, 'saveFlag3')if (!saveFlag) {editTables.value.init()} else {subDataList.value.push(...store.state.isopreservation.deleteList)store.commit('resetDeleteList')const res = await bizEnvironmentApi.saveEnvironmentList(subDataList.value)if (res == null) {flag = true}}return flag}

父组件

//调用中间组件方法
let flag = await researchSysForms.value.getFormData() 

3. 图例

在这里插入图片描述

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

从零开始精通Onvif之加密与认证

&#x1f4a1; 如果想阅读最新的文章&#xff0c;或者有技术问题需要交流和沟通&#xff0c;可搜索并关注微信公众号“希望睿智”。 概述 安全是Onvif规范的核心部分&#xff0c;它涵盖了加密和认证两大领域。在Onvif标准下&#xff0c;安全措施主要包括&#xff1a;设备访问控…

大模型AI技术实现语言规范练习

人工智能技术可以为语言规范练习提供多种有效的解决方案&#xff0c;帮助学习者更有效地掌握语言规范。以下是一些常见的应用场景。北京木奇移动技术有限公司&#xff0c;专业的软件外包开发公司&#xff0c;欢迎交流合作。 1. 智能纠错 利用自然语言处理技术&#xff0c;可以…

DC/AC电源模块一种效率与可靠性兼备的能源转换解决方案

DC/AC电源模块都是一种效率与可靠性兼备的能源转换解决方案 DC/AC电源模块是一种能够将直流电源&#xff08;DC&#xff09;转换为交流电源&#xff08;AC&#xff09;的设备。它在现代电子设备中扮演着非常重要的角色&#xff0c;因为许多设备需要交流电源才能正常运行。无论…

树形结构的勾选、取消勾选、删除、清空已选、回显、禁用

树形结构的勾选、取消勾选、删除、清空已选、回显、禁用 基本页面&#xff1a; 分为上传文件和编辑的页面 代码实现要点&#xff1a; 上传文件页面&#xff1a; 点开选择范围弹窗&#xff0c;三个radio单选框都为可选状态&#xff0c;默认显示的是第一个单选框&#xff08;按…

开源C++版AI画图大模型框架stable-diffusion.cpp开发使用初体验

stable-diffusion.cpp是一个C编写的轻量级开源类AIGC大模型框架&#xff0c;可以支持在消费级普通设备上本地部署运行大模型进行AI画图&#xff0c;以及作为依赖库集成的到应用程序中提供类似于网页版stable-diffusion的功能。 以下基于stable-diffusion.cpp的源码利用C api来…

人工智能的未来:畅想智能新时代

人工智能正在改变我们的世界&#xff0c;它将带我们走向何方&#xff1f; 著名神经科学家、Numenta 公司创始人杰夫•霍金斯 Jeff Hawkins 在其著作《人工智能的未来》中&#xff0c;描绘了一幅人工智能发展的光明图景。他认为&#xff0c;人工智能将超越人类智能&#xff0c;…

理解Gobrs-Async相对于CompletableFuture的优势

Gobrs-Async框架针对复杂应用场景下的异步任务编排&#xff0c;提供了一些传统Future或CompletableFuture所不具备的特性和能力&#xff0c;以下是它能够解决的问题和相对于CompletableFuture的优势&#xff1a; 1. **全链路异常回调**&#xff1a; - Gobrs-Async允许为任务…

关于地图点击的操作

_this.map.dragging.disable(); //地图拖拽 _this.map.doubleClickZoom.disable(); //禁止双击放大地图 _this.map.scrollWheelZoom.disable(); //禁止鼠标滑轮滚动放大缩小地图 _this.map.dragging.enable(); //e…

备份和镜像TrinityCore

相比重新安装&#xff0c;省去了编译的过程&#xff0c;同时还能保留以前的人物、装备等。 注意&#xff0c;若不想重新编译安装&#xff0c;则需要创建一样的目录、账户等&#xff0c;以减少不必要的麻烦。 首先备份数据: mysql备份和导入方法见&#xff1a;使用dump备份my…

视觉与味蕾的交响:红酒与艺术的无界狂欢,震撼你的感官世界

在浩瀚的艺术海洋中&#xff0c;红酒以其不同的魅力&#xff0c;成为了一种跨界整合的媒介。当雷盛红酒与艺术相遇&#xff0c;它们共同呈现出一场特别的视觉盛宴&#xff0c;让人沉醉在色彩与光影的交织中&#xff0c;感受红酒与艺术的无界碰撞。 雷盛红酒&#xff0c;宛如一件…

AI作画Prompt不会写?Amazon Bedrock Claude3.5来帮忙

最新上线的Claude3.5 Sonnet按照官方介绍的数据来看&#xff0c;在多方面超越了CPT-4o&#xff0c;是迄今为止最智能的模型。 而跟上一个版本相比&#xff0c;速度是Claude 3 Opus的两倍&#xff0c;成本只有其五分之一。 Claude3.5 Sonnet不仅擅长解释图表、图形或者从不完…

vue3中子组件调用父组件事件

在 Vue 3 中&#xff0c;子组件调用父组件的事件&#xff08;或方法&#xff09;的方式与 Vue 2 类似&#xff0c;但 Vue 3 引入了 Composition API&#xff0c;这可能会改变你组织代码的方式。不过&#xff0c;基本的通信机制——通过自定义事件 ($emit) 通知父组件——仍然保…

总结:DataX

一、介绍 本文主要介绍DataX的安装与使用。 二、安装 安装&#xff1a;DataX/userGuid.md at master alibaba/DataX GitHub 六、案例 实现从MySQL同步数据到HDFS&#xff0c;然后使用Hive进行聚合计算并将结果存储回MySQL。 步骤2&#xff1a;使用DataX同步MySQL数据到H…

Day28:回溯法 491.递增子序列 46.全排列 47.全排列 II 332.重新安排行程 51. N皇后 37. 解数独

491. 非递减子序列 给你一个整数数组 nums &#xff0c;找出并返回所有该数组中不同的递增子序列&#xff0c;递增子序列中 至少有两个元素 。你可以按 任意顺序 返回答案。 数组中可能含有重复元素&#xff0c;如出现两个整数相等&#xff0c;也可以视作递增序列的一种特殊情…

Atcoder ABC359E Water Tank 题解

题目传送门 题解 分析 分类讨论。 记第 i i i 个答案为 a n s i 1 ans_i1 ansi​1。 第 i i i 个数就是目前的最大值。 显然&#xff0c; a n s i h i i ans_ih_i \times i ansi​hi​i。第 i i i 个数就是目前的最大值。 记 l a s t i last_i lasti​ 为 i i i …

网络安全学习路线图(2024版详解)

近期&#xff0c;大家在网上对于网络安全讨论比较多&#xff0c;想要学习的人也不少&#xff0c;但是需要学习哪些内容&#xff0c;按照什么顺序去学习呢&#xff1f;其实我们已经出国多版本的网络安全学习路线图&#xff0c;一直以来效果也比较不错&#xff0c;本次我们针对市…

Java中多态的实现原理解析

Java中多态的实现原理解析 大家好&#xff0c;我是免费搭建查券返利机器人省钱赚佣金就用微赚淘客系统3.0的小编&#xff0c;也是冬天不穿秋裤&#xff0c;天冷也要风度的程序猿&#xff01;在本文中&#xff0c;我们将深入探讨Java中多态的实现原理及其应用。多态是面向对象编…

centos中查看服务的日志

在CentOS中查看服务的日志通常涉及查看系统日志文件&#xff0c;这些文件通常位于/var/log/目录下。不同的服务可能会有不同的日志文件。以下是一些常见的日志文件和查看它们的方法&#xff1a; 1. **系统日志**&#xff1a;系统日志通常存储在/var/log/messages或/var/log/sy…

学会python——生成日志信息(python实例十二)

目录 1、认识Python 2、环境与工具 2.1 python环境 2.2 Visual Studio Code编译 3、生成日志信息 3.1 代码构思 3.2 代码示例 3.3 运行结果 4、总结 1、认识Python Python 是一个高层次的结合了解释性、编译性、互动性和面向对象的脚本语言。 Python 的设计具有很强的…

MySQL serverTimezone=UTC

在数据库连接字符串中使用 serverTimezoneUTC 是一个常见的配置选项&#xff0c;特别是当数据库服务器和应用程序服务器位于不同的时区时。这个选项指定了数据库服务器应当使用的时区&#xff0c;以确保日期和时间数据在客户端和服务器之间正确传输和处理。 UTC&#xff08;协…