fix: 优化交易记录功能,储蓄账户类型筛选。
This commit is contained in:
@@ -16,6 +16,11 @@
|
|||||||
inputAlign="right" border="none"></u--input>
|
inputAlign="right" border="none"></u--input>
|
||||||
<u-icon slot="right" name="arrow-down"></u-icon>
|
<u-icon slot="right" name="arrow-down"></u-icon>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
|
<u-form-item label="储蓄账户类型" v-show="debitTypeShow" prop="tempDebitTypeName" @click="handleDebitType">
|
||||||
|
<u--input v-model="tempDebitTypeName" disabled disabledColor="#ffffff" placeholder="请选择储蓄账户类型"
|
||||||
|
inputAlign="right" border="none"></u--input>
|
||||||
|
<u-icon slot="right" name="arrow-down"></u-icon>
|
||||||
|
</u-form-item>
|
||||||
<u-form-item label="记账账户" prop="accountName" required @click="handleAccountName">
|
<u-form-item label="记账账户" prop="accountName" required @click="handleAccountName">
|
||||||
<u--input v-model="form.accountName" disabled disabledColor="#ffffff" placeholder="请选择记账账户"
|
<u--input v-model="form.accountName" disabled disabledColor="#ffffff" placeholder="请选择记账账户"
|
||||||
inputAlign="right" border="none"></u--input>
|
inputAlign="right" border="none"></u--input>
|
||||||
@@ -57,6 +62,8 @@
|
|||||||
<u-toast ref="uToast"></u-toast>
|
<u-toast ref="uToast"></u-toast>
|
||||||
<u-picker itemHeight="88" :show="showAccountType" :columns="accountTypeList" keyName="dictLabel" @cancel="handleAccountTypeCancel"
|
<u-picker itemHeight="88" :show="showAccountType" :columns="accountTypeList" keyName="dictLabel" @cancel="handleAccountTypeCancel"
|
||||||
@confirm="handleAccountTypeConfirm"></u-picker>
|
@confirm="handleAccountTypeConfirm"></u-picker>
|
||||||
|
<u-picker itemHeight="88" :show="showDebitType" :columns="debitTypeList" keyName="dictLabel" @cancel="handleDebitTypeCancel"
|
||||||
|
@confirm="handleDebitTypeConfirm"></u-picker>
|
||||||
<u-picker itemHeight="88" :show="showAccountName" :columns="accountNameList" keyName="nameCodeAvailableLimit" @cancel="handleAccountNameCancel"
|
<u-picker itemHeight="88" :show="showAccountName" :columns="accountNameList" keyName="nameCodeAvailableLimit" @cancel="handleAccountNameCancel"
|
||||||
@confirm="handleAccountNameConfirm"></u-picker>
|
@confirm="handleAccountNameConfirm"></u-picker>
|
||||||
<u-picker itemHeight="88" :show="showDealCategory" :columns="dealCategoryList" keyName="dictLabel" @cancel="handleDealCategoryCancel"
|
<u-picker itemHeight="88" :show="showDealCategory" :columns="dealCategoryList" keyName="dictLabel" @cancel="handleDealCategoryCancel"
|
||||||
@@ -93,14 +100,20 @@ const showAccountName = ref(false)
|
|||||||
const showDealCategory = ref(false)
|
const showDealCategory = ref(false)
|
||||||
const showChildCategory = ref(false)
|
const showChildCategory = ref(false)
|
||||||
const showDealType = ref(false)
|
const showDealType = ref(false)
|
||||||
|
const showDebitType = ref(false)
|
||||||
const title = ref("账户交易记录")
|
const title = ref("账户交易记录")
|
||||||
const accountTypeList = ref([])
|
const accountTypeList = ref([])
|
||||||
const accountNameList = ref([])
|
const accountNameList = ref([])
|
||||||
const dealCategoryList = ref([])
|
const dealCategoryList = ref([])
|
||||||
const childCategoryList = ref([])
|
const childCategoryList = ref([])
|
||||||
|
const debitTypeList = ref([])
|
||||||
const childCategoryShow = ref(true)
|
const childCategoryShow = ref(true)
|
||||||
|
const debitTypeShow = ref(false)
|
||||||
const flag = ref('add')
|
const flag = ref('add')
|
||||||
const dealTypeList = ref([])
|
const dealTypeList = ref([])
|
||||||
|
// 临时变量,仅用于前端筛选,不保存到数据库
|
||||||
|
const tempDebitType = ref(null)
|
||||||
|
const tempDebitTypeName = ref(null)
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
form: {
|
form: {
|
||||||
id: null,
|
id: null,
|
||||||
@@ -123,10 +136,12 @@ const data = reactive({
|
|||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
status: '1',
|
status: '1',
|
||||||
type: '1',
|
type: '1',
|
||||||
|
debitType: null,
|
||||||
pageSize: 1000
|
pageSize: 1000
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
typeName: [{ required: true, message: '记账类型不能为空', trigger:['change', 'blur'] }],
|
typeName: [{ required: true, message: '记账类型不能为空', trigger:['change', 'blur'] }],
|
||||||
|
tempDebitTypeName: [{ required: false, message: '储蓄账户类型不能为空', trigger: ['change', 'blur'] }],
|
||||||
accountName: [{ required: true, message: '记账账户不能为空', trigger: ['change', 'blur'] }],
|
accountName: [{ required: true, message: '记账账户不能为空', trigger: ['change', 'blur'] }],
|
||||||
amount: [{type: 'number', required: true, message: '交易金额不能为空', trigger: ['change', 'blur'] }],
|
amount: [{type: 'number', required: true, message: '交易金额不能为空', trigger: ['change', 'blur'] }],
|
||||||
dealTypeName: [{ required: true, message: '交易类型不能为空', trigger:['change', 'blur'] }],
|
dealTypeName: [{ required: true, message: '交易类型不能为空', trigger:['change', 'blur'] }],
|
||||||
@@ -154,6 +169,10 @@ onLoad((option) => {
|
|||||||
})
|
})
|
||||||
onReady(() => {
|
onReady(() => {
|
||||||
form.value.createTime = dayjs(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss")
|
form.value.createTime = dayjs(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss")
|
||||||
|
// 新增时默认显示储蓄账户类型筛选(因为默认就是储蓄卡)
|
||||||
|
if(form.value.id == null && flag.value == null) {
|
||||||
|
debitTypeShow.value = true
|
||||||
|
}
|
||||||
getData()
|
getData()
|
||||||
})
|
})
|
||||||
function getData() {
|
function getData() {
|
||||||
@@ -161,6 +180,10 @@ onLoad((option) => {
|
|||||||
// 类型
|
// 类型
|
||||||
getDicts('account_type').then(res => {
|
getDicts('account_type').then(res => {
|
||||||
accountTypeList.value =[res.data]
|
accountTypeList.value =[res.data]
|
||||||
|
})
|
||||||
|
// 储蓄账户类型
|
||||||
|
getDicts('debit_type').then(res => {
|
||||||
|
debitTypeList.value =[res.data]
|
||||||
})
|
})
|
||||||
// 类型
|
// 类型
|
||||||
getDicts('deal_type').then(res => {
|
getDicts('deal_type').then(res => {
|
||||||
@@ -198,6 +221,7 @@ onLoad((option) => {
|
|||||||
if(form.value.id!=null){
|
if(form.value.id!=null){
|
||||||
getAccountDealRecord(form.value.id).then(res => {
|
getAccountDealRecord(form.value.id).then(res => {
|
||||||
form.value = res.data
|
form.value = res.data
|
||||||
|
|
||||||
if (form.value.dealCategory === '1') {
|
if (form.value.dealCategory === '1') {
|
||||||
childCategoryShow.value = true
|
childCategoryShow.value = true
|
||||||
// 交易类别
|
// 交易类别
|
||||||
@@ -229,9 +253,28 @@ getDicts('deal_category').then(result => {
|
|||||||
queryAccountParams.value.type = null
|
queryAccountParams.value.type = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 编辑和复制时,如果是储蓄账户,自动回填储蓄账户类型并显示筛选框
|
||||||
|
if(form.value.type === '1' && form.value.accountId) {
|
||||||
|
debitTypeShow.value = true
|
||||||
|
// 从账户列表中查找当前账户的储蓄账户类型
|
||||||
|
listAccounts({pageNum: 1, pageSize: 1000, type: '1', status: '1'}).then((response) => {
|
||||||
|
const currentAccount = response.rows.find(item => item.id === form.value.accountId)
|
||||||
|
if(currentAccount && currentAccount.debitType) {
|
||||||
|
tempDebitType.value = currentAccount.debitType
|
||||||
|
getDicts('debit_type').then(result => {
|
||||||
|
tempDebitTypeName.value = dictStr(currentAccount.debitType, result.data)
|
||||||
|
})
|
||||||
|
queryAccountParams.value.debitType = currentAccount.debitType
|
||||||
|
}
|
||||||
|
accountNameList.value = [response.rows.filter(item => item.debitType === tempDebitType.value)]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果是复制模式,重置交易时间
|
||||||
if(flag.value!=null){
|
if(flag.value!=null){
|
||||||
form.value.createTime = dayjs(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss")
|
form.value.createTime = dayjs(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss")
|
||||||
}
|
}
|
||||||
|
|
||||||
listAccounts(queryAccountParams.value).then((response) => {
|
listAccounts(queryAccountParams.value).then((response) => {
|
||||||
accountNameList.value = [response.rows]
|
accountNameList.value = [response.rows]
|
||||||
})
|
})
|
||||||
@@ -264,15 +307,52 @@ getDicts('deal_category').then(result => {
|
|||||||
queryAccountParams.value.type = form.value.type
|
queryAccountParams.value.type = form.value.type
|
||||||
form.value.accountId = null
|
form.value.accountId = null
|
||||||
form.value.accountName = null
|
form.value.accountName = null
|
||||||
|
tempDebitType.value = null
|
||||||
|
tempDebitTypeName.value = null
|
||||||
|
queryAccountParams.value.debitType = null
|
||||||
|
|
||||||
|
// 如果是储蓄账户(type='1')且不是修改模式,显示储蓄账户类型选择
|
||||||
|
if (form.value.type === '1' && form.value.id == null) {
|
||||||
|
debitTypeShow.value = true
|
||||||
|
} else {
|
||||||
|
debitTypeShow.value = false
|
||||||
listAccounts(queryAccountParams.value).then((response) => {
|
listAccounts(queryAccountParams.value).then((response) => {
|
||||||
accountNameList.value = [response.rows]
|
accountNameList.value = [response.rows]
|
||||||
})
|
})
|
||||||
|
}
|
||||||
showAccountType.value = false
|
showAccountType.value = false
|
||||||
|
|
||||||
}
|
}
|
||||||
function handleAccountTypeCancel() {
|
function handleAccountTypeCancel() {
|
||||||
showAccountType.value = false
|
showAccountType.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleDebitType() {
|
||||||
|
if (debitTypeList.value[0].length === 0) {
|
||||||
|
proxy.$refs['uToast'].show({
|
||||||
|
message: '储蓄账户类型为空', type: 'warning'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
showDebitType.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDebitTypeConfirm(e) {
|
||||||
|
tempDebitTypeName.value = e.value[0].dictLabel
|
||||||
|
tempDebitType.value = e.value[0].dictValue
|
||||||
|
queryAccountParams.value.debitType = tempDebitType.value
|
||||||
|
form.value.accountId = null
|
||||||
|
form.value.accountName = null
|
||||||
|
listAccounts(queryAccountParams.value).then((response) => {
|
||||||
|
accountNameList.value = [response.rows]
|
||||||
|
})
|
||||||
|
showDebitType.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDebitTypeCancel() {
|
||||||
|
showDebitType.value = false
|
||||||
|
}
|
||||||
|
|
||||||
function handleAccountName() {
|
function handleAccountName() {
|
||||||
if (accountNameList.value[0].length === 0) {
|
if (accountNameList.value[0].length === 0) {
|
||||||
proxy.$refs['uToast'].show({
|
proxy.$refs['uToast'].show({
|
||||||
|
|||||||
@@ -92,6 +92,10 @@
|
|||||||
<text class="row-label">记账类型:</text>
|
<text class="row-label">记账类型:</text>
|
||||||
<text class="row-value">{{ dictStr(item.type, accountTypeList) }}</text>
|
<text class="row-value">{{ dictStr(item.type, accountTypeList) }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="item-row" v-show="item.type === '1' && getAccountDebitType(item.accountId)">
|
||||||
|
<text class="row-label">储蓄账户类型:</text>
|
||||||
|
<text class="row-value">{{ dictStr(getAccountDebitType(item.accountId), debitTypeList) }}</text>
|
||||||
|
</view>
|
||||||
<view class="item-row">
|
<view class="item-row">
|
||||||
<text class="row-label">交易时间:</text>
|
<text class="row-label">交易时间:</text>
|
||||||
<text class="row-value">{{ item.createTime }}</text>
|
<text class="row-value">{{ item.createTime }}</text>
|
||||||
@@ -161,6 +165,7 @@ const status = ref('loadmore')
|
|||||||
const accountTypeList = ref([])
|
const accountTypeList = ref([])
|
||||||
const dealTypeList = ref([])
|
const dealTypeList = ref([])
|
||||||
const dealCategoryList = ref([])
|
const dealCategoryList = ref([])
|
||||||
|
const debitTypeList = ref([])
|
||||||
const settingPickShow = ref(false)
|
const settingPickShow = ref(false)
|
||||||
const settingColumns = ref([])
|
const settingColumns = ref([])
|
||||||
const showAccount = ref(false)
|
const showAccount = ref(false)
|
||||||
@@ -250,6 +255,10 @@ function getDict() {
|
|||||||
getDicts('deal_category').then(res => {
|
getDicts('deal_category').then(res => {
|
||||||
dealCategoryList.value = res.data
|
dealCategoryList.value = res.data
|
||||||
})
|
})
|
||||||
|
// 储蓄账户类型
|
||||||
|
getDicts('debit_type').then(res => {
|
||||||
|
debitTypeList.value = res.data
|
||||||
|
})
|
||||||
}
|
}
|
||||||
function settingConfirm(e) {
|
function settingConfirm(e) {
|
||||||
queryParams.value.settingId = e.value[0].settingId
|
queryParams.value.settingId = e.value[0].settingId
|
||||||
@@ -268,6 +277,14 @@ function dictStr(val, arr) {
|
|||||||
})
|
})
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据账户ID获取储蓄账户类型
|
||||||
|
function getAccountDebitType(accountId) {
|
||||||
|
if (!accountId || !accountList.value[0]) return null
|
||||||
|
const account = accountList.value[0].find(item => item.id === accountId)
|
||||||
|
return account ? account.debitType : null
|
||||||
|
}
|
||||||
|
|
||||||
function handleAccount() {
|
function handleAccount() {
|
||||||
if (accountList.value[0].length === 0) {
|
if (accountList.value[0].length === 0) {
|
||||||
proxy.$refs['uToast'].show({
|
proxy.$refs['uToast'].show({
|
||||||
|
|||||||
Reference in New Issue
Block a user