<template>
|
<view class="box">
|
<view class="box_head">观察主题:{{themeName}}</view>
|
<u-gap height="5" bgColor="#F9F9F9"></u-gap>
|
<u-collapse :value="collapseList" ref="collapse">
|
<template v-if="!workOrderId">
|
<u-collapse-item name="1" :title="item.name" v-for="(item, a) in list" :key="a">
|
<view style="width: 12rpx; height: 32rpx; background-color: #206EEE; margin-right: 8rpx;" slot="icon">
|
</view>
|
<view class="list">
|
<view class="list_row" v-for="(child, b) in item.childList" :key="b">
|
<view class="list_row_title">{{b + 1}}. {{child.name}}</view>
|
<view class="list_row_radio">
|
<u-radio-group v-model="child.value" placement="row" @change="$refs.collapse.init()">
|
<u-radio name="1" label="符合" :disabled="workOrderId ? true : false"></u-radio>
|
<u-radio name="2" label="不符合" :disabled="workOrderId ? true : false"></u-radio>
|
</u-radio-group>
|
</view>
|
<view class="list_row_textarea" v-if="child.value === '2'">
|
<u--textarea v-model="child.eventInfo" placeholder="请输入不符合原因"></u--textarea>
|
</view>
|
<view class="list_row_upload" v-if="child.value === '2'">
|
<view class="list_row_upload_label">图片</view>
|
<u-upload
|
:fileList="child.multifileList"
|
@afterRead="afterRead($event, a, b)"
|
@delete="deletePic($event, a, b)"
|
:name="(b + 1).toString()"
|
multiple />
|
</view>
|
</view>
|
</view>
|
</u-collapse-item>
|
</template>
|
<template v-else>
|
<u-collapse-item name="1" :title="item.childTitle" v-for="(item, a) in list1" :key="a">
|
<view style="width: 12rpx; height: 32rpx; background-color: #206EEE; margin-right: 8rpx;" slot="icon">
|
</view>
|
<view class="list">
|
<view class="list_row" v-for="(child, b) in item.problemMapList" :key="b">
|
<view class="list_row_title">{{child.title}}</view>
|
<view class="list_row_radio">
|
<u-radio-group v-model="child.status" placement="row" @change="$refs.collapse.init()">
|
<u-radio :name="1" label="符合" :disabled="workOrderId ? true : false"></u-radio>
|
<u-radio :name="2" label="不符合" :disabled="workOrderId ? true : false"></u-radio>
|
</u-radio-group>
|
</view>
|
<view class="list_row_info" v-if="child.status === 2">{{child.eventInfo}}</view>
|
<view class="list_row_img" v-if="child.status === 2">
|
<view class="list_row_img_label">图片</view>
|
<view class="list_row_img_list" v-if="child.imgList">
|
<view class="list_row_img_list_row" v-for="(imgRow, n) in child.imgList.split(',')" :key="n" @click="previewImage(base + imgRow, child.imgList.split(',').map(item => base + item))">
|
<image :src="base + imgRow" mode="widthFix"></image>
|
</view>
|
<view class="list_row_img_list_zw"></view>
|
<view class="list_row_img_list_zw"></view>
|
</view>
|
</view>
|
</view>
|
</view>
|
</u-collapse-item>
|
</template>
|
</u-collapse>
|
<view style="padding: 0 30rpx calc(env(safe-area-inset-bottom) + 30rpx) 30rpx; box-sizing: border-box;" v-if="!workOrderId">
|
<u-button type="primary" text="提交" @click="submit" style="margin-top: 60rpx;"></u-button>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
id: null,
|
workOrderId: null,
|
themeName: '',
|
value: '1',
|
value1: '',
|
fileList: [],
|
list: [],
|
list1: [],
|
collapseList: [],
|
base: ''
|
};
|
},
|
onLoad(option) {
|
this.id = option.theme
|
this.themeName = option.themeName
|
this.workOrderId = option.id
|
this.getList()
|
if (option.id) {
|
this.getDetails()
|
}
|
},
|
methods: {
|
// 获取dca详情
|
getDetails() {
|
this.$u.api.detail({ id: this.workOrderId })
|
.then(res => {
|
this.list1 = JSON.parse(res.data.remark).childMapList
|
this.base = res.data.path
|
})
|
},
|
previewImage(current, urls) {
|
uni.previewImage({
|
current,
|
urls
|
});
|
},
|
submit() {
|
// 总数
|
let tatal = 0
|
// 符合
|
let dcaYesNum = 0
|
// 不符合
|
let dcaNoNum = 0
|
let dcaNoProblemDTOList = []
|
for (let i = 0; i < this.list.length; i++) {
|
for (let b = 0; b < this.list[i].childList.length; b++) {
|
console.log(this.list[i].childList[b].value, this.list[i].childList[b].eventInfo)
|
if (!this.list[i].childList[b].value) {
|
return uni.showToast({
|
title: '请先完善上述所有单选项',
|
icon: 'none'
|
})
|
}
|
if (this.list[i].childList[b].value === '2' && !this.list[i].childList[b].eventInfo) {
|
return uni.showToast({
|
title: '请先完善上述所有不符合原因',
|
icon: 'none'
|
})
|
}
|
tatal++
|
if (this.list[i].childList[b].value === '1') {
|
dcaYesNum++
|
}
|
if (this.list[i].childList[b].value === '2') {
|
dcaNoNum++
|
dcaNoProblemDTOList.push({
|
eventInfo: this.list[i].childList[b].eventInfo,
|
multifileList: this.list[i].childList[b].multifileList,
|
problemId: this.list[i].childList[b].id
|
})
|
}
|
}
|
}
|
console.log('提交', dcaYesNum, dcaNoNum, dcaNoProblemDTOList, tatal)
|
uni.$emit('update',{ dcaYesNum, dcaNoNum, dcaNoProblemDTOList, tatal })
|
uni.navigateBack({ delta: 1 });
|
},
|
// 获取题目
|
async getList() {
|
let res = await this.$u.api.getCategoryVOForGCXTree({ categoryId: this.id })
|
if (res.code === 200) {
|
res.data[0].childList.forEach(item => {
|
this.list.push(item)
|
})
|
this.list.forEach((one, index) => {
|
this.collapseList.push(index + 1)
|
one.childList.forEach(two => {
|
this.$set(two, 'value', '');
|
this.$set(two, 'eventInfo', '');
|
this.$set(two, 'multifileList', []);
|
})
|
})
|
}
|
},
|
// 删除图片
|
deletePic(event, a, b) {
|
this.list[a].childList[b].multifileList.forEach((item, index) => {
|
if (item.imgaddr === event.file.imgaddr) {
|
this.list[a].childList[b].multifileList.splice(index, 1)
|
}
|
})
|
},
|
// 上传图片
|
async afterRead(event, a, b) {
|
var that = this
|
uni.showLoading({ title: '上传中...', mask: true })
|
uni.uploadFile({
|
url: this.$baseUrl + '/web/public/uploadBatch',
|
files: event.file.map(e => {
|
return { name: 'files', uri: e.url }
|
}),
|
formData: {
|
folder: "WORKORDER_FILE_PATH",
|
},
|
success(res) {
|
uni.hideLoading();
|
let obj = JSON.parse(res.data)
|
if (obj.code === 200) {
|
console.log(obj.data)
|
obj.data.forEach(item => {
|
item.fileurl = item.imgaddr
|
})
|
that.list[a].childList[b].multifileList = [...that.list[a].childList[b].multifileList, ...obj.data]
|
that.$refs.collapse.init()
|
}
|
}
|
})
|
// var that = this
|
// uni.uploadFile({
|
// url: this.$baseUrl + '/web/public/upload',
|
// filePath: event.file.url,
|
// name: "file",
|
// formData: {
|
// folder: "WORKORDER_FILE_PATH"
|
// },
|
// success: (res) => {
|
// let obj = JSON.parse(res.data)
|
// if (obj.code === 200) {
|
// obj.data.fileurl = obj.data.imgaddr
|
// that.list[a].childList[b].multifileList.push(obj.data)
|
// that.$refs.collapse.init()
|
// }
|
// }
|
// });
|
},
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.box {
|
width: 100%;
|
|
.box_head {
|
width: 100%;
|
height: 88rpx;
|
line-height: 88rpx;
|
padding: 0 34rpx;
|
box-sizing: border-box;
|
color: rgba(16, 16, 16, 1);
|
font-size: 28rpx;
|
}
|
|
.list {
|
width: 100%;
|
display: flex;
|
flex-direction: column;
|
|
.list_row {
|
width: 100%;
|
display: flex;
|
flex-direction: column;
|
margin-top: 30rpx;
|
|
&:first-child {
|
margin: 0;
|
}
|
|
.list_row_title {
|
color: rgba(16, 16, 16, 1);
|
font-size: 28rpx;
|
}
|
|
.list_row_radio {
|
width: 100%;
|
margin-top: 42rpx;
|
}
|
|
.list_row_textarea {
|
width: 100%;
|
height: 156rpx;
|
margin-top: 30rpx;
|
}
|
|
.list_row_info {
|
width: 100%;
|
color: rgba(16,16,16,1);
|
font-size: 28rpx;
|
margin-top: 30rpx;
|
}
|
|
.list_row_img {
|
width: 100%;
|
display: flex;
|
flex-direction: column;
|
margin-top: 30rpx;
|
.list_row_img_label {
|
color: rgba(108,108,108,1);
|
font-size: 28rpx;
|
}
|
.list_row_img_list {
|
width: 100%;
|
margin-top: 30rpx;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
flex-wrap: wrap;
|
.list_row_img_list_zw {
|
width: 156rpx;
|
height: 0;
|
}
|
.list_row_img_list_row {
|
width: 156rpx;
|
height: 156rpx;
|
margin-bottom: 20rpx;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
overflow: hidden;
|
image {
|
width: 100%;
|
}
|
}
|
}
|
}
|
|
.list_row_upload {
|
width: 100%;
|
margin-top: 40rpx;
|
|
.list_row_upload_label {
|
color: rgba(108, 108, 108, 1);
|
font-size: 28rpx;
|
margin-bottom: 20rpx;
|
}
|
}
|
}
|
}
|
}
|
</style>
|