594 lines
14 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="deetailPage">
<headers :showBack="true">
<view class="headerName">
进度管理系统
</view>
</headers>
<view class="content">
<view class="title">
工程进度
</view>
<view class="b-bottom2">
<view class="name"><text class="mustStar">*</text>上报时间</view>
<view class="inputFrom">
<dateTimePiccker fields="minute" :defaultValue=form.uploadDate
@change="bindPickerChange($event,'startTime')" class="dateTimePiccker">
<view class="uni-input uni-select cl" v-if="form.uploadDate===''">
请选择 <image class="icon-right" src="/static/icon-right-ccc.png"></image>
</view>
<view class="uni-input uni-select" v-else>{{form.uploadDate}}
<image class="icon-right" src="/static/icon-right.png"></image>
</view>
</dateTimePiccker>
</view>
</view>
<view class="b-bottom" style="display: block;">
<view class="name"><text class="mustStar">*</text>上报进度</view>
<view class="inputFrom" style="width: 100%;margin-left: 0px;">
<slider :value="form.progressRatio" @change="sliderChange" min="0" max="100" show-value />
</view>
</view>
<view class="b-bottom-textarea">
<view class="name">反馈内容</view>
<textarea auto-height :maxlength="-1" @input='supplementTextarea' :value="form.feedbackContent"
placeholder="多行输入"></textarea>
</view>
<view class="b-bottom" style="border-bottom: 2rpx solid #f0f0f0;">
<view class="name">上传图片</view>
<view class="uni-form-input imgBox_wrap">
<view class="imgBox" v-show="imgFileList.length>0" v-for="(item,index) in imgFileList" :key="index">
<image :src="url_config+'image/'+item.url" class="img"
@click="previewImage(url_config+'image/'+item.url)"></image>
<view @click="deleteImg(item)" style="margin: 10rpx;" class="deleteImg">×</view>
</view>
<view class="addImgBox" @click="uploadImg()" v-if="imgFileList.length<5">
<image src="/static/icon-add.png" class="icon-add"></image>
</view>
</view>
</view>
<view class="delay-content" style="border-bottom: 2rpx solid #f0f0f0;">
<view class="name"><text class="mustStar">*</text>是否有延期误工事件</view>
<radio-group class="radio_box" @change="radioChange">
<label class="radio">
<radio value="1" />是
</label>
<label class="radio">
<radio value="0" checked="true" />否
</label>
</radio-group>
</view>
<view class="b-bottom-textarea" v-if="form.hasDelayEvent == 1">
<view class="name" style="width: 30%;"><text class="mustStar">*</text>延期误工原因</view>
<textarea auto-height :maxlength="-1" @input='reasonTextarea' :value="form.delayEventReason"
placeholder="多行输入"></textarea>
</view>
<view class="delay-reason-content" style="border-bottom: 2rpx solid #f0f0f0;"
v-if="form.hasDelayEvent == 1">
<view class="name"><text class="mustStar">*</text>延期原因类型</view>
<checkbox-group class="check_box" @change="checkChange">
<label class="check">
<checkbox value="1" />人为因素
</label>
<label class="check">
<checkbox value="2" />环境因素
</label>
<label class="check">
<checkbox value="3" />不可抵抗因素
</label>
</checkbox-group>
</view>
<!-- <view class="title">
材料用量
</view>
<view class="martNum" v-for="(item, index) in materialList" :key="index">
<view class="name">{{item.name}}</view>
<input type="number" placeholder-class="cl" class="inpuStyle uni-select cl" :value="item.actualUsage"
placeholder="请输入" @input='eventData($event,index)' />
<view class="unit">{{item.unit}}</view>
</view> -->
<view class="addProgess" @click="addSaveBtn">
提交
</view>
</view>
</view>
</template>
<script>
import dateTimePiccker from '@/components/dateTimePicker/index.vue'
export default {
components: {
dateTimePiccker
},
data() {
return {
form: {
uploadDate: '',
progressRatio: 0,
feedbackContent: '',
hasDelayEvent: '0',
delayEventReason: '',
delayEventType: []
},
imgFileList: [],
projectSn: '',
materialList: [],
itemForm: {}
}
},
onLoad(option) {
this.projectSn = JSON.parse(uni.getStorageSync('projectDetail')).projectSn;
this.itemForm = JSON.parse(decodeURIComponent(option.item));
console.log("数据itemForm",this.itemForm)
},
onShow() {
// this.getList()
},
methods: {
checkChange(e) {
console.log(e, 777)
this.form.delayEventType = e.detail.value
},
radioChange(e) {
console.log(e, 666)
this.form.hasDelayEvent = e.detail.value;
},
//获取材料用量列表
getList() {
let data = {
projectSn: this.projectSn,
taskProgressId: this.itemForm.id,
}
this.sendRequest({
url: 'xmgl/xzTaskProgressMaterialRel/detailList',
method: 'get',
data,
success: res => {
if (res.result.length > 0) {
console.log('获取材料用量列表', res);
this.materialList = res.result
this.getDetail()
}
}
})
},
// /xmgl/xzTaskProgressContent/list?lang=zh_CN&taskProgressId=1722560016547635200
//获取任务
getDetail() {
let data = {
taskProgressId: this.itemForm.id,
}
this.sendRequest({
url: 'xmgl/xzTaskProgressContent/list',
method: 'get',
data,
success: res => {
if (res.result.length > 0) {
console.log('获取上传进度详情-----', res);
this.form.uploadDate = res.result[0].uploadDate
this.form.progressRatio = res.result[0].progressRatio
this.form.feedbackContent = res.result[0].feedbackContent
console.log('获取上传进度详情+++++', this.form);
if (res.result[0].image !== "") {
this.imgFileList = JSON.parse(res.result.image)
}
} else {
this.selectNowDate()
}
}
})
},
sliderChange(e) {
this.form.progressRatio = e.detail.value
},
bindPickerChange(e, type) {
if (type == 'startTime') {
this.form.uploadDate = e.f3;
}
},
// 延期误工原因
reasonTextarea(e) {
this.form.delayEventReason = e.detail.value
},
//反馈内容
supplementTextarea(e) {
this.form.feedbackContent = e.detail.value
},
//材料用量
eventData(e, index) {
this.materialList[index].actualUsage = e.detail.value;
console.log('输入的数据', this.materialList[index].actualUsage);
},
//预览图片
previewImage(url) {
uni.previewImage({
urls: [url]
})
},
uploadImg(type) {
var that = this
uni.chooseImage({
count: 5 - that.imgFileList.length,
success(res) {
const tempFilePaths = res.tempFilePaths;
uni.uploadFile({
url: that.url_config + 'upload/image', //仅为示例,非真实的接口地址
filePath: tempFilePaths[0],
name: 'files',
success: (uploadFileRes) => {
let data = {
name: JSON.parse(uploadFileRes.data).data[0].filename,
url: JSON.parse(uploadFileRes.data).data[0].imageUrl
};
that.imgFileList.push(data)
}
});
}
})
},
//删除附件
deleteImg(val) {
let that = this;
uni.showModal({
title: '提示',
content: '确定删除该附件吗?',
success: function(res) {
if (res.confirm) {
let fileArr = JSON.parse(JSON.stringify(that.imgFileList));
fileArr.forEach((item, index) => {
if (item.url == val.url) {
fileArr.splice(index, 1)
}
})
that.imgFileList = fileArr;
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
},
//新增保存
addSaveBtn() {
console.log(this.form, 111222);
if (this.form.uploadDate == "") {
uni.showToast({
title: "请选择上报时间",
icon: 'none'
})
return
}
if (this.form.hasDelayEvent !== '0') {
if (!this.form.delayEventReason) {
uni.showToast({
title: "请输入延期误工原因",
icon: 'none'
})
return
}
if (this.form.delayEventType.length == 0) {
uni.showToast({
title: "请选择延期原因类型",
icon: 'none'
})
return
}
}
let data = JSON.parse(JSON.stringify(this.form));
data.projectSn = this.projectSn;
data.taskProgressId = String(this.itemForm.id)
data.image = JSON.stringify(this.imgFileList)
data.typeDataList = this.materialList
console.log('新增提交的数据', data);
data.delayEventType = this.form.delayEventType.join(',')
if (+this.form.progressRatio <= +this.itemForm.progressRatio) {
uni.showToast({
title: "上报进度必须大于当前进度",
icon: 'none'
})
return;
}
this.sendRequest({
url: 'xmgl/xzTaskProgressContent/add',
method: 'post',
data: data,
success: (res) => {
console.log(res)
if (res.code == 200) {
uni.showToast({
title: '保存成功'
})
setTimeout(() => {
uni.navigateBack({
delta: 1
})
}, 1000)
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
}
}
})
},
selectNowDate() {
let date = new Date(),
year = date.getFullYear(),
month = date.getMonth() + 1,
day = date.getDate(),
hours = date.getHours(), //获取当前小时数(0-23)
minutes = date.getMinutes(), //获取当前分钟数(0-59)
seconds = date.getSeconds()
month >= 1 && month <= 9 ? (month = '0' + month) : ''
day >= 0 && day <= 9 ? (day = '0' + day) : ''
hours >= 0 && hours <= 9 ? (hours = '0' + hours) : ''
minutes >= 0 && minutes <= 9 ? (minutes = '0' + minutes) : ''
seconds >= 0 && seconds <= 9 ? (seconds = '0' + seconds) : ''
let timer = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
// console.log(timer)
this.form.uploadDate = timer
},
}
}
</script>
<style lang="less">
.content {
width: 100%;
box-sizing: border-box;
padding: 20rpx 30rpx;
font-size: 28rpx;
.title {
font-weight: bold;
font-size: 30rpx;
margin: 20rpx 0 30rpx 4rpx;
}
.b-bottom2 {
display: flex;
margin-bottom: 30rpx;
.name {
width: 20%;
}
.inputFrom {
width: 80%;
margin-left: 20rpx;
}
}
.b-bottom {
border-top: 2rpx solid #f0f0f0;
display: flex;
// height: 200rpx;
line-height: 80rpx;
.inputFrom {
width: 80%;
margin-left: 40rpx;
}
.name {
width: 20%;
}
.icon-right {
margin-left: 16rpx;
width: 16rpx;
height: 32rpx;
}
}
.b-bottom-textarea {
border-top: 2rpx solid #f0f0f0;
display: flex;
min-height: 200rpx;
// line-height: 80rpx;
padding-top: 20rpx;
.inputFrom {
width: 80%;
margin-left: 40rpx;
}
.name {
width: 20%;
}
.icon-right {
margin-left: 16rpx;
width: 16rpx;
height: 32rpx;
}
:deep(.uni-textarea-placeholder ){
font-size: 28rpx;
}
}
.delay-content {
border-top: 2rpx solid #f0f0f0;
display: flex;
align-items: center;
justify-content: space-between;
height: 200rpx;
.name {
width: 50%;
}
.radio_box {
display: flex;
.radio {
margin-right: 40rpx;
display: flex;
align-items: center;
}
// :deep(.uni-radio-input){
// width: 28rpx;
// height: 28rpx;
// font-size: 28rpx;
// }
// :deep(.uni-radio-input-checked::before){
// font-size: 28rpx;
// }
}
}
.delay-reason-content {
border-top: 2rpx solid #f0f0f0;
display: flex;
height: 200rpx;
padding-top: 20rpx;
.name {
width: 28%;
}
.check_box {
display: flex;
flex-direction: column;
.check {
margin-bottom: 20rpx;
display: flex;
align-items: center;
}
:deep(.uni-checkbox-input ){
width: 28rpx;
height: 28rpx;
font-size: 28rpx;
}
:deep(.uni-checkbox-input-checked::before ){
font-size: 28rpx;
}
}
}
.addProgess {
width: 50%;
background: #5181f6;
text-align: center;
margin: auto;
height: 60rpx;
color: #fff;
border-radius: 40rpx;
line-height: 60rpx;
margin-top: 110rpx;
font-size: 28rpx;
}
}
::v-deep .uni-slider-thumb {
width: 30rpx !important;
height: 26rpx !important;
margin-top: -7px !important;
}
.imgBox_wrap {
display: flex;
flex-wrap: wrap;
margin-top: 20rpx;
margin-bottom: 20rpx;
width: 75%;
}
.addImgBox {
border: 1px solid rgba(42, 43, 91, 0.1);
background-color: #f6f5f8;
width: 120rpx;
height: 120rpx;
display: inline-flex;
align-items: center;
justify-content: center;
border-radius: 20rpx;
font-size: 24rpx;
.icon-add {
width: 36rpx;
height: 36rpx;
}
}
.deleteImg {
position: absolute;
right: -6rpx;
top: -36rpx;
font-size: 30rpx;
color: #fff;
}
.imgBox {
width: 120rpx;
height: 120rpx;
display: inline-flex;
position: relative;
margin-right: 30rpx;
margin-bottom: 16rpx;
.img {
width: 100%;
height: 100%;
border-radius: 20rpx;
}
.deleteImg {
position: absolute;
right: -6rpx;
top: -36rpx;
font-size: 30rpx;
color: #fff;
}
}
.textarea {
width: calc(79% - 64rpx);
padding: 16rpx 30rpx;
box-sizing: border-box;
}
.martNum {
display: flex;
align-items: center;
margin: 20rpx 20rpx 0 20rpx;
border-bottom: 2rpx solid #f0f0f0;
padding-bottom: 20rpx;
.name {
width: 15%;
// white-space: nowrap;
}
.unit {
width: 10%;
margin-left: 80rpx;
text-align: center;
white-space: nowrap;
}
}
::v-deep .uni-input-input {
color: #000 !important;
}
.mustStar {
color: red;
}
</style>