|
|
@@ -219,6 +219,94 @@
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</el-form>
|
|
|
+ <headerTitle
|
|
|
+ title="部门信息"
|
|
|
+ style="margin-top: 30px"
|
|
|
+ v-if="isDeptType"
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ size="small"
|
|
|
+ icon="el-icon-plus"
|
|
|
+ class="ele-btn-icon"
|
|
|
+ @click="addDeptPosition"
|
|
|
+ >
|
|
|
+ 新增
|
|
|
+ </el-button>
|
|
|
+ </headerTitle>
|
|
|
+ <el-table
|
|
|
+ v-if="isDeptType"
|
|
|
+ :data="departmentPositionList"
|
|
|
+ border
|
|
|
+ class="dept-position-table"
|
|
|
+ >
|
|
|
+ <el-table-column type="index" label="序号" width="80" align="center" />
|
|
|
+ <el-table-column label="岗位名称" min-width="160" align="center">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-select
|
|
|
+ v-if="!row.id"
|
|
|
+ v-model="row.positionId"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 100%"
|
|
|
+ @change="onDeptPositionNameChange(row)"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in positionList"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.positionName"
|
|
|
+ :value="item.id"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ <span v-else>{{ row.positionName }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="岗位层级" min-width="140" align="center">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-select
|
|
|
+ v-if="!row.id"
|
|
|
+ v-model="row.positionLevelId"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 100%"
|
|
|
+ :disabled="!row.positionId"
|
|
|
+ @change="onDeptPositionLevelChange(row)"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in row.levelOptions"
|
|
|
+ :key="item.positionLevelId"
|
|
|
+ :label="item.positionLevel"
|
|
|
+ :value="item.positionLevelId"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ <span v-else>{{ row.positionLevel }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="编制人数" min-width="120" align="center">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-input-number
|
|
|
+ v-model="row.establishmentCount"
|
|
|
+ :min="0"
|
|
|
+ :precision="0"
|
|
|
+ controls-position="right"
|
|
|
+ style="width: 100%"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" width="80" align="center">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-link
|
|
|
+ type="danger"
|
|
|
+ :underline="false"
|
|
|
+ @click="removeDeptPosition(row)"
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </el-link>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
<!-- <headerTitle
|
|
|
title="工厂信息"
|
|
|
style="margin-top: 30px"
|
|
|
@@ -372,7 +460,12 @@
|
|
|
addOrganization,
|
|
|
updateOrganization,
|
|
|
getById,
|
|
|
- getCode
|
|
|
+ getCode,
|
|
|
+ getDepartmentPositionPage,
|
|
|
+ saveDepartmentPositionBatch,
|
|
|
+ deleteDepartmentPosition,
|
|
|
+ getHrPositionPage,
|
|
|
+ getHrPositionById
|
|
|
} from '@/api/system/organization';
|
|
|
import { basicAreaPageAPI } from '@/api/regionalManage';
|
|
|
import { cityDataLabel } from 'ele-admin/packages/utils/regions';
|
|
|
@@ -449,13 +542,18 @@
|
|
|
// 提交状态
|
|
|
loading: false,
|
|
|
// 是否是修改
|
|
|
- isUpdate: false
|
|
|
+ isUpdate: false,
|
|
|
+ departmentPositionList: [],
|
|
|
+ positionList: []
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
// 是否开启响应式布局
|
|
|
styleResponsive() {
|
|
|
return this.$store.state.theme.styleResponsive;
|
|
|
+ },
|
|
|
+ isDeptType() {
|
|
|
+ return String(this.form.type) === '30';
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
@@ -491,18 +589,175 @@
|
|
|
const saveOrUpdate = this.isUpdate
|
|
|
? updateOrganization
|
|
|
: addOrganization;
|
|
|
- saveOrUpdate(data)
|
|
|
- .then((msg) => {
|
|
|
- this.loading = false;
|
|
|
- this.$message.success(msg);
|
|
|
- this.updateVisible(false);
|
|
|
- this.$emit('done');
|
|
|
- })
|
|
|
- .catch((e) => {
|
|
|
+ const submit = async () => {
|
|
|
+ if (this.isDeptType) {
|
|
|
+ const payload = this.buildDepartmentPositionPayload();
|
|
|
+ if (payload === false) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (payload.length) {
|
|
|
+ await saveDepartmentPositionBatch(payload);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const msg = await saveOrUpdate(data);
|
|
|
+ this.$message.success(msg);
|
|
|
+ this.updateVisible(false);
|
|
|
+ this.$emit('done');
|
|
|
+ };
|
|
|
+ submit()
|
|
|
+ .catch(() => {})
|
|
|
+ .finally(() => {
|
|
|
this.loading = false;
|
|
|
- // this.$message.error(e.message);
|
|
|
});
|
|
|
},
|
|
|
+ createDeptPositionRow() {
|
|
|
+ return {
|
|
|
+ id: null,
|
|
|
+ positionId: '',
|
|
|
+ positionName: '',
|
|
|
+ positionLevel: '',
|
|
|
+ positionLevelId: '',
|
|
|
+ establishmentCount: undefined,
|
|
|
+ levelOptions: []
|
|
|
+ };
|
|
|
+ },
|
|
|
+ buildDepartmentPositionPayload() {
|
|
|
+ if (!this.form.id) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ const rows = [];
|
|
|
+ for (const row of this.departmentPositionList) {
|
|
|
+ const isNew = !row.id;
|
|
|
+ const emptyNew =
|
|
|
+ isNew &&
|
|
|
+ !row.positionId &&
|
|
|
+ !row.positionLevelId &&
|
|
|
+ (row.establishmentCount === undefined ||
|
|
|
+ row.establishmentCount === null ||
|
|
|
+ row.establishmentCount === '');
|
|
|
+ if (emptyNew) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ !row.positionId ||
|
|
|
+ !row.positionName ||
|
|
|
+ !row.positionLevelId ||
|
|
|
+ row.establishmentCount === undefined ||
|
|
|
+ row.establishmentCount === null ||
|
|
|
+ row.establishmentCount === ''
|
|
|
+ ) {
|
|
|
+ this.$message.warning('请完善部门岗位信息');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ rows.push({
|
|
|
+ ...(row.id ? { id: row.id } : {}),
|
|
|
+ deptId: this.form.id,
|
|
|
+ positionId: row.positionId,
|
|
|
+ positionName: row.positionName,
|
|
|
+ positionLevelId: row.positionLevelId,
|
|
|
+ positionLevel: row.positionLevel,
|
|
|
+ establishmentCount: Number(row.establishmentCount)
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return rows;
|
|
|
+ },
|
|
|
+ isDeptPositionFilled(row) {
|
|
|
+ return (
|
|
|
+ !!row.positionId &&
|
|
|
+ !!row.positionLevelId &&
|
|
|
+ row.establishmentCount !== undefined &&
|
|
|
+ row.establishmentCount !== null &&
|
|
|
+ row.establishmentCount !== ''
|
|
|
+ );
|
|
|
+ },
|
|
|
+ addDeptPosition() {
|
|
|
+ if (
|
|
|
+ this.departmentPositionList.some(
|
|
|
+ (item) => !this.isDeptPositionFilled(item)
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ this.$message.warning('请先填写岗位名称、岗位层级和编制人数');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.ensurePositionOptions();
|
|
|
+ this.departmentPositionList.push(this.createDeptPositionRow());
|
|
|
+ },
|
|
|
+ async removeDeptPosition(row) {
|
|
|
+ const list = this.departmentPositionList;
|
|
|
+ const index = list.indexOf(row);
|
|
|
+ if (index < 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!row.id) {
|
|
|
+ list.splice(index, 1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ await this.$confirm('确定删除该岗位编制吗?', '提示', {
|
|
|
+ type: 'warning'
|
|
|
+ });
|
|
|
+ await deleteDepartmentPosition(row.id);
|
|
|
+ list.splice(index, 1);
|
|
|
+ this.$message.success('删除成功');
|
|
|
+ } catch (e) {}
|
|
|
+ },
|
|
|
+ async ensurePositionOptions() {
|
|
|
+ if (this.positionList.length) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const res = await getHrPositionPage({
|
|
|
+ pageNum: 1,
|
|
|
+ size: 9999,
|
|
|
+ status: 1
|
|
|
+ });
|
|
|
+ this.positionList = (res && res.list) || [];
|
|
|
+ },
|
|
|
+ async onDeptPositionNameChange(row) {
|
|
|
+ row.positionLevel = '';
|
|
|
+ row.positionLevelId = '';
|
|
|
+ row.levelOptions = [];
|
|
|
+ const position = this.positionList.find(
|
|
|
+ (item) => item.id === row.positionId
|
|
|
+ );
|
|
|
+ row.positionName = position ? position.positionName : '';
|
|
|
+ if (!row.positionId) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const detail = await getHrPositionById(row.positionId);
|
|
|
+ const configs = (detail && detail.levelConfigs) || [];
|
|
|
+ row.levelOptions = configs
|
|
|
+ .filter((item) => item.positionLevelId)
|
|
|
+ .map((item) => ({
|
|
|
+ positionLevelId: item.positionLevelId,
|
|
|
+ positionLevel: item.positionLevel
|
|
|
+ }));
|
|
|
+ },
|
|
|
+ onDeptPositionLevelChange(row) {
|
|
|
+ const level = (row.levelOptions || []).find(
|
|
|
+ (item) => item.positionLevelId === row.positionLevelId
|
|
|
+ );
|
|
|
+ row.positionLevel = level ? level.positionLevel : '';
|
|
|
+ },
|
|
|
+ async loadDepartmentPositions() {
|
|
|
+ if (!this.form.id || !this.isDeptType) {
|
|
|
+ this.departmentPositionList = [];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ await this.ensurePositionOptions();
|
|
|
+ const res = await getDepartmentPositionPage({
|
|
|
+ deptId: this.form.id,
|
|
|
+ pageNum: 1,
|
|
|
+ size: 9999
|
|
|
+ });
|
|
|
+ this.departmentPositionList = ((res && res.list) || []).map((item) => ({
|
|
|
+ ...item,
|
|
|
+ levelOptions: []
|
|
|
+ }));
|
|
|
+ },
|
|
|
+ resetDepartmentPosition() {
|
|
|
+ this.departmentPositionList = [];
|
|
|
+ this.positionList = [];
|
|
|
+ },
|
|
|
formValidate() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
this.$refs.form.validate((valid) => {
|
|
|
@@ -568,6 +823,11 @@
|
|
|
this.factoryForm.name = n.name;
|
|
|
}
|
|
|
},
|
|
|
+ 'form.type'(val) {
|
|
|
+ if (this.visible && String(val) === '30' && this.form.id) {
|
|
|
+ this.loadDepartmentPositions();
|
|
|
+ }
|
|
|
+ },
|
|
|
visible(visible) {
|
|
|
if (visible) {
|
|
|
if (this.data) {
|
|
|
@@ -594,6 +854,7 @@
|
|
|
}
|
|
|
this.responsibleName =
|
|
|
res.manager && res.manager.map((item) => item.name).toString();
|
|
|
+ this.loadDepartmentPositions();
|
|
|
});
|
|
|
|
|
|
// this.form.type = '' + this.form.type; //回显
|
|
|
@@ -616,8 +877,16 @@
|
|
|
this.enterprise = { ...defEnterprise };
|
|
|
this.managerFirst = {};
|
|
|
this.responsibleName = '';
|
|
|
+ this.resetDepartmentPosition();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+ .dept-position-table {
|
|
|
+ width: 100%;
|
|
|
+ margin-bottom: 10px;
|
|
|
+ }
|
|
|
+</style>
|