|
|
|
@ -0,0 +1,296 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="list-container">
|
|
|
|
|
<table-list
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
:code="code"
|
|
|
|
|
:config="config"
|
|
|
|
|
:data="list"
|
|
|
|
|
:operation="['create', 'search', 'remove']"
|
|
|
|
|
:reset="handleReset"
|
|
|
|
|
title="搜索配置"
|
|
|
|
|
:total="total"
|
|
|
|
|
@create="handleCreate()"
|
|
|
|
|
@remove="handleRemove"
|
|
|
|
|
@search="handleSearch"
|
|
|
|
|
>
|
|
|
|
|
<template #search>
|
|
|
|
|
<el-form inline label-width="100px">
|
|
|
|
|
<el-form-item label="所属系统" prop="systemId">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="state.condition.systemId"
|
|
|
|
|
:config="{ label: 'systemName', value: 'id' }"
|
|
|
|
|
:opts="opts.system"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</template>
|
|
|
|
|
</table-list>
|
|
|
|
|
<el-dialog v-model="formState.formVisible" :title="formState.form.id ? '编辑' : '添加' + '系统'" width="480px">
|
|
|
|
|
<el-form
|
|
|
|
|
ref="refsForm"
|
|
|
|
|
v-loading="formState.submitting"
|
|
|
|
|
label-width="100px"
|
|
|
|
|
:model="formState.form"
|
|
|
|
|
:rules="formState.rules"
|
|
|
|
|
>
|
|
|
|
|
<el-form-item label="所属系统" prop="systemId">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="formState.form.systemId"
|
|
|
|
|
:config="{ label: 'systemName', value: 'id' }"
|
|
|
|
|
:opts="opts.system"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="搜索码" prop="searchCode">
|
|
|
|
|
<el-input v-model="formState.form.searchCode" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="搜索名" prop="searchName">
|
|
|
|
|
<el-input v-model="formState.form.searchName" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item prop="searchFiled">
|
|
|
|
|
<template #label>
|
|
|
|
|
<span>搜索字段</span>
|
|
|
|
|
<el-tooltip
|
|
|
|
|
content="搜索字段配置,格式“字段名/搜索类型”,搜索类型即ES中字段的分词器类型,模糊搜索standard,拼音搜索pinyin,全词匹配搜索keyword"
|
|
|
|
|
placement="top"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
<el-input v-model="formState.form.searchFiled" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="数据库名称" prop="databaseName">
|
|
|
|
|
<el-input v-model="formState.form.databaseName" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item prop="documentIdExp">
|
|
|
|
|
<template #label>
|
|
|
|
|
<span>ES文档ID</span>
|
|
|
|
|
<el-tooltip
|
|
|
|
|
content="数据导入ES后,作为ES文档id的字段,使用占位符形式,如:${offer_id}+${offer_sub_id}(连表查询一对多时要注意是多个表的主键连接才能确定唯一性)"
|
|
|
|
|
placement="top"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
<el-input v-model="formState.form.documentIdExp" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item prop="syncCron">
|
|
|
|
|
<template #label>
|
|
|
|
|
<span>同步频率</span>
|
|
|
|
|
<el-tooltip
|
|
|
|
|
content="同步数据到ES的频率(cron表达式),示例:‘* */30 * * * ?’(每30分钟同步一次)"
|
|
|
|
|
placement="top"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
<el-input v-model="formState.form.syncCron" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="作者" prop="author">
|
|
|
|
|
<el-input v-model="formState.form.author" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<el-button @click="formState.formVisible = false">取消</el-button>
|
|
|
|
|
<el-button :loading="formState.submitting" type="primary" @click="handleSave">保存</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="jsx">
|
|
|
|
|
import ElButton from '@/components/extra/ElButton.vue';
|
|
|
|
|
import ElTooltip from '@/components/extra/ElTooltip.vue';
|
|
|
|
|
const store = useStore();
|
|
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
|
|
const loading = ref(false);
|
|
|
|
|
const code = computed(() => store.state.searchConfig.code);
|
|
|
|
|
const list = computed(() => store.state.searchConfig.list);
|
|
|
|
|
const total = computed(() => store.state.searchConfig.total);
|
|
|
|
|
const opts = computed(() => store.state.searchConfig.opts);
|
|
|
|
|
if (!unref(opts).init) {
|
|
|
|
|
store.dispatch('searchConfig/load');
|
|
|
|
|
}
|
|
|
|
|
const state = reactive({
|
|
|
|
|
condition: {
|
|
|
|
|
systemId: null,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
watch(
|
|
|
|
|
() => state.condition,
|
|
|
|
|
(value) => {
|
|
|
|
|
store.commit('searchConfig/setCondition', _.cloneDeep(value));
|
|
|
|
|
},
|
|
|
|
|
{ immediate: true, deep: true }
|
|
|
|
|
);
|
|
|
|
|
const handleReset = () => {
|
|
|
|
|
state.condition = {
|
|
|
|
|
systemId: null,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
const handleSearch = async () => {
|
|
|
|
|
loading.value = true;
|
|
|
|
|
await store.dispatch('searchConfig/search');
|
|
|
|
|
loading.value = false;
|
|
|
|
|
};
|
|
|
|
|
onActivated(handleSearch);
|
|
|
|
|
|
|
|
|
|
/* 表单 */
|
|
|
|
|
const refsForm = ref(null);
|
|
|
|
|
const formState = reactive({
|
|
|
|
|
formVisible: false,
|
|
|
|
|
submitting: false,
|
|
|
|
|
form: {
|
|
|
|
|
author: null,
|
|
|
|
|
databaseName: null,
|
|
|
|
|
documentIdExp: null,
|
|
|
|
|
id: null,
|
|
|
|
|
searchCode: null,
|
|
|
|
|
searchFiled: null,
|
|
|
|
|
searchName: null,
|
|
|
|
|
syncCron: null,
|
|
|
|
|
systemId: null,
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
author: [{ required: true, message: '作者不能为空' }],
|
|
|
|
|
databaseName: [{ required: true, message: '数据库名称不能为空' }],
|
|
|
|
|
documentIdExp: [{ required: true, message: 'ES文档ID不能为空' }],
|
|
|
|
|
searchCode: [{ required: true, message: '搜索码不能为空' }],
|
|
|
|
|
searchFiled: [{ required: true, message: '搜索字段不能为空' }],
|
|
|
|
|
searchName: [{ required: true, message: '搜索名不能为空' }],
|
|
|
|
|
syncCron: [{ required: true, message: '同步频率不能为空' }],
|
|
|
|
|
systemId: [{ required: true, message: '系统ID不能为空' }],
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
// 添加/编辑
|
|
|
|
|
const handleCreate = (row) => {
|
|
|
|
|
Object.assign(
|
|
|
|
|
formState.form,
|
|
|
|
|
row || {
|
|
|
|
|
author: null,
|
|
|
|
|
databaseName: null,
|
|
|
|
|
documentIdExp: null,
|
|
|
|
|
id: null,
|
|
|
|
|
searchCode: null,
|
|
|
|
|
searchFiled: null,
|
|
|
|
|
searchName: null,
|
|
|
|
|
syncCron: null,
|
|
|
|
|
systemId: null,
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
formState.formVisible = true;
|
|
|
|
|
};
|
|
|
|
|
// 保存
|
|
|
|
|
const handleSave = async () => {
|
|
|
|
|
formState.submitting = true;
|
|
|
|
|
try {
|
|
|
|
|
await proxy.$validate(refsForm);
|
|
|
|
|
let data = _.cloneDeep(formState.form);
|
|
|
|
|
let res = await store.dispatch('searchConfig/save', data);
|
|
|
|
|
if (res) {
|
|
|
|
|
formState.formVisible = false;
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.info('取消保存', e);
|
|
|
|
|
}
|
|
|
|
|
formState.submitting = false;
|
|
|
|
|
};
|
|
|
|
|
const handleRemove = async (rows) => {
|
|
|
|
|
store.dispatch(
|
|
|
|
|
'searchConfig/remove',
|
|
|
|
|
rows.map((item) => item.id)
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
const config = reactive({
|
|
|
|
|
columns: [
|
|
|
|
|
{
|
|
|
|
|
type: 'selection',
|
|
|
|
|
width: 60,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '所属系统',
|
|
|
|
|
prop: 'systemId',
|
|
|
|
|
minWidth: 120,
|
|
|
|
|
slots: {
|
|
|
|
|
default: ({ row }) =>
|
|
|
|
|
proxy.$dict(unref(opts).system, row.systemId, { label: 'systemName', value: 'id' }),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '搜索码',
|
|
|
|
|
prop: 'searchCode',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '搜索名',
|
|
|
|
|
prop: 'searchName',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
prop: 'searchFiled',
|
|
|
|
|
minWidth: 120,
|
|
|
|
|
slots: {
|
|
|
|
|
header: () => (
|
|
|
|
|
<p>
|
|
|
|
|
<span>搜索字段</span>
|
|
|
|
|
<ElTooltip
|
|
|
|
|
content="搜索字段配置,格式“字段名/搜索类型”,搜索类型即ES中字段的分词器类型,模糊搜索standard,拼音搜索pinyin,全词匹配搜索keyword"
|
|
|
|
|
placement="top"
|
|
|
|
|
/>
|
|
|
|
|
</p>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
label: '数据库名称',
|
|
|
|
|
prop: 'databaseName',
|
|
|
|
|
minWidth: 120,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
prop: 'documentIdExp',
|
|
|
|
|
minWidth: 120,
|
|
|
|
|
slots: {
|
|
|
|
|
header: () => (
|
|
|
|
|
<p>
|
|
|
|
|
<span>ES文档ID</span>
|
|
|
|
|
<ElTooltip
|
|
|
|
|
content="数据导入ES后,作为ES文档id的字段,使用占位符形式,如:${offer_id}+${offer_sub_id}(连表查询一对多时要注意是多个表的主键连接才能确定唯一性)"
|
|
|
|
|
placement="top"
|
|
|
|
|
/>
|
|
|
|
|
</p>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
prop: 'syncCron',
|
|
|
|
|
minWidth: 120,
|
|
|
|
|
slots: {
|
|
|
|
|
header: () => (
|
|
|
|
|
<p>
|
|
|
|
|
<span>同步频率</span>
|
|
|
|
|
<ElTooltip
|
|
|
|
|
content="同步数据到ES的频率(cron表达式),示例:‘* */30 * * * ?’(每30分钟同步一次)"
|
|
|
|
|
placement="top"
|
|
|
|
|
/>
|
|
|
|
|
</p>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '作者',
|
|
|
|
|
prop: 'author',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '操作',
|
|
|
|
|
fixed: 'right',
|
|
|
|
|
width: 120,
|
|
|
|
|
slots: {
|
|
|
|
|
default: ({ row }) => (
|
|
|
|
|
<div>
|
|
|
|
|
<ElButton type="text" onClick={() => handleCreate(row)}>
|
|
|
|
|
编辑
|
|
|
|
|
</ElButton>
|
|
|
|
|
<ElButton type="text" onClick={() => handleRemove([row])}>
|
|
|
|
|
删除
|
|
|
|
|
</ElButton>
|
|
|
|
|
</div>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped></style>
|