|
|
@@ -14,66 +14,76 @@
|
|
|
<el-col :span="8">
|
|
|
<el-form-item
|
|
|
label="工厂编码:"
|
|
|
- prop="loginName"
|
|
|
+ prop="code"
|
|
|
style="margin-bottom: 22px"
|
|
|
>
|
|
|
<el-input
|
|
|
clearable
|
|
|
:maxlength="20"
|
|
|
- v-model="form.loginName"
|
|
|
- placeholder="请输入用户账号"
|
|
|
+ v-model="form.code"
|
|
|
+ placeholder="请输入"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
<el-form-item
|
|
|
label="工厂名称:"
|
|
|
- prop="loginName"
|
|
|
+ prop="name"
|
|
|
style="margin-bottom: 22px"
|
|
|
>
|
|
|
<el-input
|
|
|
clearable
|
|
|
:maxlength="20"
|
|
|
- v-model="form.loginName"
|
|
|
- placeholder="请输入用户账号"
|
|
|
+ v-model="form.name"
|
|
|
+ placeholder="请输入"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
|
<el-form-item
|
|
|
label="所属公司:"
|
|
|
- prop="loginName"
|
|
|
+ prop="groupId"
|
|
|
style="margin-bottom: 22px"
|
|
|
>
|
|
|
- <el-input
|
|
|
+ <ele-tree-select
|
|
|
clearable
|
|
|
- :maxlength="20"
|
|
|
- v-model="form.loginName"
|
|
|
- placeholder="请输入用户账号"
|
|
|
+ :data="options.groupId"
|
|
|
+ v-model="form.groupId"
|
|
|
+ valueKey="id"
|
|
|
+ labelKey="name"
|
|
|
+ placeholder="请选择"
|
|
|
+ default-expand-all
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="16" style="margin-bottom: 22px">
|
|
|
- <el-form-item label="地址:" prop="loginName">
|
|
|
+ <el-form-item label="地址:" prop="location_city">
|
|
|
<div class="location-warp">
|
|
|
<el-cascader
|
|
|
- v-model="form.value"
|
|
|
- :options="cityData"
|
|
|
+ clearable
|
|
|
+ style="width: 385px"
|
|
|
+ v-model="form.location"
|
|
|
+ :options="options.cityDataLabel"
|
|
|
></el-cascader>
|
|
|
<el-input
|
|
|
class="detail"
|
|
|
clearable
|
|
|
:maxlength="20"
|
|
|
- v-model="form.location"
|
|
|
+ v-model="form.locationDetail"
|
|
|
placeholder="请输入详细地址"
|
|
|
/>
|
|
|
</div>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="8" style="margin-bottom: 22px">
|
|
|
- <el-form-item label="状态:" prop="loginName">
|
|
|
+ <el-form-item label="状态:" prop="enabled">
|
|
|
<div class="location-warp">
|
|
|
- <el-select v-model="form.location" v placeholder="请选择">
|
|
|
+ <el-select
|
|
|
+ v-model="form.enabled"
|
|
|
+ v
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
<el-option
|
|
|
v-for="item in options.zt"
|
|
|
:key="item.value"
|
|
|
@@ -97,16 +107,21 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { regionData } from 'element-china-area-data';
|
|
|
+import { cityDataLabel } from 'ele-admin/packages/utils/regions';
|
|
|
+import { listOrganizations } from '@/api/system/organization';
|
|
|
+import { saveOrUpdate } from '@/api/factoryModel/factoryManagement';
|
|
|
export default {
|
|
|
data() {
|
|
|
const defaultForm = {
|
|
|
- id: null,
|
|
|
- loginName: '',
|
|
|
- roleId: [],
|
|
|
- loginPwd: '',
|
|
|
- enable: 1,
|
|
|
- location: ''
|
|
|
+ id: '',
|
|
|
+ code: '',
|
|
|
+ name: '',
|
|
|
+ groupId: '',
|
|
|
+ locationDetail: '',
|
|
|
+ location: [],
|
|
|
+ enabled: 1,
|
|
|
+ parentId: '',
|
|
|
+ type: 1 // FACTORY(1, "工厂"), WORKSHOP_PLAN(2, "厂房"), WORKSHOP(3, "车间"), LINE(4, "厂线");
|
|
|
};
|
|
|
return {
|
|
|
defaultForm,
|
|
|
@@ -114,24 +129,26 @@ export default {
|
|
|
form: { ...defaultForm },
|
|
|
// 表单验证规则
|
|
|
rules: {
|
|
|
- loginName: [
|
|
|
- { required: true, message: '请输入用户账号', trigger: 'blur' }
|
|
|
- ],
|
|
|
- roleId: [{ required: true, message: '请选择角色', trigger: 'blur' }],
|
|
|
- loginPwd: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- pattern: /^[\S]{5,18}$/,
|
|
|
- message: '密码必须为5-18位非空白字符',
|
|
|
- trigger: 'blur'
|
|
|
- }
|
|
|
- ]
|
|
|
+ code: [{ required: true, message: '请输入', trigger: 'blur' }],
|
|
|
+ name: [{ required: true, message: '请输入', trigger: 'blur' }],
|
|
|
+ groupId: [{ required: true, message: '请输入', trigger: 'blur' }]
|
|
|
},
|
|
|
visible: false,
|
|
|
type: '', // add/edit
|
|
|
loading: false,
|
|
|
options: {
|
|
|
- zt: []
|
|
|
+ zt: [
|
|
|
+ {
|
|
|
+ label: '生效',
|
|
|
+ value: 1
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '未生效',
|
|
|
+ value: 0
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ groupId: [],
|
|
|
+ cityDataLabel
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
@@ -147,22 +164,26 @@ export default {
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
- },
|
|
|
- cityData() {
|
|
|
- let result = regionData.find((n) => {
|
|
|
- return n.label == '湖南省';
|
|
|
- });
|
|
|
- if (result) {
|
|
|
- return result.children;
|
|
|
- } else {
|
|
|
- return [];
|
|
|
- }
|
|
|
}
|
|
|
},
|
|
|
+ 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;
|
|
|
+ }
|
|
|
},
|
|
|
/* 保存编辑 */
|
|
|
save() {
|
|
|
@@ -171,18 +192,25 @@ export default {
|
|
|
return false;
|
|
|
}
|
|
|
this.loading = true;
|
|
|
- if (!this.isUpdate) {
|
|
|
- delete this.form.id;
|
|
|
- }
|
|
|
+
|
|
|
const data = {
|
|
|
- ...this.form
|
|
|
+ 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()
|
|
|
};
|
|
|
- const saveOrUpdate = this.isUpdate ? putUsers : addUsers;
|
|
|
+ if (this.type == 'edit') {
|
|
|
+ data.id = this.form.id;
|
|
|
+ }
|
|
|
+ console.log(data);
|
|
|
saveOrUpdate(data)
|
|
|
.then((msg) => {
|
|
|
this.loading = false;
|
|
|
this.$message.success(msg);
|
|
|
- this.updateVisible(false);
|
|
|
+ this.handleClose();
|
|
|
this.$emit('done');
|
|
|
})
|
|
|
.catch((e) => {
|
|
|
@@ -198,6 +226,23 @@ export default {
|
|
|
handleClose() {
|
|
|
this.restForm();
|
|
|
this.visible = false;
|
|
|
+ },
|
|
|
+ // 获取公司数据
|
|
|
+ getGs() {
|
|
|
+ listOrganizations().then((list) => {
|
|
|
+ console.log(list);
|
|
|
+ this.options.groupId = this.$util.toTreeData({
|
|
|
+ data: list,
|
|
|
+ idField: 'id',
|
|
|
+ parentIdField: 'parentId'
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ setLocation() {
|
|
|
+ return {
|
|
|
+ location: this.form.location.join('/'),
|
|
|
+ locationDetail: this.form.locationDetail
|
|
|
+ };
|
|
|
}
|
|
|
}
|
|
|
};
|