integrated_traffic_uniapp/components/other-select/index.vue

150 lines
4.7 KiB
Vue
Raw Normal View History

2024-01-16 17:24:49 +08:00
<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
2024-02-01 09:01:50 +08:00
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
2024-02-22 11:39:41 +08:00
}else if(lists[i].WORK_TYPE == "ELECTRICITY"){
lists[i].CHECK_NO = "临时用电" + ' ' + lists[i].CHECK_NO
}else if(lists[i].WORK_TYPE == "BREAKGROUND"){
lists[i].CHECK_NO = "动土作业" + ' ' + lists[i].CHECK_NO
}else if(lists[i].WORK_TYPE == "HOISTING"){
lists[i].CHECK_NO = "吊装作业" + ' ' + lists[i].CHECK_NO
}else if(lists[i].WORK_TYPE == "CUTROAD"){
lists[i].CHECK_NO = "断路作业" + ' ' + lists[i].CHECK_NO
2024-02-27 14:37:29 +08:00
}else if(lists[i].WORK_TYPE == "BLINDBOARD"){
lists[i].CHECK_NO = "盲板作业" + ' ' + lists[i].CHECK_NO
2024-02-01 09:01:50 +08:00
}
console.log(lists[i].CHECK_NO)
}
}
2024-01-16 17:24:49 +08:00
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>