<template>
  <div class="app-container">
    <div class="dark-el-button">
      <el-button type="primary" icon="el-icon-plus" @click="handleAdd" class="myButton">新增</el-button>
    </div>

    <!--上报对象表格-->
    <el-table
      :data="tableData"
      :header-cell-style="{background:'#ECF1FE'}"
      v-loading="tableLoading" border style="width: 100%">
      <el-table-column type="expand">
        <template slot-scope="props">
          <table style="width: 100%;text-align: left">
            <tr>
              <td>温度公式：{{ props.row.t }}</td>
              <td>湿度公式：{{ props.row.rh }}</td>
              <td>气压公式：{{ props.row.pressure }}</td>
            </tr>
            <tr>
              <td>总辐射公式：{{ props.row.globalRadiation }}</td>
              <td>直辐射公式：{{ props.row.directRadiation }}</td>
              <td>散辐射公式：{{ props.row.diffuseRadiation }}</td>
            </tr>
            <tr>
              <td>10米风速公式：{{ props.row.ws10 }}</td>
              <td>10米风向公式：{{ props.row.wd10 }}</td>
              <td>30米风速公式：{{ props.row.ws30 }}</td>
              <td>30米风向公式：{{ props.row.wd30 }}</td>
            </tr>
            <tr>
              <td>50米风速公式：{{ props.row.ws50 }}</td>
              <td>50米风向公式：{{ props.row.wd50 }}</td>
              <td>70米风速公式：{{ props.row.ws70 }}</td>
              <td>70米风向公式：{{ props.row.wd70 }}</td>
            </tr>
            <tr>
              <td>80米风速公式：{{ props.row.ws80 }}</td>
              <td>80米风向公式：{{ props.row.wd80 }}</td>
              <td>90米风速公式：{{ props.row.ws90 }}</td>
              <td>90米风向公式：{{ props.row.wd90 }}</td>
            </tr>
            <tr>
              <td>100米风速公式：{{ props.row.ws100 }}</td>
              <td>100米风向公式：{{ props.row.wd100 }}</td>
              <td>轮毂高风速公式：{{ props.row.wsHubHeight }}</td>
              <td>轮毂高风向公式：{{ props.row.wdHubHeight }}</td>
            </tr>
          </table>
        </template>
      </el-table-column>
      <el-table-column prop="dataType" align="center" label="数据类型" width="100px" :formatter="formatDataType"></el-table-column>
      <el-table-column prop="time" align="center" label="预测时间公式"></el-table-column>
<!--      <el-table-column prop="stationCode" align="center" label="场站编号"></el-table-column>-->
      <el-table-column label="操作" align="center" width="150px">
        <template slot-scope="scope">
          <el-button type="text" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑</el-button>
          <el-button type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page=this.page.currentPage
        :page-sizes="[10, 15, 30, 50]"
        :page-size=this.page.pageSize
        layout="total, sizes, prev, pager, next, jumper"
        :total=this.page.total>
      </el-pagination>
    </div>
    <!--编辑框-->
    <div class="dark-el-dialog">
      <el-dialog :title="saveFlag==1?'新增':'编辑'" :visible.sync="visible" width="100%" :fullscreen="true">

        <el-row :gutter="20">
          <el-col :span="16">


            <div>
                    <span style="color: red">
            <font size="4px">灰色文本框需要点击后，在右侧进行编辑录入！</font>
                    </span>
            </div>
            &nbsp;
            <div class="grid-content bg-purple">
              <el-form v-model="form" ref="form" :key="timer">
                <el-row :gutter="16">
                  <el-col :span="8">
                    <el-form-item prop="dataType" label-width="110px">
                    <span slot="label">
                      <font color="red">*</font>数据类型
                    </span>
                      <el-select popper-class="cpp-popper" v-model="form.dataType" clearable @focus="clearformula">
                        <el-option
                          v-for="item in this.dataTypes"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"/>
                      </el-select>
                    </el-form-item>
                  </el-col>

                </el-row>
                <!--              <el-row>-->
                <!--                <el-col :span="24">-->
                <!--                  <el-form-item prop="stationCode" label-width="110px">-->
                <!--                    <span slot="label">-->
                <!--                      <font color="red">*</font>场站编号-->
                <!--                    </span>-->
                <!--                     <el-select popper-class="cpp-popper" v-model="form.stationCode" multiple clearable @focus="clearformula" style="width: 100%">-->
                <!--                      <el-option-->
                <!--                        v-for="item in this.stationCodeList"-->
                <!--                        :key="item.stationCode"-->
                <!--                        :label="item.stationCode"-->
                <!--                        :value="item.stationCode"/>-->
                <!--                    </el-select>-->
                <!--                  </el-form-item>-->
                <!--                </el-col>-->
                <!--              </el-row>-->
                <el-row :gutter="16">
                  <el-col :span="8">
                    <el-form-item prop="time" label-width="110px" class="formulaColor">
                    <span slot="label">
                      <font color="red">*</font>预测时间公式
                    </span>
                      <el-input v-model="form.time" readonly
                                @click.native="ftck(form.time,'form.time','(预测时间)')"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="globalRadiation" label-width="110px" class="formulaColor">
                    <span slot="label">
                      总辐射公式
                    </span>
                      <el-input v-model="form.globalRadiation" readonly
                                @click.native="ftck(form.globalRadiation,'form.globalRadiation','(总辐射)')"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="directRadiation" label-width="110px" class="formulaColor">
                    <span slot="label">
                      直辐射公式
                    </span>
                      <el-input v-model="form.directRadiation" readonly
                                @click.native="ftck(form.directRadiation,'form.directRadiation','(直辐射)')"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="16">
                  <el-col :span="8">
                    <el-form-item prop="diffuseRadiation" label-width="110px" class="formulaColor">
                    <span slot="label">
                     散辐射公式
                    </span>
                      <el-input v-model="form.diffuseRadiation" readonly
                                @click.native="ftck(form.diffuseRadiation,'form.diffuseRadiation','(散辐射)')"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="ws10" label-width="110px" class="formulaColor">
                    <span slot="label">
                      10米风速
                    </span>
                      <el-input v-model="form.ws10" readonly
                                @click.native="ftck(form.ws10,'form.ws10','(10米风速)')"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="wd10" label-width="110px" class="formulaColor">
                    <span slot="label">
                      10米风向
                    </span>
                      <el-input v-model="form.wd10" readonly
                                @click.native="ftck(form.wd10,'form.wd10','(10米风向)')"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="16">
                  <el-col :span="8">
                    <el-form-item prop="ws30" label-width="110px" class="formulaColor">
                    <span slot="label">
                     30米风速
                    </span>
                      <el-input v-model="form.ws30" readonly
                                @click.native="ftck(form.ws30,'form.ws30','(30米风速)')"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="wd30" label-width="110px" class="formulaColor">
                    <span slot="label">
                      30米风向
                    </span>
                      <el-input v-model="form.wd30" readonly
                                @click.native="ftck(form.wd30,'form.wd30','(30米风向)')"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="ws50" label-width="110px" class="formulaColor">
                    <span slot="label">
                      50米风速
                    </span>
                      <el-input v-model="form.ws50" readonly
                                @click.native="ftck(form.ws50,'form.ws50','(50米风速)')"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="16">
                  <el-col :span="8">
                    <el-form-item prop="wd50" label-width="110px" class="formulaColor">
                    <span slot="label">
                     50米风向
                    </span>
                      <el-input v-model="form.wd50" readonly
                                @click.native="ftck(form.wd50,'form.wd50','(50米风向)')"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="ws70" label-width="110px" class="formulaColor">
                    <span slot="label">
                      70米风速
                    </span>
                      <el-input v-model="form.ws70" readonly
                                @click.native="ftck(form.ws70,'form.ws70','(70米风速)')"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="wd70" label-width="110px" class="formulaColor">
                    <span slot="label">
                      70米风向
                    </span>
                      <el-input v-model="form.wd70" readonly
                                @click.native="ftck(form.wd70,'form.wd70','(70米风向)')"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="16">
                  <el-col :span="8">
                    <el-form-item prop="ws80" label-width="110px" class="formulaColor">
                    <span slot="label">
                     80米风速
                    </span>
                      <el-input v-model="form.ws80" readonly
                                @click.native="ftck(form.ws80,'form.ws80','(80米风速)')"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="wd80" label-width="110px" class="formulaColor">
                    <span slot="label">
                      80米风向
                    </span>
                      <el-input v-model="form.wd80" readonly
                                @click.native="ftck(form.wd80,'form.wd80','(80米风向)')"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="ws90" label-width="110px" class="formulaColor">
                    <span slot="label">
                      90米风速
                    </span>
                      <el-input v-model="form.ws90" readonly
                                @click.native="ftck(form.ws90,'form.ws90','(90米风速)')"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="16">
                  <el-col :span="8">
                    <el-form-item prop="wd90" label-width="110px" class="formulaColor">
                    <span slot="label">
                     90米风向
                    </span>
                      <el-input v-model="form.wd90" readonly
                                @click.native="ftck(form.wd90,'form.wd90','(90米风向)')"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="ws100" label-width="110px" class="formulaColor">
                    <span slot="label">
                      100米风速
                    </span>
                      <el-input v-model="form.ws100" readonly
                                @click.native="ftck(form.ws100,'form.ws100','(100米风速)')"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="wd100" label-width="110px" class="formulaColor">
                    <span slot="label">
                      100米风向
                    </span>
                      <el-input v-model="form.wd100" readonly
                                @click.native="ftck(form.wd100,'form.wd100','(100米风向)')"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="16">
                  <el-col :span="8">
                    <el-form-item prop="wsHubHeight" label-width="110px" class="formulaColor">
                    <span slot="label">
                      100米风速
                    </span>
                      <el-input v-model="form.wsHubHeight" readonly
                                @click.native="ftck(form.wsHubHeight,'form.wsHubHeight','(轮毂高风速)')"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="wdHubHeight" label-width="110px" class="formulaColor">
                    <span slot="label">
                      100米风向
                    </span>
                      <el-input v-model="form.wdHubHeight" readonly
                                @click.native="ftck(form.wdHubHeight,'form.wdHubHeight','(轮毂高风向)')"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="16">
                  <el-col :span="8">
                    <el-form-item prop="t" label-width="110px" class="formulaColor">
                    <span slot="label">
                     温度公式
                    </span>
                      <el-input v-model="form.t" readonly
                                @click.native="ftck(form.t,'form.t','(温度)')"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="rh" label-width="110px" class="formulaColor">
                    <span slot="label">
                      湿度公式
                    </span>
                      <el-input v-model="form.rh" readonly
                                @click.native="ftck(form.rh,'form.rh','(湿度)')"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="pressure" label-width="110px" class="formulaColor">
                    <span slot="label">
                      气压公式
                    </span>
                      <el-input v-model="form.pressure" readonly
                                @click.native="ftck(form.pressure,'form.pressure','(气压)')"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="handleSave('form')">
                  <span v-if="saveFlag == 1">保 存</span>
                  <span v-else>修 改</span>
                </el-button>
                <el-button @click="visible = false">取 消</el-button>
              </div>
            </div>

          </el-col>
          <el-col :span="1">
            <el-divider direction="vertical" style="height: 200px"></el-divider>
          </el-col>
          <el-col :span="5">
            <h2>公式编辑区{{ this.editinfo }}</h2>
            <el-form>
              <el-row>
                <el-col>
                  <el-form-item prop="rownumber" label-width="110px">
                  <span slot="label">
                      <font color="red">*</font>解析行
                  </span>
                    <el-input v-model="pfform.rownumber"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col>
                  <el-form-item prop="columnumber" label-width="110px">
                  <span slot="label">
                      <font color="red">*</font>解析列
                  </span>
                    <el-input v-model="pfform.columnumber"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col>
                  <el-form-item label="标签名" prop="signname" label-width="110px">
                    <el-input v-model="pfform.signname"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col>
                  <el-form-item label="时间格式" prop="timeformat" label-width="110px">
                    <el-select popper-class="cpp-popper" v-model="pfform.timeformat" clearable>
                      <el-option
                        v-for="item in this.timeFormat"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"/>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-button type="primary" @click="genformula">
                  <span>生成公式</span>
                </el-button>
                <el-button type="primary" @click="destoryformula">
                  <span>清除录入</span>
                </el-button>
              </el-row>
            </el-form>
          </el-col>
        </el-row>
      </el-dialog>
    </div>

  </div>
</template>

<script>
export default {
  name: "index",
  data() {
    return {
      // stationCodeList: [],
      dataTypes: [
        {value: 's', label: '时间单行'},
        {value: 'm', label: '时间多行'}
      ],
      timeFormat: [
        {value: 'yyyy-MM-dd HH:mm:ss', label: 'yyyy-MM-dd HH:mm:ss'},
        {value: 'yyyy-MM-dd', label: 'yyyy-MM-dd'},
        {value: 'yyyy-MM-dd_HH:mm', label: 'yyyy-MM-dd_HH:mm'},
        {value: 'yyyy-MM-dd HH:mm', label: 'yyyy-MM-dd HH:mm'}
      ],
      editinfo: '',
      timer: new Date().getTime(),
      props: {multiple: true},
      staionList: [],//场站集合
      tableLoading: false,
      tableData: [],
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 10 // 每页显示多少条
      },
      info: '',
      visible: false,
      form: {
        // fileName: '',
        time: '',
        dataType: 'm',
        // stationCode: '',
        t: '',
        rh: '',
        pressure: '',
        globalRadiation: '',
        directRadiation: '',
        diffuseRadiation: '',
        ws10: '',
        wd10: '',
        ws30: '',
        wd30: '',
        ws50: '',
        wd50: '',
        ws70: '',
        wd70: '',
        ws80: '',
        wd80: '',
        ws90: '',
        wd90: '',
        ws100: '',
        wd100: '',
        wsHubHeight: '',
        wdHubHeight: ''
      },
      pfform: {
        rownumber: '',
        columnumber: '',
        signname: '',
        timeformat: ''
      },
      tempformulasign: '',
      saveFlag: 1
    };
  },
  mounted() {
    // this.getElectricFieldList()
    this.getTableList()
  },
  methods: {
    formatDataType(row, column) {
      let belongTo = '未知类型'
      for (let i = 0; i < this.dataTypes.length; i++) {
        if (row.dataType === this.dataTypes[i].value) {
          belongTo = this.dataTypes[i].label
        }
      }
      return belongTo
    },
    getTableList() {
      this.tableLoading = true
      this.$axios.get("/parsingNwp/page", {
        params: {
          currentPage: this.page.currentPage,
          pageSize: this.page.pageSize
        }
      }).then(response => {
        this.tableData = response.data.records
        this.page.total = response.data.total
        this.tableLoading = false
      }).catch((e) => {
        this.tableLoading = false
      })
    },
    // getElectricFieldList() {
    //   // 获取所有场站
    //   fetchElectricFieldList().then(response => {
    //     this.stationCodeList = response.data
    //     this.tableLoading = false
    //   }).catch((e) => {
    //     this.tableLoading = false
    //   })
    // },
    destoryformula() {
      // 清空公式区字段
      if (this.tempformulasign == 'form.time') {
        this.form.time = ''
      }
      else if (this.tempformulasign == 'form.t') {
        this.form.t = ''
      }
      else if (this.tempformulasign == 'form.rh') {
        this.form.rh = ''
      }
      else if (this.tempformulasign == 'form.pressure') {
        this.form.pressure = ''
      }
      else if (this.tempformulasign == 'form.globalRadiation') {
        this.form.globalRadiation = ''
      }
      else if (this.tempformulasign == 'form.directRadiation') {
        this.form.directRadiation = ''
      }
      else if (this.tempformulasign == 'form.diffuseRadiation') {
        this.form.diffuseRadiation = ''
      }
      else if (this.tempformulasign == 'form.ws10') {
        this.form.ws10 = ''
      }
      else if (this.tempformulasign == 'form.wd10') {
        this.form.wd10 = ''
      }
      else if (this.tempformulasign == 'form.ws30') {
        this.form.ws30 = ''
      }
      else if (this.tempformulasign == 'form.wd30') {
        this.form.wd30 = ''
      }
      else if (this.tempformulasign == 'form.ws50') {
        this.form.ws50 = ''
      }
      else if (this.tempformulasign == 'form.wd50') {
        this.form.wd50 = ''
      }
      else if (this.tempformulasign == 'form.ws70') {
        this.form.ws70 = ''
      }
      else if (this.tempformulasign == 'form.wd70') {
        this.form.wd70 = ''
      }
      else if (this.tempformulasign == 'form.ws80') {
        this.form.ws80 = ''
      }
      else if (this.tempformulasign == 'form.wd80') {
        this.form.wd80 = ''
      }
      else if (this.tempformulasign == 'form.ws90') {
        this.form.ws90 = ''
      }
      else if (this.tempformulasign == 'form.wd90') {
        this.form.wd90 = ''
      }
      else if (this.tempformulasign == 'form.ws100') {
        this.form.ws100 = ''
      }
      else if (this.tempformulasign == 'form.wd100') {
        this.form.wd100 = ''
      }
      else if (this.tempformulasign == 'form.wsHubHeight') {
        this.form.wsHubHeight = ''
      }
      else if (this.tempformulasign == 'form.wdHubHeight') {
        this.form.wdHubHeight = ''
      }


      this.clearformula()
    },
    clearformula() {
      // 清空公式区字段
      this.pfform.rownumber = ''
      this.pfform.columnumber = ''
      this.pfform.signname = ''
      this.pfform.timeformat = ''
      this.editinfo = ''
      this.tempformulasign = ''
    },
    ftck(obj, sign, editname) {
      this.clearformula()
      if (obj != undefined && obj != null) {
        var objs = obj.split('<=>')
        for (let i = 0; i < objs.length; i++) {
          if (objs[i] != "") {
            if (i == 0) {
              this.pfform.rownumber = objs[i]
            } else if (i == 1) {
              this.pfform.columnumber = objs[i]
            } else if (i == 2) {
              this.pfform.signname = objs[i]
            } else if (i == 3) {
              this.pfform.timeformat = objs[i]
            }
          }
        }
      }
      this.tempformulasign = sign;
      this.editinfo = editname
    },
    genformula() {
      if (this.tempformulasign==''){
        this.$message.warning('请先选定左侧公式项')
        return
      }
      if (!this.pfform.rownumber || !this.pfform.columnumber) {
        this.$message.warning('填写必填项')
        return
      }
      if ((this.pfform.signname && !this.pfform.timeformat) || (!this.pfform.signname && this.pfform.timeformat)) {
        this.$message.warning('标签名称和时间格式要同时填写')
        return
      }
      // 拼装公式
      var resultStr = ''
      if (this.pfform.rownumber) {
        resultStr = this.pfform.rownumber
      }
      if (this.pfform.columnumber) {
        resultStr = resultStr + '<=>' + this.pfform.columnumber
      }
      if (this.pfform.signname) {
        resultStr = resultStr + '<=>' + this.pfform.signname
      }
      if (this.pfform.timeformat) {
        resultStr = resultStr + '<=>' + this.pfform.timeformat
      }
      // 将生成的公式赋值到左侧表格中
      if (this.tempformulasign == 'form.time') {
        this.form.time = resultStr
      }
      else if (this.tempformulasign == 'form.t') {
        this.form.t = resultStr
      }
      else if (this.tempformulasign == 'form.rh') {
        this.form.rh = resultStr
      }
      else if (this.tempformulasign == 'form.pressure') {
        this.form.pressure = resultStr
      }
      else if (this.tempformulasign == 'form.globalRadiation') {
        this.form.globalRadiation = resultStr
      }
      else if (this.tempformulasign == 'form.directRadiation') {
        this.form.directRadiation = resultStr
      }
      else if (this.tempformulasign == 'form.diffuseRadiation') {
        this.form.diffuseRadiation = resultStr
      }
      else if (this.tempformulasign == 'form.ws10') {
        this.form.ws10 = resultStr
      }
      else if (this.tempformulasign == 'form.wd10') {
        this.form.wd10 = resultStr
      }
      else if (this.tempformulasign == 'form.ws30') {
        this.form.ws30 = resultStr
      }
      else if (this.tempformulasign == 'form.wd30') {
        this.form.wd30 = resultStr
      }
      else if (this.tempformulasign == 'form.ws50') {
        this.form.ws50 = resultStr
      }
      else if (this.tempformulasign == 'form.wd50') {
        this.form.wd50 = resultStr
      }
      else if (this.tempformulasign == 'form.ws70') {
        this.form.ws70 = resultStr
      }
      else if (this.tempformulasign == 'form.wd70') {
        this.form.wd70 = resultStr
      }
      else if (this.tempformulasign == 'form.ws80') {
        this.form.ws80 = resultStr
      }
      else if (this.tempformulasign == 'form.wd80') {
        this.form.wd80 = resultStr
      }
      else if (this.tempformulasign == 'form.ws90') {
        this.form.ws90 = resultStr
      }
      else if (this.tempformulasign == 'form.wd90') {
        this.form.wd90 = resultStr
      }
      else if (this.tempformulasign == 'form.ws100') {
        this.form.ws100 = resultStr
      }
      else if (this.tempformulasign == 'form.wd100') {
        this.form.wd100 = resultStr
      }
      else if (this.tempformulasign == 'form.wsHubHeight') {
        this.form.wsHubHeight = resultStr
      }
      else if (this.tempformulasign == 'form.wdHubHeight') {
        this.form.wdHubHeight = resultStr
      }

      this.timer = new Date().getTime()
      this.clearformula()
    },
    /*保存*/
    handleSave(formName) {
      if (
        // !this.form.fileName ||
        !this.form.time || !this.form.dataType
        // || this.form.stationCode==""
      ) {
        this.$message.warning('填写必填项');
        return false;
      } else {
        if (this.saveFlag === 1) {
          this.$axios.post("/parsingNwp", this.form).then(response => {
            this.dialogVisible = false
            this.getTableList()
            this.tableLoading = false
            this.$message.success(response.data)
          }).catch(() => {
            this.tableLoading = false
          })
        } else {
          this.$axios.put("/parsingNwp", this.form).then(response => {
            this.dialogVisible = false
            this.getTableList()
            this.tableLoading = false
            this.$message.success(response.data)
          }).catch(() => {
            this.tableLoading = false
          })
        }
        this.visible = false
      }
    },
    /*上报对象*/
    handleAdd() {
      this.saveFlag = 1
      this.info = ''
      this.form = {
        // fileName: '',
        time: '',
        dataType: 'm',
        // stationCode: '',
        t: '',
        rh: '',
        pressure: '',
        globalRadiation: '',
        directRadiation: '',
        diffuseRadiation: '',
        ws10: '',
        wd10: '',
        ws30: '',
        wd30: '',
        ws50: '',
        wd50: '',
        ws70: '',
        wd70: '',
        ws80: '',
        wd80: '',
        ws90: '',
        wd90: '',
        ws100: '',
        wd100: '',
        wsHubHeight: '',
        wdHubHeight: ''
      }
      this.clearformula()
      this.visible = true
    },
    /*上报对象编辑*/
    handleEdit(row) {
      this.saveFlag = 2
      let newRow = Object.assign({},row)
      // let tempStationCode = newRow.stationCode.split(',')
      this.form = newRow
      // this.form.stationCode = tempStationCode
      this.clearformula()
      this.visible = true
    },
    /*上报对象删除*/
    handleDelete(row) {
      this.$confirm('是否确认删除此条配置?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.delete("/parsingNwp/" + row.id).then(response => {
          this.getTableList()
          this.$message.success(response.data)
        })
      })
    },
    /*上报对象pageSize改变*/
    handleSizeChange(val) {
      this.page.pageSize = val
      this.page.currentPage = 1
      this.getTableList()

    },
    /*上报对象currentPage改变*/
    handleCurrentChange(val) {
      this.page.currentPage = val
      this.getTableList()
    }
  }
}
</script>

<style scoped>
.block {
  float: right;
}

.myButton {
  margin-bottom: .5%;
}

.uploadno {
  background: #2d8cf0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  text-align: center;
  display: inline-block;
  color: #fff;
}

.el-divider--vertical {
  display: inline-block;
  width: 1px;
  height: 35em;
  margin: 0 8px;
  vertical-align: middle;
  position: relative;
}

/deep/ .formulaColor .el-input--small .el-input__inner {
  height: 32px;
  line-height: 32px;
  background-color: rgba(204, 204, 204, 0.5);
}

</style>
