<template>
  <div id="app" v-cloak>
    <div class="app-main">
      <div class="app-main-zhunbeixuanzhuan">
        <div class="app-main-xuanzhuan">
          <div class="search clear">
            <div
              class="shengxia"
              @click="dialog = true"
              v-text="
                (options.find((item) => item.value == value) || {}).label ||
                '--'
              "
            ></div>
            <el-date-picker
              v-if="value === '4'"
              class="fr"
              style="width: 112px"
              v-model="dadataTime"
              :size="'small'"
              align="right"
              type="date"
              :editable="false"
              :clearable="false"
              placeholder="选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
              :picker-options="pickerOptions"
            >
            </el-date-picker>
            <div class="fr my-fr" v-else>
              <i class="el-icon-time"></i>
              <span>{{ dadataTime }}</span>
            </div>
          </div>
          <ul class="myul">
            <li class="myli" v-if="value === '1'">
              <sales-report-rejected />
            </li>
            <li class="myli" v-else-if="value === '2'">
              <sales-report />
            </li>
            <li class="myli" v-else-if="value === '3'">
              <sales-report-m />
            </li>
            <li class="myli" v-else>
              <sales-report-rejected-settlement :date="dadataTime" />
            </li>
          </ul>
          <el-drawer
            :before-close="handleClose"
            :visible.sync="dialog"
            :modal="false"
            :show-close="false"
            size="200"
            direction="ttb"
            ref="drawer"
          >
            <div class="demo-drawer__content">
              <div class="demo-drawer__content_header">
                <font>请选择报表类型</font>
              </div>
              <ul class="demo-drawer__content_body">
                <li
                  v-for="(item, index) in options"
                  :key="item.value + item.label + index"
                  :class="{ active_e: item.value === value + '' }"
                  @click="changeOption(index)"
                >
                  <font>{{ item.label }}</font>
                </li>
              </ul>
            </div>
          </el-drawer>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      dialog: false,
      options: [
        {
          value: "1",
          label: "业绩达成报表(含退货)",
        },
        {
          value: "2",
          label: "业绩达成报表",
        },
        {
          value: "3",
          label: "销售退货报表",
        },
        {
          value: "4",
          label: "测试业绩达成报表(含退货)-产品确认单",
        },
      ],
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
      },
      value: "1",
      dadataTime: "",
    };
  },
  async created() {
    this.dadataTime = this.transformTime();
  },
  methods: {
    transformTime() {
      let time = new Date();
      let y = time.getFullYear();
      let M = time.getMonth() + 1;
      let d = time.getDate();
      return y + "-" + (M < 10 ? "0" + M : M) + "-" + (d < 10 ? "0" + d : d);
    },
    selectChange() {
      if (this.value !== 4) {
        this.dadataTime = this.transformTime();
      }
    },
    changeOption(index) {
      this.value = this.options[index].value;
    },
  },
};
</script>
<style lang="scss">
@mixin layout-dev {
  position: fixed;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
html {
  @include layout-dev;

  body {
    @include layout-dev;
    text-align: left;
  }
  .clear::after,
  .clear::before {
    content: "";
    display: block;
    clear: both;
  }

  #app {
    @include layout-dev;

    padding: 0;
    .app-main {
      width: 100%;
      height: 100%;
      padding: 0;
      margin: 0;
      box-sizing: border-box;
      .app-main-zhunbeixuanzhuan {
        position: relative;
        width: 100%;
        height: 100%;
        box-sizing: border-box;
        .app-main-xuanzhuan {
          position: absolute;
          width: 100%;
          height: 100%;
          // bottom: 0px;
          box-sizing: border-box;
          // left: -667px;
          // width: 667px;
          // height: 375px;
          padding: 16px;
          // transform: rotate(90deg);
          // -ms-transform: rotate(90deg);
          // /* Internet Explorer 9*/
          // -moz-transform: rotate(90deg);
          // /* Firefox */
          // -webkit-transform: rotate(90deg);
          // /* Safari 和 Chrome */
          // -o-transform: rotate(90deg);
          // transform-origin: right bottom;
        }
      }
      .search {
        position: relative;
        padding: 0 0 12px 0;
      }
      .shengxia {
        float: left;
        height: 33px;
        line-height: 32px;
        width: calc(100% - 122px);
        -webkit-appearance: none;
        background-color: #fff;
        background-image: none;
        border-radius: 4px;
        border: 1px solid #dcdfe6;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        color: #606266;
        font-size: 13px;
        outline: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        　white-space: nowrap;
        padding: 0 15px;
      }
      .fr {
        float: right;
      }
      .fr.my-fr {
        width: 112px;
        line-height: 32px;
        text-align: right;
        i {
          font-size: 17px;
          height: 32px;
          line-height: 32px;
          color: #606266;
          display: inline-block;
          vertical-align: top;
        }
        span {
          display: inline-block;
          vertical-align: top;
          color: #606266;
          font-size: 14px;
          padding: 0 0 0 5px;
        }
      }
      .title {
        text-align: center;
        padding: 0 0 8px 0;
      }
      .el-table .el-table__header-wrapper table thead tr th {
        background: #f5f7fa !important;
      }
      .el-date-editor.fr.el-input.el-input--small.el-input--prefix.el-input--suffix.el-date-editor--date {
        .el-input__inner {
          padding-right: 0 !important;
        }
      }
      .el-drawer__wrapper {
        #el-drawer__title {
          margin: 0 !important;
          display: none !important;
        }
        .el-drawer__body {
          .demo-drawer__content_header {
            padding: 20px 20px 0 !important;
            font-size: 16px !important;
            color: #72767b !important;
          }
          ul.demo-drawer__content_body {
            width: 100% !important;
            box-sizing: border-box !important;
            li {
              height: 23px !important;
              line-height: 23px !important;
              font-size: 14px !important;
              color: #72767b !important;
              box-sizing: border-box !important;
            }
            li.active_e {
              height: 23px !important;
              line-height: 23px !important;
              color: #409eff !important;
              font-size: 14px !important;
              box-sizing: border-box !important;
            }
          }
        }
      }
      .myul {
        position: relative;
        list-style-type: none;
        padding: 0;
        margin: 0;
        box-sizing: border-box;
        width: 100%;
        .myli {
          position: relative;
          list-style-type: none;
          padding: 0;
          margin: 0;
          width: 100%;
        }
      }
    }
  }
}
</style>
