<template>
    <div class="global-variable">
        <div class="condition">
            <el-form :inline="true" :model="formInline" class="demo-form-inline">
                <el-form-item label="机型型号:">
                    <el-input v-model="formInline.user" placeholder="请输入批次编号" size="small"></el-input>
                </el-form-item>
                <el-form-item label="选择日期:" size="small">
                    <el-date-picker v-model="formInline.timeQuantum" type="daterange" range-separator="至"
                        start-placeholder="开始日期" end-placeholder="结束日期">
                    </el-date-picker>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit" size="small">查询</el-button>
                    <el-button @click="reset" size="small">重置</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div class="list-page">
            <div class="newly">

                <el-button type="primary" @click="newnuedialog" size="small">新增</el-button>
            </div>

            <el-table class="center-align-table" :data="tableData" border :cell-style="rowStyle">
                <el-table-column align="center" fixed prop="" label="机型型号">
                    <template slot-scope="scope">
                        <el-button @click="particulars(scope.row)" type="text" size="small">泗洪风场</el-button>
                    </template>
                </el-table-column>

                <el-table-column align="center" label="厂商编号"> </el-table-column>


                <el-table-column prop="" align="center" label="机型类型" width="100">
                </el-table-column>
                <el-table-column prop="" align="center" label="厂商名称" width="100">
                </el-table-column>

                <el-table-column prop="" align="center" label="品牌名称" width="100">
                </el-table-column>
                <el-table-column prop="" align="center" label="状态" width="100">
                </el-table-column>
                <el-table-column prop="" align="center" label="创建时间">
                </el-table-column>
                <el-table-column prop="transition" align="center" fixed="right" label="操作" width="200">
                    <template slot-scope="scope">
                        <el-button @click="compile(scope.row)" type="text" size="small">编辑</el-button>
                        <el-button @click="uploading(scope.row)" type="text" size="small">上传</el-button>
                        <el-button v-if="scope.row.transition == 1" @click="start(scope.row)" type="text"
                            size="small">启用</el-button>
                        <el-button v-else style="color: #666" @click="stop(scope.row)" type="text"
                            size="small">停用</el-button>
                        <el-button style="color: #f00" @click="deleted(scope.row)" type="text"
                            size="small">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination :page-size="10" :pager-count="11" layout="total, prev, pager, next" :total="35">
                </el-pagination>
            </div>
        </div>

        <!-- 弹出层 -->

        <!-- 新增 -->
        <el-dialog :title="title" :visible.sync="nuedialog" width="800px">
            <div class="general">

                <div class="condition">
                    <p>机型型号:</p>
                    <el-input v-model="windsiteName"></el-input>
                </div>
                <div class="condition">
                    <p>厂商名称:</p>
                    <el-input v-model="airdensity"></el-input>
                </div>


                <div class="condition">
                    <p>品牌名称:</p>
                    <el-input v-model="altitude"></el-input>
                </div>

                <div class="condition">
                    <p>驱动方式:</p>
                    <el-select v-model="sheng" placeholder="请选择">
                        <el-option v-for="item in shengOptions" :key="item.value" :label="item.label"
                            :value="item.value">
                        </el-option>
                    </el-select>
                </div>

                <div class="condition">
                    <p>塔筒高度:</p>
                    <el-input v-model="longitude"></el-input>
                </div>

                <div class="condition">
                    <p>叶片长度:</p>
                    <el-input v-model="dimensionality"></el-input>
                </div>


            </div>

            <span slot="footer" class="dialog-footer">
                <el-button @click="nuedialog = false" size="small">取 消</el-button>
                <el-button type="primary" @click="newly" size="small">确 定</el-button>
            </span>
        </el-dialog>

        <!-- 风场详情 -->
        <el-dialog title="机器详情" :visible.sync="unusualdialog" width="800px">
            <div class="general">
                <div class="condition">
                    <p>机型型号:</p>
                </div>
                <div class="condition">
                    <p>厂商名称:</p>
                </div>

                <div class="condition">
                    <p>厂商编号:</p>
                </div>
                <div class="condition">
                    <p>品牌名称:</p>
                </div>

                <div class="condition">
                    <p>驱动方式:</p>
                </div>
                <div class="condition">
                    <p>状态:</p>
                </div>
                <div class="condition">
                    <p>塔筒高度:</p>
                </div>

                <div class="condition">
                    <p>叶片长度:</p>
                </div>


            </div>
            <div class="attachment">
                <p>下载标准功率曲线附件</p>

            </div>
        </el-dialog>

        <!-- 风机数量 -->
        <el-dialog title="风机信息" :visible.sync="draught" width="1000px">
            <el-table class="center-align-table" :data="tableData" border :cell-style="rowStyle" stripe>
                <!-- Table Columns -->
                <el-table-column fixed prop="name" align="center" label="风机名称">
                </el-table-column>
                <el-table-column prop="" align="center" label="风机编号">
                </el-table-column>
                <el-table-column prop="" align="center" label="风机机型">
                </el-table-column>
                <el-table-column prop="" align="center" label="主机厂商">
                </el-table-column>
                <el-table-column prop="" align="center" label="是否标杆">
                </el-table-column>
                <el-table-column prop="" align="center" label="海拔高度/米" width="80">
                </el-table-column>
                <el-table-column prop="" align="center" label="经度" width="80">
                </el-table-column>
                <el-table-column prop="" align="center" label="纬度" width="80">
                </el-table-column>
                <el-table-column prop="" align="center" label="额定容量">
                </el-table-column>
            </el-table>

            <div class="pagination-container">
                <el-pagination :page-size="10" :pager-count="11" layout="total, prev, pager, next" :total="35">
                </el-pagination>
            </div>
        </el-dialog>
        <!-- 测风塔 -->
        <el-dialog title="测风塔信息" :visible.sync="anemometerdialog" width="800px">
            <H3 class="centeredH3">测风塔名称</H3>
            <div class="general">
                <div class="condition">
                    <p>测风塔编号:</p>
                </div>
                <div class="condition">
                    <p>测风塔名称:</p>
                </div>

                <div class="condition">
                    <p>经度:</p>
                </div>
                <div class="condition">
                    <p>维度:</p>
                </div>

                <div class="condition">
                    <p>测风塔高度:</p>
                </div>
            </div>
        </el-dialog>


        <!-- 上传 -->
        <el-dialog title="上传文件" :visible.sync="uploadingPOP" width="400px">
            <div class="UPcondition">
                <p>文件类型:</p>
                <el-select v-model="superior" placeholder="请选择">
                    <el-option v-for="item in superiorOptions" :key="item.value" :label="item.label"
                        :value="item.value">
                    </el-option>
                </el-select>
            </div>
            <p class="model-center">模板下载</p>

            <el-upload class="upload-demo" :file-list="fileList" drag
                action="https://jsonplaceholder.typicode.com/posts/" multiple>
                <i class="el-icon-upload"></i>
                <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                <div class="el-upload__tip" slot="tip">
                    只能上传jpg/png文件，且不超过500kb
                </div>
            </el-upload>
            <span slot="footer" class="dialog-footer">
                <el-button @click="uploadingPOP = false" size="small">取 消</el-button>
                <el-button type="primary" @click="filesubmit" size="small">提交</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
export default {
    data() {
        return {
            // 新增信息
            windsiteName: "",
            airdensity: "",
            superior: "",
            superiorOptions: [],
            altitude: "",
            sheng: "",
            shengOptions: [],
            shi: "",
            shiOptions: [],
            longitude: "",
            dimensionality: "",
            anemometer: "",
            anemometerOptions: [],

            fileList: [
                {
                    name: "food.jpeg",
                    url: "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100",
                },

            ],
            formInline: {
                user: "",
                region: "",
                timeQuantum: "",
            },
            tableData: [
                {
                    id: 1,
                    name: "王小虎",
                    transition: "1",
                },
                {
                    id: 3,
                    name: "王小虎",
                    abnormal: "1",
                    transition: "0",
                    children: [
                        {
                            id: 31,

                            name: "王小虎",

                            abnormal: "1",
                        },
                    ],
                },
            ],
            nuedialog: false,
            unusualdialog: false,

            draught: false,
            anemometerdialog: false,
            uploadingPOP: false,
            newform: {
                unit: "",
                province: "",
                city: "",
                descr: "",
            },
            title: "新增",
        };
    },
    methods: {
        rowStyle() {
            return "text-align:center";
        },

        // 查询
        onSubmit() {
            console.log("submit!");
        },
        // 重置
        reset() { },

        // 新增
        newly() {
            this.nuedialog = false;
        },

        //异常详情
        particulars(row) {
            this.unusualdialog = true;
        },
        //风机信息
        ONdraught(row) {
            this.draught = true;
        },
        ONanemometer(row) {
            this.anemometerdialog = true;
        },
        // 编辑
        compile(row) {
            this.nuedialog = true;
            this.title = "编辑";
        },
        // 上传附件
        uploading(row) {
            this.uploadingPOP = true;
        },
        // 附件提交
        filesubmit() {
            this.uploadingPOP = false;
        },
        // 启用
        start(row) { },
        // 停用
        stop(row) { },
        // 删除
        deleted(row) {
            this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    this.$message({
                        type: "success",
                        message: "删除成功!",
                    });
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消删除",
                    });
                });
        },
        // 删除附件
        deleteRow(row) {
            this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    this.$message({
                        type: "success",
                        message: "删除成功!",
                    });
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消删除",
                    });
                });
        },


        // 新增
        newnuedialog() {
            this.nuedialog = true;
            this.title = "新增";
        },
    },
};
</script>

<style lang="scss" scoped>
.general {
    display: flex;
    flex-wrap: wrap;

    .condition {
        width: 50%;
        display: flex;

        p {
            width: 100px;
            text-align: right;
            line-height: 40px;
        }

        span {
            line-height: 40px;

            padding-left: 20px;
        }

        .el-select {
            width: 100%;
            margin-bottom: 20px;
        }

        .el-input {
            margin-bottom: 20px;
        }
    }
}

.UPcondition {
    display: flex;

    p {
        width: 74px;
        text-align: right;
        line-height: 40px;
    }

    .el-select {
        width: 100%;
        margin-bottom: 20px;
    }

    .el-input {
        margin-bottom: 20px;
    }
}

.attachment {
    display: flex;
    padding-top: 10px;

    p {
        margin-right: 20px;
        color: #409eff;
    }
}

.model-center {
    color: #666;
    line-height: 40px;
    height: 40px;
    font-size: 14px;
}
</style>