SmartStorage/pages/waitCrash/waitCrash.vue

151 lines
3.8 KiB
Vue
Raw Normal View History

2023-12-20 15:15:23 +08:00
<template>
<view>
<view class="form-area">
<uni-forms :modelValue="crashForm" label-position="top">
<uni-forms-item
label="报废数量"
v-show="ifNo == 0"
>
<uni-easyinput type="number" placeholder="请输入" v-model="crashForm.scrapNum"></uni-easyinput>
</uni-forms-item>
<uni-forms-item
label="报废原因"
>
<uni-easyinput placeholder="请输入报废原因" v-model="crashForm.scrapReason"></uni-easyinput>
</uni-forms-item>
<uni-forms-item
label="损坏原因"
>
<uni-data-checkbox v-model="crashForm.scrapType" :localdata="brokeRange"></uni-data-checkbox>
</uni-forms-item>
<uni-forms-item
label="备注"
>
<uni-easyinput placeholder="请输入" v-model="crashForm.remark"></uni-easyinput>
</uni-forms-item>
<uni-forms-item
label="报废图片"
>
<uni-file-picker
v-model="crashForm.ids"
@select="uploadPhoto"
limit="3"
title="最多选择3张图片"
:del-icon="false"
></uni-file-picker>
</uni-forms-item>
<button style="background-color: #3788FF; color: #fff;" @click="subForm">提交</button>
</uni-forms>
</view>
<u-loading-page :loading="showLoading" color="#000" loading-text="表单提交中,请稍后..."></u-loading-page>
</view>
</template>
<script>
import { basePath, systemPath } from '../../public';
export default {
data() {
return {
ifNo: '',
showLoading: false,
crashForm: {
scrapNum: 1,
scrapReason: '',
scrapType: '',
remark: '',
fileIds: []
},
brokeRange: [
{ text: '人为', value: '1' },
{ text: '自然', value: '0' }
],
totalSub: {},
id: '',
taskId: '',
maId: '',
typeId: ''
}
},
methods: {
uploadPhoto (e) {
let that = this
console.log(e);
// this.crashForm.crashPic = e.tempFilePaths
// 上传图片
for (let i = 0; i < e.tempFilePaths.length; i++) {
uni.uploadFile({
url: systemPath + '/sys/file/upload', //仅为示例,非真实的接口地址
filePath: e.tempFilePaths[i],
name: 'file',
success: (res) => {
let dealedData = JSON.parse(res.data)
if (dealedData.code == 200) {
console.log(dealedData);
that.crashForm.fileIds.push(dealedData.data.id)
}
}
});
}
},
subForm () {
let that = this
console.log(this.crashForm);
this.crashForm.fileIds = this.crashForm.fileIds.join(',')
this.crashForm.id = this.id
this.crashForm.taskId = this.taskId
this.crashForm.maId = this.maId
this.crashForm.typeId = this.typeId
this.crashForm.companyId = uni.getStorageSync('userInfo').sysUser.companyId
this.crashForm.userId = uni.getStorageSync('userInfo').userid
this.crashForm.repairType = 3
console.log(this.crashForm);
this.showLoading = true
uni.request({
url: basePath + '/repair/submitRepairApply',
method: 'POST',
header: {
'content-type': 'application/json',
'Authorization': uni.getStorageSync('token')
},
data: this.crashForm,
success: (res) => {
console.log(res);
if (res.data.code == 200) {
uni.showToast({
icon: 'none',
title: res.data.msg,
success: () => {
that.showLoading = false
uni.switchTab({
url: '/pages/workSpace/workSpace'
})
}
})
} else {
that.showLoading = false
uni.showToast({
icon: 'none',
title: res.data.msg
})
}
}
})
}
},
onLoad(params) {
this.id = params.id
this.taskId = params.taskId
this.maId = params.maId
this.typeId = params.typeId
this.ifNo = params.ifNo
}
}
</script>
<style lang="scss">
.form-area{
width: 90%;
margin: 2vh auto;
}
</style>