<template>
  <el-dialog :title="object.val" :visible.sync="dialogTableVisible" width="70%">
    <el-table :data="gridData" border :header-cell-style="{background:'#F3F4F7'}">
      <el-table-column type="index" label="序号" align="center" width="50"></el-table-column>
      <el-table-column property="Name" label="名称" show-overflow-tooltip align="center"></el-table-column>
      <el-table-column property="address" label="软件" align="center" width="80">
        <template slot-scope="scope" v-if="scope.row.Application">
          <el-button type="text" @click="handleDown(scope.$index,scope.row,'Application')">下载</el-button>
        </template>
      </el-table-column>
      <el-table-column property="Remark" label="特殊说明" align="center"></el-table-column>
      <el-table-column property="Scope" label="适用厂家" align="center"></el-table-column>
      <el-table-column property="Manual" label="使用说明" align="center" width="80">
        <template slot-scope="scope" v-if="scope.row.Manual">
          <el-button type="text" @click="handleDown(scope.$index,scope.row,'Manual')">下载</el-button>
        </template>
      </el-table-column>
      <el-table-column property="Eg" label="配置示例" align="center" width="80">
        <template slot-scope="scope" v-if="scope.row.Eg">
          <el-button type="text" @click="handleDown(scope.$index,scope.row,'Eg')">下载</el-button>
        </template>
      </el-table-column>

    </el-table>
  </el-dialog>
</template>

<script>
  import {queryTxList,dowloadProtocol} from "@/fetch/point_http"
  export default {
    name: "settingDialog",
    data() {
      return {
        gridData: [{
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }],
        dialogTableVisible: false,
        object: {}
      };
    },
    methods: {
      show(val) {
        this.dialogTableVisible = true
        this.object = val
        this.getTxOption(this.object.val)
      },
      getTxOption(object ){
        let data = {
          Filters:`Type='${object}'`
        }
        queryTxList(data,res=>{
          console.log(res)
          this.gridData = res.Content
        })
      },
      handleDown(index, row,name) {
        let params
        console.log(row)
        if(name=='Application'){
          params = {
            Property: 'Application',
            ProtocolId: row.Id
          }
        }else if(name=='Manual'){
           params = {
            Property: 'Manual',
            ProtocolId: row.Id
          }
        }else if(name=='Eg'){
           params = {
            Property: 'Eg',
            ProtocolId: row.Id
          }
        }
        dowloadProtocol(params,res=>{
        })
      },

    }
  }
</script>

<style scoped>

</style>
