qa-prevention-xgf-app/components/other-select/index.vue

118 lines
2.7 KiB
Vue
Raw Normal View History

2024-06-27 17:49:52 +08:00
<template>
<u-popup :show="visible" mode="center">
<scroll-view scroll-y style="width: 100vw;height: 100vh;">
<view class="container">
<u-checkbox-group v-model="selectValue" placement="column">
<u-checkbox :customStyle="{marginBottom: '8px'}" v-for="(item, index) in list" :key="index"
:label="type === 'assignments' ? item.ID : item.NAME"
:name="type === 'assignments' ? item.ID : item.NAME">
2024-06-27 17:49:52 +08:00
</u-checkbox>
</u-checkbox-group>
<view class="button_group_placeholder"></view>
<view class="button_group">
<u-button type="primary" text="确定" @click="determine" :customStyle="{width:'48%'}"></u-button>
<u-button text="关闭" @click="close" :customStyle="{width:'48%'}"></u-button>
</view>
</view>
</scroll-view>
</u-popup>
</template>
<script>
import {
getOtherAssignmentsSelectList,
2024-08-29 16:19:09 +08:00
getRiskIdentificationResultsSelectList,
2024-08-31 09:55:46 +08:00
getQyDicList,
2024-08-29 16:19:09 +08:00
getUserList
2024-07-09 18:01:48 +08:00
} from '@/api'
2024-06-27 17:49:52 +08:00
export default {
props: {
visible: {
type: Boolean,
required: true,
},
value: {
type: String,
required: true,
},
type: {
type: String,
required: true,
}
},
data() {
return {
list: [],
selectValue: [],
}
},
watch: {
visible: {
handler(newValue) {
2024-07-04 17:57:31 +08:00
if (newValue) {
this.selectValue = this.value.split(',')
this.getData()
}
2024-06-27 17:49:52 +08:00
},
immediate: true
}
},
methods: {
async getData() {
if (this.type === 'assignments') {
const resData = await getOtherAssignmentsSelectList()
2024-07-04 17:57:31 +08:00
this.list = resData.list
2024-06-27 17:49:52 +08:00
} else if (this.type === 'identification') {
const resData = await getRiskIdentificationResultsSelectList({
vectors: JSON.stringify(['accidentType'])
})
this.list = resData.accidentType
2024-08-29 16:19:09 +08:00
} else if (this.type === 'hotWorkMethod') {
2024-08-31 09:55:46 +08:00
const resData = await getQyDicList({
2024-08-29 16:19:09 +08:00
DICTIONARIES_ID: "63cf39931a89467594efc441bf67f6dd",
});
this.list = resData.list
} else if (this.type === 'userNameSelect') {
const resData = await getUserList({
DEPARTMENT_ID: this.$store.state.userInfo.DEPARTMENT_ID,
TYPE: 2
});
this.list = resData.list.list
2024-06-27 17:49:52 +08:00
}
},
close() {
2024-07-04 17:57:31 +08:00
this.selectValue = []
2024-06-27 17:49:52 +08:00
this.$emit('update:visible', false)
},
determine() {
2024-07-04 17:57:31 +08:00
const emitValue = this.selectValue.join(',')
2024-06-27 17:49:52 +08:00
this.$emit('input', emitValue)
this.close()
}
},
}
</script>
<style scoped lang="scss">
.container {
padding: 30upx;
.button_group_placeholder {
height: 100upx;
background-color: #fff;
}
.button_group {
background-color: #fff;
display: flex;
position: fixed;
bottom: 0;
padding: 20upx 5%;
width: 90%;
left: 0;
right: 0;
}
}
2024-07-04 17:57:31 +08:00
</style>