|
|
@@ -86,6 +86,7 @@
|
|
|
v-model="form.leaderId"
|
|
|
placeholder="请选择"
|
|
|
style="width: 100%"
|
|
|
+ filterable
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="item in options.leaderId"
|
|
|
@@ -138,229 +139,227 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-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';
|
|
|
-import AreaSelect from "@/views/enterpriseModel/regionalManage/components/area-cascader.vue";
|
|
|
-import {basicAreaPageAPI} from "@/api/regionalManage";
|
|
|
+ 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';
|
|
|
+ import AreaSelect from '@/views/enterpriseModel/regionalManage/components/area-cascader.vue';
|
|
|
+ import { basicAreaPageAPI } from '@/api/regionalManage';
|
|
|
|
|
|
-export default {
|
|
|
- components: {AreaSelect},
|
|
|
- props: {
|
|
|
- options_groupId: {
|
|
|
- type: Array,
|
|
|
- default() {
|
|
|
- return [];
|
|
|
+ export default {
|
|
|
+ components: { AreaSelect },
|
|
|
+ props: {
|
|
|
+ options_groupId: {
|
|
|
+ type: Array,
|
|
|
+ default() {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- },
|
|
|
- watch: {
|
|
|
- options_groupId(nval) {
|
|
|
- this.toTreeData(nval);
|
|
|
- }
|
|
|
- },
|
|
|
- data() {
|
|
|
- const defaultForm = function () {
|
|
|
- return {
|
|
|
- id: '',
|
|
|
- code: '',
|
|
|
- name: '',
|
|
|
- groupId: '',
|
|
|
- areaId: '',
|
|
|
- areaName: '',
|
|
|
- extInfo: {
|
|
|
- principalDep: '', // 负责人部门
|
|
|
- location: [],
|
|
|
- locationDetail: ''
|
|
|
- },
|
|
|
- areaIdList: [],
|
|
|
- enabled: 1,
|
|
|
- parentId: 0,
|
|
|
- leaderId: '',
|
|
|
- type: 1 // FACTORY(1, "工厂"), WORKSHOP_PLAN(2, "厂房"), WORKSHOP(3, "车间"), LINE(4, "厂线");
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ options_groupId(nval) {
|
|
|
+ this.toTreeData(nval);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ const defaultForm = function () {
|
|
|
+ return {
|
|
|
+ id: '',
|
|
|
+ code: '',
|
|
|
+ name: '',
|
|
|
+ groupId: '',
|
|
|
+ areaId: '',
|
|
|
+ areaName: '',
|
|
|
+ extInfo: {
|
|
|
+ principalDep: '', // 负责人部门
|
|
|
+ location: [],
|
|
|
+ locationDetail: ''
|
|
|
+ },
|
|
|
+ areaIdList: [],
|
|
|
+ enabled: 1,
|
|
|
+ parentId: 0,
|
|
|
+ leaderId: '',
|
|
|
+ type: 1 // FACTORY(1, "工厂"), WORKSHOP_PLAN(2, "厂房"), WORKSHOP(3, "车间"), LINE(4, "厂线");
|
|
|
+ };
|
|
|
};
|
|
|
- };
|
|
|
- return {
|
|
|
- defaultForm,
|
|
|
- // 表单数据
|
|
|
- form: {...defaultForm()},
|
|
|
- // 表单验证规则
|
|
|
- rules: {
|
|
|
- code: [{required: true, message: '请输入', trigger: 'blur'}],
|
|
|
- name: [{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,
|
|
|
- areaList: [],
|
|
|
- areaTreeList: [],
|
|
|
- type: '', // add/edit
|
|
|
- loading: false,
|
|
|
- options: {
|
|
|
- zt: [
|
|
|
- {
|
|
|
- label: '生效',
|
|
|
- value: 1
|
|
|
+ return {
|
|
|
+ defaultForm,
|
|
|
+ // 表单数据
|
|
|
+ form: { ...defaultForm() },
|
|
|
+ // 表单验证规则
|
|
|
+ rules: {
|
|
|
+ code: [{ required: true, message: '请输入', trigger: 'blur' }],
|
|
|
+ name: [{ required: true, message: '请输入', trigger: 'blur' }],
|
|
|
+ groupId: [{ required: true, message: '请输入', trigger: 'blur' }],
|
|
|
+ leaderId: {
|
|
|
+ required: true,
|
|
|
+ message: '请输入',
|
|
|
+ trigger: 'change'
|
|
|
},
|
|
|
- {
|
|
|
- label: '未生效',
|
|
|
- value: 0
|
|
|
- }
|
|
|
- ],
|
|
|
- groupId: [],
|
|
|
- cityDataLabel,
|
|
|
- leaderId: []
|
|
|
- }
|
|
|
- };
|
|
|
- },
|
|
|
- computed: {
|
|
|
- title() {
|
|
|
- switch (this.type) {
|
|
|
- case 'add':
|
|
|
- return '新增工厂';
|
|
|
- break;
|
|
|
- case 'edit':
|
|
|
- return '编辑工厂';
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- created() {
|
|
|
- this.getGs();
|
|
|
- this.getBasicAreaList();
|
|
|
- },
|
|
|
- methods: {
|
|
|
- open(type, row) {
|
|
|
- this.type = type;
|
|
|
- this.visible = true;
|
|
|
- if (type == 'edit') {
|
|
|
- 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];
|
|
|
+ 'extInfo.principalDep': [
|
|
|
+ { required: true, message: '请输入', trigger: 'change' }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ visible: false,
|
|
|
+ areaList: [],
|
|
|
+ areaTreeList: [],
|
|
|
+ type: '', // add/edit
|
|
|
+ loading: false,
|
|
|
+ options: {
|
|
|
+ zt: [
|
|
|
+ {
|
|
|
+ label: '生效',
|
|
|
+ value: 1
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '未生效',
|
|
|
+ value: 0
|
|
|
}
|
|
|
- }
|
|
|
+ ],
|
|
|
+ groupId: [],
|
|
|
+ cityDataLabel,
|
|
|
+ leaderId: []
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ title() {
|
|
|
+ switch (this.type) {
|
|
|
+ case 'add':
|
|
|
+ return '新增工厂';
|
|
|
+ break;
|
|
|
+ case 'edit':
|
|
|
+ return '编辑工厂';
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
-
|
|
|
- this.getUserPage();
|
|
|
}
|
|
|
},
|
|
|
- toTreeData(val) {
|
|
|
- this.options.principalDep = this.$util.toTreeData({
|
|
|
- data: val,
|
|
|
- idField: 'id',
|
|
|
- parentIdField: 'parentId'
|
|
|
- });
|
|
|
+ created() {
|
|
|
+ this.getGs();
|
|
|
+ this.getBasicAreaList();
|
|
|
},
|
|
|
- /* 保存编辑 */
|
|
|
- save() {
|
|
|
- this.$refs.form.validate((valid) => {
|
|
|
- if (!valid) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- this.loading = true;
|
|
|
+ methods: {
|
|
|
+ open(type, row) {
|
|
|
+ this.type = type;
|
|
|
+ this.visible = true;
|
|
|
+ if (type == 'edit') {
|
|
|
+ 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.type == 'add') {
|
|
|
- delete this.form.id;
|
|
|
+ this.getUserPage();
|
|
|
}
|
|
|
- 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() {
|
|
|
- this.form = {...this.defaultForm()};
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.form.clearValidate();
|
|
|
- });
|
|
|
- },
|
|
|
- handleClose() {
|
|
|
- this.restForm();
|
|
|
- this.visible = false;
|
|
|
- },
|
|
|
- /* 获取区域集合 */
|
|
|
- async getBasicAreaList() {
|
|
|
- this.areaList = await basicAreaPageAPI(
|
|
|
- {
|
|
|
+ },
|
|
|
+ toTreeData(val) {
|
|
|
+ this.options.principalDep = this.$util.toTreeData({
|
|
|
+ data: val,
|
|
|
+ idField: 'id',
|
|
|
+ parentIdField: 'parentId'
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /* 保存编辑 */
|
|
|
+ save() {
|
|
|
+ this.$refs.form.validate((valid) => {
|
|
|
+ if (!valid) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ this.loading = true;
|
|
|
+
|
|
|
+ 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);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ restForm() {
|
|
|
+ this.form = { ...this.defaultForm() };
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.form.clearValidate();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleClose() {
|
|
|
+ this.restForm();
|
|
|
+ this.visible = false;
|
|
|
+ },
|
|
|
+ /* 获取区域集合 */
|
|
|
+ async getBasicAreaList() {
|
|
|
+ this.areaList = await basicAreaPageAPI({
|
|
|
pageNum: 1,
|
|
|
size: 9999
|
|
|
- }
|
|
|
- )
|
|
|
- this.areaTreeList = this.$util.toTreeData({
|
|
|
- data: this.areaList,
|
|
|
- idField: 'id',
|
|
|
- parentIdField: 'parentId'
|
|
|
- });
|
|
|
-
|
|
|
- },
|
|
|
- getAreaInfo(nodeInfo) {
|
|
|
- this.form.areaName = nodeInfo[0]?.pathLabels.join('/') || ''
|
|
|
- this.form.areaId = this.form.areaId || ''
|
|
|
- },
|
|
|
- // 获取公司数据
|
|
|
- getGs() {
|
|
|
- listOrganizations().then((list) => {
|
|
|
- this.options.groupId = this.$util.toTreeData({
|
|
|
- data: list,
|
|
|
+ });
|
|
|
+ this.areaTreeList = this.$util.toTreeData({
|
|
|
+ data: this.areaList,
|
|
|
idField: 'id',
|
|
|
parentIdField: 'parentId'
|
|
|
});
|
|
|
- });
|
|
|
- },
|
|
|
- // 选择负责人部门
|
|
|
- change_principalDep() {
|
|
|
- this.form.leaderId = '';
|
|
|
- this.getUserPage();
|
|
|
- },
|
|
|
- // 获取人员
|
|
|
- getUserPage() {
|
|
|
- if (!this.form.extInfo.principalDep) return this.options.leaderId = []
|
|
|
- let par = {
|
|
|
- groupId: this.form.extInfo.principalDep,
|
|
|
- size: 999
|
|
|
- };
|
|
|
- getUserPage(par).then((res) => {
|
|
|
- this.options.leaderId = res.list;
|
|
|
- });
|
|
|
+ },
|
|
|
+ getAreaInfo(nodeInfo) {
|
|
|
+ this.form.areaName = nodeInfo[0]?.pathLabels.join('/') || '';
|
|
|
+ this.form.areaId = this.form.areaId || '';
|
|
|
+ },
|
|
|
+ // 获取公司数据
|
|
|
+ getGs() {
|
|
|
+ listOrganizations().then((list) => {
|
|
|
+ this.options.groupId = this.$util.toTreeData({
|
|
|
+ data: list,
|
|
|
+ idField: 'id',
|
|
|
+ parentIdField: 'parentId'
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 选择负责人部门
|
|
|
+ change_principalDep() {
|
|
|
+ this.form.leaderId = '';
|
|
|
+ this.getUserPage();
|
|
|
+ },
|
|
|
+ // 获取人员
|
|
|
+ getUserPage() {
|
|
|
+ if (!this.form.extInfo.principalDep)
|
|
|
+ return (this.options.leaderId = []);
|
|
|
+ let par = {
|
|
|
+ groupId: this.form.extInfo.principalDep,
|
|
|
+ size: 999
|
|
|
+ };
|
|
|
+ getUserPage(par).then((res) => {
|
|
|
+ this.options.leaderId = res.list;
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
-};
|
|
|
+ };
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
-.location-warp {
|
|
|
- display: flex;
|
|
|
+ .location-warp {
|
|
|
+ display: flex;
|
|
|
|
|
|
- .detail {
|
|
|
- margin-left: 10px;
|
|
|
+ .detail {
|
|
|
+ margin-left: 10px;
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
-:deep(
|
|
|
- .el-dialog:not(.ele-dialog-form)
|
|
|
- .el-dialog__body
|
|
|
- .el-form
|
|
|
- .el-form-item:last-child
|
|
|
- ) {
|
|
|
- margin-bottom: 22px;
|
|
|
-}
|
|
|
+ :deep(
|
|
|
+ .el-dialog:not(.ele-dialog-form)
|
|
|
+ .el-dialog__body
|
|
|
+ .el-form
|
|
|
+ .el-form-item:last-child
|
|
|
+ ) {
|
|
|
+ margin-bottom: 22px;
|
|
|
+ }
|
|
|
</style>
|