安全违章接口调试完成
This commit is contained in:
parent
67c26f9f77
commit
5395425ba5
|
|
@ -0,0 +1,34 @@
|
|||
import { ref } from 'vue'
|
||||
import { getProjectApi, getMajorApi } from '@/services/common'
|
||||
import { useCommonStore } from '@/stores/index'
|
||||
const commonStore = useCommonStore()
|
||||
|
||||
export default function getProjectAndMajorData() {
|
||||
// 定义公共 hooks 把项目数据和专业数据 return出去
|
||||
const projectList = ref([])
|
||||
const majorList = ref([])
|
||||
|
||||
// 先从store里面判断之前是否已经存过 如果没有存则发起请求获取数据并存入store里面 当存过之后 其他页面使用时则无需再重复发起请求获取
|
||||
|
||||
async function getData() {
|
||||
// 项目数据
|
||||
if (!commonStore.projectList || commonStore.projectList.length < 1) {
|
||||
const { data: result } = await getProjectApi({})
|
||||
commonStore.setProjectList(result)
|
||||
projectList.value = result
|
||||
} else {
|
||||
projectList.value = commonStore.projectList
|
||||
}
|
||||
|
||||
// 专业数据
|
||||
if (!commonStore.majorList || commonStore.majorList.length < 1) {
|
||||
const { data: res } = await getMajorApi()
|
||||
commonStore.setMajorList(res)
|
||||
majorList.value = res
|
||||
} else {
|
||||
majorList.value = commonStore.majorList
|
||||
}
|
||||
}
|
||||
|
||||
return { getData, projectList, majorList }
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@
|
|||
</up-input>
|
||||
</up-form-item>
|
||||
|
||||
<TitleTipModal :TitleTip="`违章信息`" />
|
||||
<TitleTipModal :TitleTip="`检查信息`" />
|
||||
<up-form-item prop="examiner" label="检查人">
|
||||
<up-input
|
||||
border="none"
|
||||
|
|
|
|||
|
|
@ -105,7 +105,6 @@
|
|||
:label="props.addAndEditFormType == 3 ? '违章照片' : '违章照片(最多9张)'"
|
||||
>
|
||||
<up-upload
|
||||
name="1"
|
||||
multiple
|
||||
@delete="onDeletePicVrImgList"
|
||||
@afterRead="onAfterReadVrImgList"
|
||||
|
|
@ -149,17 +148,21 @@
|
|||
:label="props.addAndEditFormType == 3 ? '整改照片' : '整改照片(最多9张)'"
|
||||
>
|
||||
<up-upload
|
||||
name="1"
|
||||
multiple
|
||||
@delete="onDeleteCorrectionImgList"
|
||||
@afterRead="onAfterReadCorrectionImgList"
|
||||
:deletable="!props.addAndEditFormType == 3"
|
||||
:fileList="addAndEditModel.correctionImgList"
|
||||
:maxCount="props.addAndEditFormType == 3 ? 1 : 9"
|
||||
/>
|
||||
</up-form-item>
|
||||
|
||||
<up-button type="primary" text="提交" @tap="onSubmitForm" style="width: 100%" />
|
||||
<up-button
|
||||
text="提交"
|
||||
type="primary"
|
||||
@tap="onSubmitForm"
|
||||
style="width: 100%"
|
||||
v-if="addAndEditFormType != 3"
|
||||
/>
|
||||
</up-form>
|
||||
|
||||
<!-- 项目选择弹框 -->
|
||||
|
|
@ -233,10 +236,15 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref } from 'vue'
|
||||
import { debounce, set } from 'lodash-es' // 引入防抖函数
|
||||
import { reactive, ref, watch } from 'vue'
|
||||
import { debounce } from 'lodash-es' // 引入防抖函数
|
||||
import { getProjectApi, getMajorApi, getProcedureApi } from '@/services/common.js'
|
||||
import { addSafetyViolationsApi } from '@/services/safetyViolations.js'
|
||||
import {
|
||||
addSafetyViolationsApi,
|
||||
editSafetyViolationsApi,
|
||||
getSafetyViolationsDetailsByIdApi,
|
||||
} from '@/services/safetyViolations.js'
|
||||
import getProjectAndMajorData from '@/hooks/useCommon.js'
|
||||
import TitleTipModal from '@/components/TitleTipModal/index'
|
||||
|
||||
const addAndEditModelRef = ref(null)
|
||||
|
|
@ -248,16 +256,26 @@ const onSearchProjectName = ref('') // 项目搜索条件
|
|||
const dateValue = ref(Date.now()) // 年月日选择器数据源
|
||||
const sendLoading = ref(false) // 加载中
|
||||
const dateType = ref(1)
|
||||
// const { projectList, majorList, getData } = getProjectAndMajorData()
|
||||
// onMounted(async () => {
|
||||
// await getData()
|
||||
// })
|
||||
|
||||
const props = defineProps({
|
||||
// 表单类型 1. 新增 2. 修改 3. 详情
|
||||
addAndEditFormType: {
|
||||
type: [Number, String],
|
||||
default: () => 1,
|
||||
},
|
||||
// 列表id
|
||||
detailsId: {
|
||||
type: [Number, String],
|
||||
default: () => '',
|
||||
},
|
||||
})
|
||||
|
||||
console.log(props.addAndEditFormType, '表单类型')
|
||||
|
||||
// 修改时删除的数据源
|
||||
const deleteFileList = []
|
||||
// 表单数据源
|
||||
const addAndEditModel = reactive({
|
||||
dataSource: 2,
|
||||
|
|
@ -275,17 +293,7 @@ const addAndEditModel = reactive({
|
|||
rectUserName: '', //整改人
|
||||
rectTime: '', //整改时间
|
||||
rectDesc: '', //整改说明
|
||||
// procedure: '',
|
||||
// major: '',
|
||||
// examiner: '',
|
||||
// inspectTime: '',
|
||||
// correctionTerm: '',
|
||||
// vrLocation: '',
|
||||
// vrDescribe: '',
|
||||
vrImgList: [], // 违章照片
|
||||
// correctionPerson: '',
|
||||
// correctionDescribe: '',
|
||||
// correctionTime: '',
|
||||
correctionImgList: [], // 整改照片
|
||||
})
|
||||
|
||||
|
|
@ -509,6 +517,7 @@ const formatDate = (timestamp) => {
|
|||
|
||||
// 违章照片上传
|
||||
const onAfterReadVrImgList = (event) => {
|
||||
console.log('event', event)
|
||||
let lists = [].concat(event.file)
|
||||
lists.map((item) => {
|
||||
addAndEditModel.vrImgList.push({
|
||||
|
|
@ -519,6 +528,10 @@ const onAfterReadVrImgList = (event) => {
|
|||
// 违章照片删除
|
||||
const onDeletePicVrImgList = (event) => {
|
||||
addAndEditModel.vrImgList.splice(event.index, 1)
|
||||
|
||||
if (props.addAndEditFormType == 2 && addAndEditModel.vrImgList[event.index]?.id) {
|
||||
deleteFileList.push(addAndEditModel.vrImgList[event.index]?.id)
|
||||
}
|
||||
}
|
||||
|
||||
// 整改照片上传
|
||||
|
|
@ -533,93 +546,131 @@ const onAfterReadCorrectionImgList = (event) => {
|
|||
// 违章照片删除
|
||||
const onDeleteCorrectionImgList = (event) => {
|
||||
addAndEditModel.correctionImgList.splice(event.index, 1)
|
||||
if (props.addAndEditFormType == 2 && addAndEditModel.correctionImgList[event.index]?.id) {
|
||||
deleteFileList.push(addAndEditModel.correctionImgList[event.index]?.id)
|
||||
}
|
||||
}
|
||||
|
||||
// 提交
|
||||
const onSubmitForm = debounce(() => {
|
||||
console.log(
|
||||
'%c🔍 表单提交入参 %c',
|
||||
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
|
||||
'',
|
||||
addAndEditModel,
|
||||
)
|
||||
|
||||
addAndEditModelRef.value
|
||||
.validate()
|
||||
.then(async (valid) => {
|
||||
if (valid) {
|
||||
// 先调上传接口把图片上传
|
||||
sendLoading.value = true
|
||||
let successVrImgList = []
|
||||
let successCorrectionImgList = []
|
||||
if (addAndEditModel.vrImgList.length > 0) {
|
||||
successVrImgList = await uploadImgFun(addAndEditModel.vrImgList, 1)
|
||||
}
|
||||
if (addAndEditModel.correctionImgList.length > 0) {
|
||||
successCorrectionImgList = await uploadImgFun(
|
||||
addAndEditModel.correctionImgList,
|
||||
2,
|
||||
)
|
||||
}
|
||||
const uploadImages = new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
let successVrImgList = []
|
||||
let successCorrectionImgList = []
|
||||
|
||||
// 组装参数
|
||||
const {
|
||||
dataSource,
|
||||
proId, // 工程id
|
||||
proName, // 工程名称
|
||||
majorId, // 专业id
|
||||
majorName, // 专业名称
|
||||
gxId, // 工序id
|
||||
gxName, // 工序名称
|
||||
checkUserName, // 检查人
|
||||
vioDate, // 违章时间
|
||||
vioPlace, // 违章地点
|
||||
vioDesc, // 违章描述
|
||||
rectDate, // 整改期限
|
||||
rectUserName, //整改人
|
||||
rectTime, //整改时间
|
||||
rectDesc, //整改说明
|
||||
} = addAndEditModel
|
||||
let successVrImgListNoEdit = []
|
||||
let successCorrectionImgListNoEdit = []
|
||||
|
||||
const addParams = {
|
||||
dataSource,
|
||||
proId, // 工程id
|
||||
proName, // 工程名称
|
||||
majorId, // 专业id
|
||||
majorName, // 专业名称
|
||||
gxId, // 工序id
|
||||
gxName, // 工序名称
|
||||
checkUserName, // 检查人
|
||||
vioDate, // 违章时间
|
||||
vioPlace, // 违章地点
|
||||
vioDesc, // 违章描述
|
||||
rectDate, // 整改期限
|
||||
rectUserName, //整改人
|
||||
rectTime, //整改时间
|
||||
rectDesc, //整改说明
|
||||
fileList: [...successVrImgList, ...successCorrectionImgList],
|
||||
uploadType: 1,
|
||||
}
|
||||
if (addAndEditModel.vrImgList.length > 0) {
|
||||
successVrImgListNoEdit = addAndEditModel.vrImgList.map((e) => !e.isEdit)
|
||||
successVrImgList = await uploadImgFun(successVrImgListNoEdit, 1)
|
||||
}
|
||||
if (addAndEditModel.correctionImgList.length > 0) {
|
||||
successCorrectionImgListNoEdit = addAndEditModel.correctionImgList.map(
|
||||
(e) => !e.isEdit,
|
||||
)
|
||||
successCorrectionImgList = await uploadImgFun(
|
||||
successCorrectionImgListNoEdit,
|
||||
2,
|
||||
)
|
||||
}
|
||||
|
||||
const res = await addSafetyViolationsApi(addParams)
|
||||
console.log(
|
||||
'%c🔍 表单提交出参 %c',
|
||||
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
|
||||
'',
|
||||
res,
|
||||
)
|
||||
resolve({ successVrImgList, successCorrectionImgList }) // 上传成功,返回结果
|
||||
} catch (error) {
|
||||
reject(error) // 上传失败,抛出错误
|
||||
}
|
||||
})
|
||||
|
||||
sendLoading.value = false
|
||||
if (res.code === 200) {
|
||||
uni.$u.toast('新增成功')
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
}, 500)
|
||||
} else {
|
||||
uni.$u.toast('新增失败' + res.data)
|
||||
}
|
||||
uploadImages
|
||||
.then(async ({ successVrImgList, successCorrectionImgList }) => {
|
||||
console.log('图片上传成功,开始提交表单...')
|
||||
// 这里写提交表单的逻辑
|
||||
// 组装参数
|
||||
const {
|
||||
dataSource,
|
||||
proId, // 工程id
|
||||
proName, // 工程名称
|
||||
majorId, // 专业id
|
||||
majorName, // 专业名称
|
||||
gxId, // 工序id
|
||||
gxName, // 工序名称
|
||||
checkUserName, // 检查人
|
||||
vioDate, // 违章时间
|
||||
vioPlace, // 违章地点
|
||||
vioDesc, // 违章描述
|
||||
rectDate, // 整改期限
|
||||
rectUserName, //整改人
|
||||
rectTime, //整改时间
|
||||
rectDesc, //整改说明
|
||||
} = addAndEditModel
|
||||
|
||||
const addParams = {
|
||||
dataSource,
|
||||
proId, // 工程id
|
||||
proName, // 工程名称
|
||||
majorId, // 专业id
|
||||
majorName, // 专业名称
|
||||
gxId, // 工序id
|
||||
gxName, // 工序名称
|
||||
checkUserName, // 检查人
|
||||
vioDate, // 违章时间
|
||||
vioPlace, // 违章地点
|
||||
vioDesc, // 违章描述
|
||||
rectDate, // 整改期限
|
||||
rectUserName, //整改人
|
||||
rectTime, //整改时间
|
||||
rectDesc, //整改说明
|
||||
fileList: [...successVrImgList, ...successCorrectionImgList],
|
||||
uploadType: 1,
|
||||
}
|
||||
|
||||
const SED_API =
|
||||
props.addAndEditFormType == 1
|
||||
? addSafetyViolationsApi
|
||||
: editSafetyViolationsApi
|
||||
|
||||
if (props.addAndEditFormType == 2) {
|
||||
Object.assign(addParams, {
|
||||
id: props.detailsId,
|
||||
delFileList: deleteFileList,
|
||||
})
|
||||
}
|
||||
|
||||
console.log(
|
||||
'%c🔍 表单提交入参 %c',
|
||||
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
|
||||
'',
|
||||
addParams,
|
||||
)
|
||||
const res = await SED_API(addParams)
|
||||
console.log(
|
||||
'%c🔍 表单提交出参 %c',
|
||||
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
|
||||
'',
|
||||
res,
|
||||
)
|
||||
|
||||
sendLoading.value = false
|
||||
if (res.code === 200) {
|
||||
uni.$u.toast(res.data)
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
}, 500)
|
||||
} else {
|
||||
uni.$u.toast(res.data)
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('图片上传失败:', error)
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch((error) => {})
|
||||
|
|
@ -674,16 +725,88 @@ const uploadImgFun = async (list, type) => {
|
|||
}
|
||||
|
||||
// 获取表单详情
|
||||
const getFormDetail = () => {
|
||||
console.log('---获取详情数据')
|
||||
}
|
||||
// props.addAndEditFormType 如果为2怎为编辑表单
|
||||
if (props.addAndEditFormType == 2) {
|
||||
// 先获取详情数据并回显
|
||||
getFormDetail()
|
||||
const getFormDetail = async () => {
|
||||
const res = await getSafetyViolationsDetailsByIdApi({ id: props?.detailsId })
|
||||
|
||||
if (res.code === 200) {
|
||||
const {
|
||||
dataSource,
|
||||
proId, // 工程id
|
||||
proName, // 工程名称
|
||||
majorId, // 专业id
|
||||
majorName, // 专业名称
|
||||
gxId, // 工序id
|
||||
gxName, // 工序名称
|
||||
checkUserName, // 检查人
|
||||
vioDate, // 违章时间
|
||||
vioPlace, // 违章地点
|
||||
vioDesc, // 违章描述
|
||||
rectDate, // 整改期限
|
||||
rectUserName, //整改人
|
||||
rectTime, //整改时间
|
||||
rectDesc, //整改说明
|
||||
rectPhotoList,
|
||||
vioPhotoList,
|
||||
} = res.data
|
||||
|
||||
let rectPhotoListEdit = []
|
||||
let vioPhotoListEdit = []
|
||||
|
||||
if (rectPhotoList.length > 0) {
|
||||
rectPhotoListEdit = rectPhotoList.map((e) => {
|
||||
return {
|
||||
idEdit: true,
|
||||
url: e.url,
|
||||
}
|
||||
})
|
||||
}
|
||||
if (vioPhotoList.length > 0) {
|
||||
vioPhotoListEdit = vioPhotoList.map((e) => {
|
||||
return {
|
||||
idEdit: true,
|
||||
url: e.url,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Object.assign(addAndEditModel, {
|
||||
proId, // 工程id
|
||||
proName, // 工程名称
|
||||
majorId, // 专业id
|
||||
majorName, // 专业名称
|
||||
gxId, // 工序id
|
||||
gxName, // 工序名称
|
||||
checkUserName, // 检查人
|
||||
vioDate, // 违章时间
|
||||
vioPlace, // 违章地点
|
||||
vioDesc, // 违章描述
|
||||
rectDate, // 整改期限
|
||||
rectUserName, //整改人
|
||||
rectTime, //整改时间
|
||||
rectDesc, //整改说明
|
||||
vrImgList: vioPhotoList,
|
||||
correctionImgList: rectPhotoList,
|
||||
})
|
||||
|
||||
getProcedureData(majorId)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取表单详情
|
||||
// 监听当前页面是新增还是修改
|
||||
watch(
|
||||
() => props.addAndEditFormType,
|
||||
(newValue) => {
|
||||
console.log('newValue当前表单的类型', newValue)
|
||||
|
||||
if (newValue != 1) {
|
||||
getFormDetail()
|
||||
}
|
||||
},
|
||||
{
|
||||
deep: true,
|
||||
immediate: true,
|
||||
},
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
/>
|
||||
|
||||
<view class="container">
|
||||
<AddAndEditForm :addAndEditFormType="addAndEditFormType" />
|
||||
<AddAndEditForm :addAndEditFormType="addAndEditFormType" :detailsId="detailsId" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
|
@ -22,12 +22,16 @@ import { onLoad } from '@dcloudio/uni-app'
|
|||
const { safeAreaInsets } = uni.getSystemInfoSync()
|
||||
|
||||
const addAndEditFormType = ref(1)
|
||||
const detailsId = ref('')
|
||||
const uploadRecordUrl = ref('/pages/safetyViolations/upload-record/index')
|
||||
|
||||
onLoad((query) => {
|
||||
if (query.type) {
|
||||
addAndEditFormType.value = query.type
|
||||
}
|
||||
if (query.id) {
|
||||
detailsId.value = query.id
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
<up-input
|
||||
clearable
|
||||
placeholder="输入搜索关键词"
|
||||
v-model.trim="onSearchKeyword"
|
||||
suffixIconStyle="color: #909399"
|
||||
v-model.trim="queryParams.keyWord"
|
||||
>
|
||||
<template #suffix>
|
||||
<up-icon name="search" size="24" @tap="onSearchRecord" />
|
||||
|
|
@ -19,58 +19,47 @@
|
|||
</view>
|
||||
|
||||
<view class="upload-record-list">
|
||||
<up-list
|
||||
ref="upListRef"
|
||||
style="width: 100%"
|
||||
@scroll="onScrollUpList"
|
||||
@scrolltolower="onScrollTolower"
|
||||
>
|
||||
<up-list-item v-for="item in 10" :key="item">
|
||||
<up-list ref="upListRef" style="width: 100%" @scrolltolower="onScrollTolower">
|
||||
<up-list-item v-for="item in safetyViolationsList" :key="item.id">
|
||||
<view class="record-item">
|
||||
<view @tap="onHandleViewDetails">
|
||||
<!-- 日期 -->
|
||||
<view class="item-date">
|
||||
<text>2024-05-06</text>
|
||||
<text>{{ item.vioDate }}</text>
|
||||
<view>
|
||||
<up-button
|
||||
size="mini"
|
||||
text="修改"
|
||||
type="primary"
|
||||
@tap="onHandleEditRecord"
|
||||
@tap="onHandleEditRecord(item.id)"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 名称 -->
|
||||
<view class="item-name">
|
||||
<text>N3917</text>
|
||||
<text>{{ item.proName }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 文字内容 -->
|
||||
<view class="text-content">
|
||||
<up-text
|
||||
:lines="2"
|
||||
text="关于uview-plus的取名来由,首字母u来自于uni-app首字母,
|
||||
uni-app是基Vuejs,Vue和View(延伸为UI、视图之意)同音,同时view组件uni-app中
|
||||
最础最重要的组件,故取名uview-plus,表达源于uni-app和Vue之意,同时在此也对它示感谢。"
|
||||
/>
|
||||
<up-text :lines="2" :text="item.vioDesc" />
|
||||
</view>
|
||||
</view>
|
||||
<!-- 图片内容 -->
|
||||
<view class="swiper-container">
|
||||
<up-swiper
|
||||
:list="list1"
|
||||
:indicator="true"
|
||||
:list="item.vioPhotoList"
|
||||
interval="5000"
|
||||
@click="onClickSwiper"
|
||||
/>
|
||||
<view class="swiper-count"> 3张 </view>
|
||||
<view class="swiper-count">{{ item.vioPhotoNum }} 张 </view>
|
||||
</view>
|
||||
|
||||
<!-- 检查人 -->
|
||||
<view class="inspect-person">
|
||||
<view> 检查人:武松 </view>
|
||||
<view> 整改日期:2025-05-06 </view>
|
||||
<view> 检查人:{{ item.checkUserName }} </view>
|
||||
<view> 整改日期:{{ item.rectTime }} </view>
|
||||
</view>
|
||||
</view>
|
||||
</up-list-item>
|
||||
|
|
@ -79,8 +68,6 @@ uni-app是基Vuejs,Vue和View(延伸为UI、视图之意)同音,同时view
|
|||
<view class="loading-text">
|
||||
{{ finish ? '没有更多数据了~' : '正在加载...' }}
|
||||
</view>
|
||||
|
||||
<!-- <up-back-top :scroll-top="scrollTop" icon="arrow-up" @tap="onHandleBackTop" /> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -88,40 +75,91 @@ uni-app是基Vuejs,Vue和View(延伸为UI、视图之意)同音,同时view
|
|||
|
||||
<script setup>
|
||||
import NavBarModal from '@/components/NavBarModal/index'
|
||||
import { ref, reactive } from 'vue'
|
||||
import { ref, computed } from 'vue'
|
||||
import { debounce } from 'lodash-es' // 引入防抖函数
|
||||
|
||||
import { getSafetyViolationsListApi } from '@/services/safetyViolations.js'
|
||||
const { safeAreaInsets } = uni.getSystemInfoSync()
|
||||
const onSearchKeyword = ref('')
|
||||
const finish = ref(false)
|
||||
const upListRef = ref(null) // 获取列表组件的引用
|
||||
const total = ref(0)
|
||||
const safetyViolationsList = ref([])
|
||||
|
||||
const scrollTop = ref(0)
|
||||
// 查询条件
|
||||
const queryParams = ref({
|
||||
page: 1,
|
||||
limit: 10,
|
||||
keyWord: '',
|
||||
})
|
||||
|
||||
const onScrollUpList = (e) => {
|
||||
scrollTop.value = e
|
||||
// 获取上传记录列表数据
|
||||
const getSafetyViolationsListData = async (isTap = false) => {
|
||||
try {
|
||||
console.log(
|
||||
'%c🔍 获取安全违章上传记录入参 %c',
|
||||
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
|
||||
'',
|
||||
queryParams.value,
|
||||
)
|
||||
const res = await getSafetyViolationsListApi(queryParams.value)
|
||||
|
||||
console.log(
|
||||
'%c🔍 获取安全违章上传记录出参 %c',
|
||||
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
|
||||
'',
|
||||
res,
|
||||
)
|
||||
|
||||
// 更新总数
|
||||
total.value = res.count
|
||||
// 处理数据
|
||||
if (isTap) {
|
||||
// 点击搜索时,直接替换数据
|
||||
safetyViolationsList.value = res?.data || []
|
||||
// 重置页码
|
||||
queryParams.value.page = 1
|
||||
} else {
|
||||
// 下拉加载时,追加数据
|
||||
if (res.data && res.data.length > 0) {
|
||||
safetyViolationsList.value = [...safetyViolationsList.value, ...res.data]
|
||||
}
|
||||
}
|
||||
|
||||
safetyViolationsList.value.forEach((e) => {
|
||||
e.vioPhotoList = e.vioPhoto?.split(',')
|
||||
})
|
||||
} catch (error) {
|
||||
// 发生错误时重置数据
|
||||
if (isTap) {
|
||||
safetyViolationsList.value = []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const list1 = reactive([
|
||||
'https://img1.baidu.com/it/u=1361177696,203903602&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1455',
|
||||
'https://img1.baidu.com/it/u=1361177696,203903602&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1455',
|
||||
'https://img1.baidu.com/it/u=1361177696,203903602&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1455',
|
||||
])
|
||||
getSafetyViolationsListData()
|
||||
|
||||
// 滚动触底事件
|
||||
const onScrollTolower = debounce(() => {
|
||||
console.log('onScrollTolower')
|
||||
console.log('onScrollTolower', '滚动触底')
|
||||
// 判断是否还有更多数据
|
||||
if (safetyViolationsList.value.length < total.value) {
|
||||
queryParams.value.page++
|
||||
getSafetyViolationsListData(false)
|
||||
}
|
||||
}, 500)
|
||||
|
||||
// 判断数据是否加载完毕
|
||||
const finish = computed(() => {
|
||||
if (total.value === safetyViolationsList.value.length) return true
|
||||
})
|
||||
|
||||
// 搜索
|
||||
const onSearchRecord = () => {
|
||||
console.log('onSearchRecord', onSearchKeyword.value)
|
||||
console.log('onSearchRecord', queryParams.value.keyWord)
|
||||
getSafetyViolationsListData(true)
|
||||
}
|
||||
// 修改
|
||||
const onHandleEditRecord = () => {
|
||||
const onHandleEditRecord = (id) => {
|
||||
console.log('onHandleEditRecord')
|
||||
uni.redirectTo({
|
||||
url: `/pages/safetyViolations/index?type=2&id=1`, // 强制跳转并传参
|
||||
url: `/pages/safetyViolations/index?type=2&id=${id}`, // 强制跳转并传参
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
import { http } from '@/utils/http'
|
||||
|
||||
// 质量检查表单提交接口
|
||||
export const addQualityInspectionApi = (data) => {
|
||||
return http({
|
||||
method: 'POST',
|
||||
url: '/imgTool/imgUpload/qualityInspection/insertQualityInspection',
|
||||
data,
|
||||
header: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
})
|
||||
}
|
||||
// 质量检查数据列表
|
||||
export const getQualityInspectionListApi = (data) => {
|
||||
return http({
|
||||
method: 'GET',
|
||||
url: '/imgTool/imgUpload/qualityInspection/getList',
|
||||
data,
|
||||
})
|
||||
}
|
||||
// 质量检查表单获取详情
|
||||
export const getQualityInspectionDetailsByIdApi = (data) => {
|
||||
return http({
|
||||
method: 'GET',
|
||||
url: '/imgTool/imgUpload/qualityInspection/getQualityInspectionById',
|
||||
data,
|
||||
})
|
||||
}
|
||||
// 质量检查表单修改
|
||||
export const editQualityInspectionApi = (data) => {
|
||||
return http({
|
||||
method: 'POST',
|
||||
url: '/imgTool/imgUpload/qualityInspection/updateQualityInspectionById',
|
||||
data,
|
||||
header: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
@ -11,3 +11,30 @@ export const addSafetyViolationsApi = (data) => {
|
|||
},
|
||||
})
|
||||
}
|
||||
// 安全违章数据列表
|
||||
export const getSafetyViolationsListApi = (data) => {
|
||||
return http({
|
||||
method: 'GET',
|
||||
url: '/imgTool/imgUpload/safetyViolation/getList',
|
||||
data,
|
||||
})
|
||||
}
|
||||
// 安全违章表单获取详情
|
||||
export const getSafetyViolationsDetailsByIdApi = (data) => {
|
||||
return http({
|
||||
method: 'GET',
|
||||
url: '/imgTool/imgUpload/safetyViolation/getSafetyViolationById',
|
||||
data,
|
||||
})
|
||||
}
|
||||
// 安全违章表单修改
|
||||
export const editSafetyViolationsApi = (data) => {
|
||||
return http({
|
||||
method: 'POST',
|
||||
url: '/imgTool/imgUpload/safetyViolation/updateSafetyViolationById',
|
||||
data,
|
||||
header: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,3 +11,4 @@ export default pinia
|
|||
|
||||
// 模块统一导出
|
||||
export * from './modules/member'
|
||||
export * from './modules/common'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
|
||||
export const useCommonStore = defineStore('common', () => {
|
||||
// 项目数据
|
||||
const projectList = ref([])
|
||||
// 专业数据
|
||||
const majorList = ref([])
|
||||
|
||||
// 存储项目数据
|
||||
const setProjectList = (val) => {
|
||||
projectList.value = val
|
||||
}
|
||||
// 存储专业数据
|
||||
const setMajorList = (val) => {
|
||||
majorList.value = val
|
||||
}
|
||||
|
||||
// 把数据和方法 return 出去
|
||||
return {
|
||||
projectList,
|
||||
majorList,
|
||||
setProjectList,
|
||||
setMajorList,
|
||||
}
|
||||
})
|
||||
|
|
@ -102,7 +102,7 @@ export const http = (options) => {
|
|||
// 3. 其他错误
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '请求错误',
|
||||
title: '请求失败,请切换网络后尝试',
|
||||
})
|
||||
reject(res)
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ export const http = (options) => {
|
|||
fail(err) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '请求失败',
|
||||
title: '请求失败,请切换网络后尝试',
|
||||
})
|
||||
console.log(err, '请求失败')
|
||||
reject(err)
|
||||
|
|
|
|||
Loading…
Reference in New Issue