Commit 48af1bf3 authored by xinzhedeai's avatar xinzhedeai

危险备案功能开发弯沉

parent e58604d3
......@@ -34,11 +34,11 @@ var http2 = {
if(params.fileList){ // 用于接口传递的额外参数 如文件流等){
extraData.fileList = params.fileList
}
// console.log('http2方法进来了~extraData', extraData)
console.log('http2方法进来了~extraData', extraData)
// vaildInterfacefn("gqyjglptxiefn", params.serviceId, data, "1", "https://" + urldomaincreatesign, "https://" + urldomaingateway).then((value) => {
vaildInterfacefn("gqyjglptxiefn", params.serviceId, data, "1", extraData).then((value) => {
// console.log('vaildInterfacefn响应', value)
console.log('vaildInterfacefn响应', value)
/**
* code: 200
data: "048b04671ad85e52e" // value 值就是接口返回的data值
......
......@@ -59,7 +59,16 @@ const API_KEY_MAP = {
publicKey: '04fcdb9f752aa40e2f75078ae4817b3c4684042747d82b7bd9640146001aaf885e9b9627c2273498bc9940174132af52ed19cbe2f871bcaab52018123e5311e58f',
privateKey: '0092ba7d7629e681f4a82cede0c129749710e4f7cd2437ac83141036053896c08e'
},
// 应急演练编辑
// 应急演练图片上传(危险备案和应急演练可以共用,返回全路径)
'emergency-add': { // 应急演练新增
id: 'yjyljhxzenterpriseDrills',
publicKey: '048d58d3d7083d8c349c49132efb0c3f77e76018f7d71c41395668c35fbb2876536d1a19e8383c960db0360625b45a0d6b566d2204573e0e556727c5c5cb3d7fbc',
privateKey: '57960a25ce1f4968586be888fe4980586aca9bed6fd5a08e69c92be63829473e'
},
'upload': { // 应急演练图片上传(危险备案和应急演练可以共用)
id: 'wjscjkupload',
publicKey: '042e41f442af21dcbed1431e20510db26bdd1ccc54a327e42daf8621a0b5291f4586ea56ccd59aeef12ba0528911ed93c338a270948fe4e2d5b64adb87eb0e7cc5',
privateKey: '00bb211356bb9b883066cbd221feaf82a9492944d4082a881ed77ffdc812d6f908'
},
}
var gemhoUtil = window.gemhoUtil || {}
gemhoUtil.formatDate = function(date, type) {
var ymd =
`${date.getFullYear() + 1}-${((date.getMonth()+1)>9?'':'0')+(date.getMonth() + 1)}-${(date.getDate()>9?'':'0')+date.getDate()}`;
`${date.getFullYear()}-${((date.getMonth()+1)>9?'':'0')+(date.getMonth() + 1)}-${(date.getDate()>9?'':'0')+date.getDate()}`;
if (type === 'YYYY-MM-DD HH:MM:SS') {
return ymd + ' 00:00:00';
}
......
......@@ -44,17 +44,17 @@
<body>
<div id="app">
<div class="content" v-cloak>
<input type="submit" id="submitBtn" style="display:none;">
<van-cell-group>
<van-field v-model="form.name" :disabled="disabled" label="危险作业" placeholder="" />
</van-cell-group>
<van-cell-group :class="{'disable-van-cell': disabled}">
<van-cell is-link @click="showPopup('showPopup4hdInspectDate1')" >作业起始时间<span class="formValue">{{form.workTime1}}</span></van-cell>
<van-cell is-link @click="showPopup('showPopup4hdInspectDate1')" >作业起始时间<span class="formValue">{{form.startTime}}</span></van-cell>
<van-popup v-model="showPopup4hdInspectDate1" position="bottom" :style="{ height: '30%' }">
<van-datetime-picker v-model="hdInspectDateModel1" type="date" title="选择年月日" @confirm="confirm4hdInspectDate1" @cancel="showPopup4hdInspectDate1=false" />
</van-cell-group>
<van-cell-group :class="{'disable-van-cell': disabled}">
<van-cell is-link @click="showPopup('showPopup4hdInspectDate2')" >作业结束时间<span class="formValue">{{form.workTime2}}</span></van-cell>
<van-cell is-link @click="showPopup('showPopup4hdInspectDate2')" >作业结束时间<span class="formValue">{{form.endTime}}</span></van-cell>
<van-popup v-model="showPopup4hdInspectDate2" position="bottom" :style="{ height: '30%' }">
<van-datetime-picker v-model="hdInspectDateModel2" type="date" title="选择年月日" @confirm="confirm4hdInspectDate2" @cancel="showPopup4hdInspectDate2=false" />
</van-cell-group>
......@@ -80,34 +80,32 @@
<van-cell-group>
<van-field v-model="form.remark" :disabled="disabled" label="备注" placeholder="" />
</van-cell-group>
<van-cell-group :class="{'disable-van-cell': true}">
<van-cell-group :class="{'disable-van-cell': true}" v-show="showWrapper">
<van-cell>文件预览:
<div style="width: 6.5rem;">
<van-image
v-show="(form.filePathList[0]) && (form.filePathList[0].indexOf('.png')>-1 || form.filePathList[0].indexOf('.jpg')>-1 || form.filePathList[0].indexOf('.jpeg')>-1)"
v-show="showImage"
width="100"
height="100"
:src="previewUrl+'/' + form.filePathList[0]"
/>
</div>
<span v-show="(form.filePathList[0]) && (form.filePathList[0].indexOf('.pdf')>-1)" @click="previewFile">{{ form.filePathList[0] }}</span>
<span v-show="form.filePathList[0] && !disabled" style="font-weight: bold; cursor: pointer;" @click="form.filePathList=[];fileList=[]"> 删除</span>
<span v-show="showPdf" @click="previewFile">{{ form.filePathList[0] }}</span>
<span v-show="!disabled" style="font-weight: bold; cursor: pointer;" @click="form.filePathList=[];fileList=[]"> 删除</span>
</van-cell>
</van-cell-group>
<van-cell-group :class="{'disable-van-cell': disabled}">
<van-cell>文件
<!-- :before-read="beforeRead" :max-size="1*1024*1024"-->
<van-cell-group :class="{'disable-van-cell': disabled}" v-show="pageType !== 'detail' && !form.filePathList.length">
<van-cell>文件:<span style="color: red;">(限制大小2.5M以内)</span>
<div style="width: 2.5rem;">
<van-uploader v-model="fileList"
accept=".jpg,.jpeg,.png,.pdf"
:preview-image="false"
:before-upload="beforeUpload"
:after-read="afterRead"
:max-count="1" :deletable="!disabled" :preview-full-image="false">
<van-button v-show="pageType !== 'detail' && !form.filePathList.length" size="mini" icon="plus" type="primary">上传文件</van-button>
:before-read="beforeRead"
:max-count="1" :preview-full-image="false">
<van-button size="mini" icon="plus" type="primary">上传文件</van-button>
</van-uploader>
</div></van-cell>
</van-cell-group>
......
......@@ -7,13 +7,14 @@ window.addEventListener("load", function() {
el: '#app',
data() {
return {
uploading: false,
previewUrl: BASE_URL,
form: {
id: '',
companyId: '',
name: "",
workTime1: "",
workTime2: "",
startTime: "",
endTime: "",
workTime: '',
workNumber: '',
mainPlace: '',
......@@ -43,6 +44,13 @@ window.addEventListener("load", function() {
}
},
mounted() {
// if(gemhoUtil.getCookie('uploading')=== 'Y'){
// vant.Dialog.alert({
// title: '信息提示',
// message: '网络错误,请重新上传图片'
// })
// return
// }
if (gemhoUtil.getParameter('type') === 'detail') {
this.disabled = true
this.pageType = 'detail'
......@@ -57,7 +65,17 @@ window.addEventListener("load", function() {
this.resetData()
}
},
computed:{
showImage(){
return this.form.filePathList[0] && (this.form.filePathList[0].indexOf('.png')>-1 || this.form.filePathList[0].indexOf('.jpg')>-1 || this.form.filePathList[0].indexOf('.jpeg')>-1)
},
showPdf(){
return this.form.filePathList[0] && (this.form.filePathList[0].indexOf('.pdf')>-1)
},
showWrapper(){
return this.form.filePathList[0]
}
},
methods: {
previewFile(){
// var src = 'dangerjob/e40eda16-7a86-4a2a-976b-892e17eeed49.pdf'
......@@ -65,12 +83,24 @@ window.addEventListener("load", function() {
console.log(this.previewUrl + '/' + this.form.filePathList[0])
location.href = this.previewUrl + '/' + this.form.filePathList[0]
},
beforeUpload(file) {
console.log('beforeUpload',file)
// 在文件上传之前的处理逻辑,例如校验文件大小、文件类型等
return true; // 返回 true 继续上传,返回 false 中止上传
},
beforeRead(file) {
if (file.size > (2.5*1024*1024)) {
vant.Dialog.alert({
title: '信息提示',
message: '文件大小不可超过2.5M'
})
return false;
}
return true;
},
afterRead(file) { // 调用爱山东中台系统,将数据流传递过去
// gemhoUtil.setCookie('uploading', 'Y')
vant.Toast.loading({
message: '正在处理...',
forbidClick: true,
......@@ -88,49 +118,16 @@ window.addEventListener("load", function() {
file: file.file
}]
}, (res) => {
// gemhoUtil.setCookie('uploading', 'N')
if(res){
console.log('接口回调数据', JSON.parse(res))
var result = JSON.parse(res)
this.form.filePathList = result.body ? [result.body] : []
this.loading = false; // 加载状态结束
if(result.body && result.body.indexOf('dangerjob') > -1){
this.form.filePathList = [result.body]
}
vant.Toast.clear()
vant.Toast({
message: '操作完成',
})
}
})
// // console.log('afterRead',file)
// // 文件读取完成后的处理逻辑
// const formData = new FormData();
// formData.append('file', file.file); // 通过FormData构建要上传的文件数据
// formData.append('modelName', 'dangerjob');
// // 发送HTTP POST请求
// fetch(this.previewUrl + '/api/common/upload', {
// method: 'POST',
// body: formData
// })
// .then(response => {
// if (response.ok) {
// return response.json();
// }
// throw new Error('Network response was not ok.');
// })
// .then(data => {
// console.log(data); // 处理后端返回的数据
// // 可根据后端返回的数据做进一步处理,如显示上传成功信息等
// this.form.filePathList = data.body ? [data.body] : []
// })
// .catch(error => {
// console.error('There has been a problem with your fetch operation:', error);
// });
},
resetData() {
// 使用 Object.assign 来重写 this.$data,以达到重置 data 的目的
......@@ -142,6 +139,11 @@ window.addEventListener("load", function() {
}
},
detail() {
vant.Toast.loading({
message: '正在加载...',
forbidClick: true,
loadingType: 'spinner',
});
http2.post({
serviceId: API_KEY_MAP["dw-list"]['id'],
interfacePublicKey: API_KEY_MAP["dw-list"]["publicKey"],
......@@ -153,14 +155,14 @@ window.addEventListener("load", function() {
if(res){
console.log('接口回调数据', JSON.parse(res))
vant.Toast.clear()
var result = JSON.parse(res)
// this.noticeContent = result.noticeContent
this.form = result.content[0]
this.form.filePathList = result.content[0].filePathList || []
if(this.form.workTime && this.form.workTime.length){
this.form.workTime1 = this.form.workTime[0]
this.form.workTime2 = this.form.workTime[1]
this.form.startTime = this.form.workTime[0]
this.form.endTime = this.form.workTime[1]
}
}
})
......@@ -172,19 +174,29 @@ window.addEventListener("load", function() {
})
return;
}
if (!this.form.workTime1 || !this.form.workTime2) {
if (!this.form.startTime || !this.form.endTime) {
vant.Dialog.alert({
message: '请选择作业时间',
})
return;
}
if(+new Date(this.form.startTime) > +new Date(this.form.endTime)){
vant.Dialog.alert({
message: '起始时间不能大于结束时间',
})
return;
}
// this.form.companyId = this.companyId
this.form.workTime = this.form.workTime1+','+ this.form.workTime2// [this.form.workTime1, this.form.workTime2]
delete this.form['workTime1']
delete this.form['workTime2']
this.form.workTime = [this.form.startTime, this.form.endTime]
// const tempStartTime = this.form['startTime']
// const tempEndTime = this.form['endTime']
delete this.form['startTime']
delete this.form['endTime']
vant.Toast.loading({
message: '正在处理...',
forbidClick: true,
loadingType: 'spinner',
});
http2.post({
serviceId: API_KEY_MAP["dw-list-detail"]['id'],
interfacePublicKey: API_KEY_MAP["dw-list-detail"]["publicKey"],
......@@ -197,46 +209,29 @@ window.addEventListener("load", function() {
vant.Toast({
message: '操作成功',
})
this.form['startTime'] = tempStartTime
this.form['endTime'] = tempEndTime
if (!this.form.id) { // 添加时则
location.reload()
}
}
})
// var url = "/api/dangerJobReport/create"
// http.post(url, this.form).then((res) => {
// console.log('添加结果', res)
// vant.Toast({
// message: '操作成功',
// })
// if (!this.form.id) { // 添加时则
// location.reload()
// }
// })
},
formatDate(date, type) {
var ymd =
`${date.getFullYear() + 1}-${((date.getMonth()+1)>9?'':'0')+(date.getMonth() + 1)}-${(date.getDate()>9?'':'0')+date.getDate()}`;
if (type === 'YYYY-MM-DD HH:MM:SS') {
return ymd + ' 00:00:00';
}
return ymd
},
confirm4hdInspectDate1(value) {
console.log('value', value)
this.form.workTime1 = this.formatDate(new Date(value))
this.form.startTime = gemhoUtil.formatDate(new Date(value))
this.showPopup4hdInspectDate1 = false
},
confirm4hdInspectDate2(value) {
console.log('value', value)
this.form.workTime2 = this.formatDate(new Date(value))
this.form.endTime = gemhoUtil.formatDate(new Date(value))
this.showPopup4hdInspectDate2 = false
},
confirm4hdRectificationDate(value) {
console.log('value', value)
this.form.uploadDate = this.formatDate(new Date(value))
this.form.uploadDate = gemhoUtil.formatDate(new Date(value))
this.showPopup4hdRectificationDate = false
},
......
......@@ -22,19 +22,23 @@ window.addEventListener("load", function() {
},
methods: {
add(){
gemhoUtil.setCookie('uploading', 'N')
gemhoUtil.navigatePage('./dw-list-detail.html?type=add')
},
detail(item){
gemhoUtil.setCookie('uploading', 'N')
gemhoUtil.navigatePage('./dw-list-detail.html?dwId='+item.id+'&type=detail')
},
edit(item){
gemhoUtil.setCookie('uploading', 'N')
gemhoUtil.navigatePage('./dw-list-detail.html?dwId='+item.id+'&type=edit')
},
getList(){
if(this.loading){
return
}
this.loading = true
// if(this.loading){
// return
// }
// this.loading = true
setTimeout(() => {
http2.post({
serviceId: API_KEY_MAP["dw-list"]['id'],
interfacePublicKey: API_KEY_MAP["dw-list"]["publicKey"],
......@@ -57,28 +61,10 @@ window.addEventListener("load", function() {
if(this.page*this.size >= this.total){
this.finished = true; // 下滑不在刷新数据
}
}
this.loading = false
})
// http.get('/api/dangerJobReport/page',{
// page: this.page++,// 每次请求增加下一页
// size: this.size,
// // companyId: localStorage.getItem('companyId'),
// county: localStorage.getItem('appCounty'),
// sort: 'id,desc',
// }).then((res)=>{
// this.loading = false; // 加载状态结束
// this.list.push(...res.content);
// this.total = res.totalElements
// if(this.page*this.size >= this.total){
// this.finished = true; // 下滑不在刷新数据
// }
// })
}, 0)
}
},
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment