<template>
  <div class="ls-search-form">
    <el-row :gutter="30" class="search-style">
      <el-col :span="5">
        <label>报告类型</label>
        <common-select
          :dictType="'Crm_Report_Type'"
          size="mini"
          v-model="queryParam.workType"
          style="width: 100%"
        >
        </common-select>
      </el-col>
      <el-col :span="5">
        <label>批阅状态</label>
        <common-select
          :dictType="'Crm_ReviewStatus'"
          size="mini"
          v-model="queryParam.reviewStatus"
        ></common-select>
      </el-col>
     <!-- <el-col :span="4">
        <label>提交部门</label>
        <el-select
          clearable
          :filterable="true"
          size="mini"
          v-model="queryParam.deptName"
          placeholder="请选择"
        >
          <el-option
            v-for="item in depts"
            :value="item"
            :key="item"
            :label="item"
          ></el-option>
        </el-select>
      </el-col>-->
      <el-col :span="5">
        <label>提交人员</label>
        <el-input
          v-model="queryParam.createrName"
          size="mini"
          placeholder="请输入"
          @keyup.enter.native="doSearch"
          clearable
        ></el-input>
      </el-col>
      <el-col :span="8">
        <label>提交时间</label>
        <el-date-picker
          @change="timeData"
          v-model="timeDatas"
          type="daterange"
          size="mini"
          clearable
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd HH:mm:ss"
        >
        </el-date-picker>
      </el-col>
    </el-row>
   <!-- <el-row :gutter="20" class="search-style">
      <el-col :span="8">
        <label>关键词搜索</label>
        <el-input
          v-model="queryParam.searchKey"
          size="mini"
          placeholder="请输入"
          @keyup.enter.native="doSearch"
          clearable
        ></el-input>
      </el-col>
    </el-row>-->
    <div class="btns-wrap">
      <el-button
        @click="doSearch"
        type="warning"
        icon="el-icon-search"
        size="mini"
        >查询</el-button
      >
      <el-button
        @click="reSet"
        type="info"
        icon="el-icon-refresh-left"
        plain
        size="mini"
        >重置</el-button
      >
    </div>
  </div>
</template>

<script>
import commonSelect from "../../../../components/common-select.vue";
export default {
  name: "task-list-search",
  components: {
    commonSelect,
  },
  props: {
    getData: {
      type: Object,
      default: () => {},
      required: false,
    },
  },
  created: function () {
    //this.innitDepts();
    // this.queryParam=this.getData
  },
  computed: {
    sid() {
      return this.$common.getUrlParams("sid");
    },
  },
  methods: {
    innitDepts() {
      this.$ajax.post({
          domain: "crmUrl",
          url: "work.getAllDetps",
          data: {},
          requestType: 'body',
          showLoad: false,
          success: function (res) {
            if (res.errorCode === 200) {
              this.depts = res.data;
            }
          }.bind(this),
          error: function (res) {
            this.$message.error(  res.body.msg || res.msg );
          }.bind(this)
      })
    },
    doSearch: function () {
      this.$emit("query", this.queryParam);
    },
    //重置
    reSet: function () {
      var date = new Date();
      var mytime = date.toLocaleString();
      console.log(mytime);
      this.queryParam = {
        deptName: "",
        starTime: "",
        endTime: "",
        reviewStatus: "",
        deptId: "",
        createrId: "",
        createrName: "",
        workType: "",
        searchKey:""
      };
      this.timeDatas = [];
      this.doSearch();
    },
    timeData() {
      if (this.timeDatas == "" || this.timeDatas == undefined) {
        this.queryParam.starTime = "";
        this.queryParam.endTime = "";
      } else {
        this.queryParam.starTime = this.timeDatas[0];
        this.queryParam.endTime = this.timeDatas[1];
      }
    },
  },
  watch: {
    getData: {
      handler(val) {
        console.log("getData", val);
        if ("getData".length == {}) {
          // this.typeData()
          this.queryParam = "getData";
        }
      },
    },
    immediate: true,
  },
  data: function () {
    return {
      personnelData: [],
      timeDatas: [],
      openType: "",
      users: "", //v-mdoel aws-org users
      queryParam: {
        createrName: "",
        starTime: "",
        endTime: "",
        deptName: "",
        reviewStatus: "",
        deptId: "",
        workType: "",
        reportBigType: "workReport",
      },
      depts: [],
    };
  },
};
</script>

<style type="text/css" scoped lang="scss">
</style>
