|
|
@@ -12,11 +12,7 @@
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
|
|
<el-row>
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item
|
|
|
- label="工厂编码:"
|
|
|
- prop="code"
|
|
|
- style="margin-bottom: 22px"
|
|
|
- >
|
|
|
+ <el-form-item label="工厂编码:" prop="code">
|
|
|
<el-input
|
|
|
clearable
|
|
|
:maxlength="20"
|
|
|
@@ -26,11 +22,7 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item
|
|
|
- label="工厂名称:"
|
|
|
- prop="name"
|
|
|
- style="margin-bottom: 22px"
|
|
|
- >
|
|
|
+ <el-form-item label="工厂名称:" prop="name">
|
|
|
<el-input
|
|
|
clearable
|
|
|
:maxlength="20"
|
|
|
@@ -40,11 +32,7 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item
|
|
|
- label="所属公司:"
|
|
|
- prop="groupId"
|
|
|
- style="margin-bottom: 22px"
|
|
|
- >
|
|
|
+ <el-form-item label="所属公司:" prop="groupId">
|
|
|
<ele-tree-select
|
|
|
clearable
|
|
|
:data="options.groupId"
|
|
|
@@ -56,26 +44,7 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="16" style="margin-bottom: 22px">
|
|
|
- <el-form-item label="地址:" prop="location_city">
|
|
|
- <div class="location-warp">
|
|
|
- <el-cascader
|
|
|
- clearable
|
|
|
- style="width: 385px"
|
|
|
- v-model="form.location"
|
|
|
- :options="options.cityDataLabel"
|
|
|
- ></el-cascader>
|
|
|
- <el-input
|
|
|
- class="detail"
|
|
|
- clearable
|
|
|
- :maxlength="20"
|
|
|
- v-model="form.locationDetail"
|
|
|
- placeholder="请输入详细地址"
|
|
|
- />
|
|
|
- </div>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="8" style="margin-bottom: 22px">
|
|
|
+ <el-col :span="8">
|
|
|
<el-form-item label="状态:" prop="enabled">
|
|
|
<div class="location-warp">
|
|
|
<el-select
|
|
|
@@ -95,6 +64,56 @@
|
|
|
</div>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="负责人部门:" prop="extInfo.principalDep">
|
|
|
+ <ele-tree-select
|
|
|
+ clearable
|
|
|
+ :data="options_groupId"
|
|
|
+ v-model="form.extInfo.principalDep"
|
|
|
+ valueKey="id"
|
|
|
+ labelKey="name"
|
|
|
+ placeholder="请选择"
|
|
|
+ @change="change_principalDep"
|
|
|
+ default-expand-all
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="负责人:" prop="leaderId">
|
|
|
+ <el-select
|
|
|
+ v-model="form.leaderId"
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in options.leaderId"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="16">
|
|
|
+ <el-form-item label="地址:" prop="location_city">
|
|
|
+ <div class="location-warp">
|
|
|
+ <el-cascader
|
|
|
+ clearable
|
|
|
+ style="width: 385px"
|
|
|
+ v-model="form.extInfo.location"
|
|
|
+ :options="options.cityDataLabel"
|
|
|
+ ></el-cascader>
|
|
|
+ <el-input
|
|
|
+ class="detail"
|
|
|
+ clearable
|
|
|
+ :maxlength="20"
|
|
|
+ v-model="form.extInfo.locationDetail"
|
|
|
+ placeholder="请输入详细地址"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
</el-row>
|
|
|
</el-form>
|
|
|
<template v-slot:footer>
|
|
|
@@ -110,28 +129,56 @@
|
|
|
import { cityDataLabel } from 'ele-admin/packages/utils/regions';
|
|
|
import { listOrganizations } from '@/api/system/organization';
|
|
|
import { saveOrUpdate } from '@/api/factoryModel';
|
|
|
+import { getUserPage } from '@/api/system/organization';
|
|
|
export default {
|
|
|
+ props: {
|
|
|
+ options_groupId: {
|
|
|
+ type: Array,
|
|
|
+ default() {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ options_groupId(nval) {
|
|
|
+ this.toTreeData(nval);
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
- const defaultForm = {
|
|
|
- id: '',
|
|
|
- code: '',
|
|
|
- name: '',
|
|
|
- groupId: '',
|
|
|
- locationDetail: '',
|
|
|
- location: [],
|
|
|
- enabled: 1,
|
|
|
- parentId: '',
|
|
|
- type: 1 // FACTORY(1, "工厂"), WORKSHOP_PLAN(2, "厂房"), WORKSHOP(3, "车间"), LINE(4, "厂线");
|
|
|
+ const defaultForm = function () {
|
|
|
+ return {
|
|
|
+ id: '',
|
|
|
+ code: '',
|
|
|
+ name: '',
|
|
|
+ groupId: '',
|
|
|
+ extInfo: {
|
|
|
+ principalDep: '', // 负责人部门
|
|
|
+ location: [],
|
|
|
+ locationDetail: ''
|
|
|
+ },
|
|
|
+ enabled: 1,
|
|
|
+ parentId: 0,
|
|
|
+ leaderId: '',
|
|
|
+ type: 1 // FACTORY(1, "工厂"), WORKSHOP_PLAN(2, "厂房"), WORKSHOP(3, "车间"), LINE(4, "厂线");
|
|
|
+ };
|
|
|
};
|
|
|
return {
|
|
|
defaultForm,
|
|
|
// 表单数据
|
|
|
- form: { ...defaultForm },
|
|
|
+ form: { ...defaultForm() },
|
|
|
// 表单验证规则
|
|
|
rules: {
|
|
|
code: [{ required: true, message: '请输入', trigger: 'blur' }],
|
|
|
name: [{ required: true, message: '请输入', trigger: 'blur' }],
|
|
|
- groupId: [{ required: true, message: '请输入', trigger: 'blur' }]
|
|
|
+ groupId: [{ required: true, message: '请输入', trigger: 'blur' }],
|
|
|
+ leaderId: {
|
|
|
+ required: true,
|
|
|
+ message: '请输入',
|
|
|
+ trigger: 'change'
|
|
|
+ },
|
|
|
+ 'extInfo.principalDep': [
|
|
|
+ { required: true, message: '请输入', trigger: 'change' }
|
|
|
+ ]
|
|
|
},
|
|
|
visible: false,
|
|
|
type: '', // add/edit
|
|
|
@@ -148,7 +195,8 @@ export default {
|
|
|
}
|
|
|
],
|
|
|
groupId: [],
|
|
|
- cityDataLabel
|
|
|
+ cityDataLabel,
|
|
|
+ leaderId: []
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
@@ -174,17 +222,24 @@ export default {
|
|
|
this.type = type;
|
|
|
this.visible = true;
|
|
|
if (type == 'edit') {
|
|
|
- this.form.id = row.id;
|
|
|
- this.form.code = row.code;
|
|
|
- this.form.name = row.name;
|
|
|
- this.form.groupId = row.groupId;
|
|
|
- this.form.enabled = row.enabled;
|
|
|
- this.form.parentId = row.parentId;
|
|
|
- this.form.type = row.type;
|
|
|
- this.form.location = row.extInfo.location.split('/');
|
|
|
- this.form.locationDetail = row.extInfo.locationDetail;
|
|
|
+ for (const key of Object.keys(this.form)) {
|
|
|
+ if (key !== 'extInfo') {
|
|
|
+ this.form[key] = row[key];
|
|
|
+ } else {
|
|
|
+ for (const el of Object.keys(this.form.extInfo)) {
|
|
|
+ this.form.extInfo[el] = row.extInfo[el];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
+ toTreeData(val) {
|
|
|
+ this.options.principalDep = this.$util.toTreeData({
|
|
|
+ data: val,
|
|
|
+ idField: 'id',
|
|
|
+ parentIdField: 'parentId'
|
|
|
+ });
|
|
|
+ },
|
|
|
/* 保存编辑 */
|
|
|
save() {
|
|
|
this.$refs.form.validate((valid) => {
|
|
|
@@ -193,20 +248,10 @@ export default {
|
|
|
}
|
|
|
this.loading = true;
|
|
|
|
|
|
- const data = {
|
|
|
- code: this.form.code,
|
|
|
- name: this.form.name,
|
|
|
- groupId: this.form.groupId,
|
|
|
- enabled: this.form.enabled,
|
|
|
- parentId: this.form.groupId,
|
|
|
- type: this.form.type,
|
|
|
- extInfo: this.setLocation()
|
|
|
- };
|
|
|
- if (this.type == 'edit') {
|
|
|
- data.id = this.form.id;
|
|
|
+ if (this.type == 'add') {
|
|
|
+ delete this.form.id;
|
|
|
}
|
|
|
- console.log(data);
|
|
|
- saveOrUpdate(data)
|
|
|
+ saveOrUpdate(this.form)
|
|
|
.then((msg) => {
|
|
|
this.loading = false;
|
|
|
this.$message.success(msg);
|
|
|
@@ -220,8 +265,10 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
restForm() {
|
|
|
- this.$refs.form.clearValidate();
|
|
|
- this.form = { ...this.defaultForm };
|
|
|
+ this.form = { ...this.defaultForm() };
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.form.clearValidate();
|
|
|
+ });
|
|
|
},
|
|
|
handleClose() {
|
|
|
this.restForm();
|
|
|
@@ -238,11 +285,20 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
- setLocation() {
|
|
|
- return {
|
|
|
- location: this.form.location.join('/'),
|
|
|
- locationDetail: this.form.locationDetail
|
|
|
+ // 选择负责人部门
|
|
|
+ change_principalDep() {
|
|
|
+ this.form.leaderId = '';
|
|
|
+ this.getUserPage();
|
|
|
+ },
|
|
|
+ // 获取人员
|
|
|
+ getUserPage() {
|
|
|
+ let par = {
|
|
|
+ groupId: this.form.extInfo.principalDep,
|
|
|
+ size: 999
|
|
|
};
|
|
|
+ getUserPage(par).then((res) => {
|
|
|
+ this.options.leaderId = res.list;
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
@@ -254,4 +310,12 @@ export default {
|
|
|
margin-left: 10px;
|
|
|
}
|
|
|
}
|
|
|
+:deep(
|
|
|
+ .el-dialog:not(.ele-dialog-form)
|
|
|
+ .el-dialog__body
|
|
|
+ .el-form
|
|
|
+ .el-form-item:last-child
|
|
|
+ ) {
|
|
|
+ margin-bottom: 22px;
|
|
|
+}
|
|
|
</style>
|