This commit is contained in:
hongchao 2025-07-31 09:56:16 +08:00
commit 167f3e64ce
2 changed files with 433 additions and 430 deletions

View File

@ -132,7 +132,7 @@ const getTableList = () => {
// // "statusList":statusList.value, // // "statusList":statusList.value,
// } // }
// console.log(obj) // console.log(obj)
uni.showLoading({ title: '提交中...', mask: true }) uni.showLoading({ title: '加载中...', mask: true })
getBackInfo(id.value,keyWord.value).then(res => { getBackInfo(id.value,keyWord.value).then(res => {
uni.hideLoading() uni.hideLoading()
console.log(res) console.log(res)

View File

@ -1,472 +1,475 @@
<template> <template>
<view class="page-container"> <view class="page-container">
<!-- 任务信息 --> <!-- 任务信息 -->
<div class="card-container"> <div class="card-container">
<div class="card-header" @click="toggleCollapse"> <div class="card-header" @click="toggleCollapse">
<span class="title">任务信息</span> <span class="title">任务信息</span>
<span style="color: #007AFF">{{ collapsed ? '展开' : '收起' }}</span> <span style="color: #007AFF">{{ collapsed ? '展开' : '收起' }}</span>
</div> </div>
<view v-show="!collapsed"> <view v-show="!collapsed">
<uni-forms :model="item" label-width="170rpx" :border="true"> <uni-forms :model="item" label-width="170rpx" :border="true">
<uni-forms-item label="单位:" name="unitName"> <uni-forms-item label="单位:" name="unitName">
<span class="form-item">{{ item.unitName }}</span> <span class="form-item">{{ item.unitName }}</span>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="工程:" name="proName"> <uni-forms-item label="工程:" name="proName">
<span class="form-item">{{ item.proName }}</span> <span class="form-item">{{ item.proName }}</span>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="单号:" name="code"> <uni-forms-item label="单号:" name="code">
<span class="form-item">{{ item.code }}</span> <span class="form-item">{{ item.code }}</span>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="人员:" name="fieldPerson"> <uni-forms-item label="人员:" name="fieldPerson">
<span class="form-item">{{ item.fieldPerson }}</span> <span class="form-item">{{ item.fieldPerson }}</span>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="电话:" name="phone"> <uni-forms-item label="电话:" name="phone">
<span class="form-item">{{ item.phone }}</span> <span class="form-item">{{ item.phone }}</span>
</uni-forms-item> </uni-forms-item>
</uni-forms> </uni-forms>
</view> </view>
</div> </div>
<!-- 维修物资 --> <!-- 维修物资 -->
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<span class="title">维修物资</span> <span class="title">维修物资</span>
</div> </div>
<div class="select-area"> <div class="select-area">
<uni-row :gutter="24" style="display: flex; align-items: center"> <uni-row :gutter="24" style="display: flex; align-items: center">
<uni-col :span="10"> <uni-col :span="10">
<view> <view>
<uni-data-select v-model="typeId" placeholder="请选择物资类型" :localdata="maTypeSelectList" <uni-data-select v-model="typeId" placeholder="请选择物资类型" :localdata="maTypeSelectList"
@change="getMaCode" filterable> @change="getMaCode" filterable>
</uni-data-select> </uni-data-select>
</view> </view>
</uni-col> </uni-col>
<uni-col :span="10"> <uni-col :span="10">
<view> <view>
<uni-data-select v-model="typeCode" placeholder="请选择规格型号" :localdata="maCodeSelectList" <uni-data-select v-model="typeCode" placeholder="请选择规格型号"
@change="selectMaCode"> :localdata="maCodeSelectList"
</uni-data-select> @change="selectMaCode">
</view> </uni-data-select>
</uni-col> </view>
</uni-row> </uni-col>
</div> </uni-row>
<scroll-view scroll-y class="scroll-container" @scrolltolower="onScrollTolower"> </div>
<view v-for="(item, index) in typeList" :key="index" class="table-list-item"> <scroll-view scroll-y class="scroll-container" @scrolltolower="onScrollTolower">
<div class="title"> <view v-for="(item, index) in typeList" :key="index" class="table-list-item">
<div class="title-left"> <div class="title">
<span class="code">{{ item.materialName }}</span> <div class="title-left">
</div> <span class="code">{{ item.materialName }}</span>
<div class="status-tag"> </div>
<view @click.stop="deleteItem(item)" style="padding-right: 10rpx;"> <div class="status-tag">
<uni-icons type="trash" size="24" color="#ff0000" /> <view @click.stop="deleteItem(item)" style="padding-right: 10rpx;">
</view> <uni-icons type="trash" size="24" color="#ff0000" />
</view>
</div> </div>
</div> </div>
<view class="line"></view> <view class="line"></view>
<template v-for="field in fieldMap" :key="field.label"> <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.labelSpan">{{ field.label }}</uni-col>
<uni-col :span="field.valueSpan"> <uni-col :span="field.valueSpan">
<view class="cont"> <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> </view>
</uni-row> </uni-col>
</template> </uni-row>
<uni-row :gutter="24"> </template>
<uni-col :span="8">配件数量</uni-col> <uni-row :gutter="24" style="padding-top: 12px">
<uni-col :span="16"> <uni-col :span="8">是否收费</uni-col>
<view class="cont"> <uni-col :span="16">
<uni-data-select v-model="item.charge" placeholder="请选择规格型号" :localdata="charge" <view class="cont">
@change="selectMaCode"> <uni-data-select v-model="item.charge" placeholder="请选择规格型号" :localdata="charge"
</uni-data-select> @change="selectMaCode">
</view> </uni-data-select>
</uni-col> </view>
</uni-row> </uni-col>
<uni-row :gutter="24"> </uni-row>
<uni-col :span="8">配件数量</uni-col> <uni-row :gutter="24" style="padding-top: 12px">
<uni-col :span="16"> <uni-col :span="8">配件数量</uni-col>
<view class="cont"> <uni-col :span="16">
<uni-easyinput type="number" v-model="item.preNum" @input="onChangeNumber(item)" <view class="cont">
placeholder="输入数值" style="flex: 1;" /> <uni-easyinput type="number" v-model="item.preNum" @input="onChangeNumber(item)"
</view> placeholder="输入数值" style="flex: 1;" />
</uni-col> </view>
</uni-row> </uni-col>
</view> </uni-row>
</scroll-view> </view>
</div> </scroll-view>
</div>
<!-- 底部按钮 --> <!-- 底部按钮 -->
<div class="footer-btn"> <div class="footer-btn">
<button class="btn-cont" @click="submitNum">确认</button> <button class="btn-cont" @click="submitNum">确认</button>
</div> </div>
</view> </view>
</template> </template>
<script setup> <script setup>
import { import {
ref, ref,
reactive reactive,
} from 'vue' } from 'vue'
import { import {
onLoad onLoad,
} from '@dcloudio/uni-app' } from '@dcloudio/uni-app'
import { import {
getUseType, getUseType,
insertDetails insertDetails,
} from '@/services/fieldMaintenance/fieldMaintenance.js' } 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 = [{
label: '规格型号',
key: 'typeName',
labelSpan: 8,
valueSpan: 16
},
{
label: '在用数',
key: 'num',
labelSpan: 8,
valueSpan: 16
}
]
const getMaType = () => {
let obj = {
"agreementId": item.value.agreementId,
}
getUseType(obj).then(res => {
console.log(res)
maTypeSelectList.value = res.data.map(option => {
return {
value: option.typeId,
text: option.typeName,
}
});
}).catch(error => {
console.log(error)
})
}
//
const getMaCode = () => {
let obj = {
"agreementId": item.value.agreementId,
"typeId": typeId.value
}
getUseType(obj).then(res => {
console.log(res)
maCodeSelectList.value = res.data.map(option => {
let obj = {
...option,
bmFileInfos: [],
value: option.typeId,
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 deleteItem = (item) => { const maCodeSelectList = ref([])
typeList.value = typeList.value.filter(i => i.itemId !== item.itemId); 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 = [{
label: '规格型号',
key: 'typeName',
labelSpan: 8,
valueSpan: 16,
},
{
label: '在用数',
key: 'num',
labelSpan: 8,
valueSpan: 16,
},
]
const getMaType = () => {
let obj = {
'agreementId': item.value.agreementId,
}
getUseType(obj).then(res => {
console.log(res)
maTypeSelectList.value = res.data.map(option => {
return {
value: option.typeId,
text: option.typeName,
}
})
}).catch(error => {
console.log(error)
})
}
//
const getMaCode = () => {
let obj = {
'agreementId': item.value.agreementId,
'typeId': typeId.value,
}
getUseType(obj).then(res => {
console.log(res)
maCodeSelectList.value = res.data.map(option => {
let obj = {
...option,
bmFileInfos: [],
value: option.typeId,
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 deleteItem = (item) => {
const selectMaCode = (e) => { typeList.value = typeList.value.filter(i => i.itemId !== item.itemId)
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);
}
console.log(typeList.value);
};
const toggleCollapse = () => (collapsed.value = !collapsed.value) //
const onChangeNumber = (item) => { const selectMaCode = (e) => {
console.log(item) const matched = maCodeSelectList.value.find(item => item.typeId == e)
let maxNum = Number(item.num) if (matched) {
// outboundNum.value const itemCopy = JSON.parse(JSON.stringify(matched))
setTimeout(() => { itemCopy.itemId = generateUniqueId()
if (item.unitValue == 1) { itemCopy.preNum = 0
item.preNum = Number(String(item.preNum).replace(/[^\d.]/g, '')) itemCopy.charge = 0
} else { itemCopy.taskId = item.value.id
item.preNum = Number(String(item.preNum).replace(/[^\d]/g, '')) typeList.value.push(itemCopy)
} }
if (Number(item.preNum) <= 0) { console.log(typeList.value)
item.preNum = 0; }
}
if (Number(item.preNum) > maxNum) {
uni.showToast({
title: '已达到当前资最大在用数量!',
icon: 'none',
})
item.preNum = maxNum;
}
}, 500)
}
const submitNum = () => { const toggleCollapse = () => (collapsed.value = !collapsed.value)
console.log(item) const onChangeNumber = (item) => {
const jsonData = JSON.stringify(typeList.value); console.log(item)
console.log(jsonData) let maxNum = Number(item.num)
insertDetails(JSON.parse(jsonData)).then(res => { // outboundNum.value
if(res.code==200){ setTimeout(() => {
uni.showToast({ title: '编辑成功', icon: 'none' }) if (item.unitValue == 1) {
uni.navigateBack({ item.preNum = Number(String(item.preNum).replace(/[^\d.]/g, ''))
delta: 1 // } else {
}); item.preNum = Number(String(item.preNum).replace(/[^\d]/g, ''))
}else{ }
uni.showToast({ title: res.msg, icon: 'none' }) if (Number(item.preNum) <= 0) {
} item.preNum = 0
}).catch(error => { }
console.log(error) if (Number(item.preNum) > maxNum) {
}) uni.showToast({
} title: '已达到当前资最大在用数量!',
icon: 'none',
})
item.preNum = maxNum
}
}, 500)
}
onLoad((options) => { const submitNum = () => {
item.value = JSON.parse(options.item) console.log(item)
getMaType() 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, //
})
} else {
uni.showToast({ title: res.msg, icon: 'none' })
}
}).catch(error => {
console.log(error)
})
}
onLoad((options) => {
item.value = JSON.parse(options.item)
getMaType()
})
</script> </script>
<style lang="scss"> <style lang="scss">
.page-container { .page-container {
display: flex; display: flex;
height: 97vh; height: 97vh;
padding: 24rpx; padding: 24rpx;
flex-direction: column; flex-direction: column;
background-color: #f7f8fa; background-color: #f7f8fa;
.card-container { .card-container {
padding: 24rpx; padding: 24rpx;
background-color: #fff; background-color: #fff;
border-radius: 20rpx; border-radius: 20rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06); box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
margin-bottom: 24rpx; margin-bottom: 24rpx;
.card-header { .card-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
cursor: pointer; cursor: pointer;
.title { .title {
font-size: 32rpx; font-size: 32rpx;
font-weight: 600; font-weight: 600;
color: #262626; color: #262626;
position: relative; position: relative;
padding-left: 24rpx; padding-left: 24rpx;
&::before { &::before {
content: ''; content: '';
position: absolute; position: absolute;
left: 0; left: 0;
top: 50%; top: 50%;
transform: translateY(-50%); transform: translateY(-50%);
width: 6rpx; width: 6rpx;
height: 28rpx; height: 28rpx;
background: #3784fb; background: #3784fb;
border-radius: 6rpx; border-radius: 6rpx;
} }
} }
.header-action { .header-action {
color: #007aff; color: #007aff;
padding-left: 10rpx; padding-left: 10rpx;
} }
} }
} }
.card { .card {
height: 77vh; height: 77vh;
padding: 24rpx; padding: 24rpx;
background-color: #fff; background-color: #fff;
border-radius: 20rpx; border-radius: 20rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06); box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
margin-bottom: 24rpx; margin-bottom: 24rpx;
overflow: hidden; overflow: hidden;
/* 超出隐藏 */ /* 超出隐藏 */
.card-header { .card-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
cursor: pointer; cursor: pointer;
.title { .title {
font-size: 32rpx; font-size: 32rpx;
font-weight: 600; font-weight: 600;
color: #262626; color: #262626;
position: relative; position: relative;
padding-left: 24rpx; padding-left: 24rpx;
&::before { &::before {
content: ''; content: '';
position: absolute; position: absolute;
left: 0; left: 0;
top: 50%; top: 50%;
transform: translateY(-50%); transform: translateY(-50%);
width: 6rpx; width: 6rpx;
height: 28rpx; height: 28rpx;
background: #3784fb; background: #3784fb;
border-radius: 6rpx; border-radius: 6rpx;
} }
} }
.header-action { .header-action {
color: #007aff; color: #007aff;
padding-left: 10rpx; padding-left: 10rpx;
} }
} }
.scroll-container { .scroll-container {
padding: 24rpx; padding: 12rpx;
height: 85%; height: 85%;
.table-list-item { .table-list-item {
margin: 24rpx 0; margin: 24rpx 0;
padding: 24rpx; padding: 24rpx;
background-color: #fff; background-color: #fff;
min-height: 300rpx; min-height: 300rpx;
border-radius: 20rpx; border-radius: 20rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06); box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
transition: all 0.3s ease; transition: all 0.3s ease;
.title { .title {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
// margin-bottom: 20rpx; // margin-bottom: 20rpx;
.title-left { .title-left {
.code { .code {
font-size: 32rpx; font-size: 32rpx;
font-weight: 300; font-weight: 300;
color: #3784fb; color: #3784fb;
letter-spacing: 1rpx; letter-spacing: 1rpx;
} }
} }
span.status { span.status {
padding: 8rpx 28rpx; padding: 8rpx 28rpx;
border-radius: 8rpx; border-radius: 8rpx;
font-size: 26rpx; font-size: 26rpx;
font-weight: 600; font-weight: 600;
&.completed { &.completed {
background-color: rgba(82, 196, 26, 0.1); background-color: rgba(82, 196, 26, 0.1);
color: #52c41a; color: #52c41a;
} }
&.pending { &.pending {
background-color: rgba(250, 140, 22, 0.1); background-color: rgba(250, 140, 22, 0.1);
color: #fa8c16; color: #fa8c16;
} }
} }
} }
.line { .line {
margin: 24rpx 0; margin: 24rpx 0;
height: 2rpx; height: 2rpx;
background: linear-gradient(90deg, background: linear-gradient(90deg,
rgba(232, 232, 232, 0) 0%, rgba(232, 232, 232, 0) 0%,
rgba(232, 232, 232, 1) 50%, rgba(232, 232, 232, 1) 50%,
rgba(232, 232, 232, 0) 100%); rgba(232, 232, 232, 0) 100%);
} }
:deep(.uni-row) { :deep(.uni-row) {
/* margin-bottom: 20rpx; */ /* margin-bottom: 20rpx; */
.uni-col-6 { .uni-col-6 {
color: #8c8c8c; color: #8c8c8c;
font-size: 28rpx; font-size: 28rpx;
font-weight: 500; font-weight: 500;
} }
} }
.cont { .cont {
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
line-height: 1.8; line-height: 1.8;
color: #262626; color: #262626;
font-size: 28rpx; font-size: 28rpx;
font-weight: 500; font-weight: 500;
} }
} }
} }
.loading-text { .loading-text {
text-align: center; text-align: center;
font-size: 26rpx; font-size: 26rpx;
color: #8c8c8c; color: #8c8c8c;
padding: 32rpx 0; padding: 32rpx 0;
letter-spacing: 1rpx; letter-spacing: 1rpx;
} }
} }
.form-item { .form-item {
height: 100%; height: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
} }
.count-input { .count-input {
display: flex; display: flex;
align-items: center; align-items: center;
} }
.footer-btn { .footer-btn {
margin-top: auto; margin-top: auto;
padding: 32rpx; padding: 32rpx;
position: fixed; position: fixed;
bottom: 0; bottom: 0;
left: 0; left: 0;
width: 92%; width: 92%;
z-index: 999; z-index: 999;
/* 保证在顶层 */ /* 保证在顶层 */
display: flex; display: flex;
justify-content: center; justify-content: center;
.btn-cont { .btn-cont {
width: 100%; width: 100%;
height: 88rpx; height: 88rpx;
line-height: 88rpx; line-height: 88rpx;
text-align: center; text-align: center;
background: linear-gradient(135deg, #4b8eff 0%, #3784fb 100%); background: linear-gradient(135deg, #4b8eff 0%, #3784fb 100%);
color: #fff; color: #fff;
border-radius: 44rpx; border-radius: 44rpx;
font-size: 32rpx; font-size: 32rpx;
font-weight: 600; font-weight: 600;
box-shadow: 0 6rpx 20rpx rgba(55, 132, 251, 0.2); box-shadow: 0 6rpx 20rpx rgba(55, 132, 251, 0.2);
&:active { &:active {
transform: scale(0.98); transform: scale(0.98);
opacity: 0.9; opacity: 0.9;
box-shadow: 0 2rpx 8rpx rgba(55, 132, 251, 0.2); box-shadow: 0 2rpx 8rpx rgba(55, 132, 251, 0.2);
} }
} }
} }
} }
</style> </style>