国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

uni-app表單組件

這篇具有很好參考價(jià)值的文章主要介紹了uni-app表單組件。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

common-form.vue

<template>
	<view>
		<u--form :model="form" ref="uForm" :rules="rules" :labelWidth="labelWidth" labelAlign="left"  :labelPosition="labelPosition">
			<u-form-item :label="item.label" :prop="item.prop" v-for="(item) in formData" :key="item.prop" 
			 :required="item.isRule === '1'"
			 :class="item.type === 'textarea'?'labelLeft':item.type === 'wrapInput'?'warp-item':''"
			 customStyle="padding:28upx 32upx;background:#fff;margin-top:2upx;" class="form-item"
			 @click="handleFormItem(item)">
				<!-- 輸入框 -->
				<u-input v-model="form[item.prop]" :inputAlign="labelPosition==='left'?'right':''" :placeholder="item.placeholder||placeholder" border="none" :type="item.isType" :disabled="item.disable" clearable v-if="item.type=='input'"/>
				<number :inputAlign="labelPosition==='left'?'right':''" v-if="item.type=='number'" :itemData="{precision:2,value:form[item.prop]}" @ok="setFormProp"/>
				<view class="u-font-28" style="text-align: right;" v-if="item.type === 'wrapInput'" v-html="form[item.prop]&&form[item.prop].replace(/,/g,'<br />')||'--'"></view>
				<!-- 文本域 -->
				<u--textarea v-model="form[item.prop]" :placeholder="item.placeholder||'請輸入內(nèi)容'" :confirmType="'done'" :disabled="item.disable" v-if="item.type=='textarea'" border="none" customStyle="padding:0" :height="20 * item.rows"></u--textarea>
				<textarea v-model="form[item.prop]" placeholder="請輸入內(nèi)容" v-if="item.type=='TextContent'" disabled="true" border="none" customStyle="padding:10upx" :height="20 * item.rows"></textarea>
				<!-- 單選框 -->
				<u-radio-group  v-model="form[item.prop]" :disabled="item.disable" v-if="item.type == 'radio'"  placement="column">
					<u-radio :label="radio.label" :name="radio.value" :class="[radioIndex!==0?'u-mt-40': 'u-mt-16','radio']" v-for="(radio,radioIndex) in item.options" :key="radio.value"></u-radio>
				</u-radio-group>
				<!-- 復(fù)選框 -->
				<u-checkbox-group
					v-model="form[item.prop]"
					placement="column"
					:disabled="item.disable"
					v-if="item.type == 'checkbox'"
					activeColor="#0054A3"
					class="checkbox-group">
					<u-checkbox
						:customStyle="{marginBottom: '8px'}"
						v-for="(item, index) in item.options"
						:key="index"
						:label="item.label"
						:name="item.value"
						class="u-mb-32"
					>
					</u-checkbox>
				</u-checkbox-group>
				
				<!-- 時(shí)間 -->
				<template v-if="isShowDate(item)">
					<!-- <u-input v-model="form[item.prop]" placeholder="請選擇" border="none" clearable readonly/> -->
					<view class="u-content-color" :style="labelPosition==='left'?'text-align: right;flex: 1;':''">
						{{ translateTime(form[item.prop]) }}
					</view>
					<template v-if="!item.disable&&labelPosition==='top'">
						<u-icon
							slot="labelTop-Right"
							name="arrow-right" color="#a9a9a9" size="18" v-if="!form[item.prop] || item.disable">
						</u-icon>
						<u-icon
							slot="labelTop-Right"
							name="close-circle-fill" color="#a6a6a6" size="18" @click.native.stop="form[item.prop]=''" v-else>
						</u-icon>
					</template>
				</template>
				
				<!-- 圖片 -->
				<template v-if="item.type == 'file'">
					<view v-if="labelPosition!=='left'" class="" slot="labelTop-Right" @click="uploadImage(item)">
						<u-icon name="photo" size="25" color="#363636"></u-icon>
					</view>
					<view :style="labelPosition==='left'?'flex: 1;display: flex;align-items: center;':''" class="u-rela u-mr-2" v-for="(image,index) in form[item.prop]" :key="index">
						<!-- <u--image :src="image" radius="2" width="90upx" height="90upx" @click.native.stop="previewImage(image)"></u--image> -->
						<comImage :image="image" :levelLayout="item.levelLayout||''"/>
						<!-- <view class="image-close u-flex-xy-center" @click="handleDeleteImage(item.prop,index)">
							<u-icon name="close" color="#fff" size="12"></u-icon>
						</view> -->
						<view v-if="labelPosition==='left'" @click="uploadImage(item)">
							<u-icon v-if="!item.disable" name="arrow-right" size="16" color="#363636"></u-icon>
						</view>
					</view>
				</template>
				<!-- 文件 -->
				<template v-if="item.type == 'docFile'">
					<view v-if="labelPosition!=='left'" class="" slot="labelTop-Right" @click="uploadDocFile(item)">
						<u-icon name="plus" size="22" color="#363636"></u-icon>
					</view>
					<view :style="labelPosition==='left'?'flex: 1;display: flex;align-items: center;':''" class="u-rela u-mr-2" v-for="(it,index) in form[item.prop]" :key="index">
						<view class="">
							{{it}}
						</view>
					</view>
				</template>
				
				<!-- 選擇器 -->
				<template v-if="item.type == 'select'">
					<view :style="labelPosition==='left'?'text-align: right;flex: 1;':''" class="u-content-color" v-if="typeof form[item.prop] ==='string'||typeof form[item.prop] ==='number'">
						{{ translateName(item) }}
					</view>
					<!-- 多選類型的數(shù)組 -->
					<view :style="labelPosition==='left'?'text-align: right;':''" v-else v-for="(value,vIndex) in form[item.prop]" :key="vIndex" style="width:100%">
						{{ getMultiLabel(value,item) }}
					</view>
					
					<template v-if="!item.disable&&labelPosition==='top'">
						<u-icon
							slot="labelTop-Right"
							color="#a9a9a9" size="18"
							name="arrow-right" v-if="!form[item.prop]">
						</u-icon>
						<u-icon
							slot="labelTop-Right"
							size="18"
							name="close-circle-fill" color="#a6a6a6" @click.native.stop="clearValue(item)" v-else>
						</u-icon>
					</template>
				</template>
				<template v-if="item.type == 'seachSelect'">
					<view :style="labelPosition==='left'?'text-align: right;flex: 1;':''" class="u-content-color">
						{{ item.getName || form[item.editName] || '請選擇' }}
					</view>
					<template v-if="!item.disable&&labelPosition==='top'">
						<u-icon
							slot="labelTop-Right"
							color="#a9a9a9" size="18"
							name="arrow-right" v-if="!form[item.prop]">
						</u-icon>
						<u-icon
							slot="labelTop-Right"
							size="18"
							name="close-circle-fill" color="#a6a6a6" @click.native.stop="clearValue(item)" v-else>
						</u-icon>
					</template>
				</template>
				<template v-if="item.type == 'seachDrugName'">
					<view :style="labelPosition==='left'?'text-align: right;flex: 1;':''" class="u-content-color">
						{{ item.drugName || form[item.editName] || '請選擇' }}
					</view>
					<template v-if="!item.disable&&labelPosition==='top'">
						<u-icon
							slot="labelTop-Right"
							color="#a9a9a9" size="18"
							name="arrow-right" v-if="!form[item.prop]">
						</u-icon>
						<u-icon
							slot="labelTop-Right"
							size="18"
							name="close-circle-fill" color="#a6a6a6" @click.native.stop="clearValue(item)" v-else>
						</u-icon>
					</template>
				</template>
				
				<!-- 部門 -->
				<template v-if="item.type == 'deptTree'">
					<view class="u-content-color" >
						 {{ deptName || '請選擇' }}
					</view> 
					<u-icon
						slot="labelTop-Right"
						color="#a9a9a9" size="18"
						name="arrow-right" v-if="!deptName">
					</u-icon>
					<u-icon
						slot="labelTop-Right"
						size="18"
						name="close-circle-fill" color="#a6a6a6" @click.native.stop="clearValue(item)" v-else>
					</u-icon>
				</template>

				<!-- 省市區(qū) -->
				<template v-if="item.type == 'province'">
					<view class="u-content-color" :style="labelPosition==='left'?'text-align: right;flex: 1;':''">
						 {{ region|| form[item.editName] || '請選擇' }}
					</view>
					<template v-if="!item.disable&&labelPosition==='top'">
						<u-icon
							slot="labelTop-Right"
							color="#a9a9a9" size="18"
							name="arrow-right" v-if="!region">
						</u-icon>
						<u-icon
							slot="labelTop-Right"
							size="18"
							name="close-circle-fill" color="#a6a6a6" @click.native.stop="clearProValue" v-else>
						</u-icon>
					</template>
				</template>

			</u-form-item>
		</u--form>
		
		<u-datetime-picker
			:show="dateTimeShow"
			v-model="dateTimeValue"
			:mode="dateMode"
			:minDate="minDate"
			@confirm="dateTimeConfirm"
			@cancel="dateTimeShow=false"
			:closeOnClickOverlay="true"
			@close="dateTimeShow=false"
		></u-datetime-picker>
		
		<year ref="year" @ok="setFormProp"/>
		<!-- 日期范圍 -->
		<u-calendar :show="calendarShow" :monthNum="'72'" :minDate="minDate" :maxDate="maxDate" :defaultDate="defaultDate" :mode="calendarMode" :allowSameDay="true" :closeOnClickOverlay="true" @confirm="calendarConfirm" @close="calendarShow=false"></u-calendar>
		
		<lotus-address v-if="proControl" v-on:choseVal="choseValue" :lotusAddressData="lotusAddressData"></lotus-address>
		
		<actionList ref="actionList" @ok="setFormProp" @nextPage="nextPage"/>
	</view>
</template>

<script>
import actionList from './actionList.vue'
import comImage from './comImage.vue'
import number from './number.vue'
import year from '../year/year.vue'
import { dictData,updateImg } from '@/api/common.js'
import lotusAddress from "../Winglau14-lotusAddress/Winglau14-lotusAddress.vue";

export default {
	components: {
		actionList,
		comImage,
		number,
		year,
		lotusAddress
	},
	props: {
		form: {
			type: Object,
			default: () => {}
		},
		// 表達(dá)數(shù)據(jù)必填
		formData: {
			type: Array,
			default: () => [],
			required: true
		},
		rules: {
			type: Object,
			default: () => {}
		},
		// 占位符
		placeholder: {
			type: String,
			default: '請輸入'
		},
		// label寬度
		labelWidth: {
			type: [String,Number],
			default: 45
		},
		// 布局方式參數(shù)
		labelPosition: {
			type: [String],
			default: 'top'
		},
	},
	computed: {
		// rules() {
		// }
	},
	watch:{
		"form":(val)=>{
		}
	},
	data() {
		return {
			value: '',
			dateTimeShow: false,
			dateTimeValue: '',
			curField: '', // 當(dāng)前表單元素綁定字段
			dateMode: '', //日期模式
			deptName: null, // 部門名稱
			calendarShow: false,
			calendarMode: 'single', // 日歷模式 
			isLoaded: false, // 是否已加載
			lotusAddressData:{ // 省市區(qū)
				visible:false,
				provinceName:'',
				cityName:'',
				townName:'',
			},
			region:'',
			proControl:false,
			minDate:null,
			maxDate:null,
			defaultDate:null,
			getToday:''
		};
	},
	mounted() {
	    this.$refs.uForm.setRules(this.rules)
		//獲取今天的日期
		var date = new Date()
		this.dateTimeValue = date.getFullYear()+'-'+(date.getMonth()<9?'0':'')+(date.getMonth()+1)+'-'+(date.getDate()<10?'0':'')+date.getDate()
		
	},
	created() {
		this.getOptions()
	},
	methods: {
		nextPage(n){
			this.$emit('nextPage',n )
		},
		//打開picker
		openPicker() {
			this.lotusAddressData.visible = true;
			this.lotusAddressData.provinceName = '';
			this.lotusAddressData.cityName = '';
			this.lotusAddressData.townName = '';
		},
		clearProValue(){
			this.region = ''
			this.form.nativePlace = ''
		},
		//回傳已選的省市區(qū)的值
		choseValue(res){
			//res數(shù)據(jù)源包括已選省市區(qū)與省市區(qū)code
			console.log(res);
			this.lotusAddressData.visible = res.visible;//visible為顯示與關(guān)閉組件標(biāo)識(shí)true顯示false隱藏
			//res.isChose = 1省市區(qū)已選 res.isChose = 0;未選
			if(res.isChose){
				this.lotusAddressData.provinceName = res.province;//省
				this.lotusAddressData.cityName = res.city;//市
				this.lotusAddressData.townName = res.town;//區(qū)
				this.region = `${res.province} ${res.city} ${res.town}`; //region為已選的省市區(qū)的值
				// this.form.nativePlace = res.provinceCode+res.cityCode+res.townCode// 籍貫
				// this.form.nativePlace = res.townCode// 籍貫(只取最后一級的code)
				// this.form.address = res.townCode// 客戶管理-客戶地址(只取最后一級的code)
				
				this.formData.map(item=>{
					if (item.type === 'province') {
						this.form[item.prop] = res.townCode || res.cityCode // 區(qū)是空時(shí),取上一級的code
					}
				})
			}
		},
		async getOptions(){
			await Promise.all(
				this.formData.map(async (item)=>{
					if (item.dictType) {
						item.options = await this.getDicts(item.dictType)
						if (this.form[item.prop]) {
							this.translateName(item)
						}
					}
					if (item.type === 'province') { //省市區(qū)顯示控件條件
						this.proControl = true
					}
				})
			)
		},
		// 自定義的設(shè)置最大時(shí)間、最小時(shí)間、默認(rèn)時(shí)間的方法
		chooseTimed(){
			let date = new Date()
			let year = date.getFullYear()
			let month = date.getMonth() + 1
			let day = date.getDate()
			if (month <= 9) {
				month = '0' + month
			}
			if (day <= 9) {
				day = '0' + day
			}
			let minyear = year - 2
			this.minDate = minyear + '-' + month + '-' + day
			let maxyear = year + 8
			this.maxDate = maxyear + '-' + month + '-' + day
			this.defaultDate = year + '-' + month + '-' + day
		},
		// 點(diǎn)擊表單元素
		async handleFormItem(item,index) {
			if (item.disable) {
				return
			}
			const { type,prop,label } = item
			if (item.minDate) {
				this.minDate = item.minDate || null
			}
			let dateType = {
				month: 'year-month',
				date: 'date',
				datetime: 'datetime',
			}
			// 日期
			if(dateType[type]) {
				this.dateMode = dateType[type]
				this.dateTimeShow = true
			} else if(type == 'daterange') {
				this.calendarMode = 'range'
				this.calendarShow = true
				this.chooseTimed()
			} else if(type == 'dates') {
				this.calendarMode = 'multiple'
				this.calendarShow = true
			} else if(type == 'year') {
				this.$refs.year.showPicker()
			} else if(type == 'select') {
				this.$refs.actionList.showPop(label,item.options,item.multiple)
			} else if(type == 'deptTree') {
				uni.$u.route('/pages/oaApproval/selectDept')
			}else if(type == 'seachSelect') {
				uni.$u.route('/pages/oaApproval/selectPerson',{
					isMultiple: true
				})
			}else if(type == 'seachDrugName') {
				uni.$u.route('/pages/businessTalk/selectDrug')
			} else if (type === 'province') {
				this.openPicker()
			}
			this.curField = prop
		},
		getDicts(dictType){
			return new Promise((resolve, reject)=>{
				dictData(dictType).then(res=>{
					if (res.code === 200) {
						const options = res.data.map(item => {
							return {
								dictType: item.dictType,
								label: item.dictLabel,
								value: item.dictValue
							}
						})
						resolve(options)
					}
				})
			})
			
		},
		// 上傳文件
		uploadDocFile(item){
			if (item.disable) {
				return
			}
			this.$utils.uploadPhoneFile((data) => {
				if (!data||data.length<=0) {
					uni.$u.toast('上傳失??!')
					return
				}
				console.log(data)
				this.form[this.curField] = [data[0].filePath]
			})
		},
		// 上傳圖片
		uploadImage(item) {
			if (item.disable) {
				return
			}
			this.$utils.uploadImage((data) => {
				if (!data||data.length<=0) {
					uni.$u.toast('上傳失??!')
					return
				}
				if (this.curField === 'pic') { // 頭像上傳
					this.form[this.curField] = [data[0].filePath]
					updateImg({pic:data[0].id,id:uni.getStorageSync('userInfo').staff.id}).then(res=>{
						if (res.code === 200) {
							let userData = uni.getStorageSync('userInfo')
							userData.staff.pic = data[0].filePath
							uni.setStorageSync('userInfo', userData)
							uni.$u.toast('上傳成功!')
							
						}
					})
				} else if (this.curField === 'attachObjList') { /** 需要上傳附件的所有信息字段對象的情況,自定義一個(gè)picObj存儲(chǔ)對象數(shù)據(jù) */
					data.map(item=>{
						if (!this.form.picObj) {
							this.form.picObj = []
						}
						this.form.picObj.push(item)
					})
				} else if (this.curField === 'files') { /** 需要上傳附件的所有信息字段對象的情況【智能績效-溝通反饋】*/
					data.map(item=>{
						if (!this.form[this.curField]) {
							this.form[this.curField] = []
						}
						this.form[this.curField].push(item)
					})
				} else { //多選圖片
					data.map(item=>{
						if (!this.form[this.curField]) {
							this.form[this.curField] = []
						}
						this.form[this.curField].push(item.filePath)
					})
				}
			})
		},
		// 是否顯示時(shí)間控件
		isShowDate(item) {
			let dateType = ['month','date','datetime','daterange','dates','year']
			return dateType.indexOf(item.type) !== -1
		},
		// 時(shí)間確認(rèn)
		dateTimeConfirm({ value }) {
			this.dateTimeShow = false
			this.form[this.curField] = this.dateMode == 'datetime' ? 
										this.$u.timeFormat(value,'yyyy-mm-dd hh:MM') 
										: this.$u.timeFormat(value,'yyyy-mm-dd')
		},
		// 時(shí)間范圍
		calendarConfirm(time) {
			this.calendarShow = false
			if(this.calendarMode === 'range') {
				this.form[this.curField] = [time[0],time[time.length - 1]]
				this.$refs.uForm.validateField(this.form[this.curField]) //無法及時(shí)觸發(fā)驗(yàn)證的問題
				//時(shí)間范圍無法及時(shí)觸發(fā)驗(yàn)證的問題
				this.rules[this.curField].validator = (rule, value, callback) => {
						if (value&&value.length>0) {
							return true
						} else {
							return false
						}
							}
				this.$forceUpdate()
				return
			}
			
			this.form[this.curField] = time
		},
		
		// 刪除圖片
		handleDeleteImage(prop,index) {
			this.form[prop].splice(index,1)
		},
		// 菜單選擇
		actionSelect(value) {
			this.form[this.curField] = value.name
		},
		getNameFac(item) {//人員選擇獨(dú)立頁面
			this.form[this.curField] = item.value
			this.formData.map((it,index)=>{
				if (this.curField === it.prop) {
					this.$set(this.formData[index],'getName',item.label)
				}
			})
		},
		getDrugNameFac(item) {//人員選擇獨(dú)立頁面
			this.form[this.curField] = item.value
			this.formData.map((it,index)=>{
				if (this.curField === it.prop) {
					this.$set(this.formData[index],'drugName',item.label)
				}
			})
		},
		getMultiLabel(it,item){
			let mulData = item.options.filter(row => it === row.value)
			return mulData.length>0&&mulData[0].label || '--'
		},
		// 翻譯選擇器
		translateName(item) {
			let { options,prop,dictType } = item
			// 不相等說明不是同一個(gè)form-item下的元素,不能執(zhí)行以下方法;解決選日期時(shí),會(huì)清空單選的問題;
			if (this.curField||this.form[prop]) {
				let match = []
				if (prop === this.curField) {
					match = options.filter(row => row.value === this.form[this.curField])
				} else {
					match = options.filter(row => row.value === this.form[prop])
				}
				if(match.length) {
					return match[0].label
				}else {
					return item.placeholder||'請選擇'
				}
			} else {
				return item.placeholder||'請選擇'
			}
		},
		// 時(shí)間翻譯器
		translateTime(time) {
			if(!time) { return '請選擇' }
			if(Array.isArray(time)) {
				return time.join(',')
			} else {
				return time
			}
		},
		// 設(shè)置form屬性值以及提示語
		setFormProp(value,tipMessage) {
			this.form[this.curField] = value
			if(tipMessage) {
				this.rules[this.curField].message = tipMessage
			}
			this.$refs.uForm.validateField(this.curField) //無法及時(shí)觸發(fā)驗(yàn)證的問題
			this.$forceUpdate()
		},
		clearValue(item) {
			this.form[item.prop]=''
			this.deptName = null
			this.getName = null
			this.drugName = null
			this.$forceUpdate()
		},
		
		// 校驗(yàn)
		validate() {
			return this.$refs.uForm.validate()
		}
	},
};
</script>
<style lang="scss" scoped>
	.form-item {
		& ::v-deep .u-form-item__body__right__message {
			// background: #f9eae4;
			padding: 6upx 0 6upx 32upx;
			color: #e93f32;
			font-size: 11px;
		}
		& ::v-deep .u-form-item__body__left__content__required {
			font-size: 14px;
			/* #ifdef H5 */
				top: 0;
			/* #endif */
		}
		
		& ::v-deep .u-form-item__body__left__content__label {
			font-size: 32upx;
		}
		& ::v-deep .u-form-item__body__left {
			// width: 100%!important;
			width: auto!important;
		}
		
		& ::v-deep .u-form-item__body__right__content__slot {
			flex-wrap: wrap;
		}
		
	}
	.warp-item {
		& ::v-deep .u-form-item__body__right__content {
			align-self: flex-end;
		}
	}
	.labelLeft{
		& ::v-deep .u-form-item__body {
			flex-direction: column!important;
		}
	}
	.checkbox-group {
		width: 100%;
		& ::v-deep .u-checkbox-label--left {
			margin-bottom: 0;
			padding-top: 16upx; 
		}
		& ::v-deep .u-checkbox-label--left text {
			width: 100%;
			padding: 28upx 10upx;
			border-bottom: 1upx solid #ccc;
		}
		& ::v-deep .uicon-checkbox-mark{
			padding: 0!important;
			border-bottom: none!important;
		}
	}
	.image-close {
		width: 35upx;
		height: 35upx;
		border-radius: 50%;
		position: absolute;
		right: -12upx;
		top: -12upx;
		background: #1c1f21;
	}
	.radio {
		& ::v-deep .u-radio__text {
			width: 100%;
			padding: 28upx 10upx;
			border-bottom: 1upx solid #ccc;
		}
	}
</style>

actionList.vue

<template>
	<view class="">
		<u-popup :show="show" @close="close" @open="open" round="10">
			<view>
				<view class="u-flex u-py-16 u-border-bottom u-px-32 u-flex-items-center">
					<u-icon name="close" size="16" @click="show = false"></u-icon>
					<view style="width: 100%;" class="text-center u-bold u-font-28">請選擇</view>
					<u-button type="primary" text="確定" shape="circle" customStyle="width:170upx;height:58upx;" v-if="multiple" @click="handleMultiple"></u-button>
				</view>
				<view style="width: 100%;margin: auto;" v-if="title === '所屬項(xiàng)目'">
					<u-search placeholder="搜索" v-model="keyWord" @change="getSeach()" :showAction="false" bgColor="#f5f5f7" shape="square" height="40" class="u-mb-16" :inputStyle="{fontSize: '30upx'}" searchIconSize="24"></u-search>
				</view>
				<view class="u-px-32 u-pt-16">
					<!-- 多選 -->
					<template v-if="multiple">
						<scroll-view :scroll-top="0" scroll-y="true" style="max-height: 600upx;">
							<u-checkbox-group
								v-model="checkboxValue"
								placement="column"
								activeColor="#0054A3"
								shape="circle"
								class="checkbox"
							>
								<u-checkbox
									:customStyle="{marginBottom: '8px'}"
									v-for="(item, index) in checkboxList"
									:key="index"
									:label="item.label"
									:name="item.value"
								>
								</u-checkbox>
							</u-checkbox-group>
						</scroll-view>
					</template>
					<!-- 單選 -->
					<template v-else>
						<scroll-view :scroll-top="0" scroll-y="true" style="max-height: 600upx;" @scrolltolower="scrolltolower">
						 <u-radio-group
						    v-model="radioValue"
						    placement="column"
							activeColor="#0054A3"
						  >
						    <u-radio
						      :customStyle="{marginBottom: '8px'}"
						      v-for="(item, index) in options"
						      :key="index"
						      :label="item.fname?item.fname+'-'+item.label:item.label"
						      :name="item.value"
						      @change="radioChange"
							  class="radio"
						    >
						    </u-radio>
						  </u-radio-group> 
						</scroll-view>
					</template>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
			  show: false,
				// 基本案列數(shù)據(jù)
			  options: [],
			  oldDataList: [],//暫存源數(shù)據(jù)
			  // u-radio-group的v-model綁定的值如果設(shè)置為某個(gè)radio的name,就會(huì)被默認(rèn)選中
			  radioValue: '',
			  title: '',
			  checkboxValue:[],
			  // 基本案列數(shù)據(jù)
			  checkboxList: [],
			  multiple: false, // 是否多選
			  selectPage:1,
			  keyWord:''
			}
		},
		methods: {
			changeOp(options){
				// this.options = options
			},
			scrolltolower(){
				// console.log('觸底了哦')
				// console.log(this.title)
				// let params = {selectPage:this.selectPage,keyWord:this.keyWord,name:this.title}
				// if ( this.title === '藥品名稱') {
				// 	this.selectPage++
				// 	this.$emit('nextPage',params)
				// }
			},
			getSeach(){ //在固定數(shù)據(jù)條件下,前端做的篩選搜索
				// let params = {selectPage:1,keyWord:this.keyWord,name:this.title}
				// this.$emit('nextPage',params)
				let _search = this.keyWord
				if (_search) {
					var reg = new RegExp(_search, 'ig')
					const list = this.oldDataList.filter(function(e) {
					  return e.label.match(reg)
					})
					this.options = list
				  } else {
					this.options = this.oldDataList
				  }
			},
			showPop(label,options,multip) {
				if (multip) {
					this.multiple = multip
					this.checkboxList = options
					this.show = true
				} else {
					this.multiple = false
					this.selectPage = 1
					this.radioValue = ''
					this.title = label
					this.options = options
					this.oldDataList = options
					this.show = true
				}
				
			},
			open() {
			},
			close() {
				this.selectPage = 1
				this.show = false
				this.keyWord = ''
			},
			radioChange(value) {
				this.show = false
				this.$emit('ok',value)
			},
			handleMultiple() {
				this.show = false
				this.$emit('ok',this.checkboxValue )
			}
		}
	}
</script>

<style lang="scss" scoped>
	.radio {
		& ::v-deep .u-radio__text {
			width: 100%;
			padding: 28upx 10upx;
			border-bottom: 1upx solid #ccc;
			// border-bottom-width: 0.5px!important;
			// border-color: $u-border-color!important;
			// border-bottom-style: solid;
		}
	}
	
	.u-radio-group {
		padding: 0 16upx;
	}
	
	.checkbox {
		& ::v-deep .u-checkbox-label--left text {
			width: 100%;
			padding: 26upx 0;
		}
	}
	
</style>

comImage.vue

<template>
    <view style="width:100%;">
        <u--image :levelLayout="levelLayout" :src="filePath" radius="2" width="90upx" height="90upx" @click.native.stop="previewImage(image)"></u--image>
    </view>
</template>

<script>
	import { querryFilePath } from '@/api/approval.js'
    export default {
        props: {
            image: {
                type: String,
                default: ''
            },
			levelLayout: {
                type: String,
                default: ''
            },
        },
        data() {
            return {
				filePath: ''
            }
        },
		watch: {
			image: {
				handler(newVal) {
					if (newVal) {
						this.getPath()
					}
				},
				immediate: true
			}
		},
		methods: {
			async getPath(){
				if (this.image instanceof Object) {
					this.filePath = this.image.filePath
				}else if (this.image.indexOf('.') !== -1) {
					this.filePath = this.image
				} else {
					const obj = await querryFilePath({fileId:this.image})
					this.filePath = obj.data&&obj.data.length>0&&obj.data[0].filePath
				}
			},
			// 預(yù)覽圖片
			previewImage(images) {
				// 預(yù)覽圖片
				this.$utils.previewImage(null,images)
			},
		},
    }
</script>

<style lang="scss" scoped>

</style>

number.vue文章來源地址http://www.zghlxwxcb.cn/news/detail-600357.html

<template>
    <view style="width:100%">
        <u-input v-model="value" :inputAlign="inputAlign" placeholder="請輸入" border="none" clearable type="number" @change="confirm" @confirm="confirm"/>
    </view>
</template>

<script>
    export default {
        props: {
            // 
            itemData: {
                type: Object,
                default: () => {}
            },
			inputAlign: {
				type: String,
				default: ''
			},
        },
		watch:{
			'itemData':{
				handler(newVal) {
					let { precision,value } = newVal
					this.value = value.toFixed(precision)
				},
				deep: true
			}
		},
        created () {
			// let { precision,value } = this.itemData
			// this.value = value.toFixed(precision)
        },
        data() {
            return {
                value: null
            }
        },
		methods: {
			confirm() {
				let value = Number(this.value)
				let { max,min,tipMessage,precision } = this.itemData
				let tip = value >  max ? `不能超過${max}` : value <  min ? `不能小于${min}` : tipMessage
				this.$emit('ok',Number(Number(this.value).toFixed(precision)),tip)
			}
		},
    }
</script>

<style lang="scss" scoped>

</style>

到了這里,關(guān)于uni-app表單組件的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 前端vue uni-app cc-countdown倒計(jì)時(shí)組件

    前端vue uni-app cc-countdown倒計(jì)時(shí)組件

    隨著技術(shù)的不斷發(fā)展,傳統(tǒng)的開發(fā)方式使得系統(tǒng)的復(fù)雜度越來越高。在傳統(tǒng)開發(fā)過程中,一個(gè)小小的改動(dòng)或者一個(gè)小功能的增加可能會(huì)導(dǎo)致整體邏輯的修改,造成牽一發(fā)而動(dòng)全身的情況。為了解決這個(gè)問題,我們采用了組件化的開發(fā)模式。通過組件化開發(fā),可以有效地實(shí)現(xiàn)單

    2024年02月15日
    瀏覽(37)
  • 前端vue uni-app基于原生input組件的增強(qiáng)簡單通用實(shí)用輸入框

    前端vue uni-app基于原生input組件的增強(qiáng)簡單通用實(shí)用輸入框

    隨著技術(shù)的發(fā)展,開發(fā)的復(fù)雜度也越來越高,傳統(tǒng)開發(fā)方式將一個(gè)系統(tǒng)做成了整塊應(yīng)用,經(jīng)常出現(xiàn)的情況就是一個(gè)小小的改動(dòng)或者一個(gè)小功能的增加可能會(huì)引起整體邏輯的修改,造成牽一發(fā)而動(dòng)全身。通過組件化開發(fā),可以有效實(shí)現(xiàn)單獨(dú)開發(fā),單獨(dú)維護(hù),而且他們之間可以隨

    2024年02月04日
    瀏覽(28)
  • 前端vue uni-app百度地圖定位組件,顯示地圖定位,標(biāo)記點(diǎn),并顯示詳細(xì)地址

    快速實(shí)現(xiàn)前端百度地圖定位組件,顯示地圖定位,標(biāo)記點(diǎn),并顯示詳細(xì)地址; 閱讀全文下載完整代碼請關(guān)注微信公眾號(hào): 前端組件開發(fā) 效果圖如下: ? ? 代碼如下: # 百度地圖定位組件,顯示地圖定位,標(biāo)記點(diǎn),并顯示詳細(xì)地址 #### 使用方法 ```使用方法 #安裝vue-baidu-map插件

    2024年02月08日
    瀏覽(26)
  • 前端vue uni-app多圖片上傳組件,支持單個(gè)文件,多個(gè)文件上傳 步驟條step使用

    前端vue uni-app多圖片上傳組件,支持單個(gè)文件,多個(gè)文件上傳 步驟條step使用

    快速實(shí)現(xiàn)多圖片上傳組件,支持單個(gè)文件,多個(gè)文件上傳 步驟條step使用;?閱讀全文下載完整代碼請關(guān)注微信公眾號(hào): 前端組件開發(fā) 效果圖如下: 使用方法 ? 使用方法 HTML代碼部分 ? html JS代碼 (引入組件 填充數(shù)據(jù)) ? javascript

    2024年02月08日
    瀏覽(31)
  • uni-app:重置表單數(shù)據(jù)

    uni-app:重置表單數(shù)據(jù)

    2024年02月09日
    瀏覽(27)
  • uni-app組件概述

    1.1、組件的含義 組件是視圖層的基本組成單元。 組件是一個(gè)單獨(dú)且可復(fù)用的功能模塊的封裝。 組件,包括:以組件名稱為標(biāo)記的開始標(biāo)簽和結(jié)束標(biāo)簽、組件內(nèi)容、組件屬性、組件屬性值。 component-name 是開始標(biāo)簽, /component-name 是結(jié)束標(biāo)簽 開始標(biāo)簽和結(jié)束標(biāo)簽之間,稱為組件

    2024年02月07日
    瀏覽(30)
  • Uni-app組件使用

    組件是 視圖層的基本組成單元 。是一個(gè)單獨(dú)且 可復(fù)用的功能模塊的封裝 。 組件名稱是由尖括號(hào)包裹的,可以看成一個(gè)語義化標(biāo)簽,是有開始標(biāo)簽和結(jié)束標(biāo)簽的。 如下舉個(gè)簡單的例子: uni-card ?//這是開始標(biāo)簽 text 這是一個(gè)基礎(chǔ)卡片示例,內(nèi)容較少,此示例展示了一個(gè)沒有任

    2024年02月09日
    瀏覽(17)
  • uni-app如何使用組件

    使用組件是uni-app的常見操作之一。以下是使用組件的步驟: 在uni-app項(xiàng)目中創(chuàng)建組件。 可以通過在components文件夾中創(chuàng)建一個(gè).vue文件來創(chuàng)建組件。 也可以通過在HBuilderX中使用模板或向?qū)韯?chuàng)建組件。 在需要使用組件的頁面或組件中引入組件。 可以使用import導(dǎo)入組件,例如:

    2024年02月13日
    瀏覽(20)
  • uni-app的組件(一)

    uni-app的組件(一)

    scroll-view 可滾動(dòng)視圖區(qū)域。用于區(qū)域滾動(dòng) 屬性說明(查看更多屬性請查看官網(wǎng) [swiper | uni-app官網(wǎng) (dcloud.net.cn)](https://uniapp.dcloud.net.cn/component/swiper.html) ) 屬性名 類型 默認(rèn)值 說明 scroll-y Boolean false 允許縱向滾動(dòng) scroll-top Number/String 設(shè)置豎向滾動(dòng)條位置 @scroll EventHandle 滾動(dòng)時(shí)觸

    2024年01月16日
    瀏覽(24)
  • uni-app的組件(二)

    uni-app的組件(二)

    多項(xiàng)選擇器checkbox-group 多項(xiàng)選擇器,內(nèi)部由多個(gè) checkbox 組成。 屬性說明(查看更多屬性請查看官網(wǎng) [swiper | uni-app官網(wǎng) (dcloud.net.cn)](https://uniapp.dcloud.net.cn/component/swiper.html) ) 屬性名 類型 默認(rèn)值 說明 checked Boolean false 當(dāng)前是否選中,可用來設(shè)置默認(rèn)選中 disabled Boolean false 是否

    2024年01月18日
    瀏覽(22)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包