ljlong_2630
3 months ago
4 changed files with 387 additions and 268 deletions
@ -1,276 +1,376 @@ |
|||||
<template> |
<template> |
||||
<!-- 选择备件 --> |
<!-- 选择备件 --> |
||||
<u-popup v-model="props.isShowSelectItem" mode="center" border-radius="14"> |
<u-popup v-model="props.isShowSelectItem" mode="center" border-radius="14"> |
||||
<view class="popup-title">选择备件</view> |
<view class="popup-title">选择备件</view> |
||||
<view class="popup"> |
<view class="popup"> |
||||
<!-- <input v-model="searchKeyword" @input="filterItems" placeholder="搜索备件名称"> --> |
<u-search placeholder="搜索" v-model="form1.searchName" @change="searchItem" clearabled=false></u-search> |
||||
<u-search placeholder="搜索" v-model="form1.searchName" @change="searchItem" clearabled=false></u-search> |
<view class="list"> |
||||
<!-- <u-input v-model="form1.searchName" placeholder="请输入备件名称" @change="searchItem"/> |
<view class="item" v-for="(item, index) in singleColumnList" :key="index" @click="chooseItem(item)"> |
||||
<u-button>搜索</u-button> --> |
<u-checkbox v-model="item.checked" shape="circle" style="margin-top: 8rpx;"></u-checkbox> |
||||
<view class="list"> |
<view class="right"> |
||||
<view class="item" v-for="(item,index) in singleColumnList" :key="index" @click="chooseItem(item)"> |
<view class="item-name"> |
||||
<u-checkbox v-model="item.checked" shape="circle" style="margin-top: 8rpx;"></u-checkbox> |
名称: <span>{{ item.name }}</span> |
||||
<view class="right"> |
</view> |
||||
<view class="item-name"> |
<view class="item-dec"> |
||||
名称: <span>{{item.name}}</span> |
型号: <span>{{ item.specifications }}</span> |
||||
</view> |
</view> |
||||
<view class="item-dec"> |
<view class="item-dec"> |
||||
型号: <span>{{item.specifications}}</span> |
编码: <span>{{ item.number }}</span> |
||||
</view> |
</view> |
||||
<view class="item-dec"> |
<view class="item-dec" style="display: flex;"> |
||||
编码: <span>{{item.number}}</span> |
<span style="white-space: nowrap; align-self: flex-start;">图片:</span> |
||||
</view> |
<div style="display: flex; flex-direction: column; margin-left: 10px;"> |
||||
</view> |
<span |
||||
</view> |
v-for="(pic, picIndex) in item.picture" |
||||
</view> |
:key="picIndex" |
||||
</view> |
@click.stop="showImage(pic.path)" |
||||
<view class="popup-footer"> |
@longpress.stop="showFullText(pic.name)" |
||||
<view @click="chooseItem1(0)">取消</view> |
class="image-link" |
||||
<view class="sure" @click="chooseItem1(1)">确认</view> |
> |
||||
</view> |
{{ pic.name }} |
||||
</u-popup> |
</span> |
||||
|
</div> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="popup-footer"> |
||||
|
<view @click="chooseItem1(0)">取消</view> |
||||
|
<view class="sure" @click="chooseItem1(1)">确认</view> |
||||
|
</view> |
||||
|
</u-popup> |
||||
|
|
||||
|
<!-- 全屏图片弹窗 --> |
||||
|
<u-popup v-model="isImagePopupVisible" mode="center" border-radius="0"> |
||||
|
<view class="image-popup"> |
||||
|
<view class="close-btn" @click="closeImagePopup">X</view> |
||||
|
<img :src="currentImagePath" class="full-image" /> |
||||
|
</view> |
||||
|
</u-popup> |
||||
|
|
||||
|
<!-- 长按显示完整内容的浮窗 --> |
||||
|
<div v-if="showTooltip" class="tooltip" :style="{ top: tooltipPosition.top, left: tooltipPosition.left }"> |
||||
|
{{ tooltipContent }} |
||||
|
</div> |
||||
</template> |
</template> |
||||
|
|
||||
<script setup lang="ts"> |
<script setup lang="ts"> |
||||
import { |
import { ref, defineProps, defineEmits, getCurrentInstance, watch } from 'vue'; |
||||
ref, |
import { onLoad } from '@dcloudio/uni-app'; |
||||
defineProps, |
import * as repairOrderApi from "@/api/repairOrder"; |
||||
defineEmits, |
|
||||
getCurrentInstance, |
const props = defineProps({ |
||||
watch |
isShowSelectItem: { |
||||
} from 'vue' |
type: Boolean, |
||||
import { |
default: () => { return false }, |
||||
onLoad, |
require: true |
||||
} from '@dcloudio/uni-app' |
}, |
||||
import * as repairOrderApi from "@/api/repairOrder" |
singleColumnList: { |
||||
|
type: Array, |
||||
const props = defineProps({ |
default: () => { return [] }, |
||||
isShowSelectItem: { |
require: false |
||||
type: Boolean, |
}, |
||||
default: () => { return false }, |
}); |
||||
require: true |
|
||||
}, |
// 监测isShowSelectItem的变化 |
||||
singleColumnList:{ |
watch(() => props.isShowSelectItem, (newValue, oldValue) => { |
||||
type: Array, |
if (newValue) { |
||||
default: () => { return [] }, |
console.log('props.isShowSelectItem', props.isShowSelectItem); |
||||
require: false |
form1.value.searchName = null; |
||||
}, |
form1.value.temporarilyNumber = null; |
||||
}); |
form1.value.temporarilyName = null; |
||||
|
} |
||||
// 监测isShowSelectItem的变化 |
}); |
||||
watch(() => props.isShowSelectItem, (newValue, oldValue) => { |
|
||||
if(newValue){ |
const { proxy } = getCurrentInstance(); |
||||
console.log('props.isShowSelectItem',props.isShowSelectItem); |
const repairOrderList = ref([]); |
||||
form1.value.searchName = null |
const itemList = ref([]); |
||||
form1.value.temporarilyNumber = null |
const type = ref(''); |
||||
form1.value.temporarilyName = null |
const isShowSelectItem = ref(false); |
||||
} |
const selectVal = ref(null); |
||||
}); |
const emits = defineEmits(['searchItem', 'chooseItem1']); |
||||
const { proxy } = getCurrentInstance() |
const form1 = ref({ |
||||
|
number: "", |
||||
const repairOrderList = ref([]) |
name: "", |
||||
|
specifications: "", |
||||
const itemList = ref([]) |
qty: 0, |
||||
const type = ref('') |
temporarilyNumber: "", |
||||
const isShowSelectItem = ref(false); |
temporarilyName: "", |
||||
const selectVal = ref(null); |
temporarilySpecifications: "", |
||||
const emits = defineEmits(['searchItem','chooseItem1']); |
searchName: "", |
||||
const form1 = ref({ |
}); |
||||
number: "", |
|
||||
name:"", |
// 管理全屏图片弹窗的状态 |
||||
specifications:"", |
const isImagePopupVisible = ref(false); |
||||
qty: 0, |
const currentImagePath = ref(''); |
||||
temporarilyNumber:"",//;临时选中的编码 |
|
||||
temporarilyName:"",//临时选中的名称 |
// 管理浮窗的状态 |
||||
temporarilySpecifications:"",//临时选中的型号 |
const showTooltip = ref(false); |
||||
searchName:"",//模糊搜索 |
const tooltipContent = ref(''); |
||||
}) |
const tooltipPosition = ref({ top: '0px', left: '0px' }); |
||||
onLoad((option) => { |
|
||||
if (option.type) type.value = option.type; |
// 打开全屏图片弹窗 |
||||
if (option.type) isShowSelectItem.value = option.isShowSelectItem;//是否显示 |
function showImage(path) { |
||||
if (option.selectVal) selectVal.value = option.selectVal;//是否显示 |
currentImagePath.value = path; |
||||
}) |
isImagePopupVisible.value = true; |
||||
//取消和确认方法 |
} |
||||
function chooseItem1(type){ |
|
||||
if(type==1){ |
// 关闭全屏图片弹窗 |
||||
form1.value.number = form1.value.temporarilyNumber |
function closeImagePopup() { |
||||
form1.value.name = form1.value.temporarilyName |
isImagePopupVisible.value = false; |
||||
form1.value.specifications = form1.value.temporarilySpecifications |
} |
||||
} |
|
||||
emits('chooseItem1',type,form1); |
// 显示完整内容的浮窗 |
||||
} |
function showFullText(text) { |
||||
function searchItem(){ |
tooltipContent.value = text; |
||||
emits('searchItem',form1.value.searchName); |
showTooltip.value = true; |
||||
} |
// 设置浮窗位置(这里可以根据需求设置具体位置) |
||||
function chooseItem(item){ |
tooltipPosition.value = { top: '50px', left: '50px' }; |
||||
console.log('props.isShowSelectItem',props.isShowSelectItem); |
} |
||||
console.log('props.singleColumnList',props.singleColumnList); |
|
||||
let arr = props.singleColumnList.filter(cur=>cur.number != item.number) |
onLoad((option) => { |
||||
arr.forEach(item=>{ |
if (option.type) type.value = option.type; |
||||
item.checked = false |
if (option.type) isShowSelectItem.value = option.isShowSelectItem; |
||||
}) |
if (option.selectVal) selectVal.value = option.selectVal; |
||||
item.checked = !item.checked |
}); |
||||
let arr1 = props.singleColumnList.filter(cur=>cur.number == item.number) |
|
||||
form1.value.temporarilyNumber = arr1[0].number; |
// 取消和确认方法 |
||||
form1.value.temporarilyName = arr1[0].name; |
function chooseItem1(type) { |
||||
form1.value.temporarilySpecifications = arr1[0].specifications; |
if (type == 1) { |
||||
} |
form1.value.number = form1.value.temporarilyNumber; |
||||
|
form1.value.name = form1.value.temporarilyName; |
||||
|
form1.value.specifications = form1.value.temporarilySpecifications; |
||||
|
} |
||||
|
emits('chooseItem1', type, form1); |
||||
|
} |
||||
|
|
||||
|
function searchItem() { |
||||
|
emits('searchItem', form1.value.searchName); |
||||
|
} |
||||
|
|
||||
|
function chooseItem(item) { |
||||
|
console.log('props.isShowSelectItem', props.isShowSelectItem); |
||||
|
console.log('props.singleColumnList', props.singleColumnList); |
||||
|
let arr = props.singleColumnList.filter(cur => cur.number != item.number); |
||||
|
arr.forEach(item => { |
||||
|
item.checked = false; |
||||
|
}); |
||||
|
item.checked = !item.checked; |
||||
|
let arr1 = props.singleColumnList.filter(cur => cur.number == item.number); |
||||
|
form1.value.temporarilyNumber = arr1[0].number; |
||||
|
form1.value.temporarilyName = arr1[0].name; |
||||
|
form1.value.temporarilySpecifications = arr1[0].specifications; |
||||
|
} |
||||
</script> |
</script> |
||||
|
|
||||
<style lang="scss" scoped> |
<style lang="scss" scoped> |
||||
.add-form-container { |
.add-form-container { |
||||
min-height: calc(100vh - 140rpx); |
min-height: calc(100vh - 140rpx); |
||||
background: white; |
background: white; |
||||
padding: 0px 30rpx 140rpx; |
padding: 0px 30rpx 140rpx; |
||||
} |
} |
||||
|
|
||||
|
.footer { |
||||
.footer { |
position: fixed; |
||||
position: fixed; |
bottom: 0px; |
||||
bottom: 0px; |
left: 0px; |
||||
left: 0px; |
width: 100%; |
||||
width: 100%; |
z-index: 22; |
||||
z-index: 22; |
} |
||||
} |
|
||||
|
.btns { |
||||
.btns { |
display: flex; |
||||
display: flex; |
button { |
||||
|
flex: 1; |
||||
|
|
||||
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; |
|
||||
} |
|
||||
} |
|
||||
} |
} |
||||
|
.sure { |
||||
.right-button { |
|
||||
background: #409eff; |
background: #409eff; |
||||
color: white; |
color: white; |
||||
padding: 0rpx 30rpx; |
border-radius: 0px; |
||||
border-radius: 16rpx; |
&::after { |
||||
text-align: center; |
border: 1px solid #409eff; |
||||
font-size: 28rpx; |
border-radius: 0px; |
||||
} |
|
||||
|
|
||||
.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; |
|
||||
} |
} |
||||
} |
} |
||||
|
.reset { |
||||
.list { |
background: #F5F5F5; |
||||
.item { |
border-radius: 0px; |
||||
display: flex; |
&::after { |
||||
margin-bottom: 20rpx; |
border-radius: 0px; |
||||
|
|
||||
.item-box { |
|
||||
background: #F5F5F5; |
|
||||
border-radius: 12rpx; |
|
||||
flex: 1; |
|
||||
width: 0rpx; |
|
||||
} |
|
||||
|
|
||||
.spare-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; |
.right-button { |
||||
justify-content: flex-start; |
background: #409eff; |
||||
align-items: center; |
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 { |
||||
.popup-title { |
flex: 1; |
||||
text-align: center; |
font-size: 28rpx; |
||||
font-size: 32rpx; |
color: rgb(192, 196, 204); |
||||
font-weight: bold; |
|
||||
color: #409eff; |
|
||||
padding: 30rpx 30rpx 0px |
|
||||
} |
} |
||||
|
} |
||||
.popup { |
|
||||
width: 600rpx; |
.title { |
||||
padding: 30rpx 60rpx 30rpx; |
padding: 32rpx 0px; |
||||
|
position: relative; |
||||
|
span { |
||||
|
position: absolute; |
||||
|
left: -16rpx; |
||||
|
color: #fa3534; |
||||
|
padding-top: 6rpx; |
||||
} |
} |
||||
|
} |
||||
|
|
||||
.popup-footer { |
.list { |
||||
|
.item { |
||||
display: flex; |
display: flex; |
||||
border-top: 1px solid #e4e4e4; |
margin-bottom: 20rpx; |
||||
|
.item-box { |
||||
view { |
background: #F5F5F5; |
||||
line-height: 100rpx; |
border-radius: 12rpx; |
||||
flex: 1; |
flex: 1; |
||||
text-align: center; |
width: 0rpx; |
||||
|
} |
||||
&.sure { |
.spare-title { |
||||
|
padding: 20rpx 30rpx; |
||||
|
border-bottom: 1px solid #e4e4e4; |
||||
|
.title-txt { |
||||
color: #409eff; |
color: #409eff; |
||||
|
font-size: 30rpx; |
||||
|
font-weight: bold; |
||||
} |
} |
||||
} |
} |
||||
|
.dec { |
||||
|
color: #9c9c9c; |
||||
|
padding: 20rpx 30rpx 20rpx; |
||||
|
} |
||||
} |
} |
||||
|
} |
||||
::v-deep .u-checkbox-group { |
|
||||
display: grid !important; |
.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; |
||||
|
} |
||||
} |
} |
||||
</style> |
} |
||||
|
|
||||
|
::v-deep .u-checkbox-group { |
||||
|
display: grid !important; |
||||
|
} |
||||
|
|
||||
|
.image-popup { |
||||
|
position: relative; |
||||
|
width: 100%; |
||||
|
height: 100%; |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
background-color: rgba(0, 0, 0, 0.8); |
||||
|
} |
||||
|
|
||||
|
.close-btn { |
||||
|
position: absolute; |
||||
|
top: 10px; |
||||
|
right: 10px; |
||||
|
color: white; |
||||
|
font-size: 24px; |
||||
|
cursor: pointer; |
||||
|
} |
||||
|
|
||||
|
.full-image { |
||||
|
max-width: 100%; |
||||
|
max-height: 100%; |
||||
|
} |
||||
|
|
||||
|
.item-dec { |
||||
|
display: flex; |
||||
|
align-items: flex-start; |
||||
|
} |
||||
|
|
||||
|
.image-link { |
||||
|
cursor: pointer; |
||||
|
color: blue; |
||||
|
text-decoration: underline; |
||||
|
margin-bottom: 5px; |
||||
|
overflow: hidden; /* 隐藏超出部分 */ |
||||
|
text-overflow: ellipsis; /* 显示省略号 */ |
||||
|
white-space: nowrap; /* 不换行 */ |
||||
|
max-width: 150px; /* 根据需要设置最大宽度 */ |
||||
|
} |
||||
|
|
||||
|
.image-popup { |
||||
|
position: relative; |
||||
|
width: 100%; |
||||
|
height: 100%; |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
background-color: rgba(0, 0, 0, 0.8); |
||||
|
} |
||||
|
|
||||
|
.close-btn { |
||||
|
position: absolute; |
||||
|
top: 10px; |
||||
|
right: 10px; |
||||
|
color: white; |
||||
|
font-size: 24px; |
||||
|
cursor: pointer; |
||||
|
} |
||||
|
|
||||
|
.full-image { |
||||
|
max-width: 100%; |
||||
|
max-height: 100%; |
||||
|
} |
||||
|
.tooltip { |
||||
|
position: absolute; |
||||
|
background-color: #f9f9f9; |
||||
|
border: 1px solid #ccc; |
||||
|
padding: 10px; |
||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); |
||||
|
z-index: 1000; |
||||
|
white-space: normal; |
||||
|
} |
||||
|
</style> |
Loading…
Reference in new issue