<template>
  <el-card
    shadow="never"
    class="aui-card--fill"
  >
    <div class="mod-sys__user">
      <el-form
        :inline="true"
        :model="dataForm"
        @keyup.enter.native="getDataList()"
      >
        <el-form-item>
          <el-input
            v-model="dataForm.company"
            placeholder="请输入单位名称"
            clearable
          ></el-input>
        </el-form-item>

        <el-form-item>
          <el-input
            v-model="dataForm.name"
            placeholder="请输入姓名"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-cascader
            v-model="dataForm.location"
            placeholder="请选择所属市区级"
            :options="optionsOfLocation"
            :props="{ checkStrictly: true }"
            clearable
          ></el-cascader>
        </el-form-item>
        <el-form-item>
          <el-select
            v-model="dataForm.committee"
            placeholder="请选择所属委员会"
            clearable
          >
            <el-option
              v-for="item in optionsOfCommittee"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item>
          <el-button @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>

        <el-form-item>
          <el-button
            v-if="$hasPermission('sys:user:delete')"
            type="danger"
            @click="deleteHandle()"
          >{{ $t('deleteBatch') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button
            v-if="$hasPermission('sys:user:export')"
            type="info"
            @click="exportHandle()"
          >{{ $t('export') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button
            type="info"
            @click="taozhuan()"
          >跳转页面测试按钮</el-button>
          <el-button
            type="info"
            @click="taozhuanDe()"
          >跳转详情测试按钮</el-button>
        </el-form-item>
      </el-form>
      <el-table
        v-loading="dataListLoading"
        :data="dataList"
        border
        @selection-change="dataListSelectionChangeHandle"
        @sort-change="dataListSortChangeHandle"
        style="width: 100%;"
      >
        <el-table-column
          type="selection"
          header-align="center"
          align="center"
          width="50"
        ></el-table-column>
        <el-table-column
          prop="company"
          label="单位"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="name"
          label="联系人"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="mobile"
          :label="$t('user.mobile')"
          sortable="custom"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="committee"
          label="委员会"
          header-align="center"
          align="center"
        ></el-table-column>

        <el-table-column
          prop="location"
          label="所属市区"
          header-align="center"
          align="center"
        ></el-table-column>

        <el-table-column
          prop="createDate"
          :label="$t('user.createDate')"
          sortable="custom"
          header-align="center"
          align="center"
          width="180"
        ></el-table-column>
        <el-table-column
          :label="$t('handle')"
          fixed="right"
          header-align="center"
          align="center"
          width="150"
        >
          <template slot-scope="scope">
            <el-button
              type="text"
              size="small"
              @click="taozhuan(scope.row.id)"
            >修改</el-button>
            <el-button
              type="text"
              size="small"
              @click="taozhuanDe(scope.row.id)"
            >详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle"
      >
      </el-pagination>

    </div>
  </el-card>
</template>

<script>
import mixinViewModule from "@/mixins/view-module";

export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: "/user/user/page",
        getDataListIsPage: true,
        deleteURL: "/user/user",
        deleteIsBatch: true,
        exportURL: "/user/user/export",
      },
      dataForm: {
        company: "",
        name: "",
        location: "",
        committee: "",
      },
      optionsOfLocation: [
        {
          value: "ningbo",
          label: "宁波",
          children: [
            {
              value: "haishu",
              label: "海曙区",
            },
            {
              value: "yingzhou",
              label: "鄞州区",
            },
            {
              value: "beilun",
              label: "北仑区",
            },
            {
              value: "zhenhai",
              label: "镇海区",
            },
          ],
        },
      ],
      optionsOfCommittee: [
        {
          value: "网络安全协会",
          label: "网络安全协会",
        },
        {
          value: "网络安全协会1",
          label: "网络安全协会1",
        },
        {
          value: "网络安全协会2",
          label: "网络安全协会2",
        },
        {
          value: "网络安全协会3",
          label: "网络安全协会3",
        },
        {
          value: "网络安全协会4",
          label: "网络安全协会4",
        },
      ],
    };
  },
  methods: {
    taozhuan(id) {
      this.$router.push({
        path: "/memberManageExamine",
        query: { type: "xiugai" },
      });
    },

    taozhuanDe(id) {
      this.$router.push({
        path: "/memberManageDetail",
        query: { type: "xiangqing" },
      });
    },
  },
};
</script>
