integrated_traffic_uniapp/components/other-select/index.vue

140 lines
4.0 KiB
Vue

<template>
<page-meta :page-style="'overflow:'+(visible?'hidden':'visible')"></page-meta>
<uni-popup ref="popup" type="center" :mask-click="false">
<scroll-view scroll-y style="width: 100vw;height: 100vh;">
<view :style="{padding: this.CustomBar + 15 + 'px 15px 15px 15px'}">
<checkbox-group @change="change">
<view v-for="(item,index) in list" :key="index" style="display: flex;margin-top: 15upx">
<checkbox :value="type === 'assignments' ? item.CHECK_NO : item.NAME" :checked="value.indexOf(type === 'assignments' ? item.CHECK_NO : item.NAME) !== -1" />
<view style="padding-left: 10upx;">{{ type === 'assignments' ? item.CHECK_NO : item.NAME }}</view>
</view>
</checkbox-group>
</view>
<view class="cu-bar btn-group" style="margin-top: 50upx;">
<button class="cu-btn bg-blue margin-tb-sm lg" @click="determine">确定</button>
<button class="cu-btn bg-grey margin-tb-sm lg" @click="close"></button>
</view>
</scroll-view>
</uni-popup>
</template>
<script>
import uniPopup from '@/components/more-select/uni-popup/uni-popup.vue';
import {basePath, loginUser} from "@/common/tool";
export default {
components: {
uniPopup,
},
props: {
visible: {
type: Boolean,
required: true,
default: false
},
value:{
type: String,
required: true,
default: ''
},
type:{
type: String,
required: true,
default: ''
}
},
data() {
return {
list: [],
selectValue:[],
}
},
watch:{
visible:{
handler(newValue) {
if (newValue) this.getData()
},
immediate:true
}
},
methods: {
getData() {
uni.showLoading({
title: '请稍候'
})
let url = ''
let data = {}
if(this.type === 'assignments') {
url = 'app/eightwork/list'
data = {
CORPINFO_ID:loginUser.CORPINFO_ID
}
} else {
url = 'app/eightwork/getInfo'
data = {
vectors: JSON.stringify([ 'accidentType'])
}
}
uni.request({
url: basePath + url,
method: 'POST',
header: {
'Content-type': 'application/x-www-form-urlencoded'
},
data,
success: (res) => {
if ("success" === res.data.result) {
uni.hideLoading();
this.list = this.type === 'assignments' ? res.data.varList : res.data.accidentType
if(this.list == res.data.varList){
const lists = res.data.varList
for (let i = 0; i < lists.length; i++) {
if(lists[i].WORK_TYPE == "HOTWORK"){
lists[i].CHECK_NO = "动火作业" + ' ' + lists[i].CHECK_NO
}else if(lists[i].WORK_TYPE == "CONFINEDSPACE"){
lists[i].CHECK_NO = "受限作业" + ' ' + lists[i].CHECK_NO
}else if(lists[i].WORK_TYPE == "HIGHWORK"){
lists[i].CHECK_NO = "高处作业" + ' ' + lists[i].CHECK_NO
}
console.log(lists[i].CHECK_NO)
}
}
this.$nextTick(() => {
this.$refs.popup.open()
})
} else if ("exception" === res.data.result) {
uni.showToast({
title: '错误',
duration: 2000
});
}
}
});
},
change(event){
this.selectValue = event.detail.value
},
close(){
this.$emit('update:visible',false)
this.$refs.popup.close()
},
determine(){
const value = []
for (let i = 0; i < this.selectValue.length; i++) {
if(this.value.indexOf(this.selectValue[i]) === -1){
value.push(this.selectValue[i])
}
}
this.value && value.unshift(this.value)
const emitValue = value.join(',')
this.$emit('input',emitValue)
this.close()
}
},
}
</script>
<style scoped>
</style>