<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="filterForm.data.timegranid"
                                    :oneFoo="getTableData"
                                    :custom ="1"
                                ></zj-timegran-date>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                         <el-form-item label="钢种">
                            <el-select
                            filterable clearable
                            collapse-tags
                            v-model="filterForm.data.grades"
                            multiple
                            placeholder=""
                            style="width: 100%;"
                            >
                            <el-option
                            v-for="item of  nameObj.grades.arr"
                            :key="item.id"
                            :value="item.name"
                            :label="item.name"
                            ></el-option>
                            </el-select>
                            </el-form-item>
                        </el-col>
                      <el-col :span="6"
                      >
                          <el-form-item label="规格">
                            <el-select
                            filterable clearable
                            collapse-tags
                            v-model="filterForm.data.specifications"
                            multiple
                            placeholder=""
                            style="width: 100%;"
                            >
                            <el-option
                            v-for="item of  nameObj.specifications.arr"
                            :key="item.id"
                            :value="item.name"
                            :label="item.name"
                            ></el-option>
                            </el-select>
                            </el-form-item>
                      </el-col>
                      <el-col :span="3"
                      >
                          <el-form-item label="状态">
                            <el-select
                            filterable clearable
                            v-model="filterForm.data.state"
                            placeholder=""
                            style="width: 100%;"
                            >
                            <el-option
                            v-for="item of  nameObj.state.arr"
                            :key="item.id"
                            :value="item.id"
                            :label="item.name"
                            ></el-option>
                            </el-select>
                            </el-form-item>
                      </el-col>
                      <el-col :span="3"
                      >
                          <el-form-item label="订单类型">
                            <el-select
                            filterable clearable
                            v-model="filterForm.data.tag"
                            placeholder=""
                            style="width: 100%;"
                            >
                            <el-option
                            v-for="item of  nameObj.tag.arr"
                            :key="item.id"
                            :value="item.id"
                            :label="item.name"
                            ></el-option>
                            </el-select>
                            </el-form-item>
                      </el-col>
                      <!-- <el-col :span="6"
                      v-if="filterForm.data.gx==='XG'"
                      >
                          <el-form-item label="宽度*高度">
                            <el-select
                            filterable clearable
                            v-model="filterForm.data.lengthTimesWidth"
                            multiple
                            placeholder=""
                            style="width: 100%;"
                            >
                            <el-option
                            v-for="item of  nameObj.lengthTimeswidth.arr"
                            :key="item.id"
                            :value="item.name"
                            :label="item.name"
                            ></el-option>
                            </el-select>
                            </el-form-item>
                      </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.ADD && !isCheck"
                                >新增</el-button>
                                <el-upload
                                  style="display: inline-block;margin-left:5px"
                                  action=""
                                  :on-progress='beforeUpload'
                                  :multiple='false'
                                  :limit="1"
                                  accept=".xls"
                                  :show-file-list="false"
                                  ><el-button
                                  size="mini"
                                  type="primary"
                                  :loading='loading'>导入</el-button>
                                  </el-upload>
                                  <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-edit-outline"
                                    @click="but_copy()"
                                    :loading="loading"
                                    v-if="butPrivilege.PUT && !isCheck"
                                >复制</el-button>
                                <!-- <el-button
                                     type="primary"
                                     size="mini"
                                     icon="el-icon-add-outline"
                                    @click="issue(1)"
                                    :loading="loading"
                                >下发</el-button>
                                <el-button
                                   type="primary"
                                   size="mini"
                                   icon="el-icon-add-outline"
                                   @click="issue(0)"
                                   :loading="loading"
                                >取消下发</el-button> -->
                                 <el-button
                                     type="primary"
                                     size="mini"
                                     icon="el-icon-add-outline"
                                    @click="submitaudit()"
                                    :loading="loading"
                                >提交审核</el-button>
                                <el-button
                                    class="button"
                                    type="danger"
                                    size="mini"
                                    icon="el-icon-delete"
                                    v-if="butPrivilege.DELETE && !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="40"
                            align="center"
                            fixed="left"
                            class-name="cnspicuous"
                        ></el-table-column>
                        <el-table-column
                        sortable
                            prop="id"
                            label="国贸计划编号"
                            fixed="left"
                            align="center"
                            width="120px"
                            :show-overflow-tooltip="true"
                        ></el-table-column>
                        <el-table-column
                        sortable
                            prop="jhTime"
                            label="排产日期"
                            align="center"
                            fixed="left"
                            width="88px"
                            :show-overflow-tooltip="true"
                        ></el-table-column>
                        <el-table-column
                        sortable
                            prop="deliveryDate"
                            label="交货日期"
                            align="center"
                            fixed="left"
                            width="88px"
                            :show-overflow-tooltip="true"
                        ></el-table-column>
                        <el-table-column
                        sortable
                            prop="state"
                            label="状态"
                            align="center"
                            fixed="left"
                            width="88px"
                            :show-overflow-tooltip="true"
                        >
                         <template slot-scope="scope">
                                <span
                                    :style="{color: nameObj.state.obj[scope.row.state] ? nameObj.state.obj[scope.row.state].color : ''}"
                                >{{ nameObj.state.obj[scope.row.state] ? nameObj.state.obj[scope.row.state].name : scope.row.state }}</span>
                        </template>
                        </el-table-column>
                        <el-table-column
                        sortable
                            prop="tag"
                            label="订单类型"
                            align="center"
                            fixed="left"
                            width="88px"
                            :show-overflow-tooltip="true"
                        >
                         <template slot-scope="scope">
                                <span
                                    :style="{color: nameObj.tag.obj[scope.row.tag] ? nameObj.tag.obj[scope.row.tag].color : ''}"
                                >{{ nameObj.tag.obj[scope.row.tag] ? nameObj.tag.obj[scope.row.tag].name : scope.row.tag }}</span>
                        </template>
                        </el-table-column>
                        <el-table-column
                        sortable
                            prop="grades"
                            label="钢种"
                            align="center"
                            fixed="left"
                            width="106px"
                            :show-overflow-tooltip="true"
                        >
                        <template slot-scope="scope">
                                    <el-form-item
                                    :prop="scope.row.seq + '.grades'"
                                    v-if="!isCheck && scope.row.isSelection"
                                    :rules="tableFormRules.grades"
                                  >
                                    <el-select
                                    allow-create
                                    filterable
                                    clearable
                                    v-model="tableFormDataObj[scope.row.seq].grades"
                                    placeholder=""
                                    >
                                    <el-option
                                    v-for="item of nameObj.grades.arr"
                                    :key="item.id"
                                    :value="item.name"
                                    :label="item.name"
                                    ></el-option>
                                    </el-select>
                                </el-form-item>
                                <span v-else>{{ nameObj.grades.obj[scope.row.grades] ? nameObj.grades.obj[scope.row.grades].name : scope.row.grades }}</span>
                                </template>
                        </el-table-column>
                        <el-table-column
                        sortable
                            prop="specifications"
                            label="规格"
                            fixed="left"
                            align="center"
                            width="120px"
                            :show-overflow-tooltip="true"
                        >
                        <template slot-scope="scope">
                                <el-form-item
                                  :prop="scope.row.seq + '.specifications'"
                                   v-if=" !isCheck && scope.row.isSelection"
                                   :rules="tableFormRules.specifications"
                                  >
                                    <el-select
                                    allow-create
                                    filterable
                                    clearable
                                    v-model="tableFormDataObj[scope.row.seq].specifications"
                                    placeholder=""
                                    >
                                    <el-option
                                    v-for="item of nameObj.specifications.arr"
                                    :key="item.id"
                                    :value="item.name"
                                    :label="item.name"
                                    ></el-option>
                                    </el-select>
                                </el-form-item>
                                <span v-else>{{ nameObj.specifications.obj[scope.row.specifications] ? nameObj.specifications.obj[scope.row.specifications].name : scope.row.specifications }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column
                        sortable
                            prop="lengths"
                            label="长度(mm)"
                            fixed="left"
                            align="center"
                            width="90px"
                            :show-overflow-tooltip="true"
                            v-if="filterForm.data.gx!='GX'"
                        >

                        <template slot-scope="scope">
                                <el-form-item
                                    v-if="!isCheck && scope.row.isSelection"
                                    :prop="scope.row.seq + '.lengths'"
                                    :rules="tableFormRules.lengths"
                                >
                                    <el-input clearable
                                        style="width: 100%;"
                                        @keydown.native="keyDown" :id="scope.$index + scope.column.id"
                                        v-model="tableFormDataObj[scope.row.seq].lengths"
                                        @change="chnageApportvalue(scope.row.seq, tableFormDataObj[scope.row.seq].lengths, scope.$index)"
                                    ></el-input>
                                </el-form-item>
                                <span v-else>{{scope.row.lengths}}</span>
                        </template>
                        </el-table-column>
                        <el-table-column
                             sortable
                            prop="teshu"
                            label="客户是否有特殊要求"
                            align="center"
                            width="140px"
                            :show-overflow-tooltip="true"
                             v-if="this.filterForm.data.workproc_type==='AT2004'"
                        >
                        </el-table-column>

                        <el-table-column
                         align="center"
                         label="添加化学成分信息"
                         width="110px"
                         :show-overflow-tooltip="true"
                         v-if="filterForm.data.gx==='LG'"
                        >
                        <template  slot-scope="scope">
                        <el-popover
                            placement="top"
                            title="添加化学成分信息"
                            width="600"
                            :ref="'popover-' + scope.row.id"
                            trigger="click"
                            @show="gethxcfDate1(scope.row)"
                        >
                              <div style="float:left">
                                 <el-button
                                 class="button"
                                 type="primary"
                                 size="mini"
                                 icon="el-icon-edit-outline"
                                 @click="addhxcf(scope.row)"
                                 :loading="loading"
                                 >
                                 保存
                                 </el-button>
                             </div>
                              <div>
                                    <div class="box-bottom">
                                        <P><el-button class="el-icon-plus" style="float:right;margin-top:34px;padding:9px 20px;margin-right: 4px" type="min" @click.prevent="addRow(scope.row)"></el-button></P>
                                        <p><el-button class="el-icon-minus" style="position:relative;top:34px;left:380px;padding:9px 20px" type="min" @click.prevent="delData(scope.row)"></el-button></p>
                                        <el-form
                                        size="mini"
                                        ref="dialog_form_hxcf"
                                        label-width="0px"
                                        :model="hxcfDataObj"
                                        >
                                        <el-table
                                            id="multipleTable"
                                            ref="multipleTable"
                                            :data="gridData"
                                            tooltip-effect="dark"
                                            v-loading="gridDataLoading"
                                            border
                                            stripe
                                            style="width: 80%"
                                            @selection-change="selectRow"
                                            @cell-click="cellClickHxcf"
                                            >
                                            <el-table-column
                                                type="selection"
                                                width="40"
                                                align="center"
                                                fixed="left"
                                                class-name="cnspicuous"
                                            ></el-table-column>
                                            <el-table-column
                                                sortable
                                                label="成分信息"
                                                prop="chemcode"
                                                align="center"
                                                min-width="100px"
                                                :show-overflow-tooltip="true"
                                             >
                                               <template slot-scope="scope">
                                                   <el-form-item
                                                    v-if="scope.row.isSelection"
                                                    :prop="scope.row.seq + '.chemcode'"
                                                    :rules="hxcfRules.chemcode"
                                                   >
                                                   <el-select
                                                   filterable
                                                   collapse-tags
                                                   v-model="hxcfDataObj[scope.row.seq].chemcode"
                                                   >
                                                   <el-option
                                                    v-for="item of nameObj.hxcf.arr"
                                                    :key="item.id"
                                                    :value="item.id"
                                                    :label="item.name"
                                                    ></el-option>
                                                   </el-select>
                                                   </el-form-item>
                                                   <span v-else>{{nameObj.hxcf.obj[scope.row.chemcode] ? nameObj.hxcf.obj[scope.row.chemcode].name : scope.row.chemcode }}</span>
                                               </template>
                                            </el-table-column>
                                            <el-table-column sortable min-width="100" prop="nkstdmin" align="center" label="下限值">
                                            <template slot-scope="scope">
                                                <el-form-item
                                                 v-if="scope.row.isSelection"
                                                 :prop="scope.row.seq + '.nkstdmin'"
                                                 :rules="hxcfRules.nkstdmin"
                                                >
                                                    <el-input
                                                    style="width: 100%;"
                                                    v-model="hxcfDataObj[scope.row.seq].nkstdmin"
                                                    >
                                                    </el-input>
                                                </el-form-item>
                                               <span v-else>{{scope.row.nkstdmin}}</span>
                                            </template>
                                            </el-table-column>
                                            <el-table-column sortable min-width="100" prop="nkstdmax" align="center" label="上限值">
                                            <template slot-scope="scope">
                                                <el-form-item
                                                v-if="scope.row.isSelection"
                                                :prop="scope.row.seq + '.nkstdmax'"
                                                :rules="hxcfRules.nkstdmax"
                                                >
                                                    <el-input
                                                    style="width: 100%;"
                                                    v-model="hxcfDataObj[scope.row.seq].nkstdmax"
                                                    >
                                                    </el-input>
                                                </el-form-item>
                                                <span v-else>{{scope.row.nkstdmax}}</span>
                                            </template>
                                            </el-table-column>
                                        </el-table>
                                        </el-form>
                                    </div>
                              </div>
                                <el-button slot="reference" class= "el-tooltip" size="mini" type="text">点击添加数据</el-button>
                        </el-popover>
                        </template>
                        </el-table-column>
                        <el-table-column
                        sortable
                            prop="planweight"
                            align="center"
                            label="计划量"
                            width="90px"
                            :show-overflow-tooltip="true"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    v-if="!isCheck && scope.row.isSelection"
                                    :prop="scope.row.seq + '.planweight'"
                                    :rules="tableFormRules.planWeight"
                                >
                                    <el-input clearable
                                        style="width: 100%;"
                                        @keydown.native="keyDown" :id="scope.$index + scope.column.id"
                                        v-model="tableFormDataObj[scope.row.seq].planweight"
                                        @change="chnageApportvalue(scope.row.seq, tableFormDataObj[scope.row.seq].planweight, scope.$index)"
                                    ></el-input>
                                </el-form-item>
                                <span v-else>{{scope.row.planweight}}</span>
                            </template>
                        </el-table-column>
                        <!-- <el-table-column
                        sortable
                            prop="lengthtimeswidth"
                            label="高度*宽度"
                            align="center"
                            fixed="left"
                            width="120px"
                            :show-overflow-tooltip="true"
                            v-if="filterForm.data.gx ==='XG'"
                        >
                        <template slot-scope="scope">
                                <el-form-item
                                  :prop="scope.row.seq + '.lengthtimeswidth'"
                                   v-if=" !isCheck && scope.row.isSelection && scope.row.state !== '2'"
                                   :rules="tableFormRules.lengthtimeswidth"
                                  >
                                    <el-select
                                    allow-create
                                    filterable
                                    clearable
                                    v-model="tableFormDataObj[scope.row.seq].lengthtimeswidth"
                                    placeholder=""
                                    >
                                    <el-option
                                    v-for="item of nameObj.lengthTimeswidth.arr"
                                    :key="item.id"
                                    :value="item.name"
                                    :label="item.name"
                                    ></el-option>
                                    </el-select>
                                </el-form-item>
                                <span v-else>{{ nameObj.lengthTimeswidth.obj[scope.row.lengthtimeswidth] ? nameObj.lengthTimeswidth.obj[scope.row.lengthtimeswidth].name : scope.row.lengthtimeswidth }}</span>
                            </template>
                        </el-table-column> -->
                        <el-table-column
                        sortable
                            prop="transportType"
                            label="运输方式"
                            align="center"
                            width="87px"
                            :show-overflow-tooltip="true"
                            v-if="filterForm.data.gx!='LG'"
                        >
                        <template slot-scope="scope">
                        <el-form-item
                                    :prop="scope.row.seq + '.transportType'"
                                    v-if=" !isCheck && scope.row.isSelection"
                                    :rules="tableFormRules.transportType"
                                  >
                                    <el-select
                                    allow-create
                                    filterable
                                    clearable
                                    v-model="tableFormDataObj[scope.row.seq].transportType"
                                    placeholder=""
                                    >
                                    <el-option
                                    v-for="item of nameObj.transportType.arr"
                                    :key="item.id"
                                    :value="item.name"
                                    :label="item.name"
                                    ></el-option>
                                    </el-select>
                                </el-form-item>
                                <span v-else>{{ nameObj.transportType.obj[scope.row.transportType] ? nameObj.transportType.obj[scope.row.transportType].name : scope.row.transportType }}</span>
                                </template>
                        </el-table-column>
                        <el-table-column
                        sortable
                            prop="purpose"
                            label="用途"
                            align="center"
                            width="87px"
                            :show-overflow-tooltip="true"
                            v-if="filterForm.data.gx === 'GX'"
                        >
                        <template slot-scope="scope">
                        <el-form-item
                                    :prop="scope.row.seq + '.purpose'"
                                    v-if=" !isCheck && scope.row.isSelection"
                                    :rules="tableFormRules.purpose"
                                  >
                                    <el-select
                                    allow-create
                                    filterable
                                    clearable
                                    v-model="tableFormDataObj[scope.row.seq].purpose"
                                    placeholder=""
                                    >
                                    <el-option
                                    v-for="item of nameObj.purpose.arr"
                                    :key="item.id"
                                    :value="item.name"
                                    :label="item.name"
                                    ></el-option>
                                    </el-select>
                                </el-form-item>
                                <span v-else>{{ nameObj.purpose.obj[scope.row.purpose] ? nameObj.purpose.obj[scope.row.purpose].name : scope.row.purpose }}</span>
                                </template>
                        </el-table-column>
                        <el-table-column
                        sortable
                            prop="receivetime"
                            label="接收时间"
                            align="center"
                            width="135px"
                            :show-overflow-tooltip="true"
                        ></el-table-column>
                        <el-table-column
                        sortable
                            prop="createman"
                            label="创建人"
                            align="center"
                            width="77px"
                            :show-overflow-tooltip="true"
                        >
                        </el-table-column>
                        <el-table-column
                        sortable
                            prop="createtime"
                            label="创建时间"
                            align="center"
                            width="135px"
                            :show-overflow-tooltip="true"
                        >
                        </el-table-column>
                         <el-table-column
                         sortable
                            prop="updatetime"
                            label="修改时间"
                            align="center"
                            width="135px"
                            :show-overflow-tooltip="true"
                        >
                        </el-table-column>
                        <el-table-column
                        sortable
                            prop="updateman"
                            label="修改人"
                            align="center"
                            width="77px"
                            :show-overflow-tooltip="true"
                        ></el-table-column>
                        <el-table-column
                            sortable
                            prop="gmReviewer"
                            label="审核人"
                            align="center"
                            min-width="120px"
                            :show-overflow-tooltip="true"
                        >
                        </el-table-column>
                         <el-table-column
                             sortable
                            prop="gmReviewerTime"
                            label="审核时间"
                            align="center"
                            width="120px"
                            :show-overflow-tooltip="true"
                        >
                        </el-table-column>
                        <el-table-column
                        sortable
                            prop="memo"
                            label="备注"
                            align="center"
                            width="170px"
                            :show-overflow-tooltip="true"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    v-if="!isCheck && scope.row.isSelection"
                                    :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>
                </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="jhTime"
                    >
                    <el-date-picker
                      v-model="dialog.editorBox.form.data.jhTime"
                      type="date"
                      style="width: 100%;"
                      placeholder="选择日期"
                      value-format="yyyy-MM-dd"
                      :disabled = "dialog.editorBox.form.data.dateEnable">
                    </el-date-picker>
                    <!-- <zj-timegran-date
                    v-model="dialog.editorBox.form.data.jhTime"
                    style="width: 100%;"
                    :timegranId="'DAY'"
                    disabled = "true"
                    ></zj-timegran-date> -->
                </el-form-item>
            </el-col>
            <el-col :span="12">
                  <el-form-item
                    label="交货日期"
                    prop="deliveryDate"
                    >
                    <el-date-picker
                      v-model="dialog.editorBox.form.data.deliveryDate"
                      type="date"
                      style="width: 100%;"
                      placeholder="选择日期"
                      value-format="yyyy-MM-dd"
                      :disabled = "dialog.editorBox.form.data.dateEnable">
                    </el-date-picker>
                    <!-- <zj-timegran-date
                    v-model="dialog.editorBox.form.data.deliveryDate"
                    style="width: 100%;"
                    :timegranId="'DAY'"
                    disabled = "true"
                    ></zj-timegran-date> -->
                </el-form-item>
            </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
           <el-form-item
           label="订单类型"
           prop="tag"
               >
          <el-select
                   filterable
                   v-model="dialog.editorBox.form.data.tag"
                   placeholder=""
                  style="width: 100%;"
                   @change="isMileageCardOrder"
                  >
                  <el-option
                  v-for="item of nameObj.tag.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="grades"
               >
                   <el-select
                     filterable
                     clearable
                     allow-create
                     v-model="dialog.editorBox.form.data.grades"
                     placeholder=""
                     style="width: 100%;"
                     :rules="tableFormRules.grades"
                    >
                    <el-option
                    v-for="item of nameObj.grades.arr"
                    :key="item.id"
                    :value="item.name"
                    :label="item.name"
                    ></el-option>
                    </el-select>
               </el-form-item>
             </el-col>
            <el-col :span="12">
                <el-form-item
                 label="规格"
                 prop="specifications"
                >
               <el-select
                     allow-create
                     filterable
                     clearable
                     v-model="dialog.editorBox.form.data.specifications"
                     placeholder=""
                    style="width: 100%;"
                    :rules="tableFormRules.specifications"
                    >
                    <el-option
                    v-for="item of nameObj.specifications.arr"
                    :key="item.id"
                    :value="item.name"
                    :label="item.name"
                    ></el-option>
                </el-select>
                </el-form-item>
            </el-col>
            <el-col :span="12">
            <el-form-item
            label="运输方式"
            prop="transportType"
            v-if="filterForm.data.gx != 'LG'"
                >
            <el-select
                     filterable clearable
                     v-model="dialog.editorBox.form.data.transportType"
                     placeholder=""
                     :rules="dialog.editorBox.form.transportType"
                    style="width: 100%;"
                    >
                    <el-option
                    v-for="item of nameObj.transportType.arr"
                    :key="item.id"
                    :value="item.name"
                    :label="item.name"
                    ></el-option>
                    </el-select>
            </el-form-item>
            </el-col>
            <el-col :span="12">
            <el-form-item
            label="用途"
            prop="purpose"
            v-if="filterForm.data.gx === 'GX'"
                >
            <el-select
                     filterable clearable
                     v-model="dialog.editorBox.form.data.purpose"
                     placeholder=""
                     :rules="dialog.editorBox.form.purpose"
                    style="width: 100%;"
                    >
                    <el-option
                    v-for="item of nameObj.purpose.arr"
                    :key="item.id"
                    :value="item.name"
                    :label="item.name"
                    ></el-option>
                    </el-select>
            </el-form-item>
            </el-col>
            <!-- <el-col :span="12">
                <el-form-item
                label="高度*宽度(mm)"
                prop="lengthTimesWidth"
                v-if="filterForm.data.gx ==='XG'"
                    >
                <el-select
                    allow-create
                    filterable
                    clearable
                    :rules="dialog.editorBox.form.lengthTimesWidth"
                    v-model="dialog.editorBox.form.data.lengthTimesWidth"
                    >
                    <el-option
                    v-for="item of nameObj.lengthTimeswidth.arr"
                    :key="item.id"
                    :value="item.name"
                    :label="item.name"
                    ></el-option>
                    </el-select>
                </el-form-item>
            </el-col> -->
            <el-col :span="12">
                <el-form-item
                label="长度(mm)"
                prop="lengths"
                v-if="filterForm.data.gx!='GX'"
                    >
                <el-input
                    clearable
                    style="width: 100%;"
                    :rules="dialog.editorBox.form.lengths"
                    v-model="dialog.editorBox.form.data.lengths"
                ></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="12">
            <el-form-item
            label="排产量"
            prop="planWeight"
                >
           <el-input
                clearable
                style="width: 100%;"
                :rules="dialog.editorBox.form.planWeight"
                v-model="dialog.editorBox.form.data.planWeight"
               ></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, // 是否为审核人
            visible: false,
            selectlistRow: [],
            filterForm: {
                show: true,
                data: {
                    show: false,
                    clock: '',
                    clockc: '',
                    workprocid: [],
                    location: [],
                    networkid: [],
                    lengthTimesWidth: [],
                    state: '',
                    unit: '',
                    memo: '',
                    startTime: '',
                    endTime: '',
                    kxf_weight: '',
                    yxf_weight: '',
                    gx: '',
                    workproc_type: '',
                    tag: ''
                },
                rules: {
                },
                disabled: {
                    networkid: false
                }
            },
            dialog: {
                fRow: null,
                editorBox: {
                    show: false,
                    type: '',
                    form: {
                        default: {
                            workprocid: ''
                        },
                        data: {
                            workprocid: '',
                            unitid: '',
                            jxdays: '',
                            memo: '',
                            grades: '',
                            specifications: '',
                            transportType: '',
                            chemicalStandard: '',
                            purpose: '',
                            planWeight: '',
                            jhTime: '',
                            lengths: '',
                            surfaceStandard: '',
                            dimension: '',
                            lengthTimesWidth: '',
                            iateralArea: '',
                            deliveryDate: '',
                            tag: '0',
                            dateEnable: false
                        },
                         rules: {
                             planWeight: [
                                { required: true, message: '该项不能为空', trigger: 'change' },
                                { validator: zCheckNumber1, trigger: 'change' }
                            ],
                            lengths: [
                                { validator: zCheckNumber1, trigger: 'change' }
                                ],
                            weightDay: [
                                { required: true, message: '该项不能为空', trigger: 'change' },
                                { validator: zCheckNumber1, trigger: 'change' }
                            ],
                            specifications: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                                ],
                            may: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                            ],
                            grades: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                                ],
                            unitid: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                                ],
                            memo: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                                ],
                            jhTime: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                            ],
                            deliveryDate: [
                                { required: true, message: '该项不能为空', 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: [
            ],
            gridData: [],
            loading: false,
            tableLoading: false,
            gridDataLoading: false,
            multipleSelection: [],
            hxcfSelection: [],
            hxcfDataObj: {},
            tableFormDataObj: {},
            hxcfRules: {
                chemcode: [
                    { required: true, message: '该项不能为空', trigger: 'change' }
                ],
                nkstdmin: [
                    { required: true, message: '该项不能为空', trigger: 'change' },
                    { validator: zCheckNumber1, trigger: 'change' }
                ],
                nkstdmax: [
                    { required: true, message: '该项不能为空', trigger: 'change' },
                    { validator: zCheckNumber1, trigger: 'change' }
                ]
            },
            tableFormRules: {
                grades: [
                     { required: true, message: '该项不能为空', trigger: 'change' }
                ],
                lengths: [
                     { validator: zCheckNumber1, trigger: 'change' }
                ],
                mendvalue: [
                    // { required: true, message: '该项不能为空', trigger: 'change' },
                    { validator: zCheckNumber1, trigger: 'change' }
                ],
                specifications: [
                    { required: true, message: '该项不能为空', trigger: 'change' }
                ],
                planWeight: [
                     { 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: 'green'
                        },
                        '3': {
                            name: '已接收',
                            color: 'red'
                        }
                    },
                    arr: [
                        {
                            id: '0',
                            name: '已编辑'
                        },
                        {
                            id: '1',
                            name: '正在审核'
                        },
                        {
                            id: '2',
                            name: '已下发'
                        },
                        {
                            id: '3',
                            name: '已接收'
                        }
                    ]
                },
                type: {
                    obj: {
                        '0': '否',
                        '1': '是'
                    },
                    arr: [
                        {
                            id: '0',
                            name: '否'
                        },
                        {
                            id: '1',
                            name: '是'
                        }
                    ]
                },
                 transportType: {
                    obj: {'0': {name: '火运'}, '1': {name: '汽运'}, '2': {name: '汽运或者火运'}},
                    arr: [
                        {
                            id: '0',
                            name: '火运'
                        },
                        {
                            id: '1',
                            name: '汽运'
                        },
                        {
                            id: '2',
                            name: '汽运或者火运'
                        }
                    ]
                },
                hxcf: {
                    obj: {},
                    arr: []
                },
                workprocid: {
                    obj: {},
                    arr: []
                },
                location: {
                    obj: {},
                    arr: [],
                    showDataArr: []
                },
                purpose: {
                    obj: {
                        '0': {name: '标准件'},
                        '1': {name: '铁丝'},
                        '2': {name: '钢丝、弹簧'}
                    },
                    arr: [
                        {
                            id: '0',
                            name: '标准件'
                        },
                        {
                            id: '1',
                            name: '铁丝'
                        },
                        {
                            id: '2',
                            name: '钢丝、弹簧'
                        }
                    ]
                },
                locateid: {
                    obj: {},
                    arr: []
                },
                networkid: {
                    obj: {},
                    arr: []
                },
                userId: {
                    obj: {},
                    arr: []
                },
                unitid: {
                    obj: {},
                    arr: [],
                    defaults: ''
                },
                 grades: {
                    obj: {},
                    arr: []
                },
                specifications: {
                    obj: {},
                    arr: []
                },
                lengthTimeswidth: {
                    obj: {},
                    arr: []
                },
                chemicalStandard: {
                    obj: {},
                    arr: []
                },
                tag: {
                    obj: {
                        '0': {
                            name: '正常',
                            color: '#7a7a7a'
                        },
                        '1': {
                            name: '应急',
                            color: 'red'
                        }
                    },
                    arr: [
                        {
                            id: '0',
                            name: '正常'
                        },
                        {
                            id: '1',
                            name: '应急'
                        }
                    ]
                }
            },
            butPrivilege: {
                ADD: false,
                DELETE: false,
                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.workproc_type) {
            that.filterForm.data.workproc_type = that.$route.query.workproc_type;
        }
        // 当有审核与取消审核权限时，默认其为审核人，审核人无法修改数据
        if (that.butPrivilege.CHECK || that.butPrivilege.UNDOCHECK) {
            that.isCheck = true;
        }
        // 管理员在这里录入数据
        if (that.loginName === 'admin' && that.filterForm.disabled.networkid) {
            that.isCheck = false;
        }
        // 接收路由参数
        if (that.$route.query.gx) {
            that.filterForm.data.gx = that.$route.query.gx;
            let its = that.filterForm.data.gx.split(',');
            if (its && its.length > 10) {
                that.pageSize = 50;
                that.custom = 0;
            }
        }
        if (that.$route.query.gx === 'GX') {
             that.getGrades();
             that.getSpecifications();
             that.getStandards();
        }
        if (that.$route.query.gx === 'LG') {
            that.getGradesASLg();
            that.getSpecificationsAsLg();
            that.getStandardsAsLg();
        }
        if (that.$route.query.gx === 'XG') {
             that.getGrades();
             that.getlengthTimesWidth();
             that.getStandards();
        }
        that.getNodeData();
        // that.getLocation();
        that.getUnitIdData();
        that.getLocateIdData();
        that.gethxcf();
        // that.getTableData();
    },
    methods: {
        //  计算树区域高度
        getRoleHeight (dom) {
            return window.innerHeight - dom.offsetTop;
        },
        // 自定义的表格合计方法：只给指定列进行合计
        getSummaries (param) {
            const prop = ['planweight']; // 合计列绑定的prop
            return XtcommonSummaries(param, prop);
        },
        // 获取高线钢种
        getGrades () {
            let that = this
            let type = '';
            if (that.filterForm.data.gx === 'GX') {
               type = '高线'
            }
            if (that.filterForm.data.gx === 'XG') {
               type = '型钢'
            }
            let url = 'pass/product/v1/emssteel/getGrades/?type=' + type;
            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.steelName
                            })
                                obj[item.id] = {
                                name: item.steelName,
                                id: item.id
                            }
                        }
                        that.nameObj.grades.arr = arr;
                        that.nameObj.grades.obj = obj;
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
        gethxcfDate1 (row) {
          let that = this;
          let arr = [];
          try{
          that.gridDataLoading = true;
          if(row.dataByGmid) {
            for (let i = 0; i < row.dataByGmid.length; i++) {
              let item = row.dataByGmid[i];
              arr.push({
                  seq: i,
                  gmid: item.gmid,
                  chemcode: item.chemCode,
                  nkstdmin: item.nkStdMin,
                  nkstdmax: item.nkStdMax
              })
            }
          }
          that.gridData = arr;
          that.gridDataLoading = false;
          }catch(e){
            that.gridData = arr;
            //TODO handle the exception
            that.gridDataLoading = false;
          }
        },
         gethxcfDate (row) {
         let that = this;
         let url = 'pass/ems/v1/chemicalconstituentss/getDataByGmid';
         let params = {};
         params = {
             gmid: row.id
         }
         that.gridDataLoading = true;
         that.axios.get(url, {
             params: params
            }).then(function (res) {
                if (res.code === '0') {
                    let arr = [];
                    for (let i = 0; i < res.data.length; i++) {
                        let item = res.data[i];
                        arr.push({
                            seq: i,
                            gmid: item.gmid,
                            chemcode: item.chemCode,
                            nkstdmin: item.nkStdMin,
                            nkstdmax: item.nkStdMax
                        })
                    }
                    that.gridData = arr;
                    that.gridDataLoading = false;
                } else {
                    that.$message.error(res.message);
                }
            }).catch(function () {
                that.leftTableLoading = false;
            });
        },

        addhxcf (row) {
            let that = this;
            if (that.hxcfSelection.length > 0) {
               that.$refs['dialog_form_hxcf'].validate((valid, obj) => {
                    if (valid) {
                        let SubmitData = [];
                         for (let key in that.hxcfDataObj) {
                              SubmitData.push({
                              gmid: row.id,
                              chemCode: that.hxcfDataObj[key].chemcode,
                              nkStdMin: that.hxcfDataObj[key].nkstdmin,
                              nkStdMax: that.hxcfDataObj[key].nkstdmax
                              });
                         }
                         that.gridDataLoading = true;
                         that.axios.put('pass/ems/v1/chemicalconstituentss/update', SubmitData)
                         .then(function (res) {
                            if (res.code === '0') {
                              that.$message({
                                message: '保存成功',
                                type: 'success'
                                });
                            that.gethxcfDate(row);
                            if (row.dataByGmid) {
                              for (let item of SubmitData) {
                                row.dataByGmid.push({
                                  chemCode: item.chemCode,
                                  gmid: item.gmid,
                                  id: {
                                    chemCode: item.chemCode,
                                    gmid: item.gmid
                                  },
                                  nkStdMax: item.nkStdMax,
                                  nkStdMin: item.nkStdMin
                                });
                              }
                              // row.dataByGmid.concat(SubmitData);
                            } else {
                              let arr = [];
                              for (let item of SubmitData) {
                                arr.push({
                                  chemCode: item.chemCode,
                                  gmid: item.gmid,
                                  id: {
                                    chemCode: item.chemCode,
                                    gmid: item.gmid
                                  },
                                  nkStdMax: item.nkStdMax,
                                  nkStdMin: item.nkStdMin
                                });
                              }
                              row.dataByGmid = arr;
                              row.teshu = '是';
                            }
                            } else {
                              that.$message.error(res.message);
                            }
                          that.gridDataLoading = false;
                         }).catch(function () {
                             that.gridDataLoading = false;
                         });
                    }
                });
            } else {
                this.$message.error('至少要选择一条数据');
            }
        },
        gethxcf () {
            let that = this;
            let url = 'pass/ems/v1/qcmbasechems/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.chemCode,
                                name: item.chemName
                            })
                                obj[item.id] = {
                                name: item.chemName,
                                id: item.id
                            }
                        }
                        that.nameObj.hxcf.arr = arr;
                        that.nameObj.hxcf.obj = obj;
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
      selectRow (val) {
          let that = this;
          let hxcfDataObj = {};
          let arr = [];
           for (let item of val) {
               arr.push(item.seq);
           }
         this.seqArr = arr.sort(sortNumber);
         for (let item of that.gridData) {
             item.isSelection = false;
         }
        for (let item of val) {
            let obj = {};
            let xId = item.seq;
            if (that.hxcfDataObj[xId]) {
                 hxcfDataObj[xId] = that.hxcfDataObj[xId];
            } else {
                for (let key in item) {
                    obj[key] = item[key];
                }
                hxcfDataObj[xId] = obj;
            }
            item.isSelection = true;
        }
        that.hxcfDataObj = hxcfDataObj;
        that.hxcfSelection = val;
      },
       addRow (row) {
        let that = this;
        let seq = that.gridData.length;
        var list = {
            seq: seq + 1,
            chemcode: '',
            nkstdmin: 0,
            nkstdmax: 0
          }
        this.gridData.unshift(list)
      },
      delData (row) {
          let that = this;
          let gridData = that.gridData;
          // let val = that.hxcfSelection;
          if (that.hxcfSelection.length > 0) {
              let SubmitData = [];
              for (let item of that.hxcfSelection) {
                    SubmitData.push({
                        gmid: item.gmid,
                        chemCode: item.chemcode,
                        nkStdMin: item.nkstdmin,
                        nkStdMax: item.nkstdmax
                    });
                }
                 that.axios.delete('pass/ems/v1/chemicalconstituentss/delete', {
                  data: SubmitData,
                  contentType: 'application/json;charset=UTF-8'
                }).then(function (res) {
                 if (res.code === '0') {
                     that.$message({
                     message: '删除成功',
                     type: 'success'
                });
                that.hxcfSelection.forEach((val, index) => {
                    gridData.forEach((v, i) => {
                    if (val.seq === v.seq) {
                        gridData.splice(i, 1)
                        }
                    })
                    row.dataByGmid.forEach((v, i) => {
                    if (val.chemcode === v.chemCode) {
                        row.dataByGmid.splice(i, 1)
                        }
                    })
                })
                row.teshu = row.dataByGmid ? (row.dataByGmid.length > 0 ? '是' : '否') : '否'
                 // this.$refs.multipleTable.clearSelection();
            }
        });
            //   that.$confirm('是否删除已选数据?', '提示', {
            //       confirmButtonText: '确定',
            //       cancelButtonText: '取消',
            //       state: 'warning'
            //   }).then(() => {
            //   });
          } else {
              this.$message.error('至少要选择一条数据');
          }
    },
        // 获取高线规格
        getSpecifications () {
            let that = this
            let url = 'pass/product/v1/emssteel/getSpecifications/?type=' + '高线';
            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.specName
                            })
                            obj[item.id] = {
                                name: item.specName,
                                unitid: item.id
                            }
                        }
                        that.nameObj.specifications.arr = arr;
                        that.nameObj.specifications.obj = obj;
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
        // 获取高线执行标准
         getStandards () {
             let that = this
            let url = 'pass/product/v1/emsstandard/getStandards';
            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.basecode,
                                name: item.basename
                            })
                        }
                        that.nameObj.chemicalStandard.arr = arr;
                        that.nameObj.chemicalStandard.obj = obj;
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
        // 获取炼钢钢种
        getGradesASLg () {
            let that = this
            let url = 'pass/product/v1/emsvqcmbasesteel/getBase'
            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] = {
                                name: item.name,
                                id: item.id
                            }
                        }
                        that.nameObj.grades.arr = arr;
                        that.nameObj.grades.obj = obj;
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
        // 获取炼钢规格
        getSpecificationsAsLg () {
            let that = this
            let url = 'pass/product/v1/emsvqcmbasespecbillet/getbasespecbillet';
            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] = {
                                name: item.name,
                                id: item.id
                            }
                        }
                        that.nameObj.specifications.arr = arr;
                        that.nameObj.specifications.obj = obj;
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
        // 获取炼钢化学成分标准
        getStandardsAsLg () {
            let that = this
            let url = 'pass/product/v1/emsvqcmstdchem/getstdchem';
            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.basecode,
                                name: item.standardgb
                            })
                        }
                        that.nameObj.chemicalStandard.arr = arr;
                        that.nameObj.chemicalStandard.obj = obj;
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
        // 获取型钢规格
        getlengthTimesWidth () {
            let that = this
            let url = 'pass/ems/v1/emsprodplanrounds/getbasespecbillet';
            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.specifications
                            })
                        }
                        that.nameObj.specifications.arr = arr;
                        that.nameObj.specifications.obj = obj;
                    } else {
                        that.$message.error(res.message);
                    }
                });
        },
        // 获取工序列表
        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 = {
                jhTime: that.dialog.editorBox.form.data.jhTime,
                grades: that.dialog.editorBox.form.data.grades,
                unitid: '008',
                chemicalStandard: that.dialog.editorBox.form.data.chemicalStandard,
                planWeight: that.dialog.editorBox.form.data.planWeight,
                specifications: that.dialog.editorBox.form.data.specifications,
                transportType: that.dialog.editorBox.form.data.transportType,
                memo: that.dialog.editorBox.form.data.memo,
                workprocType: that.filterForm.data.workproc_type,
                lengths: that.dialog.editorBox.form.data.lengths,
                purpose: that.dialog.editorBox.form.data.purpose,
                iateralArea: that.dialog.editorBox.form.data.iateralArea,
                deliveryDate: that.dialog.editorBox.form.data.deliveryDate,
                lengthTimesWidth: that.dialog.editorBox.form.data.lengthTimesWidth,
                dimension: that.dialog.editorBox.form.data.dimension,
                surfaceStandard: that.dialog.editorBox.form.data.surfaceStandard,
                tag: that.dialog.editorBox.form.data.tag,
                state: '0'
            };
            that.$refs['dialog_form'].validate((valid) => {
               if (valid) {
                        that.loading = true;
                        that.axios.post('pass/ems/v1/emsgmpcjhs/', 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;
                            });
                }
            });
        },
        // 获取位置
        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 = {
                   workprocType: that.filterForm.data.workproc_type,
                   startTime: that.filterForm.data.may[0],
                   endTime: that.filterForm.data.may[1],
                   grades: that.filterForm.data.grades.toString(),
                   specifications: that.filterForm.data.specifications.toString(),
                   lengthTimesWidth: that.filterForm.data.lengthTimesWidth.toString(),
                   tag: that.filterForm.data.tag,
                   state: that.filterForm.data.state
                };
                if (that.filterForm.data.tag === '1') {
                  pData = {
                     workprocType: that.filterForm.data.workproc_type,
                     grades: that.filterForm.data.grades.toString(),
                     specifications: that.filterForm.data.specifications.toString(),
                     lengthTimesWidth: that.filterForm.data.lengthTimesWidth.toString(),
                     tag: that.filterForm.data.tag,
                     state: that.filterForm.data.state
                  };
                }
                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/emsgmpcjhs/?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];
                            let that = this;

                            arr.push({
                                dataByGmid: item.dataByGmid,
                                teshu: item.dataByGmid != null && item.dataByGmid.length > 0 ? '是' : '否',
                                seq: i,
                                id: item.id,
                                jhTime: item.jhTime,
                                state: item.state,
                                may: item.may,
                                grades: item.grades,
                                specifications: item.specifications,
                                lengths: item.lengths,
                                chemicalStandard: item.chemicalStandard,
                                surfacestandard: item.surfaceStandard,
                                workprocType: item.workproctype,
                                iateralarea: item.iateralArea,
                                lengthtimeswidth: item.lengthTimesWidth,
                                transportType: item.transportType,
                                receivetime: item.receiveTime,
                                createman: item.createMan,
                                createtime: item.createTime,
                                updateman: item.updateMan,
                                purpose: item.purpose,
                                updatetime: item.updateTime,
                                memo: item.memo,
                                planweight: item.planWeight,
                                dimension: item.dimension,
                                deliveryDate: item.deliveryDate,
                                gmReviewer: item.gmReviewer,
                                gmReviewerTime: item.gmReviewerTime,
                                tag: item.tag ? item.tag : '0'

                            });
                        }
                        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;
            if (column['property'] === 'workprocid' || column['property'] === 'adds' || column['property'] === 'rxj' || column['property'] === 'yhj') {
                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.grades = '';
            that.dialog.editorBox.form.data.transportType = '';
            that.dialog.editorBox.form.data.specifications = '';
            that.dialog.editorBox.form.data.unitid = '';
            that.dialog.editorBox.form.data.memo = '';
            that.dialog.editorBox.form.data.chemicalStandard = '';
            that.dialog.editorBox.form.data.planWeight = '';
            that.dialog.editorBox.form.data.lengths = '';
            that.dialog.editorBox.form.data.lengthTimesWidth = '';
            that.dialog.editorBox.form.data.memo = '';
            that.dialog.editorBox.form.data.tag = '0';
            that.dialog.editorBox.form.data.deliveryDate = formatDate(new Date(), 'yyyy-MM-dd');
            that.dialog.editorBox.form.data.jhTime = formatDate(new Date(), 'yyyy-MM-dd');
            that.dialog.editorBox.form.data.dateEnable = false;
            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 (row.state === '3' && !this.isCheck) {
                return false;
            } else {
                return true;
            }
        },
        // 成分标准选择
        checkboxTcf (row, index) {
          if (row.isSelection) {
              return true
          }
          return false;
        },
        // 获取标准计量单位
        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,
                                jhTime: that.tableFormDataObj[key].jhTime,
                                grades: that.tableFormDataObj[key].grades,
                                transportType: that.tableFormDataObj[key].transportType,
                                specifications: that.tableFormDataObj[key].specifications,
                                unitid: that.tableFormDataObj[key].unitid,
                                memo: that.tableFormDataObj[key].memo,
                                workprocType: that.filterForm.data.workproc_type,
                                chemicalStandard: that.tableFormDataObj[key].chemicalStandard,
                                planWeight: that.tableFormDataObj[key].planweight,
                                createTime: that.tableFormDataObj[key].createtime,
                                purpose: that.tableFormDataObj[key].purpose,
                                createMan: that.tableFormDataObj[key].createman,
                                updateTime: that.tableFormDataObj[key].updatetime,
                                updateMan: that.tableFormDataObj[key].updateman,
                                state: '0',
                                lengths: that.tableFormDataObj[key].lengths,
                                surfaceStandard: that.tableFormDataObj[key].surfacestandard,
                                deliveryDate: that.tableFormDataObj[key].deliveryDate,
                                dimension: that.tableFormDataObj[key].dimension,
                                iateralArea: that.tableFormDataObj[key].iateralarea,
                                lengthTimesWidth: that.tableFormDataObj[key].lengthtimeswidth,
                                gmReviewer: that.tableFormDataObj[key].gmReviewer,
                                gmReviewerTime: that.tableFormDataObj[key].gmReviewerTime,
                                tag: that.tableFormDataObj[key].tag ? that.tableFormDataObj[key].tag : '0'
                            });
                        }
                        that.loading = true;
                        that.axios.put('pass/ems/v1/emsgmpcjhs/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_copy_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({
                                jhTime: that.dialog.editorBox2.form.data.may,
                                grades: that.tableFormDataObj[key].grades,
                                transportType: that.tableFormDataObj[key].transportType,
                                specifications: that.tableFormDataObj[key].specifications,
                                unitid: that.tableFormDataObj[key].unitid,
                                workprocType: that.filterForm.data.workproc_type,
                                chemicalStandard: that.tableFormDataObj[key].chemicalStandard,
                                planWeight: '0',
                                deliveryDate: that.tableFormDataObj[key].deliveryDate,
                                lengths: that.tableFormDataObj[key].lengths,
                                surfaceStandard: that.tableFormDataObj[key].surfacestandard,
                                dimension: that.tableFormDataObj[key].dimension,
                                iateralArea: that.tableFormDataObj[key].iateralarea,
                                lengthTimesWidth: that.tableFormDataObj[key].lengthtimeswidth,
                                tag: that.tableFormDataObj[key].tag ? that.tableFormDataObj[key].tag : '0'
                            });
                        }
                        that.loading = true;
                        that.axios.put('pass/ems/v1/emsgmpcjhs/batchcopy', SubmitData)
                            .then(function (res) {
                                if (res.code === '0') {
                                    that.$message({
                                        message: '复制成功',
                                        type: 'success'
                                    });
                                    that.dialog.editorBox2.show = false;
                                    that.getTableData();
                                } else {
                                    that.$message.error(res.message);
                                }
                                that.loading = false;
                            }).catch(function () {
                                that.loading = false;
                            });
                        }
                });
            } else {
                this.$message.error('至少要选择一条数据');
            }
        },
        // 下发
         issue (state) {
            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,
                                workprocType: that.filterForm.data.workproc_type,
                                state: state
                            });
                        }
                        that.loading = true;
                        that.axios.put('pass/ems/v1/emsgmpcjhs/updatestate', 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('至少要选择一条数据');
            }
        },
        submitaudit () {
            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,
                                workprocType: that.filterForm.data.workproc_type,
                                state: '1',
                                lengths: that.tableFormDataObj[key].lengths,
                                grades: that.tableFormDataObj[key].grades,
                                specifications: that.tableFormDataObj[key].specifications,
                                planWeight: that.tableFormDataObj[key].planweight,
                                tag: that.tableFormDataObj[key].tag ? that.tableFormDataObj[key].tag : '0'
                            });
                        }
                        that.loading = true;
                        that.axios.put('pass/ems/v1/emsgmpcjhs/submitaudit', 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) {
                    SubmitData.push({
                        id: item.id,
                        state: item.state,
                        sqno: item.sqno
                    });
                }
                that.$confirm('是否删除已选数据?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    state: 'warning'
                }).then(() => {
                    that.axios.delete('pass/ems/v1/emsgmpcjhs/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('至少要选择一条数据');
            }
        },
        tableRowClassName ({row, rowIndex}) {
            // 把每一行的索引放进row
            row.index = rowIndex;
        },
        cellClickHxcf (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();
            });
        },
        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();
            });
        },
        // 导入方法
        beforeUpload (event, file, fileList) {
          let _this = this
          let formData = new FormData();
          formData.append('file', file.raw)
          _this.loading = true
          this.axios.post('pass/ems/v1/emsgmpcjhs/excelimport/', formData, {
            headers: {'Content-Type': 'multipart/form-data'}
          }).then(res => {
            if (res.code === '200') {
              this.$message.success('操作成功')
              _this.getTableData();
            } else {
              this.$message.error(res.message)
            }
            _this.loading = false
          }).catch(() => {
            _this.loading = false
          })
        },
        // 订单类型下拉框选择事件
        isMileageCardOrder (val) {
          let that = this;
          if (val === '1') {
           that.dialog.editorBox.form.data.deliveryDate = '2020-01-01';
           that.dialog.editorBox.form.data.jhTime = '2020-01-01';
           that.dialog.editorBox.form.data.dateEnable = true;
          } else {
            that.dialog.editorBox.form.data.deliveryDate = formatDate(new Date(), 'yyyy-MM-dd');
            that.dialog.editorBox.form.data.jhTime = formatDate(new Date(), 'yyyy-MM-dd');
            that.dialog.editorBox.form.data.dateEnable = false;
          }
        }
    }
}
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>
