Files
hht-shangdianke-uni/pages/manage/fixed-point-task.vue

147 lines
3.7 KiB
Vue
Raw Permalink Normal View History

<template>
<view class="zd_container">
<nav-bar :title="title"></nav-bar>
<view class="zd_content">
<view class="zd_wrapper">
<view class="zd-row border-bottom">
<view class="zd-col-5">
<span class="filter_label">起点区域</span>
</view>
<view class="zd-col-19 filter_select">
<zxz-uni-data-select v-model="index1" filterable :localdata="options1" @change="selectChange1"></zxz-uni-data-select>
</view>
</view>
<view class="zd-row border-bottom">
<view class="zd-col-5">
<span class="filter_label">起点点位</span>
</view>
<view class="zd-col-19 filter_select">
<zxz-uni-data-select v-model="index2" filterable :localdata="options2"></zxz-uni-data-select>
</view>
</view>
<view class="zd-row border-bottom">
<view class="zd-col-5">
<span class="filter_label">终点区域</span>
</view>
<view class="zd-col-19 filter_select">
<zxz-uni-data-select v-model="index3" filterable :localdata="options3" @change="selectChange3"></zxz-uni-data-select>
</view>
</view>
<view class="zd-row">
<view class="zd-col-5">
<span class="filter_label">终点点位</span>
</view>
<view class="zd-col-19 filter_select">
<zxz-uni-data-select v-model="index4" filterable :localdata="options4"></zxz-uni-data-select>
</view>
</view>
</view>
</view>
<view class="zd-row submit-bar">
<button class="zd-col-11 button-default" @tap="clearUp">清空</button>
<button class="zd-col-11 button-primary" :class="{'button-info': !index2 || !index4}" :disabled="disabled" @tap="_taskConfirm">确认</button>
</view>
</view>
</template>
<script>
import NavBar from '@/components/NavBar.vue'
import SearchBox from '@/components/SearchBox.vue'
import {queryDevice, taskConfirm} from '@/utils/getData2.js'
export default {
components: {
NavBar,
SearchBox
},
data() {
return {
title: '',
options1: [],
index1: '',
options2: [],
index2: '',
options3: [],
index3: '',
options4: [],
index4: '',
disabled: false
};
},
onLoad (options) {
this.title = options.title
},
created () {
this._queryDevice()
},
methods: {
/** 点位下拉框 */
async _queryDevice () {
let res = await queryDevice()
res.map(el => {
this.$set(el, 'value', el.region_code)
this.$set(el, 'text', el.region_name)
})
this.options1 = [...res]
this.options3 = [...res]
},
selectChange1 (e) {
this.options2 = []
this.options1.map(el => {
if (el.value === e) {
this.options2 = [...el.deviceArr]
}
})
if (this.options2.length > 0) {
this.options2.map(ele => {
this.$set(ele, 'value', ele.point_code)
this.$set(ele, 'text', ele.point_name)
})
}
},
selectChange3 (e) {
this.options4 = []
this.options3.map(el => {
if (el.value === e) {
this.options4 = [...el.deviceArr]
}
})
if (this.options4.length > 0) {
this.options4.map(ele => {
this.$set(ele, 'value', ele.point_code)
this.$set(ele, 'text', ele.point_name)
})
}
},
async _taskConfirm () {
this.disabled = true
if (!this.index2 || this.index4 === '') {
this.disabled = false
return
}
try {
let res = await taskConfirm(this.index2, this.index4)
this.clearUp()
uni.showToast({
title: res.message,
icon: 'none'
})
} catch (e) {
this.disabled = false
}
},
clearUp () {
this.index1 = ''
this.index2 = ''
this.index3 = ''
this.index4 = ''
this.options2 = []
this.options4 = []
this.disabled = false
}
}
}
</script>
<style lang="stylus">
</style>