mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-11-09 04:03:51 +08:00
v3.14.0 更新;【新增】EasyExcel重磅升级为FastExcel;【新增】使用最强Argon2算法作为密码存储;【新增】大家吐槽的数据字典改为可重复;【新增】前端布局再增加多种样式;【优化】升级SaToken到最新版本;【优化】token使用Sa-Token的Bearer类型;【优化】优化其他
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
},
|
||||
},
|
||||
}"
|
||||
:transformCellText="transformCellText"
|
||||
>
|
||||
<!---全局loading--->
|
||||
<a-spin :spinning="spinning" tip="稍等片刻,我在拼命加载中..." size="large">
|
||||
@@ -43,13 +44,16 @@
|
||||
|
||||
<script setup>
|
||||
import dayjs from 'dayjs';
|
||||
import { computed } from 'vue';
|
||||
import { computed, h, useSlots } from 'vue';
|
||||
import { messages } from '/@/i18n';
|
||||
import { useAppConfigStore } from '/@/store/modules/system/app-config';
|
||||
import { useSpinStore } from '/@/store/modules/system/spin';
|
||||
import { theme } from 'ant-design-vue';
|
||||
import { themeColors } from '/@/theme/color.js';
|
||||
import { Popover } from 'ant-design-vue';
|
||||
import SmartCopyIcon from '/@/components/smart-copy-icon/index.vue';
|
||||
|
||||
const slots = useSlots();
|
||||
const antdLocale = computed(() => messages[useAppConfigStore().language].antdLocale);
|
||||
const dayjsLocale = computed(() => messages[useAppConfigStore().language].dayjsLocale);
|
||||
dayjs.locale(dayjsLocale);
|
||||
@@ -67,4 +71,28 @@
|
||||
const borderRadius = computed(() => {
|
||||
return useAppConfigStore().borderRadius;
|
||||
});
|
||||
function transformCellText({ text, column, record, index }) {
|
||||
if (column && column.textEllipsisFlag === true) {
|
||||
return h(
|
||||
Popover,
|
||||
{ placement: 'bottom' },
|
||||
{
|
||||
default: () =>
|
||||
h('div', { style: { whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }, id: `${column.dataIndex}${index}` }, text),
|
||||
content: () =>
|
||||
h('div', { style: { display: 'flex' } }, [
|
||||
h('div', text),
|
||||
h(SmartCopyIcon, { value: document.getElementById(`${column.dataIndex}${index}`).innerText }),
|
||||
]),
|
||||
}
|
||||
);
|
||||
} else {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="less">
|
||||
:deep(.ant-table-column-sorters) {
|
||||
align-items: flex-start !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<template>
|
||||
<div>
|
||||
<template v-for="(item, index) in options">
|
||||
<template v-if="values.includes(item.valueCode)">
|
||||
{{ item.valueName }}
|
||||
<span> </span>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
// 数据
|
||||
options: {
|
||||
type: Array,
|
||||
default: null,
|
||||
},
|
||||
// 当前的值
|
||||
value: [Number, String, Array],
|
||||
});
|
||||
const values = computed(() => {
|
||||
if (props.value === null || typeof props.value === 'undefined' || props.value === '') return [];
|
||||
return Array.isArray(props.value) ? props.value.map((item) => item.valueCode) : props.value.split(',');
|
||||
});
|
||||
</script>
|
||||
@@ -99,10 +99,20 @@
|
||||
getHtml,
|
||||
getText,
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.w-e-full-screen-container {
|
||||
z-index: 9999 !important;
|
||||
}
|
||||
</style>
|
||||
<!-- 解决弹窗高度警告信息显示 -->
|
||||
<style>
|
||||
::v-deep .w-e-text-container {
|
||||
height: 420px !important;
|
||||
}
|
||||
.w-e-text-container .w-e-scroll {
|
||||
height: 500px !important;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<template>
|
||||
<CopyOutlined
|
||||
@click="copy"
|
||||
:style="{
|
||||
color: `${color}`,
|
||||
}"
|
||||
class="icon"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { message } from 'ant-design-vue';
|
||||
const props = defineProps({
|
||||
value: {
|
||||
type: [String, Number],
|
||||
default: '',
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
default: '#1890ff',
|
||||
},
|
||||
});
|
||||
|
||||
function copy() {
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = props.value;
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(textarea);
|
||||
message.success('复制成功');
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="less">
|
||||
.icon {
|
||||
margin: 0 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,178 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<div class="table-title">
|
||||
<slot name="title">
|
||||
{{ column.title }}
|
||||
</slot>
|
||||
</div>
|
||||
<div class="filter" style="max-width: 300px; min-height: 40px">
|
||||
<slot>
|
||||
<template v-if="column.filterOptions">
|
||||
<template v-if="column.filterOptions.type === 'input'">
|
||||
<a-input-search
|
||||
@change="change('no-search')"
|
||||
v-model:value="modelValue"
|
||||
allowClear
|
||||
:placeholder="column.placeholder || column.title"
|
||||
@search="change"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.filterOptions.type === 'date-range'">
|
||||
<a-range-picker
|
||||
v-model:value="createDateRange"
|
||||
:ranges="column.filterOptions.ranges ? defaultTimeRanges : []"
|
||||
style="width: 100%"
|
||||
@change="changeCreateDate"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.filterOptions.type === 'datetime-range'">
|
||||
<a-range-picker
|
||||
show-time
|
||||
v-model:value="createDateRange"
|
||||
:ranges="column.filterOptions.ranges ? defaultTimeRanges : []"
|
||||
style="width: 100%"
|
||||
@change="changeCreateDate"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.filterOptions.type === 'month'">
|
||||
<a-range-picker v-model:value="createDateRange" picker="month" @change="changeCreateDate" />
|
||||
</template>
|
||||
<template v-else-if="column.filterOptions.type === 'submit'">
|
||||
<div class="smart-table-operate"><a-button :type="column.filterOptions.btnType" @click="submit">查询</a-button></div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<component
|
||||
v-if="componentsKey.includes(column.filterOptions.type)"
|
||||
:is="getComponent(column.filterOptions.type)"
|
||||
width="100%"
|
||||
v-model:value="modelValue"
|
||||
:multiple="column.filterOptions.multiple"
|
||||
:keyCode="column.filterOptions.keyCode"
|
||||
:enumName="column.filterOptions.enumName"
|
||||
:systemConfigKey="column.filterOptions.systemConfigKey"
|
||||
:placeholder="column.placeholder"
|
||||
:leaveFlag="column.filterOptions.leaveFlag"
|
||||
:categoryType="column.filterOptions.categoryType"
|
||||
@change="change"
|
||||
/>
|
||||
<div v-else class="error-component">未定义的组件类型</div>
|
||||
</template>
|
||||
</template>
|
||||
</slot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, useSlots, watch, onMounted, defineAsyncComponent } from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
import _ from 'lodash';
|
||||
import { defaultTimeRanges } from '/@/lib/default-time-ranges';
|
||||
const props = defineProps({
|
||||
value: {
|
||||
type: [Number, String, Array, Object],
|
||||
},
|
||||
column: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
});
|
||||
|
||||
const components = {
|
||||
'enum-select': defineAsyncComponent(() => import('/@/components/framework/smart-enum-select/index.vue')),
|
||||
'dict-select': defineAsyncComponent(() => import('/@/components/support/dict-select/index.vue')),
|
||||
'employee-select': defineAsyncComponent(() => import('/@/components/system/employee-select/index.vue')),
|
||||
'enterprise-select': defineAsyncComponent(() => import('/@/components/business/oa/enterprise-select/index.vue')),
|
||||
'boolean-select': defineAsyncComponent(() => import('/@/components/framework/boolean-select/index.vue')),
|
||||
'category-tree': defineAsyncComponent(() => import('/@/components/business/category-tree-select/index.vue')),
|
||||
};
|
||||
|
||||
const componentsKey = Object.keys(components);
|
||||
|
||||
function getComponent(key) {
|
||||
return components[key];
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
() => {
|
||||
if (props.column.filterOptions && (props.column.filterOptions.type === 'date-range' || props.column.filterOptions.type === 'datetime-range')) {
|
||||
if (!_.isEmpty(props.value) && props.value.length === 2 && !_.isEmpty(props.value[0]) && !_.isEmpty(props.value[1])) {
|
||||
createDateRange.value = [dayjs(props.value[0]), dayjs(props.value[1])];
|
||||
} else {
|
||||
createDateRange.value = [];
|
||||
}
|
||||
} else {
|
||||
modelValue.value = props.value;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const slots = useSlots();
|
||||
|
||||
const emits = defineEmits(['change', 'update:value']);
|
||||
const createDateRange = ref([]);
|
||||
const modelValue = ref(undefined);
|
||||
|
||||
function changeCreateDate(dates, dateStrings) {
|
||||
// emits('update:value',dates)
|
||||
emits('change', {
|
||||
type: props.column.filterOptions.type,
|
||||
key: props.column.filterOptions.key || props.column.dataIndex,
|
||||
value: [dateStrings[0], dateStrings[1]],
|
||||
search: true,
|
||||
});
|
||||
}
|
||||
|
||||
//是否立即查询
|
||||
function change(search) {
|
||||
let isSearch = true;
|
||||
if (search === 'no-search') {
|
||||
isSearch = false;
|
||||
}
|
||||
emits('update:value', modelValue.value);
|
||||
emits('change', {
|
||||
type: props.column.filterOptions.type,
|
||||
key: props.column.filterOptions.key || props.column.dataIndex,
|
||||
value: modelValue.value,
|
||||
search: isSearch,
|
||||
});
|
||||
}
|
||||
|
||||
function submit() {
|
||||
emits('change', {
|
||||
search: true,
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (props.column.filterOptions && (props.column.filterOptions.type === 'date-range' || props.column.filterOptions.type === 'datetime-range')) {
|
||||
if (!_.isEmpty(props.value) && props.value.length === 2 && !_.isEmpty(props.value[0]) && !_.isEmpty(props.value[1])) {
|
||||
createDateRange.value = [dayjs(props.value[0]), dayjs(props.value[1])];
|
||||
} else {
|
||||
createDateRange.value = [];
|
||||
}
|
||||
} else {
|
||||
modelValue.value = props.value;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style scoped lang="less">
|
||||
.container {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.table-title {
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.filter {
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.error-component {
|
||||
color: red;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
</style>
|
||||
@@ -16,7 +16,7 @@
|
||||
:before-upload="beforeUpload"
|
||||
:customRequest="customRequest"
|
||||
:file-list="fileList"
|
||||
:headers="{ 'x-access-token': useUserStore().getToken }"
|
||||
:headers="{ Authorization: 'Bearer ' + useUserStore().getToken }"
|
||||
:list-type="listType"
|
||||
@change="handleChange"
|
||||
@preview="handlePreview"
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<script setup>
|
||||
import _ from 'lodash';
|
||||
import { tableColumnApi } from '/@/api/support/table-column-api';
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import { onMounted, ref, watch, reactive } from 'vue';
|
||||
import SmartTableColumnModal from './smart-table-column-modal.vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { mergeColumn } from './smart-table-column-merge';
|
||||
@@ -66,17 +66,17 @@
|
||||
const emit = defineEmits(['update:modelValue']);
|
||||
|
||||
// 原始表格列数据(复制一份最原始的columns集合,以供后续各个地方使用)
|
||||
let originalColumn = _.cloneDeep(props.modelValue);
|
||||
|
||||
onMounted(() => {
|
||||
buildUserTableColumns();
|
||||
// 监听全屏事件 解决按下 ESC 退出全屏 fullScreenFlag 未改变导致下次第一下点击全屏无效的问题
|
||||
addEventListener('fullscreenchange', (event) => {
|
||||
if (document.fullscreenElement === null) {
|
||||
fullScreenFlag.value = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
let originalColumn = reactive(_.cloneDeep(props.modelValue));
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(value) => {
|
||||
originalColumn = value;
|
||||
},
|
||||
{
|
||||
deep: true,
|
||||
}
|
||||
);
|
||||
onMounted(buildUserTableColumns);
|
||||
|
||||
//构建用户的数据列
|
||||
async function buildUserTableColumns() {
|
||||
@@ -176,7 +176,8 @@
|
||||
// 将弹窗修改的列数据,赋值给原表格 列数组
|
||||
function updateColumn(changeColumnArray) {
|
||||
//合并列
|
||||
const newColumns = mergeColumn(_.cloneDeep(originalColumn), changeColumnArray);
|
||||
let obj = mergeColumn(_.cloneDeep(originalColumn), changeColumnArray);
|
||||
const newColumns = obj.newColumns;
|
||||
emit(
|
||||
'update:modelValue',
|
||||
newColumns.filter((e) => e.showFlag)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 表格列设置
|
||||
*
|
||||
* @Author: 1024创新实验室-主任:卓大
|
||||
* @Date: 2022-08-26 23:45:51
|
||||
* @Wechat: zhuda1024
|
||||
* @Email: lab1024@163.com
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||
*/
|
||||
/*
|
||||
* 表格列设置
|
||||
*
|
||||
* @Author: 1024创新实验室-主任:卓大
|
||||
* @Date: 2022-08-26 23:45:51
|
||||
* @Wechat: zhuda1024
|
||||
* @Email: lab1024@163.com
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
@@ -16,6 +16,7 @@ import _ from 'lodash';
|
||||
* @param {*} userTableColumnArray
|
||||
*/
|
||||
export function mergeColumn(originalTableColumnArray, userTableColumnArray) {
|
||||
let saveFlag = false;
|
||||
if (!userTableColumnArray) {
|
||||
return originalTableColumnArray;
|
||||
}
|
||||
@@ -40,8 +41,13 @@ export function mergeColumn(originalTableColumnArray, userTableColumnArray) {
|
||||
if (userColumn) {
|
||||
fontColumn.sort = userColumn.sort;
|
||||
fontColumn.showFlag = userColumn.showFlag;
|
||||
if (userColumn.width) {
|
||||
fontColumn.width = userColumn.width;
|
||||
if (fontColumn.dragAndDropFlag) {
|
||||
saveFlag = true;
|
||||
delete fontColumn.dragAndDropFlag;
|
||||
} else {
|
||||
if (userColumn.width) {
|
||||
fontColumn.width = userColumn.width;
|
||||
}
|
||||
}
|
||||
}
|
||||
newColumns.push(fontColumn);
|
||||
@@ -50,5 +56,8 @@ export function mergeColumn(originalTableColumnArray, userTableColumnArray) {
|
||||
|
||||
//第三步:前端列进行排序
|
||||
newColumns = _.sortBy(newColumns, (e) => e.sort);
|
||||
return newColumns;
|
||||
return {
|
||||
newColumns,
|
||||
saveFlag,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
function hide() {
|
||||
visible.value = false;
|
||||
}
|
||||
|
||||
const saveFlag = ref(false);
|
||||
//获取用户的列数据
|
||||
async function getUserTableColumns(tableId, columns) {
|
||||
if (!tableId) {
|
||||
@@ -128,14 +128,18 @@
|
||||
}
|
||||
|
||||
//根据前端列和后端列构建新的列数据
|
||||
tableData.value = mergeColumn(columns, userTableColumnArray);
|
||||
|
||||
let obj = mergeColumn(columns, userTableColumnArray);
|
||||
tableData.value = obj.newColumns;
|
||||
saveFlag.value = obj.saveFlag;
|
||||
//将已经显示的展示出来
|
||||
for (const item of tableData.value) {
|
||||
if (item.showFlag) {
|
||||
selectedRowKeyList.value.push(item.columnKey);
|
||||
}
|
||||
}
|
||||
if (saveFlag.value) {
|
||||
save(false);
|
||||
}
|
||||
|
||||
nextTick(() => {
|
||||
initDrag();
|
||||
@@ -253,7 +257,7 @@
|
||||
}
|
||||
|
||||
//保存
|
||||
async function save() {
|
||||
async function save(closeFlag = true) {
|
||||
submitLoading.value = true;
|
||||
try {
|
||||
let columnList = [];
|
||||
@@ -277,9 +281,11 @@
|
||||
columnList,
|
||||
});
|
||||
|
||||
message.success('保存成功');
|
||||
emit('change', columnList);
|
||||
hide();
|
||||
if (closeFlag) {
|
||||
message.success('保存成功');
|
||||
hide();
|
||||
}
|
||||
} catch (e) {
|
||||
smartSentry.captureError(e);
|
||||
} finally {
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<template>
|
||||
<div :class="className">
|
||||
<div v-if="overflow" class="ellipsis-box">
|
||||
<a-popover>
|
||||
<template #content>
|
||||
{{ text }}
|
||||
<SmartCopyIcon :value="text" />
|
||||
</template>
|
||||
<div>
|
||||
<slot>
|
||||
{{ text }}
|
||||
</slot>
|
||||
</div>
|
||||
</a-popover>
|
||||
</div>
|
||||
<div v-else>
|
||||
<slot>
|
||||
{{ text }}
|
||||
</slot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted, ref, nextTick } from 'vue';
|
||||
import { Modal } from 'ant-design-vue';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import SmartCopyIcon from '/@/components/smart-copy-icon/index.vue';
|
||||
|
||||
const props = defineProps({
|
||||
text: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
classKey: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
|
||||
const overflow = ref(false);
|
||||
const className = ref();
|
||||
onMounted(() => {
|
||||
className.value = props.classKey + uuid();
|
||||
nextTick(() => {
|
||||
let doc = document.querySelector(`.${className.value}`);
|
||||
let fontSize = window.getComputedStyle(doc).fontSize.replace('px', '');
|
||||
let clientWidth = doc.clientWidth;
|
||||
let span = document.createElement('span');
|
||||
document.body.appendChild(span);
|
||||
span.style.fontSize = `${fontSize}px`;
|
||||
span.innerText = props.text;
|
||||
let width = span.offsetWidth;
|
||||
document.body.removeChild(span);
|
||||
overflow.value = width > clientWidth;
|
||||
});
|
||||
});
|
||||
|
||||
function showModel() {
|
||||
Modal.info({
|
||||
content: props.text,
|
||||
icon: '',
|
||||
okText: '关闭',
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.ellipsis-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
div {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -14,6 +14,10 @@ export const appDefaultConfig = {
|
||||
layout: 'side',
|
||||
// 侧边菜单宽度 , 默认为200px
|
||||
sideMenuWidth: 200,
|
||||
// 表格高度
|
||||
tableYHeight: 300,
|
||||
//标签页位置
|
||||
pageTagLocation: 'top',
|
||||
// 菜单主题
|
||||
sideMenuTheme: 'dark',
|
||||
// 主题颜色索引
|
||||
|
||||
@@ -14,6 +14,8 @@ export default {
|
||||
antdLocale: antd,
|
||||
dayjsLocale: dayjs,
|
||||
'setting.title': 'Setting',
|
||||
'setting.table.yHeight': 'Table Height',
|
||||
'setting.pagetag.location': 'TagPage Position',
|
||||
'setting.color': 'Theme Color',
|
||||
'setting.menu.layout': 'Menu Layout',
|
||||
'setting.menu.width': 'Menu Width',
|
||||
|
||||
@@ -14,6 +14,8 @@ export default {
|
||||
antdLocale: antd,
|
||||
dayjsLocale: dayjs,
|
||||
'setting.title': '网站设置',
|
||||
'setting.table.yHeight': '表格高度',
|
||||
'setting.pagetag.location': '标签页位置',
|
||||
'setting.color': '主题颜色',
|
||||
'setting.menu.layout': '菜单布局',
|
||||
'setting.menu.width': '菜单宽度',
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
-->
|
||||
|
||||
<template>
|
||||
<a-drawer :title="$t('setting.title')" placement="right" :width="410" :open="visible" @close="close">
|
||||
<a-drawer :title="$t('setting.title')" placement="right" :width="450" :open="visible" @close="close">
|
||||
<a-form layout="horizontal" :label-col="{ span: 8 }">
|
||||
<a-form-item label="语言/Language">
|
||||
<a-select v-model:value="formState.language" @change="changeLanguage" style="width: 120px">
|
||||
@@ -47,6 +47,10 @@
|
||||
<a-input-number @change="changeSideMenuWidth" v-model:value="formState.sideMenuWidth" :min="1" />
|
||||
像素(px)
|
||||
</a-form-item>
|
||||
<a-form-item :label="$t('setting.table.yHeight')">
|
||||
<a-input-number @change="changeTableYHeight" v-model:value="formState.tableYHeight" :min="100" />
|
||||
像素(px)
|
||||
</a-form-item>
|
||||
<a-form-item :label="$t('setting.page.width')" v-if="formState.layout === LAYOUT_ENUM.TOP.value">
|
||||
<a-input @change="changePageWidth" v-model:value="formState.pageWidth" />
|
||||
像素(px)或者 百分比
|
||||
@@ -70,6 +74,12 @@
|
||||
<a-radio-button value="light">Light</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item :label="$t('setting.pagetag.location')">
|
||||
<a-radio-group v-model:value="formState.pageTagLocation" button-style="solid" @change="changePageTagLocation">
|
||||
<a-radio-button value="top">顶部</a-radio-button>
|
||||
<a-radio-button value="center">中部</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item :label="$t('setting.pagetag.style')">
|
||||
<a-radio-group v-model:value="formState.pageTagStyle" button-style="solid" @change="changePageTagStyle">
|
||||
<a-radio-button value="default">默认</a-radio-button>
|
||||
@@ -81,7 +91,13 @@
|
||||
<a-switch @change="changePageTagFlag" v-model:checked="formState.pageTagFlag" checked-children="显示" un-checked-children="隐藏" />
|
||||
</a-form-item>
|
||||
<a-form-item :label="$t('setting.bread')">
|
||||
<a-switch @change="changeBreadCrumbFlag" v-model:checked="formState.breadCrumbFlag" checked-children="显示" un-checked-children="隐藏" />
|
||||
<a-switch
|
||||
@change="changeBreadCrumbFlag"
|
||||
:disabled="formState.pageTagLocation === 'top'"
|
||||
v-model:checked="formState.breadCrumbFlag"
|
||||
checked-children="显示"
|
||||
un-checked-children="隐藏"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item :label="$t('setting.footer')">
|
||||
<a-switch @change="changeFooterFlag" v-model:checked="formState.footerFlag" checked-children="显示" un-checked-children="隐藏" />
|
||||
@@ -111,7 +127,7 @@
|
||||
</a-drawer>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, reactive, h } from 'vue';
|
||||
import { ref, reactive, h, watch } from 'vue';
|
||||
import { i18nList } from '/@/i18n/index';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import localStorageKeyConst from '/@/constants/local-storage-key-const';
|
||||
@@ -186,6 +202,8 @@
|
||||
colorIndex: appConfigStore.colorIndex,
|
||||
// 侧边菜单宽度
|
||||
sideMenuWidth: appConfigStore.sideMenuWidth,
|
||||
// 表格高度
|
||||
tableYHeight: appConfigStore.tableYHeight,
|
||||
// 菜单主题
|
||||
sideMenuTheme: appConfigStore.sideMenuTheme,
|
||||
// 页面紧凑
|
||||
@@ -206,10 +224,26 @@
|
||||
helpDocExpandFlag: appConfigStore.helpDocExpandFlag,
|
||||
// 水印
|
||||
watermarkFlag: appConfigStore.watermarkFlag,
|
||||
//标签页位置
|
||||
pageTagLocation: appConfigStore.pageTagLocation,
|
||||
};
|
||||
|
||||
let formState = reactive({ ...formValue });
|
||||
|
||||
watch(
|
||||
() => formState.pageTagLocation,
|
||||
() => {
|
||||
if (formState.pageTagLocation === 'top') {
|
||||
formState.breadCrumbFlag = false;
|
||||
} else {
|
||||
formState.breadCrumbFlag = true;
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
);
|
||||
|
||||
const { locale } = useI18n();
|
||||
function changeLanguage(languageValue) {
|
||||
locale.value = languageValue;
|
||||
@@ -218,6 +252,12 @@
|
||||
});
|
||||
}
|
||||
|
||||
function changePageTagLocation(e) {
|
||||
appConfigStore.$patch({
|
||||
pageTagLocation: e.target.value,
|
||||
});
|
||||
}
|
||||
|
||||
function changeLayout(e) {
|
||||
appConfigStore.$patch({
|
||||
layout: e.target.value,
|
||||
@@ -236,6 +276,12 @@
|
||||
sideMenuWidth: value,
|
||||
});
|
||||
}
|
||||
function changeTableYHeight(value) {
|
||||
appConfigStore.$patch({
|
||||
tableYHeight: value,
|
||||
});
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
function changePageWidth(e) {
|
||||
appConfigStore.$patch({
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
};
|
||||
</script>
|
||||
<style scoped lang="less">
|
||||
::v-deep(.ant-menu-item-selected) {
|
||||
:deep(.ant-menu-item-selected) {
|
||||
border-right: 3px !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -8,14 +8,7 @@
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||
-->
|
||||
<template>
|
||||
<a-menu
|
||||
v-model:openKeys="openKeys"
|
||||
v-model:selectedKeys="selectedKeys"
|
||||
class="smart-menu"
|
||||
mode="inline"
|
||||
:theme="theme"
|
||||
:inlineCollapsed="collapsed"
|
||||
>
|
||||
<a-menu v-model:openKeys="openKeys" v-model:selectedKeys="selectedKeys" class="smart-menu" mode="inline" :theme="theme">
|
||||
<template v-for="item in menuTree" :key="item.menuId">
|
||||
<template v-if="item.visibleFlag && !item.disabledFlag">
|
||||
<template v-if="$lodash.isEmpty(item.children)">
|
||||
@@ -80,7 +73,7 @@
|
||||
let parentList = menuParentIdListMap.get(currentRoute.name) || [];
|
||||
|
||||
// 如果是折叠菜单的话,则不需要设置openkey
|
||||
if(!props.collapsed){
|
||||
if (!props.collapsed) {
|
||||
// 使用lodash的union函数,进行 去重合并两个数组
|
||||
let needOpenKeys = _.map(parentList, 'name').map(Number);
|
||||
openKeys.value = _.union(openKeys.value, needOpenKeys);
|
||||
|
||||
@@ -46,7 +46,6 @@ let currentRoute = useRoute();
|
||||
function updateSelectKeyAndOpenKey() {
|
||||
// 第一步,根据路由 更新选中 顶级菜单
|
||||
let parentList = useUserStore().menuParentIdListMap.get(currentRoute.name) || [];
|
||||
console.log('parentList', parentList)
|
||||
if (parentList.length === 0) {
|
||||
topMenuRef.value.updateSelectKey(currentRoute.name);
|
||||
return;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<!--
|
||||
* 递归菜单
|
||||
*
|
||||
* @Author: 1024创新实验室-主任:卓大
|
||||
* @Date: 2022-09-06 20:29:12
|
||||
* @Wechat: zhuda1024
|
||||
* @Email: lab1024@163.com
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||
*
|
||||
* @Author: 1024创新实验室-主任:卓大
|
||||
* @Date: 2022-09-06 20:29:12
|
||||
* @Wechat: zhuda1024
|
||||
* @Email: lab1024@163.com
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||
-->
|
||||
<template>
|
||||
<div class="recursion-container" v-show="topMenu.children && topMenu.children.length > 0">
|
||||
@@ -39,10 +39,11 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { HOME_PAGE_NAME } from '/@/constants/system/home-const';
|
||||
import SubMenu from './sub-menu.vue';
|
||||
import { router } from '/@/router';
|
||||
import { useRoute } from 'vue-router';
|
||||
import _ from 'lodash';
|
||||
import menuEmitter from './top-expand-menu-mitt';
|
||||
import { useAppConfigStore } from '/@/store/modules/system/app-config';
|
||||
@@ -59,10 +60,23 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
|
||||
//菜单宽度
|
||||
const sideMenuWidth = computed(() => useAppConfigStore().$state.sideMenuWidth);
|
||||
|
||||
// 选中的顶级菜单
|
||||
let topMenu = ref({});
|
||||
menuEmitter.on('selectTopMenu', onSelectTopMenu);
|
||||
|
||||
//动态通知顶部菜单栏侧边栏状态
|
||||
watch(
|
||||
topMenu,
|
||||
(value) => {
|
||||
let hasSideMenu = value.children && value.children.length > 0;
|
||||
menuEmitter.emit('sideMenuChange', hasSideMenu);
|
||||
},
|
||||
{ immediate: true, deep: true }
|
||||
);
|
||||
|
||||
// 监听选中顶级菜单事件
|
||||
function onSelectTopMenu(selectedTopMenu) {
|
||||
topMenu.value = selectedTopMenu;
|
||||
@@ -75,6 +89,7 @@ function onSelectTopMenu(selectedTopMenu) {
|
||||
}
|
||||
|
||||
//展开的菜单
|
||||
let currentRoute = useRoute();
|
||||
const selectedKeys = ref([]);
|
||||
const openKeys = ref([]);
|
||||
|
||||
@@ -87,6 +102,15 @@ function updateSelectKeyAndOpenKey(parentList, currentSelectKey) {
|
||||
selectedKeys.value = [currentSelectKey];
|
||||
}
|
||||
|
||||
watch(
|
||||
currentRoute,
|
||||
(value) => {
|
||||
selectedKeys.value = [value.name];
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
);
|
||||
// 页面跳转
|
||||
function turnToPage(route) {
|
||||
useUserStore().deleteKeepAliveIncludes(route.menuId.toString());
|
||||
@@ -113,22 +137,22 @@ const color = computed(() => {
|
||||
background-color: v-bind('color.background');
|
||||
}
|
||||
|
||||
.min-logo {
|
||||
height: @header-user-height;
|
||||
line-height: @header-user-height;
|
||||
padding: 0px 15px 0px 15px;
|
||||
// background-color: v-bind('color.background');
|
||||
.min-logo {
|
||||
height: @header-user-height;
|
||||
line-height: @header-user-height;
|
||||
padding: 0px 15px 0px 15px;
|
||||
// background-color: v-bind('color.background');
|
||||
|
||||
width: 80px;
|
||||
z-index: 21;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
.logo-img {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
}
|
||||
width: 80px;
|
||||
z-index: 21;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
.logo-img {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
}
|
||||
}
|
||||
.top-menu {
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
|
||||
@@ -75,19 +75,22 @@ function updateSelectKey(key) {
|
||||
defineExpose({ updateSelectKey });
|
||||
|
||||
// 动态计算当前导航宽度
|
||||
let menuInfo = computed(() => {
|
||||
let hasSideMenu = ref(false);
|
||||
menuEmitter.on('sideMenuChange', (data) => {
|
||||
hasSideMenu.value = data;
|
||||
});
|
||||
|
||||
const menuInfo = computed(() => {
|
||||
let width = '100vw';
|
||||
let right = '-100vw';
|
||||
let selectedItem = _.find(menuTree.value, { menuId: Number(selectedKeys.value[0]) });
|
||||
const hasSecoundMenu = selectedItem && !_.isEmpty(selectedItem.children) && selectedItem.children.some((e) => e.visibleFlag);
|
||||
if (hasSecoundMenu) {
|
||||
if (props.collapsed) {
|
||||
width = 'calc(100vw - 80px)';
|
||||
right = 'calc(-100vw + 80px)';
|
||||
} else {
|
||||
width = 'calc(100vw - 180px)';
|
||||
right = 'calc(-100vw + 180px)';
|
||||
}
|
||||
if (hasSideMenu.value) {
|
||||
if (props.collapsed) {
|
||||
width = 'calc(100vw - 80px)';
|
||||
right = 'calc(-100vw + 80px)';
|
||||
} else {
|
||||
width = 'calc(100vw - 180px)';
|
||||
right = 'calc(-100vw + 180px)';
|
||||
}
|
||||
}
|
||||
return {
|
||||
width,
|
||||
|
||||
@@ -20,7 +20,12 @@
|
||||
<!-- 顶部头部信息 -->
|
||||
<a-layout-header class="smart-layout-header" :id="LAYOUT_ELEMENT_IDS.header" v-show="!fullScreenFlag">
|
||||
<a-row justify="space-between" class="smart-layout-header-user">
|
||||
<a-col class="smart-layout-header-left">
|
||||
<a-col
|
||||
class="smart-layout-header-left"
|
||||
:style="{
|
||||
'max-width': `calc(100% - ${rightWidth}px)`,
|
||||
}"
|
||||
>
|
||||
<span class="collapsed-button">
|
||||
<menu-unfold-outlined v-if="collapsed" class="trigger" @click="() => (collapsed = !collapsed)" />
|
||||
<menu-fold-outlined v-else class="trigger" @click="() => (collapsed = !collapsed)" />
|
||||
@@ -32,7 +37,8 @@
|
||||
</span>
|
||||
</a-tooltip>
|
||||
<span class="location-breadcrumb">
|
||||
<MenuLocationBreadcrumb />
|
||||
<PageTag v-if="pageTagLocation === 'top'" />
|
||||
<MenuLocationBreadcrumb v-if="pageTagLocation !== 'top'" />
|
||||
</span>
|
||||
</a-col>
|
||||
<!---用戶操作区域-->
|
||||
@@ -40,7 +46,7 @@
|
||||
<HeaderUserSpace />
|
||||
</a-col>
|
||||
</a-row>
|
||||
<PageTag />
|
||||
<PageTag v-if="pageTagLocation === 'center'" />
|
||||
</a-layout-header>
|
||||
|
||||
<!--中间内容-->
|
||||
@@ -84,7 +90,7 @@
|
||||
</a-layout>
|
||||
</template>
|
||||
<script setup>
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||
import HeaderUserSpace from './components/header-user-space/index.vue';
|
||||
import MenuLocationBreadcrumb from './components/menu-location-breadcrumb/index.vue';
|
||||
import PageTag from './components/page-tag/index.vue';
|
||||
@@ -99,6 +105,7 @@
|
||||
import { useRouter } from 'vue-router';
|
||||
import { HOME_PAGE_NAME } from '/@/constants/system/home-const';
|
||||
import { LAYOUT_ELEMENT_IDS } from '/@/layout/layout-const.js';
|
||||
const appConfigStore = useAppConfigStore();
|
||||
|
||||
const windowHeight = ref(window.innerHeight);
|
||||
//是否全屏
|
||||
@@ -115,6 +122,8 @@
|
||||
const footerFlag = computed(() => useAppConfigStore().$state.footerFlag);
|
||||
// 是否显示水印
|
||||
const watermarkFlag = computed(() => useAppConfigStore().$state.watermarkFlag);
|
||||
// 标签页位置
|
||||
const pageTagLocation = computed(() => useAppConfigStore().$state.pageTagLocation);
|
||||
// 多余高度
|
||||
const dueHeight = computed(() => {
|
||||
let due = 40;
|
||||
@@ -126,6 +135,34 @@
|
||||
}
|
||||
return due;
|
||||
});
|
||||
|
||||
watch(
|
||||
pageTagLocation,
|
||||
(newVal) => {
|
||||
if (newVal == 'top') {
|
||||
nextTick(() => {
|
||||
sizeComputed();
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
);
|
||||
const rightWidth = ref(0);
|
||||
function sizeComputed() {
|
||||
const tagParentElement = document.querySelector('.location-breadcrumb');
|
||||
const tagsElement = tagParentElement.querySelector('.ant-tabs-nav-list');
|
||||
const parentElement = document.querySelector('.smart-layout-header-user');
|
||||
const rightElement = document.querySelector('.smart-layout-header-right');
|
||||
rightWidth.value = rightElement.offsetWidth;
|
||||
let ro = new ResizeObserver((e) => {
|
||||
rightWidth.value = rightElement.offsetWidth + 10;
|
||||
});
|
||||
ro.observe(rightElement);
|
||||
ro.observe(tagsElement);
|
||||
ro.observe(parentElement);
|
||||
}
|
||||
//是否隐藏菜单
|
||||
const collapsed = ref(false);
|
||||
|
||||
@@ -204,6 +241,7 @@
|
||||
}
|
||||
|
||||
.location-breadcrumb {
|
||||
width: calc(100% - 56px);
|
||||
margin-left: 15px;
|
||||
line-height: @header-user-height;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
<template>
|
||||
<a-layout class="admin-layout" style="min-height: 100%">
|
||||
<!-- 侧边菜单 side-menu -->
|
||||
<a-layout-sider :id="LAYOUT_ELEMENT_IDS.menu" class="side-menu" :width="sideMenuWidth" :collapsed="collapsed" :theme="theme" v-show="!fullScreenFlag">
|
||||
<a-layout-sider
|
||||
:id="LAYOUT_ELEMENT_IDS.menu"
|
||||
class="side-menu"
|
||||
:width="sideMenuWidth"
|
||||
v-model:collapsed="collapsed"
|
||||
:theme="theme"
|
||||
v-show="!fullScreenFlag"
|
||||
>
|
||||
<!-- 左侧菜单 -->
|
||||
<SideMenu :collapsed="collapsed" />
|
||||
</a-layout-sider>
|
||||
@@ -11,27 +18,35 @@
|
||||
<!-- 顶部头部信息 -->
|
||||
<a-layout-header class="layout-header" :id="LAYOUT_ELEMENT_IDS.header" v-show="!fullScreenFlag">
|
||||
<a-row class="layout-header-user" justify="space-between">
|
||||
<a-col class="layout-header-left">
|
||||
<span class="collapsed-button">
|
||||
<menu-unfold-outlined v-if="collapsed" class="trigger" @click="() => (collapsed = !collapsed)" />
|
||||
<menu-fold-outlined v-else class="trigger" @click="() => (collapsed = !collapsed)" />
|
||||
</span>
|
||||
<a-tooltip placement="bottom">
|
||||
<template #title>首页</template>
|
||||
<span class="home-button" @click="goHome">
|
||||
<home-outlined class="trigger" />
|
||||
<a-col
|
||||
class="layout-header-left"
|
||||
:style="{
|
||||
'max-width': `calc(100% - ${rightWidth}px)`,
|
||||
}"
|
||||
>
|
||||
<div class="layout-header-box">
|
||||
<span class="collapsed-button">
|
||||
<menu-unfold-outlined v-if="collapsed" class="trigger" @click="() => (collapsed = !collapsed)" />
|
||||
<menu-fold-outlined v-else class="trigger" @click="() => (collapsed = !collapsed)" />
|
||||
</span>
|
||||
</a-tooltip>
|
||||
<span class="location-breadcrumb">
|
||||
<MenuLocationBreadcrumb />
|
||||
</span>
|
||||
<a-tooltip placement="bottom">
|
||||
<template #title>首页</template>
|
||||
<span class="home-button" @click="goHome">
|
||||
<home-outlined class="trigger" />
|
||||
</span>
|
||||
</a-tooltip>
|
||||
<span class="location-breadcrumb">
|
||||
<PageTag v-if="pageTagLocation === 'top'" />
|
||||
<MenuLocationBreadcrumb />
|
||||
</span>
|
||||
</div>
|
||||
</a-col>
|
||||
<!---用戶操作区域-->
|
||||
<a-col class="layout-header-right">
|
||||
<HeaderUserSpace />
|
||||
</a-col>
|
||||
</a-row>
|
||||
<PageTag />
|
||||
<PageTag v-if="pageTagLocation === 'center'" />
|
||||
</a-layout-header>
|
||||
|
||||
<!--中间内容-->
|
||||
@@ -94,6 +109,8 @@
|
||||
import { useRouter } from 'vue-router';
|
||||
import { HOME_PAGE_NAME } from '/@/constants/system/home-const';
|
||||
import { LAYOUT_ELEMENT_IDS } from '/@/layout/layout-const.js';
|
||||
import { nextTick } from 'vue';
|
||||
const appConfigStore = useAppConfigStore();
|
||||
|
||||
const windowHeight = ref(window.innerHeight);
|
||||
//是否全屏
|
||||
@@ -112,6 +129,8 @@
|
||||
const footerFlag = computed(() => useAppConfigStore().$state.footerFlag);
|
||||
// 是否显示水印
|
||||
const watermarkFlag = computed(() => useAppConfigStore().$state.watermarkFlag);
|
||||
// 标签页位置
|
||||
const pageTagLocation = computed(() => useAppConfigStore().$state.pageTagLocation);
|
||||
// 多余高度
|
||||
const dueHeight = computed(() => {
|
||||
let due = 40;
|
||||
@@ -123,6 +142,36 @@
|
||||
}
|
||||
return due;
|
||||
});
|
||||
|
||||
watch(
|
||||
pageTagLocation,
|
||||
(newVal) => {
|
||||
if (newVal == 'top') {
|
||||
nextTick(() => {
|
||||
sizeComputed();
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
);
|
||||
|
||||
const rightWidth = ref(0);
|
||||
function sizeComputed() {
|
||||
const tagParentElement = document.querySelector('.location-breadcrumb');
|
||||
const tagsElement = tagParentElement.querySelector('.ant-tabs-nav-list');
|
||||
const parentElement = document.querySelector('.layout-header-user');
|
||||
const rightElement = document.querySelector('.layout-header-right');
|
||||
rightWidth.value = rightElement.offsetWidth;
|
||||
let ro = new ResizeObserver((e) => {
|
||||
rightWidth.value = rightElement.offsetWidth + 10;
|
||||
});
|
||||
ro.observe(rightElement);
|
||||
ro.observe(tagsElement);
|
||||
ro.observe(parentElement);
|
||||
}
|
||||
|
||||
//是否隐藏菜单
|
||||
const collapsed = ref(false);
|
||||
|
||||
@@ -188,6 +237,11 @@
|
||||
display: flex;
|
||||
height: @header-user-height;
|
||||
|
||||
.layout-header-box {
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
}
|
||||
.collapsed-button {
|
||||
margin-left: 10px;
|
||||
line-height: @header-user-height;
|
||||
@@ -205,6 +259,7 @@
|
||||
}
|
||||
|
||||
.location-breadcrumb {
|
||||
width: calc(100% - 56px);
|
||||
margin-left: 15px;
|
||||
line-height: @header-user-height;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,12 @@
|
||||
<!-- 顶部头部信息 -->
|
||||
<a-layout-header class="smart-layout-header">
|
||||
<a-row justify="space-between" class="smart-layout-header-user">
|
||||
<a-col class="smart-layout-header-left">
|
||||
<a-col
|
||||
class="smart-layout-header-left"
|
||||
:style="{
|
||||
'max-width': `calc(100% - ${rightWidth}px)`,
|
||||
}"
|
||||
>
|
||||
<span class="collapsed-button">
|
||||
<menu-unfold-outlined v-if="collapsed" class="trigger" @click="() => (collapsed = !collapsed)" />
|
||||
<menu-fold-outlined v-else class="trigger" @click="() => (collapsed = !collapsed)" />
|
||||
@@ -32,7 +37,8 @@
|
||||
</span>
|
||||
</a-tooltip>
|
||||
<span class="location-breadcrumb">
|
||||
<MenuLocationBreadcrumb />
|
||||
<PageTag v-if="pageTagLocation === 'top'" />
|
||||
<MenuLocationBreadcrumb v-if="pageTagLocation === 'center'" />
|
||||
</span>
|
||||
</a-col>
|
||||
<!---用戶操作区域-->
|
||||
@@ -40,7 +46,7 @@
|
||||
<HeaderUserSpace />
|
||||
</a-col>
|
||||
</a-row>
|
||||
<PageTag />
|
||||
<PageTag v-if="pageTagLocation === 'center'" />
|
||||
</a-layout-header>
|
||||
|
||||
<!--中间内容-->
|
||||
@@ -76,204 +82,234 @@
|
||||
</a-layout>
|
||||
</template>
|
||||
<script setup>
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import HeaderUserSpace from './components/header-user-space/index.vue';
|
||||
import MenuLocationBreadcrumb from './components/menu-location-breadcrumb/index.vue';
|
||||
import PageTag from './components/page-tag/index.vue';
|
||||
import TopExpandMenu from './components/top-expand-menu/index.vue';
|
||||
import SmartFooter from './components/smart-footer/index.vue';
|
||||
import { smartKeepAlive } from './components/smart-keep-alive';
|
||||
import IframeIndex from '/@/components/framework/iframe/iframe-index.vue';
|
||||
import watermark from '../lib/smart-watermark';
|
||||
import { useAppConfigStore } from '/@/store/modules/system/app-config';
|
||||
import { useUserStore } from '/@/store/modules/system/user';
|
||||
import SideHelpDoc from './components/side-help-doc/index.vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { HOME_PAGE_NAME } from '/@/constants/system/home-const';
|
||||
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||
import HeaderUserSpace from './components/header-user-space/index.vue';
|
||||
import MenuLocationBreadcrumb from './components/menu-location-breadcrumb/index.vue';
|
||||
import PageTag from './components/page-tag/index.vue';
|
||||
import TopExpandMenu from './components/top-expand-menu/index.vue';
|
||||
import SmartFooter from './components/smart-footer/index.vue';
|
||||
import { smartKeepAlive } from './components/smart-keep-alive';
|
||||
import IframeIndex from '/@/components/framework/iframe/iframe-index.vue';
|
||||
import watermark from '../lib/smart-watermark';
|
||||
import { useAppConfigStore } from '/@/store/modules/system/app-config';
|
||||
import { useUserStore } from '/@/store/modules/system/user';
|
||||
import SideHelpDoc from './components/side-help-doc/index.vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { HOME_PAGE_NAME } from '/@/constants/system/home-const';
|
||||
|
||||
const windowHeight = ref(window.innerHeight);
|
||||
const windowHeight = ref(window.innerHeight);
|
||||
|
||||
//主题颜色
|
||||
const theme = computed(() => useAppConfigStore().$state.sideMenuTheme);
|
||||
//是否显示标签页
|
||||
const pageTagFlag = computed(() => useAppConfigStore().$state.pageTagFlag);
|
||||
// 是否显示帮助文档
|
||||
const helpDocFlag = computed(() => useAppConfigStore().$state.helpDocExpandFlag);
|
||||
// 是否显示页脚
|
||||
const footerFlag = computed(() => useAppConfigStore().$state.footerFlag);
|
||||
// 是否显示水印
|
||||
const watermarkFlag = computed(() => useAppConfigStore().$state.watermarkFlag);
|
||||
// 多余高度
|
||||
const dueHeight = computed(() => {
|
||||
let due = 40;
|
||||
if (useAppConfigStore().$state.pageTagFlag) {
|
||||
due = due + 40;
|
||||
//主题颜色
|
||||
const theme = computed(() => useAppConfigStore().$state.sideMenuTheme);
|
||||
//是否显示标签页
|
||||
const pageTagFlag = computed(() => useAppConfigStore().$state.pageTagFlag);
|
||||
// 是否显示帮助文档
|
||||
const helpDocFlag = computed(() => useAppConfigStore().$state.helpDocExpandFlag);
|
||||
// 是否显示页脚
|
||||
const footerFlag = computed(() => useAppConfigStore().$state.footerFlag);
|
||||
// 是否显示水印
|
||||
const watermarkFlag = computed(() => useAppConfigStore().$state.watermarkFlag);
|
||||
// 标签页位置
|
||||
const pageTagLocation = computed(() => useAppConfigStore().$state.pageTagLocation);
|
||||
// 多余高度
|
||||
const dueHeight = computed(() => {
|
||||
let due = 40;
|
||||
if (useAppConfigStore().$state.pageTagFlag) {
|
||||
due = due + 40;
|
||||
}
|
||||
if (useAppConfigStore().$state.footerFlag) {
|
||||
due = due + 40;
|
||||
}
|
||||
return due;
|
||||
});
|
||||
watch(
|
||||
pageTagLocation,
|
||||
(newVal) => {
|
||||
if (newVal == 'top') {
|
||||
nextTick(() => {
|
||||
sizeComputed();
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
);
|
||||
const rightWidth = ref(0);
|
||||
function sizeComputed() {
|
||||
const tagParentElement = document.querySelector('.location-breadcrumb');
|
||||
const tagsElement = tagParentElement.querySelector('.ant-tabs-nav-list');
|
||||
const parentElement = document.querySelector('.smart-layout-header-user');
|
||||
const rightElement = document.querySelector('.smart-layout-header-right');
|
||||
rightWidth.value = rightElement.offsetWidth;
|
||||
let ro = new ResizeObserver((e) => {
|
||||
rightWidth.value = rightElement.offsetWidth + 10;
|
||||
});
|
||||
ro.observe(rightElement);
|
||||
ro.observe(tagsElement);
|
||||
ro.observe(parentElement);
|
||||
}
|
||||
if (useAppConfigStore().$state.footerFlag) {
|
||||
due = due + 40;
|
||||
}
|
||||
return due;
|
||||
});
|
||||
//是否隐藏菜单
|
||||
const collapsed = ref(false);
|
||||
//是否隐藏菜单
|
||||
const collapsed = ref(false);
|
||||
|
||||
//页面初始化的时候加载水印
|
||||
onMounted(() => {
|
||||
if (watermarkFlag.value) {
|
||||
watermark.set('smartAdminLayoutContent', useUserStore().actualName);
|
||||
} else {
|
||||
watermark.clear();
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
() => watermarkFlag.value,
|
||||
(newValue) => {
|
||||
if (newValue) {
|
||||
//页面初始化的时候加载水印
|
||||
onMounted(() => {
|
||||
if (watermarkFlag.value) {
|
||||
watermark.set('smartAdminLayoutContent', useUserStore().actualName);
|
||||
} else {
|
||||
watermark.clear();
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
() => watermarkFlag.value,
|
||||
(newValue) => {
|
||||
if (newValue) {
|
||||
watermark.set('smartAdminLayoutContent', useUserStore().actualName);
|
||||
} else {
|
||||
watermark.clear();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
window.addEventListener('resize', function () {
|
||||
windowHeight.value = window.innerHeight;
|
||||
});
|
||||
|
||||
//回到顶部
|
||||
const backTopTarget = () => {
|
||||
return document.getElementById('smartAdminMain');
|
||||
};
|
||||
// ----------------------- keep-alive相关 -----------------------
|
||||
let { route, keepAliveIncludes, iframeNotKeepAlivePageFlag, keepAliveIframePages } = smartKeepAlive();
|
||||
const router = useRouter();
|
||||
function goHome() {
|
||||
router.push({ name: HOME_PAGE_NAME });
|
||||
}
|
||||
);
|
||||
|
||||
window.addEventListener('resize', function () {
|
||||
windowHeight.value = window.innerHeight;
|
||||
});
|
||||
|
||||
//回到顶部
|
||||
const backTopTarget = () => {
|
||||
return document.getElementById('smartAdminMain');
|
||||
};
|
||||
// ----------------------- keep-alive相关 -----------------------
|
||||
let { route, keepAliveIncludes, iframeNotKeepAlivePageFlag, keepAliveIframePages } = smartKeepAlive();
|
||||
const router = useRouter();
|
||||
function goHome() {
|
||||
router.push({ name: HOME_PAGE_NAME });
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="less">
|
||||
:deep(.ant-layout-header) {
|
||||
height: auto;
|
||||
}
|
||||
:deep(.layout-header) {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.smart-layout-header {
|
||||
background: #fff;
|
||||
padding: 0;
|
||||
z-index: 21;
|
||||
}
|
||||
|
||||
.smart-layout-header-user {
|
||||
height: @header-user-height;
|
||||
border-bottom: 1px solid #f6f6f6;
|
||||
}
|
||||
|
||||
.smart-layout-header-left {
|
||||
display: flex;
|
||||
height: @header-user-height;
|
||||
|
||||
.collapsed-button {
|
||||
margin-left: 10px;
|
||||
line-height: @header-user-height;
|
||||
:deep(.ant-layout-header) {
|
||||
height: auto;
|
||||
}
|
||||
:deep(.layout-header) {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.home-button {
|
||||
margin-left: 15px;
|
||||
cursor: pointer;
|
||||
padding: 0 5px;
|
||||
line-height: @header-user-height;
|
||||
.smart-layout-header {
|
||||
background: #fff;
|
||||
padding: 0;
|
||||
z-index: 21;
|
||||
}
|
||||
|
||||
.home-button:hover {
|
||||
background-color: #efefef;
|
||||
.smart-layout-header-user {
|
||||
height: @header-user-height;
|
||||
border-bottom: 1px solid #f6f6f6;
|
||||
}
|
||||
|
||||
.location-breadcrumb {
|
||||
margin-left: 15px;
|
||||
line-height: @header-user-height;
|
||||
.smart-layout-header-left {
|
||||
display: flex;
|
||||
height: @header-user-height;
|
||||
|
||||
.collapsed-button {
|
||||
margin-left: 10px;
|
||||
line-height: @header-user-height;
|
||||
}
|
||||
|
||||
.home-button {
|
||||
margin-left: 15px;
|
||||
cursor: pointer;
|
||||
padding: 0 5px;
|
||||
line-height: @header-user-height;
|
||||
}
|
||||
|
||||
.home-button:hover {
|
||||
background-color: #efefef;
|
||||
}
|
||||
|
||||
.location-breadcrumb {
|
||||
width: calc(100% - 56px);
|
||||
margin-left: 15px;
|
||||
line-height: @header-user-height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.smart-layout-header-right {
|
||||
display: flex;
|
||||
height: @header-user-height;
|
||||
}
|
||||
.smart-layout-header-right {
|
||||
display: flex;
|
||||
height: @header-user-height;
|
||||
}
|
||||
|
||||
.admin-layout {
|
||||
.side-menu {
|
||||
height: 100vh;
|
||||
flex: 0 !important;
|
||||
min-width: inherit !important;
|
||||
max-width: none !important;
|
||||
// width: auto !important;
|
||||
&.fixed-side {
|
||||
position: fixed;
|
||||
.admin-layout {
|
||||
.side-menu {
|
||||
height: 100vh;
|
||||
left: 0;
|
||||
top: 0;
|
||||
flex: 0 !important;
|
||||
min-width: inherit !important;
|
||||
max-width: none !important;
|
||||
// width: auto !important;
|
||||
&.fixed-side {
|
||||
position: fixed;
|
||||
height: 100vh;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
.side-menu::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
.side-menu::-webkit-scrollbar-thumb {
|
||||
border-radius: 10px;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
.side-menu::-webkit-scrollbar-track {
|
||||
border-radius: 0;
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
}
|
||||
.side-menu::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
.side-menu::-webkit-scrollbar-thumb {
|
||||
border-radius: 10px;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
.side-menu::-webkit-scrollbar-track {
|
||||
border-radius: 0;
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.help-doc-sider {
|
||||
flex: 0 !important;
|
||||
min-width: 100px;
|
||||
height: 100vh;
|
||||
max-width: 100px;
|
||||
width: auto !important;
|
||||
&.fixed-side {
|
||||
position: fixed;
|
||||
.help-doc-sider {
|
||||
flex: 0 !important;
|
||||
min-width: 100px;
|
||||
height: 100vh;
|
||||
right: 0;
|
||||
top: 0;
|
||||
max-width: 100px;
|
||||
width: auto !important;
|
||||
&.fixed-side {
|
||||
position: fixed;
|
||||
height: 100vh;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.virtual-side {
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.virtual-header {
|
||||
transition: all 0.2s;
|
||||
opacity: 0;
|
||||
|
||||
&.fixed-tabs.multi-page:not(.fixed-header) {
|
||||
height: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.admin-layout-main {
|
||||
padding-top: 46px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.admin-layout-content {
|
||||
background-color: inherit;
|
||||
min-height: auto;
|
||||
position: relative;
|
||||
padding: 10px 10px 0px 10px;
|
||||
height: calc(100% - v-bind(dueHeight) px);
|
||||
overflow-x: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.virtual-side {
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.virtual-header {
|
||||
transition: all 0.2s;
|
||||
opacity: 0;
|
||||
|
||||
&.fixed-tabs.multi-page:not(.fixed-header) {
|
||||
height: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.admin-layout-main {
|
||||
padding-top: 46px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.admin-layout-content {
|
||||
background-color: inherit;
|
||||
min-height: auto;
|
||||
.smart-layout-footer {
|
||||
position: relative;
|
||||
padding: 10px 10px 0px 10px;
|
||||
height: calc(100% - v-bind(dueHeight) px);
|
||||
overflow-x: hidden;
|
||||
padding: 10px 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
.smart-layout-footer {
|
||||
position: relative;
|
||||
padding: 10px 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
<!--中间内容-->
|
||||
<a-layout-content :id="LAYOUT_ELEMENT_IDS.content" class="admin-layout-content">
|
||||
<!---标签页-->
|
||||
<div class="page-tag-div" v-show="pageTagFlag && !fullScreenFlag" :id="LAYOUT_ELEMENT_IDS.header">
|
||||
<div class="page-tag-div" v-show="(pageTagFlag && !fullScreenFlag) || breadCrumbFlag" :id="LAYOUT_ELEMENT_IDS.header">
|
||||
<MenuLocationBreadcrumb v-if="pageTagLocation !== 'top'" />
|
||||
<PageTag />
|
||||
</div>
|
||||
|
||||
@@ -56,6 +57,7 @@
|
||||
import { useRouter } from 'vue-router';
|
||||
import { HOME_PAGE_NAME } from '/@/constants/system/home-const';
|
||||
import { LAYOUT_ELEMENT_IDS } from '/@/layout/layout-const.js';
|
||||
import MenuLocationBreadcrumb from './components/menu-location-breadcrumb/index.vue';
|
||||
|
||||
const windowHeight = ref(window.innerHeight);
|
||||
//主题颜色
|
||||
@@ -76,6 +78,10 @@
|
||||
const footerFlag = computed(() => useAppConfigStore().$state.footerFlag);
|
||||
// 是否显示水印
|
||||
const watermarkFlag = computed(() => useAppConfigStore().$state.watermarkFlag);
|
||||
// 标签页位置
|
||||
const pageTagLocation = computed(() => useAppConfigStore().$state.pageTagLocation);
|
||||
// 面包屑
|
||||
const breadCrumbFlag = computed(() => useAppConfigStore().$state.breadCrumbFlag);
|
||||
// 页面宽度
|
||||
const pageWidth = computed(() => useAppConfigStore().$state.pageWidth);
|
||||
// 多余高度
|
||||
@@ -85,9 +91,16 @@
|
||||
}
|
||||
|
||||
let due = '45px';
|
||||
if (useAppConfigStore().$state.pageTagFlag) {
|
||||
if (useAppConfigStore().$state.pageTagFlag || useAppConfigStore().$state.breadCrumbFlag) {
|
||||
due = '85px';
|
||||
}
|
||||
if (
|
||||
useAppConfigStore().$state.pageTagFlag &&
|
||||
useAppConfigStore().$state.pageTagLocation === 'center' &&
|
||||
useAppConfigStore().$state.breadCrumbFlag
|
||||
) {
|
||||
due = '125px';
|
||||
}
|
||||
return due;
|
||||
});
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import _ from 'lodash';
|
||||
import LocalStorageKeyConst from '/@/constants/local-storage-key-const.js';
|
||||
|
||||
// token的消息头
|
||||
const TOKEN_HEADER = 'x-access-token';
|
||||
const TOKEN_HEADER = 'Authorization';
|
||||
|
||||
// 创建axios对象
|
||||
const smartAxios = axios.create({
|
||||
@@ -37,7 +37,7 @@ smartAxios.interceptors.request.use(
|
||||
// 在发送请求之前消息头加入token token
|
||||
const token = localRead(LocalStorageKeyConst.USER_TOKEN);
|
||||
if (token) {
|
||||
config.headers[TOKEN_HEADER] = token;
|
||||
config.headers[TOKEN_HEADER] = 'Bearer ' + token;
|
||||
} else {
|
||||
delete config.headers[TOKEN_HEADER];
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ import 'vue3-tabs-chrome/dist/vue3-tabs-chrome.css';
|
||||
import '/@/theme/index.less';
|
||||
import { localRead } from '/@/utils/local-util.js';
|
||||
import LocalStorageKeyConst from '/@/constants/local-storage-key-const.js';
|
||||
import { Table } from 'ant-design-vue';
|
||||
import { useAppConfigStore } from '/@/store/modules/system/app-config';
|
||||
import '/@/utils/ployfill';
|
||||
|
||||
/*
|
||||
* -------------------- ※ 着重 解释说明下main.js的初始化逻辑 begin ※ --------------------
|
||||
@@ -64,7 +67,7 @@ async function getLoginInfo() {
|
||||
}
|
||||
}
|
||||
|
||||
function initVue() {
|
||||
async function initVue() {
|
||||
let vueApp = createApp(App);
|
||||
let app = vueApp.use(router).use(store).use(i18n).use(Antd).use(smartEnumPlugin, constantsInfo).use(privilegePlugin).use(JsonViewer);
|
||||
//注入权限
|
||||
@@ -83,11 +86,17 @@ function initVue() {
|
||||
//挂载
|
||||
app.mount('#app');
|
||||
}
|
||||
|
||||
function setTableYHeight() {
|
||||
Table.props.scroll.default = {
|
||||
y: useAppConfigStore().tableYHeight,
|
||||
};
|
||||
}
|
||||
//不需要获取用户信息、用户菜单、用户菜单动态路由,直接初始化vue即可
|
||||
let token = localRead(LocalStorageKeyConst.USER_TOKEN);
|
||||
if (!token) {
|
||||
initVue();
|
||||
await initVue();
|
||||
setTableYHeight();
|
||||
} else {
|
||||
getLoginInfo();
|
||||
await getLoginInfo();
|
||||
setTableYHeight();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||
*/
|
||||
import { useUserStore } from '/@/store/modules/system/user';
|
||||
import _ from 'lodash';
|
||||
|
||||
const privilege = (value) => {
|
||||
// 超级管理员
|
||||
|
||||
53
smart-admin-web-javascript/src/store/modules/system/dict.js
Normal file
53
smart-admin-web-javascript/src/store/modules/system/dict.js
Normal file
@@ -0,0 +1,53 @@
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
export const useDictStore = defineStore({
|
||||
id: 'dict',
|
||||
state: () => ({
|
||||
dict: new Array(),
|
||||
}),
|
||||
actions: {
|
||||
// 获取字典
|
||||
getDict(keyCode) {
|
||||
if (keyCode == null && keyCode == '') {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
for (let i = 0; i < this.dict.length; i++) {
|
||||
if (this.dict[i].keyCode == keyCode) {
|
||||
return this.dict[i].value;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
// 设置字典
|
||||
setDict(keyCode, value) {
|
||||
if (keyCode !== null && keyCode !== '') {
|
||||
this.dict.push({
|
||||
key: keyCode,
|
||||
value: value,
|
||||
});
|
||||
}
|
||||
},
|
||||
// 删除字典
|
||||
removeDict(keyCode) {
|
||||
let flag = false;
|
||||
try {
|
||||
for (let i = 0; i < this.dict.length; i++) {
|
||||
if (this.dict[i].keyCode == keyCode) {
|
||||
this.dict.splice(i, 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
flag = false;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
// 清空字典
|
||||
cleanDict() {
|
||||
this.dict = new Array();
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -73,7 +73,7 @@ export const useUserStore = defineStore({
|
||||
}
|
||||
return localRead(localKey.USER_TOKEN);
|
||||
},
|
||||
getNeedUpdatePwdFlag(state) {
|
||||
getNeedUpdatePwdFlag(state){
|
||||
return state.needUpdatePwdFlag;
|
||||
},
|
||||
//是否初始化了 路由
|
||||
@@ -206,7 +206,7 @@ export const useUserStore = defineStore({
|
||||
// @ts-ignore
|
||||
menuTitle: route.meta.title,
|
||||
menuQuery: route.query,
|
||||
menuIcon: route.meta?.icon,
|
||||
menuIcon:route.meta?.icon,
|
||||
// @ts-ignore
|
||||
fromMenuName: from.name,
|
||||
fromMenuQuery: from.query,
|
||||
|
||||
22
smart-admin-web-javascript/src/utils/dict.js
Normal file
22
smart-admin-web-javascript/src/utils/dict.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { useDictStore } from '/@/store/modules/system/dict';
|
||||
import { dictApi } from '/@/api/support/dict-api';
|
||||
|
||||
/**
|
||||
* 获取字典数据
|
||||
*/
|
||||
|
||||
export function useDict(...args) {
|
||||
let res = {};
|
||||
args.forEach(async (keyCode, index) => {
|
||||
res[keyCode] = [];
|
||||
const dicts = useDictStore().getDict(keyCode);
|
||||
if (dicts) {
|
||||
res[keyCode] = dicts;
|
||||
} else {
|
||||
let result = await dictApi.valueList(keyCode);
|
||||
res[keyCode] = result.data;
|
||||
useDictStore().setDict(keyCode, res[keyCode]);
|
||||
}
|
||||
});
|
||||
return res;
|
||||
}
|
||||
14
smart-admin-web-javascript/src/utils/ployfill.js
Normal file
14
smart-admin-web-javascript/src/utils/ployfill.js
Normal file
@@ -0,0 +1,14 @@
|
||||
//去除谷歌浏览器的scroll、wheel等事件警告
|
||||
(function () {
|
||||
if (typeof EventTarget !== 'undefined') {
|
||||
let func = EventTarget.prototype.addEventListener;
|
||||
EventTarget.prototype.addEventListener = function (type, fn, capture) {
|
||||
this.func = func;
|
||||
if (typeof capture !== 'boolean') {
|
||||
capture = capture || {};
|
||||
capture.passive = false;
|
||||
}
|
||||
this.func(type, fn, capture);
|
||||
};
|
||||
}
|
||||
})();
|
||||
@@ -17,7 +17,7 @@
|
||||
</a-modal>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { ref, reactive, nextTick } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { SmartLoading } from '/@/components/framework/smart-loading';
|
||||
import _ from 'lodash';
|
||||
@@ -43,6 +43,21 @@
|
||||
Object.assign(form, rowData);
|
||||
}
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
// 解决弹窗错误信息显示,没有可忽略
|
||||
const domArr = document.getElementsByClassName('ant-modal');
|
||||
if (domArr && domArr.length > 0) {
|
||||
Array.from(domArr).forEach((item) => {
|
||||
if (item.childNodes && item.childNodes.length > 0) {
|
||||
Array.from(item.childNodes).forEach((child) => {
|
||||
if (child.setAttribute) {
|
||||
child.setAttribute('aria-hidden', 'false');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onClose() {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<SmartEnumSelect enum-name="GOODS_STATUS_ENUM" v-model:value="form.goodsStatus" />
|
||||
</a-form-item>
|
||||
<a-form-item label="产地" name="place">
|
||||
<DictSelect width="100%" key-code="GODOS_PLACE" v-model:value="form.place" mode="tags" />
|
||||
<DictSelect width="100%" key-code="GOODS_PLACE" v-model:value="form.place" mode="tags" />
|
||||
</a-form-item>
|
||||
<a-form-item label="上架状态" name="shelvesFlag">
|
||||
<a-radio-group v-model:value="form.shelvesFlag">
|
||||
@@ -107,7 +107,7 @@
|
||||
Object.assign(form, rowData);
|
||||
}
|
||||
if (form.place && form.place.length > 0) {
|
||||
form.place = form.place.map((e) => e.valueCode);
|
||||
form.place = form.place.split(',');
|
||||
}
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="产地" name="place" class="smart-query-form-item">
|
||||
<DictSelect key-code="GODOS_PLACE" v-model:value="queryForm.place" width="120px" />
|
||||
<DictSelect key-code="GOODS_PLACE" v-model:value="queryForm.place" width="120px" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="商品状态" name="goodsStatus" class="smart-query-form-item">
|
||||
@@ -35,8 +35,8 @@
|
||||
<a-form-item label="快速筛选" class="smart-query-form-item">
|
||||
<a-radio-group v-model:value="queryForm.shelvesFlag" @change="onSearch">
|
||||
<a-radio-button :value="undefined">全部</a-radio-button>
|
||||
<a-radio-button :value="true">上架</a-radio-button>
|
||||
<a-radio-button :value="false">下架</a-radio-button>
|
||||
<a-radio-button :value="'true'">上架</a-radio-button>
|
||||
<a-radio-button :value="'false'">下架</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
|
||||
@@ -102,15 +102,28 @@
|
||||
:dataSource="tableData"
|
||||
:columns="columns"
|
||||
rowKey="goodsId"
|
||||
:scroll="{ x: 1000 }"
|
||||
bordered
|
||||
:pagination="false"
|
||||
:showSorterTooltip="false"
|
||||
:row-selection="{ selectedRowKeys: selectedRowKeyList, onChange: onSelectChange }"
|
||||
@change="onChange"
|
||||
@resizeColumn="handleResizeColumn"
|
||||
>
|
||||
<!-- main.js中有全局表格高度配置,也可单独配置 -->
|
||||
<!-- :scroll="{ y: 300 }" -->
|
||||
<template #headerCell="{ column }">
|
||||
<SmartHeaderCell v-model:value="queryForm[column.filterOptions?.key || column.dataIndex]" :column="column" @change="queryData" />
|
||||
</template>
|
||||
<template #bodyCell="{ text, record, column }">
|
||||
<template v-if="column.dataIndex === 'goodsName'">
|
||||
{{ text }}
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'place'">
|
||||
<span>{{ text && text.length > 0 ? text.map((e) => e.valueName).join(',') : '' }}</span>
|
||||
<DictPreview :options="descList.GOODS_PLACE" :value="text" />
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'remark'">
|
||||
<span>{{ text ? text : '' }}</span>
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'goodsStatus'">
|
||||
<span>{{ $smartEnumPlugin.getDescByValue('GOODS_STATUS_ENUM', text) }}</span>
|
||||
@@ -176,7 +189,7 @@
|
||||
</template>
|
||||
<script setup>
|
||||
import GoodsFormModal from './components/goods-form-modal.vue';
|
||||
import { reactive, ref, onMounted } from 'vue';
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { SmartLoading } from '/@/components/framework/smart-loading';
|
||||
import { goodsApi } from '/@/api/business/goods/goods-api';
|
||||
@@ -189,52 +202,88 @@
|
||||
import { GOODS_STATUS_ENUM } from '/@/constants/business/erp/goods-const';
|
||||
import DictSelect from '/@/components/support/dict-select/index.vue';
|
||||
import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';
|
||||
import { FILE_FOLDER_TYPE_ENUM } from '/@/constants/support/file-const.js';
|
||||
import FileUpload from '/@/components/support/file-upload/index.vue';
|
||||
import _ from 'lodash';
|
||||
import SmartHeaderCell from '/@/components/smart-table-header-cell/index.vue';
|
||||
import DictPreview from '/@/components/dict-preview/index.vue';
|
||||
import { useDict } from '/@/utils/dict';
|
||||
|
||||
const descList = useDict('GOODS_PLACE');
|
||||
// ---------------------------- 表格列 ----------------------------
|
||||
|
||||
const columns = ref([
|
||||
{
|
||||
title: '商品分类',
|
||||
dataIndex: 'categoryName',
|
||||
resizable: true,
|
||||
filterOptions: {
|
||||
type: 'category-tree',
|
||||
key: 'categoryId',
|
||||
categoryType: CATEGORY_TYPE_ENUM.GOODS.value,
|
||||
},
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '商品名称',
|
||||
dataIndex: 'goodsName',
|
||||
resizable: true,
|
||||
filterOptions: {
|
||||
type: 'input',
|
||||
key: 'searchWord',
|
||||
},
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '商品状态',
|
||||
dataIndex: 'goodsStatus',
|
||||
sorter: true
|
||||
resizable: true,
|
||||
sorter: true,
|
||||
filterOptions: {
|
||||
type: 'enum-select',
|
||||
enumName: 'GOODS_STATUS_ENUM',
|
||||
},
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '产地',
|
||||
dataIndex: 'place',
|
||||
resizable: true,
|
||||
filterOptions: {
|
||||
type: 'dict-select',
|
||||
keyCode: 'GOODS_PLACE',
|
||||
},
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '商品价格',
|
||||
title: '价格',
|
||||
dataIndex: 'price',
|
||||
sorter: true
|
||||
resizable: true,
|
||||
sorter: true,
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '上架状态',
|
||||
title: '状态',
|
||||
dataIndex: 'shelvesFlag',
|
||||
sorter: true
|
||||
resizable: true,
|
||||
sorter: true,
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'remark',
|
||||
ellipsis: true,
|
||||
resizable: true,
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
resizable: true,
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
resizable: true,
|
||||
fixed: 'right',
|
||||
width: 100,
|
||||
},
|
||||
@@ -251,7 +300,7 @@
|
||||
goodsType: undefined,
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
sortItemList: []
|
||||
sortItemList: [],
|
||||
};
|
||||
// 查询表单form
|
||||
const queryForm = reactive(_.cloneDeep(queryFormState));
|
||||
@@ -261,7 +310,15 @@
|
||||
const tableData = ref([]);
|
||||
// 总数
|
||||
const total = ref(0);
|
||||
|
||||
function handleResizeColumn(w, col) {
|
||||
columns.value.forEach((item) => {
|
||||
if (item.dataIndex === col.dataIndex) {
|
||||
item.width = Math.floor(w);
|
||||
// 拖动宽度标识
|
||||
item.dragAndDropFlag = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
// 重置查询条件
|
||||
function resetQuery() {
|
||||
let pageSize = queryForm.pageSize;
|
||||
@@ -421,11 +478,11 @@
|
||||
await goodsApi.exportGoods();
|
||||
}
|
||||
|
||||
function onChange(pagination, filters, sorter, { action }){
|
||||
function onChange(pagination, filters, sorter, { action }) {
|
||||
if (action === 'sort') {
|
||||
const { order, field } = sorter;
|
||||
let column = camelToUnderscore(field);
|
||||
let findIndex = queryForm.sortItemList.findIndex(e => e.column === column);
|
||||
let findIndex = queryForm.sortItemList.findIndex((e) => e.column === column);
|
||||
if (findIndex !== -1) {
|
||||
queryForm.sortItemList.splice(findIndex, 1);
|
||||
}
|
||||
@@ -433,7 +490,7 @@
|
||||
let isAsc = order !== 'ascend';
|
||||
queryForm.sortItemList.push({
|
||||
column,
|
||||
isAsc
|
||||
isAsc,
|
||||
});
|
||||
}
|
||||
queryData();
|
||||
@@ -441,6 +498,6 @@
|
||||
}
|
||||
|
||||
function camelToUnderscore(str) {
|
||||
return str.replace(/([A-Z])/g, "_$1").toLowerCase();
|
||||
return str.replace(/([A-Z])/g, '_$1').toLowerCase();
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -85,6 +85,21 @@
|
||||
detail(enterpriseId);
|
||||
}
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
// 解决弹窗错误信息显示,没有可忽略
|
||||
const domArr = document.getElementsByClassName('ant-modal');
|
||||
if (domArr && domArr.length > 0) {
|
||||
Array.from(domArr).forEach((item) => {
|
||||
if (item.childNodes && item.childNodes.length > 0) {
|
||||
Array.from(item.childNodes).forEach((child) => {
|
||||
if (child.setAttribute) {
|
||||
child.setAttribute('aria-hidden', 'false');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onClose() {
|
||||
|
||||
@@ -60,102 +60,102 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { noticeApi } from '/@/api/business/oa/notice-api';
|
||||
import { PAGE_SIZE, PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
||||
import DepartmentTreeSelect from '/@/components/system/department-tree-select/index.vue';
|
||||
import uaparser from 'ua-parser-js';
|
||||
import { reactive, ref } from 'vue';
|
||||
import { noticeApi } from '/@/api/business/oa/notice-api';
|
||||
import { PAGE_SIZE, PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
||||
import DepartmentTreeSelect from '/@/components/system/department-tree-select/index.vue';
|
||||
import uaparser from 'ua-parser-js';
|
||||
|
||||
const props = defineProps({
|
||||
noticeId: {
|
||||
type: [Number, String],
|
||||
},
|
||||
});
|
||||
const props = defineProps({
|
||||
noticeId: {
|
||||
type: [Number, String],
|
||||
},
|
||||
});
|
||||
|
||||
defineExpose({
|
||||
onSearch,
|
||||
});
|
||||
defineExpose({
|
||||
onSearch,
|
||||
});
|
||||
|
||||
const tableColumns = [
|
||||
{
|
||||
title: '姓名',
|
||||
dataIndex: 'employeeName',
|
||||
},
|
||||
{
|
||||
title: '查看次数',
|
||||
dataIndex: 'pageViewCount',
|
||||
},
|
||||
{
|
||||
title: '首次查看设备',
|
||||
dataIndex: 'firstIp',
|
||||
},
|
||||
{
|
||||
title: '首次查看时间',
|
||||
dataIndex: 'createTime',
|
||||
},
|
||||
{
|
||||
title: '最后一次查看设备',
|
||||
dataIndex: 'lastIp',
|
||||
},
|
||||
{
|
||||
title: '最后一次查看时间',
|
||||
dataIndex: 'updateTime',
|
||||
with: 80,
|
||||
},
|
||||
];
|
||||
const tableColumns = [
|
||||
{
|
||||
title: '姓名',
|
||||
dataIndex: 'employeeName',
|
||||
},
|
||||
{
|
||||
title: '查看次数',
|
||||
dataIndex: 'pageViewCount',
|
||||
},
|
||||
{
|
||||
title: '首次查看设备',
|
||||
dataIndex: 'firstIp',
|
||||
},
|
||||
{
|
||||
title: '首次查看时间',
|
||||
dataIndex: 'createTime',
|
||||
},
|
||||
{
|
||||
title: '最后一次查看设备',
|
||||
dataIndex: 'lastIp',
|
||||
},
|
||||
{
|
||||
title: '最后一次查看时间',
|
||||
dataIndex: 'updateTime',
|
||||
with: 80,
|
||||
},
|
||||
];
|
||||
|
||||
const tableData = ref([]);
|
||||
const total = ref(0);
|
||||
const tableLoading = ref(false);
|
||||
const tableData = ref([]);
|
||||
const total = ref(0);
|
||||
const tableLoading = ref(false);
|
||||
|
||||
const defaultQueryForm = {
|
||||
noticeId: props.noticeId,
|
||||
departmentId: null,
|
||||
keywords: '',
|
||||
pageNum: 1,
|
||||
pageSize: PAGE_SIZE,
|
||||
};
|
||||
const defaultQueryForm = {
|
||||
noticeId: props.noticeId,
|
||||
departmentId: null,
|
||||
keywords: '',
|
||||
pageNum: 1,
|
||||
pageSize: PAGE_SIZE,
|
||||
};
|
||||
|
||||
const queryForm = reactive({ ...defaultQueryForm });
|
||||
const queryForm = reactive({ ...defaultQueryForm });
|
||||
|
||||
function buildDeviceInfo(userAgent) {
|
||||
if (!userAgent) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let ua = uaparser(userAgent);
|
||||
let browser = ua.browser.name;
|
||||
let os = ua.os.name;
|
||||
return browser + '/' + os + '/' + (ua.device.vendor ? ua.device.vendor + ua.device.model : '');
|
||||
}
|
||||
|
||||
async function queryViewRecord() {
|
||||
try {
|
||||
tableLoading.value = true;
|
||||
const result = await noticeApi.queryViewRecord(queryForm);
|
||||
|
||||
for (const e of result.data.list) {
|
||||
e.firstDevice = buildDeviceInfo(e.firstUserAgent);
|
||||
e.lastDevice = buildDeviceInfo(e.lastUserAgent);
|
||||
function buildDeviceInfo(userAgent) {
|
||||
if (!userAgent) {
|
||||
return '';
|
||||
}
|
||||
|
||||
tableData.value = result.data.list;
|
||||
total.value = result.data.total;
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
} finally {
|
||||
tableLoading.value = false;
|
||||
let ua = uaparser(userAgent);
|
||||
let browser = ua.browser.name;
|
||||
let os = ua.os.name;
|
||||
return browser + '/' + os + '/' + (ua.device.vendor ? ua.device.vendor + ua.device.model : '');
|
||||
}
|
||||
}
|
||||
// 点击查询
|
||||
function onSearch() {
|
||||
queryForm.pageNum = 1;
|
||||
queryViewRecord();
|
||||
}
|
||||
|
||||
// 点击重置
|
||||
function resetQuery() {
|
||||
Object.assign(queryForm, defaultQueryForm);
|
||||
queryViewRecord();
|
||||
}
|
||||
async function queryViewRecord() {
|
||||
try {
|
||||
tableLoading.value = true;
|
||||
const result = await noticeApi.queryViewRecord(queryForm);
|
||||
|
||||
for (const e of result.data.list) {
|
||||
e.firstDevice = buildDeviceInfo(e.firstUserAgent);
|
||||
e.lastDevice = buildDeviceInfo(e.lastUserAgent);
|
||||
}
|
||||
|
||||
tableData.value = result.data.list;
|
||||
total.value = result.data.total;
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
} finally {
|
||||
tableLoading.value = false;
|
||||
}
|
||||
}
|
||||
// 点击查询
|
||||
function onSearch() {
|
||||
queryForm.pageNum = 1;
|
||||
queryViewRecord();
|
||||
}
|
||||
|
||||
// 点击重置
|
||||
function resetQuery() {
|
||||
Object.assign(queryForm, defaultQueryForm);
|
||||
queryViewRecord();
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
新建
|
||||
</a-button>
|
||||
|
||||
<a-button @click="confirmBatchDelete" v-privilege="'support:dict:batchDelete'" type="text" danger :disabled="selectedRowKeyList.length === 0">
|
||||
<a-button @click="confirmBatchDelete" v-privilege="'support:dict:batchDelete'" type="primary" danger :disabled="selectedRowKeyList.length === 0">
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
|
||||
@@ -165,7 +165,7 @@
|
||||
import JobFormModal from './components/job-form-modal.vue';
|
||||
import JobLogListModal from './components/job-log-list-modal.vue';
|
||||
import { SmartLoading } from '/@/components/framework/smart-loading/index.js';
|
||||
|
||||
const activeKey = ref('1');
|
||||
const columns = ref([
|
||||
{
|
||||
title: 'id',
|
||||
@@ -242,8 +242,6 @@
|
||||
},
|
||||
]);
|
||||
|
||||
const activeKey = ref('1');
|
||||
|
||||
// ---------------- 查询数据 -----------------------
|
||||
|
||||
const queryFormState = {
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
list-type="picture-card"
|
||||
class="avatar-uploader"
|
||||
:show-upload-list="false"
|
||||
:headers="{ 'x-access-token': useUserStore().getToken }"
|
||||
:headers="{ Authorization: 'Bearer ' + useUserStore().getToken }"
|
||||
:customRequest="customRequest"
|
||||
:before-upload="beforeUpload"
|
||||
>
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
<div class="password-form-area">
|
||||
<a-form ref="formRef" :model="form" :rules="rules" layout="vertical">
|
||||
<a-form-item label="原密码" name="oldPassword">
|
||||
<a-input-password class="form-item" v-model:value.trim="form.oldPassword" type="password" placeholder="请输入原密码" />
|
||||
<a-input-password class="form-item" v-model:value.trim="form.oldPassword" type="password" placeholder="请输入原密码" autocomplete="off" />
|
||||
</a-form-item>
|
||||
<a-form-item label="新密码" name="newPassword" :help="tips">
|
||||
<a-input-password class="form-item" v-model:value.trim="form.newPassword" type="password" placeholder="请输入新密码" />
|
||||
<a-input-password class="form-item" v-model:value.trim="form.newPassword" type="password" placeholder="请输入新密码" autocomplete="off" />
|
||||
</a-form-item>
|
||||
<a-form-item label="确认密码" name="confirmPwd" :help="tips">
|
||||
<a-input-password class="form-item" v-model:value.trim="form.confirmPwd" type="password" placeholder="请输入确认密码" />
|
||||
<a-input-password class="form-item" v-model:value.trim="form.confirmPwd" type="password" placeholder="请输入确认密码" autocomplete="off" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<a-button type="primary" style="margin: 20px 0 0 250px" @click="onSubmit">修改密码</a-button>
|
||||
|
||||
@@ -31,9 +31,13 @@
|
||||
});
|
||||
// 选中的菜单
|
||||
let selectedMenu = ref({ menuId: 0 });
|
||||
let selectedKeys = computed(() => {
|
||||
return _.isEmpty(selectedMenu.value) ? [] : [selectedMenu.value.menuId];
|
||||
});
|
||||
let selectedKeys = ref([]);
|
||||
watch(
|
||||
() => selectedMenu.value,
|
||||
(newQuery, oldQuery) => {
|
||||
selectedKeys.value = _.isEmpty(selectedMenu.value) ? [] : [selectedMenu.value.menuId];
|
||||
}
|
||||
);
|
||||
|
||||
function selectMenu(menuId) {
|
||||
selectedMenu.value = menuList.value.find((e) => e.menuId === menuId);
|
||||
|
||||
@@ -28,13 +28,13 @@
|
||||
</a-modal>
|
||||
</template>
|
||||
<script setup>
|
||||
import message from 'ant-design-vue/lib/message';
|
||||
import { reactive, ref } from 'vue';
|
||||
import { departmentApi } from '/@/api/system/department-api';
|
||||
import DepartmentTreeSelect from '/@/components/system/department-tree-select/index.vue';
|
||||
import EmployeeSelect from '/@/components/system/employee-select/index.vue';
|
||||
import { smartSentry } from '/@/lib/smart-sentry';
|
||||
import { SmartLoading } from '/@/components/framework/smart-loading';
|
||||
import message from 'ant-design-vue/lib/message';
|
||||
import { nextTick, reactive, ref } from 'vue';
|
||||
import { departmentApi } from '/@/api/system/department-api';
|
||||
import DepartmentTreeSelect from '/@/components/system/department-tree-select/index.vue';
|
||||
import EmployeeSelect from '/@/components/system/employee-select/index.vue';
|
||||
import { smartSentry } from '/@/lib/smart-sentry';
|
||||
import { SmartLoading } from '/@/components/framework/smart-loading';
|
||||
|
||||
// ----------------------- 对外暴漏 ---------------------
|
||||
|
||||
@@ -45,27 +45,42 @@ defineExpose({
|
||||
// ----------------------- modal 的显示与隐藏 ---------------------
|
||||
const emits = defineEmits(['refresh']);
|
||||
|
||||
const visible = ref(false);
|
||||
function showModal(data) {
|
||||
visible.value = true;
|
||||
updateFormData(data);
|
||||
}
|
||||
function closeModal() {
|
||||
visible.value = false;
|
||||
resetFormData();
|
||||
}
|
||||
const visible = ref(false);
|
||||
function showModal(data) {
|
||||
visible.value = true;
|
||||
updateFormData(data);
|
||||
nextTick(() => {
|
||||
// 解决弹窗错误信息显示,没有可忽略
|
||||
const domArr = document.getElementsByClassName('ant-modal');
|
||||
if (domArr && domArr.length > 0) {
|
||||
Array.from(domArr).forEach((item) => {
|
||||
if (item.childNodes && item.childNodes.length > 0) {
|
||||
Array.from(item.childNodes).forEach((child) => {
|
||||
if (child.setAttribute) {
|
||||
child.setAttribute('aria-hidden', 'false');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function closeModal() {
|
||||
visible.value = false;
|
||||
resetFormData();
|
||||
}
|
||||
|
||||
// ----------------------- form 表单操作 ---------------------
|
||||
const formRef = ref();
|
||||
const departmentTreeSelect = ref();
|
||||
const defaultDepartmentForm = {
|
||||
id: undefined,
|
||||
managerId: undefined, //部门负责人
|
||||
name: undefined,
|
||||
parentId: undefined,
|
||||
sort: 0,
|
||||
};
|
||||
const employeeSelect = ref();
|
||||
// ----------------------- form 表单操作 ---------------------
|
||||
const formRef = ref();
|
||||
const departmentTreeSelect = ref();
|
||||
const defaultDepartmentForm = {
|
||||
id: undefined,
|
||||
managerId: undefined, //部门负责人
|
||||
name: undefined,
|
||||
parentId: undefined,
|
||||
sort: 0,
|
||||
};
|
||||
const employeeSelect = ref();
|
||||
|
||||
let formState = reactive({
|
||||
...defaultDepartmentForm,
|
||||
@@ -91,49 +106,49 @@ function resetFormData() {
|
||||
Object.assign(formState, defaultDepartmentForm);
|
||||
}
|
||||
|
||||
async function handleOk() {
|
||||
try {
|
||||
await formRef.value.validate();
|
||||
if (formState.departmentId) {
|
||||
updateDepartment();
|
||||
} else {
|
||||
addDepartment();
|
||||
async function handleOk() {
|
||||
try {
|
||||
await formRef.value.validate();
|
||||
if (formState.departmentId) {
|
||||
updateDepartment();
|
||||
} else {
|
||||
addDepartment();
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('参数验证错误,请仔细填写表单数据!');
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('参数验证错误,请仔细填写表单数据!');
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------- form 表单 ajax 操作 ---------------------
|
||||
//添加部门ajax请求
|
||||
async function addDepartment() {
|
||||
SmartLoading.show();
|
||||
try {
|
||||
await departmentApi.addDepartment(formState);
|
||||
emits('refresh');
|
||||
closeModal();
|
||||
} catch (error) {
|
||||
smartSentry.captureError(error);
|
||||
} finally {
|
||||
SmartLoading.hide();
|
||||
}
|
||||
}
|
||||
|
||||
//更新部门ajax请求
|
||||
async function updateDepartment() {
|
||||
SmartLoading.show();
|
||||
try {
|
||||
if (formState.parentId == formState.departmentId) {
|
||||
message.warning('上级部门不能为自己');
|
||||
return;
|
||||
// ----------------------- form 表单 ajax 操作 ---------------------
|
||||
//添加部门ajax请求
|
||||
async function addDepartment() {
|
||||
SmartLoading.show();
|
||||
try {
|
||||
await departmentApi.addDepartment(formState);
|
||||
emits('refresh');
|
||||
closeModal();
|
||||
} catch (error) {
|
||||
smartSentry.captureError(error);
|
||||
} finally {
|
||||
SmartLoading.hide();
|
||||
}
|
||||
}
|
||||
|
||||
//更新部门ajax请求
|
||||
async function updateDepartment() {
|
||||
SmartLoading.show();
|
||||
try {
|
||||
if (formState.parentId == formState.departmentId) {
|
||||
message.warning('上级菜单不能为自己');
|
||||
return;
|
||||
}
|
||||
await departmentApi.updateDepartment(formState);
|
||||
emits('refresh');
|
||||
closeModal();
|
||||
} catch (error) {
|
||||
smartSentry.captureError(error);
|
||||
} finally {
|
||||
SmartLoading.hide();
|
||||
}
|
||||
await departmentApi.updateDepartment(formState);
|
||||
emits('refresh');
|
||||
closeModal();
|
||||
} catch (error) {
|
||||
smartSentry.captureError(error);
|
||||
} finally {
|
||||
SmartLoading.hide();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -17,16 +17,16 @@
|
||||
>
|
||||
<a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 6 }">
|
||||
<a-form-item label="职务名称" name="positionName">
|
||||
<a-input style="width: 100%" v-model:value="form.positionName" placeholder="职务名称"/>
|
||||
<a-input style="width: 100%" v-model:value="form.positionName" placeholder="职务名称" />
|
||||
</a-form-item>
|
||||
<a-form-item label="职级" name="level">
|
||||
<a-input style="width: 100%" v-model:value="form.level" placeholder="职级"/>
|
||||
<a-input style="width: 100%" v-model:value="form.level" placeholder="职级" />
|
||||
</a-form-item>
|
||||
<a-form-item label="排序" name="sort">
|
||||
<a-input-number :min="0" :step="1" :precision="0" style="width: 100%" v-model:value="form.sort" placeholder="排序"/>
|
||||
<a-input-number :min="0" :step="1" :precision="0" style="width: 100%" v-model:value="form.sort" placeholder="排序" />
|
||||
</a-form-item>
|
||||
<a-form-item label="备注" name="remark">
|
||||
<a-input style="width: 100%" v-model:value="form.remark" placeholder="备注"/>
|
||||
<a-input style="width: 100%" v-model:value="form.remark" placeholder="备注" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
@@ -39,86 +39,100 @@
|
||||
</a-modal>
|
||||
</template>
|
||||
<script setup>
|
||||
import { reactive, ref, nextTick } from 'vue';
|
||||
import _ from 'lodash';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { SmartLoading } from '/@/components/framework/smart-loading';
|
||||
import { positionApi } from '/@/api/system/position-api';
|
||||
import { smartSentry } from '/@/lib/smart-sentry';
|
||||
import { reactive, ref, nextTick } from 'vue';
|
||||
import _ from 'lodash';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { SmartLoading } from '/@/components/framework/smart-loading';
|
||||
import { positionApi } from '/@/api/system/position-api';
|
||||
import { smartSentry } from '/@/lib/smart-sentry';
|
||||
|
||||
// ------------------------ 事件 ------------------------
|
||||
// ------------------------ 事件 ------------------------
|
||||
|
||||
const emits = defineEmits(['reloadList']);
|
||||
const emits = defineEmits(['reloadList']);
|
||||
|
||||
// ------------------------ 显示与隐藏 ------------------------
|
||||
// 是否显示
|
||||
const visibleFlag = ref(false);
|
||||
// ------------------------ 显示与隐藏 ------------------------
|
||||
// 是否显示
|
||||
const visibleFlag = ref(false);
|
||||
|
||||
function show (rowData) {
|
||||
Object.assign(form, formDefault);
|
||||
if (rowData && !_.isEmpty(rowData)) {
|
||||
Object.assign(form, rowData);
|
||||
}
|
||||
visibleFlag.value = true;
|
||||
nextTick(() => {
|
||||
formRef.value.clearValidate();
|
||||
});
|
||||
}
|
||||
|
||||
function onClose () {
|
||||
Object.assign(form, formDefault);
|
||||
visibleFlag.value = false;
|
||||
}
|
||||
|
||||
// ------------------------ 表单 ------------------------
|
||||
|
||||
// 组件ref
|
||||
const formRef = ref();
|
||||
|
||||
const formDefault = {
|
||||
positionId: undefined,
|
||||
positionName: undefined, //职务名称
|
||||
level: undefined,//职纪
|
||||
sort: 0,
|
||||
remark: undefined, //备注
|
||||
};
|
||||
|
||||
let form = reactive({ ...formDefault });
|
||||
|
||||
const rules = {
|
||||
positionName: [{ required: true, message: '请输入职务名称' }],
|
||||
};
|
||||
|
||||
// 点击确定,验证表单
|
||||
async function onSubmit () {
|
||||
try {
|
||||
await formRef.value.validateFields();
|
||||
save();
|
||||
} catch (err) {
|
||||
message.error('参数验证错误,请仔细填写表单数据!');
|
||||
}
|
||||
}
|
||||
|
||||
// 新建、编辑API
|
||||
async function save () {
|
||||
SmartLoading.show();
|
||||
try {
|
||||
if (form.positionId) {
|
||||
await positionApi.update(form);
|
||||
} else {
|
||||
await positionApi.add(form);
|
||||
function show(rowData) {
|
||||
Object.assign(form, formDefault);
|
||||
if (rowData && !_.isEmpty(rowData)) {
|
||||
Object.assign(form, rowData);
|
||||
}
|
||||
message.success('操作成功');
|
||||
emits('reloadList');
|
||||
onClose();
|
||||
} catch (err) {
|
||||
smartSentry.captureError(err);
|
||||
} finally {
|
||||
SmartLoading.hide();
|
||||
}
|
||||
}
|
||||
visibleFlag.value = true;
|
||||
nextTick(() => {
|
||||
formRef.value.clearValidate();
|
||||
|
||||
defineExpose({
|
||||
show,
|
||||
});
|
||||
// 解决弹窗错误信息显示,没有可忽略
|
||||
const domArr = document.getElementsByClassName('ant-modal');
|
||||
if (domArr && domArr.length > 0) {
|
||||
Array.from(domArr).forEach((item) => {
|
||||
if (item.childNodes && item.childNodes.length > 0) {
|
||||
Array.from(item.childNodes).forEach((child) => {
|
||||
if (child.setAttribute) {
|
||||
child.setAttribute('aria-hidden', 'false');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onClose() {
|
||||
Object.assign(form, formDefault);
|
||||
visibleFlag.value = false;
|
||||
}
|
||||
|
||||
// ------------------------ 表单 ------------------------
|
||||
|
||||
// 组件ref
|
||||
const formRef = ref();
|
||||
|
||||
const formDefault = {
|
||||
positionId: undefined,
|
||||
positionName: undefined, //职务名称
|
||||
level: undefined, //职纪
|
||||
sort: 0,
|
||||
remark: undefined, //备注
|
||||
};
|
||||
|
||||
let form = reactive({ ...formDefault });
|
||||
|
||||
const rules = {
|
||||
positionName: [{ required: true, message: '请输入职务名称' }],
|
||||
};
|
||||
|
||||
// 点击确定,验证表单
|
||||
async function onSubmit() {
|
||||
try {
|
||||
await formRef.value.validateFields();
|
||||
save();
|
||||
} catch (err) {
|
||||
message.error('参数验证错误,请仔细填写表单数据!');
|
||||
}
|
||||
}
|
||||
|
||||
// 新建、编辑API
|
||||
async function save() {
|
||||
SmartLoading.show();
|
||||
try {
|
||||
if (form.positionId) {
|
||||
await positionApi.update(form);
|
||||
} else {
|
||||
await positionApi.add(form);
|
||||
}
|
||||
message.success('操作成功');
|
||||
emits('reloadList');
|
||||
onClose();
|
||||
} catch (err) {
|
||||
smartSentry.captureError(err);
|
||||
} finally {
|
||||
SmartLoading.hide();
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
show,
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user