优化:

1、取消新增报告时,我方领导必填项
This commit is contained in:
wangyang
2025-08-13 10:43:37 +08:00
parent b46899331f
commit a6ee6db40d
4 changed files with 196 additions and 195 deletions

View File

@@ -1,67 +1,66 @@
<template> <template>
<uni-forms ref="formRef" :model="formData" label-width="100px" label-position="top"> <uni-forms ref="formRef" :model="formData" label-width="100px" label-position="top">
<uni-forms-item label="客户人员" name="customerUserList" class="f-c-right"> <uni-forms-item label="客户人员" name="customerUserList" class="f-c-right">
<uni-easyinput v-model="formData.customerUserList" placeholder="请选择客户人员" name="input" <uni-easyinput v-model="formData.customerUserList" placeholder="请选择客户人员" name="input"
:disabled="isDisabled" :disabled="isDisabled"
@focus="chooseClientUser"></uni-easyinput> @focus="chooseClientUser"></uni-easyinput>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="我方参与人" name="myUserList" class="f-c-right"> <uni-forms-item label="我方参与人" name="myUserList" class="f-c-right">
<uni-easyinput v-model="formData.myUserList" placeholder="请选择我方参与人" name="input" <uni-easyinput v-model="formData.myUserList" placeholder="请选择我方参与人" name="input"
:disabled="isDisabled" :disabled="isDisabled"
@focus="chooseMyUser"></uni-easyinput> @focus="chooseMyUser"></uni-easyinput>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="住宿天数" name="stayDays"> <uni-forms-item label="住宿天数" name="stayDays">
<picker <picker
@change="handlePickerChange" @change="handlePickerChange"
:value="stayDaysIndex" :value="stayDaysIndex"
:range="stayDaysOptions" :range="stayDaysOptions"
:disabled="isDisabled" :disabled="isDisabled"
> >
<view class="picker-container"> <view class="picker-container">
<view class="picker-display"> <view class="picker-display">
{{ stayDaysOptions[stayDaysIndex] }} {{ stayDaysOptions[stayDaysIndex] }}
</view>
<uni-icons type="arrowdown" size="16" color="#666"></uni-icons>
</view> </view>
<uni-icons type="arrowdown" size="16" color="#666"></uni-icons> </picker>
</view> </uni-forms-item>
</picker>
</uni-forms-item>
<uni-forms-item label="活动文字" name="activeTxt" class="uni-forms-item is-direction-top is-top"> <uni-forms-item label="活动文字" name="activeTxt" class="uni-forms-item is-direction-top is-top">
<uni-easyinput type="textarea" autoHeight v-model="formData.activeTxt" placeholder="请输入" 活动文字 <uni-easyinput type="textarea" autoHeight v-model="formData.activeTxt" placeholder="请输入" 活动文字
class="form-texarea" /> class="form-texarea"/>
</uni-forms-item> </uni-forms-item>
</uni-forms> </uni-forms>
<view class="footer-con"> <view class="footer-con">
<button class="btn-default" type="default" @click="handleDeleteVisistDetailItem" size="mini"> </button> <button class="btn-default" type="default" @click="handleDeleteVisistDetailItem" size="mini"> </button>
<button class="btn-primary" type="primary" @click="submitForm" size="mini">保存/修改</button> <button class="btn-primary" type="primary" @click="submitForm" size="mini">保存/修改</button>
</view> </view>
</template> </template>
<script setup name="lyVisitComponent"> <script setup name="lyVisitComponent">
import { ref, reactive } from 'vue' import {ref, reactive} from 'vue'
import cache from '../../../../../utils/cache' import cache from '../../../../../utils/cache'
import { onShow, onUnload } from '@dcloudio/uni-app'; import {onShow, onUnload} from '@dcloudio/uni-app';
import { addVisistDetail, deleVisistDetailItem, getVisistDetailItem } from '../../../../../api/crm/activity/activity'; import {addVisistDetail, deleVisistDetailItem, getVisistDetailItem} from '../../../../../api/crm/activity/activity';
let customerUserList = ref([]) let customerUserList = ref([])
let myUserList = ref([]) let myUserList = ref([])
let activeTxt = ref('') let activeTxt = ref('')
let isDisabled = ref(false) let isDisabled = ref(false)
const props = defineProps({ const props = defineProps({
cusName: String, //客户单位名称 cusName: String, //客户单位名称
cusId: Number,//客户ID cusId: Number,//客户ID
visistId: Number,//活动ID visistId: Number,//活动ID
status: String //状态 status: String //状态
}) })
// 表单数据 // 表单数据
const formData = ref({ const formData = ref({
customerUserList, customerUserList,
myUserList, myUserList,
activeTxt activeTxt
}); });
// 表单ref // 表单ref
@@ -69,150 +68,151 @@ const formRef = ref(null);
//删除明细项的内容 //删除明细项的内容
let lyDeleteForm = reactive({}) let lyDeleteForm = reactive({})
function handleDeleteVisistDetailItem() { function handleDeleteVisistDetailItem() {
lyDeleteForm.treeName = '联谊活动' lyDeleteForm.treeName = '联谊活动'
lyDeleteForm.visistId = props.visistId lyDeleteForm.visistId = props.visistId
deleVisistDetailItem(lyDeleteForm).then(res => { deleVisistDetailItem(lyDeleteForm).then(res => {
if (res.code == 200) { if (res.code == 200) {
uni.showToast({ uni.showToast({
title: '删除成功', title: '删除成功',
duration: 2000 duration: 2000
}); });
//响应成功,删除缓存记录 //响应成功,删除缓存记录
handleDelete() handleDelete()
} else { } else {
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,
icon: 'none', icon: 'none',
}); });
} }
}) })
} }
// 删除内容 // 删除内容
let handleDelete = () => { let handleDelete = () => {
formData.value.customerUserList = null formData.value.customerUserList = null
formData.value.myUserList = null formData.value.myUserList = null
formData.value.activeTxt = null formData.value.activeTxt = null
if (cache.get('checkedLYClientList') != null) { stayDaysIndex.value = 0
cache.remove('checkedYWClientList'); if (cache.get('checkedLYClientList') != null) {
} cache.remove('checkedYWClientList');
if (cache.get('checkedLYMyUserList') != null) { }
cache.remove('checkedLYMyUserList'); if (cache.get('checkedLYMyUserList') != null) {
} cache.remove('checkedLYMyUserList');
}
} }
//删除缓存 //删除缓存
let handleDeleteLocal = () => { let handleDeleteLocal = () => {
cache.remove('checkedLYClientList'); cache.remove('checkedLYClientList');
cache.remove('checkedLYMyUserList'); cache.remove('checkedLYMyUserList');
} }
let lyForm = reactive({}) let lyForm = reactive({})
// 保存/修改 // 保存/修改
const submitForm = async () => { const submitForm = async () => {
try { try {
// 验证表单 // 验证表单
await formRef.value.validate(); await formRef.value.validate();
// 验证通过后的操作 // 验证通过后的操作
uni.showToast({ uni.showToast({
title: '验证通过', title: '验证通过',
icon: 'success' icon: 'success'
}); });
lyForm.treeName = '联谊活动' lyForm.treeName = '联谊活动'
lyForm.cusId = props.cusId lyForm.cusId = props.cusId
lyForm.visistId = props.visistId lyForm.visistId = props.visistId
if (Array.isArray(myUserList.value)) { if (Array.isArray(myUserList.value)) {
lyForm.ourPersonnel = myUserList.value.join(',') lyForm.ourPersonnel = myUserList.value.join(',')
} else { } else {
lyForm.ourPersonnel = myUserList.value lyForm.ourPersonnel = myUserList.value
}
if (Array.isArray(customerUserList.value)) {
lyForm.cusPersonnel = customerUserList.value.join(',')
} else {
lyForm.cusPersonnel = customerUserList.value
}
lyForm.bandResult = activeTxt.value
lyForm.multiple = stayDaysIndex.value+1
// 提交服务器进行新增
addVisistDetail(lyForm).then(res => {
if (res.code == 200) {
uni.showToast({
title: '提交成功',
duration: 2000
});
//响应成功,删除缓存记录
handleDeleteLocal()
} else {
uni.showToast({
title: res.msg,
icon: 'none',
});
}
})
} catch (err) {
console.log('表单验证失败:', err);
} }
if (Array.isArray(customerUserList.value)) {
lyForm.cusPersonnel = customerUserList.value.join(',')
} else {
lyForm.cusPersonnel = customerUserList.value
}
lyForm.bandResult = activeTxt.value
lyForm.multiple = stayDaysIndex.value + 1
// 提交服务器进行新增
addVisistDetail(lyForm).then(res => {
if (res.code == 200) {
uni.showToast({
title: '提交成功',
duration: 2000
});
//响应成功,删除缓存记录
handleDeleteLocal()
} else {
uni.showToast({
title: res.msg,
icon: 'none',
});
}
})
} catch (err) {
console.log('表单验证失败:', err);
}
}; };
//页面渲染完成后查询catch的get //页面渲染完成后查询catch的get
onShow(() => { onShow(() => {
if (cache.get('checkedLYClientList') != null && cache.get('checkedLYClientList') != []) { if (cache.get('checkedLYClientList') != null && cache.get('checkedLYClientList') != []) {
customerUserList.value = cache.get('checkedLYClientList') customerUserList.value = cache.get('checkedLYClientList')
} }
if (cache.get('checkedLYMyUserList') != null && cache.get('checkedLYMyUserList') != []) { if (cache.get('checkedLYMyUserList') != null && cache.get('checkedLYMyUserList') != []) {
myUserList.value = cache.get('checkedLYMyUserList') myUserList.value = cache.get('checkedLYMyUserList')
} }
console.log(props.status,'获取的状态') console.log(props.status, '获取的状态')
if(props.status=='完成'){ if (props.status == '完成') {
isDisabled.value = true isDisabled.value = true
}else{ } else {
isDisabled.value = false isDisabled.value = false
} }
}) })
//查询日常走访的内容 //查询日常走访的内容
let queryLYForm = reactive({}) let queryLYForm = reactive({})
let getLYVisitReportDetailContent = () => { let getLYVisitReportDetailContent = () => {
queryLYForm.visistId = props.visistId queryLYForm.visistId = props.visistId
queryLYForm.cusId = props.cusId queryLYForm.cusId = props.cusId
queryLYForm.treeName = '联谊活动' queryLYForm.treeName = '联谊活动'
getVisistDetailItem(queryLYForm).then(res => { getVisistDetailItem(queryLYForm).then(res => {
if (res.rows[0] != null) { if (res.rows[0] != null) {
customerUserList.value = res.rows[0].customerPersonnel customerUserList.value = res.rows[0].customerPersonnel
myUserList.value = res.rows[0].ourPersonnel myUserList.value = res.rows[0].ourPersonnel
stayDaysIndex.value = res.rows[0].multiple-1 stayDaysIndex.value = res.rows[0].multiple - 1
activeTxt.value = res.rows[0].bandResult activeTxt.value = res.rows[0].bandResult
} }
}) })
} }
//页面卸载之后,删除缓存信息 //页面卸载之后,删除缓存信息
onUnload(() => { onUnload(() => {
handleDeleteLocal() handleDeleteLocal()
}) })
//选择客户人员 //选择客户人员
function chooseClientUser() { function chooseClientUser() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/business/CRM/marketActivity/customerUserList?cusName=' + props.cusName + '&chooseType=联谊活动' url: '/pages/business/CRM/marketActivity/customerUserList?cusName=' + props.cusName + '&chooseType=联谊活动'
}) })
} }
//选择我方参与人 //选择我方参与人
function chooseMyUser() { function chooseMyUser() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/business/CRM/marketActivity/myUserList?chooseType=联谊活动' url: '/pages/business/CRM/marketActivity/myUserList?chooseType=联谊活动'
}) })
} }
// 住宿天数 // 住宿天数
@@ -221,13 +221,13 @@ const stayDaysIndex = ref(0) // 默认未选择
const handlePickerChange = (e) => { const handlePickerChange = (e) => {
stayDaysIndex.value = e.detail.value stayDaysIndex.value = e.detail.value
console.log("天数数字:",stayDaysIndex.value+1) console.log("天数数字:", stayDaysIndex.value + 1)
} }
// 明确暴露给父组件的方法 // 明确暴露给父组件的方法
defineExpose({ defineExpose({
handleDelete, handleDelete,
getLYVisitReportDetailContent getLYVisitReportDetailContent
}) })
</script> </script>
@@ -235,55 +235,55 @@ defineExpose({
<style scoped lang="scss"> <style scoped lang="scss">
.all-body { .all-body {
/* #ifdef APP-PLUS */ /* #ifdef APP-PLUS */
top: 150rpx; top: 150rpx;
height: calc(100vh - 75px); height: calc(100vh - 75px);
/* #endif */ /* #endif */
/* #ifndef APP-PLUS */ /* #ifndef APP-PLUS */
top: 120rpx; top: 120rpx;
height: calc(100vh); height: calc(100vh);
/* #endif */ /* #endif */
} }
.search { .search {
display: flex; display: flex;
} }
.search .btn-search { .search .btn-search {
border: none; border: none;
background: none; background: none;
line-height: normal; line-height: normal;
color: #fff; color: #fff;
line-height: 56rpx !important; line-height: 56rpx !important;
padding: 10rpx 0 0; padding: 10rpx 0 0;
text-align: left; text-align: left;
cursor: pointer; cursor: pointer;
} }
.search .btn-search::after { .search .btn-search::after {
display: none; display: none;
} }
.search .custom-search { .search .custom-search {
width: 80%; width: 80%;
} }
.search .custom-search.uni-searchbar { .search .custom-search.uni-searchbar {
padding-right: 0 !important; padding-right: 0 !important;
} }
.scroll-h { .scroll-h {
/* #ifdef APP-PLUS */ /* #ifdef APP-PLUS */
height: calc(100vh - 120px); height: calc(100vh - 120px);
/* #endif */ /* #endif */
/* #ifndef APP-PLUS */ /* #ifndef APP-PLUS */
height: calc(100vh - 110px); height: calc(100vh - 110px);
/* #endif */ /* #endif */
} }
.white-bg { .white-bg {
padding-bottom: 10rpx; padding-bottom: 10rpx;
} }
.picker-container { .picker-container {

View File

@@ -80,9 +80,9 @@
</view> </view>
</block> </block>
<!-- 评论 --> <!-- 评论 -->
<block v-if="activeTab === 1"> <!-- <block v-if="activeTab === 1">-->
<view class="white-bg white-bg-2">评论内容</view> <!-- <view class="white-bg white-bg-2">评论内容</view>-->
</block> <!-- </block>-->
</customTabs> </customTabs>
@@ -139,7 +139,7 @@ const getVisitorReportDetail = async () => {
// 报告明细&评论 // 报告明细&评论
const activeTab = ref(0);//默认报告明细 const activeTab = ref(0);//默认报告明细
const tabList = ['报告明细', '评论']; const tabList = ['报告明细'];
// 点击赞 // 点击赞
let zanFlag = ref(false) let zanFlag = ref(false)

View File

@@ -71,7 +71,11 @@ import { ref, reactive, onMounted } from 'vue'
import MescrollUni from 'mescroll-uni/mescroll-uni.vue'; import MescrollUni from 'mescroll-uni/mescroll-uni.vue';
import { getNavBarPaddingTop } from '@/utils/system.js' import { getNavBarPaddingTop } from '@/utils/system.js'
import { getQueryVisistList } from '../../../../api/crm/activity/activity'; import { getQueryVisistList } from '../../../../api/crm/activity/activity';
import {onShow} from "@dcloudio/uni-app";
onShow(()=>{
downCallback(mescrollRef.value.mescroll)
})
let list = ref([]) let list = ref([])
let queryParams = reactive({ let queryParams = reactive({
@@ -118,17 +122,22 @@ const downCallback = async (mescroll) => {
const upCallback = async (mescroll) => { const upCallback = async (mescroll) => {
try { try {
setTimeout(async () => { setTimeout(async () => {
// const res = await getVisitorReportList(mescroll.num, mescroll.size); queryParams.pageNum = 1;
queryParams.pageSize = upOption.value.page.size;
const res = await getQueryVisistList(queryParams);
if (mescroll.num === 1) { if (mescroll.num === 1) {
// list.value = res.list; list.value = res.rows;
} else { } else {
// list.value.push(...res.list); list.value.push(...res.rows);
} }
// mescroll.endBySize(res.list.length, res.total); console.log(res,'长度测试')
mescroll.endBySize(res.rows.length, res.total);
}, 500); }, 500);
} catch (error) { } catch (error) {
mescroll.endErr(); mescroll.endErr();
} }
console.log('长度测试111')
} }
const upOption = ref({ const upOption = ref({

View File

@@ -17,7 +17,7 @@
<!-- 正文内容 --> <!-- 正文内容 -->
<view class="white-bg"> <view class="white-bg">
<view class="form-con"> <view class="form-con">
<uni-forms ref="formRef" :model="formData" :rules="rules" label-width="100px"> <uni-forms ref="formRef" :model="formData" label-width="100px">
<view @click="addVisistReport" class="form-item-container"> <view @click="addVisistReport" class="form-item-container">
<uni-forms-item label="客户名称" name="cusName" class="f-c-right"> <uni-forms-item label="客户名称" name="cusName" class="f-c-right">
<text class="name">{{ formData.cusName }}</text> <text class="name">{{ formData.cusName }}</text>
@@ -65,7 +65,7 @@
<uni-forms-item label="我方领导" name="leader" required <uni-forms-item label="我方领导" name="leader"
class="uni-forms-item is-direction-top is-top"> class="uni-forms-item is-direction-top is-top">
<multipleSelect :multiple="true" :value="chooseMyLeaderList" downInner <multipleSelect :multiple="true" :value="chooseMyLeaderList" downInner
@@ -123,14 +123,6 @@ const changeValue2 = (item, value) => {
formData.value.leader = chooseMyLeaderList formData.value.leader = chooseMyLeaderList
}; };
// 验证规则
const rules = {
leader: {
rules: [
{ required: true, errorMessage: '我方领导不能为空' }
]
}
};
// 修改日期 // 修改日期
let changeDate = (e) => { let changeDate = (e) => {