<template>
  <div>
    <el-button type="primary" icon="el-icon-plus" plain @click="handleAdd" class="myButton">新增</el-button>
    <!--上报对象表格-->
    <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.lwr }}</td>
              <td>总辐射公式：{{ props.row.swr }}</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>170米风速公式：{{ props.row.ws170 }}</td>
              <td>170米风向公式：{{ props.row.wd170 }}</td>
            </tr>
          </table>
        </template>
      </el-table-column>
      <el-table-column prop="fileName" align="center" label="文件名关键字" width="200px"></el-table-column>
      <el-table-column prop="dataType" align="center" label="数据类型" width="100px" :formatter="formatDataType"></el-table-column>
      <el-table-column prop="preTime" align="center" label="预测时间公式"  width="300px"></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>
    <!--编辑框-->
    <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="fileName" label-width="110px">
                    <span slot="label">
                      <font color="red">*</font>文件名关键字
                    </span>
                    <el-input v-model="form.fileName" @focus="clearformula"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item prop="dataType" label-width="110px">
                    <span slot="label">
                      <font color="red">*</font>数据类型
                    </span>
                    <el-select v-model="form.dataType" clearable @focus="clearformula">
                      <el-option
                        v-for="item in this.dataType"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"/>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item prop="preTime" label-width="110px" class="formulaColor">
                    <span slot="label">
                      <font color="red">*</font>预测时间公式
                    </span>
                    <el-input v-model="form.preTime" readonly
                              @click.native="ftck(form.preTime,'form.preTime','(预测时间)')"></el-input>
                  </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 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="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-row :gutter="16">
                <el-col :span="8">
                  <el-form-item prop="lwr" label-width="110px" class="formulaColor">
                    <span slot="label">
                     全波总辐射公式
                    </span>
                    <el-input v-model="form.lwr" readonly
                              @click.native="ftck(form.lwr,'form.lwr','(全波总辐射)')"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item prop="swr" label-width="110px" class="formulaColor">
                    <span slot="label">
                      总辐射公式
                    </span>
                    <el-input v-model="form.swr" readonly
                              @click.native="ftck(form.swr,'form.swr','(总辐射)')"></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="ws170" label-width="110px" class="formulaColor">
                    <span slot="label">
                      170米风速
                    </span>
                    <el-input v-model="form.ws170" readonly
                              @click.native="ftck(form.ws170,'form.ws170','(170米风速)')"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item prop="wd170" label-width="110px" class="formulaColor">
                    <span slot="label">
                      170米风向
                    </span>
                    <el-input v-model="form.wd170" readonly
                              @click.native="ftck(form.wd170,'form.wd170','(170米风向)')"></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 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>
</template>

<script>

import {addObj, putObj, delObj, fetchListPage} from "@/api/an/PFParsingNwp";
import {fetchElectricFieldList} from "@/api/an/PFParsingCommon";

export default {
  name: "index",
  data() {
    return {
      stationCodeList: [],
      dataType: [
        {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: '',
        preTime: '',
        dataType: '',
        stationCode: '',
        t: '',
        rh: '',
        pressure: '',
        lwr: '',
        swr: '',
        directRadiation: '',
        diffuseRadiation: '',
        ws10: '',
        wd10: '',
        ws30: '',
        wd30: '',
        ws50: '',
        wd50: '',
        ws70: '',
        wd70: '',
        ws80: '',
        wd80: '',
        ws90: '',
        wd90: '',
        ws100: '',
        wd100: '',
        ws170: '',
        wd170: ''
      },
      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.dataType.length; i++) {
        if (row.dataType === this.dataType[i].value) {
          belongTo = this.dataType[i].label
        }
      }
      return belongTo
    },
    getTableList() {
      this.tableLoading = true
      // 获取列表
      fetchListPage(Object.assign({
        current: this.page.currentPage,
        size: this.page.pageSize
      })).then(response => {
        this.tableData = response.data.data.records
        this.page.total = response.data.data.total
        this.tableLoading = false
      }).catch((e) => {
        this.tableLoading = false
      })
    },
    getElectricFieldList() {
      // 获取所有场站
      fetchElectricFieldList().then(response => {
        this.stationCodeList = response.data.data
        this.tableLoading = false
      }).catch((e) => {
        this.tableLoading = false
      })
    },
    destoryformula() {
      // 清空公式区字段
      if (this.tempformulasign == 'form.preTime') {
        this.form.preTime = ''
      }
      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.lwr') {
        this.form.lwr = ''
      }
      else if (this.tempformulasign == 'form.swr') {
        this.form.swr = ''
      }
      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.ws170') {
        this.form.ws170 = ''
      }
      else if (this.tempformulasign == 'form.wd170') {
        this.form.wd170 = ''
      }
      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.preTime') {
        this.form.preTime = 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.lwr') {
        this.form.lwr = resultStr
      }
      else if (this.tempformulasign == 'form.swr') {
        this.form.swr = 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.ws170') {
        this.form.ws170 = resultStr
      }
      else if (this.tempformulasign == 'form.wd170') {
        this.form.wd170 = resultStr
      }
      this.timer = new Date().getTime()
      this.clearformula()
    },
    /*保存*/
    handleSave(formName) {
      if (!this.form.fileName || !this.form.preTime || !this.form.dataType || this.form.stationCode=="") {
        this.$message.warning('填写必填项');
        return false;
      } else {
        const data = this.form.stationCode
        let data1 = "";
        for (let n = 0; n < data.length; n++) {
          for (let j = 0; j < this.stationCodeList.length; j++) {
            if (data[n] == this.stationCodeList[j]["stationCode"]) {
              data1 = data1 + this.stationCodeList[j]["stationCode"] + ","
            }
          }
        }
        data1 = data1.substr(0, data1.length - 1)
        this.form.stationCode = data1
        if (this.saveFlag === 1) {
          addObj(this.form).then(response => {
            this.dialogVisible = false
            this.getTableList()
            this.tableLoading = false
            this.$message.success(response.data.data)
          }).catch(() => {
            this.tableLoading = false
          })
        } else {
          putObj(this.form).then(response => {
            this.dialogVisible = false
            this.getTableList()
            this.tableLoading = false
            this.$message.success(response.data.data)
          }).catch(() => {
            this.tableLoading = false
          })
        }
        this.visible = false
      }
    },
    /*上报对象*/
    handleAdd() {
      this.saveFlag = 1
      this.info = ''
      this.form = {}
      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(() => {
        delObj(row.id).then(response => {
          this.getTableList()
          this.$message.success(response.data.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: #cccccc;
}

</style>
