Commit f21b694a authored by 刘文虎's avatar 刘文虎

自动多选组件

parent 38d31e0d
Pipeline #2746 canceled with stages
......@@ -7,12 +7,15 @@
</template>
<script>
import XlCalculator from '@/components/xl-calculator/xl-calculator.nvue';
export default {
name: 'billing-details',
components:{
XlCalculator
},
data() {
return {
show: true,
show: false,
};
},
methods: {
......
<template>
<view class="checkbox-group">
<view class="checkbox-group-item" :class="{ active: item.value === checked }" v-for="(item, index) in options" :key="index" @click="handleCheck(item)">
{{ item.label }}
</view>
</view>
</template>
<script>
export default {
name:"checkbox-group",
props: {
checked: {
type: Number | String,
default: ''
},
options: {
type: Array,
default: () => []
}
},
data() {
return {};
},
methods: {
handleCheck(item) {
console.log(item);
this.$emit('click', item);
}
}
};
</script>
<style lang="scss" scoped>
.checkbox-group {
display: flex;
flex-wrap: wrap;
&-item {
padding: 12upx 24upx;
font-size: 24upx;
line-height: 28upx;
color: #333333;
// background-color: #ffffff;
background-color: #f2f2f2;
border-radius: 8upx;
margin-right: 24upx;
&:last-child {
margin-right: 0;
}
}
.active {
background-color: #87c287;
color: #ffffff;
}
}
</style>
<template>
<view class="create-schedule">
<view class="">添加行程</view>
<view class="schedule-card">
<u-form :model="form" ref="uForm" label-position="top" :error-type="errorType" label-width="180">
<u-form-item label="计划类型:" prop="type">
<view class="input-view">
<CheckboxGroup :checked="form.type" :options="scheduleTypeOptions" @click="scheduleTypeChange" ></CheckboxGroup>
</view>
</u-form-item>
<u-form-item label="计划时间:" prop="createdTime">
<view class="input-view">
<input type="text" v-model="form.createdTime" placeholder="请选择" class="field-input" />
<u-icon name="scan" color="#272727" size="28" class="field-icon" @click="toScan('createdTime')"></u-icon>
</view>
</u-form-item>
<u-form-item label="提醒设置:" prop="setting"></u-form-item>
</u-form>
</view>
<view class=""><button @click="startRecording">录音</button></view>
<!-- <u-prop></u-prop> -->
<u-popup v-model="soundShow" mode="bottom" border-radius="14" safe-area-inset-bottom>
<sound-recording ref="sound-recording" @cancel="soundCancel" @confirm="soundConfirm"></sound-recording>
</u-popup>
......@@ -11,44 +25,73 @@
<script>
import SoundRecording from '@/components/sound-recording/sound-recording.vue';
import {authorize,openSetting,showModal} from "@/utils/auth.js"
import CheckboxGroup from './components/checkbox-group.vue';
import { authorize, openSetting, showModal } from '@/utils/auth.js';
import { scheduleTypeOptions } from '@/utils/options/schedule';
export default {
components: { SoundRecording },
components: { SoundRecording, CheckboxGroup },
data() {
return {
soundShow: false // 录音弹框
scheduleTypeOptions,
soundShow: false, // 录音弹框
form: {
type: '',
createdTime: '',
setting: ''
},
errorType: ['toast', 'border-bottom'],
rules: {
type: [{ required: true, message: '请选择计划类型', trigger: ['change', 'blur'] }],
createdTime: [{ required: true, message: '请选择计划时间', trigger: ['change', 'blur'] }],
setting: [{ required: true, message: '请选择提醒设置', trigger: ['change', 'blur'] }]
}
};
},
methods:{
startRecording(){
authorize("scope.record").then(()=>{
this.soundShow=true
}).catch(()=>{
this.showModal()
})
methods: {
startRecording() {
authorize('scope.record')
.then(() => {
this.soundShow = true;
})
.catch(() => {
this.showModal();
});
},
showModal(){
showModal() {
showModal({
content:"检测到您没打开录音功能权限,是否去设置打开?",
callback:()=>{
content: '检测到您没打开录音功能权限,是否去设置打开?',
callback: () => {
openSetting({
scope:"scope.record",
callback:()=>{
this.soundShow=true
scope: 'scope.record',
callback: () => {
this.soundShow = true;
}
})
});
}
})
});
},
soundCancel(){
this.soundShow=false
soundCancel() {
this.soundShow = false;
},
soundConfirm(e){
console.log(e)
this.soundShow=false
soundConfirm(e) {
console.log(e);
this.soundShow = false;
},
scheduleTypeChange(item) {
console.log(item);
this.form.type = item.value;
}
}
};
</script>
<style lang="scss" scoped></style>
<style lang="scss" scoped>
.create-schedule {
padding: 0 32upx;
.schedule-card {
padding: 0 32upx;
background-color: #ffffff;
border-radius: 20upx;
}
}
</style>
export const scheduleTypeOptions = [{
value: "1",
label: "工作"
},
{
value: "2",
label: "生活"
},
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment