BAOLH
2026-03-10 31741895b1381df8335e012d7ab0a5cfb6ba1f32
用户信息添加二级岗位信息
10 files added
5 files modified
753 ■■■■■ changed files
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/JobSecond.java 67 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java 4 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/JobSecondRepository.java 28 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/JobSecondController.java 94 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/JobSecondService.java 83 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/JobSecondDto.java 47 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/JobSecondQueryCriteria.java 36 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java 2 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/JobSecondServiceImpl.java 111 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java 1 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/JobSecondMapper.java 32 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/api/system/jobSecond.js 32 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/system/job/index.vue 30 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/system/job/jobSecond.vue 150 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/system/user/index.vue 36 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/JobSecond.java
New file
@@ -0,0 +1,67 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.system.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.base.BaseEntity;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author baolh
* @date 2026-03-10
**/
@Entity
@Data
@Table(name="sys_job_second")
public class JobSecond extends BaseEntity implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "ID")
    private Long id;
    @Column(name = "`job_id`")
    @ApiModelProperty(value = "岗位ID")
    private Long jobId;
    @Column(name = "`name`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "岗位名称")
    private String name;
    @Column(name = "`enabled`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "岗位状态")
    private Boolean enabled;
    @Column(name = "`job_sort`")
    @ApiModelProperty(value = "排序")
    private Integer jobSort;
    public void copy(JobSecond source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java
@@ -149,6 +149,10 @@
    @ApiModelProperty(value = "登录控制")
    private Boolean loginEnabled;
    @Column(name = "`job_second_id`")
    @ApiModelProperty(value = "二级岗位ID")
    private Long jobSecondId;
    @Override
    public boolean equals(Object o) {
        if (this == o) {
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/JobSecondRepository.java
New file
@@ -0,0 +1,28 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.system.repository;
import me.zhengjie.modules.system.domain.JobSecond;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2026-03-10
**/
public interface JobSecondRepository extends JpaRepository<JobSecond, Long>, JpaSpecificationExecutor<JobSecond> {
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/JobSecondController.java
New file
@@ -0,0 +1,94 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.system.rest;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.system.domain.JobSecond;
import me.zhengjie.modules.system.service.JobSecondService;
import me.zhengjie.modules.system.service.dto.JobSecondQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2026-03-10
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "二级岗位管理")
@RequestMapping("/api/jobSecond")
public class JobSecondController {
    private final JobSecondService jobSecondService;
    @Log("导出数据")
    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('jobSecond:list')")
    public void exportJobSecond(HttpServletResponse response, JobSecondQueryCriteria criteria) throws IOException {
        jobSecondService.download(jobSecondService.queryAll(criteria), response);
    }
    @GetMapping
    @Log("查询二级岗位")
    @ApiOperation("查询二级岗位")
    @PreAuthorize("@el.check('jobSecond:list')")
    public ResponseEntity<Object> queryJobSecond(JobSecondQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(jobSecondService.queryAll(criteria,pageable),HttpStatus.OK);
    }
    @PostMapping
    @Log("新增二级岗位")
    @ApiOperation("新增二级岗位")
    @PreAuthorize("@el.check('jobSecond:add')")
    public ResponseEntity<Object> createJobSecond(@Validated @RequestBody JobSecond resources){
        return new ResponseEntity<>(jobSecondService.create(resources),HttpStatus.CREATED);
    }
    @PutMapping
    @Log("修改二级岗位")
    @ApiOperation("修改二级岗位")
    @PreAuthorize("@el.check('jobSecond:edit')")
    public ResponseEntity<Object> updateJobSecond(@Validated @RequestBody JobSecond resources){
        jobSecondService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
    @DeleteMapping
    @Log("删除二级岗位")
    @ApiOperation("删除二级岗位")
    @PreAuthorize("@el.check('jobSecond:del')")
    public ResponseEntity<Object> deleteJobSecond(@RequestBody Long[] ids) {
        jobSecondService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
    @GetMapping(value = "/getAll")
    @Log("查询二级岗位")
    @ApiOperation("查询二级岗位")
    public ResponseEntity<Object> queryAllJobSecond(JobSecondQueryCriteria criteria){
        return new ResponseEntity<>(jobSecondService.queryAll(criteria), HttpStatus.OK);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/JobSecondService.java
New file
@@ -0,0 +1,83 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.JobSecond;
import me.zhengjie.modules.system.service.dto.JobSecondDto;
import me.zhengjie.modules.system.service.dto.JobSecondQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @description 服务接口
* @author baolh
* @date 2026-03-10
**/
public interface JobSecondService {
    /**
    * 查询数据分页
    * @param criteria 条件
    * @param pageable 分页参数
    * @return Map<String,Object>
    */
    Map<String,Object> queryAll(JobSecondQueryCriteria criteria, Pageable pageable);
    /**
    * 查询所有数据不分页
    * @param criteria 条件参数
    * @return List<JobSecondDto>
    */
    List<JobSecondDto> queryAll(JobSecondQueryCriteria criteria);
    /**
     * 根据ID查询
     * @param id ID
     * @return JobSecondDto
     */
    JobSecondDto findById(Long id);
    /**
    * 创建
    * @param resources /
    * @return JobSecondDto
    */
    JobSecondDto create(JobSecond resources);
    /**
    * 编辑
    * @param resources /
    */
    void update(JobSecond resources);
    /**
    * 多选删除
    * @param ids /
    */
    void deleteAll(Long[] ids);
    /**
    * 导出数据
    * @param all 待导出的数据
    * @param response /
    * @throws IOException /
    */
    void download(List<JobSecondDto> all, HttpServletResponse response) throws IOException;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/JobSecondDto.java
New file
@@ -0,0 +1,47 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.system.service.dto;
import lombok.Data;
import me.zhengjie.base.BaseDTO;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @website https://eladmin.vip
* @description /
* @author baolh
* @date 2026-03-10
**/
@Data
public class JobSecondDto extends BaseDTO implements Serializable {
    /** ID */
    private Long id;
    /** 岗位ID */
    private Long jobId;
    /** 岗位名称 */
    private String name;
    /** 岗位状态 */
    private Boolean enabled;
    /** 排序 */
    private Integer jobSort;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/JobSecondQueryCriteria.java
New file
@@ -0,0 +1,36 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.system.service.dto;
import lombok.Data;
import me.zhengjie.annotation.Query;
import java.util.List;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2026-03-10
**/
@Data
public class JobSecondQueryCriteria{
    @Query
    private Long jobId;
    @Query(type = Query.Type.IN, propName = "jobId")
    private List<Long> jobIds;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java
@@ -91,4 +91,6 @@
    private String weComId;
    private Boolean loginEnabled;
    private Long jobSecondId;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/JobSecondServiceImpl.java
New file
@@ -0,0 +1,111 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.system.service.impl;
import me.zhengjie.modules.system.domain.JobSecond;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.utils.FileUtil;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.system.repository.JobSecondRepository;
import me.zhengjie.modules.system.service.JobSecondService;
import me.zhengjie.modules.system.service.dto.JobSecondDto;
import me.zhengjie.modules.system.service.dto.JobSecondQueryCriteria;
import me.zhengjie.modules.system.service.mapstruct.JobSecondMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author baolh
* @date 2026-03-10
**/
@Service
@RequiredArgsConstructor
public class JobSecondServiceImpl implements JobSecondService {
    private final JobSecondRepository jobSecondRepository;
    private final JobSecondMapper jobSecondMapper;
    @Override
    public Map<String,Object> queryAll(JobSecondQueryCriteria criteria, Pageable pageable){
        Page<JobSecond> page = jobSecondRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
        return PageUtil.toPage(page.map(jobSecondMapper::toDto));
    }
    @Override
    public List<JobSecondDto> queryAll(JobSecondQueryCriteria criteria){
        return jobSecondMapper.toDto(jobSecondRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
    }
    @Override
    @Transactional
    public JobSecondDto findById(Long id) {
        JobSecond jobSecond = jobSecondRepository.findById(id).orElseGet(JobSecond::new);
        ValidationUtil.isNull(jobSecond.getId(),"JobSecond","id",id);
        return jobSecondMapper.toDto(jobSecond);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public JobSecondDto create(JobSecond resources) {
        return jobSecondMapper.toDto(jobSecondRepository.save(resources));
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(JobSecond resources) {
        JobSecond jobSecond = jobSecondRepository.findById(resources.getId()).orElseGet(JobSecond::new);
        ValidationUtil.isNull( jobSecond.getId(),"JobSecond","id",resources.getId());
        jobSecond.copy(resources);
        jobSecondRepository.save(jobSecond);
    }
    @Override
    public void deleteAll(Long[] ids) {
        for (Long id : ids) {
            jobSecondRepository.deleteById(id);
        }
    }
    @Override
    public void download(List<JobSecondDto> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (JobSecondDto jobSecond : all) {
            Map<String,Object> map = new LinkedHashMap<>();
            map.put("岗位ID", jobSecond.getJobId());
            map.put("岗位名称", jobSecond.getName());
            map.put("岗位状态", jobSecond.getEnabled());
            map.put("排序", jobSecond.getJobSort());
            map.put("创建者", jobSecond.getCreateBy());
            map.put("更新者", jobSecond.getUpdateBy());
            map.put("创建日期", jobSecond.getCreateTime());
            map.put("更新时间", jobSecond.getUpdateTime());
            list.add(map);
        }
        FileUtil.downloadExcel(list, response);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
@@ -590,6 +590,7 @@
        user.setRoles(resources.getRoles());
        user.setDept(resources.getDept());
        user.setJobs(resources.getJobs());
        user.setJobSecondId(resources.getJobSecondId());
        user.setCompanys(resources.getCompanys());
        user.setPhone(resources.getPhone());
        user.setNickName(resources.getNickName());
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/JobSecondMapper.java
New file
@@ -0,0 +1,32 @@
/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.system.service.mapstruct;
import me.zhengjie.base.BaseMapper;
import me.zhengjie.modules.system.domain.JobSecond;
import me.zhengjie.modules.system.service.dto.JobSecondDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://eladmin.vip
* @author baolh
* @date 2026-03-10
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface JobSecondMapper extends BaseMapper<JobSecondDto, JobSecond> {
}
eladmin-web-master/src/api/system/jobSecond.js
New file
@@ -0,0 +1,32 @@
import request from '@/utils/request'
import { initData } from '@/api/data'
export function add(data) {
  return request({
    url: 'api/jobSecond',
    method: 'post',
    data
  })
}
export function del(ids) {
  return request({
    url: 'api/jobSecond/',
    method: 'delete',
    data: ids
  })
}
export function edit(data) {
  return request({
    url: 'api/jobSecond',
    method: 'put',
    data
  })
}
export function getAll(params) {
  return initData('api/jobSecond/getAll', params)
}
export default { add, edit, del, getAll }
eladmin-web-master/src/views/system/job/index.vue
@@ -1,12 +1,15 @@
<template>
  <div class="app-container">
    <el-row :gutter="10">
      <el-col :xs="24" :sm="24" :md="10" :lg="11" :xl="11" style="margin-bottom: 10px">
        <el-card class="box-card">
    <!--工具栏-->
    <div class="head-container">
      <eHeader :dict="dict" :permission="permission" />
      <crudOperation :permission="permission" />
    </div>
    <!--表格渲染-->
    <el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
          <el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%;" @selection-change="crud.selectionChangeHandler" @current-change="handleCurrentChange">
      <el-table-column type="selection" width="55" />
      <el-table-column prop="name" label="名称" />
      <el-table-column prop="jobSort" label="排序">
@@ -45,6 +48,18 @@
    <pagination />
    <!--表单渲染-->
    <eForm :job-status="dict.job_status" />
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="24" :md="14" :lg="13" :xl="13">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>二级岗位</span>
          </div>
          <jobSecond ref="jobSecond" :permission="permission" />
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>
@@ -52,13 +67,14 @@
import crudJob from '@/api/system/job'
import eHeader from './module/header'
import eForm from './module/form'
import jobSecond from './jobSecond'
import CRUD, { presenter } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'
import udOperation from '@crud/UD.operation'
export default {
  name: 'Job',
  components: { eHeader, eForm, crudOperation, pagination, udOperation },
  components: { eHeader, eForm, crudOperation, pagination, udOperation, jobSecond },
  cruds() {
    return CRUD({
      title: '岗位',
@@ -99,6 +115,16 @@
      }).catch(() => {
        data.enabled = !data.enabled
      })
    },
    // 选中字典后,设置字典详情数据
    handleCurrentChange(val) {
      if (val) {
        this.$refs.jobSecond.query.jobId = val.id
        this.$refs.jobSecond.jobId = val.id
        this.$refs.jobSecond.jobName = val.name
        this.$refs.jobSecond.crud.toQuery()
      }
    }
  }
}
eladmin-web-master/src/views/system/job/jobSecond.vue
New file
@@ -0,0 +1,150 @@
<template>
  <div class="app-container">
    <div v-if="jobName === ''">
      <div class="my-code">点击岗位查看详情</div>
    </div>
    <!--工具栏-->
    <div v-else class="head-container">
      <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="岗位名称" prop="name">
            <el-input v-model="form.name" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="岗位状态" prop="enabled">
            <el-radio
              v-for="item in dict.job_status"
              :key="item.id"
              v-model="form.enabled"
              :label="item.value === 'true'"
            >
              {{ item.label }}
            </el-radio>
          </el-form-item>
          <el-form-item label="排序">
            <el-input v-model="form.jobSort" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column label="所属岗位">
          {{ jobName }}
        </el-table-column>
        <el-table-column prop="name" label="岗位名称" />
        <el-table-column prop="enabled" label="岗位状态" align="center">
          <template slot-scope="scope">
            <el-switch
              v-model="scope.row.enabled"
              active-color="#409EFF"
              inactive-color="#F56C6C"
              @change="changeEnabled(scope.row, scope.row.enabled)"
            />
          </template>
        </el-table-column>
        <el-table-column prop="jobSort" label="排序" />
        <el-table-column prop="createTime" label="创建日期" />
        <el-table-column v-if="checkPer(['admin','jobSecond:edit','jobSecond:del'])" label="操作" width="150px" align="center" fixed="right">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>
<script>
import crudJobSecond from '@/api/system/jobSecond'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
const defaultForm = { id: null, jobId: null, name: null, enabled: null, jobSort: null, createBy: null, updateBy: null, createTime: null, updateTime: null }
export default {
  name: 'JobSecond',
  components: { pagination, crudOperation, udOperation },
  mixins: [presenter(), header(), form(function() {
    return Object.assign(defaultForm, { jobId: this.jobId })
  }), crud()],
  cruds() {
    return CRUD({ title: '二级岗位', url: 'api/jobSecond', idField: 'id', query: { jobId: null }, sort: ['jobSort,asc', 'id,desc'], crudMethod: { ...crudJobSecond },
      optShow: {
        add: true,
        edit: true,
        del: true,
        reset: false,
        download: false
      },
      queryOnPresenterCreated: false
    })
  },
  // 数据字典
  dicts: ['job_status'],
  data() {
    return {
      jobId: null,
      jobName: '',
      permission: {
        add: ['admin', 'jobSecond:add'],
        edit: ['admin', 'jobSecond:edit'],
        del: ['admin', 'jobSecond:del']
      },
      rules: {
        name: [
          { required: true, message: '岗位名称不能为空', trigger: 'blur' }
        ],
        enabled: [
          { required: true, message: '岗位状态不能为空', trigger: 'blur' }
        ],
        jobSort: [
          { required: true, message: '排序不能为空', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    },
    // 改变状态
    changeEnabled(data, val) {
      this.$confirm('此操作将 "' + this.dict.label.job_status[val] + '" ' + data.name + '二级岗位, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        // eslint-disable-next-line no-undef
        crudJobSecond.edit(data).then(() => {
          // eslint-disable-next-line no-undef
          this.crud.notify(this.dict.label.job_status[val] + '成功', 'success')
        }).catch(err => {
          data.enabled = !data.enabled
          console.log(err.data.message)
        })
      }).catch(() => {
        data.enabled = !data.enabled
      })
    }
  }
}
</script>
<style scoped>
</style>
eladmin-web-master/src/views/system/user/index.vue
@@ -125,6 +125,16 @@
                placeholder="选择部门"
              />
            </el-form-item>
            <el-form-item label="排班" prop="sysRostering.id">
              <el-select v-model="form.sysRostering.id" clearable style="width: 184px" placeholder="请选择">
                <el-option
                  v-for="item in rosterings"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="岗位" prop="jobs">
              <el-select
                v-model="jobDatas"
@@ -144,13 +154,14 @@
                />
              </el-select>
            </el-form-item>
            <el-form-item label="排班" prop="sysRostering.id">
              <el-select v-model="form.sysRostering.id" clearable style="width: 184px" placeholder="请选择">
            <el-form-item label="二级岗位" prop="jobSecondId">
              <el-select v-model="form.jobSecondId" clearable style="width: 184px" placeholder="请选择">
                <el-option
                  v-for="item in rosterings"
                  :key="item.id"
                  v-for="item in jobSeconds"
                  :key="item.name"
                  :label="item.name"
                  :value="item.id"
                  :disabled="!item.enabled"
                />
              </el-select>
            </el-form-item>
@@ -299,6 +310,7 @@
import { getDepts, getDeptSuperior } from '@/api/system/dept'
import { getAll, getLevel } from '@/api/system/role'
import crudJob from '@/api/system/job'
import crudJobSecond from '@/api/system/jobSecond'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
@@ -316,7 +328,7 @@
let userRoles = []
let userJobs = []
let userCompanys = []
const defaultForm = { id: null, username: null, company: { id: null }, internshipTime: null, nickName: null, gender: '男', email: null, enabled: 'false', loginEnabled: 'false', roles: [], jobs: [], dept: { id: null }, phone: null, birthday: null, address: null, dingding: null, weComId: null, sysRostering: { id: null }, levelId: null, companys: [] }
const defaultForm = { id: null, username: null, company: { id: null }, internshipTime: null, nickName: null, gender: '男', email: null, enabled: 'false', loginEnabled: 'false', roles: [], jobs: [], dept: { id: null }, phone: null, birthday: null, address: null, dingding: null, weComId: null, sysRostering: { id: null }, levelId: null, companys: [], jobSecondId: null }
export default {
  name: 'User',
  components: { Treeselect, crudOperation, rrOperation, udOperation, pagination, DateRangePicker },
@@ -339,7 +351,7 @@
    }
    return {
      height: document.documentElement.clientHeight - 180 + 'px;',
      deptName: '', depts: [], deptDatas: [], jobs: [], level: 3, roles: [],
      deptName: '', depts: [], deptDatas: [], jobs: [], jobSeconds: [], level: 3, roles: [],
      jobDatas: [], roleDatas: [], companyDatas: [], // 多选时使用
      defaultProps: { children: 'children', label: 'name', isLeaf: 'leaf' },
      permission: {
@@ -458,6 +470,9 @@
        // 用户表单
        this.form.levelId = null
      }
      if (value.length > 0) {
        this.getJobSeconds()
      }
    },
    changeCompany(value) {
      userCompanys = []
@@ -533,6 +548,8 @@
        const com = { id: company.id }
        userCompanys.push(com)
      })
      // 获取可选二级岗位
      this.getJobSeconds()
    },
    // 提交前做的操作
    [CRUD.HOOK.afterValidateCU](crud) {
@@ -685,6 +702,13 @@
        this.jobs = res
      }).catch(() => { })
    },
    // 获取弹窗内二级岗位数据
    getJobSeconds() {
      const that = this
      crudJobSecond.getAll({ jobIds: that.jobDatas }).then(res => {
        that.jobSeconds = res
      }).catch(() => { })
    },
    // 获取权限级别
    getRoleLevel() {
      getLevel().then(res => {