新增导入后数据对比

This commit is contained in:
xbx 2024-01-22 10:44:00 +08:00
parent 89263fb8ba
commit cfaa6acf1f
8 changed files with 3126 additions and 162 deletions

View File

@ -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(currentIndex<this.ipagination.current){
this.ipagination.current=currentIndex;
if (currentIndex < this.ipagination.current) {
this.ipagination.current = currentIndex;
}
console.log('currentIndex',currentIndex)
console.log('currentIndex', currentIndex)
},
handleEdit: function (record) {
this.$refs.modalForm.edit(record);
@ -244,11 +244,11 @@ export const JeecgListMixin = {
this.ipagination = pagination;
this.loadData();
},
handleToggleSearch(){
handleToggleSearch() {
this.toggleSearchStatus = !this.toggleSearchStatus;
},
// 给popup查询使用(查询区域不支持回填多个字段,限制只返回一个字段)
getPopupField(fields){
getPopupField(fields) {
return fields.split(',')[0]
},
modalFormOk() {
@ -257,39 +257,39 @@ export const JeecgListMixin = {
//清空列表选中
this.onClearSelected()
},
handleDetail:function(record){
handleDetail: function (record) {
this.$refs.modalForm.edit(record);
this.$refs.modalForm.title="详情";
this.$refs.modalForm.title = "详情";
this.$refs.modalForm.disableSubmit = true;
},
/* 导出 */
handleExportXls2(){
handleExportXls2() {
let paramsStr = encodeURI(JSON.stringify(this.getQueryParams()));
let url = `${window._CONFIG['domianURL']}/${this.url.exportXlsUrl}?paramsStr=${paramsStr}`;
window.location.href = url;
},
handleExportXls(fileName){
if(!fileName || typeof fileName != "string"){
handleExportXls(fileName) {
if (!fileName || typeof fileName != "string") {
fileName = "导出文件"
}
let param = this.getQueryParams();
if(this.selectedRowKeys && this.selectedRowKeys.length>0){
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: (<div>
<span>{msg}</span><br/>
content: (
<div>
<span>{msg}</span><br />
<span>具体详情请 <a href={href} target="_blank" download={fileName}>点击下载</a> </span>
</div>
)
})
});
} 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: (
<div>
<span>{msg}</span><br />
<span>具体详情请 <a href={href} target="_blank" download={fileName}>点击下载</a> </span>
</div>
)
});
} 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);

View File

@ -26,11 +26,11 @@
<a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
</span>
</a-col>
<a-col :xl="2" >
<a-col :xl="2">
<img style="height: 55px;" src="@/assets/collegelogo.jpg" alt="image">
</a-col>
<a-col :xl="4">
<p style="font-size: 20px; padding-top: 10px;">学院资产信息</p>
<p style="font-size: 20px; padding-top: 10px;">学院资产信息</p>
</a-col>
</a-row>
</a-form>
@ -41,9 +41,42 @@
<div class="table-operator">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<a-button type="primary" icon="download" @click="handleExportXls('家具信息表(学院)')">导出</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
<!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
@change="handleImportExcel">
<a-button type="primary" icon="import">导入</a-button>
</a-upload> -->
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
@change="ImportData">
<a-button type="primary" icon="import">导入</a-button>
<a-modal v-model="showDifference" title="数据对比" :width="1300" okText="导入" @ok="DifferenceOk">
<!-- 居中显示表格标题 -->
<div style="text-align: center; padding: 10px; background-color: #f0f0f0;
border-bottom: 1px solid #d9d9d9;">
<span style="font-size: 18px; font-weight: bold;">{{ this.tableTitle }}</span>
</div>
<a-table size="small" :scroll="{ x: true, y: '400px' }" :columns="DiffrentColumns"
:dataSource="ContrastData" :rowSelection="{
selectedRowKeys: SelectReserveData, onChange: onSelectReserveChange, onSelectAll: onSelectReserveAll,
onSelect: onSelectReserve, getCheckboxProps: record => ({
props: {
disabled: record.NotKeep === '1',
},
}),
}" :pagination="false" bordered>
<span slot="action" slot-scope="text, record">
<a @click="handleDetail(record)">详情</a>
</span>
</a-table>
<!-- 展示新旧数据新增的数据按钮 -->
<div style="display: flex; justify-content: space-between; margin-top: 10px;">
<a-button style="margin-left: 200px;" @click="showLocalData()" type="primary"
icon="zoom-in">本地的新增数据</a-button>
<a-button style="margin: auto;" @click="showDifferenceData()" type="primary"
icon="zoom-in">存在差异的数据</a-button>
<a-button style="margin-right: 200px;" @click="showImportData()" type="primary"
icon="zoom-in">导入的新增数据</a-button>
</div>
</a-modal>
</a-upload>
<a-button type="primary" icon="zoom-in" @click="showHistoryModal">历史数据</a-button>
<a-modal v-model="historyModalVisible" title="历史数据" @ok="closeHistoryModal">
@ -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: (
<div>
<span>{msg}</span><br />
<span>具体详情请 <a href={href} target="_blank" download={fileName}>点击下载</a> </span>
</div>
)
});
} 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 {
</script>
<style scoped>
@import '~@assets/less/common.less';
.modal-content {
max-height: 400px; /* 设置最大高度,根据需要进行调整 */
overflow-y: auto; /* 添加垂直滚动条 */
max-height: 400px;
/* 设置最大高度,根据需要进行调整 */
overflow-y: auto;
/* 添加垂直滚动条 */
}
.container {
display: flex;
align-items: center;

View File

@ -10,8 +10,8 @@
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row :gutter="24">
<a-col :xl="5" :lg="7" :md="8" :sm="24">
<a-auto-complete v-model="queryParam.recipient" :dataSource="UserdataSource"
placeholder="请选择领用人" @select="onSelect" @search="onSearch" @change="onChange" />
<a-auto-complete v-model="queryParam.recipient" :dataSource="UserdataSource" placeholder="请选择领用人"
@select="onSelect" @search="onSearch" @change="onChange" />
</a-col>
<a-col :xl="7" :lg="7" :md="8" :sm="24">
<a-form-item label="购置日期">
@ -30,7 +30,7 @@
<img style="height: 55px;" src="@/assets/schoollogo.jpg" alt="image">
</a-col>
<a-col :xl="4" :lg="7" :md="8" :sm="24">
<p style="font-size: 20px; padding-top: 10px;">学校资产信息</p>
<p style="font-size: 20px; padding-top: 10px;">学校资产信息</p>
</a-col>
</a-row>
</a-form>
@ -41,9 +41,42 @@
<div class="table-operator">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<a-button type="primary" icon="download" @click="handleExportXls('家具信息表')">导出</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
<!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
@change="handleImportExcel">
<a-button type="primary" icon="import">导入</a-button>
</a-upload> -->
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
@change="ImportData">
<a-button type="primary" icon="import">导入</a-button>
<a-modal v-model="showDifference" title="数据对比" :width="1300" okText="导入" @ok="DifferenceOk">
<!-- 居中显示表格标题 -->
<div style="text-align: center; padding: 10px; background-color: #f0f0f0;
border-bottom: 1px solid #d9d9d9;">
<span style="font-size: 18px; font-weight: bold;">{{ this.tableTitle }}</span>
</div>
<a-table size="small" :scroll="{ x: true, y: '400px' }" :columns="DiffrentColumns"
:dataSource="ContrastData" :rowSelection="{
selectedRowKeys: SelectReserveData, onChange: onSelectReserveChange, onSelectAll: onSelectReserveAll,
onSelect: onSelectReserve, getCheckboxProps: record => ({
props: {
disabled: record.NotKeep === '1',
},
}),
}" :pagination="false" bordered>
<span slot="action" slot-scope="text, record">
<a @click="handleDetail(record)">详情</a>
</span>
</a-table>
<!-- 展示新旧数据新增的数据按钮 -->
<div style="display: flex; justify-content: space-between; margin-top: 10px;">
<a-button style="margin-left: 200px;" @click="showLocalData()" type="primary"
icon="zoom-in">本地的新增数据</a-button>
<a-button style="margin: auto;" @click="showDifferenceData()" type="primary"
icon="zoom-in">存在差异的数据</a-button>
<a-button style="margin-right: 200px;" @click="showImportData()" type="primary"
icon="zoom-in">导入的新增数据</a-button>
</div>
</a-modal>
</a-upload>
<a-button type="primary" icon="zoom-in" @click="showHistoryModal">历史数据</a-button>
<a-modal v-model="historyModalVisible" title="历史数据" @ok="closeHistoryModal">
@ -54,8 +87,7 @@
<p style="font-size: 17px;">{{ TimestampData }}</p>
</div>
<div class="right">
<a-button type="primary" icon="download"
@click="ExportData('家具信息表', TimestampData)">导出</a-button>
<a-button type="primary" icon="download" @click="ExportData('家具信息表', TimestampData)">导出</a-button>
</div>
</div>
</div>
@ -120,7 +152,7 @@ import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import RmsFurnitureModal from './modules/RmsFurnitureModal'
import { getAction } from '../../../api/manage'
import { getAction, postAction } from '../../../api/manage'
import RmsLocationModal from '../LocationList/modules/RmsLocationModal'
import locationaTree from '../components/locationaTree'
@ -133,10 +165,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: [
{
@ -271,7 +489,16 @@ export default {
},
UserList: {},
historyModalVisible: false, //
historyData: [] //
historyData: [], //
ContrastData: [], //
NotOldRmsData: [], //
NotNewRmsData: [], //
NewDifferentData: [], //
NewTempDifferentData: [], //
OldDifferentData: [], //
returnData: [], //
tableTitle: "存在差异的数据:",
showDifference: false,
}
},
created() {
@ -283,6 +510,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: (
<div>
<span>{msg}</span><br />
<span>具体详情请 <a href={href} target="_blank" download={fileName}>点击下载</a> </span>
</div>
)
});
} 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/rmsFurniture/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)
@ -320,10 +764,14 @@ export default {
</script>
<style scoped>
@import '~@assets/less/common.less';
.modal-content {
max-height: 400px; /* 设置最大高度,根据需要进行调整 */
overflow-y: auto; /* 添加垂直滚动条 */
max-height: 400px;
/* 设置最大高度,根据需要进行调整 */
overflow-y: auto;
/* 添加垂直滚动条 */
}
.container {
display: flex;
align-items: center;

View File

@ -26,11 +26,11 @@
<a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
</span>
</a-col>
<a-col :xl="2" >
<a-col :xl="2">
<img style="height: 55px;" src="@/assets/collegelogo.jpg" alt="image">
</a-col>
<a-col :xl="4">
<p style="font-size: 20px; padding-top: 10px;">学院资产信息</p>
<p style="font-size: 20px; padding-top: 10px;">学院资产信息</p>
</a-col>
</a-row>
</a-form>
@ -41,9 +41,42 @@
<div class="table-operator">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<a-button type="primary" icon="download" @click="handleExportXls('仪器信息表(学院)')">导出</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
<!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
@change="handleImportExcel">
<a-button type="primary" icon="import">导入</a-button>
</a-upload> -->
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
@change="ImportData">
<a-button type="primary" icon="import">导入</a-button>
<a-modal v-model="showDifference" title="数据对比" :width="1300" okText="导入" @ok="DifferenceOk">
<!-- 居中显示表格标题 -->
<div style="text-align: center; padding: 10px; background-color: #f0f0f0;
border-bottom: 1px solid #d9d9d9;">
<span style="font-size: 18px; font-weight: bold;">{{ this.tableTitle }}</span>
</div>
<a-table size="small" :scroll="{ x: true, y: '400px' }" :columns="DiffrentColumns"
:dataSource="ContrastData" :rowSelection="{
selectedRowKeys: SelectReserveData, onChange: onSelectReserveChange, onSelectAll: onSelectReserveAll,
onSelect: onSelectReserve, getCheckboxProps: record => ({
props: {
disabled: record.NotKeep === '1',
},
}),
}" :pagination="false" bordered>
<span slot="action" slot-scope="text, record">
<a @click="handleDetail(record)">详情</a>
</span>
</a-table>
<!-- 展示新旧数据新增的数据按钮 -->
<div style="display: flex; justify-content: space-between; margin-top: 10px;">
<a-button style="margin-left: 200px;" @click="showLocalData()" type="primary"
icon="zoom-in">本地的新增数据</a-button>
<a-button style="margin: auto;" @click="showDifferenceData()" type="primary"
icon="zoom-in">存在差异的数据</a-button>
<a-button style="margin-right: 200px;" @click="showImportData()" type="primary"
icon="zoom-in">导入的新增数据</a-button>
</div>
</a-modal>
</a-upload>
<a-button type="primary" icon="zoom-in" @click="showHistoryModal">历史数据</a-button>
<a-modal v-model="historyModalVisible" title="历史数据" @ok="closeHistoryModal">
@ -54,8 +87,7 @@
<p style="font-size: 17px;">{{ TimestampData }}</p>
</div>
<div class="right">
<a-button type="primary" icon="download"
@click="ExportData('家具信息表', TimestampData)">导出</a-button>
<a-button type="primary" icon="download" @click="ExportData('家具信息表', TimestampData)">导出</a-button>
</div>
</div>
</div>
@ -108,7 +140,7 @@ import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import RmsInstrumentCollegeModal from './modules/RmsInstrumentCollegeModal.vue'
import { getAction } from '@/api/manage'
import { getAction, postAction } from '@/api/manage'
import RmsLocationModal from '../LocationList/modules/RmsLocationModal'
import locationaTree from '../components/locationaTree'
export default {
@ -120,10 +152,189 @@ 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: 'instrumentNumber',
width: 100,
//绿
customRender: (text, record) => getCustomRender(text, record, 'instrumentNumber'),
},
{
title: '仪器名称',
align: "center",
dataIndex: 'instrumentName',
width: 120,
//绿
customRender: (text, record) => getCustomRender(text, record, 'instrumentName')
},
{
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: 120,
//绿
customRender: (text, record) => getCustomRender(text, record, 'specifications')
},
{
title: '单价',
align: "center",
dataIndex: 'unitPrice',
width: 120,
//绿
customRender: (text, record) => getCustomRender(text, record, 'unitPrice')
},
{
title: '厂家',
align: "center",
dataIndex: 'manufactuer',
width: 200,
//绿
customRender: (text, record) => getCustomRender(text, record, 'manufactuer')
},
{
title: '购置日期',
align: "center",
dataIndex: 'purchaseDate',
width: 100,
//绿
customRender: (text, record) => getDateCustomRender(text, record, 'purchaseDate')
},
{
title: '领用人',
align: "center",
dataIndex: 'recipient',
width: 80,
//绿
customRender: (text, record) => getCustomRender(text, record, 'recipient')
},
{
title: '入库时间',
align: "center",
dataIndex: 'entryDate',
width: 100,
//绿
customRender: (text, record) => getDateCustomRender(text, record, 'entryDate')
},
{
title: '单据号',
align: "center",
dataIndex: 'documentNumber',
width: 100,
//绿
customRender: (text, record) => getCustomRender(text, record, 'documentNumber')
},
{
title: '存放地址',
align: "center",
dataIndex: 'locationName',
width: 110,
//绿
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: '操作',
dataIndex: 'action',
align: "center",
width: 60,
scopedSlots: { customRender: 'action' }
}
],
//
columns: [
{
@ -249,7 +460,16 @@ export default {
},
UserList: {},
historyModalVisible: false, //
historyData: [] //
historyData: [], //
ContrastData: [], //
NotOldRmsData: [], //
NotNewRmsData: [], //
NewDifferentData: [], //
NewTempDifferentData: [], //
OldDifferentData: [], //
returnData: [], //
tableTitle: "存在差异的数据:",
showDifference: false,
}
},
created() {
@ -261,6 +481,220 @@ 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: (
<div>
<span>{msg}</span><br />
<span>具体详情请 <a href={href} target="_blank" download={fileName}>点击下载</a> </span>
</div>
)
});
} 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/rmsInstrumentCollege/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.instrumentNumber === oldItem.instrumentNumber); // id
newItem.uniqueKey = temp++;
oldItem.uniqueKey = temp++;
//
oldItem.isOldData = true;
//
const fieldsToCompare = [
'instrumentNumber',
'instrumentName',
'collectingUnitNumber',
'categoryId',
'model',
'specifications',
'unitPrice',
'manufactuer',
'purchaseDate',
'recipient',
'entryDate',
'documentNumber',
'locationName',
'note',
'approvalStatus',
'initialAudit'
];
//
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)
@ -272,8 +706,8 @@ export default {
closeHistoryModal() {
this.historyModalVisible = false; //
},
//
getUserInfo() {
//
getUserInfo() {
getAction(this.url.userUrl).then(res => {
this.UserList = res.result.records;
})
@ -298,10 +732,14 @@ export default {
</script>
<style scoped>
@import '~@assets/less/common.less';
.modal-content {
max-height: 400px; /* 设置最大高度,根据需要进行调整 */
overflow-y: auto; /* 添加垂直滚动条 */
max-height: 400px;
/* 设置最大高度,根据需要进行调整 */
overflow-y: auto;
/* 添加垂直滚动条 */
}
.container {
display: flex;
align-items: center;

View File

@ -41,9 +41,42 @@
<div class="table-operator">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<a-button type="primary" icon="download" @click="handleExportXls('仪器信息表(学院)')">导出</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
<!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
@change="handleImportExcel">
<a-button type="primary" icon="import">导入</a-button>
</a-upload> -->
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
@change="ImportData">
<a-button type="primary" icon="import">导入</a-button>
<a-modal v-model="showDifference" title="数据对比" :width="1300" okText="导入" @ok="DifferenceOk">
<!-- 居中显示表格标题 -->
<div style="text-align: center; padding: 10px; background-color: #f0f0f0;
border-bottom: 1px solid #d9d9d9;">
<span style="font-size: 18px; font-weight: bold;">{{ this.tableTitle }}</span>
</div>
<a-table size="small" :scroll="{ x: true, y: '400px' }" :columns="DiffrentColumns"
:dataSource="ContrastData" :rowSelection="{
selectedRowKeys: SelectReserveData, onChange: onSelectReserveChange, onSelectAll: onSelectReserveAll,
onSelect: onSelectReserve, getCheckboxProps: record => ({
props: {
disabled: record.NotKeep === '1',
},
}),
}" :pagination="false" bordered>
<span slot="action" slot-scope="text, record">
<a @click="handleDetail(record)">详情</a>
</span>
</a-table>
<!-- 展示新旧数据新增的数据按钮 -->
<div style="display: flex; justify-content: space-between; margin-top: 10px;">
<a-button style="margin-left: 200px;" @click="showLocalData()" type="primary"
icon="zoom-in">本地的新增数据</a-button>
<a-button style="margin: auto;" @click="showDifferenceData()" type="primary"
icon="zoom-in">存在差异的数据</a-button>
<a-button style="margin-right: 200px;" @click="showImportData()" type="primary"
icon="zoom-in">导入的新增数据</a-button>
</div>
</a-modal>
</a-upload>
<a-button type="primary" icon="zoom-in" @click="showHistoryModal">历史数据</a-button>
<a-modal v-model="historyModalVisible" title="历史数据" @ok="closeHistoryModal">
@ -101,7 +134,7 @@
</template>
<script>
import { getAction } from '@/api/manage'
import { getAction, postAction } from '@/api/manage'
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
@ -120,11 +153,190 @@ export default {
instrumentSelect
},
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: 'instrumentNumber',
width: 100,
//绿
customRender: (text, record) => getCustomRender(text, record, 'instrumentNumber'),
},
{
title: '仪器名称',
align: "center",
dataIndex: 'instrumentName',
width: 120,
//绿
customRender: (text, record) => getCustomRender(text, record, 'instrumentName')
},
{
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: 120,
//绿
customRender: (text, record) => getCustomRender(text, record, 'specifications')
},
{
title: '单价',
align: "center",
dataIndex: 'unitPrice',
width: 120,
//绿
customRender: (text, record) => getCustomRender(text, record, 'unitPrice')
},
{
title: '厂家',
align: "center",
dataIndex: 'manufactuer',
width: 200,
//绿
customRender: (text, record) => getCustomRender(text, record, 'manufactuer')
},
{
title: '购置日期',
align: "center",
dataIndex: 'purchaseDate',
width: 100,
//绿
customRender: (text, record) => getDateCustomRender(text, record, 'purchaseDate')
},
{
title: '领用人',
align: "center",
dataIndex: 'recipient',
width: 80,
//绿
customRender: (text, record) => getCustomRender(text, record, 'recipient')
},
{
title: '入库时间',
align: "center",
dataIndex: 'entryDate',
width: 100,
//绿
customRender: (text, record) => getDateCustomRender(text, record, 'entryDate')
},
{
title: '单据号',
align: "center",
dataIndex: 'documentNumber',
width: 100,
//绿
customRender: (text, record) => getCustomRender(text, record, 'documentNumber')
},
{
title: '存放地址',
align: "center",
dataIndex: 'locationName',
width: 110,
//绿
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: '操作',
dataIndex: 'action',
align: "center",
width: 60,
scopedSlots: { customRender: 'action' }
}
],
columns: [
{
title: '仪器编号',
@ -249,7 +461,16 @@ export default {
},
UserList: {},
historyModalVisible: false, //
historyData: [] //
historyData: [], //
ContrastData: [], //
NotOldRmsData: [], //
NotNewRmsData: [], //
NewDifferentData: [], //
NewTempDifferentData: [], //
OldDifferentData: [], //
returnData: [], //
tableTitle: "存在差异的数据:",
showDifference: false,
}
},
created() {
@ -261,37 +482,222 @@ export default {
},
},
methods: {
// ExportInstrumentData(fileName, TimestampData) {
// console.log(TimestampData)
// if (!fileName || typeof fileName != "string") {
// fileName = ""
// }
// let param = this.getQueryParams();
// if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
// param['selections'] = this.selectedRowKeys.join(",")
// }
// param['timestamp'] = TimestampData.timestamp
// 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' }))
// let link = document.createElement('a')
// link.style.display = 'none'
// link.href = url
// link.setAttribute('download', fileName + '.xls')
// document.body.appendChild(link)
// link.click()
// document.body.removeChild(link); //
// window.URL.revokeObjectURL(url); //blob
// }
// })
// },
//
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: (
<div>
<span>{msg}</span><br />
<span>具体详情请 <a href={href} target="_blank" download={fileName}>点击下载</a> </span>
</div>
)
});
} 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/rmsInstrument/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.instrumentNumber === oldItem.instrumentNumber); // id
newItem.uniqueKey = temp++;
oldItem.uniqueKey = temp++;
//
oldItem.isOldData = true;
//
const fieldsToCompare = [
'instrumentNumber',
'instrumentName',
'collectingUnitNumber',
'categoryId',
'model',
'specifications',
'unitPrice',
'manufactuer',
'purchaseDate',
'recipient',
'entryDate',
'documentNumber',
'locationName',
'note',
'approvalStatus',
'initialAudit'
];
//
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)
@ -303,11 +709,6 @@ export default {
closeHistoryModal() {
this.historyModalVisible = false; //
},
// AddDataInstrument() {
// getAction("/rms/rmsIntangible/addDataInstrument").then(res => {
// console.log(res)
// })
// },
//
getUserInfo() {
getAction(this.url.userUrl).then(res => {

View File

@ -26,11 +26,11 @@
<a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
</span>
</a-col>
<a-col :xl="2" >
<a-col :xl="2">
<img style="height: 55px;" src="@/assets/collegelogo.jpg" alt="image">
</a-col>
<a-col :xl="4">
<p style="font-size: 20px; padding-top: 10px;">学院资产信息</p>
<p style="font-size: 20px; padding-top: 10px;">学院资产信息</p>
</a-col>
</a-row>
</a-form>
@ -44,8 +44,37 @@
<a-button type="primary" icon="download" @click="handleExportXls('无形资产(学院)')">导出</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
@change="handleImportExcel">
@change="ImportData">
<a-button type="primary" icon="import">导入</a-button>
<a-modal v-model="showDifference" title="数据对比" :width="1300" okText="导入" @ok="DifferenceOk">
<!-- 居中显示表格标题 -->
<div style="text-align: center; padding: 10px; background-color: #f0f0f0;
border-bottom: 1px solid #d9d9d9;">
<span style="font-size: 18px; font-weight: bold;">{{ this.tableTitle }}</span>
</div>
<a-table size="small" :scroll="{ x: true, y: '400px' }" :columns="DiffrentColumns"
:dataSource="ContrastData" :rowSelection="{
selectedRowKeys: SelectReserveData, onChange: onSelectReserveChange, onSelectAll: onSelectReserveAll,
onSelect: onSelectReserve, getCheckboxProps: record => ({
props: {
disabled: record.NotKeep === '1',
},
}),
}" :pagination="false" bordered>
<span slot="action" slot-scope="text, record">
<a @click="handleDetail(record)">详情</a>
</span>
</a-table>
<!-- 展示新旧数据新增的数据按钮 -->
<div style="display: flex; justify-content: space-between; margin-top: 10px;">
<a-button style="margin-left: 200px;" @click="showLocalData()" type="primary"
icon="zoom-in">本地的新增数据</a-button>
<a-button style="margin: auto;" @click="showDifferenceData()" type="primary"
icon="zoom-in">存在差异的数据</a-button>
<a-button style="margin-right: 200px;" @click="showImportData()" type="primary"
icon="zoom-in">导入的新增数据</a-button>
</div>
</a-modal>
</a-upload>
<a-button type="primary" icon="zoom-in" @click="showHistoryModal">历史数据</a-button>
<a-modal v-model="historyModalVisible" title="历史数据" @ok="closeHistoryModal">
@ -125,7 +154,7 @@ import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import RmsIntangibleCollegeModal from './modules/RmsIntangibleCollegeModal.vue'
import { getAction } from '@/api/manage'
import { getAction, postAction} from '@/api/manage'
import RmsLocationModal from '../LocationList/modules/RmsLocationModal'
import locationaTree from '../components/locationaTree'
export default {
@ -136,11 +165,219 @@ export default {
RmsLocationModal,
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: 'intangibleNumber',
width: 100,
//绿
customRender: (text, record) => getCustomRender(text, record, 'intangibleNumber'),
},
{
title: '资产名称',
align: "center",
dataIndex: 'intangibleName',
width: 120,
//绿
customRender: (text, record) => getCustomRender(text, record, 'intangibleName')
},
{
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: 'unitPrice',
width: 80,
//绿
customRender: (text, record) => getCustomRender(text, record, 'unitPrice')
},
{
title: '购置日期',
align: "center",
dataIndex: 'purchaseDate',
width: 100,
//绿
customRender: (text, record) => getDateCustomRender(text, record, 'purchaseDate')
},
{
title: '专利申请号',
align: "center",
dataIndex: 'patentApplicationNumber',
width: 80,
//绿
customRender: (text, record) => getCustomRender(text, record, 'patentApplicationNumber')
},
{
title: '发明人',
align: "center",
dataIndex: 'inventor',
width: 80,
//绿
customRender: (text, record) => getCustomRender(text, record, 'inventor')
},
{
title: '发明名称',
align: "center",
dataIndex: 'inventionName',
width: 120,
//绿
customRender: (text, record) => getCustomRender(text, record, 'inventionName')
},
{
title: '注册日期',
align: "center",
dataIndex: 'registrationDate',
width: 100,
//绿
customRender: (text, record) => getDateCustomRender(text, record, 'registrationDate')
},
{
title: '注册机关',
align: "center",
dataIndex: 'registrationAuthority',
width: 120,
//绿
customRender: (text, record) => getCustomRender(text, record, 'registrationAuthority')
},
{
title: '授权公告日',
align: "center",
dataIndex: 'authorizationAnnouncement',
width: 100,
//绿
customRender: (text, record) => getDateCustomRender(text, record, 'authorizationAnnouncement')
},
{
title: '批准文号',
align: "center",
dataIndex: 'approvalNumber',
width: 120,
//绿
customRender: (text, record) => getCustomRender(text, record, 'approvalNumber')
},
{
title: '领用人',
align: "center",
dataIndex: 'recipient',
width: 80,
//绿
customRender: (text, record) => getCustomRender(text, record, 'recipient')
},
{
title: '入库时间',
align: "center",
dataIndex: 'entryDate',
width: 100,
//绿
customRender: (text, record) => getDateCustomRender(text, record, 'entryDate')
},
{
title: '单据号',
align: "center",
dataIndex: 'documentNumber',
width: 100,
//绿
customRender: (text, record) => getCustomRender(text, record, 'documentNumber')
},
{
title: '存放地址',
align: "center",
dataIndex: 'locationName',
width: 110,
//绿
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: '操作',
dataIndex: 'action',
align: "center",
width: 60,
scopedSlots: { customRender: 'action' },
}
],
//
columns: [
{
@ -296,7 +533,16 @@ export default {
},
UserList: {},
historyModalVisible: false, //
historyData: [] //
historyData: [], //
ContrastData: [], //
NotOldRmsData: [], //
NotNewRmsData: [], //
NewDifferentData: [], //
NewTempDifferentData: [], //
OldDifferentData: [], //
returnData: [], //
tableTitle: "存在差异的数据:",
showDifference: false,
}
},
created() {
@ -308,6 +554,224 @@ 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: (
<div>
<span>{msg}</span><br />
<span>具体详情请 <a href={href} target="_blank" download={fileName}>点击下载</a> </span>
</div>
)
});
} 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/rmsIntangibleCollege/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.intangibleNumber === oldItem.intangibleNumber); // id
newItem.uniqueKey = temp++;
oldItem.uniqueKey = temp++;
//
oldItem.isOldData = true;
//
const fieldsToCompare = [
'collectingUnitNumber',
'locationName',
'recipient',
'documentNumber',
'approvalStatus',
'initialAudit',
'categoryId',
'intangibleName',
'unitPrice',
'purchaseDate',
'patentApplicationNumber',
'inventor',
'inventionName',
'registrationDate',
'registrationAuthority',
'authorizationAnnouncement',
'approvalNumber',
'note',
'entryDate'
];
//
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)
@ -348,6 +812,7 @@ export default {
</script>
<style scoped>
@import '~@assets/less/common.less';
.modal-content {
max-height: 400px;
/* 设置最大高度,根据需要进行调整 */

View File

@ -10,8 +10,8 @@
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row :gutter="24">
<a-col :xl="5" :lg="7" :md="8" :sm="24">
<a-auto-complete v-model="queryParam.recipient" :dataSource="UserdataSource"
placeholder="请选择领用人" @select="onSelect" @search="onSearch" @change="onChange" />
<a-auto-complete v-model="queryParam.recipient" :dataSource="UserdataSource" placeholder="请选择领用人"
@select="onSelect" @search="onSearch" @change="onChange" />
</a-col>
<a-col :xl="7" :lg="7" :md="8" :sm="24">
<a-form-item label="购置日期">
@ -30,7 +30,7 @@
<img style="height: 55px;" src="@/assets/schoollogo.jpg" alt="image">
</a-col>
<a-col :xl="4" :lg="7" :md="8" :sm="24">
<p style="font-size: 20px; padding-top: 10px;">学校资产信息</p>
<p style="font-size: 20px; padding-top: 10px;">学校资产信息</p>
</a-col>
</a-row>
</a-form>
@ -43,9 +43,42 @@
<!-- <a-button @click="AddData()" type="primary" icon="plus">导数据</a-button> -->
<a-button type="primary" icon="download" @click="handleExportXls('无形资产')">导出</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
<!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
@change="handleImportExcel">
<a-button type="primary" icon="import">导入</a-button>
</a-upload> -->
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
@change="ImportData">
<a-button type="primary" icon="import">导入</a-button>
<a-modal v-model="showDifference" title="数据对比" :width="1300" okText="导入" @ok="DifferenceOk">
<!-- 居中显示表格标题 -->
<div style="text-align: center; padding: 10px; background-color: #f0f0f0;
border-bottom: 1px solid #d9d9d9;">
<span style="font-size: 18px; font-weight: bold;">{{ this.tableTitle }}</span>
</div>
<a-table size="small" :scroll="{ x: true, y: '400px' }" :columns="DiffrentColumns"
:dataSource="ContrastData" :rowSelection="{
selectedRowKeys: SelectReserveData, onChange: onSelectReserveChange, onSelectAll: onSelectReserveAll,
onSelect: onSelectReserve, getCheckboxProps: record => ({
props: {
disabled: record.NotKeep === '1',
},
}),
}" :pagination="false" bordered>
<span slot="action" slot-scope="text, record">
<a @click="handleDetail(record)">详情</a>
</span>
</a-table>
<!-- 展示新旧数据新增的数据按钮 -->
<div style="display: flex; justify-content: space-between; margin-top: 10px;">
<a-button style="margin-left: 200px;" @click="showLocalData()" type="primary"
icon="zoom-in">本地的新增数据</a-button>
<a-button style="margin: auto;" @click="showDifferenceData()" type="primary"
icon="zoom-in">存在差异的数据</a-button>
<a-button style="margin-right: 200px;" @click="showImportData()" type="primary"
icon="zoom-in">导入的新增数据</a-button>
</div>
</a-modal>
</a-upload>
<a-button type="primary" icon="zoom-in" @click="showHistoryModal">历史数据</a-button>
<a-modal v-model="historyModalVisible" title="历史数据" @ok="closeHistoryModal">
@ -126,7 +159,7 @@ import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import RmsIntangibleModal from './modules/RmsIntangibleModal.vue'
import { getAction } from '../../../api/manage'
import { getAction, postAction } from '../../../api/manage'
import RmsLocationModal from '../LocationList/modules/RmsLocationModal'
import locationaTree from '../components/locationaTree'
@ -138,11 +171,217 @@ export default {
RmsLocationModal,
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: 'intangibleNumber',
width: 100,
//绿
customRender: (text, record) => getCustomRender(text, record, 'intangibleNumber'),
},
{
title: '资产名称',
align: "center",
dataIndex: 'intangibleName',
width: 120,
//绿
customRender: (text, record) => getCustomRender(text, record, 'intangibleName')
},
{
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: 'unitPrice',
width: 80,
//绿
customRender: (text, record) => getCustomRender(text, record, 'unitPrice')
},
{
title: '购置日期',
align: "center",
dataIndex: 'purchaseDate',
width: 100,
//绿
customRender: (text, record) => getDateCustomRender(text, record, 'purchaseDate')
},
{
title: '专利申请号',
align: "center",
dataIndex: 'patentApplicationNumber',
width: 80,
//绿
customRender: (text, record) => getCustomRender(text, record, 'patentApplicationNumber')
},
{
title: '发明人',
align: "center",
dataIndex: 'inventor',
width: 80,
//绿
customRender: (text, record) => getCustomRender(text, record, 'inventor')
},
{
title: '发明名称',
align: "center",
dataIndex: 'inventionName',
width: 120,
//绿
customRender: (text, record) => getCustomRender(text, record, 'inventionName')
},
{
title: '注册日期',
align: "center",
dataIndex: 'registrationDate',
width: 100,
//绿
customRender: (text, record) => getDateCustomRender(text, record, 'registrationDate')
},
{
title: '注册机关',
align: "center",
dataIndex: 'registrationAuthority',
width: 120,
//绿
customRender: (text, record) => getCustomRender(text, record, 'registrationAuthority')
},
{
title: '授权公告日',
align: "center",
dataIndex: 'authorizationAnnouncement',
width: 100,
//绿
customRender: (text, record) => getDateCustomRender(text, record, 'authorizationAnnouncement')
},
{
title: '批准文号',
align: "center",
dataIndex: 'approvalNumber',
width: 120,
//绿
customRender: (text, record) => getCustomRender(text, record, 'approvalNumber')
},
{
title: '领用人',
align: "center",
dataIndex: 'recipient',
width: 80,
//绿
customRender: (text, record) => getCustomRender(text, record, 'recipient')
},
{
title: '入库时间',
align: "center",
dataIndex: 'entryDate',
width: 100,
//绿
customRender: (text, record) => getDateCustomRender(text, record, 'entryDate')
},
{
title: '单据号',
align: "center",
dataIndex: 'documentNumber',
width: 100,
//绿
customRender: (text, record) => getCustomRender(text, record, 'documentNumber')
},
{
title: '存放地址',
align: "center",
dataIndex: 'locationName',
width: 110,
//绿
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: '操作',
dataIndex: 'action',
align: "center",
width: 60,
scopedSlots: { customRender: 'action' },
}
],
//
columns: [
{
@ -270,7 +509,7 @@ export default {
title: '审核状态',
align: "center",
dataIndex: 'approvalStatus_dictText',
width: 120
width: 120,
},
{
title: '初审状态',
@ -297,11 +536,24 @@ export default {
timestampUrl: "/rms/rmsIntangible/getTimestamp",
},
UserList: {},
historyModalVisible: false, //
historyData: [] //
historyData: [], //
ContrastData: [], //
NotOldRmsData: [], //
NotNewRmsData: [], //
NewDifferentData: [], //
NewTempDifferentData: [], //
OldDifferentData: [], //
returnData: [], //
tableTitle: "存在差异的数据:",
showDifference: false,
}
},
created() {
this.getUserInfo();
},
@ -311,11 +563,224 @@ export default {
},
},
methods: {
// AddData(){
// getAction("/rms/rmsIntangible/addData").then(res => {
// console.log(res)
// });
// },
//
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: (
<div>
<span>{msg}</span><br />
<span>具体详情请 <a href={href} target="_blank" download={fileName}>点击下载</a> </span>
</div>
)
});
} 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/rmsIntangible/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.intangibleNumber === oldItem.intangibleNumber); // id
newItem.uniqueKey = temp++;
oldItem.uniqueKey = temp++;
//
oldItem.isOldData = true;
//
const fieldsToCompare = [
'collectingUnitNumber',
'locationName',
'recipient',
'documentNumber',
'approvalStatus',
'initialAudit',
'categoryId',
'intangibleName',
'unitPrice',
'purchaseDate',
'patentApplicationNumber',
'inventor',
'inventionName',
'registrationDate',
'registrationAuthority',
'authorizationAnnouncement',
'approvalNumber',
'note',
'entryDate'
];
//
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)
@ -352,11 +817,13 @@ export default {
},
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
.modal-content {
max-height: 400px;
/* 设置最大高度,根据需要进行调整 */

View File

@ -0,0 +1,213 @@
<template>
<div>
<span class="ant-input-wrapper ant-input-group">
<!-- <input placeholder="请选择资产" type="text" readonly="true" unselectable="on" class="ant-input"> -->
<a-button type="primary" preIcon="ant-design:plus-outlined" @click="showModal()">选择</a-button>
</span>
<!-- table区域-begin -->
<a-modal title="请选择资产" closable :visible="visible" :width="1000" @cancel="onCancel" @ok="onOk" @close="onClose">
<div style="margin: -10px;background-color: rgb(236, 236, 236);padding: 10px;">
<div style="margin-bottom: 10px;">
<a-auto-complete v-model="queryParam.recipient" :dataSource="UserdataSource" placeholder="请选择领用人"
@select="onSelect" @search="onSearch" @change="onChange" />
<a-button type="primary" @click="searchQuery" icon="search" style="margin-left: 8px">查询</a-button>
<a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
</div>
<div class="ant-alert ant-alert-info" style="margin-bottom: 10px;">
<i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
selectedRowKeys.length }}</a>
<a style="margin-left: 24px" @click="onClearSelected">清空</a>
</div>
<div style="background-color: #fff;">
<a-table style="padding: 10px;" ref="table" size="large" :scroll="{ x: true }" bordered rowKey="id"
:columns="columns" :dataSource="dataSource" :pagination="ipagination" :loading="loading"
:rowSelection="{ sselectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
class="j-table-force-nowrap" @change="handleTableChange">
</a-table>
</div>
</div>
</a-modal>
</div>
</template>
<script>
import { getAction } from '@/api/manage'
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
export default {
mixins: [JeecgListMixin, mixinDevice],
data() {
return {
visible: false,
value: '',
dataSource: [],
UserdataSource: [],
//
columns: [
{
title: '仪器编号',
align: "center",
dataIndex: 'instrumentNumber',
width: 120
},
{
title: '仪器名称',
align: "center",
dataIndex: 'instrumentName',
width: 120
},
{
title: '领用单位号',
align: "center",
dataIndex: 'collectingUnitNumber_dictText',
width: 200
},
{
title: '分类号',
align: "center",
dataIndex: 'categoryId',
width: 120
},
{
title: '型号',
align: "center",
dataIndex: 'model',
width: 120
},
{
title: '规格',
align: "center",
dataIndex: 'specifications',
width: 120
},
{
title: '单价',
align: "center",
dataIndex: 'unitPrice',
width: 120
},
{
title: '厂家',
align: "center",
dataIndex: 'manufactuer',
width: 200
},
{
title: '购置日期',
align: "center",
dataIndex: 'purchaseDate',
customRender: function (text) {
return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
},
width: 120
},
{
title: '领用人',
align: "center",
dataIndex: 'recipient_dictText',
width: 80
},
{
title: '入库时间',
align: "center",
dataIndex: 'entryDate',
customRender: function (text) {
return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
},
width: 80
},
{
title: '单据号',
align: "center",
dataIndex: 'documentNumber'
},
{
title: '存放地址',
align: "center",
dataIndex: 'locationName',
width: 120
},
{
title: '备注',
align: "center",
dataIndex: 'note',
width: 120
},
{
title: '审核状态',
align: "center",
dataIndex: 'approvalStatus_dictText',
width: 120
},
{
title: '初审状态',
align: "center",
dataIndex: 'initialAudit_dictText',
width: 120
},
],
url: {
list: "/rms/rmsInstrument/list",
delete: "/rms/rmsInstrument/delete",
deleteBatch: "/rms/rmsInstrument/deleteBatch",
exportXlsUrl: "/rms/rmsInstrument/exportXls",
importExcelUrl: "rms/rmsInstrument/importExcel",
userUrl: "/sys/user/queryUserComponentData?column=createTime&order=desc&field=id,,username,realname,sex,phone,orgCodeTxt&pageNo=1&pageSize=100",
},
UserList: {},
}
},
created() {
this.getUserInfo();
},
computed: {
importExcelUrl: function () {
return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
},
},
methods: {
showModal() {
this.visible = true;
},
//
getUserInfo() {
getAction(this.url.userUrl).then(res => {
this.UserList = res.result.records;
})
},
onSearch(query) {
this.UserdataSource = this.UserList.filter(user =>
user.username.includes(query) || user.realname.includes(query)
).map(user => ({
value: user.username,
text: user.realname
}));
},
onCancel() {
//
this.visible = false;
//
},
onOk() {
//
//
},
onClose() {
//
//
this.visible = false;
}
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>