|
|
@@ -99,8 +99,7 @@
|
|
|
<el-col :xs="24" :sm="12">
|
|
|
<el-form-item label="所属工厂">
|
|
|
<el-select v-model="form.factoryId" filterable clearable class="full-width"
|
|
|
- :loading="factoryLoading" :disabled="!form.groupId"
|
|
|
- :placeholder="form.groupId ? '请选择所属工厂' : '请先选择所属机构'" @change="handleFactoryChange">
|
|
|
+ :loading="factoryLoading" placeholder="请选择所属工厂" @change="handleFactoryChange">
|
|
|
<el-option v-for="item in factoryOptions" :key="String(item.id)" :label="item.name"
|
|
|
:value="item.id" />
|
|
|
</el-select>
|
|
|
@@ -162,8 +161,6 @@
|
|
|
<el-col :xs="24" :sm="12"><el-form-item label="员工状态" prop="status"><el-select v-model="form.status"
|
|
|
class="full-width"><el-option v-for="item in statusOptions" :key="item.value" :label="item.label"
|
|
|
:value="item.value" /></el-select></el-form-item></el-col>
|
|
|
- <el-col :xs="24" :sm="12"><el-form-item label="关键工序"><el-input v-model.trim="form.keyProcess"
|
|
|
- maxlength="30" placeholder="标记特种工序岗位人员" /></el-form-item></el-col>
|
|
|
<el-col :xs="24" :sm="12"><el-form-item label="是否启用">
|
|
|
<div class="enable-field"><el-switch v-model="form.enabled" active-color="#18a875" /><span>{{
|
|
|
form.enabled ? '启用' :
|
|
|
@@ -662,7 +659,6 @@ const emptyForm = () => ({
|
|
|
positionSequenceId: '', positionSequence: '', positionSequenceName: '',
|
|
|
positionType: '', level: '', staffingLevel: '', dutyLevel: '', manager: '', managerId: null,
|
|
|
employmentType: '', employmentTypeName: '', status: '全职', hireDate: '', regularDate: '', account: '', enabled: true,
|
|
|
- keyProcess: '',
|
|
|
phone: '', email: '', wechat: '', workAddress: '', currentAddress: '', registeredAddress: '', emergencyContact: '', emergencyRelation: '', emergencyPhone: '', familyMembers: [],
|
|
|
education: '本科', school: '', major: '', graduationDate: '',
|
|
|
educations: [],
|
|
|
@@ -961,7 +957,7 @@ export default {
|
|
|
sectionProgress() {
|
|
|
const count = (keys) => `${keys.filter((key) => { const value = this.form[key]; return Array.isArray(value) ? value.length : Boolean(value); }).length}/${keys.length}`;
|
|
|
return {
|
|
|
- base: count(['name', 'employeeNo', 'groupId', 'factory', 'deptIds', 'status', 'hireDate', 'positionId', 'employmentType', 'staffingLevel', 'gender', 'birthDate', 'idCard', 'ethnic', 'politicalStatus', 'maritalStatus', 'nativePlace', 'education', 'school', 'phone', 'email', 'wechat', 'currentAddress', 'registeredAddress', 'workAddress', 'emergencyContact', 'emergencyPhone', 'keyProcess']),
|
|
|
+ base: count(['name', 'employeeNo', 'groupId', 'factory', 'deptIds', 'status', 'hireDate', 'positionId', 'employmentType', 'staffingLevel', 'gender', 'birthDate', 'idCard', 'ethnic', 'politicalStatus', 'maritalStatus', 'nativePlace', 'education', 'school', 'phone', 'email', 'wechat', 'currentAddress', 'registeredAddress', 'workAddress', 'emergencyContact', 'emergencyPhone']),
|
|
|
experience: count(['educations', 'previousJobs']),
|
|
|
contract: `${[this.form.contract.number || this.form.contract.name, this.form.contract.startDate, this.form.contract.endDate].filter(Boolean).length}/3`,
|
|
|
payroll: count(['bankAccounts', 'socialSecurityRecords']),
|
|
|
@@ -1135,9 +1131,10 @@ export default {
|
|
|
/* 新增员工默认带出所属机构(登录机构列表第一个) */
|
|
|
this.applyDefaultLegalEntity();
|
|
|
this.normalizeDeptAgainstOptions();
|
|
|
- this.loadFactories().then(() => this.syncFactoryDisplay());
|
|
|
this.loadManagerOptions({ keepSelection: true });
|
|
|
});
|
|
|
+ /* 所属工厂与机构、部门互不关联:并行加载,不等机构 */
|
|
|
+ this.loadFactories().then(() => this.syncFactoryDisplay());
|
|
|
this.syncAge();
|
|
|
if (!this.employee) this.generateEmployeeNo();
|
|
|
this.$nextTick(() => {
|
|
|
@@ -1731,21 +1728,18 @@ export default {
|
|
|
input.setAttribute('placeholder', want);
|
|
|
}
|
|
|
},
|
|
|
+ /* 所属机构切换:只重置依赖机构的部门 / 岗位 / 汇报对象级联。
|
|
|
+ 所属工厂与机构、部门互不关联(工厂列表是独立的平铺数据),这里保持已选工厂不动 */
|
|
|
handleLegalEntityChange(id) {
|
|
|
const selected = this.legalEntities.find((item) => String(item.id) === String(id));
|
|
|
this.form.legalEntity = selected?.name || '';
|
|
|
this.form.company = selected?.name || this.form.company;
|
|
|
- // 工厂与隶属部门都只挂所属机构:换机构时两者一起重置(彼此之间互不影响)
|
|
|
this.deptCascaderKey += 1;
|
|
|
- this.form.factoryId = null;
|
|
|
- this.form.factory = '';
|
|
|
- this.factoryOptions = [];
|
|
|
this.applyDeptIds([]);
|
|
|
this.form.managerId = null;
|
|
|
this.form.manager = '';
|
|
|
this.managerOptions = [];
|
|
|
this.resetPositionsByDepartment();
|
|
|
- this.loadFactories();
|
|
|
},
|
|
|
normalizeDeptAgainstOptions() {
|
|
|
const ids = this.normalizeDeptIds(
|
|
|
@@ -1819,87 +1813,27 @@ export default {
|
|
|
this.organizationTree = [];
|
|
|
}
|
|
|
},
|
|
|
- collectFactoryOrgs(groupId) {
|
|
|
- if (!groupId) return [];
|
|
|
- const tree = this.organizationTree.length ? this.organizationTree : this.organizations;
|
|
|
- const find = (nodes) => {
|
|
|
- for (const node of nodes || []) {
|
|
|
- if (!node) continue;
|
|
|
- if (String(node.id) === String(groupId)) return node;
|
|
|
- const matched = find(node.children || []);
|
|
|
- if (matched) return matched;
|
|
|
- }
|
|
|
- return null;
|
|
|
- };
|
|
|
- const list = [];
|
|
|
- const walk = (nodes) => {
|
|
|
- (nodes || []).forEach((node) => {
|
|
|
- if (!node) return;
|
|
|
- const type = String(node.type);
|
|
|
- if (type === '40' || type === 'factory') {
|
|
|
- list.push({
|
|
|
- id: String(node.id),
|
|
|
- name: node.name || '',
|
|
|
- code: node.groupCode || '',
|
|
|
- groupId: String(groupId),
|
|
|
- });
|
|
|
- }
|
|
|
- walk(node.children || []);
|
|
|
- });
|
|
|
- };
|
|
|
- walk(find(tree || [])?.children || []);
|
|
|
- return list.filter((item) => item.id && item.name);
|
|
|
- },
|
|
|
- factoryBelongsToOrg(item = {}, groupId) {
|
|
|
- if (!groupId) return false;
|
|
|
- const orgId = String(groupId);
|
|
|
- const ids = [
|
|
|
- item.groupId,
|
|
|
- item.organizationId,
|
|
|
- item.companyId,
|
|
|
- item.parentId,
|
|
|
- item.legalId,
|
|
|
- ]
|
|
|
- .filter((value) => value != null && value !== '')
|
|
|
- .map((value) => String(value));
|
|
|
- if (!ids.length) return true;
|
|
|
- return ids.includes(orgId);
|
|
|
- },
|
|
|
+ /**
|
|
|
+ * 所属工厂:直接取工厂列表接口 /main/factoryarea/page(type=1 工厂)。
|
|
|
+ * ★ 工厂与所属机构、隶属部门不层级关联:不按机构过滤、也不从组织树里捞,
|
|
|
+ * 换机构不影响工厂下拉;接口失败直接报错,不做兜底。
|
|
|
+ */
|
|
|
async loadFactories() {
|
|
|
- const groupId = this.form.groupId;
|
|
|
- if (!groupId) {
|
|
|
- this.factoryOptions = [];
|
|
|
- this.factoryLoading = false;
|
|
|
- return;
|
|
|
- }
|
|
|
this.factoryLoading = true;
|
|
|
try {
|
|
|
- const fromTree = this.collectFactoryOrgs(groupId);
|
|
|
- if (fromTree.length) {
|
|
|
- this.factoryOptions = fromTree;
|
|
|
- return;
|
|
|
- }
|
|
|
- const data = await getFactoryAreaPage({
|
|
|
- pageNum: 1,
|
|
|
- size: 999,
|
|
|
- type: 1,
|
|
|
- groupId,
|
|
|
- organizationId: groupId,
|
|
|
- });
|
|
|
- this.factoryOptions = (Array.isArray(data?.list) ? data.list : (Array.isArray(data) ? data : []))
|
|
|
+ const data = await getFactoryAreaPage();
|
|
|
+ const list = Array.isArray(data?.list) ? data.list : Array.isArray(data) ? data : [];
|
|
|
+ this.factoryOptions = list
|
|
|
.map((item) => ({
|
|
|
id: String(item.id),
|
|
|
name: item.name || item.factoryName || item.pathName || `工厂 ${item.id}`,
|
|
|
code: item.code || '',
|
|
|
enabled: item.enabled,
|
|
|
- groupId: item.groupId || item.organizationId || item.companyId || item.parentId || '',
|
|
|
}))
|
|
|
- .filter((item) => item.id && item.name && this.factoryBelongsToOrg(item, groupId));
|
|
|
+ .filter((item) => item.id && item.name);
|
|
|
} catch (error) {
|
|
|
- this.factoryOptions = this.collectFactoryOrgs(groupId);
|
|
|
- if (!this.factoryOptions.length) {
|
|
|
- this.$message.error(error.message || '工厂列表加载失败');
|
|
|
- }
|
|
|
+ this.factoryOptions = [];
|
|
|
+ this.$message.error(error.message || '工厂列表加载失败');
|
|
|
} finally {
|
|
|
this.factoryLoading = false;
|
|
|
}
|