代码优化

This commit is contained in:
BianLzhaoMin 2025-04-08 17:51:41 +08:00
parent c6ecf0c761
commit f24b443062
9 changed files with 91 additions and 65 deletions

View File

@ -1,6 +1,6 @@
<template>
<!-- 重要事项及宣传类 ---- 上传记录 -->
<view class="upload-record">
<view class="upload-record" :style="{ paddingTop: safeAreaInsets?.top + 44 + 'px' }">
<NavBarModal :navBarTitle="`协调照片`" />
<view class="container">
<view class="search-input">
@ -134,6 +134,7 @@ import NavBarModal from '@/components/NavBarModal/index'
import { ref, computed } from 'vue'
import { debounce } from 'lodash-es' //
import { getCoordinatePhotoListApi } from '@/services/coordinatePhotos.js'
const { safeAreaInsets } = uni.getSystemInfoSync()
const coordinatePhotosList = ref([])
const total = ref(0)

View File

@ -1,6 +1,6 @@
<template>
<!-- 重要事项及宣传类 ---- 上传记录 -->
<view class="upload-record">
<view class="upload-record" :style="{ paddingTop: safeAreaInsets?.top + 44 + 'px' }">
<NavBarModal :navBarTitle="`重要事项及宣传类`" />
<view class="container">
<view class="search-input">
@ -79,6 +79,7 @@ import NavBarModal from '@/components/NavBarModal/index'
import { ref, reactive, computed } from 'vue'
import { debounce } from 'lodash-es' //
import { getImportantMattersListApi } from '@/services/importantMatters.js'
const { safeAreaInsets } = uni.getSystemInfoSync()
const importantMattersList = ref([])
const total = ref(0)

View File

@ -112,11 +112,7 @@
@afterRead="onAfterReadVrImgList"
:deletable="props.addAndEditFormType != 3"
:fileList="addAndEditModel.vrImgList"
:maxCount="
props.addAndEditFormType == 3
? addAndEditModel.vrImgList.length
: 9 - addAndEditModel.vrImgList
"
:maxCount="props.addAndEditFormType == 3 ? addAndEditModel.vrImgList.length : 9"
/>
</up-form-item>
<TitleTipModal :TitleTip="`整改信息`" />
@ -163,9 +159,7 @@
@afterRead="onAfterReadCorrectionImgList"
:fileList="addAndEditModel.correctionImgList"
:maxCount="
props.addAndEditFormType == 3
? addAndEditModel.correctionImgList.length
: 9 - addAndEditModel.correctionImgList
props.addAndEditFormType == 3 ? addAndEditModel.correctionImgList.length : 9
"
/>
</up-form-item>
@ -315,6 +309,7 @@ const addAndEditModel = reactive({
rectDesc: '', //
vrImgList: [], //
correctionImgList: [], //
rectStatus: 0,
})
//
@ -521,11 +516,7 @@ const onAfterReadVrImgList = (event) => {
}
//
const onDeletePicVrImgList = (event) => {
if (
props.addAndEditFormType == 2 &&
addAndEditModel.vrImgList[event.index].id &&
addAndEditModel.vrImgList[event.index].idEdit
) {
if (props.addAndEditFormType == 2 && addAndEditModel.vrImgList[event.index].isEdit) {
deleteFileList.push({ id: addAndEditModel.vrImgList[event.index].id })
}
@ -544,12 +535,8 @@ const onAfterReadCorrectionImgList = (event) => {
}
//
const onDeleteCorrectionImgList = (event) => {
if (
props.addAndEditFormType == 2 &&
addAndEditModel.correctionImgList[event.index].id &&
addAndEditModel.correctionImgList[event.index].idEdit
) {
deleteFileList.push({ id: addAndEditModel.correctionImgList[event.index]?.id })
if (props.addAndEditFormType == 2 && addAndEditModel.correctionImgList[event.index].isEdit) {
deleteFileList.push({ id: addAndEditModel.correctionImgList[event.index].id })
}
addAndEditModel.correctionImgList.splice(event.index, 1)
@ -618,6 +605,7 @@ const onSubmitForm = debounce(() => {
rectUserName, //
rectTime, //
rectDesc, //
rectStatus,
} = addAndEditModel
const addParams = {
@ -638,6 +626,7 @@ const onSubmitForm = debounce(() => {
rectDesc, //
fileList: [...successVrImgList, ...successCorrectionImgList],
uploadType: 2,
rectStatus: addAndEditModel.correctionImgList.length > 0 ? 1 : 0,
}
const SED_API =
@ -669,11 +658,11 @@ const onSubmitForm = debounce(() => {
sendLoading.value = false
if (res.code === 200) {
uni.$u.toast(res.data)
// setTimeout(() => {
// uni.navigateBack({
// delta: 1,
// })
// }, 500)
setTimeout(() => {
uni.navigateBack({
delta: 1,
})
}, 500)
} else {
uni.$u.toast(res.data)
}
@ -757,6 +746,7 @@ const getFormDetail = async () => {
rectDesc, //
rectPhotoList,
vioPhotoList,
rectStatus,
} = res.data
let rectPhotoListEdit = []
@ -798,6 +788,7 @@ const getFormDetail = async () => {
rectDesc, //
vrImgList: vioPhotoListEdit,
correctionImgList: rectPhotoListEdit,
rectStatus,
})
getProcedureData(majorId)

View File

@ -1,6 +1,6 @@
<template>
<!-- 质量检查 ---- 上传记录 -->
<view class="upload-record">
<view class="upload-record" :style="{ paddingTop: safeAreaInsets?.top + 44 + 'px' }">
<NavBarModal :navBarTitle="`质量检查`" />
<view class="container">
<view class="search-input">
@ -83,7 +83,6 @@ import { ref, computed } from 'vue'
import { debounce } from 'lodash-es' //
import { getQualityInspectionListApi } from '@/services/qualityInspection.js'
const { safeAreaInsets } = uni.getSystemInfoSync()
const upListRef = ref(null) //
const total = ref(0)
const qualityInspectionList = ref([])

View File

@ -1,6 +1,6 @@
<template>
<!-- 安全违章 ---- 上传记录 -->
<view class="upload-record">
<view class="upload-record" :style="{ paddingTop: safeAreaInsets?.top + 44 + 'px' }">
<NavBarModal :navBarTitle="`安全措施落实`" />
<view class="container">
<view class="search-input">
@ -83,6 +83,7 @@ import NavBarModal from '@/components/NavBarModal/index'
import { ref, reactive, computed } from 'vue'
import { debounce } from 'lodash-es' //
import { getSafetyMeasureListApi } from '@/services/safetyMeasure.js'
const { safeAreaInsets } = uni.getSystemInfoSync()
const safetyMeasureList = ref([])
const total = ref(0)

View File

@ -112,11 +112,7 @@
@afterRead="onAfterReadVrImgList"
:fileList="addAndEditModel.vrImgList"
:deletable="props.addAndEditFormType != 3"
:maxCount="
props.addAndEditFormType == 3
? addAndEditModel.vrImgList.length
: 9 - addAndEditModel.vrImgList.length
"
:maxCount="props.addAndEditFormType == 3 ? addAndEditModel.vrImgList.length : 9"
/>
</up-form-item>
<TitleTipModal :TitleTip="`整改信息`" />
@ -163,9 +159,7 @@
:deletable="props.addAndEditFormType != 3"
:fileList="addAndEditModel.correctionImgList"
:maxCount="
props.addAndEditFormType == 3
? addAndEditModel.correctionImgList.length
: 9 - addAndEditModel.correctionImgList.length
props.addAndEditFormType == 3 ? addAndEditModel.correctionImgList.length : 9
"
/>
</up-form-item>
@ -315,6 +309,7 @@ const addAndEditModel = reactive({
rectDesc: '', //
vrImgList: [], //
correctionImgList: [], //
rectStatus: 0,
})
//
@ -512,11 +507,7 @@ const onAfterReadVrImgList = (event) => {
}
//
const onDeletePicVrImgList = (event) => {
if (
props.addAndEditFormType == 2 &&
addAndEditModel.vrImgList[event.index].id &&
addAndEditModel.vrImgList[event.index].idEdit
) {
if (props.addAndEditFormType == 2 && addAndEditModel.vrImgList[event.index].isEdit) {
deleteFileList.push({ id: addAndEditModel.vrImgList[event.index].id })
}
@ -535,12 +526,8 @@ const onAfterReadCorrectionImgList = (event) => {
}
//
const onDeleteCorrectionImgList = (event) => {
if (
props.addAndEditFormType == 2 &&
addAndEditModel.correctionImgList[event.index].id &&
addAndEditModel.correctionImgList[event.index].idEdit
) {
deleteFileList.push({ id: addAndEditModel.correctionImgList[event.index]?.id })
if (props.addAndEditFormType == 2 && addAndEditModel.correctionImgList[event.index].isEdit) {
deleteFileList.push({ id: addAndEditModel.correctionImgList[event.index].id })
}
addAndEditModel.correctionImgList.splice(event.index, 1)
@ -609,6 +596,7 @@ const onSubmitForm = debounce(() => {
rectUserName, //
rectTime, //
rectDesc, //
rectStatus,
} = addAndEditModel
const addParams = {
@ -629,6 +617,7 @@ const onSubmitForm = debounce(() => {
rectDesc, //
fileList: [...successVrImgList, ...successCorrectionImgList],
uploadType: 2,
rectStatus: addAndEditModel.correctionImgList.length > 0 ? 1 : 0,
}
const SED_API =
@ -748,12 +737,13 @@ const getFormDetail = async () => {
rectDesc, //
rectPhotoList,
vioPhotoList,
rectStatus,
} = res.data
let rectPhotoListEdit = []
let vioPhotoListEdit = []
if (rectPhotoList?.length > 0) {
if (rectPhotoList.length > 0) {
rectPhotoListEdit = rectPhotoList.map((e) => {
return {
isEdit: true,
@ -762,7 +752,7 @@ const getFormDetail = async () => {
}
})
}
if (vioPhotoList?.length > 0) {
if (vioPhotoList.length > 0) {
vioPhotoListEdit = vioPhotoList.map((e) => {
return {
isEdit: true,
@ -789,6 +779,7 @@ const getFormDetail = async () => {
rectDesc, //
vrImgList: vioPhotoListEdit,
correctionImgList: rectPhotoListEdit,
rectStatus,
})
getProcedureData(majorId)

26
src/utils/env.js Normal file
View File

@ -0,0 +1,26 @@
const ENV = process.env.NODE_ENV
const platform = uni.getSystemInfoSync().platform
// let BASE_URL = 'http://192.168.2.188:21907/gz_att_wechat' // 本地
// let BASE_URL = 'http://192.168.0.14:21907/gz_att_wechat' // 测试服务地址
// let BASE_URL = 'https://jj.jypxks.com/gz_att_wechat' // 生产服务地址
// let BASE_URL = 'http://192.168.0.50:1907/gz_att_wechat' // 孙亮
let BASE_URL = 'http://192.168.2.131:1907/gz_att_wechat' // 孙亮
// 如果是浏览器调试会产生跨域 则配置请求基地址为 api 或其他 必须与vue.config.js 中配置的代理一致 解决跨域问题
// if (ENV === 'development' && (platform === 'h5' || platform === 'windows')) {
// BASE_URL = 'api'
// }
// // 生产则直接配置 线上ip 或者 nginx代理的路径
// if (ENV === 'production' && (platform === 'h5' || platform === 'windows')) {
// BASE_URL = '/prod-api'
// }
// // app不产生跨域 直接配置请求基地址 开发环境
// if (ENV === 'development' && (platform === 'android' || platform === 'ios')) {
// BASE_URL = 'https://test-cc.zhgkxt.com/sgzbgl-api'
// }
// // app不产生跨域 直接配置请求基地址 生产环境
// if (ENV === 'production' && (platform === 'android' || platform === 'ios')) {
// BASE_URL = 'http://*****'
// }
export default BASE_URL

View File

@ -23,20 +23,36 @@ const httpInterceptor = {
options.url = baseURL + options.url
}
if (options?.isPassWord) {
if (options.isEncrypt) {
if (options.data) {
options.data = cloneDeep(options.data) // 参数深拷贝 避免影响视图
for (const key in options.data) {
options.data[key] = encrypt(options.data[key])
}
// if (options?.isPassWord) {
// if (options.isEncrypt) {
// if (options.data) {
// options.data = cloneDeep(options.data) // 参数深拷贝 避免影响视图
// for (const key in options.data) {
// options.data[key] = encrypt(options.data[key])
// }
// }
// } else {
// if (!options.isNull) {
// options.data = {
// // encryptedData: encrypt(JSON.stringify(options.data)),
// encryptedData: JSON.stringify(options.data),
// }
// }
// }
// }
if (options.isEncrypt) {
if (options.data) {
options.data = cloneDeep(options.data) // 参数深拷贝 避免影响视图
for (const key in options.data) {
options.data[key] = encrypt(options.data[key])
}
} else {
if (!options.isNull) {
options.data = {
// encryptedData: encrypt(JSON.stringify(options.data)),
encryptedData: JSON.stringify(options.data),
}
}
} else {
if (!options.isNull) {
options.data = {
encryptedData: encrypt(JSON.stringify(options.data)),
// encryptedData: JSON.stringify(options.data),
}
}
}

View File

@ -9,9 +9,9 @@ export default defineConfig({
// 在此处编写代理规则
'/api': {
// target: 'http://192.168.0.133:11997', // 梁超
// target: 'http://192.168.0.137:11997', // 方亮
target: 'http://192.168.0.137:11997', // 方亮
// target: 'http://192.168.0.60:11997', // 赵福海
target: 'http://192.168.0.39:11997', // 陈长文
// target: 'http://192.168.0.39:11997', // 陈长文
changeOrigin: true,
rewrite: (path) => {
return path.replace(/\/api/, '')