123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501 |
- <template>
- <!-- 能源实时监控标准维护 -->
- <div class="nyjkbz">
- <div class="box">
- <div class="box-top">
- <el-form
- style="overflow: hidden;"
- :style="filterForm.show ? null : { height: '0px' }"
- size="mini"
- >
- <el-row>
- <el-col :span="6">
- <el-form-item label="监测因子" label-width="70px">
- <el-input
- clearable
- v-model.trim="filterForm.data.comments"
- placeholder="监测因子"
- style="width: 100%;"
- @keyup.enter.native="getTableData()"
- ></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div class="box-top-gjl">
- <el-button
- class="button"
- type="primary"
- size="mini"
- icon="el-icon-edit-outline"
- v-privilege="activeMenu + 'PUT'"
- @click="but_edit_plural()"
- :loading="loading"
- >修改</el-button>
- <div style="float:right; text-align: right;">
- <el-button
- class="button"
- type="primary"
- size="mini"
- icon="el-icon-search"
- v-privilege="activeMenu + 'QUERY'"
- @click="getTableData()"
- >查询</el-button>
- <el-button
- class="button"
- type="primary"
- size="mini"
- icon="el-icon-refresh"
- v-privilege="activeMenu + 'QUERY'"
- @click="tableDataCancel();"
- >重置</el-button>
- <el-button
- size="mini"
- :icon="filterForm.show ? 'el-icon-caret-top' : 'el-icon-caret-bottom'"
- :title="filterForm.show ? '收起搜索区' : '展开搜索区'"
- @click="filterForm.show = !filterForm.show;
- $nextTick(() => {
- singleTableHeight = getRoleHeight($refs['singleTable'].$el) - 45;
- }
- );"
- >{{ filterForm.show ? '收起' : '展开' }}</el-button>
- </div>
- </div>
- </div>
- <div class="box-bottom">
- <el-form
- size="mini"
- ref="dialog_form_arr"
- label-width="0px"
- :model="tableFormDataObj"
- >
- <el-table
- stripe
- id="singleTable"
- ref="singleTable"
- :data="tableData"
- v-loading="tableLoading"
- style="width: 100%;"
- :height="singleTableHeight"
- border
- size="mini"
- highlight-current-row
- @selection-change="handleSelectionChange"
- :span-method="arraySpanMethod"
- :cell-style="setColor"
- >
- <el-table-column
- type="selection"
- width="40"
- align="center"
- fixed="left"
- ></el-table-column>
- <el-table-column
- prop="TABLE_NAME"
- label="能源"
- width="120px"
- align="center"
- :show-overflow-tooltip="true">
- <template slot-scope="scope">
- <span>{{ nameObj.nyObj[scope.row.TABLE_NAME] }}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="COMMENTS"
- label="监测因子"
- width="400px"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- prop="FLAG"
- label="启用报警"
- width="110px"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="scope">
- <el-form-item
- v-if="scope.row.isSelection"
- :prop="scope.row.col + '.FLAG'"
- :rules="dialog.editorBox.form.rules.FLAG"
- >
- <el-select
- filterable
- clearable
- style="width: 100%;"
- v-model="tableFormDataObj[scope.row.col].FLAG"
- >
- <el-option
- v-for="item of nameObj.flag.arr"
- :key="item.id"
- :value="item.id"
- :label="item.name"
- ></el-option>
- </el-select>
- </el-form-item>
- <span v-else>{{ nameObj.flag.obj[scope.row.FLAG] ? nameObj.flag.obj[scope.row.FLAG] : scope.row.FLAG }}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="ST"
- label="报警开始时间"
- width="196px"
- :show-overflow-tooltip="true"
- > <template slot-scope="scope">
- <el-form-item
- v-if="scope.row.isSelection"
- :prop="scope.row.col + '.ST'"
- :rules="dialog.editorBox.form.rules.ST"
- >
- <el-date-picker
- v-model="tableFormDataObj[scope.row.col].ST"
- type="datetime"
- style="width: 100%;"
- format="yyyy-MM-dd HH:mm:ss"
- value-format="yyyy-MM-dd HH:mm:ss">
- </el-date-picker>
- </el-form-item>
- <span v-else>{{scope.row.ST}}</span>
- </template>
- </el-table-column>
- <el-table-column label="标准">
- <el-table-column prop="VALD" label="最小值" min-width="90px" :show-overflow-tooltip="true">
- <template slot-scope="scope">
- <el-form-item
- v-if="scope.row.isSelection"
- :prop="scope.row.col + '.VALD'"
- :rules="dialog.editorBox.form.rules.VALD"
- >
- <el-input placeholder="请填写数值"
- clearable
- style="width: 100%;"
- v-model.trim="tableFormDataObj[scope.row.col].VALD"
- ></el-input>
- </el-form-item>
- <span v-else>{{scope.row.VALD}}</span>
- </template>
- </el-table-column>
- <el-table-column prop="VALU" label="最大值" min-width="90px" :show-overflow-tooltip="true">
- <template slot-scope="scope">
- <el-form-item
- v-if="scope.row.isSelection"
- :prop="scope.row.col + '.VALU'"
- :rules="dialog.editorBox.form.rules.VALU"
- >
- <el-input placeholder="请填写数值"
- clearable
- style="width: 100%;"
- v-model.trim="tableFormDataObj[scope.row.col].VALU"
- ></el-input>
- </el-form-item>
- <span v-else>{{scope.row.VALU}}</span>
- </template>
- </el-table-column>
- </el-table-column>
- </el-table>
- </el-form>
- <!-- <el-pagination
- layout="total, sizes, prev, pager, next, jumper"
- :total="total"
- :page-sizes="[10, 20, 50, 100, 500, 1000]"
- :page-size="pageSize"
- :current-page.sync="pageNum"
- @size-change="tableSizeChange"
- @current-change="getTableData()"
- style="text-align: right;margin-top: 10px;"
- ></el-pagination> -->
- </div>
- </div>
- </div>
- </template>
- <script>
- import { formatDate } from '@/utils/util.js';
- import { zCheckNumber1 } from '~/utils/validator.js'
- export default {
- name: 'nyjkbz',
- data () {
- return {
- multipleSelection: [],
- tableFormDataObj: {},
- activeMenu: '',
- filterForm: {
- show: true,
- data: {
- comments: ''
- }
- },
- pageNum: 1,
- pageSize: 20,
- total: 0,
- singleTableHeight: 100,
- tableData: [],
- nameObj: {
- nyObj: {
- 'COREDAS_AR': '氩气',
- 'COREDAS_BFG': '高炉煤气',
- 'COREDAS_CLD': '转炉煤气',
- 'COREDAS_COG': '焦炉煤气',
- 'COREDAS_N2': '氮气',
- 'COREDAS_O2': '氧气'
- },
- flag: {
- obj: {
- '0': '否',
- '1': '是'
- },
- arr: [
- {
- id: '0',
- name: '否'
- },
- {
- id: '1',
- name: '是'
- }
- ]
- }
- },
- loading: false,
- tableLoading: false,
- dialog: {
- editorBox: {
- show: false,
- form: {
- rules: {
- FLAG: [
- { required: true, message: '该项不能为空', trigger: 'change' }
- ],
- VALD: [
- { validator: zCheckNumber1, trigger: 'change' }
- ],
- VALU: [
- { validator: zCheckNumber1, trigger: 'change' }
- ]
- }
- }
- },
- equationEditing: {
- show: false,
- form: {
- data: {
- clock: '',
- code: ''
- }
- }
- }
- }
- }
- },
- created () {
- this.activeMenu = window.localStorage.getItem('activeMenu');
- },
- mounted () {
- let that = this;
- window.PEDataObj = {
- // 将数据绑定到window上,供main页面使用
- vm: that,
- // tableArr:用于导出成Excel的表格的信息
- tableArr: [
- {
- name: '',
- id: 'singleTable'
- }
- ]
- };
- that.$nextTick(() => {
- // 立即获取的height有一定偏差,通过setTimeout延迟来解决
- setTimeout(() => {
- that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 45;
- }, 1);
- });
- that.getTableData();
- },
- methods: {
- // 计算树区域高度
- getRoleHeight (dom) {
- return window.innerHeight - dom.offsetTop;
- },
- // 获取表格中的数据
- getTableData (pageNum) {
- let that = this,
- params = {
- comments: that.filterForm.data.comments
- };
- that.pageNum = pageNum || that.pageNum;
- that.tableLoading = true;
- let url = 'pass/ems/v1/coredasabnormalinfos/getCoredasStd';
- that.axios.get(url, {
- params: params
- })
- .then(function (res) {
- if (res.code === '0') {
- that.tableData = res.data.data;
- // that.total = res.data.total;
- } else {
- that.$message.error(res.message);
- }
- that.tableLoading = false;
- }).catch(function () {
- that.tableLoading = false;
- });
- },
- // 改变表格显示条数
- tableSizeChange (val) {
- let that = this;
- that.pageSize = val;
- that.getTableData(1);
- },
- // 重置搜索
- tableDataCancel () {
- let that = this;
- for (let key in that.filterForm.data) {
- if (that.filterForm.data[key] instanceof Array) {
- that.filterForm.data[key] = [];
- } else {
- that.filterForm.data[key] = '';
- }
- }
- that.getTableData(1);
- },
- // 表格中多选按钮的相关方法
- handleSelectionChange (val) {
- let that = this;
- let tableFormDataObj = {};
- for (let item of that.tableData) {
- item.isSelection = false;
- }
- for (let item of val) {
- let obj = {};
- let xId = item.col;
- if (that.tableFormDataObj[xId]) {
- tableFormDataObj[xId] = that.tableFormDataObj[xId];
- } else {
- for (let key in item) {
- obj[key] = item[key];
- }
- tableFormDataObj[xId] = obj;
- }
- item.isSelection = true;
- }
- that.tableFormDataObj = tableFormDataObj;
- that.multipleSelection = val;
- },
- // 批量修改
- but_edit_plural () {
- let that = this;
- if (that.multipleSelection.length > 0) {
- that.$refs['dialog_form_arr'].validate((valid, obj) => {
- if (valid) {
- let SubmitData = [];
- for (let key in that.tableFormDataObj) {
- SubmitData.push({
- col: that.tableFormDataObj[key].col,
- TABLE_NAME: that.tableFormDataObj[key].TABLE_NAME,
- ST: that.tableFormDataObj[key].ST,
- FLAG: that.tableFormDataObj[key].FLAG,
- VALD: that.tableFormDataObj[key].VALD,
- VALU: that.tableFormDataObj[key].VALU
- });
- }
- that.loading = true;
- that.axios.put('pass/ems/v1/coredasabnormalinfos/', SubmitData).then(function (res) {
- if (res.code === '0') {
- that.$message({
- message: '修改成功',
- type: 'success'
- });
- that.getTableData();
- that.dialog.editorBox.show = false;
- } else {
- that.$message.error(res.message);
- }
- that.loading = false;
- }).catch(function () {
- that.loading = false;
- });
- } else {
- let col = Object.keys(obj)[0].split('.')[1];
- if (col && col === 'VALD') {
- this.$message.error('最小值请填写数字');
- } else if (col && col === 'VALU') {
- this.$message.error('最大值请填写数字');
- } else if (col && col === 'FLAG') {
- this.$message.error('是否启用报警不能为空');
- } else {
- this.$message.error('数据不完整或者格式错误');
- }
- }
- });
- } else {
- this.$message.error('至少要选择一条数据');
- }
- },
- // 表格合并单元格
- arraySpanMethod ({ row, column, rowIndex, columnIndex }) {
- let tableData = this.$refs.singleTable.tableData
- let rowsPan = 1;
- let thisColomnData = row[column['property']];
- // 能源列 合并
- if (column['property'] === 'TABLE_NAME' && thisColomnData) {
- if (rowIndex > 0 && thisColomnData === tableData[rowIndex - 1][column['property']]) {
- return {
- rowspan: 0,
- colspan: 0
- };
- }
- while (tableData[rowIndex + rowsPan] && thisColomnData === tableData[rowIndex + rowsPan][column['property']]) {
- rowsPan += 1
- }
- return {
- rowspan: rowsPan,
- colspan: 1
- };
- }
- },
- setColor ({row, column, rowIndex, columnIndex}) {
- if (column['property'] === 'TABLE_NAME' || columnIndex === 0) {
- return 'background-color:#fff'
- }
- }
- }
- }
- </script>
- <style lang="less">
- .nyjkbz {
- min-width: 700px;
- height: 100%;
- .box {
- height: 100%;
- padding: 15px 15px 0 15px;
- .box-top {
- .el-form-item {
- margin-bottom: 7px;
- }
- .box-top-gjl {
- overflow: hidden;
- padding: 7px 0;
- border-top: 1px solid #ccc;
- }
- }
- .el-table .el-table__row {
- height: 35px;
- }
- .el-table__body .el-form-item--mini.el-form-item {
- margin: 0px;
- .error {
- overflow: hidden;
- color: #f56c6c;
- font-size: 12px;
- line-height: 1;
- }
- }
- }
- .color_no {
- color: #7a7a7a;
- }
- .color_yes {
- color: #1a9f17;
- }
- }
- </style>
|