<!--
 * @Description: 修改
 * @Author: wsd
 * @Date: 2022-10-26 14:20:38
 * @LastEditTime: 2022-10-26 15:43:04
 * @LastEditors: wsd
-->
<template>
  <el-dialog
    title="历史版本列表"
    :visible.sync="dialogVisible"
    width="80%"
    :close-on-click-modal="false"
    :before-close="handleClose"
  >
    <div class="container">
      <el-table :data="tableData">
        <el-table-column type="index" label="序号" width="50" align="center">
        </el-table-column>
        <el-table-column
          prop="name"
          label="代理服务名称"
          align="center"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="version"
          label="版本"
          align="center"
          show-overflow-tooltip
        >
          <!-- <template #default="{row}">
            <p>{{row.version ? row.version : '无'}}</p>
          </template> -->
        </el-table-column>
        <el-table-column
          prop="versionOld"
          label="继承版本"
          align="center"
          show-overflow-tooltip
        >
          <template #default="{row}">
            <p>{{row.versionOld ? row.versionOld : '无'}}</p>
          </template>
        </el-table-column>
        <el-table-column
          prop="publisher"
          label="发布人"
          align="center"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="publishTime"
          label="发布日期"
          align="center"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="description"
          label="操作"
          align="center"
          show-overflow-tooltip
        >
          <template #default="{row}">
            <el-button type="text" @click="detailInfo(row)">查看详情</el-button>
            <el-button type="text" @click="recovery(row, 'recovery')">恢复</el-button>
            <el-button type="text" @click="recovery(row, 'active')">恢复并激活</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- <el-pagination
        :page-size="page.pageSize"
        :current-page.sync="page.pageNum"
        background
        @current-change="quickQueryData()"
        :total="page.total"
      ></el-pagination> -->
      <el-dialog :close-on-click-modal="false" title="代理服务定义" :visible.sync="dialogFormVisible" :destroy-on-close="true" append-to-body width="72%">
        <agency-info v-model="dialogFormVisible" :currentRow="currentRow" @confirm="handleSubmit()" />
      </el-dialog>
    </div>
  </el-dialog>
</template>
<script>
import AgencyInfo from '../../esb_service/agency_service/AgencyInfo.vue'
import { versionSave, versionBackup ,versionQuery} from '@/api/system_manage'
export default {
  name: '',
  components: {
    AgencyInfo
  },
  props: {
    rowData: {
      type: Array,
      default: () => []
    },
    visibles: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      page: {
        pageSize: 10,
        pageNum: 1,
        total: 0
      },
      currentRow: {},
      dialogFormVisible: false,
      dialogVisible: false,
      tableData: [],
      versonList:{}
    }
  },
  watch: {
    rowData(row) {
      this.tableData = row
    },
    visibles(val) {
      this.dialogVisible = val
    }
  },
  created() {},
  mounted() {
    this.getData()
  },
  methods: {
    quickQueryData() {
    },
    handleSubmit() {
    },
    detailInfo(row) {
      this.dialogFormVisible = true
    },
    handleClose() {
      this.dialogVisible = false
      this.$emit('confirm')
    },
    recovery(row, type) {
      this.$confirm('确定恢复当前版本的代理服务？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          if (type === 'active') {
             
          } else {
            console.log(1111111112222)
            const filters =[
        {
          key: 'proxy_service_id',
          opt: "LIKE",
          type: "S",
          value: 1,
        }
      ]
      versionQuery({
          filters:filters,
          orderby: "updateon",
          pageNum: 1,
          pageSize: 1000,
          sort:"desc"
             }).then(res => {
                this.tableData=res.data.list
      })
      
          }
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
      
    },
    getData(){
      console.log(12313,'dddd')
      const filters =[
        {
          key: 'proxy_service_id',
          opt: "LIKE",
          type: "S",
          value: 1,
        }
      ]
      versionQuery({
          filters:filters,
          orderby: "updateon",
          pageNum: 1,
          pageSize: 1000,
          sort:"desc"
             }).then(res => {
                this.tableData=res.data.list
      })
    }
  }
  
}
</script>
<style lang='scss' scoped>
</style>
