Merge branch 'feat-search-0611-xwk' into msb_prod

merge-requests/1/head
向文可 2 years ago
commit 9bd8879474

@ -0,0 +1,35 @@
import request from '@/utils/request.js';
export const search = (params) => {
return request({
url: '/search/admin/searchConfig',
method: 'get',
params,
});
};
export const detail = (id) => {
return request({
url: '/search/admin/searchConfig/' + id,
method: 'get',
});
};
export const create = (data) => {
return request({
url: '/search/admin/searchConfig',
method: 'post',
data,
});
};
export const update = (data) => {
return request({
url: '/search/admin/searchConfig',
method: 'put',
data,
});
};
export const remove = (id) => {
return request({
url: '/search/admin/searchConfig',
method: 'delete',
params: { id },
});
};

@ -0,0 +1,35 @@
import request from '@/utils/request.js';
export const search = (params) => {
return request({
url: '/search/admin/systemConfig',
method: 'get',
params,
});
};
export const detail = (id) => {
return request({
url: '/search/admin/systemConfig/' + id,
method: 'get',
});
};
export const create = (data) => {
return request({
url: '/search/admin/systemConfig',
method: 'post',
data,
});
};
export const update = (data) => {
return request({
url: '/search/admin/systemConfig',
method: 'put',
data,
});
};
export const remove = (id) => {
return request({
url: '/search/admin/systemConfig',
method: 'delete',
params: { id },
});
};

@ -0,0 +1,16 @@
<template>
<component :is="render" />
</template>
<script setup lang="jsx">
import { ElTooltip } from 'element-plus/es/components/tooltip/index';
import 'element-plus/es/components/tooltip/style/css';
import ElIcon from './ElIcon.vue';
const props = defineProps({});
const attrs = useAttrs();
const slots = {
default: () => <ElIcon name="information" style="position: relative;top: 2px;margin-left: 5px;" />,
...useSlots(),
};
const render = () => <ElTooltip {...props} {...attrs} v-slots={slots} />;
</script>
<style lang="less" scoped></style>

@ -34,13 +34,10 @@ const actions = {
}
return res;
},
load: async ({ commit }) => {
load: async ({ state, commit }) => {
commit('setOpts', {
...state.opts,
init: true,
visible: [
{ label: '显示', value: true },
{ label: '隐藏', value: false },
],
});
},
detail: async ({ state, dispatch }, id) => {

@ -11,7 +11,7 @@ const state = () => ({
summary: [],
opts: {
init: false,
company: [{ label: '顺丰', value: 'sf' }],
company: [],
},
});
const getters = {};
@ -31,8 +31,9 @@ const actions = {
}
return res;
},
load: async ({ commit }) => {
load: async ({ state, commit }) => {
commit('setOpts', {
...state.opts,
init: true,
company: await api.searchShip(),
});

@ -0,0 +1,82 @@
import * as api from '@/api/search/config.js';
import * as systemAPI from '@/api/search/system.js';
import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
const state = () => ({
code: 'SearchConfig',
condition: {},
list: [],
total: 0,
opts: {
init: false,
system: [],
},
});
const getters = {};
const mutations = {
setCode: (state, data) => (state.code = data),
setCondition: (state, data) => (state.condition = data),
setList: (state, data) => (state.list = data),
setTotal: (state, data) => (state.total = data),
setOpts: (state, data) => (state.opts = data),
};
const actions = {
search: async ({ state, commit, rootGetters }) => {
let data = { ...state.condition };
let res = await api.search({ ...rootGetters['local/page'](state.code), ...data });
commit('setList', res?.records || []);
commit('setTotal', res?.total || 0);
if (!res) {
ElMessage.error('查询失败');
}
return res;
},
load: async ({ state, commit }) => {
commit('setOpts', {
...state.opts,
init: true,
system: (await systemAPI.search({ pageIndex: 1, length: 99999 }))?.records || [],
});
},
detail: async (context, id) => {
let res = await api.detail(id);
if (!res) {
ElMessage.error('加载详情失败');
}
return res;
},
save: async ({ dispatch }, data) => {
let save = data.id ? api.update : api.create;
let res = await save(data);
if (res) {
ElMessage.success('保存成功');
dispatch('search');
} else {
ElMessage.error('保存失败');
}
return res;
},
remove: async ({ dispatch }, idList) => {
if (!idList.length) {
ElMessage.warning('请选择要删除的数据');
} else {
try {
await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作');
let res = await api.remove(idList.join(','));
if (res) {
ElMessage.success('删除成功');
dispatch('search');
} else {
ElMessage.error('删除失败');
}
} catch (e) {
console.info('取消删除', e);
}
}
},
};
export default {
state,
getters,
mutations,
actions,
};

@ -0,0 +1,85 @@
import * as api from '@/api/search/system.js';
import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
const state = () => ({
code: 'SearchSystem',
condition: {},
list: [],
total: 0,
opts: {
init: false,
type: [
{
label: 'MySQL',
value: 1,
},
],
},
});
const getters = {};
const mutations = {
setCode: (state, data) => (state.code = data),
setCondition: (state, data) => (state.condition = data),
setList: (state, data) => (state.list = data),
setTotal: (state, data) => (state.total = data),
setOpts: (state, data) => (state.opts = data),
};
const actions = {
search: async ({ state, commit, rootGetters }) => {
let data = { ...state.condition };
let res = await api.search({ ...rootGetters['local/page'](state.code), ...data });
commit('setList', res?.records || []);
commit('setTotal', res?.total || 0);
if (!res) {
ElMessage.error('查询失败');
}
return res;
},
load: async ({ state, commit }) => {
commit('setOpts', {
...state.opts,
init: true,
});
},
detail: async (context, id) => {
let res = await api.detail(id);
if (!res) {
ElMessage.error('加载详情失败');
}
return res;
},
save: async ({ dispatch }, data) => {
let save = data.id ? api.update : api.create;
let res = await save(data);
if (res) {
ElMessage.success('保存成功');
dispatch('search');
} else {
ElMessage.error('保存失败');
}
return res;
},
remove: async ({ dispatch }, idList) => {
if (!idList.length) {
ElMessage.warning('请选择要删除的数据');
} else {
try {
await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作');
let res = await api.remove(idList.join(','));
if (res) {
ElMessage.success('删除成功');
dispatch('search');
} else {
ElMessage.error('删除失败');
}
} catch (e) {
console.info('取消删除', e);
}
}
},
};
export default {
state,
getters,
mutations,
actions,
};

@ -7,7 +7,10 @@ const state = () => ({
total: 0,
opts: {
init: false,
gender: [],
gender: [
{ label: '男', value: 1 },
{ label: '女', value: 2 },
],
},
});
const getters = {};
@ -36,13 +39,10 @@ const actions = {
}
return res;
},
load: async ({ commit }) => {
load: async ({ state, commit }) => {
commit('setOpts', {
...state.opts,
init: true,
gender: [
{ label: '男', value: 1 },
{ label: '女', value: 2 },
],
});
},
enable: async ({ dispatch }, data) => {

@ -33,8 +33,9 @@ const actions = {
}
return res;
},
load: async ({ commit }) => {
load: async ({ state, commit }) => {
commit('setOpts', {
...state.opts,
init: true,
});
},

@ -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>

@ -0,0 +1,191 @@
<template>
<div class="list-container">
<table-list
v-loading="loading"
:code="code"
:config="config"
:data="list"
:operation="['create', 'remove']"
:reset="handleReset"
title="系统配置"
:total="total"
@create="handleCreate()"
@remove="handleRemove"
@search="handleSearch"
/>
<el-dialog v-model="formState.formVisible" :title="formState.form.id ? '编辑' : '添加' + '系统'" width="480px">
<el-form
ref="refsForm"
v-loading="formState.submitting"
label-width="120px"
:model="formState.form"
:rules="formState.rules"
>
<el-form-item label="系统编码" prop="systemCode">
<el-input v-model="formState.form.systemCode" />
</el-form-item>
<el-form-item label="系统名称" prop="systemName">
<el-input v-model="formState.form.systemName" />
</el-form-item>
<el-form-item label="数据库类型" prop="databaseType">
<el-select v-model="formState.form.databaseType" :opts="opts.type" />
</el-form-item>
<el-form-item prop="datasource">
<template #label>
<span>数据库配置</span>
<el-tooltip content="格式“ip:port”" placement="top" />
</template>
<el-input v-model="formState.form.datasource" />
</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.searchSystem.code);
const list = computed(() => store.state.searchSystem.list);
const total = computed(() => store.state.searchSystem.total);
const opts = computed(() => store.state.searchSystem.opts);
if (!unref(opts).init) {
store.dispatch('searchSystem/load');
}
const state = reactive({
condition: {},
});
watch(
() => state.condition,
(value) => {
store.commit('searchSystem/setCondition', _.cloneDeep(value));
},
{ immediate: true, deep: true }
);
const handleReset = () => {
state.condition = {};
};
const handleSearch = async () => {
loading.value = true;
await store.dispatch('searchSystem/search');
loading.value = false;
};
onActivated(handleSearch);
/* 表单 */
const refsForm = ref(null);
const formState = reactive({
formVisible: false,
submitting: false,
form: {
id: null,
databaseType: null,
datasource: null,
systemCode: null,
systemName: null,
},
rules: {
databaseType: [{ required: true, message: '数据库类型不能为空' }],
datasource: [{ required: true, message: '数据库配置不能为空' }],
systemCode: [{ required: true, message: '系统编码不能为空' }],
systemName: [{ required: true, message: '系统名称不能为空' }],
},
});
// /
const handleCreate = (row) => {
Object.assign(
formState.form,
row || {
id: null,
databaseType: null,
datasource: null,
order: null,
systemCode: null,
systemName: 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('searchSystem/save', data);
if (res) {
formState.formVisible = false;
}
} catch (e) {
console.info('取消保存', e);
}
formState.submitting = false;
};
const handleRemove = async (rows) => {
store.dispatch(
'searchSystem/remove',
rows.map((item) => item.id)
);
};
const config = reactive({
columns: [
{
type: 'selection',
width: 60,
},
{
label: '系统编码',
prop: 'systemCode',
},
{
label: '系统名称',
prop: 'systemName',
},
{
label: '数据库类型',
width: 100,
slots: {
default: ({ row }) => proxy.$dict(unref(opts).type, row.databaseType),
},
},
{
prop: 'datasource',
minWidth: 120,
slots: {
header: () => (
<p>
<span>数据库配置</span>
<ElTooltip content="格式“ip:port”" placement="top" />
</p>
),
},
},
{
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>

@ -22,11 +22,11 @@ export default (configEnv) => {
'/api': {
// target: 'http://192.168.10.109:8090/', // 显雨
// target: 'http://192.168.10.5:4500', // 高玉
// target: 'http://192.168.10.67:8090', // 罗战
// target: 'http://192.168.10.94:8090', // 周渺
// target: 'http://192.168.10.87:8090', // 罗战
// target: 'http://192.168.10.93:8090', // 周渺
// target: 'http://192.168.10.124:8090', // 舒梦娇
target: 'https://k8s-horse-gateway.mashibing.cn/', // 测试地址
// target: 'https://you-gateway.mashibing.com', // 生产环境
// target: 'https://k8s-horse-gateway.mashibing.cn/', // 测试地址
target: 'https://you-gateway.mashibing.com', // 生产环境
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},

Loading…
Cancel
Save