Browse Source

定时任务+跳转下载文件

master
aBin 4 years ago
parent
commit
acabf8732d
  1. 6
      .env.development
  2. 16082
      package-lock.json
  3. 59
      src/components/Day/Day.vue
  4. 155
      src/components/Day/Weight.vue
  5. 72
      src/components/Search/Search.vue
  6. 10
      src/components/Table/Table.vue
  7. 80
      src/views/Index/Index.vue
  8. 35
      yarn.lock

6
.env.development

@ -1,10 +1,10 @@
VUE_APP_MODE=development
VUE_APP_NODE_ENV=development
VUE_APP_SCENE=wisdomcar_counter
VUE_APP_BASE_URL=http://test.tall.wiki/
VUE_APP_API_URL=http://test.tall.wiki/gateway
VUE_APP_BASE_URL=http://www.tall.wiki/
VUE_APP_API_URL=http://www.tall.wiki/gateway
VUE_APP_PROXY_URL=/gateway
VUE_APP_PUBLIC_PATH=/wisdomcar_counter
VUE_APP_MSG_URL=wss://test.tall.wiki/websocket/message/v4.0/ws
VUE_APP_MSG_URL=wss://www.tall.wiki/websocket/message/v4.0/ws
VUE_APP_TITLE=选矿系统
VUE_APP_DESCRIPTION=选矿系统

16082
package-lock.json

File diff suppressed because it is too large

59
src/components/Day/Day.vue

@ -4,6 +4,9 @@
<div id="echarts" :style="{ width: '100%', height: '500px' }" class="chart-box">
<div id="Day" style="width: 100%; height: 100%"></div>
</div>
<div id="RFID" :style="{ width: '100%', height: '150px' }" class="chart-box">
<div id="RFIDmap" style="width: 100%; height: 100%"></div>
</div>
</div>
</template>
<script>
@ -33,7 +36,7 @@ export default {
// option
option() {
return {
legend: { data: ['体重数据', 'RFID'] },
legend: { data: ['体重数据'] },
tooltip: { trigger: 'axis' },
grid: {
left: '3%',
@ -57,11 +60,47 @@ export default {
// lineStyle: { color: '#73C0DE' },
data: this.weightDate,
},
// {
// name: 'RFID',
// type: 'line',
// markPoint: { data: this.weight1 },
// data: this.weight2,
// },
],
};
},
// option1
option1() {
return {
legend: { data: ['RFID'] },
tooltip: { trigger: 'axis' },
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
},
xAxis: {
type: 'category',
data: this.dateTiem,
},
yAxis: {
type: 'value',
axisLabel: { formatter: '{value}' },
},
series: [
// {
// name: '',
// type: 'line',
// step: 'start',
// // lineStyle: { color: '#73C0DE' },
// data: this.weightDate,
// },
{
name: 'RFID',
type: 'line',
markPoint: { data: this.weight1 },
// data: this.weight2,
data: this.weight2,
},
],
};
@ -94,8 +133,10 @@ export default {
drawLine() {
// domecharts
let myChart = this.$echarts.init(document.getElementById('Day'));
let RFIDmap = this.$echarts.init(document.getElementById('RFIDmap'));
//
myChart.setOption(this.option);
RFIDmap.setOption(this.option1);
},
getStyle(obj, attr) {
if (obj.currentStyle) {
@ -113,24 +154,12 @@ export default {
//
for (let i = 0; i < list.length; i++) {
this.dateTiem.push(this.format(parseInt(list[i].time)));
this.weight2.push(-50);
this.weight2.push(0);
}
//
for (let i = 0; i < list.length; i++) {
this.weightDate.push(parseInt(list[i].value) / 1000);
}
// // rfid线
// for (let i = 0; i < list.length; i++) {
// let obj = {};
// if (list[i].type === 2) {
// obj = {
// value: list[i].name,
// xAxis: this.format(parseInt(list[i].time)),
// yAxis: -50,
// };
// }
// this.weight1.push(obj);
// }
// rfid线
for (let i = 0; i < list.length; i++) {
let obj = {};

155
src/components/Day/Weight.vue

@ -0,0 +1,155 @@
<template>
<!-- 选矿新版rfid图 -->
<div>
<div id="Weight-box" :style="{ width: '100%', height: '500px' }" class="chart-box">
<div id="Weight" style="width: 100%; height: 100%"></div>
</div>
</div>
</template>
<script>
export default {
name: 'Weight',
props: {
list: {
type: Array,
default: () => [],
},
},
data() {
return {
width: '',
height: '',
timer: null,
dateTiem: [],
weight1: [],
weight2: [],
weight3: [],
start: 95,
end: 100,
};
},
computed: {
// option
option() {
return {
color: ['#80FFA5', '#FF0087', '#FFBF00'],
title: { text: '倾角图' },
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: { backgroundColor: '#6a7985' },
},
},
dataZoom: [
{
start: 98,
end: 100,
},
],
legend: { data: ['称重1', '称重2', '称重3'] },
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
},
xAxis: [
{
type: 'category',
boundaryGap: false,
data: this.dateTiem, //
},
],
yAxis: [{ type: 'value' }],
series: [
{
name: '称重1',
type: 'line',
// stack: '',
smooth: true,
lineStyle: { width: 2 },
showSymbol: false,
emphasis: { focus: 'series' },
data: this.weight1,
},
{
name: '称重2',
type: 'line',
// stack: '',
smooth: true,
lineStyle: { width: 2 },
showSymbol: false,
emphasis: { focus: 'series' },
data: this.weight2,
},
{
name: '称重3',
type: 'line',
// stack: '',
smooth: true,
lineStyle: { width: 2 },
showSymbol: false,
emphasis: { focus: 'series' },
data: this.weight3,
},
],
};
},
},
watch: {
list() {
this.forList(this.list);
this.drawLine();
},
},
mounted() {
this.forList(this.list);
this.drawLine();
let wh = window.innerWidth;
let hg = window.innerHeight;
this.width = wh + 'px';
this.height = hg + 'px';
window.onresize = () => {
return (() => {
wh = window.innerWidth;
hg = window.innerHeight;
this.width = wh + 'px';
this.height = hg + 'px';
})();
};
},
methods: {
drawLine() {
// domecharts
let WeightChart = this.$echarts.init(document.getElementById('Weight'));
//
WeightChart.setOption(this.option);
},
getStyle(obj, attr) {
if (obj.currentStyle) {
return obj.currentStyle[attr];
} else {
return document.defaultView.getComputedStyle(obj, null)[attr];
}
},
//
forList(list) {
//
for (let i = 0; i < list.length; i++) {
this.dateTiem.push(this.$moment(parseInt(list[i].time)).format('YYYY-MM-DD HH:mm:ss'));
// 1
this.weight1.push(list[i].value.split(',')[0]);
// 2
this.weight2.push(list[i].value.split(',')[1]);
// 3
this.weight3.push(list[i].value.split(',')[2]);
}
},
},
};
</script>
<style lang="stylus" scoped ></style>

72
src/components/Search/Search.vue

@ -1,3 +1,10 @@
<!--
* @Author: wally
* @email: 18603454788@163.com
* @Date: 2021-03-25 20:52:37
* @LastEditors: wally
* @LastEditTime: 2021-03-26 00:28:57
-->
<template>
@ -8,6 +15,10 @@
:format="dateFormat"
@change="onChange"
/>
<span class="ml-3">类型</span>
<a-select style="width: 120px" @change="handleChange" allow-clear placeholder="全部">
<a-select-option v-for="item in typeList" :value="item.id" :key="item.id"> {{ item.name }} </a-select-option>
</a-select>
<a-button @click="handleTableChange" class="mx-2" type="primary">搜索</a-button>
<a-button @click="downFile" icon="download" class="mx-2 down-btn" type="primary">下载</a-button>
</div>
@ -15,21 +26,46 @@
</template>
<script>
import { weightExport } from 'config/api';
export default {
name: 'Search',
data() {
return {
timeObj: {
startTime: this.$moment(Date.parse(new Date()) - 3600 * 30 * 24 * 1000).format('YYYY-MM-DD'),
startTime: this.$moment(Date.parse(new Date()) - 3600 * 24 * 1000).format('YYYY-MM-DD'),
types: [1, 2],
endTime: this.$moment(Date.parse(new Date())).format('YYYY-MM-DD'),
},
dateFormat: 'YYYY-MM-DD',
clear: true,
typeList: [
{
id: 1,
name: '称重',
},
{
id: 2,
name: 'RFID',
},
{
id: 7,
name: '倾角',
},
],
btnObj: null,
};
},
created() {
this.btnObj = this.timeObj;
},
methods: {
handleChange(e) {
if (e) {
this.timeObj.types = [];
this.timeObj.types.push(e);
} else {
this.timeObj.types = [1, 2];
}
},
onChange(e) {
// this.timeObj.endTime = this.$moment(e._d).unix() * 1000 + 3600 * 24 * 1000;
console.log(e);
@ -44,9 +80,11 @@ export default {
this.timeObj.endTime = this.$moment(this.timeObj.endTime).unix() * 1000;
}
const mistake = this.timeObj.endTime - this.timeObj.startTime;
if (mistake > 3600 * 24 * 30 * 1000) {
this.$message.error('时间跨度请不要超过30天');
if (mistake > 3600 * 24 * 7 * 1000) {
this.$message.error('时间跨度请不要超过7天');
} else {
console.log(this.timeObj);
this.btnObj = this.timeObj;
this.$emit('getData', this.timeObj);
}
},
@ -59,14 +97,26 @@ export default {
this.timeObj.endTime = this.$moment(this.timeObj.endTime).unix() * 1000;
}
const mistake = this.timeObj.endTime - this.timeObj.startTime;
if (mistake > 3600 * 24 * 30 * 1000) {
this.$message.error('时间跨度请不要超过30天');
if (mistake > 3600 * 24 * 7 * 1000) {
this.$message.error('时间跨度请不要超过7天');
} else {
this.$message.success('导出成功');
window.open(
`http://test.tall.wiki/gateway/wisdomcar/record/weightExport?
startTime=${this.timeObj.startTime}&&endTime=${this.timeObj.endTime}`,
);
if (this.timeObj.types.length > 1) {
console.log(`https://www.tall.wiki/gateway/wisdomcar/record/weightExport?
startTime=${this.btnObj.startTime}&&endTime=${this.btnObj.endTime}
&&types=${this.btnObj.types[0]}&&types=${this.btnObj.types[1]}`);
window.open(
`https://www.tall.wiki/gateway/wisdomcar/record/weightExport?
startTime=${this.btnObj.startTime}&&endTime=${this.btnObj.endTime}
&&types=${this.btnObj.types[0]}&&types=${this.btnObj.types[1]}`,
);
} else {
window.open(
`https://www.tall.wiki/gateway/wisdomcar/record/weightExport?
startTime=${this.btnObj.startTime}&&endTime=${this.btnObj.endTime}
&&types=${this.btnObj.types[1]}`,
);
}
}
},
},

10
src/components/Table/Table.vue

@ -1,3 +1,10 @@
<!--
* @Author: wally
* @email: 18603454788@163.com
* @Date: 2021-03-25 20:52:37
* @LastEditors: wally
* @LastEditTime: 2021-03-25 21:49:41
-->
<template>
<div class="main flex-1">
<div style="width: 100%" v-if="list && list.length > 0">
@ -18,7 +25,8 @@
</template>
<template slot="value" slot-scope="text, record">
<span v-if="record.type === 1">{{ record.value / 1000 }}kg</span>
<span v-if="record.type === 2">{{ record.name }}</span>
<span v-else-if="record.type === 2">{{ record.name }}</span>
<span v-else>{{ record.value }}</span>
</template>
</a-table>
</div>

80
src/views/Index/Index.vue

@ -1,11 +1,21 @@
<!--
* @Author: wally
* @email: 18603454788@163.com
* @Date: 2021-03-25 20:52:38
* @LastEditors: wally
* @LastEditTime: 2021-03-26 00:05:43
-->
<template>
<div>
<div class="fill-width mb-3">
<a-card style="width: 100%; height: 100px; margin-bottom: 12px">
<Search @getData="getData" />
</a-card>
<a-card style="width: 100%; height: 600px; margin-bottom: 12px" title="平车记录">
<Day :list="list" v-if="list.length > 0" />
<a-card style="width: 100%; height: 750px; margin-bottom: 12px" title="平车记录">
<div v-if="list.length > 0">
<Day :list="list" v-if="timeObj.types[0] !== 7" />
<Weight :list="list" v-else />
</div>
<a-empty v-else />
</a-card>
<a-card style="width: 100%; height: auto">
@ -18,34 +28,64 @@
<script>
import { mapActions } from 'vuex';
import Day from 'components/Day/Day.vue';
import Weight from 'components/Day/Weight.vue';
import Search from 'components/Search/Search.vue';
import Table from 'components/Table/Table.vue';
import { weightList } from 'config/api';
export default {
name: 'Index',
components: { Day, Search, Table },
components: { Day, Search, Table, Weight },
data() {
return {
list: [],
str: '',
disProgress: true,
timeObj: {
startTime: Date.parse(new Date()) - 3600 * 24 * 1000,
endTime: Date.parse(new Date()),
types: [1, 2],
},
timer: null,
timeNum: 5000,
};
},
async created() {
if (this.timer) {
clearInterval(this.timer);
}
this.timer = null;
await this.getData();
},
destoryed() {
this.clearInterval(this.timer);
this.timer = null;
},
methods: {
async getData(timeData) {
const hide = this.$message.loading('正在获取数据...', 0);
try {
if (timeData) {
this.timeObj.startTime = timeData.startTime;
this.timeObj.endTime = timeData.endTime;
this.timeObj.types = timeData.types;
}
console.log(this.timeObj.types);
clearInterval(this.timer);
this.timer = null;
if (this.timeObj.types.length > 0 && this.timeObj.types[0] === 7) {
this.timeNum = 60000;
} else {
this.timeNum = 5000;
}
this.timer = setInterval(async () => {
await this.getData1();
}, this.timeNum);
this.disProgress = true;
const params = {
param: {
carId: 1,
startTime: timeData && timeData.startTime ? timeData.startTime : Date.parse(new Date()) - 3600 * 30 * 24 * 1000,
endTime: timeData && timeData.endTime ? timeData.endTime : Date.parse(new Date()),
startTime: timeData && timeData.startTime ? timeData.startTime : this.timeObj.startTime,
endTime: timeData && timeData.endTime ? timeData.endTime : this.timeObj.endTime,
types: timeData && timeData.types ? timeData.types : this.timeObj.types,
},
};
const res = await weightList(params);
@ -54,10 +94,32 @@ export default {
let { list } = this;
list = data;
this.list = [...list];
setTimeout(hide, 500);
this.$message.success('获取数据成功');
// this.list = data;
this.disProgress = false;
} else {
// this.$message.error(msg);
}
} catch (error) {
// this.$message.error(error);
}
},
async getData1() {
try {
const params = {
param: {
carId: 1,
startTime: this.timeObj.startTime,
endTime: this.timeObj.endTime,
types: this.timeObj.types,
},
};
const res = await weightList(params);
const { code, data, msg } = res.data;
if (code === 200) {
let { list } = this;
list = data;
this.list = [...list];
} else {
this.$message.error(msg);
}

35
yarn.lock

@ -1717,8 +1717,8 @@
"color-convert" "^2.0.1"
"ansi-styles@^4.1.0":
"integrity" "sha1-7dgDYornHATIWuegkG7a00tkiTc="
"resolved" "https://registry.npm.taobao.org/ansi-styles/download/ansi-styles-4.3.0.tgz?cache=0&sync_timestamp=1601839122515&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fansi-styles%2Fdownload%2Fansi-styles-4.3.0.tgz"
"integrity" "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="
"resolved" "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz"
"version" "4.3.0"
dependencies:
"color-convert" "^2.0.1"
@ -2536,8 +2536,8 @@
"supports-color" "^7.1.0"
"chalk@^4.1.0":
"integrity" "sha1-ThSHCmGNni7dl92DRf2dncMVZGo="
"resolved" "https://registry.npm.taobao.org/chalk/download/chalk-4.1.0.tgz"
"integrity" "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A=="
"resolved" "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz"
"version" "4.1.0"
dependencies:
"ansi-styles" "^4.1.0"
@ -2763,8 +2763,8 @@
"color-name" "1.1.3"
"color-convert@^2.0.1":
"integrity" "sha1-ctOmjVmMm9s68q0ehPIdiWq9TeM="
"resolved" "https://registry.npm.taobao.org/color-convert/download/color-convert-2.0.1.tgz"
"integrity" "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ=="
"resolved" "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz"
"version" "2.0.1"
dependencies:
"color-name" "~1.1.4"
@ -2775,8 +2775,8 @@
"version" "1.1.3"
"color-name@~1.1.4":
"integrity" "sha1-wqCah6y95pVD3m9j+jmVyCbFNqI="
"resolved" "https://registry.npm.taobao.org/color-name/download/color-name-1.1.4.tgz"
"integrity" "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
"resolved" "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz"
"version" "1.1.4"
"color-string@^1.5.4":
@ -4710,8 +4710,8 @@
"version" "3.0.0"
"has-flag@^4.0.0":
"integrity" "sha1-lEdx/ZyByBJlxNaUGGDaBrtZR5s="
"resolved" "https://registry.npm.taobao.org/has-flag/download/has-flag-4.0.0.tgz"
"integrity" "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
"resolved" "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz"
"version" "4.0.0"
"has-symbols@^1.0.1":
@ -8787,8 +8787,8 @@
"has-flag" "^4.0.0"
"supports-color@^7.1.0":
"integrity" "sha1-G33NyzK4E4gBs+R4umpRyqiWSNo="
"resolved" "https://registry.npm.taobao.org/supports-color/download/supports-color-7.2.0.tgz?cache=0&sync_timestamp=1598611732186&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsupports-color%2Fdownload%2Fsupports-color-7.2.0.tgz"
"integrity" "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw=="
"resolved" "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz"
"version" "7.2.0"
dependencies:
"has-flag" "^4.0.0"
@ -9411,9 +9411,9 @@
"version" "2.3.4"
"vue-loader-v16@npm:vue-loader@^16.0.0-beta.7":
"integrity" "sha1-9bKG1grGiGaExjoXoYQ5HMngGZo="
"resolved" "https://registry.npm.taobao.org/vue-loader/download/vue-loader-16.1.1.tgz?cache=0&sync_timestamp=1607093652138&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-loader%2Fdownload%2Fvue-loader-16.1.1.tgz"
"version" "16.1.1"
"integrity" "sha512-8QTxh+Fd+HB6fiL52iEVLKqE9N1JSlMXLR92Ijm6g8PZrwIxckgpqjPDWRP5TWxdiPaHR+alUWsnu1ShQOwt+Q=="
"resolved" "https://registry.npmjs.org/vue-loader/-/vue-loader-16.1.2.tgz"
"version" "16.1.2"
dependencies:
"chalk" "^4.1.0"
"hash-sum" "^2.0.0"
@ -9466,6 +9466,11 @@
"resolved" "https://registry.npm.taobao.org/vue/download/vue-2.6.12.tgz"
"version" "2.6.12"
"vuetify@^2.4.6":
"integrity" "sha512-oqAWKAin07ip/QuT/p4bL1LegE3MYPbfojrOcj80RATZDSnJyco2PZD8QuIzd0RhYfdAuSTkY8elvHsLu90RuQ=="
"resolved" "https://registry.npmjs.org/vuetify/-/vuetify-2.4.6.tgz"
"version" "2.4.6"
"vuex@^3.4.0":
"integrity" "sha1-8bjc6mSbwlJUz09DWAgdv12hiz0="
"resolved" "https://registry.npm.taobao.org/vuex/download/vuex-3.5.1.tgz?cache=0&sync_timestamp=1604065438225&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvuex%2Fdownload%2Fvuex-3.5.1.tgz"

Loading…
Cancel
Save