<template>
  <el-dialog
    :title="$t('admin.assignAdmin')"
    v-model="visible"
    :width="800"
    destroy-on-close
    @closed="$emit('closed')"
  >
    <el-container>
      <el-header>
        <div class="left-panel">
          <div class="right-panel-search">
            <el-input
              v-model="search.KeyWord"
              clearable
              :placeholder="$t('admin.pleaseInputAdminName')"
            >
            </el-input>
            <el-button type="primary" icon="el-icon-search" @click="upsearch">{{
              $t("query")
            }}</el-button>
          </div>
        </div>
      </el-header>
      <el-main class="nopadding">
        <scTable
          ref="table"
          :apiObj="apiObj"
          :pageSize="10"
          row-key="AdminCode"
          stripe
          :hideDo="true"
        >
          <el-table-column prop="AdminCode" :width="34">
            <template #default="scope">
              <el-radio
                v-model="selectCode"
                :label="scope.row.AdminCode"
                @click="selectCode = scope.row.AdminCode"
              />
            </template>
          </el-table-column>
          <el-table-column
            :label="$t('admin.accountName')"
            prop="AdminName"
          ></el-table-column>
          <el-table-column
            :label="$t('admin.fullName')"
            prop="FullName"
          ></el-table-column>
          <el-table-column
            :label="$t('admin.roleName')"
            prop="DefaultRoleName"
          ></el-table-column>
        </scTable>
      </el-main>
    </el-container>

    <template #footer>
      <el-button @click="visible = false">{{
        $t("dialogBox.cancelButtonText")
      }}</el-button>
      <el-button type="primary" :loading="isSaveing" @click="submit()">{{
        $t("dialogBox.saveButtonText")
      }}</el-button>
    </template>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      visible: false,
      selectCode: "",
      apiObj: this.query,
      search: { KeyWord: "", IsShowSuperRoleCode: false, QueryType: "1" },
    };
  },
  methods: {
    open() {
      this.visible = true;
      return this;
    },
    setData(selectCode) {
      this.selectCode = selectCode;
    },
    submit() {
      this.$emit("success", this.selectCode);
      this.visible = false;
    },
    async query(params) {
      return await this.$API.wing.list("GetAdminPagesAsync", params);
    },
    //搜索
    upsearch() {
      this.$refs.table.upData(this.search);
    },
    //刷新当前页
    refresh() {
      this.$refs.table.refresh();
    },
  },
};
</script>

<style>
</style>
