DESKTOP-4R4T6M5_莫攀20200723

day08

1.学习内容

  • 前端显示的表数据的删除功能。
    #### 2.自我总结
  • 今日完成
    • 关联表的异步请求与页面展示
  • 关键代码
    • EmployeeDao
      ``
      /**
      * 查询公司信息
      * @return
      */
      public List<Map<String,Object>> queryDepartments() {
      String sql = "SELECT
      department_iddepartmentId,department_namedepartmentName," +
      "
      manager_name` managerName " +
      "FROM em_departments";
      List> list = queryForMap(sql);
      return list;
      }

/**
* 查询某个公司的城市地址
* @param departmentId
* @return
*/
public List> queryCitysOfDepartment(Integer departmentId){
String sql = "SELECT location_id locationId,city," +
"street_address streetAddress,d.department_id departmentId " +
"FROM em_departments d " +
"LEFT OUTER JOIN em_locations l " +
"ON d.department_id=l.department_id " +
"WHERE d.department_id=?";
List> list = queryForMap(sql, departmentId);
return list;
}

/**
* 查询某个公司的工作岗位
* @param departmentId
* @return
*/
public List> queryJobsOfDepartment(Integer departmentId){
String sql = "SELECT job_id jobId,job_title jobTitle,min_salary minSalary," +
"max_salary maxSalary,j.department_id departmentId " +
"FROM em_departments d " +
"LEFT OUTER JOIN em_jobs j " +
"ON d.department_id=j.department_id " +
"WHERE d.department_id=?";
List> list = queryForMap(sql, departmentId);
return list;
}

- 前端vue渲染

getField(val) {
//点击部门下拉列表为部门options动态赋值
if (val == "departmentId") {
this.\(http
.get("api/EmployeeManage/EmployeeServlet?method=getDepartments")
.then(res => {
var index = this.operateFormLabel.findIndex(
item => item.model === val
);
this.operateFormLabel[index].options = res.data.data;
});
}
},
getDepartmentId(val) {
//console.log(val);
//根据val的值给所在地下拉列表options动态赋值
this.\)http
.get(
"api/EmployeeManage/EmployeeServlet?method=getCitysOfDepartment&departmentId=" +
val
)
.then(response => {
var index = this.operateFormLabel.findIndex(
item => item.model === "locationId"
);
this.operateFormLabel[index].options = response.data.data;
console.log(this.operateFormLabel[index].options);
});
//根据val的值给职位下拉列表options动态赋值
this.$http
.get(
"api/EmployeeManage/EmployeeServlet?method=getJobsOfDepartment&departmentId=" +
val
)
.then(res => {
var index = this.operateFormLabel.findIndex(
item => item.model === "jobId"
);
this.operateFormLabel[index].options = res.data.data;
});
}

标签

评论

© 2021 成都云创动力科技有限公司 蜀ICP备20006351号-1