This commit is contained in:
hongchao 2025-06-30 18:06:43 +08:00
commit b441997a84
5 changed files with 360 additions and 2 deletions

View File

@ -686,6 +686,12 @@
"navigationStyle": "custom"
}
},
{
"path": "pages/nameplateUpdate/index",
"style": {
"navigationStyle": "custom"
}
},
// start
//
{

View File

@ -48,7 +48,7 @@
<ScanQrCode ref="scanQrCodeRef" @scanSuccess="handleScanSuccess" @scanError="handleScanError" />
</template>
<script setup lang="ts">
<script setup>
import {
getWsMaInfoList,
updateCheckTime

View File

@ -0,0 +1,333 @@
<template>
<uni-nav-bar
fixed
:border="false"
background-color="#dcf4ff"
color="black"
status-bar
title="铭牌信息更新"
><template v-slot:left>
<view style="display: flex; align-items: center" @click="back">
<!-- 图标 -->
<uni-icons type="left" size="20" color="black"></uni-icons>
</view>
</template>
<template v-slot:right>
<view style="display: flex; align-items: center" @click="onQrCode">
<!-- 文本 -->
<text>二维码</text>
</view>
</template>
</uni-nav-bar>
<div class="content">
<div class="search">
<uni-easyinput v-model="keyWord" placeholder="请输入设备编码"></uni-easyinput>
<button
type="primary"
size="mini"
@click="handleSearch"
style="margin-left: 10px; background-color: #18bc37"
>
查询
</button>
</div>
<div class="popup" style="margin: 20px 0 30px" @click="handlePopup(1)">{{ typeName || '请选择对应机具' }}</div>
<div class="search-item">
<div>设备类型{{ formData.materialName }}</div>
<div>
<span><span style="color: red">*</span>规格型号</span
><uni-easyinput v-model="formData.materialModel" placeholder="请输入"></uni-easyinput>
</div>
<div>二维码{{ formData.qrCode }}</div>
<div>设备编码{{ formData.maCode }}</div>
<div>设备状态{{ formData.maStatus }}</div>
<div>
<span>本次检修人员</span
><uni-easyinput v-model="formData.checkMan" placeholder="请输入"></uni-easyinput>
</div>
<div>
<span>本次检修时间</span>
<uni-datetime-picker type="date" v-model="formData.thisCheckTime" @change="changeTime" />
</div>
<div>
<span>下次检修时间</span>
<uni-datetime-picker
type="date"
v-model="formData.nextCheckTime"
@change="changeNextTime"
/>
</div>
<div>
<span><span style="color: red">*</span>出厂时间</span>
<uni-datetime-picker type="date" v-model="formData.outFacTime" @change="changeFacTime" />
</div>
<div style="display: flex; align-items: center; justify-content: space-between">
<div><span style="color: red">*</span>机具厂家</div>
<div class="popup" style="width: 70%" @click="handlePopup(2)">
{{ formData.maVender || '请选择' }}
</div>
</div>
</div>
<button
type="primary"
size="mini"
@click="handleSubmit"
style="margin-top: 30px; background-color: #18bc37; width: 100%"
>
确认修改
</button>
</div>
<uni-popup ref="popup" border-radius="5px 5px 5px 5px" background-color="#fff">
<div
v-for="(item, index) in list"
:key="index"
class="popup-item"
@click.stop="handleCheck(item)"
>
<div>{{ item.name }}</div>
<uni-data-checkbox
v-model="item.isChecked"
:localdata="range"
@change="handleCheck(item, $event)"
></uni-data-checkbox>
</div>
</uni-popup>
<ScanQrCode ref="scanQrCodeRef" @scanSuccess="handleScanSuccess" @scanError="handleScanError" />
</template>
<script setup>
import { getWsMaInfoList, updateCheckTime } from '@/services/wsMaInfo/wsMaInfo.js'
import { getInfoByCode, updateInfo } from '@/services/information'
import { getSupplierList } from '@/services/repair/repair.js'
import { onLoad } from '@dcloudio/uni-app'
import { reactive, ref } from 'vue'
import ScanQrCode from '@/pages/devicesSearch/ScanQrCode'
const keyWord = ref('')
const qrCode = ref('')
let formData = reactive({
id: '',
maVender: '',
supplierId: '',
})
const scanQrCodeRef = ref()
const popup = ref()
const typeName = ref('')
const list = ref([])
const typeList = ref([]) //
const range = ref([{ value: 0, text: '' }])
const supplierList = ref([]) //
onLoad(() => {
console.log('onLoad')
getSupplier()
})
const back = () => {
uni.navigateBack({
delta: 1,
})
}
const onQrCode = () => {
console.log('🚀 ~ onQrCode ~ 二维码:')
if (scanQrCodeRef.value) scanQrCodeRef.value.scanQrCode()
}
const handleSearch = () => {
console.log('🚀 ~ handleSearch ~ 查询:', keyWord.value)
if (!keyWord.value) {
uni.showToast({
title: '请输入设备编码',
icon: 'none',
})
return
}
qrCode.value = ''
typeList.value = []
getInfo()
}
const getInfo = () => {
const params = {
maCode: keyWord.value,
qrCode: qrCode.value,
}
getInfoByCode(params)
.then((res) => {
if (res.code === 200 && res.data && res.data.length > 0) {
typeList.value = res.data.map((option) => {
return {
...option,
id: option.maId,
name: option.materialName + '-' + option.materialModel,
isChecked: 1,
}
})
}
})
.catch((error) => {
console.log(error)
})
}
//
const getSupplier = () => {
getSupplierList()
.then((res) => {
if (res.code === 200) {
supplierList.value = res.rows.map((item) => {
return {
...item,
id: item.supplierId,
name: item.supplier,
isChecked: 1,
isSupplier: true,
}
})
}
})
.catch((error) => {
console.log(error)
})
}
const changeTime = (e) => {
formData.thisCheckTime = e
}
const changeNextTime = (e) => {
formData.nextCheckTime = e
}
const changeFacTime = (e) => {
formData.outFacTime = e
}
const handlePopup = (type) => {
console.log('🚀 ~ handlePopup ~ 弹窗:')
if (type === 1) {
list.value = typeList.value
} else {
list.value = supplierList.value
}
if (list.value.length === 0) {
uni.showToast({ title: '暂无数据', icon: 'none' })
return
}
popup.value.open()
}
const handleCheck = (item) => {
console.log('🚀 ~ handleCheck ~ 单选:', item)
// typeList item.isChecked 0 1
list.value.forEach((i) => {
i.isChecked = i.id === item.id ? 0 : 1
})
if (item.isSupplier) {
formData.maVender = item.supplier
formData.supplierId = item.supplierId
} else {
formData = {}
formData = item
typeName.value = item.name
}
popup.value.close()
}
//
const handleScanSuccess = (result) => {
qrCode.value = result?.text?.split('?qrcode=')[1] || result?.text
if (qrCode.value === '') {
uni.showToast({ title: '扫码识别失败', icon: 'none' })
} else {
keyWord.value = ''
getInfo()
}
}
//
const handleScanError = (error) => {
console.error('扫描出错:', error.message)
uni.showToast({ title: error.message, icon: 'none' })
}
//
const handleSubmit = () => {
//
console.log('🚀 ~ handleSubmit ~ formData:', formData)
if (!formData.materialModel || !formData.outFacTime || !formData.maVender) {
uni.showToast({ title: '请填写完整信息', icon: 'none' })
return
}
delete formData.maStatus
updateInfo(formData)
.then((res) => {
if (res.code === 200) {
uni.showToast({
title: res.msg,
icon: 'none',
})
resetFormData()
}
})
.catch((error) => {
console.log(error)
})
}
const resetFormData = () => {
Object.keys(formData).forEach(key => {
formData[key] = ''
})
}
</script>
<style scoped lang="scss">
.content {
padding: 10px;
.search {
display: flex;
align-items: center;
justify-content: space-between;
}
.popup {
background: #fff;
/* margin: 20px 0 30px; */
padding: 5px 10px;
}
.search-item {
line-height: 1.9;
div {
display: flex;
align-items: center;
margin-bottom: 5px;
}
}
}
.popup-item {
padding: 10px;
border-bottom: 1px solid #c7c9ce;
display: flex;
align-items: center;
justify-content: space-between;
}
::v-deep .uni-popup__wrapper {
width: calc(100% - 20px);
/* padding: 10px; */
}
::v-deep .uni-data-checklist {
// flex: 1
flex: none;
}
</style>

View File

@ -158,7 +158,7 @@ const newInfoList = ref([
},
{
title: '铭牌更新',
url: '',
url: '/pages/nameplateUpdate/index',
iconSrc: '../../static/workbench/minPai.png',
},
])

View File

@ -0,0 +1,19 @@
import { http } from '@/utils/http'
// 获取铭牌信息
export const getInfoByCode = (data) => {
return http({
method: 'GET',
url: '/material/ma_machine/getInfoByCode',
data,
})
}
// 更新铭牌
export const updateInfo = (data) => {
return http({
method: 'PUT',
url: '/material/ma_machine',
data,
})
}