Commit 48af1bf3 authored by xinzhedeai's avatar xinzhedeai

危险备案功能开发弯沉

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