|  |  | 
 |  |  | <template> | 
 |  |  |   <div> | 
 |  |  |     <el-input placeholder="请选择适用地点" :value="buildingName" disabled> | 
 |  |  |     <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"> | 
 |  |  |       <building-form @choice="choice"></building-form> | 
 |  |  |       <buildList v-if="open" ref="buildRef" :schoolId="schoolId"></buildList> | 
 |  |  |       <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 buildingForm from './form' | 
 |  |  |  | 
 |  |  | import buildList from "./buildList"; | 
 |  |  | import { getBuilding } from "@/api/oa/building"; | 
 |  |  | /** | 
 |  |  |  * 高校建筑单元 | 
 |  |  |  */ | 
 |  |  | export default { | 
 |  |  |   name: "BuildInput", | 
 |  |  |   components: { | 
 |  |  |     buildingForm | 
 |  |  |     buildList | 
 |  |  |   }, | 
 |  |  |   model: { | 
 |  |  |     prop: 'value', | 
 |  |  | 
 |  |  |       type: [Number], | 
 |  |  |       default: undefined | 
 |  |  |     }, | 
 |  |  |     schoolId: { | 
 |  |  |       type: Number, | 
 |  |  |       default: undefined | 
 |  |  |     } | 
 |  |  |   }, | 
 |  |  |   data() { | 
 |  |  |     return { | 
 |  |  |       message: undefined, | 
 |  |  |       open: false, | 
 |  |  |       buildingName: '' | 
 |  |  |       name: '' | 
 |  |  |     } | 
 |  |  |   }, | 
 |  |  |   watch: { | 
 |  |  |     'value': function (v) { | 
 |  |  |       if (v) { | 
 |  |  |         getBuilding(v).then(response => { | 
 |  |  |           this.name = response.data.name; | 
 |  |  |         }); | 
 |  |  |       }else { | 
 |  |  |         this.name = ''; | 
 |  |  |       } | 
 |  |  |     } | 
 |  |  |   }, | 
 |  |  |   created() { | 
 |  |  |     if (this.value) { | 
 |  |  |       getBuilding(this.value).then(response => { | 
 |  |  |         this.name = response.data.name; | 
 |  |  |       }); | 
 |  |  |     } | 
 |  |  |   }, | 
 |  |  |   methods: { | 
 |  |  | 
 |  |  |     handleBuilding() { | 
 |  |  |       this.open = true; | 
 |  |  |     }, | 
 |  |  |     // 选中建筑单元 | 
 |  |  |     choice(r) { | 
 |  |  |       this.buildingName = r.name; | 
 |  |  |     submitForm() { | 
 |  |  |       if (!this.$refs.buildRef.currentRow) { | 
 |  |  |         this.$message.warning("请选择一条数据") | 
 |  |  |         this.buttonLoading = false; | 
 |  |  |         return; | 
 |  |  |       } | 
 |  |  |       const row = this.$refs.buildRef.currentRow; | 
 |  |  |       this.name = row.name; | 
 |  |  |       this.open = false; | 
 |  |  |       this.$emit("change", r.id); | 
 |  |  |       this.$emit("change", row.id); | 
 |  |  |     } | 
 |  |  |   } | 
 |  |  | } |