ljlong_2630
3 months ago
3 changed files with 320 additions and 8 deletions
@ -0,0 +1,236 @@ |
|||
<template> |
|||
<!-- 选择人员 --> |
|||
<u-popup v-model="props.isShowSelectPerson" mode="center" border-radius="14"> |
|||
<view class="popup-title">选择人员</view> |
|||
<view class="popup"> |
|||
<u-search placeholder="搜索" v-model="form1.searchName" @change="searchPerson"></u-search> |
|||
<view class="list"> |
|||
<view class="person" v-for="(person, index) in singleColumnList" :key="index" @click="choosePerson(person)"> |
|||
<u-checkbox v-model="person.checked" shape="circle" style="margin-top: 8rpx;"></u-checkbox> |
|||
<view class="right"> |
|||
<view class="person-nickname"> |
|||
<span>{{person.nickname}}</span> |
|||
</view> |
|||
<!-- <view class="person-name"> |
|||
登录名: <span>{{person.name}}</span> |
|||
</view> --> |
|||
<!-- <view class="person-id"> |
|||
ID: <span>{{person.id}}</span> |
|||
</view> --> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<view class="popup-footer"> |
|||
<view @click="choosePerson1(0)">取消</view> |
|||
<view class="sure" @click="choosePerson1(1)">确认</view> |
|||
</view> |
|||
</u-popup> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import { |
|||
ref, |
|||
defineProps, |
|||
defineEmits, |
|||
getCurrentInstance, |
|||
watch |
|||
} from 'vue' |
|||
import { |
|||
onLoad, |
|||
} from '@dcloudio/uni-app' |
|||
const props = defineProps({ |
|||
isShowSelectPerson: { |
|||
type: Boolean, |
|||
default: () => { return false }, |
|||
require: true |
|||
}, |
|||
singleColumnList: { |
|||
type: Array, |
|||
default: () => { return [] }, |
|||
require: false |
|||
} |
|||
}); |
|||
// 监测isShowSelectPerson的变化 |
|||
watch(() => props.isShowSelectPerson, (newValue, oldValue) => { |
|||
if (newValue) { |
|||
console.log('props.isShowSelectPerson', props.isShowSelectPerson); |
|||
form1.value.searchName = "" |
|||
form1.value.temporarilyId = null |
|||
form1.value.temporarilyNickname = null |
|||
form1.value.temporarilyName = null |
|||
} |
|||
}); |
|||
const { proxy } = getCurrentInstance() |
|||
const personList = ref([]) |
|||
const type = ref('') |
|||
const isShowSelectPerson = ref(false); |
|||
const selectVal = ref(null); |
|||
const emits = defineEmits(['searchPerson', 'choosePerson']); |
|||
const form1 = ref({ |
|||
id: "", |
|||
nickname: "", |
|||
name: "", |
|||
temporarilyId: "", // 临时选中的ID |
|||
temporarilyNickname: "", // 临时选中的别名 |
|||
temporarilyName: "", // 临时选中的登录名 |
|||
searchName: "", // 模糊搜索 |
|||
}) |
|||
onLoad((option) => { |
|||
if (option.type) type.value = option.type; |
|||
if (option.type) isShowSelectPerson.value = option.isShowSelectPerson; // 是否显示 |
|||
if (option.selectVal) selectVal.value = option.selectVal; // 是否显示 |
|||
}) |
|||
// 取消和确认方法 |
|||
function choosePerson1(type) { |
|||
if (type == 1) { |
|||
form1.value.id = form1.value.temporarilyId |
|||
form1.value.nickname = form1.value.temporarilyNickname |
|||
form1.value.name = form1.value.temporarilyName |
|||
} |
|||
emits('choosePerson', type, form1); |
|||
} |
|||
function searchPerson() { |
|||
emits('searchPerson', form1.value.searchName); |
|||
} |
|||
function choosePerson(person) { |
|||
console.log('props.isShowSelectPerson', props.isShowSelectPerson); |
|||
console.log('props.singleColumnList', props.singleColumnList); |
|||
let arr = props.singleColumnList.filter(cur => cur.id != person.id) |
|||
arr.forEach(person => { |
|||
person.checked = false |
|||
}) |
|||
person.checked = !person.checked |
|||
let arr1 = props.singleColumnList.filter(cur => cur.id == person.id) |
|||
form1.value.temporarilyId = arr1[0].id; |
|||
form1.value.temporarilyNickname = arr1[0].nickname; |
|||
form1.value.temporarilyName = arr1[0].name; |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
.add-form-container { |
|||
min-height: calc(100vh - 140rpx); |
|||
background: white; |
|||
padding: 0px 30rpx 140rpx; |
|||
} |
|||
.footer { |
|||
position: fixed; |
|||
bottom: 0px; |
|||
left: 0px; |
|||
width: 100%; |
|||
z-index: 22; |
|||
} |
|||
.btns { |
|||
display: flex; |
|||
button { |
|||
flex: 1; |
|||
} |
|||
.sure { |
|||
background: #409eff; |
|||
color: white; |
|||
border-radius: 0px; |
|||
&::after { |
|||
border: 1px solid #409eff; |
|||
border-radius: 0px; |
|||
} |
|||
} |
|||
.reset { |
|||
background: #F5F5F5; |
|||
border-radius: 0px; |
|||
&::after { |
|||
border-radius: 0px; |
|||
} |
|||
} |
|||
} |
|||
.right-button { |
|||
background: #409eff; |
|||
color: white; |
|||
padding: 0rpx 30rpx; |
|||
border-radius: 16rpx; |
|||
text-align: center; |
|||
font-size: 28rpx; |
|||
} |
|||
.select { |
|||
display: flex; |
|||
align-items: center; |
|||
height: 72rpx; |
|||
width: 100%; |
|||
.input { |
|||
flex: 1; |
|||
font-size: 28rpx; |
|||
color: #000000; |
|||
} |
|||
.placeholder { |
|||
flex: 1; |
|||
font-size: 28rpx; |
|||
color: rgb(192, 196, 204); |
|||
} |
|||
} |
|||
.title { |
|||
padding: 32rpx 0px; |
|||
position: relative; |
|||
span { |
|||
position: absolute; |
|||
left: -16rpx; |
|||
color: #fa3534; |
|||
padding-top: 6rpx; |
|||
} |
|||
} |
|||
.list { |
|||
.person { |
|||
display: flex; |
|||
margin-bottom: 20rpx; |
|||
.person-box { |
|||
background: #F5F5F5; |
|||
border-radius: 12rpx; |
|||
flex: 1; |
|||
width: 0rpx; |
|||
} |
|||
.person-title { |
|||
padding: 20rpx 30rpx; |
|||
border-bottom: 1px solid #e4e4e4; |
|||
.title-txt { |
|||
color: #409eff; |
|||
font-size: 30rpx; |
|||
font-weight: bold; |
|||
} |
|||
} |
|||
.dec { |
|||
color: #9c9c9c; |
|||
padding: 20rpx 30rpx 20rpx; |
|||
} |
|||
} |
|||
} |
|||
.add-btn { |
|||
display: flex; |
|||
justify-content: flex-start; |
|||
align-items: center; |
|||
} |
|||
.popup-title { |
|||
text-align: center; |
|||
font-size: 32rpx; |
|||
font-weight: bold; |
|||
color: #409eff; |
|||
padding: 30rpx 30rpx 0px; |
|||
} |
|||
.popup { |
|||
width: 600rpx; |
|||
padding: 30rpx 60rpx 30rpx; |
|||
} |
|||
.popup-footer { |
|||
display: flex; |
|||
border-top: 1px solid #e4e4e4; |
|||
view { |
|||
line-height: 100rpx; |
|||
flex: 1; |
|||
text-align: center; |
|||
&.sure { |
|||
color: #409eff; |
|||
} |
|||
} |
|||
} |
|||
::v-deep .u-checkbox-group { |
|||
display: grid !important; |
|||
} |
|||
</style> |
Loading…
Reference in new issue