提交 397b9e08 authored 作者: lidongxu's avatar lidongxu

refactor(inspectiontask/*): 修改:勤策移动端_售点稽查_上传照片添加loading效果

上级 5ceac0f6
...@@ -219,6 +219,7 @@ const form = reactive({ // 当前页信息总对象 ...@@ -219,6 +219,7 @@ const form = reactive({ // 当前页信息总对象
const getInspectionTaskDetailFn = async () => { const getInspectionTaskDetailFn = async () => {
const res = await getInspectionTaskDetailAPI({ const res = await getInspectionTaskDetailAPI({
storeCode: form.storeCode, storeCode: form.storeCode,
storeName: form.storeName,
rstId: form.rstId, rstId: form.rstId,
}) })
if (res.data) { if (res.data) {
...@@ -273,20 +274,7 @@ const getInspectionTaskDetailFn = async () => { ...@@ -273,20 +274,7 @@ const getInspectionTaskDetailFn = async () => {
// 一定在这里获取地理位置(保证稽查任务 id 创建完毕) // 一定在这里获取地理位置(保证稽查任务 id 创建完毕)
getLocationFn() getLocationFn()
} }
onMounted(async () => { getInspectionTaskDetailFn()
if (route.query.taskStatus) {
// 从新建稽查任务页面过来的,直接初始化
// 先走一次创建任务,再走查询详情
// 没有的话调用新建接口,得到一个总体稽查任务 id
const res = await createInspectionTaskAPI({
storeName: route.query.storeName,
storePicture: route.query.storePicture,
selectedType: route.query.selectedType
})
form.rstId = res.data.rstId
}
getInspectionTaskDetailFn()
})
// 门店图片预览 // 门店图片预览
...@@ -365,12 +353,17 @@ const handleClickLocation = () => { ...@@ -365,12 +353,17 @@ const handleClickLocation = () => {
/*************** 门头照上传 ***************/ /*************** 门头照上传 ***************/
// 上传照片 // 上传照片
const commitStorePhotosRead = async (file) => { const commitStorePhotosRead = async (file) => {
form.commitStorePicture = [{
url: file.content,
status: 'uploading',
message: '上传中...'
}]
const date = new Date() const date = new Date()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
const theDate = date.getDate()
const pictureUrl = await uploadFileToOSSAPI(`risk/${date.getFullYear()}-${month}/storeFrontPhoto/${useUserStore().empInfo.empNo}/${uuidv4()}.png`, file.file) const pictureUrl = await uploadFileToOSSAPI(`risk/${date.getFullYear()}-${month}/storeFrontPhoto/${useUserStore().empInfo.empNo}/${uuidv4()}.png`, file.file)
form.commitStorePicture = [{ form.commitStorePicture = [{
url: pictureUrl url: pictureUrl,
status: 'done'
}] }]
await createInspectionTaskAPI({ await createInspectionTaskAPI({
storeCode: form.storeCode, storeCode: form.storeCode,
...@@ -448,13 +441,20 @@ const handleRemarkChange = async () => { ...@@ -448,13 +441,20 @@ const handleRemarkChange = async () => {
// 大日期照片上传 // 大日期照片上传
const longTimePictureArrRead = async (file) => { const longTimePictureArrRead = async (file) => {
const index = form.longTimePictureArr.length
form.longTimePictureArr[index] = {
url: file.content,
status: 'uploading',
message: '上传中...'
}
const date = new Date() const date = new Date()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
const theDate = date.getDate() const theDate = date.getDate()
const pictureUrl = await uploadFileToOSSAPI(`risk/${date.getFullYear()}-${month}/longTimePicture/${useUserStore().empInfo.empNo}/${form.storeCode}/${uuidv4()}.png`, file.file) const pictureUrl = await uploadFileToOSSAPI(`risk/${date.getFullYear()}-${month}/longTimePicture/${useUserStore().empInfo.empNo}/${form.storeCode}/${uuidv4()}.png`, file.file)
form.longTimePictureArr.push({ form.longTimePictureArr[index] = {
url: pictureUrl url: pictureUrl,
}) status: 'done'
}
await createInspectionTaskAPI({ await createInspectionTaskAPI({
storeCode: form.storeCode, storeCode: form.storeCode,
storeName: form.storeName, storeName: form.storeName,
......
...@@ -151,7 +151,7 @@ const deleteItem = async (obj, index) => { ...@@ -151,7 +151,7 @@ const deleteItem = async (obj, index) => {
nextTick(() => { nextTick(() => {
isDeleteNow.value = false isDeleteNow.value = false
}) })
showNotify({ type: 'success', message: '删除成功' }) showNotify({ type: 'success', message: '删除分组成功' })
}) })
} }
...@@ -183,14 +183,20 @@ const handleCostChange = async (index) => { ...@@ -183,14 +183,20 @@ const handleCostChange = async (index) => {
const displayPhotosRead = async (file, { name, index }) => { const displayPhotosRead = async (file, { name, index }) => {
// name:是当前照片组件所在陈列组的索引 // name:是当前照片组件所在陈列组的索引
// index: 当前照片组的索引 // index: 当前照片组的索引
const date = new Date() const date = new Date()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
const theDate = date.getDate()
const target = displayGroup.value[name] const target = displayGroup.value[name]
const photoIndex = target.photoArr.length
target.photoArr[photoIndex] = {
url: file.content,
status: 'uploading',
message: '上传中...'
}
const pictureUrl = await uploadFileToOSSAPI(`risk/${date.getFullYear()}-${month}/displayPhoto/${useUserStore().empInfo.empNo}/${props.form.storeCode}/${uuidv4()}.png`, file.file) const pictureUrl = await uploadFileToOSSAPI(`risk/${date.getFullYear()}-${month}/displayPhoto/${useUserStore().empInfo.empNo}/${props.form.storeCode}/${uuidv4()}.png`, file.file)
target.photoArr.push({ target.photoArr[photoIndex] = {
url: pictureUrl url: pictureUrl,
}) status: 'done'
}
await createInspectionTaskDetailAPI({ await createInspectionTaskDetailAPI({
taskDetail: { taskDetail: {
...@@ -236,7 +242,7 @@ const handleOverallChange = async () => { ...@@ -236,7 +242,7 @@ const handleOverallChange = async () => {
rstId: props.form.rstId, rstId: props.form.rstId,
cgclRiskRArr: props.form.cgclRiskRArr cgclRiskRArr: props.form.cgclRiskRArr
}) })
showNotify({ type: 'success', message: '核查结果,保存成功' }) showNotify({ type: 'success', message: '总体核查结果,保存成功' })
} }
defineExpose({ defineExpose({
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
label="执行情况" label="执行情况"
placeholder="执行情况" placeholder="执行情况"
auto-complete="off" auto-complete="off"
:rules="[{ required: true, message: '请输入执行情况' }]" :rules="[{ required: true, message: '请输入执行情况' }]"
@change="handleCostChange(index)" /> @change="handleCostChange(index)" />
<van-field label="档期补差照片" <van-field label="档期补差照片"
label-align="top" label-align="top"
...@@ -150,7 +150,7 @@ const deleteItem = async (obj, index) => { ...@@ -150,7 +150,7 @@ const deleteItem = async (obj, index) => {
nextTick(() => { nextTick(() => {
isDeleteNow.value = false isDeleteNow.value = false
}) })
showNotify({ type: 'success', message: '删除成功' }) showNotify({ type: 'success', message: '删除分组成功' })
}) })
} }
/*************** 基本信息 ***************/ /*************** 基本信息 ***************/
...@@ -181,14 +181,20 @@ const handleCostChange = async (index) => { ...@@ -181,14 +181,20 @@ const handleCostChange = async (index) => {
const displayPhotosRead = async (file, { name, index }) => { const displayPhotosRead = async (file, { name, index }) => {
// name:是当前照片组件所在陈列组的索引 // name:是当前照片组件所在陈列组的索引
// index: 当前照片组的索引 // index: 当前照片组的索引
const date = new Date() const date = new Date()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
const theDate = date.getDate()
const target = displayGroup.value[name] const target = displayGroup.value[name]
const targetIndex = target.photoArr.length
target.photoArr[targetIndex] = {
url: file.content,
status: 'uploading',
message: '上传中...'
}
const pictureUrl = await uploadFileToOSSAPI(`risk/${date.getFullYear()}-${month}/scheduleAdjustmentPhoto/${useUserStore().empInfo.empNo}/${props.form.storeCode}/${uuidv4()}.png`, file.file) const pictureUrl = await uploadFileToOSSAPI(`risk/${date.getFullYear()}-${month}/scheduleAdjustmentPhoto/${useUserStore().empInfo.empNo}/${props.form.storeCode}/${uuidv4()}.png`, file.file)
target.photoArr.push({ target.photoArr[targetIndex] = {
url: pictureUrl url: pictureUrl,
}) status: 'done'
}
await createInspectionTaskDetailAPI({ await createInspectionTaskDetailAPI({
taskDetail: { taskDetail: {
...@@ -198,7 +204,7 @@ const displayPhotosRead = async (file, { name, index }) => { ...@@ -198,7 +204,7 @@ const displayPhotosRead = async (file, { name, index }) => {
} }
}) })
showNotify({ type: 'success', message: '档期陈列照片,上传成功' }) showNotify({ type: 'success', message: '档期补差照片,上传成功' })
} }
// 删除照片 // 删除照片
const deletedisplayPhotos = async (file, { name, index }) => { const deletedisplayPhotos = async (file, { name, index }) => {
...@@ -211,7 +217,7 @@ const deletedisplayPhotos = async (file, { name, index }) => { ...@@ -211,7 +217,7 @@ const deletedisplayPhotos = async (file, { name, index }) => {
photoArr: target.photoArr.map(o => o.url) photoArr: target.photoArr.map(o => o.url)
} }
}) })
showNotify({ type: 'success', message: '档期陈列照片,删除成功' }) showNotify({ type: 'success', message: '档期补差照片,删除成功' })
} }
// 核查结果 // 核查结果
const handleVerifyChange = async (index) => { const handleVerifyChange = async (index) => {
......
...@@ -150,7 +150,7 @@ const deleteItem = async (obj, index) => { ...@@ -150,7 +150,7 @@ const deleteItem = async (obj, index) => {
nextTick(() => { nextTick(() => {
isDeleteNow.value = false isDeleteNow.value = false
}) })
showNotify({ type: 'success', message: '删除成功' }) showNotify({ type: 'success', message: '删除分组成功' })
}) })
} }
/*************** 基本信息 ***************/ /*************** 基本信息 ***************/
...@@ -183,12 +183,18 @@ const displayPhotosRead = async (file, { name, index }) => { ...@@ -183,12 +183,18 @@ const displayPhotosRead = async (file, { name, index }) => {
// index: 当前照片组的索引 // index: 当前照片组的索引
const date = new Date() const date = new Date()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
const theDate = date.getDate()
const target = displayGroup.value[name] const target = displayGroup.value[name]
const targetIndex = target.photoArr.length
target.photoArr[targetIndex] = {
url: file.content,
status: 'uploading',
message: '上传中...'
}
const pictureUrl = await uploadFileToOSSAPI(`risk/${date.getFullYear()}-${month}/scheduleDisplayPhoto/${useUserStore().empInfo.empNo}/${props.form.storeCode}/${uuidv4()}.png`, file.file) const pictureUrl = await uploadFileToOSSAPI(`risk/${date.getFullYear()}-${month}/scheduleDisplayPhoto/${useUserStore().empInfo.empNo}/${props.form.storeCode}/${uuidv4()}.png`, file.file)
target.photoArr.push({ target.photoArr[targetIndex] = {
url: pictureUrl url: pictureUrl,
}) status: 'done'
}
await createInspectionTaskDetailAPI({ await createInspectionTaskDetailAPI({
taskDetail: { taskDetail: {
...@@ -234,7 +240,7 @@ const handleOverallChange = async () => { ...@@ -234,7 +240,7 @@ const handleOverallChange = async () => {
rstId: props.form.rstId, rstId: props.form.rstId,
dqclRiskRArr: props.form.dqclRiskRArr dqclRiskRArr: props.form.dqclRiskRArr
}) })
showNotify({ type: 'success', message: '核查结果,保存成功' }) showNotify({ type: 'success', message: '总体核查结果,保存成功' })
} }
defineExpose({ defineExpose({
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
</template> </template>
<script setup> <script setup>
import { uploadFileToOSSAPI } from '@/api' import { uploadFileToOSSAPI, createInspectionTaskAPI } from '@/api'
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { typeOptions as typeOption } from '@/views/mobile/constant' import { typeOptions as typeOption } from '@/views/mobile/constant'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
...@@ -92,49 +92,54 @@ const form = reactive({ ...@@ -92,49 +92,54 @@ const form = reactive({
selectedType: '' selectedType: ''
}) })
const typeOptions = ref(typeOption); // 渠道类型 const typeOptions = ref(typeOption); // 渠道类型
const showTypePopup = ref(false);
// 门头照上传逻辑 // 门头照上传逻辑
const posPhotosRead = async (file) => { const posPhotosRead = async (file) => {
form.storePicture = [
{
url: file.content,
status: 'uploading',
message: '上传中...'
}
]
const date = new Date() const date = new Date()
const month = date.getMonth() + 1 const month = date.getMonth() + 1
const theDate = date.getDate()
const pictureUrl = await uploadFileToOSSAPI(`risk/newTerminal-storePhoto/${date.getFullYear()}-${month}/${useUserStore().empInfo.empNo}/${uuidv4()}.png`, file.file) const pictureUrl = await uploadFileToOSSAPI(`risk/newTerminal-storePhoto/${date.getFullYear()}-${month}/${useUserStore().empInfo.empNo}/${uuidv4()}.png`, file.file)
form.storePicture = [{ form.storePicture = [{
url: pictureUrl url: pictureUrl,
status: 'done'
}] }]
showNotify({ type: 'success', message: '照片上传成功' }) showNotify({ type: 'success', message: '照片上传成功' })
} }
// 删除照片 // 删除照片
const deletePosPhotos = async () => { const deletePosPhotos = async () => {
form.storePicture = [] form.storePicture = []
showNotify({ type: 'success', message: '照片删除成功' }) showNotify({ type: 'success', message: '照片删除成功' })
} }
// 确认渠道类型
// const handleTypeConfirm = ({ selectedValues }) => {
// form.selectedType = selectedValues;
// showTypePopup.value = false;
// };
// 创建任务(跳转路由传参即可) // 创建任务(跳转路由传参即可)
const myFormRef = ref(null) const myFormRef = ref(null)
const handleCreateTask = () => { const handleCreateTask = () => {
// 校验整个表单 // 校验整个表单
myFormRef.value.validate().then(() => { myFormRef.value.validate().then(async () => {
// 校验通过,执行创建任务逻辑 const res = await createInspectionTaskAPI({
storeName: form.storeName,
storePicture: form.storePicture[0]?.url,
selectedType: form.selectedType
})
// 校验通过,跳到稽查任务详情页
router.push({ router.push({
path: '/inspectionTask', path: '/inspectionTask',
query: { query: {
taskStatus: true, rstId: res.data.rstId,
storeName: form.storeName, storeName: form.storeName,
storePicture: form.storePicture[0]?.url, storePicture: form.storePicture[0]?.url,
selectedType: form.selectedType selectedType: form.selectedType
} }
}) })
}) })
}; }
</script> </script>
<style lang="scss" <style lang="scss"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论