Merge branch 'feat-config-0609-xwk' into msb_test

msb_test
向文可 2 years ago
commit c4c0c671d8

@ -0,0 +1,14 @@
import request from '@/utils/request.js';
export const search = () => {
return request({
url: '/mall/base/orderConfig/getOrderConfig',
method: 'get',
});
};
export const update = (data) => {
return request({
url: '/mall/base/orderConfig/saveOrUpdate',
method: 'post',
data,
});
};

@ -0,0 +1,27 @@
import * as api from '@/api/config/order.js';
import { ElMessage } from '@/plugins/element-plus';
const state = () => ({});
const getters = {};
const mutations = {};
const actions = {
search: async () => {
let res = await api.search();
if (!res) {
ElMessage.error('查询订单配置失败');
}
return res;
},
update: async (context, data) => {
let res = await api.update(data);
if (!res) {
ElMessage.error('保存订单配置失败');
}
return res;
},
};
export default {
state,
getters,
mutations,
actions,
};

@ -0,0 +1,94 @@
<template>
<div class="list-container">
<el-form ref="refsForm" v-loading="state.loading" label-width="120px" :model="state.form" :rules="state.rules">
<el-form-item label="秒杀订单超过" prop="seckillOrderPayExpire">
<el-input v-model="state.form.seckillOrderPayExpire" :clearable="false" type="number">
<template #append></template>
</el-input>
<p>未付款订单自动关闭</p>
</el-form-item>
<el-form-item label="正常订单超过" prop="normalOrderPayExpire">
<el-input v-model="state.form.normalOrderPayExpire" :clearable="false" type="number">
<template #append></template>
</el-input>
<p>未付款订单自动关闭</p>
</el-form-item>
<el-form-item label="订单发货超过" prop="automaticReceipt">
<el-input v-model="state.form.automaticReceipt" :clearable="false" type="number">
<template #append></template>
</el-input>
<p>未收货订单自动完成</p>
</el-form-item>
<el-form-item label="订单完成超过" prop="afterSalesExpire">
<el-input v-model="state.form.afterSalesExpire" :clearable="false" type="number">
<template #append></template>
</el-input>
<p>自动结束交易不能申请售后</p>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleUpdate"></el-button>
<el-button @click="handleSearch"></el-button>
</el-form-item>
</el-form>
</div>
</template>
<script setup>
const { proxy } = getCurrentInstance();
const store = useStore();
const refsForm = ref(null);
const state = reactive({
loading: false,
form: {
seckillOrderPayExpire: 30,
normalOrderPayExpire: 30,
automaticReceipt: 15,
afterSalesExpire: 7,
},
rules: {
seckillOrderPayExpire: [{ required: true, message: '秒杀订单超时自动关闭不能为空' }],
normalOrderPayExpire: [{ required: true, message: '正常订单超时自动关闭不能为空' }],
automaticReceipt: [{ required: true, message: '订单发货超时自动完成不能为空' }],
afterSalesExpire: [{ required: true, message: '订单完成超时自动结束交易不能为空' }],
},
});
const handleSearch = async () => {
let res = await store.dispatch('orderConfig/search');
Object.assign(state.form, res);
};
handleSearch();
const handleUpdate = async () => {
state.loading = true;
try {
await proxy.$validate(refsForm);
await store.dispatch('orderConfig/update', state.form);
} catch (e) {
console.info('取消保存', e);
}
state.loading = false;
};
</script>
<style lang="less" scoped>
.list-container {
display: flex;
justify-content: center;
align-items: center;
.el-form {
// width: 680px;
:deep(.el-form-item__content) {
flex-wrap: nowrap;
.el-input {
width: 120px;
input {
text-align: center;
}
}
p {
min-width: max-content;
margin-left: @layout-space;
}
}
}
}
</style>
Loading…
Cancel
Save