<template>
  <div id="salesmanList">
    <search-box-new
      ref="searchBox"
      :formData="formData"
      :formList="formList"
      @search="search"
      @init="init"
    />
    <table-list
      rowKey="id"
      ref="tableList"
      :tableSets="tableSet"
      :tableData="tableData"
      :navText="navText"
      @addClick="addClick"
      :loading="loading"
    >
      <template slot="customize">
        <!-- <el-button @click="sales" type="success" size="medium">关联现有业务员</el-button> -->
      </template>
      <template slot="btn" slot-scope="props">
        <!-- <el-button type="text" @click="del(props.scope.row)">禁用</el-button>
        <el-button type="text" @click="del(props.scope.row)">启用</el-button>
        <el-button type="text" @click="editClick(props.scope.row)"
          >详情</el-button
        >
        <el-button type="text" @click="del(props.scope.row)">删除</el-button> -->
      </template>
    </table-list>
    <pagination
      :total="total"
      :pageSize="formData.pageSize"
      :currentPage="formData.pageNum"
      @handleSizeChange="handleSizeChange"
      @handleCurrentChange="handleCurrentChange"
    />
    <form-box ref="formBox"></form-box>
    <sales-checkout ref="salesCheckout" > </sales-checkout>
  </div>
</template>

<script>
import searchBoxNew from "@/components/searchBoxNew";
import tableList from "@/components/tableList";
import pagination from "@/components/pagination";
import FormBox from "./formBox.vue";
import salesCheckout from "./salesCheckout.vue"
export default {
  name: "SalesmanList",
  components: { searchBoxNew, tableList, pagination, FormBox,salesCheckout },
  data() {
    return {
      disabledBtn: false,
      loading: false, //当前表单加载是否加载动画
      navText: {
        title: "业务员列表",
        index: 0,
        ch: "条",
        num: true,
        choice: true,
        addHide: true,
        openCheckMore: true,
        tableHide:true,
        changeWidth: "260px",
        backFatherBtn: {
          status: false,
          title: "配置下单填选模板",
        },
      },
      //搜索
      formList: [
        {
          prop: "tenantId",
          placeholder: "请选择机构",
          scope: "systemtenantlist",
        },
        {
          lable: "邀请人",
          prop: "parentName",
          placeholder: "请输入邀请人",
        },
        {
          lable: "姓名",
          prop: "realname",
          placeholder: "请输入姓名",
        },
      ],
      formData: {
        status: "0,1",
        pageSize: 10,
        pageNum: 1,
      },
      // 表单
      tableSet: [
        {
          label: "业务员编码",
          prop: "userAccount",
          hidden: true,
        },
        {
          label: "姓名",
          prop: "realname",
          hidden: true,
        },
        {
          label: "手机号",
          prop: "phonenumber",
          hidden: true,
        },
        {
          label: "身份证号",
          prop: "idCard",
          hidden: true,
        },
        {
          label: "所属机构",
          prop: "tenantName",
          hidden: true,
        },
        {
          label: "是否完成提现授权",
          prop: "gzhOpenId",
          hidden: true,
          scope:"isgzhOpenId"
        },
        {
          label: "邀请人姓名",
          prop: "parentName",
          hidden: true,
        },
        {
          label: "累计推广员数",
          prop: "promotionNum",
          hidden: true,
        },
        {
          label: "账号状态",
          prop: "status",
          scope: "isOptions",
          hidden: true,
          options: [
            {
              label: "有效",
              value: 1,
            },
            {
              label: "禁止",
              value: 0,
            },
          ],
        },
      ],
      tableData: [], //表单数据
      total: 0, //一共多少条
    };
  },
  created() {
    this.search();
  },
  methods: {
    //关联业务员
    sales(){
      this.$refs.salesCheckout.showBox();
    },
    //添加
    addClick() {
      this.$refs.formBox.showBox();
    },
    editClick(e) {
      this.$refs.formBox.showBox(true);
    },
    search(v) {
      this.loading = true;
      if (v === 2) {
        this.formData = {
          status: "0,1",
          pageSize: 10,
          pageNum: 1,
        };
      }
      var data = JSON.parse(JSON.stringify(this.formData));
      this.$api
        .distributiontempsellerlist(data)
        .then((res) => {
          this.tableData = res.rows;
          this.total = res.total;
          this.navText.index = res.total;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    init() {
      this.search(2);
    },
    del(v) {
      this.$alert(
        "确定删除此内容？<br />内容删除后将无法恢复，请慎重考虑",
        "提示",
        {
          dangerouslyUseHTMLString: true,
        }
      )
        .then(() => {
          this.$message.success("删除成功");
          this.search();
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },

    handleSizeChange(v) {
      this.formData.pageSize = v;
      this.formData.pageNum = 1;
      this.search();
    },
    handleCurrentChange(v) {
      this.formData.pageNum = v;
      this.search();
    },
  },
};
</script>

<style lang="scss" scoped>
/deep/.el-button {
  border-radius: 8px;
}
/deep/.el-dialog {
  border-radius: 8px;
  .el-dialog__header {
    padding: 0;
    .hearders {
      height: 40px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0px 18px 0px 20px;
      border-bottom: 1px solid #e2e2e2;
      .leftTitle {
        font-size: 14px;
        font-weight: bold;
        color: #2f4378;
      }
      .rightBoxs {
        display: flex;
        align-items: center;
        img {
          width: 14px;
          height: 14px;
          margin-left: 13px;
          cursor: pointer;
        }
      }
    }
  }
  .el-dialog__footer {
    padding: 0;
    .dialog-footer {
      padding: 0px 40px;
      height: 70px;
      border-top: 1px solid #e2e2e2;
      display: flex;
      align-items: center;
      justify-content: flex-end;
    }
  }
}
.imgBox {
  width: 100%;
  // height: 210px;
  border: 1px solid #e2e2e2;
  border-radius: 8px;
  padding: 8px 8px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  .imgLabel {
    flex: 1;
    width: 100%;
    border: 1px dotted #e2e2e2;
    color: #999;
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    .msPhoto {
      display: flex;
      justify-content: center;
      align-items: center;
      max-width: 100%;
      max-height: 270px;
      img {
        max-width: 100%;
        max-height: 270px;
      }
    }
    .imgbbx {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 100%;
      i {
        font-weight: bold;
        margin: 14px 0;
        font-size: 24px;
      }
    }
  }
  p {
    margin: 5px 0px;
  }
}
.numInputs {
  width: 150px;
}
</style>
