|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <div>
|
|
|
3
|
+ <el-card :body-style="cardBodyStyle">
|
|
|
4
|
+ <el-form :model="query" label-width="auto" label-position="right">
|
|
|
5
|
+ <el-row :gutter="10">
|
|
|
6
|
+ <el-col :span="5">
|
|
|
7
|
+ <el-form-item label="客户名称" style="margin-bottom: 0px;">
|
|
|
8
|
+ <el-select v-model="query.customerName" filterable placeholder="请选择客户" clearable style="width:100%;" size="small">
|
|
|
9
|
+ <el-option v-for="item in optionsCust" :key="item.id" :label="item.customerNm" :value="item.customerNm" />
|
|
|
10
|
+ </el-select>
|
|
|
11
|
+ </el-form-item>
|
|
|
12
|
+ </el-col>
|
|
|
13
|
+ <el-col :span="4">
|
|
|
14
|
+ <el-form-item label="" style="margin-bottom: 0px; margin-top: 5px;">
|
|
|
15
|
+ <el-button type="primary" @click="handleSearch">查询</el-button>
|
|
|
16
|
+ <el-button type="success" @click="handleAdd">新增</el-button>
|
|
|
17
|
+ </el-form-item>
|
|
|
18
|
+ </el-col>
|
|
|
19
|
+ </el-row>
|
|
|
20
|
+ </el-form>
|
|
|
21
|
+ </el-card>
|
|
|
22
|
+
|
|
|
23
|
+ <el-card :body-style="cardBodyStyle">
|
|
|
24
|
+ <el-table :data="tableData" border highlight-current-row v-loading="loading">
|
|
|
25
|
+ <el-table-column type="index" label="序号" align="center" width="60">
|
|
|
26
|
+ <template #default="scope">
|
|
|
27
|
+ <span>{{ scope.$index + (currentPage - 1) * pageSize + 1 }}</span>
|
|
|
28
|
+ </template>
|
|
|
29
|
+ </el-table-column>
|
|
|
30
|
+ <el-table-column prop="customer.customerNm" label="客户名称" width="180" show-overflow-tooltip />
|
|
|
31
|
+ <el-table-column prop="materialName" label="品名简称" width="180" show-overflow-tooltip />
|
|
|
32
|
+ <el-table-column prop="keepDay" label="免堆时间(天)" width="150" show-overflow-tooltip />
|
|
|
33
|
+ <el-table-column prop="ordPrice" label="免堆期价格(元/吨)" width="150" show-overflow-tooltip align="right">
|
|
|
34
|
+ <template #default="scope">
|
|
|
35
|
+ <span>{{ scope.row.ordPrice ? scope.row.ordPrice.toFixed(2) : '0.00' }}</span>
|
|
|
36
|
+ </template>
|
|
|
37
|
+ </el-table-column>
|
|
|
38
|
+ <el-table-column prop="outOrdPrice" label="超期价格(元/天/吨)" width="150" show-overflow-tooltip align="right">
|
|
|
39
|
+ <template #default="scope">
|
|
|
40
|
+ <span>{{ scope.row.outOrdPrice ? scope.row.outOrdPrice.toFixed(2) : '0.00' }}</span>
|
|
|
41
|
+ </template>
|
|
|
42
|
+ </el-table-column>
|
|
|
43
|
+ <el-table-column prop="payWay" label="支付方式" width="120" show-overflow-tooltip />
|
|
|
44
|
+ <el-table-column prop="addName" label="添加人" width="120" show-overflow-tooltip />
|
|
|
45
|
+ <el-table-column prop="addTime" label="添加时间" width="180" show-overflow-tooltip>
|
|
|
46
|
+ <template #default="scope">
|
|
|
47
|
+ <span>{{ formatDate(scope.row.addTime) }}</span>
|
|
|
48
|
+ </template>
|
|
|
49
|
+ </el-table-column>
|
|
|
50
|
+ <el-table-column label="操作" width="200" fixed="right">
|
|
|
51
|
+ <template #default="scope">
|
|
|
52
|
+ <el-button plain type="warning" size="mini" @click="handleEdit(scope.row)">编辑</el-button>
|
|
|
53
|
+ <el-button plain type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
|
|
|
54
|
+ </template>
|
|
|
55
|
+ </el-table-column>
|
|
|
56
|
+ </el-table>
|
|
|
57
|
+ </el-card>
|
|
|
58
|
+
|
|
|
59
|
+ <el-card :body-style="cardBodyStyle">
|
|
|
60
|
+ <el-pagination :current-page="currentPage" :page-size="pageSize" :page-sizes="pageSizes" :total="totalRows"
|
|
|
61
|
+ background layout="total, sizes, prev, pager, next, jumper"
|
|
|
62
|
+ @size-change="handleSizeChange"
|
|
|
63
|
+ @current-change="handleCurrentChange" />
|
|
|
64
|
+ </el-card>
|
|
|
65
|
+
|
|
|
66
|
+ <!-- 新增/编辑对话框 -->
|
|
|
67
|
+ <el-dialog :title="dialogTitle" v-model="dialogVisible" width="500px" :close-on-click-modal="false">
|
|
|
68
|
+ <el-form :model="form" label-width="120px" label-position="right" :rules="rules" ref="ruleFormRef">
|
|
|
69
|
+ <el-form-item label="客户名称" prop="customerId">
|
|
|
70
|
+ <el-select v-model="form.customerId" filterable placeholder="请选择客户" clearable style="width: 100%;">
|
|
|
71
|
+ <el-option v-for="item in optionsCust" :key="item.id" :label="item.customerNm" :value="item.id" />
|
|
|
72
|
+ </el-select>
|
|
|
73
|
+ </el-form-item>
|
|
|
74
|
+ <el-form-item label="品名" prop="materialName">
|
|
|
75
|
+ <el-input v-model="form.materialName" placeholder="请输入品名" style="width: 100%;" />
|
|
|
76
|
+ </el-form-item>
|
|
|
77
|
+ <el-form-item label="免堆时间" prop="keepDay">
|
|
|
78
|
+ <el-input v-model="form.keepDay" type="number" placeholder="请输入免堆时间" style="width: 100%;">
|
|
|
79
|
+ <template slot="append">天</template>
|
|
|
80
|
+ </el-input>
|
|
|
81
|
+ </el-form-item>
|
|
|
82
|
+ <el-form-item label="免堆期单价" prop="ordPrice">
|
|
|
83
|
+ <el-input v-model="form.ordPrice" type="number" placeholder="请输入免堆期单价" style="width: 100%;">
|
|
|
84
|
+ <template slot="append">元/吨</template>
|
|
|
85
|
+ </el-input>
|
|
|
86
|
+ </el-form-item>
|
|
|
87
|
+ <el-form-item label="超期单价" prop="outOrdPrice">
|
|
|
88
|
+ <el-input v-model="form.outOrdPrice" type="number" placeholder="请输入超期单价" style="width: 100%;">
|
|
|
89
|
+ <template slot="append">元/天/吨</template>
|
|
|
90
|
+ </el-input>
|
|
|
91
|
+ </el-form-item>
|
|
|
92
|
+ <el-form-item label="支付方式" prop="payWay">
|
|
|
93
|
+ <el-radio-group v-model="form.payWay">
|
|
|
94
|
+ <el-radio label="月结">月结</el-radio>
|
|
|
95
|
+ <el-radio label="现金">现金</el-radio>
|
|
|
96
|
+ </el-radio-group>
|
|
|
97
|
+ </el-form-item>
|
|
|
98
|
+ </el-form>
|
|
|
99
|
+ <template #footer>
|
|
|
100
|
+ <div class="dialog-footer">
|
|
|
101
|
+ <el-button type="success" plain @click="handleSave">保存</el-button>
|
|
|
102
|
+ <el-button type="danger" plain @click="handleCancelSave">取消</el-button>
|
|
|
103
|
+ </div>
|
|
|
104
|
+ </template>
|
|
|
105
|
+ </el-dialog>
|
|
|
106
|
+ </div>
|
|
|
107
|
+</template>
|
|
|
108
|
+
|
|
|
109
|
+<script>
|
|
|
110
|
+import axios from '@/axios'
|
|
|
111
|
+
|
|
|
112
|
+export default {
|
|
|
113
|
+ data() {
|
|
|
114
|
+ return {
|
|
|
115
|
+ cardBodyStyle: { padding: '10px' },
|
|
|
116
|
+ // 查询条件
|
|
|
117
|
+ query: {
|
|
|
118
|
+ customerName: '',
|
|
|
119
|
+ },
|
|
|
120
|
+ // 表格数据
|
|
|
121
|
+ tableData: [],
|
|
|
122
|
+ loading: false,
|
|
|
123
|
+ // 对话框控制
|
|
|
124
|
+ dialogVisible: false,
|
|
|
125
|
+ dialogTitle: '新增价格',
|
|
|
126
|
+ // 客户选项
|
|
|
127
|
+ optionsCust: [],
|
|
|
128
|
+ // 表单数据
|
|
|
129
|
+ form: {
|
|
|
130
|
+ id: '',
|
|
|
131
|
+ customerId: '',
|
|
|
132
|
+ materialName: '',
|
|
|
133
|
+ keepDay: '',
|
|
|
134
|
+ ordPrice: '',
|
|
|
135
|
+ outOrdPrice: '',
|
|
|
136
|
+ payWay: '月结'
|
|
|
137
|
+ },
|
|
|
138
|
+ // 分页相关
|
|
|
139
|
+ currentPage: 1,
|
|
|
140
|
+ totalRows: 0,
|
|
|
141
|
+ pageSizes: [10, 20, 50, 100],
|
|
|
142
|
+ pageSize: 10,
|
|
|
143
|
+ // 表单验证规则
|
|
|
144
|
+ rules: {
|
|
|
145
|
+ customerId: [
|
|
|
146
|
+ { required: true, message: '请选择客户', trigger: 'change' }
|
|
|
147
|
+ ],
|
|
|
148
|
+ materialName: [
|
|
|
149
|
+ { required: true, message: '请输入品名', trigger: 'blur' }
|
|
|
150
|
+ ],
|
|
|
151
|
+ keepDay: [
|
|
|
152
|
+ { required: true, message: '请输入免堆时间', trigger: 'blur' }
|
|
|
153
|
+ ],
|
|
|
154
|
+ ordPrice: [
|
|
|
155
|
+ { required: true, message: '请输入免堆期单价', trigger: 'blur' }
|
|
|
156
|
+ ],
|
|
|
157
|
+ outOrdPrice: [
|
|
|
158
|
+ { required: true, message: '请输入超期单价', trigger: 'blur' }
|
|
|
159
|
+ ],
|
|
|
160
|
+ payWay: [
|
|
|
161
|
+ { required: true, message: '请选择支付方式', trigger: 'change' }
|
|
|
162
|
+ ]
|
|
|
163
|
+ }
|
|
|
164
|
+ }
|
|
|
165
|
+ },
|
|
|
166
|
+ mounted() {
|
|
|
167
|
+ this.getTableData()
|
|
|
168
|
+ this.getAllCustomer()
|
|
|
169
|
+ },
|
|
|
170
|
+ methods: {
|
|
|
171
|
+ // 查询
|
|
|
172
|
+ handleSearch() {
|
|
|
173
|
+ this.currentPage = 1
|
|
|
174
|
+ this.getTableData()
|
|
|
175
|
+ },
|
|
|
176
|
+
|
|
|
177
|
+ // 新增按钮
|
|
|
178
|
+ handleAdd() {
|
|
|
179
|
+ this.dialogTitle = '新增价格'
|
|
|
180
|
+ this.form = {
|
|
|
181
|
+ id: '',
|
|
|
182
|
+ customerId: '',
|
|
|
183
|
+ materialName: '',
|
|
|
184
|
+ keepDay: '',
|
|
|
185
|
+ ordPrice: '',
|
|
|
186
|
+ outOrdPrice: '',
|
|
|
187
|
+ payWay: '月结'
|
|
|
188
|
+ }
|
|
|
189
|
+ this.dialogVisible = true
|
|
|
190
|
+ // 清除表单验证
|
|
|
191
|
+ if (this.$refs.ruleFormRef) {
|
|
|
192
|
+ this.$refs.ruleFormRef.clearValidate()
|
|
|
193
|
+ }
|
|
|
194
|
+ },
|
|
|
195
|
+
|
|
|
196
|
+ // 编辑按钮
|
|
|
197
|
+ handleEdit(row) {
|
|
|
198
|
+ this.dialogTitle = '编辑价格'
|
|
|
199
|
+ this.form = {
|
|
|
200
|
+ id: row.id,
|
|
|
201
|
+ customerId: row.customerId,
|
|
|
202
|
+ materialName: row.materialName,
|
|
|
203
|
+ keepDay: row.keepDay,
|
|
|
204
|
+ ordPrice: row.ordPrice,
|
|
|
205
|
+ outOrdPrice: row.outOrdPrice,
|
|
|
206
|
+ payWay: row.payWay || '月结'
|
|
|
207
|
+ }
|
|
|
208
|
+ this.dialogVisible = true
|
|
|
209
|
+ // 清除表单验证
|
|
|
210
|
+ if (this.$refs.ruleFormRef) {
|
|
|
211
|
+ this.$refs.ruleFormRef.clearValidate()
|
|
|
212
|
+ }
|
|
|
213
|
+ },
|
|
|
214
|
+
|
|
|
215
|
+ // 保存
|
|
|
216
|
+ handleSave() {
|
|
|
217
|
+ this.$refs.ruleFormRef.validate((valid) => {
|
|
|
218
|
+ if (valid) {
|
|
|
219
|
+ const url = 'sto/Price/save'
|
|
|
220
|
+ const param = {
|
|
|
221
|
+ json: JSON.stringify(this.form)
|
|
|
222
|
+ }
|
|
|
223
|
+ axios.post(url, param).then(response => {
|
|
|
224
|
+ if (response.data.code == 0) {
|
|
|
225
|
+ this.$message({
|
|
|
226
|
+ message: '保存成功',
|
|
|
227
|
+ type: 'success',
|
|
|
228
|
+ })
|
|
|
229
|
+ this.dialogVisible = false
|
|
|
230
|
+ this.getTableData()
|
|
|
231
|
+ } else {
|
|
|
232
|
+ this.$message({
|
|
|
233
|
+ type: 'error',
|
|
|
234
|
+ message: '保存失败:' + response.data.msg
|
|
|
235
|
+ })
|
|
|
236
|
+ }
|
|
|
237
|
+ }).catch(error => {
|
|
|
238
|
+ this.$message({
|
|
|
239
|
+ type: 'error',
|
|
|
240
|
+ message: '请求失败:' + error
|
|
|
241
|
+ })
|
|
|
242
|
+ })
|
|
|
243
|
+ } else {
|
|
|
244
|
+ this.$message({
|
|
|
245
|
+ type: 'warning',
|
|
|
246
|
+ message: '请完善表单信息'
|
|
|
247
|
+ })
|
|
|
248
|
+ return false
|
|
|
249
|
+ }
|
|
|
250
|
+ })
|
|
|
251
|
+ },
|
|
|
252
|
+
|
|
|
253
|
+ // 取消保存
|
|
|
254
|
+ handleCancelSave() {
|
|
|
255
|
+ this.dialogVisible = false
|
|
|
256
|
+ },
|
|
|
257
|
+
|
|
|
258
|
+ // 删除
|
|
|
259
|
+ handleDelete(row) {
|
|
|
260
|
+ this.$confirm('确定删除本条记录?', '提示', {
|
|
|
261
|
+ confirmButtonText: '确认',
|
|
|
262
|
+ cancelButtonText: '取消',
|
|
|
263
|
+ type: 'warning',
|
|
|
264
|
+ draggable: true,
|
|
|
265
|
+ }).then(() => {
|
|
|
266
|
+ const url = 'sto/Price/remove'
|
|
|
267
|
+ const param = { id: row.id }
|
|
|
268
|
+ axios.post(url, param).then(response => {
|
|
|
269
|
+ if (response.data.code == 0) {
|
|
|
270
|
+ this.$message({
|
|
|
271
|
+ type: 'success',
|
|
|
272
|
+ message: '删除成功!',
|
|
|
273
|
+ })
|
|
|
274
|
+ this.getTableData()
|
|
|
275
|
+ } else {
|
|
|
276
|
+ this.$message.error('操作失败!' + response.data.msg)
|
|
|
277
|
+ }
|
|
|
278
|
+ })
|
|
|
279
|
+ }).catch(() => {
|
|
|
280
|
+ this.$message({
|
|
|
281
|
+ type: 'info',
|
|
|
282
|
+ message: '已取消',
|
|
|
283
|
+ })
|
|
|
284
|
+ })
|
|
|
285
|
+ },
|
|
|
286
|
+
|
|
|
287
|
+ // 分页大小改变
|
|
|
288
|
+ handleSizeChange(val) {
|
|
|
289
|
+ this.pageSize = val
|
|
|
290
|
+ this.getTableData()
|
|
|
291
|
+ },
|
|
|
292
|
+
|
|
|
293
|
+ // 当前页改变
|
|
|
294
|
+ handleCurrentChange(val) {
|
|
|
295
|
+ this.currentPage = val
|
|
|
296
|
+ this.getTableData()
|
|
|
297
|
+ },
|
|
|
298
|
+
|
|
|
299
|
+ // 格式化日期
|
|
|
300
|
+ formatDate(dateString) {
|
|
|
301
|
+ if (!dateString) return ''
|
|
|
302
|
+ const date = new Date(dateString)
|
|
|
303
|
+ return date.toLocaleString()
|
|
|
304
|
+ },
|
|
|
305
|
+
|
|
|
306
|
+ // 获取表格数据
|
|
|
307
|
+ getTableData() {
|
|
|
308
|
+ this.loading = true
|
|
|
309
|
+ const url = 'sto/Price/query'
|
|
|
310
|
+ const param = {
|
|
|
311
|
+ page: this.currentPage,
|
|
|
312
|
+ rows: this.pageSize,
|
|
|
313
|
+ customerName: this.query.customerName
|
|
|
314
|
+ }
|
|
|
315
|
+ axios.get(url, param).then(response => {
|
|
|
316
|
+ if (response.data.code == 0) {
|
|
|
317
|
+ this.tableData = response.data.data.records || response.data.data.list
|
|
|
318
|
+ this.totalRows = response.data.data.total
|
|
|
319
|
+ } else {
|
|
|
320
|
+ this.$message.error('操作失败!' + response.data.msg)
|
|
|
321
|
+ }
|
|
|
322
|
+ this.loading = false
|
|
|
323
|
+ }).catch(error => {
|
|
|
324
|
+ this.loading = false
|
|
|
325
|
+ this.$message.error('请求失败:' + error)
|
|
|
326
|
+ })
|
|
|
327
|
+ },
|
|
|
328
|
+
|
|
|
329
|
+ // 获取所有客户
|
|
|
330
|
+ getAllCustomer() {
|
|
|
331
|
+ const url = 'sto/Customer/query'
|
|
|
332
|
+ const param = {
|
|
|
333
|
+ page: 1,
|
|
|
334
|
+ rows: 1000
|
|
|
335
|
+ }
|
|
|
336
|
+ axios.get(url, param).then(response => {
|
|
|
337
|
+ if (response.data.code == 0) {
|
|
|
338
|
+ this.optionsCust = response.data.data.records || response.data.data.list
|
|
|
339
|
+ }
|
|
|
340
|
+ }).catch(error => {
|
|
|
341
|
+ this.$message.error('获取客户列表失败:' + error)
|
|
|
342
|
+ })
|
|
|
343
|
+ }
|
|
|
344
|
+ }
|
|
|
345
|
+}
|
|
|
346
|
+</script>
|
|
|
347
|
+
|
|
|
348
|
+<style scoped>
|
|
|
349
|
+::v-deep .el-dialog__body {
|
|
|
350
|
+ background-color: #F2F6FC;
|
|
|
351
|
+}
|
|
|
352
|
+</style>
|