安全措施落实接口调试完成

This commit is contained in:
BianLzhaoMin 2025-04-07 17:51:31 +08:00
parent 2f39f0b71d
commit 0034ac44f1
12 changed files with 551 additions and 430 deletions

View File

@ -1,34 +1,16 @@
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
}
export function useCommon() {
// 获取项目数据(自动处理缓存)
const getProjectList = async () => {
return await commonStore.getProjectList()
}
return { getData, projectList, majorList }
// 获取专业数据(自动处理缓存)
const getMajorList = async () => {
return await commonStore.getMajorList()
}
return { getProjectList, getMajorList }
}

View File

@ -246,17 +246,19 @@
</template>
<script setup>
import { reactive, ref, watch } from 'vue'
import { reactive, ref, watch, onMounted } from 'vue'
import { debounce } from 'lodash-es' //
import { getProjectApi, getMajorApi, getProcedureApi } from '@/services/common.js'
import { useCommon } from '@/hooks/useCommon.js'
import { getProcedureApi } from '@/services/common.js'
import {
addQualityInspectionApi,
editQualityInspectionApi,
getQualityInspectionDetailsByIdApi,
} from '@/services/qualityInspection.js'
import getProjectAndMajorData from '@/hooks/useCommon.js'
import TitleTipModal from '@/components/TitleTipModal/index'
const { getProjectList, getMajorList } = useCommon()
const addAndEditModelRef = ref(null)
const projectShow = ref(false) //
const majorShow = ref(false) //
@ -266,10 +268,6 @@ 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.
@ -284,6 +282,13 @@ const props = defineProps({
},
})
//
const projectList = ref([])
//
const majorList = reactive([])
//
const procedureList = reactive([])
//
const deleteFileList = []
//
@ -366,45 +371,6 @@ const addAndEditModelRules = ref({
},
],
})
//
const projectList = ref([])
//
const getProjectData = async () => {
console.log(
'%c🔍 获取项目请求入参 %c',
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
'',
{},
)
const res = await getProjectApi({})
projectList.value = res.data
console.log(
'%c🔍 获取项目请求出参 %c',
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
'',
res,
)
}
getProjectData()
//
const majorList = reactive([])
//
const getMajorData = async () => {
const { data: res } = await getMajorApi()
console.log(
'%c🔍 获取专业请求出参 %c',
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
'',
res,
)
majorList.push(res)
}
getMajorData()
//
const procedureList = reactive([])
//
const getProcedureData = async (pid) => {
@ -424,8 +390,6 @@ const getProcedureData = async (pid) => {
procedureList.push(res)
}
// getProcedureData()
//
const formatter = (type, value) => {
if (type === 'year') {
@ -442,18 +406,16 @@ const formatter = (type, value) => {
//
const onSelectProject = () => {
console.log('---选择')
projectShow.value = true
}
//
const onSearchInProjectPopup = () => {
console.log('---搜索', onSearchProjectName.value)
// console.log('---', onSearchProjectName.value)
}
//
const onScrollTolower = () => {
console.log('---滚动触底')
// console.log('---')
}
//
@ -476,7 +438,6 @@ const onSelectMajor = () => {
//
const onConfirmMajor = (item) => {
console.log('---确定', item.value[0].name)
addAndEditModel.majorName = item.value[0].name
addAndEditModel.majorId = item.value[0].id
getProcedureData(item.value[0].id)
@ -514,7 +475,6 @@ const onConfirmDate = (item) => {
addAndEditModel.rectTime = formatDateValue
}
dateShow.value = false
console.log('---日期确定', formatDateValue)
}
const formatDate = (timestamp) => {
@ -527,7 +487,6 @@ const formatDate = (timestamp) => {
//
const onAfterReadVrImgList = (event) => {
console.log('event', event)
let lists = [].concat(event.file)
lists.map((item) => {
addAndEditModel.vrImgList.push({
@ -628,9 +587,6 @@ const onSubmitForm = debounce(() => {
uploadImages
.then(async ({ successVrImgList, successCorrectionImgList }) => {
console.log('图片上传成功,开始提交表单...')
console.log('successVrImgList', successVrImgList)
//
//
const {
@ -749,7 +705,6 @@ const uploadImgFun = async (list, type) => {
sendLoading.value = false
res = JSON.parse(res.data)
console.log(res, '上传成功')
if (res.code === 200) {
successList = res.data
resolve(successList) //
@ -832,18 +787,19 @@ const getFormDetail = async () => {
correctionImgList: rectPhotoListEdit,
})
console.log(addAndEditModel, 'addAndEditModel')
getProcedureData(majorId)
}
}
onMounted(async () => {
projectList.value = await getProjectList()
majorList.push(await getMajorList())
})
//
watch(
() => props.addAndEditFormType,
(newValue) => {
console.log('newValue当前表单的类型', newValue)
if (newValue != 1) {
getFormDetail()
}

View File

@ -38,7 +38,7 @@
<!-- 名称 -->
<view class="item-name">
<text>{{ item.proName }}</text>
<text>{{ item.vioPlace }}</text>
</view>
<!-- 文字内容 -->

View File

@ -10,23 +10,24 @@
style="background-color: #fff; padding: 0 30rpx 20rpx"
>
<TitleTipModal :TitleTip="`项目信息`" />
<up-form-item prop="projectName" label="项目名称" required>
<up-form-item prop="proName" label="项目名称" required>
<up-input
readonly
border="none"
:placeholder="props.addAndEditFormType == 3 ? '' : '点击选择项目'"
v-model="addAndEditModel.projectName"
v-model="addAndEditModel.proName"
@click="onSelectProject"
>
<template #suffix v-if="props.addAndEditFormType != 3">
<up-icon name="arrow-right" @tap="onSelectProject" />
<up-icon name="arrow-right" />
</template>
</up-input>
</up-form-item>
<up-form-item prop="major" label="专业">
<up-form-item prop="majorName" label="专业">
<up-input
border="none"
readonly
v-model="addAndEditModel.major"
v-model="addAndEditModel.majorName"
:placeholder="props.addAndEditFormType == 3 ? '' : '点击选择专业'"
>
<template #suffix v-if="props.addAndEditFormType != 3">
@ -34,11 +35,11 @@
</template>
</up-input>
</up-form-item>
<up-form-item prop="procedure" label="工序">
<up-form-item prop="gxName" label="工序">
<up-input
border="none"
readonly
v-model="addAndEditModel.procedure"
v-model="addAndEditModel.gxName"
:placeholder="props.addAndEditFormType == 3 ? '' : '点击选择工序'"
>
<template #suffix v-if="props.addAndEditFormType != 3">
@ -47,127 +48,71 @@
</up-input>
</up-form-item>
<!-- <TitleTipModal :TitleTip="`违章信息`" />
<up-form-item prop="examiner" label="检查人">
<up-input
border="none"
:readonly="props.addAndEditFormType == 3"
:placeholder="props.addAndEditFormType == 3 ? '' : '请输入检查人'"
/>
</up-form-item>
<up-form-item prop="inspectTime" label="检查日期">
<up-input
readonly
border="none"
inputAlign="right"
v-model="addAndEditModel.inspectTime"
:placeholder="props.addAndEditFormType == 3 ? '' : '点击选择检查日期'"
>
<template #suffix v-if="props.addAndEditFormType != 3">
<up-icon name="arrow-right" @tap="onSelectDate(1)" />
</template>
</up-input>
</up-form-item>
<up-form-item prop="correctionTerm" label="整改期限" required>
<up-input
readonly
border="none"
inputAlign="right"
v-model="addAndEditModel.correctionTerm"
:placeholder="props.addAndEditFormType == 3 ? '' : '点击选择整改期限'"
>
<template #suffix v-if="props.addAndEditFormType != 3">
<up-icon name="arrow-right" @tap="onSelectDate(2)" />
</template>
</up-input>
</up-form-item>
<up-form-item prop="vrLocation" label="违章地点" required>
<up-input
border="none"
v-model="addAndEditModel.vrLocation"
:readonly="props.addAndEditFormType == 3"
:placeholder="props.addAndEditFormType == 3 ? '' : '请输入违章地点'"
/>
</up-form-item>
<up-form-item prop="vrDescribe" label="违章描述" required>
<up-textarea
autoHeight
border="none"
v-model="addAndEditModel.vrDescribe"
:readonly="props.addAndEditFormType == 3"
:placeholder="props.addAndEditFormType == 3 ? '' : '请输入违章描述'"
/>
</up-form-item>
<up-form-item
prop="vrImgList"
:label="props.addAndEditFormType == 3 ? '违章照片' : '违章照片(最多9张)'"
required
>
<up-upload
name="1"
multiple
@delete="onDeletePicVrImgList"
@afterRead="onAfterReadVrImgList"
:fileList="addAndEditModel.vrImgList"
:maxCount="props.addAndEditFormType == 3 ? 1 : 9"
/>
</up-form-item> -->
<TitleTipModal :TitleTip="`检查信息`" />
<up-form-item prop="correctionPerson" label="检查人">
<up-form-item prop="checkUserName" label="检查人">
<up-input
border="none"
:readonly="props.addAndEditFormType == 3"
v-model="addAndEditModel.correctionPerson"
v-model="addAndEditModel.checkUserName"
:placeholder="props.addAndEditFormType == 3 ? '' : '请输入检查人'"
/>
</up-form-item>
<up-form-item prop="correctionTime" label="检查日期">
<up-form-item prop="checkDate" label="检查日期">
<up-input
readonly
border="none"
inputAlign="right"
v-model="addAndEditModel.correctionTime"
v-model="addAndEditModel.checkDate"
:placeholder="props.addAndEditFormType == 3 ? '' : '点击选择检查日期'"
>
<template #suffix v-if="props.addAndEditFormType != 3">
<up-icon name="arrow-right" @tap="onSelectDate(3)" />
<up-icon name="arrow-right" @tap="onSelectDate" />
</template>
</up-input>
</up-form-item>
<up-form-item prop="vrLocation" label="检查地点" required>
<up-form-item prop="checkPlace" label="检查地点" required>
<up-input
border="none"
v-model="addAndEditModel.vrLocation"
v-model="addAndEditModel.checkPlace"
:readonly="props.addAndEditFormType == 3"
:placeholder="props.addAndEditFormType == 3 ? '' : '请输入检查地点'"
/>
</up-form-item>
<up-form-item prop="correctionDescribe" label="检查描述" required>
<up-form-item prop="checkDesc" label="检查描述" required>
<up-textarea
autoHeight
border="none"
:readonly="props.addAndEditFormType == 3"
v-model="addAndEditModel.correctionDescribe"
v-model="addAndEditModel.checkDesc"
:placeholder="props.addAndEditFormType == 3 ? '' : '请输入检查描述'"
/>
</up-form-item>
<up-form-item
required
prop="examiner"
:label="props.addAndEditFormType == 3 ? '检查照片' : '检查照片(最多9张)'"
prop="correctionImgList"
:label="props.addAndEditFormType == 3 ? '现场照片' : '现场照片(最多9张)'"
>
<up-upload
name="1"
multiple
@delete="onDeleteCorrectionImgList"
@afterRead="onAfterReadCorrectionImgList"
:deletable="!props.addAndEditFormType == 3"
:deletable="props.addAndEditFormType != 3"
:fileList="addAndEditModel.correctionImgList"
:maxCount="props.addAndEditFormType == 3 ? 1 : 9"
:maxCount="
props.addAndEditFormType == 3
? addAndEditModel.correctionImgList.length
: 9 - addAndEditModel.correctionImgList.length
"
/>
</up-form-item>
<up-button type="primary" text="提交" @tap="onSubmitForm" style="width: 100%" />
<up-button
type="primary"
text="提交"
@tap="onSubmitForm"
style="width: 100%; margin-top: 10rpx"
/>
</up-form>
<!-- 项目选择弹框 -->
@ -190,11 +135,11 @@
<!-- 工程列表 -->
<view class="project-list">
<up-list @scrolltolower="onScrollTolower" style="width: 100%">
<up-list-item v-for="item in 20" :key="item">
<up-cell :title="`xxxxxxxxx工程-${item}`" @tap="onSelectProjectItem(item)">
<up-list-item v-for="(item, index) in projectList" :key="item.id">
<up-cell :title="item.name" @tap="onSelectProjectItem(item)">
<template #icon>
<text style="margin-right: 10rpx">
{{ item }}
{{ index + 1 }}
</text>
</template>
</up-cell>
@ -206,7 +151,7 @@
<!-- 专业选择器 -->
<up-picker
keyName="label"
keyName="name"
:show="majorShow"
:columns="majorList"
@confirm="onConfirmMajor"
@ -214,7 +159,7 @@
/>
<!-- 工序选择器 -->
<up-picker
keyName="label"
keyName="name"
:show="procedureShow"
:columns="procedureList"
@confirm="onConfirmProcedure"
@ -241,11 +186,19 @@
</template>
<script setup>
import { reactive, ref } from 'vue'
import { onMounted, reactive, ref, watch } from 'vue'
import { debounce } from 'lodash-es' //
import { useCommon } from '@/hooks/useCommon.js'
import {
addSafetyMeasureApi,
editSafetyMeasureApi,
getSafetyMeasureDetailsByIdApi,
} from '@/services/safetyMeasure.js'
import { getProcedureApi } from '@/services/common.js'
import TitleTipModal from '@/components/TitleTipModal/index'
const addAndEditModelRef = ref(null)
const { getProjectList, getMajorList } = useCommon()
const addAndEditModelRef = ref(null)
const projectShow = ref(false) //
const majorShow = ref(false) //
const procedureShow = ref(false) //
@ -260,30 +213,32 @@ const props = defineProps({
type: [Number, String],
default: () => 1,
},
// id
detailsId: {
type: [Number, String],
default: () => 1,
},
})
console.log(props.addAndEditFormType, '表单类型')
//
const addAndEditModel = reactive({
projectName: '',
procedure: '',
major: '',
examiner: '',
inspectTime: '',
correctionTerm: '',
vrLocation: '',
vrDescribe: '',
vrImgList: [],
correctionPerson: '',
correctionDescribe: '',
correctionTime: '',
correctionImgList: [],
dataSource: 2,
proId: '', // id
proName: '', //
majorId: '', // id
majorName: '', //
gxId: '', // id
gxName: '', //
checkUserName: '', //
checkDate: '', //
checkPlace: '', //
checkDesc: '', //
correctionImgList: [], //
})
//
const addAndEditModelRules = ref({
projectName: [
proName: [
{
type: 'string',
required: true,
@ -291,51 +246,28 @@ const addAndEditModelRules = ref({
trigger: ['blur', 'change'],
},
],
correctionTerm: [
checkPlace: [
{
type: 'string',
required: true,
message: '请选择整改期限',
message: '请填写检查地点',
trigger: ['blur', 'change'],
},
],
vrLocation: [
checkDesc: [
{
type: 'string',
required: true,
message: '请填写违章地点',
message: '请填写检查描述',
trigger: ['blur', 'change'],
},
],
vrDescribe: [
correctionImgList: [
{
type: 'string',
type: 'array',
required: true,
message: '请填写违章描述',
trigger: ['blur', 'change'],
},
],
vrImgList: [
{
type: 'string',
required: true,
message: '请上传违章照片',
trigger: ['blur', 'change'],
},
],
correctionPerson: [
{
type: 'string',
required: true,
message: '请填写整改人',
trigger: ['blur', 'change'],
},
],
correctionDescribe: [
{
type: 'string',
required: true,
message: '请填写整改说明',
message: '请上传现场照片',
trigger: ['blur', 'change'],
},
],
@ -343,47 +275,7 @@ const addAndEditModelRules = ref({
//
const projectList = ref([])
//
const majorList = reactive([
[
{
label: '专业1',
value: 2021,
},
{
label: '专业2',
value: 2022,
},
{
label: '专业3',
value: 2023,
},
{
label: '专业4',
value: 2024,
},
],
])
//
const procedureList = reactive([
[
{
label: '工序1',
id: 2021,
},
{
label: '工序2',
id: 2022,
},
{
label: '工序3',
id: 2023,
},
{
label: '工序4',
id: 2024,
},
],
])
const majorList = ref([])
//
const formatter = (type, value) => {
@ -399,25 +291,45 @@ const formatter = (type, value) => {
return value
}
//
const procedureList = reactive([])
//
const getProcedureData = async (pid) => {
console.log(
'%c🔍 获取专业请求入参 %c',
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
'',
pid,
)
const { data: res } = await getProcedureApi({ pid })
console.log(
'%c🔍 获取工序请求出参 %c',
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
'',
res,
)
procedureList.push(res)
}
//
const onSelectProject = () => {
console.log('---选择')
projectShow.value = true
}
//
const onSearchInProjectPopup = () => {
console.log('---搜索', onSearchProjectName.value)
// console.log('---', onSearchProjectName.value)
}
//
const onScrollTolower = () => {
console.log('---滚动触底')
// console.log('---')
}
//
const onSelectProjectItem = (item) => {
addAndEditModel.projectName = 'xxxxxx工程' + item
addAndEditModel.proName = item.name
addAndEditModel.proId = item.id
projectShow.value = false
}
@ -434,8 +346,9 @@ const onSelectMajor = () => {
//
const onConfirmMajor = (item) => {
console.log('---确定', item.value[0].label)
addAndEditModel.major = item.value[0].label
addAndEditModel.majorName = item.value[0].name
addAndEditModel.majorId = item.value[0].id
getProcedureData(item.value[0].id)
majorShow.value = false
}
//
@ -445,31 +358,21 @@ const onSelectProcedure = () => {
//
const onConfirmProcedure = (item) => {
addAndEditModel.procedure = item.value[0].label
addAndEditModel.gxName = item.value[0].name
addAndEditModel.gxId = item.value[0].id
procedureShow.value = false
}
//
const onSelectDate = (type) => {
// type 1. 2. 3.
dateType.value = type
const onSelectDate = () => {
dateShow.value = true
}
//
const onConfirmDate = (item) => {
const onConfirmDate = () => {
const formatDateValue = formatDate(dateValue.value)
if (dateType.value === 1) {
addAndEditModel.inspectTime = formatDateValue
}
if (dateType.value === 2) {
addAndEditModel.correctionTerm = formatDateValue
}
if (dateType.value === 3) {
addAndEditModel.correctionTime = formatDateValue
}
addAndEditModel.checkDate = formatDateValue
dateShow.value = false
console.log('---日期确定', formatDateValue)
}
const formatDate = (timestamp) => {
@ -480,26 +383,13 @@ const formatDate = (timestamp) => {
return `${year}-${month}-${day}`
}
//
const onAfterReadVrImgList = (event) => {
let lists = [].concat(event.file)
lists.map((item) => {
addAndEditModel.vrImgList.push({
...item,
})
})
}
//
const onDeletePicVrImgList = (event) => {
addAndEditModel.vrImgList.splice(event.index, 1)
}
//
//
const onAfterReadCorrectionImgList = (event) => {
let lists = [].concat(event.file)
lists.map((item) => {
addAndEditModel.correctionImgList.push({
...item,
isEdit: false,
})
})
}
@ -510,27 +400,250 @@ const onDeleteCorrectionImgList = (event) => {
//
const onSubmitForm = debounce(() => {
console.log('---提交')
sendLoading.value = true
addAndEditModelRef.value.validate().then((valid) => {
if (valid) {
console.log('校验通过')
sendLoading.value = false
}
})
addAndEditModelRef.value
.validate()
.then(async (valid) => {
if (valid) {
//
sendLoading.value = true
const uploadImages = new Promise(async (resolve, reject) => {
try {
let successCorrectionImgList = []
let successCorrectionImgListNoEdit = []
if (addAndEditModel.correctionImgList.length > 0) {
addAndEditModel.correctionImgList.forEach((e) => {
if (e.isEdit === false) {
successCorrectionImgListNoEdit.push(e)
}
})
}
if (successCorrectionImgListNoEdit.length > 0) {
successCorrectionImgList = await uploadImgFun(
successCorrectionImgListNoEdit,
5,
)
}
resolve({ successCorrectionImgList }) //
} catch (error) {
reject(error) //
}
})
uploadImages
.then(async ({ successCorrectionImgList }) => {
//
//
const {
dataSource,
proId, // id
proName, //
majorId, // id
majorName, //
gxId, // id
gxName, //
checkUserName, //
checkDate, //
checkPlace, //
checkDesc, //
correctionImgList,
} = addAndEditModel
const correctionImgListOld = []
correctionImgList.forEach((e) => {
if (e.isEdit) correctionImgListOld.push(e)
})
const addParams = {
dataSource,
proId, // id
proName, //
majorId, // id
majorName, //
gxId, // id
gxName, //
checkUserName, //
checkDate, //
checkPlace, //
checkDesc, //
sysFileResourceList: [
...correctionImgListOld,
...successCorrectionImgList,
],
uploadType: 3,
}
const SED_API =
props.addAndEditFormType == 1
? addSafetyMeasureApi
: editSafetyMeasureApi
if (props.addAndEditFormType == 2) {
Object.assign(addParams, {
id: props.detailsId,
})
}
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.msg)
}
})
.catch((error) => {
// console.error(':', error)
})
}
})
.catch((error) => {})
}, 1000)
//
const getFormDetail = () => {
console.log('---获取详情数据')
}
// props.addAndEditFormType 2
if (props.addAndEditFormType == 2) {
//
getFormDetail()
//
const uploadImgFun = async (list, type) => {
console.log(list, '上传逻辑')
return new Promise((resolve, reject) => {
let successList = []
let files = []
list.forEach((f) => {
let d = {
file: f.url,
name: 'files',
uri: f.url,
}
files.push(d)
})
sendLoading.value = true
uni.uploadFile({
url: '/imgTool/sys/file/uploadFile',
files: files,
name: 'files',
formData: {
params: JSON.stringify({
uploadType: 3,
sourceType: type,
sourceTypeName: '安全措施落实-现场照片',
}),
},
success: (res) => {
sendLoading.value = false
res = JSON.parse(res.data)
if (res.code === 200) {
successList = res.data
resolve(successList) //
} else {
uni.$u.toast('上传失败' + res.msg)
reject(new Error('上传失败: ' + res.msg))
}
},
fail: (err) => {
sendLoading.value = false
reject(new Error('网络错误: ' + err.errMsg))
},
})
})
}
//
const getFormDetail = async () => {
console.log(
'%c🔍 获取安全措施落实详情入参 %c',
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
'',
props?.detailsId,
)
const res = await getSafetyMeasureDetailsByIdApi({ id: props?.detailsId })
if (res.code === 200) {
const {
dataSource,
proId, // id
proName, //
majorId, // id
majorName, //
gxId, // id
gxName, //
checkUserName, //
checkDate, //
checkPlace, //
checkDesc, //
sysFileResourceList,
} = res.data
let correctionImgListEdit = []
if (sysFileResourceList.length > 0) {
correctionImgListEdit = sysFileResourceList.map((e) => {
return {
idEdit: true,
url: e.originalFilePath,
...e,
}
})
}
Object.assign(addAndEditModel, {
proId, // id
proName, //
majorId, // id
majorName, //
gxId, // id
gxName, //
checkUserName, //
checkDate, //
checkPlace, //
checkDesc, //
correctionImgList: correctionImgListEdit,
})
getProcedureData(majorId)
}
}
//
watch(
() => props.addAndEditFormType,
(newValue) => {
if (newValue != 1) {
getFormDetail()
}
},
{
deep: true,
immediate: true,
},
)
onMounted(async () => {
projectList.value = await getProjectList()
majorList.value.push(await getMajorList())
})
</script>
<style scoped lang="scss">

View File

@ -8,7 +8,7 @@
/>
<view class="container">
<AddAndEditForm :addAndEditFormType="addAndEditFormType" />
<AddAndEditForm :addAndEditFormType="addAndEditFormType" :detailsId="detailsId" />
</view>
</view>
</template>
@ -20,7 +20,7 @@ import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
const { safeAreaInsets } = uni.getSystemInfoSync()
const detailsId = ref('')
const addAndEditFormType = ref(1)
const uploadRecordUrl = ref('/pages/safetyMeasure/upload-record/index')
@ -28,6 +28,9 @@ onLoad((query) => {
if (query.type) {
addAndEditFormType.value = query.type
}
if (query.id) {
detailsId.value = query.id
}
})
</script>

View File

@ -8,7 +8,7 @@
<up-input
clearable
placeholder="输入搜索关键词"
v-model.trim="onSearchKeyword"
v-model.trim="queryParams.keyWord"
suffixIconStyle="color: #909399"
>
<template #suffix>
@ -18,53 +18,50 @@
</view>
</view>
<view class="upload-record-list">
<view class="upload-record-list" v-if="total > 0">
<up-list @scrolltolower="onScrollTolower" style="width: 100%">
<up-list-item v-for="item in 10" :key="item">
<up-list-item v-for="item in safetyMeasureList" :key="item.id">
<view class="record-item">
<view @tap="onHandleViewDetails">
<view @tap="onHandleViewDetails(item.id)">
<!-- 日期 -->
<view class="item-date">
<text>2024-05-06</text>
<text>{{ item.checkDate }}</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.checkPlace }}</text>
</view>
<!-- 文字内容 -->
<view class="text-content">
<up-text
:lines="2"
text="关于uview-plus的取名来由首字母u来自于uni-app首字母
uni-app是基VuejsVue和View(延伸为UI视图之意)同音同时view组件uni-app中
最础最重要的组件故取名uview-plus表达源于uni-app和Vue之意同时在此也对它示感谢"
/>
<up-text :lines="2" :text="item.checkDesc" />
</view>
</view>
<!-- 图片内容 -->
<view class="swiper-container">
<up-swiper
:list="list1"
:indicator="true"
:list="item?.sysFileResourceList"
keyName="originalFilePath"
interval="5000"
@click="onClickSwiper"
/>
<view class="swiper-count"> 3 </view>
<view class="swiper-count">
{{ item?.sysFileResourceList.length }}
</view>
</view>
<!-- 检查人 -->
<view class="inspect-person">
<view> 检查人武松 </view>
<view> 检查人{{ item.checkUserName }}</view>
<!-- <view> 整改日期2025-05-06 </view> -->
</view>
</view>
@ -75,45 +72,98 @@ uni-app是基VuejsVue和View(延伸为UI、视图之意)同音同时view
{{ finish ? '没有更多数据了~' : '正在加载...' }}
</view>
</view>
<up-empty mode="data" v-else />
</view>
</view>
</template>
<script setup>
import NavBarModal from '@/components/NavBarModal/index'
import { ref, reactive } from 'vue'
import { ref, reactive, computed } from 'vue'
import { debounce } from 'lodash-es' //
const scrollTop = ref(0)
const onSearchKeyword = ref('')
const finish = ref(false)
import { getSafetyMeasureListApi } from '@/services/safetyMeasure.js'
const safetyMeasureList = ref([])
const total = ref(0)
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 queryParams = ref({
pageNum: 1,
pageSize: 10,
keyWord: '',
})
//
const getSafetyMeasureListData = 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 { data: res } = await getSafetyMeasureListApi(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.total
//
if (isTap) {
//
safetyMeasureList.value = res?.list || []
//
queryParams.value.pageNum = 1
} else {
//
if (res.list && res.list.length > 0) {
safetyMeasureList.value = [...safetyMeasureList.value, ...res.list]
}
}
} catch (error) {
//
if (isTap) {
safetyMeasureList.value = []
}
}
}
getSafetyMeasureListData()
//
const onScrollTolower = debounce(() => {
console.log('onScrollTolower')
//
if (safetyMeasureList.value.length < total.value) {
queryParams.value.page++
getSafetyMeasureListData(false)
}
}, 500)
//
const finish = computed(() => {
if (total.value === safetyMeasureList.value.length) return true
})
//
const onSearchRecord = () => {
console.log('onSearchRecord', onSearchKeyword.value)
getSafetyMeasureListData(true)
}
//
const onHandleEditRecord = () => {
const onHandleEditRecord = (id) => {
console.log('onHandleEditRecord')
uni.redirectTo({
url: `/pages/safetyMeasure/index?type=2&id=1`, //
url: `/pages/safetyMeasure/index?type=2&id=${id}`, //
})
}
//
const onHandleViewDetails = () => {
const onHandleViewDetails = (id) => {
uni.redirectTo({
url: `/pages/safetyMeasure/index?type=3&id=1`, //
url: `/pages/safetyMeasure/index?type=3&id=${id}`, //
})
}

View File

@ -246,17 +246,19 @@
</template>
<script setup>
import { reactive, ref, watch } from 'vue'
import { reactive, ref, watch, onMounted } from 'vue'
import { debounce } from 'lodash-es' //
import { useCommon } from '@/hooks/useCommon.js'
import { getProjectApi, getMajorApi, getProcedureApi } from '@/services/common.js'
import {
addSafetyViolationsApi,
editSafetyViolationsApi,
getSafetyViolationsDetailsByIdApi,
} from '@/services/safetyViolations.js'
import getProjectAndMajorData from '@/hooks/useCommon.js'
import TitleTipModal from '@/components/TitleTipModal/index'
const { getProjectList, getMajorList } = useCommon()
const addAndEditModelRef = ref(null)
const projectShow = ref(false) //
const majorShow = ref(false) //
@ -266,10 +268,6 @@ 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.
@ -284,6 +282,13 @@ const props = defineProps({
},
})
//
const projectList = ref([])
//
const majorList = reactive([])
//
const procedureList = reactive([])
//
const deleteFileList = []
//
@ -366,45 +371,6 @@ const addAndEditModelRules = ref({
},
],
})
//
const projectList = ref([])
//
const getProjectData = async () => {
console.log(
'%c🔍 获取项目请求入参 %c',
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
'',
{},
)
const res = await getProjectApi({})
projectList.value = res.data
console.log(
'%c🔍 获取项目请求出参 %c',
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
'',
res,
)
}
getProjectData()
//
const majorList = reactive([])
//
const getMajorData = async () => {
const { data: res } = await getMajorApi()
console.log(
'%c🔍 获取专业请求出参 %c',
'background: linear-gradient(90deg, #FF6B6B, #4ECDC4); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold;',
'',
res,
)
majorList.push(res)
}
getMajorData()
//
const procedureList = reactive([])
//
const getProcedureData = async (pid) => {
@ -442,18 +408,16 @@ const formatter = (type, value) => {
//
const onSelectProject = () => {
console.log('---选择')
projectShow.value = true
}
//
const onSearchInProjectPopup = () => {
console.log('---搜索', onSearchProjectName.value)
// console.log('---', onSearchProjectName.value)
}
//
const onScrollTolower = () => {
console.log('---滚动触底')
// console.log('---')
}
//
@ -476,7 +440,6 @@ const onSelectMajor = () => {
//
const onConfirmMajor = (item) => {
console.log('---确定', item.value[0].name)
addAndEditModel.majorName = item.value[0].name
addAndEditModel.majorId = item.value[0].id
getProcedureData(item.value[0].id)
@ -514,7 +477,6 @@ const onConfirmDate = (item) => {
addAndEditModel.rectTime = formatDateValue
}
dateShow.value = false
console.log('---日期确定', formatDateValue)
}
const formatDate = (timestamp) => {
@ -527,7 +489,6 @@ const formatDate = (timestamp) => {
//
const onAfterReadVrImgList = (event) => {
console.log('event', event)
let lists = [].concat(event.file)
lists.map((item) => {
addAndEditModel.vrImgList.push({
@ -628,9 +589,6 @@ const onSubmitForm = debounce(() => {
uploadImages
.then(async ({ successVrImgList, successCorrectionImgList }) => {
console.log('图片上传成功,开始提交表单...')
console.log('successVrImgList', successVrImgList)
//
//
const {
@ -749,7 +707,6 @@ const uploadImgFun = async (list, type) => {
sendLoading.value = false
res = JSON.parse(res.data)
console.log(res, '上传成功')
if (res.code === 200) {
successList = res.data
resolve(successList) //
@ -832,8 +789,6 @@ const getFormDetail = async () => {
correctionImgList: rectPhotoListEdit,
})
console.log(addAndEditModel, 'addAndEditModel')
getProcedureData(majorId)
}
}
@ -842,8 +797,6 @@ const getFormDetail = async () => {
watch(
() => props.addAndEditFormType,
(newValue) => {
console.log('newValue当前表单的类型', newValue)
if (newValue != 1) {
getFormDetail()
}
@ -853,6 +806,11 @@ watch(
immediate: true,
},
)
onMounted(async () => {
projectList.value = await getProjectList()
majorList.push(await getMajorList())
})
</script>
<style scoped lang="scss">

View File

@ -38,7 +38,7 @@
<!-- 名称 -->
<view class="item-name">
<text>{{ item.proName }}</text>
<text>{{ item.vioPlace }}</text>
</view>
<!-- 文字内容 -->

View File

@ -0,0 +1,46 @@
import { http } from '@/utils/http'
// 安全措施落实表单提交接口
export const addSafetyMeasureApi = (data) => {
return http({
method: 'POST',
url: '/imgTool/safetyMeasure/addSafetyMeasures',
data,
header: {
'Content-Type': 'application/x-www-form-urlencoded',
},
})
}
// 安全措施落实数据列表
export const getSafetyMeasureListApi = (data) => {
return http({
method: 'POST',
url: '/imgTool/safetyMeasure/getSafetyMeasuresList',
data,
header: {
'Content-Type': 'application/x-www-form-urlencoded',
},
})
}
// 安全措施落实表单获取详情
export const getSafetyMeasureDetailsByIdApi = (data) => {
return http({
method: 'POST',
url: '/imgTool/safetyMeasure/getSafetyMeasuresById',
data,
header: {
'Content-Type': 'application/x-www-form-urlencoded',
},
})
}
// 安全措施落实表单修改
export const editSafetyMeasureApi = (data) => {
return http({
method: 'POST',
url: '/imgTool/safetyMeasure/updateSafetyMeasures',
data,
header: {
'Content-Type': 'application/x-www-form-urlencoded',
},
})
}

View File

@ -1,5 +1,6 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { defineStore } from 'pinia'
import { getProjectApi, getMajorApi } from '@/services/common'
export const useCommonStore = defineStore('common', () => {
// 项目数据
@ -8,19 +9,31 @@ export const useCommonStore = defineStore('common', () => {
const majorList = ref([])
// 存储项目数据
const setProjectList = (val) => {
projectList.value = val
const getProjectList = async () => {
if (projectList.value.length < 1) {
const { data: result } = await getProjectApi({})
projectList.value = result
return projectList.value
} else {
return projectList.value
}
}
// 存储专业数据
const setMajorList = (val) => {
majorList.value = val
const getMajorList = async () => {
if (majorList.value.length < 1) {
const { data: result } = await getMajorApi()
majorList.value = result
return majorList.value
} else {
return majorList.value
}
}
// 把数据和方法 return 出去
return {
projectList,
majorList,
setProjectList,
setMajorList,
getProjectList,
getMajorList,
}
})

View File

@ -65,7 +65,6 @@ export const http = (options) => {
...options,
success(res) {
// 1. 判断是否请求成功
if (res.statusCode >= 200 && res.statusCode < 300) {
if (res.data.code >= 200 && res.data.code < 300) {
resolve(res.data)

View File

@ -9,7 +9,8 @@ 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', // 赵福海
changeOrigin: true,
rewrite: (path) => {
return path.replace(/\/api/, '')