ljlong_2630
3 months ago
6 changed files with 402 additions and 5 deletions
@ -0,0 +1,243 @@ |
|||||
|
<template> |
||||
|
<!-- 选择设备或模具 --> |
||||
|
<u-popup v-model="props.isShowSelectDevice" mode="center" border-radius="14"> |
||||
|
<view class="popup-title">选择{{ deviceType }}</view> |
||||
|
<view class="popup"> |
||||
|
<u-search placeholder="搜索" v-model="form1.searchName" @change="searchDevice"></u-search> |
||||
|
<view class="list"> |
||||
|
<view class="device" v-for="(device, index) in singleColumnList" :key="index" @click="chooseDevice(device)"> |
||||
|
<u-checkbox v-model="device.checked" shape="circle" style="margin-top: 8rpx;"></u-checkbox> |
||||
|
<view class="right"> |
||||
|
<view class="device-name"> |
||||
|
名称: <span>{{device.name}}</span> |
||||
|
</view> |
||||
|
<view class="device-dec"> |
||||
|
型号: <span>{{device.specification}}</span> |
||||
|
</view> |
||||
|
<view class="device-dec"> |
||||
|
{{ deviceType === 'DEVICE' ? '设备编号' : '模具编号' }}: <span>{{device.number}}</span> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="popup-footer"> |
||||
|
<view @click="chooseDevice1(0)">取消</view> |
||||
|
<view class="sure" @click="chooseDevice1(1)">确认</view> |
||||
|
</view> |
||||
|
</u-popup> |
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"> |
||||
|
import { |
||||
|
ref, |
||||
|
defineProps, |
||||
|
defineEmits, |
||||
|
getCurrentInstance, |
||||
|
watch |
||||
|
} from 'vue' |
||||
|
import { |
||||
|
onLoad, |
||||
|
} from '@dcloudio/uni-app' |
||||
|
const props = defineProps({ |
||||
|
isShowSelectDevice: { |
||||
|
type: Boolean, |
||||
|
default: () => { return false }, |
||||
|
require: true |
||||
|
}, |
||||
|
singleColumnList: { |
||||
|
type: Array, |
||||
|
default: () => { return [] }, |
||||
|
require: false |
||||
|
}, |
||||
|
deviceType: { |
||||
|
type: String, |
||||
|
default: 'DEVICE', |
||||
|
require: true |
||||
|
} |
||||
|
}); |
||||
|
// 监测isShowSelectDevice的变化 |
||||
|
watch(() => props.isShowSelectDevice, (newValue, oldValue) => { |
||||
|
if (newValue) { |
||||
|
console.log('props.isShowSelectDevice', props.isShowSelectDevice); |
||||
|
form1.value.searchName = null |
||||
|
form1.value.temporarilyNumber = null |
||||
|
form1.value.temporarilyName = null |
||||
|
} |
||||
|
}); |
||||
|
const { proxy } = getCurrentInstance() |
||||
|
const repairOrderList = ref([]) |
||||
|
const deviceList = ref([]) |
||||
|
const type = ref('') |
||||
|
const isShowSelectDevice = ref(false); |
||||
|
const selectVal = ref(null); |
||||
|
const emits = defineEmits(['searchDevice', 'chooseDevice1']); |
||||
|
const form1 = ref({ |
||||
|
number: "", |
||||
|
name: "", |
||||
|
specification: "", |
||||
|
qty: 0, |
||||
|
temporarilyNumber: "", // 临时选中的编码 |
||||
|
temporarilyName: "", // 临时选中的名称 |
||||
|
temporarilySpecifications: "", // 临时选中的型号 |
||||
|
searchName: "", // 模糊搜索 |
||||
|
}) |
||||
|
const isDevice = ref(props.deviceType === 'DEVICE'); |
||||
|
onLoad((option) => { |
||||
|
if (option.type) type.value = option.type; |
||||
|
if (option.type) isShowSelectDevice.value = option.isShowSelectDevice; // 是否显示 |
||||
|
if (option.selectVal) selectVal.value = option.selectVal; // 是否显示 |
||||
|
}) |
||||
|
// 取消和确认方法 |
||||
|
function chooseDevice1(type) { |
||||
|
if (type == 1) { |
||||
|
form1.value.number = form1.value.temporarilyNumber |
||||
|
form1.value.name = form1.value.temporarilyName |
||||
|
form1.value.specification = form1.value.temporarilySpecifications |
||||
|
} |
||||
|
emits('chooseDevice1', type, form1); |
||||
|
} |
||||
|
function searchDevice() { |
||||
|
emits('searchDevice', form1.value.searchName); |
||||
|
} |
||||
|
function chooseDevice(device) { |
||||
|
console.log('props.isShowSelectDevice', props.isShowSelectDevice); |
||||
|
console.log('props.singleColumnList', props.singleColumnList); |
||||
|
let arr = props.singleColumnList.filter(cur => cur.number != device.number) |
||||
|
arr.forEach(device => { |
||||
|
device.checked = false |
||||
|
}) |
||||
|
device.checked = !device.checked |
||||
|
let arr1 = props.singleColumnList.filter(cur => cur.number == device.number) |
||||
|
form1.value.temporarilyNumber = arr1[0].number; |
||||
|
form1.value.temporarilyName = arr1[0].name; |
||||
|
form1.value.temporarilySpecifications = arr1[0].specification; |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.add-form-container { |
||||
|
min-height: calc(100vh - 140rpx); |
||||
|
background: white; |
||||
|
padding: 0px 30rpx 140rpx; |
||||
|
} |
||||
|
.footer { |
||||
|
position: fixed; |
||||
|
bottom: 0px; |
||||
|
left: 0px; |
||||
|
width: 100%; |
||||
|
z-index: 22; |
||||
|
} |
||||
|
.btns { |
||||
|
display: flex; |
||||
|
button { |
||||
|
flex: 1; |
||||
|
} |
||||
|
.sure { |
||||
|
background: #409eff; |
||||
|
color: white; |
||||
|
border-radius: 0px; |
||||
|
&::after { |
||||
|
border: 1px solid #409eff; |
||||
|
border-radius: 0px; |
||||
|
} |
||||
|
} |
||||
|
.reset { |
||||
|
background: #F5F5F5; |
||||
|
border-radius: 0px; |
||||
|
&::after { |
||||
|
border-radius: 0px; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
.right-button { |
||||
|
background: #409eff; |
||||
|
color: white; |
||||
|
padding: 0rpx 30rpx; |
||||
|
border-radius: 16rpx; |
||||
|
text-align: center; |
||||
|
font-size: 28rpx; |
||||
|
} |
||||
|
.select { |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
height: 72rpx; |
||||
|
width: 100%; |
||||
|
.input { |
||||
|
flex: 1; |
||||
|
font-size: 28rpx; |
||||
|
color: #000000; |
||||
|
} |
||||
|
.placeholder { |
||||
|
flex: 1; |
||||
|
font-size: 28rpx; |
||||
|
color: rgb(192, 196, 204); |
||||
|
} |
||||
|
} |
||||
|
.title { |
||||
|
padding: 32rpx 0px; |
||||
|
position: relative; |
||||
|
span { |
||||
|
position: absolute; |
||||
|
left: -16rpx; |
||||
|
color: #fa3534; |
||||
|
padding-top: 6rpx; |
||||
|
} |
||||
|
} |
||||
|
.list { |
||||
|
.device { |
||||
|
display: flex; |
||||
|
margin-bottom: 20rpx; |
||||
|
.device-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; |
||||
|
justify-content: flex-start; |
||||
|
align-items: center; |
||||
|
} |
||||
|
.popup-title { |
||||
|
text-align: center; |
||||
|
font-size: 32rpx; |
||||
|
font-weight: bold; |
||||
|
color: #409eff; |
||||
|
padding: 30rpx 30rpx 0px |
||||
|
} |
||||
|
.popup { |
||||
|
width: 600rpx; |
||||
|
padding: 30rpx 60rpx 30rpx; |
||||
|
} |
||||
|
.popup-footer { |
||||
|
display: flex; |
||||
|
border-top: 1px solid #e4e4e4; |
||||
|
view { |
||||
|
line-height: 100rpx; |
||||
|
flex: 1; |
||||
|
text-align: center; |
||||
|
&.sure { |
||||
|
color: #409eff; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
::v-deep .u-checkbox-group { |
||||
|
display: grid !important; |
||||
|
} |
||||
|
</style> |
Loading…
Reference in new issue