export default {
  data(){
    return {
      visibleDialog: false,
      searchVal: "",
      activeName: "1",
      departments: {},
      roles: [],
    }
  },
  methods:{
    getRoleList() {
      // console.log('getRoleList')
      this.roles= [
        {
          "code": "SHGLY",
          "roleId": "1",
          "scope": "1",
          "roleName": "审核管理员",
          "description": "初始化内置审批角色",
          "status": "1"
        }, {
          "code": "",
          "roleId": "2",
          "scope": "1",
          "roleName": "招商事业部",
          "description": "",
          "status": "1"
        }, {
          "code": "",
          "roleId": "3",
          "scope": "1",
          "roleName": "互联网部门",
          "description": "",
          "status": "1"
        }, {
          "code": "",
          "roleId": "4",
          "scope": "1",
          "roleName": "销售部",
          "description": "",
          "status": "1"
        }, {
          "code": "",
          "roleId": "5",
          "scope": "1",
          "roleName": "战区一",
          "description": "",
          "status": "1"
        }, {
          "code": "",
          "roleId": "6",
          "scope": "1",
          "roleName": "战区二",
          "description": "",
          "status": "1"
        }, {
          "code": "",
          "roleId": "7",
          "scope": "1",
          "roleName": "JAVA开发",
          "description": "",
          "status": "1"
        }, {
          "code": "",
          "roleId": "8",
          "scope": "1",
          "roleName": "测试审批角色",
          "description": "",
          "status": "1"
        }
      ]

      // this.$axios.get(`${process.env.BASE_URL}roles.json`).then(res => {
      //     this.roles = res.data.list;
      // })
    },
    getDepartmentList(parentId = 0) {
      // console.log('getDepartmentList')
        // this.$axios.get(`${process.env.BASE_URL}departments.json?parentId=${parentId}`).then(res => {
        //     this.departments = res.data;
        // })
      this.departments = {
          "childDepartments": [{
            "departmentKey": "RLXZB_V2",
            "departmentName": "人力行政部",
            "id": "150",
            "parentId": "0",
            "departmentNames": "人力行政部"
          }, {
            "departmentKey": "ZNBN",
            "departmentName": "法务部",
            "id": "324",
            "parentId": "0",
            "departmentNames": "法务部"
          }],
          "employees": [{
            "id": "53128111",
            "employeeName": "亚nan",
            "isLeave": "0",
            "open": "false"
          }],
          "titleDepartments": []
        }
    },
    getDebounceData(event, type = 1) {
      this.$appfunc.debounce(function () {
          if (event.target.value) {
              if (type == 1) {
                  this.departments.childDepartments = [];
                  // this.$axios.get(`${process.env.BASE_URL}employees.json?searchName=${event.target.value}&pageNum=1&pageSize=30`).then(res => {
                  //     this.departments.employees = res.data.list
                  // })
                this.departments.employees=   [
                  {
                    "departmentName": "招商事业部",
                    "employeeName": "111111",
                    "employeeDepartmentId": "121",
                    "id": "5312",
                    "departmentNames": "招商事业部"
                  }, {
                    "departmentName": "111",
                    "employeeName": "东亚-测试",
                    "employeeDepartmentId": "139",
                    "id": "2515638",
                    "departmentNames": "111"
                  }, {
                    "departmentName": "招商事业部",
                    "employeeName": "1111",
                    "employeeDepartmentId": "121",
                    "id": "2515746",
                    "departmentNames": "招商事业部"
                  }
                ]
              } else {
                  // this.$axios.get(`${process.env.BASE_URL}roles.json?searchName=${event.target.value}&pageNum=1&pageSize=30`).then(res => {
                  //     this.roles = res.data.list
                  // })
                this.roles =    [
                    {
                      "code": "SHGLY",
                      "roleId": "1",
                      "scope": "1",
                      "roleName": "审核管理员",
                      "description": "初始化内置审批角色",
                      "status": "1"
                    }, {
                      "code": "",
                      "roleId": "2",
                      "scope": "1",
                      "roleName": "招商事业部",
                      "description": "",
                      "status": "1"
                    }, {
                      "code": "",
                      "roleId": "3",
                      "scope": "1",
                      "roleName": "互联网部门",
                      "description": "",
                      "status": "1"
                    }, {
                      "code": "",
                      "roleId": "4",
                      "scope": "1",
                      "roleName": "销售部",
                      "description": "",
                      "status": "1"
                    }, {
                      "code": "",
                      "roleId": "5",
                      "scope": "1",
                      "roleName": "战区一",
                      "description": "",
                      "status": "1"
                    }, {
                      "code": "",
                      "roleId": "6",
                      "scope": "1",
                      "roleName": "战区二",
                      "description": "",
                      "status": "1"
                    }, {
                      "code": "",
                      "roleId": "7",
                      "scope": "1",
                      "roleName": "JAVA开发",
                      "description": "",
                      "status": "1"
                    }, {
                      "code": "",
                      "roleId": "8",
                      "scope": "1",
                      "roleName": "测试审批角色",
                      "description": "",
                      "status": "1"
                    }
                    ]
              }
          } else {
              type == 1 ? this.getDepartmentList() : this.getRoleList();
          }
      }.bind(this))()
    },
  }
}
