|
|
@ -93,25 +93,25 @@ |
|
|
|
<view class="radio-options"> |
|
|
|
<view |
|
|
|
class="radio-item" |
|
|
|
:class="{ active: isExpend === true }" |
|
|
|
@click="selectCost(true)" |
|
|
|
:class="{ active: isExpend === '1' }" |
|
|
|
@click="selectCost('1')" |
|
|
|
> |
|
|
|
<view class="radio-dot" :class="{ active: isExpend === true }"></view> |
|
|
|
<text :class="{ active: isExpend === true }">是</text> |
|
|
|
<view class="radio-dot" :class="{ active: isExpend === '1' }"></view> |
|
|
|
<text :class="{ active: isExpend === '1' }">是</text> |
|
|
|
</view> |
|
|
|
<view |
|
|
|
class="radio-item" |
|
|
|
:class="{ active: isExpend === false }" |
|
|
|
@click="selectCost(false)" |
|
|
|
:class="{ active: isExpend === '0' }" |
|
|
|
@click="selectCost('0')" |
|
|
|
> |
|
|
|
<view class="radio-dot" :class="{ active: isExpend === false }"></view> |
|
|
|
<text :class="{ active: isExpend === false }">否</text> |
|
|
|
<view class="radio-dot" :class="{ active: isExpend === '0' }"></view> |
|
|
|
<text :class="{ active: isExpend === '0' }">否</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 产生费用 --> |
|
|
|
<view v-if="isExpend" class="cost-section"> |
|
|
|
<view v-if="isExpend === '1'" class="cost-section"> |
|
|
|
<view class="form-item form-item-header"> |
|
|
|
<text class="label active">产生费用</text> |
|
|
|
</view> |
|
|
@ -244,21 +244,19 @@ |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 日期选择器 --> |
|
|
|
<uv-picker |
|
|
|
<uv-datetime-picker |
|
|
|
confirm-color="#C70019" |
|
|
|
ref="datePicker" |
|
|
|
mode="date" |
|
|
|
@confirm="confirmDate" |
|
|
|
@cancel="cancelDate" |
|
|
|
></uv-picker> |
|
|
|
></uv-datetime-picker> |
|
|
|
|
|
|
|
<uv-picker |
|
|
|
<uv-datetime-picker |
|
|
|
confirm-color="#C70019" |
|
|
|
ref="nextDatePicker" |
|
|
|
mode="date" |
|
|
|
@confirm="confirmNextDate" |
|
|
|
@cancel="cancelNextDate" |
|
|
|
></uv-picker> |
|
|
|
></uv-datetime-picker> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
@ -273,7 +271,7 @@ export default { |
|
|
|
stateFrontImage: [], |
|
|
|
stateBackText: '', |
|
|
|
stateBackImage: [], |
|
|
|
isExpend: false, |
|
|
|
isExpend: '0', |
|
|
|
newCostName: '', |
|
|
|
costList: [], |
|
|
|
remarkText: '', |
|
|
@ -287,7 +285,7 @@ export default { |
|
|
|
computed: { |
|
|
|
// 计算总金额 |
|
|
|
amount() { |
|
|
|
return this.costList.reduce((sum, item) => sum + (parseFloat(item.amount) || 0), 0) |
|
|
|
return this.costList.reduce((sum, item) => sum + (parseFloat(item.amount) * Number(item.quantity) || 0), 0) |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
@ -298,12 +296,11 @@ export default { |
|
|
|
|
|
|
|
// 确认日期 |
|
|
|
confirmDate(e) { |
|
|
|
this.maintenanceDate = e.value |
|
|
|
}, |
|
|
|
|
|
|
|
// 取消日期选择 |
|
|
|
cancelDate() { |
|
|
|
// 取消操作 |
|
|
|
// uv-datetime-picker返回的是时间戳,需要转换为日期格式 |
|
|
|
const date = new Date(e.value) |
|
|
|
this.maintenanceDate = date.getFullYear() + '-' + |
|
|
|
String(date.getMonth() + 1).padStart(2, '0') + '-' + |
|
|
|
String(date.getDate()).padStart(2, '0') |
|
|
|
}, |
|
|
|
|
|
|
|
// 显示下次保养日期选择器 |
|
|
@ -313,12 +310,11 @@ export default { |
|
|
|
|
|
|
|
// 确认下次保养日期 |
|
|
|
confirmNextDate(e) { |
|
|
|
this.nextMaintenanceDate = e.value |
|
|
|
}, |
|
|
|
|
|
|
|
// 取消下次保养日期选择 |
|
|
|
cancelNextDate() { |
|
|
|
// 取消操作 |
|
|
|
// uv-datetime-picker返回的是时间戳,需要转换为日期格式 |
|
|
|
const date = new Date(e.value) |
|
|
|
this.nextMaintenanceDate = date.getFullYear() + '-' + |
|
|
|
String(date.getMonth() + 1).padStart(2, '0') + '-' + |
|
|
|
String(date.getDate()).padStart(2, '0') |
|
|
|
}, |
|
|
|
|
|
|
|
// 选择是否产生费用 |
|
|
@ -452,11 +448,7 @@ export default { |
|
|
|
uni.showToast({ title: '请填写保养人', icon: 'none' }) |
|
|
|
return |
|
|
|
} |
|
|
|
// 先去掉日期限制 |
|
|
|
// if (!this.maintenanceDate) { |
|
|
|
// uni.showToast({ title: '请选择保养日期', icon: 'none' }) |
|
|
|
// return |
|
|
|
// } |
|
|
|
|
|
|
|
if (!this.stateFrontText.trim()) { |
|
|
|
uni.showToast({ title: '请填写保养前状态', icon: 'none' }) |
|
|
|
return |
|
|
@ -466,15 +458,22 @@ export default { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.isExpend === '1' && !this.amount){ |
|
|
|
uni.showToast({ title: '请填写消费', icon: 'none' }) |
|
|
|
return |
|
|
|
} |
|
|
|
// 把costList切换成字符串并用,,;分割 |
|
|
|
// 提交数据 |
|
|
|
const formData = { |
|
|
|
maintenanceName: this.maintenanceName, |
|
|
|
maintenanceDate: this.maintenanceDate, |
|
|
|
maintenanceDate: this.maintenanceDate, |
|
|
|
stateFrontText: this.stateFrontText, |
|
|
|
stateFrontImage: this.stateFrontImage?.join(',') || '', |
|
|
|
stateBackText: this.stateBackText, |
|
|
|
stateBackImage: this.stateBackImage?.join(',') || '', |
|
|
|
expenseList: this.costList.map(item => { |
|
|
|
return `${item.name},${item.quantity},${item.amount}` |
|
|
|
}).join(';'), |
|
|
|
isExpend: this.isExpend, |
|
|
|
amount: this.amount, |
|
|
|
remarkText: this.remarkText, |
|
|
@ -486,17 +485,22 @@ export default { |
|
|
|
|
|
|
|
|
|
|
|
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' }) |
|
|
|
try{ |
|
|
|
|
|
|
|
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' }) |
|
|
|
} |
|
|
|
}catch(err){ |
|
|
|
// uni.showToast({ title: err.message, icon: 'none' }) |
|
|
|
this.submiting = false |
|
|
|
} |
|
|
|
this.submiting = false |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad(options) { |
|
|
|