Skip to content

Commit

Permalink
支持脚本内容搜索?内容搜索更常用 TencentBlueKing#1337
Browse files Browse the repository at this point in the history
  • Loading branch information
hLinx committed Nov 29, 2022
1 parent 8154aff commit 1c79dc6
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<Icon type="new-dark" svg class="new-flag" />
</div>
</jb-form-item>
<jb-form-item :label="$t('script.版本日志')">
<jb-form-item :label="$t('script.版本日志.label')">
<bk-input
v-model="formData.versionDesc"
type="textarea"
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 @@ -50,14 +50,14 @@
:class="{ active: contentTab === 'content' }"
@click="handleChangeDispaly('content')"
v-test="{ type: 'button', value: 'scriptContentTab' }">
{{ $t('script.脚本内容') }}
{{ $t('script.脚本内容.label') }}
</div>
<div
class="content-tab-item"
:class="{ active: contentTab === 'log' }"
@click="handleChangeDispaly('log')"
v-test="{ type: 'button', value: 'scriptVersionLogTab' }">
{{ $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 @@ -58,7 +58,7 @@
required>
<bk-input :value="formData.version" readonly />
</jb-form-item>
<jb-form-item :label="$t('script.版本日志')">
<jb-form-item :label="$t('script.版本日志.label')">
<bk-input
v-model="formData.versionDesc"
type="textarea"
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 @@ -61,7 +61,7 @@
:placeholder="$t('script.输入版本号')"
:maxlength="30" />
</jb-form-item>
<jb-form-item :label="$t('script.脚本内容')" required property="content">
<jb-form-item :label="$t('script.脚本内容.label')" required property="content">
<div ref="content">
<ace-editor
v-model="formData.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 @@ -366,6 +366,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 @@ -446,7 +451,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 @@ -44,7 +44,7 @@
<jb-search-select
@on-change="handleSearch"
:data="searchSelect"
:placeholder="$t('script.直接输入 版本号 或 更新人 进行全局模糊搜索')"
:placeholder="$t('script.选择匹配的字段并输入关键字进行搜索')"
:show-condition="false"
style="width: 420px;" />
</template>
Expand Down Expand Up @@ -360,6 +360,7 @@
import ScriptBasic from './components/script-basic';
import Diff from '../common/diff';
import NewVersion from './components/new-version';
import { Base64 } from 'js-base64';

const TABLE_COLUMN_CACHE = 'script_version_list_columns';

Expand Down Expand Up @@ -513,13 +514,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 @@ -625,7 +636,7 @@
const windowHeight = window.innerHeight;
this.tableHeight = windowHeight - top - 20;
},

rowClassName ({ row }) {
return row.scriptVersionId === this.selectVersionId ? 'active' : '';
},
Expand Down Expand Up @@ -679,12 +690,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 @@ -824,7 +839,7 @@
*/
handleSync (row) {
const routerName = this.isPublicScript ? 'scriptPublicSync' : 'scriptSync';

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

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

0 comments on commit 1c79dc6

Please sign in to comment.