<template>
<!-- 月计划 -->
    <div class="outElectricity">
        <div class="box">
            <div class="box-top">
                <el-form
                    style="overflow: hidden;"
                    :style="filterForm.show ? null : { height: '0px' }"
                    size="mini"
                    label-width="75px"
                >
                    <el-row>
                        <el-col :span="6">
                            <el-form-item label="月份">
                                <zj-timegran-date
                                    v-model="filterForm.data.may"
                                    style="width: 100%;"
                                    :type="'daterange'"
                                    :timegranId="'MONTH'"
                                    :oneFoo="getTableData"
                                    :defaultOffset="0"
                                ></zj-timegran-date>
                            </el-form-item>
                        </el-col>
                        <el-col :span="5">
                            <el-form-item label="工序">
                                <el-select
                                    filterable clearable
                                    v-model="filterForm.data.workprocid"
                                    multiple
                                    collapse-tags
                                    style="width: 100%;"
                                >
                                    <el-option
                                        v-for="item of nameObj.location.showDataArr"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.name"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                        </el-col>
                    </el-row>
                </el-form>
                <div class="box-top-gjl">
                    <el-form size="mini" label-width="75px">
                        <el-row>
                            <el-col :span="16">
                                <el-button
                                    class="button"
                                    type="primary"
                                    size="mini"
                                    icon="el-icon-plus"
                                    style="margin-left: 20px;"
                                    @click="but_add"
                                    :loading="loading"
                                    v-if="butPrivilege.PUT && !isCheck"
                                >新增</el-button>
                                <el-button
                                    class="button"
                                    type="primary"
                                    size="mini"
                                    icon="el-icon-edit-outline"
                                    @click="but_edit_plural()"
                                    :loading="loading"
                                    v-if="butPrivilege.PUT && !isCheck"
                                >修改</el-button>
                                <el-button
                                   class="button"
                                    type="primary"
                                    size="mini"
                                    icon="el-icon-plus"
                                    style="margin-left: 20px;"
                                    @click="but_copy"
                                    :loading="loading"
                                >复制</el-button>
                                <el-button
                                    class="button"
                                    type="danger"
                                    size="mini"
                                    icon="el-icon-delete"
                                    v-if="butPrivilege.PUT && !isCheck"
                                    @click="but_del_plural()"
                                    :loading="loading"
                                >删除</el-button>
                            </el-col>
                            <el-col :span="8">
                                <div style="float:right; text-align: right;">
                                    <el-button
                                        class="button"
                                        type="primary"
                                        size="mini"
                                        icon="el-icon-search"
                                        v-if="butPrivilege.QUERY"
                                        @click="getTableData()"
                                    >查询</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>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
            </div>
            <div class="box-bottom">
                <el-form
                    size="mini"
                    ref="dialog_form_arr"
                    label-width="0px"
                    :model="tableFormDataObj"
                >
                    <el-table stripe
                        id="singleTable"
                        ref="singleTable"
                        :data="tableData"
                        v-loading="tableLoading"
                        style="width: 100%;"
                        :height="singleTableHeight"
                        border
                        size="mini"
                        highlight-current-row
                        @selection-change="handleSelectionChange"
                        show-summary
                        :summary-method="getSummaries"
                        :span-method="arraySpanMethod"
                        :row-class-name="tableRowClassName"
                        @cell-click="cellClick"
                    >
                        <el-table-column
                            type="selection"
                            width="46"
                            align="center"
                            :selectable='checkboxT'
                            fixed="left"
                            class-name="cnspicuous"
                        ></el-table-column>
                        <el-table-column
                            prop="workprocid"
                            label="工序"
                            fixed="left"
                            width="90px"
                            :show-overflow-tooltip="true"
                        >
                        <template slot-scope="scope">
                              <span>{{ nameObj.workprocid.obj[scope.row.workprocid] ? nameObj.workprocid.obj[scope.row.workprocid] : scope.row.workprocid }}</span>
                        </template>
                        </el-table-column>
                        <el-table-column
                            prop="productid"
                            label="产品"
                            fixed="left"
                            width="120px"
                            :show-overflow-tooltip="true"
                        ></el-table-column>
                        <!-- <el-table-column
                            prop="rxj"
                            label="月计划量"
                            fixed="left"
                            width="100px"
                            :show-overflow-tooltip="true"
                        ></el-table-column> -->
                        <el-table-column
                            prop="may"
                            label="日期"
                            fixed="left"
                            width="120px"
                            :show-overflow-tooltip="true"
                        ></el-table-column>
                        <el-table-column
                            prop="weightDay"
                            label="计划量(日)"
                            width="120px"
                            :show-overflow-tooltip="true"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    v-if="!isCheck && scope.row.isSelection && scope.row.state !== '2'"
                                    :prop="scope.row.seq + '.weightDay'"
                                    :rules="tableFormRules.weightDay"
                                >
                                    <el-input clearable
                                        style="width: 100%;"
                                        v-model="tableFormDataObj[scope.row.seq].weightDay"
                                        refcous="true"
                                        @keydown.native="keyDown" :id="scope.$index + scope.column.id"
                                        @change = "getApportValue(scope.row.seq, tableFormDataObj[scope.row.seq].weightDay,scope.$index, $event)"
                                    ></el-input>
                                    <template slot="error" slot-scope="scope">
                                        <p class="error" :title="scope.error">{{ scope.error }}</p>
                                    </template>
                                </el-form-item>
                                <span v-else>{{scope.row.weightDay}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="unitid"
                            label="计量单位"
                            width="80px"
                            :show-overflow-tooltip="true"
                        >
                        <template slot-scope="scope">
                              <span>{{ nameObj.unitid.obj[scope.row.unit] ? nameObj.unitid.obj[scope.row.unit] : scope.row.unit }}</span>
                         </template>
                        </el-table-column>
                        <!-- <el-table-column
                            prop="jxdays"
                            label="检修小时"
                            width="80px"
                            :show-overflow-tooltip="true"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    v-if="!isCheck && scope.row.isSelection && scope.row.state !== '2'"
                                    :prop="scope.row.seq + '.jxdays'"
                                    :rules="tableFormRules.jxdays"
                                >
                                    <el-input clearable
                                        style="width: 100%;"
                                        v-model="tableFormDataObj[scope.row.seq].jxdays"
                                        refcous="true"
                                        @keydown.native="keyDown" :id="scope.$index + scope.column.id"
                                        @change = "getApportValue(scope.row.seq, tableFormDataObj[scope.row.seq].jxdays, scope.$index, $event)"
                                    ></el-input>
                                    <template slot="error" slot-scope="scope">
                                        <p class="error" :title="scope.error">{{ scope.error }}</p>
                                    </template>
                                </el-form-item>
                                <span v-else>{{scope.row.jxdays}}</span>
                            </template>
                        </el-table-column> -->
                        <!-- <el-table-column
                            prop="sqno"
                            label="序号"
                            width="60px"
                            :show-overflow-tooltip="true"
                        ></el-table-column> -->
<!--                        <el-table-column
                            prop="weightMonth"
                            label="目标计划量(月)"
                            width="110px"
                            :show-overflow-tooltip="true"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    v-if="!isCheck && scope.row.isSelection"
                                    :prop="scope.row.seq + '.weightMonth'"
                                    :rules="tableFormRules.weightMonth"
                                >
                                    <el-input clearable
                                        style="width: 100%;"
                                        @keydown.native="keyDown" :id="scope.$index + scope.column.id"
                                        v-model="tableFormDataObj[scope.row.seq].weightMonth"
                                        @change="chnageApportvalue(scope.row.seq, tableFormDataObj[scope.row.seq].weightMonth, scope.$index)"
                                    ></el-input>
                                </el-form-item>
                                <span v-else>{{scope.row.weightMonth}}</span>
                            </template>
                        </el-table-column>
                         <el-table-column
                            prop="yhj"
                            label="月合计"
                            width="100px"
                            :show-overflow-tooltip="true"
                        ></el-table-column>
                         <el-table-column
                            prop="kxf_weight"
                            label="可下发量"
                            width="100px"
                            :show-overflow-tooltip="true"
                        >
                        <template slot-scope="scope">
                                <el-form-item
                                    v-if="!isCheck && scope.row.isSelection"
                                    :prop="scope.row.seq + '.kxf_weight'"
                                    :rules="tableFormRules.kxf_weight"
                                >
                                    <el-input clearable
                                        style="width: 100%;"
                                        @keydown.native="keyDown" :id="scope.$index + scope.column.id"
                                        v-model="tableFormDataObj[scope.row.seq].kxf_weight"
                                        @change="chnageApportvalue(scope.row.seq, tableFormDataObj[scope.row.seq].kxf_weight, scope.$index)"
                                    ></el-input>
                                </el-form-item>
                                <span v-else>{{scope.row.kxf_weight}}</span>
                            </template>
                        </el-table-column>
                         <el-table-column
                            prop="yxf_weight"
                            label="已下发量"
                            width="100px"
                            :show-overflow-tooltip="true"
                        >
                         <template slot-scope="scope">
                                <el-form-item
                                    v-if="!isCheck && scope.row.isSelection"
                                    :prop="scope.row.seq + '.yxf_weight'"
                                    :rules="tableFormRules.yxf_weight"
                                >
                                    <el-input clearable
                                        style="width: 100%;"
                                        @keydown.native="keyDown" :id="scope.$index + scope.column.id"
                                        v-model="tableFormDataObj[scope.row.seq].yxf_weight"
                                        @change="chnageApportvalue(scope.row.seq, tableFormDataObj[scope.row.seq].yxf_weight, scope.$index)"
                                    ></el-input>
                                </el-form-item>
                                <span v-else>{{scope.row.yxf_weight}}</span>
                            </template>
                        </el-table-column> -->
                        <el-table-column
                            prop="createman"
                            label="创建人"
                            width="120px"
                            :show-overflow-tooltip="true"
                        >
                        </el-table-column>
                        <el-table-column
                            prop="createtime"
                            label="创建时间"
                            width="180px"
                            :show-overflow-tooltip="true"
                        >
                        </el-table-column>
                         <el-table-column
                            prop="updatetime"
                            label="修改时间"
                            width="180px"
                            :show-overflow-tooltip="true"
                        >
                        </el-table-column>
                        <el-table-column
                            prop="updateman"
                            label="修改人"
                            width="120px"
                            :show-overflow-tooltip="true"
                        ></el-table-column>
                        <el-table-column
                            prop="memo"
                            label="备注"
                            width="400px"
                            :show-overflow-tooltip="true"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    v-if="!isCheck && scope.row.isSelection && scope.row.state !== '2'"
                                    :prop="scope.row.seq + '.memo'"
                                    :rules="tableFormRules.memo"
                                >
                                    <el-input clearable
                                        style="width: 100%;"
                                        v-model="tableFormDataObj[scope.row.seq].memo"
                                        @keydown.native="keyDown" :id="scope.$index + scope.column.id"
                                    ></el-input>
                                    <template slot="error" slot-scope="scope">
                                        <p class="error" :title="scope.error">{{ scope.error }}</p>
                                    </template>
                                </el-form-item>
                                <span v-else>{{scope.row.memo}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="id"
                            label="ID"
                            width="140px"
                            :show-overflow-tooltip="true"
                            v-if="filterForm.data.show"
                        ></el-table-column>
                    </el-table>
                </el-form>
                <el-pagination
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total"
                    :page-sizes="[10, 20, 50, 100, 500, 1000]"
                    :page-size="pageSize"
                    :current-page.sync="pageNum"
                    @size-change="tableSizeChange"
                    @current-change="getTableData()"
                    style="text-align: right;margin-top: 10px;"
                ></el-pagination>
            </div>
        </div>
        <el-dialog
        title="月度计划编制 新增"
        :visible.sync="dialog.editorBox.show"
         width="600px"
        :close-on-click-modal="false"
        :show-close="!loading"
        >
     <div>
         <el-form
         ref="dialog_form"
         :model="dialog.editorBox.form.data"
         :rules="dialog.editorBox.form.rules"
         size="mini"
         label-width="95px"
         >
         <el-row>
             <el-col :span="12">
               <el-form-item
               label="工序"
               prop="workprocid"
               >
                   <el-select
                     filterable clearable
                     v-model="dialog.editorBox.form.data.workprocid"
                     placeholder=""
                    style="width: 100%;"
                    >
                    <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="12">
                  <el-form-item
                    label="日期"
                    prop="may"
                    >
                    <zj-timegran-date
                    v-model="dialog.editorBox.form.data.may"
                    style="width: 100%;"
                    :timegranId="'DAY'"
                    ></zj-timegran-date>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="12">
                <el-form-item
                 label="产品"
                 prop="productid"
                >
               <el-input
                clearable
                style="width: 100%;"
                :rules="dialog.editorBox.form.productid"
                v-model="dialog.editorBox.form.data.productid"
               >
               </el-input>
                </el-form-item>
            </el-col>
            <el-col :span="12">
               <el-form-item
               label="单位名称"
               prop="unitid"
               >
                   <el-select
                     filterable clearable
                     v-model="dialog.editorBox.form.data.unitid"
                     placeholder=""
                     :rules="dialog.editorBox.form.unitid"
                    style="width: 100%;"
                    >
                    <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-row>
        <el-row>
            <el-col :span="12">
            <el-form-item
            label="目标计划量(日)"
            prop="weightDay"
                >
           <el-input
                clearable
                style="width: 100%;"
                :rules="dialog.editorBox.form.weightDay"
                v-model="dialog.editorBox.form.data.weightDay"
               ></el-input>
            </el-form-item>
            </el-col>
            <el-col :span="12">
            <el-form-item
            label="检修小时"
            prop="jxdays"
                >
             <el-input
                clearable
                style="width: 100%;"
                :rules="dialog.editorBox.form.jxdays"
                v-model="dialog.editorBox.form.data.jxdays"
               ></el-input>
            </el-form-item>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="12">
                <el-form-item
                label="目标计划量 (月)"
                prop="weightMonth"
                >
                <el-input
                clearable
                style="width: 100%;"
                :rules="dialog.editorBox.form.weightMonth"
                v-model="dialog.editorBox.form.data.weightMonth"
               ></el-input>
                </el-form-item>
            </el-col>
             <el-col :span="12">
                <el-form-item
                 label="备注"
                 prop="memo"
                 :rules="dialog.editorBox.form.memo"
                >
               <el-input
                clearable
                style="width: 100%;"
                :rules="dialog.editorBox.form.memo"
                v-model="dialog.editorBox.form.data.memo"
               >
               </el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="12">
                <el-form-item
                label="可下发量"
                prop="kxf_weight"
                >
                <el-input
                clearable
                style="width: 100%;"
                :rules="dialog.editorBox.form.kxf_weight"
                v-model="dialog.editorBox.form.data.kxf_weight"
               ></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item
                label="已下发量"
                prop="yxf_weight"
                >
                <el-input
                clearable
                style="width: 100%;"
                :rules="dialog.editorBox.form.yxf_weight"
                v-model="dialog.editorBox.form.data.yxf_weight"
               ></el-input>
                </el-form-item>
            </el-col>
        </el-row>
         </el-form>
         </div>
         <span
        slot="footer"
        class="dialog-footer"
            >
        <el-button
        @click="dialog.editorBox.show = false"
        :loading="loading"
        >取 消</el-button>
        <el-button
        type="primary"
        @click="dataSave"
        :loading="loading"
        >保 存</el-button>
    </span>
    </el-dialog>
     <el-dialog
       title="月度计划编制-复制"
       :visible.sync="dialog.editorBox2.show"
       width="400px"
       :close-on-click-modal="false"
       :show-close="!loading"
     >
         <div>
        <el-form
         :model="dialog.editorBox2.form.data"
         ref="dialog_form2"
         size="mini"
         label-width="300px"
         :rules="dialog.editorBox2.form.rules"
         >
         <el-row>
             <el-col>
                 <el-col :span="12">
                  <el-form-item
                    label="时间"
                    prop="may"
                    label-width="100px"
                    >
                    <zj-timegran-date
                    v-model="dialog.editorBox2.form.data.may"
                     style="width: 150%;"
                    :timegranId="'DAY'"
                    :defaultOffset="-1"
                    :rules="dialog.editorBox2.form.may"
                    ></zj-timegran-date>
                </el-form-item>
            </el-col>
             </el-col>
         </el-row>
         </el-form>
         </div>
         <span
        slot="footer"
        class="dialog-footer"
            >
        <el-button
        :loading="loading"
        @click="dialog.editorBox2.show = false"
        >取 消</el-button>
        <el-button
        type="primary"
        @click="but_copy_plural"
        :loading="loading"
        >保 存</el-button>
    </span>
     </el-dialog>
    </div>
</template>

<script>
import { zCheckNumber1 } from '~/utils/validator.js'
import timegranDate from '~/components/zg/timegranDate.vue'
import {formatDate, XtcommonSummaries, getCookie} from '@/utils/util.js';
export default {
    name: 'outElectricity',
    components: {
        'zj-timegran-date': timegranDate
    },
    data () {
        let setDate = new Date();
        setDate.setDate(15);
        setDate.setMonth((setDate.getMonth() - 1));
        return {
            rowIndex: '',
            columnId: '',
            focusTarget: null,
            seqArr: [],
            editSetFlag: '',
            isCheck: false, // 是否为审核人
            filterForm: {
                show: true,
                data: {
                    show: false,
                    clock: '',
                    clockc: '',
                    workprocid: [],
                    location: [],
                    networkid: [],
                    state: '',
                    itemname: '',
                    searchtype: '0',
                    measureid: '',
                    productid: '',
                    may: '',
                    weightMonth: '',
                    weightDay: '',
                    unit: '',
                    jxdays: '',
                    createtime: '',
                    createman: '',
                    updatetime: '',
                    updateman: '',
                    memo: '',
                    startTime: '',
                    endTime: '',
                    kxf_weight: '',
                    yxf_weight: ''
                },
                rules: {
                },
                disabled: {
                    networkid: false
                }
            },
            dialog: {
                fRow: null,
                editorBox: {
                    show: false,
                    type: '',
                    form: {
                        default: {
                            workprocid: ''
                        },
                        data: {
                            workprocid: '',
                            unitid: '',
                            may: '',
                            productid: '',
                            weightDay: '',
                            weightMonth: '',
                            jxdays: '',
                            memo: '',
                            kxf_weight: '',
                            yxf_weight: '',
                            sqno: ''
                        },
                         rules: {
                             weightMonth: [
                                { required: true, message: '该项不能为空', trigger: 'change' },
                                { validator: zCheckNumber1, trigger: 'change' }
                            ],
                            weightDay: [
                                { required: true, message: '该项不能为空', trigger: 'change' },
                                { validator: zCheckNumber1, trigger: 'change' }
                            ],
                            workprocid: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                                ],
                            may: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                            ],
                            productid: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                                ],
                            unitid: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                                ],
                            jxdays: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                                ],
                            memo: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                                ],
                            kxf_weight: [
                                { required: true, message: '该项不能为空', trigger: 'change' },
                                { validator: zCheckNumber1, trigger: 'change' }
                            ],
                            yxf_weight: [
                                { required: true, message: '该项不能为空', trigger: 'change' },
                                { validator: zCheckNumber1, trigger: 'change' }
                            ]
                        }
                    }
                },
                editorBox2: {
                    show: false,
                    type: '',
                    form: {
                      data: {
                          may: ''
                      },
                      rules: {
                            may: [{ required: true, message: '该项不能为空', trigger: 'change' }]
                        }
                    }
                }
            },
            pageNum: 1,
            pageSize: 100,
            total: 0,
            singleTableHeight: 100,
            tableData: [
            ],
            loading: false,
            tableLoading: false,
            multipleSelection: [],
            tableFormDataObj: {},
            tableFormRules: {
                mintvalue: [
                    // { required: true, message: '该项不能为空', trigger: 'change' },
                    { validator: zCheckNumber1, trigger: 'change' }
                ],
                mendvalue: [
                    // { required: true, message: '该项不能为空', trigger: 'change' },
                    { validator: zCheckNumber1, trigger: 'change' }
                ],
                weightDay: [
                    { required: true, message: '该项不能为空', trigger: 'change' },
                    { validator: zCheckNumber1, trigger: 'change' }
                ],
                jxdays: [
                     { required: true, message: '该项不能为空', trigger: 'change' },
                     { validator: zCheckNumber1, trigger: 'change' }
                ],
                weightMonth: [
                     { required: true, message: '该项不能为空', trigger: 'change' },
                     { validator: zCheckNumber1, trigger: 'change' }
                ],
                wastage: [
                    { validator: zCheckNumber1, trigger: 'change' }
                ],
                secondVal: [
                    { validator: zCheckNumber1, trigger: 'change' }
                ],
                kxf_weight: [
                    { required: true, message: '该项不能为空', trigger: 'change' },
                     { validator: zCheckNumber1, trigger: 'change' }
                ],
                yxf_weight: [
                    { required: true, message: '该项不能为空', trigger: 'change' },
                     { validator: zCheckNumber1, trigger: 'change' }
                ],
                bz: [

                ]
            },
            nameObj: {
                state: {
                    obj: {
                        '0': {
                            name: '未编辑',
                            color: '#7a7a7a'
                        },
                        '1': {
                            name: '已编辑',
                            color: 'rgb(28, 111, 217)'
                        },
                        '2': {
                            name: '已审核',
                            color: 'red'
                        }
                    },
                    arr: [
                        {
                            id: '1',
                            name: '已编辑'
                        },
                        {
                            id: '2',
                            name: '已审核'
                        }
                    ]
                },
                type: {
                    obj: {
                        '0': '否',
                        '1': '是'
                    },
                    arr: [
                        {
                            id: '0',
                            name: '否'
                        },
                        {
                            id: '1',
                            name: '是'
                        }
                    ]
                },
                workprocid: {
                    obj: {},
                    arr: []
                },
                location: {
                    obj: {},
                    arr: [],
                    showDataArr: []
                },
                locateid: {
                    obj: {},
                    arr: []
                },
                networkid: {
                    obj: {},
                    arr: []
                },
                userId: {
                    obj: {},
                    arr: []
                },
                unitid: {
                    obj: {},
                    arr: [],
                    defaults: ''
                }
            },
            butPrivilege: {
                QUERY: false,
                PUT: false,
                CHECK: false,
                UNDOCHECK: false
            },
            loginName: getCookie('loginName')
        }
    },
    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);
        });
        // 接收路由参数
        if (that.$route.query.networkid) {
            that.filterForm.disabled.networkid = true;
            that.filterForm.data.networkid = that.$route.query.networkid.split(',');
        }
        // 当有审核与取消审核权限时，默认其为审核人，审核人无法修改数据
        if (that.butPrivilege.CHECK || that.butPrivilege.UNDOCHECK) {
            that.isCheck = true;
        }
        // 管理员在这里录入数据
        if (that.loginName === 'admin' && that.filterForm.disabled.networkid) {
            that.isCheck = false;
        }
        that.getNodeData();
        that.getUnitIdData();
        that.getLocateIdData();
    },
    methods: {
        //  计算树区域高度
        getRoleHeight (dom) {
            return window.innerHeight - dom.offsetTop;
        },
        // 自定义的表格合计方法：只给指定列进行合计
        getSummaries (param) {
            const prop = ['apportvalue', 'realvalue', 'wastage', 'weightDay', 'yhj']; // 合计列绑定的prop
            return XtcommonSummaries(param, prop);
        },
        // 获取工序列表
        getNodeData () {
            let that = this
            let url = 'pass/ems/v1/trmworkprocs/getIdAndName?issettle=1';
            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;
                        that.connn();
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
        connn () {
            let that = this;
            if (!that.filterForm.data.networkid || that.filterForm.data.networkid.length === 0) {
                that.nameObj.location.showDataArr = that.nameObj.workprocid.arr;
            } else {
                let url = 'pass/ems/v1/emsprodplanmonths/getWorkprocs'
                that.axios.get(url)
                    .then(function (res) {
                        if (res.code === '0') {
                            let arr = [];
                            for (let item of res.data) {
                                arr.push({
                                    id: item.id,
                                    name: item.name
                                })
                            }
                            that.nameObj.location.showDataArr = arr;
                        } else {
                            that.$message.error(res.message);
                        }
                    });
            }
        },
        dataSave () {
            let that = this;
            let SubmitData = [];
            SubmitData.push({
                productid: that.dialog.editorBox.form.data.productid,
                workprocid: that.dialog.editorBox.form.data.workprocid.toString(),
                may: that.dialog.editorBox.form.data.may,
                weightMonth: that.dialog.editorBox.form.data.weightMonth,
                weightDay: that.dialog.editorBox.form.data.weightDay,
                unit: that.dialog.editorBox.form.data.unitid,
                jxdays: that.dialog.editorBox.form.data.jxdays,
                memo: that.dialog.editorBox.form.data.memo,
                kxf_weight: that.dialog.editorBox.form.data.kxf_weight,
                yxf_weight: that.dialog.editorBox.form.data.yxf_weight
            });
            that.$refs['dialog_form'].validate((valid) => {
               if (valid) {
                        that.loading = true;
                        that.axios.post('pass/ems/v1/emsprodplanmonths/', SubmitData, {
                            contentType: 'application/json'
                        })
                            .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;
                            });
                }
            });
        },
        but_copy_plural () {
            let that = this;
            let SubmitData = [];
            for (let key in that.tableFormDataObj) {
                SubmitData.push({
                    productid: that.tableFormDataObj[key].productid,
                    workprocid: that.tableFormDataObj[key].workprocid,
                    may: that.dialog.editorBox2.form.data.may,
                    networkid: that.tableFormDataObj[key].networkid,
                    weightMonth: that.tableFormDataObj[key].weightMonth,
                    weightDay: that.tableFormDataObj[key].weightDay,
                    unit: that.tableFormDataObj[key].unit,
                    jxdays: that.tableFormDataObj[key].jxdays,
                    createtime: that.tableFormDataObj[key].createtime,
                    createman: that.tableFormDataObj[key].createman,
                    updatetime: that.tableFormDataObj[key].updatetime,
                    updateman: that.tableFormDataObj[key].updateman,
                    state: that.tableFormDataObj[key].state,
                    memo: that.tableFormDataObj[key].memo,
                    kxf_weight: that.tableFormDataObj[key].kxf_weight,
                    yxf_weight: that.tableFormDataObj[key].yxf_weight
                            });
                        }
                   that.$refs['dialog_form2'].validate((valid) => {
                      if (valid) {
                        that.loading = true;
                        that.axios.post('pass/ems/v1/emsprodplanmonths/', SubmitData, {
                             contentType: 'application/json'
                        })
                            .then(function (res) {
                                if (res.code === '0') {
                                    that.$message({
                                        message: '复制成功',
                                        type: 'success'
                                    });
                                    that.getTableData();
                                    that.dialog.editorBox2.show = false;
                                } else {
                                    that.$message.error(res.message);
                                }
                                that.loading = false;
                            }).catch(function () {
                                that.loading = false;
                            });
                }
                   });
        },
        // 获取位置
        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);
                    }
                });
        },
        // 获取表格中的数据
        getTableData (pageNum) {
            let that = this,
                params = {},
                pData = {
                    id: that.filterForm.data.id,
                    productid: that.filterForm.data.productid,
                    workprocid: that.filterForm.data.workprocid.toString(),
                    networkid: that.filterForm.data.networkid.toString(),
                    weightMonth: that.filterForm.data.weightMonth,
                    weightDay: that.filterForm.data.weightDay,
                    unit: that.filterForm.data.unit,
                    state: that.filterForm.data.state,
                    jxdays: that.filterForm.data.jxdays,
                    createtime: that.filterForm.data.createtime,
                    createman: that.filterForm.data.createman,
                    updatetime: that.filterForm.data.updatetime,
                    updateman: that.filterForm.data.updateman,
                    memo: that.filterForm.data.memo,
                    startTime: that.filterForm.data.may[0],
                    endTime: that.filterForm.data.may[1]
                };
                for (let key in pData) {
                    if (pData[key]) {
                        params[key] = pData[key];
                    }
                }
            that.pageNum = pageNum || that.pageNum;
            that.tableLoading = true;
            let url = 'pass/ems/v1/emsprodplanmonths/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize;
            that.axios.get(url, {
                params: params
            })
                .then(function (res) {
                    if (res.code === '0') {
                        let arr = [];
                        for (let i = 0; i < res.data.list.length; i++) {
                            let item = res.data.list[i];
                            arr.push({
                                seq: i,
                                id: item.id,
                                productid: item.productid,
                                workprocid: item.workprocid,
                                may: item.may,
                                networkid: item.networkid,
                                weightMonth: item.weightMonth,
                                weightDay: item.weightDay,
                                unit: item.unit,
                                jxdays: item.jxdays,
                                createtime: item.createtime,
                                createman: item.createman,
                                updatetime: item.updatetime,
                                updateman: item.updateman,
                                memo: item.memo,
                                state: item.state,
                                kxf_weight: item.kxf_weight,
                                yxf_weight: item.yxf_weight,
                                sqno: item.sqno
                            });
                        }
                        that.total = res.data.total;
                        that.tableData = arr;
                        that.getAdds();
                    } else {
                        that.$message.error(res.message);
                    }
                    that.$nextTick(() => {
                        setTimeout(() => {
                            that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 46;
                        }, 1);
                    });
                    that.tableLoading = false;
                }).catch(function () {
                    that.tableLoading = false;
                });
        },
        // 获取表格中的数据
        getTableDataEdit () {
            let that = this,
                params = {},
                pData = {
                    id: that.filterForm.data.id,
                    productid: that.filterForm.data.productid,
                    workprocid: that.filterForm.data.workprocid.toString(),
                    may: that.filterForm.data.clockc[0],
                    networkid: that.filterForm.data.networkid.toString(),
                    weightMonth: that.filterForm.data.weightMonth,
                    weightDay: that.filterForm.data.weightDay,
                    unit: that.filterForm.data.unit,
                    state: that.filterForm.data.state,
                    jxdays: that.filterForm.data.jxdays,
                    createtime: that.filterForm.data.createtime,
                    createman: that.filterForm.data.createman,
                    updatetime: that.filterForm.data.updatetime,
                    updateman: that.filterForm.data.updateman,
                    memo: that.filterForm.data.memo
                };
                for (let key in pData) {
                    if (pData[key]) {
                        params[key] = pData[key];
                    }
                }
            that.tableLoading = true;
            let url = 'pass/ems/v1/emsprodplanmonths/getDateEditForPage/?pageNum=1&pageSize=' + that.pageSize;
            that.axios.get(url, {
                params: params
            })
                .then(function (res) {
                    if (res.code === '0') {
                        let arr = [];
                        for (let i = 0; i < res.data.list.length; i++) {
                            let item = res.data.list[i];
                            arr.push({
                                seq: i,
                                id: item.id,
                                productid: item.productid,
                                workprocid: item.workprocid,
                                may: item.may,
                                state: item.state,
                                networkid: item.networkid,
                                weightMonth: item.weightMonth,
                                weightDay: item.weightDay,
                                unit: item.unit,
                                jxdays: item.jxdays,
                                createtime: item.createtime,
                                createman: item.createman,
                                updatetime: item.updatetime,
                                updateman: item.updateman,
                                memo: item.memo
                            });
                        }
                        that.total = res.data.total;
                        that.tableData = arr;
                        that.getAdds();
                    } else {
                        that.$message.error(res.message);
                    }
                    that.$nextTick(() => {
                        setTimeout(() => {
                            that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 46;
                        }, 1);
                    });
                    that.tableLoading = false;
                }).catch(function () {
                    that.tableLoading = false;
                });
        },
        // 合并相同的用电地点
        arraySpanMethod ({ row, column, rowIndex, columnIndex }) {
            let that = this;
            let tableData = this.$refs.singleTable.tableData
            let c1 = row.workprocid;
            let c2 = row.location;
            let c3 = row.workshop;
            let c4 = row.clock;
            let c5 = row.clocke;
            let rowsPan = 1;
            // let adds = this.$refs.singleTable.tableData[rowIndex].realvalue;
            if (column['property'] === 'adds') {
                if (rowIndex > 0 && c1 === tableData[rowIndex - 1].workprocid && c2 === tableData[rowIndex - 1].location &&
                c3 === tableData[rowIndex - 1].workshop && c4 === tableData[rowIndex - 1].clock && c5 === tableData[rowIndex - 1].clocke) {
                    return {
                        rowspan: 0,
                        colspan: 0
                    };
                };
                while (tableData[rowIndex + rowsPan] && c1 === tableData[rowIndex + rowsPan].workprocid && c2 === tableData[rowIndex + rowsPan].location &&
                    c3 === tableData[rowIndex + rowsPan].workshop && c4 === tableData[rowIndex + rowsPan].clock && c5 === tableData[rowIndex + rowsPan].clocke) {
                    rowsPan += 1
                }
                return {
                    rowspan: rowsPan,
                    colspan: 1
                };
            }
        },
        but_add () {
            let that = this;
            that.dialog.editorBox.form.data.productid = '';
            that.dialog.editorBox.form.data.workprocid = '';
            that.dialog.editorBox.form.data.weightMonth = '';
            that.dialog.editorBox.form.data.weightDay = '';
            that.dialog.editorBox.form.data.unitid = '';
            that.dialog.editorBox.form.data.jxdays = '';
            that.dialog.editorBox.form.data.memo = '';
            that.dialog.editorBox.form.data.kxf_weight = '';
            that.dialog.editorBox.form.data.yxf_weight = '';
            that.dialog.editorBox.form.data.memo = '';
            that.dialog.editorBox.show = true;
             setTimeout(() => {
                that.$refs['dialog_form'].clearValidate();
            }, 100);
        },
        but_copy () {
            let that = this;
            if (that.multipleSelection.length > 0) {
                that.$refs['dialog_form_arr'].validate((valid, obj) => {
                if (valid) {
                    that.dialog.editorBox2.show = true;
                setTimeout(() => {
                    that.$refs['dialog_form2'].clearValidate();
            }, 100);
                }
                });
            } else {
                this.$message.error('至少要选择一条数据');
            }
      },
        // 改变表格显示条数
        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.disabled || !that.filterForm.disabled[key]) {
                    if (that.filterForm.data[key] instanceof Array) {
                        that.filterForm.data[key] = [];
                    } else {
                        that.filterForm.data[key] = '';
                    }
                }
            }
            that.getTableData(1);
        },
        keyDown (event1, disabledFlag) {
            let tdTarget = event1.target;
            let _this = this;
            while (tdTarget.tagName !== 'TD') {
                tdTarget = tdTarget.parentElement;
            }
            // 如果按下键盘下键或者回车键
            if (event.keyCode === 40 || event.keyCode === 13) {
                let index = parseInt(this.rowIndex);
                // index++;
                if (index !== this.seqArr[this.seqArr.length - 1]) {
                    for (let i = 0; i < this.seqArr.length; i++) {
                        if (index === this.seqArr[i]) {
                        index = this.seqArr[i + 1];
                        break;
                        }
                    }
                }
                this.editSetFlag = index + this.columnId;
                let id = '#' + this.editSetFlag;
                this.$nextTick(() => {
                    $(id).click();
                });
            } else if (event.keyCode === 38) { // 键盘上键
                let index = parseInt(this.rowIndex);
                if (index !== this.seqArr[0]) {
                    for (let i = 0; i < this.seqArr.length; i++) {
                        if (index === this.seqArr[i]) {
                        index = this.seqArr[i - 1];
                        break;
                        }
                    }
                }
                this.editSetFlag = index + this.columnId;
                let id = '#' + this.editSetFlag;
                this.$nextTick(() => {
                    $(id).click();
                });
            } else if (event.keyCode === 37) { // 键盘左键
                $(tdTarget).prevAll().find('input:text').last().click();
            } else if (event.keyCode === 39) { // 键盘右键
                $(tdTarget).nextAll().find('input').eq(0).click();
            }
        },
        // 只允许对未接受的数据进行操作
        checkboxT (row, index) {
            if (this.isCheck) {
                return false;
            } else {
                return true;
            }
        },
        // 获取标准计量单位
        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);
                    }
                });
        },
        handleSelectionChange (val) {
            let that = this;
            let tableFormDataObj = {};
            let arr = [];
            for (let item of val) {
                arr.push(item.seq);
            }
            this.seqArr = arr.sort(sortNumber);
            for (let item of that.tableData) {
                item.isSelection = false;
            }
            for (let item of val) {
                let obj = {};
                let xId = item.seq;
                if (that.tableFormDataObj[xId]) {
                    // 如果已存在该数据则使用该数据
                    tableFormDataObj[xId] = that.tableFormDataObj[xId];
                } else {
                    // 负责则从对应行中获取行内原数据
                    for (let key in item) {
                        obj[key] = item[key];
                    }
                    item.realvalue = (!isNaN(Number(item.apportvalue)) && !isNaN(Number(item.wastage))) ? Number(item.apportvalue) + Number(item.wastage) - Number(item.secondVal) : item.realvalue;
                    tableFormDataObj[xId] = obj;
                }
                item.isSelection = true;
            }
            for (let item of that.tableData) {
                if (item.isSelection === false) {
                    item.realvalue = (!isNaN(Number(item.apportvalue)) && !isNaN(Number(item.wastage))) ? Number(item.apportvalue) + Number(item.wastage) - Number(item.secondVal) : item.realvalue;
                }
            }
            that.tableFormDataObj = tableFormDataObj;
            that.multipleSelection = val;
            this.getAdds();
        },
        // 当上月底码发生改变时计算抄度与实际电量
        getApportValue (seq, value, rowIndex, event) {
            let that = this;
            if (!isNaN(Number(value))) {
                if (!isNaN(Number(that.tableFormDataObj[seq].mintvalue)) && !isNaN(Number(that.tableFormDataObj[seq].mendvalue)) && that.tableFormDataObj[seq].mintvalue !== null && that.tableFormDataObj[seq].mendvalue !== null) {
                    let poor = that.floatComputed(Number(that.tableFormDataObj[seq].mendvalue), Number(that.tableFormDataObj[seq].mintvalue), '-');
                    that.tableFormDataObj[seq].apportvalue = that.floatComputed(poor, Number(that.tableFormDataObj[seq].mods), '*').toFixed(0);
                    let rv1 = that.floatComputed(Number(that.tableFormDataObj[seq].apportvalue), Number(that.tableFormDataObj[seq].wastage), '+');
                    that.tableFormDataObj[seq].realvalue = that.floatComputed(rv1, Number(that.tableFormDataObj[seq].secondVal), '-').toFixed(0);
                    that.showRealValue(rowIndex, that.tableFormDataObj[seq].realvalue);
                }
            }
        },
        // 手动修改抄度后计算实际电量
        chnageApportvalue (seq, value, rowIndex) {
            let that = this;
            if (!isNaN(Number(value)) && !isNaN(Number(that.tableFormDataObj[seq].wastage))) {
                that.tableFormDataObj[seq].realvalue = that.floatComputed(Number(value), Number(that.tableFormDataObj[seq].wastage), '+').toFixed(0);
            }
            that.showRealValue(rowIndex, that.tableFormDataObj[seq].realvalue);
        },
        // 手动修改损耗后计算实际电量
        chnageWastage (seq, value, rowIndex) {
            let that = this;
            if (!isNaN(Number(value)) && !isNaN(Number(that.tableFormDataObj[seq].apportvalue)) && that.tableFormDataObj[seq].apportvalue !== null) {
                let rv1 = that.floatComputed(Number(value), Number(that.tableFormDataObj[seq].apportvalue), '+');
                that.tableFormDataObj[seq].realvalue = that.floatComputed(rv1, Number(that.tableFormDataObj[seq].secondVal), '-').toFixed(0);
                that.showRealValue(rowIndex, that.tableFormDataObj[seq].realvalue);
            }
        },
        // 手动修改二次转供电后计算实际电量
        chnageSecondVal (seq, value, rowIndex) {
            let that = this;
            if (!isNaN(Number(value)) && !isNaN(Number(that.tableFormDataObj[seq].apportvalue)) && that.tableFormDataObj[seq].apportvalue !== null) {
                let val1 = that.floatComputed(Number(that.tableFormDataObj[seq].apportvalue), Number(that.tableFormDataObj[seq].wastage), '+');
                that.tableFormDataObj[seq].realvalue = that.floatComputed(val1, Number(value), '-').toFixed(0);
                that.showRealValue(rowIndex, that.tableFormDataObj[seq].realvalue);
            }
        },
        // 统计合计值
        getAdds () {
            let that = this;
            let wlarr = [];
            for (var i = 0; i < that.tableData.length; i++) {
               wlarr.push(that.tableData[i].workprocid + '-' + that.tableData[i].location + '-' + that.tableData[i].workshop + '-' + that.tableData[i].clock + '-' + that.tableData[i].clocke);
            }
            let wls = [...new Set(wlarr)]
            let arrs = [];
            for (let wl of wls) {
                let rxj = 0;
                let yhj = 0;
                for (let item of that.tableData) {
                    if (wl === item.workprocid + '-' + item.location + '-' + item.workshop + '-' + item.clock + '-' + item.clocke) {
                        rxj = that.floatComputed(Number(item.weightDay), rxj, '+');
                        yhj = that.floatComputed(Number(item.weightMonth), yhj, '+');
                    }
                }
                for (let i = 0; i < that.tableData.length; i++) {
                    if (wl === that.tableData[i].workprocid + '-' + that.tableData[i].location + '-' + that.tableData[i].workshop + '-' + that.tableData[i].clock + '-' + that.tableData[i].clocke) {
                        that.tableData[i].rxj = rxj;
                        that.tableData[i].yhj = yhj;
                    }
                }
            }
        },
        // 展示实际电量
        showRealValue (rowIndex, value) {
            let that = this;
            for (let i = 0; i < that.tableData.length; i++) {
                if (i === rowIndex) {
                    that.tableData[i].realvalue = value;
                }
            }
            this.getAdds();
        },
        // 批量修改
        but_edit_plural () {
            let that = this;
            if (that.multipleSelection.length > 0) {
                that.$refs['dialog_form_arr'].validate((valid, obj) => {
                    if (valid) {
                        let SubmitData = [];
                        for (let key in that.tableFormDataObj) {
                            SubmitData.push({
                                id: that.tableFormDataObj[key].id,
                                productid: that.tableFormDataObj[key].productid,
                                workprocid: that.tableFormDataObj[key].workprocid,
                                may: that.tableFormDataObj[key].may,
                                networkid: that.tableFormDataObj[key].networkid,
                                weightMonth: that.tableFormDataObj[key].weightMonth.toString(),
                                weightDay: that.tableFormDataObj[key].weightDay.toString(),
                                unit: that.tableFormDataObj[key].unit,
                                jxdays: that.tableFormDataObj[key].jxdays,
                                createtime: that.tableFormDataObj[key].createtime,
                                createman: that.tableFormDataObj[key].createman,
                                updatetime: that.tableFormDataObj[key].updatetime,
                                updateman: that.tableFormDataObj[key].updateman,
                                state: that.tableFormDataObj[key].state,
                                memo: that.tableFormDataObj[key].memo,
                                kxf_weight: that.tableFormDataObj[key].kxf_weight,
                                yxf_weight: that.tableFormDataObj[key].yxf_weight,
                                sqno: that.tableFormDataObj[key].sqno
                            });
                        }
                        that.loading = true;
                        that.axios.put('pass/ems/v1/emsprodplanmonths/batchupdate', SubmitData)
                            .then(function (res) {
                                if (res.code === '0') {
                                    that.$message({
                                        message: '修改成功',
                                        type: 'success'
                                    });
                                    that.getTableData();
                                    that.dialog.editorBox.show = false;
                                } else {
                                    that.$message.error(res.message);
                                }
                                that.loading = false;
                            }).catch(function () {
                                that.loading = false;
                            });
                        }
                });
            } else {
                this.$message.error('至少要选择一条数据');
            }
        },
        // 批量删除
        but_del_plural () {
            let that = this;
            if (that.multipleSelection.length > 0) {
                let SubmitData = [];
                for (let item of that.multipleSelection) {
                    if (!item.id) {
                        this.$message.error('数据未保存，请点击"查询"');
                        return;
                    }
                    SubmitData.push({
                        id: item.id,
                        sqno: item.sqno
                    });
                }
                that.$confirm('是否删除已选数据?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    state: 'warning'
                }).then(() => {
                    that.axios.delete('pass/ems/v1/emsprodplanmonths/delete', {
                        data: SubmitData,
                        contentType: 'application/json;charset=UTF-8'
                    })
                        .then(function (res) {
                            if (res.code === '0') {
                                that.$message({
                                    message: '删除成功',
                                    type: 'success'
                                });
                                that.getTableData();
                            } else {
                                that.$message.error(res.message);
                            }
                        }).catch(function () {
                        });
                }).catch(() => {
                });
            } else {
                this.$message.error('至少要选择一条数据');
            }
        },
        upState (state = '2') {
            let that = this;
            let dataArr = [];
            for (let item of that.multipleSelection) {
                if (item.state !== state) {
                    dataArr.push(item);
                }
            }
            if (dataArr.length > 0) {
                that.$confirm('本次将要' + (state === '2' ? '审核' : '撤销审核') + dataArr.length + '条数据，是否确定?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    state: 'warning'
                }).then(() => {
                    let SubmitData = [];
                    for (let item of dataArr) {
                        SubmitData.push({
                            state: state,
                            id: item.id
                        });
                    }
                    that.loading = true;
                    that.axios.put('pass/ems/v1/trmtransfereactvalues/batchcheck2', SubmitData)
                        .then(function (res) {
                            if (res.code === '0') {
                                that.$message({
                                    message: (state === '2' ? '审核' : '撤销') + '成功',
                                    type: 'success'
                                });
                                that.getTableData();
                            } else {
                                that.$message.error(res.message);
                            }
                            that.loading = false;
                        }).catch(function () {
                            that.loading = false;
                        });
                }).catch(() => {
                });
            } else {
                if (that.multipleSelection.length > 0) {
                    this.$message.error('没有需要' + (state === '2' ? '审核' : '撤销') + '的数据');
                } else {
                    this.$message.error('至少要选择一条数据');
                }
            }
        },
        tableRowClassName ({row, rowIndex}) {
            // 把每一行的索引放进row
            row.index = rowIndex;
        },
        cellClick (row, column, cell, event) {
            let _this = this;
            this.rowIndex = row.index;
            this.columnId = column.id;
            _this.editSetFlag = row.index + column.id;
            _this.focusTarget = event.target;
            while (_this.focusTarget.tagName !== 'TD') {
                _this.focusTarget = _this.focusTarget.parentElement;
            }
            _this.$nextTick(() => {
                let target = this.focusTarget;
                $(target).find('input').focus();
            });
        }
    }
}
function sortNumber (a, b) {
  return a - b
}
</script>

<style lang="less">
.outElectricity{
    min-width: 700px;
    height: 100%;
    .box {
        height: 100%;
        padding: 15px 15px 0 15px;
        .box-top {
            .el-form-item {
                margin-bottom: 7px;
            }
            .box-top-gjl {
                overflow: hidden;
                padding: 7px 0;
                border-top: 1px solid #ccc;
            }
        }
        .rowDisable td {
            color: #6bb025 !important;
        }
        .el-table .el-table__row {
            height: 35px;
        }
        .el-table__body .el-form-item--mini.el-form-item {
            margin: 0px;
            .error {
                overflow: hidden;
                color: #f56c6c;
                font-size: 12px;
                line-height: 1;
            }
        }
    }
    .color_no {
        color: #7a7a7a;
    }
    .color_yes {
        color: #1a9f17;
    }
    .cnspicuous .el-checkbox__input.is-disabled .el-checkbox__inner {
        background-color: #dcdfe6;
        border-color: #babbbf;
    }
}
</style>
