<!--
人员授权
@Author: linqian
@Date: 2021-04-06 14:30
-->
<template>
  <dg-row class="property-wapper" gutter="1rem">
    <!-- 人员列表区域 -->
    <dg-col :span="15" class="property-wapper__center">
      <dg-card header="人员列表">
        <!-- 搜索栏 -->
        <search-bar :conditionForm="conditionForm" @submitSearch="receiveSearch"></search-bar>
        <!-- 人员列表 -->
        <new-table
           ref="table"
          :tableUrl="userTableUrl"
          :tableHeader="tableHeader"
          :condition="condition"
          @handleRowClick="receiveIsClickedUser"
        ></new-table>
      </dg-card>
    </dg-col>
    <!-- 权限设置 -->
    <dg-col :span="9" :key="key">
      <set-auth :subId="subId" subType="USER" saveApi="saveUserDataAuth"></set-auth>
    </dg-col>
  </dg-row>
</template>
<script>
import { staffUserPage } from '@/api/role-auth-info';
import setAuth from './components/set-auth';
import searchBar from '@/components/search-bar';
import { searchOpt } from '@/mixins/page-opt';
import newTable from '@/components/new-table';
export default {
  components: { setAuth, searchBar, newTable },
  mixins: [searchOpt],
  data() {
    return {
      // 激活的tab
      activeName: 'tableAuth',
      rowStyle: {
        cursor: 'pointer'
      },
      conditionForm: [
        {
          label: '用户类型',
          name: 'userType',
          op: '=',
          value: '',
          component: 'DgSelect',
          attr: {
            enum: 'UserTypeEnum',
            style: "width: 9rem"
          }
        },
        {
          label: '姓名',
          name: 'name',
          op: 'like',
          value: '',
          component: 'ElInput',
          attr: {
              style: "width: 9rem"
          }
        },
        {
          label: '单位名称',
          name: 'orgId',
          op: '=',
          value: '',
          apiName: 'getOrgTree',
          nodeKey: 'id',
          type: 'APP',
          component: 'SelectOrgTree',
          placeholder: '请选择单位名称'
        }
      ],
      userTableUrl: staffUserPage,
      key: 0,
      subId: '',
      tableHeader: [
        {
          label: '姓名',
          prop: 'name'
        },
        {
          label: '身份证号码',
          prop: 'idcard'
        },
        {
          label: '用户类型',
          prop: 'userType',
          enum: 'UserTypeEnum'
        },{
            label: "单位名称",
            prop: "orgName"
        }
      ]
    };
  },
  computed: {},
  methods: {
    /**
     * @description: 接收被点击人员
     * @param {*} row
     */
    receiveIsClickedUser(row) {
      this.subId = row.idcard;
      this.key++;
    },
  },
  created() {},
  mounted() {}
};
</script>

<style lang='scss' scoped>
  @import "./index.scss";
  /deep/ .el-card__body {
    height: 45rem;
  }
</style>