if (form.value.dataList !== undefined && form.value.dataList !== null && form.value.dataList.length > 0) { const totalDeductCommission = countTotal(form.value.refundList, 'deductCommission') // 重新计算退保扣款金额 if (props.statementType === 'Receivables') { const receivablesCommission = form.value.d.commission = countTotal(form.value.dataList, 'totalCommission') - totalDeductCommission // 初始化应收金额 const receivablesGrossProfit = receivablesCommission - countTotal(form.value.dataList, 'rebatePremium') // 初始化毛利金额 if (receivablesCommission === 0 && receivablesGrossProfit === 0) { ElNotification.error('请先完成应收对账后,再次尝试提交!') } } else if (props.statementType === 'Payables') { const payablesCommission = form.value.d.commission = countTotal(form.value.dataList, 'totalChannelCommission') - totalDeductCommission // 初始化应付金额 if (payablesCommission === 0) { ElNotification.error('请先完成应付对账后,再次尝试提交!') } } else { const postData = { policy: form.value.dataList, statement: form.value.d, refund: form.value.refundList } api.post('/statement/saveStatement', postData).then(() => { ElNotification.success('对账单保存成功') resolve() }).catch(() => { }) } } else { ElNotification.error('暂无对账单明细,请添加待对账保单!') }优化这段代码
时间: 2023-05-26 15:03:32 浏览: 155
&& form.value.dataList.length > 0) {
// Perform action
} else {
// Display error message
}
相关问题
解释一下getDataList() { this.dataListLoading = true; let params = { page: this.pageIndex, limit: this.pageSize, sort: 'id', order: 'desc', } if(this.searchForm.xueqi!='' && this.searchForm.xueqi!=undefined){ params['xueqi'] = '%' + this.searchForm.xueqi + '%' } if(this.searchForm.kechengfenlei!='' && this.searchForm.kechengfenlei !=undefined){ params['kechengfenlei'] = '%' + this.searchForm.kechengfenlei + '%' } if(this.searchForm.xueshengxingming!='' && this.searchForm.xueshengxingming!=undefined){ params['xueshengxingming'] = '%' + this.searchForm.xueshengxingming + '%' } this.$http({ url: "jiaocailingqu/page", method: "get", params: params }).then(({ data }) => { if (data && data.code === 0) { this.dataList = data.data.list; this.totalPage = data.data.total; } else { this.dataList = []; this.totalPage = 0; } this.dataListLoading = false; }); }是什么意思
这是一个Vue.js组件的方法,主要用于从后端API获取数据列表。函数中使用了一个布尔变量"dataListLoading"来表示数据是否正在加载中。然后,定义了一个对象"params",用于存储请求参数,包括当前页码、每页显示的数据量、排序方式等信息。如果搜索表单中的某些字段不为空,则将其添加到请求参数中。最后,使用Vue.js的$http模块发送一个get请求,请求的URL为“jiaocailingqu/page”,同时传递请求参数params。当请求成功时,将返回的数据存储在"dataList"和"totalPage"变量中。如果请求失败,则"dataList"和"totalPage"将被设置为默认值。最后,将"dataListLoading"变量设置为false,表示数据已经加载完成。
getList(page, fenlei, ref = '') { if(fenlei == '全部') //首先判断分类是否为“全部” this.swiperIndex = -1;//如果是则把swiperIndex设置为-1 for(let i=0;i<this.fenlei.length;i++) {//遍历分类数组this.fenlei,找到对应的分类 if(fenlei == this.fenlei[i]) { this.swiperIndex = i;//把swiperIndex设置为对应的索引值 break; } } this.curFenlei = fenlei;//将当前分类赋值给curFenlei(当前分类)变量 if (this.curFenlei == '全部') {//根据curFenlei是否为“全部”来决定是否设置isPlain变量为false或true this.isPlain = false; } else { this.isPlain = true; } let params = {page, limit: this.pageSize}; let searchWhere = {}; if (this.formSearch.jingdianmingcheng != '') searchWhere.jingdianmingcheng = '%' + this.formSearch.jingdianmingcheng + '%'; if (this.formSearch.jingdiandizhi != '') searchWhere.jingdiandizhi = '%' + this.formSearch.jingdiandizhi + '%'; if(this.formSearch.menpiaojiagestart!='' && this.formSearch.menpiaojiagestart!=undefined ){ searchWhere.menpiaojiagestart = this.formSearch.menpiaojiagestart } if(this.formSearch.menpiaojiageend!='' && this.formSearch.menpiaojiageend!=undefined){ searchWhere.menpiaojiageend = this.formSearch.menpiaojiageend } if (this.curFenlei != '全部') searchWhere.jingdianleixing = this.curFenlei; this.$http.get('lvyoujingdian/list', {params: Object.assign(params, searchWhere)}).then(res => { if (res.data.code == 0) { this.dataList = res.data.data.list; this.total = res.data.data.total; this.pageSize = res.data.data.pageSize; this.totalPage = res.data.data.totalPage; this.pageSizes = [this.pageSize, this.pageSize*2, this.pageSize*3, this.pageSize*5]; } }); },
这是一个 Vue.js 的方法,用于获取旅游景点的列表数据。它接受三个参数,分别是页码、分类和 ref(默认为空字符串)。首先它会判断分类是否为“全部”,如果是则把 swiperIndex(轮播图的索引)设置为-1,否则遍历分类数组找到对应的分类并将 swiperIndex 设置为对应的索引值。然后将当前分类赋值给 curFenlei 变量,并根据 curFenlei 是否为“全部”来决定是否设置 isPlain 变量为 false 或 true。接下来根据传入的参数组装成查询条件 searchWhere,然后通过 HTTP GET 请求获取数据,并将获取到的数据赋值给 dataList、total、pageSize 和 totalPage 等变量。最后根据 pageSize 计算出 pageSizes 数组,并返回获取到的数据。
阅读全文