|
|
@ -10,9 +10,9 @@ |
|
|
|
<!-- 保养人 --> |
|
|
|
<view class="form-item"> |
|
|
|
<text class="label">保养人</text> |
|
|
|
<view class="input-area" @click="focusMaintainer"> |
|
|
|
<view class="input-area" > |
|
|
|
<input |
|
|
|
v-model="maintainer" |
|
|
|
v-model="maintenanceName" |
|
|
|
placeholder="请填写" |
|
|
|
class="input-field" |
|
|
|
ref="maintainerInput" |
|
|
@ -35,7 +35,7 @@ |
|
|
|
</view> |
|
|
|
<view class="textarea-container"> |
|
|
|
<uv-textarea |
|
|
|
v-model="beforeStatus" |
|
|
|
v-model="stateFrontText" |
|
|
|
placeholder="请填写保养前的设备内容" |
|
|
|
:maxlength="200" |
|
|
|
:show-confirm-bar="false" |
|
|
@ -47,8 +47,8 @@ |
|
|
|
|
|
|
|
<!-- 保养前图片 --> |
|
|
|
<view class="image-upload"> |
|
|
|
<view v-for="(img, index) in beforeImageList" :key="index" class="image-item"> |
|
|
|
<image :src="img" mode="aspectFill" @click="previewImage(img, beforeImageList)"></image> |
|
|
|
<view v-for="(img, index) in stateFrontImage" :key="index" class="image-item"> |
|
|
|
<image :src="img" mode="aspectFill" @click="previewImage(img, stateFrontImage)"></image> |
|
|
|
<view class="delete-btn" @click="deleteBeforeImage(index)"> |
|
|
|
<uv-icon name="close" size="12" color="#fff"></uv-icon> |
|
|
|
</view> |
|
|
@ -64,7 +64,7 @@ |
|
|
|
</view> |
|
|
|
<view class="textarea-container"> |
|
|
|
<uv-textarea |
|
|
|
v-model="afterStatus" |
|
|
|
v-model="stateBackText" |
|
|
|
placeholder="请填写保养后的设备内容" |
|
|
|
:maxlength="200" |
|
|
|
:show-confirm-bar="false" |
|
|
@ -76,8 +76,8 @@ |
|
|
|
|
|
|
|
<!-- 保养后图片 --> |
|
|
|
<view class="image-upload"> |
|
|
|
<view v-for="(img, index) in afterImageList" :key="index" class="image-item"> |
|
|
|
<image :src="img" mode="aspectFill" @click="previewImage(img, afterImageList)"></image> |
|
|
|
<view v-for="(img, index) in stateBackImage" :key="index" class="image-item"> |
|
|
|
<image :src="img" mode="aspectFill" @click="previewImage(img, stateBackImage)"></image> |
|
|
|
<view class="delete-btn" @click="deleteAfterImage(index)"> |
|
|
|
<uv-icon name="close" size="12" color="#fff"></uv-icon> |
|
|
|
</view> |
|
|
@ -93,25 +93,25 @@ |
|
|
|
<view class="radio-options"> |
|
|
|
<view |
|
|
|
class="radio-item" |
|
|
|
:class="{ active: hasCost === true }" |
|
|
|
:class="{ active: isExpend === true }" |
|
|
|
@click="selectCost(true)" |
|
|
|
> |
|
|
|
<view class="radio-dot" :class="{ active: hasCost === true }"></view> |
|
|
|
<text :class="{ active: hasCost === true }">是</text> |
|
|
|
<view class="radio-dot" :class="{ active: isExpend === true }"></view> |
|
|
|
<text :class="{ active: isExpend === true }">是</text> |
|
|
|
</view> |
|
|
|
<view |
|
|
|
class="radio-item" |
|
|
|
:class="{ active: hasCost === false }" |
|
|
|
:class="{ active: isExpend === false }" |
|
|
|
@click="selectCost(false)" |
|
|
|
> |
|
|
|
<view class="radio-dot" :class="{ active: hasCost === false }"></view> |
|
|
|
<text :class="{ active: hasCost === false }">否</text> |
|
|
|
<view class="radio-dot" :class="{ active: isExpend === false }"></view> |
|
|
|
<text :class="{ active: isExpend === false }">否</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 产生费用 --> |
|
|
|
<view v-if="hasCost" class="cost-section"> |
|
|
|
<view v-if="isExpend" class="cost-section"> |
|
|
|
<view class="form-item form-item-header"> |
|
|
|
<text class="label active">产生费用</text> |
|
|
|
</view> |
|
|
@ -183,7 +183,7 @@ |
|
|
|
</view> |
|
|
|
<view class="textarea-container"> |
|
|
|
<uv-textarea |
|
|
|
v-model="remark" |
|
|
|
v-model="remarkText" |
|
|
|
placeholder="请填写备注" |
|
|
|
:maxlength="200" |
|
|
|
:show-confirm-bar="false" |
|
|
@ -195,8 +195,8 @@ |
|
|
|
|
|
|
|
<!-- 附件图片 --> |
|
|
|
<view class="image-upload"> |
|
|
|
<view v-for="(img, index) in attachmentList" :key="index" class="image-item"> |
|
|
|
<image :src="img" mode="aspectFill" @click="previewImage(img, attachmentList)"></image> |
|
|
|
<view v-for="(img, index) in remarkImage" :key="index" class="image-item"> |
|
|
|
<image :src="img" mode="aspectFill" @click="previewImage(img, remarkImage)"></image> |
|
|
|
<view class="delete-btn" @click="deleteAttachment(index)"> |
|
|
|
<uv-icon name="close" size="12" color="#fff"></uv-icon> |
|
|
|
</view> |
|
|
@ -221,7 +221,7 @@ |
|
|
|
</view> |
|
|
|
<view class="textarea-container"> |
|
|
|
<uv-textarea |
|
|
|
v-model="finalRemark" |
|
|
|
v-model="remark" |
|
|
|
placeholder="请填写备注" |
|
|
|
:maxlength="200" |
|
|
|
:show-confirm-bar="false" |
|
|
@ -237,6 +237,7 @@ |
|
|
|
<uv-button |
|
|
|
type="primary" |
|
|
|
text="立即提交" |
|
|
|
:disabled="submiting" |
|
|
|
:custom-style="{ backgroundColor: '#C70019', borderRadius: '25px' }" |
|
|
|
@click="submitMaintenance" |
|
|
|
></uv-button> |
|
|
@ -266,22 +267,29 @@ export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
// 表单数据 |
|
|
|
maintainer: '', |
|
|
|
maintenanceName: '', |
|
|
|
maintenanceDate: '', |
|
|
|
beforeStatus: '', |
|
|
|
beforeImageList: [], |
|
|
|
afterStatus: '', |
|
|
|
afterImageList: [], |
|
|
|
hasCost: null, |
|
|
|
stateFrontText: '', |
|
|
|
stateFrontImage: [], |
|
|
|
stateBackText: '', |
|
|
|
stateBackImage: [], |
|
|
|
isExpend: false, |
|
|
|
newCostName: '', |
|
|
|
costList: [], |
|
|
|
remark: '', |
|
|
|
attachmentList: [], |
|
|
|
remarkText: '', |
|
|
|
remarkImage: [], |
|
|
|
nextMaintenanceDate: '', |
|
|
|
finalRemark: '' |
|
|
|
remark: '', |
|
|
|
showpieceId: '', |
|
|
|
submiting: false |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
// 计算总金额 |
|
|
|
amount() { |
|
|
|
return this.costList.reduce((sum, item) => sum + (parseFloat(item.amount) || 0), 0) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
methods: { |
|
|
|
// 显示日期选择器 |
|
|
|
showDatePicker() { |
|
|
@ -315,7 +323,7 @@ export default { |
|
|
|
|
|
|
|
// 选择是否产生费用 |
|
|
|
selectCost(value) { |
|
|
|
this.hasCost = value |
|
|
|
this.isExpend = value |
|
|
|
if (!value) { |
|
|
|
this.costList = [] |
|
|
|
this.newCostName = '' |
|
|
@ -365,7 +373,7 @@ export default { |
|
|
|
if (result && result.success) { |
|
|
|
console.log(result); |
|
|
|
|
|
|
|
this.beforeImageList.push(result.url) |
|
|
|
this.stateFrontImage.push(result.url) |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('图片上传失败:', error) |
|
|
@ -378,7 +386,7 @@ export default { |
|
|
|
|
|
|
|
// 删除保养前图片 |
|
|
|
deleteBeforeImage(index) { |
|
|
|
this.beforeImageList.splice(index, 1) |
|
|
|
this.stateFrontImage.splice(index, 1) |
|
|
|
}, |
|
|
|
|
|
|
|
// 上传保养后图片 |
|
|
@ -388,7 +396,7 @@ export default { |
|
|
|
if (result && result.success) { |
|
|
|
console.log(result); |
|
|
|
|
|
|
|
this.afterImageList.push(result.url) |
|
|
|
this.stateBackImage.push(result.url) |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('头像上传失败:', error) |
|
|
@ -401,7 +409,7 @@ export default { |
|
|
|
|
|
|
|
// 删除保养后图片 |
|
|
|
deleteAfterImage(index) { |
|
|
|
this.afterImageList.splice(index, 1) |
|
|
|
this.stateBackImage.splice(index, 1) |
|
|
|
}, |
|
|
|
|
|
|
|
// 上传附件 |
|
|
@ -412,7 +420,7 @@ export default { |
|
|
|
if (result && result.success) { |
|
|
|
console.log(result); |
|
|
|
|
|
|
|
this.attachmentList.push(result.url) |
|
|
|
this.remarkImage.push(result.url) |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('头像上传失败:', error) |
|
|
@ -425,7 +433,7 @@ export default { |
|
|
|
|
|
|
|
// 删除附件 |
|
|
|
deleteAttachment(index) { |
|
|
|
this.attachmentList.splice(index, 1) |
|
|
|
this.remarkImage.splice(index, 1) |
|
|
|
}, |
|
|
|
|
|
|
|
// 预览图片 |
|
|
@ -435,56 +443,64 @@ export default { |
|
|
|
current: url |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 聚焦输入框方法 |
|
|
|
focusMaintainer() { |
|
|
|
this.$refs.maintainerInput.focus() |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 提交保养 |
|
|
|
submitMaintenance() { |
|
|
|
async submitMaintenance() { |
|
|
|
// 表单验证 |
|
|
|
if (!this.maintainer.trim()) { |
|
|
|
if (!this.maintenanceName.trim()) { |
|
|
|
uni.showToast({ title: '请填写保养人', icon: 'none' }) |
|
|
|
return |
|
|
|
} |
|
|
|
if (!this.maintenanceDate) { |
|
|
|
uni.showToast({ title: '请选择保养日期', icon: 'none' }) |
|
|
|
return |
|
|
|
} |
|
|
|
if (!this.beforeStatus.trim()) { |
|
|
|
// 先去掉日期限制 |
|
|
|
// if (!this.maintenanceDate) { |
|
|
|
// uni.showToast({ title: '请选择保养日期', icon: 'none' }) |
|
|
|
// return |
|
|
|
// } |
|
|
|
if (!this.stateFrontText.trim()) { |
|
|
|
uni.showToast({ title: '请填写保养前状态', icon: 'none' }) |
|
|
|
return |
|
|
|
} |
|
|
|
if (!this.afterStatus.trim()) { |
|
|
|
if (!this.stateBackText.trim()) { |
|
|
|
uni.showToast({ title: '请填写保养后状态', icon: 'none' }) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 提交数据 |
|
|
|
const formData = { |
|
|
|
maintainer: this.maintainer, |
|
|
|
maintenanceName: this.maintenanceName, |
|
|
|
maintenanceDate: this.maintenanceDate, |
|
|
|
beforeStatus: this.beforeStatus, |
|
|
|
beforeImageList: this.beforeImageList, |
|
|
|
afterStatus: this.afterStatus, |
|
|
|
afterImageList: this.afterImageList, |
|
|
|
hasCost: this.hasCost, |
|
|
|
costList: this.costList, |
|
|
|
remark: this.remark, |
|
|
|
attachmentList: this.attachmentList, |
|
|
|
stateFrontText: this.stateFrontText, |
|
|
|
stateFrontImage: this.stateFrontImage?.join(',') || '', |
|
|
|
stateBackText: this.stateBackText, |
|
|
|
stateBackImage: this.stateBackImage?.join(',') || '', |
|
|
|
isExpend: this.isExpend, |
|
|
|
amount: this.amount, |
|
|
|
remarkText: this.remarkText, |
|
|
|
remarkImage: this.remarkImage?.join(',') || '', |
|
|
|
nextMaintenanceDate: this.nextMaintenanceDate, |
|
|
|
finalRemark: this.finalRemark |
|
|
|
remark: this.remark, |
|
|
|
showpieceId: this.showpieceId |
|
|
|
} |
|
|
|
|
|
|
|
console.log('提交数据:', formData) |
|
|
|
uni.showToast({ title: '提交成功', icon: 'success' }) |
|
|
|
|
|
|
|
// 返回上一页 |
|
|
|
setTimeout(() => { |
|
|
|
uni.navigateBack() |
|
|
|
}, 1500) |
|
|
|
this.submiting = true |
|
|
|
const subRes = await this.$api.exhibit.addMaintenance(formData) |
|
|
|
if(subRes.code == 200){ |
|
|
|
uni.showToast({ title: subRes.message, icon: 'success' }) |
|
|
|
// 返回上一页 |
|
|
|
setTimeout(() => { |
|
|
|
uni.navigateBack() |
|
|
|
}, 1000) |
|
|
|
}else{ |
|
|
|
uni.showToast({ title: subRes.message, icon: 'none' }) |
|
|
|
} |
|
|
|
this.submiting = false |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad(options) { |
|
|
|
this.showpieceId = options.id |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|