|
|
@@ -7,16 +7,12 @@
|
|
|
:before-close="handleClose"
|
|
|
:close-on-click-modal="false"
|
|
|
:close-on-press-escape="false"
|
|
|
- width="1000px"
|
|
|
+ width="1200px"
|
|
|
>
|
|
|
<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,61 +32,145 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
- <el-form-item
|
|
|
- label="所属公司:"
|
|
|
- prop="groupId"
|
|
|
- style="margin-bottom: 22px"
|
|
|
- >
|
|
|
+ <el-form-item label="所属工厂:" prop="extInfo.factoryId">
|
|
|
+ <el-select
|
|
|
+ v-model="form.extInfo.factoryId"
|
|
|
+ placeholder="请选择"
|
|
|
+ @change="change_factoryId"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in options_factory"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="所属车间:" prop="parentId">
|
|
|
+ <el-select
|
|
|
+ v-model="form.parentId"
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 100%"
|
|
|
+ @change="change_workshop"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in options.workshop"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="所属产线:" prop="parentId">
|
|
|
+ <el-select
|
|
|
+ v-model="form.parentId"
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 100%"
|
|
|
+ @change="change_workshop"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in options.workshop"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </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.groupId"
|
|
|
+ :data="options.principalDep"
|
|
|
+ v-model="form.extInfo.principalDep"
|
|
|
valueKey="id"
|
|
|
labelKey="name"
|
|
|
placeholder="请选择"
|
|
|
+ @change="change_principalDep"
|
|
|
default-expand-all
|
|
|
/>
|
|
|
</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-col :span="8">
|
|
|
+ <el-form-item label="负责人:" prop="extInfo.principal">
|
|
|
+ <el-select
|
|
|
+ v-model="form.extInfo.principal"
|
|
|
+ placeholder="请选择"
|
|
|
+ @change="change_principal"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in options.principal"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="节拍时间:" prop="extInfo.meterTime">
|
|
|
+ <div class="workMeter-warp">
|
|
|
<el-input
|
|
|
- class="detail"
|
|
|
+ class="s1"
|
|
|
clearable
|
|
|
:maxlength="20"
|
|
|
- v-model="form.locationDetail"
|
|
|
- placeholder="请输入详细地址"
|
|
|
+ v-model="form.extInfo.meterTime"
|
|
|
+ placeholder="请输入"
|
|
|
/>
|
|
|
- </div>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="8" style="margin-bottom: 22px">
|
|
|
- <el-form-item label="状态:" prop="enabled">
|
|
|
- <div class="location-warp">
|
|
|
- <el-select
|
|
|
- v-model="form.enabled"
|
|
|
- v
|
|
|
- placeholder="请选择"
|
|
|
- style="width: 100%"
|
|
|
- >
|
|
|
+ <el-select class="s2" v-model="form.enabled" placeholder="请选择">
|
|
|
<el-option
|
|
|
- v-for="item in options.zt"
|
|
|
+ v-for="item in options.meterTimeUnit"
|
|
|
:key="item.value"
|
|
|
:label="item.label"
|
|
|
:value="item.value"
|
|
|
>
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
+ <span class="s3">/次</span>
|
|
|
</div>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
+
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="状态:" prop="enabled">
|
|
|
+ <el-select
|
|
|
+ v-model="form.enabled"
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in options.enabled"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="备注:" prop="remark">
|
|
|
+ <el-input
|
|
|
+ clearable
|
|
|
+ :maxlength="100"
|
|
|
+ type="textarea"
|
|
|
+ v-model="form.remark"
|
|
|
+ placeholder="请输入"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
</el-row>
|
|
|
</el-form>
|
|
|
<template v-slot:footer>
|
|
|
@@ -107,21 +183,45 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { cityDataLabel } from 'ele-admin/packages/utils/regions';
|
|
|
-import { listOrganizations } from '@/api/system/organization';
|
|
|
-import { saveOrUpdate } from '@/api/factoryModel';
|
|
|
+import { listWorkshopByParentId } from '@/api/factoryModel';
|
|
|
+import { getUserPage } from '@/api/system/organization';
|
|
|
export default {
|
|
|
+ props: {
|
|
|
+ options_groupId: {
|
|
|
+ type: Array,
|
|
|
+ default() {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ options_factory: {
|
|
|
+ type: Array,
|
|
|
+ default() {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ options_groupId(nval) {
|
|
|
+ this.toTreeData(nval);
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
const defaultForm = {
|
|
|
id: '',
|
|
|
code: '',
|
|
|
name: '',
|
|
|
- groupId: '',
|
|
|
- locationDetail: '',
|
|
|
- location: [],
|
|
|
+ extInfo: {
|
|
|
+ factoryId: '',
|
|
|
+ principal: '', // 负责人
|
|
|
+ principalDep: '', // 负责人部门
|
|
|
+ locationDetail: '', // 详细地址
|
|
|
+ location: [], // 省市区
|
|
|
+ meterTimeUnit: '时', // 节拍时间单位
|
|
|
+ meterTime: '' // 节拍时间
|
|
|
+ },
|
|
|
enabled: 1,
|
|
|
- parentId: '',
|
|
|
- type: 1 // FACTORY(1, "工厂"), WORKSHOP_PLAN(2, "厂房"), WORKSHOP(3, "车间"), LINE(4, "厂线");
|
|
|
+ productionLineId: '',
|
|
|
+ remark: ''
|
|
|
};
|
|
|
return {
|
|
|
defaultForm,
|
|
|
@@ -131,13 +231,28 @@ export default {
|
|
|
rules: {
|
|
|
code: [{ required: true, message: '请输入', trigger: 'blur' }],
|
|
|
name: [{ required: true, message: '请输入', trigger: 'blur' }],
|
|
|
- groupId: [{ required: true, message: '请输入', trigger: 'blur' }]
|
|
|
+ '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' }
|
|
|
+ ]
|
|
|
},
|
|
|
visible: false,
|
|
|
type: '', // add/edit
|
|
|
loading: false,
|
|
|
options: {
|
|
|
- zt: [
|
|
|
+ principalDep: [],
|
|
|
+ principal: [],
|
|
|
+ workshop: [],
|
|
|
+ enabled: [
|
|
|
{
|
|
|
label: '生效',
|
|
|
value: 1
|
|
|
@@ -147,8 +262,24 @@ export default {
|
|
|
value: 0
|
|
|
}
|
|
|
],
|
|
|
- groupId: [],
|
|
|
- cityDataLabel
|
|
|
+ meterTimeUnit: [
|
|
|
+ {
|
|
|
+ value: '时',
|
|
|
+ label: '时'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: '分',
|
|
|
+ label: '分'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: '秒',
|
|
|
+ label: '秒'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: '日',
|
|
|
+ label: '日'
|
|
|
+ }
|
|
|
+ ]
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
@@ -156,33 +287,37 @@ export default {
|
|
|
title() {
|
|
|
switch (this.type) {
|
|
|
case 'add':
|
|
|
- return '新增工厂';
|
|
|
+ return '新增工位';
|
|
|
break;
|
|
|
case 'edit':
|
|
|
- return '编辑工厂';
|
|
|
+ return '编辑工位';
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- created() {
|
|
|
- this.getGs();
|
|
|
- },
|
|
|
methods: {
|
|
|
open(type, row) {
|
|
|
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];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 请求下拉数据
|
|
|
+ if (this.form.extInfo.factoryId) {
|
|
|
+ this.getListWorkshopByParentId();
|
|
|
+ }
|
|
|
+ if (this.form.extInfo.principalDep) {
|
|
|
+ this.getUserPage();
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
/* 保存编辑 */
|
|
|
@@ -193,30 +328,20 @@ 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)
|
|
|
- .then((msg) => {
|
|
|
- this.loading = false;
|
|
|
- this.$message.success(msg);
|
|
|
- this.handleClose();
|
|
|
- this.$emit('done');
|
|
|
- })
|
|
|
- .catch((e) => {
|
|
|
- this.loading = false;
|
|
|
- this.$message.error(e.message);
|
|
|
- });
|
|
|
+ // 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);
|
|
|
+ // });
|
|
|
});
|
|
|
},
|
|
|
restForm() {
|
|
|
@@ -227,22 +352,56 @@ export default {
|
|
|
this.restForm();
|
|
|
this.visible = false;
|
|
|
},
|
|
|
- // 获取公司数据
|
|
|
- getGs() {
|
|
|
- listOrganizations().then((list) => {
|
|
|
- console.log(list);
|
|
|
- this.options.groupId = this.$util.toTreeData({
|
|
|
- data: list,
|
|
|
- idField: 'id',
|
|
|
- parentIdField: 'parentId'
|
|
|
- });
|
|
|
+ // 格式化公司数据
|
|
|
+ toTreeData(val) {
|
|
|
+ this.options.principalDep = this.$util.toTreeData({
|
|
|
+ data: val,
|
|
|
+ idField: 'id',
|
|
|
+ parentIdField: 'parentId'
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 获取车间
|
|
|
+ getListWorkshopByParentId() {
|
|
|
+ listWorkshopByParentId(this.form.extInfo.factoryId).then((res) => {
|
|
|
+ this.options.workshop = res;
|
|
|
});
|
|
|
},
|
|
|
- setLocation() {
|
|
|
- return {
|
|
|
- location: this.form.location.join('/'),
|
|
|
- locationDetail: this.form.locationDetail
|
|
|
+ // 获取人员
|
|
|
+ getUserPage() {
|
|
|
+ let par = {
|
|
|
+ groupId: this.form.extInfo.principalDep,
|
|
|
+ size: 999
|
|
|
};
|
|
|
+ getUserPage(par).then((res) => {
|
|
|
+ this.options.principal = res.list;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 选择工厂
|
|
|
+ change_factoryId() {
|
|
|
+ this.form.parentId = '';
|
|
|
+ this.form.groupId = '';
|
|
|
+ this.options.workshop = [];
|
|
|
+ this.getListWorkshopByParentId();
|
|
|
+ },
|
|
|
+ // 选择负责人部门
|
|
|
+ change_principalDep() {
|
|
|
+ this.form.extInfo.principal = '';
|
|
|
+ this.options.principal = [];
|
|
|
+ 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;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
@@ -254,4 +413,24 @@ export default {
|
|
|
margin-left: 10px;
|
|
|
}
|
|
|
}
|
|
|
+.workMeter-warp {
|
|
|
+ .s1 {
|
|
|
+ width: 40%;
|
|
|
+ }
|
|
|
+ .s2 {
|
|
|
+ width: 40%;
|
|
|
+ margin-left: 10px;
|
|
|
+ }
|
|
|
+ .s3 {
|
|
|
+ margin-left: 10px;
|
|
|
+ }
|
|
|
+}
|
|
|
+:deep(
|
|
|
+ .el-dialog:not(.ele-dialog-form)
|
|
|
+ .el-dialog__body
|
|
|
+ .el-form
|
|
|
+ .el-form-item:last-child
|
|
|
+ ) {
|
|
|
+ margin-bottom: 22px;
|
|
|
+}
|
|
|
</style>
|