From 11c0a77405834bdaea58c5f8f5eb9fb7b2df62e4 Mon Sep 17 00:00:00 2001
From: wu <2468489804@qq.com>
Date: Sun, 24 Jul 2022 10:39:22 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0SCADA=E6=95=B0=E6=8D=AE?=
=?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=89=8D=E7=AB=AFEXCEL=E5=AF=BC=E5=87=BA&?=
=?UTF-8?q?=E7=AD=9B=E9=80=89=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main.js | 5 +-
src/views/scada/scadaQuery/index.vue | 254 ++++++++++++++++++++++++++-
2 files changed, 256 insertions(+), 3 deletions(-)
diff --git a/src/main.js b/src/main.js
index 034a1b7..12716e6 100644
--- a/src/main.js
+++ b/src/main.js
@@ -12,17 +12,20 @@ import 'element-ui/lib/theme-chalk/index.css'
import D2Crud from '@d2-projects/d2-crud'
// Cheetah-Grid
import vueCheetahGrid from 'vue-cheetah-grid'
-
+//导入D2-admin的导出EXCEL插件
+import pluginExport from '@d2-projects/vue-table-export'
// 菜单和路由设置
import router from './router'
import { menuAside } from '@/menu'
import { frameInRoutes } from '@/router/routes'
+
// 核心插件
Vue.use(d2Admin)
Vue.use(ElementUI)
Vue.use(D2Crud)
Vue.use(vueCheetahGrid)
+Vue.use(pluginExport)
new Vue({
router,
diff --git a/src/views/scada/scadaQuery/index.vue b/src/views/scada/scadaQuery/index.vue
index bdd40f6..a6792af 100644
--- a/src/views/scada/scadaQuery/index.vue
+++ b/src/views/scada/scadaQuery/index.vue
@@ -44,8 +44,66 @@
查询
+
+ 导出EXCEL
+
+
+
+
+
+
+
+
+
+
+
+ TRUE
+ FALSE
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 筛选
+
+
+ 还原
+
const now = new Date()
+//导出表头
+const columns = [
+ {
+ label: '序号',
+ prop: 'id'
+ },
+ {
+ label: '节点名称',
+ prop: 'name'
+ },
+ {
+ label: '值',
+ prop: 'value'
+ },
+ {
+ label: '设备',
+ prop: 'device_code'
+ },
+ {
+ label: '批次',
+ prop: 'batch'
+ },
+ {
+ label: '采集时间',
+ prop: 'capture_time'
+ }
+
+]
+
+const options = [
+ {
+ value: 'string',
+ label: 'string(字符串)'
+ },
+ {
+ value: 'number',
+ label: 'number(数字)'
+ },
+ {
+ value: 'bool',
+ label: 'bool(逻辑值)'
+ }
+]
+
+
+const stringOptions = [
+ {
+ value: '_.eq',
+ label: '等于'
+ },
+ {
+ value: '!_.eq',
+ label: '不等于'
+ },
+ {
+ value: 'this.stringCompare',
+ label: '包含'
+ },
+ {
+ value: '!this.stringCompare',
+ label: '不包含'
+ }
+]
+
export default {
data () {
return {
@@ -125,7 +247,24 @@ export default {
picker.$emit('pick', [start, end])
}
}]
- }
+ },
+ excelData: [],
+ stringOptions,
+ show_integer_input: '',
+ key: false,
+ selectData: {
+ select: '>',
+ max: 0,
+ selectBool: false,
+ selectString: '',
+ selectStringCompare: '_.eq',
+ intervalNumber: {
+ min: 0,
+ max: 0
+ }
+ },
+ valueType: '',
+ options,
}
},
methods: {
@@ -144,6 +283,10 @@ export default {
}
},
async getData () {
+ this.excelData = []
+ if (!this.formInline.workingSubclass) {
+ this.$message.error('请选择工序单元')
+ }
try {
this.data = await this.$api.QUERY_NODE_DATA({
workingSubclass: this.formInline.workingSubclass,
@@ -154,10 +297,117 @@ export default {
} catch (e) {
console.log(e)
}
- }
+ },
+ async exportExcel() {
+ let data = this.excelData.length < 1 ? this.data : this.excelData //如果没有使用 this.excelData为空则代表没有使用筛选
+ this.$export.excel({
+ columns,
+ data
+ }).then(() => {
+ this.$message.error('导出EXCEL成功!')
+ })
+ },
+ valueSearch(e) {
+ this.show_integer_input = e
+ },
+ //还原
+ selectRestore() {
+ this.show_integer_input = ''
+ this.selectData = {
+ select: '>',
+ max: 0,
+ selectBool: false,
+ selectString: '',
+ selectStringCompare: '_.eq',
+ intervalNumber: {
+ min: 0,
+ max: 0
+ }
+ }
+ this.excelData = []
+ this.valueType = ''
+ this.key = !this.key //取反重新渲染组件
+ },
+ //筛选
+ search() {
+ let max = this.selectData.intervalNumber.max
+ let min = this.selectData.intervalNumber.min
+ if (max < min) {
+ this.selectData.intervalNumber.min = 0
+ this.selectData.intervalNumber.max = 0
+ this.$message.error('数字区间筛选最大值不能小于最小值')
+ return false
+ }
+ this.excelData = []
+ this.key = !this.key //取反重新组件渲染
+ },
+ tableFilter(e) {
+ switch (this.valueType) {
+ case 'string':
+ if (eval(this.selectData.selectStringCompare + '("' + this.selectData.selectString + '","' + e.value + '")')) {
+ this.excelData.push(e)
+ return e;
+ }
+ break;
+ case 'bool':
+ if (e.value === this.selectData.selectBool) {
+ this.excelData.push(e)
+ return e;
+ }
+ break;
+ case 'number':
+ //判断值是否为数字并且不为Boolean
+ if (Number(e.value) && !isBoolean(e.value)) {
+ let condition = e.value + this.selectData.select + this.selectData.max
+ if (this.selectData.intervalNumber.max && this.selectData.select !== '=') {
+ //拼接区间判断
+ condition = '(' + condition + ') && '
+ condition += '(' + this.selectData.intervalNumber.min + ' < ' + e.value + ') && (' + e.value + ' < ' + this.selectData.intervalNumber.max + ')'
+ }
+
+ if (eval(condition)) {
+ this.excelData.push(e)
+ return e;
+ }
+ }
+ break;
+ default:
+ return e
+ }
+ },
+ stringCompare(val, other) {
+ return other.indexOf(val) > -1 ? true : false
+ },
},
mounted () {
this.getworkingSubclasses()
}
}
+
\ No newline at end of file