/*
 * @description:  实际申请人
 */
<template>
  <EMSTableNew
    ref="emsTable"
    :action="action"
    :columns="columns"
    :params="searchForm"
    :rowClickHandle="rowClick"
  >
    <Form ref="searchForm" class="select-actual-applicant_searchForm" slot="search-bar" :model="searchForm" :labelWidth="110"
        inline>
      <FormItem prop="title" label="实际申请人名称">
        <Input v-model="searchForm.title" type="text" placeholder="请输入" clearable />
      </FormItem>
      <FormItem prop="code" label="实际申请人账号">
        <Input v-model="searchForm.code" type="text" placeholder="请输入" clearable />
      </FormItem>
      <FormItem prop="queryOuName" label="实际申请人公司">
        <Input v-model="searchForm.queryOuName" type="text" placeholder="请输入" clearable />
      </FormItem>
      <div
          v-show="!showMore"
          class="search_btns ivu-form-item"
          style="width: 25%"
        >
          <Button
            type="warning"
            class="ems-btn-medium ems-btn-type1"
            @click.native="search"
          >
            {{ $t('查询') }}
          </Button>          
          <Button
            class="ems-btn-medium ems-btn-type3"
            @click.native="reset"
          >
            {{ $t('重置') }}
          </Button>
          <a @click="changeShowMore">{{ $t('查看更多') }}</a>
        </div>
      <FormItem prop="queryOrgName" label="实际申请人部门">
        <Input v-model="searchForm.queryOrgName" type="text" placeholder="请输入" clearable />
      </FormItem>
      <div
          v-show="showMore"
          class="search_btns ivu-form-item"
          style="width: 100%"
        >
          <Button
            type="warning"
            class="ems-btn-medium ems-btn-type1"
            @click.native="search"
          >
            {{ $t('查询') }}
          </Button>          
          <Button
            class="ems-btn-medium ems-btn-type3"
            @click.native="reset"
          >
            {{ $t('重置') }}
          </Button>
          <a @click="changeShowMore">{{ $t('隐藏更多') }}</a>
        </div>
    </Form>
    
    <!-- <div slot="handle-bar">
      <Button type="warning" icon="md-search" @click.native="search">查询</Button>
      <Button type="info" icon="md-sync" @click.native="reset">重置</Button>
    </div> -->
  </EMSTableNew>
</template>
<script>
export default {
  name: "SelectBudgetSubject",
  props: {
    title: {
      type: String,
      default: "选择实际申请人"
    },
    orgId: {
      type: String,
      default: ""
    },
    ouCodes: {
      type: String,
      default: ""
    },
    bizLineCode: {
      type: String,
      default: ""
    },
    userWithoutSelf: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      action: "/ems/ems-base-application/sysorg/findSubEmployees/allOrg/2",
      searchForm: {
        orgId: this.orgId,
        ouCodes: this.ouCodes,
        bizLineCode: this.bizLineCode,
        userWithoutSelf: this.userWithoutSelf,
        title: "",
        code: "",
        queryOuName: "",
        queryOrgName: "",
        orgLevel: 2
      },
      showMore: false,
      columns: [
        {
          title: "序号",
          type: "index",
          width: 60,
          resizable: true,
          align: "left",
        },
        {
          title: `账号`,
          align: "left",
          resizable: true,
          key: "code",
          minWidth: 150
        },
        {
          title: `编号`,
          align: "left",
          resizable: true,
          key: "id",
          minWidth: 150
        },
        {
          title: `名称`,
          align: "left",
          resizable: true,
          key: "title",
          width: 150
        },
        {
          title: `公司`,
          align: "left",
          resizable: true,
          key: "ouName",
          width: 150
        },
        {
          title: `部门`,
          align: "left",
          resizable: true,
          key: "orgName",
          width: 150
        },
        {
          title: `岗位`,
          align: "left",
          key: "jobCodeDescr",
          width: 150
        }
      ]
    };
  },
  computed: {},
  created() {
    this.$emit("SetTitle", this.title);
  },
  mounted() {},
  methods: {
    changeShowMore() {
      this.showMore = !this.showMore;
      this.$refs.emsTable.showMore();
    },
    onSelectRow(data) {
      if (data.length == 0) return;
      this.$emit("Close", data[0]);
    },
    search() {
      this.$refs.emsTable.load(this.searchForm);
    },
    reset() {
      this.$refs.searchForm.resetFields();
      this.$refs.emsTable.load(this.searchForm);
    },
    rowClick(selection) {
      if (selection) {
        this.$emit("Close", selection);
      }
    }
  }
};
</script>
<style lang="less">
.select-actual-applicant_searchForm{
  padding-top: 5px;
  .ivu-form-item{
    width: 23.5%;
  }
}
</style>
