|
|
@@ -129,6 +129,24 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
+ <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
+ <el-form-item label="工商注册号:" prop="businessRegistrationNo">
|
|
|
+ <el-input
|
|
|
+ clearable
|
|
|
+ v-model="enterprise.businessRegistrationNo"
|
|
|
+ placeholder="请输入工商注册号"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
+ <el-form-item label="联系人:" prop="contact">
|
|
|
+ <el-input
|
|
|
+ clearable
|
|
|
+ v-model="enterprise.contact"
|
|
|
+ placeholder="请输入联系人"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
<el-col v-bind="styleResponsive ? { sm: 12 } : { span: 12 }">
|
|
|
<el-form-item label="登记日期:" prop="registerDate">
|
|
|
<el-date-picker
|
|
|
@@ -213,223 +231,243 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import OrgSelect from './org-select.vue';
|
|
|
-import OrgTypeSelect from './org-type-select.vue';
|
|
|
-import staffSelection from './staffSelection.vue';
|
|
|
-import fileUpload from '@/components/upload/fileUpload';
|
|
|
-import { copyObj } from '@/utils/util';
|
|
|
-import addUser from '@/views/system/user/components/add.vue';
|
|
|
-const defEnterprise = {
|
|
|
- businessLicenseFile: [],
|
|
|
- name: null,
|
|
|
- address: null,
|
|
|
- tel: '',
|
|
|
- registerDate: '',
|
|
|
- unifiedSocialCreditCode: '',
|
|
|
- businessScope: '',
|
|
|
- mainProduct: '',
|
|
|
- remark: '',
|
|
|
- fax: ''
|
|
|
-};
|
|
|
-import {
|
|
|
- addOrganization,
|
|
|
- updateOrganization,
|
|
|
- getById,
|
|
|
- getCode
|
|
|
-} from '@/api/system/organization';
|
|
|
-export default {
|
|
|
- components: { OrgSelect, OrgTypeSelect, staffSelection, fileUpload, addUser },
|
|
|
- props: {
|
|
|
- // 弹窗是否打开
|
|
|
- visible: Boolean,
|
|
|
- // 修改回显的数据
|
|
|
- data: Object,
|
|
|
- // 上级id
|
|
|
- parentId: [Number, String],
|
|
|
- // 机构数据
|
|
|
- organizationList: Array
|
|
|
- },
|
|
|
- data() {
|
|
|
- const defaultForm = {
|
|
|
- id: null,
|
|
|
- parentId: null,
|
|
|
- name: '',
|
|
|
- type: '',
|
|
|
- sort: null,
|
|
|
- manager: [],
|
|
|
- groupCode: '',
|
|
|
- managerFirst: []
|
|
|
-
|
|
|
- };
|
|
|
- return {
|
|
|
- defaultForm,
|
|
|
- responsibleName: '',
|
|
|
- managerFirst:{},
|
|
|
- // 表单数据
|
|
|
- form: { ...defaultForm },
|
|
|
- enterprise: { ...defEnterprise },
|
|
|
- // 表单验证规则
|
|
|
- rules: {
|
|
|
- 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,
|
|
|
- // 是否是修改
|
|
|
- isUpdate: false
|
|
|
- };
|
|
|
- },
|
|
|
- computed: {
|
|
|
- // 是否开启响应式布局
|
|
|
- styleResponsive() {
|
|
|
- return this.$store.state.theme.styleResponsive;
|
|
|
- }
|
|
|
- },
|
|
|
- methods: {
|
|
|
- /* 保存编辑 */
|
|
|
- async save() {
|
|
|
- if (!(await this.formValidate())) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (
|
|
|
- ['10', '20'].includes(this.form.type) &&
|
|
|
- !(await this.enterpriseValidate())
|
|
|
- ) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- let form = {
|
|
|
- ...this.form
|
|
|
+ import OrgSelect from './org-select.vue';
|
|
|
+ import OrgTypeSelect from './org-type-select.vue';
|
|
|
+ import staffSelection from './staffSelection.vue';
|
|
|
+ import fileUpload from '@/components/upload/fileUpload';
|
|
|
+ import { copyObj } from '@/utils/util';
|
|
|
+ import addUser from '@/views/system/user/components/add.vue';
|
|
|
+ const defEnterprise = {
|
|
|
+ businessLicenseFile: [],
|
|
|
+ name: null,
|
|
|
+ address: null,
|
|
|
+ tel: '',
|
|
|
+ registerDate: '',
|
|
|
+ unifiedSocialCreditCode: '',
|
|
|
+ businessScope: '',
|
|
|
+ mainProduct: '',
|
|
|
+ remark: '',
|
|
|
+ fax: '',
|
|
|
+ businessRegistrationNo:'',
|
|
|
+ contact:''
|
|
|
+ };
|
|
|
+ import {
|
|
|
+ addOrganization,
|
|
|
+ updateOrganization,
|
|
|
+ getById,
|
|
|
+ getCode
|
|
|
+ } from '@/api/system/organization';
|
|
|
+ export default {
|
|
|
+ components: {
|
|
|
+ OrgSelect,
|
|
|
+ OrgTypeSelect,
|
|
|
+ staffSelection,
|
|
|
+ fileUpload,
|
|
|
+ addUser
|
|
|
+ },
|
|
|
+ props: {
|
|
|
+ // 弹窗是否打开
|
|
|
+ visible: Boolean,
|
|
|
+ // 修改回显的数据
|
|
|
+ data: Object,
|
|
|
+ // 上级id
|
|
|
+ parentId: [Number, String],
|
|
|
+ // 机构数据
|
|
|
+ organizationList: Array
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ const defaultForm = {
|
|
|
+ id: null,
|
|
|
+ parentId: null,
|
|
|
+ name: '',
|
|
|
+ type: '',
|
|
|
+ sort: null,
|
|
|
+ manager: [],
|
|
|
+ groupCode: '',
|
|
|
+ managerFirst: []
|
|
|
};
|
|
|
- if (['10', '20'].includes(this.form.type)) {
|
|
|
- form['enterprise'] = this.enterprise;
|
|
|
- }
|
|
|
- if(this.managerFirst?.name){
|
|
|
- this.form.managerFirst[0]=this.managerFirst
|
|
|
- }
|
|
|
- this.loading = true;
|
|
|
- const data = {
|
|
|
- ...form,
|
|
|
- parentId: this.form.parentId || 0
|
|
|
+ return {
|
|
|
+ defaultForm,
|
|
|
+ responsibleName: '',
|
|
|
+ managerFirst: {},
|
|
|
+ // 表单数据
|
|
|
+ form: { ...defaultForm },
|
|
|
+ enterprise: { ...defEnterprise },
|
|
|
+ // 表单验证规则
|
|
|
+ rules: {
|
|
|
+ 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,
|
|
|
+ // 是否是修改
|
|
|
+ isUpdate: false
|
|
|
};
|
|
|
- if (!this.isUpdate) {
|
|
|
- delete data.id;
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ // 是否开启响应式布局
|
|
|
+ styleResponsive() {
|
|
|
+ return this.$store.state.theme.styleResponsive;
|
|
|
}
|
|
|
- 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);
|
|
|
+ methods: {
|
|
|
+ /* 保存编辑 */
|
|
|
+ async save() {
|
|
|
+ if (!(await this.formValidate())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ ['10', '20'].includes(this.form.type) &&
|
|
|
+ !(await this.enterpriseValidate())
|
|
|
+ ) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let form = {
|
|
|
+ ...this.form
|
|
|
+ };
|
|
|
+ if (['10', '20'].includes(this.form.type)) {
|
|
|
+ form['enterprise'] = this.enterprise;
|
|
|
+ }
|
|
|
+ if (this.managerFirst?.name) {
|
|
|
+ this.form.managerFirst[0] = this.managerFirst;
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ },
|
|
|
+ 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();
|
|
|
- },
|
|
|
- openStaffSelection() {
|
|
|
- console.log(this.form.manager);
|
|
|
- this.$refs.staffSelection.open(
|
|
|
- JSON.parse(JSON.stringify(this.form.manager)) || []
|
|
|
- );
|
|
|
- },
|
|
|
- addOpen() {
|
|
|
- this.$refs.addUserRef.open();
|
|
|
- },
|
|
|
- clearManagerFirst() {
|
|
|
- this.managerFirst = {};
|
|
|
- },
|
|
|
- userBk(data) {
|
|
|
- this.managerFirst = data;
|
|
|
- },
|
|
|
- /* 更新visible */
|
|
|
- updateVisible(value) {
|
|
|
- this.$emit('update:visible', value);
|
|
|
- }
|
|
|
- },
|
|
|
- watch: {
|
|
|
- form: {
|
|
|
- deep: true,
|
|
|
- handler(n) {
|
|
|
- this.enterprise.name = n.name;
|
|
|
+ //选择负责人
|
|
|
+ confirmStaffSelection(data) {
|
|
|
+ this.form.manager = JSON.parse(JSON.stringify(data));
|
|
|
+ this.responsibleName = data.map((item) => item.name).toString();
|
|
|
+ },
|
|
|
+ openStaffSelection() {
|
|
|
+ console.log(this.form.manager);
|
|
|
+ this.$refs.staffSelection.open(
|
|
|
+ JSON.parse(JSON.stringify(this.form.manager)) || []
|
|
|
+ );
|
|
|
+ },
|
|
|
+ addOpen() {
|
|
|
+ this.$refs.addUserRef.open();
|
|
|
+ },
|
|
|
+ clearManagerFirst() {
|
|
|
+ this.managerFirst = {};
|
|
|
+ },
|
|
|
+ userBk(data) {
|
|
|
+ this.managerFirst = data;
|
|
|
+ },
|
|
|
+ /* 更新visible */
|
|
|
+ updateVisible(value) {
|
|
|
+ this.$emit('update:visible', value);
|
|
|
}
|
|
|
},
|
|
|
- visible(visible) {
|
|
|
- if (visible) {
|
|
|
- if (this.data) {
|
|
|
- getById(this.data.id).then((res) => {
|
|
|
- for (const key in res.enterprise) {
|
|
|
- this.$set(this.enterprise, key, res.enterprise[key]);
|
|
|
- }
|
|
|
- for (const key in res) {
|
|
|
- if (key == 'parentId') {
|
|
|
- this.$set(this.form, key, res[key] == 0 ? '' : res[key] ?? '');
|
|
|
+ watch: {
|
|
|
+ form: {
|
|
|
+ deep: true,
|
|
|
+ handler(n) {
|
|
|
+ this.enterprise.name = n.name;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ visible(visible) {
|
|
|
+ if (visible) {
|
|
|
+ if (this.data) {
|
|
|
+ getById(this.data.id).then((res) => {
|
|
|
+ for (const key in res.enterprise) {
|
|
|
+ this.$set(this.enterprise, key, res.enterprise[key]);
|
|
|
}
|
|
|
- if (key != 'enterprise') {
|
|
|
- this.$set(this.form, key, res[key]);
|
|
|
+ for (const key in res) {
|
|
|
+ if (key == 'parentId') {
|
|
|
+ this.$set(
|
|
|
+ this.form,
|
|
|
+ key,
|
|
|
+ res[key] == 0 ? '' : res[key] ?? ''
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if (key != 'enterprise') {
|
|
|
+ this.$set(this.form, key, res[key]);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- this.form.type = '' + this.form.type; //回显
|
|
|
- if(this.form?.managerFirst.length){
|
|
|
- this.managerFirst=this.form.managerFirst[0]
|
|
|
- }
|
|
|
- this.responsibleName =
|
|
|
- res.manager && res.manager.map((item) => item.name).toString();
|
|
|
- });
|
|
|
+ this.form.type = '' + this.form.type; //回显
|
|
|
+ if (this.form?.managerFirst.length) {
|
|
|
+ this.managerFirst = this.form.managerFirst[0];
|
|
|
+ }
|
|
|
+ this.responsibleName =
|
|
|
+ res.manager && res.manager.map((item) => item.name).toString();
|
|
|
+ });
|
|
|
|
|
|
- // this.form.type = '' + this.form.type; //回显
|
|
|
- // this.responsibleName =
|
|
|
- // this.data.manager &&
|
|
|
- // this.data.manager.map((item) => item.name).toString();
|
|
|
- this.isUpdate = true;
|
|
|
+ // 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;
|
|
|
+ getCode().then((res) => {
|
|
|
+ this.form.groupCode = res;
|
|
|
+ });
|
|
|
+ this.isUpdate = false;
|
|
|
+ }
|
|
|
} else {
|
|
|
- this.form.parentId = this.parentId;
|
|
|
- getCode().then((res) => {
|
|
|
- this.form.groupCode = res;
|
|
|
- });
|
|
|
- this.isUpdate = false;
|
|
|
+ this.$refs.form.clearValidate();
|
|
|
+ this.$refs.enterpriseForm &&
|
|
|
+ this.$refs.enterpriseForm.clearValidate();
|
|
|
+ this.form = { ...this.defaultForm };
|
|
|
+ this.enterprise = { ...defEnterprise };
|
|
|
+ this.managerFirst = {};
|
|
|
+ this.responsibleName = '';
|
|
|
}
|
|
|
- } else {
|
|
|
- this.$refs.form.clearValidate();
|
|
|
- this.$refs.enterpriseForm && this.$refs.enterpriseForm.clearValidate();
|
|
|
- this.form = { ...this.defaultForm };
|
|
|
- this.enterprise = { ...defEnterprise };
|
|
|
- this.managerFirst={}
|
|
|
- this.responsibleName = '';
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-};
|
|
|
+ };
|
|
|
</script>
|