diff --git a/src/components/ImageUpload/index.vue b/src/components/ImageUpload/index.vue new file mode 100644 index 0000000..50322e6 --- /dev/null +++ b/src/components/ImageUpload/index.vue @@ -0,0 +1,147 @@ + + + diff --git a/src/components/index.js b/src/components/index.js index 28d6c51..792466f 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -26,6 +26,7 @@ import StandardFormRow from '@/components/StandardFormRow' import ArticleListContent from '@/components/ArticleListContent' import Dialog from '@/components/Dialog' +import ImageUpload from '@/components/ImageUpload' import SearchCom from '@/components/SearchCom' import orgTree from '@/components/OrgTree/Index' @@ -55,6 +56,7 @@ export { ArticleListContent, Dialog, + ImageUpload, SearchCom, orgTree } diff --git a/src/views/org/OrgForm.vue b/src/views/org/OrgForm.vue index 41293a1..eea5757 100644 --- a/src/views/org/OrgForm.vue +++ b/src/views/org/OrgForm.vue @@ -20,12 +20,12 @@ - + {{ id }} @@ -62,7 +62,7 @@ label="类型" > - 单位 + {{ orgType === 1 ? '单位' : '项目' }} 部门 @@ -107,7 +107,7 @@ sm: { span: 15 } }, orgTree: [], - modalTitle: '新增机构', + modalTitle: '新增', visible: false, confirmLoading: false, formLoading: true, @@ -117,20 +117,23 @@ key: 'id', value: 'id' }, - form: this.$form.createForm(this) + form: this.$form.createForm(this), + orgType: 1 } }, methods: { // 新增初始化方法 - add () { + add (orgType) { this.visible = true - this.modalTitle = '新增机构' + this.modalTitle = '新增' + this.orgType = orgType this.getOrgTree() }, // 编辑初始化方法 edit (record) { this.visible = true - this.modalTitle = '编辑机构' + this.modalTitle = '编辑' + this.orgType = record.orgType this.getOrgTree() setTimeout(() => { this.form.setFieldsValue( @@ -150,15 +153,22 @@ * 获取机构树,并加载于表单中 */ getOrgTree () { - orgList().then((res) => { + const params = { orgType: this.orgType } + orgList(params).then((res) => { this.formLoading = false if (!res.code === 200 || !res.data.length) { - this.orgTree = [] + this.orgTree = [{ + 'id': '0', + 'parentId': '0', + 'name': '顶级', + 'value': '0', + 'pid': '0' + }] return } const orgList = listToTree(res.data, [], rootParentId) this.orgTree = [{ - 'id': '-1', + 'id': '0', 'parentId': '0', 'name': '顶级', 'value': '0', @@ -174,6 +184,7 @@ validateFields((errors, values) => { if (!errors) { if (values.id) { + values.orgType = this.orgType orgEdit(values).then((res) => { if (res.code === 200) { this.$message.success('编辑成功') @@ -188,6 +199,7 @@ this.confirmLoading = false }) } else { + values.orgType = this.orgType orgAdd(values).then((res) => { if (res.code === 200) { this.$message.success('新增成功') diff --git a/src/views/org/OrgList.vue b/src/views/org/OrgList.vue index d76244f..fdfeaca 100644 --- a/src/views/org/OrgList.vue +++ b/src/views/org/OrgList.vue @@ -1,9 +1,9 @@ \ No newline at end of file + diff --git a/src/views/person/PersonForm.vue b/src/views/person/PersonForm.vue index 912209b..5582560 100644 --- a/src/views/person/PersonForm.vue +++ b/src/views/person/PersonForm.vue @@ -179,6 +179,29 @@ 上传身份证 + + + + + + + + + + + + + + + + + @@ -191,9 +214,11 @@ import { personAddOrUpdate, personGet } from '@/api/person/person' import { dictionaryDropDown } from '@/api/sys/dictionaryItem' import OrgTree from '../org/OrgTree' + import ImageUpload from '@/components/ImageUpload' export default { components: { - OrgTree + OrgTree, + ImageUpload }, data () { return { @@ -213,7 +238,9 @@ jobsData: [], workTypeData: [], degreeData: [], - typeData: [] + typeData: [], + fileList: [], + fileList2: [] } }, mounted () { @@ -262,7 +289,18 @@ }) this.form.getFieldDecorator('type', { valuePropName: 'checked', initialValue: typeIntArr }) - console.log(data) + if (data.idPhotoFace) { + this.fileList.push(data.idPhotoFace) + } + if (data.idPhotoBack) { + this.fileList2.push(data.idPhotoBack) + } + this.$nextTick(() => { + this.$refs.upload.flush() + }) + this.$nextTick(() => { + this.$refs.upload1.flush() + }) this.form.setFieldsValue( { id: data.id, @@ -317,18 +355,34 @@ validateFields((errors, values) => { if (!errors) { values.type = values.type.join(',') - console.log(values) - personAddOrUpdate(values).then((res) => { - this.confirmLoading = false - if (res.code === 200) { - this.$message.success('操作成功') - this.$emit('ok', values) - this.handleCancel() - } else { - this.$message.error('操作失败:' + res.msg) + + // 先上传身份证照片 + this.$refs.upload.submitUpload().then((url) => { + if (url.length > 0) { + values.idPhotoFace = url } - }).finally((res) => { - this.confirmLoading = false + this.$refs.upload1.submitUpload().then((url1) => { + if (url1.length > 0) values.idPhotoBack = url1 + + // 上传之后调用人员增改方法 + personAddOrUpdate(values).then((res) => { + this.confirmLoading = false + if (res.code === 200) { + this.$message.success('操作成功') + this.$emit('ok', values) + + this.handleCancel() + } else { + this.$message.error('操作失败:' + res.msg) + } + }).finally((res) => { + this.confirmLoading = false + }) + }, (err) => { + this.$message.error(err) + }) + }, (err) => { + this.$message.error(err) }) } else { this.confirmLoading = false @@ -349,7 +403,6 @@ if (parseInt(idCardNo.substr(16, 1)) % 2 === 1) { this.form.setFieldsValue({ sex: 1 }) } else { - console.log('sex 2') this.form.setFieldsValue({ sex: 2 }) } @@ -365,7 +418,6 @@ if (monthNow < monthBirth || (monthNow === monthBirth && dayNow < dayBirth)) { age-- } - console.log(age) // 得到年龄 this.form.setFieldsValue({ age }) }, @@ -373,7 +425,6 @@ this.$refs.orgModal.loadOrg() }, selectOrg (orgData) { - console.log(orgData) this.form.setFieldsValue({ orgId: orgData.id }) this.form.setFieldsValue({ orgName: orgData.name }) }, diff --git a/src/views/person/PersonList.vue b/src/views/person/PersonList.vue index 07c4479..d37038b 100644 --- a/src/views/person/PersonList.vue +++ b/src/views/person/PersonList.vue @@ -14,6 +14,10 @@
+ + + {{ orgType === 1 ? '切换到项目组' : '切换到人员管理' }} + @@ -175,27 +179,12 @@ key: 'id', value: 'id' }, - orgId: '' + orgId: '', + orgType: 1 } }, created () { - /** - * 获取到机构树,展开顶级下树节点,考虑到后期数据量变大,不建议全部展开 - */ - orgList().then(res => { - this.treeLoading = false - if (!res.code === 200 || !res.data.length) { - return - } - this.orgTree = listToTree(res.data, [], rootParentId) - this.orgId = this.orgTree[0].id - console.log(this.orgId) - for (var item of this.orgTree) { - if (item.pid === 0) { - this.defaultExpandedKeys.push(item.id) - } - } - }) + this.getOrgTree() if (this.hasPerm('person:edit') || this.hasPerm('person:resetPwd') || this.hasPerm('person:del')) { this.columns.push({ @@ -207,6 +196,31 @@ } }, methods: { + /** + * 获取到机构树,展开顶级下树节点,考虑到后期数据量变大,不建议全部展开 + */ + async getOrgTree () { + await orgList({ orgType: this.orgType }).then(res => { + this.treeLoading = false + if (!res.code === 200 || !res.data.length) { + return + } + this.defaultExpandedKeys = [] + this.orgTree = listToTree(res.data, [], rootParentId) + this.orgId = this.orgTree[0].id + for (var item of this.orgTree) { + if (item.pid === 0) { + this.defaultExpandedKeys.push(item.id) + } + } + }) + }, + async changeOrgType () { + this.orgType = this.orgType === 1 ? 2 : 1 + await this.getOrgTree() + // 此处使用async和await 由于需要等待orgTree的返回 再往下依据结果继续执行 + this.handleClick(this.orgId) + }, /** * 重置密码 */ @@ -326,9 +340,7 @@ * 点击左侧机构树查询列表 */ handleClick (e) { - this.queryParam = { - 'orgId': e.toString() - } + this.queryParam.orgId = e.toString() this.orgId = e.toString() this.$refs.table.refresh(true) }, diff --git a/src/views/person/PersonRegister.vue b/src/views/person/PersonRegister.vue index 33e33be..b254f2c 100644 --- a/src/views/person/PersonRegister.vue +++ b/src/views/person/PersonRegister.vue @@ -85,7 +85,6 @@ // 加载数据方法 必须为 Promise 对象 loadData: parameter => { return personRegisterPage(Object.assign(parameter, this.queryParam)).then((res) => { - console.log(res) this.invitationCode = res.invitationCode return res }) diff --git a/src/views/sys/dictionaryItem/DictionaryItemList.vue b/src/views/sys/dictionaryItem/DictionaryItemList.vue index d675a30..2cbf112 100644 --- a/src/views/sys/dictionaryItem/DictionaryItemList.vue +++ b/src/views/sys/dictionaryItem/DictionaryItemList.vue @@ -46,14 +46,13 @@