<template>
<!-- 计量点信息维护 -->
    <div class="measurementPlace">
        <div class="box">
            <div class="box-top">
                <el-form
                    style="overflow: hidden;"
                    :style="filterForm.show ? null : { height: '0px' }"
                    size="mini"
                    label-width="80px"
                >
                    <el-row>
                        <el-col :span="6">
                            <el-form-item label="能介类型">
                                <el-select
                                    filterable clearable
                                    v-model="filterForm.data.energytypeid"
                                    multiple
                                    collapse-tags
                                    placeholder="能介类型"
                                    style="width: 100%;"
                                >
                                    <el-option
                                        v-for="item of nameObj.energytypeid.arr"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.name"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="能介">
                                <el-select
                                    filterable clearable
                                    v-model="filterForm.data.energyid"
                                    multiple
                                    collapse-tags
                                    placeholder="能介"
                                    style="width: 100%;"
                                >
                                    <template v-for="item of nameObj.energyid.arr">
                                        <el-option
                                            v-if="filterForm.data.energytypeid.indexOf(item.energytypeid) !== -1 || Object.keys(filterForm.data.energytypeid).length === 0"
                                            :key="item.id"
                                            :value="item.id"
                                            :label="item.name"
                                        ></el-option>
                                    </template>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="用能属性">
                                <el-select
                                    filterable clearable
                                    v-model="filterForm.data.propertyid"
                                    placeholder="用能属性"
                                    multiple
                                    collapse-tags
                                    style="width: 100%;"
                                >
                                    <el-option
                                        v-for="item of nameObj.propertyid.arr"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.name"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="手抄或自动">
                                <el-select
                                    filterable clearable
                                    v-model="filterForm.data.itemtype"
                                    placeholder="手抄或自动"
                                    style="width: 100%;"
                                >
                                    <el-option
                                        v-for="item of nameObj.itemtype.arr"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.name"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="6">
                            <el-form-item label="位置">
                                <el-select
                                    filterable clearable
                                    v-model="filterForm.data.locateid"
                                    placeholder="位置"
                                    multiple
                                    collapse-tags
                                    style="width: 100%;"
                                >
                                    <el-option
                                        v-for="item of nameObj.locateid.arr"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.name"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="站所">
                                <el-select
                                    filterable clearable
                                    v-model="filterForm.data.networkid"
                                    placeholder="站所"
                                    multiple
                                    collapse-tags
                                    style="width: 100%;"
                                >
                                    <el-option
                                        v-for="item of nameObj.networkid.arr"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.name"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="计量点编号">
                                <el-input clearable
                                    v-model.trim="filterForm.data.itemid"
                                    placeholder="计量点编号"
                                    style="width: 100%;"
                                    @keyup.enter.native="getTableData(1)"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="计量点名称">
                                <el-input clearable
                                    v-model.trim="filterForm.data.itemname"
                                    placeholder="计量点名称"
                                    style="width: 100%;"
                                    @keyup.enter.native="getTableData(1)"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <!-- <el-col :span="6">
                            <el-form-item label="计量层级">
                                <el-select
                                    filterable clearable
                                    v-model="filterForm.data.hierarchy"
                                    placeholder="计量层级"
                                    style="width: 100%;"
                                >
                                    <el-option
                                        v-for="item of nameObj.hierarchy.arr"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.name"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col> -->
                        <el-col :span="6">
                            <el-form-item label="TAG点别名">
                                <el-input clearable
                                    v-model.trim="filterForm.data.tagAlias"
                                    placeholder="TAG点别名"
                                    style="width: 100%;"
                                    @keyup.enter.native="getTableData(1)"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="数据表">
                                <el-input clearable
                                    v-model.trim="filterForm.data.tagTable"
                                    placeholder="小时数据表"
                                    style="width: 100%;"
                                    @keyup.enter.native="getTableData(1)"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="数据列">
                                <el-input clearable
                                    v-model.trim="filterForm.data.tagCol"
                                    placeholder="小时表列(TAG)"
                                    style="width: 100%;"
                                    @keyup.enter.native="getTableData(1)"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="公式版本">
                                <el-date-picker
                                    type="month"
                                    v-model="filterForm.data.version"
                                    placeholder="公式版本"
                                    style="width: 100%;"
                                    format="yyyyMM"
                                    value-format="yyyyMM00"
                                ></el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!-- <div style="text-align: right;margin-bottom: 13px;">
                    </div> -->
                </el-form>
                <div class="box-top-gjl">
                    <el-button
                        class="button"
                        type="primary"
                        size="mini"
                        icon="el-icon-plus"
                        v-if="butPrivilege.ADD"
                        @click="but_add"
                    >新增</el-button>
                    <!-- <el-button
                        class="button"
                        type="primary"
                        size="mini"
                        icon="el-icon-upload2"
                    >导入计量点</el-button>
                    <el-button
                        class="button"
                        type="primary"
                        size="mini"
                        icon="el-icon-download"
                    >导出全部计量点</el-button> -->
                    <div style="float:right; text-align: right;">
                        <el-button
                            class="button"
                            type="primary"
                            size="mini"
                            icon="el-icon-search"
                            v-if="butPrivilege.QUERY"
                            @click="filterForm.useflag='';getTableData(1);"
                        >查询全部</el-button>
                        <el-button
                            class="button"
                            type="primary"
                            icon="el-icon-search"
                            size="mini"
                            v-if="butPrivilege.QUERY"
                            @click="filterForm.useflag='1';getTableData(1)"
                        >查询</el-button>
                        <el-button
                            class="button"
                            type="primary"
                            icon="el-icon-refresh"
                            size="mini"
                            v-if="butPrivilege.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-table
                    stripe
                    id="singleTable"
                    ref="singleTable"
                    :data="tableData"
                    v-loading="tableLoading"
                    style="width: 100%;"
                    :height="singleTableHeight"
                    border
                    size="mini"
                    highlight-current-row
                    @current-change="handleCurrentChange"
                    :row-class-name="rowClassName"
                >
                    <el-table-column
                        sortable
                        prop="itemid"
                        label="计量点编号"
                        width="120px"
                        :show-overflow-tooltip="true"
                    ></el-table-column>
                    <el-table-column
                        sortable
                        prop="itemname"
                        label="计量点名称"
                        min-width="150px"
                        :show-overflow-tooltip="true"
                    ></el-table-column>
                    <el-table-column
                        sortable
                        prop="tagAlias"
                        label="TAG别名"
                        min-width="150px"
                        :show-overflow-tooltip="true"
                    ></el-table-column>
                    <el-table-column
                        sortable
                        prop="itemdesc"
                        label="描述信息"
                        min-width="150px"
                        :show-overflow-tooltip="true"
                    ></el-table-column>
                    <el-table-column
                        sortable
                        prop="itemtype"
                        label="手抄自动"
                        width="72px"
                        :show-overflow-tooltip="true"
                    >
                        <template slot-scope="scope">
                            <span>{{ nameObj.itemtype.obj[scope.row.itemtype] ? nameObj.itemtype.obj[scope.row.itemtype] : scope.row.itemtype }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        sortable
                        prop="locateid"
                        label="位置"
                        min-width="100px"
                        :show-overflow-tooltip="true"
                    >
                        <template slot-scope="scope">
                            <span>{{ nameObj.locateid.obj[scope.row.locateid] ? nameObj.locateid.obj[scope.row.locateid] : scope.row.locateid }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        sortable
                        prop="networkid"
                        label="站所"
                        min-width="100px"
                        :show-overflow-tooltip="true"
                    >
                        <template slot-scope="scope">
                            <span>{{ nameObj.networkid.obj[scope.row.networkid] ? nameObj.networkid.obj[scope.row.networkid] : scope.row.networkid }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        sortable
                        prop="energytypeid"
                        label="能介类型"
                        width="75px"
                        :show-overflow-tooltip="true"
                    >
                        <template slot-scope="scope">
                            <span>{{ nameObj.energytypeid.obj[scope.row.energytypeid] ? nameObj.energytypeid.obj[scope.row.energytypeid] : scope.row.energytypeid }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        sortable
                        prop="energyid"
                        label="能介"
                        width="85px"
                        :show-overflow-tooltip="true"
                    >
                        <template slot-scope="scope">
                            <span>{{ nameObj.energyid.obj[scope.row.energyid] ? nameObj.energyid.obj[scope.row.energyid].name : scope.row.energyid }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        sortable
                        prop="propertyid"
                        label="用能属性"
                        width="80px"
                        :show-overflow-tooltip="true"
                    >
                        <template slot-scope="scope">
                            <span>{{ nameObj.propertyid.obj[scope.row.propertyid] ? nameObj.propertyid.obj[scope.row.propertyid] : scope.row.propertyid }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        sortable
                        prop="unitid"
                        label="计量单位"
                        min-width="80px"
                        :show-overflow-tooltip="true"
                    >
                        <template slot-scope="scope">
                            <span>{{ nameObj.unitid.obj[scope.row.unitid] ? nameObj.unitid.obj[scope.row.unitid] : scope.row.unitid }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        sortable
                        prop="mintimegranid"
                        label="最小时间粒度"
                        min-width="100px"
                        :show-overflow-tooltip="true"
                    >
                        <template slot-scope="scope">
                            <span>{{ nameObj.mintimegranid.obj[scope.row.mintimegranid] ? nameObj.mintimegranid.obj[scope.row.mintimegranid] : scope.row.mintimegranid }}</span>
                        </template>
                    </el-table-column>
                    <!-- <el-table-column
                        sortable
                        prop="isschedule"
                        label="是否调度项"
                        width="90px"
                        :show-overflow-tooltip="true"
                    >
                        <template slot-scope="scope">
                            <span :class="{color_yes:  scope.row.isschedule === '1', color_no:  scope.row.isschedule === '0'}">{{ scope.row.isschedule === '0' ? '否' : scope.row.isschedule === '1' ? '是' : '' }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        sortable
                        prop="issettle"
                        label="是否结算项"
                        width="90px"
                        :show-overflow-tooltip="true"
                    >
                        <template slot-scope="scope">
                            <span :class="{color_yes:  scope.row.issettle === '1', color_no:  scope.row.issettle === '0'}">{{ scope.row.issettle === '0' ? '否' : scope.row.issettle === '1' ? '是' : '' }}</span>
                        </template>
                    </el-table-column> -->
                    <el-table-column
                        sortable
                        prop="useflag"
                        label="启用"
                        width="60px"
                        :show-overflow-tooltip="true"
                    >
                        <template slot-scope="scope">
                            <span :class="{color_yes:  scope.row.useflag === '1', color_no:  scope.row.useflag === '0'}">{{ scope.row.useflag === '0' ? '否' : scope.row.useflag === '1' ? '是' : '' }}</span>
                        </template>
                    </el-table-column>
                    <!-- <el-table-column
                        sortable
                        prop="showno"
                        label="顺序号"
                        width="90px"
                        :show-overflow-tooltip="true"
                    ></el-table-column> -->
                    <el-table-column
                        sortable
                        prop="sourceType"
                        label="数据来源"
                        min-width="100px"
                        :show-overflow-tooltip="true"
                    >
                    </el-table-column>
                    <el-table-column
                        sortable
                        prop="bdesc1"
                        label="das地址"
                        min-width="100px"
                        :show-overflow-tooltip="true"
                    ></el-table-column>
                    <el-table-column
                        sortable
                        prop="tagTable"
                        label="对应数据表"
                        width="200px"
                        :show-overflow-tooltip="true"
                    ></el-table-column>
                    <el-table-column
                        sortable
                        prop="tagCol"
                        label="对应数据列"
                        width="90px"
                        :show-overflow-tooltip="true"
                    ></el-table-column>
                    <el-table-column
                        class-name="gn-TableDownloadExcel-none"
                        v-if="butPrivilege.PUT || butPrivilege.DELETE"
                        label="操作"
                        align="center"
                        min-width="236px"
                        fixed="right"
                    >
                        <template slot-scope="scope">
                            <div>
                                <el-button
                                    type="primary"
                                    size="mini"
                                    @click="but_equationEditing(scope.row)"
                                    v-if="butPrivilege.PUT && scope.row.itemtype === 'VIRTUAL'"
                                >公式</el-button>
                                <el-button
                                    type="primary"
                                    size="mini"
                                    v-if="butPrivilege.PUT"
                                    @click="but_edit(scope.row)"
                                >修改</el-button>
                                <el-button
                                    v-if="butPrivilege.PUT && scope.row.useflag === '1'"
                                    type="danger"
                                    size="mini"
                                    @click="upUseflag(scope.row, '0')"
                                >禁用</el-button>
                                <el-button
                                    v-if="butPrivilege.PUT && scope.row.useflag !== '1'"
                                    type="primary"
                                    size="mini"
                                    @click="upUseflag(scope.row, '1')"
                                >启用</el-button>
                                <el-button
                                    type="danger"
                                    size="mini"
                                    v-if="butPrivilege.DELETE"
                                    @click="but_del(scope.row)"
                                >删除</el-button>
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
                <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>
        <el-dialog
            :title="'计量点信息 - ' + (dialog.editorBox.type === 'add' ? '新增' : '修改')"
            :visible.sync="dialog.editorBox.show"
            width="950px"
            :close-on-click-modal="false"
            :show-close="!loading"
        >
            <el-tabs
                v-model="dialog.editorBox.activeName"
                type="border-card"
            >
                <el-tab-pane
                    label="基础信息"
                    name="1"
                >
                    <div>
                        <el-form
                            ref="dialog_form"
                            :model="dialog.editorBox.form.data"
                            :rules="dialog.editorBox.form.rules"
                            size="mini"
                            label-width="90px"
                        >
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item
                                        label="计量点编号"
                                        prop="itemid"
                                    >
                                        <el-input clearable
                                            style="width: 100%;"
                                            v-model="dialog.editorBox.form.data.itemid"
                                            disabled
                                        ></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item
                                        label="计量点名称"
                                        prop="itemname"
                                    >
                                        <el-input clearable
                                            style="width: 100%;"
                                            v-model="dialog.editorBox.form.data.itemname"
                                        ></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item
                                        label="TAG别名"
                                        prop="tagAlias"
                                    >
                                        <el-input clearable
                                            style="width: 100%;"
                                            v-model="dialog.editorBox.form.data.tagAlias"
                                        ></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item
                                        label="位置"
                                        prop="locateid"
                                    >
                                        <el-select
                                            filterable clearable
                                            style="width: 100%;"
                                            v-model="dialog.editorBox.form.data.locateid"
                                            @change="autoSetName()"
                                        >
                                            <el-option
                                                v-for="item of nameObj.locateid.arr"
                                                :key="item.id"
                                                :value="item.id"
                                                :label="item.name"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item
                                        label="能介类型"
                                        prop="energytypeid"
                                    >
                                        <el-select
                                            filterable clearable
                                            style="width: 100%;"
                                            v-model="dialog.editorBox.form.data.energytypeid"
                                            @change="dialog.editorBox.form.data.energyid='';"
                                        >
                                            <el-option
                                                v-for="item of nameObj.energytypeid.arr"
                                                :key="item.id"
                                                :value="item.id"
                                                :label="item.name"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item
                                        label="能介"
                                        prop="energyid"
                                    >
                                        <el-select
                                            filterable clearable
                                            style="width: 100%;"
                                            v-model="dialog.editorBox.form.data.energyid"
                                            @change="dialog.editorBox.form.data.unitid = nameObj.energyid.obj[dialog.editorBox.form.data.energyid].unitid; autoSetName()"
                                        >
                                            <template v-for="item of nameObj.energyid.arr">
                                                <el-option
                                                    v-if="item.energytypeid === dialog.editorBox.form.data.energytypeid || dialog.editorBox.form.data.energytypeid === ''"
                                                    :key="item.id"
                                                    :value="item.id"
                                                    :label="item.name"
                                                ></el-option>
                                            </template>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item
                                        label="用能属性"
                                        prop="propertyid"
                                    >
                                        <el-select
                                            filterable clearable
                                            style="width: 100%;"
                                            v-model="dialog.editorBox.form.data.propertyid"
                                            @change="autoSetName()"
                                        >
                                            <el-option
                                                v-for="item of nameObj.propertyid.arr"
                                                :key="item.id"
                                                :value="item.id"
                                                :label="item.name"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item
                                        label="手抄或自动"
                                        prop="itemtype"
                                    >
                                        <el-select
                                            filterable clearable
                                            style="width: 100%;"
                                            v-model="dialog.editorBox.form.data.itemtype"
                                        >
                                            <el-option
                                                v-for="item of nameObj.itemtype.arr"
                                                :key="item.id"
                                                :value="item.id"
                                                :label="item.name"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item
                                        label="站所"
                                        prop="networkid"
                                        :rules="[{required: dialog.editorBox.form.data.energytypeid ===  'E', message:'该项不能为空'}]"
                                    >
                                        <el-select
                                            filterable clearable
                                            style="width: 100%;"
                                            v-model="dialog.editorBox.form.data.networkid"
                                        >
                                            <el-option
                                                v-for="item of nameObj.networkid.arr"
                                                :key="item.id"
                                                :value="item.id"
                                                :label="item.name"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item
                                        label="描述信息"
                                        prop="itemdesc"
                                    >
                                        <el-input clearable
                                            style="width: 100%;"
                                            v-model.trim="dialog.editorBox.form.data.itemdesc"
                                        ></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item
                                        label="计量单位"
                                        prop="unitid"
                                    >
                                        <el-select
                                            filterable clearable
                                            style="width: 100%;"
                                            v-model="dialog.editorBox.form.data.unitid"
                                        >
                                            <el-option
                                                v-for="item of nameObj.unitid.arr"
                                                :key="item.id"
                                                :value="item.id"
                                                :label="item.name"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item
                                        label="最小时间粒度"
                                        prop="mintimegranid"
                                    >
                                        <el-select
                                            filterable clearable
                                            style="width: 100%;"
                                            v-model="dialog.editorBox.form.data.mintimegranid"
                                        >
                                            <el-option
                                                v-for="item of nameObj.mintimegranid.arr"
                                                :key="item.id"
                                                :value="item.id"
                                                :label="item.name"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <!-- <el-col :span="8">
                                    <el-form-item
                                        label="是否调度项"
                                        prop="isschedule"
                                    >
                                        <el-select
                                            filterable clearable
                                            style="width: 100%;"
                                            v-model="dialog.editorBox.form.data.isschedule"
                                        >
                                            <el-option
                                                label="是"
                                                value="1"
                                            ></el-option>
                                            <el-option
                                                label="否"
                                                value="0"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col> -->
                                <el-col :span="8">
                                    <el-form-item
                                        label="工序"
                                        prop="costid"
                                    >
                                        <el-select
                                            filterable clearable
                                            style="width: 100%;"
                                            v-model="dialog.editorBox.form.data.costid"
                                        >
                                            <el-option
                                                v-for="item of nameObj.workprocid.arr"
                                                :key="item.id"
                                                :value="item.id"
                                                :label="item.name"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="16">
                                    <el-form-item
                                        label="数据来源"
                                        prop="sourceType"
                                    >
                                        <el-input filterable clearable
                                            style="width: 100%;"
                                            v-model.trim="dialog.editorBox.form.data.sourceType"
                                        >
                                        </el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                        </el-form>
                    </div>
                </el-tab-pane>
                <el-tab-pane
                    label="计量点属性"
                    name="2"
                >
                    <div class="attribute-box">
                        <div class="item">
                            <p class="bt">基本属性</p>
                            <el-form
                                ref="dialog_form1"
                                :model="dialog.editorBox.form1.data"
                                :rules="dialog.editorBox.form1.rules"
                                class="nr"
                                label-width="90px"
                                size="mini"
                            >
                                <el-row>
                                    <el-col :span="8">
                                        <el-form-item label="默认值" prop="defaultvalue">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.defaultvalue"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="精度" prop="digits">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.digits"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="级别" prop="node">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.node"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="8">
                                        <el-form-item label="顺序号" prop="showno">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.showno"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="父级ID" prop="parentid">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.parentid"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="记录创建时间" prop="recTime">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model="dialog.editorBox.form1.data.recTime"
                                                disabled
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="8">
                                        <el-form-item label="启用" prop="useflag">
                                            <el-select
                                                filterable clearable
                                                style="width: 100%;"
                                                v-model="dialog.editorBox.form1.data.useflag"
                                            >
                                                <el-option
                                                    label="是"
                                                    value="1"
                                                ></el-option>
                                                <el-option
                                                    label="否"
                                                    value="0"
                                                ></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="点状态" prop="status">
                                            <el-select
                                                filterable clearable
                                                style="width: 100%;"
                                                v-model="dialog.editorBox.form1.data.status"
                                            >
                                                <el-option
                                                    label="是"
                                                    value="1"
                                                ></el-option>
                                                <el-option
                                                    label="否"
                                                    value="0"
                                                ></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </el-form>
                        </div>
                        <div class="item">
                            <p class="bt">扩展属性</p>
                            <el-form
                                class="nr"
                                label-width="90px"
                                size="mini"
                            >
                                <el-row>
                                    <el-col :span="8">
                                        <el-form-item label="仪表ID" prop="tagid">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.tagid"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="仪表名称" prop="tagname">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.tagname"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="跳变范围" prop="rangeVal">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.rangeVal"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="8">
                                        <el-form-item label="异常点标签" prop="tagBadSymbol">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.tagBadSymbol"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="倍率" prop="tagModulus">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.tagModulus"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="瞬时信号ID" prop="tagIdMap">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.tagIdMap"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="8">
                                        <el-form-item label="计算模式" prop="calcMod">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.calcMod"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="数据类型" prop="dataType">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.dataType"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="仪表类型" prop="meterType">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.meterType"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="8">
                                        <el-form-item label="准点精度" prop="meterScale">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.meterScale"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="仪表位置" prop="meterLoc">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.meterLoc"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </el-form>
                        </div>
                        <div class="item">
                            <p class="bt">特殊属性</p>
                            <el-form
                                class="nr"
                                label-width="90px"
                                size="mini"
                            >
                                <el-row>
                                    <el-col :span="8">
                                        <el-form-item label="对应数据表" prop="tagTable">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.tagTable"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="对应数据列" prop="tagCol">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.tagCol"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="最大值标志位" prop="maxVal">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.maxVal"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="8">
                                        <el-form-item label="最小值标志位" prop="minVal">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.minVal"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="平均值标志位" prop="avgVal">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.avgVal"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="累计值标志位" prop="sumVal">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.sumVal"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="8">
                                        <el-form-item label="电开关号" prop="bcode">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.bcode"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="das地址" prop="bdesc1">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model="dialog.editorBox.form1.data.bdesc1"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="8">
                                        <el-form-item label="录入序号" prop="bdesc2">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.bdesc2"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="8">
                                        <el-form-item label="备用描述" prop="btype1">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.btype1"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="16">
                                        <el-form-item label="十分钟表字段" prop="btype2">
                                            <el-input clearable
                                                style="width: 100%;"
                                                v-model.trim="dialog.editorBox.form1.data.btype2"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </el-form>
                        </div>
                    </div>
                </el-tab-pane>
            </el-tabs>
            <span
                slot="footer"
                class="dialog-footer"
            >
                <el-button
                    size="mini"
                    @click="dialog.editorBox.show = false"
                    :loading="loading"
                >取 消</el-button>
                <el-button
                    size="mini"
                    type="primary"
                    @click="dataSave"
                    :loading="loading"
                >保 存</el-button>
            </span>
        </el-dialog>
        <zj-formulaEditor :equationEditing="dialog.equationEditing"></zj-formulaEditor>
    </div>
</template>

<script>
import formulaEditor from '@/components/zg/formulaEditor.vue'
import { zCheckNumber2 } from '@/utils/validator.js'
import { formatDate } from '@/utils/util.js';
export default {
    name: 'measurementPlace',
    components: {
        'zj-formulaEditor': formulaEditor
    },
    data () {
        return {
            activeMenu: '',
            filterForm: {
                show: true,
                useflag: '1',
                data: {
                    energytypeid: '',
                    energyid: '',
                    propertyid: '',
                    itemtype: '',
                    locateid: '',
                    itemid: '',
                    itemname: '',
                    networkid: '',
                    hierarchy: '',
                    tagAlias: '',
                    version: formatDate(new Date(), 'yyyyMM00'),
                    tagTable: '',
                    tagCol: ''
                },
                rules: {

                }
            },
            pageNum: 1,
            pageSize: 20,
            total: 0,
            singleTableHeight: 100,
            tableData: [],
            nameObj: {
                workprocid: {
                    obj: {},
                    arr: []
                },
                energytypeid: {
                    obj: {},
                    arr: []
                },
                energyid: {
                    obj: {},
                    arr: []
                },
                propertyid: {
                    obj: {},
                    arr: []
                },
                locateid: {
                    obj: {},
                    arr: []
                },
                networkid: {
                    obj: {},
                    arr: []
                },
                unitid: {
                    obj: {},
                    arr: []
                },
                hierarchy: {
                    obj: {},
                    arr: []
                },
                itemtype: {
                    obj: {
                        'AUTO': '自动上传',
                        'MANUAL': '手抄',
                        'VIRTUAL': '虚拟'
                    },
                    arr: [
                        {
                            id: 'AUTO',
                            name: '自动上传'
                        },
                        {
                            id: 'MANUAL',
                            name: '手抄'
                        },
                        {
                            id: 'VIRTUAL',
                            name: '虚拟'
                        }
                    ]
                },
                mintimegranid: {
                    obj: {
                        'SHIFT': '班',
                        'DAY': '日',
                        'MONTH': '月',
                        'YEAR': '年'
                    },
                    arr: [
                        // {
                        //     id: 'SHIFT',
                        //     name: '班'
                        // },
                        {
                            id: 'DAY',
                            name: '日'
                        },
                        {
                            id: 'MONTH',
                            name: '月'
                        },
                        {
                            id: 'YEAR',
                            name: '年'
                        }
                    ]
                }
            },
            loading: false,
            tableLoading: false,
            dialog: {
                editorBox: {
                    show: false,
                    activeName: '1',
                    type: '',
                    addRow: null,
                    form: {
                        data: {
                            itemid: '',
                            itemname: '',
                            tagAlias: '',
                            itemdesc: '',
                            itemtype: '',
                            locateid: '',
                            networkid: '',
                            energytypeid: '',
                            energyid: '',
                            propertyid: '',
                            unitid: '',
                            isschedule: '0',
                            costid: '',
                            sourceType: '',
                            mintimegranid: 'DAY'
                        },
                        rules: {
                            // itemid: [
                            //     { required: true, message: '该项不能为空', trigger: 'change' }
                            // ],
                            itemname: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                            ],
                            // tagAlias: [
                            //      { required: true, message: '该项不能为空', trigger: 'change' }
                            // ],
                            locateid: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                            ],
                            networkid: [],
                            energytypeid: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                            ],
                            energyid: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                            ],
                            propertyid: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                            ],
                            itemtype: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                            ],
                            mintimegranid: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                            ],
                            bdesc2: [
                                { validator: zCheckNumber2, trigger: 'change' }
                            ]
                        }
                    },
                    form1: {
                        data: {
                            // 基础
                            defaultvalue: '',
                            digits: '',
                            node: '',
                            showno: '',
                            parentid: '',
                            recTime: '',
                            useflag: '',
                            status: '',
                            // 扩展
                            tagid: '',
                            tagname: '',
                            rangeVal: '',
                            tagBadSymbol: '',
                            tagModulus: '',
                            tagIdMap: '',
                            calcMod: '',
                            dataType: '',
                            meterType: '',
                            meterScale: '',
                            meterLoc: '',
                            // 特殊
                            tagTable: '',
                            tagCol: '',
                            maxVal: '',
                            minVal: '',
                            avgVal: '',
                            sumVal: '',
                            bcode: '',
                            bdesc1: '',
                            bdesc2: '',
                            btype1: '',
                            btype2: ''
                        },
                        rules: {
                            showno: [
                                { validator: zCheckNumber2, trigger: 'change' }
                            ]
                        }
                    }
                },
                equationEditing: {
                    show: false,
                    form: {
                        data: {
                            clock: '',
                            code: ''
                        }
                    }
                }
            },
            butPrivilege: {
                QUERY: false,
                ADD: false,
                PUT: false,
                DELETE: false
            }
        }
    },
    created () {
        // 获取按钮权限
        this.activeMenu = window.localStorage.getItem('activeMenu');
        for (let key in this.butPrivilege) {
            this.butPrivilege[key] = this.checkPrivilege(this.activeMenu + key);
        }
    },
    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.getEnergyTypeIdData();
        that.getEnergyIdData();
        that.getPropertyIdData();
        that.getLocateIdData();
        that.getNetworkIdData();
        // that.getSourceTypeData();
        that.getworkprocidData();
        that.getUnitIdData();
        that.getHierarchyData();
        that.getTableData();
    },
    methods: {
        //  计算树区域高度
        getRoleHeight (dom) {
            return window.innerHeight - dom.offsetTop;
        },
        // 获取工序
        getworkprocidData () {
            let that = this
            let url = 'pass/ems/v1/trmworkprocs/getIdAndName';
            that.axios.get(url)
                .then(function (res) {
                    if (res.code === '0') {
                        let arr = [];
                        let obj = {};
                        for (let item of res.data) {
                            arr.push({
                                id: item.id,
                                name: item.name
                            })
                            obj[item.id] = item.name;
                        }
                        that.nameObj.workprocid.arr = arr;
                        that.nameObj.workprocid.obj = obj;
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
        // 获取能介类型
        getEnergyTypeIdData () {
            let that = this
            let url = 'pass/ems/v1/trmenergytypes/selectNameAndId/';
            that.axios.get(url)
                .then(function (res) {
                    if (res.code === '0') {
                        let arr = [];
                        let obj = {};
                        for (let item of res.data) {
                            arr.push({
                                id: item.id,
                                name: item.name
                            })
                            obj[item.id] = item.name;
                        }
                        that.nameObj.energytypeid.arr = arr;
                        that.nameObj.energytypeid.obj = obj;
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
        connn () {
            // this.filterForm.data.energytypeid = this.filterForm.data.energytypeid.join(',')
            // console.log(this.filterForm.data.energytypeid)
            // console.log(111)
            // let that = this;
            // let set = new Set();
            // console.log(that.filterForm.data.energytypeid)
            // if (!that.filterForm.data.energytypeid || that.filterForm.data.energytypeid.length === 0) {
            //     that.nameObj.energytypeid.showDataArr = that.nameObj.energytypeid.arr;
            // } else {
            //     for (let key of that.filterForm.data.energytypeid) {
            //         if (that.nameObj.energytypeid.obj[key]) {
            //             for (let name of that.nameObj.energytypeid.obj[key]) {
            //                 set.add(name);
            //             }
            //         }
            //     }
            //     that.nameObj.energytypeid.showDataArr = [...set];
            //     // console.log(that.nameObj.energytypeid.showDataArr)
            // }
        },
        // 获取能介
        getEnergyIdData () {
            let that = this;
            let url = 'pass/ems/v1/trmenergys/selectNameAndId/';
            that.axios.get(url)
                .then(function (res) {
                    if (res.code === '0') {
                        let arr = [];
                        let obj = {};
                        for (let item of res.data) {
                            arr.push({
                                id: item.id,
                                name: item.name,
                                energytypeid: item.energytypeid,
                                unitid: item.unitid
                            })
                            obj[item.id] = {
                                name: item.name,
                                unitid: item.unitid
                            }
                        }
                        that.nameObj.energyid.arr = arr;
                        that.nameObj.energyid.obj = obj;
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
        // 获取属性
        getPropertyIdData () {
            let that = this
            let url = 'pass/ems/v1/trmenergypropertys/getidandname/';
            that.axios.get(url)
                .then(function (res) {
                    if (res.code === '0') {
                        let arr = [];
                        let obj = {};
                        for (let item of res.data) {
                            arr.push({
                                id: item.id,
                                name: item.name
                            })
                            obj[item.id] = item.name;
                        }
                        that.nameObj.propertyid.arr = arr;
                        that.nameObj.propertyid.obj = obj;
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
        // 获取位置
        getLocateIdData () {
            let that = this
            let url = 'pass/ems/v1/trmlocations/getidandname/';
            that.axios.get(url)
                .then(function (res) {
                    if (res.code === '0') {
                        let arr = [];
                        let obj = {};
                        for (let item of res.data) {
                            arr.push({
                                id: item.id,
                                name: item.name
                            })
                            obj[item.id] = item.name;
                        }
                        that.nameObj.locateid.arr = arr;
                        that.nameObj.locateid.obj = obj;
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
        // 获取站所
        getNetworkIdData () {
            let that = this
            let url = 'pass/ems/v1/trmstations/getidandname/';
            that.axios.get(url)
                .then(function (res) {
                    if (res.code === '0') {
                        let arr = [];
                        let obj = {};
                        for (let item of res.data) {
                            arr.push({
                                id: item.id,
                                name: item.name
                            })
                            obj[item.id] = item.name;
                        }
                        that.nameObj.networkid.arr = arr;
                        that.nameObj.networkid.obj = obj;
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
        // // 获取数据来源
        // getSourceTypeData () {
        //     let that = this
        //     let url = 'pass/ems/v1/trml1sources/getidandname/';
        //     that.axios.get(url)
        //         .then(function (res) {
        //             if (res.code === '0') {
        //                 let arr = [];
        //                 let obj = {};
        //                 for (let item of res.data) {
        //                     arr.push({
        //                         id: item.id,
        //                         name: item.name
        //                     })
        //                     obj[item.id] = item.name;
        //                 }
        //                 that.nameObj.sourceType.arr = arr;
        //                 that.nameObj.sourceType.obj = obj;
        //             } else {
        //                 that.$message.error(res.message);
        //             }
        //         });
        // },
        // 获取标准计量单位
        getUnitIdData () {
            let that = this
            let url = 'pass/ems/v1/trmunits/getIdAndName';
            that.axios.get(url)
                .then(function (res) {
                    if (res.code === '0') {
                        let arr = [];
                        let obj = {};
                        for (let item of res.data) {
                            arr.push({
                                id: item.id,
                                name: item.name
                            })
                            obj[item.id] = item.name;
                            // if (item.name === '吨') {
                            //     that.nameObj.unitid.defaults = that.nameObj.unitid.defaults ? that.nameObj.unitid.defaults : item.id;
                            // }
                        }
                        that.nameObj.unitid.arr = arr;
                        that.nameObj.unitid.obj = obj;
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
        // 获取计量层级
        getHierarchyData () {
            let that = this
            let url = 'pass/ems/v1/trmcalpoints/getRmCalpoint/';
            that.axios.get(url)
                .then(function (res) {
                    if (res.code === '0') {
                        let arr = [];
                        let obj = {};
                        for (let item of res.data) {
                            arr.push({
                                id: item.id,
                                name: item.name
                            })
                            obj[item.id] = item.name;
                        }
                        that.nameObj.hierarchy.arr = arr;
                        that.nameObj.hierarchy.obj = obj;
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
        // 获取表格中的数据
        getTableData (pageNum) {
            let that = this,
                params = {
                    energytypeid: that.filterForm.data.energytypeid.join(','),
                    energyid: that.filterForm.data.energyid.join(','),
                    propertyid: that.filterForm.data.propertyid.join(','),
                    itemtype: that.filterForm.data.itemtype,
                    locateid: that.filterForm.data.locateid.join(','),
                    itemid: that.filterForm.data.itemid,
                    itemname: that.filterForm.data.itemname,
                    networkid: that.filterForm.data.networkid.join(','),
                    node: that.filterForm.data.hierarchy,
                    tagAlias: that.filterForm.data.tagAlias,
                    version: that.filterForm.data.version,
                    tagTable: that.filterForm.data.tagTable,
                    tagCol: that.filterForm.data.tagCol,
                    useflag: that.filterForm.useflag
                };
            that.pageNum = pageNum || that.pageNum;
            that.tableLoading = true;
            let url = 'pass/ems/v1/trmcalpoints/like/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize;
            that.axios.get(url, {
                params: params
            })
                .then(function (res) {
                    if (res.code === '0') {
                        let arr = [];
                        for (let item of res.data.list) {
                            arr.push({
                                itemid: item.itemid,
                                itemname: item.itemname,
                                tagAlias: item.tagAlias,
                                itemdesc: item.itemdesc,
                                itemtype: item.itemtype,
                                locateid: item.locateid,
                                networkid: item.networkid,
                                energytypeid: item.energytypeid,
                                energyid: item.energyid,
                                propertyid: item.propertyid,
                                unitid: item.unitid,
                                isschedule: item.isschedule,
                                // issettle: item.issettle,
                                costid: item.costid,
                                sourceType: item.sourceType,
                                mintimegranid: item.mintimegranid,
                                // 基础
                                defaultvalue: item.defaultvalue,
                                digits: item.digits,
                                node: item.node,
                                showno: item.showno,
                                parentid: item.parentid,
                                recTime: item.recTime,
                                useflag: item.useflag,
                                status: item.status,
                                // 扩展
                                tagid: item.tagid,
                                tagname: item.tagname,
                                rangeVal: item.rangeVal,
                                tagBadSymbol: item.tagBadSymbol,
                                tagModulus: item.tagModulus,
                                tagIdMap: item.tagIdMap,
                                calcMod: item.calcMod,
                                dataType: item.dataType,
                                meterType: item.meterType,
                                meterScale: item.meterScale,
                                meterLoc: item.meterLoc,
                                // 特殊
                                tagTable: item.tagTable,
                                tagCol: item.tagCol,
                                maxVal: item.maxVal,
                                minVal: item.minVal,
                                avgVal: item.avgVal,
                                sumVal: item.sumVal,
                                bcode: item.bcode,
                                bdesc1: item.bdesc1,
                                bdesc2: item.bdesc2,
                                btype1: item.btype1,
                                btype2: item.btype2
                            })
                        }
                        that.tableData = arr;
                        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);
        },
        // 选择添加时的模板
        handleCurrentChange (row) {
            let that = this;
            that.dialog.editorBox.addRow = row;
        },
        // 自动生成名称
        autoSetName () {
            let that = this;
            if (that.dialog.editorBox.form.data.itemname === '') {
                if (that.dialog.editorBox.form.data.locateid && that.dialog.editorBox.form.data.energyid && that.dialog.editorBox.form.data.propertyid) {
                    that.dialog.editorBox.form.data.itemname += that.nameObj.locateid.obj[that.dialog.editorBox.form.data.locateid];
                    that.dialog.editorBox.form.data.itemname += that.nameObj.energyid.obj[that.dialog.editorBox.form.data.energyid].name;
                    that.dialog.editorBox.form.data.itemname += that.nameObj.propertyid.obj[that.dialog.editorBox.form.data.propertyid];
                }
            }
        },
        but_add () {
            let that = this;
            if (that.dialog.editorBox.addRow) {
                for (let key in that.dialog.editorBox.form.data) {
                    if (that.dialog.editorBox.addRow[key] || that.dialog.editorBox.addRow[key] === 0) {
                        that.dialog.editorBox.form.data[key] = that.dialog.editorBox.addRow[key];
                    } else {
                        that.dialog.editorBox.form.data[key] = '';
                    }
                }
                for (let key in that.dialog.editorBox.form1.data) {
                    if (that.dialog.editorBox.addRow[key] || that.dialog.editorBox.addRow[key] === 0) {
                        that.dialog.editorBox.form1.data[key] = that.dialog.editorBox.addRow[key];
                    } else {
                        that.dialog.editorBox.form1.data[key] = '';
                    }
                }
                this.$refs['singleTable'].setCurrentRow();
            } else {
                for (let key in that.dialog.editorBox.form.data) {
                    if (that.filterForm.data[key] || that.filterForm.data[key] === 0) {
                        that.dialog.editorBox.form.data[key] = that.filterForm.data[key];
                    } else {
                        that.dialog.editorBox.form.data[key] = '';
                    }
                }
                for (let key in that.dialog.editorBox.form1.data) {
                    if (that.filterForm.data[key] || that.filterForm.data[key] === 0) {
                        that.dialog.editorBox.form1.data[key] = that.filterForm.data[key];
                    } else {
                        that.dialog.editorBox.form1.data[key] = '';
                    }
                }
                that.dialog.editorBox.form.data.unitid = that.nameObj.energyid.obj[that.dialog.editorBox.form.data.energyid] ? that.nameObj.energyid.obj[that.dialog.editorBox.form.data.energyid].unitid : '';
                // that.dialog.editorBox.form.data.unitid = that.nameObj.unitid.defaults ? that.nameObj.unitid.defaults : '';
                that.dialog.editorBox.form.data.isschedule = '0';
                that.dialog.editorBox.form1.data.useflag = '1';
                that.dialog.editorBox.form1.data.status = '0';
            }
            that.dialog.editorBox.form.data.itemid = '';
            // that.dialog.editorBox.form.data.itemname = '';
            that.dialog.editorBox.form1.data.recTime = '';
            that.dialog.editorBox.activeName = '1';
            that.dialog.editorBox.type = 'add';
            that.dialog.editorBox.show = true;
            setTimeout(() => {
                that.$refs['dialog_form'].clearValidate();
            }, 100);
        },
        but_edit (row) {
            let that = this;
            for (let key in that.dialog.editorBox.form.data) {
                if (typeof row[key] !== 'undefined') {
                    that.dialog.editorBox.form.data[key] = row[key];
                }
            }
            for (let key in that.dialog.editorBox.form1.data) {
                if (typeof row[key] !== 'undefined') {
                    that.dialog.editorBox.form1.data[key] = row[key];
                }
            }
            that.dialog.editorBox.activeName = '1';
            that.dialog.editorBox.type = 'edit';
            that.dialog.editorBox.show = true;
        },
        but_del (row) {
            let that = this;
            that.$confirm('是否删除该条数据?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                state: 'warning'
            }).then(() => {
                that.axios.delete('pass/ems/v1/trmcalpoints/' + row.itemid)
                    .then(function (res) {
                        if (res.code === '0') {
                            that.$message({
                                message: '删除成功',
                                type: 'success'
                            });
                            that.getTableData();
                        } else {
                            that.$message.error(res.message);
                        }
                    }).catch(function () {
                    });
            }).catch(() => {
            });
        },
        dataSave () {
            let that = this;
            let SubmitData = {
                itemid: that.dialog.editorBox.form.data.itemid,
                itemname: that.dialog.editorBox.form.data.itemname,
                tagAlias: that.dialog.editorBox.form.data.tagAlias,
                itemdesc: that.dialog.editorBox.form.data.itemdesc,
                itemtype: that.dialog.editorBox.form.data.itemtype,
                locateid: that.dialog.editorBox.form.data.locateid,
                networkid: that.dialog.editorBox.form.data.networkid,
                energytypeid: that.dialog.editorBox.form.data.energytypeid,
                energyid: that.dialog.editorBox.form.data.energyid,
                propertyid: that.dialog.editorBox.form.data.propertyid,
                unitid: that.dialog.editorBox.form.data.unitid,
                isschedule: that.dialog.editorBox.form.data.isschedule,
                costid: that.dialog.editorBox.form.data.costid,
                sourceType: that.dialog.editorBox.form.data.sourceType,
                mintimegranid: that.dialog.editorBox.form.data.mintimegranid,
                // 基础
                defaultvalue: that.dialog.editorBox.form1.data.defaultvalue,
                digits: that.dialog.editorBox.form1.data.digits,
                node: that.dialog.editorBox.form1.data.node,
                showno: that.dialog.editorBox.form1.data.showno,
                parentid: that.dialog.editorBox.form1.data.parentid,
                recTime: that.dialog.editorBox.form1.data.recTime,
                useflag: that.dialog.editorBox.form1.data.useflag,
                status: that.dialog.editorBox.form1.data.status,
                // 扩展
                tagid: that.dialog.editorBox.form1.data.tagid,
                tagname: that.dialog.editorBox.form1.data.tagname,
                rangeVal: that.dialog.editorBox.form1.data.rangeVal,
                tagBadSymbol: that.dialog.editorBox.form1.data.tagBadSymbol,
                tagModulus: that.dialog.editorBox.form1.data.tagModulus,
                tagIdMap: that.dialog.editorBox.form1.data.tagIdMap,
                calcMod: that.dialog.editorBox.form1.data.calcMod,
                dataType: that.dialog.editorBox.form1.data.dataType,
                meterType: that.dialog.editorBox.form1.data.meterType,
                meterScale: that.dialog.editorBox.form1.data.meterScale,
                meterLoc: that.dialog.editorBox.form1.data.meterLoc,
                // 特殊
                tagTable: that.dialog.editorBox.form1.data.tagTable,
                tagCol: that.dialog.editorBox.form1.data.tagCol,
                maxVal: that.dialog.editorBox.form1.data.maxVal,
                minVal: that.dialog.editorBox.form1.data.minVal,
                avgVal: that.dialog.editorBox.form1.data.avgVal,
                sumVal: that.dialog.editorBox.form1.data.sumVal,
                bcode: that.dialog.editorBox.form1.data.bcode,
                bdesc1: that.dialog.editorBox.form1.data.bdesc1,
                bdesc2: that.dialog.editorBox.form1.data.bdesc2,
                btype1: that.dialog.editorBox.form1.data.btype1,
                btype2: that.dialog.editorBox.form1.data.btype2
            };
            that.$refs['dialog_form'].validate((valid) => {
                if (valid) {
                    that.$refs['dialog_form1'].validate((valid1) => {
                        if (valid1) {
                            if (that.dialog.editorBox.type === 'add') {
                                let foorData = new FormData();
                                for (let key in SubmitData) {
                                    foorData.append(key, SubmitData[key]);
                                }
                                that.loading = true;
                                that.axios.post('pass/ems/v1/trmcalpoints/', foorData, {
                                    headers: {
                                        'Content-Type': 'multipart/form-data'
                                    }
                                })
                                    .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 {
                                that.loading = true;
                                that.axios.put('pass/ems/v1/trmcalpoints/' + SubmitData.itemid, SubmitData)
                                    .then(function (res) {
                                        if (res.code === '0') {
                                            let msg = res.message
                                            if (!msg || msg === '操作成功') {
                                                that.$message({
                                                    message: '修改成功',
                                                    type: 'success'
                                                });
                                            } else {
                                                that.$message.warning('修改成功，注意：' + msg);
                                            }
                                            that.getTableData();
                                            that.dialog.editorBox.show = false;
                                        } else {
                                            that.$message.error(res.message);
                                        }
                                        that.loading = false;
                                    }).catch(function () {
                                        that.loading = false;
                                    });
                            }
                        } else {
                            that.dialog.editorBox.activeName = '2';
                        }
                    });
                } else {
                    that.dialog.editorBox.activeName = '1';
                }
            });
        },
        but_equationEditing (row) {
            let that = this;
            that.dialog.equationEditing.form.data.clock = that.filterForm.data.version;
            that.dialog.equationEditing.form.data.code = row.itemid;
            that.dialog.equationEditing.show = true;
        },
        rowClassName ({row, rowIndex}) {
            return row.useflag !== '1' ? 'rowDisable' : ''
        },
        upUseflag (row, useflag = 0) {
            let that = this;
            let SubmitData = {
                itemname: row.itemname,
                tagAlias: row.tagAlias,
                itemdesc: row.itemdesc,
                itemtype: row.itemtype,
                locateid: row.locateid,
                networkid: row.networkid,
                energytypeid: row.energytypeid,
                energyid: row.energyid,
                propertyid: row.propertyid,
                unitid: row.unitid,
                isschedule: row.isschedule,
                sourceType: row.sourceType,
                useflag: useflag,
                mintimegranid: row.mintimegranid
            };
            that.$confirm('是否' + (useflag === '1' ? '启用' : '禁用') + '?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                that.axios.put('pass/ems/v1/trmcalpoints/' + row.itemid, SubmitData)
                    .then(function (res) {
                        if (res.code === '0') {
                            that.$message({
                                message: useflag === '1' ? '启用成功' : '禁用成功',
                                type: 'success'
                            });
                            that.getTableData();
                            that.dialog.editorBox.show = false;
                        } else {
                            that.$message.error(res.message);
                        }
                    }).catch(function () {
                    });
            }).catch(() => {
            })
        }
    }
}
</script>

<style lang="less">
.measurementPlace {
    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;
                // margin-top: -7px;
                padding: 7px 0;
                border-top: 1px solid #ccc;
                // border-bottom: 1px solid #ccc;
                // margin-bottom: 6px;
            }
        }
        .rowDisable td {
            background-color: #dfdfdf !important;
        }
    }
    .attribute-box {
        .item {
            border: #ccc 1px solid;
            padding: 5px;
            margin-bottom: 6px;
            .bt {
                font-size: 14px;
                font-weight: 600;
                color: #000;
                padding-left: 10px;
                border-left: #008fe0 5px solid;
            }
        }
    }
    .color_no {
        color: #7a7a7a;
    }
    .color_yes {
        color: #1a9f17;
    }
    .el-button--mini {
        padding: 7px 12px;
    }
}
</style>
