hz-zhhq-app/pages/epidemic/travel-report.vue

940 lines
24 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="hzIndex">
<hzHeader title="出行报备"></hzHeader>
<!-- <view class="banner-box">
<image src="/static/images//epidemic//cxbb-banner.png" mode=""></image>
</view> -->
<view class="hzContent">
<view class="main">
<view class="tab-box">
<view class="tab-item" :class="currentTabIndex == 0 ? 'active' : ''" @click="currentTabIndex = 0">出行报备<view class="activeLine" v-if="currentTabIndex == 0"></view></view>
<view class="tab-item" :class="currentTabIndex == 1 ? 'active' : ''" @click="currentTabIndex = 1">报备记录<view class="activeLine" v-if="currentTabIndex == 1"></view></view>
</view>
</view>
<view class="content" v-if="currentTabIndex == 0">
<view class="interviewee">
<view class="form-box" style="border-radius: 10upx;margin-bottom: 20upx;">
<view class="form-item" >
<text class="label">姓  名:</text>
<view class="ipt-box"><input class="top-t" v-model="formData.userName" placeholder="请输入姓名" type="text" maxlength="50" disabled="true" /></view>
</view>
<view class="form-item" >
<text class="label">联系方式:</text>
<view class="ipt-box"><input class="top-t" v-model="formData.phone" placeholder="请输入联系方式" type="text" maxlength="50" disabled="true" /></view>
</view>
<view class="form-item" >
<text class="label">部  门:</text>
<view class="ipt-box"><input class="top-t" v-model="formData.orgName" placeholder="请输入部门" type="text" maxlength="50" disabled="true" /></view>
</view>
</view>
<view class="form-box-ud" style="border-radius: 10upx;">
<view class="form-item" v-for="(item, index) in questions" :key="index">
<text class="label"><text v-if="item.required" style="color: red;">*</text>{{index+1+'.'+item.title}}</text>
<view class="ipt-box">
<radio-group v-if="item.type=='radius'" @change="changeRadioGroup($event,item.formName)">
<label class="uni-list-cell uni-list-cell-pd radio-group" v-for="(obj, index1) in item.options" :key="index1" >
<view>
<radio color="#4db4ea" :value="obj" :checked="obj==formData[item.formName]" />
</view>
<view>{{obj}}</view>
</label>
</radio-group>
<textarea v-model="formData[item.formName]" v-if="item.type=='textarea'" maxlength="120" :placeholder="item.placeholderText"/>
<view class="img-box" v-if="item.imgName">
<view class="img-item" v-if="formData[item.imgName]">
<image class="remove-btn" @click="removeImg(item.imgName)" src="/static/icons/delete-icon.png" mode=""></image>
<image class="img" :src="img[item.imgName][0].replace(/[\r\n]/g,'')" mode=""></image>
</view>
<view v-else class="img-item upload-btn" @click="chooseImg(item.imgName)" ><image class="img" src="/static/imgs/tianjia-img.png" mode=""></image></view>
</view>
<input v-if="item.type=='text'" v-model="formData[item.formName]" type="text" maxlength="120" :placeholder="item.placeholderText" />
<uni-datetime-picker v-if="item.type=='daterange'" v-model="formData[item.formName]" type="daterange" :start="today" />
</view>
</view>
</view>
<view class="form-box" style="border-radius: 10upx;margin-top: 20upx;">
<view class="form-item" >
<text class="label">审批人:</text>
<view class="ipt-box select">
<image class="arrow" src="/static/icons/right-arrow.png" mode=""></image>
<picker class="picker" v-if="examList.length > 0" :range="examList" @change="changeExamList" range-key="name">
<view>{{ examList[examIndex].name }}</view>
</picker>
</view>
</view>
</view>
<!-- <view class="form-box" style="border-radius: 10upx;">
<view class="form-item" >
<text class="label" >审批人:</text>
<view class="ipt-box select">
<image class="arrow" src="/static/icons/right-arrow.png" mode=""></image>
<picker class="picker" v-if="examList.length > 0" :range="examList" @change="changeExamList" range-key="name">
<view>{{ examList[examIndex].name }}</view>
</picker>
</view>
</view>
</view> -->
</view>
<view class="occupied"></view>
<view class="footer-btn" @click="submit"><view class="btn">提交</view></view>
</view>
<!-- 检查列表 -->
<view v-if="currentTabIndex == 1" style="margin-top: 20upx;">
<view class="list-content" v-if="reportList.length > 0">
<view class="details" v-for="(item, i) in reportList" :key="i" >
<view class="detail_header" @click="details(item)">
<!-- <text class="blueSign"></text> -->
<image src="/static/img/carIcon.png" mode="" style="width: 40upx;height: 35upx;margin-left: 20upx;vertical-align: middle;"></image>
<text class="font-tilte">出行报备</text>
<text v-if="item.EXAMINE_STATE ==0" class="statusred" style="color: #ff9000;background-color: #FFEFE3;" >待审核</text>
<text v-if="item.EXAMINE_STATE ==2" class="statusred" style="color: #BD1515;background-color: #F6DFDF;">已拒绝</text>
<text v-if="item.EXAMINE_STATE ==1" class="statusred" style="color: #0DB0A7;background-color: #C1EFEA;">已通过</text>
</view>
<view class="detail_msg">
<view class="info-item" @click="details(item)">
<text>报备时间:</text>
<text class="infoSpan">{{ formatDate(item.GMT_CREATED,'dateTime')}}</text>
</view>
<view class="info-item" @click="details(item)">
<text>出行日期:</text>
<text class="infoSpan">{{item.TRAVEL_DATE.replace("|"," 至 ")}}</text>
</view>
<view class="info-item" @click="details(item)">
<text>目的地:</text>
<text class="infoSpan">{{item.TRAVEL_PLACE}}</text>
</view>
<view class="info-item" @click="details(item)">
<text>出行方式:</text>
<text class="infoSpan">{{item.TRAVEL_METHOD}}</text>
</view>
<view v-if="item.TRAVEL_METHOD!='自驾'" class="info-item" @click="details(item)">
<text>车次航班:</text>
<text class="infoSpan">{{item.TRAVEL_METHOD_INFO}}</text>
</view>
<view class="info-item" @click="details(item)">
<text>出行类型:</text>
<text class="infoSpan">{{item.TRAVEL_TYPE}}</text>
</view>
<!-- <view class="info-item" style="width: 100%;text-align: center;" @click="details(item)">
<text style="width: 100%;color: #4db4ea;">点击查看详情</text>
</view> -->
</view>
</view>
</view>
<content-none v-else :padTop="20"></content-none>
</view>
<load-more v-if="currentTabIndex == 1" :loadingType="loadingType" :contentText="contentText"></load-more>
</view>
</view>
</template>
<script>
import { travelReportAdd ,travelReportPage,getDeptExamineAuth} from '@/common/api.js';
import { callbackRequest,callbackRequestNoLoading, getStorage, alertTip, convertImgToBase64, formatDate,wxSdk,uploadImg } from '@/common/util.js';
import loadMore from '@/components/loadMore.vue';
import contentNone from '@/components/contentNone.vue';
import { pathToBase64 } from '@/js_sdk/mmmm-image-tools/index.js';
export default {
components: {
loadMore,
contentNone
},
data() {
return {
today:new Date().getTime(),
formatDate: formatDate,
//分页
page: 1,
pageSize: 10,
loadingType: 0, //0-loading前1-loading中2-没有更多了
contentText: {
contentdown: '上拉加载更多',
contentrefresh: '正在加载...',
contentnomore: '没有更多数据了'
},
currentTabIndex:0,
travelTypes: [{ id: '因公', name: '因公' }, { id: '因私', name: '因私' }],//,{ id: '离婚', name: '离婚' }, { id: '丧偶', name: '丧偶' }
travelMethods:[{ id: '公共交通', name: '公共交通' }, { id: '自驾', name: '自驾' }],
questions:[
{
title:'目的地',
formName:'travelPlace',
type:'text',
required:true,
requiredText:'请输入目的地',
placeholderText:'请输入目的地',
},
{
title:'出行日期',
formName:'travelDate',
type:'daterange',
required:true,
requiredText:'请选择出行日期',
},
{
title:'出行方式',
formName:'travelMethod',
type:'radius',
required:true,
requiredText:'请选择出行方式',
options:[
'自驾','汽运','高铁','飞机'
]
},
{
title:'出行车次、航班(座位号)',
formName:'travelMethodInfo',
type:'text',
required:false,
requiredText:'请输入出行车次、航班(座位号)',
placeholderText:'请输入出行车次、航班(座位号)',
},
{
title:'返程方式',
formName:'travelMethodBack',
type:'radius',
required:true,
requiredText:'请选择返程方式',
options:[
'自驾','汽运','高铁','飞机'
]
},
{
title:'返程车次、航班(座位号)',
formName:'travelMethodInfoBack',
type:'text',
required:false,
requiredText:'请输入返程车次、航班(座位号)',
placeholderText:'请输入返程车次、航班(座位号)',
},
{
title:'出行类型',
formName:'travelType',
type:'radius',
required:true,
requiredText:'请选择出行类型',
options:[
'因公','因私'
]
},
{
title:'出行事由',
type:'textarea',
placeholderText:'请输入120字内',
required:false,
formName:'reason',
}
],
formData:{
userId: getStorage('userInfo').userId,
userName: getStorage('userInfo').userName,
phone: getStorage('userInfo').telnumber,
orgId: getStorage('userInfo').department_id,
orgName: getStorage('userInfo').departmentName,
travelDate:[],
travelMethod:'',
travelMethodInfo:"",
travelMethodBack:"",
travelMethodInfoBack:"",
travelType:"",
travelPlace: '',
reason: '',
approvalForm:''
},
reportList:[],
imgs:[],
imgsId:[],
showAlert:false,
submitFlag:true,
examIndex:0,
examList: []
};
},
watch: {
currentTabIndex: function(newVal, oldVal) {
if (newVal ==1) {
this.page = 1;
this.loadingType = 0;
this.dataList();
}else{
}
},
formData: {
handler(newValue,oldValue){
if(this.formData.travelMethod!='自驾'){
this.questions[3].required=true;
}else{
this.questions[3].required=false;
}
if(this.formData.travelMethodBack!='自驾'){
this.questions[5].required=true;
}else{
this.questions[5].required=false;
}
},
deep:true
}
},
onLoad(option) {
this.getDeptExamineAuth();
this.currentTabIndex = option.currentTabIndex || 0;
},
onShow() {
if (this.currentTabIndex == 0) {
}else{
this.page = 1;
this.loadingType = 0;
this.dataList();
}
},
methods: {
changeRadioGroup(e,radioData){
this.formData[radioData] = e.detail.value;
// console.log(data);
},
getDeptExamineAuth(){
let params = {
method: getDeptExamineAuth,
data: {
userId: getStorage('userInfo').userId,
departmentId:getStorage('userInfo').deptIdUrl,
}
};
callbackRequest(params).then(res => {
res = res.data;
if (res.returnCode == 1) {
console.log(res);
this.examList = res.returnData;
} else {
alertTip(res.returnMsg);
}
});
},
dataList() {
let params = {
method: travelReportPage,
data: {
userId:getStorage('userInfo').userId,
pageNum: this.page,
pageSize: this.pageSize,
}
};
callbackRequest(params).then(res => {
res = res.data;
if (res.returnCode == 1) {
if (this.page == 1) {
this.reportList = res.returnData || [];
} else {
if (res.returnData.length > 0) {
this.reportList = this.reportList.concat(res.returnData);
this.loadingType = 0;
} else {
this.loadingType = 2;
}
}
} else {
alertTip(res.returnMsg);
}
});
},
submit() {
if(this.submitFlag){
this.submitFlag = false;
if(!this.verificationForm()){
this.submitFlag = true;
return false;
}
// if(typeof this.formData.travelDate != 'string'){
// this.formData.travelDate = this.formData.travelDate.join("|");
// }
let params = {
method: travelReportAdd,
data: {
userId: this.formData.userId,
userName: this.formData.userName,
phone: this.formData.phone,
orgId: this.formData.orgId,
orgName: this.formData.orgName,
travelDate:this.formData.travelDate.join("|"),
travelMethod:this.formData.travelMethod,
travelMethodInfo:this.formData.travelMethodInfo,
travelType:this.formData.travelType,
travelPlace:this.formData.travelPlace,
reason: this.formData.reason,
approvalForm:this.imgsId[0]||'',
examinePersonId:this.examList[this.examIndex].id,
examinePersonName:this.examList[this.examIndex].name,
travelMethodBack:this.formData.travelMethodBack,
travelMethodInfoBack:this.formData.travelMethodInfoBack,
}
};
// let dates = [this.formData.travelDate[0],this.formData.travelDate[1]];
// dates.push(this.formData.travelDate);
// params.data.travelDate = dates.join("|");
callbackRequest(params).then(res => {
res = res.data;
if (res.returnCode == 1) {
this.submitFlag = true;
alertTip(res.returnMsg);
this.formData={
userId: getStorage('userInfo').userId,
userName: getStorage('userInfo').userName,
phone: getStorage('userInfo').telnumber,
orgId: getStorage('userInfo').department_id,
orgName: getStorage('userInfo').departmentName,
travelDate:[],
travelMethod:'',
travelMethodInfo:"",
travelMethodBack:"",
travelMethodInfoBack:"",
travelType:"",
travelPlace: '',
reason: '',
approvalForm:''
};
setTimeout(_ => {
this.currentTabIndex = 1;
}, 2000);
} else {
this.submitFlag = true;
alertTip(res.returnMsg);
}
});
}
},
verificationForm(){
for(let i=0;i<this.questions.length;i++){
let obj = this.questions[i];
if(obj.required){
if(obj.type=='radius'){
if(!this.formData[obj.formName]){
alertTip(obj.requiredText);
return false;
}
}else if(obj.type=='img'){
if(!this.formData[obj.imgName]){
alertTip(obj.requiredText);
return false;
}
}else if(obj.type=='daterange'){
if(this.formData[obj.formName].length==0){
alertTip(obj.requiredText);
return false;
}
}else{
if(!this.formData[obj.formName]){
alertTip(obj.requiredText);
return false;
}
}
}
}
return true;
},
changeExamList(e){
this.examIndex = e.detail.value;
},
details: function(item) {
uni.navigateTo({
url: '/pages/epidemic/travel-report-detail?item=' + JSON.stringify(item)
});
},
changeTravelType(e){
this.formData.travelType = e.detail.value;
},
changeTravelMethod(e){
this.formData.travelMethod = e.detail.value;
if(e.detail.value=='自驾'){
this.formData.travelMethodInfo = '';
}
},
async chooseImg() {
let chec = 0;
let sty = [];
let _this = this;
uni.showActionSheet({
itemList:['拍照','相册'],
success:function(resp){
chec = resp.tapIndex;
if (chec == 0) {
sty = ['camera']; //从相册相机选择
} else {
sty = ['album']; //从相册相机选择
}
uni.chooseImage({
count:1,
sizeType: ['compressed'],
sourceType: sty,
quality: 1,
success: async function(res){
let resData = res.tempFilePaths;
for(let i=0;i<resData.length;i++){
if(_this.imgs.length>1){
break;
}
uni.getImageInfo({
src: resData[i],
success:async (path) => {
convertImgToBase64(path.path, async function(base64) {
if(_this.imgs.length<1){
// _this.imgs.push(base64);
uni.showLoading({
title: '图片上传中'
})
let blength = base64.length;
let glength = 7500;
if(blength<=glength){
let uploadParam = {
base64: base64,
userId: getStorage('userInfo').userId+i,
groupEnd: '1'
}
await uploadImg(uploadParam).then(resu => {
resu = resu.data ;
uni.hideLoading();
if (resu.returnCode != 1) {
alertTip(resu.returnMsg);
}else{
_this.imgs.push(base64);
_this.imgsId.push(resu.returnData+".jpg");
}
});
}else{
let fnum = parseInt(blength/glength);
for(let j=1;j<fnum+1;j++){
if(j==fnum){
let groupBase = base64.slice((j-1)*glength);
console.log(groupBase.length,"groupBaselength");
let uploadParam = {
base64: groupBase,
userId: getStorage('userInfo').userId+i,
groupEnd: '1'
}
await uploadImg(uploadParam).then(resu => {
resu = resu.data ;
if (resu.returnCode == 1) {
_this.imgs.push(base64);
_this.imgsId.push(resu.returnData+".jpg");
} else {
uni.hideLoading();
alertTip(resu.returnMsg);
return;
}
});
}else{
let groupBase = base64.slice((j-1)*glength,glength*j);
let uploadParam = {
base64: groupBase,
userId: getStorage('userInfo').userId+i,
groupEnd: '0'
}
await uploadImg(uploadParam).then(resu => {
resu = resu.data ;
if (resu.returnCode == 1) {
} else {
uni.hideLoading();
alertTip(resu.returnMsg);
return;
}
});
}
}
uni.hideLoading();
}
}
});
},
});
}
}
});
},
fail:function(resp){
console.log(resp.errMsg);
}
});
},
//删除图片
removeImg(index) {
this.imgs.splice(index, 1);
this.imgsId.splice(index, 1);
},
},
onReachBottom() {
if (this.loadingType !== 0 || this.currentTabIndex == 0) {
return;
}
this.loadingType = 1;
this.page = this.page + 1;
this.dataList();
},
};
</script>
<style lang="scss">
@import url('../../static/css/repair/malfunction-repair.css');
@import '@/static/css/common.scss';
.form-box-ud {
background: #fff;
.form-item {
overflow: hidden;
// border-bottom: 1px solid #eee;
padding: 30upx 20upx 10upx 20upx;
.label {
width: 150upx;
font-size: 28upx;
color: #333;
font-weight: bold;
line-height: 50upx;
}
.ipt-box {
margin-left: 40upx;
margin-top: 20upx;
input {
width: 100%;
height: 70upx;
line-height: 70upx;
font-size: 28upx;
color: #666;
border: 1px solid #e5e5e5;
padding-left: 20upx;
border-radius: 10upx;
// padding: 40upx 20upx;
}
textarea{
width: 100%;
height: 200upx;
font-size: 28upx;
color: #666;
border: 1px solid #e5e5e5;
padding: 20upx;
border-radius: 10upx;
}
.radio-group{
font-size: 26upx;
display: flex;
justify-content: flex-start;
align-items: center;
margin-right: 40upx;
min-width: 140upx;
margin-bottom: 20upx;
}
}
.select {
.arrow {
float: right;
width: 16upx;
height: 29upx;
margin-top: 10upx;
}
.picker {
height: 50upx;
line-height: 50upx;
font-size: 26upx;
color: #666;
margin-left: 10upx;
}
}
}
}
.uni-textarea-textarea{
text-align:left
}
.nolist {
font-size: 30upx;
color: #797979;
text-align: center;
margin-top: 20upx;
}
.main {
margin: 180upx 40upx 0;
position: relative;
z-index: 10;
.tab-box {
overflow: hidden;
// border-radius: 10upx 10upx 0 0;
// background: rgba(132, 149, 167, 0.8);
height: 80upx;
.tab-item {
float: left;
height: 70upx;
width: 30%;
font-size: 30upx;
// color: #e5f6ff;
// text-align: center;
line-height: 70upx;
}
.active {
// background: #fff;
color: #333;
border-radius: 10upx 10upx 0 0;
font-weight: bold;
}
.activeLine{
background: linear-gradient( 90deg, #50CBA1 0%, #06AEA6 100%), #5685F2;
border-radius: 10upx;
width: 80upx;
height: 10upx;
}
}
}
.list-content {
font-size: 28upx;
margin: 0 40rpx;
.details {
background: white;
padding: 0 15upx 15upx;
border-radius: 20upx;
margin-bottom: 20rpx;
position: relative;
.detail_header {
border-bottom: #f8f8f8 5upx solid;
height: 100upx;
line-height: 100upx;
// margin: 0;
// border-radius: 10upx;
.blueSign {
height: 28upx;
width: 5upx;
background: #00c277;
display: inline-block;
margin-left: 20upx;
vertical-align: middle;
}
.font-tilte {
font-size: 32upx;
font-weight: bold;
margin-left: 20upx;
vertical-align: middle;
}
}
.detail_msg {
margin-left: 20upx;
border-radius: 10upx;
overflow: hidden;
color: #999999;
view {
height: 60upx;
line-height: 60upx;
}
.status {
position: absolute;
color: red;
margin-left: 580upx;
margin-top: -15upx;
}
}
}
}
.statusgr {
float: right;
margin-right: 30upx;
color: #00c277;
}
.statusred {
width: 160upx;
height: 60upx;
line-height: 60upx;
text-align: center;
border-radius: 50upx;
float: right;
margin-right: 30upx;
margin-top: 25upx;
}
.img-box {
overflow: hidden;
padding-top: 20rpx;
padding-bottom: 10rpx;
.img-item {
float: left;
width: 200upx;
height: 200upx;
border: 1px solid #ddd;
margin: 0 22rpx 20upx 0upx;
position: relative;
box-sizing: border-box;
.img {
display: block;
width: 100%;
height: 100%;
}
.remove-btn {
position: absolute;
top: -18upx;
right: -18upx;
width: 44upx;
height: 44upx;
z-index: 2;
}
}
.upload-btn {
.img {
width: 60upx;
height: 60upx;
margin: 70upx auto 0;
}
}
}
.detail_msg .info-item {
font-size: 28upx;
margin-right: 30upx;
text {
display: inline-block;
width: 140upx;
color: #999999;
}
.infoSpan {
width: auto;
font-size: 28upx;
color: #999999;
float: right;
}
}
.form-box {
background: #fff;
.form-item {
overflow: hidden;
border-bottom: 1px solid #eee;
padding: 30upx 20upx;
.label {
float: left;
width: 150upx;
font-size: 28upx;
color: #333;
font-weight: bold;
line-height: 50upx;
}
.ipt-box {
margin-left: 160upx;
input {
width: 100%;
height: 50upx;
line-height: 50upx;
font-size: 26upx;
color: #666;
}
}
.select {
.arrow {
float: right;
width: 16upx;
height: 29upx;
margin-top: 10upx;
}
.picker {
height: 50upx;
line-height: 50upx;
font-size: 26upx;
color: #666;
margin-left: 10upx;
}
}
}
}
.comment-btn {
float: right;
font-size: 24upx;
border-radius: 10upx;
color: #fff;
// line-height: 30upx;
text-align: center;
min-width: 120upx;
margin-right: 30upx;
background-color: #00c277;
padding:0px 20upx
}
.common-shade{
position:fixed;
top:0;
left:0;
width:100%;
height:100vh;
background: rgba(0,0,0,0.7);
z-index:9999;
}
.box {
display: flex;
display: -webkit-flex;
}
.box-row-reverse {
flex-direction: row;
}
/*上下排列*/
.box-column {
flex-direction: column;
}
/*上下排列*/
.box-left {
justify-content: flex-start;
}
/*居右*/
.box-right {
justify-content: flex-end;
}
/*居左*/
.box-center {
justify-content: center;
}
/*居中*/
.box-between {
justify-content: space-between;
}
/*两端对齐*/
.box-align-center {
align-items: center;
}
.box-wrap {
flex-wrap: wrap;
}
</style>