<template>
  <div class="quote">
    <div class="back-line-main">
      <!-- <div class="back-line-header"></div> -->
      <div style="background-color: #fff">
        <div class="table-title">
          <h2>代理人</h2>
          <div>
            <span>时间筛选</span>
            <a-range-picker
              @change="onChangeTime"
              v-model="formState.time"
              value-format="YYYY-MM-DD"
              style="margin-left: 10px"
            >
              <a-icon slot="suffixIcon" type="calendar" />
            </a-range-picker>
            <a-radio-group
              default-value="0"
              button-style="solid"
              v-model="formState.type"
              @change="getVerification()"
              style="margin-left: 10px"
            >
              <a-radio-button
                value="1"
                @click="
                  (formState.time = []),
                    (formState.beginDate = ''),
                    (formState.endDate = '')
                "
              >
                当天
              </a-radio-button>
              <a-radio-button
                value="2"
                @click="
                  (formState.time = []),
                    (formState.beginDate = ''),
                    (formState.endDate = '')
                "
              >
                近7天
              </a-radio-button>
              <a-radio-button
                value="3"
                @click="
                  (formState.time = []),
                    (formState.beginDate = ''),
                    (formState.endDate = '')
                "
              >
                近30天
              </a-radio-button>
            </a-radio-group>
          </div>
        </div>

        <standard-table
          bordered
          :columns="columns"
          :dataSource="tableList"
          :pagination="pagination"
          @clear="onClear"
          @change="onChange"
          :loading="loading"
        >
          <div slot="date" slot-scope="{ record }">
            {{ moment(record.dateTime) }}
          </div>
        </standard-table>
      </div>
    </div>
  </div>
</template>
            
  <script>
import StandardTable from "@/components/table/StandardTable";
// import mixin from "../../minins/mixin";
//   import tree from "@/components/tree/tree";
import moment from "moment";

const columns = [
  {
    title: "日期",
    dataIndex: "dateTime",
    // scopedSlots: { customRender: "date" },
  },

  {
    title: "呼出时长（分钟）",
    dataIndex: "exhaleDuration",
  },
  {
    title: "呼出数量",
    dataIndex: "outgoingCallsNumber",
  },
  {
    title: "接通数量",
    dataIndex: "connectionsNumber",
  },
  {
    title: "输出成功率",
    dataIndex: "callSuccessRate",
  },
  {
    title: "添加微信人数",
    dataIndex: "wxCount",
  },
  {
    title: "添加企业微信人数",
    dataIndex: "qywxCount",
  },
];

export default {
  components: {
    StandardTable,
    //   tree,
  },
  //   mixins: [mixin],
  data() {
    return {
      formState: {
        type: undefined,
        time: [moment().format("YYYY-MM-DD"), moment().format("YYYY-MM-DD")],
        beginDate: moment().format("YYYY-MM-DD"),
        endDate: moment().format("YYYY-MM-DD"),
        userName: "",
        groupId: "",
        deptId: "",
      },
      backLinePersonnel: {},
      columns: columns,
      companyList: [],
      tableList: [],
      pagination: {
        current: 1,
        defaultPageSize: 10,
        total: 0,
        pagesize0ptions: ["10", "20", "30", "50", "100"],
        hideOnSinglePage: false,
        showQuickJumper: true, //
        showSizeChanger: true, //是否可以改变pagesize
        showTotal: (total) => `共 ${total} 条数据`,
      },
      loading: false,
      wholeList: [],
      provinceList: [],
      cityList: [],
      areaList: [],
      storeList: [],
      treeData: [
        { title: "Expand to load", key: "0" },
        { title: "Expand to load", key: "1" },
        { title: "Tree Node", key: "2", isLeaf: true },
      ],
      amount: {},
      groupList: [],
    };
  },
  mounted() {
    // this.$route.query.data

    this.getVerification();
    //   this.getGroupList();
    // setTimeout(() => {
    // }, 1000);
  },
  methods: {
    getGroupList() {
      this.$API.sales
        .getSalesGroupList({
          deptId: this.formState.deptId || "99",
        })
        .then((res) => {
          if (res.data.code === 200) {
            this.groupList = [...res.data.data];
          }
        });
    },
    chooseUser(val) {
      this.formState.deptId = val;
      this.getGroupList();
      this.getVerification();
    },
    getList() {
      this.pagination.current = 1;
      this.pagination.defaultPageSize = 10;
      this.getVerification();
    },
    onChangeTime(val) {
      this.formState.beginDate = val[0];
      this.formState.endDate = val[1];
      this.formState.type = undefined;
      this.pagination.current = 1;
      this.pagination.defaultPageSize = 10;
      this.getVerification();
    },

    async getVerification() {
      this.loading = true;

      this.$API.sales
        .getSalesDetails({
          pageNum: this.pagination.current,
          pageSize: this.pagination.defaultPageSize,
          ...this.formState,
          userId: this.$route.query.userId,
        })
        .then((res) => {
          if (res.data.code === 200) {
            this.loading = false;
            this.tableList = res.data.data.content;
            this.pagination = {
              current: res.data.data.pageNum,
              defaultPageSize: res.data.data.pageSize,
              total: res.data.data.totalSize,
            };
          } else {
            this.loading = false;

            this.tableList = [];
            this.$message.error(res.data.msg);
            this.pagination.total = 0;
          }
        });
    },
    onClear() {
      this.$message.info("您清空了勾选的所有行");
    },

    onChange(pagination) {
      // this.$message.info('表格状态改变了')

      this.pagination = {
        current: pagination.current,
        defaultPageSize: pagination.pageSize,
        total: pagination.total,
      };
      this.getVerification();
    },
  },
};
</script>
  <style lang='less' scoped>
.quote {
  display: flex;
  > div:first-child {
    width: 20%;
    background: #fff;
    margin-right: 15px;
  }
  .quote-tree {
    padding: 15px;
    box-sizing: border-box;
    //
    > div:first-child {
      border-bottom: 1px solid #f0f0f0;
    }
  }
}
.back-line-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  .back-line-header {
    // padding: 15px;
    box-sizing: border-box;
    .back-line-header-title {
      padding: 15px;
      box-sizing: border-box;
      background: #ffffff;
      box-shadow: 0px 2px 8px 0px rgba(141, 149, 176, 0.15);
      border-radius: 8px 8px 8px 8px;
      border: 2px solid rgba(255, 255, 255, 0.2);
      h2 {
        margin: 0;
      }
      > div {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        > dl {
          flex: none;
          width: 180px;
          height: 80px;
          display: flex;
          //   align-items: center;
          justify-content: space-between;
          flex-direction: column;
          padding: 10px;
          box-sizing: border-box;

          border-radius: 4px 4px 4px 4px;

          > dd {
            display: flex;
            // align-items: center;
            justify-content: flex-end;
            margin: 0;
            font-family: PingFang SC, PingFang SC;
            font-weight: 500;
            font-size: 24px;
            // color: rgba(0, 0, 0, 0.85);
            // padding-left: 15px;
            box-sizing: border-box;
          }
        }
        > dl:first-child {
          background: url("../../assets/img/business1.png");
          color: #11a6d3;
        }
        > dl:nth-child(2) {
          background: url("../../assets/img/business2.png");
          color: #f87f2c;
        }
        > dl:nth-child(3) {
          background: url("../../assets/img/business3.png");
          color: #fab600;
        }
        > dl:nth-child(4) {
          background: url("../../assets/img/business4.png");
          color: #80be38;
        }
        > dl:nth-child(5) {
          background: url("../../assets/img/business5.png");
          color: #906cef;
        }
        > dl:nth-child(6) {
          background: url("../../assets/img/business6.png");
          color: #47a2eb;
        }
      }
      span {
        display: block;
        margin-right: 15px;
      }
      /deep/.ant-calendar-picker {
        width: 300px;
      }
    }
  }
  > div {
    // height: 152px;
    // background: #fff;
    .ant-form {
      display: flex;
      padding-top: 10px;
      box-sizing: border-box;
      > .ant-form-item {
        flex: none;
        /deep/.ant-form-item-control-wrapper {
          width: 100%;
        }
      }
    }
    .form-item-search {
      // display: flex;
      // justify-content: flex-end;
      /deep/ .ant-form-item-control {
        display: flex;
        justify-content: flex-end;
      }
    }
  }
  .table-title {
    padding: 15px;
    border-bottom: 1px solid #eee;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    h2 {
      margin: 0;
    }
    > div {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: flex-end;
    }
  }
}
.ant-form {
  display: flex;
  padding-top: 10px;
  box-sizing: border-box;
}
.ant-form-item {
  // display: flex;
}
</style>