| | |
| | | 1代表需要默认值 ,0代表不需要默认值 |
| | | --> |
| | | <script> |
| | | import exceptionApi from '@/api/exceptionApi.js'; |
| | | export default { |
| | | props:{ |
| | | // 0代表不需要默认值,1代表需要默认值 |
| | | isNeedDefaultSite:{ |
| | | type:String, |
| | | default:'0' |
| | | }, |
| | | // 0代表不需要,1代表根据时段和异常来给出输入建议 |
| | | isNeedRealTimeAdvice:{ |
| | | type:String, |
| | | default:'0' |
| | | }, |
| | | exceptionType:{ |
| | | type:Array, |
| | | default:()=>{ |
| | | return [] |
| | | } |
| | | }, |
| | | beginTime:{ |
| | | type:String, |
| | | default:'' |
| | | }, |
| | | endTime:{ |
| | | type:String, |
| | | default:'' |
| | | }, |
| | | siteName:{ |
| | | type:String, |
| | | default:'-1' |
| | | } |
| | | }, |
| | | emits:['submitValue','submitSiteNums'], |
| | | data() { |
| | | return { |
| | | // 用户选中的值 |
| | | state: '', |
| | | // 站点名称 |
| | | siteNames:[], |
| | | // 保存输入建议的站点名称 |
| | | siteNames: [] |
| | | } |
| | | }, |
| | | watch:{ |
| | | beginTime(val,oldVal){ |
| | | |
| | | if(this.isNeedRealTimeAdvice =='1' && oldVal != ''){ |
| | | exceptionApi.getExceptionName(this.exceptionType,this.beginTime,this.endTime).then( res=>{ |
| | | this.siteNames = [] |
| | | const sites = res.data.data |
| | | sites.filter((item) => { |
| | | this.siteNames.push(item['name']) |
| | | }) |
| | | }) |
| | | } |
| | | }, |
| | | exceptionType(){ |
| | | if(this.isNeedRealTimeAdvice =='1' ){ |
| | | exceptionApi.getExceptionName(this.exceptionType,this.beginTime,this.endTime).then( res=>{ |
| | | this.siteNames = [] |
| | | const sites = res.data.data |
| | | sites.filter((item) => { |
| | | this.siteNames.push(item['name']) |
| | | }) |
| | | }) |
| | | } |
| | | }, |
| | | siteName(){ |
| | | if(this.siteName != '-1' && this.siteName != ''){ |
| | | this.state = this.siteName |
| | | this.$emit('submitValue', this.state) |
| | | } |
| | | } |
| | | }, |
| | | mounted() { |
| | | // 加载所有的站点名称 |
| | | this.loadAll() |
| | |
| | | this.state = '' |
| | | this.$emit('submitValue',this.state) |
| | | } |
| | | |
| | | }, |
| | | methods: { |
| | | querySearch(queryString, cb) { |
| | |
| | | }, |
| | | // 初始化加载所有的站点名字 |
| | | loadAll() { |
| | | this.$http.get('/dust/sitename').then(response=>{ |
| | | if(this.isNeedRealTimeAdvice == '1'){ |
| | | exceptionApi.getExceptionName(this.exceptionType,this.beginTime,this.endTime).then( res=>{ |
| | | this.siteNames = [] |
| | | const sites = res.data.data |
| | | sites.filter((item) => { |
| | | this.siteNames.push(item['name']) |
| | | }) |
| | | }) |
| | | |
| | | }else if(this.isNeedRealTimeAdvice == '0'){ |
| | | this.$http.get('/dust/sitename').then((response) => { |
| | | const sites = response.data.data |
| | | sites.filter(item=>{ |
| | | sites.filter((item) => { |
| | | this.siteNames.push(item['name']) |
| | | }) |
| | | this.$emit('submitSiteNums',this.siteNames.length) |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | // 点击选中建议项时触发 |
| | | handleSelect(item) { |
| | | this.state = item |
| | |
| | | |
| | | .text { |
| | | font-weight: bold; |
| | | margin-top: 5px; |
| | | font-size: 16px; |
| | | font-size: 14px; |
| | | color: #333333; |
| | | } |
| | | .el-autocomplete { |
| | | margin-top: 5px; |
| | | width: 200px; |
| | | } |
| | | |
| | | </style> |