新增支付方式添加与修改
This commit is contained in:
25
src/api/setting.js
Normal file
25
src/api/setting.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付方式
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function tbShopPayTypeGet(params) {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbShopPayType',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更改/增加支付方式
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function tbShopPayType(data, method = 'post') {
|
||||||
|
return request({
|
||||||
|
url: '/api/tbShopPayType',
|
||||||
|
method: method,
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
94
src/views/systemMerchant/components/addPayType.vue
Normal file
94
src/views/systemMerchant/components/addPayType.vue
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog title="添加支付方式" :visible.sync="dialogVisible" :show-close="false" @close="reset">
|
||||||
|
<el-form ref="form" :model="form" label-width="120px" label-position="left">
|
||||||
|
<el-form-item label="支付方式" prop="">
|
||||||
|
<el-input v-model="form.payName" placeholder="请输入商户号"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="是否虚拟">
|
||||||
|
<el-radio-group v-model="form.isIdeal">
|
||||||
|
<el-radio :label="1">虚拟</el-radio>
|
||||||
|
<el-radio :label="0">非虚拟</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
<div class="tips">虚拟:微信、支付宝支付等。 非虚拟:现金</div>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="开钱箱权限">
|
||||||
|
<el-switch v-model="form.isOpenCashDrawer" :active-value="1" :inactive-value="0"></el-switch>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="是否生效">
|
||||||
|
<el-switch v-model="form.isDisplay" :active-value="1" :inactive-value="0"></el-switch>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="排序">
|
||||||
|
<el-input-number v-model="form.sorts" controls-position="right" :min="0"></el-input-number>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="close">取消</el-button>
|
||||||
|
<el-button type="primary" @click="submitHandle" :loading="formLoading">
|
||||||
|
<span v-if="!formLoading">保存</span>
|
||||||
|
<span v-else>保存中...</span>
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { tbShopPayType } from '@/api/setting'
|
||||||
|
export default ({
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dialogVisible: false,
|
||||||
|
formLoading: false,
|
||||||
|
resetForm: '',
|
||||||
|
form: {
|
||||||
|
id: '',
|
||||||
|
shopId: localStorage.getItem('shopId'),
|
||||||
|
payName: '',
|
||||||
|
isIdeal: 1,
|
||||||
|
isOpenCashDrawer: 1,
|
||||||
|
isDisplay: 1,
|
||||||
|
sorts: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.resetForm = { ...this.form }
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 保存
|
||||||
|
async submitHandle() {
|
||||||
|
this.formLoading = true
|
||||||
|
try {
|
||||||
|
await tbShopPayType(this.form, this.form.id ? 'put' : 'post')
|
||||||
|
this.$emit('success')
|
||||||
|
this.formLoading = false
|
||||||
|
this.$notify({
|
||||||
|
title: '成功',
|
||||||
|
message: `${this.form.pid ? '编辑' : '添加'}成功`,
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
this.close()
|
||||||
|
} catch (error) {
|
||||||
|
this.formLoading = false
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
close() {
|
||||||
|
this.dialogVisible = false
|
||||||
|
},
|
||||||
|
reset() {
|
||||||
|
this.form = { ...this.resetForm }
|
||||||
|
},
|
||||||
|
show(obj) {
|
||||||
|
this.dialogVisible = true
|
||||||
|
if (obj && obj.id) {
|
||||||
|
this.form.id = obj.id
|
||||||
|
this.form.payName = obj.payName
|
||||||
|
this.form.isIdeal = obj.isIdeal
|
||||||
|
this.form.isOpenCashDrawer = obj.isOpenCashDrawer
|
||||||
|
this.form.isDisplay = obj.isDisplay
|
||||||
|
this.form.sorts = obj.sorts
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -1,158 +1,123 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<!--工具栏-->
|
|
||||||
<div class="head-container">
|
<div class="head-container">
|
||||||
<div v-if="crud.props.searchToggle">
|
<el-button type="primary" icon="el-icon-plus" @click="$refs.addPayType.show()">添加支付方式</el-button>
|
||||||
<!-- 搜索 -->
|
</div>
|
||||||
<label class="el-form-item-label">自增id</label>
|
<div class="head-container">
|
||||||
<el-input v-model="query.id" clearable placeholder="自增id" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
|
<el-table :data="tableData.list" v-loading="tableData.loading">
|
||||||
<label class="el-form-item-label">支付类型</label>
|
<el-table-column prop="payName" label="支付方式"></el-table-column>
|
||||||
<el-input v-model="query.payType" clearable placeholder="支付类型" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
|
<el-table-column prop="payType" label="类型"></el-table-column>
|
||||||
<label class="el-form-item-label">支付类型名称</label>
|
<el-table-column prop="isOpenCashDrawer" label="开钱箱权限">
|
||||||
<el-input v-model="query.payName" clearable placeholder="支付类型名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
|
<template v-slot="scope">
|
||||||
<label class="el-form-item-label">是否快捷展示</label>
|
<el-switch v-model="scope.row.isOpenCashDrawer" :active-value="1" :inactive-value="0" disabled></el-switch>
|
||||||
<el-input v-model="query.isShowShortcut" clearable placeholder="是否快捷展示" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
|
</template>
|
||||||
<label class="el-form-item-label">店铺id</label>
|
|
||||||
<el-input v-model="query.shopId" clearable placeholder="店铺id" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
|
|
||||||
<label class="el-form-item-label">是否打开钱箱</label>
|
|
||||||
<el-input v-model="query.isOpenCashDrawer" clearable placeholder="是否打开钱箱" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
|
|
||||||
<label class="el-form-item-label">createdAt</label>
|
|
||||||
<el-input v-model="query.createdAt" clearable placeholder="createdAt" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
|
|
||||||
<label class="el-form-item-label">排序</label>
|
|
||||||
<el-input v-model="query.sorts" clearable placeholder="排序" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
|
|
||||||
<rrOperation :crud="crud" />
|
|
||||||
</div>
|
|
||||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
|
||||||
<crudOperation :permission="permission" />
|
|
||||||
<!--表单组件-->
|
|
||||||
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
|
|
||||||
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
|
|
||||||
<el-form-item label="自增id" prop="id">
|
|
||||||
<el-input v-model="form.id" style="width: 370px;" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="支付类型">
|
|
||||||
<el-input v-model="form.payType" style="width: 370px;" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="支付类型名称">
|
|
||||||
<el-input v-model="form.payName" style="width: 370px;" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="是否快捷展示">
|
|
||||||
<el-radio-group v-model="form.isShowShortcut" style="width: 140px">
|
|
||||||
<el-radio label="1">是</el-radio>
|
|
||||||
<el-radio label="0">否</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="店铺id">
|
|
||||||
<el-input v-model="form.shopId" style="width: 370px;" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="是否打开钱箱">
|
|
||||||
<el-radio-group v-model="form.isOpenCashDrawer" style="width: 140px">
|
|
||||||
<el-radio label="1">是</el-radio>
|
|
||||||
<el-radio label="0">否</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="createdAt">
|
|
||||||
<el-input v-model="form.createdAt" style="width: 370px;" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="排序">
|
|
||||||
<el-input v-model="form.sorts" style="width: 370px;" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<div slot="footer" class="dialog-footer">
|
|
||||||
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
|
||||||
<el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
|
||||||
</div>
|
|
||||||
</el-dialog>
|
|
||||||
<!--表格渲染-->
|
|
||||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
|
||||||
<el-table-column type="selection" width="55" />
|
|
||||||
<el-table-column prop="id" label="自增id" />
|
|
||||||
<el-table-column prop="payType" label="支付类型" />
|
|
||||||
<el-table-column prop="payName" label="支付类型名称" />
|
|
||||||
<el-table-column prop="isShowShortcut" label="是否快捷展示" >
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<span>{{ form.isShowShortcut == 1 ? '是' : '否' }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column prop="isDisplay" label="是否生效">
|
||||||
<el-table-column prop="shopId" label="店铺id" />
|
<template v-slot="scope">
|
||||||
|
<el-switch v-model="scope.row.isDisplay" :active-value="1" :inactive-value="0" disabled></el-switch>
|
||||||
<el-table-column prop="isOpenCashDrawer" label="是否打开钱箱">
|
</template>
|
||||||
<el-switch
|
|
||||||
v-model="form.isOpenCashDrawer"
|
|
||||||
class="switch"
|
|
||||||
:active-value="1"
|
|
||||||
:inactive-value="0"
|
|
||||||
active-text="是"
|
|
||||||
inactive-text="否"
|
|
||||||
/>
|
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="createdAt" label="createdAt" />
|
<el-table-column prop="sorts" label="条件排序"></el-table-column>
|
||||||
<el-table-column prop="sorts" label="排序" />
|
<el-table-column label="操作" width="150">
|
||||||
<el-table-column v-if="checkPer(['admin','tbShopPayType:edit','tbShopPayType:del'])" label="操作" width="150px" align="center">
|
<template v-slot="scope">
|
||||||
<template slot-scope="scope">
|
<el-button type="text" icon="el-icon-edit" @click="$refs.addPayType.show(scope.row)">编辑</el-button>
|
||||||
<udOperation
|
|
||||||
:data="scope.row"
|
|
||||||
:permission="permission"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
<!--分页组件-->
|
|
||||||
<pagination />
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="head-container">
|
||||||
|
<el-pagination :total="tableData.total" :current-page="tableData.page + 1" :page-size="tableData.size"
|
||||||
|
@current-change="paginationChange" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
|
||||||
|
</div>
|
||||||
|
<addPayType ref="addPayType" @success="getTableData" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import crudTbShopPayType from '@/api/tbShopPayType'
|
import dayjs from 'dayjs'
|
||||||
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
import { tbShopPayTypeGet } from '@/api/setting.js'
|
||||||
import rrOperation from '@crud/RR.operation'
|
import addPayType from './components/addPayType'
|
||||||
import crudOperation from '@crud/CRUD.operation'
|
|
||||||
import udOperation from '@crud/UD.operation'
|
|
||||||
import pagination from '@crud/Pagination'
|
|
||||||
|
|
||||||
const defaultForm = { id: null, payType: null, payName: null, isShowShortcut: null, shopId: null, isRefundable: null, isOpenCashDrawer: null, isSystem: null, isIdeal: null, isDisplay: null, createdAt: null, updatedAt: null, sorts: null }
|
|
||||||
export default {
|
export default {
|
||||||
name: 'TbShopPayType',
|
components: { addPayType },
|
||||||
components: { pagination, crudOperation, rrOperation, udOperation },
|
|
||||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
|
||||||
cruds() {
|
|
||||||
return CRUD({ title: '/merchant/system/paytype', url: 'api/tbShopPayType', idField: 'id', sort: 'id,desc', crudMethod: { ...crudTbShopPayType }})
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
permission: {
|
dayjs,
|
||||||
add: ['admin', 'tbShopPayType:add'],
|
query: {
|
||||||
edit: ['admin', 'tbShopPayType:edit'],
|
name: '',
|
||||||
del: ['admin', 'tbShopPayType:del']
|
account: '',
|
||||||
|
status: ''
|
||||||
},
|
},
|
||||||
rules: {
|
status: [
|
||||||
id: [
|
{
|
||||||
{ required: true, message: '自增id不能为空', trigger: 'blur' }
|
type: 1,
|
||||||
]
|
label: '开启'
|
||||||
},
|
},
|
||||||
queryTypeOptions: [
|
{
|
||||||
{ key: 'id', display_name: '自增id' },
|
type: 0,
|
||||||
{ key: 'payType', display_name: '支付类型' },
|
label: '关闭'
|
||||||
{ key: 'payName', display_name: '支付类型' },
|
}
|
||||||
{ key: 'isShowShortcut', display_name: '是否快捷展示' },
|
],
|
||||||
{ key: 'shopId', display_name: '店铺id' },
|
tableData: {
|
||||||
{ key: 'isOpenCashDrawer', display_name: '是否打开钱箱' },
|
list: [],
|
||||||
{ key: 'createdAt', display_name: 'createdAt' },
|
page: 0,
|
||||||
{ key: 'sorts', display_name: '排序' }
|
size: 10,
|
||||||
]
|
loading: false,
|
||||||
|
total: 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.getTableData()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
dropdownClick(e) {
|
||||||
[CRUD.HOOK.beforeRefresh]() {
|
switch (e.command) {
|
||||||
return true
|
case 1:
|
||||||
|
this.$refs.detailModal.show(e.row)
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 重置查询
|
||||||
|
resetHandle() {
|
||||||
|
this.query.name = ''
|
||||||
|
this.query.account = ''
|
||||||
|
this.query.status = ''
|
||||||
|
this.getTableData()
|
||||||
|
},
|
||||||
|
// 分页回调
|
||||||
|
paginationChange(e) {
|
||||||
|
this.tableData.page = e - 1
|
||||||
|
this.getTableData()
|
||||||
|
},
|
||||||
|
// 获取商家列表
|
||||||
|
async getTableData() {
|
||||||
|
this.tableData.loading = true
|
||||||
|
try {
|
||||||
|
const res = await tbShopPayTypeGet({
|
||||||
|
page: this.tableData.page,
|
||||||
|
size: this.tableData.size,
|
||||||
|
shopId: localStorage.getItem('shopId')
|
||||||
|
})
|
||||||
|
this.tableData.loading = false
|
||||||
|
this.tableData.list = res.content
|
||||||
|
this.tableData.total = res.totalElements
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped lang="scss">
|
||||||
|
.shop_info {
|
||||||
|
display: flex;
|
||||||
|
|
||||||
</style>
|
.info {
|
||||||
|
flex: 1;
|
||||||
|
padding-left: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user