<template>
|
<div>
|
<el-input placeholder="请选择" :value="name" disabled>
|
<el-button slot="append" v-if="currentId" icon="el-icon-circle-close" @click="handleClear"></el-button>
|
<el-button slot="append" v-else icon="el-icon-thumb" @click="handleClick"></el-button>
|
</el-input>
|
<el-dialog title="隶属NVR" :visible.sync="open" width="800px" :append-to-body="true" :destroy-on-close="true">
|
<nvr-list v-if="open" ref="nvrRef" :schoolId="schoolId" @setCurrentRow="getCurrentRow"></nvr-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 nvrList from "./list";
|
import {getNvr} from "@/api/oa/nvr";
|
|
/**
|
* 高校NVR
|
*/
|
export default {
|
name: "manufacturerInput",
|
components: {
|
nvrList
|
},
|
model: {
|
prop: 'value',
|
event: 'change'
|
},
|
props: {
|
value: {
|
type: [Number],
|
default: undefined
|
},
|
schoolId: {
|
type: Number,
|
default: undefined
|
}
|
},
|
data() {
|
return {
|
open: false,
|
name: '',
|
currentId: ''
|
}
|
},
|
watch: {
|
'value': function (v) {
|
if (v) {
|
getNvr(v).then(response => {
|
this.name = response.data.deploymentName;
|
this.currentId = response.data.id
|
});
|
}else {
|
this.name = '';
|
}
|
}
|
},
|
created() {
|
if (this.value) {
|
getNvr(this.value).then(response => {
|
this.name = response.data.deploymentName;
|
this.currentId = response.data.id;
|
});
|
}
|
},
|
methods: {
|
handleClear () {
|
this.currentId = undefined;
|
this.name = undefined;
|
this.$emit("change", undefined);
|
this.$emit('nvrIdChange')
|
},
|
getCurrentRow (e) {
|
this.currentId = e.id
|
},
|
handleClick() {
|
this.open = true;
|
},
|
submitForm() {
|
const row = this.$refs.nvrRef.currentRow;
|
if (!row) {
|
this.$message.warning("请选择一条数据")
|
this.buttonLoading = false;
|
return;
|
}
|
this.name = row.deploymentName;
|
this.open = false;
|
this.$emit("change", row.id);
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
|
</style>
|