添加全局变量
This commit is contained in:
@@ -23,9 +23,10 @@
|
||||
<Icon size="14" name="el-icon-ArrowUp" style="color: #fff" v-if="showSelect" />
|
||||
<Icon size="14" name="el-icon-ArrowDown" style="color: #fff" v-else />
|
||||
</el-button>
|
||||
<el-button @click="onComSearch" v-if="showSearch" type="primary" :icon="Search">查询</el-button>
|
||||
<el-button @click="onResetForm" v-if="showSearch" :icon="RefreshLeft">重置</el-button>
|
||||
<el-button @click="onComSearch" v-if="showSearch" type="primary" :icon="Search">查询</el-button>
|
||||
<el-button @click="onResetForm" v-if="showSearch" :icon="RefreshLeft">重置</el-button>
|
||||
</template>
|
||||
<!-- :loading="tableStore.table.loading" -->
|
||||
<slot name="operation"></slot>
|
||||
</div>
|
||||
<el-form
|
||||
|
||||
17
src/main.ts
17
src/main.ts
@@ -1,4 +1,4 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createApp, reactive } from 'vue'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import pinia from '@/stores/index'
|
||||
@@ -15,25 +15,23 @@ import '@/styles/index.scss'
|
||||
import '@/assets/font/iconfont.css'
|
||||
import { ElDialog } from 'element-plus'
|
||||
import BaiduMap from 'vue-baidu-map-3x'
|
||||
import BaiduMapOffline from 'vue-baidu-map-offline';
|
||||
import BaiduMapOffline from 'vue-baidu-map-offline'
|
||||
import ExcelJS from 'exceljs'
|
||||
import VXETablePluginExportXLSX from 'vxe-table-plugin-export-xlsx'
|
||||
// 方式1:NPM 安装,注入 ExcelJS 对象
|
||||
VXETable.use(VXETablePluginExportXLSX, {
|
||||
ExcelJS
|
||||
ExcelJS
|
||||
})
|
||||
window.XEUtils = XEUtils
|
||||
|
||||
// 初始化多语言
|
||||
import { setupI18n } from '@/plugins/vueI18n'
|
||||
|
||||
|
||||
// 引入 form-create
|
||||
import { setupFormCreate } from '@/plugins/formCreate'
|
||||
|
||||
// 创建实例
|
||||
const setupAll = async () => {
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
//开启离线地图
|
||||
@@ -43,8 +41,8 @@ const setupAll = async () => {
|
||||
// });
|
||||
app.use(BaiduMap, {
|
||||
ak: 'Yp57V71dkOPiXjiN8VdcFRsVELzlVNKK',
|
||||
v: '3.0',
|
||||
});
|
||||
v: '3.0'
|
||||
})
|
||||
|
||||
await setupI18n(app)
|
||||
app.use(router)
|
||||
@@ -55,7 +53,10 @@ const setupAll = async () => {
|
||||
registerIcons(app) // icons
|
||||
|
||||
app.config.globalProperties.eventBus = mitt()
|
||||
|
||||
// 配置全局变量
|
||||
app.config.globalProperties.$allVariables = reactive({
|
||||
butLoading: false
|
||||
})
|
||||
setupFormCreate(app)
|
||||
|
||||
await router.isReady()
|
||||
|
||||
@@ -6,16 +6,16 @@ import { mainHeight } from '@/utils/layout'
|
||||
|
||||
interface TableStoreParams {
|
||||
url: string // 请求地址
|
||||
pk?: string
|
||||
pk?: string
|
||||
column: TableColumn[]
|
||||
params?: anyObj
|
||||
method?: Method // 请求方式
|
||||
params?: anyObj
|
||||
method?: Method // 请求方式
|
||||
isWebPaging?: boolean // 是否前端分页
|
||||
showPage?: boolean //是否需要分页
|
||||
paramsPOST?: boolean // post请求 params传参
|
||||
publicHeight?: number //计算高度
|
||||
resetCallback?: () => void // 重置
|
||||
loadCallback?: () => void // 接口调用后的回调
|
||||
loadCallback?: () => void // 接口调用后的回调
|
||||
beforeSearchFun?: () => void // 接口调用前的回调
|
||||
}
|
||||
|
||||
@@ -78,24 +78,28 @@ export default class TableStore {
|
||||
},
|
||||
requestPayload(this.method, this.table.params, this.paramsPOST)
|
||||
)
|
||||
).then((res: any) => {
|
||||
if (res.data) {
|
||||
this.table.data = res.data.records || res.data
|
||||
this.table.total = res.data?.total || res.data.length || 0
|
||||
} else {
|
||||
this.table.data = []
|
||||
this.table.total = 0
|
||||
}
|
||||
if (Array.isArray(res)) {
|
||||
this.table.data = res
|
||||
}
|
||||
if (this.isWebPaging) {
|
||||
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.loadCallback && this.table.loadCallback()
|
||||
this.table.loading = false
|
||||
})
|
||||
)
|
||||
.then((res: any) => {
|
||||
if (res.data) {
|
||||
this.table.data = res.data.records || res.data
|
||||
this.table.total = res.data?.total || res.data.length || 0
|
||||
} else {
|
||||
this.table.data = []
|
||||
this.table.total = 0
|
||||
}
|
||||
if (Array.isArray(res)) {
|
||||
this.table.data = res
|
||||
}
|
||||
if (this.isWebPaging) {
|
||||
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.loadCallback && this.table.loadCallback()
|
||||
this.table.loading = false
|
||||
})
|
||||
.catch(() => {
|
||||
this.table.loading = false
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<div class="default-main">
|
||||
<!-- <el-button :loading="$allVariables.butLoading ">123</el-button> -->
|
||||
<el-tabs v-model="activeName" type="border-card">
|
||||
<el-tab-pane label="终端在线率列表" name="1">
|
||||
<Table />
|
||||
@@ -12,7 +13,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref, provide } from 'vue'
|
||||
import { onMounted, reactive, ref, getCurrentInstance } from 'vue'
|
||||
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import Table from './components/table.vue'
|
||||
@@ -23,6 +24,15 @@ defineOptions({
|
||||
const activeName = ref('1')
|
||||
|
||||
const layout = mainHeight(63) as any
|
||||
// const { proxy } = getCurrentInstance()
|
||||
// onMounted(() => {
|
||||
// setTimeout(() => {
|
||||
// proxy.$allVariables.butLoading = true
|
||||
// setTimeout(() => {
|
||||
// proxy.$allVariables.butLoading = false
|
||||
// }, 3000);
|
||||
// }, 3000);
|
||||
// })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -30,6 +40,7 @@ const layout = mainHeight(63) as any
|
||||
width: 100%;
|
||||
height: 500px;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__content) {
|
||||
height: v-bind('layout.height');
|
||||
overflow-y: auto;
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="init">查询</el-button>
|
||||
<el-button type="primary" @click="init" icon="el-icon-Search">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="flex: 1; overflow: hidden" class="mt10">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<DatePicker ref='datePickerRef'></DatePicker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type='primary' @click='init'>查询</el-button>
|
||||
<el-button type='primary' @click='init' icon="el-icon-Search">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style='flex: 1;' class='mt10'>
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="init">查询</el-button>
|
||||
<el-button type="primary" @click="init" icon="el-icon-Search">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="flex: 1; overflow-y: scroll" class="mt10">
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="init">查询</el-button>
|
||||
<el-button type="primary" @click="init" icon="el-icon-Search">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="flex: 1" class="mt10">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<DatePicker ref="datePickerRef"></DatePicker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="init">查询</el-button>
|
||||
<el-button type="primary" @click="init" icon="el-icon-Search">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="flex: 1" class="mt10">
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="init">查询</el-button>
|
||||
<el-button type="primary" @click="init" icon="el-icon-Search">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<vxe-table :data="analysisData" v-bind="defaultAttribute">
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="init">查询</el-button>
|
||||
<el-button type="primary" @click="init" icon="el-icon-Search">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="flex: 1; display: flex; overflow: hidden" class="mt10">
|
||||
|
||||
Reference in New Issue
Block a user