| | |
| | | <!-- |
| | | 远程搜索 站点名称 输入框组件 |
| | | 根据输入站点的内容提供对应的输入建议 |
| | | |
| | | 1.向父组件传入站点名字 和 设备编码 |
| | | 2.可以选择建议或者任意输入 |
| | | 3.父组件可以设置输入框有无默认的站点名称 |
| | | 4.父组件可以设置是否需要根据选中的异常类型来给出站点建议 |
| | | ** |
| | | 在父组件中设置 |
| | | <InputSearch :isNeedDefaultSite="1" @submit-value="(n)=>form.name=n"> </InputSearch> |
| | |
| | | 父组件通过注入 :isNeedDefaultSite="1"或 :isNeedDefaultSite="0"来代表该输入框有无默认的站点名称 |
| | | 1代表需要默认值 ,0代表不需要默认值 |
| | | --> |
| | | |
| | | |
| | | |
| | | <script> |
| | | import exceptionApi from '@/api/exceptionApi.js'; |
| | | export default { |
| | |
| | | default:'-1' |
| | | } |
| | | }, |
| | | emits: ['submitValue', 'submitSiteNums'], |
| | | emits: ['submitValue', 'submitSiteNums','submitMncode'], |
| | | data() { |
| | | return { |
| | | // 用户选中的值 |
| | | state: '', |
| | | // 保存输入建议的站点名称 |
| | | siteNames: [] |
| | | siteNames: [], |
| | | // 保存输入建议的站点设备编号 |
| | | siteNamesAndMnCode:[] |
| | | } |
| | | }, |
| | | watch:{ |
| | |
| | | if(this.siteName != '-1' && this.siteName != ''){ |
| | | this.state = this.siteName |
| | | this.$emit('submitValue', this.state) |
| | | } |
| | | }, |
| | | state(){ |
| | | if(this.state != '' && this.state != null){ |
| | | // 查找对应的设备编号 |
| | | this.onSiteNameSelected(this.state) |
| | | } |
| | | } |
| | | }, |
| | |
| | | const sites = res.data.data |
| | | sites.filter((item) => { |
| | | this.siteNames.push(item['name']) |
| | | let temp = {} |
| | | temp.name = item.name |
| | | temp.mnCode = item.mnCode |
| | | this.siteNamesAndMnCode.push(temp) |
| | | }) |
| | | }) |
| | | |
| | |
| | | const sites = response.data.data |
| | | sites.filter((item) => { |
| | | this.siteNames.push(item['name']) |
| | | let temp = {} |
| | | temp.name = item.name |
| | | temp.mnCode = item.mnCode |
| | | this.siteNamesAndMnCode.push(temp) |
| | | }) |
| | | this.$emit('submitSiteNums', this.siteNames.length) |
| | | }) |
| | | } |
| | | }, |
| | | // 根据选中的站点查询设备编号 |
| | | onSiteNameSelected(siteName) { |
| | | const selectedSite = this.siteNamesAndMnCode.find((site) => site.name == siteName); |
| | | if (selectedSite) { |
| | | this.$emit('submitMncode',selectedSite.mnCode) |
| | | }else{ |
| | | this.$emit('submitMncode','') |
| | | } |
| | | }, |
| | | |
| | | // 点击选中建议项时触发 |
| | | handleSelect(item) { |
| | |
| | | clearSiteName() { |
| | | this.state = '' |
| | | this.$emit('submitValue', this.state) |
| | | } |
| | | }, |
| | | |
| | | } |
| | | } |
| | | </script> |
| | |
| | | popper-class="my-autocomplete" |
| | | placeholder="请输入" |
| | | @select="handleSelect" |
| | | @change="handleSelect" |
| | | clearable |
| | | @clear="clearSiteName" |
| | | > |