accounting-page 0.1.27 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -10
- package/package.json +3 -3
- package/src/views/VoucherCreate.vue +52 -5
package/README.md
CHANGED
|
@@ -5,13 +5,4 @@ This template should help get you started developing with Vue 3 and TypeScript i
|
|
|
5
5
|
the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
|
6
6
|
|
|
7
7
|
Learn more about the recommended Project Setup and IDE Support in
|
|
8
|
-
the [Vue Docs TypeScript Guide](https://vuejs.org/guide/typescript/overview.html#project-setup).
|
|
9
|
-
|
|
10
|
-
## TODO
|
|
11
|
-
|
|
12
|
-
- [X] 统计周期:本月首日—今日,报表类型选择资产负债表
|
|
13
|
-
- [X] 科目选择框设置为全屏/最大化
|
|
14
|
-
- [X] 凭证保存成功后,自动新建空白凭证窗口
|
|
15
|
-
- [ ] 科目选择框新增搜索功能(暂时搁置)
|
|
16
|
-
- [X] 金额支持小数点,计算精度保留到分
|
|
17
|
-
- [ ] 输入框点击后,无需聚焦。
|
|
8
|
+
the [Vue Docs TypeScript Guide](https://vuejs.org/guide/typescript/overview.html#project-setup).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "accounting-page",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"axios": "^1.19.0",
|
|
14
14
|
"vant": "^4.10.0",
|
|
15
|
-
"vue": "^3.5.
|
|
15
|
+
"vue": "^3.5.41",
|
|
16
16
|
"vue-router": "^5.2.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/node": "^26.1.2",
|
|
20
20
|
"@vitejs/plugin-vue": "^6.0.8",
|
|
21
21
|
"@vue/tsconfig": "^0.9.1",
|
|
22
|
-
"typescript": "~6.0.
|
|
22
|
+
"typescript": "~6.0.3",
|
|
23
23
|
"vite": "^8.2.0",
|
|
24
24
|
"vue-tsc": "^3.3.9"
|
|
25
25
|
}
|
|
@@ -59,7 +59,8 @@
|
|
|
59
59
|
</div>
|
|
60
60
|
<!-- 右侧科目列表 -->
|
|
61
61
|
<div class="right-account">
|
|
62
|
-
<
|
|
62
|
+
<van-field v-model="accountSearch" placeholder="搜索科目/编码" clearable style="margin:8px 12px;" />
|
|
63
|
+
<div v-for="acc in filteredAccountList" :key="acc.value" class="acc-item" @click="selectAccount(acc)">
|
|
63
64
|
{{ acc.text }}
|
|
64
65
|
</div>
|
|
65
66
|
</div>
|
|
@@ -68,7 +69,7 @@
|
|
|
68
69
|
</template>
|
|
69
70
|
|
|
70
71
|
<script lang="ts" setup>
|
|
71
|
-
import { ref, reactive, onMounted } from 'vue'
|
|
72
|
+
import { ref, reactive, onMounted, computed } from 'vue'
|
|
72
73
|
import { showToast } from 'vant'
|
|
73
74
|
import axios from 'axios'
|
|
74
75
|
|
|
@@ -82,6 +83,7 @@ const rawAccountList = ref<any[]>([])
|
|
|
82
83
|
const categoryList = ref<any[]>([])
|
|
83
84
|
const currentAccountList = ref<any[]>([])
|
|
84
85
|
const activeCateId = ref<number>()
|
|
86
|
+
const accountSearch = ref('')
|
|
85
87
|
|
|
86
88
|
const totalDebit = ref(0)
|
|
87
89
|
const totalCredit = ref(0)
|
|
@@ -111,6 +113,7 @@ const list = reactive<{
|
|
|
111
113
|
|
|
112
114
|
const voucher = reactive<Voucher>(initVoucher())
|
|
113
115
|
const entries = ref([
|
|
116
|
+
{ accountName: '', accountId: null, debit: '', credit: '', remark: '' },
|
|
114
117
|
{ accountName: '', accountId: null, debit: '', credit: '', remark: '' }
|
|
115
118
|
])
|
|
116
119
|
|
|
@@ -159,12 +162,53 @@ const switchCategory = (cateId: number) => {
|
|
|
159
162
|
currentAccountList.value = rawAccountList.value.filter(item => item.category === targetCate?.name)
|
|
160
163
|
}
|
|
161
164
|
|
|
165
|
+
// 根据搜索词计算显示的科目列表:
|
|
166
|
+
// - 若有搜索词,则在全部科目中全局匹配(code+name)
|
|
167
|
+
// - 否则显示当前分类的科目
|
|
168
|
+
const filteredAccountList = computed(() => {
|
|
169
|
+
const q = accountSearch.value.trim().toLowerCase()
|
|
170
|
+
if (!q) return currentAccountList.value
|
|
171
|
+
return rawAccountList.value.filter(item => item.text.toLowerCase().includes(q))
|
|
172
|
+
})
|
|
173
|
+
|
|
162
174
|
// 选择科目
|
|
163
175
|
const selectAccount = (acc: any) => {
|
|
164
|
-
const
|
|
176
|
+
const idx = currentEntryIndex.value
|
|
177
|
+
const entry = entries.value[idx]
|
|
165
178
|
entry.accountName = acc.text
|
|
166
179
|
entry.accountId = acc.value
|
|
167
180
|
showAccountPicker.value = false
|
|
181
|
+
|
|
182
|
+
// 自动平衡逻辑(仅在两笔分录时启用):
|
|
183
|
+
// 当一方已有借/贷金额且另一方金额为空时,选完科目后自动把数值填到对方相反栏位
|
|
184
|
+
if (entries.value.length === 2) {
|
|
185
|
+
const otherIdx = idx === 0 ? 1 : 0
|
|
186
|
+
const other = entries.value[otherIdx]
|
|
187
|
+
|
|
188
|
+
// 优先使用已有的对方金额去填当前项的相反栏位
|
|
189
|
+
if (other.debit !== '' && (entry.credit === '' || entry.credit == null)) {
|
|
190
|
+
entry.credit = other.debit
|
|
191
|
+
calcTotal()
|
|
192
|
+
return
|
|
193
|
+
}
|
|
194
|
+
if (other.credit !== '' && (entry.debit === '' || entry.debit == null)) {
|
|
195
|
+
entry.debit = other.credit
|
|
196
|
+
calcTotal()
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// 否则如果当前项已有金额,则填充另一项的相反栏位
|
|
201
|
+
if (entry.debit !== '' && (other.credit === '' || other.credit == null)) {
|
|
202
|
+
other.credit = entry.debit
|
|
203
|
+
calcTotal()
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
if (entry.credit !== '' && (other.debit === '' || other.debit == null)) {
|
|
207
|
+
other.debit = entry.credit
|
|
208
|
+
calcTotal()
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
}
|
|
168
212
|
}
|
|
169
213
|
|
|
170
214
|
const openAccountPicker = (index: number) => {
|
|
@@ -219,9 +263,12 @@ const submit = () => {
|
|
|
219
263
|
axios.post('/voucher/create', voucher).then(() => {
|
|
220
264
|
showToast('✅ 凭证保存成功')
|
|
221
265
|
|
|
222
|
-
//
|
|
266
|
+
// 自动新开空白凭证(两笔起步)
|
|
223
267
|
Object.assign(voucher, initVoucher())
|
|
224
|
-
entries.value = [
|
|
268
|
+
entries.value = [
|
|
269
|
+
{ accountName: '', accountId: null, debit: '', credit: '', remark: '' },
|
|
270
|
+
{ accountName: '', accountId: null, debit: '', credit: '', remark: '' }
|
|
271
|
+
]
|
|
225
272
|
calcTotal()
|
|
226
273
|
|
|
227
274
|
}).catch(err => {
|