解决input.value text-overflow: ellipsis失效问题,分享一下

解决文本框设置的text-overflow: ellipsis失效的问题

bug再现:

当选择完级联面板内的所有文本时,input框的value值总体宽度超出input宽度时,是正常显示省略号的。

接下来如果再点击input框,就会出现text-overflow: ellipsis失效,导致tinput框内的value值后面没有省略号,使得完全展现。

鼠标点击事件触发的顺序:mousedown ->mouseup ->click ->mousedown ->mouseup ->click -dblclick

可以看到mousedown事件是先于click事件的,mousedown事件对于input不知道会产生什么默认的意外行为

解决办法是利用preventDefault方法阻止—下默认行为就可以了

event.on(input,'mousedown',this.mouseDownHandler = (e:MouseEvent)=>e.cancelable &&e.preventDefault()

分享的一位大神的解决方法希望可以给大家提供帮助

<template> <!-- 品牌馆 --> <view class="outBox"> <s-layout title="" navbar="inner"> <view class="brand"> <view class="brand-header" :style="{ backgroundImage: `url('${headerImg}')` }"> <view class="header-box1 flex jus-con center column"> <image class="box1-img" :src="headerTitle"></image> <view class="box1-text">严选品牌好货</view> </view> <view class="main-search flex center"> <image :src="headerSearch" class="search-icon" @click="searchInfoClick"></image> <view class="search-input flex center"> <input class="uni-input" placeholder="请输入品牌名称查找搜索" :value="inputClearValue" @input="clearInput" placeholder-style="color: #baaf9fc9;" /> <uni-icons type="clear" color="#dbdbdb" size="26" v-if="showClearIcon" @click="clearIcon" ></uni-icons> </view> <view class="search-text flex center jus-con" @click="searchInfoClick">搜索</view> </view> </view> <view class="brand-main"> <view class="main-nav flex"> <!-- <view class="inner-box" v-for="(item, index) in mainNavTitle" :key="index" @click="qiehuanNav(index)" :class="item.inline ? 'innerBoxActive' : ''" > {{ item.title }} </view> --> <SuTab v-model="activeTab" :tab="mainNavTitle" scroll :titleStyle="{ activeBg: '#734c2f', activeColor: '#FFF', color: '#fee4bf' }" @change="handleTabChange" /> </view> <view class="main-content"> <scroll-view scroll-y @scroll="handleScrollClick" style="height: 60vh"> <view class="content-box" v-for="value in 4"> <view class="conBox-title flex center"> <view class="title-left flex center"> <image class="leftImg" src="#"></image> <view class="leftText-box"> <view class="box-text1">良品铺子官方旗舰店</view> <view class="tuike flex center"> <view class="pinpai">品牌自营</view> <view>推客专享</view> </view> </view> </view> <view class="title-right flex center jus-con"> <view class="right-text1">进店</view> <uni-icons type="right" size="14" color="#fff"></uni-icons> </view> </view> <view class="conBox-swiper"> <swiper class="swiper flex" circular :autoplay="autoplay" :interval="interval" :duration="duration" > <swiper-item class="swiper-item" v-for="item in 4"> <view class="item-inner"> <image src="#" class="inner-img"></image> <view class="inner-text flex column"> <view class="inner-top">【良品铺子】猪肉脯肉干高蛋白肉脯靖江特...</view> <view class="inner-bottom"> <view class="bottom-textBox1 flex center"> <view class="textBox1-money">¥</view> <view>39.90</view> </view> <view class="flex center"> <view class="bottom-textBox2">预估返</view> <view class="bottom-textBox3">¥3.20</view> </view> </view> </view> </view> </swiper-item> </swiper> </view> </view> </scroll-view> </view> </view> </view> </s-layout> </view> </template> <script setup> import { ref } from 'vue'; import SuTab from '../../sheep/ui/su-tab/su-tab.vue'; const headerImg = ref('/static/img/brand/header-bg.png'); const headerTitle = ref('/static/img/brand/header-title.png'); const headerSearch = ref('/static/img/brand/search.png'); const inputClearValue = ref(''); const showClearIcon = ref(false); const clearInput = (e) => { inputClearValue.value = e.detail.value; if (e.detail.value.length > 0) { showClearIcon.value = true; } else { showClearIcon.value = false; } }; const clearIcon = () => { inputClearValue.value = ''; showClearIcon.value = false; }; const searchInfoClick = () => { console.log('点击了搜索'); }; const currentNavIndex = ref(null); const mainNavTitle = ref([ { title: '全部', inline: true }, { title: '个护清洁', inline: false }, { title: '美食饮品', inline: false }, { title: '服装配饰', inline: false }, { title: '运动', inline: false }, ]); // 标签切换回调 const activeTab = ref(0); const handleTabChange = (e) => { console.log('选中标签索引:', e.index, '标签数据:', e.data); currentNavIndex.value = e.index; }; const handleScrollClick = () => { console.log('滚动'); }; const qiehuanNav = (val) => { mainNavTitle.value.forEach((item) => { item.inline = false; }); mainNavTitle.value[val].inline = true; }; </script> <style lang="scss" scoped> .outBox { width: 100%; height: 100vh; overflow: hidden; position: relative; .flex { display: flex; } .center { align-items: center; } .jus-con { justify-content: center; } .column { flex-direction: column; } :deep(.page-body) { width: 100%; height: 99.7vh; background: #230a00 !important; } .brand { height: 88.5vh; .brand-header { width: 750rpx; height: 800rpx; position: absolute; top: 0; left: 0; background-repeat: no-repeat; background-size: 100% 100%; .header-box1 { width: 424rpx; height: 190rpx; margin: 190rpx 162rpx 0 164rpx; .box1-img { width: 100%; height: 136rpx; object-fit: cover; } .box1-text { font-family: PingFang SC, PingFang SC; font-weight: 400; font-size: 32rpx; color: #fee4bf; text-align: left; font-style: normal; text-transform: none; margin-top: -30rpx; } } .main-search { width: 694rpx; height: 56rpx; border-radius: 36rpx; margin: 95rpx 28rpx 0; border: 1px solid #fee4bfb3; .search-icon { width: 36rpx; height: 36rpx; margin: 18rpx 0rpx 18rpx 42rpx; } .search-input { width: 62vw; height: 44rpx; font-family: PingFang SC, PingFang SC; font-weight: 400; font-size: 28rpx; color: #666666; text-align: left; font-style: normal; text-transform: none; margin: 0 16rpx; .uni-input { width: 100%; height: 100%; color: #baaf9f; } } .search-text { width: 136rpx; height: 100%; border-radius: 36rpx; background-color: #fff2e0; font-family: PingFang SC, PingFang SC; font-weight: 400; font-size: 28rpx; color: #ff9600; text-align: left; font-style: normal; text-transform: none; } } } .brand-main { position: absolute; top: 560rpx; left: 28rpx; // z-index: 1; height: 65vh; .main-nav { width: 95.4vw; height: 56rpx; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; :deep(.ui-tab.ui-tab-scrolls .ui-tab-scroll-warp .ui-tab-scroll) { line-height: 0 !important; } :deep(.ui-tab-item) { padding: 0rpx 1rpx !important; } :deep(.ui-tab-item .ui-tab-text) { margin-right: 16rpx; padding: 8rpx 24rpx; box-sizing: border-box; border-radius: 70rpx; background-color: #562c1599; font-family: PingFang SC, PingFang SC; font-weight: 400; font-size: 28rpx; color: #fee4bf; text-align: center; font-style: normal; text-transform: none; } // .inner-box { // margin-right: 16rpx; // padding: 8rpx 24rpx; // box-sizing: border-box; // border-radius: 70rpx; // margin-right: 16rpx; // background-color: #562c1599; // font-family: PingFang SC, PingFang SC; // font-weight: 400; // font-size: 28rpx; // color: #fee4bf; // text-align: center; // font-style: normal; // text-transform: none; // } // .innerBoxActive { // color: #ffffff; // background-color: #734c2f; // } } .main-content { margin-top: 20rpx; margin-bottom: 16rpx; height: 60vh; overflow-y: auto; .content-box { width: 694rpx; height: auto; border-radius: 32rpx; background-color: #fde3be; padding: 32rpx 0 32rpx 32rpx; box-sizing: border-box; margin-bottom: 32rpx; .conBox-title { margin-bottom: 30rpx; margin-right: 32rpx; justify-content: space-between; .title-left { .leftImg { width: 96rpx; height: 96rpx; object-fit: cover; border-radius: 50%; border: 1px solid red; margin-right: 8rpx; } .leftText-box { .box-text1 { font-family: PingFang SC, PingFang SC; font-weight: 500; font-size: 32rpx; color: #000000; text-align: center; font-style: normal; text-transform: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 300rpx; margin-bottom: 8rpx; } .tuike { font-family: PingFang SC, PingFang SC; font-weight: 400; font-size: 24rpx; color: #734c2f; text-align: center; font-style: normal; text-transform: none; .pinpai { margin-right: 8rpx; } } } } .title-right { width: 130rpx; height: 56rpx; border-radius: 28rpx; background: #734c2f; margin-top: 20rpx; .right-text1 { margin-right: 2rpx; margin-left: 10rpx; font-family: PingFang SC, PingFang SC; font-weight: 400; font-size: 28rpx; color: #ffffff; text-align: left; font-style: normal; text-transform: none; } } } .conBox-swiper { height: 372rpx; .swiper { height: 100%; overflow: hidden; .swiper-item { width: 236rpx !important; height: 100%; .item-inner { margin-right: 16rpx; width: 220rpx; height: 100%; border-radius: 16rpx; .inner-img { border-radius: 16rpx 16rpx 0 0; width: 220rpx; height: 220rpx; object-fit: cover; background-color: pink; } .inner-text { padding: 4rpx 12rpx 8rpx 10rpx; box-sizing: border-box; justify-content: space-between; background-color: #fff; margin-top: -8rpx; height: 142rpx; border-radius: 0 0 16rpx 16rpx; .inner-top { width: 100%; font-family: PingFang SC, PingFang SC; font-weight: 400; font-size: 20rpx; color: #333333; text-align: left; font-style: normal; text-transform: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } .inner-bottom { margin-top: 8rpx; .bottom-textBox1 { font-family: PingFang SC, PingFang SC; font-weight: 600; font-size: 20rpx; color: #f00403; text-align: left; font-style: normal; text-transform: none; .textBox1-money { margin-top: 5rpx; } } .bottom-textBox2 { padding: 4rpx; box-sizing: border-box; border-radius: 8rpx; background-color: #fe294c; font-family: PingFang SC, PingFang SC; font-weight: 500; font-size: 16rpx; color: #ffffff; text-align: left; font-style: normal; text-transform: none; } .bottom-textBox3 { width: 67rpx; height: 28rpx; background: #ffe5e9; border-radius: 8rpx; font-family: PingFang SC, PingFang SC; font-weight: 500; font-size: 20rpx; color: #fe294c; text-align: left; font-style: normal; text-transform: none; } } } } } } } } } } } } </style> 为什么中间的 SuTab的滚动为什么不生效vue3小程序uniapp
09-26
<template> <!-- 遮罩层:点击关闭 --> <view v-if="visible" class="modal-overlay" @click="handleOverlayClick"> <!-- 主体内容 --> <view class="modal-content" @click.stop> <!-- 第一部分:标题栏 --> <view class="modal-header"> <view class="title" >{{ title }} <uni-icons class="close-btn" type="close-outline" size="13" color="#999999" @tap="close" /> </view> </view> <!-- 第二部分:可滚动表格 --> <scroll-view class="table-container" scroll-y> <view v-for="(item, index) in tableData" :key="index" class="table-row"> <!-- 左侧文本 --> <view class="text-group"> <text class="text-primary">{{ item.userName }}</text> <text class="text-secondary">{{ item.orgName + '/' + item.areaName }}</text> </view> <!-- 复选 --> <view class="checkbox-group"> {{isClique}} <CrmSelectTag v-model="item.rulse.modelValue" :disabled="item.rulse.disabled" :disabledItems="item.rulse.disabledItems" :showCreateOpportunity="isClique" :show-create-opportunity="showOpportunity" :show-marketing-visit="showVisit" @change="crmSelectTagChangeFn($event, item.userId)" /> </view> <!-- 删除按钮 --> <uni-icons class="delete-btn" type="danchuangshanchu" size="13" color="#999999" @click="removeRow(item.userId)" /> </view> <!-- 继续添加 --> </scroll-view> <view class="add-more-btn" @click="$emit('addMore')"> <uni-icons class="add-more-btn-icon" type="tianjia" size="13" color="#0F56D5" /> <text>继续添加</text> </view> <view class="add-more-btn-bottom"> </view> <view class="item-wrap no-border"> <view class="item-left-wrap"> 共享原因 <uni-icons v-if="isMast()" color="#ff3141" class="star-img" :size="7" type="xinghao" /> </view> <view class="item-right-wrap" @touchstart="handleSound" @touchend="handleSoundEnd" @touchcancel="handleSoundEnd" ><uni-icons color="#0f56d5" :size="15" type="yuyin" /></view> </view> <view class="item-bottom-wrap"> <uni-easyinput v-model="channelTypeExplain" :maxlength="100" type="textarea" placeholder="请输入" :clearable="false" :inputBorder="false" trim :autoHeight="true" :disabled-default-padding="true" placeholderStyle="font-size: 15px; color: #ccc;" :cursorSpacing="30" @input="channelInput" > </uni-easyinput> <view class="text-count"> <view class="text-count-num"> {{ (channelTypeExplain && channelTypeExplain.length) || 0 }}/100 </view> </view> </view> <!-- 吸底按钮 --> <zy-sticky-bottom :z-index="'98'" :buttons="buttons" @click="onButtonClick" needBorder /> <!-- 语音组件 --> <!-- <zy-text-transspeech :soundTop="soundTop" :visible="showSoundPopup" @end="handleSoundEndSuccess"></zy-text-transspeech> --> </view> <zy-dialog ref="dialogRef" showPrimary :primaryText="dialogPrimaryText" :cancelText="dialogCancelText" :title="dialogTitle" @primary="dialogConfirm" @cancel="dialogCancel" /> </view> </template> <script setup> import { array } from '@/uni_modules/uview-plus/libs/function/test' import { ref } from 'vue' import CrmSelectTag from './CrmSelectTag.vue' const buttons = reactive([ { text: '取消', type: 'cancel' }, { text: '完成创建', type: 'confirm', loading: false // ✅ 提前定义 } ]) const onButtonClick = button => { if (button.text == '完成创建') { handleAddCustomer() } if (button.text == '取消') { handleOverlayClick() } } const crmSelectTagChangeFn = (selectedValue, userId) => { emit('change', userId, selectedValue) } const isMast = () => { const result = props.tableData.some(item => { // 先安全获取 rulse 对象 const disabled = item.rulse.disabled const values = item.rulse.modelValue const hasOne = item.rulse.disabledItems.includes(1) return !disabled && !hasOne && (values == 1 || values == 3) }) return result } const handleAddCustomer = () => { const result = props.tableData.some(item => { const values = item.rulse?.modelValue return values == 0 }) const allFalse = props.tableData.every(item => !item.rulse.isChange) let name = '' // 查找第一个 rulse.isChange 为 false 的项 const target = props.tableData.find(item => item.rulse?.isChange === false&&item.rulse?.modelValue != 3) if (target) { // 如果找到了任意一个 isChange 为 false 的项 name = target.userName } else { // 否则:找第一个 modelValue === 0 的项 const target = props.tableData.find(item => item.rulse?.modelValue === 0) if (target) { name = target.userName } else { name = '' // 或默认值 } } if (result || allFalse) { return uni.showToast({ title: `${name}未配置被共享权限`, icon: 'none' }) } if (isMast()) { if (!channelTypeExplain.value) { return uni.showToast({ title: '被共享权限包含创建商机时必须填写共享原因', icon: 'none' }) } else if (channelTypeExplain.value && channelTypeExplain.value.length > 100) { return uni.showToast({ title: '共享原因最多可填写100字符', icon: 'none' }) } } const hasItem = props.tableData.some(item => item.rulse.disabled === false && item.rulse.isChange === false) if (hasItem) return dialogTitleFn() emit('handleAddCustomer') } const dialogTitleFn = () => { dialogTitle.value = '存在没有勾选的权限的人,是否确认提交?' dialogRef.value.show() dialogConfirm.value = async () => { emit('handleAddCustomer') } } const dialogRef = ref() const dialogPrimaryText = ref('确定') const dialogCancelText = ref('取消') const dialogTitle = ref('') const dialogConfirm = ref(() => {}) const dialogCancel = ref(() => {}) const showOpportunity = ref(true) const showVisit = ref(true) // 语言组件高度 const soundTop = ref(0) const toggleShowOpportunity = e => (showOpportunity.value = e.detail.value) const toggleShowVisit = e => (showVisit.value = e.detail.value) // Props const props = defineProps({ title: { type: String, default: '添加被共享人' }, tableData: { type: Array, default: [] }, otherCloseFn: { type: Boolean, default: false }, isClique: { type: Boolean, default: false } }) const channelTypeExplain = ref('') /** 输入其他渠道类型 */ const channelInput = val => { channelTypeExplain.value = val emit('channelInput', channelTypeExplain.value) } const showSoundPopup = ref(false) const timeStap = ref(0) const handleSound = e => { // 直接从事件中取 Y 坐标 const clientY = e.touches[0]?.clientY || e.changedTouches[0]?.clientY timeStap.value = Date.now() soundTop.value = clientY // 直接赋值 showSoundPopup.value = true } /** 结束录音 */ const handleSoundEnd = () => { if (Date.now() - timeStap.value < 1000 && timeStap.value > 0) { uni.showToast({ title: '说话时间太短', icon: 'error' }) } setTimeout(() => { showSoundPopup.value = false }, 100) } /** 转换成功 */ const handleSoundEndSuccess = val => { if (val) { channelTypeExplain.value = val emit('channelInput', channelTypeExplain.value) } else { uni.showToast({ title: '说话时间太短', icon: 'error' }) } } // Emits const emit = defineEmits([ 'addMore', 'submit', 'inputChange', 'open', 'close', 'change', 'channelInput', 'handleAddCustomer' ]) // 内部状态 const visible = ref(false) const inputValue = ref('') // 👇 暴露给外部的方法 defineExpose({ open, close }) // 打开方法 function open() { visible.value = true emit('open') } // 关闭方法 function close(val) { if (val) return visible.value = false visible.value = false emit('close') } // 点击遮罩关闭 function handleOverlayClick() { if(props.otherCloseFn) return emit('close') close() } // 删除某一行 function removeRow(index) { emit('removeRow', index) } </script> <style lang="scss" scoped> /* 样式同前,保持不变 */ .modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background-color: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: flex-start; z-index: 9; } .modal-content { background-color: #fff; border-radius: 6px; width: 100%; max-height: 85vh; overflow: hidden; /* margin-bottom: 0; */ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15); display: block; flex-direction: column; position: fixed; bottom: 0; padding-bottom: calc(80px + env(safe-area-inset-bottom)); } .modal-header { display: flex; justify-content: center; align-items: center; padding: 12px; font-size: 17px; color: #333333; text-align: center; font-weight: 500; } .title { font-size: 16px; font-weight: bold; color: #333; width: 100%; } .close-btn { float: right; } .table-container { flex: 1; max-height: 35vh; min-height: 5vh; padding: 0 8px 0 16px; padding-right: 0px; box-sizing: border-box; margin-bottom: 10px; } .table-row { display: flex; align-items: center; border-bottom: 1px dashed #eee; height: 67.5px; padding-right: 8px; } .text-group { flex: 1; display: flex; flex-direction: column; } .text-primary { font-size: 15px; color: #333333; letter-spacing: 0; line-height: 14px; margin-bottom: 6px; } .text-secondary { font-size: 13px; color: #999999; letter-spacing: 0; line-height: 14px; } .checkbox-group { display: flex; flex-direction: column; margin-right: 10px; } .delete-btn { width: 30px; display: flex; justify-content: center; align-items: center; } .add-more-btn { padding: 10px; text-align: center; border-radius: 4px; // margin: 10px 0; height: 48px; box-sizing: border-box; } .add-more-btn text { color: #0f56d5; font-size: 14px; } .add-more-btn-icon { margin-right: 6px; } .input-section { padding: 10px 16px; position: relative; } .input-box { width: 100%; height: 60px; border: 1px solid #ddd; border-radius: 4px; padding: 10px; font-size: 14px; color: #333; box-sizing: border-box; } .char-count { position: absolute; right: 20px; bottom: 15px; font-size: 12px; color: #999; } .sticky-footer { padding: 10px 16px 20px; background-color: #fff; border-top: 1px solid #eee; } .bottom-button { width: 100%; background-color: #0f56d5; color: #fff; font-size: 15px; border-radius: 4px; padding: 10px 0; } .add-more-btn-bottom { width: 100%; height: 10px; background-color: #f5f5f5; } .item-wrap { height: 48px; display: flex; align-items: center; margin-left: 16px; padding-right: 16px; border-bottom: 0.5px solid #eeeeee; .item-left-wrap { flex: 1; display: flex; align-items: center; font-size: 15px; color: #666666; font-weight: 400; .star-img { margin-left: 4px; display: flex; align-items: center; } .tips-wrap { position: relative; .tips-img { margin-left: 8px; display: flex; align-items: center; } .tips-box { .top { position: absolute; left: 5px; bottom: -12px; width: 18px; height: 10px; z-index: 99; } .tips-content { position: absolute; top: 26px; left: -20px; min-width: 202px; padding: 16px; box-sizing: border-box; background: #ffffff; box-shadow: 0 2px 5px 0 rgba(51, 51, 51, 0.2); border-radius: 10px; font-size: 13px; color: #333333; font-weight: 400; z-index: 98; } } } } &:last-child { border-bottom: 0; } .item-right-wrap { display: flex; align-items: center; justify-content: flex-end; text { padding-right: 8px; font-size: 15px; color: #cccccc; text-align: right; font-weight: 400; } .tit-cur { color: #333333; } .block { display: flex; align-items: center; justify-content: center; padding: 8px 18px; margin-right: 8px; background: #f5f5f5; border-radius: 4px; font-size: 14px; color: #333333; line-height: 14px; font-weight: 400; &:last-child { margin-right: 0; } } .checked { background: #e3efff; } .custInput { width: calc(100% - 14px); color: #333; text-align: right; :deep(.content-clear-icon) { padding: 0; } } .custName-box { display: flex; align-items: center; justify-content: flex-end; width: calc(100% - 14px); height: 100%; top: 0; left: 0; color: #333; padding-left: 14px; .custName { margin-right: 0px; padding-right: 0px; } .custName-cur { color: #333333; } } .item-right-wrap-cur { display: flex; align-items: center; .img { margin-right: 5px; margin-bottom: 2px; } } .btn { margin-right: 0px; font-size: 14px; color: #0f56d5; text-align: right; font-weight: 400; } .select { padding-right: 0; } .add { margin-right: 5px; padding-right: 0; } } } .item-wrap-cur { height: 42px; } .no-border { border-bottom: 0; } .item-bottom-wrap { padding: 0 16px; :deep(.uni-easyinput__content-textarea) { height: 47px; min-height: 47px; margin-top: 0; margin-right: 0; } .text-count { height: 25px; padding-bottom: 13px; border-bottom: 0.5px solid #eeeeee !important; .text-count-num { font-size: 15px; color: #999999; text-align: right; font-weight: 400; } } } .item-bottom-wrap-cur { margin-left: 16px; padding: 0; padding-right: 16px; padding-bottom: 19px; border-bottom: 0.5px solid #eeeeee; .custInput { height: 20px; } } </style> <script lang="ts" setup> import isTablet from '@/utils/device' const props = defineProps({ disabled: { type: Boolean, default: false }, disabledItems: { type: Array, default: [] }, showCreateOpportunity: { type: Boolean, default: false }, showMarketingVisit: { type: Boolean, default: false }, modelValue: { type: Number, default: 0 } }) const emit = defineEmits<{ (e: 'update:modelValue', value: string | number): void (e: 'change', value: 0 | 1 | 2 | 3): void }>() const isIpad = isTablet() // 构建 list 数据 const list = computed(() => { const result = [] if (props.showCreateOpportunity) { console.log("🚀 ~ list ~ props.showCreateOpportunity:", props.showCreateOpportunity) result.push({ label: '创建商机', value: 1 }) } result.push({ label: '营销拜访', value: 2 }) return result }) // 当前选中状态(内部使用数组管理) const selectedValues = computed({ get: (): number[] => { const val = Number(props.modelValue) const arr: number[] = [] if (val & 1) arr.push(1) // 营销拜访 if (val & 2) arr.push(2) // 创建商机 return arr }, set: (vals: number[]) => { let numVal = 0 if (vals.includes(1)) numVal |= 1 if (vals.includes(2)) numVal |= 2 const strVal = String(numVal) emit('update:modelValue', strVal) emit('change', numVal as 0 | 1 | 2 | 3) } }) // 判断某项是否激活 const getActive = (itemValue: number) => { return selectedValues.value.includes(itemValue) } // 点击处理 const handleItem = (value: 1 | 2) => { if (props.disabled || props.disabledItems.includes(value)) return const current = selectedValues.value const index = current.indexOf(value) if (index > -1) { // 已选中 → 移除 selectedValues.value = current.filter(v => v !== value) } else { // 未选中 → 添加 selectedValues.value = [...current, value] } } </script> <template> <view class="CrmSelectTag-container" :class="{ 'CrmSelectTag-container-iPad': isIpad }" > <view v-for="item in list" :key="item.value" class="item" :class="{ active: getActive(item.value), disabled: disabled || disabledItems.includes(item.value) }" @click="handleItem(item.value)" > <text class="item-text">{{ item.label }}</text> <view class="active-icon" v-show="getActive(item.value)"> <uni-icons class="icon" type="check-outline" color="#fff" size="9" /> </view> </view> </view> </template> <style lang="scss" scoped> .CrmSelectTag-container { display: flex; flex-wrap: wrap; gap: 12px; .item { width: 90px; box-sizing: border-box; border: 1px solid transparent; background-color: $uni-separator-bg; border-radius: $uni-border-radius-sm; font-size: $uni-font-size-15; color: $uni-text-color; font-weight: 400; position: relative; } .item-text { display: block; width: 100%; text-align: center; padding: $uni-spacing-col-xs 4px; box-sizing: border-box; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; word-break: break-all; } .active { background-color: $uni-text-color-primary-light; color: $uni-primary; border-color: $uni-primary; } .disabled { // color: $uni-text-color-extra; opacity: 0.6; pointer-events: none; } .active-icon { position: absolute; bottom: -1px; right: -1px; width: 0; height: 0; border: 8px solid transparent; border-bottom-color: $uni-primary; border-right-color: $uni-primary; border-bottom-right-radius: $uni-border-radius-sm; .icon { position: absolute; right: -8px; bottom: -12px; } } } // iPad 适配 .CrmSelectTag-container-iPad { .item { width: 109px; // 固定宽度 } } </style> console.log("🚀 ~ list ~ props.showCreateOpportunity:", props.showCreateOpportunity)传入的是false,打印的是true
最新发布
11-07
<template> <div class="container"> <!-- 左侧Tab导航 --> <div class="tabs"> <div v-if="sections.length > 0" class="tabs-wrapper"> <div v-for="(section, index) in sections" :key="index" :class="['tab', { active: activeIndex === index }]" @click="scrollToSection(index)"> <div>{{ section.name }}</div> </div> </div> <div v-else class="empty-container"> <a-empty description="暂无分类" /> </div> </div> <!-- 右侧内容区域 --> <div class="content"> <!-- 粘性定位的表单 --> <a-form :model="searchForm" label-align="left" auto-label-width layout="inline" :size="'large'" class="search-header"> <a-form-item style="width: 320px;" field="base_title" label="能力名称:" size="large"> <a-input allow-clear v-model="searchForm.base_title" placeholder="搜索能力..." @press-enter="fetchTableData" @clear="resetSearch"> <template #prefix> <icon-search /> </template> </a-input> </a-form-item> <a-form-item> <a-space size='large'> <a-button type="primary" size="medium" @click="fetchTableData"> <template #icon><icon-search /></template>查询 </a-button> <a-button type="outline" size="medium" @click="resetSearch"> <template #icon><icon-refresh /></template>重置 </a-button> </a-space> </a-form-item> </a-form> <!-- 加载状态 --> <a-spin :loading="loading" style="width: 100%"> <!-- 使用锚点的章节 --> <div v-if="sections.length > 0" class="section-container" ref="contentRef" @scroll="onScroll"> <div v-for="(section, index) in sections" :key="index" :id="section.id" :ref="el => sectionRefs[index] = el" class="section"> <!-- 一级分类标题 --> <div class="section-title"> <icon-apps /> {{ section.name }} </div> <!-- 二级分类循环 --> <template v-for="(subSection, subIndex) in section.children" :key="subIndex"> <!-- 二级分类标题 --> <div class="title">{{ subSection.name }}</div> <!-- 三级分类内容 --> <div class="sub-content"> <div v-for="(item, itemIndex) in subSection.children" :key="itemIndex" class="content-item" @click="sceneDetail(item)"> <!-- 背景图片层 --> <div class="img-wrapper"> <img :src="item.image" alt="能力背景" /> </div> <!-- 内容卡片 --> <div class="item"> <div class="item-image"> <img v-if="item.image" :src="item.image" alt="能力图标" /> <div v-else class="image-placeholder"> <a-image width="100" height="100" src="some-error.png" /> </div> </div> <div class="item-text"> <div class="item-title">{{ item.title }}</div> <div class="item-desc">{{ item.description }}</div> </div> </div> </div> </div> </template> </div> </div> <div v-else class="empty-container"> <a-empty description="暂无能力数据" /> </div> </a-spin> </div> </div> </template> <script setup lang="ts"> import { ref, onMounted, nextTick, reactive } from 'vue'; import { IconSearch, IconApps, IconRefresh } from '@arco-design/web-vue/es/icon'; import { Message } from '@arco-design/web-vue'; import { IconImage } from '@arco-design/web-vue/es/icon'; import { useAbilityMallStore } from '@/store/modules/ability-mall'; import { storeToRefs } from 'pinia'; import { useRouter } from 'vue-router'; import { getAbilityMallList, getabilityMallDetails, createAbilityMall, } from '@/api/abilityMall'; const abilityMallStore = useAbilityMallStore(); const { abilityMallList, abilityMallDetails } = storeToRefs(abilityMallStore); const { getabilityMallDetailsStore } = abilityMallStore; const router = useRouter(); // 定义三级分类数据结构 interface CategoryItem { id: string; title: string; description: string; image: string; } interface SubCategory { id: string; name: string; children: CategoryItem[]; } interface MainCategory { id: string; name: string; children: SubCategory[]; } // 状态管理 // 存储各个section的DOM引用 const sectionRefs = ref([]); // 右侧滚动区域的引用 const contentRef = ref(null); // 记录当前选中的Tab索引 const activeIndex = ref(0); const loading = ref(false); const sections = ref([]); const searchForm = reactive({ base_title: '', }); // 更高效的数据转换函数 const transformData = (apiData: any[]): MainCategory[] => { const categoryMap = new Map<string, MainCategory>(); const subcategoryMap = new Map<string, SubCategory>(); apiData.forEach((item) => { const categoryName = item.base_category; const categoryId = categoryName.replace(/\s+/g, '-').toLowerCase(); // 处理一级分类 if (!categoryMap.has(categoryId)) { categoryMap.set(categoryId, { id: categoryId, name: categoryName, children: [], }); } const category = categoryMap.get(categoryId)!; // 处理二级分类 const subcategoryName = item.base_subcategory; const subcategoryId = `${categoryId}-${subcategoryName .replace(/\s+/g, '-') .toLowerCase()}`; if (!subcategoryMap.has(subcategoryId)) { const subcategory: SubCategory = { id: subcategoryId, name: subcategoryName, children: [], }; subcategoryMap.set(subcategoryId, subcategory); category.children.push(subcategory); } const subcategory = subcategoryMap.get(subcategoryId)!; // 添加三级分类项 subcategory.children.push({ id: item.id, title: item.base_title, description: item.base_content, image: item.base_image, // 添加图片字段 }); }); return Array.from(categoryMap.values()); }; // 滚动到指定章节 - 修复滚动位置计算 // 滚动到指定章节 - 修复滚动位置计算 const scrollToSection = (index) => { if (sectionRefs.value[index]) { // 直接使用section在容器中的偏移位置 const targetOffset = sectionRefs.value[index].offsetTop; contentRef.value.scrollTo({ top: targetOffset, behavior: 'smooth' }); } }; // 处理滚动事件 - 修复滚动位置判断逻辑 // 处理滚动事件 - 修复滚动位置判断逻辑 const onScroll = () => { const scrollTop = contentRef.value.scrollTop; const containerHeight = contentRef.value.clientHeight; // 修复最后两个section无法选中的关键逻辑 let currentActive = activeIndex.value; // 检查是否滚动到底部 const isAtBottom = scrollTop + containerHeight >= contentRef.value.scrollHeight - 5; if (isAtBottom && sectionRefs.value.length > 0) { // 滚动到底部时激活最后一个section currentActive = sectionRefs.value.length - 1; } else { // 遍历所有section找到当前激活的 for (let i = 0; i < sectionRefs.value.length; i++) { const section = sectionRefs.value[i]; const sectionTop = section.offsetTop; const sectionBottom = sectionTop + section.offsetHeight; // 当前section是否在视口内 if (scrollTop < sectionBottom && (i === sectionRefs.value.length - 1 || scrollTop < sectionRefs.value[i + 1].offsetTop)) { currentActive = i; break; } } } activeIndex.value = currentActive; }; // 重置搜索 const resetSearch = () => { searchForm.base_title = ''; fetchTableData(); }; // 获取数据 async function fetchTableData() { loading.value = true; try { const { data } = await getAbilityMallList(searchForm); const fakeData = data.filter((item) => item.deleted === 0); // const fakeData = Array.from({ length: 100 }, (_, index) => ({ // id: `item-${index}`, // base_category: `一级分类 ${Math.floor(Math.random() * 20)}`, // base_subcategory: `二级分类 ${Math.floor(Math.random() * 10)}`, // base_title: `能力名称 ${index + 1}`, // base_content: `描述内容 ${index + 1}`, // base_image: `https://via.placeholder.com/100?text=Image${index + 1}`, // deleted: Math.random() > 0.2 ? 0 : 1, // 80% chance of being valid // })); // 使用模拟数据 sections.value = transformData(fakeData || []); // 重置引用 nextTick(() => { sectionRefs.value = []; // 初始化滚动监听 setTimeout(() => { if (sections.value.length > 0) { scrollToSection(0); } }, 100); }); } catch (error) { console.error('获取能力模型失败:', error); Message.error('获取能力模型失败'); } finally { loading.value = false; } } // 跳转详情 const sceneDetail = async (item: CategoryItem) => { loading.value = true; await getabilityMallDetailsStore(item.id); // router.push(`/ability/details/`); router.push({ path: '/ability/details/', query: { id: item.id }, }); loading.value = false; }; // 生命周期钩子 onMounted(() => { fetchTableData(); }); </script> <style scoped> .container { display: flex; height: 100vh; position: relative; padding: 0; background: #fff; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; } /* 左侧导航栏样式 */ .tabs { width: 200px; padding: 20px 0; flex-shrink: 0; position: sticky; top: 0; max-height: 100vh; overflow-y: auto; z-index: 10; background: #f9fafb; border-right: 1px solid #e5e6eb; .tabs-wrapper { padding: 0 10px; } .tab { height: 44px; line-height: 44px; text-align: center; margin: 8px 0; font-size: 15px; color: #1d2129; cursor: pointer; position: relative; transition: all 0.3s ease; border-radius: 6px; overflow: hidden; font-weight: 500; &:hover { background: #f2f3f5; color: #3261CE; transform: translateX(3px); } } .tab.active { color: #3261CE; background: #e8f3ff; font-weight: 600; box-shadow: 0 1px 4px rgba(22, 93, 255, 0.15); &::before { content: ''; position: absolute; left: 0; top: 0; height: 100%; width: 3px; background: #3261CE; } } .empty-container { padding: 40px 20px; } } /* 右侧内容区域 */ .content { flex: 1; height: 100%; position: relative; padding: 0; overflow: hidden; display: flex; flex-direction: column; } /* 搜索头部样式 */ .search-header { width: 100%; display: flex; gap: 16px; padding: 15px 24px; background: #fff; border-bottom: 1px solid #e5e6eb; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03); position: sticky; top: 0; z-index: 20; .header-title { font-size: 20px; font-weight: 600; margin-right: 20px; color: #1d2129; } } /* 分类区域样式 - 关键修改 */ .section-container { flex: 1; overflow-y: auto; scroll-behavior: smooth; padding: 0 24px; position: relative; height: calc(100vh - 80px); /* 减去搜索栏高度 */ } .section { padding: 32px 0; border-bottom: 1px solid #e5e6eb; &:first-child { padding-top: 24px; } &:last-child { border-bottom: none; } } .section-title { font-size: 22px; color: #1d2129; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid #e5e6eb; font-weight: 600; display: flex; align-items: center; .arco-icon { margin-right: 10px; color: #3261CE; font-size: 20px; } } .title { font-size: 18px; color: #3261CE; margin: 24px 0 16px; padding-left: 12px; border-left: 4px solid #3261CE; font-weight: 500; } /* 内容项网格布局 */ .sub-content { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; margin-top: 8px; } /* 内容项样式 */ .content-item { position: relative; height: 95px; cursor: pointer; border-radius: 8px; overflow: hidden; box-shadow: 0 3px 6px rgba(0, 0, 0, 0.03); transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); background: #fff; border: 1px solid #e5e6eb; /* 背景图片容器 */ .img-wrapper { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; opacity: 0; transform: scale(1.05); transition: all 0.5s cubic-bezier(0.22, 0.61, 0.36, 1); img { width: 100%; height: 100%; object-fit: cover; filter: blur(0); transition: filter 0.5s ease; } } /* 悬停效果 */ &:hover { transform: translateY(-5px); box-shadow: 0 12px 25px rgba(22, 93, 255, 0.2); border-color: rgba(22, 93, 255, 0.3); .img-wrapper { opacity: 1; transform: scale(1); img { filter: blur(4px) brightness(0.9); } } .item { background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(4px); } .item-image img { transform: scale(1.8); } } } /* 内容卡片样式 */ .item { display: flex; position: relative; overflow: hidden; border-radius: 8px; width: 100%; height: 100%; z-index: 2; background: rgba(255, 255, 255, 0.95); transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); } /* 图片样式 */ .item-image { width: 100px; height: 100%; flex-shrink: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #f7f8fa; transition: background 0.3s ease; img { width: 60px; height: 60px; object-fit: contain; display: block; transition: transform 0.5s cubic-bezier(0.22, 0.61, 0.36, 1); } .image-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: #c9cdd4; .arco-icon { font-size: 32px; } } } /* 文本区域样式 */ .item-text { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; } .item-title { font-size: 16px; color: #1d2129; font-weight: 500; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color 0.3s ease; } .item-desc { font-size: 13px; color: #86909c; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; line-height: 1.5; transition: color 0.3s ease; } /* 响应式调整 */ @media (max-width: 992px) { .container { flex-direction: column; } .tabs { width: 100%; position: sticky; top: 0; z-index: 30; display: flex; overflow-x: auto; padding: 10px 0; height: auto; border-right: none; border-bottom: 1px solid #e5e6eb; .tabs-wrapper { display: flex; padding: 0 16px; } .tab { flex-shrink: 0; margin: 0 8px; padding: 0 16px; height: 36px; line-height: 36px; } } .content { margin-left: 0; } .search-header { padding: 12px 16px; flex-wrap: wrap; } .section-container { padding: 0 16px; height: calc(100vh - 140px); /* 调整移动端高度 */ } .section { padding: 24px 0; } } @media (max-width: 576px) { .sub-content { grid-template-columns: 1fr; } .header-title { display: none; } .search-header { :deep(.arco-form-item) { width: 100%; margin-bottom: 12px; } } .section-container { height: calc(100vh - 180px); /* 调整小屏幕高度 */ } .content-item { height: 110px; } .item-image { width: 80px; } } </style> 选不中最后两个
07-29
<template> <view class="content"> <view class="header"> <uni-easyinput class="uni-mt-5" suffixIcon="search" v-model="value" placeholder="请输入司机姓名" @input="iptChange"></uni-easyinput> <view class="zpcl"> <text @click="cancel">一键取消</text> <text @click="openPopup">指派车辆 {{car_num}}</text> </view> <text style="color:red;font-size: 24upx;">注意:列表中蓝色字体为有订单的司机</text> </view> <view class="main"> <scroll-view style="height: 100vh;" scroll-y="true" :refresher-enabled="true" :refresher-triggered="triggered" :refresher-threshold="200" refresher-background="#FFF" @refresherpulling="onPulling" @refresherrefresh="onRefresh" @refresherrestore="onRestore" @refresherabort="onAbort" ref="scrollView"> <view class="list" v-if="isShow"> <view class="list_item" v-for="(item,index) in listData" :key="index"> <view class="list_item_left"> <view :class="{'active':item.jdsl>0}"> <text class="name">{{item.name}}</text> <text class="plate">{{item.cph}}</text> <text >{{item._cylx}}</text> </view> </view> <view class="list_item_right"> <checkbox-group @change="checkChange($event,item)"> <label> <checkbox :value="item.sjid+'-'+item.clid" :checked="item.selected" :id="item.sjid" /> </label> </checkbox-group> </view> </view> <uni-load-more :status="status" :content-text="contentText" /> </view> <view class="empty" v-else> <image src="../../static/images/nodata.png" mode=""></image> <text v-if="isText">暂无数据</text> </view> </scroll-view> <view class="popupBox"> <uni-popup ref="popup" background-color="rgba(0,0,0,0)" :mask-click="false"> <view class="popup-content"> <view class="title"> <text>确认指派</text> </view> <view class="function_button"> <button @click="canel">取消</button> <button @click="$noMultipleClicks(sendCarSubmit)">确定</button> </view> </view> </uni-popup> </view> <view class="popupBox2"> <uni-popup ref="popup2" background-color="rgba(0,0,0,0)" style="padding: 0;" :mask-click="false"> <scroll-view :scroll-y="true"> <view class="popup-content"> <text class="title">司机已有订单,是否继续派车?</text> <text class="title" style="font-size: 24upx;">(蓝色字体为当前线路)</text> <view class="popupMain" v-for="(item,index) in sjOrderInfo" :key="index" > <view class="popupMain_top"> <view class="name"> <text>姓名:</text> <text>{{item._yssjid}}</text> </view> <view class="date"> <text>日期:</text> <text>{{item.cdate}}</text> </view> </view> <view class="popupMain_bottom"> <view :class=" [item.xlid == jxid? 'active' :''], xlName" > <text>线路名称:</text> <text>{{item.jxid}}</text> </view> </view> </view> <view class="function_button"> <button @click="orderCanel">取消</button> <!-- $noMultipleClicks 防止多次点击 --> <button @click="$noMultipleClicks(orderSubmit)">确定</button> </view> </view> </scroll-view> </uni-popup> </view> </view> </view> </template> <script> import request from "@/http/request.js" export default { data() { return { status: 'no-more', car_num: 0, contentText: { contentdown: '查看更多', contentrefresh: '加载中', contentnomore: '没有更多了' }, isShow: true, isText: true, value: '', qyid: "", pageNum: 1, pageRow: 30, listData: [], jxid: "", jxjhid: "", sjid: "", carid: "", sjName: "", // 模糊搜素 xlmc: "", // 传过来的线路名称 指派车辆弹窗用 name: "", // 司机姓名 指派车辆弹窗用 plate: "", // 车牌号 指派车辆弹窗用 carid_arr: [], sjid_arr: [], cph_arr:[], noClick: true, // 防抖 triggered:false, _freshing:false, sjOrderInfo:[], changeSjid:"", // 选择的司机id changeClid:"", // 选择的车辆id changeCph:"", // 选中的车牌号 changeItem:false, // 点击勾选时的值 color:"1px solid red", num:0, acceptance:"", } }, onLoad(options) { console.log(options) this.jxid = options.jxid; this.jxjhid = options.jxjhId; this.num = options.num; this.xlmc = options.xlmc; this.acceptance = options.acceptance this.qyid = uni.getStorageSync("zcxx").qyid; uni.showLoading({ title: "加载中..." }); setTimeout(() => { uni.hideLoading(); this.getData(this.sjName); }, 1000) }, // onReachBottom() { // this.status = "loading"; // this.pageNum++; // this.getData(this.sjName, this.pageNum, this.pageRow) // console.log("page++") // }, methods: { timestampToTime(timestamp) { // 时间戳为10位需*1000,时间戳为13位不需乘1000 var date = new Date(timestamp); var Y = date.getFullYear() + "-"; var M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-"; var D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " "; var h = date.getHours()<10? "0" + date.getHours() + ":" :date.getHours()+":"; var m = date.getMinutes()<10? "0" + date.getMinutes() + ":" :date.getMinutes()+":"; var s = (date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds()) + " "; return Y + M + D + h + m + s; }, onPulling(e) { console.log("onpulling", e); if (e.detail.deltaY < 0) return // 防止上滑页面也触发下拉 this.triggered = true; }, onRefresh() { console.log("9999") if (this._freshing) return; this._freshing = true; setTimeout(() => { this.getData(this.sjName); this.carid_arr = []; this.sjid_arr = []; this.cph_arr = []; this.car_num = 0; uni.showToast({ title: "刷新成功!", icon: "success" }) }, 3000) }, // 自定义下拉刷新被复位 onRestore() { // this.triggered = 'restore'; // 需要重置 this.triggered = false; console.log("onRestore"); }, onAbort() { console.log("onAbort"); }, clickLoadMore(e) { uni.showToast({ icon: 'none', title: "当前状态:" + e.detail.status }) }, // 模糊查询 iptChange(value) { this.sjName = value this.pageNum = 1 this.listData = [] this.getData(this.sjName) }, // 获取派车列表数据 getData(sjName) { let cdzid = uni.getStorageSync("zcxx").id; let cylx = uni.getStorageSync("user")[0].cylx; request.vsportal('XcxCdzAction.zpCarList', { qyid: this.qyid, sj:"", cdzid:cdzid, jxid:this.jxid, cph:"", cylx:cylx, value:sjName }).then((res) => { if(res.status){ this.triggered = false; this.listData = res.data; this.listData.forEach((item,index) =>{ this.$set(item,'selected',false) }) }else{ this.isShow = false; uni.showToast({ title:"数据请求失败!", icon:"error" }) } }) }, // 确定派车 sendCarSubmit() { var that = this; console.log(this.num) console.log(this.car_num) if (this.num < this.car_num) { uni.showToast({ title: "最多允许指派"+this.num+"车!", icon: "none" }) } else { that.$refs.popup.close(); uni.showLoading({ title: "正在派车!" }) setTimeout(() => { request.vsportal('XcxCdzAction.zpcl', { qyid: this.qyid, jxid: this.jxid, jxjhid: this.jxjhid, clids: this.carid_arr, sjids: this.sjid_arr, cphs:this.cph_arr }).then((res) => { if (res.status) { uni.hideLoading() if(res.status && res.data == true){ uni.showToast({ title: "派车成功!", icon: "success", success() { // 派车成功则取消所有已选择的车辆 且 清空 车辆id 司机id数组 for (let i = 0; i < that.listData.length; i++) { that.listData[i].selected = false } that.carid_arr = []; that.sjid_arr = []; that.cph_arr = []; that.car_num = 0; setTimeout(() =>{ uni.navigateBack({ delta: 1, // 返回的页面数 success() { uni.$emit('update', { msg: '页面更新' }); } }); },300) } }) } } else { uni.showToast({ title: "派车失败!", icon: "error" }) } }) }, 1500) } }, // 弹窗取消按钮 canel() { this.$refs.popup.close() }, // 选择 checkChange(e, data) { let that = this; if(that.acceptance.includes('新能源车')){ if(data.energy == '2EECACJ5'){ uni.showModal({ title: '提示', content: '该线路只允许新能源车辆', showCancel: false, success: function (res) { if (res.confirm) { data.selected = false that.$forceUpdate() } else if (res.cancel) { } } }); console.log(data,'----') return } } that.changeItem = !data.selected; data.selected = !data.selected; that.changeSjid = data.sjid; that.changeClid = data.clid; that.changeCph = data.cph; if (e.detail.value.length > 0) { // 选中 且 当前选择的车辆是第一次选择 即不在 carid_arr 和 sjid_arr中 if (data.selected && !this.carid_arr.includes(data.clid) && !this.sjid_arr.includes(data.sjid)) { request.vsportal('XcxCdzAction.sjwwc', { sjids: data.sjid, jxjhid:this.jxjhid, clid:data.clid, cph:data.cph }).then((res) => { console.log(res) if (res.status && res.data.length>0) { for(let i=0;i<res.data.length;i++){ res.data[i].cdate = this.timestampToTime(res.data[i].cdate); } this.$refs.popup2.open('center'); this.sjOrderInfo = res.data; }else if(res.status && res.data.zt == false){ console.log("000") uni.showToast({ title: res.data.message, icon: "error", duration: 2000 // 增加显示时间 }) data.selected = false; this.$set(data,'selected',false) }else if(res.status && res.data.length == 0){ that.carid_arr.push(data.clid); that.sjid_arr.push(data.sjid); that.cph_arr.push(data.cph) this.car_num = this.carid_arr.length } // { // // uni.showToast({ // // title: "司机有订单!", // // icon: "error" // // }) // // that.carid_arr = that.carid_arr.filter(item => item !== data.clid); // // that.sjid_arr = that.sjid_arr.filter(item => item !== data.sjid); // // data.selected = false; // // this.car_num = this.carid_arr.length // } }) } else { console.log("错误") } } else { // console.log("0000") if (!data.selected && this.carid_arr.includes(data.clid) && this.sjid_arr.includes(data.sjid)) { this.carid_arr.push(data.clid); this.sjid_arr.push(data.sjid) this.carid_arr = this.carid_arr.filter(item => item !== data.clid); this.sjid_arr = this.sjid_arr.filter(item => item !== data.sjid); console.log("车辆id" + this.carid_arr) console.log("司机id" + this.carid_arr) } else { console.log("错误") } this.car_num = this.carid_arr.length } }, // 司机订单信息弹窗 取消按钮 orderCanel(){ this.$refs.popup2.close(); for (let i = 0; i < this.listData.length; i++) { if(this.listData[i].sjid == this.changeSjid){ console.log("09") // this.listData[i].selected = false; this.$set(this.listData[i],'selected',false) } } }, // 司机订单信息弹窗 确定按钮 orderSubmit(){ this.$refs.popup2.close(); this.carid_arr.push(this.changeClid); this.sjid_arr.push(this.changeSjid); this.cph_arr.push(this.changeCph); this.car_num = this.carid_arr.length }, // 一键取消 cancel() { for (let i = 0; i < this.listData.length; i++) { this.listData[i].selected = false } this.carid_arr = []; this.sjid_arr = []; this.cph_arr = []; this.car_num = 0 }, // 指派车辆 openPopup() { if (this.carid_arr.length > 0) { this.$refs.popup.open('center'); } else { uni.showToast({ title: "请至少选择一辆", icon: "error" }) } }, // change(e) { // console.log('当前模式:' + e.type + ',状态:' + e.show); // }, } } </script> <style lang="scss"> .active{ color:blue; } .active2{ color:red; font-weight: bold; } .content { padding: 32upx; .header { padding: 20upx 32upx; position: fixed; top: 0; left: 0; right: 0; z-index: 999; background-color: #fff; .zpcl { width: 100%; margin-top: 20upx; box-sizing: border-box; // padding-right: 62upx; display: flex; justify-content: space-between; z-index: 99; text { display: block; text-align: center; font-size: 30upx; width: 280upx; height: 60upx; line-height: 60upx; border-radius: 12upx; background-color: #2257FF; color: #FFFFFF; // border-radius: 50upx; } text:nth-child(1) { border: 1px solid #2257FF; color: #2257FF; background-color: #fff; } } } .main { margin-top: 200upx; height: 100%; .list{ position: relative; } .list_item { display: flex; justify-content: space-between; line-height: 70upx; border-bottom: 1px solid #ddd; .list_item_left { position: relative; display: flex; align-items: center; text { display: inline-block; width: 150upx; overflow: hidden; white-space: normal; text-overflow: ellipsis; margin-right: 30upx; font-size: 28upx; // color: #333333; } .plate::after { content: ''; width: 1px; height: 30upx; background-color: #ddd; position: absolute; top: 25upx; right: 39%; } text:nth-child(3) { font-size: 28upx; // color: #666666; } .name { width: 120upx; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } } .list_item_right { text { font-size: 24upx; color: #2257FF; } } } .empty { display: block; width: 518upx; height: 518upx; margin-left: 50%; margin-top: 80%; transform: translate(-50%, -50%); image { display: block; width: 100%; height: 518upx; } text { display: block; width: 400upx; text-align: center; margin: 0 auto; font-size: 24upx; color: #666666; } } .popupBox{ .popup-content { width: 586upx; height: 300upx; background-color: #fff; display: flex; flex-direction: column; justify-content: space-evenly; border-radius: 28upx; padding: 52upx; box-sizing: border-box; .title { text-align: center; text { font-size: 34upx; color: #333333; font-weight: bold; } } .sendCarInfo { display: flex; flex-direction: column; justify-content: center; align-items: center; flex-wrap: nowrap; text { font-size: 34upx; font-weight: bold; color: #333333; } text:nth-child(2) { font-weight: normal; } text:nth-child(3) { font-weight: normal; display: inline-block; margin-left: 10upx; } } .function_button { margin-top: 60upx; display: flex; // justify-content: space-between; // border: 1px solid red; button { display: block; width: 200upx; height: 60upx; line-height: 60upx; border: 1px solid #2257FF; background-color: #fff; color: #2257FF; outline: none; font-size: 28upx; } :nth-child(2) { background-color: #2257FF; color: #fff; } } } } .popupBox2{ .popup-content { width: 586upx; height: 900upx; background-color: #fff; overflow: auto; // display: flex; // flex-direction: column; // justify-content: space-evenly; border-radius: 28upx; padding:30upx ; // box-sizing: border-box; .title{ display: inline-block; width: 100%; text-align: center; font-size: 34upx; margin-bottom: 30upx; color: #ff4120; } .popupMain{ border: 1px solid #ddd; padding: 30upx; border-radius: 16upx; margin-bottom: 15upx; } .popupMain_top{ // display: flex; // justify-content: space-between; } .title { text-align: center; text { font-size: 34upx; color: #333333; font-weight: bold; } } .sendCarInfo { display: flex; flex-direction: column; justify-content: center; align-items: center; flex-wrap: nowrap; text { font-size: 34upx; font-weight: bold; color: #333333; } text:nth-child(2) { font-weight: normal; } text:nth-child(3) { font-weight: normal; display: inline-block; margin-left: 10upx; } } .function_button { margin-top: 60upx; display: flex; // justify-content: space-between; // border: 1px solid red; button { display: block; width: 200upx; height: 60upx; line-height: 60upx; border: 1px solid #2257FF; background-color: #fff; color: #2257FF; outline: none; font-size: 28upx; } :nth-child(2) { background-color: #2257FF; color: #fff; } } } } } } </style>整体代码优化重新写一下
09-30
<el-dialog :title="title" :visible.sync="open" width="1300px" :modal="false" append-to-body> <el-form ref="form" :model="form" :rules="rules" label-width="120px" > <!-- 第一行字段 --> <el-row :gutter="50"> <el-col :span="8"> <el-form-item label="工厂代号" prop="plantNo"> <el-input v-model="form.plantNo" placeholder="请输入工厂代号" /> </el-form-item> <el-form-item label="工厂名称" prop="plantName"> <el-input v-model="form.plantName" placeholder="请输入工厂名称" /> </el-form-item> <el-form-item label="产品描述" prop="plantName"> <el-input v-model="form.plantName" placeholder="请输入产品描述" /> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="router版本" prop="routerVersion"> <el-select v-model="form.routerVersion" placeholder="请输入router版本" > <el-option v-for="dict in dict.type.router_version" :key="dict.value" :label="dict.label" :value="dict.value" /> </el-select> </el-form-item> <el-form-item label="产品料号" prop="partNo"> <el-input v-model="form.partNo" placeholder="请输入产品料号" /> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="旧型号" prop="plantName"> <el-input v-model="form.plantName" placeholder="请输入工厂名称" /> </el-form-item> <el-form-item label="新型号" prop="plantName"> <el-input v-model="form.plantName" placeholder="请输入工厂名称" /> </el-form-item> </el-col> </el-row> <!-- 第二行字段 --> <!-- 工序列表动态生成 --> <!-- 表头行 --> <el-row :gutter="50" class="header-row"> <el-col :span="2">名称</el-col> <el-col :span="2">英文名</el-col> <el-col :span="4">流程卡内容</el-col> <el-col :span="2">等待(h)</el-col> <el-col :span="2">运行(H)</el-col> <el-col :span="2">set_up</el-col> <el-col :span="2">人工</el-col> <el-col :span="2">单位</el-col> <el-col :span="2">数量</el-col> <el-col :span="2">状况</el-col> <el-col :span="2">代码</el-col> <el-col :span="2">操作</el-col> </el-row> <!-- 数据行循环 --> <div v-for="(process, index) in formData.processes" :key="index" class="process-row"> <el-row :gutter="50"> <!-- 工序名称 --> <el-col :span="2"> <el-form-item :prop="`processes.${index}.processName`" :rules="rules.processName"> <el-input v-model="process.processName" placeholder="工序名称" /> </el-form-item> </el-col> <!-- 英语名称 --> <el-col :span="2"> <el-form-item :prop="`processes.${index}.englishName`" :rules="rules.englishName"> <el-input v-model="process.englishName" placeholder="English Name" /> </el-form-item> </el-col> <!-- 流程卡内容 --> <el-col :span="4"> <el-form-item> <el-input v-model="process.cardContent" type="textarea" :autosize="{ minRows: 1, maxRows: 3}" /> </el-form-item> </el-col> <!-- 时间参数组:拆分成4个字段 --> <!-- 等待(h) --> <el-col :span="2"> <el-form-item :prop="`processes.${index}.processWatitime`"> <el-input v-model="process.processWatitime" /> </el-form-item> </el-col> <!-- 运行(H) --> <el-col :span="2"> <el-form-item :prop="`processes.${index}.machineRuntime`"> <el-input v-model="process.machineRuntime" /> </el-form-item> </el-col> <!-- set_up --> <el-col :span="2"> <el-form-item> <el-input v-model="process.setuptime" placeholder="min/pcs" /> </el-form-item> </el-col> <!-- 人工 --> <el-col :span="2"> <el-form-item> <el-input v-model="process.labortime" placeholder="min/pcs" /> </el-form-item> </el-col> <!-- 单位/数量:拆分成两个字段 --> <!-- 单位 --> <el-col :span="2"> <el-form-item> <el-input v-model="process.routerUnit" /> </el-form-item> </el-col> <!-- 数量 --> <el-col :span="2"> <el-form-item> <el-input v-model="process.quantity" /> </el-form-item> </el-col> <!-- 状态/代码:拆分成两个字段 --> <!-- 状况 --> <el-col :span="2"> <el-form-item> <el-select v-model="process.routerStatus" placeholder="状态"> <el-option v-for="dict in dict.type.router_status" :key="dict.value" :label="dict.label" :value="dict.value" /> </el-select> </el-form-item> </el-col> <!-- 代码 --> <el-col :span="2"> <el-form-item> <el-input v-model="process.processCode" /> </el-form-item> </el-col> <!-- 操作按钮 --> <el-col :span="2"> <el-button type="danger" icon="el-icon-delete" circle @click="removeProcess(index)" /> </el-col> </el-row> </div> </el-form>循环生成部分,标题有换行,数据显示布局不对,跟标题也不对应,数据无法显示,数据显示超出form
09-28
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值