<template>
  <el-dialog
    title="选择检查要点"
    :visible.sync="isShow"
    class="g-dialog-select-safe-check"
    :close-on-click-modal="false"
    width="55%"
    top="10vh"
    append-to-body
  >
    <div class="el-dialog-div">
      <g-search-table
        ref="st"
        url="/core/resumption/ruleItem/pointSelectionPage"
        method="get"
        :search-data="search"
        :manual="true"
        :pageable="true"
        :select="true"
        :select-default="selectList"
        :drag="false"
        @select="onSelect"
      >
        <!-- 搜索 -->
        <template slot="searchs">
          <el-form-item prop="ruleId" label="履职内容库">
            <el-select v-model="search.ruleId">
              <el-option
                v-for="item in ruleList"
                :value="item.id"
                :key="item.id"
                :label="item.name"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="key" label="关键字">
            <el-input v-model="search.key"></el-input>
          </el-form-item>
        </template>

        <!-- 表格 -->
        <template slot="columns">
          <el-table-column
            prop="itemName"
            label="履职项"
           min-width="40%"
          ></el-table-column>
          <el-table-column label="履职内容" prop="pointName" min-width="40%"> </el-table-column>
          <el-table-column
            prop="areaName"
            label="履职区域"
            min-width="20%"
          ></el-table-column>
          <!--          <el-table-column prop="nfcName"
                           label="采集点"
                           width="120"></el-table-column>-->
        </template>
      </g-search-table>
    </div>

    <div slot="footer" class="dialog-footer">
      <el-button @click="onHide">关闭</el-button>
      <el-button type="primary" @click="onSubmit">确定</el-button>
    </div>
  </el-dialog>
</template>
<script>
import GSearchTable from "@/components/table/gx.search.table.vue";
import { ruleListForOrg } from "@/api/resumption/rule.js";
export default {
  components: { GSearchTable },
  data() {
    return {
      isShow: false,
      selectList: [],
      ruleList: [],
      search: this.emptySearch(),
    };
  },
  computed: {},
  watch: {},
  props: {
    defaultSelect:{
      type:Array
    },
    orgType:{
      type:String
    }
  },
  methods: {
    show() {
      this.search = this.emptySearch();
      this.isShow = true;
      this.selectList =this.defaultSelect; 
      ruleListForOrg({ orgType: this.orgType }).then((r) => {
        this.ruleList = r.data;
        if (r.data && r.data.length > 0) {
          this.search.ruleId = r.data[0].id;
          // this.$refs.st.search();
        }
      });
    },
    onHide() {
      this.isShow = false;
    },
    onSelect(item) {      
      this.selectList = item;
    },
    onSubmit() {
      let s=this.selectList
      this.$emit("select", this.selectList);
      this.onHide();
    },
    emptySearch() {
      return {
        ruleId: null,
        itemName: null,
      };
    },
  },
  mounted() {},
};
</script>
<style lang="scss" scoped>
.el-dialog-div {
  overflow: auto;
}
</style>
