Commit cde37d44 authored by xinzhedeai's avatar xinzhedeai

add:应急演练列表页面接口对接,erudajs本地引入

parent 10631a9e
This diff is collapsed.
......@@ -24,9 +24,8 @@ document.write(`
`)
// 移动端 debugger 调试
// if (localStorage.getItem('debug')=='Y') {
document.write(
'<script type="text/javascript" src="//cdn.bootcdn.net/ajax/libs/eruda/2.4.1/eruda.js"></script>\
<script>eruda.init();</script>'
document.write(`<script type="text/javascript" src="${contextPath}/sdk/eruda-2.4.1.js"></script>\
<script>eruda.init();</script>`
)
// }
......
......@@ -154,7 +154,9 @@ window.addEventListener("load", function () {
}
if (res) {
var result = JSON.parse(res)
console.log('消费者', result)
this.merInformation = { ...this.merInformation, ...result.data }
// this.merInformation.safeLevel = 1
}
}
)
......
......@@ -13,7 +13,7 @@
<div class="wrapper" v-cloak>
<!-- 商户头部信息 -->
<div class="header">
<van-search v-model="merName" show-action placeholder="请输入培训演练标题" @search="onSearch">
<van-search v-model="title" show-action placeholder="请输入培训演练标题" @search="onSearch">
<template #action>
<div @click="onSearch"></div>
</template>
......@@ -25,16 +25,18 @@
<!-- Tab栏 -->
<van-tabs v-model:active="activeTab" @click="clickTab" title-active-color="#1989fa" line-height="2px"
style="margin-bottom: 15px;">
<van-tab title="安全培训" name="0"></van-tab>
<van-tab title="应急演练" name="1"></van-tab>
<van-tab :title="item.dictLabel" v-for="item in tabList4lv1"></van-tab>
<!-- <van-tab title="安全培训" name="0"></van-tab>
<van-tab title="应急演练" name="1"></van-tab> -->
<div class="subNavWrapper">
<!-- 隐患记录子Tab -->
<van-tabs v-if="activeTab==0" v-model:active="subActiveTab" type="card">
<van-tab title="全部"></van-tab>
<van-tabs v-if="activeTab==0" v-model:active="subActiveTab" @click="clickSubTab" type="card">
<van-tab :title="item.dictLabel" v-for="item in tabList4lv2"></van-tab>
<!-- <van-tab title="全部"></van-tab>
<van-tab title="特种作业"></van-tab>
<van-tab title="常规"></van-tab>
<van-tab title="新员工"></van-tab>
<van-tab title="新员工"></van-tab> -->
</van-tabs>
<!-- 隐患列表 -->
<van-list v-model:loading="loading" :offset="10" :finished="finished" finished-text="没有更多了" @load="getList" :immediate-check="false">
......@@ -44,17 +46,17 @@
<van-cell v-for="item in hazardList" :key="item.id" @click="viewDetail(item.id)">
<div style="width: 100%;position: relative;">
<!-- 第一行:商户名称 -->
<div class="tab1-row1 bold">{{ item.merName }}</div>
<div class="tab1-row1 bold">{{ item.title }}</div>
<!-- 第二行:场所类型 + 检查单位(两列) -->
<div class="tab1-row1">
<span>日期:{{ item.placeType }}</span>
<span>日期:{{ item.exerciseDate }}</span>
</div>
<!-- 第三行:监察人 + 检查日期(两列) -->
<div class="tab1-row2">
<span v-if="activeTab==0">培训人数:{{ item.pushDate }}</span>
<span v-if="activeTab==1">演练人数:{{ item.pushDate }}</span>
<span v-if="activeTab==0">培训人数:{{ item.participantsNum }}</span>
<span v-if="activeTab==1">演练人数:{{ item.responsiblePerson }}</span>
<span>培训人:{{ item.pushPeople }}</span>
</div>
......
......@@ -4,16 +4,18 @@
* description: 商户首页
*/
var VUE = null
window.addEventListener("load", function () {
window.addEventListener("load", function() {
VUE = new Vue({
el: '#app',
data() {
return {
merName: '',
title: '',
userType: gemhoUtil.getCookie('userType'),
tabList4lv1: [],
tabList4lv2: [],
// 新增子Tab数据
subActiveTab: 0,
hazardList: [// 更多示例数据...
hazardList: [ // 更多示例数据...
],
activeTab: 0,
showTimePicker: false,
......@@ -50,8 +52,74 @@ window.addEventListener("load", function () {
console.log(params);
this.merId = params.merId
this.init() // 获取隐患记录
this.getDict4tab1()
this.getDict4tab2()
},
methods: {
getDict4tab1() {
http2.post({
serviceId: API_KEY_MAP["page"]['id'],
interfacePublicKey: API_KEY_MAP["page"]["publicKey"],
interfacePrivateKey: API_KEY_MAP["page"]["privateKey"],
reqParams: {
page: 1,
size: 9999,
sign: 15,
dictType: 'training_exercise_type'
}
}, (res) => {
if (!res) { // 中台返回为undefined 重新请求
vant.Toast.clear()
setTimeout(() => {
this.getDict4businessType()
}, 0);
return
}
if (res) {
console.log('接口回调数据=生产经营类型', JSON.parse(res))
setTimeout(() => {
this.$nextTick(() => {
vant.Toast.clear()
})
}, 0);
var result = JSON.parse(res)
this.tabList4lv1 = result.rows
}
})
},
getDict4tab2() {
http2.post({
serviceId: API_KEY_MAP["page"]['id'],
interfacePublicKey: API_KEY_MAP["page"]["publicKey"],
interfacePrivateKey: API_KEY_MAP["page"]["privateKey"],
reqParams: {
page: 1,
size: 9999,
sign: 15,
dictType: 'safety_training_category'
}
}, (res) => {
if (!res) { // 中台返回为undefined 重新请求
vant.Toast.clear()
setTimeout(() => {
this.getDict4businessType()
}, 0);
return
}
if (res) {
console.log('接口回调数据=生产经营类型', JSON.parse(res))
setTimeout(() => {
this.$nextTick(() => {
vant.Toast.clear()
})
}, 0);
var result = JSON.parse(res)
this.tabList4lv2 = result.rows
}
})
},
reset() {
this.page = 1
this.size = 10
......@@ -60,11 +128,14 @@ window.addEventListener("load", function () {
},
clickTab() {
this.init()
console.log('activeTab', this.activeTab)
},
clickSubTab() {
this.init()
console.log('activeSubTab', this.subActiveTab)
},
onSearch() {
console.log('xxxx', this.merName)
console.log('xxxx', this.title)
this.init()
},
init() {
......@@ -108,16 +179,16 @@ window.addEventListener("load", function () {
loadingType: 'spinner',
})
setTimeout(() => {
http2.post(
{
http2.post({
serviceId: API_KEY_MAP['page']['id'],
interfacePublicKey: API_KEY_MAP['page']['publicKey'],
interfacePrivateKey: API_KEY_MAP['page']['privateKey'],
reqParams: {
sign: 3,
sign: 30,
merId: this.merId,
merName: this.merName,
type: this.activeTab,
title: this.title,
exerciseType: this.activeTab + 1,
safetyTrainingType: this.activeTab == 1 ? 0 : this.subActiveTab,
pageNum: this.page++, // 每次请求增加下一页
pageSize: this.size,
sort: 'lawId,desc',
......
......@@ -5,7 +5,7 @@
<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>
<title>安全培训</title>
<!-- 在 includeHead.js 之后添加环境判断 -->
<script src="../sdk/includeHead.js"></script>
<script type="text/javascript" src="../sdk/axios_http3.js"></script>
......@@ -41,7 +41,7 @@
</div>
</div>
<div class="form-item">
<span class="form-label title_require">培训</span>
<span class="form-label title_require">负责</span>
<div class="form-input-wrap">
<input type="text" v-model="formData.contactDetails" :disabled="flag=='XQ'"
class="form-input" placeholder="">
......@@ -76,6 +76,7 @@
<!-- 详情模式 -->
<div class="img-wrapper" style="display: flex;gap:.16rem; margin-top: 0.25rem;
margin-bottom: 0.15rem;">
<div class="form-label title_require">培训照片</div>
<div style="position: relative;" v-for="(imgItem, index) in formData.floorPlanPhotos">
<img :src="previewUrl + imgItem" style="width: 1.6rem; height: 1.6rem;"
@click="showImage(formData.floorPlanPhotos, index)" />
......@@ -100,6 +101,7 @@
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
/**
* author: dabao
* date: 2024-03-15
* description: 商户首页
*/
var VUE = null
window.addEventListener("load", function () {
VUE = new Vue({
el: '#app',
data() {
return {
previewUrl: BASE_URL,
flag: 'XQ',
flag: 'ADD',
showDatePicker: false, // 控制日期选择器显示
minDate: new Date(gemhoUtil.getTargetDateYMD()), // 最小可选日期
maxDate: new Date(2099, 11, 31), // 最大可选日期
// 日期选择的最小范围,这里设置为当前日期的前 10 年
// maxDate: new Date(new Date().getFullYear() + 10, 11),
// 新增以下数据
formData: {
floorPlanPhotos: '',
submitDate: gemhoUtil.getTargetDateYMD(),
createDate: gemhoUtil.getTargetDateYMD(),
date: gemhoUtil.getTargetDateYMD(),
phone: '',
businessHours: '',
type: '', // 新增类型字段
},
id: ''
}
},
created() {
},
mounted() {
this.id = gemhoUtil.getParameter('id')
if(this.id){ // 详情
this.flag = 'XQ'
this.detail() // 获取商户信息
}else{
this.flag = 'ADD'
}
},
methods: {
// 处理平面图删除
handleDeleteFloorPlan(index, type) {
this.formData.floorPlanPhotos.splice(index, 1);
},
beforeRead(file) {
if(!['image/png','image/jpeg','image/jpg'].includes(file.type)){
vant.Dialog.alert({
title: '信息提示',
message: '文件格式不正确'
})
return;
}
if (file.size > (10 * 1024 * 1024)) {
vant.Dialog.alert({
title: '信息提示',
message: '文件大小不可超过10M'
})
return false;
}
return true;
},
afterRead(file, type) { // 调用爱山东中台系统,将数据流传递过去
alert(type)
vant.Toast.loading({
message: '正在处理...',
forbidClick: true,
loadingType: 'spinner',
});
// 文件读取完成后的处理逻辑
const formData = new FormData();
formData.append('file', file.file); // 通过FormData构建要上传的文件数据
// formData.append('biz_content',SM.encrypt('dangerjob', API_KEY_MAP["upload"]["publicKey"]));
// 发送HTTP POST请求
fetch(BASE_URL + '/common/upload', {
method: 'POST',
body: formData,
headers: {
'Authorization': gemhoUtil.getCookie('token'),
}
})
.then(response => {
if (response.ok) {
return response.json();
}
throw new Error('Network response was not ok.');
})
.then(value => {
console.log(value, 'value图片上********'); // 处理后端返回的数据
if(value){ // 返回信息不为空,则进行解密操作
this.formData.floorPlanPhotos.push(value.fileName)
// 可根据后端返回的数据做进一步处理,如显示上传成功信息等
setTimeout(() => {
vant.Toast.clear()
}, 0);
}else{
this.afterRead(file)
}
})
.catch(error => {
// console.error('There has been a problem with your fetch operation:', error);
});
},
showDatePickerModal(){
if(this.flag=='XQ'){
return
}
this.showDatePicker = true
},
showImage(list, index) {
const images = list.map((item)=>{
return this.previewUrl + item
})
console.log(images, 'images')
vant.ImagePreview({
images,
startPosition: index,
closeable: true,
});
},
gotoPage(stringifyUrl) {
let url = gemhoUtil.setParameter(`src/_${stringifyUrl}.html`)
gemhoUtil.navigatePage(url, '跳转中...')
},
// 确认日期选择
onDateConfirm(date) {
// 将 Date 对象格式化为 YYYY-MM-DD 字符串
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
this.formData.date = `${year}-${month}-${day}`;
this.showDatePicker = false;
},
// 文件上传处理
handleFileUpload(file) {
console.log('上传文件:', file);
// 此处可添加实际文件上传逻辑
},
submitForm() {
if (!this.formData.content) {
vant.Dialog.alert({
message: '培训标题不可为空',
})
return;
}
if (!this.formData.content) {
vant.Dialog.alert({
message: '培训演练类别不可为空',
})
return;
}
if (!this.formData.content) {
vant.Dialog.alert({
message: '培训人数不可为空',
})
return;
}
if (!this.formData.content) {
vant.Dialog.alert({
message: '培训人不可为空',
})
return;
}
if (!this.formData.content) {
vant.Dialog.alert({
message: '图片不可为空',
})
return;
}
vant.Toast.loading({
message: '正在处理...',
forbidClick: true,
loadingType: 'spinner',
});
var reqParam = {
merId: this.merId,
...this.formData,
}
// var url = "/gq/checkRecord/safeCheckRecord"
http3.post('/gq/consumer', reqParam).then((res) => {
console.log('添加结果', res)
vant.Toast({
message: '操作成功',
})
location.reload()
})
},
//获取商户信息
detail() {
vant.Toast.loading({
message: '正在加载...',
forbidClick: true,
loadingType: 'spinner',
})
setTimeout(() => {
http2.post(
{
serviceId: API_KEY_MAP['no-page']['id'],
interfacePublicKey: API_KEY_MAP['no-page']['publicKey'],
interfacePrivateKey: API_KEY_MAP['no-page']['privateKey'],
reqParams: {
sign: 11,
pageNum: this.page++, // 每次请求增加下一页
pageSize: this.size,
merId: this.merId,
sort: 'lawId,desc',
},
},
(res) => {
if (!res) {
// 中台返回为undefined 重新请求
vant.Toast.clear()
setTimeout(() => {
// this.getList()
}, 0)
return
}
if (res) {
var result = JSON.parse(res)
this.formData = { ...this.formData, ...result.data }
}
}
)
}, 0)
},
}
});
})
\ No newline at end of file
html,
body {
letter-spacing: 0.01rem;
background-color: #fff;
overflow-x: hidden;
}
.wrapper {
/* padding: 0.2rem; */
background-color: #fff;
}
.header {
padding: 0.2rem;
background: #fff;
}
.header .title {
font-weight: bold;
font-size: 0.32rem;
color: #000000;
display: flex;
justify-content: start;
align-items: center;
gap: 0.2rem;
padding: 0.3rem 0.3rem;
}
.header .title img {
width: 0.51rem;
height: 0.52rem;
}
.detail {
width: 100%;
/* height: 1.88rem; */
background: #f5f6fa;
border-radius: 0.01rem;
/* padding-left: 0.2rem; */
padding: 0.3rem;
margin-bottom: 0.2rem;
display: flex;
align-items: start;
flex-direction: column;
justify-content: space-around;
/* padding-bottom: 0.1rem;
gap: 0.1rem; */
}
.detail .van-col {
font-family: PingFang SC;
font-weight: 500;
font-size: 0.28rem;
color: #737373;
}
.detail span {
font-family: PingFang SC;
font-weight: 500;
font-size: 0.28rem;
color: #737373;
}
.detail .detail_link {
position: absolute;
right: 0.3rem;
font-size: 0.26rem;
color: #1081e3;
cursor: pointer;
}
.func_btn {
width: 7.12rem;
height: 0.8rem;
background: #1081e3;
border-radius: 0.1rem;
font-family: PingFang SC;
font-weight: 500;
font-size: 0.3rem;
color: #ffffff;
margin: 0 auto;
border-width: 0;
margin-left: 0.2rem;
cursor: pointer;
}
.func_btn span {
font-size: 0.5rem;
vertical-align: -0.05rem;
margin-right: 0.1rem;
}
.tag {
display: inline-block;
width: 1.9rem;
height: 0.42rem;
line-height: 0.42rem;
text-align: center;
border-radius: 21px;
font-weight: 500;
font-size: 0.28rem;
color: #ffffff;
}
.green {
background: #00b55e;
}
.yellow {
background: rgba(255, 148, 21, 1);
}
.red {
background: rgba(255, 33, 49, 1);
}
/* 添加以下样式 */
.van-tabs__line {
background-color: #1989fa;
}
.blue-text {
color: #1989fa;
font-weight: 500;
}
.van-list {
background: #fff;
border-radius: 8px;
margin: 0 0.1rem;
}
.subNavWrapper .van-cell {
padding: 12px 10px;
}
.van-tab {
color: #000;
}
.van-tab__text {
font-weight: bold;
font-size: 0.3rem;
/* color: #000; */
}
.van-tab--active {
color: #1081e3;
}
.van-field__label {
font-weight: bold;
}
.van-field__control {
color: #737373;
}
.navToBtn {
color: #5b5b5b;
font-size: 0.36rem;
margin-top: 0.04rem;
position: absolute;
right: 0;
}
[v-cloak] {
display: none;
}
/* 基础重置样式 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
-webkit-tap-highlight-color: transparent;
/* 去除移动端点击高亮 */
}
body {
font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
font-size: 16px;
background-color: #f8f9fa;
}
/* 表单容器 */
.form-container {
max-width: 750px;
/* 移动端最大宽度 */
margin: .05rem auto .2rem;
padding: 0 15px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
/* 表单单项 */
.form-item {
display: flex;
align-items: center;
/* 垂直居中 */
height: 50px;
padding: 0 12px;
border-bottom: 1px solid #f0f2f5;
}
/* 最后一项去除下边框 */
.form-item:last-child {
border-bottom: none;
}
/* 表单标题 */
.form-label {
flex-shrink: 0;
/* 防止标题被压缩 */
width: 1.8rem;
/* 标题固定宽度,可根据需求调整 */
color: #333;
font-size: .15rem;
text-align: left;
/* 标题左对齐 */
}
/* 输入框容器 */
.form-input-wrap {
flex: 1;
/* 占据剩余空间 */
height: 100%;
display: flex;
align-items: center;
padding-left: 0.2rem;
}
/* 输入框样式 */
.form-input {
width: 100%;
height: .7rem;
/* 输入框高度小于容器,留出垂直空间 */
border: none;
outline: none;
font-size: .3rem;
color: #666;
}
/* 输入框placeholder样式 */
.form-input::placeholder {
color: #999;
font-size: .14rem;
}
/* 输入框聚焦效果 */
.form-input:focus {
color: #262626;
}
.imager-item-title {
height: .5rem;
line-height: .5rem;
/* padding: 0 .12rem !important; */
font-size: .14rem !important;
margin-left: .24rem !important;
/* border-bottom: 1px solid #f0f2f5; */
margin-bottom: .15rem !important;
font-weight: 400;
}
.save-btn {
width: 98%;
background: #1890ff;
color: #fff;
border: none;
padding: 7px 20px;
border-radius: 3px;
font-size: 16px;
cursor: pointer;
margin-bottom: .4rem;
}
.textareaEle {
width: 100%;
border: 1px solid #CACACA;
font-size: .28rem;
border-radius: .05rem;
padding: .15rem;
}
.merchant-icon {
width: 100%;
}
.date-wrapper .van-cell {
padding-left: 0;
margin-top: -.23rem;
}
/* 必填标题 */
.title_require {
position: relative;
padding: 0;
margin: 0;
/* margin-top: 0.1rem; */
/* padding-left: 0.2rem; */
font-size: .28rem;
}
.title_require::before {
position: absolute;
content: '*';
color: #ee0a24;
font-size: .14rem;
left: -10px;
top: 50%;
transform: translateY(-50%);
}
.form-label-div {
height: 50px;
line-height: 50px;
padding: 0 12px;
font-size: .28rem;
font-weight: 500;
margin-bottom: -.3rem;
}
.img-wrapper {
display: flex;
gap: .16rem;
margin-top: 0.25rem;
margin-bottom: 0.15rem;
}
\ 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>
<!-- 在 includeHead.js 之后添加环境判断 -->
<script src="../sdk/includeHead.js"></script>
<script type="text/javascript" src="../sdk/axios_http3.js"></script>
</head>
<body>
<div id="app" class="page_wrapper" v-cloak>
<div class="third-layer">
<!-- form开始 -->
<div class="form-container">
<div class="form-item">
<span class="form-label title_require">演练标题</span>
<div class="form-input-wrap">
<input type="text" v-model="formData.contactName" :disabled="flag=='XQ'" class="form-input"
placeholder="">
</div>
</div>
<div class="form-item">
<span class="form-label title_require">演练人数(人)</span>
<div class="form-input-wrap">
<input type="text" v-model="formData.contactDetails" :disabled="flag=='XQ'"
class="form-input" placeholder="">
</div>
</div>
<div class="form-item">
<span class="form-label title_require">负责人</span>
<div class="form-input-wrap">
<input type="text" v-model="formData.contactDetails" :disabled="flag=='XQ'"
class="form-input" placeholder="">
</div>
</div>
<div class="form-item date-wrapper">
<span class="form-label title_require">演练日期</span>
<div class="form-input-wrap">
<van-field readonly v-model="formData.date" :disabled="flag=='XQ'" placeholder=""
class="form-input" @click="showDatePickerModal" />
</div>
</div>
<van-popup v-model="showDatePicker" position="bottom">
<van-datetime-picker type="date" :min-date="minDate" :max-date="maxDate"
@confirm="onDateConfirm" @cancel="showDatePicker = false" />
</van-popup>
<div class="form-label form-label-div">演练照片</div>
<div class="img-wrapper">
<div style="position: relative;" v-for="(imgItem, index) in formData.floorPlanPhotos">
<img :src="previewUrl + imgItem" style="width: 1.6rem; height: 1.6rem;"
@click="showImage(formData.floorPlanPhotos, index)" />
<div v-if="flag=='XG'" class="van-uploader__preview-delete"
@click="handleDeleteFloorPlan(index, 'floorPlan')"><i
class="van-icon van-icon-cross van-uploader__preview-delete-icon"></i></div>
</div>
<div v-if="formData.floorPlanPhotos.length<6 && flag=='ADD' ">
<van-uploader :before-read="beforeRead" :after-read="(file) => afterRead(file, 'floorPlan')"
class="uploader-wrapper" :deletable="false" :preview-image="false"
>
<img src="../image/code/upload.png" style="width:1.6rem;height: 1.6rem;" alt=""
srcset="">
</van-uploader>
</div>
</div>
<!-- form结束 -->
<button class="save-btn" style="margin-left: 50%; transform: translateX(-50%);"
@click="submitForm">提交</button>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
......@@ -73,7 +73,6 @@ window.addEventListener("load", function () {
return true;
},
afterRead(file, type) { // 调用爱山东中台系统,将数据流传递过去
alert(type)
vant.Toast.loading({
message: '正在处理...',
forbidClick: 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