From cfaa6acf1fd9e77bf63ce8dee6c60bd611593e27 Mon Sep 17 00:00:00 2001 From: xbx <1827135378@qq.com> Date: Mon, 22 Jan 2024 10:44:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AF=BC=E5=85=A5=E5=90=8E?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AF=B9=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mixins/JeecgListMixin.js | 239 ++++++--- .../RmsFurnitureCollegeList.vue | 463 ++++++++++++++++- .../rms/FurnitureList/RmsFurnitureList.vue | 468 ++++++++++++++++- .../RmsInstrumentCollegeList.vue | 460 +++++++++++++++- .../rms/InstrumentList/RmsInstrumentList.vue | 479 +++++++++++++++-- .../RmsIntangibleCollegeList.vue | 475 ++++++++++++++++- .../rms/IntangibleList/RmsIntangibleList.vue | 491 +++++++++++++++++- src/views/rms/components/instrumentSelect.vue | 213 ++++++++ 8 files changed, 3126 insertions(+), 162 deletions(-) create mode 100644 src/views/rms/components/instrumentSelect.vue diff --git a/src/mixins/JeecgListMixin.js b/src/mixins/JeecgListMixin.js index 884271c..2eab52f 100644 --- a/src/mixins/JeecgListMixin.js +++ b/src/mixins/JeecgListMixin.js @@ -4,20 +4,20 @@ * data中url定义 list为查询列表 delete为删除单条记录 deleteBatch为批量删除 */ import { filterObj } from '@/utils/util'; -import { deleteAction, getAction,downFile,getFileAccessHttpUrl } from '@/api/manage' +import { deleteAction, getAction, downFile, getFileAccessHttpUrl } from '@/api/manage' import Vue from 'vue' import { ACCESS_TOKEN, TENANT_ID } from "@/store/mutation-types" import store from '@/store' export const JeecgListMixin = { - data(){ + data() { return { /* 查询条件-请不要在queryParam中声明非字符串值的属性 */ queryParam: {}, /* 数据源 */ - dataSource:[], + dataSource: [], /* 分页参数 */ - ipagination:{ + ipagination: { current: 1, pageSize: 10, pageSizeOptions: ['10', '20', '30'], @@ -29,22 +29,22 @@ export const JeecgListMixin = { total: 0 }, /* 排序参数 */ - isorter:{ + isorter: { column: 'createTime', order: 'desc', }, /* 筛选参数 */ filters: {}, /* table加载状态 */ - loading:false, + loading: false, /* table选中keys*/ selectedRowKeys: [], /* table选中records*/ selectionRows: [], /* 查询折叠 */ - toggleSearchStatus:false, + toggleSearchStatus: false, /* 高级查询条件生效状态 */ - superQueryFlag:false, + superQueryFlag: false, /* 高级查询条件 */ superQueryParams: '', /** 高级查询拼接方式 */ @@ -52,27 +52,27 @@ export const JeecgListMixin = { } }, created() { - if(!this.disableMixinCreated){ - console.log(' -- mixin created -- ') - this.loadData(); - //初始化字典配置 在自己页面定义 - this.initDictConfig(); - } + if (!this.disableMixinCreated) { + console.log(' -- mixin created -- ') + this.loadData(); + //初始化字典配置 在自己页面定义 + this.initDictConfig(); + } }, computed: { //token header - tokenHeader(){ - let head = {'X-Access-Token': Vue.ls.get(ACCESS_TOKEN)} + tokenHeader() { + let head = { 'X-Access-Token': Vue.ls.get(ACCESS_TOKEN) } let tenantid = Vue.ls.get(TENANT_ID) - if(tenantid){ + if (tenantid) { head['tenant-id'] = tenantid } return head; } }, - methods:{ + methods: { loadData(arg) { - if(!this.url.list){ + if (!this.url.list) { this.$message.error("请设置url.list属性!") return } @@ -82,35 +82,35 @@ export const JeecgListMixin = { } var params = this.getQueryParams();//查询条件 this.loading = true; + console.log("loadData params", params) getAction(this.url.list, params).then((res) => { if (res.success) { //update-begin---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------ - this.dataSource = res.result.records||res.result; - if(res.result.total) - { + this.dataSource = res.result.records || res.result; + if (res.result.total) { this.ipagination.total = res.result.total; - }else{ + } else { this.ipagination.total = 0; } //update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------ - }else{ + } else { this.$message.warning(res.message) } }).finally(() => { this.loading = false }) }, - initDictConfig(){ + initDictConfig() { console.log("--这是一个假的方法!") }, handleSuperQuery(params, matchType) { //高级查询方法 - if(!params){ - this.superQueryParams='' + if (!params) { + this.superQueryParams = '' this.superQueryFlag = false - }else{ + } else { this.superQueryFlag = true - this.superQueryParams=JSON.stringify(params) + this.superQueryParams = JSON.stringify(params) this.superQueryMatchType = matchType } this.loadData(1) @@ -118,11 +118,11 @@ export const JeecgListMixin = { getQueryParams() { //获取查询条件 let sqp = {} - if(this.superQueryParams){ - sqp['superQueryParams']=encodeURI(this.superQueryParams) + if (this.superQueryParams) { + sqp['superQueryParams'] = encodeURI(this.superQueryParams) sqp['superQueryMatchType'] = this.superQueryMatchType } - var param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters); + var param = Object.assign(sqp, this.queryParam, this.isorter, this.filters); param.field = this.getQueryField(); param.pageNo = this.ipagination.current; param.pageSize = this.ipagination.pageSize; @@ -160,7 +160,7 @@ export const JeecgListMixin = { this.loadData(1); }, batchDel: function () { - if(!this.url.deleteBatch){ + if (!this.url.deleteBatch) { this.$message.error("请设置url.deleteBatch属性!") return } @@ -178,7 +178,7 @@ export const JeecgListMixin = { content: "是否删除选中数据?", onOk: function () { that.loading = true; - deleteAction(that.url.deleteBatch, {ids: ids}).then((res) => { + deleteAction(that.url.deleteBatch, { ids: ids }).then((res) => { if (res.success) { //重新计算分页问题 that.reCalculatePage(that.selectedRowKeys.length) @@ -196,12 +196,12 @@ export const JeecgListMixin = { } }, handleDelete: function (id) { - if(!this.url.delete){ + if (!this.url.delete) { this.$message.error("请设置url.delete属性!") return } var that = this; - deleteAction(that.url.delete, {id: id}).then((res) => { + deleteAction(that.url.delete, { id: id }).then((res) => { if (res.success) { //重新计算分页问题 that.reCalculatePage(1) @@ -212,16 +212,16 @@ export const JeecgListMixin = { } }); }, - reCalculatePage(count){ + reCalculatePage(count) { //总数量-count - let total=this.ipagination.total-count; + let total = this.ipagination.total - count; //获取删除后的分页数 - let currentIndex=Math.ceil(total/this.ipagination.pageSize); + let currentIndex = Math.ceil(total / this.ipagination.pageSize); //删除后的分页数<所在当前页 - if(currentIndex0){ + if (this.selectedRowKeys && this.selectedRowKeys.length > 0) { param['selections'] = this.selectedRowKeys.join(",") } - console.log("导出参数",param) - downFile(this.url.exportXlsUrl,param).then((data)=>{ + console.log("导出参数", param) + downFile(this.url.exportXlsUrl, param).then((data) => { if (!data) { this.$message.warning("文件下载失败") return } if (typeof window.navigator.msSaveBlob !== 'undefined') { - window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls') - }else{ - let url = window.URL.createObjectURL(new Blob([data],{type: 'application/vnd.ms-excel'})) + window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xls') + } else { + let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' })) let link = document.createElement('a') link.style.display = 'none' link.href = url - link.setAttribute('download', fileName+'.xls') + link.setAttribute('download', fileName + '.xls') document.body.appendChild(link) link.click() document.body.removeChild(link); //下载完成移除元素 @@ -299,7 +299,7 @@ export const JeecgListMixin = { }, // 重写导出方法 ExportData(fileName, TimestampData) { - console.log("传入的时间戳"+TimestampData) + console.log("传入的时间戳" + TimestampData) if (!fileName || typeof fileName != "string") { fileName = "导出文件" } @@ -330,38 +330,53 @@ export const JeecgListMixin = { }) }, /* 导入 */ - handleImportExcel(info){ + handleImportExcel(info) { + // 设置加载状态为true,表示正在上传 this.loading = true; + // 如果文件状态不是'uploading',在控制台输出文件信息 if (info.file.status !== 'uploading') { console.log(info.file, info.fileList); } + // 处理文件上传完成的情况 if (info.file.status === 'done') { + // 设置加载状态为false,表示上传完成 this.loading = false; + // 检查上传是否成功 if (info.file.response.success) { - // this.$message.success(`${info.file.name} 文件上传成功`); + // 如果上传成功 if (info.file.response.code === 201) { - let { message, result: { msg, fileUrl, fileName } } = info.file.response - let href = window._CONFIG['domianURL'] + fileUrl + // 处理成功响应的情况 + let { message, result: { msg, fileUrl, fileName } } = info.file.response; + let href = window._CONFIG['domianURL'] + fileUrl; + // 弹出一个警告提示框,提醒用户下载文件 this.$warning({ title: message, - content: (
- {msg}
+ content: ( +
+ {msg}
具体详情请 点击下载
) - }) + }); } else { - this.$message.success(info.file.response.message || `${info.file.name} 文件上传成功`) + console.log("后端返回的数据:", info.file.response); + // 处理上传成功但是响应状态码不为201的情况 + this.$message.success(info.file.response.message || `${info.file.name} 文件上传成功`); } - this.loadData() + // 重新加载数据 + this.loadData(); } else { + // 处理上传失败的情况 this.$message.error(`${info.file.name} ${info.file.response.message}.`); } } else if (info.file.status === 'error') { + // 处理上传错误的情况 this.loading = false; + // 处理服务器返回的500错误 if (info.file.response.status === 500) { - let data = info.file.response - const token = Vue.ls.get(ACCESS_TOKEN) + let data = info.file.response; + const token = Vue.ls.get(ACCESS_TOKEN); + // 如果Token失效,提示用户登录已过期,提供重新登录选项 if (token && data.message.includes("Token失效")) { this.$error({ title: '登录已过期', @@ -370,33 +385,101 @@ export const JeecgListMixin = { mask: false, onOk: () => { store.dispatch('Logout').then(() => { - Vue.ls.remove(ACCESS_TOKEN) + Vue.ls.remove(ACCESS_TOKEN); window.location.reload(); - }) + }); } - }) + }); } } else { + // 处理其他上传错误情况 this.$message.error(`文件上传失败: ${info.file.msg} `); } } }, + //重写导入方法 + ImportData(info) { + // 设置加载状态为true,表示正在上传 + this.loading = true; + // 如果文件状态不是'uploading',在控制台输出文件信息 + if (info.file.status !== 'uploading') { + console.log(info.file, info.fileList); + } + // 处理文件上传完成的情况 + if (info.file.status === 'done') { + // 设置加载状态为false,表示上传完成 + this.loading = false; + // 检查上传是否成功 + if (info.file.response.success) { + // 如果上传成功 + if (info.file.response.code === 201) { + // 处理成功响应的情况 + let { message, result: { msg, fileUrl, fileName } } = info.file.response; + let href = window._CONFIG['domianURL'] + fileUrl; + // 弹出一个警告提示框,提醒用户下载文件 + this.$warning({ + title: message, + content: ( +
+ {msg}
+ 具体详情请 点击下载 +
+ ) + }); + } else { + // 处理上传成功但是响应状态码不为201的情况 + this.$message.success(info.file.response.message || `${info.file.name} 文件上传成功`); + } + // 重新加载数据 + this.loadData(); + } else { + // 处理上传失败的情况 + this.$message.error(`${info.file.name} ${info.file.response.message}.`); + } + } else if (info.file.status === 'error') { + // 处理上传错误的情况 + this.loading = false; + // 处理服务器返回的500错误 + if (info.file.response.status === 500) { + let data = info.file.response; + const token = Vue.ls.get(ACCESS_TOKEN); + // 如果Token失效,提示用户登录已过期,提供重新登录选项 + if (token && data.message.includes("Token失效")) { + this.$error({ + title: '登录已过期', + content: '很抱歉,登录已过期,请重新登录', + okText: '重新登录', + mask: false, + onOk: () => { + store.dispatch('Logout').then(() => { + Vue.ls.remove(ACCESS_TOKEN); + window.location.reload(); + }); + } + }); + } + } else { + // 处理其他上传错误情况 + this.$message.error(`文件上传失败: ${info.file.msg} `); + } + } + }, /* 图片预览 */ - getImgView(text){ - if(text && text.indexOf(",")>0){ - text = text.substring(0,text.indexOf(",")) + getImgView(text) { + if (text && text.indexOf(",") > 0) { + text = text.substring(0, text.indexOf(",")) } return getFileAccessHttpUrl(text) }, /* 文件下载 */ // update--autor:lvdandan-----date:20200630------for:修改下载文件方法名uploadFile改为downloadFile------ - downloadFile(text){ - if(!text){ + downloadFile(text) { + if (!text) { this.$message.warning("未知的文件") return; } - if(text.indexOf(",")>0){ - text = text.substring(0,text.indexOf(",")) + if (text.indexOf(",") > 0) { + text = text.substring(0, text.indexOf(",")) } let url = getFileAccessHttpUrl(text) window.open(url); diff --git a/src/views/rms/FurnitureCollegeList/RmsFurnitureCollegeList.vue b/src/views/rms/FurnitureCollegeList/RmsFurnitureCollegeList.vue index 9a10b3d..15cf73b 100644 --- a/src/views/rms/FurnitureCollegeList/RmsFurnitureCollegeList.vue +++ b/src/views/rms/FurnitureCollegeList/RmsFurnitureCollegeList.vue @@ -26,11 +26,11 @@ 重置 - + image -

学院资产信息

+

学院资产信息

@@ -41,9 +41,42 @@
新增 导出 - 导入 + --> + + 导入 + + +
+ {{ this.tableTitle }} +
+ + + 详情 + + + +
+ 本地的新增数据 + 存在差异的数据 + 导入的新增数据 +
+
历史数据 @@ -117,7 +150,7 @@ import '@/assets/less/TableExpand.less' import { mixinDevice } from '@/utils/mixin' import { JeecgListMixin } from '@/mixins/JeecgListMixin' import RmsFurnitureCollegeModal from './modules/RmsFurnitureCollegeModal.vue' -import { getAction } from '../../../api/manage' +import { getAction, postAction } from '../../../api/manage' import RmsLocationModal from '../LocationList/modules/RmsLocationModal' import locationaTree from '../components/locationaTree' @@ -130,10 +163,196 @@ export default { locationaTree }, data() { + // 通用的 customRender 函数 + function getDateCustomRender(text, record, differenceKey) { + const isDifferenceKey = `is${differenceKey}Difference`; + let backgroundColor = 'transparent'; + if (record.isOldData) { + backgroundColor = record[isDifferenceKey] ? '#fde2e2' : '#d9d9d9'; + } else { + backgroundColor = record[isDifferenceKey] ? '#fde2e2' : 'transparent'; + } // 在这里添加购置日期列的特定逻辑,如果有的话 + const processedText = !text ? "" : (text.length > 10 ? text.substr(0, 10) : text); + return { + children: processedText, + attrs: { + style: `background-color: ${backgroundColor};` + } + }; + } + function getCustomRender(text, record, differenceKey) { + const isDifferenceKey = `is${differenceKey}Difference`; + let backgroundColor = 'transparent'; + if (record.isOldData) { + backgroundColor = record[isDifferenceKey] ? '#fde2e2' : '#d9d9d9'; + } else { + backgroundColor = record[isDifferenceKey] ? '#fde2e2' : 'transparent'; + } + return { + children: text, + attrs: { + style: `background-color: ${backgroundColor};` + } + }; + } return { value: '', dataSource: [], UserdataSource: [], + SelectReserveData: [], + // 表头 + DiffrentColumns: [ + { + title: '家具编号', + align: "center", + dataIndex: 'furnitureNumber', + width: 100, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'furnitureNumber'), + }, + { + title: '家具名称', + align: "center", + dataIndex: 'furnitureName', + width: 120, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'furnitureName'), + }, + { + title: '领用单位号', + align: "center", + dataIndex: 'collectingUnitNumber', + width: 120, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'collectingUnitNumber'), + }, + { + title: '分类号', + align: "center", + dataIndex: 'categoryId', + width: 80, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'categoryId'), + }, + { + title: '型号', + align: "center", + dataIndex: 'model', + width: 120, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'model'), + }, + { + title: '规格', + align: "center", + dataIndex: 'specifications', + width: 150, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'specifications'), + }, + { + title: '数量', + align: "center", + dataIndex: 'number', + width: 80, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'number'), + }, + { + title: '单价', + align: "center", + dataIndex: 'unitPrice', + width: 80, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'unitPrice'), + }, + { + title: '金额', + align: "center", + dataIndex: 'amount', + width: 80, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'amount'), + }, + { + title: '厂家', + align: "center", + dataIndex: 'manufactuer', + width: 200, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'manufactuer'), + }, + { + title: '购置日期', + align: "center", + dataIndex: 'purchaseDate', + width: 100, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'purchaseDate'), + }, + { + title: '领用人', + align: "center", + dataIndex: 'recipient', + width: 80, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'recipient'), + }, + { + title: '单据号', + align: "center", + dataIndex: 'documentNumber', + width: 80, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'documentNumber'), + }, + { + title: '存放地址', + align: "center", + dataIndex: 'locationName', + width: 120, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'locationName'), + }, + { + title: '备注', + align: "center", + dataIndex: 'note', + width: 120, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'note'), + }, + { + title: '审核状态', + align: "center", + dataIndex: 'approvalStatus', + width: 100, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'approvalStatus'), + }, + { + title: '初审状态', + align: "center", + dataIndex: 'initialAudit', + width: 80, + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'initialAudit'), + }, + { + title: '使用年限', + align: "center", + dataIndex: 'usageYears', + //如果是差异数据显示黄色,是新数据显示绿色 + customRender: (text, record) => getCustomRender(text, record, 'usageYears'), + }, + { + title: '操作', + dataIndex: 'action', + align: "center", + width: 60, + scopedSlots: { customRender: 'action' } + } + ], // 表头 columns: [ { @@ -267,7 +486,16 @@ export default { }, UserList: {}, historyModalVisible: false, // 控制历史数据模态框的显示与隐藏 - historyData: [] // 历史数据数组,用于存储所有历史数据 + historyData: [], // 历史数据数组,用于存储所有历史数据 + ContrastData: [], // 用于存储对比表格的数据 + NotOldRmsData: [], //新数据中存在但旧数据中不存在的 + NotNewRmsData: [], //旧数据中存在但新数据中不存在的 + NewDifferentData: [], //新数据中存在差异的 + NewTempDifferentData: [], //新数据中存在差异的 + OldDifferentData: [], //旧数据中存在差异的 + returnData: [], //返回的数据 + tableTitle: "存在差异的数据:", + showDifference: false, } }, created() { @@ -279,6 +507,223 @@ export default { }, }, methods: { + //重写导入方法 + ImportData(info) { + // 设置加载状态为true,表示正在上传 + this.loading = true; + // 如果文件状态不是'uploading',在控制台输出文件信息 + if (info.file.status !== 'uploading') { + console.log(info.file, info.fileList); + } + // 处理文件上传完成的情况 + if (info.file.status === 'done') { + // 设置加载状态为false,表示上传完成 + this.loading = false; + if (info.file.response.success) { + if (info.file.response.code === 201) { + let { message, result: { msg, fileUrl, fileName } } = info.file.response; + let href = window._CONFIG['domianURL'] + fileUrl; + this.$warning({ + title: message, + content: ( +
+ {msg}
+ 具体详情请 点击下载 +
+ ) + }); + } else { + const resultList = info.file.response.result; + //接收List中的第一个 + this.NotOldRmsData = resultList[0]; + this.NotNewRmsData = resultList[1]; + this.NewDifferentData = resultList[2]; + this.OldDifferentData = resultList[3]; + console.log("新数据中存在但旧数据中不存在的:" + this.NotOldRmsData); + console.log("旧数据中存在但新数据中不存在的:" + this.NotNewRmsData); + console.log("新数据中存在差异的:" + this.NewDifferentData); + console.log("旧数据中存在差异的:" + this.OldDifferentData); + this.SelectReserveData = []; + this.showDifference = true; + // 标记差异数据 + this.markDifferenceData(); + // this.$message.success(info.file.response.message || `${info.file.name} 文件上传成功`); + } + this.loadData(); + } else { + this.$message.error(`${info.file.name} ${info.file.response.message}.`); + } + } else if (info.file.status === 'error') { + this.loading = false; + if (info.file.response.status === 500) { + let data = info.file.response; + const token = Vue.ls.get(ACCESS_TOKEN); + if (token && data.message.includes("Token失效")) { + this.$error({ + title: '登录已过期', + content: '很抱歉,登录已过期,请重新登录', + okText: '重新登录', + mask: false, + onOk: () => { + store.dispatch('Logout').then(() => { + Vue.ls.remove(ACCESS_TOKEN); + window.location.reload(); + }); + } + }); + } + } else { + this.$message.error(`文件上传失败: ${info.file.msg} `); + } + } + }, + DifferenceOk() { + this.returnData = []; + for (const item of this.SelectReserveData) { + this.returnData.push(this.NewTempDifferentData[item]); + } + this.SelectReserveData = []; + console.log(this.returnData) + postAction("/rms/rmsFurnitureCollege/SureImportExcel", this.returnData).then(res => { + if (res && res.success) { + this.$message.success(res.message); + this.loadData(); + this.showDifference = false; + } else { + // 处理导入失败的情况 + this.$message.error("导入失败:" + (res ? res.message : "未知错误")); + } + this.loadData(); + this.showDifference = false; + }); + }, + // 检查并标记两个对象间不同的字段 + checkAndMarkDifferences(source, target, field) { + if (source[field] !== target[field]) { + source['is' + field + 'Difference'] = true; + target['is' + field + 'Difference'] = true; + } + }, + markDifferenceData() { + let temp = 0; + if (this.NewTempDifferentData.length > 0) { + this.NewTempDifferentData = []; + } + // 比较 NewDifferentData 和 OldDifferentData标出差异字段 + for (const oldItem of this.OldDifferentData) { + const newItem = this.NewDifferentData.find(item => item.furnitureNumber === oldItem.furnitureNumber); // 假设你有一个唯一标识字段 id + newItem.uniqueKey = temp++; + oldItem.uniqueKey = temp++; + //初始化差异标记 + oldItem.isOldData = true; + // 定义需要比较的字段 + const fieldsToCompare = [ + 'furnitureNumber', + 'furnitureName', + 'collectingUnitNumber', + 'categoryId', + 'model', + 'specifications', + 'number', + 'unitPrice', + 'amount', + 'manufactuer', + 'purchaseDate', + 'recipient', + 'documentNumber', + 'locationName', + 'note', + 'approvalStatus', + 'initialAudit', + 'usageYears', + ]; + // 循环比较字段 + fieldsToCompare.forEach(field => { + this.checkAndMarkDifferences(oldItem, newItem, field); + }); + this.NewTempDifferentData.push(newItem); + this.NewTempDifferentData.push(oldItem); + console.log("oldItem=" + oldItem.collectingUnitNumber + " 值 " + oldItem.iscollectingUnitNumberDifference) + } + for (const oldItem of this.NotNewRmsData) { + oldItem.isOldData = true; + oldItem.NotKeep = '1'; + } + for (const newItem of this.NotOldRmsData) { + newItem.NotKeep = '1'; + } + this.ContrastData = this.NewTempDifferentData; + }, + // 展示本地的新增数据 + showLocalData() { + this.ContrastData = this.NotNewRmsData; + console.log(this.ContrastData) + this.tableTitle = "本地的新增数据:"; + this.SelectReserveData = []; + }, + // 展示导入的新增数据 + showImportData() { + this.ContrastData = this.NotOldRmsData; + this.tableTitle = "导入的新增数据:"; + this.SelectReserveData = []; + }, + // 展示存在差异的数据 + showDifferenceData() { + this.ContrastData = this.NewTempDifferentData; + console.log(this.ContrastData) + this.tableTitle = "存在差异的数据:"; + this.SelectReserveData = []; + }, + //全选时触发 + onSelectReserveAll(selected, selectedRows, changeRows) { + if (selected) { + this.SelectReserveData = this.NewTempDifferentData.filter((item, index) => index % 2 === 0).map(item => item.uniqueKey); + } else { + this.SelectReserveData = []; + } + this.NewTempDifferentData.forEach(item => { + item.NotKeep = '0'; + }); + this.SelectReserveData.forEach(selectedRowKey => { + if (selectedRowKey % 2 == 0) { + if (this.NewTempDifferentData[selectedRowKey + 1]) { + this.NewTempDifferentData[selectedRowKey + 1].NotKeep = '1'; + } + } else { + if (this.NewTempDifferentData[selectedRowKey - 1]) { + this.NewTempDifferentData[selectedRowKey - 1].NotKeep = '1'; + } + } + }); + this.ContrastData = [...this.NewTempDifferentData]; + }, + onSelectReserveChange(selectedRowKeys, selectedRows) { + if (selectedRowKeys.length == this.NewTempDifferentData.length) { + // 如果全选框被选中,则选取所有偶数行 + selectedRowKeys = this.NewTempDifferentData.filter((item, index) => index % 2 === 0).map(item => item.uniqueKey); + } + console.log(selectedRowKeys, selectedRows); + this.SelectReserveData = selectedRowKeys; + this.NewTempDifferentData.forEach(item => { + item.NotKeep = '0'; + }); + selectedRowKeys.forEach(selectedRowKey => { + if (selectedRowKey % 2 == 0) { + if (this.NewTempDifferentData[selectedRowKey + 1]) { + this.NewTempDifferentData[selectedRowKey + 1].NotKeep = '1'; + } + } else { + if (this.NewTempDifferentData[selectedRowKey - 1]) { + this.NewTempDifferentData[selectedRowKey - 1].NotKeep = '1'; + } + } + }); + this.ContrastData = [...this.NewTempDifferentData]; + }, + onSelectReserve(record, selected, selectedRows) { + console.log(record, selected, selectedRows); + }, + showHistoryModal() { getAction(this.url.timestampUrl).then(res => { console.log(res) @@ -316,10 +761,14 @@ export default { \ No newline at end of file