Skip to content

Commit

Permalink
merge: 支持脚本内容搜索?内容搜索更常用 TencentBlueKing#1337
Browse files Browse the repository at this point in the history
  • Loading branch information
hLinx committed Nov 29, 2022
2 parents 4379d38 + 1c79dc6 commit 12ed901
Show file tree
Hide file tree
Showing 10 changed files with 481 additions and 32 deletions.
8 changes: 4 additions & 4 deletions src/frontend/src/layout-new.vue
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@
}, {
immediate: true,
});

/**
* @desc 获取是否是admin用户
*/
Expand All @@ -340,7 +340,7 @@
.then((data) => {
isEnableFeatureFileManage.value = data.ENABLE_FEATURE_FILE_MANAGE;
});

/**
* @desc 侧导航展开收起
*/
Expand All @@ -363,13 +363,13 @@
if (routerName === localtionRouterName) {
return;
}

routerName = localtionRouterName;
router.push({
name: routerName,
});
};

</script>
<style lang="postcss">
#app {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
type="new-dark" />
</div>
</jb-form-item>
<jb-form-item :label="$t('script.版本日志')">
<jb-form-item :label="$t('script.版本日志.label')">
<bk-input
v-model="formData.versionDesc"
:maxlength="100"
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/views/script-manage/common/detail/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@
class="content-tab-item"
:class="{ active: contentTab === 'content' }"
@click="handleChangeDispaly('content')">
{{ $t('script.脚本内容') }}
{{ $t('script.脚本内容.label') }}
</div>
<div
v-test="{ type: 'button', value: 'scriptVersionLogTab' }"
class="content-tab-item"
:class="{ active: contentTab === 'log' }"
@click="handleChangeDispaly('log')">
{{ $t('script.版本日志') }}
{{ $t('script.版本日志.label') }}
</div>
</div>
<div class="version-content">
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/views/script-manage/common/edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
readonly
:value="formData.version" />
</jb-form-item>
<jb-form-item :label="$t('script.版本日志')">
<jb-form-item :label="$t('script.版本日志.label')">
<bk-input
v-model="formData.versionDesc"
:maxlength="100"
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/views/script-manage/create/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
:placeholder="$t('script.输入版本号')" />
</jb-form-item>
<jb-form-item
:label="$t('script.脚本内容')"
:label="$t('script.脚本内容.label')"
property="content"
required>
<div ref="content">
Expand Down
7 changes: 6 additions & 1 deletion src/frontend/src/views/script-manage/list/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,11 @@
remoteMethod: PublicScriptService.scriptTypeList,
remoteExecuteImmediate: true,
},
{
name: I18n.t('script.脚本内容.colHead'),
id: 'content',
default: true,
},
{
name: I18n.t('script.场景标签.colHead'),
id: 'tags',
Expand Down Expand Up @@ -453,7 +458,7 @@
{ id: 'lastModifyTime' },
]);
}

this.rules = {
name: [
{
Expand Down
12 changes: 9 additions & 3 deletions src/frontend/src/views/script-manage/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@ export default {
版本状态: 'Status',
名称: 'NAME',
输入版本号: 'Type the version number...',
版本日志: 'ChangeLog',
脚本内容: 'Contents',
版本日志: {
label: 'ChangeLog',
colHead: 'CHANGE LOG',
},
脚本内容: {
label: 'Contents',
colHead: 'CONTENT',
},
提交: 'Commit',
取消: 'Cancel',
立即同步: 'Synchronize Now',
Expand Down Expand Up @@ -88,7 +94,7 @@ export default {
版本管理: 'Versions',
上传文件: 'Upload',
版本对比: 'Diff',
'直接输入 版本号 或 更新人 进行全局模糊搜索': 'Search by Version No. or Modified By...',
选择匹配的字段并输入关键字进行搜索: 'Select matching fields and enter keywords to search',
更新时间: 'LAST MODIFIED ON',
状态: 'STATUS',
'确定上线该版本?': 'Are you sure ?',
Expand Down
31 changes: 23 additions & 8 deletions src/frontend/src/views/script-manage/version/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<template #right>
<jb-search-select
:data="searchSelect"
:placeholder="$t('script.直接输入 版本号 或 更新人 进行全局模糊搜索')"
:placeholder="$t('script.选择匹配的字段并输入关键字进行搜索')"
:show-condition="false"
style="width: 420px;"
@on-change="handleSearch" />
Expand Down Expand Up @@ -341,6 +341,7 @@
</template>
<script>
import Tippy from 'bk-magic-vue/lib/utils/tippy';
import { Base64 } from 'js-base64';
import _ from 'lodash';

import NotifyService from '@service/notify';
Expand Down Expand Up @@ -526,13 +527,23 @@
this.scriptId = this.$route.params.id;

this.fetchData(true);

this.searchSelect = [
{
name: I18n.t('script.版本号.colHead'),
id: 'version',
default: true,
},
{
name: I18n.t('script.脚本内容.colHead'),
id: 'content',
default: true,
},
{
name: I18n.t('script.版本日志.colHead'),
id: 'versionDesc',
default: true,
},
{
name: I18n.t('script.更新人.colHead'),
id: 'lastModifyUser',
Expand Down Expand Up @@ -638,7 +649,7 @@
const windowHeight = window.innerHeight;
this.tableHeight = windowHeight - top - 20;
},

rowClassName ({ row }) {
return row.scriptVersionId === this.selectVersionId ? 'active' : '';
},
Expand Down Expand Up @@ -692,12 +703,16 @@
* @param {Object} payload 搜索字段
*/
handleSearch (payload) {
let list = this.dataMemo;
let scriptVersionList = this.dataMemo;
Object.keys(payload).forEach((key) => {
const reg = new RegExp(encodeRegexp(payload[key]));
list = list.filter(item => reg.test(item[key]));

scriptVersionList = scriptVersionList.filter((scriptVersionData) => {
const value = key === 'content' ? Base64.decode(scriptVersionData.content) : scriptVersionData[key];
return reg.test(value);
});
});
this.data = Object.freeze(list);
this.data = Object.freeze(scriptVersionList);
this.handleLayoutFlod();
},
/**
Expand Down Expand Up @@ -837,7 +852,7 @@
*/
handleSync (row) {
const routerName = this.isPublicScript ? 'scriptPublicSync' : 'scriptSync';

this.$router.push({
name: routerName,
params: {
Expand Down Expand Up @@ -978,7 +993,7 @@
handleEditCancel () {
this.displayCom = 'detail';
},

/**
* @desc 判断是否可以选中
* @param {Object} row 脚本数据
Expand Down
Loading

0 comments on commit 12ed901

Please sign in to comment.