单位添加关联项目

This commit is contained in:
fan 2021-01-12 14:34:20 +08:00
parent affd81e756
commit 4b95be70dd
2 changed files with 42 additions and 12 deletions

View File

@ -12,6 +12,12 @@
import { addCompany, updateCompany } from '@/api/company';
export default {
name: 'Add',
props: {
projectListNew:{
type: Array,
required: true
}
},
data() {
return {
dialogVisible: false,
@ -19,7 +25,8 @@ export default {
address: '',
name: '',
phone: '',
id: ''
id: '',
projectCode: ''
},
update: false
};
@ -31,7 +38,8 @@ export default {
items: [
{ prop: 'name', label: '名称', type: 'text' },
{ prop: 'phone', label: '电话', type: 'text' },
{ prop: 'address', label: '地址', type: 'text' }
{ prop: 'address', label: '地址', type: 'text' },
{ prop: 'projectCode', label: '关联项目', type: 'select', options: this.projectListNew}
]
};
return form;
@ -47,12 +55,15 @@ export default {
],
address:[
{ required: true, message: '请输入公司地址', trigger: 'blur'}
],
projectCode: [
{ required: true, message: '请选择关联项目', trigger: 'change'}
]
};
return crules;
},
title() {
return this.update ? '添加单位' : '修改单位';
return this.update ? '修改单位' : '添加单位';
}
},
methods: {
@ -65,19 +76,22 @@ export default {
id: data.id,
name: data.name,
phone: data.phone,
address: data.address
};
} else {
this.formModel = {
address: '',
name: '',
phone: '',
id: ''
address: data.address,
projectCode: data.projectCode
};
}
},
handleClose() {
this.dialogVisible = false;
this.update = false;
this.formModel = {
address: '',
name: '',
phone: '',
id: '',
projectCode: ''
};
this.$refs.dataform.resetFields();
},
doSave() {
this.$refs.dataform.validateForm(() => {

View File

@ -1,7 +1,7 @@
<template>
<div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<edit-company ref="editCompany" @reloadTable="reloadTable" />
<edit-company ref="editCompany" :project-list-new="projectListNew" @reloadTable="reloadTable" />
<qr-code ref="qrCode" />
</div>
</template>
@ -10,6 +10,7 @@
import { getCompanyListPaging, deleteCompany } from '@/api/company';
import EditCompany from './add';
import QrCode from '@/components/QrCode';
import { ProjectList } from '@/scripts/ProjectConfig';
export default {
name: 'CompanyManage',
components: {
@ -28,6 +29,8 @@ export default {
queryObject: {
}
},
projectMap: {},
projectListNew: [],
queryList: {
query: getCompanyListPaging,
selectCheckShow: false,
@ -45,6 +48,13 @@ export default {
title: '单位地址',
prop: 'address'
},
{
title: '关联项目',
prop: 'projectCode',
type: 'tag',
columnValue: (row) => { return this.projectMap[row.projectCode]; },
tagType: (row) => { return 'success'; }
},
{
title: '单位管理人员',
prop: 'managerNames',
@ -81,6 +91,12 @@ export default {
currentModel: {}
};
},
created() {
ProjectList.forEach(elem => {
this.projectMap[elem.value.toUpperCase()] = elem.label;
this.projectListNew.push({value: elem.value.toUpperCase(), label: elem.label});
});
},
methods: {
handlerAddCompany() {
this.$refs.editCompany.doShow();