|
@@ -2,7 +2,7 @@
|
|
import searchCop from './components/search.vue'
|
|
import searchCop from './components/search.vue'
|
|
import excelCop from '@/components/excel.vue'
|
|
import excelCop from '@/components/excel.vue'
|
|
import treeCop from '@/components/tree.vue'
|
|
import treeCop from '@/components/tree.vue'
|
|
-import tableCop from './components/table.vue'
|
|
|
|
|
|
+import chartCop from './components/chart.vue'
|
|
import { ElMessage } from 'element-plus';
|
|
import { ElMessage } from 'element-plus';
|
|
import { onMounted, ref, onActivated } from 'vue'
|
|
import { onMounted, ref, onActivated } from 'vue'
|
|
import request from "@/api/axios.js"
|
|
import request from "@/api/axios.js"
|
|
@@ -12,20 +12,12 @@ const treeHeight = '81vh' //tree高度
|
|
const excelHeight = '81vh' //excel高度
|
|
const excelHeight = '81vh' //excel高度
|
|
const tableHeight = '81vh'
|
|
const tableHeight = '81vh'
|
|
/**excel 开始 */
|
|
/**excel 开始 */
|
|
|
|
+const excelCheckIds = ref([])
|
|
const excelList = ref<{ id: string, name: string }[]>([])
|
|
const excelList = ref<{ id: string, name: string }[]>([])
|
|
-const funExcelChange = async (obj: any) => { //点击excel项时
|
|
|
|
- tableShowId.value = obj.id
|
|
|
|
- tableName.value = obj.name
|
|
|
|
- tableLoading.value = true
|
|
|
|
- const res = await request.get('/power/prepare/show', { params: { id: obj.id } })
|
|
|
|
- tableColumn.value = res.data.title.map(o => {
|
|
|
|
- return {
|
|
|
|
- prop: o.key,
|
|
|
|
- label: o.des,
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- tableData.value = res.data.data
|
|
|
|
- tableLoading.value = false
|
|
|
|
|
|
+//点击excel项时
|
|
|
|
+const funExcelChange = async (obj: any) => { }
|
|
|
|
+const funExcelCheckChange = ({ checkArr, data }) => {
|
|
|
|
+ excelCheckIds.value = checkArr
|
|
}
|
|
}
|
|
/**tree 开始 */
|
|
/**tree 开始 */
|
|
const treeData = ref([])
|
|
const treeData = ref([])
|
|
@@ -45,9 +37,23 @@ const funRepeatMap = (arr: any) => {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
const funGetTree = async () => {
|
|
const funGetTree = async () => {
|
|
- const res = await request.get("/power/prepare/tree")
|
|
|
|
|
|
+ const res = await request.get("/power/process/tree")
|
|
treeData.value = funRepeatMap(res.data)
|
|
treeData.value = funRepeatMap(res.data)
|
|
}
|
|
}
|
|
|
|
+const funTreeCheckChange = ({ current, checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys }) => { //tree change -> excel change
|
|
|
|
+ funCurrentChange({ current, currentNode: '' })
|
|
|
|
+ const checkIds = []
|
|
|
|
+ if (checkedNodes.length) {
|
|
|
|
+ for (const node of checkedNodes) {
|
|
|
|
+ if (node.childs && node.childs.length) {
|
|
|
|
+ for (const child of node.childs) {
|
|
|
|
+ checkIds.push(child.id)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ excelCheckIds.value = checkIds
|
|
|
|
+}
|
|
const funCurrentChange = ({ current, currentNode }) => {
|
|
const funCurrentChange = ({ current, currentNode }) => {
|
|
if (current.childs) {
|
|
if (current.childs) {
|
|
excelList.value = current.childs.map(o => {
|
|
excelList.value = current.childs.map(o => {
|
|
@@ -67,46 +73,105 @@ const funCurrentChange = ({ current, currentNode }) => {
|
|
excelList.value = []
|
|
excelList.value = []
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-/**table 开始 */
|
|
|
|
-const tableShowId = ref('')
|
|
|
|
-const tableName = ref('')
|
|
|
|
-const tableColumn = ref([])
|
|
|
|
-const tableLoading = ref(false)
|
|
|
|
-const tableData = ref([])
|
|
|
|
-const funExport = async () => {
|
|
|
|
- const a = document.createElement('a')
|
|
|
|
- a.href = config.baseURL + '/power/prepare/download?id=' + tableShowId.value
|
|
|
|
- a.download = ''
|
|
|
|
- a.click()
|
|
|
|
|
|
+/**chart */
|
|
|
|
+const funText = (index) => {
|
|
|
|
+ let str = ''
|
|
|
|
+ switch (index) {
|
|
|
|
+ case 0:
|
|
|
|
+ str = '0-2.5'
|
|
|
|
+ break
|
|
|
|
+ case 1:
|
|
|
|
+ str = '2.5-5'
|
|
|
|
+ break
|
|
|
|
+ case 2:
|
|
|
|
+ str = '5-7.5'
|
|
|
|
+ break
|
|
|
|
+ case 3:
|
|
|
|
+ str = '7.5-10'
|
|
|
|
+ break
|
|
|
|
+ case 4:
|
|
|
|
+ str = '10-12.5'
|
|
|
|
+ break
|
|
|
|
+ case 5:
|
|
|
|
+ str = '12.5-15'
|
|
|
|
+ break
|
|
|
|
+ case 6:
|
|
|
|
+ str = '15-17.5'
|
|
|
|
+ break
|
|
|
|
+ case 7:
|
|
|
|
+ str = '17.5-20'
|
|
|
|
+ break
|
|
|
|
+ case 8:
|
|
|
|
+ str = '20-22.5'
|
|
|
|
+ break
|
|
|
|
+ case 9:
|
|
|
|
+ str = '22.5-25'
|
|
|
|
+ break
|
|
|
|
+ case 10:
|
|
|
|
+ str = '25-inf'
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ return str
|
|
}
|
|
}
|
|
|
|
+const chartData = ref<any>([]) //roses的chartList
|
|
/**submit */
|
|
/**submit */
|
|
-const progress = ref(0)
|
|
|
|
-const funWebSocket = () => {
|
|
|
|
- const webSocket = new WebSocket(`${config.socketURL}/ws/powerfitting/admin`)
|
|
|
|
- webSocket.onerror = () => setTimeout(() => { funWebSocket() }, 2000)
|
|
|
|
-
|
|
|
|
- webSocket.onmessage = (event) => {
|
|
|
|
- const message = JSON.parse(event.data)
|
|
|
|
- if (message.code === 200) {
|
|
|
|
- progress.value = Number(message.data) * 100
|
|
|
|
- if (progress.value === 100) {
|
|
|
|
- ElMessage.success('数据加载完成')
|
|
|
|
- funGetTree()
|
|
|
|
- progress.value = 0
|
|
|
|
|
|
+const funSubmit = async (params) => {
|
|
|
|
+ const rosesRes = await request.get('/wind/roses', {
|
|
|
|
+ params: {
|
|
|
|
+ ids: excelCheckIds.value.join(','),
|
|
|
|
+ mode: params.mode
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ if (rosesRes.code === 200) {
|
|
|
|
+ if (rosesRes.data?.length) {
|
|
|
|
+ console.log(rosesRes.data)
|
|
|
|
+ chartData.value = []
|
|
|
|
+ for (const chart of rosesRes.data) {
|
|
|
|
+ chartData.value.push({
|
|
|
|
+ title: chart.wt,
|
|
|
|
+ xAxis: {
|
|
|
|
+ type: 'value',
|
|
|
|
+ max: 360,
|
|
|
|
+ },
|
|
|
|
+ series: chart.roses?.length ?chart.roses.map((o, index) => {
|
|
|
|
+ return {
|
|
|
|
+ type: 'bar',
|
|
|
|
+ data: o,
|
|
|
|
+ coordinateSystem: 'polar',
|
|
|
|
+ name: funText(index),
|
|
|
|
+ stack: 'a',
|
|
|
|
+ emphasis: {
|
|
|
|
+ focus: 'series'
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }): []
|
|
|
|
+ })
|
|
|
|
+ chartData.value.push({
|
|
|
|
+ title: chart.wt,
|
|
|
|
+ xAxis: {
|
|
|
|
+ type: 'category',
|
|
|
|
+ boundaryGap: false,
|
|
|
|
+ data: ['N', 'N-E', 'E', 'S-E', 'S', 'W-S', 'W', 'N-W']
|
|
|
|
+ },
|
|
|
|
+ series: chart.count?.length? chart.count.map((o,index) => {
|
|
|
|
+ return {
|
|
|
|
+ type: 'bar',
|
|
|
|
+ data: o,
|
|
|
|
+ coordinateSystem: 'polar',
|
|
|
|
+ name: funText(index),
|
|
|
|
+ stack: 'a',
|
|
|
|
+ emphasis: {
|
|
|
|
+ focus: 'series'
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }): []
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-const funSubmit = async (params) => {
|
|
|
|
- const res = await request.get('/power/prepare/data', { params: params })
|
|
|
|
- if (res.code === 200) {
|
|
|
|
- ElMessage.success(res.msg)
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
/**created */
|
|
/**created */
|
|
funGetTree()
|
|
funGetTree()
|
|
-funWebSocket()
|
|
|
|
/**activated */
|
|
/**activated */
|
|
onActivated(() => {
|
|
onActivated(() => {
|
|
funGetTree()
|
|
funGetTree()
|
|
@@ -117,20 +182,21 @@ onActivated(() => {
|
|
<search-cop @submit="funSubmit"></search-cop>
|
|
<search-cop @submit="funSubmit"></search-cop>
|
|
<el-row :gutter="10">
|
|
<el-row :gutter="10">
|
|
<el-col :span="5">
|
|
<el-col :span="5">
|
|
- <tree-cop :data="treeData" :height="treeHeight" @currentChange="funCurrentChange" @refresh="funGetTree">
|
|
|
|
|
|
+ <tree-cop :data="treeData" @checkChange="funTreeCheckChange" :show-checkbox="true" :height="treeHeight"
|
|
|
|
+ @currentChange="funCurrentChange" @refresh="funGetTree">
|
|
</tree-cop>
|
|
</tree-cop>
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="3">
|
|
<el-col :span="3">
|
|
- <excel-cop :data="excelList" :height="excelHeight" @excelChange="funExcelChange"></excel-cop>
|
|
|
|
|
|
+ <excel-cop :checkIds="excelCheckIds" :showCheckbox="true" :data="excelList" :height="excelHeight"
|
|
|
|
+ @excelChange="funExcelChange" @checkChange="funExcelCheckChange"></excel-cop>
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="16">
|
|
<el-col :span="16">
|
|
- <div>
|
|
|
|
- <table-cop :data="tableData" :column="tableColumn" :loading="tableLoading" :height="tableHeight"
|
|
|
|
- :tableId="tableShowId" :tableName="tableName" @export="funExport"></table-cop>
|
|
|
|
|
|
+ <div :style="{ height: tableHeight }" class="flex flex-wrap justify-center overflow-y-auto">
|
|
|
|
+ <chart-cop height="500px" width="500px" v-for="item in chartData" :xAxis="item.xAxis" :title="item.title"
|
|
|
|
+ :series="item.series">
|
|
|
|
+ </chart-cop>
|
|
</div>
|
|
</div>
|
|
</el-col>
|
|
</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
- <el-progress :percentage="progress" class="!absolute top-0 right-0 left-0" :indeterminate="false" color="rgb(19,206,102)"
|
|
|
|
- :stroke-width="4" :show-text="false" />
|
|
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|