feat:选择饭卡类型组件
This commit is contained in:
1 parent
52349bc31f
commit
c0fa9492f0
6 files changed
+363
-7
No files matched your search
@@ -0,0 +1,41 @@
|
|||||||
|
import request from "/@/utils/request"
|
||||||
|
|
||||||
|
export function fetchList(query?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/wallet/wallet-recharge-apply/page',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addObj(obj?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/wallet/wallet-recharge-apply',
|
||||||
|
method: 'post',
|
||||||
|
data: obj
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getObj(id?: string) {
|
||||||
|
return request({
|
||||||
|
url: '/wallet/wallet-recharge-apply/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function delObjs(ids?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/wallet/wallet-recharge-apply',
|
||||||
|
method: 'delete',
|
||||||
|
data: ids
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function putObj(obj?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/wallet/wallet-recharge-apply',
|
||||||
|
method: 'put',
|
||||||
|
data: obj
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
@@ -7,11 +7,6 @@
|
|||||||
<div class="color-primary">{{ v.name }}</div>
|
<div class="color-primary">{{ v.name }}</div>
|
||||||
<div class="pl5 color-success">{{ v.phone }}</div>
|
<div class="pl5 color-success">{{ v.phone }}</div>
|
||||||
</div>
|
</div>
|
||||||
<template #loading>
|
|
||||||
<svg class="circular" viewBox="0 0 50 50">
|
|
||||||
<circle class="path" cx="25" cy="25" r="20" fill="none" />
|
|
||||||
</svg>
|
|
||||||
</template>
|
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
@@ -61,8 +56,10 @@ async function getOptions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function remoteSearch(params: string) {
|
function remoteSearch(params: string) {
|
||||||
queryForm.name = params
|
if (params != queryForm.name) {
|
||||||
getOptions()
|
queryForm.name = params
|
||||||
|
getOptions()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear() {
|
function clear() {
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
<template>
|
||||||
|
<el-select style="width: 100%;" v-model="state.selectId" :placeholder="props.placeholder" clearable
|
||||||
|
remote-show-suffix filterable remote :remote-method="remoteSearch" :loading="state.loading"
|
||||||
|
@visible-change="(e: boolean) => e && getOptions()">
|
||||||
|
<el-option v-for="v in state.options" :key="v.id" :label="`${v.name}`" :value="v.id">
|
||||||
|
<div class="flex items-center justify-center">
|
||||||
|
<div class="color-primary">{{ v.name }}</div>
|
||||||
|
<div class="flex items-center just ml5">
|
||||||
|
<el-tag size="small">{{ state.walletType.find((i: any) => i.value == v.uniqueCode).label }}</el-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts" name="select-wallet-type">
|
||||||
|
import { reactive, computed, defineModel, withDefaults, defineProps } from 'vue'
|
||||||
|
import * as walletTypeApi from '/@/api/wallet/wallet-type'
|
||||||
|
import { useDict } from '/@/hooks/dict'
|
||||||
|
|
||||||
|
const selectId = defineModel()
|
||||||
|
|
||||||
|
export type Props = {
|
||||||
|
placeholder?: string,
|
||||||
|
}
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
placeholder: "请选择",
|
||||||
|
})
|
||||||
|
|
||||||
|
const queryForm = reactive<any>({
|
||||||
|
name: "",
|
||||||
|
current: 1,
|
||||||
|
size: 10,
|
||||||
|
})
|
||||||
|
|
||||||
|
const state = reactive<any>({
|
||||||
|
loading: true,
|
||||||
|
selectId: selectId,
|
||||||
|
options: [],
|
||||||
|
walletType: []
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(selectId, (newVal, oldValue) => {
|
||||||
|
if (newVal == oldValue) return
|
||||||
|
state.selectId = newVal
|
||||||
|
getOptions()
|
||||||
|
}, { immediate: true })
|
||||||
|
|
||||||
|
async function getOptions() {
|
||||||
|
try {
|
||||||
|
state.loading = true
|
||||||
|
const _pa = {
|
||||||
|
...queryForm
|
||||||
|
}
|
||||||
|
const { data } = await walletTypeApi.fetchList(_pa)
|
||||||
|
state.options = data.records ?? []
|
||||||
|
|
||||||
|
const { wallet_type } = useDict('wallet_type')
|
||||||
|
state.walletType = wallet_type
|
||||||
|
} finally {
|
||||||
|
setTimeout(() => state.loading = false, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function remoteSearch(params: string) {
|
||||||
|
if (params != queryForm.name) {
|
||||||
|
queryForm.name = params
|
||||||
|
getOptions()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function clear() {
|
||||||
|
state.selectId = null
|
||||||
|
getOptions()
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -15,6 +15,7 @@ import PreviewImage from "/@/components/PreviewImage/index.vue"
|
|||||||
|
|
||||||
// 业务组件
|
// 业务组件
|
||||||
import SelectUser from '/@/components/Select/SelectUser.vue'
|
import SelectUser from '/@/components/Select/SelectUser.vue'
|
||||||
|
import SelectWalletType from '/@/components/Select/SelectWalletType.vue'
|
||||||
|
|
||||||
|
|
||||||
// 第三方组件
|
// 第三方组件
|
||||||
@@ -52,6 +53,7 @@ export default {
|
|||||||
app.component('SvgIcon', SvgIcon);
|
app.component('SvgIcon', SvgIcon);
|
||||||
app.component('PreviewImage', PreviewImage)
|
app.component('PreviewImage', PreviewImage)
|
||||||
app.component('SelectUser', SelectUser)
|
app.component('SelectUser', SelectUser)
|
||||||
|
app.component('SelectWalletType', SelectWalletType)
|
||||||
|
|
||||||
// 导入全部的elmenet-plus的图标
|
// 导入全部的elmenet-plus的图标
|
||||||
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible" width="30%" :close-on-click-modal="false" draggable>
|
||||||
|
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
|
||||||
|
<el-row :gutter="24">
|
||||||
|
<el-col :span="24" class="mb20">
|
||||||
|
<el-form-item label="充值时间" prop="importTime">
|
||||||
|
<el-date-picker v-model="form.importTime" type="month" value-format="x" placeholder="请选择充值时间" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="24" class="mb20">
|
||||||
|
<el-form-item label="充值类型" prop="bizType">
|
||||||
|
<dict-select v-model="form.bizType" dict-code="wallet_biz_recharge" placeholder="请选择饭卡类型" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="24" class="mb20">
|
||||||
|
<el-form-item label="钱包" prop="walletTypeId">
|
||||||
|
<select-wallet-type v-model="form.walletTypeId" placeholder="请选择钱包" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="24" class="mb20">
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="form.remark" placeholder="请输入备注" type="textarea" :autosize="{ minRows: 6 }" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="visible = false">取消</el-button>
|
||||||
|
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts" name="WalletRechargeApplyDialog">
|
||||||
|
import { useDict } from '/@/hooks/dict';
|
||||||
|
import { useMessage } from "/@/hooks/message";
|
||||||
|
import { getObj, addObj, putObj } from '/@/api/wallet/wallet-recharge-apply'
|
||||||
|
import { rule } from '/@/utils/validate';
|
||||||
|
const emit = defineEmits(['refresh']);
|
||||||
|
|
||||||
|
// 定义变量内容
|
||||||
|
const dataFormRef = ref();
|
||||||
|
const visible = ref(false)
|
||||||
|
const loading = ref(false)
|
||||||
|
// 定义字典
|
||||||
|
|
||||||
|
// 提交表单数据
|
||||||
|
const form = reactive({
|
||||||
|
id: '',
|
||||||
|
userId: '',
|
||||||
|
bizType: '',
|
||||||
|
walletTypeId: '',
|
||||||
|
deptId: '',
|
||||||
|
importTime: '',
|
||||||
|
remark: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
// 定义校验规则
|
||||||
|
const dataRules = ref({
|
||||||
|
importTime: [{ required: true, message: '导入时间(手动选择)不能为空', trigger: 'change' }],
|
||||||
|
bizType: [{ required: true, message: '请选择充值类型', trigger: 'change' }],
|
||||||
|
walletTypeId: [{ required: true, message: '请选择钱包类型', trigger: 'change' }],
|
||||||
|
})
|
||||||
|
|
||||||
|
// 打开弹窗
|
||||||
|
const openDialog = (id: string) => {
|
||||||
|
visible.value = true
|
||||||
|
form.id = ''
|
||||||
|
|
||||||
|
// 重置表单数据
|
||||||
|
nextTick(() => {
|
||||||
|
dataFormRef.value?.resetFields();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 获取walletRechargeApply信息
|
||||||
|
if (id) {
|
||||||
|
form.id = id
|
||||||
|
getwalletRechargeApplyData(id)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 提交
|
||||||
|
const onSubmit = async () => {
|
||||||
|
const valid = await dataFormRef.value.validate().catch(() => { });
|
||||||
|
if (!valid) return false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
loading.value = true;
|
||||||
|
form.id ? await putObj(form) : await addObj(form);
|
||||||
|
useMessage().success(form.id ? '修改成功' : '添加成功');
|
||||||
|
visible.value = false;
|
||||||
|
emit('refresh');
|
||||||
|
} catch (err: any) {
|
||||||
|
useMessage().error(err.msg);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 初始化表单数据
|
||||||
|
const getwalletRechargeApplyData = (id: string) => {
|
||||||
|
// 获取数据
|
||||||
|
loading.value = true
|
||||||
|
getObj(id).then((res: any) => {
|
||||||
|
Object.assign(form, res.data)
|
||||||
|
}).finally(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
// 暴露变量
|
||||||
|
defineExpose({
|
||||||
|
openDialog
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
<template>
|
||||||
|
<div class="layout-padding">
|
||||||
|
<div class="layout-padding-auto layout-padding-view">
|
||||||
|
<el-row>
|
||||||
|
<div class="mb8" style="width: 100%">
|
||||||
|
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()"
|
||||||
|
v-auth="'wallet_walletRechargeApply_add'">
|
||||||
|
申 请
|
||||||
|
</el-button>
|
||||||
|
<el-button plain :disabled="multiple" icon="Delete" type="primary" v-auth="'wallet_walletRechargeApply_del'"
|
||||||
|
@click="handleDelete(selectObjs)">
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
<right-toolbar v-model:showSearch="showSearch" :export="'wallet_walletRechargeApply_export'"
|
||||||
|
@exportExcel="exportExcel" class="ml10 mr20" style="float: right;"
|
||||||
|
@queryTable="getDataList"></right-toolbar>
|
||||||
|
</div>
|
||||||
|
</el-row>
|
||||||
|
<el-table :data="state.dataList" v-loading="state.loading" border :cell-style="tableStyle.cellStyle"
|
||||||
|
:header-cell-style="tableStyle.headerCellStyle" @selection-change="selectionChangHandle"
|
||||||
|
@sort-change="sortChangeHandle">
|
||||||
|
<el-table-column type="selection" width="40" align="center" />
|
||||||
|
<el-table-column type="index" label="#" width="40" />
|
||||||
|
<el-table-column prop="userId" label="申请人ID" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="bizType" label="充值类型" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="walletTypeId" label="饭卡类型id" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="deptId" label="部门ID" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="importTime" label="导入时间(手动选择)" show-overflow-tooltip />
|
||||||
|
<el-table-column label="操作" width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button icon="edit-pen" text type="primary" v-auth="'wallet_walletRechargeApply_edit'"
|
||||||
|
@click="formDialogRef.openDialog(scope.row.id)">编辑</el-button>
|
||||||
|
<el-button icon="delete" text type="primary" v-auth="'wallet_walletRechargeApply_del'"
|
||||||
|
@click="handleDelete([scope.row.id])">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 编辑、新增 -->
|
||||||
|
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts" name="systemWalletRechargeApply">
|
||||||
|
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||||
|
import { fetchList, delObjs } from "/@/api/wallet/wallet-recharge-apply";
|
||||||
|
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||||
|
import { useDict } from '/@/hooks/dict';
|
||||||
|
|
||||||
|
// 引入组件
|
||||||
|
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||||
|
// 定义查询字典
|
||||||
|
|
||||||
|
// 定义变量内容
|
||||||
|
const formDialogRef = ref()
|
||||||
|
// 搜索变量
|
||||||
|
const queryRef = ref()
|
||||||
|
const showSearch = ref(true)
|
||||||
|
// 多选变量
|
||||||
|
const selectObjs = ref([]) as any
|
||||||
|
const multiple = ref(true)
|
||||||
|
|
||||||
|
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||||
|
queryForm: {},
|
||||||
|
pageList: fetchList
|
||||||
|
})
|
||||||
|
|
||||||
|
// table hook
|
||||||
|
const {
|
||||||
|
getDataList,
|
||||||
|
currentChangeHandle,
|
||||||
|
sizeChangeHandle,
|
||||||
|
sortChangeHandle,
|
||||||
|
downBlobFile,
|
||||||
|
tableStyle
|
||||||
|
} = useTable(state)
|
||||||
|
|
||||||
|
// 清空搜索条件
|
||||||
|
const resetQuery = () => {
|
||||||
|
// 清空搜索条件
|
||||||
|
queryRef.value?.resetFields()
|
||||||
|
// 清空多选
|
||||||
|
selectObjs.value = []
|
||||||
|
getDataList()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出excel
|
||||||
|
const exportExcel = () => {
|
||||||
|
downBlobFile('/wallet/walletRechargeApply/export', Object.assign(state.queryForm, { ids: selectObjs }), 'walletRechargeApply.xlsx')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 多选事件
|
||||||
|
const selectionChangHandle = (objs: { id: string }[]) => {
|
||||||
|
selectObjs.value = objs.map(({ id }) => id);
|
||||||
|
multiple.value = !objs.length;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 删除操作
|
||||||
|
const handleDelete = async (ids: string[]) => {
|
||||||
|
try {
|
||||||
|
await useMessageBox().confirm('此操作将永久删除');
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await delObjs(ids);
|
||||||
|
getDataList();
|
||||||
|
useMessage().success('删除成功');
|
||||||
|
} catch (err: any) {
|
||||||
|
useMessage().error(err.msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
Reference in new issue
Block a user