123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <template>
- <a-form-model ref="form" :model="model" :rules="validatorRules">
- <a-form-model-item label="设备参数名" :labelCol="labelCol" :wrapperCol="wrapperCol">
- <a-input v-model="tagname" style="width: 20%" />
- <a-button @click="get" icon="reload" type="primary" style="margin-left: 10px">获取参数值</a-button>
- <a-button @click="getdirect" icon="reload" type="warning" style="margin-left: 10px">直接获取</a-button>
- </a-form-model-item>
- <a-form-model-item label="设备参数值" :labelCol="labelCol" :wrapperCol="wrapperCol">
- <a-input v-model="tagvalue" style="width: 20%" />
- <a-button type="info" icon="reload" @click="set" style="margin-left: 10px">设置参数值</a-button>
- </a-form-model-item>
- <a-form-model-item label="获取历史数据" :labelCol="labelCol" :wrapperCol="wrapperCol">
- <a-button type="info" icon="reload" @click="getlog">获取历史数据</a-button>
- <a-button type="info" icon="reload" @click="loginwa">登录WA</a-button>
- </a-form-model-item>
- <a-form-model-item label="返回内容" :labelCol="labelCol" :wrapperCol="wrapperCol">
- <a-textarea v-model="message" rows="9" />
- </a-form-model-item>
- </a-form-model>
- </template>
- <script>
- import { getWATagNameValues, setWATagNameValues, getWADataLog } from '@/api/datacoll/webaccess.js'
- import axios from 'axios'
- export default {
- name: 'Index',
- data() {
- return {
- model: {},
- labelCol: {
- xs: { span: 24 },
- sm: { span: 5 },
- },
- wrapperCol: {
- xs: { span: 24 },
- sm: { span: 16 },
- },
- tagname: '设备状态',
- tagvalue: 2,
- message: '',
- confirmLoading: false,
- }
- },
- methods: {
- loginwa() {
- const instance = axios.create({
- baseURL: 'https://192.168.2.246/WaWebService', // 目标服务器的URL
- timeout: 20000, // 请求超时时间
- headers: {
- 'Content-Type': 'application/json',
- Authorization: 'Basic YWRtaW46',
- },
- })
- instance
- .get('/Json/Logon')
- .then((response) => {
- console.log("登录", response);
- console.log(response.header);
- })
- .catch((error) => {
- // 处理错误
- console.error(error)
- })
- },
- get() {
- console.log('获取参数')
- if (this.tagname == '' || this.tagname == null) {
- this.$modal.msgError('请输入设备参数名')
- return false
- }
- getWATagNameValues({ tagName: this.tagname }).then((response) => {
- console.log(response)
- this.message = response.message
- })
- },
- getdirect() {
- console.log('直接获取获取参数值')
- if (this.tagname == '' || this.tagname == null) {
- this.$modal.msgError('请输入设备参数名')
- return false
- }
- var param = { Tags: [
- { Name: this.tagname },
- ]}
- const instance = axios.create({
- baseURL: 'http://127.0.0.1/WaWebService/Json', // 目标服务器的URL
- timeout: 3000, // 请求超时时间
- headers: {
- 'Content-Type': 'application/json',
- Authorization: 'Basic YWRtaW46',
- },
- })
- instance
- .post('/GetTagValue/瑞莱', param)
- .then((response) => {
- console.log(response.data.Values)
- this.message = response.data.Values[0].Value
- })
- .catch((error) => {
- // 处理错误
- console.error(error)
- })
- },
- set() {
- console.log('设置参数')
- if (this.tagname == '' || this.tagname == null) {
- this.$modal.msgError('请输入设备参数名')
- return false
- }
- if (this.tagvalue == '' || this.tagvalue == null) {
- this.$modal.msgError('请输入设备参数值')
- return false
- }
- setWATagNameValues({ tagName: this.tagname, tagValue: this.tagvalue }).then((response) => {
- console.log(response)
- this.message = response.message
- })
- },
- getlog() {
- console.log('获取历史数据')
- getWADataLog().then((response) => {
- console.log(response)
- this.message = response.message
- })
- },
- exit() {
- if (this.ws) {
- this.ws.close()
- this.ws = null
- }
- },
- },
- }
- </script>
|