解决昨日买入金额错误的问题
This commit is contained in:
@@ -37,3 +37,25 @@ export function deleteLbDailyUserTradeReport(id) {
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteLbDailyUserTradeReportByDateAndTenant(reportDate, tenantId) {
|
||||
return request({
|
||||
url: '/lbDailyUserTradeReport/delete/by-date-and-tenant',
|
||||
method: 'delete',
|
||||
params: {
|
||||
reportDate,
|
||||
tenantId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function calculateReportSumByDateAndTenant(reportDate, tenantId) {
|
||||
return request({
|
||||
url: '/lbDailyUserTradeReport/calculate-report-sum/by-date-and-tenant',
|
||||
method: 'post',
|
||||
params: {
|
||||
reportDate,
|
||||
tenantId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
|
||||
<el-card class="action-container" shadow="never">
|
||||
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
|
||||
<el-button type="warning" icon="el-icon-data-analysis" :loading="reportSumLoading" @click="openReportSumDialog">汇总数据</el-button>
|
||||
<el-button type="danger" icon="el-icon-delete" :loading="deleteByDateLoading" @click="openDeleteByDateDialog">删除报表数据</el-button>
|
||||
</el-card>
|
||||
|
||||
<el-card class="table-container" shadow="never">
|
||||
@@ -53,7 +55,7 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="昵称" prop="nickname" min-width="120" />
|
||||
<el-table-column label="昨日买入金额" prop="yestodaySellAmt" min-width="130" />
|
||||
<el-table-column label="昨日买入金额" prop="yestodayBuyAmt" min-width="130" />
|
||||
<el-table-column label="当日卖出金额" prop="dailySellAmt" min-width="130" />
|
||||
<el-table-column label="当日买入金额" prop="dailyBuyAmt" min-width="130" />
|
||||
<el-table-column label="服务费" prop="serviceAmt" min-width="100" />
|
||||
@@ -118,8 +120,8 @@
|
||||
</el-row>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="昨日买入金额" prop="yestodaySellAmt">
|
||||
<el-input v-model="form.yestodaySellAmt" placeholder="请输入昨日买入金额" />
|
||||
<el-form-item label="昨日买入金额" prop="yestodayBuyAmt">
|
||||
<el-input v-model="form.yestodayBuyAmt" placeholder="请输入昨日买入金额" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
@@ -171,16 +173,53 @@
|
||||
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<el-dialog title="删除报表数据" :visible.sync="deleteByDateDialogVisible" width="480px" @close="resetDeleteByDateForm">
|
||||
<el-form ref="deleteByDateFormRef" :model="deleteByDateForm" :rules="deleteByDateRules" label-width="120px">
|
||||
<el-form-item label="报表日期" prop="reportDate">
|
||||
<el-date-picker
|
||||
v-model="deleteByDateForm.reportDate"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="请选择要删除的报表日期"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="deleteByDateDialogVisible = false">取消</el-button>
|
||||
<el-button type="danger" :loading="deleteByDateLoading" @click="submitDeleteByDate">确定删除</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<el-dialog title="汇总数据" :visible.sync="reportSumDialogVisible" width="480px" @close="resetReportSumForm">
|
||||
<el-form ref="reportSumFormRef" :model="reportSumForm" :rules="reportSumRules" label-width="120px">
|
||||
<el-form-item label="报表日期" prop="reportDate">
|
||||
<el-date-picker
|
||||
v-model="reportSumForm.reportDate"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="请选择报表日期"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="reportSumDialogVisible = false">取消</el-button>
|
||||
<el-button type="warning" :loading="reportSumLoading" @click="submitReportSum">确定汇总</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
addLbDailyUserTradeReport,
|
||||
calculateReportSumByDateAndTenant,
|
||||
deleteLbDailyUserTradeReportByDateAndTenant,
|
||||
deleteLbDailyUserTradeReport,
|
||||
getLbDailyUserTradeReportList,
|
||||
updateLbDailyUserTradeReport
|
||||
} from '@/api/lb-daily-user-trade-report'
|
||||
import { getBusinessHeaders } from '@/utils/business-headers'
|
||||
|
||||
function formatDateTimeForQuery(date) {
|
||||
const year = date.getFullYear()
|
||||
@@ -199,15 +238,27 @@ function getDefaultReportRange() {
|
||||
}
|
||||
}
|
||||
|
||||
function getLocalTodayDateString() {
|
||||
const date = new Date()
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
return `${year}-${month}-${day}`
|
||||
}
|
||||
|
||||
export default {
|
||||
name: 'LbDailyReport',
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
submitLoading: false,
|
||||
deleteByDateLoading: false,
|
||||
reportSumLoading: false,
|
||||
list: [],
|
||||
total: 0,
|
||||
dialogVisible: false,
|
||||
deleteByDateDialogVisible: false,
|
||||
reportSumDialogVisible: false,
|
||||
dialogTitle: '',
|
||||
isEdit: false,
|
||||
queryParams: {
|
||||
@@ -223,7 +274,7 @@ export default {
|
||||
tenantId: '',
|
||||
userId: '',
|
||||
nickname: '',
|
||||
yestodaySellAmt: '',
|
||||
yestodayBuyAmt: '',
|
||||
dailySellAmt: '',
|
||||
dailyBuyAmt: '',
|
||||
serviceAmt: '',
|
||||
@@ -236,6 +287,18 @@ export default {
|
||||
formRules: {
|
||||
tenantId: [{ required: true, message: '请输入租户ID', trigger: 'blur' }],
|
||||
userId: [{ required: true, message: '请输入用户ID', trigger: 'blur' }]
|
||||
},
|
||||
deleteByDateForm: {
|
||||
reportDate: ''
|
||||
},
|
||||
deleteByDateRules: {
|
||||
reportDate: [{ required: true, message: '请选择报表日期', trigger: 'change' }]
|
||||
},
|
||||
reportSumForm: {
|
||||
reportDate: getLocalTodayDateString()
|
||||
},
|
||||
reportSumRules: {
|
||||
reportDate: [{ required: true, message: '请选择报表日期', trigger: 'change' }]
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -318,7 +381,7 @@ export default {
|
||||
tenantId: row.tenantId || '',
|
||||
userId: row.userId || '',
|
||||
nickname: row.nickname || '',
|
||||
yestodaySellAmt: this.toInputString(row.yestodaySellAmt),
|
||||
yestodayBuyAmt: this.toInputString(row.yestodayBuyAmt),
|
||||
dailySellAmt: this.toInputString(row.dailySellAmt),
|
||||
dailyBuyAmt: this.toInputString(row.dailyBuyAmt),
|
||||
serviceAmt: this.toInputString(row.serviceAmt),
|
||||
@@ -345,6 +408,80 @@ export default {
|
||||
this.fetchList()
|
||||
}).catch(() => {})
|
||||
},
|
||||
openDeleteByDateDialog() {
|
||||
this.deleteByDateDialogVisible = true
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.deleteByDateFormRef) this.$refs.deleteByDateFormRef.clearValidate()
|
||||
})
|
||||
},
|
||||
openReportSumDialog() {
|
||||
this.reportSumForm.reportDate = getLocalTodayDateString()
|
||||
this.reportSumDialogVisible = true
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.reportSumFormRef) this.$refs.reportSumFormRef.clearValidate()
|
||||
})
|
||||
},
|
||||
submitDeleteByDate() {
|
||||
this.$refs.deleteByDateFormRef.validate((valid) => {
|
||||
if (!valid) return
|
||||
const tenantId = this.getTenantIdFromBusinessHeaders()
|
||||
if (!tenantId) {
|
||||
this.$message.error('未获取到租户ID,请先登录或切换到正确租户后重试')
|
||||
return
|
||||
}
|
||||
this.$confirm(`确认删除报表日期为 ${this.deleteByDateForm.reportDate} 的报表数据吗?`, '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.deleteByDateLoading = true
|
||||
return deleteLbDailyUserTradeReportByDateAndTenant(this.deleteByDateForm.reportDate, tenantId)
|
||||
}).then((res) => {
|
||||
this.$message.success(res.message || '删除成功')
|
||||
this.deleteByDateDialogVisible = false
|
||||
this.fetchList()
|
||||
}).finally(() => {
|
||||
this.deleteByDateLoading = false
|
||||
}).catch(() => {})
|
||||
})
|
||||
},
|
||||
resetDeleteByDateForm() {
|
||||
if (this.$refs.deleteByDateFormRef) this.$refs.deleteByDateFormRef.resetFields()
|
||||
this.deleteByDateForm = {
|
||||
reportDate: ''
|
||||
}
|
||||
},
|
||||
submitReportSum() {
|
||||
this.$refs.reportSumFormRef.validate((valid) => {
|
||||
if (!valid) return
|
||||
const tenantId = this.getTenantIdFromBusinessHeaders()
|
||||
if (!tenantId) {
|
||||
this.$message.error('未获取到租户ID,请先登录或切换到正确租户后重试')
|
||||
return
|
||||
}
|
||||
this.reportSumLoading = true
|
||||
calculateReportSumByDateAndTenant(this.reportSumForm.reportDate, tenantId)
|
||||
.then((res) => {
|
||||
this.$message.success(res.message || '汇总成功')
|
||||
this.reportSumDialogVisible = false
|
||||
this.fetchList()
|
||||
})
|
||||
.finally(() => {
|
||||
this.reportSumLoading = false
|
||||
})
|
||||
})
|
||||
},
|
||||
resetReportSumForm() {
|
||||
if (this.$refs.reportSumFormRef) this.$refs.reportSumFormRef.resetFields()
|
||||
this.reportSumForm = {
|
||||
reportDate: getLocalTodayDateString()
|
||||
}
|
||||
},
|
||||
getTenantIdFromBusinessHeaders() {
|
||||
const headers = getBusinessHeaders()
|
||||
const value = headers && headers['X-Tenant-Id']
|
||||
return value ? String(value).trim() : ''
|
||||
},
|
||||
handleSubmit() {
|
||||
this.$refs.dataForm.validate((valid) => {
|
||||
if (!valid) return
|
||||
@@ -365,7 +502,7 @@ export default {
|
||||
tenantId: this.form.tenantId,
|
||||
userId: this.form.userId,
|
||||
nickname: this.form.nickname || undefined,
|
||||
yestodaySellAmt: this.parseDecimal(this.form.yestodaySellAmt),
|
||||
yestodayBuyAmt: this.parseDecimal(this.form.yestodayBuyAmt),
|
||||
dailySellAmt: this.parseDecimal(this.form.dailySellAmt),
|
||||
dailyBuyAmt: this.parseDecimal(this.form.dailyBuyAmt),
|
||||
serviceAmt: this.parseDecimal(this.form.serviceAmt),
|
||||
@@ -403,7 +540,7 @@ export default {
|
||||
tenantId: '',
|
||||
userId: '',
|
||||
nickname: '',
|
||||
yestodaySellAmt: '',
|
||||
yestodayBuyAmt: '',
|
||||
dailySellAmt: '',
|
||||
dailyBuyAmt: '',
|
||||
serviceAmt: '',
|
||||
|
||||
Reference in New Issue
Block a user