parent
93f9253b85
commit
326b755ccc
@ -0,0 +1,37 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function index(params,isLoading = true) {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/api/admin/accompany-order-refund/index',
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function show(params,isLoading = true) {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/api/admin/accompany-order-refund/show',
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function save(data, isLoading = true) {
|
||||
return request({
|
||||
method: 'post',
|
||||
url: '/api/admin/accompany-order-refund/save',
|
||||
data,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
|
||||
export function destroy(params, isLoading = true) {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: '/api/admin/accompany-order-refund/destroy',
|
||||
params,
|
||||
isLoading
|
||||
})
|
||||
}
|
||||
@ -0,0 +1,424 @@
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<el-card shadow="never" style="margin-top: 20px;">
|
||||
<template #header>
|
||||
<slot name="header">
|
||||
<vxe-toolbar ref="toolbar" :export="isHasAuth('export')" :print="isHasAuth('print')" custom>
|
||||
<template #buttons>
|
||||
<el-input v-if="isHasAuth('search')" v-model="select.keyword" style="width: 160px;margin-right: 10px;" clearable size="small" placeholder="关键词搜索" />
|
||||
<el-button
|
||||
v-if="isHasAuth('create')"
|
||||
icon="el-icon-plus"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="isShowAdd = true"
|
||||
>新增</el-button>
|
||||
<el-button
|
||||
v-if="isHasAuth('search')"
|
||||
icon="el-icon-search"
|
||||
type="primary"
|
||||
plain
|
||||
size="small"
|
||||
@click="getList"
|
||||
>搜索</el-button>
|
||||
</template>
|
||||
</vxe-toolbar>
|
||||
</slot>
|
||||
</template>
|
||||
|
||||
<vxe-table
|
||||
ref="table"
|
||||
stripe
|
||||
style="margin-top: 10px"
|
||||
:loading="loading"
|
||||
:height="tableHeight"
|
||||
keep-source
|
||||
show-overflow
|
||||
:menu-config="{
|
||||
className: 'my-menus',
|
||||
body: {
|
||||
options: [
|
||||
[
|
||||
{ code: 'copy', name: '复制', prefixConfig: { icon: 'vxe-icon-copy' }, suffixConfig: { content: 'Ctrl+C' } },
|
||||
{ code: 'remove', name: '删除', prefixConfig: { icon: 'vxe-icon-delete-fill', className: 'color-red' } }
|
||||
],
|
||||
]
|
||||
}
|
||||
}"
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:column-config="{ resizable: true }"
|
||||
:export-config="{}"
|
||||
:edit-rules="validRules"
|
||||
:edit-config="{
|
||||
trigger: 'manual',
|
||||
mode: 'row',
|
||||
showStatus: true,
|
||||
isHover: true,
|
||||
autoClear: false,
|
||||
}"
|
||||
:align="allAlign"
|
||||
:expand-config="{
|
||||
padding: true
|
||||
}"
|
||||
:data="tableData"
|
||||
@menu-click="contextMenuClickEvent"
|
||||
>
|
||||
<vxe-column type="seq" width="58" align="center" />
|
||||
|
||||
<vxe-column type="expand" width="80" title="订单详情" align="center">
|
||||
<template #content="{ row }">
|
||||
<el-descriptions title="订单信息" :column="2">
|
||||
<el-descriptions-item label="订单编号">{{ row.order ? row.order.no : '' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="类型"><el-tag size="small">{{ row.order ? (row.order.type === 1 ? '陪诊' : '陪护') : '' }}</el-tag></el-descriptions-item>
|
||||
<el-descriptions-item label="服务状态"><el-tag size="small">{{ row.order ? status.get(row.order.status) : '待处理' }}</el-tag></el-descriptions-item>
|
||||
<el-descriptions-item label="服务名称">{{ row.order ? row.order.title : '' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="预约人">{{ row.order ? row.order.appoint_name : '' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="预约人电话">{{ row.order ? row.order.appoint_mobile : '' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="其他服务需求">
|
||||
{{ row.order ? row.order.content : '' }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column
|
||||
align="center"
|
||||
title="订单编号"
|
||||
field="order.no"
|
||||
width="180"
|
||||
/>
|
||||
<vxe-column
|
||||
align="center"
|
||||
title="退款编号"
|
||||
field="no"
|
||||
width="180"
|
||||
/>
|
||||
<vxe-column
|
||||
align="center"
|
||||
field="status"
|
||||
width="180"
|
||||
title="状态"
|
||||
:edit-render="{ name: 'VxeSelect', options: [{'value':0,'label':'未退款'},{'value':1,'label':'退款成功'},{'value':2,'label':'退款失败'}], props: { multiple: false }, optionProps: { value: 'value', label: 'label' } }"
|
||||
/>
|
||||
<vxe-column
|
||||
align="center"
|
||||
title="创建时间"
|
||||
field="created_at"
|
||||
width="180"
|
||||
/>
|
||||
|
||||
<vxe-column field="operate" header-align="center" title="操作" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<template v-if="isActiveStatus(row)">
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
@click="saveRowEvent(row)"
|
||||
>保存</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
@click="cancelRowEvent(row)"
|
||||
>取消</el-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-button
|
||||
v-if="isHasAuth('detail')"
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
@click="detail(row)"
|
||||
>查看</el-button>
|
||||
<el-button
|
||||
v-if="isHasAuth('edit')"
|
||||
size="small"
|
||||
type="warning"
|
||||
@click="editRowEvent(row)"
|
||||
>编辑</el-button>
|
||||
<el-button
|
||||
v-if="isHasAuth('delete')"
|
||||
size="small"
|
||||
type="danger"
|
||||
@click="destroyRowEvent(row)"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
|
||||
<el-pagination
|
||||
style="margin-top: 10px;display: flex;justify-content: flex-end;"
|
||||
:current-page.sync="select.page"
|
||||
:page-sizes="[20, 30, 40, 50]"
|
||||
:page-size.sync="select.page_size"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="total"
|
||||
@size-change="
|
||||
(e) => {
|
||||
select.page_size = e;
|
||||
select.page = 1;
|
||||
getList();
|
||||
}
|
||||
"
|
||||
@current-change="
|
||||
(e) => {
|
||||
select.page = e;
|
||||
getList();
|
||||
}
|
||||
"
|
||||
/>
|
||||
|
||||
</el-card>
|
||||
|
||||
<AddAccompanyOrderRefund
|
||||
ref="AddAccompanyOrderRefund"
|
||||
|
||||
:is-show.sync="isShowAdd"
|
||||
@refresh="getList"
|
||||
/>
|
||||
<ShowAccompanyOrderRefund
|
||||
ref="ShowAccompanyOrderRefund"
|
||||
|
||||
:is-show.sync="isShowDetail"
|
||||
/>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import VxeUI from 'vxe-pc-ui'
|
||||
|
||||
import { authMixin } from '@/mixin/authMixin'
|
||||
import { uploadSize } from '@/settings'
|
||||
import { deepCopy } from '@/utils'
|
||||
import { destroy, index, save } from '@/api/accompany-order-refund/accompany-order-refund'
|
||||
import AddAccompanyOrderRefund from './components/AddAccompanyOrderRefund.vue'
|
||||
import ShowAccompanyOrderRefund from './components/ShowAccompanyOrderRefund.vue'
|
||||
import axios from 'axios'
|
||||
import { getToken } from '@/utils/auth'
|
||||
|
||||
export default {
|
||||
name: 'AccompanyOrderRefund',
|
||||
components: {
|
||||
|
||||
AddAccompanyOrderRefund,
|
||||
ShowAccompanyOrderRefund
|
||||
},
|
||||
mixins: [authMixin],
|
||||
data() {
|
||||
return {
|
||||
uploadSize,
|
||||
examineKey: 0,
|
||||
isShowAdd: false,
|
||||
isShowDetail: false,
|
||||
|
||||
loading: false,
|
||||
tableHeight: 400,
|
||||
select: {
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
keyword: '',
|
||||
show_relation: ['order']
|
||||
|
||||
},
|
||||
total: 0,
|
||||
allAlign: null,
|
||||
tableData: [],
|
||||
form: {
|
||||
id: '',
|
||||
|
||||
status: ''
|
||||
|
||||
},
|
||||
validRules: {
|
||||
|
||||
},
|
||||
status: new Map([
|
||||
[0, '待处理'],
|
||||
[1, '已到客户家'],
|
||||
[2, '已接到客户'],
|
||||
[3, '已到医院'],
|
||||
[4, '完成服务']
|
||||
])
|
||||
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isActiveStatus() {
|
||||
return function(row) {
|
||||
if (this.$refs['table']) {
|
||||
return this.$refs['table'].isEditByRow(row)
|
||||
}
|
||||
}
|
||||
},
|
||||
isHasAuth() {
|
||||
return function(auth) {
|
||||
return this.auths_auth_mixin.indexOf(auth) !== -1
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
},
|
||||
mounted() {
|
||||
this.bindToolbar()
|
||||
this.calcTableHeight()
|
||||
},
|
||||
methods: {
|
||||
calcTableHeight() {
|
||||
const clientHeight = document.documentElement.clientHeight
|
||||
const cardTitle = document.querySelector('.el-card__header')?.getBoundingClientRect()?.height
|
||||
const search = document.querySelector('.vxe-toolbar')?.getBoundingClientRect()?.height
|
||||
const paginationHeight = (document.querySelector('.el-pagination')?.getBoundingClientRect()?.height ?? 0) + 10 // 分页的高度
|
||||
const topHeight = 50 // 页面 头部
|
||||
const padding = 80
|
||||
const margin = 20
|
||||
this.tableHeight =
|
||||
clientHeight - cardTitle - search - paginationHeight - topHeight - padding - margin
|
||||
},
|
||||
contextMenuClickEvent({ menu, row, column }) {
|
||||
switch (menu.code) {
|
||||
case 'copy':
|
||||
// 示例
|
||||
if (row && column) {
|
||||
if (VxeUI.clipboard.copy(row[column.field])) {
|
||||
this.$message.success('已复制到剪贴板!')
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'remove':
|
||||
if (row && column) {
|
||||
this.destroyRowEvent(row)
|
||||
}
|
||||
default:
|
||||
}
|
||||
},
|
||||
async detail(row) {
|
||||
await this.$refs['ShowAccompanyOrderRefund'].getDetail(row.id)
|
||||
this.isShowDetail = true
|
||||
},
|
||||
|
||||
uploadMethod(file) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
window.$_uploading = true
|
||||
return axios.post(process.env.VUE_APP_UPLOAD_API, formData, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${getToken()}`
|
||||
}
|
||||
}).then((response) => {
|
||||
window.$_uploading = false
|
||||
if (response.status === 200 && !response.data.code) {
|
||||
return {
|
||||
response: response.data,
|
||||
name: response.data.original_name,
|
||||
url: response.data.url
|
||||
}
|
||||
} else {
|
||||
this.$message.error('上传失败')
|
||||
}
|
||||
}).catch(_ => {
|
||||
window.$_uploading = false
|
||||
})
|
||||
},
|
||||
bindToolbar() {
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs['table'] && this.$refs['toolbar']) {
|
||||
this.$refs['table'].connect(this.$refs['toolbar'])
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
editRowEvent(row) {
|
||||
if (this.$refs['table']) {
|
||||
this.$refs['table'].setEditRow(row)
|
||||
}
|
||||
},
|
||||
cancelRowEvent(row) {
|
||||
if (this.$refs['table']) {
|
||||
this.$refs['table'].clearEdit().then(() => {
|
||||
// 还原行数据
|
||||
this.$refs['table'].revertData(row)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
async getList() {
|
||||
this.loading = true
|
||||
try {
|
||||
const res = await index(this.select, false)
|
||||
this.tableData = res.data
|
||||
this.total = res.total
|
||||
this.loading = false
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
async saveRowEvent(row) {
|
||||
if (window.$_uploading) {
|
||||
this.$message.warning('文件正在上传中')
|
||||
return
|
||||
}
|
||||
try {
|
||||
const errMap = await this.$refs['table'].validate()
|
||||
if (errMap) {
|
||||
throw new Error(errMap)
|
||||
}
|
||||
await this.$confirm('确认保存?', '提示', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消'
|
||||
})
|
||||
await this.$refs['table'].clearEdit()
|
||||
const form = deepCopy(this.form)
|
||||
for (const key in form) {
|
||||
form[key] = row[key]
|
||||
}
|
||||
|
||||
this.loading = true
|
||||
await save(form, false)
|
||||
await this.getList()
|
||||
this.loading = false
|
||||
} catch (err) {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
async destroyRowEvent(row) {
|
||||
try {
|
||||
await this.$confirm('确认删除?', '提示', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消'
|
||||
})
|
||||
this.loading = true
|
||||
if (row.id) {
|
||||
await destroy({
|
||||
id: row.id
|
||||
}, false)
|
||||
await this.getList()
|
||||
} else {
|
||||
console.log(row)
|
||||
this.tableData.splice(
|
||||
this.tableData.findIndex((i) => i._X_ROW_KEY === row._X_ROW_KEY),
|
||||
1
|
||||
)
|
||||
}
|
||||
this.loading = false
|
||||
} catch (err) {
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
::v-deep .el-card__header {
|
||||
padding: 6px 20px;
|
||||
}
|
||||
::v-deep .el-tag + .el-tag {
|
||||
margin-left: 4px;
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1,93 @@
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<el-drawer
|
||||
:title="$route.meta.title"
|
||||
direction="rtl"
|
||||
size="68%"
|
||||
:visible.sync="visible"
|
||||
append-to-body
|
||||
@close="$emit('update:isShow',false)"
|
||||
>
|
||||
<section class="drawer-container">
|
||||
<el-descriptions ref="elDesc" class="drawer-container__desc" size="small" border :column="2" direction="vertical" :label-style="{ 'font-weight': '500', 'font-size': '15px' }">
|
||||
|
||||
<el-descriptions-item label="状态">
|
||||
{{ [{'value':0,'label':'未退款'},{'value':1,'label':'退款成功'},{'value':2,'label':'退款失败'}].find(i => i['value'] === form['status']) ? [{'value':0,'label':'未退款'},{'value':1,'label':'退款成功'},{'value':2,'label':'退款失败'}].find(i => i[value] === form['status'])['label'] : '' }}
|
||||
</el-descriptions-item>
|
||||
|
||||
</el-descriptions>
|
||||
</section>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { show } from '@/api/accompany-order-refund/accompany-order-refund'
|
||||
|
||||
export default {
|
||||
name: 'AccompanyOrderRefundShow',
|
||||
props: {
|
||||
isShow: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
required: true
|
||||
}
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
visible: false,
|
||||
form: {
|
||||
|
||||
status: ''
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
isShow(newVal) {
|
||||
this.visible = newVal
|
||||
},
|
||||
visible(newVal) {
|
||||
this.$emit('update:isShow', newVal)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async getDetail(id) {
|
||||
try {
|
||||
const detail = await show({
|
||||
id
|
||||
})
|
||||
for (const key in this.form) {
|
||||
if (detail.hasOwnProperty(key)) {
|
||||
this.form[key] = detail[key]
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.span2 {
|
||||
grid-column: span 2;
|
||||
}
|
||||
::v-deep .el-form-item > * {
|
||||
max-width: 100%;
|
||||
}
|
||||
.drawer-container {
|
||||
height: 100%;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
& > * {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in new issue