diff --git a/frontend/src/views/grading-admin/components/render-instance-table.vue b/frontend/src/views/grading-admin/components/render-instance-table.vue
index 0b4215480..3a51145fc 100644
--- a/frontend/src/views/grading-admin/components/render-instance-table.vue
+++ b/frontend/src/views/grading-admin/components/render-instance-table.vue
@@ -166,7 +166,6 @@
{{ $t(`m.common['保存']`) }}
- {{ $t(`m.common['预览']`) }}
{{ $t(`m.common['取消']`) }}
@@ -332,12 +331,6 @@
.related_resource_types[this.curResIndex];
return curData.selectionMode;
},
- isShowPreview () {
- if (this.curIndex === -1) {
- return false;
- }
- return this.tableList[this.curIndex].policy_id !== '';
- },
// 处理无限制和聚合后多个tab数据结构不兼容情况
formatDisplayValue () {
return (payload) => {
@@ -707,35 +700,7 @@
this.curResIndex = -1;
this.curGroupIndex = -1;
},
-
- handlerResourcePreview () {
- const { id } = this.tableList[this.curIndex].resource_groups[this.curGroupIndex];
- const { system_id, type, name } = this.tableList[this.curIndex].resource_groups[this.curGroupIndex]
- .related_resource_types[this.curResIndex];
- const condition = [];
- const conditionData = this.$refs.renderResourceRef.handleGetPreviewValue();
- conditionData.forEach(item => {
- const { id, attribute, instance } = item;
- condition.push({
- id,
- attributes: attribute ? attribute.filter(item => item.values.length > 0) : [],
- instances: instance ? instance.filter(item => item.path.length > 0) : []
- });
- });
- this.previewResourceParams = {
- policy_id: this.tableList[this.curIndex].policy_id,
- resource_group_id: id,
- related_resource_type: {
- system_id,
- type,
- name,
- condition: condition.filter(item => item.attributes.length > 0 || item.instances.length > 0)
- }
- };
- this.previewDialogTitle = this.$t(`m.info['操作侧边栏操作的资源实例差异对比']`, { value: `${this.$t(`m.common['【']`)}${this.tableList[this.curIndex].name}${this.$t(`m.common['】']`)}` });
- this.isShowPreviewDialog = true;
- },
-
+
handlerConditionMouseover (payload) {
if (Object.keys(this.curCopyParams).length < 1 && this.curCopyMode === 'normal') {
return;
diff --git a/frontend/src/views/group/components/preview-resource-dialog.vue b/frontend/src/views/group/components/preview-resource-dialog.vue
index 2fa458de2..cdb5719e1 100644
--- a/frontend/src/views/group/components/preview-resource-dialog.vue
+++ b/frontend/src/views/group/components/preview-resource-dialog.vue
@@ -70,22 +70,27 @@
methods: {
async fetchData () {
// debugger
- this.isLoading = true;
const isTemplate = this.params.isTemplate;
const method = isTemplate ? 'groupTemplateCompare' : 'groupPolicyCompare';
+ const { groupId, related_resource_type, resource_group_id: resourceGroupId } = this.params;
const requestParams = {
- id: this.params.groupId,
+ id: groupId,
data: {
- related_resource_type: this.params.related_resource_type,
- resource_group_id: this.params.resource_group_id
+ related_resource_type,
+ resource_group_id: resourceGroupId
}
};
+ // 无实例和属性条件不需要调用接口
+ if (!related_resource_type.condition.length || !resourceGroupId) {
+ return;
+ }
if (!isTemplate) {
requestParams.data.policy_id = this.params.policy_id;
} else {
requestParams.templateId = this.params.id;
requestParams.data.action_id = this.params.action_id;
}
+ this.isLoading = true;
try {
const res = await this.$store.dispatch(`userGroup/${method}`, requestParams);
this.conditionData = res.data.map(item => new CompareCondition(item));
diff --git a/frontend/src/views/group/components/render-instance-table.vue b/frontend/src/views/group/components/render-instance-table.vue
index 5aa523995..1ec69998a 100644
--- a/frontend/src/views/group/components/render-instance-table.vue
+++ b/frontend/src/views/group/components/render-instance-table.vue
@@ -513,10 +513,12 @@
return curData.selectionMode;
},
isShowPreview () {
- if (this.curIndex === -1) {
+ if (this.curIndex === -1 || this.curGroupIndex === -1) {
return false;
}
- return this.tableList[this.curIndex].policy_id !== '';
+ // 预览模板需要groupId和resourceGroupId
+ const { policy_id: policyId, resource_groups: resourceGroups } = this.tableList[this.curIndex];
+ return policyId !== '' && resourceGroups[this.curGroupIndex].id && this.groupId;
},
isShowView () {
return (payload) => {
diff --git a/frontend/src/views/manage-spaces/components/render-instance-table.vue b/frontend/src/views/manage-spaces/components/render-instance-table.vue
index e9b4a1a1f..6dea95740 100644
--- a/frontend/src/views/manage-spaces/components/render-instance-table.vue
+++ b/frontend/src/views/manage-spaces/components/render-instance-table.vue
@@ -169,7 +169,6 @@
{{ $t(`m.common['保存']`) }}
- {{ $t(`m.common['预览']`) }}
{{ $t(`m.common['取消']`) }}
@@ -341,12 +340,6 @@
.related_resource_types[this.curResIndex];
return curData.selectionMode;
},
- isShowPreview () {
- if (this.curIndex === -1) {
- return false;
- }
- return this.tableList[this.curIndex].policy_id !== '';
- },
// 处理无限制和聚合后多个tab数据结构不兼容情况
formatDisplayValue () {
return (payload) => {
@@ -716,40 +709,6 @@
this.curGroupIndex = -1;
},
- handlerResourcePreview () {
- const { id } = this.tableList[this.curIndex].resource_groups[this.curGroupIndex];
- const { system_id, type, name } = this.tableList[this.curIndex].resource_groups[this.curGroupIndex]
- .related_resource_types[this.curResIndex];
- const condition = [];
- const conditionData = this.$refs.renderResourceRef.handleGetPreviewValue();
- conditionData.forEach(item => {
- const { id, attribute, instance } = item;
- condition.push({
- id,
- attributes: attribute ? attribute.filter(item => item.values.length > 0) : [],
- instances: instance ? instance.filter(item => item.path.length > 0) : []
- });
- });
- this.previewResourceParams = {
- id: this.templateId,
- policy_id: this.tableList[this.curIndex].policy_id,
- resource_group_id: id,
- related_resource_type: {
- system_id,
- type,
- name,
- condition: condition.filter(item => item.attributes.length > 0 || item.instances.length > 0)
- },
- action_id: this.tableList[this.curIndex].id,
- reverse: true,
- groupId: this.groupId,
- isTemplate: this.tableList[this.curIndex].isTemplate,
- isNotLimit: conditionData.length === 0
- };
- this.previewDialogTitle = this.$t(`m.info['操作侧边栏操作的资源实例差异对比']`, { value: `${this.$t(`m.common['【']`)}${this.tableList[this.curIndex].name}${this.$t(`m.common['】']`)}` });
- this.isShowPreviewDialog = true;
- },
-
handlerConditionMouseover (payload) {
if (Object.keys(this.curCopyParams).length < 1 && this.curCopyMode === 'normal') {
return;
diff --git a/frontend/src/views/manage-spaces/secondary-manage-space/components/render-instance-table.vue b/frontend/src/views/manage-spaces/secondary-manage-space/components/render-instance-table.vue
index 662395ac8..f572eed1e 100644
--- a/frontend/src/views/manage-spaces/secondary-manage-space/components/render-instance-table.vue
+++ b/frontend/src/views/manage-spaces/secondary-manage-space/components/render-instance-table.vue
@@ -207,7 +207,6 @@
data-test-id="group_btn_resourceInstanceSubmit">
{{ $t(`m.common['保存']`) }}
- {{ $t(`m.common['预览']`) }}
{{ $t(`m.common['取消']`) }}
@@ -457,12 +456,6 @@
.related_resource_types[this.curResIndex];
return curData.selectionMode;
},
- isShowPreview () {
- if (this.curIndex === -1) {
- return false;
- }
- return this.tableList[this.curIndex].policy_id !== '';
- },
isShowView () {
return (payload) => {
return !payload.isEmpty;
@@ -1221,40 +1214,6 @@
// this.$emit('handleAggregateAction', false)
// }
},
- handleResourcePreview () {
- // debugger
- window.changeDialog = true;
- // eslint-disable-next-line max-len
- const { system_id, type, name } = this.tableList[this.curIndex].resource_groups[this.curGroupIndex].related_resource_types[this.curResIndex];
- const condition = [];
- const conditionData = this.$refs.renderResourceRef.handleGetPreviewValue();
- conditionData.forEach(item => {
- const { id, attribute, instance } = item;
- condition.push({
- id,
- attributes: attribute ? attribute.filter(item => item.values.length > 0) : [],
- instances: instance ? instance.filter(item => item.path.length > 0) : []
- });
- });
- this.previewResourceParams = {
- id: this.templateId,
- action_id: this.tableList[this.curIndex].id,
- related_resource_type: {
- system_id,
- type,
- name,
- condition: condition.filter(item => item.attributes.length > 0 || item.instances.length > 0)
- },
- reverse: true,
- groupId: this.groupId,
- policy_id: this.tableList[this.curIndex].policy_id,
- resource_group_id: this.tableList[this.curIndex].resource_groups[this.curGroupIndex].id,
- isTemplate: this.tableList[this.curIndex].isTemplate,
- isNotLimit: conditionData.length === 0
- };
- this.previewDialogTitle = this.$t(`m.info['操作侧边栏操作的资源实例差异对比']`, { value: `${this.$t(`m.common['【']`)}${this.tableList[this.curIndex].name}${this.$t(`m.common['】']`)}` });
- this.isShowPreviewDialog = true;
- },
handlerConditionMouseover (payload) {
if (Object.keys(this.curCopyParams).length < 1 && this.curCopyMode === 'normal') {
return;