diff --git a/frontend/desktop/src/assets/html/index.html b/frontend/desktop/src/assets/html/index.html index 99de8b7b7d..3417f53a07 100644 --- a/frontend/desktop/src/assets/html/index.html +++ b/frontend/desktop/src/assets/html/index.html @@ -59,6 +59,7 @@ var ENABLE_TEMPLATE_MARKET = {{ENABLE_TEMPLATE_MARKET}} var TEMPLATE_MARKET_HOST = '{{TEMPLATE_MARKET_HOST}}' var TEMPLATE_MARKET_DOC_URL = '{{TEMPLATE_MARKET_DOC_URL}}' + var PERIODIC_TASK_SHORTEST_TIME = {{PERIODIC_TASK_SHORTEST_TIME}} // 是否开启通知中心 var ENABLE_NOTICE_CENTER = {{ENABLE_NOTICE_CENTER}} function getCookie(name) { diff --git a/frontend/desktop/src/components/common/Individualization/cronRuleSelect.vue b/frontend/desktop/src/components/common/Individualization/cronRuleSelect.vue index e9cdd98f86..17690b9259 100644 --- a/frontend/desktop/src/components/common/Individualization/cronRuleSelect.vue +++ b/frontend/desktop/src/components/common/Individualization/cronRuleSelect.vue @@ -16,6 +16,9 @@
+

+ {{ $t('当前环境配置周期任务间隔不低于 n 分钟,如有特殊需求请联系管理员配置', { n: shortestTime }) }} +

diff --git a/frontend/desktop/src/config/i18n/cn.js b/frontend/desktop/src/config/i18n/cn.js index 24b1009f42..fcb76bf51f 100644 --- a/frontend/desktop/src/config/i18n/cn.js +++ b/frontend/desktop/src/config/i18n/cn.js @@ -1824,7 +1824,11 @@ const cn = { '申明该场景的运维操作风险级别,以便场景使用者决策场景的使用方式': '申明该场景的运维操作风险级别,以便场景使用者决策场景的使用方式', '请输入标签,enter保存': '请输入标签,enter保存', '将清空输入信息': '将清空输入信息', - '【n】标签已存在': '【{n}】标签已存在' + '【n】标签已存在': '【{n}】标签已存在', + '场景名称重复:': '场景名称重复:', + '场景名称长度最小3个字符': '场景名称长度最小3个字符', + '请输入群 ID,多个 ID 以分号隔开': '请输入群 ID,多个 ID 以分号隔开', + '当前环境配置周期任务间隔不低于 n 分钟,如有特殊需求请联系管理员配置': '当前环境配置周期任务间隔不低于 {n} 分钟,如有特殊需求请联系管理员配置' } export default cn diff --git a/frontend/desktop/src/config/i18n/en.js b/frontend/desktop/src/config/i18n/en.js index 31713a6823..815308e924 100644 --- a/frontend/desktop/src/config/i18n/en.js +++ b/frontend/desktop/src/config/i18n/en.js @@ -1858,7 +1858,11 @@ const en = { '申明该场景的运维操作风险级别,以便场景使用者决策场景的使用方式': 'Declare the operational risk level of the scene to aid users in deciding how to use the scene', '请输入标签,enter保存': 'Please enter a tag and press Enter to save', '将清空输入信息': 'This will clear the input information', - '【n】标签已存在': 'The tag [{n}] already exists' + '【n】标签已存在': 'The tag [{n}] already exists', + '场景名称重复:': 'Duplicate scene name:', + '场景名称长度最小3个字符': 'The scene name must be at least 3 characters long', + '请输入群 ID,多个 ID 以分号隔开': 'Please enter group IDs, separated by semicolons if there are multiple IDs', + '当前环境配置周期任务间隔不低于 n 分钟,如有特殊需求请联系管理员配置': 'In the current environment, the interval for scheduled tasks is no less than {n} minutes. If you have special requirements, please contact the administrator for configuration' } export default en diff --git a/frontend/desktop/src/pages/task/PeriodicList/ModifyPeriodicDialog.vue b/frontend/desktop/src/pages/task/PeriodicList/ModifyPeriodicDialog.vue index c00339b447..5bb54a06e8 100644 --- a/frontend/desktop/src/pages/task/PeriodicList/ModifyPeriodicDialog.vue +++ b/frontend/desktop/src/pages/task/PeriodicList/ModifyPeriodicDialog.vue @@ -49,7 +49,16 @@ ref="basicConfigForm" :rules="rules" :model="formData"> - + + + + +

@@ -87,13 +96,13 @@

+ v-cursor="{ active: !hasPermission([flowPermission.view], option.auth_actions) }" + @click="onTempSelect([flowPermission.view], option)"> {{ option.name }}

@@ -265,6 +274,7 @@ name = '', is_latest = '', task_template_name = '', + template_source = 'project', template_id = '', template_scheme_ids = [] } = this.curRow @@ -273,6 +283,7 @@ formData: { name, is_latest: this.isEdit ? is_latest : true, + template_source, task_template_name, template_id, schemeId: this.isEdit && schemeId.length ? schemeId : [] @@ -366,7 +377,13 @@ return Object.keys(this.periodicConstants).length === 0 }, isCommon () { - return this.curRow.template_source === 'common' + return this.formData.template_source === 'common' + }, + flowPermission () { + return { + view: this.isCommon ? 'common_flow_view' : 'flow_view', + create: this.isCommon ? 'common_flow_create_periodic_task' : 'flow_create_periodic_task' + } }, sideSliderTitle () { return this.isEdit ? i18n.t('编辑周期任务') : i18n.t('新建周期任务') @@ -396,7 +413,10 @@ }, hasNoCreatePerm () { const { id, auth_actions } = this.templateData - return this.isEdit || !id ? false : !this.hasPermission(['flow_create_periodic_task'], auth_actions) + if (this.isEdit || !id) { + return false + } + return !auth_actions.includes(this.flowPermission.create) }, schemeSelectPlaceholder () { return this.formData.template_id && !this.schemeList.length ? i18n.t('此流程无执行方案,无需选择') : i18n.t('请选择') @@ -448,7 +468,8 @@ project__id: this.project_id, limit: 15, offset, - pipeline_template__name__icontains: this.flowName || undefined + pipeline_template__name__icontains: this.flowName || undefined, + common: this.isCommon } const templateListData = await this.loadTemplateList(params) if (add) { @@ -499,7 +520,14 @@ onClearTemplate () { this.formData.schemeId = [] this.schemeList = [] - this.constants = {} + this.periodicConstants = {} + }, + onFlowTypeChange () { + this.templateLoading = true + this.formData.template_id = '' + this.formData.name = '' + this.onClearTemplate() + this.handleTplSearch() }, async getTemplateDate (id) { // 获取模板详情 @@ -560,10 +588,9 @@ this.schemeLoading = true try { const defaultScheme = await this.loadDefaultSchemeList() - const common = this.curRow.template_source === 'common' const data = { - isCommon: common || undefined, - project_id: common ? undefined : this.project_id, + isCommon: this.isCommon || undefined, + project_id: this.isCommon ? undefined : this.project_id, template_id: this.formData.template_id } const resp = await this.loadTaskScheme(data) @@ -594,11 +621,10 @@ // 获取默认方案列表 async loadDefaultSchemeList () { try { - const common = this.curRow.template_source === 'common' const resp = await this.getDefaultTaskScheme({ - project_id: this.project_id, + project_id: this.isCommon ? undefined : this.project_id, template_id: this.formData.template_id, - template_type: common ? 'common' : undefined + template_type: this.isCommon ? 'common' : undefined }) if (resp.data.length) { const { scheme_ids: schemeIds } = resp.data[0] @@ -762,13 +788,13 @@ if (this.hasNoCreatePerm) { const { id, name, auth_actions } = this.templateData const resourceData = { - flow: [{ id, name }], + [this.isCommon ? 'common_flow' : 'flow']: [{ id, name }], project: [{ id: this.project_id, name: this.projectName }] } - this.applyForPermission(['flow_create_periodic_task'], auth_actions, resourceData) + this.applyForPermission([this.flowPermission.create], auth_actions, resourceData) return } const isCronError = this.$refs.cronRuleSelect.isError @@ -865,7 +891,8 @@ cron: cron, templateId: this.formData.template_id, schemeIds, - execData: JSON.stringify(pipelineData) + execData: JSON.stringify(pipelineData), + templateSource: this.isCommon ? 'common' : undefined } try { const response = await this.createPeriodic(data) @@ -958,6 +985,17 @@ .bk-form-content { width: 598px; } + .flow-form-item .bk-form-content { + display: flex; + .bk-select, + .select-box { + flex: 1; + } + .flow-type-select { + flex: 0 0 150px; + margin-right: 15px; + } + } .scheme-form-item { .tooltips-icon { right: 132px !important; diff --git a/frontend/desktop/src/pages/template/TemplateList/SharedTemplate/SharedTplSlider.vue b/frontend/desktop/src/pages/template/TemplateList/SharedTemplate/SharedTplSlider.vue index a05869c491..f44713a478 100644 --- a/frontend/desktop/src/pages/template/TemplateList/SharedTemplate/SharedTplSlider.vue +++ b/frontend/desktop/src/pages/template/TemplateList/SharedTemplate/SharedTplSlider.vue @@ -37,11 +37,15 @@
- + + minlength="2" + maxlength="50" + show-word-limit + v-model="formData.name" + @focus="repeatSceneInfo = {}"> - - - - +

+ {{ $t('场景名称重复:') }} + + {{ repeatSceneInfo.scene_name }} + + +

- - + @@ -154,7 +155,6 @@ id: undefined, type: 'create', name: '', - code: '', category: '', labels: [], risk_level: '', @@ -164,6 +164,15 @@ formData: tools.deepClone(formData), defaultFormData: tools.deepClone(formData), rules: { + name: [{ + required: true, + message: i18n.t('必填项'), + trigger: 'blur' + }, { + min: 3, + message: i18n.t('场景名称长度最小3个字符'), + trigger: 'blur' + }], required: [{ required: true, message: i18n.t('必填项'), @@ -176,7 +185,8 @@ categoryList: [], tagList: [], riskLevelList: [], - saveLoading: false + saveLoading: false, + repeatSceneInfo: {} } }, computed: { @@ -323,9 +333,13 @@ const existTplIds = params.templates.map(item => item.id) selectedTplIds.push(...existTplIds) } - params.template_ids = [...new Set(selectedTplIds)] + params.templates = [...new Set(selectedTplIds)] - await this.sharedTemplateRecord(params) + const resp = await this.sharedTemplateRecord(params) + if (!resp.result) { + this.repeatSceneInfo = resp.data + return + } this.showSuccessMessage() this.$emit('close') } catch (error) { @@ -422,6 +436,22 @@ border-color: #dcdee5; } } + .scene-repeat-tips { + display: flex; + align-items: center; + line-height: 16px; + margin-top: 3px; + font-size: 12px; + span { + color: #ff5656; + } + a { + color: #3a84ff; + .common-icon-jump-link { + font-size: 14px; + } + } + } .category-select::before { position: absolute; content: attr(data-placeholder); diff --git a/frontend/desktop/src/pages/template/TemplateList/SharedTemplate/markdownEditor/editor.vue b/frontend/desktop/src/pages/template/TemplateList/SharedTemplate/markdownEditor/editor.vue index c6846b0780..db56555088 100644 --- a/frontend/desktop/src/pages/template/TemplateList/SharedTemplate/markdownEditor/editor.vue +++ b/frontend/desktop/src/pages/template/TemplateList/SharedTemplate/markdownEditor/editor.vue @@ -14,10 +14,6 @@ event: 'change' }, props: { - code: { - type: String, - default: '' - }, value: { type: String, default: '' @@ -75,7 +71,6 @@ // 这里补充上传图片逻辑并将url通过cb传回 const resp = await this.getFileUploadAddr({ file_name: blob.name, - scene_code: this.code || 'flow_template', scene_type: this.sceneType }) await axios({ diff --git a/frontend/desktop/src/store/modules/templateMarket.js b/frontend/desktop/src/store/modules/templateMarket.js index 2809adcb9a..cad91c4e92 100644 --- a/frontend/desktop/src/store/modules/templateMarket.js +++ b/frontend/desktop/src/store/modules/templateMarket.js @@ -17,10 +17,10 @@ const templateMarket = { return axios.get('/template_market/api/templates_scene/get_file_upload_addr/', { params }).then(response => response.data.data) }, createLabel ({ commit }, params) { - return axios.post('/template_market/api/templates_scene/create_scene_label/', params).then(response => response.data) + return axios.post('/template_market/api/templates_scene/add_scene_label/', params).then(response => response.data) }, loadSharedTemplateRecord ({ commit }) { - return axios.get('/template_market/api/templates_scene/').then(response => response.data) + return axios.get('/template_market/api/templates_scene/get_scene_template_list/').then(response => response.data) }, sharedTemplateRecord ({ commit }, params) { const { id } = params