index.vue
6.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<!-- -->
<template>
<div style="padding: 0 10px;background-color:#f7f7f7;">
<div class="tab_show">
<!-- 搜索 -->
<div class="formSearch">
<el-form :inline="true" :model="formParams" class="demo-form-inline">
<el-form-item label="方案名称">
<el-input v-model="formParams.logisticsName" placeholder="请输入方案名称" />
</el-form-item>
<el-form-item>
<el-button style="background-color: #3F9B6A;color: #fff" @click="add">新增物流方案</el-button>
<el-button style="background-color: #3F9B6A;color: #fff" @click="search">查询</el-button>
<span v-for="(item,index) in btnList" :key="index" class="promissStyle">
<el-button type="success" plain @click="btnClick(item)">{{ item.permissionName }}</el-button>
</span>
</el-form-item>
</el-form>
</div>
<!-- 表格 -->
<div class="tableBox">
<el-table
ref="multipleTable"
:data="tableData"
:header-cell-style="{fontSize: '14px',color:'#0009',fontWeight: 'normal',backgroundColor:'#F2F3F5'}"
tooltip-effect="dark"
>
<el-table-column label="方案名称" width="220">
<template slot-scope="scope">{{ scope.row.logisticsName }}</template>
</el-table-column>
<el-table-column prop="regions" label="可配送范围" width="420" />
<el-table-column prop="name" label="计费方式" width="220">
<template slot-scope="scope">
<span v-if="scope.row.chargeType == 1">按件数</span>
<span v-if="scope.row.chargeType == 2">按重量</span>
<span v-if="scope.row.chargeType == 3">包邮</span>
</template>
</el-table-column>
<el-table-column label="操作" show-overflow-tooltip>
<template slot-scope="scope">
<div class="btnList">
<div @click="seeMore(scope.row)" class="tableBtn greens">查看</div>
<div @click="edit(scope.row)" class="tableBtn greens">编辑</div>
<div @click="del(scope.row)" class="tableBtn greens">删除</div>
</div>
</template>
</el-table-column>
</el-table>
<div class="fenye">
<el-pagination
:current-page="currentPage"
:page-sizes="[10, 20, 50, 100]"
:page-size="10"
background
small
layout="prev, pager, next,total"
:total="total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
</div>
</div>
<!-- 方案组件 -->
<grope-edit
ref="edit"
:dialog-visible="dialog.isVisible"
:type="dialog.type"
@close="editClose"
@success="getLists"
/>
</div>
</template>
<script>
// 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
// 例如:import 《组件名称》 from '《组件路径》';
import { getBtnList } from '@/utils/auth'
import { logisticsGetAll, logisticsDelete } from '@/api/shopSys'
import GropeEdit from './Edit'
export default {
components: {
GropeEdit
},
data() {
// 这里存放数据
return {
btnList: '',
formParams: {
logisticsName: '',
page: 1,
pageSize: 10
},
total: 1,
tableData: [],
currentPage: 1,
dialog: {
type: 'add',
isVisible: false
}
}
},
// 监听属性 类似于data概念
computed: {},
// 监控data中的数据变化
watch: {},
// 生命周期 - 创建完成(可以访问当前this实例)
created() {},
// 生命周期 - 挂载完成(可以访问DOM元素)
mounted() {
this.getList(this.formParams)
this.btnList = getBtnList()
console.log(this.btnList, 'btnList')
},
// 方法集合
methods: {
btnClick(id) {
console.log(id)
if (id.permissionName === '新建方案') {
this.add()
}
},
handleSizeChange(val) {
this.formParams.pageSize = val
this.getList(this.formParams)
},
handleCurrentChange(val) {
this.formParams.page = val
this.getList(this.formParams)
},
getLists() {
console.log(111)
this.getList(this.formParams)
},
// 查询
search() {
this.total = 1
this.formParams.page = 1
this.getList(this.formParams)
},
// 新建方案
add() {
this.dialog = {
type: 'add',
isVisible: true
}
},
// 查看
seeMore(row) {
const { logisticsId } = row
this.dialog = {
type: 'check',
isVisible: true
}
this.$refs.edit.setParams({
checkId: logisticsId
})
},
// 编辑
edit(row) {
const { logisticsId } = row
this.dialog = {
type: 'edit',
isVisible: true
}
this.$refs.edit.setParams({
checkId: logisticsId
})
},
// 关闭弹框
editClose() {
this.dialog.isVisible = false
},
// 删除
del(row) {
this.$confirm('选中数据将被永久删除, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
logisticsDelete({ logisticsId: row.logisticsId }).then(res => {
if (res.code === '') {
this.$message({
type: 'success',
message: '删除成功!'
})
}
this.getList(this.formParams)
})
})
.catch(() => {})
},
// 初始化查询所有数据
async getList(formParams) {
const res = await logisticsGetAll(formParams)
this.tableData = res.data.list
this.total = res.data.total
}
}
}
</script>
<style lang='scss' scoped>
//@import url(); 引入公共css类
@import url("../../../styles/elDialog.scss");
.tab_show {
padding: 0 20px 20px 20px;
background-color:#fff;
}
.fenye {
margin-top: 20px;
display: flex;
justify-content: flex-end;
position: relative;
}
::v-deep .el-pagination__total {
position: absolute;
left: 10px;
}
.formSearch {
display: flex;
width: 100%;
font-size: 14px;
justify-content: space-between;
}
</style>