安全违章接口调试完成
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-input>
|
||||||
</up-form-item>
|
</up-form-item>
|
||||||
|
|
||||||
<TitleTipModal :TitleTip="`违章信息`" />
|
<TitleTipModal :TitleTip="`检查信息`" />
|
||||||
<up-form-item prop="examiner" label="检查人">
|
<up-form-item prop="examiner" label="检查人">
|
||||||
<up-input
|
<up-input
|
||||||
border="none"
|
border="none"
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,6 @@
|
||||||
:label="props.addAndEditFormType == 3 ? '违章照片' : '违章照片(最多9张)'"
|
:label="props.addAndEditFormType == 3 ? '违章照片' : '违章照片(最多9张)'"
|
||||||
>
|
>
|
||||||
<up-upload
|
<up-upload
|
||||||
name="1"
|
|
||||||
multiple
|
multiple
|
||||||
@delete="onDeletePicVrImgList"
|
@delete="onDeletePicVrImgList"
|
||||||
@afterRead="onAfterReadVrImgList"
|
@afterRead="onAfterReadVrImgList"
|
||||||
|
|
@ -149,17 +148,21 @@
|
||||||
:label="props.addAndEditFormType == 3 ? '整改照片' : '整改照片(最多9张)'"
|
:label="props.addAndEditFormType == 3 ? '整改照片' : '整改照片(最多9张)'"
|
||||||
>
|
>
|
||||||
<up-upload
|
<up-upload
|
||||||
name="1"
|
|
||||||
multiple
|
multiple
|
||||||
@delete="onDeleteCorrectionImgList"
|
@delete="onDeleteCorrectionImgList"
|
||||||
@afterRead="onAfterReadCorrectionImgList"
|
@afterRead="onAfterReadCorrectionImgList"
|
||||||
:deletable="!props.addAndEditFormType == 3"
|
|
||||||
:fileList="addAndEditModel.correctionImgList"
|
:fileList="addAndEditModel.correctionImgList"
|
||||||
:maxCount="props.addAndEditFormType == 3 ? 1 : 9"
|
:maxCount="props.addAndEditFormType == 3 ? 1 : 9"
|
||||||
/>
|
/>
|
||||||
</up-form-item>
|
</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>
|
</up-form>
|
||||||
|
|
||||||
<!-- 项目选择弹框 -->
|
<!-- 项目选择弹框 -->
|
||||||
|
|
@ -233,10 +236,15 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, ref } from 'vue'
|
import { reactive, ref, watch } from 'vue'
|
||||||
import { debounce, set } from 'lodash-es' // 引入防抖函数
|
import { debounce } from 'lodash-es' // 引入防抖函数
|
||||||
import { getProjectApi, getMajorApi, getProcedureApi } from '@/services/common.js'
|
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'
|
import TitleTipModal from '@/components/TitleTipModal/index'
|
||||||
|
|
||||||
const addAndEditModelRef = ref(null)
|
const addAndEditModelRef = ref(null)
|
||||||
|
|
@ -248,16 +256,26 @@ const onSearchProjectName = ref('') // 项目搜索条件
|
||||||
const dateValue = ref(Date.now()) // 年月日选择器数据源
|
const dateValue = ref(Date.now()) // 年月日选择器数据源
|
||||||
const sendLoading = ref(false) // 加载中
|
const sendLoading = ref(false) // 加载中
|
||||||
const dateType = ref(1)
|
const dateType = ref(1)
|
||||||
|
// const { projectList, majorList, getData } = getProjectAndMajorData()
|
||||||
|
// onMounted(async () => {
|
||||||
|
// await getData()
|
||||||
|
// })
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
// 表单类型 1. 新增 2. 修改 3. 详情
|
// 表单类型 1. 新增 2. 修改 3. 详情
|
||||||
addAndEditFormType: {
|
addAndEditFormType: {
|
||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
default: () => 1,
|
default: () => 1,
|
||||||
},
|
},
|
||||||
|
// 列表id
|
||||||
|
detailsId: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: () => '',
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(props.addAndEditFormType, '表单类型')
|
// 修改时删除的数据源
|
||||||
|
const deleteFileList = []
|
||||||
// 表单数据源
|
// 表单数据源
|
||||||
const addAndEditModel = reactive({
|
const addAndEditModel = reactive({
|
||||||
dataSource: 2,
|
dataSource: 2,
|
||||||
|
|
@ -275,17 +293,7 @@ const addAndEditModel = reactive({
|
||||||
rectUserName: '', //整改人
|
rectUserName: '', //整改人
|
||||||
rectTime: '', //整改时间
|
rectTime: '', //整改时间
|
||||||
rectDesc: '', //整改说明
|
rectDesc: '', //整改说明
|
||||||
// procedure: '',
|
|
||||||
// major: '',
|
|
||||||
// examiner: '',
|
|
||||||
// inspectTime: '',
|
|
||||||
// correctionTerm: '',
|
|
||||||
// vrLocation: '',
|
|
||||||
// vrDescribe: '',
|
|
||||||
vrImgList: [], // 违章照片
|
vrImgList: [], // 违章照片
|
||||||
// correctionPerson: '',
|
|
||||||
// correctionDescribe: '',
|
|
||||||
// correctionTime: '',
|
|
||||||
correctionImgList: [], // 整改照片
|
correctionImgList: [], // 整改照片
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -509,6 +517,7 @@ const formatDate = (timestamp) => {
|
||||||
|
|
||||||
// 违章照片上传
|
// 违章照片上传
|
||||||
const onAfterReadVrImgList = (event) => {
|
const onAfterReadVrImgList = (event) => {
|
||||||
|
console.log('event', event)
|
||||||
let lists = [].concat(event.file)
|
let lists = [].concat(event.file)
|
||||||
lists.map((item) => {
|
lists.map((item) => {
|
||||||
addAndEditModel.vrImgList.push({
|
addAndEditModel.vrImgList.push({
|
||||||
|
|
@ -519,6 +528,10 @@ const onAfterReadVrImgList = (event) => {
|
||||||
// 违章照片删除
|
// 违章照片删除
|
||||||
const onDeletePicVrImgList = (event) => {
|
const onDeletePicVrImgList = (event) => {
|
||||||
addAndEditModel.vrImgList.splice(event.index, 1)
|
addAndEditModel.vrImgList.splice(event.index, 1)
|
||||||
|
|
||||||
|
if (props.addAndEditFormType == 2 && addAndEditModel.vrImgList[event.index]?.id) {
|
||||||
|
deleteFileList.push(addAndEditModel.vrImgList[event.index]?.id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 整改照片上传
|
// 整改照片上传
|
||||||
|
|
@ -533,35 +546,51 @@ const onAfterReadCorrectionImgList = (event) => {
|
||||||
// 违章照片删除
|
// 违章照片删除
|
||||||
const onDeleteCorrectionImgList = (event) => {
|
const onDeleteCorrectionImgList = (event) => {
|
||||||
addAndEditModel.correctionImgList.splice(event.index, 1)
|
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(() => {
|
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
|
addAndEditModelRef.value
|
||||||
.validate()
|
.validate()
|
||||||
.then(async (valid) => {
|
.then(async (valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
// 先调上传接口把图片上传
|
// 先调上传接口把图片上传
|
||||||
sendLoading.value = true
|
sendLoading.value = true
|
||||||
|
const uploadImages = new Promise(async (resolve, reject) => {
|
||||||
|
try {
|
||||||
let successVrImgList = []
|
let successVrImgList = []
|
||||||
let successCorrectionImgList = []
|
let successCorrectionImgList = []
|
||||||
|
|
||||||
|
let successVrImgListNoEdit = []
|
||||||
|
let successCorrectionImgListNoEdit = []
|
||||||
|
|
||||||
if (addAndEditModel.vrImgList.length > 0) {
|
if (addAndEditModel.vrImgList.length > 0) {
|
||||||
successVrImgList = await uploadImgFun(addAndEditModel.vrImgList, 1)
|
successVrImgListNoEdit = addAndEditModel.vrImgList.map((e) => !e.isEdit)
|
||||||
|
successVrImgList = await uploadImgFun(successVrImgListNoEdit, 1)
|
||||||
}
|
}
|
||||||
if (addAndEditModel.correctionImgList.length > 0) {
|
if (addAndEditModel.correctionImgList.length > 0) {
|
||||||
|
successCorrectionImgListNoEdit = addAndEditModel.correctionImgList.map(
|
||||||
|
(e) => !e.isEdit,
|
||||||
|
)
|
||||||
successCorrectionImgList = await uploadImgFun(
|
successCorrectionImgList = await uploadImgFun(
|
||||||
addAndEditModel.correctionImgList,
|
successCorrectionImgListNoEdit,
|
||||||
2,
|
2,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolve({ successVrImgList, successCorrectionImgList }) // 上传成功,返回结果
|
||||||
|
} catch (error) {
|
||||||
|
reject(error) // 上传失败,抛出错误
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
uploadImages
|
||||||
|
.then(async ({ successVrImgList, successCorrectionImgList }) => {
|
||||||
|
console.log('图片上传成功,开始提交表单...')
|
||||||
|
// 这里写提交表单的逻辑
|
||||||
// 组装参数
|
// 组装参数
|
||||||
const {
|
const {
|
||||||
dataSource,
|
dataSource,
|
||||||
|
|
@ -601,7 +630,25 @@ const onSubmitForm = debounce(() => {
|
||||||
uploadType: 1,
|
uploadType: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await addSafetyViolationsApi(addParams)
|
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(
|
console.log(
|
||||||
'%c🔍 表单提交出参 %c',
|
'%c🔍 表单提交出参 %c',
|
||||||
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
|
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
|
||||||
|
|
@ -611,15 +658,19 @@ const onSubmitForm = debounce(() => {
|
||||||
|
|
||||||
sendLoading.value = false
|
sendLoading.value = false
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
uni.$u.toast('新增成功')
|
uni.$u.toast(res.data)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.navigateBack({
|
uni.navigateBack({
|
||||||
delta: 1,
|
delta: 1,
|
||||||
})
|
})
|
||||||
}, 500)
|
}, 500)
|
||||||
} else {
|
} else {
|
||||||
uni.$u.toast('新增失败' + res.data)
|
uni.$u.toast(res.data)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('图片上传失败:', error)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {})
|
.catch((error) => {})
|
||||||
|
|
@ -674,16 +725,88 @@ const uploadImgFun = async (list, type) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取表单详情
|
// 获取表单详情
|
||||||
const getFormDetail = () => {
|
const getFormDetail = async () => {
|
||||||
console.log('---获取详情数据')
|
const res = await getSafetyViolationsDetailsByIdApi({ id: props?.detailsId })
|
||||||
}
|
|
||||||
// props.addAndEditFormType 如果为2怎为编辑表单
|
if (res.code === 200) {
|
||||||
if (props.addAndEditFormType == 2) {
|
const {
|
||||||
// 先获取详情数据并回显
|
dataSource,
|
||||||
getFormDetail()
|
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>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<AddAndEditForm :addAndEditFormType="addAndEditFormType" />
|
<AddAndEditForm :addAndEditFormType="addAndEditFormType" :detailsId="detailsId" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -22,12 +22,16 @@ import { onLoad } from '@dcloudio/uni-app'
|
||||||
const { safeAreaInsets } = uni.getSystemInfoSync()
|
const { safeAreaInsets } = uni.getSystemInfoSync()
|
||||||
|
|
||||||
const addAndEditFormType = ref(1)
|
const addAndEditFormType = ref(1)
|
||||||
|
const detailsId = ref('')
|
||||||
const uploadRecordUrl = ref('/pages/safetyViolations/upload-record/index')
|
const uploadRecordUrl = ref('/pages/safetyViolations/upload-record/index')
|
||||||
|
|
||||||
onLoad((query) => {
|
onLoad((query) => {
|
||||||
if (query.type) {
|
if (query.type) {
|
||||||
addAndEditFormType.value = query.type
|
addAndEditFormType.value = query.type
|
||||||
}
|
}
|
||||||
|
if (query.id) {
|
||||||
|
detailsId.value = query.id
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
<up-input
|
<up-input
|
||||||
clearable
|
clearable
|
||||||
placeholder="输入搜索关键词"
|
placeholder="输入搜索关键词"
|
||||||
v-model.trim="onSearchKeyword"
|
|
||||||
suffixIconStyle="color: #909399"
|
suffixIconStyle="color: #909399"
|
||||||
|
v-model.trim="queryParams.keyWord"
|
||||||
>
|
>
|
||||||
<template #suffix>
|
<template #suffix>
|
||||||
<up-icon name="search" size="24" @tap="onSearchRecord" />
|
<up-icon name="search" size="24" @tap="onSearchRecord" />
|
||||||
|
|
@ -19,58 +19,47 @@
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="upload-record-list">
|
<view class="upload-record-list">
|
||||||
<up-list
|
<up-list ref="upListRef" style="width: 100%" @scrolltolower="onScrollTolower">
|
||||||
ref="upListRef"
|
<up-list-item v-for="item in safetyViolationsList" :key="item.id">
|
||||||
style="width: 100%"
|
|
||||||
@scroll="onScrollUpList"
|
|
||||||
@scrolltolower="onScrollTolower"
|
|
||||||
>
|
|
||||||
<up-list-item v-for="item in 10" :key="item">
|
|
||||||
<view class="record-item">
|
<view class="record-item">
|
||||||
<view @tap="onHandleViewDetails">
|
<view @tap="onHandleViewDetails">
|
||||||
<!-- 日期 -->
|
<!-- 日期 -->
|
||||||
<view class="item-date">
|
<view class="item-date">
|
||||||
<text>2024-05-06</text>
|
<text>{{ item.vioDate }}</text>
|
||||||
<view>
|
<view>
|
||||||
<up-button
|
<up-button
|
||||||
size="mini"
|
size="mini"
|
||||||
text="修改"
|
text="修改"
|
||||||
type="primary"
|
type="primary"
|
||||||
@tap="onHandleEditRecord"
|
@tap="onHandleEditRecord(item.id)"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 名称 -->
|
<!-- 名称 -->
|
||||||
<view class="item-name">
|
<view class="item-name">
|
||||||
<text>N3917</text>
|
<text>{{ item.proName }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 文字内容 -->
|
<!-- 文字内容 -->
|
||||||
<view class="text-content">
|
<view class="text-content">
|
||||||
<up-text
|
<up-text :lines="2" :text="item.vioDesc" />
|
||||||
:lines="2"
|
|
||||||
text="关于uview-plus的取名来由,首字母u来自于uni-app首字母,
|
|
||||||
uni-app是基Vuejs,Vue和View(延伸为UI、视图之意)同音,同时view组件uni-app中
|
|
||||||
最础最重要的组件,故取名uview-plus,表达源于uni-app和Vue之意,同时在此也对它示感谢。"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 图片内容 -->
|
<!-- 图片内容 -->
|
||||||
<view class="swiper-container">
|
<view class="swiper-container">
|
||||||
<up-swiper
|
<up-swiper
|
||||||
:list="list1"
|
:list="item.vioPhotoList"
|
||||||
:indicator="true"
|
|
||||||
interval="5000"
|
interval="5000"
|
||||||
@click="onClickSwiper"
|
@click="onClickSwiper"
|
||||||
/>
|
/>
|
||||||
<view class="swiper-count"> 3张 </view>
|
<view class="swiper-count">{{ item.vioPhotoNum }} 张 </view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 检查人 -->
|
<!-- 检查人 -->
|
||||||
<view class="inspect-person">
|
<view class="inspect-person">
|
||||||
<view> 检查人:武松 </view>
|
<view> 检查人:{{ item.checkUserName }} </view>
|
||||||
<view> 整改日期:2025-05-06 </view>
|
<view> 整改日期:{{ item.rectTime }} </view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</up-list-item>
|
</up-list-item>
|
||||||
|
|
@ -79,8 +68,6 @@ uni-app是基Vuejs,Vue和View(延伸为UI、视图之意)同音,同时view
|
||||||
<view class="loading-text">
|
<view class="loading-text">
|
||||||
{{ finish ? '没有更多数据了~' : '正在加载...' }}
|
{{ finish ? '没有更多数据了~' : '正在加载...' }}
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- <up-back-top :scroll-top="scrollTop" icon="arrow-up" @tap="onHandleBackTop" /> -->
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -88,40 +75,91 @@ uni-app是基Vuejs,Vue和View(延伸为UI、视图之意)同音,同时view
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import NavBarModal from '@/components/NavBarModal/index'
|
import NavBarModal from '@/components/NavBarModal/index'
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import { debounce } from 'lodash-es' // 引入防抖函数
|
import { debounce } from 'lodash-es' // 引入防抖函数
|
||||||
|
import { getSafetyViolationsListApi } from '@/services/safetyViolations.js'
|
||||||
const { safeAreaInsets } = uni.getSystemInfoSync()
|
const { safeAreaInsets } = uni.getSystemInfoSync()
|
||||||
const onSearchKeyword = ref('')
|
|
||||||
const finish = ref(false)
|
|
||||||
const upListRef = ref(null) // 获取列表组件的引用
|
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 = []
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
getSafetyViolationsListData()
|
||||||
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',
|
|
||||||
])
|
|
||||||
|
|
||||||
// 滚动触底事件
|
// 滚动触底事件
|
||||||
const onScrollTolower = debounce(() => {
|
const onScrollTolower = debounce(() => {
|
||||||
console.log('onScrollTolower')
|
console.log('onScrollTolower', '滚动触底')
|
||||||
|
// 判断是否还有更多数据
|
||||||
|
if (safetyViolationsList.value.length < total.value) {
|
||||||
|
queryParams.value.page++
|
||||||
|
getSafetyViolationsListData(false)
|
||||||
|
}
|
||||||
}, 500)
|
}, 500)
|
||||||
|
|
||||||
|
// 判断数据是否加载完毕
|
||||||
|
const finish = computed(() => {
|
||||||
|
if (total.value === safetyViolationsList.value.length) return true
|
||||||
|
})
|
||||||
|
|
||||||
// 搜索
|
// 搜索
|
||||||
const onSearchRecord = () => {
|
const onSearchRecord = () => {
|
||||||
console.log('onSearchRecord', onSearchKeyword.value)
|
console.log('onSearchRecord', queryParams.value.keyWord)
|
||||||
|
getSafetyViolationsListData(true)
|
||||||
}
|
}
|
||||||
// 修改
|
// 修改
|
||||||
const onHandleEditRecord = () => {
|
const onHandleEditRecord = (id) => {
|
||||||
console.log('onHandleEditRecord')
|
console.log('onHandleEditRecord')
|
||||||
uni.redirectTo({
|
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/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. 其他错误
|
// 3. 其他错误
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: '请求错误',
|
title: '请求失败,请切换网络后尝试',
|
||||||
})
|
})
|
||||||
reject(res)
|
reject(res)
|
||||||
}
|
}
|
||||||
|
|
@ -111,7 +111,7 @@ export const http = (options) => {
|
||||||
fail(err) {
|
fail(err) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: '请求失败',
|
title: '请求失败,请切换网络后尝试',
|
||||||
})
|
})
|
||||||
console.log(err, '请求失败')
|
console.log(err, '请求失败')
|
||||||
reject(err)
|
reject(err)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue