649 lines
17 KiB
Vue
Executable File
649 lines
17 KiB
Vue
Executable File
<template>
|
||
<view class="page">
|
||
<scroll-view class="content" :scroll-top="scrollTop" scroll-y="true" @scrolltoupper="upper" @scrolltolower="lower"
|
||
@scroll="scroll">
|
||
<view class="detail-row-class">
|
||
<text class="detail-row-title-class">巡检任务:</text>
|
||
<text class="detail-row-context-class">{{taskItem.FName}}</text>
|
||
</view>
|
||
<view class="detail-row-class">
|
||
<text class="detail-row-title-class">巡检项目:</text>
|
||
<text class="detail-row-context-class">{{itemArray[index].FInspectName}}</text>
|
||
</view>
|
||
<view class="detail-row-class">
|
||
<text class="detail-row-title-class">项目分组:</text>
|
||
<text class="detail-row-context-class">{{itemArray[index].FGroupName}}</text>
|
||
</view>
|
||
<view class="detail-row-class">
|
||
<text class="detail-row-title-class">检验标准:</text>
|
||
<text class="detail-row-context-class">{{itemArray[index].FDescription.length==0?"无":itemArray[index].FDescription}}</text>
|
||
</view>
|
||
<view style="height: 25rpx;"/>
|
||
|
||
<view class="detail-item-row-class" v-if="itemArray[index].FValueType == 2">
|
||
<text class="detail-item-row-title-class">{{itemArray[index].FInspectName}}:</text>
|
||
<xfl-select style="height: 60rpx; line-height: 60rpx; font-size: 14px;"
|
||
:list="companyList" :listOrigin="companyList" :clearable="false" :isCanInput="false"
|
||
@change="companyChange" :mySelectText="companySelectText"/>
|
||
</view>
|
||
|
||
<view class="detail-item-row-class" v-if="itemArray[index].FValueType == 1">
|
||
<text class="detail-item-row-title-class">{{itemArray[index].FInspectName}}:</text>
|
||
<radio-group class="detail-row-radio-class" @change="radioChange">
|
||
<label><radio class="detail-row-radio-item-class" value="1" :checked="radioChecked == true"/>是</label>
|
||
<label><radio class="detail-row-radio-item-class" value="0" :checked="radioChecked == false"/>否</label>
|
||
</radio-group>
|
||
</view>
|
||
<view class="detail-item-row-class" v-if="itemArray[index].FValueType == 3">
|
||
<text class="detail-item-row-title-class">{{itemArray[index].FInspectName}} :</text>
|
||
<input class="detail-row-input-class" type="number" value="itemArray[index].FDefaultValue" v-model="inputText"/>
|
||
</view>
|
||
<view class="detail-item-row-class" v-if="itemArray[index].FValueType == 4">
|
||
<text class="detail-item-row-title-class">{{itemArray[index].FInspectName}} :</text>
|
||
<view class="detail-row-percentage-class">
|
||
<input class="detail-row-percentage-input-class" type="number" maxlength="8" value="itemArray[index].FDefaultValue" v-model="inputText"/>
|
||
<text class="detail-row-percentage-text-class">%</text>
|
||
</view>
|
||
</view>
|
||
<view class="detail-item-row-class" v-if="itemArray[index].FValueType == 5">
|
||
<text class="detail-item-row-title-class">{{itemArray[index].FInspectName}} :</text>
|
||
<input class="detail-row-input-class" type="text" value="itemArray[index].FDefaultValue" v-model="inputText"/>
|
||
</view>
|
||
<view class="detail-item-row-class">
|
||
<text class="detail-item-row-title-class" decode="true">备注 :</text>
|
||
<textarea class="detail-row-textarea-class" v-model="itemArray[index].FNote"></textarea>
|
||
</view>
|
||
<view class="detail-item-row-class">
|
||
<text class="detail-item-row-title-class">图片上传 :</text>
|
||
<img-upload :imgArr="imgArray" imgCount="1" ref="imgUpload"></img-upload>
|
||
</view>
|
||
</scroll-view>
|
||
|
||
<view class="detail-btn-row-class">
|
||
<button @tap="beforeBtnClick()" :disabled="index==0">上一项</button>
|
||
<button @tap="nextBtnClick()" :disabled="index==(itemArray.length-1)">下一项</button>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
<script>
|
||
import xflSelect from '../../../components/xfl-select/xfl-select.vue';
|
||
import imgUpload from '../../../components/poiuy-uImgUpload/imgUpload.vue';
|
||
import Vue from 'vue';
|
||
import {
|
||
mapState,
|
||
mapMutations
|
||
} from 'vuex';
|
||
var _self;
|
||
|
||
export default {
|
||
data() {
|
||
return {
|
||
scrollTop: 0,
|
||
old: {
|
||
scrollTop: 0
|
||
},
|
||
imgArray: new Array(),
|
||
taskItem: new Object(),
|
||
newTaskItem: new Object(),
|
||
itemArray: new Array(),
|
||
index: 0,
|
||
inputText: "",
|
||
companySelectText: "",
|
||
radioChecked:false,
|
||
backFlag:true,
|
||
backClickFlag:false,
|
||
companyList:new Array()
|
||
}
|
||
},
|
||
|
||
onLoad(options) {
|
||
_self = this;
|
||
if(options.item) {
|
||
let item = JSON.parse(options.item);
|
||
this.newTaskItem = item;
|
||
this.taskItem = this.newTaskItem.taskItem;
|
||
this.itemArray = this.newTaskItem.item;
|
||
this.index = this.newTaskItem.currentdIndex;
|
||
|
||
if(this.itemArray[this.index].FValueType == 2 && this.itemArray[this.index].FWinType == 1) {
|
||
_self.getCompanyList(this.index);
|
||
}
|
||
if(this.itemArray[this.index].FValueType == 2 && this.itemArray[this.index].FWinType == 2) {
|
||
_self.getICMOList(this.index);
|
||
}
|
||
|
||
this.itemArray.forEach(
|
||
function(el) {
|
||
if(!el.imgArray) {
|
||
el.imgArray = new Array();
|
||
}
|
||
}
|
||
);
|
||
|
||
this.updataPage();
|
||
}
|
||
},
|
||
|
||
onBackPress() {
|
||
if(_self.backFlag) {
|
||
this.backClickFlag = true;
|
||
this.saveBtnClick(this.index, 0);
|
||
}
|
||
return _self.backFlag;
|
||
},
|
||
|
||
computed: {
|
||
...mapState(['userInfo']),
|
||
},
|
||
|
||
methods: {
|
||
upper: function(e) {
|
||
console.log(e)
|
||
},
|
||
|
||
lower: function(e) {
|
||
console.log(e)
|
||
},
|
||
|
||
scroll: function(e) {
|
||
console.log(e)
|
||
this.old.scrollTop = e.detail.scrollTop
|
||
},
|
||
|
||
goTop: function(e) {
|
||
// 解决view层不同步的问题
|
||
this.scrollTop = this.old.scrollTop
|
||
this.$nextTick(function() {
|
||
this.scrollTop = 0
|
||
});
|
||
uni.showToast({
|
||
icon:"none",
|
||
title:"纵向滚动 scrollTop 值已被修改为 0"
|
||
})
|
||
},
|
||
|
||
updataPage: function(){
|
||
if(this.itemArray[this.index].FValueType == 2) {
|
||
if (this.itemArray[this.index].FValue) {
|
||
this.companySelectText = this.itemArray[this.index].FValue;
|
||
}
|
||
else {
|
||
this.companySelectText = this.itemArray[this.index].FDefaultValue;
|
||
}
|
||
if(this.itemArray[this.index].FWinType == 1) {
|
||
_self.getCompanyList(this.index);
|
||
}
|
||
if(this.itemArray[this.index].FWinType == 2) {
|
||
_self.getICMOList(this.index);
|
||
}
|
||
this.$forceUpdate();
|
||
this.radioChecked = null;
|
||
this.inputText = null;
|
||
}
|
||
|
||
if(this.itemArray[this.index].FValueType == 1) {
|
||
this.radioChecked = null;
|
||
|
||
let value;
|
||
if (this.itemArray[this.index].FValue) {
|
||
value = this.itemArray[this.index].FValue;
|
||
}
|
||
else {
|
||
value = this.itemArray[this.index].FDefaultValue;
|
||
}
|
||
|
||
if(value == "0" || value == "false") {
|
||
this.radioChecked = false;
|
||
}
|
||
|
||
if(value == "1" || value == "true") {
|
||
this.radioChecked = true;
|
||
}
|
||
|
||
this.$forceUpdate();
|
||
this.companySelectText = null;
|
||
this.inputText = null;
|
||
}
|
||
|
||
if(this.itemArray[this.index].FValueType != 1 && this.itemArray[this.index].FValueType != 2){
|
||
if (this.itemArray[this.index].FValue) {
|
||
this.inputText = this.itemArray[this.index].FValue;
|
||
}
|
||
else {
|
||
this.inputText = this.itemArray[this.index].FDefaultValue;
|
||
}
|
||
this.$forceUpdate();
|
||
this.radioChecked = null;
|
||
this.companySelectText = null;
|
||
}
|
||
|
||
this.imgArray = this.itemArray[this.index].imgArray;
|
||
},
|
||
|
||
nextBtnClick: function(){
|
||
this.saveBtnClick(this.index, 2);
|
||
},
|
||
|
||
beforeBtnClick: function(){
|
||
this.saveBtnClick(this.index, 1);
|
||
},
|
||
|
||
getCompanyList:function(index){
|
||
let userID = this.userInfo.token;
|
||
let requestParams = {
|
||
"id": userID
|
||
};
|
||
|
||
this.$request.post(
|
||
{
|
||
data: {
|
||
action: 'GetCompanyList',
|
||
params: requestParams
|
||
}
|
||
}
|
||
).then(res => {
|
||
let data = JSON.parse(res);
|
||
this.companyList = data;
|
||
this.companyList.forEach(
|
||
function(el){
|
||
el.value = el.FName;
|
||
}
|
||
);
|
||
|
||
});
|
||
},
|
||
|
||
getICMOList:function(index){
|
||
let userID = this.userInfo.token;
|
||
let requestParams = {
|
||
"id": userID
|
||
};
|
||
|
||
this.$request.post(
|
||
{
|
||
data: {
|
||
action: 'GetICMOList',
|
||
params: requestParams
|
||
}
|
||
}
|
||
).then(res => {
|
||
let data = JSON.parse(res);
|
||
this.companyList = data;
|
||
this.companyList.forEach(
|
||
function(el){
|
||
el.value = el.FBillNO;
|
||
}
|
||
);
|
||
console.log(this.companyList);
|
||
this.$forceUpdate();
|
||
});
|
||
},
|
||
|
||
companyChange: function({ newVal, oldVal, index, orignItem }){
|
||
this.companySelectText = orignItem.value;
|
||
},
|
||
|
||
radioChange:function(evt){
|
||
console.log(evt.target.value);
|
||
this.itemArray[this.index].FValue = evt.target.value;
|
||
if(evt.target.value == "1") {
|
||
this.radioChecked = true;
|
||
}
|
||
|
||
if(evt.target.value == "0") {
|
||
this.radioChecked = false;
|
||
}
|
||
},
|
||
|
||
saveBtnClick: function(saveIndex, pageFlag){
|
||
|
||
if(this.itemArray[saveIndex].FValueType == 2) {
|
||
this.itemArray[saveIndex].FValue = this.companySelectText ;
|
||
}
|
||
|
||
if(this.itemArray[saveIndex].FValueType == 1) {
|
||
if(this.radioChecked){
|
||
this.itemArray[saveIndex].FValue = "1";
|
||
}
|
||
if(this.radioChecked==false) {
|
||
this.itemArray[saveIndex].FValue = "0";
|
||
}
|
||
}
|
||
|
||
if(this.itemArray[saveIndex].FValueType != 1 && this.itemArray[saveIndex].FValueType != 2){
|
||
this.itemArray[saveIndex].FValue = this.inputText;
|
||
}
|
||
|
||
let checkFValue = false;
|
||
if(!this.itemArray[saveIndex].FValue){
|
||
checkFValue = true;
|
||
}
|
||
else {
|
||
let tempFValue = this.itemArray[saveIndex].FValue.replace(/\s*/g,"");
|
||
if(tempFValue.length == 0) {
|
||
checkFValue = true;
|
||
}
|
||
}
|
||
|
||
if(checkFValue && _self.backClickFlag){
|
||
uni.showModal({
|
||
title: '提示',
|
||
content: '当前页有数据未填写,请确认是否离开',
|
||
success: function (res) {
|
||
if (res.confirm) {
|
||
if(_self.backClickFlag) {
|
||
_self.backClickFlag = false;
|
||
_self.backFlag = false;
|
||
uni.navigateBack({
|
||
delta:1
|
||
});
|
||
}
|
||
}else if (res.cancel) {
|
||
_self.backClickFlag = false;
|
||
_self.backFlag = true;
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
if(checkFValue && _self.backClickFlag) {
|
||
return false;
|
||
}
|
||
|
||
if(!checkFValue) {
|
||
_self.itemArray[saveIndex].isFinish = true;
|
||
}
|
||
|
||
let imgCheck = false;
|
||
if(this.$refs.imgUpload.imgArray.length > 0) {
|
||
let imgIndex = this.$refs.imgUpload.imgArray[0].indexOf("http");
|
||
if(imgIndex != 0) {
|
||
imgCheck = true;
|
||
}
|
||
}
|
||
|
||
if(imgCheck) {
|
||
let userID = this.userInfo.token;
|
||
let url = this.$request.config.baseUrl;
|
||
let fileName = _self.itemArray[saveIndex].FDetailID +"-"+ Date.parse(new Date());
|
||
|
||
this.$refs.imgUpload.upload(
|
||
res=>{
|
||
let data = res[0];
|
||
if(data.state=="200"){
|
||
_self.itemArray[saveIndex].FPicture = data.data;
|
||
let imageUrl = this.$request.config.baseUrl.replace('PhoneAPI.ashx', '');
|
||
imageUrl = imageUrl + data.data;
|
||
imageUrl = imageUrl.replace('"', '');
|
||
imageUrl = imageUrl.replace('"', '');
|
||
imageUrl = imageUrl.replace('\\', '');
|
||
imageUrl = imageUrl.replace('\\', '/');
|
||
_self.itemArray[saveIndex].imgArray[0] = imageUrl;
|
||
_self.newTaskItem.item = _self.itemArray;
|
||
|
||
uni.setStorageSync(_self.newTaskItem.taskItem.FNumber, _self.newTaskItem);
|
||
uni.showToast({
|
||
icon: 'success',
|
||
title: "图片上传成功"
|
||
});
|
||
|
||
if(pageFlag == 1) {
|
||
this.index--;
|
||
}
|
||
|
||
if(pageFlag == 2) {
|
||
this.index++;
|
||
}
|
||
this.updataPage();
|
||
|
||
if(pageFlag == 0) {
|
||
let itemString = JSON.stringify(_self.newTaskItem.taskItem);
|
||
uni.navigateBack({
|
||
delta:1
|
||
});
|
||
_self.backFlag = false;
|
||
}
|
||
}else{
|
||
//用户没有上传图片的返回 code码为400
|
||
uni.showToast({
|
||
icon: 'none',
|
||
title: "图片上传失败"
|
||
});
|
||
}
|
||
},
|
||
userID, fileName, url);
|
||
}
|
||
else {
|
||
//this.itemArray[saveIndex].isFinish = true;
|
||
this.newTaskItem.item = this.itemArray;
|
||
uni.setStorageSync(this.newTaskItem.taskItem.FNumber, this.newTaskItem);
|
||
if(pageFlag == 1) {
|
||
this.index--;
|
||
}
|
||
|
||
if(pageFlag == 2) {
|
||
this.index++;
|
||
}
|
||
|
||
this.updataPage();
|
||
|
||
if(pageFlag == 0) {
|
||
_self.backFlag = false;
|
||
}
|
||
}
|
||
},
|
||
},
|
||
|
||
components: {
|
||
xflSelect,
|
||
imgUpload
|
||
},
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
.page{
|
||
width: 100%;
|
||
height: 100%;
|
||
background-color: #F0F0F0;
|
||
display: flex;
|
||
flex-direction:column;
|
||
flex-wrap: nowrap;
|
||
justify-content: flex-end;
|
||
}
|
||
|
||
.content{
|
||
width: 100%;
|
||
height: 60%;
|
||
flex-shrink: 1;
|
||
flex-grow: 1;
|
||
}
|
||
|
||
.detail-row-class{
|
||
display: flex;
|
||
justify-content: flex-start;
|
||
align-items: flex-start;
|
||
background-color: #FFFFFF;
|
||
padding-right: 25rpx;
|
||
padding-left: 25rpx;
|
||
}
|
||
|
||
.detail-row-5-class{
|
||
display: flex;
|
||
justify-content: flex-end;
|
||
align-items: center;
|
||
background-color: #FFFFFF;
|
||
margin-top: 5px;
|
||
padding-right: 25rpx;
|
||
padding-left: 25rpx;
|
||
}
|
||
|
||
.detail-item-row-class{
|
||
display: flex;
|
||
justify-content: flex-start;
|
||
flex-direction: column;
|
||
align-items: flex-start;
|
||
background-color: #FFFFFF;
|
||
padding-right: 25rpx;
|
||
padding-left: 25rpx;
|
||
}
|
||
|
||
.detail-item-row-title-class{
|
||
font-size: 14px;
|
||
font-style: auto;
|
||
color: #707070;
|
||
font-weight: 600;
|
||
flex-shrink: 0;
|
||
flex-grow: 0;
|
||
color: #28282B;
|
||
line-height: 70rpx;
|
||
width: 100%;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.detail-row-title-class{
|
||
font-size: 14px;
|
||
font-style: auto;
|
||
color: #707070;
|
||
font-weight: 600;
|
||
flex-shrink: 0;
|
||
flex-grow: 0;
|
||
color: #28282B;
|
||
line-height: 70rpx;
|
||
height: 70rpx;
|
||
width: 170rpx;
|
||
}
|
||
|
||
.detail-row-context-class{
|
||
font-size: 14px;
|
||
font-style: auto;
|
||
color: #6B6B6B;
|
||
flex-shrink: 1;
|
||
flex-grow: 1;
|
||
line-height: 70rpx;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.detail-row-input-class{
|
||
background-color: #F5F5F5;
|
||
color: #6B6B6B;
|
||
line-height: 70rpx;
|
||
height: 70rpx;
|
||
width: 100%;
|
||
flex-shrink: 1;
|
||
flex-grow: 1;
|
||
margin-top: 10rpx;
|
||
margin-bottom: 10rpx;
|
||
padding-left: 5rpx;
|
||
padding-right: 5rpx;
|
||
border-radius:10rpx;
|
||
}
|
||
|
||
.detail-row-textarea-class{
|
||
background-color: #F5F5F5;
|
||
color: #6B6B6B;
|
||
line-height: 70rpx;
|
||
height: 160rpx;
|
||
width: 100%;
|
||
flex-shrink: 1;
|
||
flex-grow: 1;
|
||
margin-top: 10rpx;
|
||
margin-bottom: 10rpx;
|
||
padding-left: 5rpx;
|
||
padding-right: 5rpx;
|
||
border-radius:10rpx;
|
||
}
|
||
|
||
.detail-row-percentage-class{
|
||
display: flex;
|
||
flex-direction: row;
|
||
justify-content: flex-start;
|
||
line-height: 70rpx;
|
||
height: 70rpx;
|
||
width: 100%;
|
||
text-align: end;
|
||
flex-shrink: 0;
|
||
flex-grow: 0;
|
||
padding-left: 5rpx;
|
||
padding-right: 5rpx;
|
||
border-radius:10rpx;
|
||
}
|
||
|
||
|
||
.detail-row-percentage-input-class{
|
||
background-color: #F5F5F5;
|
||
color: #6B6B6B;
|
||
line-height: 70rpx;
|
||
height: 70rpx;
|
||
width: 170rpx;
|
||
text-align: end;
|
||
flex-shrink: 0;
|
||
flex-grow: 0;
|
||
margin-top: 10rpx;
|
||
margin-bottom: 10rpx;
|
||
padding-left: 5rpx;
|
||
padding-right: 5rpx;
|
||
border-radius:10rpx;
|
||
}
|
||
|
||
.detail-row-percentage-text-class{
|
||
line-height: 70rpx;
|
||
height: 70rpx;
|
||
flex-shrink: 0;
|
||
flex-grow: 0;
|
||
margin-top: 10rpx;
|
||
margin-bottom: 10rpx;
|
||
padding-left: 5rpx;
|
||
padding-right: 5rpx;
|
||
}
|
||
|
||
.detail-row-radio-class{
|
||
flex-shrink: 0;
|
||
flex-grow: 0;
|
||
line-height: 70rpx;
|
||
display: flex;
|
||
flex-direction: row;
|
||
justify-content: flex-start;
|
||
font-size: 14px;
|
||
font-style: auto;
|
||
color: #6B6B6B;
|
||
}
|
||
|
||
.detail-row-radio-item-class{
|
||
flex-shrink: 0;
|
||
flex-grow: 0;
|
||
transform: scale(0.7);
|
||
}
|
||
|
||
.detail-btn-row-class{
|
||
display: flex;
|
||
flex-direction: row;
|
||
align-items: center;
|
||
height: 80rpx;
|
||
line-height: 80rpx;
|
||
flex-shrink: 0;
|
||
flex-grow: 0;
|
||
background-color: #FFFFFF;
|
||
}
|
||
|
||
button{
|
||
flex-shrink: 0;
|
||
flex-grow: 0;
|
||
width: 5rem;
|
||
height: 60rpx;
|
||
line-height: 60rpx;
|
||
background-color: #007AFF;
|
||
font-size: 15px;
|
||
font-style: auto;
|
||
font-weight: 1000;
|
||
color: #FFFFFF;
|
||
margin-bottom: 20rpx;
|
||
margin-top: 20rpx;
|
||
}
|
||
|
||
.detail-placeholder-class{
|
||
flex-shrink: 0;
|
||
flex-grow: 0;
|
||
width: 5rem;
|
||
}
|
||
</style> |