Commit aafa8258 authored by xinzhedeai's avatar xinzhedeai

add: 检查单处理

parent 129f3d64
......@@ -173,3 +173,4 @@
</div>
</body>
</html>
......@@ -8,8 +8,15 @@ axios.defaults.timeout = 50000
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
axios.defaults.headers.post['Content-Type'] = 'application/json'
// axios.defaults.headers.common['Authorization'] = gemhoUtil.getCookie('token')
// 商户token
// axios.defaults.headers.common['Authorization'] =
// 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiLlvKDlrZ3lvakiLCJsb2dpbl91c2VyX2tleSI6IjNjMmRiMWFiLWIyZGMtNDBjYi04YjM5LWRiNTJmM2VmYzNkYyJ9.sfZyPP-COShNCjwxKR26zGDsPHXss97gu7JEpaMapIZyMQEsxzMigVickcqdhaqDwTRcfr0IxAj64vnrriS9Cw'
// admin账号token
axios.defaults.headers.common['Authorization'] =
'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxNTcyMTAzMTg4NiIsImxvZ2luX3VzZXJfa2V5IjoiMGFmNjhkZjItZjc3Ni00OTlkLTkzYjQtOGNkMmNlMDg2ZTVjIn0.NynQrQAUSqbWRGtjc00PHedLPvKdo0oHmHocwwdJmZyXQJjs0_B9_CeCeTs2PUkbEkRuYupzzPN3MvqtWC-GLw'
'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImxvZ2luX3VzZXJfa2V5IjoiYjA1MWRmZmEtYWE4Yy00NTNiLThlNGUtMTdjOTEzYmMwOWFkIn0.nj2miSFFPQRDabzhq_05z_wW0w13quXBooQbbtnyRZQxOhxenEQQZM3OgKjgd8AxjY7W2uKlpdyqGuTmMb1PRQ'
// 请求拦截器
axios.interceptors.request.use((config) => {
......
/** axios封装
* 请求拦截、相应拦截、错误统一处理
*/
// 环境的切换
axios.defaults.baseURL = 'http://192.168.2.37:8080'
axios.defaults.timeout = 50000
// post请求头
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
axios.defaults.headers.post['Content-Type'] = 'application/json'
// axios.defaults.headers.common['Authorization'] = gemhoUtil.getCookie('token')
// 商户token
// axios.defaults.headers.common['Authorization'] =
// 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiLlvKDlrZ3lvakiLCJsb2dpbl91c2VyX2tleSI6IjNjMmRiMWFiLWIyZGMtNDBjYi04YjM5LWRiNTJmM2VmYzNkYyJ9.sfZyPP-COShNCjwxKR26zGDsPHXss97gu7JEpaMapIZyMQEsxzMigVickcqdhaqDwTRcfr0IxAj64vnrriS9Cw'
// admin账号token
axios.defaults.headers.common['Authorization'] =
'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImxvZ2luX3VzZXJfa2V5IjoiYjA1MWRmZmEtYWE4Yy00NTNiLThlNGUtMTdjOTEzYmMwOWFkIn0.nj2miSFFPQRDabzhq_05z_wW0w13quXBooQbbtnyRZQxOhxenEQQZM3OgKjgd8AxjY7W2uKlpdyqGuTmMb1PRQ'
// 请求拦截器
axios.interceptors.request.use((config) => {
vant.Toast.loading({
message: '加载中...',
forbidClick: true,
loadingType: 'spinner',
})
return config
})
// 响应拦截器
axios.interceptors.response.use(
(res) => {
// 成功的响应数据 服务器的相关的数据返回来之后,响应拦截器能够检测到,可以做一些事
vant.Toast.clear()
return res
},
(error) => {
// 响应失败的时候的回调函数
return Promise.reject(new Error(error))
}
)
var http3 = {
get: function(url, params) {
return new Promise((resolve, reject) => {
axios
.get(url, {
params: params
})
.then(res => {
resolve(res.data)
})
.catch(err => {
reject(err.data)
})
})
},
post: function(url, params) {
return new Promise((resolve, reject) => {
axios
.post(url, params)
.then(res => {
let response = res.data
console.log('res.statusCode', response)
if (response.statusCode >= 300 || response.status >= 300) {
// alert('系统发生错误')
vant.Dialog.alert({
title: '信息提示',
message: response.message,
})
return
}
resolve(res.data)
})
.catch(err => {
reject(err.data)
})
})
},
delete: function(url, params) {
return new Promise((resolve, reject) => {
axios({
url,
method: 'post',
data: params,
headers: {
// 'Content-Type': 'application/json', // 'multipart/form-data;',
'Authorization': localStorage.getItem('Authorization'),
'requestType': 'delete'
},
})
.then(res => {
let response = res.data
console.log('res.statusCode', response)
if (response.statusCode >= 300 || response.status >= 300) {
// alert('系统发生错误')
vant.Dialog.alert({
title: '信息提示',
message: response.message,
})
return
}
resolve(res.data)
})
.catch(err => {
reject(err.data)
})
})
},
put: function(url, params) {
return new Promise((resolve, reject) => {
axios({
url,
method: 'post',
data: params,
headers: {
// 'Content-Type': 'application/json', // 'multipart/form-data;',
'Authorization': localStorage.getItem('Authorization'),
'requestType': 'put'
},
})
.then(res => {
let response = res.data
console.log('res.statusCode', response)
if (response.statusCode >= 300 || response.status >= 300) {
// alert('系统发生错误')
vant.Dialog.alert({
title: '信息提示',
message: response.message,
})
return
}
resolve(res.data)
})
.catch(err => {
reject(err.data)
})
})
},
postFile: function(url, params) {
return new Promise((resolve, reject) => {
axios({
url,
method: 'post',
data: params,
headers: {
'Content-Type': 'application/json', // 'multipart/form-data;',
'Authorization': localStorage.getItem('Authorization')
},
}).then(res => {
let response = res.data
console.log('res.statusCode', response)
if (response.statusCode >= 300 || response.status >= 300) {
// alert('系统发生错误')
vant.Dialog.alert({
title: '信息提示',
message: response.message,
})
return
}
resolve(res.data)
})
.catch(err => {
reject(err.data)
})
})
},
downloadFile: function(url, params) {
console.log('downloadfILE', params)
return new Promise((resolve, reject) => {
axios({
url,
method: 'get',
// data: params,
params: params,
headers: {
// 'Content-Type': 'application/json', // 'multipart/form-data;',
'Authorization': localStorage.getItem('Authorization')
},
responseType: 'blob' //在请求中加上这一行,特别重要
}).then(res => {
// 返回格式是文件流格式
// 在请求拿到文件流res以后,使用a标签下载
let fileData = res.data
let blob = new Blob([fileData], {
type: 'application/msword;charset=UTF-8'
}
/* , {
type: `application/vnd.openxmlformats-officedocument.wordprocessingml.document;charset=utf-8;`
} */
)
var a = document.createElement('a');
document.body.appendChild(a);
a.style = 'display: none';
var url = window.URL.createObjectURL(blob);
a.href = url;
a.setAttribute('download', 'YH-' + gemhoUtil.getTargetDateYMD().replaceAll('-',
'') + '.docx')
a.click();
a.remove();
window.URL.revokeObjectURL(url);
})
.catch(err => {
reject(err.data)
})
})
},
}
\ No newline at end of file
......@@ -69,3 +69,4 @@ function getPageN() {
pageN = pageN.substring(pageN.lastIndexOf('/') + 1, pageN.indexOf('.'))
return pageN
}
......@@ -8,7 +8,9 @@
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="../sdk/includeHead.js"></script>
<script type="text/javascript" src="../sdk/axios_http3.js"></script>
<script type="text/javascript" src="_check_info_data.js"></script>
<!-- <script type="text/javascript" src="_check_info_data_detail.js"></script>
<script type="text/javascript" src="_check_info_data_detail_yh.js"></script> -->
</head>
......@@ -27,7 +29,7 @@
<div class="item_title">
{{ checkData?.[checkPageIndex]?.name }}
</div>
<div v-for="(item, index) in checkData?.[checkPageIndex]?.['gqCheckItemVoList']" :key="item.id" class="check-item">
<div v-for="(item, index) in checkData?.[checkPageIndex]?.['gqCheckItemList']" :key="item.id" class="check-item">
<div class="item-header">
<!-- <div class="item-number">{{ index + 1 }}</div> -->
<div class="item-title">{{ item.id }}.{{ item.name }}</div>
......@@ -47,7 +49,7 @@
<!-- 子检查项 -->
<div class="sub-checkbox-group">
<van-cell v-if="item.itemType==1">
<van-checkbox v-for="(subItem, subIndex) in item.gqCheckQuestionDtoList" :key="subIndex"
<van-checkbox v-for="(subItem, subIndex) in item.gqCheckQuestionList" :key="subIndex"
v-model="subItem.check" shape="square" :disabled="flag!=='ADD'">
{{ subItem.name}}
</van-checkbox>
......@@ -55,7 +57,7 @@
<van-cell v-if="item.itemType==2">
<div class="limit_date_wrapper">
<span>住宿人数:</span>
<input type="text" v-model="item.gqCheckQuestionDtoList[0].content" :disabled="flag!=='ADD'"
<input type="text" v-model="item.gqCheckQuestionList[0].content" :disabled="flag!=='ADD'"
style="width:.8rem;height:.4rem;text-align:center;" />
</div>
</van-cell>
......
......@@ -12,13 +12,14 @@
*/
var VUE = null
window.onload = function() {
function countSelectedNo(result) {
// 获取 checkList 中 selected 为 'no' 的对象个数
return VUE.originCheckData.reduce((total, category) => {
return result.reduce((total, category) => {
return (
total +
category.gqCheckItemVoList.filter((item) => item.itemAnswer === 2)
category.gqCheckItemList.filter((item) => item.itemAnswer === 2)
.length
)
}, 0)
......@@ -26,10 +27,10 @@ window.onload = function() {
function countSelectedNotNull(result) {
// 获取 checkList 中 selected 不为 null 的个数
return VUE.originCheckData.reduce((total, category) => {
return result.reduce((total, category) => {
return (
total +
category.gqCheckItemVoList.filter((item) => item.itemAnswer !== 0)
category.gqCheckItemList.filter((item) => item.itemAnswer !== 0)
.length
)
}, 0)
......@@ -39,6 +40,7 @@ window.onload = function() {
el: '#app',
data: {
id: '', // 记录id || 隐患id
merId: '', // 商户id
pageName: '', // 页面名称(用于记录页面来源,用于操作后返回上一页)
flag: 'ZG_XQ', // 值为ADD新增、JC_XQ检查详情、ZG_XQ整改详情、YH_XQ隐患详情
flag: 'ADD',
......@@ -61,7 +63,7 @@ window.onload = function() {
mounted() {
/**
* 调转该_check_info.html页面时需要传递参数
* type : ADD新增、JC_XQ检查详情、ZG_XQ整改详情、YH_XQ隐患详情
* flag : ADD新增、JC_XQ检查详情、ZG_XQ整改详情、YH_XQ隐患详情
* id: 记录id || 隐患id
* pageName: 页面名称(用于记录页面来源,用于操作后返回上一页)
*
......@@ -69,6 +71,7 @@ window.onload = function() {
console.log(gemhoUtil.getParameter, 'gemhoUtil.getParameter')
this.pageName = gemhoUtil.getParameter('pageName')
this.id = gemhoUtil.getParameter('id')
this.merId = gemhoUtil.getParameter('merId')
this.flag = gemhoUtil.getParameter('flag')
// this.flag = 'JC_XQ'
......@@ -89,16 +92,16 @@ window.onload = function() {
handler(newVal) {
const snapshot = JSON.parse(JSON.stringify(newVal));
console.log('全量变化:', snapshot);
this.noCount = countSelectedNo(newVal); // selected=no 的个数
this.noCount = countSelectedNo(snapshot); // selected=no 的个数
// this.totalItems = getTotalCheckListItems(newVal); // checkList 子元素总数
this.notNullCount = countSelectedNotNull(newVal); // selected 不为 null 的个数
this.notNullCount = countSelectedNotNull(snapshot); // selected 不为 null 的个数
},
deep: true
}
},
methods: {
getOriginMatchedItemById(id) {
const result = this.originCheckData[this.checkPageIndex]['gqCheckItemVoList'].find(item =>
const result = this.originCheckData[this.checkPageIndex]['gqCheckItemList'].find(item =>
item.id === id) || []
return JSON.parse(JSON.stringify(result))
},
......@@ -108,10 +111,10 @@ window.onload = function() {
const newItem = this.getOriginMatchedItemById(item.id)
console.log(val, newItem, '数据改变了。。。。newItem')
newItem.itemAnswer = val
// console.log(this.checkData[this.checkPageIndex]['gqCheckItemVoList'])
this.$set(this.checkData[this.checkPageIndex]['gqCheckItemVoList'], index, JSON.parse(JSON
// console.log(this.checkData[this.checkPageIndex]['gqCheckItemList'])
this.$set(this.checkData[this.checkPageIndex]['gqCheckItemList'], index, JSON.parse(JSON
.stringify()));
console.log(val, this.checkData[this.checkPageIndex]['gqCheckItemVoList'][index], '数据改变了后',
console.log(val, this.checkData[this.checkPageIndex]['gqCheckItemList'][index], '数据改变了后',
index)
},
// 文件上传处理
......@@ -168,17 +171,19 @@ window.onload = function() {
vant.Toast.clear()
})
}, 0);
// var result = JSON.parse(res)
var result = res
var result = JSON.parse(res)
this.checkDate = result.data.checkDate // 检查日期
this.checkPeopleName = result.data.checkPeopleName // 检查人员
this.rectificationDeadline = result.data.rectificationDeadline // 整改截止日期
this.reviewDate = result.data.reviewDate // 隐患审核日期
this.reviewRecord = result.data.reviewRecord
this.totalItems = result.data.itemAllCount,
this.totalItems = result.itemAllCount
// 表单数据
this.checkData = JSON.parse(JSON.stringify(result.data.gqCheckTypeDtoList))
this.originCheckData = JSON.parse(JSON.stringify(result.data.gqCheckTypeDtoList))
this.checkData = JSON.parse(JSON.stringify(result.data.gqCheckTypeList))
this.originCheckData = JSON.parse(JSON.stringify(result.data.gqCheckTypeList))
countSelectedNo(this.originCheckData);
countSelectedNotNull(this.originCheckData)
}
}
)
......@@ -261,13 +266,15 @@ window.onload = function() {
var result = JSON.parse(res)
this.checkDate = result.data.checkTime // 检查日期
this.checkPeopleName = result.data.checkPeopleName // 检查人员
this.checkData = result.data.gqCheckTypeDtoList
this.checkData = result.data.gqCheckTypeList
this.noCount = result.data.hiddenCount
this.notNullCount = result.data.notRectifiedCount
this.totalItems = result.itemAllCount
// 表单数据
this.originCheckData = JSON.parse(JSON.stringify(result.data.gqCheckTypeDtoList))
this.originCheckData = JSON.parse(JSON.stringify(result.data.gqCheckTypeList))
countSelectedNo(this.originCheckData);
countSelectedNotNull(this.originCheckData)
}
}
......@@ -348,17 +355,17 @@ window.onload = function() {
},
add4JC_XQ() {
var reqParam = {
"merId": "1",
"gqCheckTypeVoList": this.checkData,
"merId": this.merId,
"gqCheckTypeList": this.checkData,
}
// var url = "/gq/checkRecord/safeCheckRecord"
http2.post('/gq/checkRecord/safeCheckRecord', reqParam).then((res) => {
http3.post('/gq/checkRecord/safeCheckRecord', reqParam).then((res) => {
console.log('添加结果', res)
vant.Toast({
message: '操作成功',
})
gemhoUtil.navigatePage(this.pageName + '.html', '操作完成,跳转中...')
// gemhoUtil.navigatePage(this.pageName + '.html', '操作完成,跳转中...')
})
}
}
......
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