
<template>
  <div>
    <basicLayout 
      ref="basicLayout" 
      formPath="tagManage" 
      tableName="dataTagDetailTable" 
      idName="sys_systemtagdetailid" 
      :apiId="{query:20221013104401,del:20221013104601}" 
      :options="options"
      @listCreate="list"
      @listData="listData"
      v-if="objectList"
      hidePagination=" ">
      <div slot="custom">
        <div style="disply:flex">
          <span style="font-size:14px;color:#666666">业务对象: </span>
            <el-select v-model="selectTarget" style="margin-right:10px" placeholder="请选择" size="small" @change="change">
            <el-option
              v-for="item in objectList"
              :key="item.sys_systemtagid"
              :label="item.name"
              :value="item.sys_systemtagid">
            </el-option>
          </el-select>
        </div>
      </div>
      <template v-slot:tbList="scope">
        <div v-if="scope.data.column.columnname == 'tag'">
          <span style="margin-right:10px">{{scope.data.column.data[scope.data.column.columnname]}}</span>
          <el-tag v-if="scope.data.column.data['issystem']" size="mini">系统</el-tag>
        </div>
        <div v-else-if="scope.data.column.columnname == 'mutextags'">
          <span v-if="scope.data.column.data[scope.data.column.columnname].length > 0">
            <el-tag style="margin-right:10px" size="mini" v-for="(item,index) in scope.data.column.data[scope.data.column.columnname]" :key="index">
              {{item.tag}}
            </el-tag>
          </span>
          <span v-else>--</span>
        </div>
        <div v-else>{{scope.data.column.data[scope.data.column.columnname]}}</div>
      </template>
      <template v-slot:tbOpreation="scope">
        <Edit class="inline-16" v-if="tool.checkAuth($route.name,'update')" :allData="allData.filter(item=>item.tag!=scope.data.data.tag)" @onSuccess="$refs.basicLayout.listData()" :data="scope.data.data"/>
        <!-- <mutextage 
          class="inline-16" 
          :tagData="selectTarget" 
          :allData="allData.filter(item=>item.tag!=scope.data.data.tag)" 
          :rowData="scope.data.data"
          @onSuccess="$refs.basicLayout.listData()"
           v-if="tool.checkAuth($route.name,'update')"/> -->
          <el-popconfirm title="确定删除当前数据吗？" @confirm="deleteRow(scope.data.data)">
            <el-button slot="reference" size="mini" type="text" v-if="tool.checkAuth($route.name,'delete') && !scope.data.data.issystem">删 除</el-button>
          </el-popconfirm>
      </template>
    </basicLayout>
  </div>
</template>

<script>
import mutextage from './components/mutextage'
import Edit from './components/edit'
import { log } from '@antv/g2plot/lib/utils'
export default {
  components:{mutextage,Edit},
  data () {
    return {
      options:[],
      selectTarget:'',
      objectList:'',
      allData:[]
      
    }
  },
  provide () {
    return {
      sys_systemtagid: () => this.selectTarget,
      allData: () => this.allData
    }
  },
  created () {
    this.getObjectList()
  },
  methods:{
    async deleteRow (data) {
      let res = await this.$api.requested({
        "id":20221013104601,
        "content": {
          "sys_systemtagdetailids": [data.sys_systemtagdetailid],
        }
      })
      console.log(res);
      this.tool.showMessage(res,() => {
        this.$refs.basicLayout.listData()
      })
    },
    listData (data) {
      this.allData = data
      console.log(data);
      
    },
    list (param) {
      param.content.sys_systemtagid = this.objectList[0].sys_systemtagid
    },
    change () {
      this.$refs.basicLayout.param.content.sys_systemtagid = this.selectTarget
      this.$refs.basicLayout.param.content.pageNumber = 1
      this.$refs.basicLayout.listData()
    },
    async getObjectList () {
      let res = await this.$api.requested({
        "id": 20221013104301,
        "content": {
        }
      })
      this.objectList = res.data
      this.selectTarget = this.objectList[0].sys_systemtagid
      console.log(this.objectList);
    }
  }
}

</script>
<style>
</style>