Commit f1d55a71 authored by xinzhedeai's avatar xinzhedeai

检查单

parent 12c49257
This diff is collapsed.
/** axios封装
* 请求拦截、相应拦截、错误统一处理
*/
// 环境的切换
axios.defaults.baseURL = 'http://192.168.3.37:8036'
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['systemId'] = '1'
axios.defaults.headers.common['Authorization'] = localStorage.getItem('Authorization')
// 请求拦截器
axios.interceptors.request.use(config => {
console.log('request拦截器', 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 http = {
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)
})
})
},
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)
})
})
},
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0, viewprot-fit:cover"> 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>
<script type="text/javascript" src="../sdk/includeHead.js"></script> <script type="text/javascript" src="../sdk/includeHead.js"></script>
<script type="text/javascript" src="_check_info_data.js"></script>
</head> </head>
<body> <body>
...@@ -24,10 +25,10 @@ ...@@ -24,10 +25,10 @@
<div class="item_title"> <div class="item_title">
{{ checkData[checkPageIndex].title }} {{ checkData[checkPageIndex].title }}
</div> </div>
<div v-for="(item, index) in checkData[checkPageIndex]['checkList']" :key="item.id" class="check-item"> <div v-for="(item, index) in checkData[checkPageIndex]['gqCheckItemVoList']" :key="item.id" class="check-item">
<div class="item-header"> <div class="item-header">
<!-- <div class="item-number">{{ index + 1 }}</div> --> <!-- <div class="item-number">{{ index + 1 }}</div> -->
<div class="item-title">{{ index + 1 }}.{{ item.title }}</div> <div class="item-title">{{ index + 1 }}.{{ item.name }}</div>
</div> </div>
<!-- 单选按钮组 --> <!-- 单选按钮组 -->
...@@ -43,9 +44,9 @@ ...@@ -43,9 +44,9 @@
<div> <div>
<!-- 子检查项 --> <!-- 子检查项 -->
<div class="sub-checkbox-group" v-if="flag=='ADD'"> <div class="sub-checkbox-group" v-if="flag=='ADD'">
<van-checkbox v-for="(subItem, subIndex) in item.subChecks" :key="subIndex" <van-checkbox v-for="(subItem, subIndex) in item.gqCheckQuestionDtoList" :key="subIndex"
v-model="subItem.checked" shape="square"> v-model="subItem.check" shape="square">
隐患点{{ subIndex + 1 }} {{ subItem.name}}
</van-checkbox> </van-checkbox>
</div> </div>
......
...@@ -2,7 +2,7 @@ window.onload = function() { ...@@ -2,7 +2,7 @@ window.onload = function() {
// 原 JavaScript 代码保持不变 // 原 JavaScript 代码保持不变
const checkData = [{ let checkData = [{
id: 1, id: 1,
title: '消防安全检查', title: '消防安全检查',
checkList: [{ checkList: [{
...@@ -149,6 +149,9 @@ window.onload = function() { ...@@ -149,6 +149,9 @@ window.onload = function() {
}, },
]; ];
checkData = res.data
function countSelectedNo(result) { function countSelectedNo(result) {
// 获取 checkList 中 selected 为 'no' 的对象个数 // 获取 checkList 中 selected 为 'no' 的对象个数
return result.reduce((total, category) => { return result.reduce((total, category) => {
...@@ -172,9 +175,9 @@ window.onload = function() { ...@@ -172,9 +175,9 @@ window.onload = function() {
} }
// 统计各个状态数量 // 统计各个状态数量
const noCount = countSelectedNo(checkData); // selected=no 的个数 const noCount = 0// countSelectedNo(checkData); // selected=no 的个数
const totalItems = getTotalCheckListItems(checkData); // checkList 子元素总数 const totalItems = 0//getTotalCheckListItems(checkData); // checkList 子元素总数
const notNullCount = countSelectedNotNull(checkData); // selected 不为 null 的个数 const notNullCount = 0//countSelectedNotNull(checkData); // selected 不为 null 的个数
// 初始化检查项数据结构 // 初始化检查项数据结构
function createCheckItem(id) { function createCheckItem(id) {
...@@ -199,7 +202,7 @@ window.onload = function() { ...@@ -199,7 +202,7 @@ window.onload = function() {
el: '#app', el: '#app',
data: { data: {
flag: 'ZG_XQ', // 值为ADD新增、JC_XQ检查详情、ZG_XQ整改详情、YH_XQ隐患详情 flag: 'ZG_XQ', // 值为ADD新增、JC_XQ检查详情、ZG_XQ整改详情、YH_XQ隐患详情
// flag: 'ADD', flag: 'ADD',
// flag: 'JC_XQ', // flag: 'JC_XQ',
// flag: 'YH_XQ', // flag: 'YH_XQ',
checkPerson: 'xxxx李先生', checkPerson: 'xxxx李先生',
......
This diff is collapsed.
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