<!--视频配置-->
<template>
  <div class="systemBase">
    <div>
      <div class="common-title-div">视频配置
        <div class="common-operation-button-div">
          <el-button icon="el-icon-circle-plus-outline" type="primary" size="mini" v-loading.fullscreen.lock="operateLoading"
           @click="addData"  v-privilege="activeMenu + 'ADD'">新增</el-button>
          <el-button icon="el-icon-edit" type="primary" size="mini" v-loading.fullscreen.lock="operateLoading"
          @click="modifyData" v-privilege="activeMenu + 'UPDATE'">修改</el-button>
          <!-- <el-button size="mini" type="primary" icon="el-icon-check" v-loading.fullscreen.lock="operateLoading"
           @click="recoveryData">启用</el-button> -->
          <el-button size="mini" type="danger" plain icon="el-icon-remove-outline" v-loading.fullscreen.lock="operateLoading"
           @click="discardData" v-privilege="activeMenu + 'DELETE'">删除</el-button>
        </div>
      </div>
      <div class="common-table-div">
        <el-table ref="dataTable"  
          @row-click="rowChange" 
          border 
          :height="tableHeight" 
          highlight-current-row
          @current-change="handleCurrentChange" 
          :data="table.list" 
          :exchangeFilterMap="{'p1Rate':{'0':'主码','3':'辅码1','4':'辅码2'},
          'p2Rate':{'0':'主码','3':'辅码1','4':'辅码2'},
          'p3Rate':{'0':'主码','3':'辅码1','4':'辅码2'},
          'p4Rate':{'0':'主码','3':'辅码1','4':'辅码2'},
          'p5Rate':{'0':'主码','3':'辅码1','4':'辅码2'},
          'p6Rate':{'0':'主码','3':'辅码1','4':'辅码2'},
          'p7Rate':{'0':'主码','3':'辅码1','4':'辅码2'},
          'p8Rate':{'0':'主码','3':'辅码1','4':'辅码2'},
          'captureimageflag':{'0':'视频流摄像头截图','1':'视频流硬盘录像机截图','2':'非视频流硬盘录像机截图','3':'非视频流摄像头截图'},
          'isSecond0':{'0':'否','1':'是'}}"
          :icore-filter-flag="icoreFilterFlag">
          <el-table-column type="index" label="序号" fixed="left" align="center"></el-table-column>
          <!-- <el-table-column type="selection" width="55" align="center"></el-table-column> -->
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="pointid" label="计量点编号" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="pointname" label="计量点名称" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="pointtype" label="计量点类型" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="videoip" label="硬盘录像机IP" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="position1" label="摄像头IP1" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="position2" label="摄像头IP2" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="position3" label="摄像头IP3" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="position4" label="摄像头IP4" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="position5" label="摄像头IP5" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="position6" label="摄像头IP6" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="position7" label="摄像头IP7" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="position8" label="摄像头IP8" align="center"></el-table-column> 
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="vdoPort" label="硬盘录像机端口" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="vdoUser" label="硬盘录像机用户" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="vdoPwd" label="硬盘录像机密码" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100" prop="vdoType" label="硬盘录像机类型" align="left"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100" prop="svr1VdoIp" label="主流媒体服务器IP" align="left"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100" prop="svr2VdoIp" label="备流媒体服务器IP" align="left"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100" prop="videotype" label="硬盘录像机型号" align="left"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" prop="p1Rate" min-width="100px" label="1号图像码率" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.p1Rate == 0">主码</span>
              <span v-else-if="scope.row.p1Rate == 3">辅码1</span>
              <span v-else-if="scope.row.p1Rate == 4">辅码2</span>
            </template>
          </el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" prop="p2Rate" min-width="100px" label="2号图像码率" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.p2Rate == 0">主码</span>
              <span v-else-if="scope.row.p2Rate == 3">辅码1</span>
              <span v-else-if="scope.row.p2Rate == 4">辅码2</span>
            </template>
          </el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" prop="p3Rate" min-width="100px" label="3号图像码率" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.p3Rate == 0">主码</span>
              <span v-else-if="scope.row.p3Rate == 3">辅码1</span>
              <span v-else-if="scope.row.p3Rate == 4">辅码2</span>
            </template>
          </el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" prop="p1Rate" min-width="100px" label="4号图像码率" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.p4Rate == 0">主码</span>
              <span v-else-if="scope.row.p4Rate == 3">辅码1</span>
              <span v-else-if="scope.row.p4Rate == 4">辅码2</span>
            </template>
          </el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" prop="p1Rate" min-width="100px" label="5号图像码率" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.p5Rate == 0">主码</span>
              <span v-else-if="scope.row.p5Rate == 3">辅码1</span>
              <span v-else-if="scope.row.p5Rate == 4">辅码2</span>
            </template>
          </el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" prop="p1Rate" min-width="100px" label="6号图像码率" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.p6Rate == 0">主码</span>
              <span v-else-if="scope.row.p6Rate == 3">辅码1</span>
              <span v-else-if="scope.row.p6Rate == 4">辅码2</span>
            </template>
          </el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" prop="p1Rate" min-width="100px" label="7号图像码率" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.p7Rate == 0">主码</span>
              <span v-else-if="scope.row.p7Rate == 3">辅码1</span>
              <span v-else-if="scope.row.p7Rate == 4">辅码2</span>
            </template>
          </el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" prop="p1Rate" min-width="100px" label="8号图像码率" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.p8Rate == 0">主码</span>
              <span v-else-if="scope.row.p8Rate == 3">辅码1</span>
              <span v-else-if="scope.row.p8Rate == 4">辅码2</span>
            </template>
          </el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="remark" label="备注信息" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="imagecount" label="视频截图数量" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" prop="captureimageflag" min-width="150px" label="截图来源" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.captureimageflag == 0">视频流摄像头截图</span>
              <span v-else-if="scope.row.captureimageflag == 1">视频流硬盘录像机截图</span>
              <span v-else-if="scope.row.captureimageflag == 2">非视频流硬盘录像机截图</span>
              <span v-else-if="scope.row.captureimageflag == 3">非视频流摄像头截图</span>
            </template>
          </el-table-column>
           <el-table-column sortable :show-overflow-tooltip="true" prop="isSecond" min-width="100px" label="是否有两个摄像头" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.isSecond == 0">否</span>
              <span v-else-if="scope.row.isSecond == 1">是</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="common-foot-style">
       <el-pagination v-loading="dataLoading" @size-change="pageSizeChange" @current-change="pageCurrentChange"
          :current-page="page.pageNum" :page-sizes="[100, 500, 1000]" :page-size="page.pageSize" layout="total, sizes, prev, pager, next, jumper"
          :total="page.totalPage">
        </el-pagination>
      </div>
      <div ref="editDiv" class="commom-edit-div" style="border-top: 1px solid #d5d5d5; margin-top: 10px">
        <el-form ref="baseData" :inline="true" :rules="ruleValidateTable" :model="baseData" label-width="110px">
           <el-form-item prop="pointname" label="计量点">
               <el-select v-model="baseData.pointname"  clearable filterable collapse-tags size="small" style="width:120px">
                   <el-option v-for="(item,index) in pointnameItem" :key="index" :label="item.baseSpotName"
                    :value="item.baseSpotName">
                   </el-option>
               </el-select>
            </el-form-item>
          <el-form-item prop="videoip" label="硬盘录像机IP">
            <el-input v-model="baseData.videoip" clearable size="small" style="width:120px" placeholder="请输入"></el-input>
          </el-form-item>
          <el-form-item prop="position1" label="摄像头IP1">
            <el-input v-model="baseData.position1" clearable size="small" style="width:120px" placeholder=""></el-input>
          </el-form-item>
          <el-form-item prop="position2" label="摄像头IP2">
            <el-input v-model="baseData.position2" clearable size="small" style="width:120px" placeholder=""></el-input>
          </el-form-item>
          <el-form-item prop="position3" label="摄像头IP3">
            <el-input v-model="baseData.position3" clearable size="small" style="width:120px" placeholder=""></el-input>
          </el-form-item>
           <el-form-item prop="position4" label="摄像头IP4">
            <el-input v-model="baseData.position4" clearable size="small" style="width:120px" placeholder=""></el-input>
          </el-form-item>
           <el-form-item prop="position5" label="摄像头IP5">
            <el-input v-model="baseData.position5" clearable size="small" style="width:120px" placeholder=""></el-input>
          </el-form-item>
           <el-form-item prop="position6" label="摄像头IP6">
            <el-input v-model="baseData.position6" clearable size="small" style="width:120px" placeholder=""></el-input>
          </el-form-item>
           <el-form-item prop="position7" label="摄像头IP7">
            <el-input v-model="baseData.position7" clearable size="small" style="width:120px" placeholder=""></el-input>
          </el-form-item>
           <el-form-item prop="position8" label="摄像头IP8">
            <el-input v-model="baseData.position8" clearable size="small" style="width:120px" placeholder=""></el-input>
          </el-form-item>
          <!-- <el-form-item prop="pointtype" label="计量点类型">
             <el-select v-model="baseData.pointtype"  filterable collapse-tags size="small" style="width:120px">
                 <el-option v-for="(item,index) in pointtypeItem" :key="index" :label="item.baseName"
                  :value="item.baseName">
                 </el-option>
             </el-select>
          </el-form-item> -->
           <el-form-item prop="vdoPort" label="硬盘录像机端口">
            <el-input v-model="baseData.vdoPort" clearable size="small" style="width:120px" placeholder=""></el-input>
          </el-form-item>
           <el-form-item prop="vdoUser" label="硬盘录像机用户">
            <el-input v-model="baseData.vdoUser" clearable size="small" style="width:120px" placeholder=""></el-input>
          </el-form-item>
           <el-form-item prop="vdoPwd" label="硬盘录像机密码">
            <el-input v-model="baseData.vdoPwd" clearable size="small" style="width:120px" placeholder=""></el-input>
          </el-form-item>
          <el-form-item prop="vdoType" label="硬盘录像机类型">
             <el-select v-model="baseData.vdoType"  filterable collapse-tags size="small" style="width:120px" @change="getVideotypeItem (baseData.vdoType)">
                 <el-option v-for="(item,index) in vdoTypeItem" :key="index" :label="item.baseName"
                  :value="item.baseName">
                 </el-option>
             </el-select>
          </el-form-item>
           <el-form-item prop="svr1VdoIp" label="主流媒体服务器IP">
            <el-input v-model="baseData.svr1VdoIp" clearable size="small" style="width:120px" placeholder=""></el-input>
          </el-form-item>
           <el-form-item prop="svr2VdoIp" label="备流媒体服务器IP">
            <el-input v-model="baseData.svr2VdoIp" clearable size="small" style="width:120px" placeholder=""></el-input>
          </el-form-item>
           <el-form-item prop="videotype" label="硬盘录像机型号">
             <el-select v-model="baseData.videotype"  clearable filterable collapse-tags size="small" style="width:120px">
                 <el-option v-for="(item,index) in videotypeItem" :key="index" :label="item.baseName"
                  :value="item.baseName">
                 </el-option>
             </el-select>
          </el-form-item>
           <el-form-item prop="p1Rate" label="1号图像码率">
             <el-select v-model="baseData.p1Rate"  clearable filterable collapse-tags size="small" style="width:120px">
                 <el-option v-for="(item,index) in pRateItem" :key="index" :label="item.pRate"
                  :value="item.pRate">
                 </el-option>
             </el-select>
          </el-form-item>
           <el-form-item prop="p2Rate" label="2号图像码率">
             <el-select v-model="baseData.p2Rate"  clearable filterable collapse-tags size="small" style="width:120px">
                 <el-option v-for="(item,index) in pRateItem" :key="index" :label="item.pRate"
                  :value="item.pRate">
                 </el-option>
             </el-select>
          </el-form-item>
           <el-form-item prop="p3Rate" label="3号图像码率">
             <el-select v-model="baseData.p3Rate"  clearable filterable collapse-tags size="small" style="width:120px">
                 <el-option v-for="(item,index) in pRateItem" :key="index" :label="item.pRate"
                  :value="item.pRate">
                 </el-option>
             </el-select>
          </el-form-item>
           <el-form-item prop="p4Rate" label="4号图像码率">
             <el-select v-model="baseData.p4Rate"  clearable filterable collapse-tags size="small" style="width:120px">
                 <el-option v-for="(item,index) in pRateItem" :key="index" :label="item.pRate"
                  :value="item.pRate">
                 </el-option>
             </el-select>
          </el-form-item>
           <el-form-item prop="p5Rate" label="5号图像码率">
             <el-select v-model="baseData.p5Rate"  clearable filterable collapse-tags size="small" style="width:120px">
                 <el-option v-for="(item,index) in pRateItem" :key="index" :label="item.pRate"
                  :value="item.pRate">
                 </el-option>
             </el-select>
          </el-form-item>
           <el-form-item prop="p6Rate" label="6号图像码率">
             <el-select v-model="baseData.p6Rate"  clearable filterable collapse-tags size="small" style="width:120px">
                 <el-option v-for="(item,index) in pRateItem" :key="index" :label="item.pRate"
                  :value="item.pRate">
                 </el-option>
             </el-select>
          </el-form-item>
           <el-form-item prop="p7Rate" label="7号图像码率">
             <el-select v-model="baseData.p7Rate"  clearable filterable collapse-tags size="small" style="width:120px">
                 <el-option v-for="(item,index) in pRateItem" :key="index" :label="item.pRate"
                  :value="item.pRate">
                 </el-option>
             </el-select>
          </el-form-item>
           <el-form-item prop="p8Rate" label="8号图像码率">
             <el-select v-model="baseData.p8Rate"  clearable filterable collapse-tags size="small" style="width:120px">
                 <el-option v-for="(item,index) in pRateItem" :key="index" :label="item.pRate"
                  :value="item.pRate">
                 </el-option>
             </el-select>
          </el-form-item>
           <el-form-item prop="captureimageflag" label="截图来源">
             <el-select v-model="baseData.captureimageflag"  clearable filterable collapse-tags size="small" style="width:120px">
                 <el-option v-for="(item,index) in captureimageflagItem" :key="index" :label="item.captureimageflag"
                  :value="item.captureimageflag">
                 </el-option>
             </el-select>
          </el-form-item>
           <el-form-item prop="isSecond" label="是否有两个摄像头">
             <el-select v-model="baseData.isSecond"  clearable filterable collapse-tags size="small" style="width:120px">
                 <el-option v-for="(item,index) in isSecondItem" :key="index" :label="item.isSecond"
                  :value="item.isSecond">
                 </el-option>
             </el-select>
          </el-form-item>
           <el-form-item prop="imagecount" label="视频截图数量">
            <el-input v-model="baseData.imagecount" clearable size="small" style="width:120px" placeholder=""></el-input>
          </el-form-item>
           <el-form-item prop="remark" label="备注信息">
            <el-input v-model="baseData.remark" clearable size="small" style="width:120px" placeholder=""></el-input>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>
<script>
import {formatDate} from '@/utils/util.js';
  export default {
    data () {
      const IsIp = (rule, value, callback) => {
        const isIp=  /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
       if (value) {
          if (!isIp.test(value)) {
           callback(new Error('请输入正确的格式！'))
          }else{
           callback()
          }
       } else {
         callback()
       }
       }
      return {
        dataLoading: false,
        operateLoading: false,
        icoreFilterFlag: true,
        pointid: '',
        actualFirst: {},
        pointnameItem: [],//计量点
        pointtypeItem: [],//计量点类型
        videotypeItem: [],//硬盘录像机型号
        isSecondItem: [
          {id:'0', isSecond:'否'},
          {id:'1', isSecond:'是'},
        ],//是否有两个摄像头
        captureimageflagItem: [
          {id:'0', captureimageflag:'视频流摄像头截图'},
          {id:'1', captureimageflag:'视频流硬盘录像机截图'},
          {id:'2', captureimageflag:'非视频流硬盘录像机截图'},
          {id:'3', captureimageflag:'非视频流摄像头截图'}
        ],//截图来源
        pRateItem: [
          {id:'0', pRate:'主码'},
          {id:'3', pRate:'辅码1'},
          {id:'4', pRate:'辅码2'}
        ],//图像码率
        vdoTypeItem: [
          // {vdoType:'海康'},
          // {vdoType:'大华'},
        ],//硬盘录像机类型
        page: {
          pageSize: 500,
          pageNum: 1,
          totalPage: 0
        },
        table: {
          list: []
        },
        baseData: {
            pointname: '',
            videoip: '',
            position1: '',
            position2: '',
            position3: '',
            position4: '',
            position5: '',
            position6: '',
            position7: '',
            position8: '',
            pointtype: '',
            vdoPort: '',
            vdoUser: '',
            vdoPwd: '',
            vdoType: '',
            svr1VdoIp: '',
            svr2VdoIp: '',
            videotype: '',
            p1Rate: '主码',
            p2Rate: '主码',
            p3Rate: '主码',
            p4Rate: '主码',
            p5Rate: '主码',
            p6Rate: '主码',
            p7Rate: '主码',
            p8Rate: '主码',
            captureimageflag: '视频流摄像头截图',
            isSecond: '是',
            imagecount: '',
            remark: ''
        },
        multipleSelection: {},
        tableHeight: 0,
        ruleValidateTable: {
          //  vdoUser: [{
          //   required: true,
          //   message: '该项不能为空',
          //   trigger: 'change'
          // }],
          // vdoPwd: [{
          //   required: true,
          //   message: '该项不能为空',
          //   trigger: 'change'
          // }],
          pointname: [{
            required: true,
            message: '该项不能为空',
            trigger: 'change'
          }],
          videoip: [
            {
            required: true,
            message: '该项不能为空',
            trigger: 'change'
          },{
             validator: IsIp.bind(this.baseData && this.baseData.videoip), 
             trigger: 'blur',
          }],
          position1: [{
             validator: IsIp.bind(this.baseData && this.baseData.position1), 
             trigger: 'blur',
          }],
          position2: [{
             validator: IsIp.bind(this.baseData && this.baseData.position2), 
             trigger: 'blur',
          }],
          position3: [{
             validator: IsIp.bind(this.baseData && this.baseData.position3), 
             trigger: 'blur',
          }],
          position4: [{
             validator: IsIp.bind(this.baseData && this.baseData.position4), 
             trigger: 'blur',
          }],
          position5: [{
             validator: IsIp.bind(this.baseData && this.baseData.position5), 
             trigger: 'blur',
          }],
          position6: [{
             validator: IsIp.bind(this.baseData && this.baseData.position6), 
             trigger: 'blur',
          }],
          position7: [{
             validator: IsIp.bind(this.baseData && this.baseData.position7), 
             trigger: 'blur',
          }],
          position8: [{
             validator: IsIp.bind(this.baseData && this.baseData.position8), 
             trigger: 'blur',
          }],
          svr1VdoIp: [{
             validator: IsIp.bind(this.baseData && this.baseData.svr1VdoIp), 
             trigger: 'blur',
          }],
          svr2VdoIp: [{
             validator: IsIp.bind(this.baseData && this.baseData.svr2VdoIp), 
             trigger: 'blur',
          }],
        },
        activeMenu: ''
      }
    },
    created(){
      this.tableHeight = (window.innerHeight - 360) > 300 ? window.innerHeight - 360 :300;
      this.activeMenu = window.top.localStorage.getItem('activeMenu')
    },
    mounted () {
      this.getDataList();
      this.getPointnameItem();
      // this.getPointtypeItem();
      this.getVdoTypeItem();
    },
    methods: {
      IpIsIp (rule, value, callback){
        const isIp=  /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
       if (!isIp.test(value)) {
        callback(new Error('请输入正确的格式！'))
       }else{
        callback()
       }
       },
     getCode (code, arr, codeKey, nameKey) {
      if (!code) {
        return '';
      }
      let targetRow = arr.find(item => {
        return item[codeKey] === code;
      });
      return targetRow ? targetRow[nameKey] : '';
    },
    refresh () {
      this.baseData = {
            pointname: '',
            videoip: '',
            position1: '',
            position2: '',
            position3: '',
            position4: '',
            position5: '',
            position6: '',
            position7: '',
            position8: '',
            pointtype: '',
            vdoPort: '',
            vdoUser: '',
            vdoPwd: '',
            vdoType: '',
            svr1VdoIp: '',
            svr2VdoIp: '',
            videotype: '',
            p1Rate: '主码',
            p2Rate: '主码',
            p3Rate: '主码',
            p4Rate: '主码',
            p5Rate: '主码',
            p6Rate: '主码',
            p7Rate: '主码',
            p8Rate: '主码',
            captureimageflag: '视频流摄像头截图',
            isSecond: '是',
            imagecount: '',
            remark: ''
        },
        this.baseData.pointname = this.pointnameItem[0].baseSpotName
        // this.baseData.pointtype = this.pointtypeItem[0].baseName
        this.baseData.videotype = this.videotypeItem[0].baseName
        this.baseData.vdoType = this.vdoTypeItem[0].baseName
        this.$refs['baseData'].resetFields();
    },
    addData () {
       this.$refs['baseData'].validate((valid) => {
          if (valid) {
              let baseDataAdd = {}
              baseDataAdd.pointname = this.baseData.pointname
              baseDataAdd.videoip = this.baseData.videoip
              baseDataAdd.position1 = this.baseData.position1
              baseDataAdd.position2 = this.baseData.position2
              baseDataAdd.position3 = this.baseData.position3
              baseDataAdd.position4 = this.baseData.position4
              baseDataAdd.position5 = this.baseData.position5
              baseDataAdd.position6 = this.baseData.position6
              baseDataAdd.position7 = this.baseData.position7
              baseDataAdd.position8 = this.baseData.position8
              baseDataAdd.vdoPort = this.baseData.vdoPort
              baseDataAdd.vdoUser = this.baseData.vdoUser
              baseDataAdd.vdoPwd = this.baseData.vdoPwd
              baseDataAdd.vdoType = this.baseData.vdoType
              baseDataAdd.svr1VdoIp = this.baseData.svr1VdoIp
              baseDataAdd.svr2VdoIp = this.baseData.svr2VdoIp
              baseDataAdd.videotype = this.baseData.videotype
              baseDataAdd.imagecount = this.baseData.imagecount
              baseDataAdd.remark = this.baseData.remark
              baseDataAdd.isSecond = this.getCode (this.baseData.isSecond, this.isSecondItem, 'isSecond', 'id')
              baseDataAdd.captureimageflag = this.getCode (this.baseData.captureimageflag, this.captureimageflagItem, 'captureimageflag', 'id')
              baseDataAdd.pointid = this.getCode (this.baseData.pointname, this.pointnameItem, 'baseSpotName', 'baseSpotNo')
              baseDataAdd.pointtype = this.getCode (this.baseData.pointname, this.pointnameItem, 'baseSpotName', 'spotTypeName')
              baseDataAdd.p1Rate = this.getCode (this.baseData.p1Rate, this.pRateItem, 'pRate', 'id')
              baseDataAdd.p2Rate = this.getCode (this.baseData.p2Rate, this.pRateItem, 'pRate', 'id')
              baseDataAdd.p3Rate = this.getCode (this.baseData.p3Rate, this.pRateItem, 'pRate', 'id')
              baseDataAdd.p4Rate = this.getCode (this.baseData.p4Rate, this.pRateItem, 'pRate', 'id')
              baseDataAdd.p5Rate = this.getCode (this.baseData.p5Rate, this.pRateItem, 'pRate', 'id')
              baseDataAdd.p6Rate = this.getCode (this.baseData.p6Rate, this.pRateItem, 'pRate', 'id')
              baseDataAdd.p7Rate = this.getCode (this.baseData.p7Rate, this.pRateItem, 'pRate', 'id')
              baseDataAdd.p8Rate = this.getCode (this.baseData.p8Rate, this.pRateItem, 'pRate', 'id')
              this.axios.post('pass/systemBase/v1/meterbasevideoinfos/add', baseDataAdd, {individualType: 'json'}).then(res=>{
                if (res.succeed) {
                   this.$message.success('新增成功');
                   this.getDataList ();
                   this.refresh();
                }  else {
                 this.$message.error(res.message)
                }
                }).catch(e => {
                 this.$message.error(e.message)
               })
          }
       })
    },
    modifyData () {
       this.$refs['baseData'].validate((valid) => {
          if (valid) {
              this.baseData.isSecond = this.getCode (this.baseData.isSecond, this.isSecondItem, 'isSecond', 'id')
              this.baseData.captureimageflag = this.getCode (this.baseData.captureimageflag, this.captureimageflagItem, 'captureimageflag', 'id')
              this.baseData.pointid = this.getCode (this.baseData.pointname, this.pointnameItem, 'baseSpotName', 'baseSpotNo')
              this.baseData.pointtype = this.getCode (this.baseData.pointname, this.pointnameItem, 'baseSpotName', 'spotTypeName')
              this.baseData.p1Rate = this.getCode (this.baseData.p1Rate, this.pRateItem, 'pRate', 'id')
              this.baseData.p2Rate = this.getCode (this.baseData.p2Rate, this.pRateItem, 'pRate', 'id')
              this.baseData.p3Rate = this.getCode (this.baseData.p3Rate, this.pRateItem, 'pRate', 'id')
              this.baseData.p4Rate = this.getCode (this.baseData.p4Rate, this.pRateItem, 'pRate', 'id')
              this.baseData.p5Rate = this.getCode (this.baseData.p5Rate, this.pRateItem, 'pRate', 'id')
              this.baseData.p6Rate = this.getCode (this.baseData.p6Rate, this.pRateItem, 'pRate', 'id')
              this.baseData.p7Rate = this.getCode (this.baseData.p7Rate, this.pRateItem, 'pRate', 'id')
              this.baseData.p8Rate = this.getCode (this.baseData.p8Rate, this.pRateItem, 'pRate', 'id')
              this.axios.post('pass/systemBase/v1/meterbasevideoinfos/'+ this.pointid, this.baseData, {individualType: 'json'}).then(res=>{
                if (res.succeed) {
                   this.$message.success('修改成功');
                   this.getDataList ();
                   this.refresh();
                }  else {
                 this.$message.error(res.message)
                }
                }).catch(e => {
                 this.$message.error(e.message)
               })
          }
       })
    },
    discardData () {
    if (JSON.stringify(this.multipleSelection) == "{}") {
        this.$message.warning('请选择您要删除的数据！');
        return;
      }
     if (this.multipleSelection.valueFlag === '0') {
           this.$message.warning('请选择状态为有效的数据！');
           return false;
      }
      this.axios.post('pass/systemBase/v1/meterbasevideoinfos/delete' + '?pointid=' + this.multipleSelection.pointid, {individualType: 'json'}).then(res => {
         if (res.succeed) {
           this.$message.success('删除成功');
           this.getDataList ();
        }  else {
         this.$message.error(res.message)
        }
        }).catch(e => {
         this.$message.error(e.message)
       })
    },
    rowChange (row, column, event) {
       this.baseData = Object.assign ({}, row);
       this.pointid = this.baseData.pointid
       this.getVideotypeItem2(this.baseData.vdoType);
       this.baseData.videotype = row.videotype
       this.baseData.isSecond = this.getCode (this.baseData.isSecond, this.isSecondItem, 'id', 'isSecond')
       this.baseData.captureimageflag = this.getCode (this.baseData.captureimageflag, this.captureimageflagItem, 'id', 'captureimageflag')
       this.baseData.p1Rate = this.getCode (this.baseData.p1Rate, this.pRateItem, 'id', 'pRate')
       this.baseData.p2Rate = this.getCode (this.baseData.p2Rate, this.pRateItem, 'id', 'pRate')
       this.baseData.p3Rate = this.getCode (this.baseData.p3Rate, this.pRateItem, 'id', 'pRate')
       this.baseData.p4Rate = this.getCode (this.baseData.p4Rate, this.pRateItem, 'id', 'pRate')
       this.baseData.p5Rate = this.getCode (this.baseData.p5Rate, this.pRateItem, 'id', 'pRate')
       this.baseData.p6Rate = this.getCode (this.baseData.p6Rate, this.pRateItem, 'id', 'pRate')
       this.baseData.p7Rate = this.getCode (this.baseData.p7Rate, this.pRateItem, 'id', 'pRate')
       this.baseData.p8Rate = this.getCode (this.baseData.p8Rate, this.pRateItem, 'id', 'pRate')
    },
      handleCurrentChange (val) {
        this.multipleSelection = val;
      },
      pageSizeChange (size) {
        this.page.pageSize = size;
        this.getDataList();
      },
      pageCurrentChange (index) {
        this.page.pageNum = index;
        this.getDataList();
      },
      getDataList () {
        this.dataLoading = true;
        this.axios.get('pass/systemBase/v1/meterbasevideoinfos/' + '?pageNum=' + this.page.pageNum + '&pageSize=' + this.page.pageSize + '&flag=0')
          .then(res => {
            this.dataLoading = false;
            this.table.list = res.data.list;
            this.page.totalPage = res.data.total;
          }).catch(e => {
            this.dataLoading = false;
          });
      },
      getPointnameItem () {
        this.axios.get('pass/systemBase/v1/meterbasespotinfos/noPage'+ '?validFlag=1')
          .then(res => {
            this.pointnameItem = res.data;
            this.baseData.pointname = res.data[0].baseSpotName;
          })
      },
      getPointtypeItem () {
          this.axios.get('pass/systemBase/v1/combaseinfos/selectSpoType')
          .then(res => {
            this.pointtypeItem = res.data;
            this.baseData.pointtype = res.data.length > 0 ? res.data[0].baseName : '';
          })
      },
      getVdoTypeItem () {
         this.axios.get('pass/systemBase/v1/combaseinfos/selectVideoType')
          .then(res => {
            this.vdoTypeItem  = res.data;
            this.baseData.vdoType = res.data.length > 0 ? res.data[0].baseName : '';
            this.getVideotypeItem(res.data[0].baseName)
          })
      },
      getVideotypeItem (vdoTypeName) {
          const vdoTypeNo = this.getCode (vdoTypeName, this.vdoTypeItem, 'baseName', 'baseCode')
          this.axios.get('pass/systemBase/v1/combaseinfos/selectVideoMark' + '?baseName=' + vdoTypeName +'&baseCode=' + vdoTypeNo)
          .then(res => {
            this.videotypeItem = res.data;
              this.baseData.videotype = res.data.length > 0 ? res.data[0].baseName : '';
          })
      },
      getVideotypeItem2 (vdoTypeName) {
          const vdoTypeNo = this.getCode (vdoTypeName, this.vdoTypeItem, 'baseName', 'baseCode')
          this.axios.get('pass/systemBase/v1/combaseinfos/selectVideoMark' + '?baseName=' + vdoTypeName +'&baseCode=' + vdoTypeNo)
          .then(res => {
            this.videotypeItem = res.data;
            if (this.baseData.videotype) {
              return
            } else {
              this.baseData.videotype = res.data.length > 0 ? res.data[0].baseName : '';
            }
          })
      },
    //  getVideotypeItem () {
    //       this.axios.get('pass/systemBase/v1/combaseinfos/selectVideoType')
    //       .then(res => {
    //         this.videotypeItem  = res.data;
    //         this.baseData.videotype = res.data.length > 0 ? res.data[0].baseName : '';
    //         this.getVdoTypeItem(res.data[0].baseName)
    //       })
    //   },
    //   getVdoTypeItem (videotypeName) {
    //       let videotypeNo = this.getCode (videotypeName, this.videotypeItem, 'baseCode', 'baseName')
    //       this.axios.get('pass/systemBase/v1/combaseinfos/selectVideoMark' + '?baseName=' + videotypeName +'?baseCode=' + videotypeNo)
    //       .then(res => {
    //         this.vdoTypeItem = res.data;
    //         this.baseData.vdoType = res.data.length > 0 ? res.data[0].baseName : '';
    //       })
    //   },
    }
  }
</script>
<style scoped>
</style>