区域锁定需求
This commit is contained in:
@@ -8,20 +8,42 @@
|
||||
<span class="filter_label">区域</span>
|
||||
</view>
|
||||
<view class="zd-col-19 filter_select">
|
||||
<zxz-uni-data-select
|
||||
<!-- <zxz-uni-data-select
|
||||
v-model="index"
|
||||
:localdata="options"
|
||||
:multiple="true"
|
||||
:collapseTags="true"
|
||||
/>
|
||||
/> -->
|
||||
<uni-data-select v-model="index" :localdata="options" @change="selectChange"></uni-data-select>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view v-show="dataList.length > 0" class="zd_wrapper grid-wraper">
|
||||
<view class="slide_new">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr v-for="(e, i) in dataList" :key="i" @click="toCheck(e)">
|
||||
<td><uni-icons :type="e.checked ? 'checkbox-filled' : 'circle'" size="26" color="#4e6ef2"></uni-icons></td>
|
||||
<td>{{e.point_name}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</view>
|
||||
</view> -->
|
||||
<view v-show="dataList.length > 0" class="zd_wrapper grid-wraper">
|
||||
<view class="zd-row point-wraper">
|
||||
<view class="zd-row point-item" v-for="(e, i) in dataList" :key="i" @click="toCheck(e)" :class="{'checked': e.checked}">{{e.point_name}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="zd-row submit-bar">
|
||||
<view class="zd-col-4 zd-row flexcol" @tap="allCheck">
|
||||
<uni-icons :type="allChecked ? 'checkbox-filled' : 'circle'" size="26" color="#4e6ef2"></uni-icons>
|
||||
<view class="checkbox-text">全选</view>
|
||||
</view>
|
||||
<button class="zd-col-5 button-default" @tap="clearUp">清空</button>
|
||||
<button class="zd-col-8 button-primary" :class="{'button-info': index.length === 0}" :disabled="disabled" @tap="_handheldLock('1')">锁定</button>
|
||||
<button class="zd-col-8 button-primary" :class="{'button-info': index.length === 0}" :disabled="disabled" @tap="_handheldLock('0')">释放</button>
|
||||
<button class="zd-col-7 button-primary" :class="{'button-info': !index}" :disabled="disabled" @tap="_handheldLock('1')">锁定</button>
|
||||
<button class="zd-col-7 button-primary" :class="{'button-info': !index}" :disabled="disabled" @tap="_handheldLock('0')">释放</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -29,8 +51,8 @@
|
||||
<script>
|
||||
import NavBar from '@/components/NavBar.vue'
|
||||
import SearchBox from '@/components/SearchBox.vue'
|
||||
// import {regionList} from '@/utils/mork2.js'
|
||||
import {regionList, handheldLock} from '@/utils/getData2.js'
|
||||
// import {regionList, selectPointByRegion} from '@/utils/mork2.js'
|
||||
import {regionList, selectPointByRegion, handheldLock} from '@/utils/getData2.js'
|
||||
export default {
|
||||
components: {
|
||||
NavBar,
|
||||
@@ -40,9 +62,13 @@
|
||||
return {
|
||||
title: '',
|
||||
options: [],
|
||||
index: [],
|
||||
index: '',
|
||||
multiple: true,
|
||||
disabled: false
|
||||
disabled: false,
|
||||
dataList: [],
|
||||
pkId: '',
|
||||
pkObj: {},
|
||||
allChecked: false
|
||||
};
|
||||
},
|
||||
onLoad (options) {
|
||||
@@ -57,14 +83,46 @@
|
||||
this.$set(el, 'text', el.label)
|
||||
})
|
||||
},
|
||||
selectChange (e) {
|
||||
if (e) {
|
||||
this._selectPointByRegion(e)
|
||||
}
|
||||
},
|
||||
async _selectPointByRegion (e) {
|
||||
let res = await selectPointByRegion(e)
|
||||
this.dataList = [...res]
|
||||
this.dataList.map(el => {
|
||||
this.$set(el, 'checked', false)
|
||||
})
|
||||
},
|
||||
toCheck (e) {
|
||||
e.checked = !e.checked
|
||||
let arr = this.dataList.filter(el => el.checked === true)
|
||||
if (arr.length === this.dataList.length) {
|
||||
this.allChecked = true
|
||||
} else {
|
||||
this.allChecked = false
|
||||
}
|
||||
},
|
||||
allCheck () {
|
||||
if (!this.dataList.length) return
|
||||
this.allChecked = !this.allChecked
|
||||
this.dataList.map(el => {
|
||||
el.checked = this.allChecked
|
||||
})
|
||||
},
|
||||
async _handheldLock (type) {
|
||||
this.disabled = true
|
||||
if (this.index.length === 0) {
|
||||
if (!this.index) {
|
||||
this.disabled = false
|
||||
return
|
||||
}
|
||||
try {
|
||||
let res = await handheldLock(this.index, type)
|
||||
let arr = null
|
||||
if (type === '0') {
|
||||
arr = this.dataList.filter(el => el.checked === true)
|
||||
}
|
||||
let res = await handheldLock(this.index, type, arr)
|
||||
this.clearUp()
|
||||
uni.showToast({
|
||||
title: res.message,
|
||||
@@ -75,8 +133,11 @@
|
||||
}
|
||||
},
|
||||
clearUp () {
|
||||
this.index = []
|
||||
this.index = ''
|
||||
this.disabled = false
|
||||
this.dataList = []
|
||||
this.pkId = ''
|
||||
this.pkObj = {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user