现场维修二维码
This commit is contained in:
parent
91dfb95a14
commit
b9b9bad95f
|
|
@ -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">
|
||||
|
|
@ -108,15 +110,16 @@
|
|||
<script setup>
|
||||
import {
|
||||
ref,
|
||||
reactive
|
||||
reactive,
|
||||
} from 'vue'
|
||||
import {
|
||||
onLoad
|
||||
onLoad,
|
||||
} from '@dcloudio/uni-app'
|
||||
import {
|
||||
getUseType,
|
||||
insertDetails
|
||||
insertDetails,
|
||||
} from '@/services/fieldMaintenance/fieldMaintenance.js'
|
||||
|
||||
const maCodeSelectList = ref([])
|
||||
const charge = ref([{
|
||||
value: 1,
|
||||
|
|
@ -127,26 +130,26 @@
|
|||
}])
|
||||
const maTypeSelectList = ref([])
|
||||
const item = ref({})
|
||||
const typeId = ref("") //类型
|
||||
const typeCode = 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
|
||||
}
|
||||
valueSpan: 16,
|
||||
},
|
||||
]
|
||||
const getMaType = () => {
|
||||
let obj = {
|
||||
"agreementId": item.value.agreementId,
|
||||
'agreementId': item.value.agreementId,
|
||||
}
|
||||
getUseType(obj).then(res => {
|
||||
console.log(res)
|
||||
|
|
@ -155,7 +158,7 @@
|
|||
value: option.typeId,
|
||||
text: option.typeName,
|
||||
}
|
||||
});
|
||||
})
|
||||
}).catch(error => {
|
||||
console.log(error)
|
||||
})
|
||||
|
|
@ -163,8 +166,8 @@
|
|||
//规格
|
||||
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,32 +179,32 @@
|
|||
text: option.typeName,
|
||||
}
|
||||
return obj
|
||||
});
|
||||
})
|
||||
}).catch(error => {
|
||||
console.log(error)
|
||||
})
|
||||
}
|
||||
const generateUniqueId = () => {
|
||||
return Date.now().toString(36) + Math.random().toString(36).substr(2, 5);
|
||||
};
|
||||
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);
|
||||
};
|
||||
typeList.value = typeList.value.filter(i => i.itemId !== item.itemId)
|
||||
}
|
||||
|
||||
// 选择规格型号
|
||||
const selectMaCode = (e) => {
|
||||
const matched = maCodeSelectList.value.find(item => item.typeId == 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) => {
|
||||
|
|
@ -215,28 +218,28 @@
|
|||
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 = () => {
|
||||
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) {
|
||||
uni.showToast({ title: '编辑成功', icon: 'none' })
|
||||
uni.navigateBack({
|
||||
delta: 1 // 返回到已存在的页面
|
||||
});
|
||||
delta: 1, // 返回到已存在的页面
|
||||
})
|
||||
} else {
|
||||
uni.showToast({ title: res.msg, icon: 'none' })
|
||||
}
|
||||
|
|
@ -342,7 +345,7 @@
|
|||
}
|
||||
|
||||
.scroll-container {
|
||||
padding: 24rpx;
|
||||
padding: 12rpx;
|
||||
height: 85%;
|
||||
|
||||
.table-list-item {
|
||||
|
|
|
|||
Loading…
Reference in New Issue