feat:更新账单记录组件
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="keyboard">
|
<div class="keyboard">
|
||||||
<div class="display">
|
<div class="display">
|
||||||
{{ model || '0' }}
|
{{ amount || '0' }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="keys">
|
<div class="keys">
|
||||||
@@ -19,22 +19,20 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineModel } from 'vue'
|
import { defineModel } from 'vue'
|
||||||
|
|
||||||
const model = defineModel<string>({
|
const amount = defineModel('amount', { type: String, default: '0' })
|
||||||
default: ''
|
|
||||||
})
|
|
||||||
|
|
||||||
const keys = [1, 2, 3, 4, 5, 6, 7, 8, 9, '.', 0] as const
|
const keys = [1, 2, 3, 4, 5, 6, 7, 8, 9, '.', 0] as const
|
||||||
|
|
||||||
const press = (key: number | '.') => {
|
const press = (key: number | '.') => {
|
||||||
const pressValue = model.value
|
const pressValue = amount.value
|
||||||
|
|
||||||
// 小数点
|
// 小数点
|
||||||
if (key === '.') {
|
if (key === '.') {
|
||||||
if (pressValue.includes('.')) return
|
if (pressValue.includes('.')) return
|
||||||
if (pressValue === '') {
|
if (pressValue === '') {
|
||||||
model.value = '0.'
|
amount.value = '0.'
|
||||||
} else {
|
} else {
|
||||||
model.value += '.'
|
amount.value += '.'
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -48,20 +46,20 @@ const press = (key: number | '.') => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (next.length > 1 && next.startsWith('0') && !next.startsWith('0.')) {
|
if (next.length > 1 && next.startsWith('0') && !next.startsWith('0.')) {
|
||||||
model.value = next.slice(1)
|
amount.value = next.slice(1)
|
||||||
} else {
|
} else {
|
||||||
model.value = next
|
amount.value = next
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeLast = () => {
|
const removeLast = () => {
|
||||||
model.value = model.value.slice(0, -1)
|
amount.value = amount.value.slice(0, -1)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.keyboard {
|
.keyboard {
|
||||||
min-height: 320px;
|
min-height: 280px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background: #f7f8fa;
|
background: #f7f8fa;
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
@@ -74,8 +72,8 @@ const removeLast = () => {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
.display {
|
.display {
|
||||||
height: 48px;
|
height: 40px;
|
||||||
line-height: 48px;
|
line-height: 40px;
|
||||||
padding: 0 14px;
|
padding: 0 14px;
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
@@ -93,7 +91,7 @@ const removeLast = () => {
|
|||||||
|
|
||||||
.key {
|
.key {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
height: 48px;
|
height: 40px;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
border: none;
|
border: none;
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import BillDailyList from '@/components/Bill/BillDailyList.vue'
|
|||||||
import { onMounted } from 'vue'
|
import { onMounted } from 'vue'
|
||||||
import { useBillStore } from '@/store/bill.ts'
|
import { useBillStore } from '@/store/bill.ts'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { getCurrentMonth, getCurrentYear } from 'vue3-common/utils/dateUtil'
|
|
||||||
|
|
||||||
const billStore = useBillStore()
|
const billStore = useBillStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -23,21 +22,12 @@ const router = useRouter()
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await billStore.initBillInfo()
|
await billStore.initBillInfo()
|
||||||
|
|
||||||
billStore.billQueryForm = {
|
|
||||||
billBook: 'all',
|
|
||||||
billYear: getCurrentYear(),
|
|
||||||
billMonth: getCurrentMonth()
|
|
||||||
}
|
|
||||||
|
|
||||||
billStore.billSearchForm = {
|
billStore.billSearchForm = {
|
||||||
category: '',
|
category: '',
|
||||||
content: '',
|
content: '',
|
||||||
location: ''
|
location: ''
|
||||||
}
|
}
|
||||||
|
|
||||||
billStore.billType = 'expensive'
|
|
||||||
billStore.billDateType = 'month'
|
|
||||||
|
|
||||||
await billStore.refreshInfo()
|
await billStore.refreshInfo()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<el-form ref="formRef" :model="billStore.currentBillRecord"
|
<el-form ref="formRef" :model="billStore.currentBillRecord"
|
||||||
:rules="rules" label-position="top" label-width="80px"
|
:rules="rules" label-position="top" label-width="80px"
|
||||||
class="form-item bill-form">
|
class="form-item bill-form">
|
||||||
<div style="display: flex;gap: 5px;">
|
<div class="item-list">
|
||||||
<el-select v-model="billStore.currentBillRecord.bookName"
|
<el-select v-model="billStore.currentBillRecord.bookName"
|
||||||
@change="changeBillBookNameEvent" style="width: 100px">
|
@change="changeBillBookNameEvent" style="width: 100px">
|
||||||
<el-option
|
<el-option
|
||||||
@@ -29,11 +29,7 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <el-form-item label="账单分类" prop="category">-->
|
<el-radio-group v-model="billStore.currentBillRecord.category" class="bill-category-group">
|
||||||
<!-- -->
|
|
||||||
<!-- </el-form-item>-->
|
|
||||||
|
|
||||||
<el-radio-group v-model="billStore.currentBillRecord.category">
|
|
||||||
<el-radio v-for="(item, index) in billInfo.billCategoryList"
|
<el-radio v-for="(item, index) in billInfo.billCategoryList"
|
||||||
:value="item.name" :key="index">
|
:value="item.name" :key="index">
|
||||||
<template #default>
|
<template #default>
|
||||||
@@ -45,30 +41,7 @@
|
|||||||
|
|
||||||
<div class="bill-gap"></div>
|
<div class="bill-gap"></div>
|
||||||
|
|
||||||
<!-- <el-form-item label="账本类型" prop="bookName">-->
|
<div class="item-list">
|
||||||
<!-- <el-radio-group v-model="billStore.currentBillRecord.bookName"-->
|
|
||||||
<!-- @change="changeBillBookNameEvent">-->
|
|
||||||
<!-- <el-radio v-for="(item, index) in billStore.billBookList"-->
|
|
||||||
<!-- :value="item.name" :key="index">-->
|
|
||||||
<!-- <template #default>-->
|
|
||||||
<!-- <i :class="item.icon" :style="{color: item.color}"/>-->
|
|
||||||
<!-- <span style="margin-left: 5px;">{{ item.name }}</span>-->
|
|
||||||
<!-- </template>-->
|
|
||||||
<!-- </el-radio>-->
|
|
||||||
<!-- </el-radio-group>-->
|
|
||||||
<!-- </el-form-item>-->
|
|
||||||
|
|
||||||
<!-- <el-form-item label="账单类别" prop="type">-->
|
|
||||||
<!-- <el-radio-group v-model="billStore.currentBillRecord.type"-->
|
|
||||||
<!-- @change="changeBillCategoryEvent">-->
|
|
||||||
<!-- <el-radio v-for="(item, index) in billInfo.billTypeList"-->
|
|
||||||
<!-- :value="item" :key="index">-->
|
|
||||||
<!-- {{ getBillTypeName(item) }}-->
|
|
||||||
<!-- </el-radio>-->
|
|
||||||
<!-- </el-radio-group>-->
|
|
||||||
<!-- </el-form-item>-->
|
|
||||||
|
|
||||||
<div style="display: flex;gap: 5px;">
|
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="billStore.currentBillRecord.date"
|
v-model="billStore.currentBillRecord.date"
|
||||||
type="date" :editable="false" placeholder="请选择账单时间"
|
type="date" :editable="false" placeholder="请选择账单时间"
|
||||||
@@ -83,45 +56,6 @@
|
|||||||
</el-input>
|
</el-input>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <el-form-item label="账单时间" prop="date">-->
|
|
||||||
<!-- <el-date-picker-->
|
|
||||||
<!-- v-model="billStore.currentBillRecord.date"-->
|
|
||||||
<!-- type="date" :editable="false" placeholder="请选择账单时间"-->
|
|
||||||
<!-- value-format="YYYY-MM-DD"/>-->
|
|
||||||
<!-- </el-form-item>-->
|
|
||||||
|
|
||||||
<!-- <el-form-item label="账单地点" prop="location">-->
|
|
||||||
<!-- <el-input v-model="billStore.currentBillRecord.location" autocomplete="off"-->
|
|
||||||
<!-- placeholder="请输入账单地点" clearable-->
|
|
||||||
<!-- show-word-limit maxlength="10">-->
|
|
||||||
<!-- <template #prefix>-->
|
|
||||||
<!-- <el-icon class="el-input__icon"><location/></el-icon>-->
|
|
||||||
<!-- </template>-->
|
|
||||||
<!-- </el-input>-->
|
|
||||||
<!-- </el-form-item>-->
|
|
||||||
|
|
||||||
<!-- <el-form-item label="账单账户" prop="payAccount">-->
|
|
||||||
<!-- <el-radio-group v-model="billStore.currentBillRecord.payAccount">-->
|
|
||||||
<!-- <el-radio v-for="(item, index) in billStore.billPayList"-->
|
|
||||||
<!-- :value="item.name" :key="index">-->
|
|
||||||
<!-- <template #default>-->
|
|
||||||
<!-- <i :class="item.icon" :style="{color: item.color}"/>-->
|
|
||||||
<!-- <span style="margin-left: 5px;">{{ item.name }}</span>-->
|
|
||||||
<!-- </template>-->
|
|
||||||
<!-- </el-radio>-->
|
|
||||||
<!-- </el-radio-group>-->
|
|
||||||
<!-- </el-form-item>-->
|
|
||||||
|
|
||||||
<!-- <el-form-item label="账单内容" prop="content">-->
|
|
||||||
<!-- <el-input v-model="billStore.currentBillRecord.content" autocomplete="off"-->
|
|
||||||
<!-- placeholder="请输入账单内容" clearable-->
|
|
||||||
<!-- show-word-limit maxlength="10">-->
|
|
||||||
<!-- <template #prefix>-->
|
|
||||||
<!-- <el-icon class="el-input__icon"><document/></el-icon>-->
|
|
||||||
<!-- </template>-->
|
|
||||||
<!-- </el-input>-->
|
|
||||||
<!-- </el-form-item>-->
|
|
||||||
|
|
||||||
<el-input v-model="billStore.currentBillRecord.content" autocomplete="off"
|
<el-input v-model="billStore.currentBillRecord.content" autocomplete="off"
|
||||||
placeholder="请输入账单内容" clearable
|
placeholder="请输入账单内容" clearable
|
||||||
show-word-limit maxlength="10">
|
show-word-limit maxlength="10">
|
||||||
@@ -135,14 +69,7 @@
|
|||||||
:rows="3" show-word-limit maxlength="50">
|
:rows="3" show-word-limit maxlength="50">
|
||||||
</el-input>
|
</el-input>
|
||||||
|
|
||||||
<!-- <el-form-item label="账单备注">-->
|
<number-input v-model:amount="billInfo.amountStr" class="amount-input" />
|
||||||
<!-- <el-input v-model="billStore.currentBillRecord.remark" type="textarea"-->
|
|
||||||
<!-- placeholder="请输入账单备注" clearable-->
|
|
||||||
<!-- :rows="5" show-word-limit maxlength="200">-->
|
|
||||||
<!-- </el-input>-->
|
|
||||||
<!-- </el-form-item>-->
|
|
||||||
|
|
||||||
<number-input :model-value="amountStr" class="amount-input" />
|
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<div class="form-button">
|
<div class="form-button">
|
||||||
@@ -155,13 +82,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { AmountInput } from 'vue3-common'
|
|
||||||
import { useBillStore } from '@/store/bill.ts'
|
import { useBillStore } from '@/store/bill.ts'
|
||||||
import { useAppStore } from '@/store/app.ts'
|
import { useAppStore } from '@/store/app.ts'
|
||||||
import { Location, Document } from '@element-plus/icons-vue'
|
import { Location, Document } from '@element-plus/icons-vue'
|
||||||
import { FormRules, UploadUserFile } from 'element-plus'
|
import { ElMessage, FormRules, UploadUserFile } from 'element-plus'
|
||||||
import { billRecordRules } from '@/utils/element/elRules.ts'
|
import { billRecordRules } from '@/utils/element/elRules.ts'
|
||||||
import { computed, nextTick, onMounted, reactive, ref } from 'vue'
|
import { nextTick, onMounted, reactive, ref } from 'vue'
|
||||||
import { IBillCategory } from '@/types/bill.ts'
|
import { IBillCategory } from '@/types/bill.ts'
|
||||||
import { commonElMessageBox } from 'vue3-common/utils/elUtil'
|
import { commonElMessageBox } from 'vue3-common/utils/elUtil'
|
||||||
import NumberInput from '@/components/NumberInput.vue'
|
import NumberInput from '@/components/NumberInput.vue'
|
||||||
@@ -174,7 +100,8 @@ const imageFileList = ref<UploadUserFile[]>([])
|
|||||||
|
|
||||||
const billInfo = reactive({
|
const billInfo = reactive({
|
||||||
billTypeList: [] as string[],
|
billTypeList: [] as string[],
|
||||||
billCategoryList: [] as IBillCategory[]
|
billCategoryList: [] as IBillCategory[],
|
||||||
|
amountStr: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
@@ -182,6 +109,8 @@ onMounted(async () => {
|
|||||||
|
|
||||||
await initBillRecord()
|
await initBillRecord()
|
||||||
initImageFileList()
|
initImageFileList()
|
||||||
|
|
||||||
|
billInfo.amountStr = billStore.currentBillRecord.amount.toString()
|
||||||
})
|
})
|
||||||
|
|
||||||
const initBillRecord = async () => {
|
const initBillRecord = async () => {
|
||||||
@@ -218,8 +147,6 @@ const initImageFileList = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const amountStr = computed<string>(() => billStore.currentBillRecord.amount.toString())
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取账单类型名称
|
* 获取账单类型名称
|
||||||
* @param type 账单类型
|
* @param type 账单类型
|
||||||
@@ -274,11 +201,16 @@ const getBillCategory = () => {
|
|||||||
* 点击确认按钮
|
* 点击确认按钮
|
||||||
*/
|
*/
|
||||||
const confirmClick = () => {
|
const confirmClick = () => {
|
||||||
|
if (billStore.currentBillRecord.content.trim()) {
|
||||||
formRef.value.validate().then(async () => {
|
formRef.value.validate().then(async () => {
|
||||||
|
billStore.currentBillRecord.amount = Number(billInfo.amountStr)
|
||||||
await billStore.handleBillApi(billStore.currentBillRecord)
|
await billStore.handleBillApi(billStore.currentBillRecord)
|
||||||
history.back()
|
history.back()
|
||||||
appStore.isShowMobileBack = false
|
appStore.isShowMobileBack = false
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
ElMessage.error('请输入账单内容')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const cancelClick = () => {
|
const cancelClick = () => {
|
||||||
@@ -305,6 +237,18 @@ const deleteClick = () => {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
|
|
||||||
|
.item-list {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-category-group {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
column-gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.bill-gap {
|
.bill-gap {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import path from 'path'
|
|||||||
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
|
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
|
||||||
import { viteMockServe } from 'vite-plugin-mock'
|
import { viteMockServe } from 'vite-plugin-mock'
|
||||||
|
|
||||||
const API_HOST = '192.168.1.7'
|
// const API_HOST = '192.168.1.7'
|
||||||
// const API_HOST = '127.0.0.1'
|
const API_HOST = '127.0.0.1'
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
|||||||
Reference in New Issue
Block a user