index.vue 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117
  1. <template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
  2. <div style="padding-left: 30px">
  3. <span style="font-weight: bold">通道:</span>
  4. <vxe-select v-model="tunnelId" placeholder="请选择使用通道" style="width: 10%" clearable>
  5. <vxe-option v-for="item in tunnelList" :key="item.id" :value="item.id" :label="item.tunnelName" />
  6. </vxe-select>
  7. <span style="font-weight: bold">设备:</span>
  8. <vxe-select v-model="eqId" placeholder="请选择查询设备" style="width: 10%" clearable>
  9. <vxe-option v-for="(item,index) in eqTableData" :key="index" :value="index" :label="item.name" />
  10. </vxe-select>
  11. <div style="display: inline-block">
  12. <vxe-toolbar>
  13. <template v-slot:buttons>
  14. <vxe-button status="primary" @click="searchPointData()">查询</vxe-button>
  15. <vxe-button status="primary" icon="fa fa-plus" @click="insertEvent()">新增</vxe-button>
  16. <vxe-button status="primary" icon="fa fa-files-o" @click="multiAdd=true">批量新增</vxe-button>
  17. <vxe-button status="primary" icon="fa fa-files-o" @click="batchDeletePoint()">批量删除</vxe-button>
  18. <vxe-button status="primary" icon="vxe-icon--refresh roll" @click="refushAll()">刷新数据点</vxe-button>
  19. </template>
  20. </vxe-toolbar>
  21. </div>
  22. <!-- <div style="float: right;padding-top: 10px">
  23. &lt;!&ndash;<el-button-group>
  24. <el-button type="primary" size="small" @click="refushEq()">刷新设备</el-button>
  25. <el-button type="primary" size="small" @click="refushTunnel()">刷新通道</el-button>
  26. </el-button-group>&ndash;&gt;
  27. </div>-->
  28. <vxe-table
  29. ref="xTable"
  30. border
  31. stripe
  32. resizable
  33. show-overflow
  34. keep-source
  35. max-height="800"
  36. align="center"
  37. :cell-style="headerCellClassName"
  38. :loading="loading"
  39. :data="tableData.slice((currentPage-1)*pageSize,currentPage*pageSize)"
  40. >
  41. <vxe-table-column type="checkbox" />
  42. <vxe-table-column field="equipmentId" title="名称" :formatter="formateEqId" />
  43. <vxe-table-column field="equipmentAttribute.explanation" title="设备属性" />
  44. <vxe-table-column title="实时数据">
  45. <template #default="{ row }">
  46. <!--{{row.id}}-->
  47. {{realTimeData[row.id]}}
  48. </template>
  49. </vxe-table-column>
  50. <vxe-table-column
  51. field="dataSource"
  52. title="数据源"
  53. :filters="enums.geterDataSourceEnum"
  54. :formatter="formatterDataSource"
  55. />
  56. <vxe-table-column field="tunnelId" title="使用通道" :formatter="formateId" />
  57. <vxe-table-column field="protocolPointNo" sortable title="通道点位" />
  58. <vxe-table-column field="protocolPointType" title="通道数据类型" :formatter="formatterPointType" />
  59. <vxe-table-column field="magnification" title="倍率" />
  60. <vxe-table-column field="generationRegulation" title="数据生成公式" :formatter="generationRegulationFormatter"/>
  61. <vxe-table-column field="showOnHomePage" title="展示顺序" sortable :formatter="showOnHomePageFormatter" />
  62. <vxe-table-column field="needAudit" title="是否考核" :filters="needAuditList" :formatter="formatterNeedAudit">
  63. <template #header>
  64. <i :class="columnShow ?'vxe-icon--remove' : 'vxe-icon--circle-plus'" @click="columnButClick"></i>
  65. <span>是否考核</span>
  66. </template>
  67. </vxe-table-column>
  68. <vxe-table-column field="maxChangeValue" title="最大变化值" :visible="false" />
  69. <vxe-table-column field="maxValue" title="最大值" :visible="false" />
  70. <vxe-table-column field="minValue" title="最小值" :visible="false" />
  71. <vxe-table-column field="maxDuration" title="最长持续时间(min)" :visible="false"/>
  72. <vxe-table-column field="id" title="Id" />
  73. <vxe-table-column title="操作" width="150">
  74. <template v-slot="{ row }">
  75. <template>
  76. <vxe-button status="primary" size="mini" @click="editRowEvent(row)">编辑</vxe-button>
  77. <vxe-button status="danger" size="mini" @click="removeEvent(row)">删除</vxe-button>
  78. </template>
  79. </template>
  80. </vxe-table-column>
  81. </vxe-table>
  82. <vxe-pager
  83. perfect
  84. :current-page.sync="currentPage"
  85. :page-size.sync="pageSize"
  86. :total="totalResult"
  87. :layouts="['PrevJump', 'PrevPage', 'JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']"
  88. />
  89. <vxe-modal
  90. ref="xModal"
  91. v-model="showEdit"
  92. :title="selectRow ? '编辑&保存' : '新增&保存'"
  93. width="800"
  94. resize
  95. destroy-on-close
  96. >
  97. <vxe-form
  98. ref="form"
  99. :data="formData"
  100. :rules="formRules"
  101. title-align="center"
  102. title-width="100"
  103. @submit="submitEvent"
  104. >
  105. <vxe-form-item title="设备类型" field="eqType" span="12">
  106. <vxe-select v-model="formData.eqType" placeholder="请选择设备类型" size="medium" @change="changeEqA">
  107. <vxe-option
  108. v-for="item in enums.equipmentTypeEnum"
  109. :key="item.value"
  110. :value="item.value"
  111. :label="item.label"
  112. />
  113. </vxe-select>
  114. </vxe-form-item>
  115. <vxe-form-item title="设备名" field="equipmentId" span="12">
  116. <vxe-select v-model="formData.equipmentId" placeholder="请选择设备名" size="medium">
  117. <vxe-option v-for="(item,index) in eqData" :key="index" :value="item.id" :label="item.name" />
  118. </vxe-select>
  119. </vxe-form-item>
  120. <vxe-form-item title="设备属性" field="equipmentAttribute" span="12">
  121. <vxe-select v-model="formData.equipmentAttribute.id" placeholder="请选择设备属性" size="medium" @change="attribute">
  122. <vxe-option v-for="item in eqaTableData" :key="item.id" :value="item.id" :label="item.explanation" />
  123. </vxe-select>
  124. </vxe-form-item>
  125. <vxe-form-item
  126. title="倍率"
  127. field="magnification"
  128. span="12"
  129. :item-render="{name: 'input', attrs: {type: 'float'}}"
  130. />
  131. <vxe-form-item title="数据源" field="dataSource" span="12" title-width="100px">
  132. <vxe-select v-model="formData.dataSource" placeholder="请选择点位生成规则" size="medium" @change="datasChange">
  133. <vxe-option
  134. v-for="item in enums.geterDataSourceEnum"
  135. :key="item.value"
  136. :value="item.value"
  137. :label="item.label"
  138. />
  139. </vxe-select>
  140. </vxe-form-item>
  141. <!--外部接入-->
  142. <vxe-form-item title="使用通道" field="tunnelId" span="12" v-show="!gatherDisable">
  143. <vxe-select
  144. v-model="formData.tunnelId"
  145. placeholder="请选择使用通道"
  146. size="medium"
  147. :disabled="gatherDisable"
  148. @change="getByTunnel"
  149. >
  150. <vxe-option v-for="item in tunnelList" :key="item.id" :value="item.id" :label="item.tunnelName" />
  151. </vxe-select>
  152. </vxe-form-item>
  153. <vxe-form-item title="通道点位" field="protocolPointNo" span="12" v-show="!gatherDisable">
  154. <vxe-input
  155. v-model="formData.protocolPointNo"
  156. placeholder="请输入通道点位"
  157. clearable
  158. type="number"
  159. :disabled="gatherDisable"
  160. @change="checkprotocolPointNo"
  161. />
  162. </vxe-form-item>
  163. <vxe-form-item title="通道数据类型" field="protocolPointType" span="12" title-width="120px">
  164. <vxe-select v-model="formData.protocolPointType" placeholder="请选择通道数据类型" size="medium">
  165. <vxe-option
  166. v-for="item in protocolDataType"
  167. :key="item.value"
  168. :value="item.value"
  169. :label="item.label"
  170. />
  171. </vxe-select>
  172. </vxe-form-item>
  173. <!--公式生成-->
  174. <vxe-form-item title="数据生成公式" field="generationRegulation" title-width="120px" span="24" v-show="generateShow">
  175. <vxe-input
  176. class="regulate"
  177. v-model="formData.generationRegulation"
  178. placeholder="请输入属性规则"
  179. type="textarea"
  180. clearable
  181. :disabled="generateDisable"
  182. >
  183. <template #suffix>
  184. <vxe-button icon="el-icon-key"
  185. v-show="regButShow"
  186. @click="regButClick"
  187. @dblclick.native="generateDisable = false"
  188. >系统自动计算</vxe-button>
  189. </template>
  190. </vxe-input>
  191. <span v-show="regTextShow">{{generationRegulationText}}</span>
  192. </vxe-form-item>
  193. <vxe-form-item title="首页展示顺序" title-width="120px" field="showOnHomePage" span="12">
  194. <vxe-input
  195. v-model="formData.showOnHomePage"
  196. placeholder="0为不展示"
  197. type="integer"
  198. clearable
  199. :disabled="formData.eqType!='WINDTOWER' && formData.eqType!='WEATHERSTATION'"
  200. />
  201. </vxe-form-item>
  202. <vxe-form-item title="是否考核" field="needAudit" span="12">
  203. <vxe-select v-model="formData.needAudit" placeholder="请选择是否考核" size="medium" @change="needChange">
  204. <vxe-option v-for="item in needAuditList" :key="item.value" :value="item.value" :label="item.label" />
  205. </vxe-select>
  206. </vxe-form-item>
  207. <vxe-form-item title="最大变化值" field="maxChangeValue" span="12" v-show="needShow">
  208. <vxe-input
  209. v-model="formData.maxChangeValue"
  210. placeholder="请输入变化值"
  211. type="number"
  212. clearable
  213. :disabled="needdisable"
  214. />
  215. </vxe-form-item>
  216. <vxe-form-item title="最大值" field="maxValue" span="12" v-show="needShow">
  217. <vxe-input
  218. v-model="formData.maxValue"
  219. placeholder="请输入最大值"
  220. type="number"
  221. clearable
  222. :disabled="needdisable"
  223. />
  224. </vxe-form-item>
  225. <vxe-form-item title="最小值" field="minValue" span="12" v-show="needShow">
  226. <vxe-input
  227. v-model="formData.minValue"
  228. placeholder="请输入最小值"
  229. type="number"
  230. clearable
  231. :disabled="needdisable"
  232. />
  233. </vxe-form-item>
  234. <vxe-form-item title="最长持续时间" field="maxDuration" span="12" title-width="120px" v-show="needShow">
  235. <vxe-input
  236. v-model="formData.maxDuration"
  237. placeholder="请输入最长持续时间"
  238. type="number"
  239. clearable
  240. :disabled="needdisable"
  241. />
  242. </vxe-form-item>
  243. <vxe-form-item align="center" span="24">
  244. <vxe-button status="primary" :disabled="buttonShow" type="submit">保存</vxe-button>
  245. <vxe-button v-show="resetShow" @click="resetForm">重置</vxe-button>
  246. <vxe-button @click="$refs.xModal.close()">取消</vxe-button>
  247. </vxe-form-item>
  248. </vxe-form>
  249. </vxe-modal>
  250. <MultiAdd :show="multiAdd" @close="changeMultiAdd" />
  251. </div>
  252. </template>
  253. <script>
  254. import enumerations from '../../enumeration'
  255. import MultiAdd from './multiAdd'
  256. export default {
  257. components: {
  258. MultiAdd
  259. },
  260. data() {
  261. const checkMaxDuration = ({ cellValue, rule, row, column }) => {
  262. var reg = /^[1-9]\d*$/
  263. if (!reg.test(this.formData.maxDuration)) {
  264. // 如果校验失败,则返回
  265. return Promise.reject(new Error('请填写正整数'))
  266. }
  267. }
  268. // 验证展示顺序 同设备上不允许有相同的顺序
  269. const checkDisplayOrder = async({ cellValue, rule, row, column }) => {
  270. if (this.formData.showOnHomePage == 0) {
  271. }
  272. if (this.formData.equipmentId === '' || this.formData.equipmentId === null) {
  273. return Promise.reject(new Error('请先选择设备!'))
  274. }
  275. if (this.formData.equipmentId === this.stationCode) {
  276. this.formData.equipmentId = 0
  277. }
  278. const param = {
  279. params: {
  280. equipmentId: this.formData.equipmentId,
  281. equipmentType: this.formData.eqType,
  282. showOnHomePage: this.formData.showOnHomePage
  283. }
  284. }
  285. const data = await this.getDataPoint(param)
  286. if (data != null && data.length >= 1) {
  287. if (data[0].equipmentAttribute.id !== this.formData.equipmentAttribute.id) { return Promise.reject(new Error('同一设备的点位顺序不能相同')) }
  288. }
  289. }
  290. const generationRegulationValidate = async({ cellValue, rule, row, column }) => {
  291. const formData = this.formData
  292. if(formData.generationRegulation === '系统自动计算'){
  293. formData.generationRegulation = '1'
  294. }
  295. if (cellValue !== null) {
  296. const flag = await this.$axios.get('/dataExchange/protocolDataPoint/checkFormula', { params: { formula: formData.generationRegulation }}).then(re => {
  297. return re.code == 0
  298. }).catch(e => {
  299. return false
  300. }
  301. )
  302. if (!flag) {
  303. return Promise.reject(new Error('非法计算公式!'))
  304. } else {
  305. return Promise.resolve()
  306. }
  307. }
  308. }
  309. return {
  310. loading: false,
  311. buttonShow: false,
  312. resetShow: true,
  313. // 后台传输数据
  314. tableData: [],
  315. elTableData: [],
  316. elId: '',
  317. stationCode: '',
  318. eqTableData: [],
  319. eqId: '',
  320. eqData: [],
  321. tempId: '',
  322. eqaTableData: [],
  323. tunnelId: '',
  324. tunnelTable: [],
  325. // 批量添加的模态框是否展示
  326. multiAdd: false,
  327. // 编辑&添加 模态框是否显示
  328. showEdit: false,
  329. selectRow: null,
  330. // 用于区分是保存处理还是编辑处理
  331. saveFlag: 1,
  332. // 编辑弹出框内修改的点表id
  333. modelId: '',
  334. // 分页
  335. currentPage: 1,
  336. pageSize: 10,
  337. totalResult: 0,
  338. // 判断表示
  339. gatherDisable: false,
  340. generateDisable: true,
  341. generateShow: false,
  342. needdisable: true,
  343. input1: true,
  344. input2: false,
  345. needShow: false,//设备属性为实际功率不展示
  346. regTextShow: false,//公式规则提示文本显示
  347. regButShow: false,//系统自动计算按钮
  348. columnShow: false,
  349. pointNo: '',
  350. equipmentList: [],
  351. generationRegulationText: '',//公式规则提示文本
  352. generationRegulationValidate: generationRegulationValidate,
  353. formData: {
  354. equipmentId: '',
  355. equipmentAttribute: { 'id': '' },
  356. eqType: '',
  357. dataSource: 'GATHER',
  358. tunnelId: '',
  359. protocolPointNo: '',
  360. protocolPointType: 'ABCD',
  361. magnification: 1,
  362. needAudit: false,
  363. showOnHomePage: 0,
  364. maxChangeValue: '',
  365. maxValue: '',
  366. minValue: '',
  367. maxDuration: '',
  368. generationRegulation: ''
  369. },
  370. // 数据类型
  371. code: '',
  372. message: '',
  373. mtunnelId: '',
  374. gatherRules: {
  375. dataSource: [{ required: true, message: '请选择数据来源' }],
  376. equipmentId: [{ required: true, message: '请选择设备' }],
  377. equipmentAttribute: [{ required: true, message: '请选择设备类型' }],
  378. eqType: [{ required: true, message: '请选择设备属性' }],
  379. magnification: [{ required: true, message: '请输入倍率' }],
  380. tunnelId: [{ required: true, message: '请选择通道' }],
  381. protocolPointNo: [{ required: true, message: '请选择通道点位' }],
  382. showOnHomePage: [{ required: true, message: '请输入页面展示顺序', validator: checkDisplayOrder }],
  383. protocolPointType: [{ required: true, message: '请选择通道数据类型' }]
  384. },
  385. geterteRules: {
  386. dataSource: [{ required: true, message: '请选择数据来源' }],
  387. equipmentId: [{ required: true, message: '请选择设备' }],
  388. equipmentAttribute: [{ required: true, message: '请选择设备类型' }],
  389. eqType: [{ required: true, message: '请选择设备属性' }],
  390. magnification: [{ required: true, message: '请输入倍率' }],
  391. showOnHomePage: [{ required: true, message: '请输入页面展示顺序', validator: checkDisplayOrder }],
  392. generationRegulation: [{ required: true, message: '请填写属性规则', validator: generationRegulationValidate }]
  393. },
  394. needAuditRules: {
  395. maxChangeValue: [{ required: true, message: '请输入变化最大值' }],
  396. maxValue: [{ required: true, message: '请输入最大值' }],
  397. minValue: [{ required: true, message: '请输入最小值' }],
  398. maxDuration: [{ required: true, message: '请输入时长允许变化的值', validator: checkMaxDuration }]
  399. },
  400. formRules: {},
  401. enums: enumerations,
  402. needAuditList: [{ label: '是', value: true }, { label: '否', value: false }],
  403. tunnelList: [],
  404. protocolDataType: enumerations.ProtocolDataType,
  405. timer: '',
  406. realTimeData: {}
  407. /* ProtocolDataType: [{ label: '遥信开关量', value: 0 },
  408. { label: '+AB', value: 1 },
  409. { label: '±AB', value: 2 },
  410. { label: '+BA', value: 3 },
  411. { label: '±BA', value: 4 },
  412. { label: '+AABB', value: 5 },
  413. { label: '±AABB', value: 6 },
  414. { label: '+BBAA', value: 7 },
  415. { label: '±BBAA', value: 8 },
  416. { label: 'ABCD', value: 9 },
  417. { label: 'CDAB', value: 10 },
  418. { label: 'DCBA', value: 11 },
  419. { label: 'BADC', value: 13 }
  420. ]*/
  421. }
  422. },
  423. created() {
  424. this.getAll()
  425. /* this.$nextTick(function() {
  426. this.getDataPoint()
  427. })*/
  428. this.formRules = Object.assign(this.formRules, this.gatherRules)
  429. // this.formRules = Object.assign(this.formRules, this.needAuditRules)
  430. },
  431. destroyed(){
  432. clearInterval(this.timer)
  433. },
  434. methods: {
  435. columnButClick () {
  436. const fields = ["maxChangeValue","maxValue","minValue","maxDuration"]
  437. this.columnShow = !this.columnShow
  438. const xTable = this.$refs.xTable
  439. fields.forEach(field => {
  440. const column = xTable.getColumnByField(field)
  441. column.visible = this.columnShow
  442. })
  443. xTable.refreshColumn()
  444. },
  445. refushAll() {
  446. this.$axios.get('/refreshContainer/allDataPoint').then(res => {
  447. // console.log(res)
  448. this.$message.success('刷新成功')
  449. })
  450. },
  451. refushEq() {
  452. this.$axios.get('/refreshContainer/allPackerDataPoint').then(res => {
  453. // console.log(res)
  454. this.$message.success('刷新设备成功')
  455. })
  456. },
  457. refushTunnel() {
  458. this.$axios.get('/refreshContainer/allGatherTunnelDataPoint').then(res => {
  459. // console.log(res)
  460. this.$message.success('刷新通道成功')
  461. })
  462. },
  463. getAll() {
  464. // this.flushRealTimeData()
  465. Promise.all([this.getEq(), this.getTunnel(), this.getEl()]).then((res) => {
  466. this.eqTableData = res[0]
  467. this.tunnelList = res[1]
  468. this.stationCode = res[2].stationCode
  469. this.elTableData.push(res[2])
  470. this.flushRealTimeData()
  471. this.$nextTick(function () {
  472. this.getAllDataPoint()
  473. })
  474. let _this=this
  475. this.timer = setInterval(function () {
  476. _this.flushRealTimeData()
  477. }, 5000)
  478. })
  479. },
  480. // 场站
  481. getEl() {
  482. const axios = this.$axios
  483. return new Promise(function(resolve, reject) {
  484. axios.get('/electricField/').then(res => {
  485. resolve(res.data)
  486. })
  487. })
  488. },
  489. // 场站设备
  490. getEq() {
  491. const axios = this.$axios
  492. return new Promise(function(resolve, reject) {
  493. axios.get('/dataExchange/equipmentInfo/').then(res => {
  494. resolve(res.data)
  495. })
  496. })
  497. },
  498. // 场站设备
  499. getAllDataPoint() {
  500. this.loading = true
  501. this.$axios.get('/dataExchange/protocolDataPoint/gatherDataPoint/').then(res => {
  502. this.tableData = res.data
  503. console.log(this.tableData)
  504. this.totalResult = this.tableData.length
  505. this.currentPage = 1
  506. // console.log(this.tableData)
  507. this.loading = false
  508. })
  509. },
  510. //实时数据
  511. flushRealTimeData(){
  512. this.$axios.get('/protocolDataContainer/').then(res => {
  513. this.realTimeData = res.data
  514. // console.log(res.data)
  515. })
  516. },
  517. getDataPoint(param) {
  518. // eslint-disable-next-line prefer-const
  519. return this.$axios.get('/dataExchange/protocolDataPoint/gatherDataPoint/', param)
  520. },
  521. // 获取通道
  522. getTunnel() {
  523. const axios = this.$axios
  524. return new Promise(function(resolve, reject) {
  525. axios.get('/TunnelInfo/getTunnel/Master').then(res => {
  526. resolve(res.data)
  527. })
  528. })
  529. },
  530. // 设备属性
  531. getEquipmentA() {
  532. this.$axios.get('/dataExchange/getByEquipmentType/' + this.code).then(res => {
  533. this.eqaTableData = res.data
  534. })
  535. },
  536. // 修改是否展示批量添加的模态框显隐的控制值
  537. changeMultiAdd() {
  538. this.multiAdd = false
  539. },
  540. // 查询点表
  541. searchPointData() {
  542. if ((this.tunnelId === '' || this.tunnelId === null) && (this.eqId === '' || this.eqId === null)) {
  543. this.getAllDataPoint()
  544. } else {
  545. this.loading = true
  546. var tunnelId = ''
  547. var equipmentId = ''
  548. var equipmentType = ''
  549. if (this.tunnelId === '' || this.tunnelId === undefined || this.tunnelId === null) {
  550. tunnelId = 'ALL'
  551. } else tunnelId = this.tunnelId
  552. if (this.eqTableData[this.eqId] === [] || this.eqTableData[this.eqId] === undefined) {
  553. equipmentId = 'ALL'
  554. equipmentType = 0
  555. } else {
  556. equipmentId = this.eqTableData[this.eqId].id
  557. if (equipmentId === this.elTableData[0].stationCode) {
  558. equipmentId = 0
  559. equipmentType = this.eqTableData[this.eqId].code
  560. } else {
  561. equipmentType = this.eqTableData[this.eqId].equipmentType.code
  562. }
  563. }
  564. this.$axios.get('/dataExchange/protocolDataPoint/getBytunnelAndEquipment/' + tunnelId + '/' + equipmentId + '/' + equipmentType).then(res => {
  565. this.tableData = res.data
  566. this.totalResult = this.tableData.length
  567. this.currentPage = 1
  568. this.loading = false
  569. })
  570. }
  571. },
  572. // 设备名改变设备属性下拉框改变
  573. changeEqA() {
  574. if (this.formateEqType(this.formData.eqType)) {
  575. this.code = this.tempId
  576. if (this.tempId === 0 || this.tempId === 21) {
  577. this.$axios.get('/electricField/').then(res => {
  578. // console.log(res.data)
  579. this.eqData = []
  580. // eslint-disable-next-line eqeqeq
  581. if (res.code == 0) {
  582. this.eqData.push({ id: res.data.stationCode, name: res.data.name })
  583. this.formData.equipmentId = res.data.stationCode
  584. }
  585. })
  586. } else {
  587. this.$axios.get('/dataExchange/equipmentInfo/' + this.tempId).then(res => {
  588. this.eqData = res.data
  589. })
  590. }
  591. this.getEquipmentA()
  592. }
  593. },
  594. getByTunnel() {
  595. this.$axios.get('/dataExchange/protocolDataPoint/getByTunnelId/' + this.formData.tunnelId).then(res => {
  596. this.tunnelTable = res.data
  597. // console.log(this.tunnelTable)
  598. this.tunnelChange()
  599. })
  600. },
  601. // 保存
  602. submitEvent(formName) {
  603. this.formData.stationCode = this.elTableData[0].stationCode
  604. this.formatecode(this.formData.protocolPointType)
  605. if (this.formData.eqType === 'POWERSTATION') {
  606. this.formData.equipmentId = 0
  607. }
  608. if (this.formData.eqType === 'POWERSTATION2') {
  609. this.formData.equipmentId = 21
  610. }
  611. this.$delete(this.formData, 'eqType')
  612. if(this.formData.dataSource ==='GENERATE' && this.formData.generationRegulation === '系统自动计算'){
  613. this.formData.generationRegulation = '1'
  614. }
  615. if (this.saveFlag === 1) {
  616. this.$axios.post('/dataExchange/protocolDataPoint/saveDataPoint/', this.formData).then(res => {
  617. this.searchPointData()
  618. }).catch((res) => {
  619. this.$message.error(`${res}`)
  620. })
  621. } else {
  622. this.formData.equipmentAttribute = {
  623. 'id': this.formData.equipmentAttribute.id
  624. }
  625. this.formData.id = this.modelId
  626. // console.log(this.formData)
  627. if (this.formData.dataSource === 'GENERATE') {
  628. this.formData.protocolPointType = 'ABCD'
  629. }
  630. this.$axios.put('/dataExchange/protocolDataPoint/updateDataPoint/', this.formData).then(res => {
  631. this.searchPointData()
  632. }).catch((res) => {
  633. this.$message.error(`${res}`)
  634. })
  635. }
  636. this.resetForm()
  637. this.formRules = {}
  638. this.$refs.xModal.close()
  639. },
  640. // 删除点表
  641. removeEvent(row) {
  642. this.$XModal.confirm('您确定要删除该采集点表及与其相关的转发点表?').then(type => {
  643. if (type === 'confirm') {
  644. this.$axios.delete('/dataExchange/protocolDataPoint/deleteById/' + row.id).then(res => {
  645. if (res.data === 1) {
  646. this.$message.success('删除点表成功')
  647. } else {
  648. this.$message.error('删除点表失败')
  649. }
  650. this.getAllDataPoint()
  651. })
  652. }
  653. })
  654. },
  655. // 编辑
  656. editRowEvent(row) {
  657. // console.log(row)
  658. this.needShow = true
  659. this.saveFlag = 2
  660. this.resetShow = false
  661. this.modelId = row.id
  662. if((row.equipmentAttribute.id === 100 && row.equipmentAttribute.equipmentType.code === 0) || (row.equipmentAttribute.id === 7003 && row.equipmentAttribute.equipmentType.code === 0)){
  663. this.needShow = false
  664. }
  665. this.formData = {
  666. equipmentId: row.equipmentId,
  667. equipmentAttribute: row.equipmentAttribute,
  668. protocolPointType: row.protocolPointType,
  669. tunnelId: row.tunnelId,
  670. dataSource: row.dataSource,
  671. protocolPointNo: row.protocolPointNo,
  672. magnification: row.magnification,
  673. needAudit: row.needAudit,
  674. showOnHomePage: row.showOnHomePage,
  675. maxChangeValue: row.maxChangeValue,
  676. maxValue: row.maxValue,
  677. minValue: row.minValue,
  678. maxDuration: row.maxDuration,
  679. generationRegulation: row.generationRegulation
  680. }
  681. if (this.formData.equipmentId === 0) {
  682. this.formData.equipmentId = this.elTableData[0].stationCode
  683. }
  684. this.mtunnelId = this.formData.tunnelId
  685. this.$nextTick(function() {
  686. if (row.dataSource === 'GATHER') {
  687. this.getByTunnel()
  688. }
  689. })
  690. if (this.formateEq(row.equipmentAttribute.equipmentType.code)) {
  691. // console.log(this.formData.eqType)
  692. this.pointNo = this.formData.protocolPointNo
  693. // 获取设备类型
  694. this.changeEqA()
  695. this.needChange()
  696. this.datasChange()
  697. this.selectRow = row
  698. this.showEdit = true
  699. }
  700. if(row.dataSource === 'GENERATE' && row.generationRegulation === '1'){
  701. this.formData.generationRegulation = '系统自动计算'
  702. this.generateDisable = true
  703. this.generateShow = true
  704. }else{
  705. this.formData.generationRegulation = row.generationRegulation
  706. }
  707. },
  708. // 添加
  709. insertEvent(row) {
  710. this.needShow = false
  711. this.saveFlag = 1
  712. this.resetForm()
  713. this.selectRow = null
  714. this.eqData = []
  715. if (this.eqId === '' || this.eqId === null) {
  716. this.formData.equipmentId = ''
  717. } else if (this.eqTableData[this.eqId].id === this.elTableData[0].stationCode) {
  718. this.formData.eqType = 'POWERSTATION'
  719. this.changeEqA()
  720. } else {
  721. var row1 = this.eqTableData[this.eqId]
  722. var cellValue = row1.equipmentType.message
  723. const item = this.enums.equipmentTypeEnum.find(item => item.label === cellValue)
  724. this.formData.eqType = item ? item.value : ''
  725. this.changeEqA()
  726. this.formData.equipmentId = row1.id
  727. }
  728. if (this.tunnelId !== '' && this.tunnelId !== undefined) {
  729. this.formData.tunnelId = this.tunnelId
  730. }
  731. this.protocolDataType = this.enums.ProtocolDataType
  732. this.showEdit = true
  733. this.resetShow = true
  734. },
  735. batchDeletePoint() {
  736. var selectRecords = this.$refs.xTable.getCheckboxRecords()
  737. if (selectRecords.length == 0) {
  738. this.$message.error('请选择要删除数据')
  739. } else {
  740. this.$XModal.confirm('您确定要批量删除采集点表及与其相关的转发点表?').then(type => {
  741. if (type === 'confirm') {
  742. var ids = []
  743. for (var i = 0; i < selectRecords.length; i++) {
  744. ids.push(selectRecords[i].id)
  745. }
  746. this.$axios.delete('/dataExchange/protocolDataPoint/batchDeleteGatherDataPoint/' + ids).then(res => {
  747. if (res.data === 1) {
  748. this.$message.success('删除批量点表成功')
  749. } else {
  750. this.$message.error('删除批量点表失败')
  751. }
  752. this.getAllDataPoint()
  753. })
  754. }
  755. })
  756. }
  757. },
  758. // 判断点表生成规则
  759. datasChange() {
  760. if (this.formData.dataSource === 'GATHER') {
  761. this.generateDisable = true
  762. this.generateShow = false
  763. this.gatherDisable = false
  764. this.regButShow = false
  765. this.regTextShow = false
  766. } else {
  767. this.generateShow = true
  768. this.gatherDisable = true
  769. this.generateDisable = false
  770. this.regBut()
  771. }
  772. this.checkValidate()
  773. },
  774. //公式生成按钮显示规则
  775. /*发电站
  776. * 97 => 系统限电, 101=>可用, 102=>理论, 108=>样板机理论, 112=>样板机可用, 113=>测风/光可用, 109=>测风/光理论
  777. * 测风塔
  778. * 4236=>可用
  779. * */
  780. regBut(){
  781. this.generateShow = true
  782. this.generateDisable = false
  783. this.formData.generationRegulation = ''
  784. var eqAttId = this.formData.equipmentAttribute.id
  785. if(eqAttId === 97 || eqAttId === 101 || eqAttId === 102 || eqAttId === 108 || eqAttId === 112 || eqAttId === 113){
  786. this.regButShow = true
  787. this.regTextShow = false
  788. }else if(eqAttId === 109 || eqAttId === 4236){
  789. this.formData.generationRegulation = ''
  790. this.generationRegulationText = ''
  791. this.regButShow = false
  792. this.regTextShow = true
  793. if(eqAttId === 109){
  794. this.generationRegulationText = '光伏组件效率*(1-0.003*(光伏组件温度-25))*math.pow(0.992,3)*总辐射*光伏组件总面积/1000000*0.79'
  795. }else{
  796. this.generationRegulationText = '1.293*(273/(273+温度摄氏度))*气压百帕/1013'
  797. }
  798. }else{
  799. this.regButShow = false
  800. this.regTextShow = false
  801. }
  802. },
  803. //公式按钮点击事件
  804. regButClick(){
  805. this.generateDisable = !this.generateDisable
  806. if(this.generateDisable){
  807. this.formData.generationRegulation = '系统自动计算'
  808. }else{
  809. this.formData.generationRegulation = ''
  810. }
  811. },
  812. attribute() {
  813. if(this.formData.dataSource === 'GENERATE'){
  814. this.regBut()
  815. }
  816. if (this.saveFlag === 1) {
  817. // console.log(this.formData.equipmentId)
  818. if (this.formData.equipmentId === '' || this.formData.equipmentId === null) {
  819. this.$message.error('请选择设备')
  820. } else {
  821. this.needShow = false
  822. var equipmentId = ''
  823. equipmentId = this.formData.equipmentId
  824. if (this.formData.eqType === 'POWERSTATION') {
  825. equipmentId = 0
  826. //设备属性为实际功率不展示考核的四项
  827. if(this.formData.equipmentAttribute.id === 100){
  828. this.needShow = false
  829. }
  830. }
  831. if (this.formData.eqType === 'POWERSTATION2') {
  832. equipmentId = 21
  833. //设备属性为实际功率不展示考核的四项
  834. if(this.formData.equipmentAttribute.id === 7003){
  835. this.needShow = false
  836. }
  837. }
  838. this.$axios.get('/dataExchange/protocolDataPoint/getProtocolGatherDataPoint/' + equipmentId + '/' + this.formData.equipmentAttribute.id).then((res) => {
  839. if (res.data.length === 0) {
  840. this.buttonShow = false
  841. } else {
  842. this.buttonShow = true
  843. // console.log(res.data)
  844. this.$message.error(`此设备的${res.data[0].equipmentAttribute.explanation}属性已经有采集点位`)
  845. }
  846. }).catch((res) => {
  847. this.$message.error(`${res}`)
  848. })
  849. }
  850. }
  851. },
  852. tunnelChange() {
  853. this.protocolDataType = []
  854. if (this.mtunnelId !== this.formData.tunnelId) {
  855. this.formData.protocolPointType = ''
  856. }
  857. for (let i = 0; i < this.tunnelList.length; i++) {
  858. if (this.formData.tunnelId === this.tunnelList[i].id) {
  859. if (this.tunnelList[i].tunnelType.substring(0, 3) === 'IEC' || this.tunnelList[i].tunnelType.substring(0, 3) === 'FIL') {
  860. this.protocolDataType = [{ label: '遥信开关量', value: 'A', key: 0 }, { label: 'ABCD', value: 'ABCD', key: 9 }]
  861. } else if (this.tunnelList[i].tunnelType.substring(0, 3) === 'CDT') {
  862. this.protocolDataType = [{ label: '遥信开关量', value: 'A', key: 0 }, { label: '+AB', value: 'P_AB', key: 1 }]
  863. } else {
  864. this.protocolDataType = this.enums.ProtocolDataType
  865. }
  866. }
  867. }
  868. },
  869. needChange() {
  870. this.formRules = {}
  871. this.checkValidate()
  872. if (this.formData.needAudit === false) {
  873. this.needdisable = true
  874. this.needShow = false
  875. } else {
  876. this.needdisable = false
  877. this.needShow = true
  878. }
  879. },
  880. checkValidate() {
  881. this.formRules = {}
  882. if (this.formData.dataSource === 'GATHER') {
  883. if (this.formData.needAudit) {
  884. this.formRules = Object.assign(this.formRules, this.gatherRules)
  885. this.formRules = Object.assign(this.formRules, this.needAuditRules)
  886. } else {
  887. this.formRules = this.gatherRules
  888. }
  889. } else {
  890. if (this.formData.needAudit) {
  891. this.formRules = Object.assign(this.formRules, this.geterteRules)
  892. this.formRules = Object.assign(this.formRules, this.needAuditRules)
  893. } else {
  894. this.formRules = this.geterteRules
  895. }
  896. }
  897. },
  898. // 重置
  899. resetForm() {
  900. // alert()
  901. this.formRules = {}
  902. this.formData = {
  903. equipmentId: '',
  904. equipmentAttribute: { 'id': '' },
  905. eqType: '',
  906. dataSource: 'GATHER',
  907. tunnelId: '',
  908. protocolPointNo: '',
  909. protocolPointType: 'ABCD',
  910. magnification: 1,
  911. needAudit: false,
  912. showOnHomePage: 0,
  913. maxChangeValue: '',
  914. maxValue: '',
  915. minValue: '',
  916. maxDuration: '',
  917. generationRegulation: ''
  918. }
  919. this.formRules = Object.assign(this.formRules, this.gatherRules)
  920. this.protocolDataType = this.enums.ProtocolDataType
  921. // this.formRules = Object.assign(this.formRules, this.needAuditRules)
  922. this.gatherDisable = false
  923. this.generateDisable = true
  924. this.generateShow = false
  925. this.columnShow = false
  926. this.needdisable = true
  927. this.buttonShow = false
  928. },
  929. // 转换类型
  930. formateEq(code) {
  931. let returnValue = ''
  932. if (code === 0) returnValue = 'POWERSTATION'
  933. if (code === 21) returnValue = 'POWERSTATION2'
  934. if (code === 1) returnValue = 'WEATHERSTATION'
  935. if (code === 2) returnValue = 'INVERTER'
  936. if (code === 3) returnValue = 'WINDTOWER'
  937. if (code === 4) returnValue = 'WINDTURBINE'
  938. if (code === 6) returnValue = 'BOOSTERSTATION'
  939. if (code === 7) returnValue = 'AGC_AVC'
  940. if (code === 8) returnValue = 'BWD'
  941. if (code === 9) returnValue = 'CYB'
  942. if (code === 10) returnValue = 'JDX'
  943. if (code === 11) returnValue = 'SYZMX'
  944. if (code === 12) returnValue = 'WGBC'
  945. if (code === 13) returnValue = 'DLQ'
  946. if (code === 14) returnValue = 'DZ'
  947. if (code === 15) returnValue = 'JDDZ'
  948. if (code === 16) returnValue = 'DXFDJ'
  949. if (code === 17) returnValue = 'QBB'
  950. if (code === 18) returnValue = 'LLB'
  951. if (code === 19) returnValue = 'FZ'
  952. if (code === 20) returnValue = 'XB'
  953. this.formData.eqType = returnValue
  954. return true
  955. },
  956. // 转换类型
  957. formateEqType(eqType) {
  958. this.tempId = ''
  959. let returnValue = ''
  960. if (eqType === 'POWERSTATION') returnValue = 0
  961. if (eqType === 'POWERSTATION2') returnValue = 21
  962. if (eqType === 'WEATHERSTATION') returnValue = 1
  963. if (eqType === 'INVERTER') returnValue = 2
  964. if (eqType === 'WINDTOWER') returnValue = 3
  965. if (eqType === 'WINDTURBINE') returnValue = 4
  966. if (eqType === 'BOOSTERSTATION') returnValue = 6
  967. if (eqType === 'AGC_AVC') returnValue = 7
  968. if (eqType === 'BWD') returnValue = 8
  969. if (eqType === 'CYB') returnValue = 9
  970. if (eqType === 'JDX') returnValue = 10
  971. if (eqType === 'SYZMX') returnValue = 11
  972. if (eqType === 'WGBC') returnValue = 12
  973. if (eqType === 'DLQ') returnValue = 13
  974. if (eqType === 'DZ') returnValue = 14
  975. if (eqType === 'JDDZ') returnValue = 15
  976. if (eqType === 'DXFDJ') returnValue = 16
  977. if (eqType === 'QBB') returnValue = 17
  978. if (eqType === 'LLB') returnValue = 18
  979. if (eqType === 'FZ') returnValue = 19
  980. if (eqType === 'XB') returnValue = 20
  981. this.tempId = returnValue
  982. return true
  983. },
  984. formatecode(protocolPointType) {
  985. let returnValue = ''
  986. if (protocolPointType === 'A') returnValue = 0
  987. if (protocolPointType === 'P_AB') returnValue = 1
  988. if (protocolPointType === 'PM_AB') returnValue = 2
  989. if (protocolPointType === 'P_BA') returnValue = 3
  990. if (protocolPointType === 'PM_BA') returnValue = 4
  991. if (protocolPointType === 'P_AABB') returnValue = 5
  992. if (protocolPointType === 'PM_AABB') returnValue = 6
  993. if (protocolPointType === 'P_BBAA') returnValue = 7
  994. if (protocolPointType === 'PM_BBAA') returnValue = 8
  995. if (protocolPointType === 'ABCD') returnValue = 9
  996. if (protocolPointType === 'CDAB') returnValue = 10
  997. if (protocolPointType === 'DCBA') returnValue = 11
  998. if (protocolPointType === 'BADC') returnValue = 13
  999. if (protocolPointType === '' || protocolPointType === null) returnValue = 'null'
  1000. this.formData.protocolPointType = returnValue
  1001. },
  1002. // 转换是否考核
  1003. formatterNeedAudit({ cellValue }) {
  1004. const item = this.needAuditList.find(item => item.value === cellValue)
  1005. return item ? item.label : ''
  1006. },
  1007. // 转换通道类型
  1008. formatterPointType({ cellValue }) {
  1009. const item = this.enums.ProtocolDataType.find(item => item.value === cellValue)
  1010. return item ? item.label : ''
  1011. },
  1012. // 展示首页的顺序
  1013. showOnHomePageFormatter({ cellValue }) {
  1014. return cellValue == 0 ? '不展示' : cellValue
  1015. },
  1016. generationRegulationFormatter({ cellValue }){
  1017. return cellValue === '1' ? '系统自动计算' : cellValue
  1018. },
  1019. formatterDataSource({ cellValue }) {
  1020. const item = this.enums.geterDataSourceEnum.find(item => item.value === cellValue)
  1021. return item ? item.label : ''
  1022. },
  1023. // 通道id转名称
  1024. formateId(row, column) {
  1025. // console.log(row)
  1026. let belongTo = '未知通道名称'
  1027. if (row.row.tunnelId === '') {
  1028. belongTo = ''
  1029. } else {
  1030. for (let i = 0; i < this.tunnelList.length; i++) {
  1031. if (row.row.tunnelId === this.tunnelList[i].id) {
  1032. belongTo = this.tunnelList[i].tunnelName
  1033. }
  1034. }
  1035. }
  1036. return belongTo
  1037. },
  1038. // 设备id转名称
  1039. formateEqId(row, column) {
  1040. let belongTo = '未知设备名称'
  1041. if (row.row.equipmentAttribute.equipmentType.code === 0 || row.row.equipmentAttribute.equipmentType.code === 21) {
  1042. belongTo = this.elTableData[0].name
  1043. } else {
  1044. for (let i = 0; i < this.eqTableData.length; i++) {
  1045. if (row.row.equipmentId === this.eqTableData[i].id && row.row.equipmentAttribute.equipmentType.code === this.eqTableData[i].equipmentType.code) {
  1046. belongTo = this.eqTableData[i].name
  1047. }
  1048. }
  1049. }
  1050. return belongTo
  1051. },
  1052. checkprotocolPointNo() {
  1053. this.buttonShow = false
  1054. if (this.formData.tunnelId === '' || this.formData.tunnelId === null) {
  1055. this.$message.error('请先选择通道')
  1056. this.formData.protocolPointNo = ''
  1057. this.buttonShow = true
  1058. } else {
  1059. if (this.formData.protocolPointNo < 0) {
  1060. this.formData.protocolPointNo = 0
  1061. this.$message.error('通道点位不能小于0')
  1062. }
  1063. var v6 = this.tunnelTable
  1064. var num = this.formData.protocolPointNo
  1065. for (let i = 0; i < v6.length; i++) {
  1066. if (this.modelId === '') {
  1067. // 新增
  1068. if (parseInt(num) === v6[i].protocolPointNo) {
  1069. this.$message.error('通道点位不能重复')
  1070. this.buttonShow = true
  1071. }
  1072. } else {
  1073. // 修改
  1074. if (parseInt(this.pointNo) !== parseInt(num)) {
  1075. if (parseInt(num) === v6[i].protocolPointNo) {
  1076. this.$message.error('通道号不能重复')
  1077. this.buttonShow = true
  1078. }
  1079. }
  1080. }
  1081. }
  1082. }
  1083. },
  1084. headerCellClassName ({ column, columnIndex }) {
  1085. if (column.title === '实时数据') {
  1086. return {
  1087. background: 'rgba(247,172,188,0.3)'
  1088. }
  1089. }
  1090. },
  1091. }
  1092. }
  1093. </script>
  1094. <style scoped>
  1095. .vxe-modal--box .vxe-modal--box{
  1096. top:10vh !important;
  1097. }
  1098. /deep/.regulate.vxe-input .vxe-input--extra-suffix, /deep/.regulate.vxe-input .vxe-input--suffix{
  1099. width: 117px;
  1100. }
  1101. </style>