<template>
|
<div>
|
<el-input placeholder="请选择" :value="name" disabled>
|
<el-button slot="append" icon="el-icon-thumb" @click="handleBuilding"></el-button>
|
</el-input>
|
<el-dialog title="所属单位" :visible.sync="open" width="800px" :append-to-body="true" :destroy-on-close="true">
|
<organization-list v-if="open" ref="organizationRef" :schoolId="schoolId"></organization-list>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
<el-button @click="open = false">取 消</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import organizationList from "./organizationList";
|
import {getOrganization} from "@/api/oa/organization";
|
/**
|
* 高校组织机构
|
*/
|
export default {
|
name: "OrganizationInput",
|
components: {
|
organizationList
|
},
|
model: {
|
prop: 'value',
|
event: 'change'
|
},
|
props: {
|
value: {
|
type: [Number],
|
default: undefined
|
},
|
schoolId: {
|
type: Number,
|
default: undefined
|
}
|
},
|
data() {
|
return {
|
open: false,
|
name: ''
|
}
|
},
|
watch: {
|
'value': function (v) {
|
if (v) {
|
getOrganization(v).then(response => {
|
this.name = response.data.name;
|
});
|
}else {
|
this.name = '';
|
}
|
}
|
},
|
created() {
|
if (this.value) {
|
getOrganization(this.value).then(response => {
|
this.name = response.data.name;
|
});
|
}
|
},
|
methods: {
|
// 选择建筑单元
|
handleBuilding() {
|
this.open = true;
|
},
|
submitForm() {
|
const row = this.$refs.organizationRef.currentRow;
|
if (!row) {
|
this.$message.warning("请选择一条数据")
|
this.buttonLoading = false;
|
return;
|
}
|
this.name = row.name;
|
this.open = false;
|
this.$emit("change", row.id);
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
|
</style>
|