现场维修二维码
This commit is contained in:
		
							parent
							
								
									94b0972f9d
								
							
						
					
					
						commit
						f9e6a4968f
					
				| 
						 | 
					@ -1,8 +1,15 @@
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
    <view class="accept page-common">
 | 
					    <view class="accept page-common">
 | 
				
			||||||
        <div class="card">
 | 
					        <div class="card">
 | 
				
			||||||
           <uni-forms :modelValue="formData"  label-width="170rpx" :border="true">
 | 
					            <uni-row :gutter="24">
 | 
				
			||||||
                <uni-forms-item label="单位名称:"  name="unitId" required>
 | 
					                <uni-col :span="6">
 | 
				
			||||||
 | 
					                    <view class="coding-btn" @tap="codeScan">二维码识别</view>
 | 
				
			||||||
 | 
					                </uni-col>
 | 
				
			||||||
 | 
					            </uni-row>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					        <div class="card">
 | 
				
			||||||
 | 
					            <uni-forms :modelValue="formData" label-width="170rpx" :border="true">
 | 
				
			||||||
 | 
					                <uni-forms-item label="单位名称:" name="unitId" required>
 | 
				
			||||||
                    <eselect
 | 
					                    <eselect
 | 
				
			||||||
                        style="width: 100%; height: 90rpx"
 | 
					                        style="width: 100%; height: 90rpx"
 | 
				
			||||||
                        ref="treeSelect"
 | 
					                        ref="treeSelect"
 | 
				
			||||||
| 
						 | 
					@ -33,6 +40,11 @@
 | 
				
			||||||
            <button class="btn-cont" @click="clearForm">清空</button>
 | 
					            <button class="btn-cont" @click="clearForm">清空</button>
 | 
				
			||||||
            <button class="btn-cont" @click="confirmAdd">确认</button>
 | 
					            <button class="btn-cont" @click="confirmAdd">确认</button>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
 | 
					        <ScanQrCode
 | 
				
			||||||
 | 
					            ref="scanQrCodeRef"
 | 
				
			||||||
 | 
					            @scanSuccess="handleScanSuccess"
 | 
				
			||||||
 | 
					            @scanError="handleScanError"
 | 
				
			||||||
 | 
					        />
 | 
				
			||||||
    </view>
 | 
					    </view>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,7 +57,11 @@ import {
 | 
				
			||||||
    insert,
 | 
					    insert,
 | 
				
			||||||
    getAgreementInfoById,
 | 
					    getAgreementInfoById,
 | 
				
			||||||
} from '@/services/fieldMaintenance/fieldMaintenance.js'
 | 
					} from '@/services/fieldMaintenance/fieldMaintenance.js'
 | 
				
			||||||
 | 
					import { getMachineByQrCodeApi } from '../../../services/back.js'
 | 
				
			||||||
import eselect from '@/components/tree-select/eselect.vue'
 | 
					import eselect from '@/components/tree-select/eselect.vue'
 | 
				
			||||||
 | 
					import ScanQrCode from '@/pages/devicesSearch/ScanQrCode.vue'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const scanQrCodeRef = ref(null)
 | 
				
			||||||
const treeSelect = ref(null)
 | 
					const treeSelect = ref(null)
 | 
				
			||||||
const treeSelect2 = ref(null)
 | 
					const treeSelect2 = ref(null)
 | 
				
			||||||
const unitId = ref('')
 | 
					const unitId = ref('')
 | 
				
			||||||
| 
						 | 
					@ -55,7 +71,49 @@ const unitList = ref([])
 | 
				
			||||||
const proList = ref([])
 | 
					const proList = ref([])
 | 
				
			||||||
const fieldPerson = ref('')
 | 
					const fieldPerson = ref('')
 | 
				
			||||||
const phone = ref('')
 | 
					const phone = ref('')
 | 
				
			||||||
 | 
					const qrCode = ref('')
 | 
				
			||||||
 | 
					const maInfo = ref({}) //二维码
 | 
				
			||||||
 | 
					// 处理扫描成功事件
 | 
				
			||||||
 | 
					const handleScanSuccess = (result) => {
 | 
				
			||||||
 | 
					    qrCode.value = result?.data?.split('?qrcode=')[1] || result?.data
 | 
				
			||||||
 | 
					    if (qrCode.value === '') {
 | 
				
			||||||
 | 
					        uni.showToast({ title: '扫码识别失败', icon: 'none' })
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        getMaInfoScan()
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					// 处理扫描失败事件
 | 
				
			||||||
 | 
					const handleScanError = (error) => {
 | 
				
			||||||
 | 
					    console.error('扫描出错:', error.message)
 | 
				
			||||||
 | 
					    uni.showToast({ title: error.message, icon: 'none' })
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//查看是否是该规格型号
 | 
				
			||||||
 | 
					const getMaInfoScan = async () => {
 | 
				
			||||||
 | 
					    let param = {
 | 
				
			||||||
 | 
					        qrCode: qrCode.value,
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    //通过二维码获取相绑定的设备编码
 | 
				
			||||||
 | 
					    const res = await getMachineByQrCodeApi(param)
 | 
				
			||||||
 | 
					    console.log(res)
 | 
				
			||||||
 | 
					    if (res.code == 200) {
 | 
				
			||||||
 | 
					        if (res.data.length > 0) {
 | 
				
			||||||
 | 
					            unitId.value = res.data[0].unitId
 | 
				
			||||||
 | 
					            proId.value = res.data[0].proId
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            uni.showToast({ title: '扫码二维码未绑定设备编码!', icon: 'none' })
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        uni.showToast({ title: res.data.msg, icon: 'none' })
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					const codeScan = async () => {
 | 
				
			||||||
 | 
					    qrCode.value = ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (scanQrCodeRef.value) {
 | 
				
			||||||
 | 
					        scanQrCodeRef.value.scanQrCode()
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
//单位
 | 
					//单位
 | 
				
			||||||
const getUnit = () => {
 | 
					const getUnit = () => {
 | 
				
			||||||
    // proId.value=e.id;
 | 
					    // proId.value=e.id;
 | 
				
			||||||
| 
						 | 
					@ -158,9 +216,9 @@ const confirmAdd = () => {
 | 
				
			||||||
        uni.showToast({ title: '请确认联系电话!', icon: 'none' })
 | 
					        uni.showToast({ title: '请确认联系电话!', icon: 'none' })
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        let obj = {
 | 
					        let obj = {
 | 
				
			||||||
                agreementId: agreementId.value,
 | 
					            agreementId: agreementId.value,
 | 
				
			||||||
                fieldPerson: fieldPerson.value,
 | 
					            fieldPerson: fieldPerson.value,
 | 
				
			||||||
                phone: phone.value,
 | 
					            phone: phone.value,
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        insert(obj)
 | 
					        insert(obj)
 | 
				
			||||||
            .then((res) => {
 | 
					            .then((res) => {
 | 
				
			||||||
| 
						 | 
					@ -213,6 +271,25 @@ onLoad((options) => {
 | 
				
			||||||
        margin-bottom: 24rpx;
 | 
					        margin-bottom: 24rpx;
 | 
				
			||||||
        height: auto;
 | 
					        height: auto;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        .coding-btn {
 | 
				
			||||||
 | 
					            height: 70rpx;
 | 
				
			||||||
 | 
					            line-height: 70rpx;
 | 
				
			||||||
 | 
					            background: linear-gradient(135deg, #4b8eff 0%, #3784fb 100%);
 | 
				
			||||||
 | 
					            border-radius: 12rpx;
 | 
				
			||||||
 | 
					            text-align: center;
 | 
				
			||||||
 | 
					            color: #fff;
 | 
				
			||||||
 | 
					            font-size: 24rpx;
 | 
				
			||||||
 | 
					            font-weight: 600;
 | 
				
			||||||
 | 
					            box-shadow: 0 6rpx 20rpx rgba(55, 132, 251, 0.2);
 | 
				
			||||||
 | 
					            transition: all 0.3s ease;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            &:active {
 | 
				
			||||||
 | 
					                transform: scale(0.98);
 | 
				
			||||||
 | 
					                opacity: 0.9;
 | 
				
			||||||
 | 
					                box-shadow: 0 2rpx 8rpx rgba(55, 132, 251, 0.2);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 表单样式
 | 
					        // 表单样式
 | 
				
			||||||
        :deep(.uni-forms) {
 | 
					        :deep(.uni-forms) {
 | 
				
			||||||
            .uni-forms-item {
 | 
					            .uni-forms-item {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue