<template>
  <div>
    <div>
      <el-table :data="tableData" style="width: 100%" header-row-class-name="custom-table-header">
        <el-table-column label="#" width="60" type="index" align="center">
          <template slot-scope="scope">
            <span>{{ (scope.$index + 1) + ((queryParams.current - 1) * queryParams.size) }}</span>
          </template>
        </el-table-column>

        <el-table-column v-for="item in column" :key="item.key" :prop="item.key" :label="item.name" align="center">
          <template slot-scope="scope">
            <div v-if="['name', 'eventNumber', 'projectNumber'].includes(item.key)">
              <el-link @click="handleItem(scope.row,item.key)">{{ scope.row[item.key] }}</el-link>
            </div>
            <div v-else v-html="getColumnData(scope.row,item.key)"></div>
          </template>
        </el-table-column>

        <el-table-column v-if="['首页'].indexOf(isOperate) == -1" label="操作" align="center" width="150px">
        <template slot-scope="scope">
          <el-dropdown @command="handleCommand($event, scope.row)" split-button type="primary" size="small"  @click="handleCommand('e',scope.row)">
            <span v-if="$reportPermission(scope.row.id,[0,1])">编辑</span>
            <span v-else>查看</span>
            <el-dropdown-menu slot="dropdown" class="text-align_center">
              <el-dropdown-item command="0" v-if="$reportPermission(scope.row.id,[0,1])">分享</el-dropdown-item>
              <el-dropdown-item command="1" v-if="[2,3].includes(scope.row.status) && $reportPermission(scope.row.id,[0,1])">导出报告</el-dropdown-item>
              <el-dropdown-item command="2" v-if="[2,3].includes(scope.row.status) && $reportPermission(scope.row.id,[0,1])">报告文档</el-dropdown-item>
              <el-dropdown-item command="3" v-if="[1,2].includes(scope.row.status)&&[0,1,2,3].includes(scope.row.type) && $reportPermission(scope.row.id,[0,1])">自定义字段</el-dropdown-item>
              <el-dropdown-item command="4" v-if="[2].includes(scope.row.status)&& [0,1,2,3].includes(scope.row.type) && $reportPermission(scope.row.id,[0,1])">任务分配</el-dropdown-item>
              <el-dropdown-item command="5" v-if="([1].includes(scope.row.status) || (scope.row.type == 4 && [1,2].includes(scope.row.status))) && $reportPermission(scope.row.id,[0,1])">{{!([3,4].includes(scope.row.type))?'拆分特征':'产品信息录入'}}</el-dropdown-item>
              <el-dropdown-item command="8" v-if="(scope.row.type == 4 && [1,2].includes(scope.row.status)) && $reportPermission(scope.row.id,[0,1])">专利与产品关联比对</el-dropdown-item>
              <el-dropdown-item command="9" v-if="(scope.row.type == 5 && [1,2].includes(scope.row.status)) && $reportPermission(scope.row.id,[0,1])"> 规避方案填写</el-dropdown-item>
              <el-dropdown-item command="10" v-if="[0,1,2,3].includes(scope.row.type)&&[2].includes(scope.row.status) && $reportPermission(scope.row.id,[0,1])"> 添加对比文件</el-dropdown-item>
              <el-dropdown-item command="11" v-if="[1,2].includes(scope.row.status) && $reportPermission(scope.row.id,[0,1])"> 完成报告</el-dropdown-item>
              <el-dropdown-item command="12" v-if="[3].includes(scope.row.status) && $reportPermission(scope.row.id,[0,1])">添加追踪报告</el-dropdown-item>
              <el-dropdown-item command="13" v-if="(scope.row.type == 7 && [1,2,3].includes(scope.row.status)) && $reportPermission(scope.row.id,[0,1])">添加无效理由和证据</el-dropdown-item>
              <el-dropdown-item command="14" v-if="(scope.row.type == 7 && [1,2,3].includes(scope.row.status)) && $reportPermission(scope.row.id,[0,1])">证据文献</el-dropdown-item>
              <!-- <el-dropdown-item command="6" v-if="[2,3].includes(scope.row.status)&& scope.row.type != 4">导入 </el-dropdown-item> -->
              <el-dropdown-item command="7" divided style="color: red;" v-if=" $reportPermission(scope.row.id,[0,1])">删除 </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import mixins from '../mixins';
export default {
  mixins:[mixins],
  props: {
    isOperate: {//控制显示
      type: String,
      default:''
    },
   
    column: {//显示栏位管理数组
      type: Array,
      default: () => {
        return [
          {
            "key": "name",
            "name": "名称",
            "type": "list",
            "order": 0,
            "hidden": true
          },
          {
            "key": "eventNumber",
            "name": "标的专利/产品",
            "type": "list",
            "order": 0,
            "hidden": true
          },
          {
            "key": "projectNumber",
            "name": "相关专题库",
            "type": "list",
            "order": 0,
            "hidden": true
          },
          {
            "key": "projectNumber1",
            "name": "事件",
            "type": "list",
            "order": 0,
            "hidden": true
          },
          {
            "key": "projectNumber2",
            "name": "负责人",
            "type": "list",
            "order": 0,
            "hidden": true
          },
          {
            "key": "projectNumber3",
            "name": "状态",
            "type": "list",
            "order": 0,
            "hidden": true
          },
          {
            "key": "projectNumber4",
            "name": "创建人",
            "type": "list",
            "order": 0,
            "hidden": true
          },
          {
            "key": "time",
            "name": "创建时间",
            "type": "list",
            "order": 0,
            "hidden": true
          },
        ]
      }
    }
  },
  data() {
    return {
      
    };
  },
  watch: {
    
  },
  mounted() {
   
  },
  methods: {
    
    // 获取栏位数据
    getColumnData(row,key) {
      if (key == 'projectNumber1') {
        if (row[key]) {
          var a=''
          row[key].forEach(item => {
            a+=item.name + '</br>'
          });
          return a
        } else {
          return ''
        }
      }
    },

  },
};
</script>
<style lang="scss">

</style>
<style lang="scss" scoped></style>
