上传视觉对比需求中,前端js改造

This commit is contained in:
yuandongqiang 2025-06-24 09:53:19 +08:00
parent 0e8b094f3e
commit b8b0e240ab
4 changed files with 4428 additions and 0 deletions

View File

@ -0,0 +1,785 @@
/**
* 业务代码
*/
// main页面打开版本列表
const versionListFun = {
versionList: [],
historyList: [],
openVersionList() {
let page = $("#versionList")
if (page.length > 0) {
this.closeVersionList()
return
}
$(`<div id="versionList" class="versionList"></div>`).appendTo("#designer_header")
this.loadVersionList()
},
loadVersionList() {
function versionItem(item) {
return `
<div class="version-item">
<div class="version-content">
<div class="top-info">
<span class="left-span version-state-${item.versionStatus}">${item.versionNo} ${item.versionStatus1}</span>
<span style="font-size: 12px;display: inline-flex;align-items: center">${item.updateTime}<span class="update-user-name" awsui-qtip="${item.updateUser}">${item.updateUser}</span>${}</span>
</div>
<div class="bottom-info">
<span class="left-span">${item.createTime}</span>
<span style="display: inline-flex;align-items: center"> ${}<span class="create-user-name" awsui-qtip="${item.createUser}">${item.createUser}</span>${}</span>
</div>
</div>
<div class="version-icon">
${item.hasCreatePerm ? `<i class="awsui-iconfont" awsui-qtip="${新建版本}" onclick="versionListFun.createNewVersion(event,${JSON.stringify(item).replace(/\"/g, "'")})">&#xe840;</i>` : ''}
<i class="awsui-iconfont" style="margin: 0 13px;display: ${item.versionStatus === 'use' ? 'none' : ''}" awsui-qtip="${版本对比}" onclick="versionListFun.openComparePage(event,${JSON.stringify(item).replace(/\"/g, "'")})">&#xe7cd;</i>
<i class="awsui-iconfont" awsui-qtip="${切换该版本}" style="display: ${item.isHistory || item.versionStatus === 'use' ? 'none' : ''}" onclick="versionListFun.switchVersion(event,${JSON.stringify(item).replace(/\"/g, "'")})">&#xe839;</i>
<div class="select-version" id="select_${item.plId}"></div>
</div>
</div>
`
}
awsui.ajax.request({
url: './jd',
method: 'POST',
data: {
cmd: 'com.actionsoft.apps.coe.pal_pl_repository_designer_version_list',
sid: sid,
wsId: wsId,
teamId: teamId,
id: ruuid
},
ok: function (res) {
if (res.result === 'ok') {
const status = {
use: 设计中,
publish: 已发布,
stop: 已停用,
approval: 审核中,
designer: 设计
}
let versionList = res.data.versionList, historyList = res.data.historyList
versionList.forEach(item => {
item.versionStatus1 = status[item.versionStatus]
})
historyList.forEach(item => {
item.versionStatus1 = status[item.versionStatus]
})
versionListFun.versionList = [...versionList]
versionListFun.historyList = [...historyList]
let str = ''
versionList.forEach(item => {
str += versionItem(item)
})
if (historyList.length > 0) {
str += `<div class="history-title">${历史版本}</div>`
historyList.forEach(item => {
str += versionItem({...item, isHistory: true})
})
}
$("#versionList").empty()
$("#versionList").append(str)
}
}
})
},
closeVersionList() {
if ($("#versionList")) {
$("#versionList").remove()
}
},
// 创建新版本
createNewVersion(event, item) {
event.stopPropagation()
if (versionListFun.historyList.length > 0 && isBpmSupportMinor != 'true') { // 不支持小版本迭代
$.confirm({
title: 提示,
content: `${确定将} ${item.versionNo} ${item.isHistory ? 历史版本为模板创建新版本文件 : 版本为模板创建新版本文件}?`,
onConfirm: function () {
awsui.ajax.request({
url: './jd',
method: 'POST',
data: {
cmd: 'com.actionsoft.apps.coe.pal_pl_repository_designer_version_manager_create',
sid: sid,
wsId: wsId,
teamId: teamId,
id: item.plId,
isLargeIteration: true,
isHistory: item.isHistory || false
},
ok: function (res) {
if (res.result === 'ok') {
versionListFun.loadVersionList()
}
}
})
}
})
} else {
let {plId, versionNo} = item
let selectVersion = $("#select_" + plId)
if (selectVersion.is(":visible")) {
selectVersion.empty()
selectVersion.hide()
return
}
$(".select-version").hide()
selectVersion.show()
let smallVersionInteger = parseInt(versionNo.match(/\d+\.\d+/g)[0]); // 小版本整数位
let smallVersionDecimal; // 小版本小数位
let arr1 = []; // 大版本号
let arr2 = []; // 以当前版本为大版本的所有小版本
let largeVersion, smallVersion
let allVersion = versionListFun.versionList.concat(versionListFun.historyList).map(item => item.versionNo.match(/\d+\.\d+/g)[0].split('.'))
allVersion.forEach(item => {
arr1.push(parseInt(item[0]))
if (item[0] == smallVersionInteger) {
arr2.push(parseInt(item[1]))
}
})
smallVersionDecimal = Math.max(...arr2) + 1
largeVersion = 'v' + (Math.max(...arr1) + 1).toFixed(1)
if (item.isHistory) {
smallVersion = 'v' + Math.max(...arr1) + '.' + smallVersionDecimal
} else {
smallVersion = 'v' + smallVersionInteger + '.' + smallVersionDecimal
}
selectVersion.html(`
<div>${请选择版本号}:</div>
<div style="height: 25px;padding: 8px 0 4px 0;">
<input class="awsui-radio" type="radio" name="versionRadio" isLargeIteration="true">
<span style="line-height: 19px">${largeVersion}</span>
</div>
<div>
<input class="awsui-radio" type="radio" name="versionRadio" isLargeIteration="false">
<span style="line-height: 19px">${smallVersion}</span>
</div>
`)
$("input[name='versionRadio']").on("click", function (event) {
event.stopPropagation()
let isLargeIteration = $(this).attr("isLargeIteration") == 'true'
awsui.ajax.request({
url: './jd',
method: 'POST',
data: {
cmd: 'com.actionsoft.apps.coe.pal_pl_repository_designer_version_manager_create',
sid: sid,
wsId: wsId,
teamId: teamId,
id: item.plId,
isLargeIteration: isLargeIteration,
isHistory: item.isHistory || false
},
ok: function (res) {
if (res.result === 'ok') {
let newId = res.data.uuid
awsui.ajax.request({
url: './jd',
method: 'POST',
data: {
cmd: 'com.actionsoft.apps.coe.pal_pl_repository_designer_version_manager_use',
sid: sid,
wsId: wsId,
teamId: teamId,
id: newId,
},
ok: function (res) {
if (res.result === 'ok') {
let currentURL = window.location.href
let url = new URL(currentURL)
let searchParams = new URLSearchParams(url.search)
searchParams.set('uuid', newId);
url.search = searchParams.toString()
window.location.href = url.toString()
}
}
})
}
}
})
});
}
},
// 打开版本对比
openComparePage(event, item) {
event.stopPropagation()
let compareBox = $("#versionCompareBox")
compareBox.empty()
compareBox.show()
let str = '<iframe id="versionCompareContent" name="versionCompareContent" style="width: 100%; height: 100%;border: none"></iframe>';
compareBox.append(str);
$('#versionCompareContent').attr(
'src', "./w?sid=" + sid
+ "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_version_compare"
+ "&wsId=" + wsId
+ "&compareVerId=" + item.plId
+ "&curId=" + ruuid
+ "&teamId=" + teamId
// 添加子页面所需参数:是否为历史版本
+ "&isHistory=" + item.isHistory
)
versionListFun.closeVersionList()
},
// 关闭版本对比
closeComparePage() {
parent.$("#versionCompareBox").hide()
parent.$("#versionCompareBox").empty()
},
// 切换版本
switchVersion(event, item) {
event.stopPropagation()
if ($("#saving_tip").text() == 文件已修改未保存) {
$.confirm({
title: 提示,
content: 文件修改未保存 + '' + 是否继续切换,
onConfirm: function () {
versionListFun.changeCurVersion(item.plId)
}
})
} else {
versionListFun.changeCurVersion(item.plId)
}
},
changeCurVersion(uuid) {
awsui.ajax.request({
url: './jd',
method: 'POST',
data: {
cmd: 'com.actionsoft.apps.coe.pal_pl_repository_designer_version_manager_use',
sid: sid,
wsId: wsId,
teamId: teamId,
id: uuid,
},
ok: function (res) {
if (res.result === 'ok') {
let currentURL = window.location.href
let url = new URL(currentURL)
let searchParams = new URLSearchParams(url.search)
searchParams.set('uuid', uuid);
url.search = searchParams.toString()
window.location.href = url.toString()
}
}
})
}
}
// 版本对比页面
const designerZoomYl = {
left: 100,
right: 100
}
const fileTabStr = ` <div class="attr-tab active-tab" tab="attr">
<div class="tab-name">${文件属性}</div>
</div>
<div class="attr-tab" tab="upFile">
<div class="tab-name">${附件}</div>
</div>
`
const shapeTabStr = ` <div class="attr-tab active-tab" tab="attr">
<div class="tab-name">${形状属性}</div>
</div>
<div class="attr-tab" tab="upFile">
<div class="tab-name">${附件}</div>
</div>
<div class="attr-tab" tab="link">
<div class="tab-name">${链接}</div>
</div>
`
const versionCompareFun = {
// 缩放
pageZoom(position, type) {
function handleZoom(position, type) {
if (type == 'zoomIn') {
if (designerZoomYl[position] + 10 > 200) {
designerZoomYl[position] = 200;
} else {
designerZoomYl[position] = designerZoomYl[position] + 10;
}
} else if (type == 'zoomOut') {
if (designerZoomYl[position] - 10 < 50) {
designerZoomYl[position] = 50;
} else {
designerZoomYl[position] = designerZoomYl[position] - 10;
}
} else {
designerZoomYl[position] = 100;
}
VersionDesigner.setZoomScale(position, designerZoomYl[position] / 100);
$("#zoom-value-" + position).text(Math.round(VersionDesigner.config.scale[position] * 100) + '%')
}
handleZoom(position, type)
if (isSameOperate) {
let otherPos = position === "left" ? "right" : "left";
designerZoomYl[otherPos] = designerZoomYl[position]
VersionDesigner.setZoomScale(otherPos, designerZoomYl[position] / 100);
$("#zoom-value-" + otherPos).text(Math.round(VersionDesigner.config.scale[otherPos] * 100) + '%')
}
},
// 鹰眼导航
openNavigation: function (position, isShow) {
function handleNav(position, isShow) {
if (isShow) {
$("#navigation-view-" + position).show()
Navigator.draw(position)
$('#show-nav-' + position).hide()
$('#close-nav-' + position).show()
} else {
$("#navigation-view-" + position).hide()
$('#show-nav-' + position).show()
$('#close-nav-' + position).hide()
}
}
handleNav(position, isShow)
if (isSameOperate) {
let otherPos = position === "left" ? "right" : "left";
handleNav(otherPos, isShow)
}
},
openAttributeView: function (position) {
function handleAttrView(position) {
let selectedLength = Utils.getSelected(position).length
let view = $("#attribute-view-" + position)
let headLeft = view.find('.head-left')
if (selectedLength > 0) {
headLeft.attr('viewType', 'shape')
headLeft.html(shapeTabStr)
versionCompareFun.writeShapeAttributeHtml(position)
} else {
headLeft.attr('viewType', 'file')
headLeft.html(fileTabStr)
versionCompareFun.writeFileAttributeHtml(position)
}
view.show()
let btn = $("#view-btn-" + position)
btn.find('.btn-text').remove()
btn.css('width', '45px')
btn.hide()
versionCompareFun.attrViewEvent(position)
}
handleAttrView(position)
if (isSameOperate) {
let otherPos = position === "left" ? "right" : "left";
handleAttrView(otherPos)
}
},
closeAttributeView: function (position) {
$("#attribute-view-" + position).hide()
$("#view-btn-" + position).show()
if (isSameOperate) {
let otherPos = position === "left" ? "right" : "left";
$("#attribute-view-" + otherPos).hide()
$("#view-btn-" + otherPos).show()
}
},
// view事件
attrViewEvent: function (position) {
let otherPos = position === "left" ? "right" : "left";
let view = $("#attribute-view-" + position), viewBody = $("#view-body-" + position)
let otherView = $("#attribute-view-" + otherPos)
// tab点击
view.find(".head-left").off("click").on("click", ".attr-tab", function () {
view.find(".head-left div.active-tab").removeClass("active-tab");
$(this).addClass("active-tab");
let activeTab = $(this).attr("tab")
viewBody.children().css('display', 'none')
viewBody.find('.view-' + activeTab).show()
if (isSameOperate) {
if (otherView.is(":visible")) {
let curType = $(this).parent().attr("viewType") // 当前是文件属性还是数据属性 file/shape
let otherViewHead = otherView.find('.head-left'), otherViewBody = $("#view-body-" + otherPos), otherType = otherViewHead.attr("viewType")
if (curType === otherType) {
updateActiveTab(otherViewHead, otherViewBody, activeTab)
} else {
if (curType === 'shape') {
let selectedId = Utils.getSelectedIds(position)[0]
if (PageModel[otherPos].define.elements[selectedId]) {
Utils.selectShape(otherPos, selectedId)
versionCompareFun.updateAttributeView(otherPos)
updateActiveTab(otherViewHead, otherViewBody, activeTab)
}
} else {
Utils.unselect(otherPos)
versionCompareFun.updateAttributeView(otherPos)
updateActiveTab(otherViewHead, otherViewBody, activeTab)
}
}
}
}
function updateActiveTab(otherViewHead, otherViewBody, activeTab) {
otherViewHead.children().removeClass("active-tab")
otherViewHead.find(`div[tab=${activeTab}]`).addClass("active-tab")
otherViewBody.children().css('display', 'none')
otherViewBody.find('.view-' + activeTab).show()
}
})
// 内容滚动
viewBody.off("scroll").on("scroll", function () {
if (isSameOperate) {
if (otherView.is(":visible")) {
let otherViewBody = $("#view-body-" + otherPos)
otherViewBody.scrollTop($(this).scrollTop())
}
}
})
},
// 点击画布更新属性页面
updateAttributeView: function (position) {
let view = $("#attribute-view-" + position)
let headLeft = view.find('.head-left')
let viewType = headLeft.attr('viewType') // 当前是文件属性还是数据属性 file/shape
if (view.is(":visible")) {
let selectedLength = Utils.getSelected(position).length
if (viewType === 'file') { // 已经打开了文件属性窗口
if (selectedLength > 0) {
headLeft.html(shapeTabStr)
headLeft.attr('viewType', 'shape')
this.writeShapeAttributeHtml(position)
}
} else { // 已经打开了数据属性窗口
if (selectedLength > 0) {
this.writeShapeAttributeHtml(position)
} else {
headLeft.html(fileTabStr)
headLeft.attr('viewType', 'file')
this.writeFileAttributeHtml(position)
}
}
this.attrViewEvent(position)
}
},
// 文件属性
writeFileAttributeHtml: function (position) {
const view = $("#attribute-view-" + position)
const activeTab = view.find(".active-tab").attr("tab")
let body = $("#view-body-" + position)
body.empty()
let allData = position === 'left' ? versionData : curData
let attr = allData.fileAttr, upFile = allData.fileUpFile, relationUpFile = allData.fileRelationUpFile
let attrStr = this.getAttrStr(position, attr)
let bodyStr = `<div class="view-attr" style="display:none;">
${attrStr === '' ? `<div class="category-item">${暂无文件属性}</div>` : `${attrStr}`}
</div>
<div class="view-upFile" style="display:none;">
${this.getAttrStr(position, [{type: 'file', name: 附件, value: upFile.value, isDiff: upFile.isDiff,}])}
${this.getAttrStr(position, [{type: 'file', name: 关联附件, value: relationUpFile.value, isDiff: relationUpFile.isDiff}])}
</div>`
body.html(bodyStr)
body.find('.view-' + activeTab).show()
// 追加差异样式
view.find(".tab-name").removeClass('attr-diff')
if (attr && attr.some(i => i.isDiff)) {
view.find('div[tab=attr]').find('.tab-name').addClass('attr-diff')
}
},
// 形状属性
writeShapeAttributeHtml: function (position) {
const view = $("#attribute-view-" + position)
const activeTab = view.find(".active-tab").attr("tab")
let body = $("#view-body-" + position)
body.empty()
let shape = Utils.getSelected(position)[0]
const allData = position === 'left' ? versionData : curData
let attributeArr = allData.shapeAttr[shape.id] || [],
shapeUpFile = allData.shapeUpFile[shape.id] || {},
shapeRelationUpFile = allData.shapeRelationUpFile[shape.id] || {},
shapeLink = allData.shapeLink[shape.id] || {file: {}, custom: {}}
let attrStr = this.getAttrStr(position, attributeArr)
let bodyStr = `<div class="view-attr" style="display:none;">
${attrStr === '' ? `<div class="category-item">${暂无形状属性}</div>` : `${attrStr}`}
</div>
<div class="view-upFile" style="display:none;">
${this.getAttrStr(position, [{type: 'file', name: 附件, value: shapeUpFile.value, isDiff: shapeUpFile.isDiff,}])}
${this.getAttrStr(position, [{type: 'file', name: 关联附件, value: shapeRelationUpFile.value, isDiff: shapeRelationUpFile.isDiff}])}
</div>
<div class="view-link" style="display:none;">
${this.getAttrStr(position, [{type: 'shapeLink', name: 文件链接, value: shapeLink.file.value, isDiff: shapeLink.file.isDiff}])}
${this.getAttrStr(position, [{type: 'shapeLink', name: 自定义链接, value: shapeLink.custom.value, isDiff: shapeLink.custom.isDiff}])}
</div>`
body.html(bodyStr)
body.find('.view-' + activeTab).show()
// 追加差异样式
view.find(".tab-name").removeClass('attr-diff')
if (attributeArr.some(i => i.isDiff)) {
view.find('div[tab=attr]').find('.tab-name').addClass('attr-diff')
}
if (shapeUpFile.isDiff || shapeRelationUpFile.isDiff) {
view.find('div[tab=upFile]').find('.tab-name').addClass('attr-diff')
}
if (shapeLink.file.isDiff || shapeLink.custom.isDiff) {
view.find('div[tab=link]').find('.tab-name').addClass('attr-diff')
}
},
getAttrStr: function (position, attr) {
let str = ''
if (!attr) return str;
attr.forEach(item => {
if (item.type === 'relation' || item.type === 'awsorg') {
item.value = item.value.toString()
}
let contentStr = ''
switch (item.type) {
case 'table':
if (item.value) {
let tableStr = ''
let table = JSON.parse(item.value).table
let t1 = table[0].name, t2 = table[0].desc
tableStr += `<div class="table-header">
<div class="left-tr" >${t1}</div>
<div class="right-tr">${t2}</div>
</div>`
for (let i = 1; i < table.length; i++) {
let t1 = table[i].name, t2 = table[i].desc
tableStr += `<div class="table-row">
<div class="left-tr">${t1}</div>
<div class="right-tr">${t2}</div>
</div>`
}
contentStr = `<div class="attr-table-content">${tableStr}</div>`
} else {
contentStr = `<div class="category-content">${暂无}${item.name}</div>`
}
break;
case 'file':
let isHighSecurity = false
let fileList = item.value || []
let listStr = ''
fileList.forEach(item => {
let security = '' // 三元
if (isHighSecurity) {
security = `<span style="color: ${item.securityInfo.color}">${item.securityInfo.name}</span>`
}
listStr += `<div class="file-item">
<div class="name-box">
<span class="name-content" awsui-qtip="${item.fileName}" style="max-width: ${security === '' ? '100%' : 'calc(100% - 50px)'}" >${item.fileName}</span>
${security}
</div>
<div class="file-menu" awsui-qtip="${预览}" onclick="versionCompareFun.previewFile('${position}',${JSON.stringify(item).replace(/\"/g, "'")})">
<i class="awsui-iconfont">&#xe698;</i>
</div>
</div>`
})
contentStr = `<div class="category-content">${listStr === '' ? `${暂无}${item.name}` : listStr}</div>`
break;
case 'link':
contentStr = `<div class="category-content">
${item.value === '' ? `${暂无}${item.name}` : `<a href="${item.value}" target="_blank" style="color: #333">${item.value}</a>`}
</div>`
break;
case 'shapeLink':
let linkStr = '', list = item.value || []
list.forEach(i => {
linkStr += `<div class="file-item">
<div class="name-box" awsui-qtip="${i.url}">
<a href="${i.url}" target="_blank" style="color: #333">${i.value}</a>
</div>
</div>`
})
contentStr = `<div class="category-content">${linkStr === '' ? `${暂无}${item.name}` : linkStr}</div>`
break;
default:
contentStr = `<div class="category-content">
${item.value === '' ? `${暂无}${item.name}` : `${item.value}`}
</div>`
}
str += `<div class="category-item ${item.isDiff ? 'attr-diff' : ''}">
<div class="attr-title">${item.name}</div>
${contentStr}
</div>`
})
return str
},
// 预览
previewFile(position, file) {
const imgType = ['jpg', 'jpeg', 'gif', 'png']
const fileType = file.fileName.split('.').reverse()[0]
if (!imgType.includes(fileType)) { // 不是图片
window.open(file.downloadUrl)
return
}
$("#attribute-view-" + position).css('opacity', 0)
$('#model-' + position).show()
const otherPos = position === 'left' ? 'right' : 'left'
const windowWidth = document.body.clientWidth
const dialog = $('#file-preview-' + position), otherDialog = $('#file-preview-' + otherPos)
const img = new Image()
img.src = file.downloadUrl
img.addEventListener('load', function () {
dialog.find('img').attr('src', img.src)
dialog.dialog({
title: file.fileName,
width: 650,
height: 480,
model: false,
onClose: function () {
$('#model-' + position).hide()
$("#attribute-view-" + position).css('opacity', 1)
}
})
let dialogWidth = dialog.outerWidth(true), otherDialogWidth = otherDialog.outerWidth(true)
let x = windowWidth / 2 / 2 - dialogWidth / 2
if (position === 'right') {
x += windowWidth / 2
}
dialog.css({
left: x + 'px'
})
if (otherDialog.is(":visible")) {
// dialog机制会把已经打开的dialog居中 这里重新设置一下
let x = windowWidth / 2 / 2 - otherDialogWidth / 2
if (otherPos === 'right') {
x += windowWidth / 2
}
otherDialog.css({
left: x + 'px'
})
}
})
},
// 同步操作
isOpenSameOperate(isOpen) {
isSameOperate = isOpen
if (isOpen) {
$('.opend-operate').show()
$('.closed-operate').hide()
} else {
$('.opend-operate').hide()
$('.closed-operate').show()
}
},
// 版本列表
openCompareList() {
versionCompareFun.closeAttributeView('left')
versionCompareFun.closeAttributeView('right')
let page = $("#compareVersionList")
if (page.is(":visible")) {
page.hide()
page.empty()
} else {
awsui.ajax.request({
url: './jd',
method: 'POST',
data: {
cmd: 'com.actionsoft.apps.coe.pal_pl_repository_designer_version_list',
sid: parent.sid,
wsId: parent.wsId,
teamId: parent.teamId,
id: parent.ruuid
},
ok: function (res) {
if (res.result === 'ok') {
const status = {
use: 设计中,
publish: 已发布,
stop: 已停用,
approval: 审核中,
designer: 设计
}
let versionList = res.data.versionList, historyList = res.data.historyList
versionList.forEach(item => {
item.versionStatus1 = status[item.versionStatus]
})
historyList.forEach(item => {
item.isHistory = true
item.versionStatus1 = status[item.versionStatus]
})
let allList = versionList.concat(historyList)
page.empty()
let str = ''
allList.forEach(item => {
let isDisabled = item.versionNo === versionData.versionNo || item.versionNo === curData.versionNo
str += `
<div style="cursor: ${isDisabled ? 'not-allowed' : 'pointer'}" class="version-item ${isDisabled ? 'disabled' : ''}" onclick="versionCompareFun.changeComparePageUrl(this,'${item.plId}','${item.isHistory}')">
<div class="version-content">
<div class="top-info">
<span class="left-span version-state-${item.versionStatus}">${item.versionNo} ${item.versionStatus1}</span>
</div>
<div class="bottom-info">
<span style="display: inline-flex;align-items: center">${item.updateTime} ${}<span style="max-width: 65px" class="update-user-name" awsui-qtip="${item.updateUser}">${item.updateUser}</span>${}</span>
</div>
</div>
<div style="width: 30px;text-align: center">
<i class="awsui-iconfont" style="font-size: 20px">${item.versionNo === versionData.versionNo ? '&#xea2e;' : ''}</i>
</div>
</div>
`
})
page.append(str)
page.show()
}
}
})
}
},
// 点击监听 关闭版本列表
closeVersionListByClick(event) {
let page = $("#compareVersionList")
if (!page.is(":visible")) {
return;
}
let targetElement = event.target; // 获取被点击的元素
let isClickInsideDropdown = document.getElementById('compareVersionList').contains(targetElement); // 检查点击是否在下拉框内
let isClickOnButton = document.querySelector('.center-top').contains(targetElement); // 检查点击是否在触发按钮内
if (!isClickInsideDropdown && !isClickOnButton) {
// 关闭下拉框
page.hide()
page.empty()
}
},
// 切换对比版本
changeComparePageUrl($this, compareVerId, isHistory) {
if ($($this).hasClass('disabled')) return
let listBox = $("#compareVersionList"), iframe = parent.$('#versionCompareContent')
listBox.hide()
listBox.empty()
parent.$.simpleAlert(正在切换, 'loading')
iframe.attr(
'src', "./w?sid=" + parent.sid
+ "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_version_compare"
+ "&wsId=" + parent.wsId
+ "&compareVerId=" + compareVerId
+ "&curId=" + curData.plId
+ "&teamId=" + parent.teamId
// 添加子页面所需参数:是否为历史版本
+ "&isHistory=" + isHistory
)
iframe.on('load', function () {
parent.$.simpleAlert("close")
})
},
// 切换到该版本
changeToSelectedV() {
$.confirm({
title: 提示,
content: 是否将 + ` ${versionData.versionNo} ` + 切换为使用中,
onConfirm: function () {
awsui.ajax.request({
url: './jd',
method: 'POST',
data: {
cmd: 'com.actionsoft.apps.coe.pal_pl_repository_designer_version_manager_use',
sid: parent.sid,
wsId: parent.wsId,
teamId: parent.teamId,
id: versionData.plId,
},
ok: function (res) {
if (res.result === 'ok') {
let currentURL = parent.window.location.href
let url = new URL(currentURL)
let searchParams = new URLSearchParams(url.search)
searchParams.set('uuid', versionData.plId);
url.search = searchParams.toString()
parent.window.location.href = url.toString()
}
}
})
}
})
}
}