/*
 *@description:
 *@author: hudw
 *@date: 2022-03-14 15:14:53
*/
<template>
  <p-table  :id="$route.meta.menuId + '_main'"
    :autoLoad="true"
    rowSelectFixed :dataSource="dataSource"
    :selectedRowKeys="selectedRowKeys" :scroll="{ x:true , y:'62vh'}" ref="mainTable" bordered :columns="mx_columns"
    :pagination="200"
    :remoteUrl="mx_remoteUrl" :remoteBefore="remoteBefore" dragle :rowSelectType="2" v-on="$listeners">
    <template slot="operation" slot-scope="text,record">
      <a href="javascript:;" @click.stop="show_info_item(record)">查看</a>
      <a-divider type="vertical" />
      <a href="javascript:;" @click.stop="update_item(record)">修改</a>
      <a-divider type="vertical" />
      <a href="javascript:;" @click.stop="delete_item(record)">删除</a>
    </template>
  </p-table>
</template>
<script>

import store from '@/store'


// export default function () {


//   // store.commit('setColumnPosition')
//   store.dispatch('getSign');
// }
import { setMainColumns } from './tableConfig';
import { mainTableInfoUrl, deleteMainItem } from '../../api';
let arr = []
// for(let i=0; i<100; i++){
//   arr.push({id:i.toString()})
// }
export default {
  props: {
    options: {
      type: Object,
      default: () => { }
    },
    selectedRowKeys: {
      type: Array,
      default: () => []
    },
    tableExtendedField: {
      type: Array
    },
    getFieldsValue: {
      type: Function
    },

    activeID: {
      type: String
    },
  },



  data() {
    return {
      dataSource: arr,
      confirmLoading: false,
      //dataSource: [],
      mx_remoteUrl: {
        method: 'post',
        url: mainTableInfoUrl
      },
      mx_remoteParams: {},
      mx_columns: setMainColumns(this),
    };
  },
  mounted() {

  },
  watch: {
    tableExtendedField(value) {
      if (value.length > 0) {
        value.forEach((element, index) => {
          this.mx_columns.splice(7 + index, 0, element);
        });
      }

    },
    activeID(v) {
      console.log("activeID", v)
      this.$refs.mainTable.activeID = v
    }
  },
  methods: {

    show_info_item(record) {
      this.$emit('view', record)
    },
    delete_item(record) {
      deleteMainItem(this, [record.id])
    },
    update_item(record) {
      this.$emit('update', record)
    },
    toggle_item(record) {
      let status = +(!record.status)
      return mainIsEnable(this, [{ providerId: record.id }], status)
    },
    reload(args) {
      return this.$refs.mainTable.reload(args)
    },
    remoteBefore(vNode, remoteUrl) {

      let searchBar = this.$parent.$parent.$parent.$refs.searchBar
      if (searchBar) {
        const { getFieldsValue } = searchBar
        remoteUrl.data = { ...remoteUrl.data, ...getFieldsValue() }

      }
    }

  }
};

</script>
  <style lang="less" >
.row-colorView {
  position: relative;

    width: 100%;
    height: 100%;
    background: #f8f8f8;
    background-image:
      linear-gradient(45deg, #dbdbdb 25%, transparent 0, transparent 75%, #dbdbdb 0),
      linear-gradient(45deg, #dbdbdb 25%, transparent 0, transparent 75%, #dbdbdb 0);
    background-position: 0 0, 15px 15px;
    background-size: 10px 10px;
    .content{
        padding: 5px;
        width: inherit;


    }


}
</style>