Commit 7dd87ce9 authored by xinzhedeai's avatar xinzhedeai

备案

parent aebf081c
...@@ -47,7 +47,7 @@ var userInfo = { ...@@ -47,7 +47,7 @@ var userInfo = {
} }
} }
var token ="Bearer eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiJjNTliYWZjYTdiOWQ0MzA2ODYzNDE4N2MwMGRlZGU1NCIsInVzZXIiOiJhZG1pbiIsInN1YiI6ImFkbWluIn0.U8gezo_te7BGJMUfLsa9dKxshyPAdDSkkYAkLHJ2xYQMxwMUlvMgpCkX6xRXJfzwJSscHaMqPgQinL445sq2lQ"; var token ="Bearer eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiI3MDVhZDI4NDE3MWE0MmQxOWU3OWNjMTJiMTUzZjMyYyIsInVzZXIiOiJhZG1pbiIsInN1YiI6ImFkbWluIn0.gsZIN6epIz5PpJRAA1X5IjM9DRBjmDpND9lR_o27cAbzEaRGL75JwXt8OBczwxDigisiiqeD4VpaMyCwIfXyNg";
localStorage.setItem('Authorization', token) localStorage.setItem('Authorization', token)
localStorage.setItem('appCounty', userInfo.user.county) localStorage.setItem('appCounty', userInfo.user.county)
......
...@@ -164,7 +164,8 @@ var http = { ...@@ -164,7 +164,8 @@ var http = {
}) })
}, },
downloadFile: function(url, params) { downloadFile: function(url, params) {
console.log('downloadfILE',params) var fileType = params.fileType ? params.fileType : 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8'
var fileName = params.fileName ? params.fileName : (+new Date()) +'.xlsx'
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios({ axios({
url, url,
...@@ -180,7 +181,7 @@ var http = { ...@@ -180,7 +181,7 @@ var http = {
// 返回格式是文件流格式 // 返回格式是文件流格式
// 在请求拿到文件流res以后,使用a标签下载 // 在请求拿到文件流res以后,使用a标签下载
let fileData = res.data let fileData = res.data
let blob = new Blob([ fileData], { type: 'application/msword;charset=UTF-8' }/* , { let blob = new Blob([ fileData], { type: fileType }/* , {
type: `application/vnd.openxmlformats-officedocument.wordprocessingml.document;charset=utf-8;` type: `application/vnd.openxmlformats-officedocument.wordprocessingml.document;charset=utf-8;`
} */) } */)
...@@ -189,7 +190,7 @@ var http = { ...@@ -189,7 +190,7 @@ var http = {
a.style = 'display: none'; a.style = 'display: none';
var url = window.URL.createObjectURL(blob); var url = window.URL.createObjectURL(blob);
a.href = url; a.href = url;
a.setAttribute('download', 'YH-'+ gemhoUtil.getTargetDateYMD().replaceAll('-', '') +'.docx') a.setAttribute('download', fileName)
a.click(); a.click();
a.remove(); a.remove();
window.URL.revokeObjectURL(url); window.URL.revokeObjectURL(url);
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0, viewprot-fit:cover">
<title>危险作业备案-详情</title>
<!-- <script src="https://cdn.bootcdn.net/ajax/libs/pdf.js/2.0.193/pdf.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/pdf.js/2.0.193/pdf.worker.min.js"></script> -->
<!-- <script src="../js/pdfjs-4.2.67-dist/build/pdf.mjs"></script>
<script src="../js/pdfjs-4.2.67-dist/build/pdf.worker.mjs"></script> -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.11.338/pdf.min.js"></script>
<script type="text/javascript" src="../js/includeHead.js"></script>
<style>
html, body{
background-color: #fff;
}
.pd-01rem{
padding-bottom: 0.1rem;
}
/* 表单相关 */
.formValue{
float: right;
}
.formSubmitBtnWrapper{
display: flex;
justify-content: center;
margin-top: 0.2rem;
margin-bottom:0.2rem;
}
.formSubmitBtnWrapper .van-button{
width: 4rem;
}
/**
* 框架样式覆盖修改
*/
.van-cell__value{overflow: unset; }
.van-cell:after{border-bottom:none;}
.van-radio-group--horizontal{float: right;}
</style>
</head>
<body>
<div id="app">
<div class="content" v-cloak>
<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-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-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>
<van-cell-group>
<van-field v-model="form.workNumber" :disabled="disabled" label="作业人数" placeholder="" />
</van-cell-group>
<van-cell-group>
<van-field v-model="form.mainPlace" :disabled="disabled" label="主要场所" placeholder="" />
</van-cell-group>
<van-cell-group>
<van-field v-model="form.reportPer" :disabled="disabled" label="报告人" placeholder="" />
</van-cell-group>
<van-cell-group>
<van-field v-model="form.perTel" :disabled="disabled" label="联系方式" placeholder="" />
</van-cell-group>
<van-cell-group :class="{'disable-van-cell': disabled}">
<van-cell is-link @click="showPopup('showPopup4hdRectificationDate')">报告时间<span class="formValue">{{form.uploadDate}}</span></van-cell>
<van-popup v-model="showPopup4hdRectificationDate" position="bottom" :style="{ height: '30%' }">
<van-datetime-picker v-model="hdRectificationDateModel" type="date" title="选择年月日" @confirm="confirm4hdRectificationDate" @cancel="showPopup4hdRectificationDate=false" />
</van-popup>
</van-cell-group>
<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>文件预览:
<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)"
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>
</van-cell>
</van-cell-group>
<van-cell-group :class="{'disable-van-cell': disabled}">
<van-cell>文件:
<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>
</van-uploader>
</div></van-cell>
</van-cell-group>
<div class="formSubmitBtnWrapper" v-if="!disabled"><van-button type="info" size="small" @click="submit">提交</van-button></div>
</div>
</div>
</body>
</html>
\ No newline at end of file
/**
* author: dabao
*/
var VUE = null
window.addEventListener("load", function() {
VUE = new Vue({
el: '#app',
data() {
return {
previewUrl: axios.defaults.baseURL,
form: {
id: '',
companyId: '',
name: "",
workTime1: "",
workTime2: "",
workTime: '',
workNumber: '',
mainPlace: '',
reportPer: '',
perTel: '',
remark: '',
uploadDate: "",
filePathList: [] // 'dangerjob/e40eda16-7a86-4a2a-976b-892e17eeed49.pdf'
},
// 企业id
companyId: localStorage.getItem('companyId'),
disabled: false,
pageType: '',
// 检查日期的模态框
hdInspectDateModel1: '', // 时间的临时model值
showPopup4hdInspectDate1: false,
// 检查日期的模态框
hdInspectDateModel2: '', // 时间的临时model值
showPopup4hdInspectDate2: false,
// 整改日期模态框
hdRectificationDateModel: '',
showPopup4hdRectificationDate: false,
fileList: [],
}
},
mounted() {
if (gemhoUtil.getParameter('type') === 'detail') {
this.disabled = true
this.pageType = 'detail'
this.detail()
} else if (gemhoUtil.getParameter('type') === 'edit') {
this.disabled = false
this.pageType = 'edit'
this.detail()
} else { // 新增
this.disabled = true
this.pageType = 'add'
this.resetData()
}
},
methods: {
previewFile(){
// var src = 'dangerjob/e40eda16-7a86-4a2a-976b-892e17eeed49.pdf'
// location.href = './pdfViewer.html?pdfSrc='+ src
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 中止上传
},
afterRead(file) {
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 的目的
Object.assign(this.$data, this.$options.data.call(this));
},
showPopup(popupType) {
if (!this.disabled) {
this[popupType] = true
}
},
detail() {
http.get('/api/dangerJobReport/page', {
page: 0, // 每次请求增加下一页
size: 1,
// companyId: gemhoUtil.getParameter('companyId'),
id: gemhoUtil.getParameter('dwId'),
sort: 'id,asc',
}).then((res) => {
console.log('响应结果', res.content)
this.form = res.content[0]
if(this.form.workTime && this.form.workTime.length){
this.form.workTime1 = this.form.workTime[0]
this.form.workTime2 = this.form.workTime[1]
}
})
},
submit() {
if (!this.form.name) {
vant.Dialog.alert({
message: '请输入危险作业备案名称',
})
return;
}
if (!this.form.workTime1 || !this.form.workTime2) {
vant.Dialog.alert({
message: '请选择作业时间',
})
return;
}
// let formData = new FormData()
// for (const key of Object.keys(this.form)) {
// formData.append(key, this.form[key]);
// }
this.form.companyId = this.companyId
this.form.workTime = [this.form.workTime1, this.form.workTime2]
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.showPopup4hdInspectDate1 = false
},
confirm4hdInspectDate2(value) {
console.log('value', value)
this.form.workTime2 = this.formatDate(new Date(value))
this.showPopup4hdInspectDate2 = false
},
confirm4hdRectificationDate(value) {
console.log('value', value)
this.form.uploadDate = this.formatDate(new Date(value))
this.showPopup4hdRectificationDate = false
},
},
});
});
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0, viewprot-fit:cover">
<title>危险作业备案-列表</title>
<script type="text/javascript" src="../js/includeHead.js"></script>
<style>
/**
* 框架样式覆盖修改
*/
.van-cell__value{overflow: unset; }
.van-cell:after{border-bottom:none;}
</style>
</head>
<body>
<div id="app">
<div class="search-wrapper">
<van-search v-model="companyName" placeholder="请输入公司名称" @search="onSearch" @clear="onClear" />
</div>
<div class="searchfuntionBtnWrapper">
<van-button type="info" size="small" @click="exportFile">导出</van-button>
</div>
<div class="content" v-cloak>
<van-list v-model:loading="loading" :offset="10" :finished="finished" finished-text="没有更多了" @load="getList">
<van-cell v-for="(item, index) in list" :key="item">
<div class="list-item-wrapper" >
<p class="">
企业名称:{{item.companyName}}
</p>
<p class="">
危险作业:{{item.name}}
</p>
<p class="">
作业人数:{{item.workNumber}}
</p>
<p class="">
作业时间:{{item.workTime && item.workTime.join('~ ')}}
</p>
<p class="">
主要场所:{{item.mainPlace}}
</p>
<div class="list-function-btn-wrapper pd-01rem">
<van-button type="info" size="mini" @click="detail(item)">查看</van-button>
</div>
</div>
</van-cell>
</van-list>
</div>
</div>
</body>
</html>
\ No newline at end of file
/**
* author: dabao
*/
var VUE = null
window.addEventListener("load", function() {
VUE = new Vue({
el: '#app',
data() {
return {
companyName: '',
value: '',
list: [],
loading: false,
finished: false,
page: 0,
size: 10,
total: 0
}
},
mounted() {
this.getList()
},
methods: {
resetSearchForm(){
this.page = 0
this.size = 20
this.total = 0
this.list = []
this.finished = false;
},
onClear(){
this.resetSearchForm()
this.getList()
},
onSearch(val){
this.resetSearchForm()
console.log('search', val)
this.getList()
},
exportFile(item){
http.downloadFile('/api/dangerJobReport/export',{
fileType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
fileName: 'DW-'+ gemhoUtil.getTargetDateYMD().replaceAll('-', '') +'.xlsx'
}).then((res)=>{
vant.Toast({
message: '操作成功',
})
this.loading = false; // 加载状态结束
})
},
add(){
gemhoUtil.navigatePage('./dw-list-detail.html?type=add')
},
detail(item){
gemhoUtil.navigatePage('./dw-list-detail.html?dwId='+item.id+'&type=detail')
},
edit(item){
gemhoUtil.navigatePage('./dw-list-detail.html?dwId='+item.id+'&type=edit')
},
getList(){
http.get('/api/dangerJobReport/page',{
page: this.page++,// 每次请求增加下一页
size: this.size,
companyName: this.companyName,
// companyId: gemhoUtil.getParameter('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; // 下滑不在刷新数据
}
})
}
},
});
});
\ No newline at end of file
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<div class="list-item-wrapper" > <div class="list-item-wrapper" >
<p class=""> <p class="">
<span id=""> <span id="">
{{item.hdDesc}} {{item.hdDesc || item.comment}}
</span> </span>
</p> </p>
<p class="list-content-fz" v-if="item.hdStatus==0"> <p class="list-content-fz" v-if="item.hdStatus==0">
......
...@@ -22,7 +22,9 @@ window.addEventListener("load", function() { ...@@ -22,7 +22,9 @@ window.addEventListener("load", function() {
methods: { methods: {
exportFile(item){ exportFile(item){
http.downloadFile('/api/thHiddenDanger/exportWord',{ http.downloadFile('/api/thHiddenDanger/exportWord',{
id: item.hdId id: item.hdId,
fileType: 'application/msword;charset=UTF-8',
fileName: 'YH-'+ gemhoUtil.getTargetDateYMD().replaceAll('-', '') +'.docx'
}).then((res)=>{ }).then((res)=>{
vant.Toast({ vant.Toast({
message: '操作成功', message: '操作成功',
......
...@@ -8,16 +8,7 @@ ...@@ -8,16 +8,7 @@
<title>隐患-列表</title> <title>隐患-列表</title>
<script type="text/javascript" src="../js/includeHead.js"></script> <script type="text/javascript" src="../js/includeHead.js"></script>
<style> <style>
/**
* 框架样式覆盖修改
*/
.van-cell__value {
overflow: unset;
}
.van-cell:after {
border-bottom: none;
}
.companyWordElipsis { .companyWordElipsis {
display: inline-block; display: inline-block;
......
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