Files
hazardousWaste_app/pages/warehousing/StockOut/components/technicalEvaluation.vue

176 lines
5.2 KiB
Vue
Raw Normal View History

2026-04-14 08:46:29 +08:00
<template>
<navigation title="技术鉴定表详情" :back-url="backUrl">
<template #right>
2026-04-23 14:35:54 +08:00
<my-link @tap="toMyTechnicalList" style="font-size: 14px;">我的</my-link>
2026-04-14 08:46:29 +08:00
</template>
</navigation>
<view class="contentBox">
<uv-form labelPosition="top" :model="formModel" class="technicalForm" ref="technicalEvaluationRef"
labelWidth="auto">
<uv-form-item label="技术鉴定表" prop="fileList" style="margin-top: 16rpx;">
<uv-upload :fileList="formModel?.fileList" name="1" multiple :maxCount="6" @afterRead="afterRead"
@delete="deleteImg" :previewFullImage="true"></uv-upload>
</uv-form-item>
<uv-form-item label="技术鉴定表备注说明" prop="remark" style="margin-top: 16rpx;">
<uv-textarea v-model="formModel.remark" placeholder="请输入技术鉴定表备注说明..." border="none"></uv-textarea>
</uv-form-item>
</uv-form>
<view class="bottom">
2026-04-23 14:35:54 +08:00
<uv-button type="primary" v-if="!formModel?.appraisalNo" @tap="submitForm">提交信息</uv-button>
<uv-button type="error" v-else @tap="delForm">删除</uv-button>
2026-04-14 08:46:29 +08:00
</view>
</view>
</template>
<script setup>
import { ref } from 'vue';
import { onLoad } from "@dcloudio/uni-app";
import { objectToQuery } from '../../../until';
import Navigation from '../../../components/Navigation.vue';
2026-04-23 14:35:54 +08:00
import { uploadTechnicalFile, addWithFiles, deleteAppraisal } from '@/api/stockOut'
2026-04-14 08:46:29 +08:00
import _ from 'lodash';
const queryParams = ref('')
const formModel = ref({
billNo: null,
remark: '',
2026-04-23 14:35:54 +08:00
appraisalNo: '',
id: '',
2026-04-14 08:46:29 +08:00
fileList: [],
})
const backUrl = ref('')
const afterRead = async (event) => {
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
console.log(event, '上传')
let files = event.file?.map(file => file.url);
let formData = {
scene: 'OUTBOUND',
bizType: 'TECHNICAL_APPRAISAL',
}
uploadTechnicalFile(files, formData).then(res => {
const some = _.some(res, { success: false })
2026-04-23 14:35:54 +08:00
console.log(some, '上传接口调取成功', res)
2026-04-14 08:46:29 +08:00
if (some) return;
if (!formModel.value.fileList || formModel.value.fileList.length == 0) {
formModel.value.fileList = []
}
2026-04-23 14:35:54 +08:00
res?.forEach(item => {
2026-04-14 08:46:29 +08:00
formModel.value.fileList.push({ url: item?.url, name: item?.name, scene: 'OUTBOUND', bizType: 'TECHNICAL_APPRAISAL' })
})
})
}
// 删除图片
const deleteImg = (index, type) => {
formModel.value.fileList?.splice(index, 1)
}
// 提交
const submitForm = () => {
2026-04-23 14:35:54 +08:00
const params = {
remark: formModel.value.remark,
billNo: queryParams.value.billNo,
fileList: formModel.value.fileList,
}
addWithFiles(params).then((res) => {
2026-04-14 08:46:29 +08:00
if (res.code == 200) {
console.log(res.data);
2026-04-23 14:35:54 +08:00
uni.setStorageSync('app_technical', {
remark: res.data?.remark,
appraisalNo: res.data.appraisalNo,
id: res.data.id,
createTime: res.data.createTime,
fileList: res.data?.fileUrlList || [],
});
uni.navigateTo({
url: backUrl.value
});
2026-04-14 08:46:29 +08:00
}
})
}
2026-04-23 14:35:54 +08:00
const delForm = () => {
deleteAppraisal({ id: formModel.value?.id }).then((res) => {
console.log(res, '删除');
formModel.value = {
billNo: null,
remark: '',
appraisalNo: '',
id: '',
fileList: [],
}
uni.removeStorageSync("app_technical");
})
}
// 数据:获取缓存信息
const getMaterialList = () => {
// 获取技术鉴定表数据
const list = uni.getStorageSync('app_technical') || {};
formModel.value = list
}
getMaterialList()
2026-04-14 08:46:29 +08:00
// 数据:路径参数
onLoad((options) => {
const query = objectToQuery(options)
queryParams.value = options
backUrl.value = `/pages/warehousing/stockOut/components/outAway${query}`
})
const toMyTechnicalList = () => {
const query = objectToQuery(queryParams.value)
uni.navigateTo({
url: `/pages/warehousing/stockOut/components/myTechnicalEvaluation${query}`
});
}
// 获取技术鉴定编数据
const getTechnicalList = () => {
const list = uni.getStorageSync('app_technical');
2026-04-23 14:35:54 +08:00
formModel.value.fileList = list?.fileList || []
2026-04-14 08:46:29 +08:00
formModel.value.remark = list?.remark
}
getTechnicalList()
</script>
<style scoped lang="scss">
::v-deep.technicalForm {
.uv-form-item {
background-color: #fff;
padding: 0 24rpx;
}
.uv-form-item__body__left__content__label {
margin-bottom: 8px;
}
.uv-form-item__body {
background-color: #fff;
padding: 12rpx;
margin-bottom: 2rpx;
}
.uv-textarea {
padding: 0;
}
}
/* 底部按钮 */
::v-deep .bottom {
position: fixed;
bottom: 0;
height: 60rpx;
font-size: 14px;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
.uv-button-wrapper {
width: 100%;
border-radius: 0;
}
.uv-button--info {
background-color: #07c160;
color: #fff;
}
}
</style>