现场维修二维码

This commit is contained in:
jiang 2025-07-30 18:28:29 +08:00
parent 91dfb95a14
commit b9b9bad95f
1 changed files with 432 additions and 429 deletions

View File

@ -44,7 +44,8 @@
</uni-col>
<uni-col :span="10">
<view>
<uni-data-select v-model="typeCode" placeholder="请选择规格型号" :localdata="maCodeSelectList"
<uni-data-select v-model="typeCode" placeholder="请选择规格型号"
:localdata="maCodeSelectList"
@change="selectMaCode">
</uni-data-select>
</view>
@ -66,17 +67,18 @@
</div>
<view class="line"></view>
<template v-for="field in fieldMap" :key="field.label">
<uni-row :gutter="24">
<uni-row :gutter="24" style="padding-top: 12px">
<uni-col :span="field.labelSpan">{{ field.label }}</uni-col>
<uni-col :span="field.valueSpan">
<view class="cont">
{{ field.formatter ? field.formatter(item[field.key]) : (item[field.key] ?? field.default ?? '无') }}
{{ field.formatter ? field.formatter(item[field.key]) : (item[field.key] ?? field.default ?? '无')
}}
</view>
</uni-col>
</uni-row>
</template>
<uni-row :gutter="24">
<uni-col :span="8">配件数量</uni-col>
<uni-row :gutter="24" style="padding-top: 12px">
<uni-col :span="8">是否收费</uni-col>
<uni-col :span="16">
<view class="cont">
<uni-data-select v-model="item.charge" placeholder="请选择规格型号" :localdata="charge"
@ -85,7 +87,7 @@
</view>
</uni-col>
</uni-row>
<uni-row :gutter="24">
<uni-row :gutter="24" style="padding-top: 12px">
<uni-col :span="8">配件数量</uni-col>
<uni-col :span="16">
<view class="cont">
@ -106,47 +108,48 @@
</template>
<script setup>
import {
import {
ref,
reactive
} from 'vue'
import {
onLoad
} from '@dcloudio/uni-app'
import {
reactive,
} from 'vue'
import {
onLoad,
} from '@dcloudio/uni-app'
import {
getUseType,
insertDetails
} from '@/services/fieldMaintenance/fieldMaintenance.js'
const maCodeSelectList = ref([])
const charge = ref([{
insertDetails,
} from '@/services/fieldMaintenance/fieldMaintenance.js'
const maCodeSelectList = ref([])
const charge = ref([{
value: 1,
text: '是',
}, {
}, {
value: 0,
text: '否',
}])
const maTypeSelectList = ref([])
const item = ref({})
const typeId = ref("") //
const typeCode = ref("") //
const collapsed = ref(true)
const typeList = ref([])
const fieldMap = [{
}])
const maTypeSelectList = ref([])
const item = ref({})
const typeId = ref('') //
const typeCode = ref('') //
const collapsed = ref(true)
const typeList = ref([])
const fieldMap = [{
label: '规格型号',
key: 'typeName',
labelSpan: 8,
valueSpan: 16
},
valueSpan: 16,
},
{
label: '在用数',
key: 'num',
labelSpan: 8,
valueSpan: 16
}
]
const getMaType = () => {
valueSpan: 16,
},
]
const getMaType = () => {
let obj = {
"agreementId": item.value.agreementId,
'agreementId': item.value.agreementId,
}
getUseType(obj).then(res => {
console.log(res)
@ -155,16 +158,16 @@
value: option.typeId,
text: option.typeName,
}
});
})
}).catch(error => {
console.log(error)
})
}
//
const getMaCode = () => {
}
//
const getMaCode = () => {
let obj = {
"agreementId": item.value.agreementId,
"typeId": typeId.value
'agreementId': item.value.agreementId,
'typeId': typeId.value,
}
getUseType(obj).then(res => {
console.log(res)
@ -176,35 +179,35 @@
text: option.typeName,
}
return obj
});
})
}).catch(error => {
console.log(error)
})
}
const generateUniqueId = () => {
return Date.now().toString(36) + Math.random().toString(36).substr(2, 5);
};
}
const generateUniqueId = () => {
return Date.now().toString(36) + Math.random().toString(36).substr(2, 5)
}
const deleteItem = (item) => {
typeList.value = typeList.value.filter(i => i.itemId !== item.itemId);
};
const deleteItem = (item) => {
typeList.value = typeList.value.filter(i => i.itemId !== item.itemId)
}
//
const selectMaCode = (e) => {
const matched = maCodeSelectList.value.find(item => item.typeId == e);
//
const selectMaCode = (e) => {
const matched = maCodeSelectList.value.find(item => item.typeId == e)
if (matched) {
const itemCopy = JSON.parse(JSON.stringify(matched));
itemCopy.itemId = generateUniqueId();
itemCopy.preNum = 0;
itemCopy.charge = 0;
itemCopy.taskId = item.value.id;
typeList.value.push(itemCopy);
const itemCopy = JSON.parse(JSON.stringify(matched))
itemCopy.itemId = generateUniqueId()
itemCopy.preNum = 0
itemCopy.charge = 0
itemCopy.taskId = item.value.id
typeList.value.push(itemCopy)
}
console.log(typeList.value);
};
console.log(typeList.value)
}
const toggleCollapse = () => (collapsed.value = !collapsed.value)
const onChangeNumber = (item) => {
const toggleCollapse = () => (collapsed.value = !collapsed.value)
const onChangeNumber = (item) => {
console.log(item)
let maxNum = Number(item.num)
// outboundNum.value
@ -215,44 +218,44 @@
item.preNum = Number(String(item.preNum).replace(/[^\d]/g, ''))
}
if (Number(item.preNum) <= 0) {
item.preNum = 0;
item.preNum = 0
}
if (Number(item.preNum) > maxNum) {
uni.showToast({
title: '已达到当前资最大在用数量!',
icon: 'none',
})
item.preNum = maxNum;
item.preNum = maxNum
}
}, 500)
}
}
const submitNum = () => {
const submitNum = () => {
console.log(item)
const jsonData = JSON.stringify(typeList.value);
const jsonData = JSON.stringify(typeList.value)
console.log(jsonData)
insertDetails(JSON.parse(jsonData)).then(res => {
if(res.code==200){
if (res.code == 200) {
uni.showToast({ title: '编辑成功', icon: 'none' })
uni.navigateBack({
delta: 1 //
});
}else{
delta: 1, //
})
} else {
uni.showToast({ title: res.msg, icon: 'none' })
}
}).catch(error => {
console.log(error)
})
}
}
onLoad((options) => {
onLoad((options) => {
item.value = JSON.parse(options.item)
getMaType()
})
})
</script>
<style lang="scss">
.page-container {
.page-container {
display: flex;
height: 97vh;
padding: 24rpx;
@ -342,7 +345,7 @@
}
.scroll-container {
padding: 24rpx;
padding: 12rpx;
height: 85%;
.table-list-item {
@ -468,5 +471,5 @@
}
}
}
}
}
</style>