nyjkbz.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. <template>
  2. <!-- 能源实时监控标准维护 -->
  3. <div class="nyjkbz">
  4. <div class="box">
  5. <div class="box-top">
  6. <el-form
  7. style="overflow: hidden;"
  8. :style="filterForm.show ? null : { height: '0px' }"
  9. size="mini"
  10. >
  11. <el-row>
  12. <el-col :span="6">
  13. <el-form-item label="监测因子" label-width="70px">
  14. <el-input
  15. clearable
  16. v-model.trim="filterForm.data.comments"
  17. placeholder="监测因子"
  18. style="width: 100%;"
  19. @keyup.enter.native="getTableData()"
  20. ></el-input>
  21. </el-form-item>
  22. </el-col>
  23. </el-row>
  24. </el-form>
  25. <div class="box-top-gjl">
  26. <el-button
  27. class="button"
  28. type="primary"
  29. size="mini"
  30. icon="el-icon-edit-outline"
  31. v-privilege="activeMenu + 'PUT'"
  32. @click="but_edit_plural()"
  33. :loading="loading"
  34. >修改</el-button>
  35. <div style="float:right; text-align: right;">
  36. <el-button
  37. class="button"
  38. type="primary"
  39. size="mini"
  40. icon="el-icon-search"
  41. v-privilege="activeMenu + 'QUERY'"
  42. @click="getTableData()"
  43. >查询</el-button>
  44. <el-button
  45. class="button"
  46. type="primary"
  47. size="mini"
  48. icon="el-icon-refresh"
  49. v-privilege="activeMenu + 'QUERY'"
  50. @click="tableDataCancel();"
  51. >重置</el-button>
  52. <el-button
  53. size="mini"
  54. :icon="filterForm.show ? 'el-icon-caret-top' : 'el-icon-caret-bottom'"
  55. :title="filterForm.show ? '收起搜索区' : '展开搜索区'"
  56. @click="filterForm.show = !filterForm.show;
  57. $nextTick(() => {
  58. singleTableHeight = getRoleHeight($refs['singleTable'].$el) - 45;
  59. }
  60. );"
  61. >{{ filterForm.show ? '收起' : '展开' }}</el-button>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="box-bottom">
  66. <el-form
  67. size="mini"
  68. ref="dialog_form_arr"
  69. label-width="0px"
  70. :model="tableFormDataObj"
  71. >
  72. <el-table
  73. stripe
  74. id="singleTable"
  75. ref="singleTable"
  76. :data="tableData"
  77. v-loading="tableLoading"
  78. style="width: 100%;"
  79. :height="singleTableHeight"
  80. border
  81. size="mini"
  82. highlight-current-row
  83. @selection-change="handleSelectionChange"
  84. :span-method="arraySpanMethod"
  85. :cell-style="setColor"
  86. >
  87. <el-table-column
  88. type="selection"
  89. width="40"
  90. align="center"
  91. fixed="left"
  92. ></el-table-column>
  93. <el-table-column
  94. prop="TABLE_NAME"
  95. label="能源"
  96. width="120px"
  97. align="center"
  98. :show-overflow-tooltip="true">
  99. <template slot-scope="scope">
  100. <span>{{ nameObj.nyObj[scope.row.TABLE_NAME] }}</span>
  101. </template>
  102. </el-table-column>
  103. <el-table-column
  104. prop="COMMENTS"
  105. label="监测因子"
  106. width="400px"
  107. :show-overflow-tooltip="true"
  108. ></el-table-column>
  109. <el-table-column
  110. prop="FLAG"
  111. label="启用报警"
  112. width="110px"
  113. :show-overflow-tooltip="true"
  114. >
  115. <template slot-scope="scope">
  116. <el-form-item
  117. v-if="scope.row.isSelection"
  118. :prop="scope.row.col + '.FLAG'"
  119. :rules="dialog.editorBox.form.rules.FLAG"
  120. >
  121. <el-select
  122. filterable
  123. clearable
  124. style="width: 100%;"
  125. v-model="tableFormDataObj[scope.row.col].FLAG"
  126. >
  127. <el-option
  128. v-for="item of nameObj.flag.arr"
  129. :key="item.id"
  130. :value="item.id"
  131. :label="item.name"
  132. ></el-option>
  133. </el-select>
  134. </el-form-item>
  135. <span v-else>{{ nameObj.flag.obj[scope.row.FLAG] ? nameObj.flag.obj[scope.row.FLAG] : scope.row.FLAG }}</span>
  136. </template>
  137. </el-table-column>
  138. <el-table-column
  139. prop="ST"
  140. label="报警开始时间"
  141. width="196px"
  142. :show-overflow-tooltip="true"
  143. > <template slot-scope="scope">
  144. <el-form-item
  145. v-if="scope.row.isSelection"
  146. :prop="scope.row.col + '.ST'"
  147. :rules="dialog.editorBox.form.rules.ST"
  148. >
  149. <el-date-picker
  150. v-model="tableFormDataObj[scope.row.col].ST"
  151. type="datetime"
  152. style="width: 100%;"
  153. format="yyyy-MM-dd HH:mm:ss"
  154. value-format="yyyy-MM-dd HH:mm:ss">
  155. </el-date-picker>
  156. </el-form-item>
  157. <span v-else>{{scope.row.ST}}</span>
  158. </template>
  159. </el-table-column>
  160. <el-table-column label="标准">
  161. <el-table-column prop="VALD" label="最小值" min-width="90px" :show-overflow-tooltip="true">
  162. <template slot-scope="scope">
  163. <el-form-item
  164. v-if="scope.row.isSelection"
  165. :prop="scope.row.col + '.VALD'"
  166. :rules="dialog.editorBox.form.rules.VALD"
  167. >
  168. <el-input placeholder="请填写数值"
  169. clearable
  170. style="width: 100%;"
  171. v-model.trim="tableFormDataObj[scope.row.col].VALD"
  172. ></el-input>
  173. </el-form-item>
  174. <span v-else>{{scope.row.VALD}}</span>
  175. </template>
  176. </el-table-column>
  177. <el-table-column prop="VALU" label="最大值" min-width="90px" :show-overflow-tooltip="true">
  178. <template slot-scope="scope">
  179. <el-form-item
  180. v-if="scope.row.isSelection"
  181. :prop="scope.row.col + '.VALU'"
  182. :rules="dialog.editorBox.form.rules.VALU"
  183. >
  184. <el-input placeholder="请填写数值"
  185. clearable
  186. style="width: 100%;"
  187. v-model.trim="tableFormDataObj[scope.row.col].VALU"
  188. ></el-input>
  189. </el-form-item>
  190. <span v-else>{{scope.row.VALU}}</span>
  191. </template>
  192. </el-table-column>
  193. </el-table-column>
  194. </el-table>
  195. </el-form>
  196. <!-- <el-pagination
  197. layout="total, sizes, prev, pager, next, jumper"
  198. :total="total"
  199. :page-sizes="[10, 20, 50, 100, 500, 1000]"
  200. :page-size="pageSize"
  201. :current-page.sync="pageNum"
  202. @size-change="tableSizeChange"
  203. @current-change="getTableData()"
  204. style="text-align: right;margin-top: 10px;"
  205. ></el-pagination> -->
  206. </div>
  207. </div>
  208. </div>
  209. </template>
  210. <script>
  211. import { formatDate } from '@/utils/util.js';
  212. import { zCheckNumber1 } from '~/utils/validator.js'
  213. export default {
  214. name: 'nyjkbz',
  215. data () {
  216. return {
  217. multipleSelection: [],
  218. tableFormDataObj: {},
  219. activeMenu: '',
  220. filterForm: {
  221. show: true,
  222. data: {
  223. comments: ''
  224. }
  225. },
  226. pageNum: 1,
  227. pageSize: 20,
  228. total: 0,
  229. singleTableHeight: 100,
  230. tableData: [],
  231. nameObj: {
  232. nyObj: {
  233. 'COREDAS_AR': '氩气',
  234. 'COREDAS_BFG': '高炉煤气',
  235. 'COREDAS_CLD': '转炉煤气',
  236. 'COREDAS_COG': '焦炉煤气',
  237. 'COREDAS_N2': '氮气',
  238. 'COREDAS_O2': '氧气'
  239. },
  240. flag: {
  241. obj: {
  242. '0': '否',
  243. '1': '是'
  244. },
  245. arr: [
  246. {
  247. id: '0',
  248. name: '否'
  249. },
  250. {
  251. id: '1',
  252. name: '是'
  253. }
  254. ]
  255. }
  256. },
  257. loading: false,
  258. tableLoading: false,
  259. dialog: {
  260. editorBox: {
  261. show: false,
  262. form: {
  263. rules: {
  264. FLAG: [
  265. { required: true, message: '该项不能为空', trigger: 'change' }
  266. ],
  267. VALD: [
  268. { validator: zCheckNumber1, trigger: 'change' }
  269. ],
  270. VALU: [
  271. { validator: zCheckNumber1, trigger: 'change' }
  272. ]
  273. }
  274. }
  275. },
  276. equationEditing: {
  277. show: false,
  278. form: {
  279. data: {
  280. clock: '',
  281. code: ''
  282. }
  283. }
  284. }
  285. }
  286. }
  287. },
  288. created () {
  289. this.activeMenu = window.localStorage.getItem('activeMenu');
  290. },
  291. mounted () {
  292. let that = this;
  293. window.PEDataObj = {
  294. // 将数据绑定到window上,供main页面使用
  295. vm: that,
  296. // tableArr:用于导出成Excel的表格的信息
  297. tableArr: [
  298. {
  299. name: '',
  300. id: 'singleTable'
  301. }
  302. ]
  303. };
  304. that.$nextTick(() => {
  305. // 立即获取的height有一定偏差,通过setTimeout延迟来解决
  306. setTimeout(() => {
  307. that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 45;
  308. }, 1);
  309. });
  310. that.getTableData();
  311. },
  312. methods: {
  313. // 计算树区域高度
  314. getRoleHeight (dom) {
  315. return window.innerHeight - dom.offsetTop;
  316. },
  317. // 获取表格中的数据
  318. getTableData (pageNum) {
  319. let that = this,
  320. params = {
  321. comments: that.filterForm.data.comments
  322. };
  323. that.pageNum = pageNum || that.pageNum;
  324. that.tableLoading = true;
  325. let url = 'pass/ems/v1/coredasabnormalinfos/getCoredasStd';
  326. that.axios.get(url, {
  327. params: params
  328. })
  329. .then(function (res) {
  330. if (res.code === '0') {
  331. that.tableData = res.data.data;
  332. // that.total = res.data.total;
  333. } else {
  334. that.$message.error(res.message);
  335. }
  336. that.tableLoading = false;
  337. }).catch(function () {
  338. that.tableLoading = false;
  339. });
  340. },
  341. // 改变表格显示条数
  342. tableSizeChange (val) {
  343. let that = this;
  344. that.pageSize = val;
  345. that.getTableData(1);
  346. },
  347. // 重置搜索
  348. tableDataCancel () {
  349. let that = this;
  350. for (let key in that.filterForm.data) {
  351. if (that.filterForm.data[key] instanceof Array) {
  352. that.filterForm.data[key] = [];
  353. } else {
  354. that.filterForm.data[key] = '';
  355. }
  356. }
  357. that.getTableData(1);
  358. },
  359. // 表格中多选按钮的相关方法
  360. handleSelectionChange (val) {
  361. let that = this;
  362. let tableFormDataObj = {};
  363. for (let item of that.tableData) {
  364. item.isSelection = false;
  365. }
  366. for (let item of val) {
  367. let obj = {};
  368. let xId = item.col;
  369. if (that.tableFormDataObj[xId]) {
  370. tableFormDataObj[xId] = that.tableFormDataObj[xId];
  371. } else {
  372. for (let key in item) {
  373. obj[key] = item[key];
  374. }
  375. tableFormDataObj[xId] = obj;
  376. }
  377. item.isSelection = true;
  378. }
  379. that.tableFormDataObj = tableFormDataObj;
  380. that.multipleSelection = val;
  381. },
  382. // 批量修改
  383. but_edit_plural () {
  384. let that = this;
  385. if (that.multipleSelection.length > 0) {
  386. that.$refs['dialog_form_arr'].validate((valid, obj) => {
  387. if (valid) {
  388. let SubmitData = [];
  389. for (let key in that.tableFormDataObj) {
  390. SubmitData.push({
  391. col: that.tableFormDataObj[key].col,
  392. TABLE_NAME: that.tableFormDataObj[key].TABLE_NAME,
  393. ST: that.tableFormDataObj[key].ST,
  394. FLAG: that.tableFormDataObj[key].FLAG,
  395. VALD: that.tableFormDataObj[key].VALD,
  396. VALU: that.tableFormDataObj[key].VALU
  397. });
  398. }
  399. that.loading = true;
  400. that.axios.put('pass/ems/v1/coredasabnormalinfos/', SubmitData).then(function (res) {
  401. if (res.code === '0') {
  402. that.$message({
  403. message: '修改成功',
  404. type: 'success'
  405. });
  406. that.getTableData();
  407. that.dialog.editorBox.show = false;
  408. } else {
  409. that.$message.error(res.message);
  410. }
  411. that.loading = false;
  412. }).catch(function () {
  413. that.loading = false;
  414. });
  415. } else {
  416. let col = Object.keys(obj)[0].split('.')[1];
  417. if (col && col === 'VALD') {
  418. this.$message.error('最小值请填写数字');
  419. } else if (col && col === 'VALU') {
  420. this.$message.error('最大值请填写数字');
  421. } else if (col && col === 'FLAG') {
  422. this.$message.error('是否启用报警不能为空');
  423. } else {
  424. this.$message.error('数据不完整或者格式错误');
  425. }
  426. }
  427. });
  428. } else {
  429. this.$message.error('至少要选择一条数据');
  430. }
  431. },
  432. // 表格合并单元格
  433. arraySpanMethod ({ row, column, rowIndex, columnIndex }) {
  434. let tableData = this.$refs.singleTable.tableData
  435. let rowsPan = 1;
  436. let thisColomnData = row[column['property']];
  437. // 能源列 合并
  438. if (column['property'] === 'TABLE_NAME' && thisColomnData) {
  439. if (rowIndex > 0 && thisColomnData === tableData[rowIndex - 1][column['property']]) {
  440. return {
  441. rowspan: 0,
  442. colspan: 0
  443. };
  444. }
  445. while (tableData[rowIndex + rowsPan] && thisColomnData === tableData[rowIndex + rowsPan][column['property']]) {
  446. rowsPan += 1
  447. }
  448. return {
  449. rowspan: rowsPan,
  450. colspan: 1
  451. };
  452. }
  453. },
  454. setColor ({row, column, rowIndex, columnIndex}) {
  455. if (column['property'] === 'TABLE_NAME' || columnIndex === 0) {
  456. return 'background-color:#fff'
  457. }
  458. }
  459. }
  460. }
  461. </script>
  462. <style lang="less">
  463. .nyjkbz {
  464. min-width: 700px;
  465. height: 100%;
  466. .box {
  467. height: 100%;
  468. padding: 15px 15px 0 15px;
  469. .box-top {
  470. .el-form-item {
  471. margin-bottom: 7px;
  472. }
  473. .box-top-gjl {
  474. overflow: hidden;
  475. padding: 7px 0;
  476. border-top: 1px solid #ccc;
  477. }
  478. }
  479. .el-table .el-table__row {
  480. height: 35px;
  481. }
  482. .el-table__body .el-form-item--mini.el-form-item {
  483. margin: 0px;
  484. .error {
  485. overflow: hidden;
  486. color: #f56c6c;
  487. font-size: 12px;
  488. line-height: 1;
  489. }
  490. }
  491. }
  492. .color_no {
  493. color: #7a7a7a;
  494. }
  495. .color_yes {
  496. color: #1a9f17;
  497. }
  498. }
  499. </style>