index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <a-form-model ref="form" :model="model" :rules="validatorRules">
  3. <a-form-model-item label="设备参数名" :labelCol="labelCol" :wrapperCol="wrapperCol">
  4. <a-input v-model="tagname" style="width: 20%" />
  5. <a-button @click="get" icon="reload" type="primary" style="margin-left: 10px">获取参数值</a-button>
  6. <a-button @click="getdirect" icon="reload" type="warning" style="margin-left: 10px">直接获取</a-button>
  7. </a-form-model-item>
  8. <a-form-model-item label="设备参数值" :labelCol="labelCol" :wrapperCol="wrapperCol">
  9. <a-input v-model="tagvalue" style="width: 20%" />
  10. <a-button type="info" icon="reload" @click="set" style="margin-left: 10px">设置参数值</a-button>
  11. </a-form-model-item>
  12. <a-form-model-item label="获取历史数据" :labelCol="labelCol" :wrapperCol="wrapperCol">
  13. <a-button type="info" icon="reload" @click="getlog">获取历史数据</a-button>
  14. <a-button type="info" icon="reload" style="margin-left: 10px" @click="loginwa">登录WA</a-button>
  15. <a-button @click="getall" icon="reload" type="warning" style="margin-left: 10px">直接获取所有</a-button>
  16. </a-form-model-item>
  17. <a-form-model-item label="返回内容" :labelCol="labelCol" :wrapperCol="wrapperCol">
  18. <a-textarea v-model="message" rows="9" />
  19. </a-form-model-item>
  20. </a-form-model>
  21. </template>
  22. <script>
  23. import { getWATagNameValues, setWATagNameValues, getWADataLog } from '@/api/datacoll/webaccess.js'
  24. import axios from 'axios'
  25. export default {
  26. name: 'Index',
  27. data() {
  28. return {
  29. model: {},
  30. labelCol: {
  31. xs: { span: 24 },
  32. sm: { span: 5 },
  33. },
  34. wrapperCol: {
  35. xs: { span: 24 },
  36. sm: { span: 16 },
  37. },
  38. tagname: '设备状态',
  39. tagvalue: 2,
  40. message: '',
  41. confirmLoading: false,
  42. }
  43. },
  44. methods: {
  45. // 登录webaccess
  46. loginwa() {
  47. const instance = axios.create({
  48. baseURL: window._CONFIG['webaccessURL'] + '/WaWebService', // 目标服务器的URL
  49. timeout: 20000, // 请求超时时间
  50. headers: {
  51. 'Content-Type': 'application/json',
  52. Authorization: window._CONFIG['webaccessAUTHOR'],
  53. },
  54. })
  55. console.log('登录前')
  56. instance
  57. .get('/Json/Logon')
  58. .then((response) => {
  59. console.log('登录', response)
  60. // console.log(response.header);
  61. })
  62. .catch((error) => {
  63. // 处理错误
  64. console.error(error)
  65. })
  66. },
  67. get() {
  68. console.log('获取参数')
  69. if (this.tagname == '' || this.tagname == null) {
  70. this.$modal.msgError('请输入设备参数名')
  71. return false
  72. }
  73. getWATagNameValues({ tagName: this.tagname }).then((response) => {
  74. console.log(response)
  75. this.message = response.message
  76. })
  77. },
  78. getdirect() {
  79. console.log('直接获取获取参数值')
  80. if (this.tagname == '' || this.tagname == null) {
  81. this.$modal.msgError('请输入设备参数名')
  82. return false
  83. }
  84. var param = { Tags: [
  85. { Name: this.tagname },
  86. ]}
  87. console.log(window._CONFIG)
  88. const instance = axios.create({
  89. baseURL: window._CONFIG['webaccessURL'] + '/WaWebService/Json', // 目标服务器的URL
  90. timeout: 3000, // 请求超时时间
  91. headers: {
  92. 'Content-Type': 'application/json',
  93. Authorization: window._CONFIG['webaccessAUTHOR'],
  94. },
  95. })
  96. instance
  97. .post('/GetTagValue/瑞莱', param)
  98. .then((response) => {
  99. console.log(response.data.Values)
  100. this.message = response.data.Values[0].Value
  101. })
  102. .catch((error) => {
  103. // 处理错误
  104. console.error(error)
  105. })
  106. },
  107. getall() {
  108. // console.log('直接获取所有')
  109. var param = {
  110. Tags: [
  111. { Name: '运行方式设定' }, { Name: '设备状态' }, { Name: '试验运行时间' }, { Name: '全部循环设定值' },
  112. { Name: '内部循环设定值' }, { Name: '全部循环运行值' }, { Name: '内部循环运行值' }, { Name: '预计结束时间' },
  113. { Name: '内部循环1_启始段' }, { Name: '内部循环1_结束段' }, { Name: '内部循环1_次数' },
  114. { Name: '内部循环2_启始段' }, { Name: '内部循环2_结束段' }, { Name: '内部循环2_次数' },
  115. { Name: '内部循环3_启始段' }, { Name: '内部循环3_结束段' }, { Name: '内部循环3_次数' },
  116. { Name: '内部循环4_启始段' }, { Name: '内部循环4_结束段' }, { Name: '内部循环4_次数' },
  117. { Name: '总的运行段数' }, { Name: '总的设定段数' }, { Name: '当前运行程序号' }, { Name: '当前运行段号' },
  118. { Name: '程序段运行时间' }, { Name: '程序段设定时间' }, { Name: '当前湿度值' }, { Name: '当前温度值' },
  119. { Name: '温度输出率' }, { Name: '起始温度值' }, { Name: '温度设定值' }, { Name: '湿度输出率' },
  120. { Name: '起始湿度值' }, { Name: '湿度设定值' }, { Name: '定值温度斜率值' },
  121. { Name: 'A1压机吸气压力' }, { Name: 'A1压机排气压力' }, { Name: 'A2压机吸气压力' }, { Name: 'A2压机排气压力' },
  122. { Name: 'B1压机吸气压力' }, { Name: 'B1压机排气压力' }, { Name: 'B2压机吸气压力' }, { Name: 'B2压机排气压力' },
  123. { Name: 'C1压机吸气压力' }, { Name: 'C1压机排气压力' }, { Name: 'C2压机吸气压力' }, { Name: 'C2压机排气压力' },
  124. { Name: 'D1压机吸气压力' }, { Name: 'D1压机排气压力' }, { Name: 'D2压机吸气压力' }, { Name: 'D2压机排气压力' },
  125. { Name: 'E1压机吸气压力' }, { Name: 'E1压机排气压力' }, { Name: 'E2压机吸气压力' }, { Name: 'E2压机排气压力' },
  126. { Name: 'F1压机吸气压力' }, { Name: 'F1压机排气压力' }, { Name: 'F2压机吸气压力' }, { Name: 'F2压机排气压力' },
  127. { Name: 'G1压机吸气压力' }, { Name: 'G1压机排气压力' }, { Name: 'G2压机吸气压力' }, { Name: 'G2压机排气压力' },
  128. { Name: 'H1压机吸气压力' }, { Name: 'H1压机排气压力' }, { Name: 'H2压机吸气压力' }, { Name: 'H2压机排气压力' },
  129. { Name: 'I1压机吸气压力' }, { Name: 'I1压机排气压力' }, { Name: 'I2压机吸气压力' }, { Name: 'I2压机排气压力' },
  130. { Name: 'J1压机吸气压力' }, { Name: 'J1压机排气压力' }, { Name: 'J2压机吸气压力' }, { Name: 'J2压机排气压力' },
  131. { Name: '氧浓度1采集值' }, { Name: '氧浓度2采集值' }, { Name: '氧浓度3采集值' }, { Name: '氧浓度4采集值' },
  132. { Name: '压差1采集值' }, { Name: '压差2采集值' }, { Name: '前风道鼓风变频器' }, { Name: '后风道鼓风变频器' },
  133. ],
  134. }
  135. const instance = axios.create({
  136. baseURL: window._CONFIG['webaccessURL'] + '/WaWebService/Json', // 目标服务器的URL
  137. timeout: 10000, // 请求超时时间
  138. headers: {
  139. 'Content-Type': 'application/json',
  140. Authorization: window._CONFIG['webaccessAUTHOR'],
  141. },
  142. })
  143. var begintime = new Date();
  144. instance
  145. .post('/GetTagValue/瑞莱', param)
  146. .then((response) => {
  147. console.log('刷新数据', { "设备实时值" : response.data.Values })
  148. this.message = "获取时长为:" + (new Date() - begintime) + " 毫秒";
  149. })
  150. .catch((error) => {
  151. // 处理错误
  152. console.error(error)
  153. this.message = "获取失败"
  154. })
  155. },
  156. set() {
  157. console.log('设置参数')
  158. if (this.tagname == '' || this.tagname == null) {
  159. this.$modal.msgError('请输入设备参数名')
  160. return false
  161. }
  162. if (this.tagvalue == '' || this.tagvalue == null) {
  163. this.$modal.msgError('请输入设备参数值')
  164. return false
  165. }
  166. setWATagNameValues({ tagName: this.tagname, tagValue: this.tagvalue }).then((response) => {
  167. console.log(response)
  168. this.message = response.message
  169. })
  170. },
  171. getlog() {
  172. console.log('获取历史数据')
  173. var begintime = new Date();
  174. getWADataLog().then((response) => {
  175. console.log(response)
  176. this.message = "获取成功,时长为:" + (new Date() - begintime) + " 毫秒";
  177. })
  178. },
  179. exit() {
  180. if (this.ws) {
  181. this.ws.close()
  182. this.ws = null
  183. }
  184. },
  185. },
  186. }
  187. </script>