pull/6/head
dwj 3 months ago
parent 648ef08f1f
commit 3f3d382407

Binary file not shown.

@ -1,9 +1,14 @@
<template>  <template>
<!-- 创建一个类名为 "app-container" div 作为整体页面容器 -->
<div class="app-container"> <div class="app-container">
<!-- 使用 el-card 组件创建一个卡片式容器用于放置筛选搜索相关内容设置类名为 "filter-container" 并取消阴影效果 -->
<el-card class="filter-container" shadow="never"> <el-card class="filter-container" shadow="never">
<div> <div>
<!-- 使用一个图标元素el-icon-search展示搜索图标 -->
<i class="el-icon-search"></i> <i class="el-icon-search"></i>
<!-- 展示一段文本内容为 "筛选搜索" -->
<span>筛选搜索</span> <span>筛选搜索</span>
<!-- el-button 组件创建一个按钮设置样式使其右浮动按钮类型为 "primary"点击时调用 "handleSearchList" 方法按钮大小为 "small"文本为 "查询搜索" -->
<el-button <el-button
style="float:right" style="float:right"
type="primary" type="primary"
@ -11,6 +16,7 @@
size="small"> size="small">
查询搜索 查询搜索
</el-button> </el-button>
<!-- 类似上述按钮设置右浮动及右外边距点击调用 "handleResetSearch" 方法用于重置筛选条件按钮大小为 "small"文本为 "重置" -->
<el-button <el-button
style="float:right;margin-right: 15px" style="float:right;margin-right: 15px"
@click="handleResetSearch()" @click="handleResetSearch()"
@ -19,13 +25,17 @@
</el-button> </el-button>
</div> </div>
<div style="margin-top: 15px"> <div style="margin-top: 15px">
<!-- el-form 组件创建一个内联表单绑定数据模型为 "listQuery"设置表单大小为 "small"标签宽度为 "140px" -->
<el-form :inline="true" :model="listQuery" size="small" label-width="140px"> <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
<!-- el-form-item 组件定义表单中的一项用于输入订单编号的搜索框双向绑定 "listQuery.orderSn"设置类名控制宽度添加占位提示文本 -->
<el-form-item label="输入搜索:"> <el-form-item label="输入搜索:">
<el-input v-model="listQuery.orderSn" class="input-width" placeholder="订单编号"></el-input> <el-input v-model="listQuery.orderSn" class="input-width" placeholder="订单编号"></el-input>
</el-form-item> </el-form-item>
<!-- 类似上述用于输入收货人相关关键字的搜索框绑定 "listQuery.receiverKeyword" -->
<el-form-item label="收货人:"> <el-form-item label="收货人:">
<el-input v-model="listQuery.receiverKeyword" class="input-width" placeholder="收货人姓名/手机号码"></el-input> <el-input v-model="listQuery.receiverKeyword" class="input-width" placeholder="收货人姓名/手机号码"></el-input>
</el-form-item> </el-form-item>
<!-- 用于选择提交时间的日期选择器绑定 "listQuery.createTime"设置日期格式类型为 "date"仅选择日期及占位提示文本通过类名控制宽度 -->
<el-form-item label="提交时间:"> <el-form-item label="提交时间:">
<el-date-picker <el-date-picker
class="input-width" class="input-width"
@ -35,6 +45,7 @@
placeholder="请选择时间"> placeholder="请选择时间">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<!-- 用于选择订单状态的下拉选择框绑定 "listQuery.status"设置类名控制宽度占位提示文本并允许清空选项通过循环选项数据动态生成下拉选项 -->
<el-form-item label="订单状态:"> <el-form-item label="订单状态:">
<el-select v-model="listQuery.status" class="input-width" placeholder="全部" clearable> <el-select v-model="listQuery.status" class="input-width" placeholder="全部" clearable>
<el-option v-for="item in statusOptions" <el-option v-for="item in statusOptions"
@ -44,6 +55,7 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- 用于选择订单分类的下拉选择框绑定 "listQuery.orderType"类似上述设置 -->
<el-form-item label="订单分类:"> <el-form-item label="订单分类:">
<el-select v-model="listQuery.orderType" class="input-width" placeholder="全部" clearable> <el-select v-model="listQuery.orderType" class="input-width" placeholder="全部" clearable>
<el-option v-for="item in orderTypeOptions" <el-option v-for="item in orderTypeOptions"
@ -53,6 +65,7 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- 用于选择订单来源的下拉选择框绑定 "listQuery.sourceType"同样的设置方式 -->
<el-form-item label="订单来源:"> <el-form-item label="订单来源:">
<el-select v-model="listQuery.sourceType" class="input-width" placeholder="全部" clearable> <el-select v-model="listQuery.sourceType" class="input-width" placeholder="全部" clearable>
<el-option v-for="item in sourceTypeOptions" <el-option v-for="item in sourceTypeOptions"
@ -65,41 +78,54 @@
</el-form> </el-form>
</div> </div>
</el-card> </el-card>
<!-- 使用 el-card 组件创建另一个卡片式容器用于展示数据列表相关的标题设置类名为 "operate-container" 并取消阴影效果 -->
<el-card class="operate-container" shadow="never"> <el-card class="operate-container" shadow="never">
<i class="el-icon-tickets"></i> <i class="el-icon-tickets"></i>
<span>数据列表</span> <span>数据列表</span>
</el-card> </el-card>
<!-- 创建一个类名为 "table-container" div用于放置展示数据的表格 -->
<div class="table-container"> <div class="table-container">
<!-- el-table 组件创建表格设置引用绑定数据宽度监听行选择变化事件以及控制加载状态等属性 -->
<el-table ref="orderTable" <el-table ref="orderTable"
:data="list" :data="list"
style="width: 100%;" style="width: 100%;"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
v-loading="listLoading" border> v-loading="listLoading" border>
<!-- 定义一个选择列用于多选表格行设置宽度和文本对齐方式 -->
<el-table-column type="selection" width="60" align="center"></el-table-column> <el-table-column type="selection" width="60" align="center"></el-table-column>
<!-- 定义表格列展示编号信息设置宽度和文本对齐方式通过插槽作用域获取对应行数据展示 -->
<el-table-column label="编号" width="80" align="center"> <el-table-column label="编号" width="80" align="center">
<template slot-scope="scope">{{scope.row.id}}</template> <template slot-scope="scope">{{scope.row.id}}</template>
</el-table-column> </el-table-column>
<!-- 定义表格列展示订单编号信息设置宽度和文本对齐方式 -->
<el-table-column label="订单编号" width="180" align="center"> <el-table-column label="订单编号" width="180" align="center">
<template slot-scope="scope">{{scope.row.orderSn}}</template> <template slot-scope="scope">{{scope.row.orderSn}}</template>
</el-table-column> </el-table-column>
<!-- 定义表格列展示提交时间信息设置宽度和文本对齐方式通过管道符调用 formatCreateTime 过滤器对时间进行格式化后展示 -->
<el-table-column label="提交时间" width="180" align="center"> <el-table-column label="提交时间" width="180" align="center">
<template slot-scope="scope">{{scope.row.createTime | formatCreateTime}}</template> <template slot-scope="scope">{{scope.row.createTime | formatCreateTime}}</template>
</el-table-column> </el-table-column>
<!-- 定义表格列展示用户账号信息设置文本对齐方式通过插槽作用域获取对应行数据展示 -->
<el-table-column label="用户账号" align="center"> <el-table-column label="用户账号" align="center">
<template slot-scope="scope">{{scope.row.memberUsername}}</template> <template slot-scope="scope">{{scope.row.memberUsername}}</template>
</el-table-column> </el-table-column>
<!-- 定义表格列展示订单金额信息设置宽度和文本对齐方式 -->
<el-table-column label="订单金额" width="120" align="center"> <el-table-column label="订单金额" width="120" align="center">
<template slot-scope="scope">{{scope.row.totalAmount}}</template> <template slot-scope="scope">{{scope.row.totalAmount}}</template>
</el-table-column> </el-table-column>
<!-- 定义表格列展示支付方式信息设置宽度和文本对齐方式通过管道符调用 formatPayType 过滤器对支付方式进行格式化后展示 -->
<el-table-column label="支付方式" width="120" align="center"> <el-table-column label="支付方式" width="120" align="center">
<template slot-scope="scope">{{scope.row.payType | formatPayType}}</template> <template slot-scope="scope">{{scope.row.payType | formatPayType}}</template>
</el-table-column> </el-table-column>
<!-- 定义表格列展示订单来源信息设置宽度和文本对齐方式通过管道符调用 formatSourceType 过滤器对订单来源进行格式化后展示 -->
<el-table-column label="订单来源" width="120" align="center"> <el-table-column label="订单来源" width="120" align="center">
<template slot-scope="scope">{{scope.row.sourceType | formatSourceType}}</template> <template slot-scope="scope">{{scope.row.sourceType | formatSourceType}}</template>
</el-table-column> </el-table-column>
<!-- 定义表格列展示订单状态信息设置宽度和文本对齐方式通过管道符调用 formatStatus 过滤器对订单状态进行格式化后展示 -->
<el-table-column label="订单状态" width="120" align="center"> <el-table-column label="订单状态" width="120" align="center">
<template slot-scope="scope">{{scope.row.status | formatStatus}}</template> <template slot-scope="scope">{{scope.row.status | formatStatus}}</template>
</el-table-column> </el-table-column>
<!-- 定义表格列展示操作按钮设置宽度和文本对齐方式通过插槽作用域根据不同订单状态动态显示相应操作按钮 -->
<el-table-column label="操作" width="200" align="center"> <el-table-column label="操作" width="200" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -127,7 +153,9 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- 创建一个类名为 "batch-operate-container" div用于放置批量操作相关的选择框和按钮 -->
<div class="batch-operate-container"> <div class="batch-operate-container">
<!-- el-select 组件创建下拉选择框设置大小绑定数据模型通过循环选项数据动态生成下拉选项 -->
<el-select <el-select
size="small" size="small"
v-model="operateType" placeholder="批量操作"> v-model="operateType" placeholder="批量操作">
@ -138,6 +166,7 @@
:value="item.value"> :value="item.value">
</el-option> </el-option>
</el-select> </el-select>
<!-- el-button 组件创建按钮设置左外边距类名点击调用 "handleBatchOperate" 方法按钮类型为 "primary" 以及按钮大小为 "small"文本为 "确定" -->
<el-button <el-button
style="margin-left: 20px" style="margin-left: 20px"
class="search-button" class="search-button"
@ -147,7 +176,9 @@
确定 确定
</el-button> </el-button>
</div> </div>
<!-- 创建一个类名为 "pagination-container" div用于放置分页组件 -->
<div class="pagination-container"> <div class="pagination-container">
<!-- el-pagination 组件创建分页器设置背景色监听页面大小和当前页变化事件配置分页布局绑定当前页每页显示数量以及可选的每页显示数量选项和总数据条数等属性 -->
<el-pagination <el-pagination
background background
@size-change="handleSizeChange" @size-change="handleSizeChange"
@ -159,6 +190,7 @@
:total="total"> :total="total">
</el-pagination> </el-pagination>
</div> </div>
<!-- el-dialog 组件创建一个对话框用于关闭订单时输入备注信息设置标题绑定可见性以及宽度等属性 -->
<el-dialog <el-dialog
title="关闭订单" title="关闭订单"
:visible.sync="closeOrder.dialogVisible" width="30%"> :visible.sync="closeOrder.dialogVisible" width="30%">
@ -175,13 +207,20 @@
<el-button type="primary" @click="handleCloseOrderConfirm"> </el-button> <el-button type="primary" @click="handleCloseOrderConfirm"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
<!-- 使用 logistics-dialog 组件自定义组件双向绑定 visible 属性推测用于控制显示隐藏 -->
<logistics-dialog v-model="logisticsDialogVisible"></logistics-dialog> <logistics-dialog v-model="logisticsDialogVisible"></logistics-dialog>
</div> </div>
</template> </template>
<script> <script>
import {fetchList,closeOrder,deleteOrder} from '@/api/order' // '@/api/order' API
import {fetchList, closeOrder, deleteOrder} from '@/api/order';
// '@/utils/date' formatDate
import {formatDate} from '@/utils/date'; import {formatDate} from '@/utils/date';
// LogisticsDialog
import LogisticsDialog from '@/views/oms/order/components/logisticsDialog'; import LogisticsDialog from '@/views/oms/order/components/logisticsDialog';
// listQuery null
const defaultListQuery = { const defaultListQuery = {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
@ -192,22 +231,96 @@
sourceType: null, sourceType: null,
createTime: null, createTime: null,
}; };
// Vue datacreatedmethods
export default { export default {
name: '组件名称(这里未定义,可自行补充合适名称)',
data() {
return {
// Object.assign defaultListQuery
listQuery: Object.assign({}, defaultListQuery),
//
list: [],
// false
listLoading: false,
// null
operateType: null,
// label value
operateOptions: [],
//
statusOptions: [],
//
orderTypeOptions: [],
//
sourceTypeOptions: [],
//
closeOrder: {
dialogVisible: false,
content: null
},
// false
logisticsDialogVisible: false
}
},
created() {
// fetchList list
// fetchList(this.listQuery).then(response => { this.list = response.data; });
},
methods: {
// fetchList
handleSearchList() {
//
this.listLoading = true;
fetchList(this.listQuery).then(response => {
this.list = response.data;
this.listLoading = false;
});
},
// handleSearchList listQuery
handleResetSearch() {
// listQuery
this.listQuery = Object.assign({}, defaultListQuery);
this.handleSearchList();
},
//
handleSelectionChange(selections) {
// selections
},
//
handleViewOrder(index, row) {
//
this.$router.push({path: '/orderDetail', query: {id: row.id}});
},
//
<script>
// Vue 使
export default {
// Vue
name: "orderList", name: "orderList",
// 使 LogisticsDialog
components: {LogisticsDialog}, components: {LogisticsDialog},
data() { data() {
return { return {
// Object.assign defaultListQuery
listQuery: Object.assign({}, defaultListQuery), listQuery: Object.assign({}, defaultListQuery),
// true
listLoading: true, listLoading: true,
// null
list: null, list: null,
// null
total: null, total: null,
// null
operateType: null, operateType: null,
//
multipleSelection: [], multipleSelection: [],
// id
closeOrder: { closeOrder: {
dialogVisible: false, dialogVisible: false,
content: null, content: null,
orderIds: [] orderIds: []
}, },
// label value
statusOptions: [ statusOptions: [
{ {
label: '待付款', label: '待付款',
@ -230,6 +343,7 @@
value: 4 value: 4
} }
], ],
//
orderTypeOptions: [ orderTypeOptions: [
{ {
label: '正常订单', label: '正常订单',
@ -240,6 +354,7 @@
value: 1 value: 1
} }
], ],
//
sourceTypeOptions: [ sourceTypeOptions: [
{ {
label: 'PC订单', label: 'PC订单',
@ -250,6 +365,7 @@
value: 1 value: 1
} }
], ],
//
operateOptions: [ operateOptions: [
{ {
label: "批量发货", label: "批量发货",
@ -264,17 +380,21 @@
value: 3 value: 3
} }
], ],
// false
logisticsDialogVisible: false logisticsDialogVisible: false
} }
}, },
created() { created() {
// getList
this.getList(); this.getList();
}, },
filters: { filters: {
// formatCreateTime 'yyyy-MM-dd hh:mm:ss'
formatCreateTime(time) { formatCreateTime(time) {
let date = new Date(time); let date = new Date(time);
return formatDate(date, 'yyyy-MM-dd hh:mm:ss') return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
}, },
// 1 ''2 '' ''
formatPayType(value) { formatPayType(value) {
if (value === 1) { if (value === 1) {
return '支付宝'; return '支付宝';
@ -284,6 +404,7 @@
return '未支付'; return '未支付';
} }
}, },
// 1 'APP' 'PC'
formatSourceType(value) { formatSourceType(value) {
if (value === 1) { if (value === 1) {
return 'APP订单'; return 'APP订单';
@ -291,6 +412,7 @@
return 'PC订单'; return 'PC订单';
} }
}, },
//
formatStatus(value) { formatStatus(value) {
if (value === 1) { if (value === 1) {
return '待发货'; return '待发货';
@ -308,35 +430,44 @@
}, },
}, },
methods: { methods: {
// listQuery defaultListQuery 便
handleResetSearch() { handleResetSearch() {
this.listQuery = Object.assign({}, defaultListQuery); this.listQuery = Object.assign({}, defaultListQuery);
}, },
// 1 getList
handleSearchList() { handleSearchList() {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.getList(); this.getList();
}, },
// val multipleSelection
handleSelectionChange(val) { handleSelectionChange(val) {
this.multipleSelection = val; this.multipleSelection = val;
}, },
// Vue this.$router'/oms/orderDetail' id
handleViewOrder(index, row) { handleViewOrder(index, row) {
this.$router.push({path: '/oms/orderDetail', query: {id: row.id}}) this.$router.push({path: '/oms/orderDetail', query: {id: row.id}})
}, },
// visible true id closeOrder.orderIds 便使
handleCloseOrder(index, row) { handleCloseOrder(index, row) {
this.closeOrder.dialogVisible = true; this.closeOrder.dialogVisible = true;
this.closeOrder.orderIds = [row.id]; this.closeOrder.orderIds = [row.id];
}, },
// covertOrder '/oms/deliverOrderList'
handleDeliveryOrder(index, row) { handleDeliveryOrder(index, row) {
let listItem = this.covertOrder(row); let listItem = this.covertOrder(row);
this.$router.push({path: '/oms/deliverOrderList', query: {list: [listItem]}}) this.$router.push({path: '/oms/deliverOrderList', query: {list: [listItem]}})
}, },
// logisticsDialogVisible true
handleViewLogistics(index, row) { handleViewLogistics(index, row) {
this.logisticsDialogVisible = true; this.logisticsDialogVisible = true;
}, },
// ids id deleteOrder ids
handleDeleteOrder(index, row) { handleDeleteOrder(index, row) {
let ids = []; let ids = [];
ids.push(row.id); ids.push(row.id);
this.deleteOrder(ids); this.deleteOrder(ids);
}, },
//
handleBatchOperate() { handleBatchOperate() {
if (this.multipleSelection == null || this.multipleSelection.length < 1) { if (this.multipleSelection == null || this.multipleSelection.length < 1) {
this.$message({ this.$message({
@ -346,14 +477,16 @@
}); });
return; return;
} }
// 1
if (this.operateType === 1) { if (this.operateType === 1) {
//
let list = []; let list = [];
// 1 covertOrder list
for (let i = 0; i < this.multipleSelection.length; i++) { for (let i = 0; i < this.multipleSelection.length; i++) {
if (this.multipleSelection[i].status === 1) { if (this.multipleSelection[i].status === 1) {
list.push(this.covertOrder(this.multipleSelection[i])); list.push(this.covertOrder(this.multipleSelection[i]));
} }
} }
// 0
if (list.length === 0) { if (list.length === 0) {
this.$message({ this.$message({
message: '选中订单中没有可以发货的订单', message: '选中订单中没有可以发货的订单',
@ -362,32 +495,38 @@
}); });
return; return;
} }
// '/oms/deliverOrderList'
this.$router.push({path: '/oms/deliverOrderList', query: {list: list}}) this.$router.push({path: '/oms/deliverOrderList', query: {list: list}})
} else if (this.operateType === 2) { } else if (this.operateType === 2) {
// // 2
// closeOrder.orderIds id closeOrder.orderIds visible true
this.closeOrder.orderIds = []; this.closeOrder.orderIds = [];
for (let i = 0; i < this.multipleSelection.length; i++) { for (let i = 0; i < this.multipleSelection.length; i++) {
this.closeOrder.orderIds.push(this.multipleSelection[i].id); this.closeOrder.orderIds.push(this.multipleSelection[i].id);
} }
this.closeOrder.dialogVisible = true; this.closeOrder.dialogVisible = true;
} else if (this.operateType === 3) { } else if (this.operateType === 3) {
// // 3
let ids = []; let ids = [];
// id ids deleteOrder ids
for (let i = 0; i < this.multipleSelection.length; i++) { for (let i = 0; i < this.multipleSelection.length; i++) {
ids.push(this.multipleSelection[i].id); ids.push(this.multipleSelection[i].id);
} }
this.deleteOrder(ids); this.deleteOrder(ids);
} }
}, },
// 1 getList
handleSizeChange(val) { handleSizeChange(val) {
this.listQuery.pageNum = 1; this.listQuery.pageNum = 1;
this.listQuery.pageSize = val; this.listQuery.pageSize = val;
this.getList(); this.getList();
}, },
// getList
handleCurrentChange(val) { handleCurrentChange(val) {
this.listQuery.pageNum = val; this.listQuery.pageNum = val;
this.getList(); this.getList();
}, },
//
handleCloseOrderConfirm() { handleCloseOrderConfirm() {
if (this.closeOrder.content == null || this.closeOrder.content === '') { if (this.closeOrder.content == null || this.closeOrder.content === '') {
this.$message({ this.$message({
@ -397,6 +536,15 @@
}); });
return; return;
} }
//
}
}
}
</script>
let params = new URLSearchParams(); let params = new URLSearchParams();
params.append('ids', this.closeOrder.orderIds); params.append('ids', this.closeOrder.orderIds);
params.append('note', this.closeOrder.content); params.append('note', this.closeOrder.content);

@ -1,39 +1,50 @@
<template>  <template>
<!-- 使用 el-card 组件创建一个卡片式的容器设置类名为 "form-container"并通过 shadow="never" 属性取消卡片的阴影效果 -->
<el-card class="form-container" shadow="never"> <el-card class="form-container" shadow="never">
<!-- el-form 组件用于创建表单它绑定了名为 "orderSetting" 的数据模型设置了表单的引用名称为 "orderSettingForm"同时指定了表单验证规则 "rules"以及标签的宽度为 150px -->
<el-form :model="orderSetting" <el-form :model="orderSetting"
ref="orderSettingForm" ref="orderSettingForm"
:rules="rules" :rules="rules"
label-width="150px"> label-width="150px">
<!-- el-form-item 组件用于定义表单中的每一个表单项此处是针对 "秒杀订单超过" 这一设置项的表单项通过 prop 属性指定了验证对应的字段名 -->
<el-form-item label="秒杀订单超过:" prop="flashOrderOvertime"> <el-form-item label="秒杀订单超过:" prop="flashOrderOvertime">
<!-- el-input 组件创建一个输入框通过 v-model 指令双向绑定了 "orderSetting.flashOrderOvertime" 数据意味着用户在输入框中输入的值会实时更新到对应的数据属性中同时设置了类名 "input-width" 用于控制输入框宽度 -->
<el-input v-model="orderSetting.flashOrderOvertime" class="input-width"> <el-input v-model="orderSetting.flashOrderOvertime" class="input-width">
<!-- 使用 slot="append" 插槽在输入框后面添加一个单位文本 "分"用于提示用户输入的时间单位 -->
<template slot="append"></template> <template slot="append"></template>
</el-input> </el-input>
<!-- 一个普通的 <span> 标签用于显示一段提示文本设置了类名 "note-margin" 来控制其左边距提示内容为未付款时订单自动关闭的相关说明 -->
<span class="note-margin">未付款订单自动关闭</span> <span class="note-margin">未付款订单自动关闭</span>
</el-form-item> </el-form-item>
<!-- 与上面类似的表单项针对 "正常订单超过" 的设置同样有输入框及对应的提示信息 -->
<el-form-item label="正常订单超过:" prop="normalOrderOvertime"> <el-form-item label="正常订单超过:" prop="normalOrderOvertime">
<el-input v-model="orderSetting.normalOrderOvertime" class="input-width"> <el-input v-model="orderSetting.normalOrderOvertime" class="input-width">
<template slot="append"></template> <template slot="append"></template>
</el-input> </el-input>
<span class="note-margin">未付款订单自动关闭</span> <span class="note-margin">未付款订单自动关闭</span>
</el-form-item> </el-form-item>
<!-- 针对 "发货超过" 的表单项输入框用于输入天数后面跟着相应的提示文本 -->
<el-form-item label="发货超过:" prop="confirmOvertime"> <el-form-item label="发货超过:" prop="confirmOvertime">
<el-input v-model="orderSetting.confirmOvertime" class="input-width"> <el-input v-model="orderSetting.confirmOvertime" class="input-width">
<template slot="append"></template> <template slot="append"></template>
</el-input> </el-input>
<span class="note-margin">未收货订单自动完成</span> <span class="note-margin">未收货订单自动完成</span>
</el-form-item> </el-form-item>
<!-- 针对 "订单完成超过" 的表单项此处有重复的标签名但应是不同业务场景下的时间设置同样有输入框和对应的提示内容 -->
<el-form-item label="订单完成超过:" prop="finishOvertime"> <el-form-item label="订单完成超过:" prop="finishOvertime">
<el-input v-model="orderSetting.finishOvertime" class="input-width"> <el-input v-model="orderSetting.finishOvertime" class="input-width">
<template slot="append"></template> <template slot="append"></template>
</el-input> </el-input>
<span class="note-margin">自动结束交易不能申请售后</span> <span class="note-margin">自动结束交易不能申请售后</span>
</el-form-item> </el-form-item>
<!-- 另一个针对 "订单完成超过" 的表单项可能对应不同的业务逻辑如自动五星好评相关的时间设置同样具备输入框和提示文本 -->
<el-form-item label="订单完成超过:" prop="commentOvertime"> <el-form-item label="订单完成超过:" prop="commentOvertime">
<el-input v-model="orderSetting.commentOvertime" class="input-width"> <el-input v-model="orderSetting.commentOvertime" class="input-width">
<template slot="append"></template> <template slot="append"></template>
</el-input> </el-input>
<span class="note-margin">自动五星好评</span> <span class="note-margin">自动五星好评</span>
</el-form-item> </el-form-item>
<!-- 定义一个表单项内部放置一个 el-button 按钮通过 @click 指令绑定了 "confirm('orderSettingForm')" 方法即点击按钮时会调用名为 "confirm" 的方法并传入 "orderSettingForm" 参数按钮类型设置为 "primary"文本显示为 "提交" -->
<el-form-item> <el-form-item>
<el-button <el-button
@click="confirm('orderSettingForm')" @click="confirm('orderSettingForm')"
@ -42,8 +53,12 @@
</el-form> </el-form>
</el-card> </el-card>
</template> </template>
<script> <script>
// '@/api/orderSetting' "getOrderSetting" "updateOrderSetting"
import {getOrderSetting, updateOrderSetting} from '@/api/orderSetting'; import {getOrderSetting, updateOrderSetting} from '@/api/orderSetting';
// "defaultOrderSetting" 0 null
const defaultOrderSetting = { const defaultOrderSetting = {
id: null, id: null,
flashOrderOvertime: 0, flashOrderOvertime: 0,
@ -52,22 +67,33 @@
finishOvertime: 0, finishOvertime: 0,
commentOvertime: 0 commentOvertime: 0
}; };
// "checkTime" 使
const checkTime = (rule, value, callback) => { const checkTime = (rule, value, callback) => {
// callback Error
if (!value) { if (!value) {
return callback(new Error('时间不能为空')); return callback(new Error('时间不能为空'));
} }
console.log("checkTime", value); console.log("checkTime", value);
// parseInt
let intValue = parseInt(value); let intValue = parseInt(value);
// callback Error
if (!Number.isInteger(intValue)) { if (!Number.isInteger(intValue)) {
return callback(new Error('请输入数字值')); return callback(new Error('请输入数字值'));
} }
// callback
callback(); callback();
}; };
// Vue
export default { export default {
// Vue "orderSetting"
name: 'orderSetting', name: 'orderSetting',
data() { data() {
return { return {
// "orderSetting" Object.assign "defaultOrderSetting"
orderSetting: Object.assign({}, defaultOrderSetting), orderSetting: Object.assign({}, defaultOrderSetting),
// 使 "checkTime" 'blur'
rules: { rules: {
flashOrderOvertime: {validator: checkTime, trigger: 'blur'}, flashOrderOvertime: {validator: checkTime, trigger: 'blur'},
normalOrderOvertime: {validator: checkTime, trigger: 'blur'}, normalOrderOvertime: {validator: checkTime, trigger: 'blur'},
@ -78,17 +104,24 @@
} }
}, },
created() { created() {
// "getDetail"
this.getDetail(); this.getDetail();
}, },
methods: { methods: {
// "confirm" "formName"
confirm(formName) { confirm(formName) {
// this.$refs[formName] validate "valid"
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
// "valid" true
if (valid) { if (valid) {
// 使 $confirm "warning"
this.$confirm('是否要提交修改?', '提示', { this.$confirm('是否要提交修改?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
// "" "updateOrderSetting" 1 "orderSetting"
// then 使 $message "!" 1000 1
updateOrderSetting(1, this.orderSetting).then(response => { updateOrderSetting(1, this.orderSetting).then(response => {
this.$message({ this.$message({
type: 'success', type: 'success',
@ -98,6 +131,7 @@
}) })
}); });
} else { } else {
// "valid" false使 $message ""
this.$message({ this.$message({
message: '提交参数不合法', message: '提交参数不合法',
type: 'warning' type: 'warning'
@ -106,7 +140,9 @@
} }
}); });
}, },
// "getDetail"
getDetail() { getDetail() {
// "getOrderSetting" 1 then "orderSetting" 便
getOrderSetting(1).then(response => { getOrderSetting(1).then(response => {
this.orderSetting = response.data; this.orderSetting = response.data;
}) })
@ -114,14 +150,14 @@
} }
} }
</script> </script>
<style scoped> <style scoped>
/* 定义类名为 "input-width" 的样式规则,设置元素的宽度为父元素宽度的 50%,这个类名应用到了输入框上,用于控制输入框在表单中的宽度占比,使其看起来更美观、布局更合理 */
.input-width { .input-width {
width: 50%; width: 50%;
} }
/* 定义类名为 "note-margin" 的样式规则,设置元素的左边距为 15 像素,这个类名应用到了提示文本的 <span> 标签上,用于控制提示文本与输入框之间的距离,使其有合适的间隔,视觉效果更好 */
.note-margin { .note-margin {
margin-left: 15px; margin-left: 15px;
} }
</style> </style>

Loading…
Cancel
Save