Merge branch 'fix-0609-xwk' into msb_prod

merge-requests/1/head
向文可 2 years ago
commit 3118cd5c6a

@ -6,6 +6,19 @@ export const search = (params) => {
params,
});
};
export const searchFree = () => {
return request({
url: '/uc/permission/NotDistribution',
method: 'get',
});
};
export const assign = (params) => {
return request({
url: '/uc/permission/menu',
method: 'put',
params,
});
};
export const create = (data) => {
return request({
url: '/uc/permission',

@ -226,8 +226,21 @@
console.error('可拖拽表格ID不存在');
}
};
// sortablejs
onMounted(handleInit);
if (props.sortable) {
// sortablejs
onMounted(handleInit);
} else {
watch(
() => props.sortable,
(value, old) => {
if (!old && value) {
handleInit();
} else if (old && !value) {
sortable.value.destroy();
}
}
);
}
//
const handleProxy = (fnName, args) => {
return unref(refsTable)[fnName]?.apply(unref(refsTable), args);

@ -165,6 +165,15 @@ const actions = {
ElMessage.error((data.isEnable ? '启用' : '禁用') + '失败');
}
},
sort: async ({ dispatch }, data) => {
let res = await api.sort(data);
if (res) {
ElMessage.success('排序成功');
dispatch('search');
} else {
ElMessage.error('排序失败');
}
},
};
export default {
state,

@ -7,6 +7,16 @@ const state = () => ({
total: 0,
opts: {
init: false,
type: [
{
label: '需要分配',
value: 1,
},
{
label: '登录即有',
value: 2,
},
],
},
});
const getters = {};
@ -38,6 +48,13 @@ const actions = {
}
return res;
},
assign: async (context, data) => {
let res = await api.assign(data);
if (!res) {
ElMessage.error('分配失败');
}
return res;
},
save: async ({ dispatch }, data) => {
if (!data.parentId) {
data.parentId = 0;

@ -1,3 +1,4 @@
import * as featureAPI from '@/api/permission/feature.js';
import * as api from '@/api/permission/menu.js';
import * as systemAPI from '@/api/permission/system.js';
import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
@ -9,6 +10,7 @@ const state = () => ({
opts: {
init: false,
system: [],
free: [],
type: [
{
label: '目录',
@ -64,6 +66,7 @@ const actions = {
...state.opts,
init: true,
system: await systemAPI.search(),
free: await featureAPI.searchFree(),
});
},
detail: async (context, id) => {

@ -7,22 +7,31 @@
:data="list"
:operation="['create', 'search', 'remove']"
:reset="handleReset"
:sortable="!!(state.condition.platform && state.condition.location)"
title="广告"
:total="total"
@create="handleCreate"
@remove="handleRemove"
@row-sort="handleSort"
@search="handleSearch"
>
<template #operation>
<el-tag style="margin-left: 20px">选择广告平台和广告位置后可以对广告进行拖动排序</el-tag>
</template>
<template #search>
<el-form inline>
<el-form-item label="广告名称" prop="name">
<el-input v-model="state.condition.name" />
<el-form-item label="广告平台" prop="platform">
<el-select v-model="state.condition.platform" :opts="opts.platform" />
</el-form-item>
<el-form-item label="广告位置" prop="location">
<el-select v-model="state.condition.location" :opts="opts.location" />
<el-select
v-model="state.condition.location"
:config="{ disabled: (item, index) => state.condition.platform === 2 && index !== 0 }"
:opts="opts.location"
/>
</el-form-item>
<el-form-item label="广告平台" prop="platform">
<el-select v-model="state.condition.platform" :opts="opts.platform" />
<el-form-item label="广告名称" prop="name">
<el-input v-model="state.condition.name" />
</el-form-item>
<el-form-item label="是否启用" prop="isEnable">
<el-select v-model="state.condition.isEnable" :opts="opts.status" />
@ -87,6 +96,19 @@
loading.value = false;
};
onActivated(handleSearch);
watch(
[() => state.condition.platform, () => state.condition.location],
(value) => {
if (value[0] && value[1]) {
if (value[0] === 2) {
state.condition.location = 1;
store.commit('advertise/setCondition', _.cloneDeep(state.condition));
}
handleSearch();
}
},
{ immediate: true, deep: true }
);
const handleCreate = () => {
router.push({ name: 'CreateAdvertise' });
};
@ -104,6 +126,17 @@
await store.dispatch('advertise/enable', row);
loading.value = false;
};
const handleSort = async (newIndex, oldIndex) => {
loading.value = true;
await store.dispatch('advertise/sort', {
id: unref(list)[newIndex].id,
platform: state.condition.platform,
location: state.condition.location,
oldSort: unref(list)[newIndex].sort,
newSort: unref(list)[oldIndex].sort,
});
loading.value = false;
};
const config = reactive({
//
columns: [
@ -188,11 +221,4 @@
});
</script>
<style lang="less" scoped>
.col {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
}
</style>
<style lang="less" scoped></style>

@ -35,7 +35,7 @@
value: 'id',
children: 'menuChild',
}"
@current-change="(data) => (state.condition2.menuId = data.id)"
@node-click="(data) => handleCreateMenu(data)"
>
<template #default="{ data }">
<div class="flex">
@ -46,9 +46,6 @@
<el-button type="text" @click.stop="handleCreateMenu(null, data)">
<el-icon name="Plus" />
</el-button>
<el-button type="text" @click.stop="handleCreateMenu(data)">
<el-icon name="Edit" />
</el-button>
<el-button type="text" @click.stop="handleDeleteMenu([data])">
<el-icon name="Delete" />
</el-button>
@ -58,12 +55,12 @@
</el-tree>
</el-scrollbar>
</el-card>
<el-card class="feature">
<el-card v-show="state.condition2.menuId" class="feature">
<template #header>
<div class="card-header">
<div class="title">功能</div>
<div class="action">
<el-button type="text" @click="handleCreateFeature()"></el-button>
<el-button type="text" @click="handlePickFeature()"></el-button>
</div>
</div>
</template>
@ -78,6 +75,7 @@
label: 'name',
value: 'id',
}"
@node-click="(data) => handleCreateFeature(data)"
>
<template #default="{ data }">
<div class="flex">
@ -85,12 +83,9 @@
{{ data.name }}
</div>
<div class="btns">
<el-button type="text" @click.stop="handleCreateFeature(data)">
<el-icon name="Edit" />
</el-button>
<el-button type="text" @click.stop="handleDeleteFeature([data])">
<!-- <el-button type="text" @click.stop="handleDeleteFeature([data])">
<el-icon name="Delete" />
</el-button>
</el-button> -->
</div>
</div>
</template>
@ -137,10 +132,10 @@
<el-radio-group v-model="menuState.form.type" :opts="opts.type" />
</el-form-item>
<el-form-item label="菜单名称" prop="title">
<el-input v-model="menuState.form.title" />
<el-input v-model="menuState.form.title" maxlength="6" />
</el-form-item>
<el-form-item label="权限标识" prop="permission">
<el-input v-model="menuState.form.permission" />
<el-input v-model="menuState.form.permission" maxlength="20" />
</el-form-item>
<el-form-item label="路由路径" prop="path">
<el-input v-model="menuState.form.path" />
@ -201,23 +196,52 @@
/>
</el-form-item>
<el-form-item label="功能名称" prop="name">
<el-input v-model="featureState.form.name" />
<el-input v-model="featureState.form.name" maxlength="20" />
</el-form-item>
<el-form-item label="服务名称" prop="service">
<el-input v-model="featureState.form.service" />
</el-form-item>
<el-form-item label="请求方式" prop="method">
<el-select v-model="featureState.form.method" :opts="opts.method" />
</el-form-item>
<el-form-item label="接口路径" prop="uri">
<el-input v-model="featureState.form.uri" />
<el-input v-model="featureState.form.uri" :rows="3" type="textarea" />
</el-form-item>
<el-form-item label="是否启用" prop="isEnable">
<el-switch v-model="featureState.form.isEnable" />
</el-form-item>
<el-form-item label="权限类型" prop="type">
<el-radio-group v-model="featureState.form.type" :opts="opts2.type" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSaveFeature"></el-button>
</el-form-item>
</el-form>
</el-scrollbar>
</el-card>
<el-dialog v-model="featureState.pickVisible" title="选择功能权限">
<el-form
ref="refsPickForm"
v-loading="featureState.submitting"
label-width="100px"
:model="featureState.pick"
:rules="featureState.pickRules"
>
<el-form-item label="功能菜单" prop="permissionId">
<el-select
v-model="featureState.pick.permissionId"
:config="{ label: 'name', value: 'id' }"
:opts="opts.free"
/>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="handleCancelPick"></el-button>
<el-button :loading="featureState.submitting" type="primary" @click="handleSavePick">
保存
</el-button>
</template>
</el-dialog>
</div>
</div>
</template>
@ -227,6 +251,7 @@
const store = useStore();
const { proxy } = getCurrentInstance();
const opts = computed(() => store.state.menu.opts);
const opts2 = computed(() => store.state.feature.opts);
if (!unref(opts).init) {
store.dispatch('menu/load');
}
@ -243,6 +268,15 @@
await store.dispatch('menu/search');
loading.value = false;
};
watch(
() => unref(opts).system,
(value) => {
state.condition.systemId = value?.[0]?.id;
},
{
deep: true,
}
);
watch(
() => state.condition,
(value) => {
@ -297,7 +331,11 @@
},
});
const handleCreateMenu = (row, parent) => {
if (row) {
state.condition2.menuId = row.id;
}
menuState.formVisible = true;
featureState.formVisible = false;
Object.assign(
menuState.form,
row || {
@ -341,6 +379,7 @@
/* 功能表单 */
const refsFeatureForm = ref(null);
const refsPickForm = ref(null);
const featureState = reactive({
formVisible: false,
submitting: false,
@ -349,21 +388,66 @@
systemId: null,
menuId: null,
name: null,
service: null,
method: 'GET',
uri: null,
type: 1,
isEnable: true,
},
rules: {
systemId: [{ required: true, message: '所属系统不能为空' }],
menuId: [{ required: true, message: '所属菜单不能为空' }],
name: [{ required: true, message: '功能名称不能为空' }],
service: [{ required: true, message: '服务名称不能为空' }],
method: [{ required: true, message: '请求方式不能为空' }],
uri: [{ required: true, message: '接口路径不能为空' }],
type: [{ required: true, message: '权限类型不能为空' }],
isEnable: [{ required: true, message: '是否启用不能为空' }],
},
pickVisible: false,
pick: {
permissionId: null,
menuId: null,
},
pickRules: {
permissionId: [{ required: true, message: '功能权限不能为空' }],
},
});
const handleCreateFeature = (row) => {
const handleCancelPick = () => {
featureState.pickVisible = false;
featureState.pick = {
permissionId: null,
menuId: null,
};
};
const handleSavePick = async () => {
featureState.submitting = true;
try {
await proxy.$validate(refsPickForm);
let res = await store.dispatch('feature/assign', featureState.pick);
if (res) {
handleSearchFeature();
handleCancelPick();
store.dispatch('menu/load');
}
} catch (e) {
console.info('取消保存', e);
}
featureState.submitting = false;
};
const handlePickFeature = async () => {
try {
await proxy.$confirm('是否选择尚未分配菜单的功能权限?');
featureState.formVisible = false;
featureState.pickVisible = true;
featureState.pick.menuId = state.condition2.menuId;
} catch (e) {
handleCreateFeature();
}
};
const handleCreateFeature = async (row) => {
featureState.formVisible = true;
menuState.formVisible = false;
Object.assign(
featureState.form,
row || {
@ -371,8 +455,10 @@
systemId: state.condition.systemId,
menuId: state.condition2.menuId,
name: null,
service: null,
method: 'GET',
uri: null,
type: 1,
isEnable: true,
}
);
@ -391,12 +477,12 @@
}
featureState.submitting = false;
};
const handleDeleteFeature = (data) => {
store.dispatch(
'feature/remove',
data.map((item) => item.id)
);
};
// const handleDeleteFeature = (data) => {
// store.dispatch(
// 'feature/remove',
// data.map((item) => item.id)
// );
// };
</script>
<style lang="less" scoped>

@ -90,33 +90,6 @@
endTime: null,
},
});
watch(
() => route.query.id,
(value) => {
state.condition.userId = value;
},
{ immediate: true, deep: true }
);
watch(
() => state.condition,
(value) => {
store.commit('order/setCondition', _.cloneDeep(value));
},
{ immediate: true, deep: true }
);
watch(
() => state.condition.orderStatus,
() => {
handleSearch();
},
{ deep: true }
);
watch(
() => state.condition.userId,
() => {
handleSearch();
}
);
const handleReset = () => {
state.condition = {
userId: null,
@ -154,6 +127,33 @@
await store.dispatch('order/search');
loading.value = false;
};
watch(
() => route.query.id,
(value) => {
state.condition.userId = value;
},
{ immediate: true, deep: true }
);
watch(
() => state.condition,
(value) => {
store.commit('order/setCondition', _.cloneDeep(value));
},
{ immediate: true, deep: true }
);
watch(
() => state.condition.orderStatus,
() => {
handleSearch();
},
{ deep: true }
);
watch(
() => state.condition.userId,
() => {
handleSearch();
}
);
onActivated(() => {
if (route.query.status) {
state.condition.orderStatus = route.query.status.split(',').map((item) => +item);

@ -52,13 +52,6 @@
dateRange: [],
},
});
watch(
() => state.condition,
(value) => {
store.commit('customer/setCondition', _.cloneDeep(value));
},
{ immediate: true, deep: true }
);
const handleReset = () => {
state.condition = {
phone: null,
@ -67,14 +60,26 @@
};
};
const handleSearch = async () => {
if (route.query.phone && !state.condition.phone) {
state.condition.phone = route.query.phone;
store.commit('customer/setCondition', _.cloneDeep(state.condition));
}
loading.value = true;
await store.dispatch('customer/search');
loading.value = false;
};
watch(
() => route.query.phone,
(value) => {
state.condition.phone = value;
store.commit('customer/setCondition', _.cloneDeep(state.condition));
handleSearch();
},
{ immediate: true }
);
watch(
() => state.condition,
(value) => {
store.commit('customer/setCondition', _.cloneDeep(value));
},
{ immediate: true, deep: true }
);
onActivated(handleSearch);
const handleEnable = async (row) => {
loading.value = true;

Loading…
Cancel
Save