<template>
    <!-- 运方单执行 -->
    <div class="PWODPerform">
        <div class="box">
            <div class="box-top">
                <el-form
                    style="overflow: hidden;"
                    :style="filterForm.show ? null : { height: '0px' }"
                    size="mini"
                    label-width="85px"
                >
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="编制时间">
                                <el-date-picker
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    format="yyyy-MM-dd HH:mm:ss"
                                    type="datetimerange"
                                    v-model="filterForm.data.creattime"
                                    placeholder=""
                                    style="width: 100%;"
                                ></el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="介质系统">
                                <el-select
                                    filterable clearable
                                    v-model="filterForm.data.mediumsystem"
                                    placeholder=""
                                    style="width: 100%;"
                                >
                                    <el-option
                                        v-for="item of nameObj.mediumsystem.arr"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.name"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="签收时间">
                                <el-date-picker
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    format="yyyy-MM-dd HH:mm:ss"
                                    type="datetimerange"
                                    v-model="filterForm.data.signtime"
                                    placeholder=""
                                    style="width: 100%;"
                                ></el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="设备名称">
                                <el-input clearable
                                    v-model="filterForm.data.equipmentname"
                                    placeholder=""
                                    style="width: 100%;"
                                    @keyup.enter.native="getTableData(1)"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="实际执行时间">
                                <el-date-picker
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    format="yyyy-MM-dd HH:mm:ss"
                                    type="datetimerange"
                                    v-model="filterForm.data.executivetime"
                                    placeholder=""
                                    style="width: 100%;"
                                ></el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="运行主管">
                                <el-input clearable
                                    v-model="filterForm.data.applyman"
                                    placeholder=""
                                    style="width: 100%;"
                                    @keyup.enter.native="getTableData(1)"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="6">
                            <el-form-item label="申请单位">
                                <el-input clearable
                                    v-model="filterForm.data.applyunit"
                                    placeholder=""
                                    style="width: 100%;"
                                    @keyup.enter.native="getTableData(1)"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="单据状态">
                                <el-select
                                    filterable clearable
                                    v-model="filterForm.data.billstatus"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                >
                                    <el-option
                                        v-for="item of nameObj.billstatus.arr"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.name"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <!-- <el-col :span="6">
                            <el-form-item label="操作状态">
                                <el-select
                                    filterable clearable
                                    v-model="filterForm.data.operatestatus"
                                    placeholder=""
                                    style="width: 100%;"
                                >
                                    <el-option
                                        v-for="item of nameObj.operatestatus.arr"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.name"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col> -->
                    </el-row>
                </el-form>
                <div class="box-top-gjl">
                    <div style="float:right; text-align: right;">
                        <el-button
                            class="button"
                            type="primary"
                            size="mini"
                            icon="el-icon-search"
                            v-privilege="activeMenu + 'QUERY'"
                            @click="getTableData(1)"
                        >查询</el-button>
                        <el-button
                            class="button"
                            type="primary"
                            size="mini"
                            icon="el-icon-refresh"
                            v-privilege="activeMenu + 'QUERY'"
                            @click="tableDataCancel();"
                        >重置</el-button>
                        <el-button
                            size="mini"
                            :icon="filterForm.show ? 'el-icon-caret-top' : 'el-icon-caret-bottom'"
                            :title="filterForm.show ? '收起搜索区' : '展开搜索区'"
                            @click="filterForm.show = !filterForm.show;
                                $nextTick(() => {
                                    singleTableHeight = getRoleHeight($refs['singleTable'].$el) - 45;
                                }
                            );"
                        >{{ filterForm.show ? '收起' : '展开' }}</el-button>
                    </div>
                </div>
            </div>
            <div class="box-bottom">
                <el-table
                    stripe
                    id="singleTable"
                    ref="singleTable"
                    :data="tableData"
                    v-loading="tableLoading"
                    style="width: 100%;"
                    :height="singleTableHeight"
                    border
                    size="mini"
                    highlight-current-row
                >
                    <el-table-column
                        sortable
                        prop="billsno"
                        label="运方单编号"
                        min-width="100px"
                        :show-overflow-tooltip="true"
                    ></el-table-column>
                    <el-table-column
                        sortable
                        prop="creattime"
                        label="编制时间"
                        min-width="100px"
                        :show-overflow-tooltip="true"
                    ></el-table-column>
                    <el-table-column
                        sortable
                        prop="equipmentname"
                        label="设备名称"
                        min-width="100px"
                        :show-overflow-tooltip="true"
                    ></el-table-column>
                    <el-table-column
                        sortable
                        prop="applyman"
                        label="运行主管"
                        min-width="100px"
                        :show-overflow-tooltip="true"
                    ></el-table-column>
                    <el-table-column
                        sortable
                        prop="applyunit"
                        label="申请单位"
                        min-width="100px"
                        :show-overflow-tooltip="true"
                    ></el-table-column>
                    <el-table-column
                        sortable
                        prop="signtime"
                        label="签收时间"
                        min-width="100px"
                        :show-overflow-tooltip="true"
                    ></el-table-column>
                    <el-table-column
                        sortable
                        prop="executivechargeman"
                        label="执行负责人"
                        min-width="100px"
                        :show-overflow-tooltip="true"
                    ></el-table-column>
                    <el-table-column
                        sortable
                        prop="executivetime"
                        label="实际执行时间"
                        min-width="100px"
                        :show-overflow-tooltip="true"
                    ></el-table-column>
                    <!-- <el-table-column
                    sortable
                        prop="operatestatus"
                        label="操作状态"
                        min-width="100px"
                        :show-overflow-tooltip="true"
                    >
                        <template slot-scope="scope">
                            <span>{{ nameObj.operatestatus.obj[scope.row.operatestatus] ? nameObj.operatestatus.obj[scope.row.operatestatus] : scope.row.operatestatus }}</span>
                        </template>
                    </el-table-column> -->
                    <el-table-column
                        sortable
                        prop="billstatus"
                        label="单据状态"
                        min-width="100px"
                        :show-overflow-tooltip="true"
                    >
                        <template slot-scope="scope">
                            <span>{{ nameObj.billstatus.obj[scope.row.billstatus] ? nameObj.billstatus.obj[scope.row.billstatus] : scope.row.billstatus }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        class-name="gn-TableDownloadExcel-none"
                        label="操作"
                        align="center"
                        width="70px"
                        fixed="right"
                    >
                        <template slot-scope="scope">
                            <div>
                                <el-button
                                    type="primary"
                                    size="mini"
                                    @click="but_edit(scope.row)"
                                >执行</el-button>
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total"
                    :page-sizes="[10, 20, 50, 100, 500, 1000]"
                    :page-size="pageSize"
                    :current-page.sync="pageNum"
                    @size-change="tableSizeChange"
                    @current-change="getTableData()"
                    style="text-align: right;margin-top: 10px;"
                ></el-pagination>
            </div>
        </div>
        <el-dialog
            :title="'运行方式变更通知单 - 执行'"
            :visible.sync="dialog.editorBox.show"
            width="940px"
            :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="120px"
                >
                    <el-row>
                        <el-col :span="8">
                            <el-form-item
                                label="介质系统"
                                prop="mediumsystem"
                            >
                                <el-select
                                    filterable clearable
                                    v-model="dialog.editorBox.form.data.mediumsystem"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                >
                                    <el-option
                                        v-for="item of nameObj.mediumsystem.arr"
                                        :key="item.id"
                                        :value="item.id"
                                        :label="item.name"
                                    ></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="运方单编号"
                                prop="billsno"
                            >
                                <el-input clearable
                                    v-model="dialog.editorBox.form.data.billsno"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="编制时间"
                                prop="creattime"
                            >
                                <el-date-picker
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    type="datetime"
                                    v-model="dialog.editorBox.form.data.creattime"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                ></el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item
                                label="运行主管"
                                prop="applyman"
                            >
                                <el-input clearable
                                    v-model="dialog.editorBox.form.data.applyman"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="申请单位负责人"
                                prop="applychargeman"
                            >
                                <el-input clearable
                                    v-model="dialog.editorBox.form.data.applychargeman"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="申请单位"
                                prop="applyunit"
                            >
                                <el-input clearable
                                    v-model="dialog.editorBox.form.data.applyunit"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item
                                label="设备名称"
                                prop="equipmentname"
                            >
                                <el-input clearable
                                    v-model="dialog.editorBox.form.data.equipmentname"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="申请停役时间"
                                prop="stoptime"
                            >
                                <el-date-picker
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    type="datetime"
                                    v-model="dialog.editorBox.form.data.stoptime"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                ></el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="申请复役时间"
                                prop="restarttime"
                            >
                                <el-date-picker
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    type="datetime"
                                    v-model="dialog.editorBox.form.data.restarttime"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                ></el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item
                                label="用户联系人及电话"
                                prop="linkmantel"
                            >
                                <el-input clearable
                                    v-model="dialog.editorBox.form.data.linkmantel"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="检修开始时间"
                                prop="timestart"
                            >
                                <el-date-picker
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    type="datetime"
                                    v-model="dialog.editorBox.form.data.timestart"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                ></el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="检修结束时间"
                                prop="timeover"
                            >
                                <el-date-picker
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    type="datetime"
                                    v-model="dialog.editorBox.form.data.timeover"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                ></el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item
                                label="现场负责人及电话"
                                prop="chargemantel"
                            >
                                <el-input clearable
                                    v-model="dialog.editorBox.form.data.chargemantel"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-form-item
                        label="现场用户地点"
                        prop="address"
                    >
                        <el-input clearable
                            type="textarea"
                            v-model="dialog.editorBox.form.data.address"
                            placeholder=""
                            style="width: 100%;"
                            disabled
                        ></el-input>
                    </el-form-item>
                    <el-form-item
                        label="任务说明"
                        prop="workcontent"
                    >
                        <el-input clearable
                            type="textarea"
                            v-model="dialog.editorBox.form.data.workcontent"
                            placeholder=""
                            style="width: 100%;"
                            disabled
                        ></el-input>
                    </el-form-item>
                    <el-form-item
                        label="注意事项"
                        prop="attention"
                    >
                        <el-input clearable
                            type="textarea"
                            v-model="dialog.editorBox.form.data.attention"
                            placeholder=""
                            style="width: 100%;"
                            disabled
                        ></el-input>
                    </el-form-item>
                    <el-container>
                        <el-main style="padding: 0;">
                            <el-form-item
                                label="结构简图"
                                prop="structdiagram"
                            >
                                <el-input clearable
                                    class="nr-textarea"
                                    type="textarea"
                                    v-model="dialog.editorBox.form.data.structdiagram"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                ></el-input>
                            </el-form-item>
                        </el-main>
                        <el-aside
                            width="200px"
                            style="padding-left: 15px;"
                        >
                            <zj-fileUploadBox
                                class="fileUploadBox"
                                :uploadBut="false"
                                :files="dialog.editorBox.files"
                            ></zj-fileUploadBox>
                        </el-aside>
                    </el-container>
                    <el-form-item
                        label="工作内容修改"
                        prop="contentchange"
                    >
                        <el-input clearable
                            type="textarea"
                            v-model="dialog.editorBox.form.data.contentchange"
                            placeholder=""
                            style="width: 100%;"
                            disabled
                        ></el-input>
                    </el-form-item>
                    <el-form-item
                        label="安全措施"
                        prop="safetyprecautions"
                    >
                        <el-input clearable
                            type="textarea"
                            v-model="dialog.editorBox.form.data.safetyprecautions"
                            placeholder=""
                            style="width: 100%;"
                            disabled
                        ></el-input>
                    </el-form-item>
                    <el-row>
                        <el-col :span="16">
                            <el-form-item
                                label="签收人"
                                prop="signman"
                            >
                                <el-input clearable
                                    v-model="dialog.editorBox.form.data.signman"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="签收时间"
                                prop="signtime"
                            >
                                <el-date-picker
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    type="datetime"
                                    v-model="dialog.editorBox.form.data.signtime"
                                    placeholder=""
                                    style="width: 100%;"
                                    disabled
                                ></el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-form-item
                        label="执行情况"
                        prop="executivesituation"
                    >
                        <el-input clearable
                            type="textarea"
                            v-model="dialog.editorBox.form.data.executivesituation"
                            placeholder=""
                            style="width: 100%;"
                        ></el-input>
                    </el-form-item>
                    <el-form-item
                        label="备注"
                        prop="note"
                    >
                        <el-input clearable
                            type="textarea"
                            v-model="dialog.editorBox.form.data.note"
                            placeholder=""
                            style="width: 100%;"
                        ></el-input>
                    </el-form-item>
                    <el-row>
                        <el-col :span="16">
                            <el-form-item
                                label="执行负责人"
                                prop="executivechargeman"
                            >
                                <el-input clearable
                                    v-model="dialog.editorBox.form.data.executivechargeman"
                                    placeholder=""
                                    style="width: 100%;"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="实际执行时间"
                                prop="executivetime"
                            >
                                <el-date-picker
                                    value-format="yyyy-MM-dd HH:mm:ss"
                                    type="datetime"
                                    v-model="dialog.editorBox.form.data.executivetime"
                                    placeholder=""
                                    style="width: 100%;"
                                ></el-date-picker>
                            </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()"
                >暂 存</el-button>
                <el-button
                    type="primary"
                    @click="submitBut()"
                >提 交</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import fileUploadBox from '@/components/zg/fileUploadBox.vue'
import { formatDate } from '@/utils/util.js'
import store from '@/store/index.js';
export default {
    name: 'PWODPerform',
    components: {
        'zj-fileUploadBox': fileUploadBox
    },
    data () {
        return {
            store,
            userInfo: {
                data: null
            },
            activeMenu: '',
            filterForm: {
                show: true,
                data: {
                    creattime: '',
                    mediumsystem: '',
                    signtime: '',
                    equipmentname: '',
                    executivetime: '',
                    applyman: '',
                    applyunit: '',
                    billstatus: 'execute'
                    // operatestatus: ''
                },
                rules: {
                    billsno: [
                        { required: true, message: '该项不能为空', trigger: 'change' }
                    ]
                }
            },
            pageNum: 1,
            pageSize: 20,
            total: 0,
            singleTableHeight: 100,
            tableData: [
                // {
                //     billsno: 'TFY_20190826_0001',
                //     creattime: '2019-08-26 15:03:56',
                //     equipmentname: 'aaa',
                //     applyman: 'admin',
                //     applyunit: '111',
                //     operatestatus: '暂存',
                //     billstatus: '编制'
                // }
            ],
            nameObj: {
                mediumsystem: {
                    obj: {
                        'WaterChannel': '水道',
                        'PowerChannel': '动力'
                    },
                    arr: [
                        {
                            id: 'WaterChannel',
                            name: '水道'
                        },
                        {
                            id: 'PowerChannel',
                            name: '动力'
                        }
                    ]
                },
                // operatestatus: {
                //     obj: {
                //         'save': '暂存'
                //     },
                //     arr: [
                //         {
                //             id: 'save',
                //             name: '暂存'
                //         }
                //     ]
                // },
                billstatus: {
                    obj: {
                        '': '全部',
                        'create': '编制',
                        'sign': '待签收',
                        'execute': '待执行',
                        'executed': '结束',
                        'drop': '报废'
                    },
                    arr: [
                        {
                            id: '',
                            name: '全部'
                        },
                        {
                            id: 'create',
                            name: '编制'
                        },
                        {
                            id: 'sign',
                            name: '待签收'
                        },
                        {
                            id: 'execute',
                            name: '待执行'
                        },
                        {
                            id: 'executed',
                            name: '结束'
                        },
                        {
                            id: 'drop',
                            name: '报废'
                        }
                    ]
                }
            },
            loading: false,
            tableLoading: false,
            dialog: {
                editorBox: {
                    show: false,
                    type: '',
                    form: {
                        data: {
                            mediumsystem: '',
                            billsno: '',
                            creattime: '',
                            applyman: '',
                            applychargeman: '',
                            applyunit: '',
                            equipmentname: '',
                            stoptime: '',
                            restarttime: '',
                            linkmantel: '',
                            timestart: '',
                            timeover: '',
                            chargemantel: '',
                            address: '',
                            workcontent: '',
                            attention: '',
                            structdiagram: '',
                            structurediagram: '', // 文件名
                            contentchange: '',
                            safetyprecautions: '',
                            signman: '',
                            signtime: '',
                            executivesituation: '',
                            note: '',
                            executivechargeman: '',
                            executivetime: '',
                            billstatus: ''
                        },
                        rules: {
                            executivesituation: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                            ],
                            note: [],
                            executivechargeman: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                            ],
                            executivetime: [
                                { required: true, message: '该项不能为空', trigger: 'change' }
                            ]
                        }
                    },
                    files: [
                        // {
                        //     name: '测试',
                        //     url: '',
                        //     file: null,
                        //     operation: '' // add or del
                        // }
                    ]
                }
            }
        };
    },
    created () {
        this.activeMenu = window.localStorage.getItem('activeMenu');
    },
    mounted () {
        let that = this;
        window.PEDataObj = {
            // 将数据绑定到window上，供main页面使用
            vm: that,
            // tableArr：用于导出成Excel的表格的信息
            tableArr: [
                {
                    name: '',
                    id: 'singleTable'
                }
            ]
        };
        that.$nextTick(() => {
            // 立即获取的height有一定偏差，通过setTimeout延迟来解决
            setTimeout(() => {
                that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 45;
            }, 1);
        });
        that.store.dispatch('getUserInfo').then((res) => {
            that.userInfo.data = res.data;
        });
        that.getTableData();
    },
    methods: {
        //  计算树区域高度
        getRoleHeight (dom) {
            return window.innerHeight - dom.offsetTop;
        },
        // 获取表格中的数据
        getTableData (pageNum) {
            let that = this,
                params = {
                    creattime: that.filterForm.data.creattime[0],
                    creattimee: that.filterForm.data.creattime[1],
                    mediumsystem: that.filterForm.data.mediumsystem,
                    signtime: that.filterForm.data.signtime[0],
                    signtimee: that.filterForm.data.signtime[1],
                    equipmentname: that.filterForm.data.equipmentname,
                    executivetime: that.filterForm.data.executivetime[0],
                    executivetimee: that.filterForm.data.executivetime[1],
                    applyman: that.filterForm.data.applyman,
                    applyunit: that.filterForm.data.applyunit,
                    billstatus: that.filterForm.data.billstatus
                    // operatestatus: that.filterForm.data.operatestatus
                };
            that.pageNum = pageNum || that.pageNum;
            that.tableLoading = true;
            let url = 'pass/ems/v1/tcm036s/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize;
            that.axios.get(url, {
                params: params
            })
                .then(function (res) {
                    if (res.code === '0') {
                        let arr = [];
                        for (let item of res.data.list) {
                            arr.push({
                                billsno: item.billsno,
                                mediumsystem: item.mediumsystem,
                                creattime: item.creattime,
                                applyman: item.applyman,
                                applychargeman: item.applychargeman,
                                applyunit: item.applyunit,
                                equipmentname: item.equipmentname,
                                stoptime: item.stoptime,
                                restarttime: item.restarttime,
                                linkmantel: item.linkmantel,
                                timestart: item.timestart,
                                timeover: item.timeover,
                                chargemantel: item.chargemantel,
                                address: item.address,
                                workcontent: item.workcontent,
                                attention: item.attention,
                                structdiagram: item.structdiagram,
                                contentchange: item.contentchange,
                                safetyprecautions: item.safetyprecautions,
                                signman: item.signman,
                                signtime: item.signtime,
                                executivesituation: item.executivesituation,
                                note: item.note,
                                executivechargeman: item.executivechargeman,
                                executivetime: item.executivetime,
                                // operatestatus: item.operatestatus,
                                billstatus: item.billstatus,
                                structurediagram: item.structurediagram
                            })
                        }
                        that.tableData = arr;
                        that.total = res.data.total;
                    } else {
                        that.$message.error(res.message);
                    }
                    that.tableLoading = false;
                }).catch(function () {
                    that.tableLoading = false;
                });
        },
        // 改变表格显示条数
        tableSizeChange (val) {
            let that = this;
            that.pageSize = val;
            that.getTableData(1);
        },
        // 重置搜索
        tableDataCancel () {
            let that = this;
            for (let key in that.filterForm.data) {
                if (that.filterForm.data[key] instanceof Array) {
                    that.filterForm.data[key] = [];
                } else {
                    that.filterForm.data[key] = '';
                }
            }
            that.filterForm.data.billstatus = 'execute';
            that.getTableData(1);
        },
        but_edit (row) {
            let that = this;
            that.dialog.editorBox.files = [];
            for (let key in that.dialog.editorBox.form.data) {
                if (typeof row[key] !== 'undefined') {
                    that.dialog.editorBox.form.data[key] = row[key];
                } else {
                    console.log(key);
                }
            }
            if (row.structurediagram) {
                let fn = (row.structurediagram + '').trim().split(';')
                if (fn && fn.length > 0) {
                    let billsno = row.billsno;
                    for (let i = 0; i < fn.length; i++) {
                        if (fn[i]) {
                            let fname = {name: fn[i], url: '/zhongsteel.pass.web/pass/ems/static/' + billsno + '/' + fn[i], file: null, operation: ''};
                            that.dialog.editorBox.files.push(fname);
                        }
                    }
                }
            }
            that.dialog.editorBox.form.data.executivechargeman = that.dialog.editorBox.form.data.executivechargeman ? that.dialog.editorBox.form.data.executivechargeman : that.userInfo.data.userName;
            that.dialog.editorBox.form.data.executivetime = that.dialog.editorBox.form.data.executivetime ? that.dialog.editorBox.form.data.executivetime : formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss');
            that.dialog.editorBox.type = 'edit';
            that.dialog.editorBox.show = true;
        },
        submitBut () {
            let that = this;
            that.$confirm('是否提交?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                that.dataSave('submit');
            }).catch(() => {
            });
        },
        dataSave (billstatus) {
            let that = this;
            let SubmitData = {
                mediumsystem: that.dialog.editorBox.form.data.mediumsystem,
                billsno: that.dialog.editorBox.form.data.billsno,
                creattime: that.dialog.editorBox.form.data.creattime,
                applyman: that.dialog.editorBox.form.data.applyman,
                applychargeman: that.dialog.editorBox.form.data.applychargeman,
                applyunit: that.dialog.editorBox.form.data.applyunit,
                equipmentname: that.dialog.editorBox.form.data.equipmentname,
                stoptime: that.dialog.editorBox.form.data.stoptime,
                restarttime: that.dialog.editorBox.form.data.restarttime,
                linkmantel: that.dialog.editorBox.form.data.linkmantel,
                timestart: that.dialog.editorBox.form.data.timestart,
                timeover: that.dialog.editorBox.form.data.timeover,
                chargemantel: that.dialog.editorBox.form.data.chargemantel,
                address: that.dialog.editorBox.form.data.address,
                workcontent: that.dialog.editorBox.form.data.workcontent,
                attention: that.dialog.editorBox.form.data.attention,
                structdiagram: that.dialog.editorBox.form.data.structdiagram,
                structurediagram: that.dialog.editorBox.form.data.structurediagram, // 文件名
                contentchange: that.dialog.editorBox.form.data.contentchange,
                safetyprecautions: that.dialog.editorBox.form.data.safetyprecautions,
                signman: that.dialog.editorBox.form.data.signman,
                signtime: that.dialog.editorBox.form.data.signtime,
                executivesituation: that.dialog.editorBox.form.data.executivesituation,
                note: that.dialog.editorBox.form.data.note,
                executivechargeman: that.dialog.editorBox.form.data.executivechargeman,
                executivetime: that.dialog.editorBox.form.data.executivetime
            };
            let message = '保存成功';
            if (billstatus) {
                if (billstatus === 'submit') {
                    SubmitData.billstatus = that.dialog.editorBox.form.data.billstatus;
                    message = '提交成功';
                } else {
                    SubmitData.billstatus = billstatus;
                    message = '操作成功';
                }
            }
            that.$refs['dialog_form'].validate((valid) => {
                if (valid) {
                    that.loading = true;
                    let url = 'pass/ems/v1/tcm036s/';
                    if (billstatus === 'submit') {
                        url = 'pass/ems/v1/tcm036s/submit/';
                    }
                    let fileData = new FormData();
                    for (let key in SubmitData) {
                        fileData.append(key, SubmitData[key] ? SubmitData[key] : '');
                    }
                    that.axios.put(url, fileData, {headers: {'Content-Type': 'multipart/form-data'}})
                        .then(function (res) {
                            if (res.code === '0') {
                                that.$message({
                                    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;
                        });
                }
            });
        }
    }
}
</script>

<style lang="less">
.PWODPerform {
    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;
            }
        }
    }
    .nr-textarea {
        .el-textarea__inner {
            min-height: 130px !important;
        }
    }
    .fileUploadBox {
        height: 130px;
        min-height: 130px !important;
        margin-bottom: 18px;
    }
}
</style>
