<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 @click="upfile" size="small">导入</el-button>
        <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="abnormal" label="风机数量" width="80">
          <template slot-scope="scope">
            <el-button @click="ONdraught(scope.row)" type="text" size="small">10</el-button>
          </template>
        </el-table-column>

        <el-table-column align="center" prop="abnormal" label="测风塔" width="80">
          <template slot-scope="scope">
            <el-button @click="ONanemometer(scope.row)" type="text" size="small">1</el-button>
          </template>
        </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="" align="center" label="状态" width="100">
        </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-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>
        <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-select v-model="shi" placeholder="请选择">
            <el-option v-for="item in shiOptions" :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 class="condition">
          <p>测风塔:</p>
          <el-select v-model="anemometer" placeholder="请选择">
            <el-option v-for="item in anemometerOptions" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </div>
      </div>
      <div class="bianji" v-show="listedfiles">
        <el-table :data="tableData" style="width: 100%">
          <el-table-column prop="" label="文件名" width="180">
          </el-table-column>
          <el-table-column prop="" label="文件类型" width="180">
          </el-table-column>
          <el-table-column prop="" label="文件大小"> </el-table-column>
          <el-table-column fixed="right" label="操作" width="120">
            <template slot-scope="scope">
              <el-button @click.native.prevent="deleteRow(scope.row)" type="text" size="small">
                删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </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>

    <!-- 风场详情 -->
    <WindsiteMessage :unusualdialog="unusualdialog" @handleClose="handleClose"></WindsiteMessage>
    <!-- 测风塔 -->
    <windsitemachine :anemometerdialog="anemometerdialog" @handleClose="handleClose"></windsitemachine>
    <!-- 风机数量 -->
    <windsitetower :draught="draught" @handleClose="handleClose"></windsitetower>
    <!-- 上传 -->
    <windsiteup :uploadingPOP="uploadingPOP" @handleClose="handleClose"></windsiteup>
    <!-- 导入 -->
    <windsitetolead :tolead=tolead @handleClose="handleClose"></windsitetolead>
  </div>
</template>

<script>
import WindsiteMessage from './component/windsiteMessage.vue';
import windsitemachine from './component/windsitemachine.vue';
import windsitetower from './component/windsitetower.vue';
import windsiteup from './component/windsiteup.vue';
import windsitetolead from './component/windsitetolead.vue';




export default {
  components: {
    WindsiteMessage, windsitemachine, windsitetower, windsiteup, windsitetolead
  },
  data() {

    return {
      // 新增信息
      windsiteName: "",
      airdensity: "",
      superior: "",
      superiorOptions: [],
      altitude: "",
      sheng: "",
      shengOptions: [],
      shi: "",
      shiOptions: [],
      longitude: "",
      dimensionality: "",
      anemometer: "",
      anemometerOptions: [],

      listedfiles:false,
      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,
      tolead: false,
      draught: false,
      anemometerdialog: false,
      uploadingPOP: false,
      newform: {
        unit: "",
        province: "",
        city: "",
        descr: "",
      },
      title: "新增",
    };
  },

  methods: {
    handleClose(value, dialogName) {
      this[dialogName] = value
    },
    rowStyle() {
      return "text-align:center";
    },

    // 查询
    onSubmit() {
      console.log("submit!");
    },
    // 重置
    reset() { },
    //导入提交
    UPsubmit() {
      this.tolead = false;
    },
    // 新增
    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.listedfiles=true
      this.title = "编辑";
    },
    // 上传附件
    uploading(row) {
      this.uploadingPOP = true;
    },

    // 启用
    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: "已取消删除",
          });
        });
    },
    // 导入
    upfile() {
      this.tolead = true;
    },
    // 新增
    newnuedialog() {
      this.nuedialog = true;
      this.listedfiles=false
      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;
  }
}


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