|
|
@@ -57,7 +57,7 @@
|
|
|
<el-col :span="8">
|
|
|
<el-form-item label="所属车间:" prop="extInfo.workshopId">
|
|
|
<el-select
|
|
|
- v-model="form.workshopId"
|
|
|
+ v-model="form.extInfo.workshopId"
|
|
|
placeholder="请选择"
|
|
|
style="width: 100%"
|
|
|
@change="change_workshop"
|
|
|
@@ -73,7 +73,7 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item label="所属产线:" prop="parentId">
|
|
|
+ <el-form-item label="所属产线:" prop="productionLineId">
|
|
|
<el-select
|
|
|
v-model="form.productionLineId"
|
|
|
placeholder="请选择"
|
|
|
@@ -81,7 +81,7 @@
|
|
|
@change="change_productionLineId"
|
|
|
>
|
|
|
<el-option
|
|
|
- v-for="item in options.productionLine"
|
|
|
+ v-for="item in options.productionLineId"
|
|
|
:key="item.id"
|
|
|
:label="item.name"
|
|
|
:value="item.id"
|
|
|
@@ -94,7 +94,7 @@
|
|
|
<el-form-item label="负责人部门:" prop="extInfo.principalDep">
|
|
|
<ele-tree-select
|
|
|
clearable
|
|
|
- :data="options.principalDep"
|
|
|
+ :data="options_groupId"
|
|
|
v-model="form.extInfo.principalDep"
|
|
|
valueKey="id"
|
|
|
labelKey="name"
|
|
|
@@ -105,15 +105,14 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item label="负责人:" prop="extInfo.principal">
|
|
|
+ <el-form-item label="负责人:" prop="leaderId">
|
|
|
<el-select
|
|
|
v-model="form.leaderId"
|
|
|
placeholder="请选择"
|
|
|
- @change="change_principal"
|
|
|
style="width: 100%"
|
|
|
>
|
|
|
<el-option
|
|
|
- v-for="item in options.principal"
|
|
|
+ v-for="item in options.leaderId"
|
|
|
:key="item.id"
|
|
|
:label="item.name"
|
|
|
:value="item.id"
|
|
|
@@ -135,7 +134,7 @@
|
|
|
/>
|
|
|
<el-select
|
|
|
class="s2"
|
|
|
- v-model="form.enabled"
|
|
|
+ v-model="form.extInfo.meterTimeUnit"
|
|
|
placeholder="请选择"
|
|
|
>
|
|
|
<el-option
|
|
|
@@ -200,7 +199,12 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { listWorkshopByParentId } from '@/api/factoryModel';
|
|
|
+import {
|
|
|
+ listWorkshopByParentId,
|
|
|
+ saveOrUpdate_gw,
|
|
|
+ listFactoryLineByParentId,
|
|
|
+ getById
|
|
|
+} from '@/api/factoryModel';
|
|
|
import { getUserPage } from '@/api/system/organization';
|
|
|
import equipmentTable from './equipmentTable.vue';
|
|
|
export default {
|
|
|
@@ -227,26 +231,29 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
- const defaultForm = {
|
|
|
- id: '',
|
|
|
- code: '',
|
|
|
- name: '',
|
|
|
- extInfo: {
|
|
|
- factoryId: '', // 工厂
|
|
|
- workshopId: '', // 车间
|
|
|
- principalDep: '', // 负责人部门
|
|
|
- meterTimeUnit: '时', // 节拍时间单位
|
|
|
- meterTime: '' // 节拍时间
|
|
|
- },
|
|
|
- leaderId: '', // 负责人
|
|
|
- enabled: 1,
|
|
|
- productionLineId: '',
|
|
|
- remark: ''
|
|
|
+ const defaultForm = function () {
|
|
|
+ return {
|
|
|
+ code: '',
|
|
|
+ enabled: 1,
|
|
|
+ extInfo: {
|
|
|
+ factoryId: '', // 工厂
|
|
|
+ workshopId: '', // 车间
|
|
|
+ principalDep: '', // 负责人部门
|
|
|
+ meterTimeUnit: '时', // 节拍时间单位
|
|
|
+ meterTime: '' // 节拍时间
|
|
|
+ },
|
|
|
+ id: '',
|
|
|
+ leaderId: '', // 负责人
|
|
|
+ name: '',
|
|
|
+ productionLineId: '',
|
|
|
+ remark: '',
|
|
|
+ workstationSubstanceList: []
|
|
|
+ };
|
|
|
};
|
|
|
return {
|
|
|
defaultForm,
|
|
|
// 表单数据
|
|
|
- form: { ...defaultForm },
|
|
|
+ form: defaultForm(),
|
|
|
// 表单验证规则
|
|
|
rules: {
|
|
|
code: [{ required: true, message: '请输入', trigger: 'blur' }],
|
|
|
@@ -254,23 +261,30 @@ export default {
|
|
|
'extInfo.factoryId': [
|
|
|
{ required: true, message: '请输入', trigger: 'change' }
|
|
|
],
|
|
|
- parentId: { required: true, message: '请输入', trigger: 'change' },
|
|
|
'extInfo.principalDep': [
|
|
|
{ required: true, message: '请输入', trigger: 'change' }
|
|
|
],
|
|
|
- 'extInfo.principal': [
|
|
|
- { required: true, message: '请输入', trigger: 'change' }
|
|
|
- ],
|
|
|
- 'extInfo.phone': [
|
|
|
- { min: 11, message: '手机号格式不正确', trigger: 'blur' }
|
|
|
- ]
|
|
|
+ 'extInfo.workshopId': {
|
|
|
+ required: true,
|
|
|
+ message: '请输入',
|
|
|
+ trigger: 'change'
|
|
|
+ },
|
|
|
+ productionLineId: {
|
|
|
+ required: true,
|
|
|
+ message: '请输入',
|
|
|
+ trigger: 'change'
|
|
|
+ },
|
|
|
+ leaderId: {
|
|
|
+ required: true,
|
|
|
+ message: '请输入',
|
|
|
+ trigger: 'change'
|
|
|
+ }
|
|
|
},
|
|
|
visible: false,
|
|
|
type: '', // add/edit
|
|
|
loading: false,
|
|
|
options: {
|
|
|
- principalDep: [],
|
|
|
- principal: [],
|
|
|
+ leaderId: [],
|
|
|
workshopId: [],
|
|
|
enabled: [
|
|
|
{
|
|
|
@@ -300,7 +314,7 @@ export default {
|
|
|
label: '日'
|
|
|
}
|
|
|
],
|
|
|
- productionLine: []
|
|
|
+ productionLineId: []
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
@@ -332,10 +346,14 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ this.getData(row.id);
|
|
|
// 请求下拉数据
|
|
|
if (this.form.extInfo.factoryId) {
|
|
|
this.getListWorkshopByParentId();
|
|
|
}
|
|
|
+ if (this.form.extInfo.workshopId) {
|
|
|
+ this.getlistFactoryLineByParentId();
|
|
|
+ }
|
|
|
if (this.form.extInfo.principalDep) {
|
|
|
this.getUserPage();
|
|
|
}
|
|
|
@@ -352,25 +370,35 @@ export default {
|
|
|
if (this.type == 'add') {
|
|
|
delete this.form.id;
|
|
|
}
|
|
|
- // saveOrUpdate(this.form)
|
|
|
- // .then((msg) => {
|
|
|
- // this.loading = false;
|
|
|
- // this.$message.success(msg);
|
|
|
- // this.handleClose();
|
|
|
- // this.$emit('done');
|
|
|
- // })
|
|
|
- // .catch((e) => {
|
|
|
- // this.loading = false;
|
|
|
- // this.$message.error(e.message);
|
|
|
- // });
|
|
|
+ this.form.workstationSubstanceList =
|
|
|
+ this.$refs.equipmentTable.datasource.map((n) => {
|
|
|
+ return {
|
|
|
+ type: 1,
|
|
|
+ substanceId: n.id
|
|
|
+ };
|
|
|
+ });
|
|
|
+ saveOrUpdate_gw(this.form)
|
|
|
+ .then((msg) => {
|
|
|
+ this.loading = false;
|
|
|
+ this.$message.success(msg);
|
|
|
+ this.handleClose();
|
|
|
+ this.$emit('done');
|
|
|
+ })
|
|
|
+ .catch((e) => {
|
|
|
+ this.loading = false;
|
|
|
+ this.$message.error(e.message);
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
restForm() {
|
|
|
- this.$refs.form.clearValidate();
|
|
|
- this.form = { ...this.defaultForm };
|
|
|
+ this.form = { ...this.defaultForm() };
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.form.clearValidate();
|
|
|
+ });
|
|
|
},
|
|
|
handleClose() {
|
|
|
this.restForm();
|
|
|
+ this.loading = false;
|
|
|
this.visible = false;
|
|
|
},
|
|
|
// 格式化公司数据
|
|
|
@@ -384,7 +412,15 @@ export default {
|
|
|
// 获取车间
|
|
|
getListWorkshopByParentId() {
|
|
|
listWorkshopByParentId(this.form.extInfo.factoryId).then((res) => {
|
|
|
- this.options.workshop = res;
|
|
|
+ this.options.workshopId = res;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 获取产线
|
|
|
+ getlistFactoryLineByParentId() {
|
|
|
+ console.log(this.form.extInfo.workshopId);
|
|
|
+ listFactoryLineByParentId(this.form.extInfo.workshopId).then((res) => {
|
|
|
+ console.log(res);
|
|
|
+ this.options.productionLineId = res;
|
|
|
});
|
|
|
},
|
|
|
// 获取人员
|
|
|
@@ -394,38 +430,46 @@ export default {
|
|
|
size: 999
|
|
|
};
|
|
|
getUserPage(par).then((res) => {
|
|
|
- this.options.principal = res.list;
|
|
|
+ this.options.leaderId = res.list;
|
|
|
});
|
|
|
},
|
|
|
// 选择工厂
|
|
|
change_factoryId() {
|
|
|
- this.form.parentId = '';
|
|
|
- this.form.groupId = '';
|
|
|
- this.options.workshop = [];
|
|
|
+ this.form.extInfo.workshopId = '';
|
|
|
+ this.form.leaderId = '';
|
|
|
+ this.options.workshopId = [];
|
|
|
+ this.options.leaderId = [];
|
|
|
this.getListWorkshopByParentId();
|
|
|
},
|
|
|
// 选择负责人部门
|
|
|
change_principalDep() {
|
|
|
- this.form.extInfo.principal = '';
|
|
|
- this.options.principal = [];
|
|
|
+ this.form.leaderId = '';
|
|
|
this.getUserPage();
|
|
|
},
|
|
|
// 选择车间
|
|
|
change_workshop() {
|
|
|
- let result = this.options.workshop.find(
|
|
|
- (n) => n.id == this.form.parentId
|
|
|
- );
|
|
|
- this.form.groupId = result.groupId;
|
|
|
- },
|
|
|
- // 选择负责人
|
|
|
- change_principal() {
|
|
|
- let result = this.options.principal.find(
|
|
|
- (n) => n.id == this.form.extInfo.principal
|
|
|
- );
|
|
|
- this.form.extInfo.phone = result.phone;
|
|
|
+ this.form.leaderId = '';
|
|
|
+ this.options.leaderId = [];
|
|
|
+ this.getlistFactoryLineByParentId();
|
|
|
},
|
|
|
// 选择产线
|
|
|
- change_productionLineId() {}
|
|
|
+ change_productionLineId() {},
|
|
|
+ // 请求详情
|
|
|
+ getData(id) {
|
|
|
+ getById(id).then((res) => {
|
|
|
+ if (
|
|
|
+ res.workstationSubstanceList &&
|
|
|
+ res.workstationSubstanceList.length > 0
|
|
|
+ ) {
|
|
|
+ let list = res.workstationSubstanceList.map((n) => {
|
|
|
+ return n.substance;
|
|
|
+ });
|
|
|
+ if (list.length > 0) {
|
|
|
+ this.$refs.equipmentTable.datasource = list;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
</script>
|