有潜在危险 添加了validaterequest=false 为什么还是报错

本文记录了一次解决ASP.NET中客户端潜在危险错误的过程。通过调整web.config文件中的requestValidationMode设置为2.0,成功解决了发布到4.0版本时出现的验证错误。

一些平时见看上去很简单的问题,一些简单的事情,也许在复杂的环境中就看上去不那么简单了.

今天遇到一个错误:话说是客户端存在潜在的危险...这样的错误我不是第一次遇到了,所以我以为很简单的在page 中添加了一个validaterequest=false 在运行页面 还是报相同的错误,于是就想不明白了,这是什么情况..?

开始在网上查资料 大致都是相同的一些回答:第一种解决方案:在page中添加validaterequest=false 第二种就是在web.config <con>中添加一个属性.而且都是很统一的答案,让我以为是我自己错了,在web.config中添加了属性 并且检查了page中的的确确是有的,再运行还是报错.

茫然....

查查看为什么出现了错误吧:

在csdn的一个问题上找到了答案:

我的问题和http://topic.youkuaiyun.com/u/20110623/14/a23e6ff5-2c92-4896-870b-2be525548433.html他得是一样的 项目是3.5的 但是发布到的却是4.0的版本上

在web.config中添加了:

<System.Web>配置节中添加如下一个配置呢?
<httpRuntime requestValidationMode="2.0" />

就完成了.

也许问题并不复杂而是一个简单的问题套在了一个简单的外衣里.变得让我有些迷惑吧!

修复以下代码:<template> <div class="container"> <el-tabs type="border-card"> <el-tab-pane :label="title"> <el-form ref="form" :model="form" :rules="rules" label-width="120px"> <el-form-item label="介绍图片:" prop="cover"> <div style="display: flex;"> <div class="flex-row"> <el-upload class="avatar-uploader" :show-file-list="false" :before-upload="beforeAvatarUpload" @change="handleFileChange"> <img v-if="form.cover" :src="form.cover" class="avatar"> <i v-else class="el-icon-plus avatar-uploader-icon"></i> </el-upload> </div> </div> </el-form-item> <el-row> <el-col :span="12"> <el-form-item label="团购名称:" prop="name"> <el-input class="input" v-model="form.name" placeholder="请输入团购名称" /> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="自动截止:" prop="isAutoEnd"> <el-switch v-model="form.isAutoEnd" :active-value="true" :inactive-value="false" /> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="团购内容:" prop="detailInfo"> <el-input class="input" v-model="form.detailInfo" placeholder="请输入团购内容" /> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="开始时间:" prop="startTime"> <el-input class="input" v-model="form.startTime" placeholder="请输入开始时间" /> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="截止时间:" prop="endTime"> <el-input class="input" v-model="form.endTime" placeholder="请输入结束时间" /> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="最大接龙人数" prop="maxJoinNum"> <el-input class="input" v-model="form.maxJoinNum" placeholder="请输入" /> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="最小成交金额" prop="minAmount"> <el-input class="input" v-model="form.minAmount" placeholder="请输入" /> </el-form-item> </el-col> </el-row> <el-form-item label="其它信息:"> <el-checkbox-group v-model="selectedItemsOther" @change="updateOtherInfo"> <el-checkbox label="真实姓名"></el-checkbox> <el-checkbox label="手机号码"></el-checkbox> </el-checkbox-group> </el-form-item> <el-form-item label="功能选择:"> <el-checkbox-group v-model="selectedItemsFunction" @change="updateFunctionSelection"> <el-checkbox label="发布最新接龙列表"></el-checkbox> <el-checkbox label="接龙金额仅创建人可见"></el-checkbox> <el-checkbox label="禁止用户取消订单"></el-checkbox> </el-checkbox-group> </el-form-item> <div> <el-form-item label="商品信息:" prop="jobUserVOLists"> </el-form-item> <el-table :data="dataList" @selection-change="handleSelectionChange"> <el-table-column type="selection" width="55" align="center" /> <el-table-column label="商品名称" align="center" prop="product.name"> <template slot-scope="scope"> <router-link :to="'/activity/activityDetail?id=' + scope.row.pkId + '&detailType=' + `${detailType}`" class="link-type"> <span style="color: blue;">{{ scope.row.cover }}</span> </router-link> </template>" </el-table-column> <el-table-column label="商品价格" align="center" prop="product.price"> <template slot-scope="scope"> </template>" </el-table-column> <el-table-column label="商品数量" align="center" prop="product.soldNum"> <template slot-scope="scope"> <ImageSizeBox :data="scope.row.cover" size="sl" fit="fit" /> </template> </el-table-column> <el-table-column label="每单限制购买量" align="center" prop="product.limitNum" width="180"> <template slot-scope="scope"> <span>{{ scope.row.startDatetime }}</span> </template> </el-table-column> <el-table-column label="商品图片" align="center" prop="product.image" width="180"> <template slot-scope="scope"> <span>{{ scope.row.endDatetime }}</span> </template> </el-table-column> <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <template slot-scope="scope"> <el-button size="mini" type="text" v-if="scope.row.status != '4'" icon="el-icon-edit" @click="openApproval(scope.row)" v-hasPermi="['solitaire:list:order']">添加 </el-button> <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['activity:management:remove']">删除 </el-button> </template> </el-table-column> </el-table> </div> </el-form> <!-- 修改/新增 --> <div class="dialog-footer"> <el-button type="primary" @click="submitForm">确 定</el-button> <el-button @click="handleBack">取 消</el-button> </div> </el-tab-pane> </el-tabs> </div> </template> <script> import { imgUrl } from '@/utils/request' import { getISOTime, checkLongitudeValidator, checkPointIsNumber } from '@/utils/parsing' import { checkPhone } from '@/utils/validate' import mapView from '@/components/MapContainer/index.vue' import { addGroupShop, getGroupBuyDetail } from '@/api/solitaire/solitaire' export default { components: { mapView }, data() { return { // 第一个复选框组绑定值 selectedItemsOther: [], // 第二个复选框组绑定值 selectedItemsFunction: [], checkList: ['选中且禁用','复选框 A'], checked: true, // 单个复选框的绑定 dataList: [], title: "接龙", // 封面图片 selectImgUrl: '', queryParams: {}, currentImgIndex: 0, // 封面图片类型选择 imgDialogVisible: false, // 表单数据 form: { canCancel: false, cover:imgUrl, detailInfo: null, endTime: null, id: 0, isAutoEnd: 0, isGetPhone: false, isGetRealName: false, isHideList: false, isHideOrderAmount: false, isJoin: 0, maxJoinNum: 0, minAmount: 0, name: "", products: [ { id: 0, image: imgUrl, limitNum: 0, name: "", parentId: 0, price: 0, soldNum: 0, totalNum: 0 } ], realEndTime: "", startTime: "", status: 0, }, // 表单校验 rules: { cover: [ { required: true, message: '请选择活动图片', trigger: ['change', 'blur'] } ], name: [ { required: true, message: '请输入团购名称', trigger: 'change' } ], othermessage: [ { type: 'array', required: true, message: '请选择其它信息', trigger: 'change' } ], selectability: [ { type: 'array', required: true, message: '请选择功能', trigger: 'change' }, ], serviceSafeguard: [ { type: 'array', required: true, message: '请选择志愿者保障', trigger: 'change' } ], detailInfo: [ { required: true, message: '请输入团购内容', trigger: 'change' } ], maxJoinNum: [ { required: true, message: '最大人数不能为空', trigger: 'change' } ], minAmount: [ { required: true, message: '最小成交金额不能为空', trigger: 'change' } ], endTime: [ { required: true, message: '结束时间必须选择', trigger: 'change' } ], startTime: [ { required: true, message: '开始时间不能为空', trigger: 'change' } ], description: [ { required: true, message: '活动开始内容不能为空', trigger: 'change' } ], address: [ { required: true, message: '地点不能为空', trigger: 'change' } ], conditionRequire: [ { required: true, message: '请输入条件说明', trigger: 'change' } ], // signStartDatetime: [ // { required: true, message: '报名开始时间必须选择', trigger: 'change' } // ], signEndDatetime: [ { required: true, message: '活动截止时间必须选择', trigger: 'change' } ], jobUserVOLists: [ { type: 'array', required: true, message: '请添加岗位需求', trigger: 'change' } ], 'organizer[0].name': [ { required: true, message: '请添加活动主办方姓名', trigger: 'change' } ], 'organizer[0].linkmanName': [ { required: true, message: '请添加活动负责人联系人', trigger: 'change' } ], 'organizer[0].phone': [ { required: true, message: '请添加活动负责人电话', trigger: 'change' }, { validator: checkPhone, trigger: 'blur' } ] }, // 图片前缀 cover: imgUrl, // //分页 column: { pageSize: null, pageNum: null }, // 队伍列表 duiwoptions: [], // 查询队伍 userqueryParams: { realName: null, role: 1, teamId: null, account: null, contactAddress: null }, checkList1: [], checkList2: [], checkList3: [], userList: [], // 补录图片 fileList: [], dialogImageUrl: '', dialogVisible: false, // 一个时间段岗位 oneTime: { startDatetime: '', endDatetime: '', jobList: [], checkLongitude: '', checkLatitude: '', checkLocation: '' }, // 一个岗位 oneJob: { jobName: '', checkInTime: '', checkOutTime: '', jobCount: '', workHour: 0, point: '', pointPercent: '', userIdList: [], jobUsers: [], checkLatitude: '', checkLongitude: '', checkLocation: '' }, // 岗位表单校验 jobRules: { jobName: [ { required: true, message: '请输入岗位名称', trigger: 'change' } ], jobCount: [ { required: true, message: '请输入岗位人数', trigger: 'change' } ], workHour: [ { required: true, message: '请输入工时', trigger: 'change' } ], pointPercent: [ { required: true, message: '请输入积分(每人每小时)', trigger: 'change' }, { validator: checkPointIsNumber, message: '积分必须为数字' } ], checkInTime: [ { required: true, message: '请输入签到时间', trigger: 'change' } ], checkOutTime: [ { required: true, message: '请输入签退时间', trigger: 'change' } ], checkLocation: [ { required: true, message: '请选择签到地点', trigger: 'change' } ] }, // 高德地图key key: '6SZBZ-RKVKZ-6JCXL-7CSK2-CPYU6-FZB32', mapVisible: false, location: {}, locationMsg: { timeIndex: 0, jobIndex: 0 } } }, created() { this.queryParams = this.$route.query; if (this.queryParams.id && this.queryParams.type == 'edit') { // 编辑 this.title = '修改团购' this.getDetail({ status: 1 }) } else { //添加 this.title = '新增团购' this.reset() } console.log(this.title) }, methods: { handleFileChange(file) { return new Promise((resolve) => { // 1. 创建文件阅读器 const reader = new FileReader(); // 2. 读取文件为DataURL reader.onload = (e) => { this.form.cover = e.target.result; // 直接使用Base64编码 resolve(true); }; reader.readAsDataURL(file.raw); }); }, // 上传前验证 beforeAvatarUpload(file) { const validTypes = ['image/jpeg', 'image/png', 'image/gif']; const isImage = validTypes.includes(file.type); const isLt2M = file.size / 1024 / 1024 < 2; if (!isImage) { this.$message.error('只支持JPG/PNG/GIF格式!'); return false; } if (!isLt2M) { this.$message.error('图片大小不能超过2MB!'); return false; } return true; }, // handleAvatarSuccess(res, file) { // this.cover = URL.createObjectURL(file.raw); // }, // handleCustomUpload(fileObj) { // const file = fileObj.file; // const fd = new FormData(); // fd.append('file', file); // uploadPic(fd, { modularName: 'ACTIVITY' }).then(res => { // this.form.cover = res; // 关键:将返回的URL绑定到form.cover // this.$message.success('图片上传成功'); // }).catch(err => { // this.$message.error('上传失败: ' + err.message); // }); // }, updateOtherInfo() { this.form.isGetRealName = this.selectedItemsOther.includes('真实姓名'); this.form.isGetPhone = this.selectedItemsOther.includes('手机号码'); }, // 更新"功能选择"表单值 updateFunctionSelection() { this.form.isHideList = this.selectedItemsFunction.includes('发布最新接龙列表'); this.form.isHideOrderAmount = this.selectedItemsFunction.includes('接龙金额仅创建人可见'); // "禁止用户取消订单"需要特殊处理:选中时canCancel=false this.form.canCancel = !this.selectedItemsFunction.includes('禁止用户取消订单'); }, // 获取活动详情 getDetail(status) { getGroupBuyDetail(this.queryParams.id, status).then(response => { this.queryParams.id, status this.form = response console.log(response,'789') }) }, // 表单重置 reset() { this.form = { cover: null, canCancel: 0, detailInfo: null, endTime: null, id: 0, isAutoEnd: 0, isGetPhone: 0, isGetRealName: 0, isHideList: 0, isHideOrderAmount: 0, isJoin: 0, maxJoinNum: 0, minAmount: 0, name: "", products: [ { id: 0, image: imgUrl, limitNum: 0, name: "", parentId: 0, price: 0, soldNum: 0, totalNum: 0 } ], realEndTime: "", startTime: "", status: 0, } }, // // 取消关闭弹窗 // closeDialog() { // this.currentImgIndex = 0 // this.selectImgUrl = '' // this.imgDialogVisible = false // }, // // 确认默认图片关闭弹窗 // submitPic() { // this.form.cover = this.selectImgUrl // this.imgDialogVisible = false // }, hasCommonValue(arr) { let seen = new Set(); // 用于存储已经遇到的值 for (let obj of arr) { for (let value of obj.jobUsers) { // 如果值已经存在于 set 中,返回 true if (seen.has(value.userId)) { return true; } // 将当前值入 set seen.add(value.userId); } } return false; // 如果没有重复的值,返回 false }, /** 提交按钮 */ submitForm() { let newForm = { canCancel: this.form.canCancel, cover: this.form.cover, detailInfo: this.form.detailInfo, endTime:this.form.endTime, id: this.form.id, isAutoEnd: this.form.isAutoEnd, isGetPhone:this.form.isGetPhone, isGetRealName: this.form.isGetRealName, isHideList: this.form.isHideList, isHideOrderAmount: this.form.isHideOrderAmount, isJoin: this.form.isJoin, maxJoinNum: this.form.maxJoinNum, minAmount: this.form.minAmount, name: this.form.name, products: [ { id:this.form.products.id, image: this.form.products.image, limitNum:this.form.products.limitNum, name:this.form.products.name, parentId: this.form.products.parentId, price: this.form.products.price, soldNum: this.form.products.soldNum, totalNum: this.form.products.totalNum } ], realEndTime: this.form.realEndTime, startTime: this.form.startTime, status: this.status, } console.log(newForm) //判断每个时间段是否有岗位 // let isJobEmpty = this.form.jobUserVOLists.some(item => item.jobList.length == 0) this.$refs['form'].validate(valid => { if (valid) { if (this.form.id != null) { updateActivity(newForm).then(response => { console.log(response) this.$modal.msgSuccess('修改成功') this.$router.back(-1) }) } else { if(this.form.name){ addGroupShop(newForm).then(response => { console.log(response) this.$modal.msgSuccess('新增成功') this.$router.back(-1) }) } else { this.$modal.msgError('请完善信息') } } } }) }, handleBack(){ this.$router.back(-1) }, // handleSelectionChange(selection) { this.ids = selection.map(item => item.pkId) this.single = selection.length !== 1 this.multiple = !selection.length }, // 上传图片 selectPicUpload(obj) { let fd = new FormData() //参数的格式是formData格式的 fd.append('file', obj.file) //参数 uploadPic(fd, { modularName: 'ACTIVITY' }).then(res => { this.form.cover = res }) }, // 上传图片之前拦截 //活动补录图片 selectPicUploadMaterial(obj) { console.log(obj) let fd = new FormData() //参数的格式是formData格式的 fd.append('file', obj.file) //参数 console.log(fd) uploadPic(fd, { modularName: 'ACTIVITY' }).then(res => { console.log(res, '=====') this.form.material.push(res) }) }, //移除图片 handleRemoveMaterial(file, fileList) { console.log(file, fileList); //拿到删除索引 let index = this.fileList.indexOf(file) this.form.material.splice(index, 1) const list = JSON.parse(JSON.stringify(fileList)) this.fileList = list.map(item => ({ name: item.name, url: item.url })) }, //图片预览 handlePictureCardPreviewMaterial(file) { this.dialogImageUrl = file.url; this.dialogVisible = true; }, // 新增时间段 addTime() { this.$set(this.form.jobUserVOLists, this.form.jobUserVOLists.length, JSON.parse(JSON.stringify(this.oneTime))) // this.form.jobUserVOLists.push(JSON.parse(JSON.stringify(this.oneTime))) }, // 岗位新增 async jobAdd(index) { let data1 = this.form.jobUserVOLists[index] let isPassNum = this.form.jobUserVOLists.filter(item => item.jobList.some(itemson => itemson.jobUsers.length > itemson.jobCount) ); if (isPassNum.length > 0) { this.$modal.msgError('所添加志愿者数目不能超过岗位人数') return } else { if (data1.startDatetime && data1.endDatetime) { this.oneJob.checkInTime = data1.startDatetime this.oneJob.checkOutTime = data1.endDatetime this.oneJob.checkLongitude = data1.checkLongitude this.oneJob.checkLatitude = data1.checkLatitude this.oneJob.checkLocation = data1.checkLocation this.oneJob.workHour = getISOTime(data1.startDatetime, data1.endDatetime) console.log(this.oneJob) } console.log(this.oneJob) this.$set(data1.jobList, data1.jobList.length, JSON.parse(JSON.stringify(this.oneJob))) } console.log('this.form.jobUserVOLists', JSON.stringify(this.form.jobUserVOLists)) }, // 改变时间段的初始时间 changeStartTime(value, timeIndex) { console.log(this.form.jobUserVOLists[timeIndex].jobList) if (this.form.jobUserVOLists[timeIndex].jobList) { this.form.jobUserVOLists[timeIndex].jobList.forEach(item => { item.checkInTime = value if (item.checkOutTime && item.checkInTime) { item.workHour = getISOTime(item.checkInTime, item.checkOutTime) if (item.jobUsers) { item.jobUsers.forEach(itemson => { itemson.workHour = item.workHour itemson.point = parseInt(item.pointPercent) * item.workHour }) } } }) } }, // 改变时间段的初始时间 changeEndTime(value, timeIndex) { if (this.form.jobUserVOLists[timeIndex].jobList) { this.form.jobUserVOLists[timeIndex].jobList.forEach(item => { item.checkOutTime = value if (item.checkOutTime && item.checkInTime) { item.workHour = getISOTime(item.checkInTime, item.checkOutTime) if (item.jobUsers) { item.jobUsers.forEach(itemson => { itemson.workHour = item.workHour itemson.point = parseInt(item.pointPercent) * item.workHour }) } } }) } }, // 改变时间段的签到纬度 changeLatitude(value, timeIndex) { if (this.form.jobUserVOLists[timeIndex].jobList) { this.form.jobUserVOLists[timeIndex].jobList.forEach(item => { item.checkLatitude = value }) } }, // 改变时间段的签到经度 changeLongitude(value, timeIndex) { if (this.form.jobUserVOLists[timeIndex].jobList) { this.form.jobUserVOLists[timeIndex].jobList.forEach(item => { item.checkLongitude = value }) } }, // 跳转 toPrck() { window.open('https://lbs.amap.com/tools/picker') }, // 删除时间段 deleteTime(timeIndex) { this.$modal.confirm('是否确认该时间段?').then(function () { }).then(() => { this.form.jobUserVOLists.splice(timeIndex, 1) this.changeNumber() }).catch(() => { }) }, // 删除岗位按钮 deleteSelect(timeIndex, jobIndex) { this.$modal.confirm('是否确认删除此岗位?').then(function () { }).then(() => { this.form.jobUserVOLists[timeIndex].jobList.splice(jobIndex, 1) this.changeNumber() }).catch(() => { }) }, // 活动最大人数改变 changeNumber() { this.form.maxCount = 0 this.form.jobUserVOLists.forEach(item => { item.jobList.forEach(itemson => { this.form.maxCount += itemson.jobUsers.length }) }) }, // 岗位人数改变 changeJobNumber(timeIndex, jobIndex) { if (this.form.jobUserVOLists[timeIndex].jobList[jobIndex].length > this.form.jobUserVOLists[timeIndex].jobList[jobIndex].jobCount) { this.$modal.msgError('所添加志愿者数目不能超过岗位人数') } else { this.form.maxCount = 0 this.form.jobUserVOLists.forEach(item => { item.jobList.forEach(itemson => { this.form.maxCount += parseInt(itemson.jobCount) }) }) } }, // 改变岗位时间 async changTime(timeIndex, jobIndex) { let data1 = this.form.jobUserVOLists[timeIndex].jobList[jobIndex] if (data1.checkOutTime && data1.checkInTime) { data1.workHour = getISOTime(data1.checkInTime, data1.checkOutTime) data1.point = parseInt(data1.pointPercent) * data1.workHour if (data1.jobUsers) { data1.jobUsers.forEach(item => { item.workHour = data1.workHour item.point = parseInt(data1.pointPercent) * data1.workHour }) } } }, //岗位志愿者选择 async AddSelect1(value, timeIndex, jobIndex) { console.log(this.form.jobUserVOLists) this.form.jobUserVOLists[timeIndex].jobList[jobIndex].jobUsers = [] this.form.jobUserVOLists[timeIndex].jobList[jobIndex].userIdList.forEach(item => { this.form.jobUserVOLists[timeIndex].jobList[jobIndex].jobUsers.push({ 'userId': item, point: this.form.jobUserVOLists[timeIndex].jobList[jobIndex].workHour * parseInt(this.form.jobUserVOLists[timeIndex].jobList[jobIndex].pointPercent), 'workHour': this.form.jobUserVOLists[timeIndex].jobList[jobIndex].workHour }) }) console.log('this.form.jobUserVOLists', JSON.stringify(this.form.jobUserVOLists)) // this.submitForm() // this.totalPeople(index) // 筛选出远程数据中有的数据进行保留,其余的push新的 // if (this.form.jobUserVOS[index].id !== '') { // let oldDate = value.filter(item => this.form.jobUserVOS[index].oldUserList.includes(item)) //远程有的 // let changeDate = value.filter(item => !oldDate.includes(item)); //剩余的新的 // let newDate = [] // changeDate.forEach(item => { // newDate.push({ // 'userId': item, // point: this.form.jobUserVOS[index].point, // 'workHour': this.form.jobUserVOS[index].workHour // }) // }) // this.form.jobUserVOS[index].jobUsers = this.form.jobUserVOS[index].oldJobUsers.filter(item => oldDate.includes(item.userId)).concat(newDate) // } else { // this.form.jobUserVOS[index].jobUsers = [] // this.form.jobUserVOS[index].userIdList.forEach(item => { // this.form.jobUserVOS[index].jobUsers.push({ // 'userId': item, // point: this.form.jobUserVOS[index].point, // 'workHour': this.form.jobUserVOS[index].workHour // }) // }) // } // this.totalPeople(index) }, // 岗位志愿者全选 selectAll(timeIndex, jobIndex) { console.log(this.form.jobUserVOLists[timeIndex].jobList[jobIndex].userIdList) if (this.form.jobUserVOLists[timeIndex].jobList[jobIndex].userIdList.length - 1 < this.userList.length) { this.form.jobUserVOLists[timeIndex].jobList[jobIndex].userIdList = this.userList.map(item => item.uid) this.form.jobUserVOLists[timeIndex].jobList[jobIndex].jobUsers = [] this.form.jobUserVOLists[timeIndex].jobList[jobIndex].userIdList.forEach(item => { this.form.jobUserVOLists[timeIndex].jobList[jobIndex].jobUsers.push({ 'userId': item, point: this.form.jobUserVOLists[timeIndex].jobList[jobIndex].workHour * parseInt(this.form.jobUserVOLists[timeIndex].jobList[jobIndex].pointPercent), 'workHour': this.form.jobUserVOLists[timeIndex].jobList[jobIndex].workHour }) }) } else { // 取消全选 this.form.jobUserVOLists[timeIndex].jobList[jobIndex].userIdList = [] this.form.jobUserVOLists[timeIndex].jobList[jobIndex].jobUsers = [] } }, // 改变积分/每人 changePointPercent(timeIndex, jobIndex) { this.form.jobUserVOLists[timeIndex].jobList[jobIndex].point = parseInt(this.form.jobUserVOLists[timeIndex].jobList[jobIndex].pointPercent) * this.form.jobUserVOLists[timeIndex].jobList[jobIndex].workHour console.log(this.form.jobUserVOLists[timeIndex].jobList[jobIndex].point) this.form.jobUserVOLists.forEach(item => { item.jobList.forEach(itemson => { itemson.jobUsers.forEach(itemson1 => { itemson1.point = itemson.workHour * parseInt(itemson.pointPercent) }) }) }) }, // 补录删除志愿者 deleteUser(e, p) { this.form.jobUserVOS[e].jobUsers.splice(p, 1) this.$modal.msgSuccess('删除成功') }, } } </script> <style scoped> .container { background-color: #f5f5f5; padding: 1%; } .title_type { font-size: 24px; font-weight: 700; margin-bottom: 20px; } .dialog-footer { display: flex; flex-direction: row; justify-content: center; align-items: center; padding-bottom: 30px; } .avatar-uploader .el-upload { border: 1px solid #f8f3f3; border-radius: 6px; cursor: pointer; position: relative; overflow: hidden; } .avatar-uploader .el-upload:hover { border-color: #409EFF; } .avatar-uploader-icon { font-size: 28px; color: #8c939d; width: 120px; height: 120px; line-height: 120px; text-align: center; } .coverImage { width: 214px; height: 129px; border-radius: 6px; cursor: pointer; } .select_mask { position: absolute; z-index: 2; background-color: rgba(127, 125, 121, 0.5); text-align: center; top: 0; bottom: 0; left: 0; right: 0; width: 214px; height: 129px; display: flex; justify-content: center; align-items: center; } .avatar { width: 214px; height: 129px; display: block; } .margin-right-10 { margin-right: 10px; } .job_box { /* border: 1px solid #ccc; */ background-color: #F8F8F8; padding: 46px 10px 10px; margin-bottom: 10px; margin-left: 50px; border-radius: 10px; } </style>
最新发布
10-24
<script setup lang="ts"> import request from '@/utils/request'; import { ElMessage, ElMessageBox } from 'element-plus'; import type { FormInstance } from 'element-plus' import { reactive, ref,onMounted } from 'vue'; interface CategoryEntity { id: number title: string parentId: number children?: CategoryEntity[] } const tableData = ref<CategoryEntity[]>([]) const formVisible = ref(false) const currentId = ref<number | null>(null) const formRef = ref<FormInstance>() const form = ref({ title: '', parentId: 0 }) const data=reactive({ user: JSON.parse(localStorage.getItem('xm-pro-user')||'{}'),//跟自己的文件名一致 title:null, pageNum:1, pageSize:5, total:0, tableData:[], form:{}, formVisible:false, rules:{ title:[ {required:true,message:'请填写分类标题',trigger:'blur'} ], } }) const load=()=>{ request.get('/category/selectPage',{ params:{ pageNum:data.pageNum, pageSize:data.pageSize, title:data.title } }).then(res=>{ if(res.code==='200'){ data.tableData=res.data?.list data.total=res.data?.total }else{ ElMessage.error(res.msg) } }) } load() const handleAdd=()=>{ data.formVisible=true data.form={} } const save=()=>{//在一个保存方法里面做2个操作,一个是新增一个是编辑 data.form.id?update():add() } const add=()=>{ formRef.value.validate((valid)=>{ if(valid){//验证通过的话再新增 request.post('/category/add',data.form).then(res=>{ if(res.code==='200'){ data.formVisible=false ElMessage.success('新增成功') load()//新增后重新载最新的数据 }else{ ElMessage.error(res.msg) } }) } }) } const update=()=>{ formRef.value.validate((valid)=>{ if(valid){ request.put('/category/update',data.form).then(res=>{ if(res.code==='200'){ data.formVisible=false ElMessage.success('操作成功') load()//更新后重新载最新的数据 }else{ ElMessage.error(res.msg) } }) } }) } const handleEdit=(row)=>{ data.form=JSON.parse(JSON.stringify(row))//深拷贝一个新的对象用于编辑,就不会影响行对象 data.formVisible=true } const del=(id)=>{ //二次确认 ElMessageBox.confirm('删除后无法恢复,确认删除?','删除确认',{type:'Warning'}).then(()=>{ request.delete('/category/deleteById/'+id).then(res=>{ if(res.code==='200'){ ElMessage.success('操作成功') load()//删除后重新载最新的数据 }else{ ElMessage.error(res.msg) } }) }).catch() } const reset=()=>{ data.title=null load() }为什么会报以下错误 </script>类型“AxiosResponse<any, any>”上不存在属性“code”类型“(msg: any) => unknown”的参数不能赋给类型“MessageParamsWithType”的参数。 不能将类型“(msg: any) => unknown”分配给类型“() => VNode<RendererNode, RendererElement, { [key: string]: any; }>”。 目标签名提供的自变量太少。预期为 1 个或更多,但实际为 0 个。ts-plugin(2345)
03-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值