appsnbcbweicheng 1.2.25 → 1.2.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,400 +0,0 @@
1
- <template>
2
- <div class="shelf-rules-container">
3
- <!-- 筛选区域 -->
4
- <el-card class="filter-card" shadow="never">
5
- <el-form :inline="true" :model="queryParams" class="demo-form-inline" size="small">
6
- <el-form-item label="规则名称">
7
- <el-input
8
- v-model="queryParams.ruleName"
9
- placeholder="请输入规则名称"
10
- clearable
11
- ></el-input>
12
- </el-form-item>
13
- <el-form-item label="生效状态">
14
- <el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
15
- <el-option label="已上架" value="1"></el-option>
16
- <el-option label="已下架" value="0"></el-option>
17
- </el-select>
18
- </el-form-item>
19
- <el-form-item>
20
- <el-button type="primary" @click="handleSearch">查询</el-button>
21
- <el-button @click="handleReset">重置</el-button>
22
- <el-button type="success" @click="handleAdd" icon="el-icon-plus">新增</el-button>
23
- </el-form-item>
24
- </el-form>
25
- </el-card>
26
-
27
- <!-- 表格区域 -->
28
- <el-card class="table-card" shadow="never">
29
- <el-table :data="tableData" border style="width: 100%" v-loading="loading">
30
- <el-table-column prop="ruleName" label="规则名称" min-width="150"></el-table-column>
31
- <el-table-column prop="status" label="生效状态" width="120" align="center">
32
- <template slot-scope="scope">
33
- <el-button
34
- size="mini"
35
- :type="scope.row.status === '1' ? 'success' : 'info'"
36
- plain
37
- round
38
- >
39
- {{ scope.row.status === '1' ? '已上架' : '已下架' }}
40
- </el-button>
41
- </template>
42
- </el-table-column>
43
- <el-table-column label="操作" width="250" fixed="right">
44
- <template slot-scope="scope">
45
- <el-button type="text" size="small" @click="handleView(scope.row)">查看</el-button>
46
- <el-button type="text" size="small" @click="handleEdit(scope.row)">编辑</el-button>
47
- <el-button
48
- type="text"
49
- size="small"
50
- :style="{ color: scope.row.status === '1' ? '#F56C6C' : '#67C23A' }"
51
- @click="handleToggleStatus(scope.row)"
52
- >
53
- {{ scope.row.status === '1' ? '停用' : '启用' }}
54
- </el-button>
55
- <el-button
56
- type="text"
57
- size="small"
58
- style="color: #f56c6c"
59
- @click="handleDelete(scope.row)"
60
- >删除</el-button
61
- >
62
- </template>
63
- </el-table-column>
64
- </el-table>
65
- <div class="pagination-container">
66
- <el-pagination
67
- background
68
- @size-change="handleSizeChange"
69
- @current-change="handleCurrentChange"
70
- :current-page="pagination.currentPage"
71
- :page-sizes="[10, 20, 50, 100]"
72
- :page-size="pagination.pageSize"
73
- layout="total, sizes, prev, pager, next, jumper"
74
- :total="pagination.total"
75
- >
76
- </el-pagination>
77
- </div>
78
- </el-card>
79
-
80
- <!-- 新增/修改弹窗 -->
81
- <el-dialog
82
- :title="dialogTitle"
83
- :visible.sync="dialogVisible"
84
- width="600px"
85
- :close-on-click-modal="false"
86
- @close="resetForm"
87
- >
88
- <el-form
89
- :model="form"
90
- :rules="rules"
91
- ref="ruleForm"
92
- label-width="100px"
93
- :disabled="isViewMode"
94
- >
95
- <el-form-item label="规则名称" prop="ruleName">
96
- <el-input
97
- v-model="form.ruleName"
98
- placeholder="请输入规则名称(最多20个字)"
99
- maxlength="20"
100
- show-word-limit
101
- ></el-input>
102
- </el-form-item>
103
-
104
- <el-form-item label="产品类型" prop="productType">
105
- <el-select v-model="form.productType" placeholder="请选择产品类型" style="width: 100%">
106
- <el-option label="类型A" value="TypeA"></el-option>
107
- <el-option label="类型B" value="TypeB"></el-option>
108
- </el-select>
109
- </el-form-item>
110
-
111
- <el-form-item label="产品模板" prop="productTemplate">
112
- <el-select
113
- v-model="form.productTemplate"
114
- multiple
115
- placeholder="请选择产品模板"
116
- style="width: 100%"
117
- >
118
- <el-option label="模板1" value="Template1"></el-option>
119
- <el-option label="模板2" value="Template2"></el-option>
120
- <el-option label="模板3" value="Template3"></el-option>
121
- </el-select>
122
- </el-form-item>
123
-
124
- <el-form-item label="规则日期" prop="ruleDate">
125
- <el-select v-model="form.ruleDate" placeholder="请选择规则日期" style="width: 100%">
126
- <el-option label="T日" value="T"></el-option>
127
- <el-option label="T+1日" value="T+1"></el-option>
128
- <el-option label="成立日" value="setup_date"></el-option>
129
- </el-select>
130
- </el-form-item>
131
-
132
- <el-form-item label="规则时间" prop="ruleTime">
133
- <div class="time-rule-container">
134
- <el-radio-group v-model="timeType" @change="handleTimeTypeChange">
135
- <el-radio label="custom">自定义</el-radio>
136
- <el-radio label="field">选择字段</el-radio>
137
- </el-radio-group>
138
-
139
- <div class="time-input-area" v-if="timeType === 'custom'">
140
- <el-time-picker
141
- v-model="form.ruleTime"
142
- placeholder="任意时间点"
143
- value-format="HH:mm:ss"
144
- style="width: 100%"
145
- >
146
- </el-time-picker>
147
- </div>
148
- <div class="time-input-area" v-else>
149
- <el-select v-model="form.ruleTime" placeholder="请选择时间字段" style="width: 100%">
150
- <el-option label="创建时间" value="create_time"></el-option>
151
- <el-option label="更新时间" value="update_time"></el-option>
152
- </el-select>
153
- </div>
154
- </div>
155
- </el-form-item>
156
-
157
- <el-form-item label="操作" prop="operation">
158
- <el-select v-model="form.operation" placeholder="请选择操作" style="width: 100%">
159
- <el-option label="上架" value="1"></el-option>
160
- <el-option label="下架" value="0"></el-option>
161
- </el-select>
162
- </el-form-item>
163
- </el-form>
164
- <span slot="footer" class="dialog-footer" v-if="!isViewMode">
165
- <el-button @click="dialogVisible = false">取 消</el-button>
166
- <el-button type="primary" @click="handleSubmit">确 定</el-button>
167
- </span>
168
- <span slot="footer" class="dialog-footer" v-else>
169
- <el-button @click="dialogVisible = false">关 闭</el-button>
170
- </span>
171
- </el-dialog>
172
- </div>
173
- </template>
174
-
175
- <script>
176
- export default {
177
- name: 'ShelfRules',
178
- data() {
179
- return {
180
- // 查询参数
181
- queryParams: {
182
- ruleName: '',
183
- status: '',
184
- },
185
- // 表格加载状态
186
- loading: false,
187
- // 表格数据
188
- tableData: [
189
- {
190
- id: 1,
191
- ruleName: '示例规则1',
192
- status: '1',
193
- productType: 'TypeA',
194
- productTemplate: ['Template1'],
195
- ruleDate: 'T',
196
- ruleTime: '09:00',
197
- operation: '1',
198
- },
199
- {
200
- id: 2,
201
- ruleName: '示例规则2',
202
- status: '0',
203
- productType: 'TypeB',
204
- productTemplate: ['Template2'],
205
- ruleDate: 'setup_date',
206
- ruleTime: 'create_time',
207
- operation: '0',
208
- },
209
- ],
210
- // 分页
211
- pagination: {
212
- currentPage: 1,
213
- pageSize: 10,
214
- total: 2,
215
- },
216
- // 弹窗控制
217
- dialogVisible: false,
218
- dialogTitle: '新增规则',
219
- isViewMode: false,
220
- // 时间规则类型
221
- timeType: 'custom',
222
- // 表单数据
223
- form: {
224
- id: undefined,
225
- ruleName: '',
226
- productType: '',
227
- productTemplate: [],
228
- ruleDate: '',
229
- ruleTime: '',
230
- operation: '',
231
- },
232
- // 校验规则
233
- rules: {
234
- ruleName: [
235
- { required: true, message: '请输入规则名称', trigger: 'blur' },
236
- { max: 20, message: '规则名称最多20个字', trigger: 'blur' },
237
- ],
238
- productType: [{ required: true, message: '请选择产品类型', trigger: 'change' }],
239
- operation: [{ required: true, message: '请选择操作', trigger: 'change' }],
240
- },
241
- }
242
- },
243
- methods: {
244
- // 搜索
245
- handleSearch() {
246
- this.loading = true
247
- // 模拟查询
248
- setTimeout(() => {
249
- this.loading = false
250
- this.$message.success('查询成功')
251
- }, 500)
252
- },
253
- // 重置
254
- handleReset() {
255
- this.queryParams = {
256
- ruleName: '',
257
- status: '',
258
- }
259
- this.handleSearch()
260
- },
261
- // 新增
262
- handleAdd() {
263
- this.dialogTitle = '新增规则'
264
- this.isViewMode = false
265
- this.dialogVisible = true
266
- this.timeType = 'custom'
267
- this.$nextTick(() => {
268
- this.$refs.ruleForm.resetFields()
269
- this.form = {
270
- id: undefined,
271
- ruleName: '',
272
- productType: '',
273
- productTemplate: [],
274
- ruleDate: '',
275
- ruleTime: '',
276
- operation: '',
277
- }
278
- })
279
- },
280
- // 查看
281
- handleView(row) {
282
- this.dialogTitle = '查看规则'
283
- this.isViewMode = true
284
- this.dialogVisible = true
285
- this.fillForm(row)
286
- },
287
- // 编辑
288
- handleEdit(row) {
289
- this.dialogTitle = '编辑规则'
290
- this.isViewMode = false
291
- this.dialogVisible = true
292
- this.fillForm(row)
293
- },
294
- // 填充表单
295
- fillForm(row) {
296
- this.$nextTick(() => {
297
- // 判断 ruleTime 是时间格式还是字段
298
- const isTimeFormat = /^([01]\d|2[0-3]):([0-5]\d)(:([0-5]\d))?$/.test(row.ruleTime)
299
- this.timeType = isTimeFormat || !row.ruleTime ? 'custom' : 'field'
300
-
301
- this.form = JSON.parse(JSON.stringify(row))
302
- // operation 映射到 status 的逻辑根据业务可能不同,这里假设 operation 字段就是用来控制 status 的
303
- // 或者 form 中 operation 字段就是对应 '操作(上架/下架)'
304
- })
305
- },
306
- // 删除
307
- handleDelete(row) {
308
- this.$confirm('确认删除该规则吗?', '提示', {
309
- confirmButtonText: '确定',
310
- cancelButtonText: '取消',
311
- type: 'warning',
312
- })
313
- .then(() => {
314
- this.$message.success('删除成功')
315
- console.log(row, 'row')
316
- // 实际业务中调用删除接口
317
- })
318
- .catch(() => {})
319
- },
320
- // 启用/停用
321
- handleToggleStatus(row) {
322
- const action = row.status === '1' ? '停用' : '启用'
323
- this.$confirm(`确认${action}该规则吗?`, '提示', {
324
- confirmButtonText: '确定',
325
- cancelButtonText: '取消',
326
- type: 'warning',
327
- })
328
- .then(() => {
329
- row.status = row.status === '1' ? '0' : '1'
330
- this.$message.success(`${action}成功`)
331
- })
332
- .catch(() => {})
333
- },
334
- // 提交表单
335
- handleSubmit() {
336
- this.$refs.ruleForm.validate(valid => {
337
- if (valid) {
338
- // 提交逻辑
339
- this.dialogVisible = false
340
- this.$message.success(this.form.id ? '修改成功' : '新增成功')
341
- // 更新列表...
342
- } else {
343
- return false
344
- }
345
- })
346
- },
347
- // 关闭弹窗重置
348
- resetForm() {
349
- this.$refs.ruleForm.clearValidate()
350
- },
351
- // 切换时间类型
352
- handleTimeTypeChange() {
353
- this.form.ruleTime = ''
354
- },
355
- // 分页
356
- handleSizeChange(val) {
357
- this.pagination.pageSize = val
358
- this.handleSearch()
359
- },
360
- handleCurrentChange(val) {
361
- this.pagination.currentPage = val
362
- this.handleSearch()
363
- },
364
- },
365
- }
366
- </script>
367
-
368
- <style scoped lang="scss">
369
- .shelf-rules-container {
370
- padding: 20px;
371
- background-color: #f0f2f5;
372
- min-height: 100%;
373
-
374
- .filter-card {
375
- margin-bottom: 20px;
376
- }
377
-
378
- .table-card {
379
- margin-bottom: 20px;
380
- }
381
-
382
- .pagination-container {
383
- margin-top: 20px;
384
- text-align: right;
385
- }
386
-
387
- .time-rule-container {
388
- display: flex;
389
- flex-direction: column;
390
-
391
- .el-radio-group {
392
- margin-bottom: 10px;
393
- }
394
-
395
- .time-input-area {
396
- width: 100%;
397
- }
398
- }
399
- }
400
- </style>