# Conflicts:
#	pnpm-lock.yaml
This commit is contained in:
sjl
2025-10-21 16:30:45 +08:00
112 changed files with 18142 additions and 5568 deletions

View File

@@ -48,10 +48,14 @@
"vxe-table-plugin-export-xlsx": "^4.0.7", "vxe-table-plugin-export-xlsx": "^4.0.7",
"grid-layout-plus": "^1.1.0", "grid-layout-plus": "^1.1.0",
"vue-i18n": "9.10.2", "vue-i18n": "9.10.2",
"qs": "^6.12.0",
"vue-types": "^5.1.1",
"web-storage-cache": "^1.1.1",
"jsencrypt": "^3.3.2",
"xe-utils": "^3.5.14" "xe-utils": "^3.5.14"
}, },
"devDependencies": { "devDependencies": {
"@purge-icons/generated": "^0.9.0", "@purge-icons/generated": "^0.9.0",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/node": "^20.10.5", "@types/node": "^20.10.5",
"@types/splitpanes": "2.2.6", "@types/splitpanes": "2.2.6",

2955
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -69,3 +69,11 @@ export const queryById = (params: any) => {
params params
}) })
} }
// 更具id 查询驾驶舱页面
export const queryByPagePath = (params: any) => {
return createAxios({
url: '/system-boot/dashboard/queryByPagePath',
method: 'post',
params
})
}

View File

@@ -0,0 +1,72 @@
import createAxios from '@/utils/request'
const SYSTEM_PREFIX = '/system-boot'
/**
* 上传文件
* @param file
*/
export const uploadFile = (file: any, path: string) => {
let form = new FormData()
form.append('file', file)
form.append('path', path)
return createAxios({
url: SYSTEM_PREFIX + '/file/upload',
method: 'POST',
headers: {
'Content-Type': 'multipart/form-data'
},
data: form
})
}
/**
* 删除文件
*/
export const deleteFile = (filePath: string) => {
let form = new FormData()
form.append('filePath', filePath)
return createAxios({
url: SYSTEM_PREFIX + '/file/delete',
method: 'POST',
data: form
})
}
/**
* 下载文件
*/
export const downloadFile = (filePath: any) => {
// let form = new FormData()
// form.append('filePath', filePath)
return createAxios({
url: SYSTEM_PREFIX + '/file/download',
method: 'GET',
params: filePath,
responseType: 'blob'
})
}
/**
* 获取文件的短期url展示
*/
export const getFileUrl = (params:any) => {
let form = new FormData()
// form.append('filePath', filePath)
return createAxios({
url: SYSTEM_PREFIX + '/file/getFileUrl',
method: 'get',
params
})
}
/**
* 根据获取文件的一个短期url及文件名
*/
export const getFileNameAndFilePath = (query: any) => {
return createAxios({
url: SYSTEM_PREFIX + '/file/getFileVO',
method: 'GET',
params: query
})
}

BIN
src/assets/img/amplify.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
src/assets/img/reduce.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
src/assets/imgs/1x1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 B

BIN
src/assets/imgs/2x2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

BIN
src/assets/imgs/2x3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

BIN
src/assets/imgs/3x3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

BIN
src/assets/imgs/amplify.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
src/assets/imgs/avatar.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
src/assets/imgs/avatar.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
src/assets/imgs/bg02.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

BIN
src/assets/imgs/bg1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
src/assets/imgs/ditu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
src/assets/imgs/ditu1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

BIN
src/assets/imgs/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
src/assets/imgs/profile.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

BIN
src/assets/imgs/reduce.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
src/assets/imgs/t_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

BIN
src/assets/imgs/t_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

BIN
src/assets/imgs/t_7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

BIN
src/assets/imgs/wechat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -0,0 +1,3 @@
import Backtop from './src/Backtop.vue'
export { Backtop }

View File

@@ -0,0 +1,17 @@
<script lang="ts" setup>
import { ElBacktop } from 'element-plus'
import { useDesign } from '@/hooks/web/useDesign'
defineOptions({ name: 'BackTop' })
const { getPrefixCls, variables } = useDesign()
const prefixCls = getPrefixCls('backtop')
</script>
<template>
<ElBacktop
:class="`${prefixCls}-backtop`"
:target="`.${variables.namespace}-layout-content-scrollbar .${variables.elNamespace}-scrollbar__wrap`"
/>
</template>

View File

@@ -0,0 +1,111 @@
<template>
<ElDialog v-if="isModal" v-model="showSearch" :show-close="false" title="菜单搜索">
<el-select
filterable
:reserve-keyword="false"
remote
placeholder="请输入菜单内容"
:remote-method="remoteMethod"
style="width: 100%"
@change="handleChange"
>
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</ElDialog>
<div v-else class="custom-hover" @click.stop="showTopSearch = !showTopSearch">
<Icon icon="ep:search" />
<el-select
filterable
:reserve-keyword="false"
remote
placeholder="请输入菜单内容"
:remote-method="remoteMethod"
class="overflow-hidden transition-all-600"
:class="showTopSearch ? '!w-220px ml2' : '!w-0'"
@change="handleChange"
>
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
</template>
<script lang="ts" setup>
defineProps({
isModal: {
type: Boolean,
default: true
}
})
const router = useRouter() // 路由对象
const showSearch = ref(false) // 是否显示弹框
const showTopSearch = ref(false) // 是否显示顶部搜索框
const value: Ref = ref('') // 用户输入的值
const routers = router.getRoutes() // 路由对象
const options = computed(() => {
// 提示选项
if (!value.value) {
return []
}
const list = routers.filter((item: any) => {
if (item.meta.title?.indexOf(value.value) > -1 || item.path.indexOf(value.value) > -1) {
return true
}
})
return list.map((item) => {
return {
label: `${item.meta.title}${item.path}`,
value: item.path
}
})
})
function remoteMethod(data) {
// 这里可以执行相应的操作(例如打开搜索框等)
value.value = data
}
function handleChange(path) {
router.push({ path })
hiddenTopSearch()
}
function hiddenTopSearch() {
showTopSearch.value = false
}
onMounted(() => {
window.addEventListener('keydown', listenKey)
window.addEventListener('click', hiddenTopSearch)
})
onUnmounted(() => {
window.removeEventListener('keydown', listenKey)
window.removeEventListener('click', hiddenTopSearch)
})
// 监听 ctrl + k
function listenKey(event) {
if ((event.ctrlKey || event.metaKey) && event.key === 'k') {
showSearch.value = !showSearch.value
// 这里可以执行相应的操作(例如打开搜索框等)
}
}
defineExpose({
openSearch: () => {
showSearch.value = true
}
})
</script>

View File

@@ -1,282 +1,282 @@
<template> <template>
<div class="w100"> <div class="w100">
<!-- el-select 的远程下拉只在有搜索词时才会加载数据显示出 option 列表 --> <!-- el-select 的远程下拉只在有搜索词时才会加载数据显示出 option 列表 -->
<!-- 使用 el-popover 在无数据/无搜索词时显示一个无数据的提醒 --> <!-- 使用 el-popover 在无数据/无搜索词时显示一个无数据的提醒 -->
<el-popover width="100%" placement="bottom" popper-class="remote-select-popper" <el-popover width="100%" placement="bottom" popper-class="remote-select-popper"
:visible="state.focusStatus && !state.loading && !state.keyword && !state.options.length" :visible="state.focusStatus && !state.loading && !state.keyword && !state.options.length"
:teleported="false" :content="$t('utils.No data')"> :teleported="false" :content="$t('utils.No data')">
<template #reference> <template #reference>
<el-select ref="selectRef" class="w100" @focus="onFocus" @blur="onBlur" <el-select ref="selectRef" class="w100" @focus="onFocus" @blur="onBlur"
:loading="state.loading || state.accidentBlur" :filterable="true" :remote="true" clearable :loading="state.loading || state.accidentBlur" :filterable="true" :remote="true" clearable
remote-show-suffix :remote-method="onLogKeyword" v-model.trim="state.value" @change="onChangeSelect" remote-show-suffix :remote-method="onLogKeyword" v-model.trim="state.value" @change="onChangeSelect"
:multiple="multiple" :key="state.selectKey" @clear="onClear" @visible-change="onVisibleChange" :multiple="multiple" :key="state.selectKey" @clear="onClear" @visible-change="onVisibleChange"
v-bind="$attrs"> v-bind="$attrs">
<el-option class="remote-select-option" v-for="item in state.options" :label="item[field]" <el-option class="remote-select-option" v-for="item in state.options" :label="item[field]"
:value="item[state.primaryKey].toString()" :key="item[state.primaryKey]"> :value="item[state.primaryKey].toString()" :key="item[state.primaryKey]">
<el-tooltip placement="right" effect="light" v-if="!isEmpty(tooltipParams)"> <el-tooltip placement="right" effect="light" v-if="!isEmpty(tooltipParams)">
<template #content> <template #content>
<p v-for="(tooltipParam, key) in tooltipParams" :key="key">{{ key }}: {{ <p v-for="(tooltipParam, key) in tooltipParams" :key="key">{{ key }}: {{
item[tooltipParam] }}</p> item[tooltipParam] }}</p>
</template> </template>
<div>{{ item[field] }}</div> <div>{{ item[field] }}</div>
</el-tooltip> </el-tooltip>
</el-option> </el-option>
<el-pagination v-if="state.total" :currentPage="state.currentPage" :page-size="state.pageSize" <el-pagination v-if="state.total" :currentPage="state.currentPage" :page-size="state.pageSize"
class="select-pagination" layout="->, prev, next" :total="state.total" class="select-pagination" layout="->, prev, next" :total="state.total"
@current-change="onSelectCurrentPageChange" /> @current-change="onSelectCurrentPageChange" />
</el-select> </el-select>
</template> </template>
</el-popover> </el-popover>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, watch, onMounted, onUnmounted, ref, nextTick, getCurrentInstance, toRaw } from 'vue' import { reactive, watch, onMounted, onUnmounted, ref, nextTick, getCurrentInstance, toRaw } from 'vue'
import { getSelectData } from '@/api/common' // import { getSelectData } from '@/api/common'
import { uuid } from '@/utils/random' import { uuid } from '@/utils/random'
import type { ElSelect } from 'element-plus' import type { ElSelect } from 'element-plus'
import { isEmpty } from 'lodash-es' import { isEmpty } from 'lodash-es'
import { getArrayKey } from '@/utils/common' // import { getArrayKey } from '@/utils/common'
const selectRef = ref<InstanceType<typeof ElSelect> | undefined>() const selectRef = ref<InstanceType<typeof ElSelect> | undefined>()
type ElSelectProps = Partial<InstanceType<typeof ElSelect>['$props']> type ElSelectProps = Partial<InstanceType<typeof ElSelect>['$props']>
type valType = string | number | string[] | number[] type valType = string | number | string[] | number[]
interface Props extends /* @vue-ignore */ ElSelectProps { interface Props extends /* @vue-ignore */ ElSelectProps {
pk?: string pk?: string
field?: string field?: string
params?: anyObj params?: anyObj
multiple?: boolean multiple?: boolean
remoteUrl: string remoteUrl: string
modelValue: valType modelValue: valType
labelFormatter?: (optionData: anyObj, optionKey: string) => string labelFormatter?: (optionData: anyObj, optionKey: string) => string
tooltipParams?: anyObj tooltipParams?: anyObj
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
pk: 'id', pk: 'id',
field: 'name', field: 'name',
params: () => { params: () => {
return {} return {}
}, },
remoteUrl: '', remoteUrl: '',
modelValue: '', modelValue: '',
multiple: false, multiple: false,
tooltipParams: () => { tooltipParams: () => {
return {} return {}
}, },
}) })
const state: { const state: {
// 主表字段名(不带表别名) // 主表字段名(不带表别名)
primaryKey: string primaryKey: string
options: anyObj[] options: anyObj[]
loading: boolean loading: boolean
total: number total: number
currentPage: number currentPage: number
pageSize: number pageSize: number
params: anyObj params: anyObj
keyword: string keyword: string
value: valType value: valType
selectKey: string selectKey: string
initializeData: boolean initializeData: boolean
accidentBlur: boolean accidentBlur: boolean
focusStatus: boolean focusStatus: boolean
} = reactive({ } = reactive({
primaryKey: props.pk, primaryKey: props.pk,
options: [], options: [],
loading: false, loading: false,
total: 0, total: 0,
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
params: props.params, params: props.params,
keyword: '', keyword: '',
value: props.modelValue ? props.modelValue : '', value: props.modelValue ? props.modelValue : '',
selectKey: uuid(), selectKey: uuid(),
initializeData: false, initializeData: false,
accidentBlur: false, accidentBlur: false,
focusStatus: false, focusStatus: false,
}) })
let io: null | IntersectionObserver = null let io: null | IntersectionObserver = null
const instance = getCurrentInstance() const instance = getCurrentInstance()
const emits = defineEmits<{ const emits = defineEmits<{
(e: 'update:modelValue', value: valType): void (e: 'update:modelValue', value: valType): void
(e: 'row', value: any): void (e: 'row', value: any): void
}>() }>()
const onChangeSelect = (val: valType) => { const onChangeSelect = (val: valType) => {
emits('update:modelValue', val) emits('update:modelValue', val)
if (typeof instance?.vnode.props?.onRow == 'function') { if (typeof instance?.vnode.props?.onRow == 'function') {
let pkArr = props.pk.split('.') let pkArr = props.pk.split('.')
let pk = pkArr[pkArr.length - 1] let pk = pkArr[pkArr.length - 1]
if (typeof val == 'number' || typeof val == 'string') { if (typeof val == 'number' || typeof val == 'string') {
const dataKey = getArrayKey(state.options, pk, val.toString()) // const dataKey = getArrayKey(state.options, pk, val.toString())
emits('row', dataKey ? toRaw(state.options[dataKey]) : {}) // emits('row', dataKey ? toRaw(state.options[dataKey]) : {})
} else { } else {
const valueArr = [] // const valueArr = []
for (const key in val) { // for (const key in val) {
let dataKey = getArrayKey(state.options, pk, val[key].toString()) // let dataKey = getArrayKey(state.options, pk, val[key].toString())
if (dataKey) valueArr.push(toRaw(state.options[dataKey])) // if (dataKey) valueArr.push(toRaw(state.options[dataKey]))
} // }
emits('row', valueArr) // emits('row', valueArr)
} }
} }
} }
const onVisibleChange = (val: boolean) => { const onVisibleChange = (val: boolean) => {
// 保持面板状态和焦点状态一致 // 保持面板状态和焦点状态一致
if (!val) { if (!val) {
nextTick(() => { nextTick(() => {
selectRef.value?.blur() selectRef.value?.blur()
}) })
} }
} }
const onFocus = () => { const onFocus = () => {
state.focusStatus = true state.focusStatus = true
if (selectRef.value?.query != state.keyword) { if (selectRef.value?.query != state.keyword) {
state.keyword = '' state.keyword = ''
state.initializeData = false state.initializeData = false
// el-select 自动清理搜索词会产生意外的脱焦 // el-select 自动清理搜索词会产生意外的脱焦
state.accidentBlur = true state.accidentBlur = true
} }
if (!state.initializeData) { if (!state.initializeData) {
getData() getData()
} }
} }
const onBlur = () => { const onBlur = () => {
state.focusStatus = false state.focusStatus = false
} }
const onClear = () => { const onClear = () => {
state.keyword = '' state.keyword = ''
state.initializeData = false state.initializeData = false
} }
const onLogKeyword = (q: string) => { const onLogKeyword = (q: string) => {
if (state.keyword != q) { if (state.keyword != q) {
state.keyword = q state.keyword = q
getData() getData()
} }
} }
const getData = (initValue: valType = '') => { const getData = (initValue: valType = '') => {
state.loading = true state.loading = true
state.params.page = state.currentPage state.params.page = state.currentPage
state.params.initKey = props.pk state.params.initKey = props.pk
state.params.initValue = initValue state.params.initValue = initValue
getSelectData(props.remoteUrl, state.keyword, state.params) getSelectData(props.remoteUrl, state.keyword, state.params)
.then((res) => { .then((res) => {
let initializeData = true let initializeData = true
let opts = res.data.options ? res.data.options : res.data.list let opts = res.data.options ? res.data.options : res.data.list
if (typeof props.labelFormatter == 'function') { if (typeof props.labelFormatter == 'function') {
for (const key in opts) { for (const key in opts) {
opts[key][props.field] = props.labelFormatter(opts[key], key) opts[key][props.field] = props.labelFormatter(opts[key], key)
} }
} }
state.options = opts state.options = opts
state.total = res.data.total ?? 0 state.total = res.data.total ?? 0
if (initValue) { if (initValue) {
// 重新渲染组件,确保在赋值前,opts已加载到-兼容 modelValue 更新 // 重新渲染组件,确保在赋值前,opts已加载到-兼容 modelValue 更新
state.selectKey = uuid() state.selectKey = uuid()
initializeData = false initializeData = false
} }
state.loading = false state.loading = false
state.initializeData = initializeData state.initializeData = initializeData
if (state.accidentBlur) { if (state.accidentBlur) {
nextTick(() => { nextTick(() => {
const inputEl = selectRef.value?.$el.querySelector('.el-select__tags .el-select__input') const inputEl = selectRef.value?.$el.querySelector('.el-select__tags .el-select__input')
inputEl && inputEl.focus() inputEl && inputEl.focus()
state.accidentBlur = false state.accidentBlur = false
}) })
} }
}) })
.catch(() => { .catch(() => {
state.loading = false state.loading = false
}) })
} }
const onSelectCurrentPageChange = (val: number) => { const onSelectCurrentPageChange = (val: number) => {
state.currentPage = val state.currentPage = val
getData() getData()
} }
const initDefaultValue = () => { const initDefaultValue = () => {
if (state.value) { if (state.value) {
// number[]转string[]确保默认值能够选中 // number[]转string[]确保默认值能够选中
if (typeof state.value === 'object') { if (typeof state.value === 'object') {
for (const key in state.value as string[]) { for (const key in state.value as string[]) {
state.value[key] = state.value[key].toString() state.value[key] = state.value[key].toString()
} }
} else if (typeof state.value === 'number') { } else if (typeof state.value === 'number') {
state.value = state.value.toString() state.value = state.value.toString()
} }
getData(state.value) getData(state.value)
} }
} }
onMounted(() => { onMounted(() => {
if (props.pk.indexOf('.') > 0) { if (props.pk.indexOf('.') > 0) {
let pk = props.pk.split('.') let pk = props.pk.split('.')
state.primaryKey = pk[1] ? pk[1] : pk[0] state.primaryKey = pk[1] ? pk[1] : pk[0]
} }
initDefaultValue() initDefaultValue()
setTimeout(() => { setTimeout(() => {
if (window?.IntersectionObserver) { if (window?.IntersectionObserver) {
io = new IntersectionObserver((entries) => { io = new IntersectionObserver((entries) => {
for (const key in entries) { for (const key in entries) {
if (!entries[key].isIntersecting) selectRef.value?.blur() if (!entries[key].isIntersecting) selectRef.value?.blur()
} }
}) })
if (selectRef.value?.$el instanceof Element) { if (selectRef.value?.$el instanceof Element) {
io.observe(selectRef.value.$el) io.observe(selectRef.value.$el)
} }
} }
}, 500) }, 500)
}) })
onUnmounted(() => { onUnmounted(() => {
io?.disconnect() io?.disconnect()
}) })
watch( watch(
() => props.modelValue, () => props.modelValue,
(newVal) => { (newVal) => {
if (String(state.value) != String(newVal)) { if (String(state.value) != String(newVal)) {
state.value = newVal ? newVal : '' state.value = newVal ? newVal : ''
initDefaultValue() initDefaultValue()
} }
} }
) )
const getSelectRef = () => { const getSelectRef = () => {
return selectRef.value return selectRef.value
} }
const focus = () => { const focus = () => {
selectRef.value?.focus() selectRef.value?.focus()
} }
const blur = () => { const blur = () => {
selectRef.value?.blur() selectRef.value?.blur()
} }
defineExpose({ defineExpose({
blur, blur,
focus, focus,
getSelectRef, getSelectRef,
}) })
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
:deep(.remote-select-popper) { :deep(.remote-select-popper) {
text-align: center; text-align: center;
} }
.remote-select-option { .remote-select-option {
white-space: pre; white-space: pre;
} }
</style> </style>

View File

@@ -1,414 +1,414 @@
<script lang="ts"> <script lang="ts">
import type { PropType, VNode } from 'vue' import type { PropType, VNode } from 'vue'
import type { modelValueTypes, InputAttr, InputData } from '@/components/baInput' import type { modelValueTypes, InputAttr, InputData } from '@/components/baInput'
import { createVNode, resolveComponent, defineComponent, computed, reactive } from 'vue' import { createVNode, resolveComponent, defineComponent, computed, reactive } from 'vue'
import { inputTypes } from '@/components/baInput' import { inputTypes } from '@/components/baInput'
import Array from '@/components/baInput/components/array.vue' import Array from '@/components/baInput/components/array.vue'
import RemoteSelect from '@/components/baInput/components/remoteSelect.vue' import RemoteSelect from '@/components/baInput/components/remoteSelect.vue'
import IconSelector from '@/components/baInput/components/iconSelector.vue' import IconSelector from '@/components/baInput/components/iconSelector.vue'
import Editor from '@/components/baInput/components/editor.vue' import Editor from '@/components/baInput/components/editor.vue'
import { getArea } from '@/api/common' // import { getArea } from '@/api/common'
export default defineComponent({ export default defineComponent({
name: 'baInput', name: 'baInput',
props: { props: {
// 输入框类型,支持的输入框见 inputTypes // 输入框类型,支持的输入框见 inputTypes
type: { type: {
type: String, type: String,
required: true, required: true,
validator: (value: string) => { validator: (value: string) => {
return inputTypes.includes(value) return inputTypes.includes(value)
}, },
}, },
// 双向绑定值 // 双向绑定值
modelValue: { modelValue: {
type: null, type: null,
required: true, required: true,
}, },
// 输入框的附加属性 // 输入框的附加属性
attr: { attr: {
type: Object as PropType<InputAttr>, type: Object as PropType<InputAttr>,
default: () => {}, default: () => {},
}, },
// 额外数据,radio、checkbox的选项等数据 // 额外数据,radio、checkbox的选项等数据
data: { data: {
type: Object as PropType<InputData>, type: Object as PropType<InputData>,
default: () => {}, default: () => {},
}, },
}, },
emits: ['update:modelValue'], emits: ['update:modelValue'],
setup(props, { emit }) { setup(props, { emit }) {
const onValueUpdate = (value: modelValueTypes) => { const onValueUpdate = (value: modelValueTypes) => {
emit('update:modelValue', value) emit('update:modelValue', value)
} }
// 子级元素属性 // 子级元素属性
let childrenAttr = props.data && props.data.childrenAttr ? props.data.childrenAttr : {} let childrenAttr = props.data && props.data.childrenAttr ? props.data.childrenAttr : {}
// string number textarea password // string number textarea password
const sntp = () => { const sntp = () => {
return () => return () =>
createVNode(resolveComponent('el-input'), { createVNode(resolveComponent('el-input'), {
type: props.type == 'string' ? 'text' : props.type, type: props.type == 'string' ? 'text' : props.type,
...props.attr, ...props.attr,
modelValue: props.modelValue, modelValue: props.modelValue,
'onUpdate:modelValue': onValueUpdate, 'onUpdate:modelValue': onValueUpdate,
}) })
} }
// radio checkbox // radio checkbox
const rc = () => { const rc = () => {
if (!props.data || !props.data.content) { if (!props.data || !props.data.content) {
console.warn('请传递 ' + props.type + '的 content') console.warn('请传递 ' + props.type + '的 content')
} }
let vNode: VNode[] = [] let vNode: VNode[] = []
for (const key in props.data.content) { for (const key in props.data.content) {
vNode.push( vNode.push(
createVNode( createVNode(
resolveComponent('el-' + props.type), resolveComponent('el-' + props.type),
{ {
label: key, label: key,
...childrenAttr, ...childrenAttr,
}, },
() => props.data.content[key] () => props.data.content[key]
) )
) )
} }
return () => { return () => {
const valueComputed = computed(() => { const valueComputed = computed(() => {
if (props.type == 'radio') { if (props.type == 'radio') {
if (props.modelValue == undefined) return '' if (props.modelValue == undefined) return ''
return '' + props.modelValue return '' + props.modelValue
} else { } else {
let modelValueArr: anyObj = [] let modelValueArr: anyObj = []
for (const key in props.modelValue) { for (const key in props.modelValue) {
modelValueArr[key] = '' + props.modelValue[key] modelValueArr[key] = '' + props.modelValue[key]
} }
return modelValueArr return modelValueArr
} }
}) })
return createVNode( return createVNode(
resolveComponent('el-' + props.type + '-group'), resolveComponent('el-' + props.type + '-group'),
{ {
...props.attr, ...props.attr,
modelValue: valueComputed.value, modelValue: valueComputed.value,
'onUpdate:modelValue': onValueUpdate, 'onUpdate:modelValue': onValueUpdate,
}, },
() => vNode () => vNode
) )
} }
} }
// select selects // select selects
const select = () => { const select = () => {
let vNode: VNode[] = [] let vNode: VNode[] = []
if (!props.data || !props.data.content) { if (!props.data || !props.data.content) {
console.warn('请传递 ' + props.type + '的 content') console.warn('请传递 ' + props.type + '的 content')
} }
for (const key in props.data.content) { for (const key in props.data.content) {
vNode.push( vNode.push(
createVNode(resolveComponent('el-option'), { createVNode(resolveComponent('el-option'), {
key: key, key: key,
label: props.data.content[key], label: props.data.content[key],
value: key, value: key,
...childrenAttr, ...childrenAttr,
}) })
) )
} }
return () => { return () => {
const valueComputed = computed(() => { const valueComputed = computed(() => {
if (props.type == 'select') { if (props.type == 'select') {
if (props.modelValue == undefined) return '' if (props.modelValue == undefined) return ''
return '' + props.modelValue return '' + props.modelValue
} else { } else {
let modelValueArr: anyObj = [] let modelValueArr: anyObj = []
for (const key in props.modelValue) { for (const key in props.modelValue) {
modelValueArr[key] = '' + props.modelValue[key] modelValueArr[key] = '' + props.modelValue[key]
} }
return modelValueArr return modelValueArr
} }
}) })
return createVNode( return createVNode(
resolveComponent('el-select'), resolveComponent('el-select'),
{ {
class: 'w100', class: 'w100',
multiple: props.type == 'select' ? false : true, multiple: props.type == 'select' ? false : true,
clearable: true, clearable: true,
...props.attr, ...props.attr,
modelValue: valueComputed.value, modelValue: valueComputed.value,
'onUpdate:modelValue': onValueUpdate, 'onUpdate:modelValue': onValueUpdate,
}, },
() => vNode () => vNode
) )
} }
} }
// datetime // datetime
const datetime = () => { const datetime = () => {
let valueFormat = 'YYYY-MM-DD HH:mm:ss' let valueFormat = 'YYYY-MM-DD HH:mm:ss'
switch (props.type) { switch (props.type) {
case 'date': case 'date':
valueFormat = 'YYYY-MM-DD' valueFormat = 'YYYY-MM-DD'
break break
case 'year': case 'year':
valueFormat = 'YYYY' valueFormat = 'YYYY'
break break
} }
return () => return () =>
createVNode(resolveComponent('el-date-picker'), { createVNode(resolveComponent('el-date-picker'), {
class: 'w100', class: 'w100',
type: props.type, type: props.type,
'value-format': valueFormat, 'value-format': valueFormat,
...props.attr, ...props.attr,
modelValue: props.modelValue, modelValue: props.modelValue,
'onUpdate:modelValue': onValueUpdate, 'onUpdate:modelValue': onValueUpdate,
}) })
} }
// remoteSelect remoteSelects // remoteSelect remoteSelects
const remoteSelect = () => { const remoteSelect = () => {
return () => return () =>
createVNode(RemoteSelect, { createVNode(RemoteSelect, {
modelValue: props.modelValue, modelValue: props.modelValue,
'onUpdate:modelValue': onValueUpdate, 'onUpdate:modelValue': onValueUpdate,
multiple: props.type == 'remoteSelect' ? false : true, multiple: props.type == 'remoteSelect' ? false : true,
...props.attr, ...props.attr,
}) })
} }
const buildFun = new Map([ const buildFun = new Map([
['string', sntp], ['string', sntp],
['number', sntp], ['number', sntp],
['textarea', sntp], ['textarea', sntp],
['password', sntp], ['password', sntp],
['radio', rc], ['radio', rc],
['checkbox', rc], ['checkbox', rc],
[ [
'switch', 'switch',
() => { () => {
const valueType = computed(() => typeof props.modelValue) const valueType = computed(() => typeof props.modelValue)
const valueComputed = computed(() => { const valueComputed = computed(() => {
if (valueType.value === 'boolean') { if (valueType.value === 'boolean') {
return props.modelValue return props.modelValue
} else { } else {
let valueTmp = parseInt(props.modelValue as string) let valueTmp = parseInt(props.modelValue as string)
return isNaN(valueTmp) || valueTmp <= 0 ? false : true return isNaN(valueTmp) || valueTmp <= 0 ? false : true
} }
}) })
return () => return () =>
createVNode(resolveComponent('el-switch'), { createVNode(resolveComponent('el-switch'), {
...props.attr, ...props.attr,
modelValue: valueComputed.value, modelValue: valueComputed.value,
'onUpdate:modelValue': (value: boolean) => { 'onUpdate:modelValue': (value: boolean) => {
let newValue: boolean | string | number = value let newValue: boolean | string | number = value
switch (valueType.value) { switch (valueType.value) {
case 'string': case 'string':
newValue = value ? '1' : '0' newValue = value ? '1' : '0'
break break
case 'number': case 'number':
newValue = value ? 1 : 0 newValue = value ? 1 : 0
} }
emit('update:modelValue', newValue) emit('update:modelValue', newValue)
}, },
}) })
}, },
], ],
['datetime', datetime], ['datetime', datetime],
[ [
'year', 'year',
() => { () => {
return () => { return () => {
const valueComputed = computed(() => (!props.modelValue ? null : '' + props.modelValue)) const valueComputed = computed(() => (!props.modelValue ? null : '' + props.modelValue))
return createVNode(resolveComponent('el-date-picker'), { return createVNode(resolveComponent('el-date-picker'), {
class: 'w100', class: 'w100',
type: props.type, type: props.type,
'value-format': 'YYYY', 'value-format': 'YYYY',
...props.attr, ...props.attr,
modelValue: valueComputed.value, modelValue: valueComputed.value,
'onUpdate:modelValue': onValueUpdate, 'onUpdate:modelValue': onValueUpdate,
}) })
} }
}, },
], ],
['date', datetime], ['date', datetime],
[ [
'time', 'time',
() => { () => {
const valueComputed = computed(() => { const valueComputed = computed(() => {
if (props.modelValue instanceof Date) { if (props.modelValue instanceof Date) {
return props.modelValue return props.modelValue
} else if (!props.modelValue) { } else if (!props.modelValue) {
return '' return ''
} else { } else {
let date = new Date() let date = new Date()
return new Date(date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + props.modelValue) return new Date(date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + props.modelValue)
} }
}) })
return () => return () =>
createVNode(resolveComponent('el-time-picker'), { createVNode(resolveComponent('el-time-picker'), {
class: 'w100', class: 'w100',
clearable: true, clearable: true,
format: 'HH:mm:ss', format: 'HH:mm:ss',
...props.attr, ...props.attr,
modelValue: valueComputed.value, modelValue: valueComputed.value,
'onUpdate:modelValue': onValueUpdate, 'onUpdate:modelValue': onValueUpdate,
}) })
}, },
], ],
['select', select], ['select', select],
['selects', select], ['selects', select],
[ [
'array', 'array',
() => { () => {
return () => return () =>
createVNode(Array, { createVNode(Array, {
modelValue: props.modelValue, modelValue: props.modelValue,
'onUpdate:modelValue': onValueUpdate, 'onUpdate:modelValue': onValueUpdate,
...props.attr, ...props.attr,
}) })
}, },
], ],
['remoteSelect', remoteSelect], ['remoteSelect', remoteSelect],
['remoteSelects', remoteSelect], ['remoteSelects', remoteSelect],
[ [
'city', 'city',
() => { () => {
type Node = { value?: number; label?: string; leaf?: boolean } type Node = { value?: number; label?: string; leaf?: boolean }
let maxLevel = props.data && props.data.level ? props.data.level - 1 : 2 let maxLevel = props.data && props.data.level ? props.data.level - 1 : 2
const lastLazyValue: { const lastLazyValue: {
value: string | number[] | unknown value: string | number[] | unknown
nodes: Node[] nodes: Node[]
key: string key: string
currentRequest: any currentRequest: any
} = reactive({ } = reactive({
value: 'ready', value: 'ready',
nodes: [], nodes: [],
key: '', key: '',
currentRequest: null, currentRequest: null,
}) })
// 请求到的node备份-s // 请求到的node备份-s
let nodeEbak: anyObj = {} let nodeEbak: anyObj = {}
const getNodes = (level: number, key: string) => { const getNodes = (level: number, key: string) => {
if (nodeEbak[level] && nodeEbak[level][key]) { if (nodeEbak[level] && nodeEbak[level][key]) {
return nodeEbak[level][key] return nodeEbak[level][key]
} }
return false return false
} }
const setNodes = (level: number, key: string, nodes: Node[] = []) => { const setNodes = (level: number, key: string, nodes: Node[] = []) => {
if (!nodeEbak[level]) { if (!nodeEbak[level]) {
nodeEbak[level] = {} nodeEbak[level] = {}
} }
nodeEbak[level][key] = nodes nodeEbak[level][key] = nodes
} }
// 请求到的node备份-e // 请求到的node备份-e
return () => return () =>
createVNode(resolveComponent('el-cascader'), { createVNode(resolveComponent('el-cascader'), {
modelValue: props.modelValue, modelValue: props.modelValue,
'onUpdate:modelValue': onValueUpdate, 'onUpdate:modelValue': onValueUpdate,
class: 'w100', class: 'w100',
clearable: true, clearable: true,
props: { props: {
lazy: true, lazy: true,
lazyLoad(node: any, resolve: any) { lazyLoad(node: any, resolve: any) {
// lazyLoad会频繁触发,在本地存储请求结果,供重复触发时直接读取 // lazyLoad会频繁触发,在本地存储请求结果,供重复触发时直接读取
const { level, pathValues } = node const { level, pathValues } = node
let key = pathValues.join(',') let key = pathValues.join(',')
key = key ? key : 'init' key = key ? key : 'init'
let locaNode = getNodes(level, key) let locaNode = getNodes(level, key)
if (locaNode) { if (locaNode) {
return resolve(locaNode) return resolve(locaNode)
} }
if (lastLazyValue.key == key && lastLazyValue.value == props.modelValue) { if (lastLazyValue.key == key && lastLazyValue.value == props.modelValue) {
if (lastLazyValue.currentRequest) { if (lastLazyValue.currentRequest) {
return lastLazyValue.currentRequest return lastLazyValue.currentRequest
} }
return resolve(lastLazyValue.nodes) return resolve(lastLazyValue.nodes)
} }
let nodes: Node[] = [] let nodes: Node[] = []
lastLazyValue.key = key lastLazyValue.key = key
lastLazyValue.value = props.modelValue lastLazyValue.value = props.modelValue
lastLazyValue.currentRequest = getArea(pathValues).then((res) => { // lastLazyValue.currentRequest = getArea(pathValues).then((res) => {
let toStr = false // let toStr = false
if (props.modelValue && typeof (props.modelValue as anyObj)[0] === 'string') { // if (props.modelValue && typeof (props.modelValue as anyObj)[0] === 'string') {
toStr = true // toStr = true
} // }
for (const key in res.data) { // for (const key in res.data) {
if (toStr) { // if (toStr) {
res.data[key].value = res.data[key].value.toString() // res.data[key].value = res.data[key].value.toString()
} // }
res.data[key].leaf = level >= maxLevel // res.data[key].leaf = level >= maxLevel
nodes.push(res.data[key]) // nodes.push(res.data[key])
} // }
lastLazyValue.nodes = nodes // lastLazyValue.nodes = nodes
lastLazyValue.currentRequest = null // lastLazyValue.currentRequest = null
setNodes(level, key, nodes) // setNodes(level, key, nodes)
resolve(nodes) // resolve(nodes)
}) // })
}, },
}, },
...props.attr, ...props.attr,
}) })
}, },
], ],
['image', upload], ['image', upload],
['images', upload], ['images', upload],
['file', upload], ['file', upload],
['files', upload], ['files', upload],
[ [
'icon', 'icon',
() => { () => {
return () => return () =>
createVNode(IconSelector, { createVNode(IconSelector, {
modelValue: props.modelValue, modelValue: props.modelValue,
'onUpdate:modelValue': onValueUpdate, 'onUpdate:modelValue': onValueUpdate,
...props.attr, ...props.attr,
}) })
}, },
], ],
[ [
'color', 'color',
() => { () => {
return () => return () =>
createVNode(resolveComponent('el-color-picker'), { createVNode(resolveComponent('el-color-picker'), {
modelValue: props.modelValue, modelValue: props.modelValue,
'onUpdate:modelValue': onValueUpdate, 'onUpdate:modelValue': onValueUpdate,
...props.attr, ...props.attr,
}) })
}, },
], ],
[ [
'editor', 'editor',
() => { () => {
return () => return () =>
createVNode(Editor, { createVNode(Editor, {
modelValue: props.modelValue, modelValue: props.modelValue,
'onUpdate:modelValue': onValueUpdate, 'onUpdate:modelValue': onValueUpdate,
...props.attr, ...props.attr,
}) })
}, },
], ],
[ [
'default', 'default',
() => { () => {
console.warn('暂不支持' + props.type + '的输入框类型,你可以自行在 BaInput 组件内添加逻辑') console.warn('暂不支持' + props.type + '的输入框类型,你可以自行在 BaInput 组件内添加逻辑')
}, },
], ],
]) ])
let action = buildFun.get(props.type) || buildFun.get('default') let action = buildFun.get(props.type) || buildFun.get('default')
return action!.call(this) return action!.call(this)
}, },
}) })
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.ba-upload-image :deep(.el-upload--picture-card) { .ba-upload-image :deep(.el-upload--picture-card) {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.ba-upload-file :deep(.el-upload-list) { .ba-upload-file :deep(.el-upload-list) {
margin-left: -10px; margin-left: -10px;
} }
</style> </style>

View File

@@ -0,0 +1,344 @@
<template>
<div>
<!--F47曲线 -->
<el-descriptions class="mt2" direction="vertical" :column="4" border>
<el-descriptions-item align="center" label="名称">{{ data.name }}</el-descriptions-item>
<el-descriptions-item align="center" label="事件总数">{{ data.gs }}</el-descriptions-item>
<el-descriptions-item align="center" label="可容忍">{{ data.krr }}</el-descriptions-item>
<el-descriptions-item align="center" label="不可容忍">{{ data.bkrr }}</el-descriptions-item>
</el-descriptions>
<my-echart
class="tall"
:options="echartList"
:style="{ width: prop.width, height: `calc(${prop.height} - 80px)` }"
/>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import MyEchart from '@/components/echarts/MyEchart.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTimeOfTheMonth } from '@/utils/formatTime'
const prop = defineProps({
width: { type: String },
height: { type: String },
timeKey: { type: String },
timeValue: { type: Object }
})
const echartList = ref({})
const OverLimitDetailsRef = ref()
const data = reactive({
name: '事件个数',
gs: 0,
krr: 0,
bkrr: 0
})
const tableStore: any = new TableStore({
url: '/user-boot/dept/deptTree',
method: 'POST',
showPage: false,
column: [],
beforeSearchFun: () => {
tableStore.table.params.searchBeginTime = prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
},
loadCallback: () => {
let res = {
data: { totalNumberOfEvents: 0, voltageToleranceCurveDataList: [] }
}
const gongData = gongfunction(res.data.voltageToleranceCurveDataList)
data.gs = res.data.voltageToleranceCurveDataList.length
data.krr = gongData.pointI.length
data.bkrr = gongData.pointIun.length
console.log(gongData)
echartList.value = {
// backgroundColor: "#f9f9f9", //地图背景色深蓝
title: {
text: `F47曲线`
},
legend: {
data: ['上限', '下限', '可容忍事件', '不可容忍事件']
},
tooltip: {
trigger: 'item',
show: true,
axisPointer: {
type: 'shadow',
label: {
color: '#fff',
fontSize: 16
}
},
textStyle: {
color: '#fff',
fontStyle: 'normal',
opacity: 0.35,
fontSize: 14
},
backgroundColor: 'rgba(0,0,0,0.55)',
borderWidth: 0,
formatter: function (a: any) {
var relVal = ''
relVal = "<font style='color:" + "'>发生时间:" + a.value[2] + '</font><br/>'
relVal += "<font style='color:" + "'>持续时间:" + a.value[0] + 's</font><br/>'
relVal += "<font style='color:" + "'>特征幅值:" + a.value[1].toFixed(2) + '%</font>'
return relVal
}
},
xAxis: [
{
type: 'log',
min: 0.001,
max: 1000,
splitLine: {
show: false
},
name: 's'
}
],
yAxis: [
{
type: 'value',
max: function (value: any) {
return value.max + 20
},
splitNumber: 10,
minInterval: 0.1,
name: '%'
}
],
color: ['#DAA520', 'green', 'red'],
options: {
dataZoom: null,
series: [
{
name: '边界线',
type: 'line',
data: [
[0.05, 0],
[0.05, 50],
[0.2, 50],
[0.2, 70],
[0.5, 70],
[0.5, 80],
[10, 80],
[1000, 80]
],
showSymbol: false,
tooltips: {
show: false
}
},
{
name: '可容忍事件',
type: 'scatter',
symbol: 'circle',
data: gongData.pointF
},
{
name: '不可容忍事件',
type: 'scatter',
symbol: 'circle',
data: gongData.pointFun
}
]
}
}
}
})
const tableRef = ref()
provide('tableRef', tableRef)
provide('tableStore', tableStore)
function gongfunction(arr: any) {
let standI = 0
let unstandI = 0
let standF = 0
let unstandF = 0
let total = 0
let pointIun = []
let pointI = []
let pointF = []
let pointFun = []
total = arr.length
if (total == 0) {
} else {
for (let i = 0; i < arr.length; i++) {
let point = []
let xx = arr[i].persistTime
let yy = arr[i].eventValue
let time = arr[i].time
let eventId = arr[i].eventId
// let index =arr[i].eventDetailIndex;
point = [xx, yy, time, eventId]
if (xx <= 0.003) {
let line = 0
line = 250 - 30000 * xx
if (yy > line) {
unstandI++
pointIun.push({
value: point,
itemStyle: { normal: { color: 'red' } }
})
} else {
standI++
pointI.push({
value: point,
itemStyle: { normal: { color: 'green' } }
})
}
} else if (xx <= 0.02) {
if (yy > 120) {
unstandI++
pointIun.push({
value: point,
itemStyle: { normal: { color: 'red' } }
})
} else {
standI++
pointI.push({
value: point,
itemStyle: { normal: { color: 'green' } }
})
}
} else if (xx <= 0.5) {
if (yy > 120 || yy < 70) {
unstandI++
pointIun.push({
value: point,
itemStyle: { normal: { color: 'red' } }
})
} else {
standI++
pointI.push({
value: point,
itemStyle: { normal: { color: 'green' } }
})
}
} else if (xx <= 10) {
if (yy > 110 || yy < 80) {
unstandI++
pointIun.push({
value: point,
itemStyle: { normal: { color: 'red' } }
})
} else {
standI++
pointI.push({
value: point,
itemStyle: { normal: { color: 'green' } }
})
}
} else {
if (yy > 110 || yy < 90) {
unstandI++
pointIun.push({
value: point,
itemStyle: { normal: { color: 'red' } }
})
} else {
standI++
pointI.push({
value: point,
itemStyle: { normal: { color: 'green' } }
})
}
}
if (xx < 0.05) {
standF++
pointF.push({
value: point,
itemStyle: { normal: { color: 'green' } }
})
} else if (xx < 0.2) {
if (yy > 50) {
standF++
pointF.push({
value: point,
itemStyle: { normal: { color: 'green' } }
})
} else {
unstandF++
pointFun.push({
value: point,
itemStyle: { normal: { color: 'red' } }
})
}
} else if (xx < 0.5) {
if (yy > 70) {
standF++
pointF.push({
value: point,
itemStyle: { normal: { color: 'green' } }
})
} else {
unstandF++
pointFun.push({
value: point,
itemStyle: { normal: { color: 'red' } }
})
}
} else {
if (yy > 80) {
standF++
pointF.push({
value: point,
itemStyle: { normal: { color: 'green' } }
})
} else {
unstandF++
pointFun.push({
value: point,
itemStyle: { normal: { color: 'red' } }
})
}
}
}
}
return {
standI,
unstandI,
pointI,
pointIun,
standF,
unstandF,
pointF,
pointFun
}
}
onMounted(() => {
setTimeout(() => {
tableStore.index()
}, 100)
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
(newVal, oldVal) => {
tableStore.index()
},
{
deep: true // 若 timeValue 是对象/数组,需开启深度监听
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,136 @@
<template>
<div>
<!--暂降方向统计 -->
<my-echart class="tall" :options="echartList" :style="{ width: prop.width, height: `calc(${prop.height} )` }" />
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import MyEchart from '@/components/echarts/MyEchart.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTimeOfTheMonth } from '@/utils/formatTime'
const prop = defineProps({
width: { type: String },
height: { type: String },
timeKey: { type: String },
timeValue: { type: Object }
})
const data = [
{
name: '来自电网',
value: 4
},
{
name: '来自负荷',
value: 41
}
]
const echartList = ref({
title: {},
tooltip: {
trigger: 'item'
},
legend: {
orient: 'vertical',
top: 'center',
right: '5%',
formatter: function (e: any) {
return e + ' ' + data.filter(item => item.name == e)[0].value + '次'
}
},
xAxis: {
show: false
},
yAxis: {
show: false
},
grid: {
left: '10px',
right: '20px'
},
options: {
dataZoom: null,
title: [
{
text: '暂降方向统计',
left: 'center'
},
{
text: data[0].value + data[1].value + '次',
left: 'center',
top: 'center'
}
],
series: [
{
type: 'pie',
center: 'center',
radius: ['55%', '75%'],
label: {
show: false,
position: 'outside',
textStyle: {
//数值样式
}
},
name: '事件统计',
data: data
}
]
}
})
const OverLimitDetailsRef = ref()
const tableStore: any = new TableStore({
url: '/user-boot/dept/deptTree',
method: 'POST',
showPage: false,
column: [],
beforeSearchFun: () => {
tableStore.table.params.searchBeginTime = prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
},
loadCallback: () => {}
})
const tableRef = ref()
provide('tableRef', tableRef)
provide('tableStore', tableStore)
// 点击行
const cellClickEvent = ({ row, column }: any) => {
if (column.field != 'name') {
console.log(row)
OverLimitDetailsRef.value.open(row)
}
}
onMounted(() => {
tableStore.index()
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
(newVal, oldVal) => {
tableStore.index()
},
{
deep: true // 若 timeValue 是对象/数组,需开启深度监听
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,206 @@
<template>
<div>
<!--指标越限程度 -->
<my-echart
class="tall"
:options="echartList"
:style="{ width: prop.width, height: `calc(${prop.height} / 2 )` }"
/>
<Table ref="tableRef" @cell-click="cellClickEvent" :height="`calc(${prop.height} / 2 )`" isGroup></Table>
<!-- 指标越限详情 -->
<OverLimitDetails ref="OverLimitDetailsRef" />
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import MyEchart from '@/components/echarts/MyEchart.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTimeOfTheMonth } from '@/utils/formatTime'
import OverLimitDetails from '@/components/cockpit/listOfMainMonitoringPoints/components/overLimitDetails.vue'
const prop = defineProps({
width: { type: String },
height: { type: String },
timeKey: { type: String },
timeValue: { type: Object }
})
const echartList = ref({
title: {
text: '指标越限严重度'
},
xAxis: {
// name: '(区域)',
data: ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡']
},
yAxis: {
name: '%', // 给X轴加单位
interval: 20
},
grid: {
left: '10px',
right: '20px'
},
options: {
series: [
{
// name: '暂降次数',
type: 'bar',
name: '越限占比',
data: [0, 7.5, 36, 0, 80],
barMaxWidth: 30
// label: {
// show: true,
// position: 'top',
// textStyle: {
// //数值样式
// color: '#000'
// },
// fontSize: 12
// }
}
]
}
})
const OverLimitDetailsRef = ref()
const tableStore: any = new TableStore({
url: '/user-boot/dept/deptTree',
method: 'POST',
showPage: false,
column: [
{
field: 'index',
title: '序号',
width: '80',
formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
}
},
{
title: '指标名称',
field: 'name',
minWidth: '90'
},
{
title: '越限最大值',
field: 'type',
minWidth: '60',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.type}</span>`
}
},
{
title: '国标限值',
field: 'type1',
minWidth: '60'
},
{
title: '越限程度(%)',
field: 'type2',
minWidth: '60'
},
{
title: '发生日期',
field: 'type3',
minWidth: '100'
},
{
title: '越限最高监测点',
field: 'type4',
minWidth: '90'
}
],
beforeSearchFun: () => {
tableStore.table.params.searchBeginTime = prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
},
loadCallback: () => {
tableStore.table.data = [
{
name: '闪变',
type: '0.0',
type1: '2.0',
type2: '0.0',
type3: '/',
type4: '/'
},
{
name: '谐波电压',
type: '1.72',
type1: '1.6',
type2: '7.5',
type3: '2025-03-09',
type4: '10kV1#电动机'
},
{
name: '谐波电流',
type: '27.2',
type1: '20.0',
type2: '36.0',
type3: '2025-03-16',
type4: '380V电焊机(治理前)'
},
{
name: '电压偏差',
type: '0.0',
type1: '2.0',
type2: '0.0',
type3: '/',
type4: '/'
},
{
name: '三相不平衡',
type: '3.6',
type1: '2.0',
type2: '80.0',
type3: '2025-03-01',
type4: '380V电焊机(治理前)'
}
]
}
})
const tableRef = ref()
provide('tableRef', tableRef)
provide('tableStore', tableStore)
// 点击行
const cellClickEvent = ({ row, column }: any) => {
if (column.field != 'name') {
console.log(row)
OverLimitDetailsRef.value.open(row)
}
}
onMounted(() => {
tableStore.index()
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
(newVal, oldVal) => {
tableStore.index()
},
{
deep: true // 若 timeValue 是对象/数组,需开启深度监听
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped></style>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,124 @@
<template>
<div>
<!--治理效果报表 -->
<TableHeader :showReset="false">
<template v-slot:select>
<el-form-item label="治理对象">
<el-select
v-model="tableStore.table.params.power"
placeholder="请选择治理对象"
clearable
style="width: 130px"
>
<el-option
v-for="item in powerList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</template>
<template v-slot:operation>
<el-button @click="downloadExcel" class="" type="primary" icon="el-icon-Download">导出excel</el-button>
</template>
</TableHeader>
<div style="display: flex">
<div
id="luckysheet"
:style="{ width: `calc(${prop.width} )`, height: `calc(${prop.height} - 57px )` }"
></div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import { exportExcel } from '@/views/govern/reportForms/export.js'
import TableHeader from '@/components/table/header/index.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTimeOfTheMonth } from '@/utils/formatTime'
import MyEchart from '@/components/echarts/MyEchart.vue'
import { useConfig } from '@/stores/config'
import Json from './index.json'
const prop = defineProps({
width: { type: String },
height: { type: String },
timeKey: { type: String },
timeValue: { type: Object }
})
const config = useConfig()
const powerList: any = ref([
{
label: '1#变压器',
value: '1'
},
{
label: '2#变压器',
value: '2'
}
])
const tableStore: any = new TableStore({
url: '/user-boot/role/selectRoleDetail?id=0',
method: 'POST',
showPage: false,
exportName: '主要监测点列表',
column: [],
beforeSearchFun: () => {
tableStore.table.params.searchBeginTime = prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
},
loadCallback: () => {}
})
const tableRef = ref()
provide('tableRef', tableRef)
tableStore.table.params.power = '1'
provide('tableStore', tableStore)
// 下载表格
const downloadExcel = () => {
exportExcel(luckysheet.getAllSheets(), '治理效果报表')
}
onMounted(() => {
luckysheet.create({
container: 'luckysheet',
title: '', // 表 头名
lang: 'zh', // 中文
showtoolbar: false, // 是否显示工具栏
showinfobar: false, // 是否显示顶部信息栏
showsheetbar: true, // 是否显示底部sheet按钮
allowEdit: false, // 禁止所有编辑操作(必填)
data: Json
})
tableStore.index()
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
(newVal, oldVal) => {
tableStore.index()
},
{
deep: true // 若 timeValue 是对象/数组,需开启深度监听
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped>
:deep(.el-select) {
min-width: 80px;
}
</style>

View File

@@ -0,0 +1,196 @@
<template>
<div>
<!--电网侧指标越限统计 -->
<my-echart
class="tall"
:options="echartList"
:style="{ width: prop.width, height: `calc(${prop.height} / 2 )` }"
/>
<Table ref="tableRef" @cell-click="cellClickEvent" :height="`calc(${prop.height} / 2 )`" isGroup></Table>
<!-- 指标越限详情 -->
<OverLimitDetails ref="OverLimitDetailsRef" />
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import MyEchart from '@/components/echarts/MyEchart.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTimeOfTheMonth } from '@/utils/formatTime'
import OverLimitDetails from '@/components/cockpit/listOfMainMonitoringPoints/components/overLimitDetails.vue'
const prop = defineProps({
width: { type: String },
height: { type: String },
timeKey: { type: String },
timeValue: { type: Object }
})
const echartList = ref({
title: {
text: '指标越限占比'
},
xAxis: {
// name: '(区域)',
data: ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡']
},
yAxis: {
name: '%', // 给X轴加单位
interval: 20
},
grid: {
left: '10px',
right: '20px'
},
options: {
series: [
{
// name: '暂降次数',
type: 'bar',
name: '越限占比',
data: [0, 45, 22, 0, 70],
barMaxWidth: 30,
// label: {
// show: true,
// position: 'top',
// textStyle: {
// //数值样式
// color: '#000'
// },
// fontSize: 12
// }
}
]
}
})
const OverLimitDetailsRef = ref()
const tableStore: any = new TableStore({
url: '/user-boot/dept/deptTree',
method: 'POST',
showPage: false,
column: [
{
field: 'index',
title: '序号',
width: '80',
formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
}
},
{
title: '名称',
field: 'name',
minWidth: '90'
},
{
title: '越限占比(%)',
children: [
{
title: '闪变',
field: 'type',
minWidth: '70',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.type}</span>`
}
},
{
title: '谐波电压',
field: 'type1',
minWidth: '80',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.type1}</span>`
}
},
{
title: '谐波电流',
field: 'type2',
minWidth: '80',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.type2}</span>`
}
},
{
title: '电压偏差',
field: 'type3',
minWidth: '80',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.type3}</span>`
}
},
{
title: '三相不平衡',
field: 'type4',
minWidth: '90',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.type4}</span>`
}
}
]
}
],
beforeSearchFun: () => {
tableStore.table.params.searchBeginTime = prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
},
loadCallback: () => {
tableStore.table.data = [
{
name: '1#变压器电网侧',
type: '0',
type1: '45',
type2: '22',
type3: '0',
type4: '70'
}
]
tableStore.table.height = `calc(${prop.height} - 80px)`
}
})
const tableRef = ref()
provide('tableRef', tableRef)
provide('tableStore', tableStore)
// 点击行
const cellClickEvent = ({ row, column }: any) => {
if (column.field != 'name') {
console.log(row)
OverLimitDetailsRef.value.open(row)
}
}
onMounted(() => {
tableStore.index()
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
(newVal, oldVal) => {
tableStore.index()
},
{
deep: true // 若 timeValue 是对象/数组,需开启深度监听
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,186 @@
<template>
<div>
<!--指标越限明细 -->
<el-calendar v-model="value" :style="{ height: prop.height, overflow: 'auto' }">
<template #date-cell="{ data }">
<div style="height: 100%; padding: 8px" :style="{ background: setBackground(data.day) }">
<p :class="data.isSelected ? 'is-selected' : ''">
{{ data.day.split('-').slice(2).join('-') }}
</p>
<el-tooltip
effect="dark"
placement="top"
:hide-after="0"
v-if="list?.filter(item => item.time == data.day)[0]?.text || false"
>
<template #content>
<span v-html="list?.filter(item => item.time == data.day)[0]?.text || ''"></span>
</template>
<div
:style="{ height: `calc(${prop.height} / 5 - 47px)`, overflow: 'auto' }"
v-html="list?.filter(item => item.time == data.day)[0]?.text || ''"
></div>
</el-tooltip>
</div>
</template>
</el-calendar>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTimeOfTheMonth } from '@/utils/formatTime'
import { overflow } from 'html2canvas/dist/types/css/property-descriptors/overflow'
import { dayjs } from 'element-plus'
dayjs.en.weekStart = 1 //设置日历的周起始日为星期一
const value = ref(new Date())
const prop = defineProps({
width: { type: String },
height: { type: String },
timeKey: { type: String },
timeValue: { type: Object }
})
const list = ref([
{
time: '2025-10-01',
key: 81,
text: '3次谐波越限<br/>5次谐波越限<br/>三相不平衡越限'
},
{
time: '2025-10-31',
key: 81,
text: '3次谐波越限<br/>5次谐波越限<br/>三相不平衡越限'
},
{
time: '2025-10-08',
key: 20,
text: '3次谐波越限<br/>5次谐波越限<br/>三相不平衡越限'
},
{
time: '2025-10-16',
key: 20,
text: '3次谐波越限<br/>5次谐波越限<br/>三相不平衡越限'
},
{
time: '2025-10-23',
key: 20,
text: '3次谐波越限<br/>5次谐波越限<br/>三相不平衡越限'
},
{
time: '2025-10-04',
key: 0,
text: ''
},
{
time: '2025-10-05',
key: 0,
text: ''
}
])
const tableStore: any = new TableStore({
url: '/user-boot/dept/deptTree',
method: 'POST',
showPage: false,
column: [],
beforeSearchFun: () => {
tableStore.table.params.searchBeginTime = prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
// value.value = new Date(prop.timeValue?.[0])
},
loadCallback: () => {
tableStore.table.data = []
}
})
const tableRef = ref([])
const setBackground = (value: string) => {
let data = []
data = list.value?.filter(item => item.time == value)
if (data && data?.length > 0) {
if (data[0].key < 10) {
return '#33996690'
} else if (data[0].key < 80) {
return '#FFCC3390'
} else if (data[0].key <= 100) {
return '#Ff660090'
}
}
return '#fff'
}
provide('tableRef', tableRef)
provide('tableStore', tableStore)
onMounted(() => {
tableStore.index()
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
(newVal, oldVal) => {
tableStore.index()
},
{
deep: true // 若 timeValue 是对象/数组,需开启深度监听
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped>
:deep(.el-calendar) {
.el-calendar__header {
display: none;
}
.el-calendar__body {
padding: 0px !important;
height: 100%;
.el-calendar-table {
height: 100%;
}
}
.el-calendar-day {
height: 100%;
padding: 0px;
overflow: hidden;
}
.el-calendar-table__row {
.next {
pointer-events: none;
}
.prev {
pointer-events: none;
}
}
.el-calendar-table .el-calendar-day:hover {
background-color: #ffffff00;
}
.el-calendar-table td.is-selected {
background-color: #ffffff00;
}
}
// /*calendar_class 是el-calendar所在父标签的css*/
// .calendar_class >>> .el-calendar-table:not(.is-range) td.next {
// pointer-events: none;
// }
// .calendar_class >>> .el-calendar-table:not(.is-range) td.prev {
// pointer-events: none;
// }
</style>

View File

@@ -0,0 +1,393 @@
<template>
<div>
<!--指标越限概率分布 -->
<my-echart
class="tall"
:options="echartList"
:style="{ width: prop.width, height: `calc(${prop.height} / 2 )` }"
/>
<my-echart
class="mt10"
:options="echartList1"
:style="{ width: prop.width, height: `calc(${prop.height} / 2 - 10px)` }"
/>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import MyEchart from '@/components/echarts/MyEchart.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTimeOfTheMonth } from '@/utils/formatTime'
const prop = defineProps({
width: { type: String },
height: { type: String },
timeKey: { type: String },
timeValue: { type: Object }
})
const echartList = ref({
options: {
xAxis: null,
yAxis: null,
dataZoom: null,
backgroundColor: '#fff',
tooltip: {
// trigger: 'axis'
textStyle: {
color: '#fff',
fontStyle: 'normal',
opacity: 0.35,
fontSize: 14
},
backgroundColor: 'rgba(0,0,0,0.55)',
borderWidth: 0,
formatter: function (params: any) {
console.log(params)
var tips = ''
for (var i = 0; i < params.length; i++) {
tips += params[i].name + '</br/>'
tips += '监测点数' + ':' + '&nbsp' + '&nbsp' + params[i].value + '</br/>'
}
return tips
}
},
title: {
text: '指标越限概率分布',
x: 'center'
},
visualMap: {
max: 20,
show: false,
inRange: {
color: ['#313695', '#00BB00', '#ff8000', '#a50026']
}
},
xAxis3D: {
type: 'category',
name: '指标越限',
data: ['0-10', '10-20', '20-30', '30-40', '40-50'],
axisLine: {
lineStyle: {
color: '#111'
}
},
axisLabel: {
color: '#111'
}
},
yAxis3D: {
type: 'category',
name: '指标类型',
data: ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡'],
nameTextStyle: {
color: '#111'
},
axisLine: {
show: true,
lineStyle: {
color: '#111'
}
},
axisLabel: {
color: '#111'
},
splitLine: {
lineStyle: {
// 使用深浅的间隔色
color: ['#111'],
type: 'dashed',
opacity: 0.5
}
}
},
zAxis3D: {
type: 'value',
splitNumber: 10,
minInterval: 10,
name: '越限占比'
},
grid3D: {
viewControl: {
projection: 'perspective',
distance: 250
},
boxWidth: 200,
boxDepth: 80,
light: {
main: {
intensity: 1.2
},
ambient: {
intensity: 0.3
}
}
},
series: [
{
type: 'bar3D',
data: [
[0, 0, 1],
[0, 1, 1],
[0.2, 1]
],
shading: 'realistic',
label: {
show: false,
textStyle: {
fontSize: 16,
borderWidth: 1
}
},
itemStyle: {
opacity: 1
},
emphasis: {
label: {
textStyle: {
fontSize: 20,
color: '#900'
}
},
itemStyle: {
color: '#900'
}
}
}
]
}
})
const echartList1 = ref({
title: {
text: '越限时间概率分布'
},
xAxis: {
// name: '时间',
// data: ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡']
type: 'time',
axisLabel: {
formatter: {
day: '{MM}-{dd}',
month: '{MM}',
year: '{yyyy}'
}
}
},
yAxis: {
name: '次' // 给X轴加单位
},
grid: {
left: '10px',
right: '20px'
},
options: {
series: [
{
type: 'line',
showSymbol: false,
// smooth: true,
name: '闪变',
data: [
['2025-10-16 07:00:00', 10],
['2025-10-16 07:15:00', 10],
['2025-10-16 07:30:00', 10],
['2025-10-16 07:45:00', 10],
['2025-10-16 08:00:00', 30],
['2025-10-16 08:15:00', 50],
['2025-10-16 08:30:00', 60],
['2025-10-16 08:45:00', 70],
['2025-10-16 09:00:00', 100],
['2025-10-16 09:15:00', 120],
['2025-10-16 09:30:00', 130],
['2025-10-16 09:45:00', 140],
['2025-10-16 10:00:00', 160],
['2025-10-16 10:15:00', 160],
['2025-10-16 10:30:00', 130],
['2025-10-16 10:45:00', 120],
['2025-10-16 11:00:00', 140],
['2025-10-16 11:15:00', 80],
['2025-10-16 11:30:00', 70],
['2025-10-16 11:45:00', 90],
['2025-10-16 12:00:00', 60],
['2025-10-16 12:15:00', 60],
['2025-10-16 12:30:00', 60],
['2025-10-16 12:45:00', 60]
]
},
{
type: 'line',
showSymbol: false,
// smooth: true,
name: '谐波电压',
data: [
['2025-10-16 07:00:00', 1],
['2025-10-16 07:15:00', 1],
['2025-10-16 07:30:00', 1],
['2025-10-16 07:45:00', 1],
['2025-10-16 08:00:00', 3],
['2025-10-16 08:15:00', 5],
['2025-10-16 08:30:00', 6],
['2025-10-16 08:45:00', 7],
['2025-10-16 09:00:00', 10],
['2025-10-16 09:15:00', 12],
['2025-10-16 09:30:00', 13],
['2025-10-16 09:45:00', 14],
['2025-10-16 10:00:00', 16],
['2025-10-16 10:15:00', 16],
['2025-10-16 10:30:00', 13],
['2025-10-16 10:45:00', 12],
['2025-10-16 11:00:00', 14],
['2025-10-16 11:15:00', 8],
['2025-10-16 11:30:00', 7],
['2025-10-16 11:45:00', 9],
['2025-10-16 12:00:00', 6],
['2025-10-16 12:15:00', 6],
['2025-10-16 12:30:00', 6],
['2025-10-16 12:45:00', 6]
]
},
{
type: 'line',
showSymbol: false,
// smooth: true,
name: '谐波电流',
data: [
['2025-10-16 07:00:00', 19],
['2025-10-16 07:15:00', 19],
['2025-10-16 07:30:00', 19],
['2025-10-16 07:45:00', 19],
['2025-10-16 08:00:00', 39],
['2025-10-16 08:15:00', 59],
['2025-10-16 08:30:00', 69],
['2025-10-16 08:45:00', 79],
['2025-10-16 09:00:00', 109],
['2025-10-16 09:15:00', 129],
['2025-10-16 09:30:00', 139],
['2025-10-16 09:45:00', 149],
['2025-10-16 10:00:00', 169],
['2025-10-16 10:15:00', 169],
['2025-10-16 10:30:00', 139],
['2025-10-16 10:45:00', 129],
['2025-10-16 11:00:00', 149],
['2025-10-16 11:15:00', 89],
['2025-10-16 11:30:00', 79],
['2025-10-16 11:45:00', 99],
['2025-10-16 12:00:00', 69],
['2025-10-16 12:15:00', 69],
['2025-10-16 12:30:00', 69],
['2025-10-16 12:45:00', 69]
]
},
{
type: 'line',
showSymbol: false,
// smooth: true,
name: '电压偏差',
data: [
['2025-10-16 07:00:00', 12],
['2025-10-16 07:15:00', 12],
['2025-10-16 07:30:00', 12],
['2025-10-16 07:45:00', 12],
['2025-10-16 08:00:00', 32],
['2025-10-16 08:15:00', 52],
['2025-10-16 08:30:00', 62],
['2025-10-16 08:45:00', 72],
['2025-10-16 09:00:00', 112],
['2025-10-16 09:15:00', 122],
['2025-10-16 09:30:00', 122],
['2025-10-16 09:45:00', 152],
['2025-10-16 10:00:00', 122],
['2025-10-16 10:15:00', 112],
['2025-10-16 10:30:00', 132],
['2025-10-16 10:45:00', 122],
['2025-10-16 11:00:00', 142],
['2025-10-16 11:15:00', 82],
['2025-10-16 11:30:00', 72],
['2025-10-16 11:45:00', 92],
['2025-10-16 12:00:00', 62],
['2025-10-16 12:15:00', 62],
['2025-10-16 12:30:00', 62],
['2025-10-16 12:45:00', 62]
]
},
{
type: 'line',
showSymbol: false,
// smooth: true,
name: '三相不平衡',
data: [
['2025-10-16 07:00:00', 10],
['2025-10-16 07:15:00', 10],
['2025-10-16 07:30:00', 10],
['2025-10-16 07:45:00', 10],
['2025-10-16 08:00:00', 30],
['2025-10-16 08:15:00', 50],
['2025-10-16 08:30:00', 60],
['2025-10-16 08:45:00', 70],
['2025-10-16 09:00:00', 100],
['2025-10-16 09:15:00', 120],
['2025-10-16 09:30:00', 130],
['2025-10-16 09:45:00', 140],
['2025-10-16 10:00:00', 160],
['2025-10-16 10:15:00', 160],
['2025-10-16 10:30:00', 130],
['2025-10-16 10:45:00', 120],
['2025-10-16 11:00:00', 140],
['2025-10-16 11:15:00', 80],
['2025-10-16 11:30:00', 70],
['2025-10-16 11:45:00', 90],
['2025-10-16 12:00:00', 60],
['2025-10-16 12:15:00', 60],
['2025-10-16 12:30:00', 60],
['2025-10-16 12:45:00', 60]
]
}
]
}
})
const tableStore: any = new TableStore({
url: '/user-boot/dept/deptTree',
method: 'POST',
showPage: false,
column: [],
beforeSearchFun: () => {
tableStore.table.params.searchBeginTime = prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
},
loadCallback: () => {
tableStore.table.data = []
}
})
const tableRef = ref()
provide('tableRef', tableRef)
provide('tableStore', tableStore)
onMounted(() => {
tableStore.index()
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
(newVal, oldVal) => {
tableStore.index()
},
{
deep: true // 若 timeValue 是对象/数组,需开启深度监听
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,145 @@
<template>
<div>
<!--主要监测点列表 -->
<TableHeader :showReset="false" >
<template v-slot:select>
<el-form-item label="关键词">
<el-input v-model="tableStore.table.params.searchValue" clearable placeholder="请输关键字" />
</el-form-item>
</template>
</TableHeader>
<Table ref="tableRef" @cell-click="cellClickEvent" :height="`calc(${prop.height} - 58px)`"></Table>
<!-- 指标越限详情 -->
<OverLimitDetails ref="OverLimitDetailsRef" />
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTimeOfTheMonth } from '@/utils/formatTime'
import { ElTag } from 'element-plus'
import OverLimitDetails from '@/components/cockpit/listOfMainMonitoringPoints/components/overLimitDetails.vue'
const prop = defineProps({
width: { type: String },
height: { type: String },
timeKey: { type: String },
timeValue: { type: Object }
})
const dictData = useDictData()
const OverLimitDetailsRef = ref()
const tableStore: any = new TableStore({
url: '/user-boot/role/selectRoleDetail?id=0',
method: 'POST',
showPage: false,
exportName: '主要监测点列表',
column: [
{
field: 'index',
title: '序号',
width: '80',
formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
}
},
{
title: '监测点名称',
field: 'name',
minWidth: '90',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.name}</span>`
}
},
{
title: '监测对象类型',
field: 'type',
minWidth: '90'
},
{
title: '是否治理',
field: 'whetherToGovern',
minWidth: '70'
},
{ title: '主要存在的电能质量问题', field: 'question', minWidth: '150' }
],
beforeSearchFun: () => {
tableStore.table.params.searchBeginTime = prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
},
loadCallback: () => {
tableStore.table.data = [
{
name: '10kV1#电动机',
type: '电动机',
whetherToGovern: '否',
question: '3次谐波电压、5次谐波电流、电压不平衡度超标'
},
{
name: '10kV2#(治理后)',
type: '电焊机',
whetherToGovern: '100A APF',
question: '所有指标均合格'
},
{
name: '380V电焊机(治理前)',
type: '电焊机',
whetherToGovern: '100A APF',
question: '5次谐波电流、电压不平衡度超标'
},
{
name: '380V水泵机',
type: '电动机',
whetherToGovern: '否',
question: '所有指标均合格'
}
]
tableStore.table.height = `calc(${prop.height} - 80px)`
}
})
const tableRef = ref()
provide('tableRef', tableRef)
tableStore.table.params.type = ''
tableStore.table.params.searchValue = ''
provide('tableStore', tableStore)
// 点击行
const cellClickEvent = ({ row, column }: any) => {
if (column.field == 'name') {
console.log(row)
OverLimitDetailsRef.value.open(row)
}
}
onMounted(() => {
tableStore.index()
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
(newVal, oldVal) => {
tableStore.index()
},
{
deep: true // 若 timeValue 是对象/数组,需开启深度监听
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,134 @@
<template>
<!-- 综合评估详情 -->
<el-dialog draggable title="指标合格率统计" v-model="dialogVisible" append-to-body width="70%">
<TableHeader datePicker showExport :showReset="false">
<template v-slot:select>
<el-form-item label="监测点名称">
<el-select
v-model="tableStore.table.params.searchValue"
placeholder="请选择监测点名称"
style="width: 240px"
>
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
</template>
</TableHeader>
<Table ref="tableRef" isGroup :height="height"></Table>
</el-dialog>
</template>
<script setup lang="ts">
import { ref, provide } from 'vue'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import TableStore from '@/utils/tableStore'
import { mainHeight } from '@/utils/layout'
const dialogVisible: any = ref(false)
const options = [
{
value: '35kV进线',
label: '35kV进线'
}
]
const height = mainHeight(0, 2).height as any
const loop50 = (key: string) => {
let list: any[] = []
for (let i = 2; i < 51; i++) {
list.push({
title: i + '次',
// field: key + i,
field: 'flicker',
width: '80'
})
}
return list
}
const tableStore: any = new TableStore({
url: '/user-boot/role/selectRoleDetail?id=0',
method: 'POST',
publicHeight: 30,
showPage: false,
exportName: '主要监测点列表',
column: [
{
field: 'index',
title: '序号',
width: '80',
formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
}
},
{
title: '日期',
field: 'time',
width: '150'
},
{
title: '名称',
field: 'name',
width: '150'
},
{
title: '闪变越限(分钟)',
field: 'flicker',
width: '80'
},
{
title: '谐波电压越限(分钟)',
children: loop50('voltage')
},
{
title: '谐波电流越限(分钟)',
children: loop50('harmonicCurrent')
},
{
title: '三相不平衡度越限(分钟)',
field: 'flicker',
width: '100'
},
{
title: '电压偏差越限(分钟)',
field: 'flicker',
width: '100'
},
{
title: '频率偏差越限(分钟)',
field: 'flicker',
width: '100'
}
],
beforeSearchFun: () => {},
loadCallback: () => {
tableStore.table.data = [
{
time: '2024-01-01 00:00:00',
name: '35kV进线',
flicker: '0',
},
{
time: '2024-01-01 00:00:00',
name: '35kV进线',
flicker: '0',
},
{
time: '2024-01-01 00:00:00',
name: '35kV进线',
flicker: '0',
},
]
}
})
tableStore.table.params.searchValue = ''
provide('tableStore', tableStore)
const open = async (row: any) => {
dialogVisible.value = true
tableStore.index()
}
defineExpose({ open })
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,271 @@
<template>
<div>
<!--指标拟合图 -->
<TableHeader :showReset="false" @selectChange="selectChange">
<template v-slot:select>
<el-form-item label="用户功率">
<el-select
v-model="tableStore.table.params.power"
placeholder="请选择用户功率"
clearable
style="width: 130px"
>
<el-option
v-for="item in powerList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="电能质量指标">
<el-select
v-model="tableStore.table.params.indicator"
placeholder="请选择电能质量指标"
clearable
style="width: 130px"
>
<el-option
v-for="item in indicatorList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="越限情况">
<el-select
v-model="tableStore.table.params.exceedingTheLimit"
placeholder="请选择越限情况"
clearable
style="width: 90px"
>
<el-option
v-for="item in exceedingTheLimitList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</template>
</TableHeader>
<my-echart
class="tall"
:options="echartList"
:style="{ width: prop.width, height: `calc(${prop.height} - ${headerHeight}px )` }"
/>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTimeOfTheMonth } from '@/utils/formatTime'
import MyEchart from '@/components/echarts/MyEchart.vue'
import { useConfig } from '@/stores/config'
const prop = defineProps({
width: { type: String },
height: { type: String },
timeKey: { type: String },
timeValue: { type: Object }
})
const config = useConfig()
const powerList: any = ref([
{
label: '三相总有功功率',
value: '1'
},
{
label: '三相总无功功率',
value: '2'
}
])
const exceedingTheLimitList: any = ref([
{
label: '越限',
value: '1'
},
{
label: '不越限',
value: '0'
}
])
const indicatorList: any = ref([
{
label: '谐波电压总畸变率',
value: '1'
},
{
label: '各次谐波电压',
value: '2'
},
{
label: '各次谐波电压',
value: '3'
},
{
label: '三相电压不平衡',
value: '4'
}
])
const echartList = ref({
title: {
text: '谐波电压总畸变率越限与功率负荷曲线拟合图'
},
xAxis: {
type: 'time',
axisLabel: {
formatter: {
day: '{MM}-{dd}',
month: '{MM}',
year: '{yyyy}'
}
}
},
yAxis: [{}, {}],
grid: {
left: '10px',
right: '20px'
},
options: {
series: [
{
// name: '暂降次数',
type: 'bar',
name: '有功功率',
data: [
['2025-10-16 07:00:00', 10],
['2025-10-16 07:15:00', 10],
['2025-10-16 07:30:00', 10],
['2025-10-16 07:45:00', 10],
['2025-10-16 08:00:00', 30],
['2025-10-16 08:15:00', 50],
['2025-10-16 08:30:00', 60],
['2025-10-16 08:45:00', 70],
['2025-10-16 09:00:00', 100],
['2025-10-16 09:15:00', 120],
['2025-10-16 09:30:00', 130],
['2025-10-16 09:45:00', 140],
['2025-10-16 10:00:00', 160],
['2025-10-16 10:15:00', 160],
['2025-10-16 10:30:00', 130],
['2025-10-16 10:45:00', 120],
['2025-10-16 11:00:00', 140],
['2025-10-16 11:15:00', 80],
['2025-10-16 11:30:00', 70],
['2025-10-16 11:45:00', 90],
['2025-10-16 12:00:00', 60],
['2025-10-16 12:15:00', 60],
['2025-10-16 12:30:00', 60],
['2025-10-16 12:45:00', 60]
],
itemStyle: {
normal: {
//这里是颜色
color: function (params: any) {
if (params.value[1] == 0 || params.value[1] == 3.14159) {
return '#ccc'
} else {
return config.layout.elementUiPrimary[0]
}
}
}
},
yAxisIndex: 0
},
{
name: '谐波总畸变率',
type: 'line',
showSymbol: false,
smooth: true,
data: [
['2025-10-16 07:00:00', 0],
['2025-10-16 07:15:00', 0],
['2025-10-16 07:30:00', 0],
['2025-10-16 07:45:00', 0],
['2025-10-16 08:00:00', 0],
['2025-10-16 08:15:00', 0.1],
['2025-10-16 08:30:00', 0.1],
['2025-10-16 08:45:00', 0.1],
['2025-10-16 09:00:00', 1],
['2025-10-16 09:15:00', 1],
['2025-10-16 09:30:00', 1],
['2025-10-16 09:45:00', 1],
['2025-10-16 10:00:00', 0.8],
['2025-10-16 10:15:00', 0.8],
['2025-10-16 10:30:00', 0.8],
['2025-10-16 10:45:00', 0.8],
['2025-10-16 11:00:00', 0.8],
['2025-10-16 11:15:00', 0.1],
['2025-10-16 11:30:00', 0.1],
['2025-10-16 11:45:00', 0.1],
['2025-10-16 12:00:00', 0],
['2025-10-16 12:15:00', 0],
['2025-10-16 12:30:00', 0],
['2025-10-16 12:45:00', 0]
],
yAxisIndex: 1
}
]
}
})
const headerHeight = ref(57)
const selectChange = (showSelect: any, height: any) => {
headerHeight.value = height
}
const tableStore: any = new TableStore({
url: '/user-boot/role/selectRoleDetail?id=0',
method: 'POST',
showPage: false,
exportName: '主要监测点列表',
column: [],
beforeSearchFun: () => {
tableStore.table.params.searchBeginTime = prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
},
loadCallback: () => {
tableStore.table.height = `calc(${prop.height} - 80px)`
}
})
const tableRef = ref()
provide('tableRef', tableRef)
tableStore.table.params.power = '1'
tableStore.table.params.indicator = '1'
tableStore.table.params.exceedingTheLimit = '1'
tableStore.table.params.searchValue = ''
provide('tableStore', tableStore)
onMounted(() => {
tableStore.index()
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
(newVal, oldVal) => {
tableStore.index()
},
{
deep: true // 若 timeValue 是对象/数组,需开启深度监听
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped>
:deep(.el-select) {
min-width: 80px;
}
</style>

View File

@@ -0,0 +1,169 @@
<template>
<div>
<!--监测点列表 -->
<Table ref="tableRef" @cell-click="cellClickEvent" :height="`calc(${prop.height} )`"></Table>
<!-- 指标越限详情 -->
<OverLimitDetails ref="OverLimitDetailsRef" />
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTimeOfTheMonth } from '@/utils/formatTime'
import { ElTag } from 'element-plus'
import OverLimitDetails from '@/components/cockpit/listOfMainMonitoringPoints/components/overLimitDetails.vue'
const prop = defineProps({
width: { type: String },
height: { type: String },
timeKey: { type: String },
timeValue: { type: Object }
})
const dictData = useDictData()
const OverLimitDetailsRef = ref()
const tableStore: any = new TableStore({
url: '/user-boot/role/selectRoleDetail?id=0',
method: 'POST',
showPage: false,
exportName: '主要监测点列表',
column: [
{
field: 'index',
title: '序号',
width: '80',
formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
}
},
{
title: '治理对象名称',
field: 'name',
minWidth: '80'
},
{
title: '电压等级',
field: 'type',
minWidth: '70'
},
{
title: '治理设备详情',
field: 'type1',
minWidth: '70'
},
{
title: '治理前报告',
field: 'type2',
minWidth: '80',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.type2}</span>`
}
},
{ title: '监测点名称', field: 'type3', minWidth: '70' },
{ title: '监测类型', field: 'type4', minWidth: '60' },
{
title: '监测点状态',
field: 'type5',
minWidth: '60',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='color: ${row.type5 === '中断' ? '#FF0000' : ''}'>${row.type5}</span>`
}
},
{ title: '最新数据时间', field: 'type6', minWidth: '140' }
],
beforeSearchFun: () => {
tableStore.table.params.searchBeginTime = prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
},
loadCallback: () => {
tableStore.table.data = [
{
name: '1#变压器',
type: '0.38kV',
type1: '250A APF',
type2: '报告.doc',
type3: '1#变压器 电网侧',
type4: '电网侧',
type5: '运行',
type6: '2025-04-11 18:16:00'
},
{
name: '1#变压器',
type: '0.38kV',
type1: '250A APF',
type2: '报告.doc',
type3: '1#变压器 负载侧',
type4: '负载侧',
type5: '运行',
type6: '2025-04-11 18:16:00'
},
{
name: '2#变压器',
type: '0.38kV',
type1: '100A SVG',
type2: '/',
type3: '1#变压器 电网侧',
type4: '电网侧',
type5: '运行',
type6: '2025-04-11 18:16:00'
},
{
name: '2#变压器',
type: '0.38kV',
type1: '100A SVG',
type2: '/',
type3: '1#变压器 负载侧',
type4: '负载侧',
type5: '中断',
type6: '2025-04-11 18:16:00'
}
]
tableStore.table.height = `calc(${prop.height} - 80px)`
}
})
const tableRef = ref()
provide('tableRef', tableRef)
tableStore.table.params.type = ''
tableStore.table.params.searchValue = ''
provide('tableStore', tableStore)
// 点击行
const cellClickEvent = ({ row, column }: any) => {
if (column.field == 'name') {
console.log(row)
OverLimitDetailsRef.value.open(row)
}
}
onMounted(() => {
tableStore.index()
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
(newVal, oldVal) => {
tableStore.index()
},
{
deep: true // 若 timeValue 是对象/数组,需开启深度监听
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,196 @@
<template>
<div>
<!--总体指标越限统计 -->
<my-echart
class="tall"
:options="echartList"
:style="{ width: prop.width, height: `calc(${prop.height} / 2 )` }"
/>
<Table ref="tableRef" @cell-click="cellClickEvent" :height="`calc(${prop.height} / 2 )`" isGroup></Table>
<!-- 指标越限详情 -->
<OverLimitDetails ref="OverLimitDetailsRef" />
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import MyEchart from '@/components/echarts/MyEchart.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTimeOfTheMonth } from '@/utils/formatTime'
import OverLimitDetails from '@/components/cockpit/listOfMainMonitoringPoints/components/overLimitDetails.vue'
const prop = defineProps({
width: { type: String },
height: { type: String },
timeKey: { type: String },
timeValue: { type: Object }
})
const echartList = ref({
title: {
text: '指标越限占比'
},
xAxis: {
// name: '(区域)',
data: ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡']
},
yAxis: {
name: '%', // 给X轴加单位
interval: 20
},
grid: {
left: '10px',
right: '20px'
},
options: {
series: [
{
// name: '暂降次数',
type: 'bar',
name: '越限占比',
data: [0, 45, 22, 0, 70],
barMaxWidth: 30,
// label: {
// show: true,
// position: 'top',
// textStyle: {
// //数值样式
// color: '#000'
// },
// fontSize: 12
// }
}
]
}
})
const OverLimitDetailsRef = ref()
const tableStore: any = new TableStore({
url: '/user-boot/dept/deptTree',
method: 'POST',
showPage: false,
column: [
{
field: 'index',
title: '序号',
width: '80',
formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
}
},
{
title: '名称',
field: 'name',
minWidth: '90'
},
{
title: '越限占比(%)',
children: [
{
title: '闪变',
field: 'type',
minWidth: '70',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.type}</span>`
}
},
{
title: '谐波电压',
field: 'type1',
minWidth: '80',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.type1}</span>`
}
},
{
title: '谐波电流',
field: 'type2',
minWidth: '80',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.type2}</span>`
}
},
{
title: '电压偏差',
field: 'type3',
minWidth: '80',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.type3}</span>`
}
},
{
title: '三相不平衡',
field: 'type4',
minWidth: '90',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.type4}</span>`
}
}
]
}
],
beforeSearchFun: () => {
tableStore.table.params.searchBeginTime = prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
},
loadCallback: () => {
tableStore.table.data = [
{
name: '10kV1#电动机',
type: '0',
type1: '45',
type2: '22',
type3: '0',
type4: '70'
}
]
tableStore.table.height = `calc(${prop.height} - 80px)`
}
})
const tableRef = ref()
provide('tableRef', tableRef)
provide('tableStore', tableStore)
// 点击行
const cellClickEvent = ({ row, column }: any) => {
if (column.field != 'name') {
console.log(row)
OverLimitDetailsRef.value.open(row)
}
}
onMounted(() => {
tableStore.index()
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
(newVal, oldVal) => {
tableStore.index()
},
{
deep: true // 若 timeValue 是对象/数组,需开启深度监听
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,119 @@
<template>
<div>
<!--敏感负荷列表 -->
<Table ref="tableRef" @cell-click="cellClickEvent" :height="`calc(${prop.height})`" isGroup></Table>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import MyEchart from '@/components/echarts/MyEchart.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTimeOfTheMonth } from '@/utils/formatTime'
const prop = defineProps({
width: { type: String },
height: { type: String },
timeKey: { type: String },
timeValue: { type: Object }
})
const OverLimitDetailsRef = ref()
const tableStore: any = new TableStore({
url: '/user-boot/dept/deptTree',
method: 'POST',
showPage: false,
column: [
{
field: 'index',
title: '序号',
width: '80',
formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
}
},
{
title: '敏感负荷名称',
field: 'name',
minWidth: '90'
},
{
title: '敏感负荷类型',
field: 'type',
minWidth: '70'
},
{
title: '是否监测',
field: 'type1',
minWidth: '80'
},
{
title: '是否治理',
field: 'type2',
minWidth: '80'
}
],
beforeSearchFun: () => {
tableStore.table.params.searchBeginTime = prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
},
loadCallback: () => {
tableStore.table.data = [
{
name: '10kV1#变压器',
type: '机房',
type1: '是',
type2: '100A APF'
},
{
name: '380kV1#母线',
type: 'PLC',
type1: '是',
type2: 'UPS'
}
]
}
})
const tableRef = ref()
provide('tableRef', tableRef)
provide('tableStore', tableStore)
// 点击行
const cellClickEvent = ({ row, column }: any) => {
if (column.field != 'name') {
console.log(row)
OverLimitDetailsRef.value.open(row)
}
}
onMounted(() => {
setTimeout(() => {
tableStore.index()
}, 500)
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
(newVal, oldVal) => {
tableStore.index()
},
{
deep: true // 若 timeValue 是对象/数组,需开启深度监听
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,199 @@
<template>
<div>
<!--暂态事件明细 -->
<el-calendar v-model="value" :style="{ height: prop.height, overflow: 'auto' }">
<template #date-cell="{ data }">
<div style="height: 100%; padding: 8px" :style="{ background: setBackground(data.day) }">
<p :class="data.isSelected ? 'is-selected' : ''">
{{ data.day.split('-').slice(2).join('-') }}
</p>
<el-tooltip
effect="dark"
placement="top"
:hide-after="0"
v-if="list?.filter(item => item.time == data.day)[0]?.type || false"
>
<template #content>
<!-- <span v-html="list?.filter(item => item.time == data.day)[0]?.type || ''"></span> -->
<div v-for="item in list?.filter(item => item.time == data.day)">
<div>电压暂降{{ item.type || '' }}</div>
<div>电压中断{{ item.type1 || '' }}</div>
<div>电压暂升{{ item.type2 || '' }}</div>
</div>
</template>
<div
:style="{ height: `calc(${prop.height} / 5 - 47px)`, overflow: 'auto' }"
v-for="item in list?.filter(item => item.time == data.day)"
>
<div>电压暂降:{{ item.type || '' }}</div>
<div>电压中断:{{ item.type1 || '' }}</div>
<div>电压暂升:{{ item.type2 || '' }}</div>
</div>
</el-tooltip>
</div>
</template>
</el-calendar>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTimeOfTheMonth } from '@/utils/formatTime'
import { overflow } from 'html2canvas/dist/types/css/property-descriptors/overflow'
import { dayjs } from 'element-plus'
dayjs.en.weekStart = 1 //设置日历的周起始日为星期一
const value = ref(new Date())
const prop = defineProps({
width: { type: String },
height: { type: String },
timeKey: { type: String },
timeValue: { type: Object }
})
const list = ref([
{
time: '2025-10-01',
key: 81,
type: 1,
type1: 1,
type2: 1
},
{
time: '2025-10-31',
key: 81,
type: 1,
type1: 1,
type2: 1
},
{
time: '2025-10-08',
key: 20,
type: 1,
type1: 1,
type2: 1
},
{
time: '2025-10-16',
key: 20,
type: 1,
type1: 1,
type2: 1
},
{
time: '2025-10-23',
key: 20,
type: 1,
type1: 1,
type2: 1
},
{
time: '2025-10-04',
key: 0
},
{
time: '2025-10-05',
key: 0
}
])
const tableStore: any = new TableStore({
url: '/user-boot/dept/deptTree',
method: 'POST',
showPage: false,
column: [],
beforeSearchFun: () => {
tableStore.table.params.searchBeginTime = prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
// value.value = new Date(prop.timeValue?.[0])
},
loadCallback: () => {
tableStore.table.data = []
}
})
const tableRef = ref([])
const setBackground = (value: string) => {
let data = []
data = list.value?.filter(item => item.time == value)
if (data && data?.length > 0) {
if (data[0].key > 0) {
return '#Ff660090'
}
}
return '#fff'
}
provide('tableRef', tableRef)
provide('tableStore', tableStore)
onMounted(() => {
tableStore.index()
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
(newVal, oldVal) => {
tableStore.index()
},
{
deep: true // 若 timeValue 是对象/数组,需开启深度监听
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped>
:deep(.el-calendar) {
.el-calendar__header {
display: none;
}
.el-calendar__body {
padding: 0px !important;
height: 100%;
.el-calendar-table {
height: 100%;
}
}
.el-calendar-day {
height: 100%;
padding: 0px;
overflow: hidden;
}
.el-calendar-table__row {
.next {
pointer-events: none;
}
.prev {
pointer-events: none;
}
}
.el-calendar-table .el-calendar-day:hover {
background-color: #ffffff00;
}
.el-calendar-table td.is-selected {
background-color: #ffffff00;
}
}
// /*calendar_class 是el-calendar所在父标签的css*/
// .calendar_class >>> .el-calendar-table:not(.is-range) td.next {
// pointer-events: none;
// }
// .calendar_class >>> .el-calendar-table:not(.is-range) td.prev {
// pointer-events: none;
// }
</style>

View File

@@ -0,0 +1,345 @@
<template>
<div>
<!--暂态事件概率分布 -->
<my-echart
class="tall"
:options="echartList"
:style="{ width: prop.width, height: `calc(${prop.height} / 2 )` }"
/>
<my-echart
class="mt10"
:options="echartList1"
:style="{ width: prop.width, height: `calc(${prop.height} / 2 - 10px)` }"
/>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import MyEchart from '@/components/echarts/MyEchart.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTimeOfTheMonth } from '@/utils/formatTime'
import { useConfig } from '@/stores/config'
const config = useConfig()
const prop = defineProps({
width: { type: String },
height: { type: String },
timeKey: { type: String },
timeValue: { type: Object }
})
const echartList = ref({
options: {
xAxis: null,
yAxis: null,
dataZoom: null,
backgroundColor: '#fff',
tooltip: {
// trigger: 'axis'
textStyle: {
color: '#fff',
fontStyle: 'normal',
opacity: 0.35,
fontSize: 14
},
backgroundColor: 'rgba(0,0,0,0.55)',
borderWidth: 0,
formatter: function (params: any) {
console.log(params)
var tips = ''
for (var i = 0; i < params.length; i++) {
tips += params[i].name + '</br/>'
tips += '监测点数' + ':' + '&nbsp' + '&nbsp' + params[i].value + '</br/>'
}
return tips
}
},
title: {
text: '暂态事件概率分布',
x: 'center'
},
visualMap: {
max: 20,
show: false,
inRange: {
color: ['#313695', '#00BB00', '#ff8000', '#a50026']
}
},
xAxis3D: {
type: 'category',
name: '特征幅值',
data: [
'0-10%',
'10%-20%',
'20%-30%',
'30%-40%',
'40%-50%',
'50%-60%',
'60%-70%',
'70%-80%',
'80%-90%',
'90%-100%'
],
axisLine: {
lineStyle: {
color: '#111'
}
},
axisLabel: {
color: '#111'
}
},
yAxis3D: {
type: 'category',
name: '持续时间',
data: ['0-0.01s', '0.01s-0.1s', '0.1s-1s', '1s-10s', '10s'],
nameTextStyle: {
color: '#111'
},
axisLine: {
show: true,
lineStyle: {
color: '#111'
}
},
axisLabel: {
color: '#111'
},
splitLine: {
lineStyle: {
// 使用深浅的间隔色
color: ['#111'],
type: 'dashed',
opacity: 0.5
}
}
},
zAxis3D: {
type: 'value',
splitNumber: 10,
minInterval: 10,
name: '暂态事件次数'
},
grid3D: {
viewControl: {
projection: 'perspective',
distance: 250
},
boxWidth: 200,
boxDepth: 80,
light: {
main: {
intensity: 1.2
},
ambient: {
intensity: 0.3
}
}
},
series: [
{
type: 'bar3D',
data: [
[0, 0, 1],
[0, 1, 1],
[0.2, 1]
],
shading: 'realistic',
label: {
show: false,
textStyle: {
fontSize: 16,
borderWidth: 1
}
},
itemStyle: {
opacity: 1
},
emphasis: {
label: {
textStyle: {
fontSize: 20,
color: '#900'
}
},
itemStyle: {
color: '#900'
}
}
}
]
}
})
const echartList1 = ref({
title: {
text: '越限时间概率分布'
},
xAxis: {
// name: '时间',
// data: ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡']
type: 'time',
axisLabel: {
formatter: {
day: '{MM}-{dd}',
month: '{MM}',
year: '{yyyy}'
}
}
},
yAxis: {
name: '次' // 给X轴加单位
},
grid: {
left: '10px',
right: '20px'
},
options: {
series: [
{
type: 'line',
showSymbol: false,
// smooth: true,
name: '电压中断',
color: '#FF9100',
data: [
['2025-10-16 07:00:00', 10],
['2025-10-16 07:15:00', 10],
['2025-10-16 07:30:00', 10],
['2025-10-16 07:45:00', 10],
['2025-10-16 08:00:00', 30],
['2025-10-16 08:15:00', 50],
['2025-10-16 08:30:00', 60],
['2025-10-16 08:45:00', 70],
['2025-10-16 09:00:00', 100],
['2025-10-16 09:15:00', 120],
['2025-10-16 09:30:00', 130],
['2025-10-16 09:45:00', 140],
['2025-10-16 10:00:00', 160],
['2025-10-16 10:15:00', 160],
['2025-10-16 10:30:00', 130],
['2025-10-16 10:45:00', 120],
['2025-10-16 11:00:00', 140],
['2025-10-16 11:15:00', 80],
['2025-10-16 11:30:00', 70],
['2025-10-16 11:45:00', 90],
['2025-10-16 12:00:00', 60],
['2025-10-16 12:15:00', 60],
['2025-10-16 12:30:00', 60],
['2025-10-16 12:45:00', 60]
]
},
{
type: 'line',
showSymbol: false,
// smooth: true,
color: '#FFBF00',
name: '电压暂降',
data: [
['2025-10-16 07:00:00', 1],
['2025-10-16 07:15:00', 1],
['2025-10-16 07:30:00', 1],
['2025-10-16 07:45:00', 1],
['2025-10-16 08:00:00', 3],
['2025-10-16 08:15:00', 5],
['2025-10-16 08:30:00', 6],
['2025-10-16 08:45:00', 7],
['2025-10-16 09:00:00', 10],
['2025-10-16 09:15:00', 12],
['2025-10-16 09:30:00', 13],
['2025-10-16 09:45:00', 14],
['2025-10-16 10:00:00', 16],
['2025-10-16 10:15:00', 16],
['2025-10-16 10:30:00', 13],
['2025-10-16 10:45:00', 12],
['2025-10-16 11:00:00', 14],
['2025-10-16 11:15:00', 8],
['2025-10-16 11:30:00', 7],
['2025-10-16 11:45:00', 9],
['2025-10-16 12:00:00', 6],
['2025-10-16 12:15:00', 6],
['2025-10-16 12:30:00', 6],
['2025-10-16 12:45:00', 6]
]
},
{
type: 'line',
showSymbol: false,
// smooth: true,
name: '电压暂升',
color: config.layout.elementUiPrimary[0],
data: [
['2025-10-16 07:00:00', 19],
['2025-10-16 07:15:00', 19],
['2025-10-16 07:30:00', 19],
['2025-10-16 07:45:00', 19],
['2025-10-16 08:00:00', 39],
['2025-10-16 08:15:00', 59],
['2025-10-16 08:30:00', 69],
['2025-10-16 08:45:00', 79],
['2025-10-16 09:00:00', 109],
['2025-10-16 09:15:00', 129],
['2025-10-16 09:30:00', 139],
['2025-10-16 09:45:00', 149],
['2025-10-16 10:00:00', 169],
['2025-10-16 10:15:00', 169],
['2025-10-16 10:30:00', 139],
['2025-10-16 10:45:00', 129],
['2025-10-16 11:00:00', 149],
['2025-10-16 11:15:00', 89],
['2025-10-16 11:30:00', 79],
['2025-10-16 11:45:00', 99],
['2025-10-16 12:00:00', 69],
['2025-10-16 12:15:00', 69],
['2025-10-16 12:30:00', 69],
['2025-10-16 12:45:00', 69]
]
}
]
}
})
const tableStore: any = new TableStore({
url: '/user-boot/dept/deptTree',
method: 'POST',
showPage: false,
column: [],
beforeSearchFun: () => {
tableStore.table.params.searchBeginTime = prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
},
loadCallback: () => {
tableStore.table.data = []
}
})
const tableRef = ref()
provide('tableRef', tableRef)
provide('tableStore', tableStore)
onMounted(() => {
tableStore.index()
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
(newVal, oldVal) => {
tableStore.index()
},
{
deep: true // 若 timeValue 是对象/数组,需开启深度监听
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,218 @@
<template>
<div>
<!--暂态事件统计 -->
<my-echart
class="tall"
:options="echartList"
:style="{ width: prop.width, height: `calc(${prop.height} / 2 )` }"
/>
<Table ref="tableRef" @cell-click="cellClickEvent" :height="`calc(${prop.height} / 2 )`" isGroup></Table>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import MyEchart from '@/components/echarts/MyEchart.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTimeOfTheMonth } from '@/utils/formatTime'
import { useConfig } from '@/stores/config'
const config = useConfig()
const prop = defineProps({
width: { type: String },
height: { type: String },
timeKey: { type: String },
timeValue: { type: Object }
})
const data = [
{
name: '电压中断',
value: 4
},
{
name: '电压暂降',
value: 41
},
{
name: '电压暂升',
value: 46
}
]
const echartList = ref({
title: {},
tooltip: {
trigger: 'item'
},
legend: {
orient: 'vertical',
top: 'center',
right: '5%',
formatter: function (e: any) {
return e + ' ' + data.filter(item => item.name == e)[0].value + '次'
}
},
xAxis: {
show: false
},
yAxis: {
show: false
},
grid: {
left: '10px',
right: '20px'
},
color: ['#FF9100', '#FFBF00', config.layout.elementUiPrimary[0]],
options: {
dataZoom: null,
title: [
{
text: '暂态事件统计',
left: 'center'
},
{
text: data[0].value + data[1].value + data[2].value + '次',
left: 'center',
top: 'center'
}
],
series: [
{
type: 'pie',
center: 'center',
radius: ['50%', '70%'],
label: {
show: false,
position: 'outside',
textStyle: {
//数值样式
}
},
name: '事件统计',
data: data
}
]
}
})
const OverLimitDetailsRef = ref()
const tableStore: any = new TableStore({
url: '/user-boot/dept/deptTree',
method: 'POST',
showPage: false,
column: [
{
field: 'index',
title: '序号',
width: '80',
formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
}
},
{
title: '名称',
field: 'name',
minWidth: '90'
},
{
title: '电压中断(次)',
field: 'type',
minWidth: '70',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.type}</span>`
}
},
{
title: '电压暂降(次)',
field: 'type1',
minWidth: '80',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.type1}</span>`
}
},
{
title: '电压暂升(次)',
field: 'type2',
minWidth: '80',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.type2}</span>`
}
}
],
beforeSearchFun: () => {
tableStore.table.params.searchBeginTime = prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
},
loadCallback: () => {
tableStore.table.data = [
{
name: '35kV1进线',
type: '2',
type1: '38',
type2: '35'
},
{
name: '35kV1变压器',
type: '2',
type1: '1',
type2: '3'
},
{
name: '35kV1母线',
type: '0',
type1: '1',
type2: '4'
},
{
name: '35kV2母线',
type: '0',
type1: '1',
type2: '4'
}
]
}
})
const tableRef = ref()
provide('tableRef', tableRef)
provide('tableStore', tableStore)
// 点击行
const cellClickEvent = ({ row, column }: any) => {
if (column.field != 'name') {
console.log(row)
OverLimitDetailsRef.value.open(row)
}
}
onMounted(() => {
setTimeout(() => {
tableStore.index()
}, 200)
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
(newVal, oldVal) => {
tableStore.index()
},
{
deep: true // 若 timeValue 是对象/数组,需开启深度监听
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,280 @@
<template>
<div>
<!--趋势对比 -->
<TableHeader :showReset="false" @selectChange="selectChange">
<template v-slot:select>
<el-form-item label="监测点名称">
<el-select
v-model="tableStore.table.params.power"
placeholder="请选择监测点名称"
clearable
style="width: 130px"
>
<el-option
v-for="item in powerList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="电能质量指标">
<el-select
v-model="tableStore.table.params.indicator"
placeholder="请选择电能质量指标"
clearable
style="width: 130px"
>
<el-option
v-for="item in indicatorList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="谐波次数">
<el-select
v-model="tableStore.table.params.exceedingTheLimit"
placeholder="请选择谐波次数"
clearable
style="width: 90px"
>
<el-option
v-for="item in exceedingTheLimitList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</template>
</TableHeader>
<my-echart
class="tall"
:options="echartList"
:style="{ width: prop.width, height: `calc(${prop.height} - ${headerHeight}px )` }"
/>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import { useDictData } from '@/stores/dictData'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getTimeOfTheMonth } from '@/utils/formatTime'
import MyEchart from '@/components/echarts/MyEchart.vue'
import { useConfig } from '@/stores/config'
const prop = defineProps({
width: { type: String },
height: { type: String },
timeKey: { type: String },
timeValue: { type: Object }
})
const config = useConfig()
const powerList: any = ref([
{
label: '1#变压器',
value: '1'
},
{
label: '2#变压器',
value: '2'
}
])
const exceedingTheLimitList: any = ref([
{
label: '2次',
value: '2'
},
{
label: '3次',
value: '3'
},
{
label: '4次',
value: '4'
},
{
label: '5次',
value: '5'
}
])
const indicatorList: any = ref([
{
label: '谐波电压总畸变率',
value: '1'
},
{
label: '各次谐波电压',
value: '2'
},
{
label: '各次谐波电压',
value: '3'
},
{
label: '三相电压不平衡',
value: '4'
}
])
const echartList = ref({
title: {
text: '趋势对比'
},
xAxis: {
type: 'time',
axisLabel: {
formatter: {
day: '{MM}-{dd}',
month: '{MM}',
year: '{yyyy}'
}
}
},
yAxis: {},
grid: {
left: '10px',
right: '20px'
},
options: {
series: [
{
// name: '暂降次数',
type: 'line',
name: '治理前',
showSymbol: false,
smooth: true,
data: [
['2025-10-16 07:00:00', 1],
['2025-10-16 07:15:00', 1],
['2025-10-16 07:30:00', 1],
['2025-10-16 07:45:00', 1],
['2025-10-16 08:00:00', 3],
['2025-10-16 08:15:00', 5],
['2025-10-16 08:30:00', 6],
['2025-10-16 08:45:00', 7],
['2025-10-16 09:00:00', 10],
['2025-10-16 09:15:00', 12],
['2025-10-16 09:30:00', 13],
['2025-10-16 09:45:00', 14],
['2025-10-16 10:00:00', 16],
['2025-10-16 10:15:00', 16],
['2025-10-16 10:30:00', 13],
['2025-10-16 10:45:00', 12],
['2025-10-16 11:00:00', 14],
['2025-10-16 11:15:00', 8],
['2025-10-16 11:30:00', 7],
['2025-10-16 11:45:00', 9],
['2025-10-16 12:00:00', 6],
['2025-10-16 12:15:00', 6],
['2025-10-16 12:30:00', 6],
['2025-10-16 12:45:00', 6]
],
itemStyle: {
normal: {
//这里是颜色
color: function (params: any) {
if (params.value[1] == 0 || params.value[1] == 3.14159) {
return '#ccc'
} else {
return config.layout.elementUiPrimary[0]
}
}
}
},
yAxisIndex: 0
},
{
name: '治理后',
type: 'line',
showSymbol: false,
smooth: true,
data: [
['2025-10-16 07:00:00', 10],
['2025-10-16 07:15:00', 10],
['2025-10-16 07:30:00', 10],
['2025-10-16 07:45:00', 10],
['2025-10-16 08:00:00', 30],
['2025-10-16 08:15:00', 50],
['2025-10-16 08:30:00', 60],
['2025-10-16 08:45:00', 70],
['2025-10-16 09:00:00', 100],
['2025-10-16 09:15:00', 120],
['2025-10-16 09:30:00', 130],
['2025-10-16 09:45:00', 140],
['2025-10-16 10:00:00', 160],
['2025-10-16 10:15:00', 160],
['2025-10-16 10:30:00', 130],
['2025-10-16 10:45:00', 120],
['2025-10-16 11:00:00', 140],
['2025-10-16 11:15:00', 80],
['2025-10-16 11:30:00', 70],
['2025-10-16 11:45:00', 90],
['2025-10-16 12:00:00', 60],
['2025-10-16 12:15:00', 60],
['2025-10-16 12:30:00', 60],
['2025-10-16 12:45:00', 60]
]
}
]
}
})
const headerHeight = ref(57)
const selectChange = (showSelect: any, height: any) => {
headerHeight.value = height
}
const tableStore: any = new TableStore({
url: '/user-boot/role/selectRoleDetail?id=0',
method: 'POST',
showPage: false,
exportName: '主要监测点列表',
column: [],
beforeSearchFun: () => {
tableStore.table.params.searchBeginTime = prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
tableStore.table.params.searchEndTime = prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
},
loadCallback: () => {
tableStore.table.height = `calc(${prop.height} - 80px)`
}
})
const tableRef = ref()
provide('tableRef', tableRef)
tableStore.table.params.power = '1'
tableStore.table.params.indicator = '1'
tableStore.table.params.exceedingTheLimit = '1'
tableStore.table.params.searchValue = ''
provide('tableStore', tableStore)
onMounted(() => {
tableStore.index()
})
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
(newVal, oldVal) => {
tableStore.index()
},
{
deep: true // 若 timeValue 是对象/数组,需开启深度监听
}
)
const addMenu = () => {}
</script>
<style lang="scss" scoped>
:deep(.el-select) {
min-width: 80px;
}
</style>

View File

@@ -1,288 +1,288 @@
<template> <template>
<div class="chart"> <div class="chart">
<div ref="chartRef" class="my-chart" /> <div ref="chartRef" class="my-chart" />
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { onBeforeUnmount, onMounted, ref, defineExpose, watch, nextTick } from 'vue' import { onBeforeUnmount, onMounted, ref, defineExpose, watch, nextTick } from 'vue'
// import echarts from './echarts' // import echarts from './echarts'
import * as echarts from 'echarts' // 全引入 import * as echarts from 'echarts' // 全引入
import 'echarts-gl' import 'echarts-gl'
import 'echarts-liquidfill' import 'echarts-liquidfill'
import 'echarts/lib/component/dataZoom' import 'echarts/lib/component/dataZoom'
import { color, gradeColor3 } from './color' import { color, gradeColor3 } from './color'
import { useConfig } from '@/stores/config' import { useConfig } from '@/stores/config'
// import { nextTick } from 'process' // import { nextTick } from 'process'
const config = useConfig() const config = useConfig()
color[0] = config.layout.elementUiPrimary[0] color[0] = config.layout.elementUiPrimary[0]
const chartRef = ref<HTMLDivElement>() const chartRef = ref<HTMLDivElement>()
const props = defineProps(['options', 'isInterVal', 'pieInterVal']) const props = defineProps(['options', 'isInterVal', 'pieInterVal'])
let chart: echarts.ECharts | any = null let chart: echarts.ECharts | any = null
const resizeHandler = () => { const resizeHandler = () => {
// 不在视野中的时候不进行resize // 不在视野中的时候不进行resize
if (!chartRef.value) return if (!chartRef.value) return
if (chartRef.value.offsetHeight == 0) return if (chartRef.value.offsetHeight == 0) return
chart.getZr().painter.getViewportRoot().style.display = 'none' chart.getZr().painter.getViewportRoot().style.display = 'none'
requestAnimationFrame(() => { requestAnimationFrame(() => {
chart.resize() chart.resize()
chart.getZr().painter.getViewportRoot().style.display = '' chart.getZr().painter.getViewportRoot().style.display = ''
}) })
} }
const initChart = () => { const initChart = () => {
if (!props.isInterVal && !props.pieInterVal) { if (!props.isInterVal && !props.pieInterVal) {
chart?.dispose() chart?.dispose()
} }
// chart?.dispose() // chart?.dispose()
chart = echarts.init(chartRef.value as HTMLDivElement) chart = echarts.init(chartRef.value as HTMLDivElement)
const options = { const options = {
title: { title: {
left: 'center', left: 'center',
// textStyle: { // textStyle: {
color: '#000', color: '#000',
textStyle: { textStyle: {
color: '#000', color: '#000',
fontSize: '18' fontSize: '18'
}, },
// }, // },
...(props.options?.title || null) ...(props.options?.title || null)
}, },
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
textStyle: { textStyle: {
color: '#fff', color: '#fff',
fontStyle: 'normal', fontStyle: 'normal',
opacity: 0.35, opacity: 0.35,
fontSize: 14 fontSize: 14
}, },
backgroundColor: 'rgba(0,0,0,0.55)', backgroundColor: 'rgba(0,0,0,0.55)',
borderWidth: 0, borderWidth: 0,
// confine: true, // confine: true,
...(props.options?.tooltip || null) ...(props.options?.tooltip || null)
}, },
toolbox: { toolbox: {
right: 10, right: 20,
top: 0, top: 15,
feature: { feature: {
saveAsImage: { saveAsImage: {
title: '保存图片' title: '保存图片'
}, },
...(props.options?.toolbox?.featureProps || null) ...(props.options?.toolbox?.featureProps || null)
}, },
// }, // },
...(props.options?.toolbox || null) ...(props.options?.toolbox || null)
}, },
legend: { legend: {
right: 40, right: 50,
top: 10, top: 25,
itemGap: 10, itemGap: 10,
itemStyle: {}, itemStyle: {},
// textStyle: { // textStyle: {
fontSize: 12, fontSize: 12,
// padding: [2, 0, 0, 0], //[上、右、下、左] // padding: [2, 0, 0, 0], //[上、右、下、左]
// }, // },
itemWidth: 15, itemWidth: 15,
itemHeight: 10, itemHeight: 10,
...(props.options?.legend || null) ...(props.options?.legend || null)
}, },
grid: { grid: {
top: '60px', top: '50px',
left: '30px', left: '30px',
right: '70px', right: '70px',
bottom: props.options?.options?.dataZoom === null ? '10px' : '40px', bottom: props.options?.options?.dataZoom === null ? '10px' : '40px',
containLabel: true, containLabel: true,
...(props.options?.grid || null) ...(props.options?.grid || null)
}, },
xAxis: props.options?.xAxis ? handlerXAxis() : null, xAxis: props.options?.xAxis ? handlerXAxis() : null,
yAxis: props.options?.yAxis ? handlerYAxis() : null, yAxis: props.options?.yAxis ? handlerYAxis() : null,
dataZoom: props.options?.dataZoom || [ dataZoom: props.options?.dataZoom || [
{ {
type: 'inside', type: 'inside',
height: 13, height: 13,
start: 0, start: 0,
bottom: '20px', bottom: '20px',
end: 100 end: 100
}, },
{ {
start: 0, start: 0,
height: 13, height: 13,
bottom: '20px', bottom: '20px',
end: 100 end: 100
} }
// { // {
// show: true, // show: true,
// yAxisIndex: 0, // yAxisIndex: 0,
// width: 12, // width: 12,
// handleSize: 8, // handleSize: 8,
// showDataShadow: false, // showDataShadow: false,
// right: 12 // right: 12
// } // }
], ],
color: props.options?.color || color, color: props.options?.color || color,
series: props.options?.series, series: props.options?.series,
...props.options?.options ...props.options?.options
} }
// console.log(options.series,"获取x轴"); // console.log(options.series,"获取x轴");
handlerBar(options) handlerBar(options)
// 处理柱状图 // 处理柱状图
chart.setOption(options, true) chart.setOption(options, true)
chart.group = 'group' chart.group = 'group'
setTimeout(() => { setTimeout(() => {
chart.resize() chart.resize()
}, 0) }, 0)
} }
const handlerBar = (options: any) => { const handlerBar = (options: any) => {
if (Array.isArray(options.series)) { if (Array.isArray(options.series)) {
options.series.forEach((item: any) => { options.series.forEach((item: any) => {
if (item.type === 'bar') { if (item.type === 'bar') {
item.barMinHeight = 10 item.barMinHeight = 5
item.barMaxWidth = 20 item.barMaxWidth = 20
item.itemStyle = Object.assign( item.itemStyle = Object.assign(
{ {
color: (params: any) => { color: (params: any) => {
if (params.value == 0 || params.value == 3.14159) { if (params.value == 0 || params.value == 3.14159) {
return '#ccc' return '#ccc'
} else { } else {
return props.options?.color return props.options?.color
? props.options?.color[params.seriesIndex] ? props.options?.color[params.seriesIndex]
: color[params.seriesIndex] : color[params.seriesIndex]
} }
} }
}, },
item.itemStyle item.itemStyle
) )
} }
}) })
} }
} }
const handlerYAxis = () => { const handlerYAxis = () => {
let temp = { let temp = {
type: 'value', type: 'value',
nameGap: 15, nameGap: 15,
nameTextStyle: { nameTextStyle: {
color: '#000' color: '#000'
}, },
splitNumber: 5, splitNumber: 5,
minInterval: 1, minInterval: 1,
axisLine: { axisLine: {
show: true, show: true,
lineStyle: { lineStyle: {
color: '#000' color: '#000'
} }
}, },
axisLabel: { axisLabel: {
color: '#000', color: '#000',
fontSize: 14, fontSize: 14,
formatter: function (value) { formatter: function (value) {
return parseFloat(value.toFixed(1)) // 格式化显示为一位小数 return parseFloat(value.toFixed(1)) // 格式化显示为一位小数
} }
}, },
splitLine: { splitLine: {
lineStyle: { lineStyle: {
// 使用深浅的间隔色 // 使用深浅的间隔色
color: ['#ccc'], color: ['#ccc'],
type: 'dashed', type: 'dashed',
opacity: 0.5 opacity: 0.5
} }
} }
} }
// props.options?.xAxis 是数组还是对象 // props.options?.xAxis 是数组还是对象
if (Array.isArray(props.options?.yAxis)) { if (Array.isArray(props.options?.yAxis)) {
return props.options?.yAxis.map((item: any) => { return props.options?.yAxis.map((item: any) => {
return { return {
...temp, ...temp,
...item ...item
} }
}) })
} else { } else {
return { return {
...temp, ...temp,
...props.options?.yAxis ...props.options?.yAxis
} }
} }
} }
const handlerXAxis = () => { const handlerXAxis = () => {
let temp = { let temp = {
type: 'category', type: 'category',
axisTick: { show: false }, axisTick: { show: false },
axisLine: { axisLine: {
// lineStyle: { // lineStyle: {
color: '#000' color: '#000'
// } // }
}, },
axisLabel: { axisLabel: {
// textStyle: { // textStyle: {
fontFamily: 'dinproRegular', fontFamily: 'dinproRegular',
color: '#000', color: '#000',
fontSize: '12' fontSize: '12'
// } // }
} }
// boundaryGap: false, // boundaryGap: false,
} }
// props.options?.xAxis 是数组还是对象 // props.options?.xAxis 是数组还是对象
if (Array.isArray(props.options?.xAxis)) { if (Array.isArray(props.options?.xAxis)) {
return props.options?.xAxis.map((item: any) => { return props.options?.xAxis.map((item: any) => {
return { return {
...temp, ...temp,
...item ...item
} }
}) })
} else { } else {
return { return {
...temp, ...temp,
...props.options?.xAxis ...props.options?.xAxis
} }
} }
} }
let throttle: ReturnType<typeof setTimeout> let throttle: ReturnType<typeof setTimeout>
// 动态计算table高度 // 动态计算table高度
const resizeObserver = new ResizeObserver(entries => { const resizeObserver = new ResizeObserver(entries => {
for (const entry of entries) { for (const entry of entries) {
if (throttle) { if (throttle) {
clearTimeout(throttle) clearTimeout(throttle)
} }
throttle = setTimeout(() => { throttle = setTimeout(() => {
resizeHandler() resizeHandler()
}, 100) }, 100)
} }
}) })
onMounted(() => { onMounted(() => {
initChart() initChart()
resizeObserver.observe(chartRef.value!) resizeObserver.observe(chartRef.value!)
}) })
defineExpose({ initChart }) defineExpose({ initChart })
onBeforeUnmount(() => { onBeforeUnmount(() => {
resizeObserver.unobserve(chartRef.value!) resizeObserver.unobserve(chartRef.value!)
chart?.dispose() chart?.dispose()
}) })
watch( watch(
() => props.options, () => props.options,
(newVal, oldVal) => { (newVal, oldVal) => {
initChart() initChart()
} }
) )
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.chart { .chart {
width: 100%; width: 100%;
height: 100%; height: 100%;
position: relative; position: relative;
.el-button { .el-button {
position: absolute; position: absolute;
right: 0px; right: 0px;
top: -60px; top: -60px;
} }
.my-chart { .my-chart {
height: 100%; height: 100%;
width: 100%; width: 100%;
} }
} }
</style> </style>

View File

@@ -1,4 +1,4 @@
export let color = [ '#07CCCA','#00BFF5', '#FFBF00', '#77DA63', '#D5FF6B', '#Ff6600', '#FF9100', '#5B6E96', '#66FFCC', '#B3B3B3'] export let color = [ '#07CCCA','#00BFF5', '#FFBF00', '#77DA63', '#Ff6600', '#FF9100', '#5B6E96', '#66FFCC', '#B3B3B3']
export const gradeColor3 = ['#339966', '#FFCC33', '#A52a2a'] export const gradeColor3 = ['#339966', '#FFCC33', '#A52a2a']
export const gradeColor5 = ['#00CC00', '#99CC99', '#FF9900','#996600','#A52a2a'] export const gradeColor5 = ['#00CC00', '#99CC99', '#FF9900','#996600','#A52a2a']

View File

@@ -1,3 +1,9 @@
<template>
<div>
</div>
</template>
<script lang="ts"> <script lang="ts">
import { createVNode, resolveComponent, defineComponent, computed, type CSSProperties } from 'vue' import { createVNode, resolveComponent, defineComponent, computed, type CSSProperties } from 'vue'
import svg from '@/components/icon/svg/index.vue' import svg from '@/components/icon/svg/index.vue'
@@ -27,7 +33,7 @@ export default defineComponent({
color: color color: color
} }
}) })
if(props.name){ if (props.name) {
if (props.name.indexOf('el-icon-') === 0) { if (props.name.indexOf('el-icon-') === 0) {
return () => return () =>
createVNode('el-icon', { class: 'icon el-icon', style: iconStyle.value }, [ createVNode('el-icon', { class: 'icon el-icon', style: iconStyle.value }, [

View File

@@ -1,295 +1,303 @@
<template> <template>
<!-- Icon --> <!-- Icon -->
<Icon class="ba-icon-dark" v-if="field.render == 'icon'" :name="fieldValue ? fieldValue : field.default ?? ''" /> <Icon class="ba-icon-dark" v-if="field.render == 'icon'" :name="fieldValue ? fieldValue : field.default ?? ''" />
<!-- switch --> <!-- switch -->
<div v-if="field.render == 'switch' && fieldValue != undefined"> <div v-if="field.render == 'switch' && fieldValue != undefined">
<el-switch <el-switch
@change="onChangeField(field, $event)" @change="onChangeField(field, $event)"
:model-value="fieldValue.toString()" :model-value="fieldValue.toString()"
:loading="row.loading" :loading="row.loading"
inline-prompt inline-prompt
:active-value="field.activeValue" :active-value="field.activeValue"
:active-text="field.activeText" :active-text="field.activeText"
:inactive-value="field.inactiveValue" :inactive-value="field.inactiveValue"
:inactive-text="field.inactiveText" :inactive-text="field.inactiveText"
/> />
</div> </div>
<!-- image --> <!-- image -->
<div v-if="field.render == 'image' && fieldValue" class="ba-render-image"> <div v-if="field.render == 'image' && fieldValue" class="ba-render-image">
<el-image <el-image
:hide-on-click-modal="true" :hide-on-click-modal="true"
:preview-teleported="true" :preview-teleported="true"
:preview-src-list="[fullUrl(fieldValue)]" :preview-src-list="[fieldValue]"
:src="fieldValue.length > 100 ? fieldValue : fullUrl(fieldValue)" :src="fieldValue.length > 100 ? fieldValue : getUrl(fieldValue)"
></el-image> ></el-image>
</div> </div>
<!-- tag --> <!-- tag -->
<div v-if="field.render == 'tag' && fieldValue !== ''"> <div v-if="field.render == 'tag' && fieldValue !== ''">
<el-tag :type="getTagType(fieldValue, field.custom)" size="small"> <el-tag :type="getTagType(fieldValue, field.custom)" size="small">
{{ field.replaceValue ? field.replaceValue[fieldValue] : fieldValue }} {{ field.replaceValue ? field.replaceValue[fieldValue] : fieldValue }}
</el-tag> </el-tag>
</div> </div>
<!-- datetime --> <!-- datetime -->
<div v-if="field.render == 'datetime'"> <div v-if="field.render == 'datetime'">
{{ !fieldValue ? '/' : timeFormat(fieldValue, field.timeFormat ?? undefined) }} {{ !fieldValue ? '/' : timeFormat(fieldValue, field.timeFormat ?? undefined) }}
</div> </div>
<!-- color --> <!-- color -->
<div v-if="field.render == 'color'"> <div v-if="field.render == 'color'">
<div :style="{ background: fieldValue }" class="ba-render-color"></div> <div :style="{ background: fieldValue }" class="ba-render-color"></div>
</div> </div>
<!-- customTemplate 自定义模板 --> <!-- customTemplate 自定义模板 -->
<div <div
v-if="field.render == 'customTemplate'" v-if="field.render == 'customTemplate'"
v-html="field.customTemplate ? field.customTemplate(row, field, fieldValue, column, index) : ''" v-html="field.customTemplate ? field.customTemplate(row, field, fieldValue, column, index) : ''"
></div> ></div>
<!-- 自定义组件/函数渲染 --> <!-- 自定义组件/函数渲染 -->
<component <component
v-if="field.render == 'customRender'" v-if="field.render == 'customRender'"
:is="field.customRender" :is="field.customRender"
:renderRow="row" :renderRow="row"
:renderField="field" :renderField="field"
:renderValue="fieldValue" :renderValue="fieldValue"
:renderColumn="column" :renderColumn="column"
:renderIndex="index" :renderIndex="index"
/> />
<!-- 按钮组 --> <!-- 按钮组 -->
<div v-if="field.render == 'buttons' && buttons" class="cn-render-buttons"> <div v-if="field.render == 'buttons' && buttons" class="cn-render-buttons">
<template v-for="(btn, idx) in buttons" :key="idx"> <template v-for="(btn, idx) in buttons" :key="idx">
<!-- 常规按钮 --> <!-- 常规按钮 -->
<el-button <el-button
link link
v-if="btn.render == 'basicButton'" v-if="btn.render == 'basicButton'"
@click="onButtonClick(btn)" @click="onButtonClick(btn)"
:class="btn.class" :class="btn.class"
class="table-operate" class="table-operate"
:type="btn.type" :type="btn.type"
:loading="props.row[btn.loading] || props.row.loading || false" :loading="props.row[btn.loading] || props.row.loading || false"
v-bind="btn.attr" v-bind="btn.attr"
> >
<div v-if="btn.text || btn.title" class="table-operate-text">{{ btn.text || btn.title }}</div> <div v-if="btn.text || btn.title" class="table-operate-text">{{ btn.text || btn.title }}</div>
</el-button> </el-button>
<!-- 带提示信息的按钮 --> <!-- 带提示信息的按钮 -->
<el-tooltip <el-tooltip
v-if="btn.render == 'tipButton'" v-if="btn.render == 'tipButton'"
:disabled="btn.title && !btn.disabledTip ? false : true" :disabled="btn.title && !btn.disabledTip ? false : true"
:content="btn.title" :content="btn.title"
placement="top" placement="top"
> >
<el-button <el-button
link link
@click="onButtonClick(btn)" @click="onButtonClick(btn)"
:class="btn.class" :class="btn.class"
class="table-operate" class="table-operate"
:type="btn.type" :type="btn.type"
v-bind="btn.attr" v-bind="btn.attr"
> >
<div v-if="btn.text || btn.title" class="table-operate-text"> <div v-if="btn.text || btn.title" class="table-operate-text">
{{ btn.text || btn.title }} {{ btn.text || btn.title }}
</div> </div>
</el-button> </el-button>
</el-tooltip> </el-tooltip>
<!-- 带确认框的按钮 --> <!-- 带确认框的按钮 -->
<el-popconfirm <el-popconfirm
v-if="btn.render == 'confirmButton'" v-if="btn.render == 'confirmButton'"
:disabled="btn.disabled && btn.disabled(row, field)" :disabled="btn.disabled && btn.disabled(row, field)"
v-bind="btn.popconfirm" v-bind="btn.popconfirm"
@confirm="onButtonClick(btn)" @confirm="onButtonClick(btn)"
> >
<template #reference> <template #reference>
<div style="display: inline-block"> <div style="display: inline-block">
<el-button link :class="btn.class" class="table-operate" :type="btn.type" v-bind="btn.attr"> <el-button link :class="btn.class" class="table-operate" :type="btn.type" v-bind="btn.attr">
<div v-if="btn.text || btn.title" class="table-operate-text"> <div v-if="btn.text || btn.title" class="table-operate-text">
{{ btn.text || btn.title }} {{ btn.text || btn.title }}
</div> </div>
</el-button> </el-button>
</div> </div>
</template> </template>
</el-popconfirm> </el-popconfirm>
<el-dropdown v-if="btn.render == 'dropdown'" trigger="click" @command="handlerCommand"> <el-dropdown v-if="btn.render == 'dropdown'" trigger="click" @command="handlerCommand">
<el-button link type="primary" class="table-operate"> <el-button link type="primary" class="table-operate">
<div class="table-operate-text">更多</div> <div class="table-operate-text">更多</div>
</el-button> </el-button>
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
<el-dropdown-item <el-dropdown-item
v-for="item in btn.buttons" v-for="item in btn.buttons"
:key="item.text" :key="item.text"
:command="item" :command="item"
:style="{ :style="{
color: item.type === 'primary' ? 'var(--el-color-primary)' : 'var(--el-color-danger' color: item.type === 'primary' ? 'var(--el-color-primary)' : 'var(--el-color-danger'
}" }"
> >
{{ item.text }} {{ item.text }}
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
</template> </template>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, inject } from 'vue' import { ref, inject } from 'vue'
import { ElMessageBox, type TagProps } from 'element-plus' import { ElMessageBox, type TagProps } from 'element-plus'
import type TableStoreClass from '@/utils/tableStore' import type TableStoreClass from '@/utils/tableStore'
import { fullUrl, timeFormat } from '@/utils/common' import { fullUrl, timeFormat } from '@/utils/common'
import type { VxeColumnProps } from 'vxe-table' import type { VxeColumnProps } from 'vxe-table'
import { getFileUrl } from '@/api/system-boot/file'
const TableStore = inject('tableStore') as TableStoreClass const TableStore = inject('tableStore') as TableStoreClass
interface Props { interface Props {
row: TableRow row: TableRow
field: TableColumn field: TableColumn
column: VxeColumnProps column: VxeColumnProps
index: number index: number
} }
const props = defineProps<Props>() const props = defineProps<Props>()
// 字段值(单元格值) // 字段值(单元格值)
const fieldName = ref(props.field.field) const fieldName = ref(props.field.field)
const fieldValue = ref(fieldName.value ? props.row[fieldName.value] : '') const fieldValue = ref(fieldName.value ? props.row[fieldName.value] : '')
if (fieldName.value && fieldName.value.indexOf('.') > -1) { if (fieldName.value && fieldName.value.indexOf('.') > -1) {
let fieldNameArr = fieldName.value.split('.') let fieldNameArr = fieldName.value.split('.')
let val: any = ref(props.row[fieldNameArr[0]]) let val: any = ref(props.row[fieldNameArr[0]])
for (let index = 1; index < fieldNameArr.length; index++) { for (let index = 1; index < fieldNameArr.length; index++) {
val.value = val.value ? val.value[fieldNameArr[index]] ?? '' : '' val.value = val.value ? val.value[fieldNameArr[index]] ?? '' : ''
} }
fieldValue.value = val.value fieldValue.value = val.value
} }
if (props.field.renderFormatter && typeof props.field.renderFormatter == 'function') { if (props.field.renderFormatter && typeof props.field.renderFormatter == 'function') {
fieldValue.value = props.field.renderFormatter(props.row, props.field, fieldValue.value, props.column, props.index) fieldValue.value = props.field.renderFormatter(props.row, props.field, fieldValue.value, props.column, props.index)
} }
const onChangeField = (row: any, value: any) => { const onChangeField = (row: any, value: any) => {
row.onChangeField && row.onChangeField(props.row, value) row.onChangeField && row.onChangeField(props.row, value)
// TableStore.onTableAction('field-change', { value: value, ...props }) // TableStore.onTableAction('field-change', { value: value, ...props })
} }
const onButtonClick = (btn: OptButton) => { const onButtonClick = (btn: OptButton) => {
btn.click && btn.click(props.row, props.field) btn.click && btn.click(props.row, props.field)
} }
const getTagType = (value: string, custom: any): TagProps['type'] => { const getTagType = (value: string, custom: any): TagProps['type'] => {
return custom && custom[value] ? custom[value] : '' return custom && custom[value] ? custom[value] : ''
} }
// 按钮组处理 最多显示三个按钮 多余的显示为下拉 // 按钮组处理 最多显示三个按钮 多余的显示为下拉
const buttonsFilter = props.field.buttons?.filter(btn => !(btn.disabled && btn.disabled(props.row, props.field))) || [] const buttonsFilter = props.field.buttons?.filter(btn => !(btn.disabled && btn.disabled(props.row, props.field))) || []
const buttons = ref<any[]>([]) const buttons = ref<any[]>([])
if (buttonsFilter.length > 3) { if (buttonsFilter.length > 3) {
buttonsFilter?.forEach((btn, index) => { buttonsFilter?.forEach((btn, index) => {
btn.text = btn.text || btn.title btn.text = btn.text || btn.title
if (index < 2) { if (index < 2) {
buttons.value.push(btn) buttons.value.push(btn)
} else { } else {
if (buttons.value.length > 2) { if (buttons.value.length > 2) {
buttons.value[buttons.value.length - 1].buttons.push(btn) buttons.value[buttons.value.length - 1].buttons.push(btn)
} else { } else {
buttons.value.push({ buttons.value.push({
render: 'dropdown', render: 'dropdown',
buttons: [btn] buttons: [btn]
}) })
} }
} }
}) })
} else { } else {
buttons.value = buttonsFilter buttons.value = buttonsFilter
} }
const handlerCommand = (item: OptButton) => { const handlerCommand = (item: OptButton) => {
switch (item.render) { switch (item.render) {
case 'basicButton': case 'basicButton':
onButtonClick(item) onButtonClick(item)
break break
case 'confirmButton': case 'confirmButton':
ElMessageBox.confirm(item.popconfirm?.title || '提示', { ElMessageBox.confirm(item.popconfirm?.title || '提示', {
confirmButtonText: item.popconfirm?.confirmButtonText || '确认', confirmButtonText: item.popconfirm?.confirmButtonText || '确认',
cancelButtonText: item.popconfirm?.cancelButtonText || '取消', cancelButtonText: item.popconfirm?.cancelButtonText || '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
onButtonClick(item) onButtonClick(item)
}) })
default: default:
break break
} }
} }
</script> const getUrl = (url: string) => {
getFileUrl({ filePath: url }).then(res => {
<style scoped lang="scss"> return res.data
.m-10 { })
margin: 4px; }
} </script>
.ba-render-image { <style scoped lang="scss">
text-align: center; .m-10 {
} margin: 4px;
}
.images-item {
width: 50px; .ba-render-image {
margin: 0 5px; text-align: center;
} }
.el-image { .images-item {
height: 36px; width: 50px;
// width: 36px; margin: 0 5px;
} }
.table-operate-text { .el-image {
padding-left: 5px; height: 36px;
font-size: 12px; // width: 36px;
} }
.table-operate { .table-operate-text {
padding: 4px 5px; padding-left: 5px;
height: auto; font-size: 12px;
} }
.cn-render-buttons { .table-operate {
display: flex; padding: 4px 5px;
align-items: center; height: auto;
justify-content: center; }
.icon { .cn-render-buttons {
font-size: 12px !important; display: flex;
// color: var(--ba-bg-color-overlay) !important; align-items: center;
} justify-content: center;
}
.icon {
.move-button { font-size: 12px !important;
cursor: move; // color: var(--ba-bg-color-overlay) !important;
} }
}
.ml-6 {
display: inline-flex; .move-button {
vertical-align: middle; cursor: move;
margin-left: 6px; }
}
.ml-6 {
.ml-6 + .el-button { display: inline-flex;
margin-left: 6px; vertical-align: middle;
} margin-left: 6px;
}
.ba-render-color {
height: 25px; .ml-6 + .el-button {
width: 100%; margin-left: 6px;
} }
.cn-render-buttons { .ba-render-color {
:deep(.el-button) { height: 25px;
margin-left: 0; width: 100%;
} }
}
</style> .cn-render-buttons {
:deep(.el-button) {
margin-left: 0;
}
}
.ba-render-image {
text-align: center;
}
</style>

View File

@@ -1,306 +1,321 @@
<template> <template>
<div ref="tableHeader" class="cn-table-header"> <div ref="tableHeader" class="cn-table-header">
<div class="table-header ba-scroll-style" :key="num"> <div class="table-header ba-scroll-style" :key="num">
<el-form
<el-form style="flex: 1; height: 34px; margin-right: 20px; display: flex; flex-wrap: wrap" ref="headerForm" style="flex: 1; height: 34px; margin-right: 20px; display: flex; flex-wrap: wrap"
@submit.prevent="" @keyup.enter="onComSearch" label-position="left" :inline="true"> ref="headerForm"
<el-form-item label="日期" v-if="datePicker" style="grid-column: span 2; max-width: 570px"> @submit.prevent=""
<DatePicker ref="datePickerRef" :nextFlag="nextFlag" :theCurrentTime="theCurrentTime"></DatePicker> @keyup.enter="onComSearch"
</el-form-item> label-position="left"
:inline="true"
<el-form-item label="区域" v-if="area"> >
<Area ref="areaRef" v-model.trim="tableStore.table.params.deptIndex" /> <el-form-item label="日期" v-if="datePicker" style="grid-column: span 2; max-width: 570px">
</el-form-item> <DatePicker ref="datePickerRef" :nextFlag="nextFlag" :theCurrentTime="theCurrentTime"></DatePicker>
<slot name="select"></slot> </el-form-item>
</el-form>
<template v-if="$slots.select || datePicker || showSearch"> <el-form-item label="区域" v-if="area">
<el-button type="primary" @click="showSelectChange" v-if="showUnfoldButton"> <Area ref="areaRef" v-model.trim="tableStore.table.params.deptIndex" />
<Icon size="14" name="el-icon-ArrowUp" style="color: #fff" v-if="showSelect" /> </el-form-item>
<Icon size="14" name="el-icon-ArrowDown" style="color: #fff" v-else /> <slot name="select"></slot>
</el-button> </el-form>
<el-button @click="onComSearch" v-if="showSearch" type="primary" :icon="Search">查询</el-button> <template v-if="$slots.select || datePicker || showSearch">
<el-button @click="onResetForm" v-if="showSearch && showReset" :icon="RefreshLeft">重置</el-button> <el-button type="primary" @click="showSelectChange" v-if="showUnfoldButton">
<el-button @click="onExport" v-if="showExport" :loading="tableStore.table.loading" type="primary" <Icon size="14" name="el-icon-ArrowUp" style="color: #fff" v-if="showSelect" />
icon="el-icon-Download">导出</el-button> <Icon size="14" name="el-icon-ArrowDown" style="color: #fff" v-else />
</template> </el-button>
<slot name="operation"></slot> <el-button @click="onComSearch" v-if="showSearch" type="primary" :icon="Search">查询</el-button>
</div> <el-button @click="onResetForm" v-if="showSearch && showReset" :icon="RefreshLeft">重置</el-button>
<el-form :style="showSelect && showUnfoldButton ? headerFormSecondStyleOpen : headerFormSecondStyleClose" <el-button
ref="headerFormSecond" @submit.prevent="" @keyup.enter="onComSearch" label-position="left" @click="onExport"
:inline="true"></el-form> v-if="showExport"
</div> :loading="tableStore.table.loading"
</template> type="primary"
icon="el-icon-Download"
<script setup lang="ts"> >
import { inject, ref, onMounted, nextTick, onUnmounted } from 'vue' 导出
import type TableStore from '@/utils/tableStore' </el-button>
import DatePicker from '@/components/form/datePicker/index.vue' </template>
import Area from '@/components/form/area/index.vue' <slot name="operation"></slot>
import { mainHeight } from '@/utils/layout' </div>
import { useDictData } from '@/stores/dictData' <el-form
import { Search, RefreshLeft } from '@element-plus/icons-vue' :style="showSelect && showUnfoldButton ? headerFormSecondStyleOpen : headerFormSecondStyleClose"
import { defineProps } from 'vue' ref="headerFormSecond"
const emit = defineEmits(['selectChange',]) @submit.prevent=""
@keyup.enter="onComSearch"
const tableStore = inject('tableStore') as TableStore label-position="left"
const tableHeader = ref() :inline="true"
const datePickerRef = ref() ></el-form>
const dictData = useDictData() </div>
const areaRef = ref() </template>
const headerForm = ref()
const headerFormSecond = ref() <script setup lang="ts">
const num = ref(0) import { inject, ref, onMounted, nextTick, onUnmounted } from 'vue'
interface Props { import type TableStore from '@/utils/tableStore'
datePicker?: boolean import DatePicker from '@/components/form/datePicker/index.vue'
area?: boolean import Area from '@/components/form/area/index.vue'
showSearch?: boolean import { mainHeight } from '@/utils/layout'
nextFlag?: boolean //控制时间是否可以往后推 import { useDictData } from '@/stores/dictData'
theCurrentTime?: boolean //控制时间前3天展示上个月时间 import { Search, RefreshLeft } from '@element-plus/icons-vue'
showReset?: boolean //是否显示重置 import { defineProps } from 'vue'
showExport?: boolean //导出控制 const emit = defineEmits(['selectChange'])
}
const tableStore = inject('tableStore') as TableStore
const props = withDefaults(defineProps<Props>(), { const tableHeader = ref()
datePicker: false, const datePickerRef = ref()
area: false, const dictData = useDictData()
showSearch: true, const areaRef = ref()
nextFlag: false, const headerForm = ref()
theCurrentTime: true, const headerFormSecond = ref()
showReset: true, const num = ref(0)
showExport:false interface Props {
}) datePicker?: boolean
// 动态计算table高度 area?: boolean
let resizeObserver = new ResizeObserver(entries => { showSearch?: boolean
for (const entry of entries) { nextFlag?: boolean //控制时间是否可以往后推
handlerHeight() theCurrentTime?: boolean //控制时间前3天展示上个月时间
computedSearchRow() showReset?: boolean //是否显示重置
} showExport?: boolean //导出控制
}) }
const showUnfoldButton = ref(false)
const headerFormSecondStyleOpen = { const props = withDefaults(defineProps<Props>(), {
opacity: 1, datePicker: false,
height: 'auto', area: false,
padding: '0 15px 0px 15px' showSearch: true,
} nextFlag: false,
const headerFormSecondStyleClose = { theCurrentTime: true,
opacity: 0, showReset: true,
height: '0', showExport: false
padding: '0' })
} // 动态计算table高度
onMounted(() => { let resizeObserver = new ResizeObserver(entries => {
if (props.datePicker && tableStore) { for (const entry of entries) {
tableStore.table.params.searchBeginTime = datePickerRef.value?.timeValue[0] handlerHeight()
tableStore.table.params.searchEndTime = datePickerRef.value?.timeValue[1] computedSearchRow()
tableStore.table.params.startTime = datePickerRef.value?.timeValue[0] }
tableStore.table.params.endTime = datePickerRef.value?.timeValue[1] })
tableStore.table.params.timeFlag = datePickerRef.value?.timeFlag const showUnfoldButton = ref(false)
} const headerFormSecondStyleOpen = {
if (props.area) { opacity: 1,
tableStore.table.params.deptIndex = dictData.state.area[0].id height: 'auto',
} padding: '0 15px 0px 15px'
nextTick(() => { }
resizeObserver.observe(tableHeader.value) const headerFormSecondStyleClose = {
computedSearchRow() opacity: 0,
}) height: '0',
}) padding: '0'
onUnmounted(() => { }
resizeObserver.disconnect() onMounted(() => {
}) if (props.datePicker && tableStore) {
tableStore.table.params.searchBeginTime = datePickerRef.value?.timeValue[0]
const handlerHeight = () => { tableStore.table.params.searchEndTime = datePickerRef.value?.timeValue[1]
if (tableStore && tableStore.table) { tableStore.table.params.startTime = datePickerRef.value?.timeValue[0]
tableStore.table.height = mainHeight( tableStore.table.params.endTime = datePickerRef.value?.timeValue[1]
tableStore.table.publicHeight + tableHeader.value.offsetHeight + (tableStore.showPage ? 58 : 0) + 20 tableStore.table.params.timeFlag = datePickerRef.value?.timeFlag
).height as string }
} if (props.area) {
} tableStore.table.params.deptIndex = dictData.state.area[0].id
// 刷新页面handler高度出下拉 }
const computedSearchRow = () => { nextTick(() => {
resizeObserver.observe(tableHeader.value)
if (!headerForm.value.$el) return computedSearchRow()
})
})
// 清空headerFormSecond.value.$el下的元素 onUnmounted(() => {
while (headerFormSecond.value.$el.firstChild) { resizeObserver.disconnect()
headerForm.value.$el.appendChild(headerFormSecond.value.$el.firstChild) })
}
const handlerHeight = () => {
// 获取第一行放了几个表单 if (tableStore && tableStore.table) {
const elFormItem = headerForm.value.$el.querySelectorAll('.el-form-item') tableStore.table.height = mainHeight(
tableStore.table.publicHeight + tableHeader.value.offsetHeight + (tableStore.showPage ? 58 : 0) + 20
// 把第一行放不下的复制一份放到headerFormSecond.value.$el ).height as string
let width = 0 }
for (let i = 0; i < elFormItem.length; i++) { }
width += elFormItem[i].offsetWidth + 32 // 刷新页面handler高度出下拉
if (width > headerForm.value.$el.offsetWidth) { const computedSearchRow = () => {
headerFormSecond.value.$el.appendChild(elFormItem[i]) if (!headerForm.value.$el) return
}
// 清空headerFormSecond.value.$el下的元素
} while (headerFormSecond.value.$el.firstChild) {
headerForm.value.$el.appendChild(headerFormSecond.value.$el.firstChild)
// 判断是否需要折叠 }
if (headerFormSecond.value.$el.scrollHeight > 0) {
showUnfoldButton.value = true // 获取第一行放了几个表单
} else { const elFormItem = headerForm.value.$el.querySelectorAll('.el-form-item')
showUnfoldButton.value = false
} // 把第一行放不下的复制一份放到headerFormSecond.value.$el
} let width = 0
for (let i = 0; i < elFormItem.length; i++) {
const showSelect = ref(false) width += elFormItem[i].offsetWidth + 32
const showSelectChange = () => { if (width > headerForm.value.$el.offsetWidth) {
showSelect.value = !showSelect.value headerFormSecond.value.$el.appendChild(elFormItem[i])
emit('selectChange', showSelect.value) }
} }
const onComSearch = async () => {
if (props.datePicker) { // 判断是否需要折叠
tableStore.table.params.searchBeginTime = datePickerRef.value.timeValue[0] if (headerFormSecond.value.$el.scrollHeight > 0) {
tableStore.table.params.searchEndTime = datePickerRef.value.timeValue[1] showUnfoldButton.value = true
tableStore.table.params.startTime = datePickerRef.value.timeValue[0] } else {
tableStore.table.params.endTime = datePickerRef.value.timeValue[1] showUnfoldButton.value = false
tableStore.table.params.timeFlag = datePickerRef.value.timeFlag }
} }
await tableStore.onTableAction('search', {}) const showSelect = ref(false)
} const showSelectChange = () => {
const setDatePicker = (list: any) => { showSelect.value = !showSelect.value
datePickerRef.value.setTimeOptions(list) setTimeout(() => {
} emit('selectChange', showSelect.value, tableHeader.value.offsetHeight)
const onResetForm = () => { }, 20)
//时间重置成默认值 }
datePickerRef.value?.setInterval(3) const onComSearch = async () => {
tableStore.onTableAction('reset', {}) if (props.datePicker) {
} tableStore.table.params.searchBeginTime = datePickerRef.value.timeValue[0]
const setInterval = (val: any) => { tableStore.table.params.searchEndTime = datePickerRef.value.timeValue[1]
datePickerRef.value.setInterval(val) tableStore.table.params.startTime = datePickerRef.value.timeValue[0]
} tableStore.table.params.endTime = datePickerRef.value.timeValue[1]
// 导出 tableStore.table.params.timeFlag = datePickerRef.value.timeFlag
const onExport = () => { }
tableStore.onTableAction('export', {showAllFlag:true})
} await tableStore.onTableAction('search', {})
}
defineExpose({ onComSearch, areaRef, setDatePicker, setInterval, datePickerRef, showSelectChange, computedSearchRow }) const setDatePicker = (list: any) => {
</script> datePickerRef.value.setTimeOptions(list)
}
<style scoped lang="scss"> const onResetForm = () => {
.cn-table-header { //时间重置成默认值
border: 1px solid var(--el-border-color); datePickerRef.value?.setInterval(3)
} tableStore.onTableAction('reset', {})
}
.table-header { const setInterval = (val: any) => {
position: relative; datePickerRef.value.setInterval(val)
overflow-x: auto; }
box-sizing: border-box; // 导出
display: flex; const onExport = () => {
align-items: center; tableStore.onTableAction('export', { showAllFlag: true })
width: 100%; }
max-width: 100%;
background-color: var(--ba-bg-color-overlay); defineExpose({ onComSearch, areaRef, setDatePicker, setInterval, datePickerRef, showSelectChange, computedSearchRow })
</script>
border-bottom: none;
padding: 13px 15px 9px; <style scoped lang="scss">
font-size: 14px; .cn-table-header {
border: 1px solid var(--el-border-color);
.table-header-operate-text { }
margin-left: 6px;
} .table-header {
} position: relative;
overflow-x: auto;
.table-com-search { box-sizing: border-box;
box-sizing: border-box; display: flex;
width: 100%; align-items: center;
max-width: 100%; width: 100%;
background-color: var(--ba-bg-color-overlay); max-width: 100%;
border: 1px solid var(--ba-border-color); background-color: var(--ba-bg-color-overlay);
border-bottom: none;
padding: 13px 15px 20px 15px; border-bottom: none;
font-size: 14px; padding: 13px 15px 9px;
} font-size: 14px;
#header-form-second, .table-header-operate-text {
#header-form { margin-left: 6px;
// display: flex; }
// flex-wrap: wrap; }
transition: all 0.3s;
} .table-com-search {
box-sizing: border-box;
.mlr-12 { width: 100%;
margin-left: 12px; max-width: 100%;
} background-color: var(--ba-bg-color-overlay);
border: 1px solid var(--ba-border-color);
.mlr-12+.el-button { border-bottom: none;
margin-left: 12px; padding: 13px 15px 20px 15px;
} font-size: 14px;
}
.table-search {
display: flex; #header-form-second,
margin-left: auto; #header-form {
// display: flex;
.quick-search { // flex-wrap: wrap;
width: auto; transition: all 0.3s;
} }
}
.mlr-12 {
.table-search-button-group { margin-left: 12px;
display: flex; }
margin-left: 12px;
border: 1px solid var(--el-border-color); .mlr-12 + .el-button {
border-radius: var(--el-border-radius-base); margin-left: 12px;
overflow: hidden; }
button:focus, .table-search {
button:active { display: flex;
background-color: var(--ba-bg-color-overlay); margin-left: auto;
}
.quick-search {
button:hover { width: auto;
background-color: var(--el-color-info-light-7); }
} }
.table-search-button-item { .table-search-button-group {
height: 30px; display: flex;
border: none; margin-left: 12px;
border-radius: 0; border: 1px solid var(--el-border-color);
} border-radius: var(--el-border-radius-base);
overflow: hidden;
.el-button+.el-button {
margin: 0; button:focus,
} button:active {
background-color: var(--ba-bg-color-overlay);
.right-border { }
border-right: 1px solid var(--el-border-color);
} button:hover {
} background-color: var(--el-color-info-light-7);
}
html.dark {
.table-search-button-group { .table-search-button-item {
height: 30px;
button:focus, border: none;
button:active { border-radius: 0;
background-color: var(--el-color-info-dark-2); }
}
.el-button + .el-button {
button:hover { margin: 0;
background-color: var(--el-color-info-light-7); }
}
.right-border {
button { border-right: 1px solid var(--el-border-color);
background-color: var(--ba-bg-color-overlay); }
}
el-icon {
color: white !important; html.dark {
} .table-search-button-group {
} button:focus,
} button:active {
} background-color: var(--el-color-info-dark-2);
}
#header-form,
#header-form-second { button:hover {
:deep(.el-select) { background-color: var(--el-color-info-light-7);
--el-select-width: 220px; }
}
button {
:deep(.el-input) { background-color: var(--ba-bg-color-overlay);
--el-input-width: 220px;
} el-icon {
} color: white !important;
</style> }
}
}
}
#header-form,
#header-form-second {
:deep(.el-select) {
--el-select-width: 220px;
}
:deep(.el-input) {
--el-input-width: 220px;
}
}
</style>

View File

@@ -1,44 +1,24 @@
<template> <template>
<div :style="{ height: tableStore.table.height }"> <div :style="{ height: typeof props.height === 'string' ? props.height : tableStore.table.height }">
<vxe-table <vxe-table ref="tableRef" height="auto" :key="key" :data="tableStore.table.data"
ref="tableRef" v-loading="tableStore.table.loading" v-bind="Object.assign({}, defaultAttribute, $attrs)"
height="auto" @checkbox-all="selectChangeEvent" @checkbox-change="selectChangeEvent" :showOverflow="showOverflow"
:key="key" :sort-config="{ remote: true }" @sort-change="handleSortChange">
:data="tableStore.table.data"
v-loading="tableStore.table.loading"
v-bind="Object.assign({}, defaultAttribute, $attrs)"
@checkbox-all="selectChangeEvent"
@checkbox-change="selectChangeEvent"
:showOverflow="showOverflow"
:sort-config="{ remote: true }"
@sort-change="handleSortChange"
>
<!-- Column 组件内部是 el-table-column --> <!-- Column 组件内部是 el-table-column -->
<template v-if="isGroup"> <template v-if="isGroup">
<GroupColumn :column="tableStore.table.column" /> <GroupColumn :column="tableStore.table.column" />
</template> </template>
<template v-else> <template v-else>
<Column <Column :attr="item" :key="key + '-column'" v-for="(item, key) in tableStore.table.column"
:attr="item" :tree-node="item.treeNode">
:key="key + '-column'"
v-for="(item, key) in tableStore.table.column"
:tree-node="item.treeNode"
>
<!-- tableStore 预设的列 render 方案 --> <!-- tableStore 预设的列 render 方案 -->
<template v-if="item.render" #default="scope"> <template v-if="item.render" #default="scope">
<FieldRender <FieldRender :field="item" :row="scope.row" :column="scope.column" :index="scope.rowIndex" :key="key +
:field="item" '-' +
:row="scope.row" item.render +
:column="scope.column" '-' +
:index="scope.rowIndex" (item.field ? '-' + item.field + '-' + scope.row[item.field] : '')
:key=" " />
key +
'-' +
item.render +
'-' +
(item.field ? '-' + item.field + '-' + scope.row[item.field] : '')
"
/>
</template> </template>
</Column> </Column>
</template> </template>
@@ -47,16 +27,11 @@
</div> </div>
<div v-if="tableStore.showPage" class="table-pagination"> <div v-if="tableStore.showPage" class="table-pagination">
<el-pagination <el-pagination :currentPage="tableStore.table.params!.pageNum" :page-size="tableStore.table.params!.pageSize"
:currentPage="tableStore.table.params!.pageNum" :page-sizes="pageSizes" background
:page-size="tableStore.table.params!.pageSize"
:page-sizes="pageSizes"
background
:layout="config.layout.shrink ? 'prev, next, jumper' : 'sizes,total, ->, prev, pager, next, jumper'" :layout="config.layout.shrink ? 'prev, next, jumper' : 'sizes,total, ->, prev, pager, next, jumper'"
:total="tableStore.table.total" :total="tableStore.table.total" @size-change="onTableSizeChange"
@size-change="onTableSizeChange" @current-change="onTableCurrentChange"></el-pagination>
@current-change="onTableCurrentChange"
></el-pagination>
</div> </div>
<slot name="footer"></slot> <slot name="footer"></slot>
</template> </template>
@@ -81,11 +56,13 @@ const key = ref(0)
interface Props extends /* @vue-ignore */ Partial<InstanceType<typeof ElTable>> { interface Props extends /* @vue-ignore */ Partial<InstanceType<typeof ElTable>> {
isGroup?: boolean isGroup?: boolean
showOverflow?: boolean showOverflow?: boolean
height?: string | number
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
isGroup: false, isGroup: false,
showOverflow: true showOverflow: true,
height: undefined
}) })
onMounted(() => { onMounted(() => {
tableStore.table.ref = tableRef.value as VxeTableInstance tableStore.table.ref = tableRef.value as VxeTableInstance
@@ -119,7 +96,7 @@ const handleSortChange = ({ field, order }: any) => {
return a[field] < b[field] ? 1 : -1 return a[field] < b[field] ? 1 : -1
} }
}) })
if (tableStore.isWebPaging) { if (tableStore.isWebPaging) {
tableStore.table.data = JSON.parse( tableStore.table.data = JSON.parse(
JSON.stringify( JSON.stringify(
@@ -148,6 +125,7 @@ watch(
() => tableStore.table.allFlag, () => tableStore.table.allFlag,
newVal => { newVal => {
if (tableStore.table.allFlag) { if (tableStore.table.allFlag) {
tableRef.value?.exportData({ tableRef.value?.exportData({
filename: tableStore.exportName || document.querySelectorAll('.ba-nav-tab.active')[0].textContent || '', // 文件名字 filename: tableStore.exportName || document.querySelectorAll('.ba-nav-tab.active')[0].textContent || '', // 文件名字
sheetName: 'Sheet1', sheetName: 'Sheet1',
@@ -207,7 +185,5 @@ defineExpose({
min-width: 128px; min-width: 128px;
} }
} }
</style> </style>
<!-- @/components/table/column/GroupColumn.vue@/components/table/column/GroupColumn.vue --> <!-- @/components/table/column/GroupColumn.vue@/components/table/column/GroupColumn.vue -->

View File

@@ -0,0 +1,55 @@
import type { App } from 'vue'
// 👇使用 form-create 需额外全局引入 element plus 组件
import {
ElAlert,
ElAside,
ElContainer,
ElDivider,
ElHeader,
ElMain,
ElPopconfirm,
ElTable,
ElTableColumn,
ElTabPane,
ElTabs,
ElTransfer
} from 'element-plus'
import FcDesigner from '@form-create/designer'
import formCreate from '@form-create/element-ui'
import install from '@form-create/element-ui/auto-import'
//======================= 自定义组件 =======================
import { UploadFile, UploadImg, UploadImgs } from '@/components/UploadFile'
import { DictSelect } from '@/components/DictSelect'
import UserSelect from '@/views/system/auth/userList/UserSelect.vue'
import { Editor } from '@/components/Editor'
const components = [
ElAside,
ElPopconfirm,
ElHeader,
ElMain,
ElContainer,
ElDivider,
ElTransfer,
ElAlert,
ElTabs,
ElTable,
ElTableColumn,
ElTabPane,
UploadImg,
UploadImgs,
UploadFile,
DictSelect,
UserSelect,
Editor
]
// 参考 http://www.form-create.com/v3/element-ui/auto-import.html 文档
export const setupFormCreate = (app: App<Element>) => {
components.forEach((component) => {
app.component(component.name, component)
})
formCreate.use(install)
app.use(formCreate)
app.use(FcDesigner)
}

View File

@@ -0,0 +1,3 @@
export const setHtmlPageLang = (locale: LocaleType) => {
document.querySelector('html')?.setAttribute('lang', locale)
}

View File

@@ -0,0 +1,42 @@
import type { App } from 'vue'
import { createI18n } from 'vue-i18n'
import { useLocaleStoreWithOut } from '@/stores/modules/locale'
import type { I18n, I18nOptions } from 'vue-i18n'
import { setHtmlPageLang } from './helper'
export let i18n: ReturnType<typeof createI18n>
const createI18nOptions = async (): Promise<I18nOptions> => {
const localeStore = useLocaleStoreWithOut()
const locale = localeStore.getCurrentLocale
const localeMap = localeStore.getLocaleMap
const defaultLocal = await import(`../../locales/${locale.lang}.ts`)
const message = defaultLocal.default ?? {}
setHtmlPageLang(locale.lang)
localeStore.setCurrentLocale({
lang: locale.lang
// elLocale: elLocal
})
return {
legacy: false,
locale: locale.lang,
fallbackLocale: locale.lang,
messages: {
[locale.lang]: message
},
availableLocales: localeMap.map((v) => v.lang),
sync: true,
silentTranslationWarn: true,
missingWarn: false,
silentFallbackWarn: true
}
}
export const setupI18n = async (app: App<Element>) => {
const options = await createI18nOptions()
i18n = createI18n(options) as I18n
app.use(i18n)
}

12
src/stores/indexs.ts Normal file
View File

@@ -0,0 +1,12 @@
import type { App } from 'vue'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
const store = createPinia()
store.use(piniaPluginPersistedstate)
export const setupStore = (app: App<Element>) => {
app.use(store)
}
export { store }

277
src/stores/modules/app.ts Normal file
View File

@@ -0,0 +1,277 @@
import { defineStore } from 'pinia'
import { store } from '../indexs'
import { setCssVar, humpToUnderline } from '@/utils'
import { ElMessage } from 'element-plus'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import { ElementPlusSize } from '@/types/elementPlus'
import { LayoutType } from '@/types/layout'
import { ThemeTypes } from '@/types/theme'
const { wsCache } = useCache()
interface AppState {
breadcrumb: boolean
breadcrumbIcon: boolean
collapse: boolean
uniqueOpened: boolean
hamburger: boolean
screenfull: boolean
search: boolean
size: boolean
locale: boolean
message: boolean
tagsView: boolean
tagsViewIcon: boolean
logo: boolean
fixedHeader: boolean
greyMode: boolean
pageLoading: boolean
layout: LayoutType
title: string
userInfo: string
isDark: boolean
currentSize: ElementPlusSize
sizeMap: ElementPlusSize[]
mobile: boolean
footer: boolean
theme: ThemeTypes
fixedMenu: boolean
}
export const useAppStore = defineStore('app', {
state: (): AppState => {
return {
userInfo: 'userInfo', // 登录信息存储字段-建议每个项目换一个字段,避免与其他项目冲突
sizeMap: ['default', 'large', 'small'],
mobile: false, // 是否是移动端
title: import.meta.env.VITE_APP_TITLE, // 标题
pageLoading: false, // 路由跳转loading
breadcrumb: true, // 面包屑
breadcrumbIcon: true, // 面包屑图标
collapse: false, // 折叠菜单
uniqueOpened: true, // 是否只保持一个子菜单的展开
hamburger: true, // 折叠图标
screenfull: true, // 全屏图标
search: true, // 搜索图标
size: true, // 尺寸图标
locale: true, // 多语言图标
message: true, // 消息图标
tagsView: true, // 标签页
tagsViewIcon: true, // 是否显示标签图标
logo: true, // logo
fixedHeader: true, // 固定toolheader
footer: true, // 显示页脚
greyMode: false, // 是否开始灰色模式,用于特殊悼念日
fixedMenu: wsCache.get('fixedMenu') || false, // 是否固定菜单
layout: wsCache.get(CACHE_KEY.LAYOUT) || 'classic', // layout布局
isDark: wsCache.get(CACHE_KEY.IS_DARK) || false, // 是否是暗黑模式
currentSize: wsCache.get('default') || 'default', // 组件尺寸
theme: wsCache.get(CACHE_KEY.THEME) || {
// 主题色
elColorPrimary: '#409eff',
// 左侧菜单边框颜色
leftMenuBorderColor: 'inherit',
// 左侧菜单背景颜色
leftMenuBgColor: '#001529',
// 左侧菜单浅色背景颜色
leftMenuBgLightColor: '#0f2438',
// 左侧菜单选中背景颜色
leftMenuBgActiveColor: 'var(--el-color-primary)',
// 左侧菜单收起选中背景颜色
leftMenuCollapseBgActiveColor: 'var(--el-color-primary)',
// 左侧菜单字体颜色
leftMenuTextColor: '#bfcbd9',
// 左侧菜单选中字体颜色
leftMenuTextActiveColor: '#fff',
// logo字体颜色
logoTitleTextColor: '#fff',
// logo边框颜色
logoBorderColor: 'inherit',
// 头部背景颜色
topHeaderBgColor: '#fff',
// 头部字体颜色
topHeaderTextColor: 'inherit',
// 头部悬停颜色
topHeaderHoverColor: '#f6f6f6',
// 头部边框颜色
topToolBorderColor: '#eee'
}
}
},
getters: {
getBreadcrumb(): boolean {
return this.breadcrumb
},
getBreadcrumbIcon(): boolean {
return this.breadcrumbIcon
},
getCollapse(): boolean {
return this.collapse
},
getUniqueOpened(): boolean {
return this.uniqueOpened
},
getHamburger(): boolean {
return this.hamburger
},
getScreenfull(): boolean {
return this.screenfull
},
getSize(): boolean {
return this.size
},
getLocale(): boolean {
return this.locale
},
getMessage(): boolean {
return this.message
},
getTagsView(): boolean {
return this.tagsView
},
getTagsViewIcon(): boolean {
return this.tagsViewIcon
},
getLogo(): boolean {
return this.logo
},
getFixedHeader(): boolean {
return this.fixedHeader
},
getGreyMode(): boolean {
return this.greyMode
},
getFixedMenu(): boolean {
return this.fixedMenu
},
getPageLoading(): boolean {
return this.pageLoading
},
getLayout(): LayoutType {
return this.layout
},
getTitle(): string {
return this.title
},
getUserInfo(): string {
return this.userInfo
},
getIsDark(): boolean {
return this.isDark
},
getCurrentSize(): ElementPlusSize {
return this.currentSize
},
getSizeMap(): ElementPlusSize[] {
return this.sizeMap
},
getMobile(): boolean {
return this.mobile
},
getTheme(): ThemeTypes {
return this.theme
},
getFooter(): boolean {
return this.footer
}
},
actions: {
setBreadcrumb(breadcrumb: boolean) {
this.breadcrumb = breadcrumb
},
setBreadcrumbIcon(breadcrumbIcon: boolean) {
this.breadcrumbIcon = breadcrumbIcon
},
setCollapse(collapse: boolean) {
this.collapse = collapse
},
setUniqueOpened(uniqueOpened: boolean) {
this.uniqueOpened = uniqueOpened
},
setHamburger(hamburger: boolean) {
this.hamburger = hamburger
},
setScreenfull(screenfull: boolean) {
this.screenfull = screenfull
},
setSize(size: boolean) {
this.size = size
},
setLocale(locale: boolean) {
this.locale = locale
},
setMessage(message: boolean) {
this.message = message
},
setTagsView(tagsView: boolean) {
this.tagsView = tagsView
},
setTagsViewIcon(tagsViewIcon: boolean) {
this.tagsViewIcon = tagsViewIcon
},
setLogo(logo: boolean) {
this.logo = logo
},
setFixedHeader(fixedHeader: boolean) {
this.fixedHeader = fixedHeader
},
setGreyMode(greyMode: boolean) {
this.greyMode = greyMode
},
setFixedMenu(fixedMenu: boolean) {
wsCache.set('fixedMenu', fixedMenu)
this.fixedMenu = fixedMenu
},
setPageLoading(pageLoading: boolean) {
this.pageLoading = pageLoading
},
setLayout(layout: LayoutType) {
if (this.mobile && layout !== 'classic') {
ElMessage.warning('移动端模式下不支持切换其他布局')
return
}
this.layout = layout
wsCache.set(CACHE_KEY.LAYOUT, this.layout)
},
setTitle(title: string) {
this.title = title
},
setIsDark(isDark: boolean) {
this.isDark = isDark
if (this.isDark) {
document.documentElement.classList.add('dark')
document.documentElement.classList.remove('light')
} else {
document.documentElement.classList.add('light')
document.documentElement.classList.remove('dark')
}
wsCache.set(CACHE_KEY.IS_DARK, this.isDark)
},
setCurrentSize(currentSize: ElementPlusSize) {
this.currentSize = currentSize
wsCache.set('currentSize', this.currentSize)
},
setMobile(mobile: boolean) {
this.mobile = mobile
},
setTheme(theme: ThemeTypes) {
this.theme = Object.assign(this.theme, theme)
wsCache.set(CACHE_KEY.THEME, this.theme)
},
setCssVarTheme() {
for (const key in this.theme) {
setCssVar(`--${humpToUnderline(key)}`, this.theme[key])
}
},
setFooter(footer: boolean) {
this.footer = footer
}
},
persist: false
})
export const useAppStoreWithOut = () => {
return useAppStore(store)
}

104
src/stores/modules/dict.ts Normal file
View File

@@ -0,0 +1,104 @@
import { defineStore } from 'pinia'
import { store } from '../indexs'
// @ts-ignore
import { DictDataVO } from '@/api/system/dict/types'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
const { wsCache } = useCache('sessionStorage')
// import { getSimpleDictDataList } from '@/api/system/dict/dict.data'
export interface DictValueType {
value: any
label: string
clorType?: string
cssClass?: string
}
export interface DictTypeType {
dictType: string
dictValue: DictValueType[]
}
export interface DictState {
dictMap: Map<string, any>
isSetDict: boolean
}
export const useDictStore = defineStore('dict', {
state: (): DictState => ({
dictMap: new Map<string, any>(),
isSetDict: false
}),
getters: {
getDictMap(): Recordable {
const dictMap = wsCache.get(CACHE_KEY.DICT_CACHE)
if (dictMap) {
this.dictMap = dictMap
}
return this.dictMap
},
getIsSetDict(): boolean {
return this.isSetDict
}
},
actions: {
async setDictMap() {
const dictMap = wsCache.get(CACHE_KEY.DICT_CACHE)
if (dictMap) {
this.dictMap = dictMap
this.isSetDict = true
} else {
// const res = await getSimpleDictDataList()
// 设置数据
const dictDataMap = new Map<string, any>()
// res.forEach((dictData: DictDataVO) => {
// // 获得 dictType 层级
// const enumValueObj = dictDataMap[dictData.dictType]
// if (!enumValueObj) {
// dictDataMap[dictData.dictType] = []
// }
// // 处理 dictValue 层级
// dictDataMap[dictData.dictType].push({
// value: dictData.value,
// label: dictData.label,
// colorType: dictData.colorType,
// cssClass: dictData.cssClass
// })
// })
this.dictMap = dictDataMap
this.isSetDict = true
wsCache.set(CACHE_KEY.DICT_CACHE, dictDataMap, { exp: 60 }) // 60 秒 过期
}
},
getDictByType(type: string) {
if (!this.isSetDict) {
this.setDictMap()
}
return this.dictMap[type]
},
async resetDict() {
wsCache.delete(CACHE_KEY.DICT_CACHE)
// const res = await getSimpleDictDataList()
// 设置数据
const dictDataMap = new Map<string, any>()
// res.forEach((dictData: DictDataVO) => {
// // 获得 dictType 层级
// const enumValueObj = dictDataMap[dictData.dictType]
// if (!enumValueObj) {
// dictDataMap[dictData.dictType] = []
// }
// // 处理 dictValue 层级
// dictDataMap[dictData.dictType].push({
// value: dictData.value,
// label: dictData.label,
// colorType: dictData.colorType,
// cssClass: dictData.cssClass
// })
// })
this.dictMap = dictDataMap
this.isSetDict = true
wsCache.set(CACHE_KEY.DICT_CACHE, dictDataMap, { exp: 60 }) // 60 秒 过期
}
}
})
export const useDictStoreWithOut = () => {
return useDictStore(store)
}

View File

@@ -0,0 +1,59 @@
import { defineStore } from 'pinia'
import { store } from '../indexs'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import en from 'element-plus/es/locale/lang/en'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
import { LocaleDropdownType } from '@/types/localeDropdown'
const { wsCache } = useCache()
const elLocaleMap = {
'zh-CN': zhCn,
en: en
}
interface LocaleState {
currentLocale: LocaleDropdownType
localeMap: LocaleDropdownType[]
}
export const useLocaleStore = defineStore('locales', {
state: (): LocaleState => {
return {
currentLocale: {
lang: wsCache.get(CACHE_KEY.LANG) || 'zh-CN',
elLocale: elLocaleMap[wsCache.get(CACHE_KEY.LANG) || 'zh-CN']
},
// 多语言
localeMap: [
{
lang: 'zh-CN',
name: '简体中文'
},
{
lang: 'en',
name: 'English'
}
]
}
},
getters: {
getCurrentLocale(): LocaleDropdownType {
return this.currentLocale
},
getLocaleMap(): LocaleDropdownType[] {
return this.localeMap
}
},
actions: {
setCurrentLocale(localeMap: LocaleDropdownType) {
// this.locale = Object.assign(this.locale, localeMap)
this.currentLocale.lang = localeMap?.lang
this.currentLocale.elLocale = elLocaleMap[localeMap?.lang]
wsCache.set(CACHE_KEY.LANG, localeMap?.lang)
}
}
})
export const useLocaleStoreWithOut = () => {
return useLocaleStore(store)
}

View File

@@ -0,0 +1,48 @@
import { defineStore } from 'pinia'
import { store } from '@/stores/indexs'
interface lockInfo {
isLock?: boolean
password?: string
}
interface LockState {
lockInfo: lockInfo
}
export const useLockStore = defineStore('lock', {
state: (): LockState => {
return {
lockInfo: {
// isLock: false, // 是否锁定屏幕
// password: '' // 锁屏密码
}
}
},
getters: {
getLockInfo(): lockInfo {
return this.lockInfo
}
},
actions: {
setLockInfo(lockInfo: lockInfo) {
this.lockInfo = lockInfo
},
resetLockInfo() {
this.lockInfo = {}
},
unLock(password: string) {
if (this.lockInfo?.password === password) {
this.resetLockInfo()
return true
} else {
return false
}
}
},
persist: true
})
export const useLockStoreWithOut = () => {
return useLockStore(store)
}

View File

@@ -0,0 +1,66 @@
import { defineStore } from 'pinia'
import { store } from '@/stores/indexs'
import { cloneDeep } from 'lodash-es'
import { flatMultiLevelRoutes, generateRoute } from '@/utils/routerHelper'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
const { wsCache } = useCache()
export interface PermissionState {
routers: AppRouteRecordRaw[]
addRouters: AppRouteRecordRaw[]
menuTabRouters: AppRouteRecordRaw[]
}
export const usePermissionStore = defineStore('permission', {
state: (): PermissionState => ({
routers: [],
addRouters: [],
menuTabRouters: []
}),
getters: {
getRouters(): AppRouteRecordRaw[] {
return this.routers
},
getAddRouters(): AppRouteRecordRaw[] {
return flatMultiLevelRoutes(cloneDeep(this.addRouters))
},
getMenuTabRouters(): AppRouteRecordRaw[] {
return this.menuTabRouters
}
},
actions: {
async generateRoutes(): Promise<unknown> {
return new Promise<void>(async (resolve) => {
// 获得菜单列表它在登录的时候setUserInfoAction 方法中已经进行获取
let res: AppCustomRouteRecordRaw[] = []
if (wsCache.get(CACHE_KEY.ROLE_ROUTERS)) {
res = wsCache.get(CACHE_KEY.ROLE_ROUTERS) as AppCustomRouteRecordRaw[]
}
const routerMap: AppRouteRecordRaw[] = generateRoute(res)
// 动态路由404一定要放到最后面
this.addRouters = routerMap.concat([
{
path: '/:path(.*)*',
redirect: '/404',
name: '404Page',
meta: {
hidden: true,
breadcrumb: false
}
}
])
// 渲染菜单的所有路由
resolve()
})
},
setMenuTabRouters(routers: AppRouteRecordRaw[]): void {
this.menuTabRouters = routers
}
},
persist: false
})
export const usePermissionStoreWithOut = () => {
return usePermissionStore(store)
}

View File

@@ -0,0 +1,55 @@
import { store } from '../index'
import { defineStore } from 'pinia'
export const useWorkFlowStore = defineStore('simpleWorkflow', {
state: () => ({
tableId: '',
isTried: false,
promoterDrawer: false,
flowPermission1: {},
approverDrawer: false,
approverConfig1: {},
copyerDrawer: false,
copyerConfig1: {},
conditionDrawer: false,
conditionsConfig1: {
conditionNodes: []
}
}),
actions: {
setTableId(payload) {
this.tableId = payload
},
setIsTried(payload) {
this.isTried = payload
},
setPromoter(payload) {
this.promoterDrawer = payload
},
setFlowPermission(payload) {
this.flowPermission1 = payload
},
setApprover(payload) {
this.approverDrawer = payload
},
setApproverConfig(payload) {
this.approverConfig1 = payload
},
setCopyer(payload) {
this.copyerDrawer = payload
},
setCopyerConfig(payload) {
this.copyerConfig1 = payload
},
setCondition(payload) {
this.conditionDrawer = payload
},
setConditionsConfig(payload) {
this.conditionsConfig1 = payload
}
}
})
export const useWorkFlowStoreWithOut = () => {
return useWorkFlowStore(store)
}

View File

@@ -0,0 +1,141 @@
import router from '@/router'
import type { RouteLocationNormalizedLoaded } from 'vue-router'
import { getRawRoute } from '@/utils/routerHelper'
import { defineStore } from 'pinia'
import { store } from '../indexs'
import { findIndex } from '@/utils'
export interface TagsViewState {
visitedViews: RouteLocationNormalizedLoaded[]
cachedViews: Set<string>
}
export const useTagsViewStore = defineStore('tagsView', {
state: (): TagsViewState => ({
visitedViews: [],
cachedViews: new Set()
}),
getters: {
getVisitedViews(): RouteLocationNormalizedLoaded[] {
return this.visitedViews
},
getCachedViews(): string[] {
return Array.from(this.cachedViews)
}
},
actions: {
// 新增缓存和tag
addView(view: RouteLocationNormalizedLoaded): void {
this.addVisitedView(view)
this.addCachedView()
},
// 新增tag
addVisitedView(view: RouteLocationNormalizedLoaded) {
if (this.visitedViews.some((v) => v.path === view.path)) return
if (view.meta?.noTagsView) return
this.visitedViews.push(
Object.assign({}, view, {
title: view.meta?.title || 'no-name'
})
)
},
// 新增缓存
addCachedView() {
const cacheMap: Set<string> = new Set()
for (const v of this.visitedViews) {
const item = getRawRoute(v)
const needCache = !item.meta?.noCache
if (!needCache) {
continue
}
const name = item.name as string
cacheMap.add(name)
}
if (Array.from(this.cachedViews).sort().toString() === Array.from(cacheMap).sort().toString())
return
this.cachedViews = cacheMap
},
// 删除某个
delView(view: RouteLocationNormalizedLoaded) {
this.delVisitedView(view)
this.delCachedView()
},
// 删除tag
delVisitedView(view: RouteLocationNormalizedLoaded) {
for (const [i, v] of this.visitedViews.entries()) {
if (v.path === view.path) {
this.visitedViews.splice(i, 1)
break
}
}
},
// 删除缓存
delCachedView() {
const route = router.currentRoute.value
const index = findIndex<string>(this.getCachedViews, (v) => v === route.name)
if (index > -1) {
this.cachedViews.delete(this.getCachedViews[index])
}
},
// 删除所有缓存和tag
delAllViews() {
this.delAllVisitedViews()
this.delCachedView()
},
// 删除所有tag
delAllVisitedViews() {
// const affixTags = this.visitedViews.filter((tag) => tag.meta.affix)
this.visitedViews = []
},
// 删除其他
delOthersViews(view: RouteLocationNormalizedLoaded) {
this.delOthersVisitedViews(view)
this.addCachedView()
},
// 删除其他tag
delOthersVisitedViews(view: RouteLocationNormalizedLoaded) {
this.visitedViews = this.visitedViews.filter((v) => {
return v?.meta?.affix || v.path === view.path
})
},
// 删除左侧
delLeftViews(view: RouteLocationNormalizedLoaded) {
const index = findIndex<RouteLocationNormalizedLoaded>(
this.visitedViews,
(v) => v.path === view.path
)
if (index > -1) {
this.visitedViews = this.visitedViews.filter((v, i) => {
return v?.meta?.affix || v.path === view.path || i > index
})
this.addCachedView()
}
},
// 删除右侧
delRightViews(view: RouteLocationNormalizedLoaded) {
const index = findIndex<RouteLocationNormalizedLoaded>(
this.visitedViews,
(v) => v.path === view.path
)
if (index > -1) {
this.visitedViews = this.visitedViews.filter((v, i) => {
return v?.meta?.affix || v.path === view.path || i < index
})
this.addCachedView()
}
},
updateVisitedView(view: RouteLocationNormalizedLoaded) {
for (let v of this.visitedViews) {
if (v.path === view.path) {
v = Object.assign(v, view)
break
}
}
}
},
persist: false
})
export const useTagsViewStoreWithOut = () => {
return useTagsViewStore(store)
}

103
src/stores/modules/user.ts Normal file
View File

@@ -0,0 +1,103 @@
import { store } from '@/stores/indexs'
import { defineStore } from 'pinia'
import { getAccessToken, removeToken } from '@/utils/auth'
import { CACHE_KEY, useCache, deleteUserCache } from '@/hooks/web/useCache'
// import { getInfo, loginOut } from '@/api/login'
const { wsCache } = useCache()
interface UserVO {
id: number
avatar: string
nickname: string
deptId: number
}
interface UserInfoVO {
// USER 缓存
permissions: string[]
roles: string[]
isSetUser: boolean
user: UserVO
}
export const useUserStore = defineStore('admin-user', {
state: (): UserInfoVO => ({
permissions: [],
roles: [],
isSetUser: false,
user: {
id: 0,
avatar: '',
nickname: '',
deptId: 0
}
}),
getters: {
getPermissions(): string[] {
return this.permissions
},
getRoles(): string[] {
return this.roles
},
getIsSetUser(): boolean {
return this.isSetUser
},
getUser(): UserVO {
return this.user
}
},
actions: {
async setUserInfoAction() {
if (!getAccessToken()) {
this.resetState()
return null
}
let userInfo = wsCache.get(CACHE_KEY.USER)
if (!userInfo) {
// userInfo = await getInfo()
}
this.permissions = userInfo.permissions
this.roles = userInfo.roles
this.user = userInfo.user
this.isSetUser = true
wsCache.set(CACHE_KEY.USER, userInfo)
wsCache.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus)
},
async setUserAvatarAction(avatar: string) {
const userInfo = wsCache.get(CACHE_KEY.USER)
// NOTE: 是否需要像`setUserInfoAction`一样判断`userInfo != null`
this.user.avatar = avatar
userInfo.user.avatar = avatar
wsCache.set(CACHE_KEY.USER, userInfo)
},
async setUserNicknameAction(nickname: string) {
const userInfo = wsCache.get(CACHE_KEY.USER)
// NOTE: 是否需要像`setUserInfoAction`一样判断`userInfo != null`
this.user.nickname = nickname
userInfo.user.nickname = nickname
wsCache.set(CACHE_KEY.USER, userInfo)
},
async loginOut() {
// await loginOut()
removeToken()
deleteUserCache() // 删除用户缓存
this.resetState()
},
resetState() {
this.permissions = []
this.roles = []
this.isSetUser = false
this.user = {
id: 0,
avatar: '',
nickname: '',
deptId: 0
}
}
}
})
export const useUserStoreWithOut = () => {
return useUserStore(store)
}

355
src/styles/app.css Normal file
View File

@@ -0,0 +1,355 @@
@charset "UTF-8";
/* 基本样式 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
outline: none !important;
}
html,
body,
#app {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif;
font-weight: 400;
-webkit-font-smoothing: antialiased;
-webkit-tap-highlight-color: transparent;
background-color: var(--ba-bg-color);
font-size: 14px;
overflow: hidden;
position: relative;
}
/* 修改纵向滚动条轨道 */
::-webkit-scrollbar {
width: 8px;
}
/* 修改纵向滚动条拇指thumb */
::-webkit-scrollbar-thumb {
background-color: var(--el-color-primary);
border-radius: 5px;
cursor: pointer !important;
}
/* 修改横向滚动条轨道 */
::-webkit-scrollbar:horizontal {
height: 8px;
}
/* 修改横向滚动条拇指thumb */
::-webkit-scrollbar-thumb:horizontal {
background-color: var(--el-color-primary);
border-radius: 5px;
}
.iconfont-icon {
width: 1em;
height: 1em;
vertical-align: -0.15em;
fill: currentColor;
overflow: hidden;
}
.w100 {
width: 100% !important;
}
.h100 {
height: 100% !important;
}
.ba-center {
display: flex;
align-items: center;
justify-content: center;
}
.default-main {
position: relative;
background: #fff;
margin: var(--ba-main-space) var(--ba-main-space) 0px var(--ba-main-space);
}
.form-one {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.form-one .el-form-item {
display: flex;
width: 98%;
margin-bottom: 15px !important;
}
.form-one .el-form-item .el-form-item__content {
flex: 1;
}
.form-one .el-form-item .el-form-item__content .el-select,
.form-one .el-form-item .el-form-item__content .el-cascader,
.form-one .el-form-item .el-form-item__content .el-input__inner,
.form-one .el-form-item .el-form-item__content .el-date-editor {
width: 100%;
}
.form-two {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.form-two .el-form-item {
display: flex;
width: 48%;
}
.form-two .el-form-item .el-form-item__content {
flex: 1;
}
.form-two .el-form-item .el-form-item__content .el-select,
.form-two .el-form-item .el-form-item__content .el-cascader,
.form-two .el-form-item .el-form-item__content .el-input__inner,
.form-two .el-form-item .el-form-item__content .el-date-editor {
width: 100%;
}
.uploadFile .el-form-item__content {
line-height: 20px !important;
}
.uploadFile .el-form-item__content div {
display: flex !important;
align-items: center !important;
}
.uploadFile .el-form-item__content .el-upload-list__item-name {
width: 150px !important;
}
.uploadFile .el-form-item__content .el-upload-list--text {
margin: 0px 20px 0 !important;
}
.zoom-handle {
position: absolute;
width: 20px;
height: 20px;
bottom: -10px;
right: -10px;
cursor: se-resize;
}
.block-help {
display: block;
width: 100%;
color: #909399;
font-size: 13px;
line-height: 16px;
padding-top: 5px;
}
/* 表格顶部菜单-s */
.table-header .table-header-operate .icon {
font-size: 14px !important;
color: var(--el-color-white) !important;
}
.table-header .el-button.is-disabled .icon {
color: var(--el-button-disabled-text-color) !important;
}
/* 表格顶部菜单-e */
/* 鼠标置入浮动效果-s */
.suspension {
transition: all 0.3s ease;
}
.suspension:hover {
-webkit-transform: translateY(-4px) scale(1.02);
-moz-transform: translateY(-4px) scale(1.02);
-ms-transform: translateY(-4px) scale(1.02);
-o-transform: translateY(-4px) scale(1.02);
transform: translateY(-4px) scale(1.02);
-webkit-box-shadow: 0 14px 24px rgba(0, 0, 0, 0.2);
box-shadow: 0 14px 24px rgba(0, 0, 0, 0.2);
z-index: 999;
border-radius: 6px;
}
/* 鼠标置入浮动效果-e */
/* 表格-s */
.ba-table-box {
border-radius: var(--el-border-radius-round);
}
.ba-table-alert {
background-color: var(--el-fill-color-darker) !important;
border: 1px solid var(--ba-boder-color);
border-bottom: 0;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
/* 表格-e */
.ba-operate-form {
padding-top: 20px;
}
/* 新增/编辑表单-e */
/* 全局遮罩-s */
.ba-layout-shade {
position: fixed;
top: 0;
left: 0;
height: 100vh;
width: 100vw;
background-color: rgba(0, 0, 0, 0.5);
z-index: 9999990;
}
/* 全局遮罩-e */
/* 图片上传预览-s */
.img-preview-dialog .el-dialog__body {
display: flex;
align-items: center;
justify-content: center;
}
.img-preview-dialog .el-dialog__body img {
max-width: 100%;
}
/* 图片上传预览-e */
/* 页面切换动画-s */
.slide-right-enter-active,
.slide-right-leave-active,
.slide-left-enter-active,
.slide-left-leave-active {
will-change: transform;
transition: all 0.3s ease;
}
.slide-right-enter-from, .slide-left-leave-to {
opacity: 0;
transform: translateX(-20px);
}
.slide-right-leave-to, .slide-left-enter-from {
opacity: 0;
transform: translateX(20px);
}
/* 页面切换动画-e */
/* 布局相关-s */
.frontend-footer-brother {
min-height: calc(100vh - 120px);
}
.user-views {
padding-left: 15px;
}
.user-views .user-views-card {
margin-bottom: 15px;
}
.ba-aside-drawer .el-drawer__body {
padding: 0;
}
/* 布局相关-e */
/* 暗黑模式公共样式-s */
.ba-icon-dark {
color: var(--el-text-color-primary) !important;
}
/* 暗黑模式公共样式-e */
/* NProgress-s */
#nprogress .bar,
#nprogress .spinner {
z-index: 999999;
}
/* NProgress-e */
/* 自适应-s */
@media screen and (max-width: 768px) {
.xs-hidden {
display: none;
}
}
@media screen and (max-width: 1024px) {
.cn-operate-dialog {
width: 96%;
}
}
@media screen and (max-width: 991px) {
.user-views {
padding: 0;
}
}
/* 自适应-e */
.custom-table-header {
box-sizing: border-box;
display: flex;
padding: 13px 15px;
align-items: center;
border: 1px solid var(--el-border-color);
}
.custom-table-header .title {
flex: 1;
font-weight: 700;
}
.custom-table-header .el-form-item {
margin-bottom: 0 !important;
}
.child-router {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: #fff;
z-index: 10;
}
.bjs-powered-by {
display: none;
}
.el-select__wrapper {
height: 32px !important;
}
@font-face {
font-family: 'AlimamaFangYuanTiVF';
src: url("../assets/font/ali/AlimamaFangYuanTiVF-Thin.woff") format("woff"), url("../assets/font/ali/AlimamaFangYuanTiVF-Thin.woff2") format("woff2");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'nablaRegular';
src: url("../assets/font/ali/Nabla_Regular.woff") format("woff"), url("../assets/font/ali/Nabla_Regular.woff2") format("woff2");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'AlimamaDongFangDaKai';
src: url("../assets/font/ali/AlimamaDongFangDaKai-Regular.woff") format("woff"), url("../assets/font/ali/AlimamaDongFangDaKai-Regular.woff2") format("woff2");
font-weight: normal;
font-style: normal;
}

1
src/styles/app.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,415 +1,416 @@
/* 基本样式 */ /* 基本样式 */
* { * {
margin: 0; margin: 0;
padding: 0; padding: 0;
box-sizing: border-box; box-sizing: border-box;
outline: none !important; outline: none !important;
} }
html, html,
body, body,
#app { #app {
margin: 0; margin: 0;
padding: 0; padding: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif; font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif;
font-weight: 400; font-weight: 400;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
background-color: var(--ba-bg-color); background-color: var(--ba-bg-color);
font-size: 14px; font-size: 14px;
overflow: hidden; overflow: hidden;
position: relative; position: relative;
} }
/* 修改纵向滚动条轨道 */ /* 修改纵向滚动条轨道 */
::-webkit-scrollbar { ::-webkit-scrollbar {
width: 8px; width: 8px;
} }
/* 修改纵向滚动条拇指thumb */ /* 修改纵向滚动条拇指thumb */
::-webkit-scrollbar-thumb { ::-webkit-scrollbar-thumb {
background-color: var(--el-color-primary); background-color: var(--el-color-primary);
border-radius: 5px; border-radius: 5px;
} cursor: pointer !important;
/* 修改横向滚动条轨道 */ }
::-webkit-scrollbar:horizontal { /* 修改横向滚动条轨道 */
height: 8px; ::-webkit-scrollbar:horizontal {
} height: 8px;
/* 修改横向滚动条拇指thumb */ }
::-webkit-scrollbar-thumb:horizontal { /* 修改横向滚动条拇指thumb */
background-color: var(--el-color-primary); ::-webkit-scrollbar-thumb:horizontal {
border-radius: 5px; background-color: var(--el-color-primary);
} border-radius: 5px;
// 阿里 iconfont Symbol引用css }
.iconfont-icon { // 阿里 iconfont Symbol引用css
width: 1em; .iconfont-icon {
height: 1em; width: 1em;
vertical-align: -0.15em; height: 1em;
fill: currentColor; vertical-align: -0.15em;
overflow: hidden; fill: currentColor;
} overflow: hidden;
}
.w100 {
width: 100% !important; .w100 {
} width: 100% !important;
}
.h100 {
height: 100% !important; .h100 {
} height: 100% !important;
}
.ba-center {
display: flex; .ba-center {
align-items: center; display: flex;
justify-content: center; align-items: center;
} justify-content: center;
}
.default-main {
position: relative; .default-main {
background: #fff; position: relative;
margin: var(--ba-main-space) var(--ba-main-space) 0px var(--ba-main-space); background: #fff;
} margin: var(--ba-main-space) var(--ba-main-space) 0px var(--ba-main-space);
}
.form-one {
display: flex; .form-one {
flex-wrap: wrap; display: flex;
justify-content: space-between; flex-wrap: wrap;
.el-form-item { justify-content: space-between;
display: flex; .el-form-item {
width: 98%; display: flex;
margin-bottom: 15px !important; width: 98%;
.el-form-item__content { margin-bottom: 15px !important;
flex: 1; .el-form-item__content {
.el-select, flex: 1;
.el-cascader, .el-select,
.el-input__inner, .el-cascader,
.el-date-editor { .el-input__inner,
width: 100%; .el-date-editor {
} width: 100%;
} }
} }
} }
.form-two { }
display: flex; .form-two {
flex-wrap: wrap; display: flex;
justify-content: space-between; flex-wrap: wrap;
.el-form-item { justify-content: space-between;
display: flex; .el-form-item {
width: 48%; display: flex;
.el-form-item__content { width: 48%;
flex: 1; .el-form-item__content {
.el-select, flex: 1;
.el-cascader, .el-select,
.el-input__inner, .el-cascader,
.el-date-editor { .el-input__inner,
width: 100%; .el-date-editor {
} width: 100%;
} }
} }
} }
//修改上传文件filelist位置 }
.uploadFile { //修改上传文件filelist位置
.el-form-item__content { .uploadFile {
line-height: 20px !important; .el-form-item__content {
div { line-height: 20px !important;
display: flex !important; div {
align-items: center !important; display: flex !important;
} align-items: center !important;
.el-upload-list__item-name { }
width: 150px !important; .el-upload-list__item-name {
} width: 150px !important;
.el-upload-list--text { }
margin: 0px 20px 0 !important; .el-upload-list--text {
} margin: 0px 20px 0 !important;
} }
} }
.zoom-handle { }
position: absolute; .zoom-handle {
width: 20px; position: absolute;
height: 20px; width: 20px;
bottom: -10px; height: 20px;
right: -10px; bottom: -10px;
cursor: se-resize; right: -10px;
} cursor: se-resize;
}
.block-help {
display: block; .block-help {
width: 100%; display: block;
color: #909399; width: 100%;
font-size: 13px; color: #909399;
line-height: 16px; font-size: 13px;
padding-top: 5px; line-height: 16px;
} padding-top: 5px;
}
/* 表格顶部菜单-s */
.table-header { /* 表格顶部菜单-s */
.table-header-operate .icon { .table-header {
font-size: 14px !important; .table-header-operate .icon {
color: var(--el-color-white) !important; font-size: 14px !important;
} color: var(--el-color-white) !important;
}
.el-button.is-disabled .icon {
color: var(--el-button-disabled-text-color) !important; .el-button.is-disabled .icon {
} color: var(--el-button-disabled-text-color) !important;
} }
}
/* 表格顶部菜单-e */
/* 表格顶部菜单-e */
/* 鼠标置入浮动效果-s */
.suspension { /* 鼠标置入浮动效果-s */
transition: all 0.3s ease; .suspension {
} transition: all 0.3s ease;
}
.suspension:hover {
-webkit-transform: translateY(-4px) scale(1.02); .suspension:hover {
-moz-transform: translateY(-4px) scale(1.02); -webkit-transform: translateY(-4px) scale(1.02);
-ms-transform: translateY(-4px) scale(1.02); -moz-transform: translateY(-4px) scale(1.02);
-o-transform: translateY(-4px) scale(1.02); -ms-transform: translateY(-4px) scale(1.02);
transform: translateY(-4px) scale(1.02); -o-transform: translateY(-4px) scale(1.02);
-webkit-box-shadow: 0 14px 24px rgba(0, 0, 0, 0.2); transform: translateY(-4px) scale(1.02);
box-shadow: 0 14px 24px rgba(0, 0, 0, 0.2); -webkit-box-shadow: 0 14px 24px rgba(0, 0, 0, 0.2);
z-index: 999; box-shadow: 0 14px 24px rgba(0, 0, 0, 0.2);
border-radius: 6px; z-index: 999;
} border-radius: 6px;
}
/* 鼠标置入浮动效果-e */
/* 鼠标置入浮动效果-e */
/* 表格-s */
.ba-table-box { /* 表格-s */
border-radius: var(--el-border-radius-round); .ba-table-box {
} border-radius: var(--el-border-radius-round);
}
.ba-table-alert {
background-color: var(--el-fill-color-darker) !important; .ba-table-alert {
border: 1px solid var(--ba-boder-color); background-color: var(--el-fill-color-darker) !important;
border-bottom: 0; border: 1px solid var(--ba-boder-color);
border-bottom-left-radius: 0; border-bottom: 0;
border-bottom-right-radius: 0; border-bottom-left-radius: 0;
} border-bottom-right-radius: 0;
}
/* 表格-e */
/* 表格-e */
// /* 新增/编辑表单-s */
// .cn-operate-dialog { // /* 新增/编辑表单-s */
// overflow: hidden; // .cn-operate-dialog {
// border-radius: var(--el-border-radius-base); // overflow: hidden;
// } // border-radius: var(--el-border-radius-base);
// }
// .cn-operate-dialog .el-dialog__header {
// padding-bottom: 16px; // .cn-operate-dialog .el-dialog__header {
// border-bottom: 1px solid var(--ba-bg-color); // padding-bottom: 16px;
// } // border-bottom: 1px solid var(--ba-bg-color);
// }
// .cn-operate-dialog .el-dialog__body {
// max-height: 60vh; // .cn-operate-dialog .el-dialog__body {
// padding-top: 20px; // max-height: 60vh;
// padding-bottom: 52px; // padding-top: 20px;
// } // padding-bottom: 52px;
// }
// .cn-operate-dialog .el-dialog__body .el-scrollbar {
// // padding-right: 60px; // .cn-operate-dialog .el-dialog__body .el-scrollbar {
// } // // padding-right: 60px;
// }
// .cn-operate-dialog .el-dialog__footer {
// padding: 15px; // .cn-operate-dialog .el-dialog__footer {
// box-shadow: var(--el-box-shadow); // padding: 15px;
// position: absolute; // box-shadow: var(--el-box-shadow);
// width: 100%; // position: absolute;
// bottom: 0; // width: 100%;
// } // bottom: 0;
// }
// .cn-operate-dialog .el-form {
// width: calc(100% - 60px); // .cn-operate-dialog .el-form {
// } // width: calc(100% - 60px);
// }
// .cn-operate-dialog .el-form--inline {
// display: grid; // .cn-operate-dialog .el-form--inline {
// grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); // display: grid;
// grid-gap: 20px 10px; // grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
// grid-gap: 20px 10px;
// .el-form-item {
// margin-right: 0; // .el-form-item {
// margin-bottom: 0; // margin-right: 0;
// } // margin-bottom: 0;
// } // }
// }
// .cn-operate-dialog .el-form--inline .el-select {
// width: 100%; // .cn-operate-dialog .el-form--inline .el-select {
// } // width: 100%;
// }
.ba-operate-form {
padding-top: 20px; .ba-operate-form {
} padding-top: 20px;
}
/* 新增/编辑表单-e */
/* 新增/编辑表单-e */
/* 全局遮罩-s */
.ba-layout-shade { /* 全局遮罩-s */
position: fixed; .ba-layout-shade {
top: 0; position: fixed;
left: 0; top: 0;
height: 100vh; left: 0;
width: 100vw; height: 100vh;
background-color: rgba(0, 0, 0, 0.5); width: 100vw;
z-index: 9999990; background-color: rgba(0, 0, 0, 0.5);
} z-index: 9999990;
}
/* 全局遮罩-e */
/* 全局遮罩-e */
/* 图片上传预览-s */
.img-preview-dialog .el-dialog__body { /* 图片上传预览-s */
display: flex; .img-preview-dialog .el-dialog__body {
align-items: center; display: flex;
justify-content: center; align-items: center;
justify-content: center;
img {
max-width: 100%; img {
} max-width: 100%;
} }
}
/* 图片上传预览-e */
/* 图片上传预览-e */
/* 页面切换动画-s */
.slide-right-enter-active, /* 页面切换动画-s */
.slide-right-leave-active, .slide-right-enter-active,
.slide-left-enter-active, .slide-right-leave-active,
.slide-left-leave-active { .slide-left-enter-active,
will-change: transform; .slide-left-leave-active {
transition: all 0.3s ease; will-change: transform;
} transition: all 0.3s ease;
}
// slide-right
.slide-right-enter-from { // slide-right
opacity: 0; .slide-right-enter-from {
transform: translateX(-20px); opacity: 0;
} transform: translateX(-20px);
}
.slide-right-leave-to {
opacity: 0; .slide-right-leave-to {
transform: translateX(20px); opacity: 0;
} transform: translateX(20px);
}
// slide-left
.slide-left-enter-from { // slide-left
@extend .slide-right-leave-to; .slide-left-enter-from {
} @extend .slide-right-leave-to;
}
.slide-left-leave-to {
@extend .slide-right-enter-from; .slide-left-leave-to {
} @extend .slide-right-enter-from;
}
/* 页面切换动画-e */
/* 页面切换动画-e */
/* 布局相关-s */
.frontend-footer-brother { /* 布局相关-s */
min-height: calc(100vh - 120px); .frontend-footer-brother {
} min-height: calc(100vh - 120px);
}
.user-views {
padding-left: 15px; .user-views {
padding-left: 15px;
.user-views-card {
margin-bottom: 15px; .user-views-card {
} margin-bottom: 15px;
} }
}
.ba-aside-drawer {
.el-drawer__body { .ba-aside-drawer {
padding: 0; .el-drawer__body {
} padding: 0;
} }
}
/* 布局相关-e */
/* 布局相关-e */
/* 暗黑模式公共样式-s */
.ba-icon-dark { /* 暗黑模式公共样式-s */
color: var(--el-text-color-primary) !important; .ba-icon-dark {
} color: var(--el-text-color-primary) !important;
}
/* 暗黑模式公共样式-e */
/* 暗黑模式公共样式-e */
/* NProgress-s */
#nprogress { /* NProgress-s */
.bar, #nprogress {
.spinner { .bar,
z-index: 999999; .spinner {
} z-index: 999999;
} }
}
/* NProgress-e */
/* NProgress-e */
/* 自适应-s */
@media screen and (max-width: 768px) { /* 自适应-s */
.xs-hidden { @media screen and (max-width: 768px) {
display: none; .xs-hidden {
} display: none;
} }
}
@media screen and (max-width: 1024px) {
.cn-operate-dialog { @media screen and (max-width: 1024px) {
width: 96%; .cn-operate-dialog {
} width: 96%;
} }
}
@media screen and (max-width: 991px) {
.user-views { @media screen and (max-width: 991px) {
padding: 0; .user-views {
} padding: 0;
} }
}
/* 自适应-e */
/* 自适应-e */
.custom-table-header {
box-sizing: border-box; .custom-table-header {
display: flex; box-sizing: border-box;
padding: 13px 15px; display: flex;
align-items: center; padding: 13px 15px;
border: 1px solid var(--el-border-color); align-items: center;
.title { border: 1px solid var(--el-border-color);
flex: 1; .title {
font-weight: 700; flex: 1;
} font-weight: 700;
.el-form-item { }
margin-bottom: 0 !important; .el-form-item {
} margin-bottom: 0 !important;
} }
}
.child-router {
position: absolute; .child-router {
top: 0; position: absolute;
left: 0; top: 0;
height: 100%; left: 0;
width: 100%; height: 100%;
background: #fff; width: 100%;
z-index: 10; background: #fff;
} z-index: 10;
.bjs-powered-by { }
display: none; .bjs-powered-by {
} display: none;
.el-select__wrapper{ }
height: 32px !important; .el-select__wrapper{
} height: 32px !important;
@font-face { }
font-family: 'AlimamaFangYuanTiVF'; @font-face {
src: url('../assets/font/ali/AlimamaFangYuanTiVF-Thin.woff') format('woff'), font-family: 'AlimamaFangYuanTiVF';
url('../assets/font/ali/AlimamaFangYuanTiVF-Thin.woff2') format('woff2'); src: url('../assets/font/ali/AlimamaFangYuanTiVF-Thin.woff') format('woff'),
font-weight: normal; url('../assets/font/ali/AlimamaFangYuanTiVF-Thin.woff2') format('woff2');
font-style: normal; font-weight: normal;
} font-style: normal;
}
//阿里变形字体
@font-face { //阿里变形字体
font-family: 'nablaRegular'; @font-face {
src: url('../assets/font/ali/Nabla_Regular.woff') format('woff'), font-family: 'nablaRegular';
url('../assets/font/ali/Nabla_Regular.woff2') format('woff2'); src: url('../assets/font/ali/Nabla_Regular.woff') format('woff'),
font-weight: normal; url('../assets/font/ali/Nabla_Regular.woff2') format('woff2');
font-style: normal; font-weight: normal;
} font-style: normal;
}
@font-face {
font-family: 'AlimamaDongFangDaKai'; @font-face {
src: url('../assets/font/ali/AlimamaDongFangDaKai-Regular.woff') format('woff'), font-family: 'AlimamaDongFangDaKai';
url('../assets/font/ali/AlimamaDongFangDaKai-Regular.woff2') format('woff2'); src: url('../assets/font/ali/AlimamaDongFangDaKai-Regular.woff') format('woff'),
font-weight: normal; url('../assets/font/ali/AlimamaDongFangDaKai-Regular.woff2') format('woff2');
font-style: normal; font-weight: normal;
} font-style: normal;
}

247
src/styles/element.css Normal file
View File

@@ -0,0 +1,247 @@
@charset "UTF-8";
/* 修复 Chrome 浏览器输入框内选中字符行高异常的bug-s */
.el-input .el-input__inner {
height: 30px;
line-height: calc(var(--el-input-height, 40px) - 4px);
}
/* 修复 Chrome 浏览器输入框内选中字符行高异常的bug-e */
.datetime-picker {
height: 32px;
padding-top: 0;
padding-bottom: 0;
}
.el-divider__text.is-center {
transform: translateX(-50%) translateY(-62%);
}
.el-menu {
user-select: none;
}
.el-menu .el-menu-item:hover,
.el-menu .el-sub-menu__title:hover {
background-color: var(--el-menu-hover-color) !important;
color: var(--el-menu-active-color) !important;
}
.el-menu .el-menu-item:hover .icon,
.el-menu .el-sub-menu__title:hover .icon {
color: var(--el-menu-active-color) !important;
}
.el-select {
min-width: 200px;
}
.el-dialog {
padding: 0px !important;
}
.el-dialog .el-dialog__footer {
padding: 15px;
box-shadow: var(--el-box-shadow);
width: 100%;
bottom: 0;
}
.el-dialog__body {
max-height: 60vh;
overflow-y: auto;
padding: 10px;
}
.el-dialog__header {
background: var(--el-color-primary);
padding: 15px;
margin-right: 0px;
}
.el-dialog__header .el-dialog__headerbtn {
top: 5px;
}
.el-dialog__header .el-dialog__headerbtn .el-icon {
color: var(--el-color-white);
}
.el-dialog__header .el-dialog__headerbtn:hover .el-icon {
color: #409eff;
}
.el-dialog__header .el-dialog__title {
color: var(--el-color-white);
}
.el-table {
--el-table-border-color: var(--ba-border-color);
}
.el-card {
border: none;
}
.el-card__header {
border-bottom: 1px solid var(--el-border-color-extra-light);
}
.el-textarea__inner {
padding: 5px 11px;
}
/* dialog滚动条-s */
.el-overlay-dialog,
.el-tabs__content,
.ba-scroll-style {
scrollbar-width: none;
}
.el-overlay-dialog::-webkit-scrollbar,
.el-tabs__content::-webkit-scrollbar,
.ba-scroll-style::-webkit-scrollbar {
width: 5px;
height: 5px;
}
.el-overlay-dialog::-webkit-scrollbar-thumb,
.el-tabs__content::-webkit-scrollbar-thumb,
.ba-scroll-style::-webkit-scrollbar-thumb {
background: #eaeaea;
border-radius: var(--el-border-radius-base);
box-shadow: none;
-webkit-box-shadow: none;
cursor: pointer !important;
}
.el-overlay-dialog:hover::-webkit-scrollbar-thumb:hover,
.el-tabs__content:hover::-webkit-scrollbar-thumb:hover,
.ba-scroll-style:hover::-webkit-scrollbar-thumb:hover {
background: #c8c9cc;
}
/* dialog滚动条-e */
/* 小屏设备 el-radio-group 样式优化-s */
.ba-input-item-radio {
margin-bottom: 10px;
}
.ba-input-item-radio .el-radio-group .el-radio {
margin-bottom: 8px;
}
/* 小屏设备 el-radio-group 样式调整-e */
.el-tabs--card > .el-tabs__header .el-tabs__item.is-active {
background: var(--el-color-primary);
color: var(--el-color-white);
}
.el-tabs__header {
margin-bottom: 0;
}
.el-form--inline .el-form-item {
margin-bottom: 10px;
}
.el-tabs--border-card > .el-tabs__content {
padding: 10px;
}
.el-page-header__header {
line-height: 32px;
}
.el-page-header__header .el-page-header__content {
font-size: 14px;
font-weight: 700;
}
.el-tabs__content {
height: calc(100% - 40px);
}
.el-tabs__content .el-tab-pane {
height: 100%;
}
.el-button--primary:focus {
color: var(--el-color-white);
outline: 0;
}
.el-button--primary:hover {
color: var(--el-color-white);
border-color: var(--el-color-primary-light-3);
background-color: var(--el-color-primary-light-3);
outline: 0;
}
.el-button.is-plain:focus {
color: var(--el-button-text-color);
border-color: var(--el-button-border-color);
}
.el-button.is-plain:hover {
color: var(--el-color-primary);
border-color: var(--el-color-primary);
}
.el-button.is-link:focus {
color: var(--el-button-text-color);
}
.el-button.is-link:hover {
color: var(--el-button-hover-link-text-color);
}
.el-button--primary.is-link:hover,
.el-button--primary.is-plain:hover,
.el-button--primary.is-text:hover {
color: var(--el-color-primary-light-5);
background-color: var(--el-color-primary-light-9) !important;
}
.el-divider--horizontal {
margin: 15px 0;
}
.el-step__title {
cursor: pointer;
}
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner,
.el-radio__input.is-disabled.is-checked .el-radio__inner {
background-color: var(--el-color-primary);
opacity: 0.6;
}
.sgmap-ctrl-bottom-left {
display: none !important;
}
.el-drawer__header {
margin-bottom: 0 !important;
}
.custom-tabs-label {
display: flex;
align-items: center;
justify-content: space-between;
}
.custom-tabs-label .el-icon {
margin-right: 5px;
}
.el-pagination__sizes .el-select {
min-width: 128px;
}
.el-collapse-item__content {
padding-bottom: 0;
}
.el-popup-parent--hidden {
width: 100% !important;
}

1
src/styles/element.min.css vendored Normal file
View File

@@ -0,0 +1 @@
.el-input .el-input__inner{height:30px;line-height:calc(var(--el-input-height, 40px) - 4px)}.datetime-picker{height:32px;padding-top:0;padding-bottom:0}.el-divider__text.is-center{transform:translateX(-50%) translateY(-62%)}.el-menu{user-select:none}.el-menu .el-menu-item:hover,.el-menu .el-sub-menu__title:hover{background-color:var(--el-menu-hover-color) !important;color:var(--el-menu-active-color) !important}.el-menu .el-menu-item:hover .icon,.el-menu .el-sub-menu__title:hover .icon{color:var(--el-menu-active-color) !important}.el-select{min-width:200px}.el-dialog{padding:0px !important}.el-dialog .el-dialog__footer{padding:15px;box-shadow:var(--el-box-shadow);width:100%;bottom:0}.el-dialog__body{max-height:60vh;overflow-y:auto;padding:10px}.el-dialog__header{background:var(--el-color-primary);padding:15px;margin-right:0px}.el-dialog__header .el-dialog__headerbtn{top:5px}.el-dialog__header .el-dialog__headerbtn .el-icon{color:var(--el-color-white)}.el-dialog__header .el-dialog__headerbtn:hover .el-icon{color:#409eff}.el-dialog__header .el-dialog__title{color:var(--el-color-white)}.el-table{--el-table-border-color:var(--ba-border-color)}.el-card{border:none}.el-card__header{border-bottom:1px solid var(--el-border-color-extra-light)}.el-textarea__inner{padding:5px 11px}.el-overlay-dialog,.el-tabs__content,.ba-scroll-style{scrollbar-width:none}.el-overlay-dialog::-webkit-scrollbar,.el-tabs__content::-webkit-scrollbar,.ba-scroll-style::-webkit-scrollbar{width:5px;height:5px}.el-overlay-dialog::-webkit-scrollbar-thumb,.el-tabs__content::-webkit-scrollbar-thumb,.ba-scroll-style::-webkit-scrollbar-thumb{background:#eaeaea;border-radius:var(--el-border-radius-base);box-shadow:none;-webkit-box-shadow:none;cursor:pointer !important}.el-overlay-dialog:hover::-webkit-scrollbar-thumb:hover,.el-tabs__content:hover::-webkit-scrollbar-thumb:hover,.ba-scroll-style:hover::-webkit-scrollbar-thumb:hover{background:#c8c9cc}.ba-input-item-radio{margin-bottom:10px}.ba-input-item-radio .el-radio-group .el-radio{margin-bottom:8px}.el-tabs--card>.el-tabs__header .el-tabs__item.is-active{background:var(--el-color-primary);color:var(--el-color-white)}.el-tabs__header{margin-bottom:0}.el-form--inline .el-form-item{margin-bottom:10px}.el-tabs--border-card>.el-tabs__content{padding:10px}.el-page-header__header{line-height:32px}.el-page-header__header .el-page-header__content{font-size:14px;font-weight:700}.el-tabs__content{height:calc(100% - 40px)}.el-tabs__content .el-tab-pane{height:100%}.el-button--primary:focus{color:var(--el-color-white);outline:0}.el-button--primary:hover{color:var(--el-color-white);border-color:var(--el-color-primary-light-3);background-color:var(--el-color-primary-light-3);outline:0}.el-button.is-plain:focus{color:var(--el-button-text-color);border-color:var(--el-button-border-color)}.el-button.is-plain:hover{color:var(--el-color-primary);border-color:var(--el-color-primary)}.el-button.is-link:focus{color:var(--el-button-text-color)}.el-button.is-link:hover{color:var(--el-button-hover-link-text-color)}.el-button--primary.is-link:hover,.el-button--primary.is-plain:hover,.el-button--primary.is-text:hover{color:var(--el-color-primary-light-5);background-color:var(--el-color-primary-light-9) !important}.el-divider--horizontal{margin:15px 0}.el-step__title{cursor:pointer}.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner,.el-radio__input.is-disabled.is-checked .el-radio__inner{background-color:var(--el-color-primary);opacity:0.6}.sgmap-ctrl-bottom-left{display:none !important}.el-drawer__header{margin-bottom:0 !important}.custom-tabs-label{display:flex;align-items:center;justify-content:space-between}.custom-tabs-label .el-icon{margin-right:5px}.el-pagination__sizes .el-select{min-width:128px}.el-collapse-item__content{padding-bottom:0}.el-popup-parent--hidden{width:100% !important}

View File

@@ -1,237 +1,238 @@
/* 修复 Chrome 浏览器输入框内选中字符行高异常的bug-s */ /* 修复 Chrome 浏览器输入框内选中字符行高异常的bug-s */
.el-input .el-input__inner { .el-input .el-input__inner {
height: 30px; height: 30px;
line-height: calc(var(--el-input-height, 40px) - 4px); line-height: calc(var(--el-input-height, 40px) - 4px);
} }
/* 修复 Chrome 浏览器输入框内选中字符行高异常的bug-e */ /* 修复 Chrome 浏览器输入框内选中字符行高异常的bug-e */
.datetime-picker { .datetime-picker {
height: 32px; height: 32px;
padding-top: 0; padding-top: 0;
padding-bottom: 0; padding-bottom: 0;
} }
.el-divider__text.is-center { .el-divider__text.is-center {
transform: translateX(-50%) translateY(-62%); transform: translateX(-50%) translateY(-62%);
} }
.el-menu { .el-menu {
user-select: none; user-select: none;
.el-menu-item:hover, .el-menu-item:hover,
.el-sub-menu__title:hover { .el-sub-menu__title:hover {
background-color: var(--el-menu-hover-color) !important; background-color: var(--el-menu-hover-color) !important;
color: var(--el-menu-active-color) !important; color: var(--el-menu-active-color) !important;
.icon { .icon {
color: var(--el-menu-active-color) !important; color: var(--el-menu-active-color) !important;
} }
} }
} }
.el-select { .el-select {
min-width: 200px; min-width: 200px;
} }
.el-dialog { .el-dialog {
padding: 0px !important; padding: 0px !important;
.el-dialog__footer { .el-dialog__footer {
padding: 15px; padding: 15px;
box-shadow: var(--el-box-shadow); box-shadow: var(--el-box-shadow);
width: 100%; width: 100%;
bottom: 0; bottom: 0;
} }
} }
.el-dialog__body { .el-dialog__body {
max-height: 60vh; max-height: 60vh;
overflow-y: auto; overflow-y: auto;
padding: 10px; padding: 10px;
} }
.el-dialog__header { .el-dialog__header {
background: var(--el-color-primary); background: var(--el-color-primary);
padding: 15px; padding: 15px;
margin-right: 0px; margin-right: 0px;
.el-dialog__headerbtn { .el-dialog__headerbtn {
top: 5px; top: 5px;
.el-icon { .el-icon {
color: var(--el-color-white); color: var(--el-color-white);
} }
} }
.el-dialog__headerbtn:hover { .el-dialog__headerbtn:hover {
.el-icon { .el-icon {
color: #409eff; color: #409eff;
} }
} }
.el-dialog__title { .el-dialog__title {
color: var(--el-color-white); color: var(--el-color-white);
} }
} }
.el-table { .el-table {
--el-table-border-color: var(--ba-border-color); --el-table-border-color: var(--ba-border-color);
} }
.el-card { .el-card {
border: none; border: none;
} }
.el-card__header { .el-card__header {
border-bottom: 1px solid var(--el-border-color-extra-light); border-bottom: 1px solid var(--el-border-color-extra-light);
} }
.el-textarea__inner { .el-textarea__inner {
padding: 5px 11px; padding: 5px 11px;
} }
/* dialog滚动条-s */ /* dialog滚动条-s */
.el-overlay-dialog, .el-overlay-dialog,
.el-tabs__content, .el-tabs__content,
.ba-scroll-style { .ba-scroll-style {
scrollbar-width: none; scrollbar-width: none;
&::-webkit-scrollbar { &::-webkit-scrollbar {
width: 5px; width: 5px;
height: 5px; height: 5px;
} }
&::-webkit-scrollbar-thumb { &::-webkit-scrollbar-thumb {
background: #eaeaea; background: #eaeaea;
border-radius: var(--el-border-radius-base); border-radius: var(--el-border-radius-base);
box-shadow: none; box-shadow: none;
-webkit-box-shadow: none; -webkit-box-shadow: none;
} cursor: pointer !important;
}
&:hover {
&::-webkit-scrollbar-thumb:hover { &:hover {
background: #c8c9cc; &::-webkit-scrollbar-thumb:hover {
} background: #c8c9cc;
} }
} }
}
/* dialog滚动条-e */
/* dialog滚动条-e */
/* 小屏设备 el-radio-group 样式优化-s */
.ba-input-item-radio { /* 小屏设备 el-radio-group 样式优化-s */
margin-bottom: 10px; .ba-input-item-radio {
margin-bottom: 10px;
.el-radio-group {
.el-radio { .el-radio-group {
margin-bottom: 8px; .el-radio {
} margin-bottom: 8px;
} }
} }
}
/* 小屏设备 el-radio-group 样式调整-e */
/* 小屏设备 el-radio-group 样式调整-e */
.el-tabs--card > .el-tabs__header .el-tabs__item.is-active {
background: var(--el-color-primary); .el-tabs--card > .el-tabs__header .el-tabs__item.is-active {
color: var(--el-color-white); background: var(--el-color-primary);
} color: var(--el-color-white);
}
.el-tabs__header {
margin-bottom: 0; .el-tabs__header {
} margin-bottom: 0;
}
.el-form--inline .el-form-item {
margin-bottom: 10px; .el-form--inline .el-form-item {
} margin-bottom: 10px;
}
.el-tabs--border-card > .el-tabs__content {
padding: 10px; .el-tabs--border-card > .el-tabs__content {
} padding: 10px;
}
.el-page-header__header {
line-height: 32px; .el-page-header__header {
.el-page-header__content { line-height: 32px;
font-size: 14px; .el-page-header__content {
font-weight: 700; font-size: 14px;
} font-weight: 700;
} }
}
.el-tabs__content {
height: calc(100% - 40px); .el-tabs__content {
.el-tab-pane { height: calc(100% - 40px);
height: 100%; .el-tab-pane {
} height: 100%;
} }
}
.el-button--primary:focus {
color: var(--el-color-white); .el-button--primary:focus {
// border-color: var(--el-color-primary); color: var(--el-color-white);
// background-color: var(--el-color-primary); // border-color: var(--el-color-primary);
outline: 0; // background-color: var(--el-color-primary);
} outline: 0;
.el-button--primary:hover { }
color: var(--el-color-white); .el-button--primary:hover {
border-color: var(--el-color-primary-light-3); color: var(--el-color-white);
background-color: var(--el-color-primary-light-3); border-color: var(--el-color-primary-light-3);
outline: 0; background-color: var(--el-color-primary-light-3);
} outline: 0;
.el-button.is-plain:focus { }
color: var(--el-button-text-color); .el-button.is-plain:focus {
border-color: var(--el-button-border-color); color: var(--el-button-text-color);
} border-color: var(--el-button-border-color);
.el-button.is-plain:hover { }
color: var(--el-color-primary); .el-button.is-plain:hover {
border-color: var(--el-color-primary); color: var(--el-color-primary);
} border-color: var(--el-color-primary);
.el-button.is-link:focus { }
color: var(--el-button-text-color); .el-button.is-link:focus {
} color: var(--el-button-text-color);
.el-button.is-link:hover { }
color: var(--el-button-hover-link-text-color); .el-button.is-link:hover {
} color: var(--el-button-hover-link-text-color);
.el-button--primary.is-link:hover, }
.el-button--primary.is-plain:hover, .el-button--primary.is-link:hover,
.el-button--primary.is-text:hover { .el-button--primary.is-plain:hover,
color: var(--el-color-primary-light-5); .el-button--primary.is-text:hover {
background-color: var(--el-color-primary-light-9) !important; color: var(--el-color-primary-light-5);
} background-color: var(--el-color-primary-light-9) !important;
}
.el-divider--horizontal {
margin: 15px 0; .el-divider--horizontal {
} margin: 15px 0;
.el-step__title { }
cursor: pointer; .el-step__title {
} cursor: pointer;
}
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner,
.el-radio__input.is-disabled.is-checked .el-radio__inner { .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner,
background-color: var(--el-color-primary); .el-radio__input.is-disabled.is-checked .el-radio__inner {
opacity: 0.6; background-color: var(--el-color-primary);
} opacity: 0.6;
}
.sgmap-ctrl-bottom-left {
display: none !important; .sgmap-ctrl-bottom-left {
} display: none !important;
}
.el-drawer__header {
margin-bottom: 0 !important; .el-drawer__header {
} margin-bottom: 0 !important;
//tabs 添加icon样式 }
.custom-tabs-label { //tabs 添加icon样式
display: flex; .custom-tabs-label {
align-items: center; display: flex;
justify-content: space-between; align-items: center;
.el-icon { justify-content: space-between;
margin-right: 5px; .el-icon {
} margin-right: 5px;
} }
.el-pagination__sizes { }
.el-select { .el-pagination__sizes {
min-width: 128px; .el-select {
} min-width: 128px;
} }
}
.el-collapse-item__content{
padding-bottom: 0; .el-collapse-item__content{
} padding-bottom: 0;
}
//解决打开dialog body容器宽度变为 calc(100% - 8px)问题
.el-popup-parent--hidden{ //解决打开dialog body容器宽度变为 calc(100% - 8px)问题
width: 100% !important; .el-popup-parent--hidden{
width: 100% !important;
} }

View File

@@ -0,0 +1,6 @@
@import './variables.scss';
// 导出变量
:export {
namespace: $namespace;
elNamespace: $elNamespace;
}

4043
src/styles/mixins.css Normal file

File diff suppressed because it is too large Load Diff

1
src/styles/mixins.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,65 +1,71 @@
@mixin set-css-var-value($name, $value) { @mixin set-css-var-value($name, $value) {
#{joinVarName($name)}: #{$value}; #{joinVarName($name)}: #{$value};
} }
@function joinVarName($list) { @function joinVarName($list) {
$name: '--ba'; $name: '--ba';
@each $item in $list { @each $item in $list {
@if $item != '' { @if $item != '' {
$name: $name + '-' + $item; $name: $name + '-' + $item;
} }
} }
@return $name; @return $name;
} }
@function getCssVarName($args...) { @function getCssVarName($args...) {
@return joinVarName($args); @return joinVarName($args);
} }
/* /*
* 通过映射设置所有的CSS变量 * 通过映射设置所有的CSS变量
*/ */
@mixin set-component-css-var($name, $variables) { @mixin set-component-css-var($name, $variables) {
@each $attribute, $value in $variables { @each $attribute, $value in $variables {
@if $attribute == 'default' { @if $attribute == 'default' {
#{getCssVarName($name)}: #{$value}; #{getCssVarName($name)}: #{$value};
} @else { } @else {
#{getCssVarName($name, $attribute)}: #{$value}; #{getCssVarName($name, $attribute)}: #{$value};
} }
} }
} }
// mt0,mr0,mb0,ml0 --> mt100,mr100,mb100,ml100 // mt0,mr0,mb0,ml0 --> mt100,mr100,mb100,ml100
@for $i from 0 through 100 { @for $i from 0 through 100 {
.mt#{$i} { .md#{$i} {
margin-top: #{$i}px !important; margin: #{$i}px !important;
} }
.mt#{$i} {
.mr#{$i} { margin-top: #{$i}px !important;
margin-right: #{$i}px !important; }
}
.mr#{$i} {
.mb#{$i} { margin-right: #{$i}px !important;
margin-bottom: #{$i}px !important; }
}
.mb#{$i} {
.ml#{$i} { margin-bottom: #{$i}px !important;
margin-left: #{$i}px !important; }
}
.ml#{$i} {
.pt#{$i} { margin-left: #{$i}px !important;
padding-top: #{$i}px !important; }
}
.pd#{$i} {
.pr#{$i} { padding: #{$i}px !important;
padding-right: #{$i}px !important; }
} .pt#{$i} {
padding-top: #{$i}px !important;
.pb#{$i} { }
padding-bottom: #{$i}px !important;
} .pr#{$i} {
padding-right: #{$i}px !important;
.pl#{$i} { }
padding-left: #{$i}px !important;
} .pb#{$i} {
} padding-bottom: #{$i}px !important;
}
.pl#{$i} {
padding-left: #{$i}px !important;
}
}

View File

@@ -0,0 +1,4 @@
// 命名空间
$namespace: v;
// el命名空间
$elNamespace: el;

141
src/types/auto-components.d.ts vendored Normal file
View File

@@ -0,0 +1,141 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}
declare module 'vue' {
export interface GlobalComponents {
AddNode: typeof import('./../components/SimpleProcessDesigner/src/addNode.vue')['default']
AppLinkInput: typeof import('./../components/AppLinkInput/index.vue')['default']
AppLinkSelectDialog: typeof import('./../components/AppLinkInput/AppLinkSelectDialog.vue')['default']
Backtop: typeof import('./../components/Backtop/src/Backtop.vue')['default']
CardTitle: typeof import('./../components/Card/src/CardTitle.vue')['default']
ColorInput: typeof import('./../components/ColorInput/index.vue')['default']
ComponentContainer: typeof import('./../components/DiyEditor/components/ComponentContainer.vue')['default']
ComponentContainerProperty: typeof import('./../components/DiyEditor/components/ComponentContainerProperty.vue')['default']
ComponentLibrary: typeof import('./../components/DiyEditor/components/ComponentLibrary.vue')['default']
ConfigGlobal: typeof import('./../components/ConfigGlobal/src/ConfigGlobal.vue')['default']
ContentDetailWrap: typeof import('./../components/ContentDetailWrap/src/ContentDetailWrap.vue')['default']
// ContentWrap: typeof import('./../components/ContentWrap/src/ContentWrap.vue')['default']
CopperModal: typeof import('./../components/Cropper/src/CopperModal.vue')['default']
CountTo: typeof import('./../components/CountTo/src/CountTo.vue')['default']
Crontab: typeof import('./../components/Crontab/src/Crontab.vue')['default']
Cropper: typeof import('./../components/Cropper/src/Cropper.vue')['default']
CropperAvatar: typeof import('./../components/Cropper/src/CropperAvatar.vue')['default']
Descriptions: typeof import('./../components/Descriptions/src/Descriptions.vue')['default']
DescriptionsItemLabel: typeof import('./../components/Descriptions/src/DescriptionsItemLabel.vue')['default']
Dialog: typeof import('./../components/Dialog/src/Dialog.vue')['default']
DictSelect: typeof import('./../components/DictSelect/src/DictSelect.vue')['default']
DictTag: typeof import('./../components/DictTag/src/DictTag.vue')['default']
DiyEditor: typeof import('./../components/DiyEditor/index.vue')['default']
DocAlert: typeof import('./../components/DocAlert/index.vue')['default']
Draggable: typeof import('./../components/Draggable/index.vue')['default']
Echart: typeof import('./../components/Echart/src/Echart.vue')['default']
Editor: typeof import('./../components/Editor/src/Editor.vue')['default']
ElAlert: typeof import('element-plus/es')['ElAlert']
ElAvatar: typeof import('element-plus/es')['ElAvatar']
ElBadge: typeof import('element-plus/es')['ElBadge']
ElButton: typeof import('element-plus/es')['ElButton']
ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
ElCard: typeof import('element-plus/es')['ElCard']
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
ElCol: typeof import('element-plus/es')['ElCol']
ElCollapse: typeof import('element-plus/es')['ElCollapse']
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
ElDialog: typeof import('element-plus/es')['ElDialog']
ElDivider: typeof import('element-plus/es')['ElDivider']
ElDrawer: typeof import('element-plus/es')['ElDrawer']
ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
ElementBaseInfo: typeof import('./../components/bpmnProcessDesigner/package/penal/base/ElementBaseInfo.vue')['default']
ElementForm: typeof import('./../components/bpmnProcessDesigner/package/penal/form/ElementForm.vue')['default']
ElementListeners: typeof import('./../components/bpmnProcessDesigner/package/penal/listeners/ElementListeners.vue')['default']
ElementMultiInstance: typeof import('./../components/bpmnProcessDesigner/package/penal/multi-instance/ElementMultiInstance.vue')['default']
ElementOtherConfig: typeof import('./../components/bpmnProcessDesigner/package/penal/other/ElementOtherConfig.vue')['default']
ElementProperties: typeof import('./../components/bpmnProcessDesigner/package/penal/properties/ElementProperties.vue')['default']
ElementTask: typeof import('./../components/bpmnProcessDesigner/package/penal/task/ElementTask.vue')['default']
ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElIcon: typeof import('element-plus/es')['ElIcon']
ElImage: typeof import('element-plus/es')['ElImage']
ElImageViewer: typeof import('element-plus/es')['ElImageViewer']
ElInput: typeof import('element-plus/es')['ElInput']
ElLink: typeof import('element-plus/es')['ElLink']
ElOption: typeof import('element-plus/es')['ElOption']
ElPagination: typeof import('element-plus/es')['ElPagination']
ElPopover: typeof import('element-plus/es')['ElPopover']
ElRadio: typeof import('element-plus/es')['ElRadio']
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
ElRow: typeof import('element-plus/es')['ElRow']
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElSkeleton: typeof import('element-plus/es')['ElSkeleton']
ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: typeof import('element-plus/es')['ElTag']
ElTooltip: typeof import('element-plus/es')['ElTooltip']
ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect']
ElUpload: typeof import('element-plus/es')['ElUpload']
Error: typeof import('./../components/Error/src/Error.vue')['default']
FlowCondition: typeof import('./../components/bpmnProcessDesigner/package/penal/flow-condition/FlowCondition.vue')['default']
Form: typeof import('./../components/Form/src/Form.vue')['default']
Highlight: typeof import('./../components/Highlight/src/Highlight.vue')['default']
Icon: typeof import('./../components/Icon/src/Icon.vue')['default']
IconSelect: typeof import('./../components/Icon/src/IconSelect.vue')['default']
IFrame: typeof import('./../components/IFrame/src/IFrame.vue')['default']
ImageViewer: typeof import('./../components/ImageViewer/src/ImageViewer.vue')['default']
Infotip: typeof import('./../components/Infotip/src/Infotip.vue')['default']
InputPassword: typeof import('./../components/InputPassword/src/InputPassword.vue')['default']
InputWithColor: typeof import('./../components/InputWithColor/index.vue')['default']
MagicCubeEditor: typeof import('./../components/MagicCubeEditor/index.vue')['default']
Modules: typeof import('./../../.idea/modules.xml')['default']
NodeWrap: typeof import('./../components/SimpleProcessDesigner/src/nodeWrap.vue')['default']
OperateLogV2: typeof import('./../components/OperateLogV2/src/OperateLogV2.vue')['default']
Pagination: typeof import('./../components/Pagination/index.vue')['default']
ProcessDesigner: typeof import('./../components/bpmnProcessDesigner/package/designer/ProcessDesigner.vue')['default']
ProcessExpressionDialog: typeof import('./../components/bpmnProcessDesigner/package/penal/task/task-components/ProcessExpressionDialog.vue')['default']
ProcessListenerDialog: typeof import('./../components/bpmnProcessDesigner/package/penal/listeners/ProcessListenerDialog.vue')['default']
ProcessPalette: typeof import('./../components/bpmnProcessDesigner/package/palette/ProcessPalette.vue')['default']
ProcessViewer: typeof import('./../components/bpmnProcessDesigner/package/designer/ProcessViewer.vue')['default']
PropertiesPanel: typeof import('./../components/bpmnProcessDesigner/package/penal/PropertiesPanel.vue')['default']
Qrcode: typeof import('./../components/Qrcode/src/Qrcode.vue')['default']
ReceiveTask: typeof import('./../components/bpmnProcessDesigner/package/penal/task/task-components/ReceiveTask.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterSearch: typeof import('./../components/RouterSearch/index.vue')['default']
RouterView: typeof import('vue-router')['RouterView']
ScriptTask: typeof import('./../components/bpmnProcessDesigner/package/penal/task/task-components/ScriptTask.vue')['default']
Search: typeof import('./../components/Search/src/Search.vue')['default']
ShortcutDateRangePicker: typeof import('./../components/ShortcutDateRangePicker/index.vue')['default']
SignalAndMessage: typeof import('./../components/bpmnProcessDesigner/package/penal/signal-message/SignalAndMessage.vue')['default']
Sticky: typeof import('./../components/Sticky/src/Sticky.vue')['default']
SummaryCard: typeof import('./../components/SummaryCard/index.vue')['default']
Table: typeof import('./../components/Table/src/Table.vue')['default']
TableSelectForm: typeof import('./../components/Table/src/TableSelectForm.vue')['default']
Tooltip: typeof import('./../components/Tooltip/src/Tooltip.vue')['default']
UploadFile: typeof import('./../components/UploadFile/src/UploadFile.vue')['default']
UploadImg: typeof import('./../components/UploadFile/src/UploadImg.vue')['default']
UploadImgs: typeof import('./../components/UploadFile/src/UploadImgs.vue')['default']
UserTask: typeof import('./../components/bpmnProcessDesigner/package/penal/task/task-components/UserTask.vue')['default']
UserTaskListeners: typeof import('./../components/bpmnProcessDesigner/package/penal/listeners/UserTaskListeners.vue')['default']
Vcs: typeof import('./../../.idea/vcs.xml')['default']
Verify: typeof import('./../components/Verifition/src/Verify.vue')['default']
VerifyPoints: typeof import('./../components/Verifition/src/Verify/VerifyPoints.vue')['default']
VerifySlide: typeof import('./../components/Verifition/src/Verify/VerifySlide.vue')['default']
VerticalButtonGroup: typeof import('./../components/VerticalButtonGroup/index.vue')['default']
'Workspace.xml': typeof import('./../../.idea/workspace.xml.tmp')['default']
XButton: typeof import('./../components/XButton/src/XButton.vue')['default']
XTextButton: typeof import('./../components/XButton/src/XTextButton.vue')['default']
YudaoUiAdminVue3: typeof import('./../../.idea/yudao-ui-admin-vue3.iml')['default']
}
export interface ComponentCustomProperties {
vLoading: typeof import('element-plus/es')['ElLoadingDirective']
}
}

78
src/types/auto-imports.d.ts vendored Normal file
View File

@@ -0,0 +1,78 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
export {}
declare global {
const DICT_TYPE: typeof import('@/utils/dict')['DICT_TYPE']
const EffectScope: typeof import('vue')['EffectScope']
const ElMessageBox: typeof import('element-plus/es')['ElMessageBox']
const computed: typeof import('vue')['computed']
const createApp: typeof import('vue')['createApp']
const customRef: typeof import('vue')['customRef']
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
const defineComponent: typeof import('vue')['defineComponent']
const effectScope: typeof import('vue')['effectScope']
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
const getCurrentScope: typeof import('vue')['getCurrentScope']
const h: typeof import('vue')['h']
const inject: typeof import('vue')['inject']
const isProxy: typeof import('vue')['isProxy']
const isReactive: typeof import('vue')['isReactive']
const isReadonly: typeof import('vue')['isReadonly']
const isRef: typeof import('vue')['isRef']
const markRaw: typeof import('vue')['markRaw']
const nextTick: typeof import('vue')['nextTick']
const onActivated: typeof import('vue')['onActivated']
const onBeforeMount: typeof import('vue')['onBeforeMount']
const onBeforeRouteLeave: typeof import('vue-router')['onBeforeRouteLeave']
const onBeforeRouteUpdate: typeof import('vue-router')['onBeforeRouteUpdate']
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
const onDeactivated: typeof import('vue')['onDeactivated']
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
const onMounted: typeof import('vue')['onMounted']
const onRenderTracked: typeof import('vue')['onRenderTracked']
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
const onScopeDispose: typeof import('vue')['onScopeDispose']
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
const onUnmounted: typeof import('vue')['onUnmounted']
const onUpdated: typeof import('vue')['onUpdated']
const provide: typeof import('vue')['provide']
const reactive: typeof import('vue')['reactive']
const readonly: typeof import('vue')['readonly']
const ref: typeof import('vue')['ref']
const required: typeof import('@/utils/formRules')['required']
const resolveComponent: typeof import('vue')['resolveComponent']
const shallowReactive: typeof import('vue')['shallowReactive']
const shallowReadonly: typeof import('vue')['shallowReadonly']
const shallowRef: typeof import('vue')['shallowRef']
const toRaw: typeof import('vue')['toRaw']
const toRef: typeof import('vue')['toRef']
const toRefs: typeof import('vue')['toRefs']
const toValue: typeof import('vue')['toValue']
const triggerRef: typeof import('vue')['triggerRef']
const unref: typeof import('vue')['unref']
const useAttrs: typeof import('vue')['useAttrs']
const useCrudSchemas: typeof import('@/hooks/web/useCrudSchemas')['useCrudSchemas']
const useCssModule: typeof import('vue')['useCssModule']
const useCssVars: typeof import('vue')['useCssVars']
const useI18n: typeof import('@/hooks/web/useI18n')['useI18n']
const useLink: typeof import('vue-router')['useLink']
const useMessage: typeof import('@/hooks/web/useMessage')['useMessage']
const useRoute: typeof import('vue-router')['useRoute']
const useRouter: typeof import('vue-router')['useRouter']
const useSlots: typeof import('vue')['useSlots']
const useTable: typeof import('@/hooks/web/useTable')['useTable']
const watch: typeof import('vue')['watch']
const watchEffect: typeof import('vue')['watchEffect']
const watchPostEffect: typeof import('vue')['watchPostEffect']
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
}
// for type re-export
declare global {
// @ts-ignore
export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
import('vue')
}

3
src/types/elementPlus.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
export type ElementPlusSize = 'default' | 'small' | 'large'
export type ElementPlusInfoType = 'success' | 'info' | 'warning' | 'danger'

5
src/types/icon.d.ts vendored Normal file
View File

@@ -0,0 +1,5 @@
export interface IconTypes {
size?: number
color?: string
icon: string
}

1
src/types/layout.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export type LayoutType = 'classic' | 'topLeft' | 'top' | 'cutMenu'

16
src/types/theme.d.ts vendored Normal file
View File

@@ -0,0 +1,16 @@
export type ThemeTypes = {
elColorPrimary?: string
leftMenuBorderColor?: string
leftMenuBgColor?: string
leftMenuBgLightColor?: string
leftMenuBgActiveColor?: string
leftMenuCollapseBgActiveColor?: string
leftMenuTextColor?: string
leftMenuTextActiveColor?: string
logoTitleTextColor?: string
logoBorderColor?: string
topHeaderBgColor?: string
topHeaderTextColor?: string
topHeaderHoverColor?: string
topToolBorderColor?: string
}

70
src/utils/auth.ts Normal file
View File

@@ -0,0 +1,70 @@
import { useCache, CACHE_KEY } from '@/hooks/web/useCache'
import { decrypt, encrypt } from '@/utils/jsencrypt'
const { wsCache } = useCache()
const AccessTokenKey = 'ACCESS_TOKEN'
const RefreshTokenKey = 'REFRESH_TOKEN'
// 获取token
export const getAccessToken = () => {
// 此处与TokenKey相同此写法解决初始化时Cookies中不存在TokenKey报错
return wsCache.get(AccessTokenKey) ? wsCache.get(AccessTokenKey) : wsCache.get('ACCESS_TOKEN')
}
// 刷新token
export const getRefreshToken = () => {
return wsCache.get(RefreshTokenKey)
}
// 设置token
export const setToken = (token: any) => {
wsCache.set(RefreshTokenKey, token.refreshToken)
wsCache.set(AccessTokenKey, token.accessToken)
}
// 删除token
export const removeToken = () => {
wsCache.delete(AccessTokenKey)
wsCache.delete(RefreshTokenKey)
}
/** 格式化tokenjwt格式 */
export const formatToken = (token: string): string => {
return 'Bearer ' + token
}
// ========== 账号相关 ==========
export type LoginFormType = {
tenantName: string
username: string
password: string
rememberMe: boolean
}
export const getLoginForm = () => {
const loginForm: LoginFormType = wsCache.get(CACHE_KEY.LoginForm)
if (loginForm) {
loginForm.password = decrypt(loginForm.password) as string
}
return loginForm
}
export const setLoginForm = (loginForm: LoginFormType) => {
loginForm.password = encrypt(loginForm.password) as string
wsCache.set(CACHE_KEY.LoginForm, loginForm, { exp: 30 * 24 * 60 * 60 })
}
export const removeLoginForm = () => {
wsCache.delete(CACHE_KEY.LoginForm)
}
// ========== 租户相关 ==========
export const getTenantId = () => {
return wsCache.get(CACHE_KEY.TenantId)
}
export const setTenantId = (username: string) => {
wsCache.set(CACHE_KEY.TenantId, username)
}

174
src/utils/color.ts Normal file
View File

@@ -0,0 +1,174 @@
/**
* 判断是否 十六进制颜色值.
* 输入形式可为 #fff000 #f00
*
* @param String color 十六进制颜色值
* @return Boolean
*/
export const isHexColor = (color: string) => {
const reg = /^#([0-9a-fA-F]{3}|[0-9a-fA-f]{6})$/
return reg.test(color)
}
/**
* RGB 颜色值转换为 十六进制颜色值.
* r, g, 和 b 需要在 [0, 255] 范围内
*
* @return String 类似#ff00ff
* @param r
* @param g
* @param b
*/
export const rgbToHex = (r: number, g: number, b: number) => {
// tslint:disable-next-line:no-bitwise
const hex = ((r << 16) | (g << 8) | b).toString(16)
return '#' + new Array(Math.abs(hex.length - 7)).join('0') + hex
}
/**
* Transform a HEX color to its RGB representation
* @param {string} hex The color to transform
* @returns The RGB representation of the passed color
*/
export const hexToRGB = (hex: string, opacity?: number) => {
let sHex = hex.toLowerCase()
if (isHexColor(hex)) {
if (sHex.length === 4) {
let sColorNew = '#'
for (let i = 1; i < 4; i += 1) {
sColorNew += sHex.slice(i, i + 1).concat(sHex.slice(i, i + 1))
}
sHex = sColorNew
}
const sColorChange: number[] = []
for (let i = 1; i < 7; i += 2) {
sColorChange.push(parseInt('0x' + sHex.slice(i, i + 2)))
}
return opacity
? 'RGBA(' + sColorChange.join(',') + ',' + opacity + ')'
: 'RGB(' + sColorChange.join(',') + ')'
}
return sHex
}
export const colorIsDark = (color: string) => {
if (!isHexColor(color)) return
const [r, g, b] = hexToRGB(color)
.replace(/(?:\(|\)|rgb|RGB)*/g, '')
.split(',')
.map((item) => Number(item))
return r * 0.299 + g * 0.578 + b * 0.114 < 192
}
/**
* Darkens a HEX color given the passed percentage
* @param {string} color The color to process
* @param {number} amount The amount to change the color by
* @returns {string} The HEX representation of the processed color
*/
export const darken = (color: string, amount: number) => {
color = color.indexOf('#') >= 0 ? color.substring(1, color.length) : color
amount = Math.trunc((255 * amount) / 100)
return `#${subtractLight(color.substring(0, 2), amount)}${subtractLight(
color.substring(2, 4),
amount
)}${subtractLight(color.substring(4, 6), amount)}`
}
/**
* Lightens a 6 char HEX color according to the passed percentage
* @param {string} color The color to change
* @param {number} amount The amount to change the color by
* @returns {string} The processed color represented as HEX
*/
export const lighten = (color: string, amount: number) => {
color = color.indexOf('#') >= 0 ? color.substring(1, color.length) : color
amount = Math.trunc((255 * amount) / 100)
return `#${addLight(color.substring(0, 2), amount)}${addLight(
color.substring(2, 4),
amount
)}${addLight(color.substring(4, 6), amount)}`
}
/* Suma el porcentaje indicado a un color (RR, GG o BB) hexadecimal para aclararlo */
/**
* Sums the passed percentage to the R, G or B of a HEX color
* @param {string} color The color to change
* @param {number} amount The amount to change the color by
* @returns {string} The processed part of the color
*/
const addLight = (color: string, amount: number) => {
const cc = parseInt(color, 16) + amount
const c = cc > 255 ? 255 : cc
return c.toString(16).length > 1 ? c.toString(16) : `0${c.toString(16)}`
}
/**
* Calculates luminance of an rgb color
* @param {number} r red
* @param {number} g green
* @param {number} b blue
*/
const luminanace = (r: number, g: number, b: number) => {
const a = [r, g, b].map((v) => {
v /= 255
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4)
})
return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722
}
/**
* Calculates contrast between two rgb colors
* @param {string} rgb1 rgb color 1
* @param {string} rgb2 rgb color 2
*/
const contrast = (rgb1: string[], rgb2: number[]) => {
return (
(luminanace(~~rgb1[0], ~~rgb1[1], ~~rgb1[2]) + 0.05) /
(luminanace(rgb2[0], rgb2[1], rgb2[2]) + 0.05)
)
}
/**
* Determines what the best text color is (black or white) based con the contrast with the background
* @param hexColor - Last selected color by the user
*/
export const calculateBestTextColor = (hexColor: string) => {
const rgbColor = hexToRGB(hexColor.substring(1))
const contrastWithBlack = contrast(rgbColor.split(','), [0, 0, 0])
return contrastWithBlack >= 12 ? '#000000' : '#FFFFFF'
}
/**
* Subtracts the indicated percentage to the R, G or B of a HEX color
* @param {string} color The color to change
* @param {number} amount The amount to change the color by
* @returns {string} The processed part of the color
*/
const subtractLight = (color: string, amount: number) => {
const cc = parseInt(color, 16) - amount
const c = cc < 0 ? 0 : cc
return c.toString(16).length > 1 ? c.toString(16) : `0${c.toString(16)}`
}
// 预设颜色
export const PREDEFINE_COLORS = [
'#ff4500',
'#ff8c00',
'#ffd700',
'#90ee90',
'#00ced1',
'#1e90ff',
'#c71585',
'#409EFF',
'#909399',
'#C0C4CC',
'#b7390b',
'#ff7800',
'#fad400',
'#5b8c5f',
'#00babd',
'#1f73c3',
'#711f57'
]

18
src/utils/dateUtil.ts Normal file
View File

@@ -0,0 +1,18 @@
/**
* Independent time operation tool to facilitate subsequent switch to dayjs
*/
// TODO 芋艿:【锁屏】可能后面删除掉
import dayjs from 'dayjs'
const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss'
const DATE_FORMAT = 'YYYY-MM-DD'
export function formatToDateTime(date?: dayjs.ConfigType, format = DATE_TIME_FORMAT): string {
return dayjs(date).format(format)
}
export function formatToDate(date?: dayjs.ConfigType, format = DATE_FORMAT): string {
return dayjs(date).format(format)
}
export const dateUtil = dayjs

View File

@@ -1,332 +1,363 @@
import dayjs from 'dayjs' import dayjs from 'dayjs'
import type { TableColumnCtx } from 'element-plus' import type { TableColumnCtx } from 'element-plus'
/** /**
* 日期快捷选项适用于 el-date-picker * 日期快捷选项适用于 el-date-picker
*/ */
export const defaultShortcuts = [ export const defaultShortcuts = [
{ {
text: '今天', text: '今天',
value: () => { value: () => {
return new Date() return new Date()
} }
}, },
{ {
text: '昨天', text: '昨天',
value: () => { value: () => {
const date = new Date() const date = new Date()
date.setTime(date.getTime() - 3600 * 1000 * 24) date.setTime(date.getTime() - 3600 * 1000 * 24)
return [date, date] return [date, date]
} }
}, },
{ {
text: '最近七天', text: '最近七天',
value: () => { value: () => {
const date = new Date() const date = new Date()
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7) date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
return [date, new Date()] return [date, new Date()]
} }
}, },
{ {
text: '最近 30 天', text: '最近 30 天',
value: () => { value: () => {
const date = new Date() const date = new Date()
date.setTime(date.getTime() - 3600 * 1000 * 24 * 30) date.setTime(date.getTime() - 3600 * 1000 * 24 * 30)
return [date, new Date()] return [date, new Date()]
} }
}, },
{ {
text: '本月', text: '本月',
value: () => { value: () => {
const date = new Date() const date = new Date()
date.setDate(1) // 设置为当前月的第一天 date.setDate(1) // 设置为当前月的第一天
return [date, new Date()] return [date, new Date()]
} }
}, },
{ {
text: '今年', text: '今年',
value: () => { value: () => {
const date = new Date() const date = new Date()
return [new Date(`${date.getFullYear()}-01-01`), date] return [new Date(`${date.getFullYear()}-01-01`), date]
} }
} }
] ]
/** /**
* 时间日期转换 * 时间日期转换
* @param date 当前时间new Date() 格式 * @param date 当前时间new Date() 格式
* @param format 需要转换的时间格式字符串 * @param format 需要转换的时间格式字符串
* @description format 字符串随意,如 `YYYY-mm、YYYY-mm-dd` * @description format 字符串随意,如 `YYYY-mm、YYYY-mm-dd`
* @description format 季度:"YYYY-mm-dd HH:MM:SS QQQQ" * @description format 季度:"YYYY-mm-dd HH:MM:SS QQQQ"
* @description format 星期:"YYYY-mm-dd HH:MM:SS WWW" * @description format 星期:"YYYY-mm-dd HH:MM:SS WWW"
* @description format 几周:"YYYY-mm-dd HH:MM:SS ZZZ" * @description format 几周:"YYYY-mm-dd HH:MM:SS ZZZ"
* @description format 季度 + 星期 + 几周:"YYYY-mm-dd HH:MM:SS WWW QQQQ ZZZ" * @description format 季度 + 星期 + 几周:"YYYY-mm-dd HH:MM:SS WWW QQQQ ZZZ"
* @returns 返回拼接后的时间字符串 * @returns 返回拼接后的时间字符串
*/ */
export function formatDate(date: Date, format?: string): string { export function formatDate(date: Date, format?: string): string {
// 日期不存在,则返回空 // 日期不存在,则返回空
if (!date) { if (!date) {
return '' return ''
} }
// 日期存在,则进行格式化 // 日期存在,则进行格式化
return date ? dayjs(date).format(format ?? 'YYYY-MM-DD HH:mm:ss') : '' return date ? dayjs(date).format(format ?? 'YYYY-MM-DD HH:mm:ss') : ''
} }
/** /**
* 获取当前的日期+时间 * 获取当前的日期+时间
*/ */
export function getNowDateTime() { export function getNowDateTime() {
return dayjs() return dayjs()
} }
/** /**
* 获取当前日期是第几周 * 获取当前日期是第几周
* @param dateTime 当前传入的日期值 * @param dateTime 当前传入的日期值
* @returns 返回第几周数字值 * @returns 返回第几周数字值
*/ */
export function getWeek(dateTime: Date): number { export function getWeek(dateTime: Date): number {
const temptTime = new Date(dateTime.getTime()) const temptTime = new Date(dateTime.getTime())
// 周几 // 周几
const weekday = temptTime.getDay() || 7 const weekday = temptTime.getDay() || 7
// 周1+5天=周六 // 周1+5天=周六
temptTime.setDate(temptTime.getDate() - weekday + 1 + 5) temptTime.setDate(temptTime.getDate() - weekday + 1 + 5)
let firstDay = new Date(temptTime.getFullYear(), 0, 1) let firstDay = new Date(temptTime.getFullYear(), 0, 1)
const dayOfWeek = firstDay.getDay() const dayOfWeek = firstDay.getDay()
let spendDay = 1 let spendDay = 1
if (dayOfWeek != 0) spendDay = 7 - dayOfWeek + 1 if (dayOfWeek != 0) spendDay = 7 - dayOfWeek + 1
firstDay = new Date(temptTime.getFullYear(), 0, 1 + spendDay) firstDay = new Date(temptTime.getFullYear(), 0, 1 + spendDay)
const d = Math.ceil((temptTime.valueOf() - firstDay.valueOf()) / 86400000) const d = Math.ceil((temptTime.valueOf() - firstDay.valueOf()) / 86400000)
return Math.ceil(d / 7) return Math.ceil(d / 7)
} }
/** /**
* 将时间转换为 `几秒前`、`几分钟前`、`几小时前`、`几天前` * 将时间转换为 `几秒前`、`几分钟前`、`几小时前`、`几天前`
* @param param 当前时间new Date() 格式或者字符串时间格式 * @param param 当前时间new Date() 格式或者字符串时间格式
* @param format 需要转换的时间格式字符串 * @param format 需要转换的时间格式字符串
* @description param 10秒 10 * 1000 * @description param 10秒 10 * 1000
* @description param 1分 60 * 1000 * @description param 1分 60 * 1000
* @description param 1小时 60 * 60 * 1000 * @description param 1小时 60 * 60 * 1000
* @description param 24小时60 * 60 * 24 * 1000 * @description param 24小时60 * 60 * 24 * 1000
* @description param 3天 60 * 60* 24 * 1000 * 3 * @description param 3天 60 * 60* 24 * 1000 * 3
* @returns 返回拼接后的时间字符串 * @returns 返回拼接后的时间字符串
*/ */
export function formatPast(param: string | Date, format = 'YYYY-mm-dd HH:MM:SS'): string { export function formatPast(param: string | Date, format = 'YYYY-mm-dd HH:MM:SS'): string {
// 传入格式处理、存储转换值 // 传入格式处理、存储转换值
let t: any, s: number let t: any, s: number
// 获取js 时间戳 // 获取js 时间戳
let time: number = new Date().getTime() let time: number = new Date().getTime()
// 是否是对象 // 是否是对象
typeof param === 'string' || 'object' ? (t = new Date(param).getTime()) : (t = param) typeof param === 'string' || 'object' ? (t = new Date(param).getTime()) : (t = param)
// 当前时间戳 - 传入时间戳 // 当前时间戳 - 传入时间戳
time = Number.parseInt(`${time - t}`) time = Number.parseInt(`${time - t}`)
if (time < 10000) { if (time < 10000) {
// 10秒内 // 10秒内
return '刚刚' return '刚刚'
} else if (time < 60000 && time >= 10000) { } else if (time < 60000 && time >= 10000) {
// 超过10秒少于1分钟内 // 超过10秒少于1分钟内
s = Math.floor(time / 1000) s = Math.floor(time / 1000)
return `${s}秒前` return `${s}秒前`
} else if (time < 3600000 && time >= 60000) { } else if (time < 3600000 && time >= 60000) {
// 超过1分钟少于1小时 // 超过1分钟少于1小时
s = Math.floor(time / 60000) s = Math.floor(time / 60000)
return `${s}分钟前` return `${s}分钟前`
} else if (time < 86400000 && time >= 3600000) { } else if (time < 86400000 && time >= 3600000) {
// 超过1小时少于24小时 // 超过1小时少于24小时
s = Math.floor(time / 3600000) s = Math.floor(time / 3600000)
return `${s}小时前` return `${s}小时前`
} else if (time < 259200000 && time >= 86400000) { } else if (time < 259200000 && time >= 86400000) {
// 超过1天少于3天内 // 超过1天少于3天内
s = Math.floor(time / 86400000) s = Math.floor(time / 86400000)
return `${s}天前` return `${s}天前`
} else { } else {
// 超过3天 // 超过3天
const date = typeof param === 'string' || 'object' ? new Date(param) : param const date = typeof param === 'string' || 'object' ? new Date(param) : param
return formatDate(date, format) return formatDate(date, format)
} }
} }
/** /**
* 时间问候语 * 时间问候语
* @param param 当前时间new Date() 格式 * @param param 当前时间new Date() 格式
* @description param 调用 `formatAxis(new Date())` 输出 `上午好` * @description param 调用 `formatAxis(new Date())` 输出 `上午好`
* @returns 返回拼接后的时间字符串 * @returns 返回拼接后的时间字符串
*/ */
export function formatAxis(param: Date): string { export function formatAxis(param: Date): string {
const hour: number = new Date(param).getHours() const hour: number = new Date(param).getHours()
if (hour < 6) return '凌晨好' if (hour < 6) return '凌晨好'
else if (hour < 9) return '早上好' else if (hour < 9) return '早上好'
else if (hour < 12) return '上午好' else if (hour < 12) return '上午好'
else if (hour < 14) return '中午好' else if (hour < 14) return '中午好'
else if (hour < 17) return '下午好' else if (hour < 17) return '下午好'
else if (hour < 19) return '傍晚好' else if (hour < 19) return '傍晚好'
else if (hour < 22) return '晚上好' else if (hour < 22) return '晚上好'
else return '夜里好' else return '夜里好'
} }
/** /**
* 将毫秒转换成时间字符串。例如说xx 分钟 * 将毫秒转换成时间字符串。例如说xx 分钟
* *
* @param ms 毫秒 * @param ms 毫秒
* @returns {string} 字符串 * @returns {string} 字符串
*/ */
export function formatPast2(ms: number): string { export function formatPast2(ms: number): string {
const day = Math.floor(ms / (24 * 60 * 60 * 1000)) const day = Math.floor(ms / (24 * 60 * 60 * 1000))
const hour = Math.floor(ms / (60 * 60 * 1000) - day * 24) const hour = Math.floor(ms / (60 * 60 * 1000) - day * 24)
const minute = Math.floor(ms / (60 * 1000) - day * 24 * 60 - hour * 60) const minute = Math.floor(ms / (60 * 1000) - day * 24 * 60 - hour * 60)
const second = Math.floor(ms / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - minute * 60) const second = Math.floor(ms / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - minute * 60)
if (day > 0) { if (day > 0) {
return day + ' 天' + hour + ' 小时 ' + minute + ' 分钟' return day + ' 天' + hour + ' 小时 ' + minute + ' 分钟'
} }
if (hour > 0) { if (hour > 0) {
return hour + ' 小时 ' + minute + ' 分钟' return hour + ' 小时 ' + minute + ' 分钟'
} }
if (minute > 0) { if (minute > 0) {
return minute + ' 分钟' return minute + ' 分钟'
} }
if (second > 0) { if (second > 0) {
return second + ' 秒' return second + ' 秒'
} else { } else {
return 0 + ' 秒' return 0 + ' 秒'
} }
} }
/** /**
* element plus 的时间 Formatter 实现,使用 YYYY-MM-DD HH:mm:ss 格式 * element plus 的时间 Formatter 实现,使用 YYYY-MM-DD HH:mm:ss 格式
* *
* @param row 行数据 * @param row 行数据
* @param column 字段 * @param column 字段
* @param cellValue 字段值 * @param cellValue 字段值
*/ */
export function dateFormatter(_row: any, _column: TableColumnCtx<any>, cellValue: any): string { export function dateFormatter(_row: any, _column: TableColumnCtx<any>, cellValue: any): string {
return cellValue ? formatDate(cellValue) : '' return cellValue ? formatDate(cellValue) : ''
} }
/** /**
* element plus 的时间 Formatter 实现,使用 YYYY-MM-DD 格式 * element plus 的时间 Formatter 实现,使用 YYYY-MM-DD 格式
* *
* @param row 行数据 * @param row 行数据
* @param column 字段 * @param column 字段
* @param cellValue 字段值 * @param cellValue 字段值
*/ */
export function dateFormatter2(_row: any, _column: TableColumnCtx<any>, cellValue: any): string { export function dateFormatter2(_row: any, _column: TableColumnCtx<any>, cellValue: any): string {
return cellValue ? formatDate(cellValue, 'YYYY-MM-DD') : '' return cellValue ? formatDate(cellValue, 'YYYY-MM-DD') : ''
} }
/** /**
* 设置起始日期时间为00:00:00 * 设置起始日期时间为00:00:00
* @param param 传入日期 * @param param 传入日期
* @returns 带时间00:00:00的日期 * @returns 带时间00:00:00的日期
*/ */
export function beginOfDay(param: Date): Date { export function beginOfDay(param: Date): Date {
return new Date(param.getFullYear(), param.getMonth(), param.getDate(), 0, 0, 0) return new Date(param.getFullYear(), param.getMonth(), param.getDate(), 0, 0, 0)
} }
/** /**
* 设置结束日期时间为23:59:59 * 设置结束日期时间为23:59:59
* @param param 传入日期 * @param param 传入日期
* @returns 带时间23:59:59的日期 * @returns 带时间23:59:59的日期
*/ */
export function endOfDay(param: Date): Date { export function endOfDay(param: Date): Date {
return new Date(param.getFullYear(), param.getMonth(), param.getDate(), 23, 59, 59) return new Date(param.getFullYear(), param.getMonth(), param.getDate(), 23, 59, 59)
} }
/** /**
* 计算两个日期间隔天数 * 计算两个日期间隔天数
* @param param1 日期1 * @param param1 日期1
* @param param2 日期2 * @param param2 日期2
*/ */
export function betweenDay(param1: Date, param2: Date): number { export function betweenDay(param1: Date, param2: Date): number {
param1 = convertDate(param1) param1 = convertDate(param1)
param2 = convertDate(param2) param2 = convertDate(param2)
// 计算差值 // 计算差值
return Math.floor((param2.getTime() - param1.getTime()) / (24 * 3600 * 1000)) return Math.floor((param2.getTime() - param1.getTime()) / (24 * 3600 * 1000))
} }
/** /**
* 日期计算 * 日期计算
* @param param1 日期 * @param param1 日期
* @param param2 添加的时间 * @param param2 添加的时间
*/ */
export function addTime(param1: Date, param2: number): Date { export function addTime(param1: Date, param2: number): Date {
param1 = convertDate(param1) param1 = convertDate(param1)
return new Date(param1.getTime() + param2) return new Date(param1.getTime() + param2)
} }
/** /**
* 日期转换 * 日期转换
* @param param 日期 * @param param 日期
*/ */
export function convertDate(param: Date | string): Date { export function convertDate(param: Date | string): Date {
if (typeof param === 'string') { if (typeof param === 'string') {
return new Date(param) return new Date(param)
} }
return param return param
} }
/** /**
* 指定的两个日期, 是否为同一天 * 指定的两个日期, 是否为同一天
* @param a 日期 A * @param a 日期 A
* @param b 日期 B * @param b 日期 B
*/ */
export function isSameDay(a: dayjs.ConfigType, b: dayjs.ConfigType): boolean { export function isSameDay(a: dayjs.ConfigType, b: dayjs.ConfigType): boolean {
if (!a || !b) return false if (!a || !b) return false
const aa = dayjs(a) const aa = dayjs(a)
const bb = dayjs(b) const bb = dayjs(b)
return aa.year() == bb.year() && aa.month() == bb.month() && aa.day() == bb.day() return aa.year() == bb.year() && aa.month() == bb.month() && aa.day() == bb.day()
} }
/** /**
* 获取一天的开始时间、截止时间 * 获取一天的开始时间、截止时间
* @param date 日期 * @param date 日期
* @param days 天数 * @param days 天数
*/ */
export function getDayRange( export function getDayRange(date: dayjs.ConfigType, days: number): [dayjs.ConfigType, dayjs.ConfigType] {
date: dayjs.ConfigType, const day = dayjs(date).add(days, 'd')
days: number return getDateRange(day, day)
): [dayjs.ConfigType, dayjs.ConfigType] { }
const day = dayjs(date).add(days, 'd')
return getDateRange(day, day) /**
} * 获取最近7天的开始时间、截止时间
*/
/** export function getLast7Days(): [dayjs.ConfigType, dayjs.ConfigType] {
* 获取最近7天的开始时间、截止时间 const lastWeekDay = dayjs().subtract(7, 'd')
*/ const yesterday = dayjs().subtract(1, 'd')
export function getLast7Days(): [dayjs.ConfigType, dayjs.ConfigType] { return getDateRange(lastWeekDay, yesterday)
const lastWeekDay = dayjs().subtract(7, 'd') }
const yesterday = dayjs().subtract(1, 'd')
return getDateRange(lastWeekDay, yesterday) /**
} * 获取最近30天的开始时间、截止时间
*/
/** export function getLast30Days(): [dayjs.ConfigType, dayjs.ConfigType] {
* 获取最近30天的开始时间、截止时间 const lastMonthDay = dayjs().subtract(30, 'd')
*/ const yesterday = dayjs().subtract(1, 'd')
export function getLast30Days(): [dayjs.ConfigType, dayjs.ConfigType] { return getDateRange(lastMonthDay, yesterday)
const lastMonthDay = dayjs().subtract(30, 'd') }
const yesterday = dayjs().subtract(1, 'd')
return getDateRange(lastMonthDay, yesterday) /**
} * 获取最近1年的开始时间、截止时间
*/
/** export function getLast1Year(): [dayjs.ConfigType, dayjs.ConfigType] {
* 获取最近1年的开始时间、截止时间 const lastYearDay = dayjs().subtract(1, 'y')
*/ const yesterday = dayjs().subtract(1, 'd')
export function getLast1Year(): [dayjs.ConfigType, dayjs.ConfigType] { return getDateRange(lastYearDay, yesterday)
const lastYearDay = dayjs().subtract(1, 'y') }
const yesterday = dayjs().subtract(1, 'd')
return getDateRange(lastYearDay, yesterday) /**
} * 获取指定日期的开始时间、截止时间
* @param beginDate 开始日期
/** * @param endDate 截止日期
* 获取指定日期的开始时间、截止时间 */
* @param beginDate 开始日期 export function getDateRange(beginDate: dayjs.ConfigType, endDate: dayjs.ConfigType): [string, string] {
* @param endDate 截止日期 return [
*/ dayjs(beginDate).startOf('d').format('YYYY-MM-DD HH:mm:ss'),
export function getDateRange( dayjs(endDate).endOf('d').format('YYYY-MM-DD HH:mm:ss')
beginDate: dayjs.ConfigType, ]
endDate: dayjs.ConfigType }
): [string, string] { /**
return [ * 获取当月时间
dayjs(beginDate).startOf('d').format('YYYY-MM-DD HH:mm:ss'), * @param beginDate 开始日期
dayjs(endDate).endOf('d').format('YYYY-MM-DD HH:mm:ss') * @param endDate 截止日期
] * @param key 1:年 2:季 3:月 4:周 5:日
} */
export function getTimeOfTheMonth(key: any): [string, string] {
const now = new Date()
const year = now.getFullYear()
const month = now.getMonth()
switch (key) {
case '1': // 年
return [formatDate(new Date(year, 0, 1), 'YYYY-MM-DD'), formatDate(now, 'YYYY-MM-DD')]
case '2': // 季
const quarterStartMonth = Math.floor(month / 3) * 3
const quarterEndMonth = quarterStartMonth + 2
return [formatDate(new Date(year, quarterStartMonth, 1), 'YYYY-MM-DD'), formatDate(now, 'YYYY-MM-DD')]
case '3': // 月
return [formatDate(new Date(year, month, 1), 'YYYY-MM-DD'), formatDate(now, 'YYYY-MM-DD')]
case '4': // 周
const dayOfWeek = now.getDay() // 0是周日
const diff = now.getDate() - dayOfWeek + (dayOfWeek === 0 ? -6 : 1) // 调整为周一
const weekStart = new Date(year, month, diff)
return [formatDate(weekStart, 'YYYY-MM-DD'), formatDate(now, 'YYYY-MM-DD')]
case '5': // 日
return [formatDate(now, 'YYYY-MM-DD'), formatDate(now, 'YYYY-MM-DD')]
default:
throw new Error('Invalid key')
}
}

452
src/utils/index.ts Normal file
View File

@@ -0,0 +1,452 @@
import { toNumber } from 'lodash-es'
/**
*
* @param component 需要注册的组件
* @param alias 组件别名
* @returns any
*/
export const withInstall = <T>(component: T, alias?: string) => {
const comp = component as any
comp.install = (app: any) => {
app.component(comp.name || comp.displayName, component)
if (alias) {
app.config.globalProperties[alias] = component
}
}
return component as T & Plugin
}
/**
* @param str 需要转下划线的驼峰字符串
* @returns 字符串下划线
*/
export const humpToUnderline = (str: string): string => {
return str.replace(/([A-Z])/g, '-$1').toLowerCase()
}
/**
* @param str 需要转驼峰的下划线字符串
* @returns 字符串驼峰
*/
export const underlineToHump = (str: string): string => {
if (!str) return ''
return str.replace(/\-(\w)/g, (_, letter: string) => {
return letter.toUpperCase()
})
}
/**
* 驼峰转横杠
*/
export const humpToDash = (str: string): string => {
return str.replace(/([A-Z])/g, '-$1').toLowerCase()
}
export const setCssVar = (prop: string, val: any, dom = document.documentElement) => {
dom.style.setProperty(prop, val)
}
/**
* 查找数组对象的某个下标
* @param {Array} ary 查找的数组
* @param {Functon} fn 判断的方法
*/
// eslint-disable-next-line
export const findIndex = <T = Recordable>(ary: Array<T>, fn: Fn): number => {
if (ary.findIndex) {
return ary.findIndex(fn)
}
let index = -1
ary.some((item: T, i: number, ary: Array<T>) => {
const ret: T = fn(item, i, ary)
if (ret) {
index = i
return ret
}
})
return index
}
export const trim = (str: string) => {
return str.replace(/(^\s*)|(\s*$)/g, '')
}
/**
* @param {Date | number | string} time 需要转换的时间
* @param {String} fmt 需要转换的格式 如 yyyy-MM-dd、yyyy-MM-dd HH:mm:ss
*/
export function formatTime(time: Date | number | string, fmt: string) {
if (!time) return ''
else {
const date = new Date(time)
const o = {
'M+': date.getMonth() + 1,
'd+': date.getDate(),
'H+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds(),
'q+': Math.floor((date.getMonth() + 3) / 3),
S: date.getMilliseconds()
}
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (const k in o) {
if (new RegExp('(' + k + ')').test(fmt)) {
fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length))
}
}
return fmt
}
}
/**
* 生成随机字符串
*/
export function toAnyString() {
const str: string = 'xxxxx-xxxxx-4xxxx-yxxxx-xxxxx'.replace(/[xy]/g, (c: string) => {
const r: number = (Math.random() * 16) | 0
const v: number = c === 'x' ? r : (r & 0x3) | 0x8
return v.toString()
})
return str
}
/**
* 首字母大写
*/
export function firstUpperCase(str: string) {
return str.toLowerCase().replace(/( |^)[a-z]/g, L => L.toUpperCase())
}
export const generateUUID = () => {
if (typeof crypto === 'object') {
if (typeof crypto.randomUUID === 'function') {
return crypto.randomUUID()
}
if (typeof crypto.getRandomValues === 'function' && typeof Uint8Array === 'function') {
const callback = (c: any) => {
const num = Number(c)
return (num ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (num / 4)))).toString(16)
}
return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, callback)
}
}
let timestamp = new Date().getTime()
let performanceNow = (typeof performance !== 'undefined' && performance.now && performance.now() * 1000) || 0
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
let random = Math.random() * 16
if (timestamp > 0) {
random = (timestamp + random) % 16 | 0
timestamp = Math.floor(timestamp / 16)
} else {
random = (performanceNow + random) % 16 | 0
performanceNow = Math.floor(performanceNow / 16)
}
return (c === 'x' ? random : (random & 0x3) | 0x8).toString(16)
})
}
/**
* element plus 的文件大小 Formatter 实现
*
* @param row 行数据
* @param column 字段
* @param cellValue 字段值
*/
// @ts-ignore
export const fileSizeFormatter = (row, column, cellValue) => {
const fileSize = cellValue
const unitArr = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
const srcSize = parseFloat(fileSize)
const index = Math.floor(Math.log(srcSize) / Math.log(1024))
const size = srcSize / Math.pow(1024, index)
const sizeStr = size.toFixed(2) //保留的小数位数
return sizeStr + ' ' + unitArr[index]
}
/**
* 将值复制到目标对象且以目标对象属性为准target: {a:1} source:{a:2,b:3} 结果为:{a:2}
* @param target 目标对象
* @param source 源对象
*/
export const copyValueToTarget = (target: any, source: any) => {
const newObj = Object.assign({}, target, source)
// 删除多余属性
Object.keys(newObj).forEach(key => {
// 如果不是target中的属性则删除
if (Object.keys(target).indexOf(key) === -1) {
delete newObj[key]
}
})
// 更新目标对象值
Object.assign(target, newObj)
}
/**
* 获取链接的参数值
* @param key 参数键名
* @param urlStr 链接地址,默认为当前浏览器的地址
*/
export const getUrlValue = (key: string, urlStr: string = location.href): string => {
if (!urlStr || !key) return ''
const url = new URL(decodeURIComponent(urlStr))
return url.searchParams.get(key) ?? ''
}
/**
* 获取链接的参数值(值类型)
* @param key 参数键名
* @param urlStr 链接地址,默认为当前浏览器的地址
*/
export const getUrlNumberValue = (key: string, urlStr: string = location.href): number => {
return toNumber(getUrlValue(key, urlStr))
}
/**
* 构建排序字段
* @param prop 字段名称
* @param order 顺序
*/
export const buildSortingField = ({ prop, order }) => {
return { field: prop, order: order === 'ascending' ? 'asc' : 'desc' }
}
// ========== NumberUtils 数字方法 ==========
/**
* 数组求和
*
* @param values 数字数组
* @return 求和结果,默认为 0
*/
export const getSumValue = (values: number[]): number => {
return values.reduce((prev, curr) => {
const value = Number(curr)
if (!Number.isNaN(value)) {
return prev + curr
} else {
return prev
}
}, 0)
}
// ========== 通用金额方法 ==========
/**
* 将一个整数转换为分数保留两位小数
* @param num
*/
export const formatToFraction = (num: number | string | undefined): string => {
if (typeof num === 'undefined') return '0.00'
const parsedNumber = typeof num === 'string' ? parseFloat(num) : num
return (parsedNumber / 100.0).toFixed(2)
}
/**
* 将一个数转换为 1.00 这样
* 数据呈现的时候使用
*
* @param num 整数
*/
// TODO @芋艿:看看怎么融合掉
export const floatToFixed2 = (num: number | string | undefined): string => {
let str = '0.00'
if (typeof num === 'undefined') {
return str
}
const f = formatToFraction(num)
const decimalPart = f.toString().split('.')[1]
const len = decimalPart ? decimalPart.length : 0
switch (len) {
case 0:
str = f.toString() + '.00'
break
case 1:
str = f.toString() + '0'
break
case 2:
str = f.toString()
break
}
return str
}
/**
* 将一个分数转换为整数
* @param num
*/
// TODO @芋艿:看看怎么融合掉
export const convertToInteger = (num: number | string | undefined): number => {
if (typeof num === 'undefined') return 0
const parsedNumber = typeof num === 'string' ? parseFloat(num) : num
// TODO 分转元后还有小数则四舍五入
return Math.round(parsedNumber * 100)
}
/**
* 元转分
*/
export const yuanToFen = (amount: string | number): number => {
return convertToInteger(amount)
}
/**
* 分转元
*/
export const fenToYuan = (price: string | number): string => {
return formatToFraction(price)
}
/**
* 计算环比
*
* @param value 当前数值
* @param reference 对比数值
*/
export const calculateRelativeRate = (value?: number, reference?: number) => {
// 防止除0
if (!reference) return 0
return ((100 * ((value || 0) - reference)) / reference).toFixed(0)
}
// ========== ERP 专属方法 ==========
const ERP_COUNT_DIGIT = 3
const ERP_PRICE_DIGIT = 2
/**
* 【ERP】格式化 Input 数字
*
* 例如说:库存数量
*
* @param num 数量
* @package digit 保留的小数位数
* @return 格式化后的数量
*/
export const erpNumberFormatter = (num: number | string | undefined, digit: number) => {
if (num == null) {
return ''
}
if (typeof num === 'string') {
num = parseFloat(num)
}
// 如果非 number则直接返回空串
if (isNaN(num)) {
return ''
}
return num.toFixed(digit)
}
/**
* 【ERP】格式化数量保留三位小数
*
* 例如说:库存数量
*
* @param num 数量
* @return 格式化后的数量
*/
export const erpCountInputFormatter = (num: number | string | undefined) => {
return erpNumberFormatter(num, ERP_COUNT_DIGIT)
}
// noinspection JSCommentMatchesSignature
/**
* 【ERP】格式化数量保留三位小数
*
* @param cellValue 数量
* @return 格式化后的数量
*/
export const erpCountTableColumnFormatter = (_, __, cellValue: any, ___) => {
return erpNumberFormatter(cellValue, ERP_COUNT_DIGIT)
}
/**
* 【ERP】格式化金额保留二位小数
*
* 例如说:库存数量
*
* @param num 数量
* @return 格式化后的数量
*/
export const erpPriceInputFormatter = (num: number | string | undefined) => {
return erpNumberFormatter(num, ERP_PRICE_DIGIT)
}
// noinspection JSCommentMatchesSignature
/**
* 【ERP】格式化金额保留二位小数
*
* @param cellValue 数量
* @return 格式化后的数量
*/
export const erpPriceTableColumnFormatter = (_, __, cellValue: any, ___) => {
return erpNumberFormatter(cellValue, ERP_PRICE_DIGIT)
}
/**
* 【ERP】价格计算四舍五入保留两位小数
*
* @param price 价格
* @param count 数量
* @return 总价格。如果有任一为空,则返回 undefined
*/
export const erpPriceMultiply = (price: number, count: number) => {
if (price == null || count == null) {
return undefined
}
return parseFloat((price * count).toFixed(ERP_PRICE_DIGIT))
}
/**
* 【ERP】百分比计算四舍五入保留两位小数
*
* 如果 total 为 0则返回 0
*
* @param value 当前值
* @param total 总值
*/
export const erpCalculatePercentage = (value: number, total: number) => {
if (total === 0) return 0
return ((value / total) * 100).toFixed(2)
}
/**
* 适配 echarts map 的地名
*
* @param areaName 地区名称
*/
export const areaReplace = (areaName: string) => {
if (!areaName) {
return areaName
}
return areaName
.replace('维吾尔自治区', '')
.replace('壮族自治区', '')
.replace('回族自治区', '')
.replace('自治区', '')
.replace('省', '')
}
/**
* bes64解密函数
*
* @param areaName 地区名称
*/
//
export const decryptFromBase64 = (base64Str: string) => {
try {
const binaryStr = atob(base64Str)
const encodedStr = binaryStr
.split('')
.map(char => {
return '%' + ('00' + char.charCodeAt(0).toString(16)).slice(-2)
})
.join('')
return decodeURIComponent(encodedStr)
} catch (error) {
console.error('解密出错:', error)
return null
}
}

117
src/utils/is.ts Normal file
View File

@@ -0,0 +1,117 @@
// copy to vben-admin
const toString = Object.prototype.toString
export const is = (val: unknown, type: string) => {
return toString.call(val) === `[object ${type}]`
}
export const isDef = <T = unknown>(val?: T): val is T => {
return typeof val !== 'undefined'
}
export const isUnDef = <T = unknown>(val?: T): val is T => {
return !isDef(val)
}
export const isObject = (val: any): val is Record<any, any> => {
return val !== null && is(val, 'Object')
}
export const isEmpty = <T = unknown>(val: T): val is T => {
if (val === null) {
return true
}
if (isArray(val) || isString(val)) {
return val.length === 0
}
if (val instanceof Map || val instanceof Set) {
return val.size === 0
}
if (isObject(val)) {
return Object.keys(val).length === 0
}
return false
}
export const isDate = (val: unknown): val is Date => {
return is(val, 'Date')
}
export const isNull = (val: unknown): val is null => {
return val === null
}
export const isNullAndUnDef = (val: unknown): val is null | undefined => {
return isUnDef(val) && isNull(val)
}
export const isNullOrUnDef = (val: unknown): val is null | undefined => {
return isUnDef(val) || isNull(val)
}
export const isNumber = (val: unknown): val is number => {
return is(val, 'Number')
}
export const isPromise = <T = any>(val: unknown): val is Promise<T> => {
return is(val, 'Promise') && isObject(val) && isFunction(val.then) && isFunction(val.catch)
}
export const isString = (val: unknown): val is string => {
return is(val, 'String')
}
export const isFunction = (val: unknown): val is Function => {
return typeof val === 'function'
}
export const isBoolean = (val: unknown): val is boolean => {
return is(val, 'Boolean')
}
export const isRegExp = (val: unknown): val is RegExp => {
return is(val, 'RegExp')
}
export const isArray = (val: any): val is Array<any> => {
return val && Array.isArray(val)
}
export const isWindow = (val: any): val is Window => {
return typeof window !== 'undefined' && is(val, 'Window')
}
export const isElement = (val: unknown): val is Element => {
return isObject(val) && !!val.tagName
}
export const isMap = (val: unknown): val is Map<any, any> => {
return is(val, 'Map')
}
export const isServer = typeof window === 'undefined'
export const isClient = !isServer
export const isUrl = (path: string): boolean => {
const reg =
/(((^https?:(?:\/\/)?)(?:[-:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&%@.\w_]*)#?(?:[\w]*))?)$/
return reg.test(path)
}
export const isDark = (): boolean => {
return window.matchMedia('(prefers-color-scheme: dark)').matches
}
// 是否是图片链接
export const isImgPath = (path: string): boolean => {
return /(https?:\/\/|data:image\/).*?\.(png|jpg|jpeg|gif|svg|webp|ico)/gi.test(path)
}
export const isEmptyVal = (val: any): boolean => {
return val === '' || val === null || val === undefined
}

View File

@@ -0,0 +1,31 @@
import { JSEncrypt } from 'jsencrypt'
// 密钥对生成 http://web.chacuo.net/netrsakeypair
const publicKey =
'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdH\n' +
'nzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ=='
const privateKey =
'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY\n' +
'7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKN\n' +
'PuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gA\n' +
'kM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWow\n' +
'cSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99Ecv\n' +
'DQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthh\n' +
'YhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3\n' +
'UP8iWi1Qw0Y='
// 加密
export const encrypt = (txt: string) => {
const encryptor = new JSEncrypt()
encryptor.setPublicKey(publicKey) // 设置公钥
return encryptor.encrypt(txt) // 对数据进行加密
}
// 解密
export const decrypt = (txt: string) => {
const encryptor = new JSEncrypt()
encryptor.setPrivateKey(privateKey) // 设置私钥
return encryptor.decrypt(txt) // 对数据进行解密
}

31
src/utils/jsencrypt.ts Normal file
View File

@@ -0,0 +1,31 @@
import { JSEncrypt } from 'jsencrypt'
// 密钥对生成 http://web.chacuo.net/netrsakeypair
const publicKey =
'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdH\n' +
'nzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ=='
const privateKey =
'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY\n' +
'7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKN\n' +
'PuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gA\n' +
'kM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWow\n' +
'cSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99Ecv\n' +
'DQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthh\n' +
'YhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3\n' +
'UP8iWi1Qw0Y='
// 加密
export const encrypt = (txt: string) => {
const encryptor = new JSEncrypt()
encryptor.setPublicKey(publicKey) // 设置公钥
return encryptor.encrypt(txt) // 对数据进行加密
}
// 解密
export const decrypt = (txt: string) => {
const encryptor = new JSEncrypt()
encryptor.setPrivateKey(privateKey) // 设置私钥
return encryptor.decrypt(txt) // 对数据进行解密
}

253
src/utils/routerHelper.ts Normal file
View File

@@ -0,0 +1,253 @@
import type { RouteLocationNormalized, Router, RouteRecordNormalized } from 'vue-router'
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import { isUrl } from '@/utils/is'
import { cloneDeep, omit } from 'lodash-es'
import qs from 'qs'
const modules = import.meta.glob('../views/**/*.{vue,tsx}')
/**
* 注册一个异步组件
* @param componentPath 例:/bpm/oa/leave/detail
*/
export const registerComponent = (componentPath: string) => {
for (const item in modules) {
if (item.includes(componentPath)) {
// 使用异步组件的方式来动态加载组件
// @ts-ignore
return defineAsyncComponent(modules[item])
}
}
}
/* Layout */
export const Layout = () => import('@/layouts/Layout.vue')
export const getParentLayout = () => {
return () =>
new Promise((resolve) => {
resolve({
name: 'ParentLayout'
})
})
}
// 按照路由中meta下的rank等级升序来排序路由
export const ascending = (arr: any[]) => {
arr.forEach((v) => {
if (v?.meta?.rank === null) v.meta.rank = undefined
if (v?.meta?.rank === 0) {
if (v.name !== 'home' && v.path !== '/') {
console.warn('rank only the home page can be 0')
}
}
})
return arr.sort((a: { meta: { rank: number } }, b: { meta: { rank: number } }) => {
return a?.meta?.rank - b?.meta?.rank
})
}
export const getRawRoute = (route: RouteLocationNormalized): RouteLocationNormalized => {
if (!route) return route
const { matched, ...opt } = route
return {
...opt,
matched: (matched
? matched.map((item) => ({
meta: item.meta,
name: item.name,
path: item.path
}))
: undefined) as RouteRecordNormalized[]
}
}
// 后端控制路由生成
export const generateRoute = (routes: AppCustomRouteRecordRaw[]): AppRouteRecordRaw[] => {
const res: AppRouteRecordRaw[] = []
const modulesRoutesKeys = Object.keys(modules)
for (const route of routes) {
// 1. 生成 meta 菜单元数据
const meta = {
title: route.name,
icon: route.icon,
hidden: !route.visible,
noCache: !route.keepAlive,
alwaysShow:
route.children &&
route.children.length === 1 &&
(route.alwaysShow !== undefined ? route.alwaysShow : true)
} as any
// 特殊逻辑:如果后端配置的 MenuDO.component 包含 ?,则表示需要传递参数
// 此时,我们需要解析参数,并且将参数放到 meta.query 中
// 这样,后续在 Vue 文件中,可以通过 const { currentRoute } = useRouter() 中,通过 meta.query 获取到参数
if (route.component && route.component.indexOf('?') > -1) {
const query = route.component.split('?')[1]
route.component = route.component.split('?')[0]
meta.query = qs.parse(query)
}
// 2. 生成 dataAppRouteRecordRaw
// 路由地址转首字母大写驼峰作为路由名称适配keepAlive
let data: AppRouteRecordRaw = {
path: route.path.indexOf('?') > -1 ? route.path.split('?')[0] : route.path,
name:
route.componentName && route.componentName.length > 0
? route.componentName
: toCamelCase(route.path, true),
redirect: route.redirect,
meta: meta
}
//处理顶级非目录路由
if (!route.children && route.parentId == 0 && route.component) {
data.component = Layout
data.meta = {}
data.name = toCamelCase(route.path, true) + 'Parent'
data.redirect = ''
meta.alwaysShow = true
const childrenData: AppRouteRecordRaw = {
path: '',
name:
route.componentName && route.componentName.length > 0
? route.componentName
: toCamelCase(route.path, true),
redirect: route.redirect,
meta: meta
}
const index = route?.component
? modulesRoutesKeys.findIndex((ev) => ev.includes(route.component))
: modulesRoutesKeys.findIndex((ev) => ev.includes(route.path))
childrenData.component = modules[modulesRoutesKeys[index]]
data.children = [childrenData]
} else {
// 目录
if (route.children) {
data.component = Layout
data.redirect = getRedirect(route.path, route.children)
// 外链
} else if (isUrl(route.path)) {
data = {
path: '/external-link',
component: Layout,
meta: {
name: route.name
},
children: [data]
} as AppRouteRecordRaw
// 菜单
} else {
// 对后端传component组件路径和不传做兼容如果后端传component组件路径那么path可以随便写如果不传component组件路径会根path保持一致
const index = route?.component
? modulesRoutesKeys.findIndex((ev) => ev.includes(route.component))
: modulesRoutesKeys.findIndex((ev) => ev.includes(route.path))
data.component = modules[modulesRoutesKeys[index]]
}
if (route.children) {
data.children = generateRoute(route.children)
}
}
res.push(data as AppRouteRecordRaw)
}
return res
}
export const getRedirect = (parentPath: string, children: AppCustomRouteRecordRaw[]) => {
if (!children || children.length == 0) {
return parentPath
}
const path = generateRoutePath(parentPath, children[0].path)
// 递归子节点
if (children[0].children) return getRedirect(path, children[0].children)
}
const generateRoutePath = (parentPath: string, path: string) => {
if (parentPath.endsWith('/')) {
parentPath = parentPath.slice(0, -1) // 移除默认的 /
}
if (!path.startsWith('/')) {
path = '/' + path
}
return parentPath + path
}
export const pathResolve = (parentPath: string, path: string) => {
if (isUrl(path)) return path
const childPath = path.startsWith('/') || !path ? path : `/${path}`
return `${parentPath}${childPath}`.replace(/\/\//g, '/')
}
// 路由降级
export const flatMultiLevelRoutes = (routes: AppRouteRecordRaw[]) => {
const modules: AppRouteRecordRaw[] = cloneDeep(routes)
for (let index = 0; index < modules.length; index++) {
const route = modules[index]
if (!isMultipleRoute(route)) {
continue
}
promoteRouteLevel(route)
}
return modules
}
// 层级是否大于2
const isMultipleRoute = (route: AppRouteRecordRaw) => {
if (!route || !Reflect.has(route, 'children') || !route.children?.length) {
return false
}
const children = route.children
let flag = false
for (let index = 0; index < children.length; index++) {
const child = children[index]
if (child.children?.length) {
flag = true
break
}
}
return flag
}
// 生成二级路由
const promoteRouteLevel = (route: AppRouteRecordRaw) => {
let router: Router | null = createRouter({
routes: [route as RouteRecordRaw],
history: createWebHashHistory()
})
const routes = router.getRoutes()
addToChildren(routes, route.children || [], route)
router = null
route.children = route.children?.map((item) => omit(item, 'children'))
}
// 添加所有子菜单
const addToChildren = (
routes: RouteRecordNormalized[],
children: AppRouteRecordRaw[],
routeModule: AppRouteRecordRaw
) => {
for (let index = 0; index < children.length; index++) {
const child = children[index]
const route = routes.find((item) => item.name === child.name)
if (!route) {
continue
}
routeModule.children = routeModule.children || []
if (!routeModule.children.find((item) => item.name === route.name)) {
routeModule.children?.push(route as unknown as AppRouteRecordRaw)
}
if (child.children?.length) {
addToChildren(routes, child.children, routeModule)
}
}
}
const toCamelCase = (str: string, upperCaseFirst: boolean) => {
str = (str || '')
.replace(/-(.)/g, function (group1: string) {
return group1.toUpperCase()
})
.replaceAll('-', '')
if (upperCaseFirst && str) {
str = str.charAt(0).toUpperCase() + str.slice(1)
}
return str
}

View File

@@ -1,216 +1,216 @@
import { reactive } from 'vue' import { reactive } from 'vue'
import createAxios from '@/utils/request' import createAxios from '@/utils/request'
import { requestPayload } from '@/utils/request' import { requestPayload } from '@/utils/request'
import { Method } from 'axios' import { Method } from 'axios'
import { mainHeight } from '@/utils/layout' import { mainHeight } from '@/utils/layout'
import { filtration } from './tableMethod' import { filtration } from './tableMethod'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
interface TableStoreParams { interface TableStoreParams {
url: string // 请求地址 url: string // 请求地址
pk?: string pk?: string
column: TableColumn[] column: TableColumn[]
params?: anyObj params?: anyObj
exportName?: any // 导出文件名 exportName?: any // 导出文件名
method?: Method // 请求方式 method?: Method // 请求方式
isWebPaging?: boolean // 是否前端分页 isWebPaging?: boolean // 是否前端分页
showPage?: boolean //是否需要分页 showPage?: boolean //是否需要分页
paramsPOST?: boolean // post请求 params传参 paramsPOST?: boolean // post请求 params传参
publicHeight?: number //计算高度 publicHeight?: number //计算高度
resetCallback?: () => void // 重置 resetCallback?: () => void // 重置
loadCallback?: () => void // 接口调用后的回调 loadCallback?: () => void // 接口调用后的回调
beforeSearchFun?: () => void // 接口调用前的回调 beforeSearchFun?: () => void // 接口调用前的回调
} }
export default class TableStore { export default class TableStore {
public url public url
public pk public pk
public method: Method public method: Method
public initData: any = null public initData: any = null
public exportName: any = null public exportName: any = null
public isWebPaging = false public isWebPaging = false
public paramsPOST = true public paramsPOST = true
public showPage = true public showPage = true
public table: CnTable = reactive({ public table: CnTable = reactive({
ref: null, ref: null,
selection: [], selection: [],
data: [], data: [],
copyData: [], copyData: [],
allData: [], allData: [],
allFlag: false, allFlag: false,
webPagingData: [], webPagingData: [],
total: 0, total: 0,
params: { params: {
pageNum: 1, pageNum: 1,
pageSize: 20 pageSize: 20
}, },
loading: true, loading: true,
column: [], column: [],
loadCallback: null, loadCallback: null,
resetCallback: null, resetCallback: null,
beforeSearchFun: null, beforeSearchFun: null,
height: '', height: '',
publicHeight: 0 publicHeight: 0
}) })
constructor(public options: TableStoreParams) { constructor(public options: TableStoreParams) {
this.url = options.url this.url = options.url
this.pk = options.pk || 'id' this.pk = options.pk || 'id'
this.paramsPOST = options.paramsPOST || false this.paramsPOST = options.paramsPOST || false
this.isWebPaging = options.isWebPaging || false this.isWebPaging = options.isWebPaging || false
this.exportName = options.exportName || null this.exportName = options.exportName || null
this.method = options.method || 'GET' this.method = options.method || 'GET'
this.table.column = options.column this.table.column = options.column
this.showPage = options.showPage !== false this.showPage = options.showPage !== false
this.table.publicHeight = options.publicHeight || 0 this.table.publicHeight = options.publicHeight || 0
this.table.resetCallback = options.resetCallback || null this.table.resetCallback = options.resetCallback || null
this.table.loadCallback = options.loadCallback || null this.table.loadCallback = options.loadCallback || null
this.table.beforeSearchFun = options.beforeSearchFun || null this.table.beforeSearchFun = options.beforeSearchFun || null
Object.assign(this.table.params, options.params) Object.assign(this.table.params, options.params)
this.table.height = mainHeight(20 + (this.showPage ? 58 : 0) + this.table.publicHeight).height as string this.table.height = mainHeight(20 + (this.showPage ? 58 : 0) + this.table.publicHeight).height as string
} }
index() { index() {
this.table.beforeSearchFun && this.table.beforeSearchFun() this.table.beforeSearchFun && this.table.beforeSearchFun()
this.table.data = [] this.table.data = []
this.table.loading = true this.table.loading = true
// 重置用的数据数据 // 重置用的数据数据
if (!this.initData) { if (!this.initData) {
this.initData = JSON.parse(JSON.stringify(this.table.params)) this.initData = JSON.parse(JSON.stringify(this.table.params))
} }
createAxios( createAxios(
Object.assign( Object.assign(
{ {
url: this.url, url: this.url,
method: this.method method: this.method
}, },
requestPayload(this.method, this.table.params, this.paramsPOST) requestPayload(this.method, this.table.params, this.paramsPOST)
) )
) )
.then((res: any) => { .then((res: any) => {
if (res.data) { if (res.data) {
this.table.data = res.data.records || res.data this.table.data = res.data.records || res.data
this.table.total = res.data?.total || res.data.length || 0 this.table.total = res.data?.total || res.data.length || 0
} else { } else {
this.table.data = [] this.table.data = []
this.table.total = 0 this.table.total = 0
} }
this.table.copyData = filtration(this.table.data) this.table.copyData = filtration(this.table.data)
if (Array.isArray(res)) { if (Array.isArray(res)) {
this.table.data = res this.table.data = res
} }
if (this.isWebPaging) { if (this.isWebPaging) {
this.table.webPagingData = window.XEUtils.chunk(this.table.data, this.table.params.pageSize) this.table.webPagingData = window.XEUtils.chunk(this.table.data, this.table.params.pageSize)
this.table.data = this.table.webPagingData[this.table.params.pageNum - 1] this.table.data = this.table.webPagingData[this.table.params.pageNum - 1]
} }
this.table.loadCallback && this.table.loadCallback() this.table.loadCallback && this.table.loadCallback()
this.table.loading = false this.table.loading = false
}) })
.catch(() => { .catch(() => {
this.table.loading = false this.table.loading = false
}) })
} }
/** /**
* 表格内的事件统一响应 * 表格内的事件统一响应
* @param event 事件:selection-change=选中项改变,page-size-change=每页数量改变,current-page-change=翻页 * @param event 事件:selection-change=选中项改变,page-size-change=每页数量改变,current-page-change=翻页
* @param data 携带数据 * @param data 携带数据
*/ */
onTableAction = (event: string, data: anyObj) => { onTableAction = (event: string, data: anyObj) => {
const actionFun = new Map([ const actionFun = new Map([
[ [
'search', 'search',
() => { () => {
this.table.params.pageNum = 1 this.table.params.pageNum = 1
this.index() this.index()
} }
], ],
[ [
'reset', 'reset',
() => { () => {
delete this.initData.pageSize delete this.initData.pageSize
// console.log(this.table.params) // console.log(this.table.params)
// console.log(this.initData) // console.log(this.initData)
Object.assign(this.table.params, this.initData) Object.assign(this.table.params, this.initData)
this.index() this.index()
this.table.resetCallback && this.table.resetCallback() this.table.resetCallback && this.table.resetCallback()
} }
], ],
[ [
'selection-change', 'selection-change',
() => { () => {
this.table.selection = data as TableRow[] this.table.selection = data as TableRow[]
} }
], ],
[ [
'page-size-change', 'page-size-change',
() => { () => {
this.table.params.pageSize = data.size this.table.params.pageSize = data.size
this.table.params.pageNum = 1 this.table.params.pageNum = 1
if (this.isWebPaging) { if (this.isWebPaging) {
this.table.webPagingData = window.XEUtils.chunk( this.table.webPagingData = window.XEUtils.chunk(
window.XEUtils.flatten(this.table.webPagingData), window.XEUtils.flatten(this.table.webPagingData),
this.table.params.pageSize this.table.params.pageSize
) )
this.table.data = this.table.webPagingData[this.table.params.pageNum - 1] this.table.data = this.table.webPagingData[this.table.params.pageNum - 1]
} else { } else {
this.index() this.index()
} }
} }
], ],
[ [
'current-page-change', 'current-page-change',
() => { () => {
this.table.params.pageNum = data.page this.table.params.pageNum = data.page
if (this.isWebPaging) { if (this.isWebPaging) {
this.table.data = [] this.table.data = []
requestAnimationFrame(() => { requestAnimationFrame(() => {
this.table.data = this.table.webPagingData[data.page - 1] this.table.data = this.table.webPagingData[data.page - 1]
}) })
} else { } else {
this.index() this.index()
} }
} }
], ],
[ [
'field-change', 'field-change',
() => { () => {
console.warn('field-change') console.warn('field-change')
} }
], ],
[ [
'default', 'default',
() => { () => {
console.warn('No action defined') console.warn('No action defined')
} }
], ],
[ [
'export', 'export',
() => { () => {
ElMessage({ ElMessage({
message: '正在导出,请稍等...', message: '正在导出,请稍等...',
type: 'info', type: 'info',
duration: 1000 duration: 1000
}) })
let params = { ...this.table.params, pageNum: 1, pageSize: this.table.total } let params = { ...this.table.params, pageNum: 1, pageSize: this.table.total }
setTimeout(() => { setTimeout(() => {
createAxios( createAxios(
Object.assign( Object.assign(
{ {
url: this.url, url: this.url,
method: this.method method: this.method
}, },
requestPayload(this.method, params, this.paramsPOST) requestPayload(this.method, params, this.paramsPOST)
) )
).then(res => { ).then(res => {
this.table.allData = filtration(res.data.records || res.data) this.table.allData = filtration(res.data.records || res.data)
this.table.allFlag = data.showAllFlag || true this.table.allFlag = data.showAllFlag || true
}) })
}, 1500) }, 1500)
} }
] ]
]) ])
const action = actionFun.get(event) || actionFun.get('default') const action = actionFun.get(event) || actionFun.get('default')
action!.call(this) action!.call(this)
} }
} }

400
src/utils/tree.ts Normal file
View File

@@ -0,0 +1,400 @@
interface TreeHelperConfig {
id: string
children: string
pid: string
}
const DEFAULT_CONFIG: TreeHelperConfig = {
id: 'id',
children: 'children',
pid: 'pid'
}
export const defaultProps = {
children: 'children',
label: 'name',
value: 'id',
isLeaf: 'leaf',
emitPath: false // 用于 cascader 组件:在选中节点改变时,是否返回由该节点所在的各级菜单的值所组成的数组,若设置 false则只返回该节点的值
}
const getConfig = (config: Partial<TreeHelperConfig>) => Object.assign({}, DEFAULT_CONFIG, config)
// tree from list
export const listToTree = <T = any>(list: any[], config: Partial<TreeHelperConfig> = {}): T[] => {
const conf = getConfig(config) as TreeHelperConfig
const nodeMap = new Map()
const result: T[] = []
const { id, children, pid } = conf
for (const node of list) {
node[children] = node[children] || []
nodeMap.set(node[id], node)
}
for (const node of list) {
const parent = nodeMap.get(node[pid])
;(parent ? parent.children : result).push(node)
}
return result
}
export const treeToList = <T = any>(tree: any, config: Partial<TreeHelperConfig> = {}): T => {
config = getConfig(config)
const { children } = config
const result: any = [...tree]
for (let i = 0; i < result.length; i++) {
if (!result[i][children!]) continue
result.splice(i + 1, 0, ...result[i][children!])
}
return result
}
export const findNode = <T = any>(
tree: any,
func: Fn,
config: Partial<TreeHelperConfig> = {}
): T | null => {
config = getConfig(config)
const { children } = config
const list = [...tree]
for (const node of list) {
if (func(node)) return node
node[children!] && list.push(...node[children!])
}
return null
}
export const findNodeAll = <T = any>(
tree: any,
func: Fn,
config: Partial<TreeHelperConfig> = {}
): T[] => {
config = getConfig(config)
const { children } = config
const list = [...tree]
const result: T[] = []
for (const node of list) {
func(node) && result.push(node)
node[children!] && list.push(...node[children!])
}
return result
}
export const findPath = <T = any>(
tree: any,
func: Fn,
config: Partial<TreeHelperConfig> = {}
): T | T[] | null => {
config = getConfig(config)
const path: T[] = []
const list = [...tree]
const visitedSet = new Set()
const { children } = config
while (list.length) {
const node = list[0]
if (visitedSet.has(node)) {
path.pop()
list.shift()
} else {
visitedSet.add(node)
node[children!] && list.unshift(...node[children!])
path.push(node)
if (func(node)) {
return path
}
}
}
return null
}
export const findPathAll = (tree: any, func: Fn, config: Partial<TreeHelperConfig> = {}) => {
config = getConfig(config)
const path: any[] = []
const list = [...tree]
const result: any[] = []
const visitedSet = new Set(),
{ children } = config
while (list.length) {
const node = list[0]
if (visitedSet.has(node)) {
path.pop()
list.shift()
} else {
visitedSet.add(node)
node[children!] && list.unshift(...node[children!])
path.push(node)
func(node) && result.push([...path])
}
}
return result
}
export const filter = <T = any>(
tree: T[],
func: (n: T) => boolean,
config: Partial<TreeHelperConfig> = {}
): T[] => {
config = getConfig(config)
const children = config.children as string
function listFilter(list: T[]) {
return list
.map((node: any) => ({ ...node }))
.filter((node) => {
node[children] = node[children] && listFilter(node[children])
return func(node) || (node[children] && node[children].length)
})
}
return listFilter(tree)
}
export const forEach = <T = any>(
tree: T[],
func: (n: T) => any,
config: Partial<TreeHelperConfig> = {}
): void => {
config = getConfig(config)
const list: any[] = [...tree]
const { children } = config
for (let i = 0; i < list.length; i++) {
// func 返回true就终止遍历避免大量节点场景下无意义循环引起浏览器卡顿
if (func(list[i])) {
return
}
children && list[i][children] && list.splice(i + 1, 0, ...list[i][children])
}
}
/**
* @description: Extract tree specified structure
*/
export const treeMap = <T = any>(
treeData: T[],
opt: { children?: string; conversion: Fn }
): T[] => {
return treeData.map((item) => treeMapEach(item, opt))
}
/**
* @description: Extract tree specified structure
*/
export const treeMapEach = (
data: any,
{ children = 'children', conversion }: { children?: string; conversion: Fn }
) => {
const haveChildren = Array.isArray(data[children]) && data[children].length > 0
const conversionData = conversion(data) || {}
if (haveChildren) {
return {
...conversionData,
[children]: data[children].map((i: number) =>
treeMapEach(i, {
children,
conversion
})
)
}
} else {
return {
...conversionData
}
}
}
/**
* 递归遍历树结构
* @param treeDatas 树
* @param callBack 回调
* @param parentNode 父节点
*/
export const eachTree = (treeDatas: any[], callBack: Fn, parentNode = {}) => {
treeDatas.forEach((element) => {
const newNode = callBack(element, parentNode) || element
if (element.children) {
eachTree(element.children, callBack, newNode)
}
})
}
/**
* 构造树型结构数据
* @param {*} data 数据源
* @param {*} id id字段 默认 'id'
* @param {*} parentId 父节点字段 默认 'parentId'
* @param {*} children 孩子节点字段 默认 'children'
*/
export const handleTree = (data: any[], id?: string, parentId?: string, children?: string) => {
if (!Array.isArray(data)) {
console.warn('data must be an array')
return []
}
const config = {
id: id || 'id',
parentId: parentId || 'parentId',
childrenList: children || 'children'
}
const childrenListMap = {}
const nodeIds = {}
const tree: any[] = []
for (const d of data) {
const parentId = d[config.parentId]
if (childrenListMap[parentId] == null) {
childrenListMap[parentId] = []
}
nodeIds[d[config.id]] = d
childrenListMap[parentId].push(d)
}
for (const d of data) {
const parentId = d[config.parentId]
if (nodeIds[parentId] == null) {
tree.push(d)
}
}
for (const t of tree) {
adaptToChildrenList(t)
}
function adaptToChildrenList(o) {
if (childrenListMap[o[config.id]] !== null) {
o[config.childrenList] = childrenListMap[o[config.id]]
}
if (o[config.childrenList]) {
for (const c of o[config.childrenList]) {
adaptToChildrenList(c)
}
}
}
return tree
}
/**
* 构造树型结构数据
* @param {*} data 数据源
* @param {*} id id字段 默认 'id'
* @param {*} parentId 父节点字段 默认 'parentId'
* @param {*} children 孩子节点字段 默认 'children'
* @param {*} rootId 根Id 默认 0
*/
// @ts-ignore
export const handleTree2 = (data, id, parentId, children, rootId) => {
id = id || 'id'
parentId = parentId || 'parentId'
// children = children || 'children'
rootId =
rootId ||
Math.min(
...data.map((item) => {
return item[parentId]
})
) ||
0
// 对源数据深度克隆
const cloneData = JSON.parse(JSON.stringify(data))
// 循环所有项
const treeData = cloneData.filter((father) => {
const branchArr = cloneData.filter((child) => {
// 返回每一项的子级数组
return father[id] === child[parentId]
})
branchArr.length > 0 ? (father.children = branchArr) : ''
// 返回第一层
return father[parentId] === rootId
})
return treeData !== '' ? treeData : data
}
/**
* 校验选中的节点,是否为指定 level
*
* @param tree 要操作的树结构数据
* @param nodeId 需要判断在什么层级的数据
* @param level 检查的级别, 默认检查到二级
* @return true 是false 否
*/
export const checkSelectedNode = (tree: any[], nodeId: any, level = 2): boolean => {
if (typeof tree === 'undefined' || !Array.isArray(tree) || tree.length === 0) {
console.warn('tree must be an array')
return false
}
// 校验是否是一级节点
if (tree.some((item) => item.id === nodeId)) {
return false
}
// 递归计数
let count = 1
// 深层次校验
function performAThoroughValidation(arr: any[]): boolean {
count += 1
for (const item of arr) {
if (item.id === nodeId) {
return true
} else if (typeof item.children !== 'undefined' && item.children.length !== 0) {
if (performAThoroughValidation(item.children)) {
return true
}
}
}
return false
}
for (const item of tree) {
count = 1
if (performAThoroughValidation(item.children)) {
// 找到后对比是否是期望的层级
if (count >= level) {
return true
}
}
}
return false
}
/**
* 获取节点的完整结构
* @param tree 树数据
* @param nodeId 节点 id
*/
export const treeToString = (tree: any[], nodeId) => {
if (typeof tree === 'undefined' || !Array.isArray(tree) || tree.length === 0) {
console.warn('tree must be an array')
return ''
}
// 校验是否是一级节点
const node = tree.find((item) => item.id === nodeId)
if (typeof node !== 'undefined') {
return node.name
}
let str = ''
function performAThoroughValidation(arr) {
for (const item of arr) {
if (item.id === nodeId) {
str += ` / ${item.name}`
return true
} else if (typeof item.children !== 'undefined' && item.children.length !== 0) {
str += ` / ${item.name}`
if (performAThoroughValidation(item.children)) {
return true
}
}
}
return false
}
for (const item of tree) {
str = `${item.name}`
if (performAThoroughValidation(item.children)) {
break
}
}
return str
}

View File

@@ -1,129 +1,129 @@
<template> <template>
<!-- 异常事件 --> <!-- 异常事件 -->
<TableHeader datePicker ref="refheader" showExport> <TableHeader datePicker ref="refheader" showExport>
<!-- <template v-slot:select> <!-- <template v-slot:select>
<el-form-item label="数据来源"> <el-form-item label="数据来源">
<el-cascader <el-cascader
placeholder="请选择数据来源" placeholder="请选择数据来源"
@change="sourceChange" @change="sourceChange"
:options="props.deviceTree" :options="props.deviceTree"
:show-all-levels="false" :show-all-levels="false"
:props="{ checkStrictly: true }" :props="{ checkStrictly: true }"
clearable clearable
></el-cascader> ></el-cascader>
</el-form-item> </el-form-item>
<el-form-item label="级别"> <el-form-item label="级别">
<el-select v-model.trim="tableStore.table.params.level" placeholder="请选择级别" clearable> <el-select v-model.trim="tableStore.table.params.level" placeholder="请选择级别" clearable>
<el-option <el-option
v-for="item in rankOptions" v-for="item in rankOptions"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value" :value="item.value"
></el-option> ></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</template> --> </template> -->
<template #select> <template #select>
<el-form-item label="设备名称"> <el-form-item label="设备名称">
<el-input <el-input
maxlength="32" maxlength="32"
clearable clearable
show-word-limit show-word-limit
v-model.trim="tableStore.table.params.searchValue" v-model.trim="tableStore.table.params.searchValue"
placeholder="请输入设备名称" placeholder="请输入设备名称"
/> />
</el-form-item> </el-form-item>
</template> </template>
</TableHeader> </TableHeader>
<!-- <div style="height: 300px;"> --> <!-- <div style="height: 300px;"> -->
<Table ref="tableRef" :isGroup="true" /> <Table ref="tableRef" :isGroup="true" />
<!-- </div> --> <!-- </div> -->
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, provide } from 'vue' import { ref, onMounted, provide } from 'vue'
import TableStore from '@/utils/tableStore' import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue' import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import { mainHeight } from '@/utils/layout' import { mainHeight } from '@/utils/layout'
const props = defineProps(['deviceTree']) const props = defineProps(['deviceTree'])
const refheader = ref() const refheader = ref()
const deviceTree = ref([]) const deviceTree = ref([])
const tabsList = ref([ const tabsList = ref([
{ {
label: '设备告警', label: '设备告警',
name: 3 name: 3
}, },
{ {
label: '稳态越限告警', label: '稳态越限告警',
name: 1 name: 1
}, },
{ {
label: '暂态事件', label: '暂态事件',
name: 0 name: 0
} }
]) ])
const rankOptions = ref([ const rankOptions = ref([
{ {
value: '1', value: '1',
label: '1级' label: '1级'
}, },
{ {
value: '2', value: '2',
label: '2级' label: '2级'
}, },
{ {
value: '3', value: '3',
label: '3级' label: '3级'
} }
]) ])
const tableStore = new TableStore({ const tableStore = new TableStore({
url: '/zl-event-boot/csDevErrEvt/list', url: '/zl-event-boot/csDevErrEvt/list',
method: 'POST', method: 'POST',
exportName: '异常事件', exportName: '异常事件',
publicHeight: 65, publicHeight: 65,
column: [ column: [
{ {
title: '序号', title: '序号',
width: 80, width: 80,
formatter: (row: any) => { formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1 return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
} }
}, },
{ title: '设备名称', field: 'ndid', align: 'center' }, { title: '设备名称', field: 'ndid', align: 'center' },
{ title: '异常时间', field: 'evtTime', align: 'center', sortable: true }, { title: '异常时间', field: 'evtTime', align: 'center', sortable: true },
{ title: '告警代码', field: 'code', align: 'center', sortable: true } { title: '告警代码', field: 'code', align: 'center', sortable: true }
] ]
}) })
provide('tableStore', tableStore) provide('tableStore', tableStore)
// "target": [], // "target": [],
// "type": "", // "type": "",
// "userId": "" // "userId": ""
tableStore.table.params.engineeringid = '' tableStore.table.params.engineeringid = ''
tableStore.table.params.projectId = '' tableStore.table.params.projectId = ''
tableStore.table.params.deviceId = '' tableStore.table.params.deviceId = ''
tableStore.table.params.type = 3 tableStore.table.params.type = 3
tableStore.table.params.eventIds = [] tableStore.table.params.eventIds = []
tableStore.table.params.status = '' tableStore.table.params.status = ''
tableStore.table.params.target = [] tableStore.table.params.target = []
tableStore.table.params.userId = '' tableStore.table.params.userId = ''
tableStore.table.params.searchValue = '' tableStore.table.params.searchValue = ''
const sourceChange = (e: any) => { const sourceChange = (e: any) => {
tableStore.table.params.engineeringid = e[0] || '' tableStore.table.params.engineeringid = e[0] || ''
tableStore.table.params.projectId = e[1] || '' tableStore.table.params.projectId = e[1] || ''
tableStore.table.params.deviceId = e[2] || '' tableStore.table.params.deviceId = e[2] || ''
} }
onMounted(() => { onMounted(() => {
tableStore.index() tableStore.index()
}) })
setTimeout(() => { setTimeout(() => {
tableStore.table.height = mainHeight(200).height as any tableStore.table.height = mainHeight(200).height as any
}, 0) }, 0)
const addMenu = () => {} const addMenu = () => {}
</script> </script>
<style></style> <style></style>

View File

@@ -1,190 +1,190 @@
<template> <template>
<TableHeader datePicker ref="refheader" showExport> <TableHeader datePicker ref="refheader" showExport>
<template v-slot:select> <template v-slot:select>
<el-form-item label="数据来源"> <el-form-item label="数据来源">
<el-cascader <el-cascader
v-model.trim="tableStore.table.params.cascader" v-model.trim="tableStore.table.params.cascader"
filterable filterable
placeholder="请选择数据来源" placeholder="请选择数据来源"
@change="sourceChange" @change="sourceChange"
:options="deviceTreeOptions" :options="deviceTreeOptions"
:show-all-levels="false" :show-all-levels="false"
:props="{ checkStrictly: true }" :props="{ checkStrictly: true }"
clearable clearable
></el-cascader> ></el-cascader>
<!-- <el-input maxlength="32" show-word-limit v-model.trim="tableStore.table.params.searchValue" placeholder="请输入设备名称" /> --> <!-- <el-input maxlength="32" show-word-limit v-model.trim="tableStore.table.params.searchValue" placeholder="请输入设备名称" /> -->
</el-form-item> </el-form-item>
<el-form-item label="级别"> <el-form-item label="级别">
<el-select v-model.trim="tableStore.table.params.level" placeholder="请选择级别" clearable> <el-select v-model.trim="tableStore.table.params.level" placeholder="请选择级别" clearable>
<el-option <el-option
v-for="item in rankOptions" v-for="item in rankOptions"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value" :value="item.value"
></el-option> ></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</template> </template>
</TableHeader> </TableHeader>
<!-- <div style="height: 300px;"> --> <!-- <div style="height: 300px;"> -->
<Table ref="tableRef" :isGroup="true" /> <Table ref="tableRef" :isGroup="true" />
<!-- </div> --> <!-- </div> -->
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, provide } from 'vue' import { ref, onMounted, provide } from 'vue'
import TableStore from '@/utils/tableStore' import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue' import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import { mainHeight } from '@/utils/layout' import { mainHeight } from '@/utils/layout'
const props = defineProps(['deviceTree']) const props = defineProps(['deviceTree'])
const refheader = ref() const refheader = ref()
const deviceTree = ref([]) const deviceTree = ref([])
const tabsList = ref([ const tabsList = ref([
{ {
label: '设备告警', label: '设备告警',
name: 3 name: 3
}, },
{ {
label: '稳态越限告警', label: '稳态越限告警',
name: 1 name: 1
}, },
{ {
label: '暂态事件', label: '暂态事件',
name: 0 name: 0
} }
]) ])
const rankOptions = ref([ const rankOptions = ref([
{ {
value: '1', value: '1',
label: '1级' label: '1级'
}, },
{ {
value: '2', value: '2',
label: '2级' label: '2级'
}, },
{ {
value: '3', value: '3',
label: '3级' label: '3级'
} }
]) ])
const tableStore = new TableStore({ const tableStore = new TableStore({
url: '/cs-harmonic-boot/eventUser/queryEventpageWeb', url: '/cs-harmonic-boot/eventUser/queryEventpageWeb',
method: 'POST', method: 'POST',
exportName: '设备告警', exportName: '设备告警',
publicHeight: 65, publicHeight: 65,
column: [ column: [
{ {
title: '序号', title: '序号',
width: 80, width: 80,
formatter: (row: any) => { formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1 return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
} }
}, },
{ title: '设备名称', field: 'equipmentName', align: 'center' }, { title: '设备名称', field: 'equipmentName', align: 'center' },
{ title: '工程名称', field: 'engineeringName', align: 'center' }, { title: '工程名称', field: 'engineeringName', align: 'center' },
{ title: '项目名称', field: 'projectName', align: 'center' }, { title: '项目名称', field: 'projectName', align: 'center' },
{ title: '发生时刻', field: 'startTime', align: 'center', minWidth: 110, sortable: true }, { title: '发生时刻', field: 'startTime', align: 'center', minWidth: 110, sortable: true },
{ {
title: '模块信息', title: '模块信息',
field: 'moduleNo', field: 'moduleNo',
align: 'center', align: 'center',
formatter: (row: any) => { formatter: (row: any) => {
return row.cellValue ? row.cellValue : '/' return row.cellValue ? row.cellValue : '/'
} }
}, },
{ {
title: '告警代码', title: '告警代码',
field: 'code', field: 'code',
align: 'center', align: 'center',
formatter: (row: any) => { formatter: (row: any) => {
return row.cellValue ? row.cellValue : '/' return row.cellValue ? row.cellValue : '/'
}, },
sortable: true sortable: true
}, },
{ {
title: '事件描述', title: '事件描述',
field: 'showName' field: 'showName'
}, },
{ {
title: '级别', title: '级别',
field: 'level', field: 'level',
render: 'tag', render: 'tag',
custom: { custom: {
1: 'danger', 1: 'danger',
2: 'warning', 2: 'warning',
3: 'success' 3: 'success'
}, },
replaceValue: { replaceValue: {
1: '1级', 1: '1级',
2: '2级', 2: '2级',
3: '3级' 3: '3级'
} }
} }
// { // {
// title: '级别', // title: '级别',
// field: 'level', // field: 'level',
// formatter: (row: any) => { // formatter: (row: any) => {
// return row.cellValue == 1 ? '1级' : row.cellValue == 2 ? '2级' : row.cellValue == 3 ? '3级' : '/' // return row.cellValue == 1 ? '1级' : row.cellValue == 2 ? '2级' : row.cellValue == 3 ? '3级' : '/'
// } // }
// } // }
], ],
beforeSearchFun: () => {} beforeSearchFun: () => {}
}) })
provide('tableStore', tableStore) provide('tableStore', tableStore)
// "target": [], // "target": [],
// "type": "", // "type": "",
// "userId": "" // "userId": ""
tableStore.table.params.cascader = '' tableStore.table.params.cascader = ''
tableStore.table.params.level = '' tableStore.table.params.level = ''
tableStore.table.params.engineeringid = '' tableStore.table.params.engineeringid = ''
tableStore.table.params.projectId = '' tableStore.table.params.projectId = ''
tableStore.table.params.deviceId = '' tableStore.table.params.deviceId = ''
tableStore.table.params.type = 3 tableStore.table.params.type = 3
tableStore.table.params.eventIds = [] tableStore.table.params.eventIds = []
tableStore.table.params.status = '' tableStore.table.params.status = ''
tableStore.table.params.target = [] tableStore.table.params.target = []
tableStore.table.params.userId = '' tableStore.table.params.userId = ''
tableStore.table.params.deviceTypeId = '' tableStore.table.params.deviceTypeId = ''
tableStore.table.params.deviceTypeName = '' tableStore.table.params.deviceTypeName = ''
const deviceTreeOptions = ref<any>(props.deviceTree) const deviceTreeOptions = ref<any>(props.deviceTree)
deviceTreeOptions.value.map((item: any, index: any) => { deviceTreeOptions.value.map((item: any, index: any) => {
if (item.children.length == 0) { if (item.children.length == 0) {
deviceTreeOptions.value.splice(index, 1) deviceTreeOptions.value.splice(index, 1)
} }
}) })
const sourceChange = (e: any) => { const sourceChange = (e: any) => {
tableStore.table.params.deviceTypeId = '' tableStore.table.params.deviceTypeId = ''
tableStore.table.params.engineeringid = '' tableStore.table.params.engineeringid = ''
tableStore.table.params.projectId = '' tableStore.table.params.projectId = ''
tableStore.table.params.deviceId = '' tableStore.table.params.deviceId = ''
if (e) { if (e) {
let name = deviceTreeOptions.value.filter((item: any) => { let name = deviceTreeOptions.value.filter((item: any) => {
return item.id == e[0] return item.id == e[0]
})[0].name })[0].name
tableStore.table.params.deviceTypeName = name tableStore.table.params.deviceTypeName = name
if (name == '便携式设备') { if (name == '便携式设备') {
tableStore.table.params.deviceTypeId = e[0] || '' tableStore.table.params.deviceTypeId = e[0] || ''
tableStore.table.params.deviceId = e[1] || '' tableStore.table.params.deviceId = e[1] || ''
} else { } else {
tableStore.table.params.deviceTypeId = e[0] || '' tableStore.table.params.deviceTypeId = e[0] || ''
tableStore.table.params.engineeringid = e[1] || '' tableStore.table.params.engineeringid = e[1] || ''
tableStore.table.params.projectId = e[2] || '' tableStore.table.params.projectId = e[2] || ''
} }
} }
} }
onMounted(() => { onMounted(() => {
tableStore.index() tableStore.index()
}) })
setTimeout(() => { setTimeout(() => {
// tableStore.table.height = mainHeight(200).height as any // tableStore.table.height = mainHeight(200).height as any
}, 0) }, 0)
const addMenu = () => {} const addMenu = () => {}
</script> </script>
<style></style> <style></style>

View File

@@ -1,147 +1,147 @@
<template> <template>
<TableHeader datePicker ref="refheader" showExport> <TableHeader datePicker ref="refheader" showExport>
<template v-slot:select> <template v-slot:select>
<el-form-item label="数据来源"> <el-form-item label="数据来源">
<el-cascader <el-cascader
v-model.trim="tableStore.table.params.cascader" v-model.trim="tableStore.table.params.cascader"
filterable filterable
placeholder="请选择数据来源" placeholder="请选择数据来源"
@change="sourceChange" @change="sourceChange"
:options="deviceTreeOptions" :options="deviceTreeOptions"
:show-all-levels="false" :show-all-levels="false"
:props="{ checkStrictly: true }" :props="{ checkStrictly: true }"
clearable clearable
></el-cascader> ></el-cascader>
<!-- <el-input maxlength="32" show-word-limit v-model.trim="tableStore.table.params.searchValue" placeholder="请输入设备名称" /> --> <!-- <el-input maxlength="32" show-word-limit v-model.trim="tableStore.table.params.searchValue" placeholder="请输入设备名称" /> -->
</el-form-item> </el-form-item>
<!-- <el-form-item label="级别"> <!-- <el-form-item label="级别">
<el-select v-model.trim="tableStore.table.params.level" placeholder="请选择级别" clearable> <el-select v-model.trim="tableStore.table.params.level" placeholder="请选择级别" clearable>
<el-option <el-option
v-for="item in rankOptions" v-for="item in rankOptions"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value" :value="item.value"
></el-option> ></el-option>
</el-select> </el-select>
</el-form-item> --> </el-form-item> -->
</template> </template>
</TableHeader> </TableHeader>
<!-- <div style="height: 300px;"> --> <!-- <div style="height: 300px;"> -->
<Table ref="tableRef" :isGroup="true" /> <Table ref="tableRef" :isGroup="true" />
<!-- </div> --> <!-- </div> -->
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, provide } from 'vue' import { ref, onMounted, provide } from 'vue'
import TableStore from '@/utils/tableStore' import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue' import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import { mainHeight } from '@/utils/layout' import { mainHeight } from '@/utils/layout'
const props = defineProps(['deviceTree']) const props = defineProps(['deviceTree'])
const refheader = ref() const refheader = ref()
const deviceTree = ref([]) const deviceTree = ref([])
const tabsList = ref([ const tabsList = ref([
{ {
label: '设备告警', label: '设备告警',
name: 3 name: 3
}, },
{ {
label: '稳态越限告警', label: '稳态越限告警',
name: 1 name: 1
}, },
{ {
label: '暂态事件', label: '暂态事件',
name: 0 name: 0
} }
]) ])
const rankOptions = ref([ const rankOptions = ref([
{ {
value: '1', value: '1',
label: '1级' label: '1级'
}, },
{ {
value: '2', value: '2',
label: '2级' label: '2级'
}, },
{ {
value: '3', value: '3',
label: '3级' label: '3级'
} }
]) ])
const tableStore = new TableStore({ const tableStore = new TableStore({
url: '/cs-harmonic-boot/eventUser/queryEventpageWeb', url: '/cs-harmonic-boot/eventUser/queryEventpageWeb',
method: 'POST', method: 'POST',
exportName: '稳态越限告警', exportName: '稳态越限告警',
publicHeight: 65, publicHeight: 65,
column: [ column: [
{ {
title: '序号', title: '序号',
width: 80, width: 80,
formatter: (row: any) => { formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1 return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
} }
}, },
{ title: '设备名称', field: 'equipmentName', align: 'center' }, { title: '设备名称', field: 'equipmentName', align: 'center' },
{ title: '工程名称', field: 'engineeringName', align: 'center' }, { title: '工程名称', field: 'engineeringName', align: 'center' },
{ title: '项目名称', field: 'projectName', align: 'center' }, { title: '项目名称', field: 'projectName', align: 'center' },
{ title: '发生时刻', field: 'startTime', align: 'center', sortable: true }, { title: '发生时刻', field: 'startTime', align: 'center', sortable: true },
{ title: '事件描述', field: 'showName', align: 'center' } { title: '事件描述', field: 'showName', align: 'center' }
], ],
beforeSearchFun: () => {} beforeSearchFun: () => {}
}) })
provide('tableStore', tableStore) provide('tableStore', tableStore)
// "target": [], // "target": [],
// "type": "", // "type": "",
// "userId": "" // "userId": ""
tableStore.table.params.engineeringid = '' tableStore.table.params.engineeringid = ''
tableStore.table.params.deviceTypeId = '' tableStore.table.params.deviceTypeId = ''
tableStore.table.params.projectId = '' tableStore.table.params.projectId = ''
tableStore.table.params.deviceId = '' tableStore.table.params.deviceId = ''
tableStore.table.params.type = 1 tableStore.table.params.type = 1
tableStore.table.params.eventIds = [] tableStore.table.params.eventIds = []
tableStore.table.params.status = '' tableStore.table.params.status = ''
tableStore.table.params.target = [] tableStore.table.params.target = []
tableStore.table.params.userId = '' tableStore.table.params.userId = ''
tableStore.table.params.cascader = '' tableStore.table.params.cascader = ''
tableStore.table.params.deviceTypeName = '' tableStore.table.params.deviceTypeName = ''
// tableStore.table.params.level='' // tableStore.table.params.level=''
const deviceTreeOptions = ref<any>(props.deviceTree) const deviceTreeOptions = ref<any>(props.deviceTree)
deviceTreeOptions.value.map((item: any, index: any) => { deviceTreeOptions.value.map((item: any, index: any) => {
if (item.children.length == 0) { if (item.children.length == 0) {
deviceTreeOptions.value.splice(index, 1) deviceTreeOptions.value.splice(index, 1)
} }
}) })
const sourceChange = (e: any) => { const sourceChange = (e: any) => {
tableStore.table.params.deviceTypeId = '' tableStore.table.params.deviceTypeId = ''
tableStore.table.params.engineeringid = '' tableStore.table.params.engineeringid = ''
tableStore.table.params.projectId = '' tableStore.table.params.projectId = ''
tableStore.table.params.deviceId = '' tableStore.table.params.deviceId = ''
if (e) { if (e) {
let name = deviceTreeOptions.value.filter((item: any) => { let name = deviceTreeOptions.value.filter((item: any) => {
return item.id == e[0] return item.id == e[0]
})[0].name })[0].name
tableStore.table.params.deviceTypeName = name tableStore.table.params.deviceTypeName = name
if (name == '便携式设备') { if (name == '便携式设备') {
tableStore.table.params.deviceTypeId = e[0] || '' tableStore.table.params.deviceTypeId = e[0] || ''
tableStore.table.params.deviceId = e[1] || '' tableStore.table.params.deviceId = e[1] || ''
} else { } else {
tableStore.table.params.deviceTypeId = e[0] || '' tableStore.table.params.deviceTypeId = e[0] || ''
tableStore.table.params.engineeringid = e[1] || '' tableStore.table.params.engineeringid = e[1] || ''
tableStore.table.params.projectId = e[2] || '' tableStore.table.params.projectId = e[2] || ''
} }
} }
} }
onMounted(() => { onMounted(() => {
tableStore.index() tableStore.index()
}) })
setTimeout(() => { setTimeout(() => {
tableStore.table.height = mainHeight(200).height as any tableStore.table.height = mainHeight(200).height as any
}, 0) }, 0)
const addMenu = () => {} const addMenu = () => {}
</script> </script>
<style></style> <style></style>

View File

@@ -1,365 +1,365 @@
<template> <template>
<div ref="refheader" v-if="!isWaveCharts"> <div ref="refheader" v-if="!isWaveCharts">
<TableHeader datePicker showExport> <TableHeader datePicker showExport>
<template v-slot:select> <template v-slot:select>
<el-form-item label="数据来源"> <el-form-item label="数据来源">
<el-cascader <el-cascader
placeholder="请选择数据来源" placeholder="请选择数据来源"
@change="sourceChange" @change="sourceChange"
filterable filterable
v-model.trim="tableStore.table.params.cascader" v-model.trim="tableStore.table.params.cascader"
:options="deviceTreeOptions" :options="deviceTreeOptions"
:show-all-levels="false" :show-all-levels="false"
:props="{ checkStrictly: true }" :props="{ checkStrictly: true }"
clearable clearable
></el-cascader> ></el-cascader>
<!-- <el-input maxlength="32" show-word-limit v-model.trim="tableStore.table.params.searchValue" placeholder="请输入设备名称" /> --> <!-- <el-input maxlength="32" show-word-limit v-model.trim="tableStore.table.params.searchValue" placeholder="请输入设备名称" /> -->
</el-form-item> </el-form-item>
<!-- <el-form-item label="级别"> <!-- <el-form-item label="级别">
<el-select v-model.trim="tableStore.table.params.level" placeholder="请选择级别" clearable> <el-select v-model.trim="tableStore.table.params.level" placeholder="请选择级别" clearable>
<el-option v-for="item in rankOptions" :key="item.value" :label="item.label" <el-option v-for="item in rankOptions" :key="item.value" :label="item.label"
:value="item.value"></el-option> :value="item.value"></el-option>
</el-select> </el-select>
</el-form-item> --> </el-form-item> -->
</template> </template>
</TableHeader> </TableHeader>
<Table></Table> <Table></Table>
</div> </div>
<waveFormAnalysis <waveFormAnalysis
v-loading="loading" v-loading="loading"
v-if="isWaveCharts" v-if="isWaveCharts"
ref="waveFormAnalysisRef" ref="waveFormAnalysisRef"
@handleHideCharts="isWaveCharts = false" @handleHideCharts="isWaveCharts = false"
:wp="wp" :wp="wp"
/> />
<!-- <div style="height: 300px;"> --> <!-- <div style="height: 300px;"> -->
<!-- <div style="padding: 10px" v-if="!view" v-loading="loading"> <!-- <div style="padding: 10px" v-if="!view" v-loading="loading">
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<div v-if="view2" style="display: flex"> <div v-if="view2" style="display: flex">
<el-radio-group v-model.trim="value" @change="changeView"> <el-radio-group v-model.trim="value" @change="changeView">
<el-radio-button label="一次值" :value="1" /> <el-radio-button label="一次值" :value="1" />
<el-radio-button label="二次值" :value="2" /> <el-radio-button label="二次值" :value="2" />
</el-radio-group> </el-radio-group>
</div> </div>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-button v-if="view2" @click="backbxlb" class="el-icon-refresh-right" icon="el-icon-Back" <el-button v-if="view2" @click="backbxlb" class="el-icon-refresh-right" icon="el-icon-Back"
style="float: right"> style="float: right">
返回 返回
</el-button> </el-button>
</el-col> </el-col>
</el-row> </el-row>
<el-tabs v-if="view2" v-model.trim="bxactiveName" @tab-click="bxhandleClick"> <el-tabs v-if="view2" v-model.trim="bxactiveName" @tab-click="bxhandleClick">
<el-tab-pane label="瞬时波形" name="ssbx" class="boxbx pt10 pb10" <el-tab-pane label="瞬时波形" name="ssbx" class="boxbx pt10 pb10"
:style="'height:' + bxecharts + ';overflow-y: scroll;'"> :style="'height:' + bxecharts + ';overflow-y: scroll;'">
<shushiboxi v-if="bxactiveName == 'ssbx' && showBoxi" :value="value" :boxoList="boxoList" :wp="wp"> <shushiboxi v-if="bxactiveName == 'ssbx' && showBoxi" :value="value" :boxoList="boxoList" :wp="wp">
</shushiboxi> </shushiboxi>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="RMS波形" class="boxbx pt10 pb10" name="rmsbx" <el-tab-pane label="RMS波形" class="boxbx pt10 pb10" name="rmsbx"
:style="'height:' + bxecharts + ';overflow-y: scroll;'"> :style="'height:' + bxecharts + ';overflow-y: scroll;'">
<rmsboxi v-if="bxactiveName == 'rmsbx' && showBoxi" :value="value" :boxoList="boxoList" :wp="wp"> <rmsboxi v-if="bxactiveName == 'rmsbx' && showBoxi" :value="value" :boxoList="boxoList" :wp="wp">
</rmsboxi> </rmsboxi>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</div> --> </div> -->
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, provide, nextTick } from 'vue' import { ref, onMounted, provide, nextTick } from 'vue'
import TableStore from '@/utils/tableStore' import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue' import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import shushiboxi from '@/components/echarts/shushiboxi.vue' import shushiboxi from '@/components/echarts/shushiboxi.vue'
import waveFormAnalysis from '@/views/govern/device/control/tabs/components/waveFormAnalysis.vue' import waveFormAnalysis from '@/views/govern/device/control/tabs/components/waveFormAnalysis.vue'
import rmsboxi from '@/components/echarts/rmsboxi.vue' import rmsboxi from '@/components/echarts/rmsboxi.vue'
import { analyseWave } from '@/api/common' import { analyseWave } from '@/api/common'
import { mainHeight } from '@/utils/layout' import { mainHeight } from '@/utils/layout'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { getFileZip } from '@/api/cs-harmonic-boot/datatrend' import { getFileZip } from '@/api/cs-harmonic-boot/datatrend'
const props = defineProps(['deviceTree']) const props = defineProps(['deviceTree'])
const refheader = ref() const refheader = ref()
const waveFormAnalysisRef = ref() const waveFormAnalysisRef = ref()
const view = ref(true) const view = ref(true)
const isWaveCharts = ref(false) const isWaveCharts = ref(false)
const view2 = ref(false) const view2 = ref(false)
const showBoxi = ref(true) const showBoxi = ref(true)
const loading = ref(false) const loading = ref(false)
const bxactiveName = ref('ssbx') const bxactiveName = ref('ssbx')
const boxoList: any = ref({}) const boxoList: any = ref({})
const wp = ref({}) const wp = ref({})
const value = ref(1) const value = ref(1)
const options = ref([ const options = ref([
{ {
value: 1, value: 1,
label: '一次值' label: '一次值'
}, },
{ {
value: 2, value: 2,
label: '二次值' label: '二次值'
} }
]) ])
const rankOptions = ref([ const rankOptions = ref([
{ {
value: '1', value: '1',
label: '1级' label: '1级'
}, },
{ {
value: '2', value: '2',
label: '2级' label: '2级'
}, },
{ {
value: '3', value: '3',
label: '3级' label: '3级'
} }
]) ])
const tableStore = new TableStore({ const tableStore = new TableStore({
url: '/cs-harmonic-boot/eventUser/queryEventpageWeb', url: '/cs-harmonic-boot/eventUser/queryEventpageWeb',
method: 'POST', method: 'POST',
publicHeight: 65, publicHeight: 65,
exportName: '暂态事件', exportName: '暂态事件',
column: [ { column: [ {
title: '序号', title: '序号',
width: 80, width: 80,
formatter: (row: any) => { formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1 return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
} }
}, },
{ title: '设备名称', field: 'equipmentName', align: 'center' }, { title: '设备名称', field: 'equipmentName', align: 'center' },
{ title: '工程名称', field: 'engineeringName', align: 'center' }, { title: '工程名称', field: 'engineeringName', align: 'center' },
{ title: '项目名称', field: 'projectName', align: 'center' }, { title: '项目名称', field: 'projectName', align: 'center' },
{ title: '发生时刻', field: 'startTime', align: 'center', width: '240',sortable: true }, { title: '发生时刻', field: 'startTime', align: 'center', width: '240',sortable: true },
{ title: '监测点名称', field: 'lineName', align: 'center' }, { title: '监测点名称', field: 'lineName', align: 'center' },
{ title: '事件描述', field: 'showName', align: 'center' }, { title: '事件描述', field: 'showName', align: 'center' },
{ title: '事件发生位置', field: 'evtParamPosition', align: 'center' }, { title: '事件发生位置', field: 'evtParamPosition', align: 'center' },
{ title: '相别', field: 'evtParamPhase', align: 'center' }, { title: '相别', field: 'evtParamPhase', align: 'center' },
{ title: '持续时间(s)', field: 'evtParamTm', align: 'center',sortable: true }, { title: '持续时间(s)', field: 'evtParamTm', align: 'center',sortable: true },
{ title: '暂降(聚升)幅值(%)', minWidth: 100, field: 'evtParamVVaDepth', align: 'center',sortable: true }, { title: '暂降(聚升)幅值(%)', minWidth: 100, field: 'evtParamVVaDepth', align: 'center',sortable: true },
{ {
title: '操作', title: '操作',
align: 'center', align: 'center',
width: '180', width: '180',
render: 'buttons', render: 'buttons',
buttons: [ buttons: [
{ {
name: 'edit', name: 'edit',
title: '波形分析', title: '波形分析',
type: 'primary', type: 'primary',
icon: 'el-icon-DataLine', icon: 'el-icon-DataLine',
render: 'basicButton', render: 'basicButton',
loading: 'loading1', loading: 'loading1',
disabled: row => { disabled: row => {
return !row.wavePath && row.evtParamTm < 20 return !row.wavePath && row.evtParamTm < 20
}, },
click: async row => { click: async row => {
row.loading1 = true row.loading1 = true
loading.value = true loading.value = true
isWaveCharts.value = true isWaveCharts.value = true
await analyseWave(row.id) await analyseWave(row.id)
.then(res => { .then(res => {
row.loading1 = false row.loading1 = false
if (res != undefined) { if (res != undefined) {
boxoList.value = row boxoList.value = row
boxoList.value.featureAmplitude = boxoList.value.featureAmplitude =
row.evtParamVVaDepth != '-' ? row.evtParamVVaDepth - 0 : null row.evtParamVVaDepth != '-' ? row.evtParamVVaDepth - 0 : null
boxoList.value.systemType = 'WX' boxoList.value.systemType = 'WX'
wp.value = res.data wp.value = res.data
} }
loading.value = false loading.value = false
}) })
.catch(() => { .catch(() => {
row.loading1 = false row.loading1 = false
loading.value = false loading.value = false
}) })
nextTick(() => { nextTick(() => {
waveFormAnalysisRef.value && waveFormAnalysisRef.value &&
waveFormAnalysisRef.value.getWpData(wp.value, boxoList.value, true) waveFormAnalysisRef.value.getWpData(wp.value, boxoList.value, true)
// waveFormAnalysisRef.value && waveFormAnalysisRef.value.setHeight(200, 190) // waveFormAnalysisRef.value && waveFormAnalysisRef.value.setHeight(200, 190)
}) })
// row.loading1 = true // row.loading1 = true
// view.value = false // view.value = false
// view2.value = true // view2.value = true
// loading.value = true // loading.value = true
// boxoList.value = row // boxoList.value = row
// boxoList.value.systemType = 'WX' // boxoList.value.systemType = 'WX'
// boxoList.value.persistTime = row.evtParamTm != '-' ? row.evtParamTm - 0 : null // boxoList.value.persistTime = row.evtParamTm != '-' ? row.evtParamTm - 0 : null
// await analyseWave(row.id) // await analyseWave(row.id)
// .then(res => { // .then(res => {
// row.loading1 = false // row.loading1 = false
// if (res != undefined) { // if (res != undefined) {
// wp.value = res.data // wp.value = res.data
// } // }
// loading.value = false // loading.value = false
// }) // })
// .catch(() => { // .catch(() => {
// row.loading1 = false // row.loading1 = false
// loading.value = false // loading.value = false
// }) // })
} }
}, },
{ {
name: 'edit', name: 'edit',
title: '波形下载', title: '波形下载',
type: 'primary', type: 'primary',
icon: 'el-icon-Check', icon: 'el-icon-Check',
loading: 'loading2', loading: 'loading2',
render: 'basicButton', render: 'basicButton',
disabled: row => { disabled: row => {
// && row.evtParamTm < 20 // && row.evtParamTm < 20
return !row.wavePath return !row.wavePath
}, },
click: row => { click: row => {
getFileZip({ eventId: row.id }).then(res => { getFileZip({ eventId: row.id }).then(res => {
let blob = new Blob([res], { type: 'application/zip' }) // console.log(blob) // var href = window.URL.createObjectURL(blob); //创建下载的链接 let blob = new Blob([res], { type: 'application/zip' }) // console.log(blob) // var href = window.URL.createObjectURL(blob); //创建下载的链接
const url = window.URL.createObjectURL(blob) const url = window.URL.createObjectURL(blob)
const link = document.createElement('a') // 创建a标签 const link = document.createElement('a') // 创建a标签
link.href = url link.href = url
link.download = row.wavePath.split('/')[2] || '波形文件' // 设置下载的文件名 link.download = row.wavePath.split('/')[2] || '波形文件' // 设置下载的文件名
document.body.appendChild(link) document.body.appendChild(link)
link.click() //执行下载 link.click() //执行下载
document.body.removeChild(link) //释放标签 document.body.removeChild(link) //释放标签
}) })
} }
}, },
{ {
name: 'edit', name: 'edit',
text: '暂无波形', text: '暂无波形',
type: 'info', type: 'info',
icon: 'el-icon-DataLine', icon: 'el-icon-DataLine',
render: 'basicButton', render: 'basicButton',
disabled: row => { disabled: row => {
return !(!row.wavePath && row.evtParamTm < 20) return !(!row.wavePath && row.evtParamTm < 20)
} }
} }
] ]
} }
], ],
beforeSearchFun: () => { beforeSearchFun: () => {
// if (!tableStore.table.params.deviceId) { // if (!tableStore.table.params.deviceId) {
// delete tableStore.table.params.deviceId // delete tableStore.table.params.deviceId
// } // }
}, },
loadCallback: () => { loadCallback: () => {
tableStore.table.data.forEach((item: any) => { tableStore.table.data.forEach((item: any) => {
item.loading = false item.loading = false
item.evtParamTm = item.evtParamTm =
item.evtParamTm.split('s')[0] != '-' ? (item.evtParamTm.split('s')[0] - 0).toFixed(2) : '-' item.evtParamTm.split('s')[0] != '-' ? (item.evtParamTm.split('s')[0] - 0).toFixed(2) : '-'
item.evtParamVVaDepth = item.evtParamVVaDepth =
item.evtParamVVaDepth.split('%')[0] != '-' ? (item.evtParamVVaDepth.split('%')[0] - 0).toFixed(2) : '-' item.evtParamVVaDepth.split('%')[0] != '-' ? (item.evtParamVVaDepth.split('%')[0] - 0).toFixed(2) : '-'
}) })
} }
}) })
provide('tableStore', tableStore) provide('tableStore', tableStore)
// "target": [], // "target": [],
// "type": "", // "type": "",
// "userId": "" // "userId": ""
tableStore.table.params.engineeringid = '' tableStore.table.params.engineeringid = ''
tableStore.table.params.projectId = '' tableStore.table.params.projectId = ''
tableStore.table.params.deviceTypeId = '' tableStore.table.params.deviceTypeId = ''
tableStore.table.params.deviceId = '' tableStore.table.params.deviceId = ''
tableStore.table.params.type = 0 tableStore.table.params.type = 0
tableStore.table.params.eventIds = [] tableStore.table.params.eventIds = []
tableStore.table.params.status = '' tableStore.table.params.status = ''
tableStore.table.params.target = [] tableStore.table.params.target = []
tableStore.table.params.userId = '' tableStore.table.params.userId = ''
tableStore.table.params.cascader = '' tableStore.table.params.cascader = ''
tableStore.table.params.deviceTypeName = '' tableStore.table.params.deviceTypeName = ''
// tableStore.table.params.level='' // tableStore.table.params.level=''
const deviceTreeOptions: any = ref<any>(props.deviceTree) const deviceTreeOptions: any = ref<any>(props.deviceTree)
deviceTreeOptions.value.map((item: any, index: any) => { deviceTreeOptions.value.map((item: any, index: any) => {
if (item.children.length == 0) { if (item.children.length == 0) {
deviceTreeOptions.value.splice(index, 1) deviceTreeOptions.value.splice(index, 1)
} }
}) })
const sourceChange = (e: any) => { const sourceChange = (e: any) => {
tableStore.table.params.deviceTypeId = '' tableStore.table.params.deviceTypeId = ''
tableStore.table.params.engineeringid = '' tableStore.table.params.engineeringid = ''
tableStore.table.params.projectId = '' tableStore.table.params.projectId = ''
tableStore.table.params.deviceId = '' tableStore.table.params.deviceId = ''
if (e) { if (e) {
let name = deviceTreeOptions.value.filter((item: any) => { let name = deviceTreeOptions.value.filter((item: any) => {
return item.id == e[0] return item.id == e[0]
})[0].name })[0].name
tableStore.table.params.deviceTypeName = name tableStore.table.params.deviceTypeName = name
if (name == '便携式设备') { if (name == '便携式设备') {
tableStore.table.params.deviceTypeId = e[0] || '' tableStore.table.params.deviceTypeId = e[0] || ''
tableStore.table.params.deviceId = e[1] || '' tableStore.table.params.deviceId = e[1] || ''
} else { } else {
tableStore.table.params.deviceTypeId = e[0] || '' tableStore.table.params.deviceTypeId = e[0] || ''
tableStore.table.params.engineeringid = e[1] || '' tableStore.table.params.engineeringid = e[1] || ''
tableStore.table.params.projectId = e[2] || '' tableStore.table.params.projectId = e[2] || ''
} }
} }
// tableStore.table.params.engineeringid = e[1] || '' // tableStore.table.params.engineeringid = e[1] || ''
// tableStore.table.params.projectId = e[2] || '' // tableStore.table.params.projectId = e[2] || ''
// const zlIndex = deviceTreeOptions.value.findIndex((item: any) => { // const zlIndex = deviceTreeOptions.value.findIndex((item: any) => {
// return item.name == '治理设备' // return item.name == '治理设备'
// }) // })
// const bxsIndex = deviceTreeOptions.value.findIndex((item: any) => { // const bxsIndex = deviceTreeOptions.value.findIndex((item: any) => {
// return item.name == '便携式设备' // return item.name == '便携式设备'
// }) // })
// console.log("🚀 ~ zlIndex ~ zlIndex:", zlIndex,bxsIndex) // console.log("🚀 ~ zlIndex ~ zlIndex:", zlIndex,bxsIndex)
// //便携式设备特殊处理 // //便携式设备特殊处理
// if (bxsIndex != -1 && deviceTreeOptions.value[bxsIndex].id == e[0] && e.length == 2) { // if (bxsIndex != -1 && deviceTreeOptions.value[bxsIndex].id == e[0] && e.length == 2) {
// tableStore.table.params.deviceId = e[1] // tableStore.table.params.deviceId = e[1]
// } // }
// //治理设备 // //治理设备
// if (zlIndex != -1 && deviceTreeOptions.value[zlIndex].id == e[0]) { // if (zlIndex != -1 && deviceTreeOptions.value[zlIndex].id == e[0]) {
// tableStore.table.params.deviceId = e[2] || '' // tableStore.table.params.deviceId = e[2] || ''
// } // }
} }
const getboxin = async (row: any) => { const getboxin = async (row: any) => {
console.log('🚀 ~ getboxin ~ row:', row) console.log('🚀 ~ getboxin ~ row:', row)
// boxoList.value = row // boxoList.value = row
// await analyseWave(row.id).then(res => { // await analyseWave(row.id).then(res => {
// if (res != undefined) { // if (res != undefined) {
// wp.value = res.data // wp.value = res.data
// view.value = false // view.value = false
// view2.value = true // view2.value = true
// } // }
// }) // })
} }
const changeView = () => { const changeView = () => {
showBoxi.value = false showBoxi.value = false
setTimeout(() => { setTimeout(() => {
showBoxi.value = true showBoxi.value = true
}, 0) }, 0)
} }
const bxhandleClick = (tab: any) => { const bxhandleClick = (tab: any) => {
if (tab.name == 'ssbx') { if (tab.name == 'ssbx') {
bxactiveName.value = 'ssbx' bxactiveName.value = 'ssbx'
} else if (tab.name == 'rmsbx') { } else if (tab.name == 'rmsbx') {
bxactiveName.value = 'rmsbx' bxactiveName.value = 'rmsbx'
} }
// console.log(tab, event); // console.log(tab, event);
} }
const backbxlb = () => { const backbxlb = () => {
view.value = true view.value = true
view2.value = false view2.value = false
setTimeout(() => { setTimeout(() => {
tableStore.table.height = mainHeight(180).height as any tableStore.table.height = mainHeight(180).height as any
}, 0) }, 0)
} }
onMounted(() => { onMounted(() => {
tableStore.index() tableStore.index()
}) })
const bxecharts = mainHeight(175).height as any const bxecharts = mainHeight(175).height as any
setTimeout(() => { setTimeout(() => {
tableStore.table.height = mainHeight(200).height as any tableStore.table.height = mainHeight(200).height as any
}, 0) }, 0)
const addMenu = () => {} const addMenu = () => {}
</script> </script>
<style scoped lang="scss"></style> <style scoped lang="scss"></style>

View File

@@ -1,202 +1,202 @@
<template> <template>
<div class="default-main"> <div class="default-main">
<TableHeader datePicker ref="refheader" > <TableHeader datePicker ref="refheader" >
<template v-slot:select> <template v-slot:select>
<el-form-item label="关键字筛选"> <el-form-item label="关键字筛选">
<el-input <el-input
v-model.trim="tableStore.table.params.name" v-model.trim="tableStore.table.params.name"
placeholder="请输入关键字" placeholder="请输入关键字"
clearable clearable
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="流程阶段"> <el-form-item label="流程阶段">
<el-select v-model.trim="tableStore.table.params.process" clearable placeholder="请选择"> <el-select v-model.trim="tableStore.table.params.process" clearable placeholder="请选择">
<el-option label="功能调试" :value="2"></el-option> <el-option label="功能调试" :value="2"></el-option>
<el-option label="出厂调试" :value="3"></el-option> <el-option label="出厂调试" :value="3"></el-option>
<el-option label="正式投运" :value="4"></el-option> <el-option label="正式投运" :value="4"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</template> </template>
<template v-slot:operation> <template v-slot:operation>
<el-button type="primary" icon="el-icon-Download" @click="exportTab">导出</el-button> <el-button type="primary" icon="el-icon-Download" @click="exportTab">导出</el-button>
</template> </template>
</TableHeader> </TableHeader>
<Table ref="tableRef" /> <Table ref="tableRef" />
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, provide } from 'vue' import { ref, onMounted, provide } from 'vue'
import TableStore from '@/utils/tableStore' import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue' import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import { queryByCode, queryByid, queryCsDictTree } from '@/api/system-boot/dictTree' import { queryByCode, queryByid, queryCsDictTree } from '@/api/system-boot/dictTree'
defineOptions({ defineOptions({
name: 'manage/monthly' name: 'manage/monthly'
}) })
const refheader = ref() const refheader = ref()
const devModelOptions: any = ref([]) const devModelOptions: any = ref([])
queryByCode('Device_Type').then(res => { queryByCode('Device_Type').then(res => {
queryByid(res.data.id).then(res => { queryByid(res.data.id).then(res => {
devModelOptions.value = res.data.map((item: any) => { devModelOptions.value = res.data.map((item: any) => {
return { return {
value: item.id, value: item.id,
label: item.name, label: item.name,
...item ...item
} }
}) })
}) })
tableStore.index() tableStore.index()
}) })
const tableStore = new TableStore({ const tableStore = new TableStore({
url: '/cs-harmonic-boot/statisticsData/halfMonthReport', url: '/cs-harmonic-boot/statisticsData/halfMonthReport',
method: 'POST', method: 'POST',
isWebPaging: true, isWebPaging: true,
exportName: '半月报功能', exportName: '半月报功能',
column: [ column: [
{ {
title: '序号', title: '序号',
width: 80, width: 80,
formatter: (row: any) => { formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1 return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
} }
}, },
{ title: '工程名称', field: 'engineeringName', minWidth: 150 }, { title: '工程名称', field: 'engineeringName', minWidth: 150 },
{ title: '项目名称', field: 'projectName', minWidth: 130 }, { title: '项目名称', field: 'projectName', minWidth: 130 },
{ title: '设备名称', field: 'devName', minWidth: 130 }, { title: '设备名称', field: 'devName', minWidth: 130 },
{ title: '监测点名称', field: 'lineName', minWidth: 130 }, { title: '监测点名称', field: 'lineName', minWidth: 130 },
{ {
title: '投运时间', title: '投运时间',
field: 'operationalTime', field: 'operationalTime',
width: 180, width: 180,
sortable: true sortable: true
}, },
{ {
title: '数据更新时间', title: '数据更新时间',
field: 'latestTime', field: 'latestTime',
width: 180, width: 180,
sortable: true sortable: true
// formatter: (row: any) => { // formatter: (row: any) => {
// return row.cellValue || '/' // return row.cellValue || '/'
// } // }
}, },
{ {
title: '设备型号', title: '设备型号',
field: 'devType', field: 'devType',
width: 130, width: 130,
formatter: row => { formatter: row => {
return devModelOptions.value.filter((item: any) => item.value == row.cellValue)[0]?.label return devModelOptions.value.filter((item: any) => item.value == row.cellValue)[0]?.label
} }
}, },
{ title: 'Mac地址', field: 'mac', width: 140 }, { title: 'Mac地址', field: 'mac', width: 140 },
{ {
title: '流程阶段', title: '流程阶段',
field: 'process', field: 'process',
width: 100, width: 100,
fixed: 'right', fixed: 'right',
render: 'tag', render: 'tag',
custom: { custom: {
2: 'warning', 2: 'warning',
3: 'warning', 3: 'warning',
4: 'success' 4: 'success'
}, },
replaceValue: { replaceValue: {
2: '功能调试', 2: '功能调试',
3: '出厂调试', 3: '出厂调试',
4: '正式投运' 4: '正式投运'
}, },
minWidth: 80 minWidth: 80
}, },
{ {
title: '运行状态', title: '运行状态',
field: 'operationalStatus', field: 'operationalStatus',
render: 'tag', render: 'tag',
fixed: 'right', fixed: 'right',
width: 100, width: 100,
custom: { custom: {
停运: 'danger', 停运: 'danger',
在运: 'success' 在运: 'success'
}, },
replaceValue: { replaceValue: {
在运: '在运', 在运: '在运',
停运: '停运' 停运: '停运'
} }
}, },
{ {
title: '通讯状态', title: '通讯状态',
field: 'communicationStatus', field: 'communicationStatus',
width: 100, width: 100,
fixed: 'right', fixed: 'right',
render: 'tag', render: 'tag',
custom: { custom: {
离线: 'danger', 离线: 'danger',
在线: 'success' 在线: 'success'
}, },
replaceValue: { replaceValue: {
离线: '离线', 离线: '离线',
在线: '在线' 在线: '在线'
} }
}, },
{ title: '在线率(%)', fixed: 'right',width: 100, field: 'onlineRate', sortable: true }, { title: '在线率(%)', fixed: 'right',width: 100, field: 'onlineRate', sortable: true },
{ title: '完整性(%)', fixed: 'right',width: 100, field: 'integrity', sortable: true } { title: '完整性(%)', fixed: 'right',width: 100, field: 'integrity', sortable: true }
], ],
beforeSearchFun: () => {}, beforeSearchFun: () => {},
loadCallback: () => { loadCallback: () => {
let name = tableStore.table.params.name let name = tableStore.table.params.name
let data = tableStore.table.copyData.filter(item => { let data = tableStore.table.copyData.filter(item => {
// 处理latestTime默认值 // 处理latestTime默认值
item.latestTime = item.latestTime || '/' item.latestTime = item.latestTime || '/'
// 需要检查的字段列表 // 需要检查的字段列表
const fieldsToCheck = ['projectName', 'engineeringName', 'mac', 'devName', 'lineName'] const fieldsToCheck = ['projectName', 'engineeringName', 'mac', 'devName', 'lineName']
console.log( console.log(
'🚀 ~ fieldsToCheck.some(field => item[field]?.includes(name)):', '🚀 ~ fieldsToCheck.some(field => item[field]?.includes(name)):',
fieldsToCheck.some(field => item[field]?.includes(name)) fieldsToCheck.some(field => item[field]?.includes(name))
) )
// 检查任何一个字段包含搜索名称 // 检查任何一个字段包含搜索名称
return fieldsToCheck.some(field => item[field]?.includes(name)) return fieldsToCheck.some(field => item[field]?.includes(name))
}) })
tableStore.table.copyData = JSON.parse(JSON.stringify(data)) tableStore.table.copyData = JSON.parse(JSON.stringify(data))
tableStore.table.total = tableStore.table.copyData.length tableStore.table.total = tableStore.table.copyData.length
if (data.length == 0) { if (data.length == 0) {
tableStore.table.data = [] tableStore.table.data = []
} else { } else {
tableStore.table.data = JSON.parse( tableStore.table.data = JSON.parse(
JSON.stringify( JSON.stringify(
window.XEUtils.chunk(data, tableStore.table.params.pageSize)[tableStore.table.params.pageNum - 1] window.XEUtils.chunk(data, tableStore.table.params.pageSize)[tableStore.table.params.pageNum - 1]
) )
) )
} }
} }
}) })
provide('tableStore', tableStore) provide('tableStore', tableStore)
tableStore.table.params.process = 4 tableStore.table.params.process = 4
tableStore.table.params.name = '' tableStore.table.params.name = ''
const tableRef = ref() const tableRef = ref()
const exportTab = () => { const exportTab = () => {
tableRef.value.getRef()?.exportData({ tableRef.value.getRef()?.exportData({
filename: '半月报功能', // 文件名字 filename: '半月报功能', // 文件名字
sheetName: 'Sheet1', sheetName: 'Sheet1',
type: 'xlsx', //导出文件类型 xlsx 和 csv type: 'xlsx', //导出文件类型 xlsx 和 csv
useStyle: true, useStyle: true,
data: tableStore.table.copyData, // 数据源 // 过滤那个字段导出 data: tableStore.table.copyData, // 数据源 // 过滤那个字段导出
columnFilterMethod: function (column: any) { columnFilterMethod: function (column: any) {
return !( return !(
column.column.title === undefined || column.column.title === undefined ||
column.column.title === '序号' || column.column.title === '序号' ||
column.column.title === '操作' column.column.title === '操作'
) )
} }
}) })
} }
onMounted(() => {}) onMounted(() => {})
setTimeout(() => { setTimeout(() => {
// tableStore.table.height = mainHeight(200).height as any // tableStore.table.height = mainHeight(200).height as any
}, 0) }, 0)
const addMenu = () => {} const addMenu = () => {}
</script> </script>
<style></style> <style></style>

Some files were not shown because too many files have changed in this diff Show More