货无忧安装平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

594 lines
13 KiB

10 months ago
<template>
9 months ago
<BasicContainer ref="basicContainer" :option="option">
10 months ago
<!-- 头部 -->
9 months ago
<template #head></template>
10 months ago
<!-- 主体 -->
<template #body>
<view class="main">
9 months ago
<scroll-view class="scvmabx" :style="{height: details.scrollheight}" @scrolltolower="() => {}"
scroll-y="true" @touchmove.stop>
10 months ago
<template v-if="details.pageType === 'install'">
9 months ago
<block v-for="(item, index) in details.pageArr" :key="item.title">
10 months ago
<view :class="{mt20: index !== 0}" v-if="item.list.length > 0">
<PullDownBox ref="imgPullDownRefList">
<template #title>
<view class="server_list_container_header">
<view class="row flex-c-sb border-none">
<view class="title">
9 months ago
{{ item.title }}
10 months ago
</view>
</view>
10 months ago
</view>
10 months ago
</template>
<template #content>
<view class="server_list_container_info">
<block v-for="(val, i) in item.list">
9 months ago
<view :class="{info_item: true, mt20: i !== 0}">
10 months ago
<view class="title info_item_title flex-c-sb">
<view class="flex-c-c">
<view class="fwb mr20">
<text>
9 months ago
{{ item.title + ' - ' }}
10 months ago
</text>
<text>
9 months ago
{{ i + 1 }}
10 months ago
</text>
</view>
10 months ago
</view>
</view>
10 months ago
<view class="info_item_container imgList flex">
<block v-for="(value, j) in val.imgList">
<!-- 单个图片 -->
<view class="image_conatiner mr20 mb20">
<view class="">
<image :src="value.url" mode=""></image>
</view>
</view>
</block>
</view>
10 months ago
</view>
10 months ago
</block>
</view>
</template>
</PullDownBox>
</view>
</block>
</template>
10 months ago
10 months ago
<template v-else>
<view class="row pr20 pl20 pt20">
<view class="info_item_container imgList flex">
<block v-for="(value, j) in details.imgList">
<!-- 单个图片 -->
<view class="image_conatiner mr20 mb20">
<view class="">
<image :src="value.url" mode=""></image>
</view>
10 months ago
</view>
10 months ago
</block>
</view>
</view>
<view class="row pr20 pl20 pb20 flex">
<text>完结备注</text>
9 months ago
<text>{{ details.form.remark }}</text>
10 months ago
</view>
10 months ago
</template>
10 months ago
9 months ago
<!-- <view class="pd20 mt20 row">
10 months ago
<view class="mb20">验收备注</view>
<u-textarea v-model="details.form.reason" placeholder="请输入"></u-textarea>
9 months ago
</view> -->
10 months ago
</scroll-view>
<view class="footer">
9 months ago
<view class="button" @click="() => handleSubmit(0)"> </view>
10 months ago
9 months ago
<view class="button subColor" @click="() => handleSubmit(1)"> </view>
10 months ago
</view>
</view>
</template>
</BasicContainer>
<tips ref="tip" />
9 months ago
<PopUp ref="checkPopUpRef">
<view class="pd20 mt20 row">
9 months ago
<!-- 验收图片 -->
<view class="mb20">
验收图片
</view>
<view class="flex imgList mb20">
<!-- 单个图片 -->
<block v-for="(item, index) in details.checkAndAcceptImgList" :key="item">
<view class="image_conatiner mr20 pd20">
<image :src="item.url" mode=""></image>
<!-- 删除 -->
<view class="removeIcon" @click="()=> handleRmove(index)">
<u-icon name="close-circle-fill" color="#666" size="50"></u-icon>
</view>
</view>
</block>
<!-- 添加图片 -->
<view class="image_conatiner addImg flex-c-c" @click="handleUploadFile">
<u-icon name="photo-fill" color="#999" size="100"></u-icon>
</view>
</view>
<!-- 备注 -->
9 months ago
<view class="mb20">验收备注</view>
<u-textarea v-model="details.form.reason" placeholder="请输入"></u-textarea>
</view>
</PopUp>
10 months ago
<!-- #ifdef APP -->
<!-- <saomiao2 :ishidestop="scanState !== 0"></saomiao2> -->
<!-- #endif -->
</template>
<script lang="ts" setup>
import {
postInstallSalesAcceptance,
postInstallAcceptance,
9 months ago
postInstallWorkingInfo,
10 months ago
} from '@/api/user.js'
9 months ago
import { onLoad, onShow, onHide, onUnload } from '@dcloudio/uni-app'
import { nextTick, reactive, ref, toRefs } from 'vue'
10 months ago
import utils from '@/utils/utils.js'
// import useSystemSettingsStore from '@/store/useSystemSettingsStore';
// import { storeToRefs } from 'pinia';
// const { scanState } = storeToRefs(useSystemSettingsStore())
// 组件实例
const basicContainer = ref()
const tip = ref()
const imgPullDownRefList = ref()
9 months ago
const checkPopUpRef = ref()
10 months ago
let details = reactive({
/** 扫描的码值 */
scancode: '',
scrollheight: '80vh',
form: {
10 months ago
/** 完结描述 */
remark: '',
10 months ago
/** 结果描述 */
9 months ago
reason: '',
10 months ago
},
/** 页面类型 -- install: 安装; installSales: 售后 */
pageType: 'install' as 'install' | 'installSales',
/** 页面信息 */
pageInfo: {
// 安装任务Id
install_id: '',
// 安装售后id
9 months ago
install_sales_id: '',
10 months ago
},
pageArr: [
{
title: '客厅',
prop: 'parlor',
tag: '1',
9 months ago
list: [],
10 months ago
},
{
title: '卧室',
tag: '2',
9 months ago
list: [],
10 months ago
},
{
title: '厨房',
prop: 'kitchen',
tag: '3',
9 months ago
list: [],
10 months ago
},
{
title: '卫生间',
prop: 'toilet',
tag: '4',
9 months ago
list: [],
10 months ago
},
{
title: '书房',
prop: 'study',
tag: '5',
9 months ago
list: [],
10 months ago
},
{
title: '阳台',
prop: 'balcony',
tag: '6',
9 months ago
list: [],
10 months ago
},
{
title: '其它',
tag: '7',
prop: 'other',
9 months ago
list: [],
},
10 months ago
],
10 months ago
imgList: [],
9 months ago
renderArr: [],
9 months ago
/** 验收图片 */
checkAndAcceptImgList: []
10 months ago
})
// 组件配置
const option = reactive({
// 标题
title: details.pageType === 'install' ? '安装验收' : '售后验收',
// 下拉刷新回调函数
async pullDownRefreshInitPage() {
return null
},
// 触底加载回到函数
9 months ago
reachBottomInitPage: async () => {
return null
},
10 months ago
haveData: true,
isEnd: false,
pageLoading: false,
})
9 months ago
onLoad(e => {
console.log('e :>> ', e)
10 months ago
details.pageType = e.pageType
9 months ago
details.pageType === 'install'
? (details.pageInfo.install_id = e.id)
: (details.pageInfo.install_sales_id = e.id)
10 months ago
10 months ago
if (details.pageType === 'install') initpage()
else if (details.pageType === 'installSales') {
9 months ago
const _info = uni.getStorageSync('installWork') || {}
console.log('_info :>> ', _info)
10 months ago
details.form.remark = _info.remark
details.imgList = _info.images
}
})
onUnload(() => {
uni.removeStorageSync('installWork')
10 months ago
})
onShow(async () => {
// // #ifdef APP
// // 初始化关闭监听
// uni.$off('scancodedate')
// // init()
// uni.$on('scancodedate', function (code) {
// console.log('code :>> ', code);
// if (code) {
// console.log(code);
// details.scancode = code
// scandata()
// }
// })
// // #endif
await nextTick()
// basicContainer.value.startPullDownRefresh()
const _height = await utils.getViewDistanceFormTop('.scvmabx')
details.scrollheight = Number(_height.replace('px', '')) - 100 + 'px'
10 months ago
})
const scandata = () => { }
9 months ago
/** 初始化获取数据 */
10 months ago
const initpage = async () => {
try {
option.pageLoading = true
const res = await postInstallWorkingInfo({ install_id: details.pageInfo.install_id })
const { code, data } = res
if (code !== 200) return
9 months ago
console.log('data :>> ', data)
10 months ago
if (utils.getObjType(data) !== 'object') return
const { reamrk, workImages } = data
details.form.remark = reamrk
if (utils.getObjType(workImages) !== 'array') return
for (let i = 0; i < workImages.length; i++) {
const value = workImages[i]
let _item
for (let i = 0; i < details.pageArr.length; i++) {
const _value = details.pageArr[i]
9 months ago
if (_value.tag !== value.room_tag + '') continue
10 months ago
_item = _value
break
}
if (!_item) continue
9 months ago
console.log('_item :>> ', _item)
10 months ago
const _index = Number(value.room_name.split(' - ')[1]) - 1
_item.list.splice(_index, 1, {
...value,
9 months ago
imgList: value.images,
10 months ago
})
}
} catch (err) {
9 months ago
console.log('err :>> ', err)
10 months ago
//TODO handle the exception
} finally {
await nextTick()
const timer = setTimeout(() => {
9 months ago
console.log('imgPullDownRefList.value :>> ', imgPullDownRefList.value)
10 months ago
if (utils.getObjType(imgPullDownRefList.value) !== 'array') return
for (let iterator of imgPullDownRefList.value) {
9 months ago
console.log('iterator :>> ', iterator)
10 months ago
iterator.handleShowPullDown && iterator.handleShowPullDown(true)
}
clearTimeout(timer)
}, 100)
option.pageLoading = false
}
}
9 months ago
/** 上传验收图片 */
/** 上传文件 */
const handleUploadFile = () => {
const successByUpload = (res) => {
console.log('res :>> ', res);
const { data } = res
const _data = JSON.parse(data)
console.log('_data :>> ', _data);
const { code, data: img } = _data
details.checkAndAcceptImgList.push({ url: img, name: img })
}
utils.handleUploadFile({
successByUpload
})
}
/** 移除图片 */
const handleRmove = (index) => {
tip.value.setdetails({
isshow: true,
content: '确认移除',
cancelTxt: '取消',
confirmTxt: '确认',
success() {
details.imgList.splice(index, 1)
// 关闭弹窗
tip.value.setdetails({ isshow: false })
},
cancel() {
// 关闭弹窗
tip.value.setdetails({ isshow: false })
}
})
}
10 months ago
/**
* 提交
* @param {number} result 结果 1 -- 通过, 0 -- 驳回
9 months ago
*/
10 months ago
const handleSubmit = (result : 0 | 1) => {
9 months ago
console.log('result :>> ', result)
10 months ago
9 months ago
checkPopUpRef.value.setDetails({
showPopUp: true,
title: '确认' + (result === 0 ? '驳回' : '通过'),
10 months ago
async success() {
9 months ago
if (result === 0 && details.checkAndAcceptImgList.length === 0) return utils.handleToast('最少上传一张驳回图片')
9 months ago
if (result === 0 && !details.form.reason) return utils.handleToast('请输入驳回原因')
10 months ago
try {
option.pageLoading = true
const submitData : {
// 验收或驳回
9 months ago
result : number
10 months ago
// 验收意见
9 months ago
reason : string
10 months ago
// 安装任务id
install_id ?: string
// 安装售后id
install_sales_id ?: string
9 months ago
// 验收图片
images : { url : string, name : string }[]
10 months ago
} = {
result,
9 months ago
reason: details.form.reason,
9 months ago
images: details.checkAndAcceptImgList
10 months ago
}
9 months ago
details.pageType === 'install'
? (submitData.install_id = details.pageInfo.install_id)
: (submitData.install_sales_id = details.pageInfo.install_sales_id)
10 months ago
const res =
9 months ago
details.pageType === 'install'
? // 安装验收
await postInstallAcceptance(submitData)
: // 售后验收
10 months ago
await postInstallSalesAcceptance(submitData)
const { code, data } = res
if (code !== 200) return
uni.navigateBack()
} catch (err) {
9 months ago
console.log('err :>> ', err)
10 months ago
//TODO handle the exception
} finally {
option.pageLoading = false
// 关闭弹窗
tip.value.setdetails({ isshow: false })
}
},
})
}
</script>
<style lang="scss" scoped>
9 months ago
@import url('@/utils/style/common.scss');
10 months ago
// 主体内容
.main {
position: relative;
border-top-right-radius: 20upx;
border-top-left-radius: 20upx;
background-color: #fff;
.scvmabx {
9 months ago
background-color: #f5f5f6;
10 months ago
:deep(.Pulldown-title-container) {
padding: 20upx;
}
:deep(.Pulldown_content) {
padding: 20upx;
padding-bottom: 0;
9 months ago
background: #f5f5f6;
10 months ago
}
:deep(.PullDownBox) {
border-radius: 0;
}
}
.info_item {
border-radius: 20upx;
overflow: hidden;
.info_item_title {
background-color: var(--subjectColor);
color: #fff;
padding: 25upx 20upx;
}
.info_item_container {
background-color: #fff;
padding: 20upx;
padding-bottom: 0upx;
}
}
.addBtn {
9 months ago
color: #2f8dff;
10 months ago
}
// 图片列表
9 months ago
// .imgList {
// flex-wrap: wrap;
// image {
// width: 160upx;
// height: 160upx;
// border-radius: 20upx;
// }
// }
}
10 months ago
9 months ago
// 图片列表
.imgList {
flex-wrap: wrap;
.image_conatiner {
position: relative;
.removeIcon {
position: absolute;
top: 0;
right: 0;
transform: translate(40%, -40%);
opacity: 0.9;
10 months ago
}
}
9 months ago
.addImg {
width: 160upx;
height: 160upx;
border-radius: 20upx;
box-sizing: border-box;
border: 2upx solid #eee;
}
image {
width: 160upx;
height: 160upx;
border-radius: 20upx;
}
10 months ago
}
// 底部
.footer {
box-sizing: border-box;
height: 100px;
padding-top: 30upx;
display: flex;
justify-content: space-between;
10 months ago
.button {
height: 80upx;
10 months ago
display: flex;
align-items: center;
justify-content: center;
flex: 1;
// margin: 10upx;
border: 2upx solid #b5babf;
border-radius: 80upx;
margin: 0 10upx;
padding: 0 10upx;
font-size: 0.9rem;
font-weight: bold;
10 months ago
&.subColor {
// border-color: var(--subjectColor);
// color: var(--subjectColor);
background-color: var(--subjectColor);
color: #fff;
border: none;
}
&.primaryColor {
// border-color: var(--primaryColor);
// color: var(--primaryColor);
background-color: var(--primaryColor);
color: #fff;
border: none;
}
&.errColor {
// border-color: var(--errColor);
// color: var(--errColor);
background-color: var(--errColor);
color: #fff;
border: none;
10 months ago
}
}
}
10 months ago
.row {
background-color: #fff;
}
</style>