|
|
@@ -1,17 +1,17 @@
|
|
|
<!-- 机构编辑弹窗 -->
|
|
|
<template>
|
|
|
<ele-modal
|
|
|
- width="680px"
|
|
|
+ width="880px"
|
|
|
:visible="visible"
|
|
|
:close-on-click-modal="true"
|
|
|
custom-class="ele-dialog-form"
|
|
|
:title="isUpdate ? '修改机构' : '添加机构'"
|
|
|
@update:visible="updateVisible"
|
|
|
>
|
|
|
- <el-form ref="form" :model="form" :rules="rules" label-width="82px">
|
|
|
+ <el-form ref="form" :model="form" :rules="rules" label-width="140px">
|
|
|
<el-row :gutter="15">
|
|
|
<el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
- <el-form-item label="上级机构:">
|
|
|
+ <el-form-item label="上级机构:">
|
|
|
<org-select
|
|
|
v-model="form.parentId"
|
|
|
:data="organizationList"
|
|
|
@@ -20,7 +20,7 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
- <el-form-item label="机构名称:" prop="name">
|
|
|
+ <el-form-item label="机构名称:" prop="name">
|
|
|
<el-input
|
|
|
clearable
|
|
|
:maxlength="20"
|
|
|
@@ -31,17 +31,22 @@
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item
|
|
|
- label="机构类型"
|
|
|
+ label="机构类型:"
|
|
|
prop="type"
|
|
|
style="margin-bottom: 22px"
|
|
|
>
|
|
|
- <DictSelection dictName="机构类型" clearable v-model="form.type" labelName='dictValue'>
|
|
|
+ <DictSelection
|
|
|
+ dictName="机构类型"
|
|
|
+ clearable
|
|
|
+ v-model="form.type"
|
|
|
+ labelName="dictValue"
|
|
|
+ >
|
|
|
</DictSelection>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item
|
|
|
- label="负责人"
|
|
|
+ label="负责人:"
|
|
|
prop="manager"
|
|
|
style="margin-bottom: 22px"
|
|
|
>
|
|
|
@@ -54,6 +59,107 @@
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</el-form>
|
|
|
+ <headerTitle
|
|
|
+ title="企业信息"
|
|
|
+ style="margin-top: 30px"
|
|
|
+ v-if="['10', '20'].includes(form.type)"
|
|
|
+ ></headerTitle>
|
|
|
+
|
|
|
+ <el-form
|
|
|
+ ref="enterpriseForm"
|
|
|
+ :model="enterprise"
|
|
|
+ :rules="enterpriseRules"
|
|
|
+ label-width="140px"
|
|
|
+ v-if="['10', '20'].includes(form.type)"
|
|
|
+ >
|
|
|
+ <el-row :gutter="15">
|
|
|
+ <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
+ <el-form-item label="企业名称:" prop="name">
|
|
|
+ <el-input
|
|
|
+ clearable
|
|
|
+ :maxlength="20"
|
|
|
+ v-model="enterprise.name"
|
|
|
+ placeholder="请输入企业名称"
|
|
|
+ :disabled="true"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
+ <el-form-item label="企业地址:" prop="address">
|
|
|
+ <el-input
|
|
|
+ clearable
|
|
|
+ :maxlength="20"
|
|
|
+ v-model="enterprise.address"
|
|
|
+ placeholder="请输入企业地址"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
+ <el-form-item label="企业电话:" prop="tel">
|
|
|
+ <el-input
|
|
|
+ clearable
|
|
|
+ :maxlength="20"
|
|
|
+ v-model="enterprise.tel"
|
|
|
+ placeholder="请输入企业电话"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
+ <el-form-item label="登记日期:" prop="registerDate">
|
|
|
+ <el-date-picker
|
|
|
+ style="width: 100%"
|
|
|
+ clearable
|
|
|
+ v-model="enterprise.registerDate"
|
|
|
+ type="date"
|
|
|
+ value-format="yyyy-MM-dd"
|
|
|
+ placeholder="请选择日期"
|
|
|
+ >
|
|
|
+ </el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
+ <el-form-item label="统一社会性代码:" prop="unifiedSocialCreditCode">
|
|
|
+ <el-input
|
|
|
+ clearable
|
|
|
+ :maxlength="20"
|
|
|
+ v-model="enterprise.unifiedSocialCreditCode"
|
|
|
+ placeholder="请输入统一社会性代码"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
+ <el-form-item label="经营范围:" prop="businessScope">
|
|
|
+ <el-input
|
|
|
+ clearable
|
|
|
+ :maxlength="20"
|
|
|
+ v-model="enterprise.businessScope"
|
|
|
+ placeholder="请输入经营范围"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
+ <el-form-item label="经营产品:" prop="mainProduct">
|
|
|
+ <el-input
|
|
|
+ clearable
|
|
|
+ :maxlength="20"
|
|
|
+ v-model="enterprise.mainProduct"
|
|
|
+ placeholder="请输入经营产品"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
+ <el-form-item prop="files" label="附件:">
|
|
|
+ <fileUpload
|
|
|
+ v-model="enterprise.businessLicenseFile"
|
|
|
+ module="main"
|
|
|
+ :showLib="false"
|
|
|
+ :limit="10"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
<template v-slot:footer>
|
|
|
<el-button @click="updateVisible(false)">取消</el-button>
|
|
|
<el-button type="primary" :loading="loading" @click="save">
|
|
|
@@ -71,14 +177,24 @@
|
|
|
import OrgSelect from './org-select.vue';
|
|
|
import OrgTypeSelect from './org-type-select.vue';
|
|
|
import staffSelection from './staffSelection.vue';
|
|
|
-
|
|
|
+ import fileUpload from '@/components/upload/fileUpload';
|
|
|
+ const defEnterprise = {
|
|
|
+ businessLicenseFile: [],
|
|
|
+ name: null,
|
|
|
+ address: null,
|
|
|
+ tel: '',
|
|
|
+ registerDate: '',
|
|
|
+ unifiedSocialCreditCode: '',
|
|
|
+ businessScope: '',
|
|
|
+ mainProduct: '',
|
|
|
+ remark: ''
|
|
|
+ };
|
|
|
import {
|
|
|
addOrganization,
|
|
|
- updateOrganization
|
|
|
+ updateOrganization,getById
|
|
|
} from '@/api/system/organization';
|
|
|
-
|
|
|
export default {
|
|
|
- components: { OrgSelect, OrgTypeSelect, staffSelection },
|
|
|
+ components: { OrgSelect, OrgTypeSelect, staffSelection, fileUpload },
|
|
|
props: {
|
|
|
// 弹窗是否打开
|
|
|
visible: Boolean,
|
|
|
@@ -102,12 +218,29 @@
|
|
|
responsibleName: '',
|
|
|
// 表单数据
|
|
|
form: { ...defaultForm },
|
|
|
+ enterprise: {...defEnterprise},
|
|
|
// 表单验证规则
|
|
|
rules: {
|
|
|
- name: [{ required: true, message: '请输入机构名称', trigger: 'blur' }],
|
|
|
- manager: [{ required: true, message: '请选择负责人', trigger: 'blur' }],
|
|
|
+ name: [
|
|
|
+ { required: true, message: '请输入机构名称', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ manager: [
|
|
|
+ { required: true, message: '请选择负责人', trigger: 'blur' }
|
|
|
+ ],
|
|
|
type: [{ required: true, message: '请选择机构类型', trigger: 'blur' }]
|
|
|
},
|
|
|
+ // 表单验证规则
|
|
|
+ enterpriseRules: {
|
|
|
+ name: [
|
|
|
+ { required: true, message: '请输入企业名称', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ address: [
|
|
|
+ { required: true, message: '请输入企业地址', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ unifiedSocialCreditCode: [
|
|
|
+ { required: true, message: '请输入统一社会性代码', trigger: 'blur' }
|
|
|
+ ]
|
|
|
+ },
|
|
|
// 提交状态
|
|
|
loading: false,
|
|
|
// 是否是修改
|
|
|
@@ -122,45 +255,67 @@
|
|
|
},
|
|
|
methods: {
|
|
|
/* 保存编辑 */
|
|
|
- save() {
|
|
|
- console.log(this.form);
|
|
|
- this.$refs.form.validate((valid) => {
|
|
|
- if (!valid) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- this.loading = true;
|
|
|
- const data = {
|
|
|
- ...this.form,
|
|
|
- parentId: this.form.parentId || 0
|
|
|
- };
|
|
|
- if (!this.isUpdate) {
|
|
|
- delete data.id;
|
|
|
- }
|
|
|
- const saveOrUpdate = this.isUpdate
|
|
|
- ? updateOrganization
|
|
|
- : addOrganization;
|
|
|
- saveOrUpdate(data)
|
|
|
- .then((msg) => {
|
|
|
- this.loading = false;
|
|
|
- this.$message.success(msg);
|
|
|
- this.updateVisible(false);
|
|
|
- this.$emit('done');
|
|
|
- })
|
|
|
- .catch((e) => {
|
|
|
- this.loading = false;
|
|
|
- // this.$message.error(e.message);
|
|
|
- });
|
|
|
+ async save() {
|
|
|
+ if (!(await this.formValidate())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ ['10', '20'].includes(this.form.type) &&
|
|
|
+ !(await this.enterpriseValidate())
|
|
|
+ ) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let form={
|
|
|
+ ...this.form,
|
|
|
+ enterprise:this.enterprise
|
|
|
+ }
|
|
|
+ this.loading = true;
|
|
|
+ const data = {
|
|
|
+ ...form,
|
|
|
+ parentId: this.form.parentId || 0
|
|
|
+ };
|
|
|
+ if (!this.isUpdate) {
|
|
|
+ delete data.id;
|
|
|
+ }
|
|
|
+ const saveOrUpdate = this.isUpdate
|
|
|
+ ? updateOrganization
|
|
|
+ : addOrganization;
|
|
|
+ saveOrUpdate(data)
|
|
|
+ .then((msg) => {
|
|
|
+ this.loading = false;
|
|
|
+ this.$message.success(msg);
|
|
|
+ this.updateVisible(false);
|
|
|
+ this.$emit('done');
|
|
|
+ })
|
|
|
+ .catch((e) => {
|
|
|
+ this.loading = false;
|
|
|
+ // this.$message.error(e.message);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ formValidate() {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ this.$refs.form.validate((valid) => {
|
|
|
+ resolve(valid);
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
+ enterpriseValidate() {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ this.$refs.enterpriseForm.validate((valid) => {
|
|
|
+ resolve(valid);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
//选择负责人
|
|
|
confirmStaffSelection(data) {
|
|
|
- this.form.manager=JSON.parse(JSON.stringify(data))
|
|
|
- this.responsibleName=data.map(item=>item.name).toString()
|
|
|
+ this.form.manager = JSON.parse(JSON.stringify(data));
|
|
|
+ this.responsibleName = data.map((item) => item.name).toString();
|
|
|
},
|
|
|
openStaffSelection() {
|
|
|
- console.log(this.form.manager)
|
|
|
+ console.log(this.form.manager);
|
|
|
this.$refs.staffSelection.open(
|
|
|
- JSON.parse(JSON.stringify(this.form.manager))||[]
|
|
|
+ JSON.parse(JSON.stringify(this.form.manager)) || []
|
|
|
);
|
|
|
},
|
|
|
/* 更新visible */
|
|
|
@@ -169,15 +324,29 @@
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
+ 'form.name'(n){
|
|
|
+ this.enterprise.name=n
|
|
|
+
|
|
|
+ },
|
|
|
visible(visible) {
|
|
|
if (visible) {
|
|
|
if (this.data) {
|
|
|
- this.$util.assignObject(this.form, {
|
|
|
- ...this.data,
|
|
|
- parentId: this.data.parentId == 0 ? '' : this.data.parentId ?? ''
|
|
|
+ getById(this.data.id).then(res=>{
|
|
|
+ this.$util.assignObject(this.form, {
|
|
|
+ ...res,
|
|
|
+ parentId: res.parentId == 0 ? '' : res.parentId ?? ''
|
|
|
});
|
|
|
- this.form.type=''+this.form.type //回显
|
|
|
- this.responsibleName=this.data.manager&&this.data.manager.map(item=>item.name).toString()
|
|
|
+ this.form.type = '' + this.form.type; //回显
|
|
|
+ this.responsibleName =
|
|
|
+ res.manager &&
|
|
|
+ res.manager.map((item) => item.name).toString();
|
|
|
+ this.enterprise=res.enterprise
|
|
|
+ })
|
|
|
+
|
|
|
+ // this.form.type = '' + this.form.type; //回显
|
|
|
+ // this.responsibleName =
|
|
|
+ // this.data.manager &&
|
|
|
+ // this.data.manager.map((item) => item.name).toString();
|
|
|
this.isUpdate = true;
|
|
|
} else {
|
|
|
this.form.parentId = this.parentId;
|
|
|
@@ -185,8 +354,10 @@
|
|
|
}
|
|
|
} else {
|
|
|
this.$refs.form.clearValidate();
|
|
|
+ this.$refs.enterpriseForm&&this.$refs.enterpriseForm.clearValidate();
|
|
|
this.form = { ...this.defaultForm };
|
|
|
- this.responsibleName=''
|
|
|
+ this.enterprise = { ...this.defEnterprise };
|
|
|
+ this.responsibleName = '';
|
|
|
}
|
|
|
}
|
|
|
}
|