fix(ui): create ad plugin params

This commit is contained in:
songlh 2024-08-26 15:08:19 +08:00
parent 9729725c6a
commit d18c1fba6e
3 changed files with 15 additions and 17 deletions

View File

@ -51,7 +51,7 @@
@pushCITypeList="pushCITypeList" @pushCITypeList="pushCITypeList"
@addPlugin="openEditDrawer(null, 'add', 'plugin')" @addPlugin="openEditDrawer(null, 'add', 'plugin')"
/> />
<EditDrawer ref="editDrawer" :is_inner="false" @updateNotInner="updateNotInner" /> <EditDrawer ref="editDrawer" :isDiscoveryPage="false" @updateNotInner="updateNotInner" />
</div> </div>
</template> </template>

View File

@ -22,11 +22,11 @@
<a-form-model-item :label="$t('name')" prop="name"> <a-form-model-item :label="$t('name')" prop="name">
<a-input v-model="form.name" /> <a-input v-model="form.name" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item :label="$t('icon')" v-if="is_inner"> <a-form-model-item :label="$t('icon')">
<CustomIconSelect v-model="customIcon" :style="{ marginTop: '6px' }" /> <CustomIconSelect v-model="customIcon" :style="{ marginTop: '6px' }" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item :label="$t('cmdb.ad.mode')" prop="is_plugin"> <a-form-model-item :label="$t('cmdb.ad.mode')" prop="is_plugin">
<a-radio-group v-model="form.is_plugin" @change="changeIsPlugin" :disabled="!is_inner"> <a-radio-group v-model="form.is_plugin" @change="changeIsPlugin" :disabled="true">
<a-radio :value="false">{{ $t('cmdb.custom_dashboard.default') }}</a-radio> <a-radio :value="false">{{ $t('cmdb.custom_dashboard.default') }}</a-radio>
<a-radio :value="true">plugin</a-radio> <a-radio :value="true">plugin</a-radio>
</a-radio-group> </a-radio-group>
@ -137,9 +137,9 @@ export default {
AgentTable AgentTable
}, },
props: { props: {
is_inner: { isDiscoveryPage: {
type: Boolean, type: Boolean,
default: true, default: false,
}, },
}, },
data() { data() {
@ -152,7 +152,7 @@ export default {
ruleData: {}, ruleData: {},
type: 'add', type: 'add',
adType: '', adType: '',
form: { name: '', is_plugin: false }, form: { name: '', is_plugin: true },
rules: {}, rules: {},
customIcon: { name: '', color: '' }, customIcon: { name: '', color: '' },
tableData: [], tableData: [],
@ -195,11 +195,9 @@ export default {
this.type = type this.type = type
this.ruleData = data this.ruleData = data
this.adType = adType this.adType = adType
if (!this.is_inner) { this.form = {
this.form = { name: '',
name: '', is_plugin: true,
is_plugin: true,
}
} }
if (adType === DISCOVERY_CATEGORY_TYPE.HTTP || adType === DISCOVERY_CATEGORY_TYPE.SNMP) { if (adType === DISCOVERY_CATEGORY_TYPE.HTTP || adType === DISCOVERY_CATEGORY_TYPE.SNMP) {
return return
@ -225,7 +223,7 @@ export default {
// eslint-disable-next-line no-useless-escape // eslint-disable-next-line no-useless-escape
this.plugin_script = this.default_plugin_script this.plugin_script = this.default_plugin_script
} }
if (data?.is_plugin || !this.is_inner) { if (this.form?.is_plugin) {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.codemirror.initCodeMirror(this.plugin_script) this.$refs.codemirror.initCodeMirror(this.plugin_script)
}) })
@ -281,7 +279,7 @@ export default {
const params = { const params = {
...this.form, ...this.form,
type, type,
is_inner: this.is_inner, is_inner: !this.form.is_plugin,
option: { icon: this.customIcon }, option: { icon: this.customIcon },
attributes: this.form.is_plugin attributes: this.form.is_plugin
? undefined ? undefined
@ -301,14 +299,14 @@ export default {
this.type = 'edit' this.type = 'edit'
this.ruleData = res this.ruleData = res
this.$message.success(this.$t('updateSuccess')) this.$message.success(this.$t('updateSuccess'))
if (this.is_inner) { if (this.isDiscoveryPage) {
this.getDiscovery() this.getDiscovery()
} }
return return
} }
this.handleClose() this.handleClose()
console.log(this.is_inner)
if (this.is_inner) { if (this.isDiscoveryPage) {
this.$message.success(this.$t('saveSuccess')) this.$message.success(this.$t('saveSuccess'))
this.getDiscovery() this.getDiscovery()
} else { } else {

View File

@ -78,7 +78,7 @@
<p class="setting-discovery-empty-text">{{ $t('noData') }}</p> <p class="setting-discovery-empty-text">{{ $t('noData') }}</p>
</div> </div>
</div> </div>
<EditDrawer ref="editDrawer" /> <EditDrawer ref="editDrawer" :isDiscoveryPage="true" />
<AccountConfig ref="accountConfig"/> <AccountConfig ref="accountConfig"/>
</div> </div>
</template> </template>