Blame view

antis-ncc-admin/src/views/lqInventory copy/UsageRecordDialog.vue 11.2 KB
f86c9c69   “wangming”   添加库存管理和学习班级管理功能
1
  <template>
384a1e80   李宇   ```
2
      <div>
9661fd47   李宇   ```
3
      <el-dialog title="库存使用记录管理" :visible.sync="visible" width="1200px" @close="closeDialog">
f86c9c69   “wangming”   添加库存管理和学习班级管理功能
4
5
6
7
8
9
10
11
12
13
14
          <div class="usage-record-container">
              <!-- 搜索区域 -->
              <div class="search-section">
                  <el-form :model="query" :inline="true" class="search-form">
                      <el-form-item label="产品名称">
                          <el-input v-model="query.productName" placeholder="请输入产品名称" clearable size="small" />
                      </el-form-item>
                      <el-form-item label="产品分类">
                          <el-input v-model="query.productCategory" placeholder="请输入产品分类" clearable size="small" />
                      </el-form-item>
                      <el-form-item label="门店">
384a1e80   李宇   ```
15
16
17
18
19
                          <el-select v-model="query.storeId" placeholder="请选择门店" style="width: 100%">
                              <el-option v-for="store in storeList" :key="store.id" :label="store.name"
                                  :value="store.id">
                              </el-option>
                          </el-select>
f86c9c69   “wangming”   添加库存管理和学习班级管理功能
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
                      </el-form-item>
                      <el-form-item label="使用时间">
                          <el-date-picker v-model="query.usageTimeRange" type="daterange" range-separator="至"
                              start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" size="small">
                          </el-date-picker>
                      </el-form-item>
                      <el-form-item>
                          <el-button type="primary" size="small" @click="search">搜索</el-button>
                          <el-button size="small" @click="reset">重置</el-button>
                          <el-button type="success" size="small" icon="el-icon-plus"
                              @click="addUsageRecord">添加使用记录</el-button>
                      </el-form-item>
                  </el-form>
              </div>
  
              <!-- 使用记录列表 -->
              <div class="table-section">
                  <el-table :data="usageList" v-loading="loading" border stripe style="width: 100%">
9661fd47   李宇   ```
38
39
40
                      <el-table-column prop="productName" label="产品名称"  fixed="left" />
                      <el-table-column prop="productCategory" label="产品分类" align="left"/>
                      <el-table-column prop="productPrice" label="单价" width="100" align="left">
f86c9c69   “wangming”   添加库存管理和学习班级管理功能
41
42
43
44
                          <template slot-scope="scope">
                              {{ formatMoney(scope.row.productPrice) }}
                          </template>
                      </el-table-column>
9661fd47   李宇   ```
45
46
47
                      <el-table-column prop="usageQuantity" label="使用数量" align="left" />
                      <el-table-column prop="storeName" label="使用门店"  align="left"/>
                      <el-table-column prop="usageTime" label="使用时间" width="160" align="left" :formatter="ncc.tableDateFormat">
f86c9c69   “wangming”   添加库存管理和学习班级管理功能
48
                      </el-table-column>
9661fd47   李宇   ```
49
50
51
                      <!-- <el-table-column prop="relatedConsumeId" label="关联消费ID" width="120" /> -->
                      <el-table-column prop="createUserName" label="创建人" align="left"/>
                      <el-table-column prop="createTime" label="创建时间" width="160" align="left" :formatter="ncc.tableDateFormat">
f86c9c69   “wangming”   添加库存管理和学习班级管理功能
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
                      </el-table-column>
                      <el-table-column prop="isEffective" label="状态" width="80" align="center">
                          <template slot-scope="scope">
                              <el-tag :type="scope.row.isEffective === 1 ? 'success' : 'danger'" size="small">
                                  {{ scope.row.isEffective === 1 ? '有效' : '无效' }}
                              </el-tag>
                          </template>
                      </el-table-column>
                      <el-table-column label="操作" width="120" fixed="right">
                          <template slot-scope="scope">
                              <el-button v-if="scope.row.isEffective === 1" type="text" size="small"
                                  @click="cancelUsageRecord(scope.row)">作废</el-button>
                          </template>
                      </el-table-column>
                  </el-table>
  
                  <!-- 分页 -->
                  <div class="pagination-section">
                      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                          :current-page="pagination.pageIndex" :page-sizes="[10, 20, 50, 100]"
                          :page-size="pagination.pageSize" layout="total, sizes, prev, pager, next, jumper"
                          :total="pagination.total">
                      </el-pagination>
                  </div>
              </div>
          </div>
  
384a1e80   李宇   ```
79
        
f86c9c69   “wangming”   添加库存管理和学习班级管理功能
80
  
384a1e80   李宇   ```
81
    
f86c9c69   “wangming”   添加库存管理和学习班级管理功能
82
      </el-dialog>
384a1e80   李宇   ```
83
84
85
        <!-- 添加使用记录弹窗 -->
        <AddUsageRecordForm v-if="addUsageRecordVisible" ref="AddUsageRecordForm" @refreshDataList="getUsageList" />
      </div>
f86c9c69   “wangming”   添加库存管理和学习班级管理功能
86
87
88
89
90
  </template>
  
  <script>
  import { getInventoryUsageList, cancelInventoryUsage } from '@/api/extend/lqInventory'
  import AddUsageRecordForm from './AddUsageRecordForm'
384a1e80   李宇   ```
91
  import request from '@/utils/request'
f86c9c69   “wangming”   添加库存管理和学习班级管理功能
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
  
  export default {
      name: 'UsageRecordDialog',
      components: {
          AddUsageRecordForm
      },
      data() {
          return {
              visible: false,
              loading: false,
              productId: '', // 特定产品ID,为空时显示所有
              productName: '', // 特定产品名称
              usageList: [],
              query: {
                  productName: '',
                  productCategory: '',
                  storeName: '',
                  usageTimeRange: [],
                  productId: '',
                  storeId: '',
                  relatedConsumeId: '',
                  currentPage: 1,
                  pageSize: 20
              },
              pagination: {
                  pageIndex: 1,
                  pageSize: 20,
                  total: 0
              },
384a1e80   李宇   ```
121
122
              addUsageRecordVisible: false,
              storeList: [] // 门店列表
f86c9c69   “wangming”   添加库存管理和学习班级管理功能
123
124
125
126
127
128
129
130
131
132
133
134
          }
      },
      methods: {
          init(productId = '', productName = '') {
              this.visible = true
              this.productId = productId
              this.productName = productName
              this.query.productId = productId
              if (productName) {
                  this.query.productName = productName
              }
              this.getUsageList()
384a1e80   李宇   ```
135
              this.getStoreList()
f86c9c69   “wangming”   添加库存管理和学习班级管理功能
136
137
          },
  
384a1e80   李宇   ```
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
          // 获取门店列表
          getStoreList() {
              request({
                  url: '/api/Extend/LqMdxx',
                  method: 'GET'
              }).then(response => {
                  this.storeList = response.data.list || []
                  if (response.code == 200 && response.data.list.length > 0) {
                      this.storeList = response.data.list.map(item => ({
                          id: item.id,
                          name: item.dm
                      }))
                  } else {
                      this.storeList = []
                  }
              }).catch(() => {
                  this.storeList = []
              })
          },
f86c9c69   “wangming”   添加库存管理和学习班级管理功能
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
          // 获取使用记录列表
          getUsageList() {
              this.loading = true
              const params = {
                  ...this.query,
                  currentPage: this.pagination.pageIndex,
                  pageSize: this.pagination.pageSize
              }
  
              // 处理日期范围
              if (this.query.usageTimeRange && this.query.usageTimeRange.length === 2) {
                  params.usageStartTime = this.query.usageTimeRange[0]
                  params.usageEndTime = this.query.usageTimeRange[1]
              }
  
              getInventoryUsageList(params).then(response => {
                  if (response.code === 200) {
                      this.usageList = response.data.list || []
                      this.pagination.total = (response.data.pagination && response.data.pagination.total) || 0
                  } else {
                      this.$message.error(response.msg || '获取使用记录失败')
                  }
                  this.loading = false
              }).catch(() => {
                  this.loading = false
              })
          },
  
          // 搜索
          search() {
              this.pagination.pageIndex = 1
              this.getUsageList()
          },
  
          // 重置
          reset() {
              this.query = {
                  productName: this.productName || '',
                  productCategory: '',
                  storeName: '',
                  usageTimeRange: [],
                  productId: this.productId,
                  storeId: '',
                  relatedConsumeId: '',
                  currentPage: 1,
                  pageSize: 20
              }
              this.pagination.pageIndex = 1
              this.getUsageList()
          },
  
          // 分页大小改变
          handleSizeChange(val) {
              this.pagination.pageSize = val
              this.pagination.pageIndex = 1
              this.getUsageList()
          },
  
          // 当前页改变
          handleCurrentChange(val) {
              this.pagination.pageIndex = val
              this.getUsageList()
          },
  
          // 添加使用记录
          addUsageRecord() {
384a1e80   李宇   ```
223
              // this.visible = false
f86c9c69   “wangming”   添加库存管理和学习班级管理功能
224
225
226
227
228
229
230
231
232
233
234
235
236
              this.addUsageRecordVisible = true
              this.$nextTick(() => {
                  this.$refs.AddUsageRecordForm.init(this.productId, this.productName)
              })
          },
  
          // 作废使用记录
          cancelUsageRecord(row) {
              this.$confirm('确定要作废这条使用记录吗?作废后库存数量将恢复。', '提示', {
                  confirmButtonText: '确定',
                  cancelButtonText: '取消',
                  type: 'warning'
              }).then(() => {
9661fd47   李宇   ```
237
                  cancelInventoryUsage(row.id,'作废').then(response => {
f86c9c69   “wangming”   添加库存管理和学习班级管理功能
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
                      if (response.code === 200) {
                          this.$message.success('作废成功')
                          this.getUsageList()
                      } else {
                          this.$message.error(response.msg || '作废失败')
                      }
                  })
              })
          },
  
          // 格式化金额
          formatMoney(value) {
              if (value === null || value === undefined || value === '') {
                  return '0.00'
              }
              return Number(value).toFixed(2)
          },
  
          // 关闭弹窗
          closeDialog() {
              this.visible = false
              this.usageList = []
              this.query = {
                  productName: '',
                  productCategory: '',
                  storeName: '',
                  usageTimeRange: [],
                  productId: '',
                  storeId: '',
                  relatedConsumeId: '',
                  currentPage: 1,
                  pageSize: 20
              }
              this.pagination = {
                  pageIndex: 1,
                  pageSize: 20,
                  total: 0
              }
          }
      }
  }
  </script>
  
  <style scoped>
  .usage-record-container {
384a1e80   李宇   ```
283
      /* padding: 20px; */
f86c9c69   “wangming”   添加库存管理和学习班级管理功能
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
  }
  
  .search-section {
      margin-bottom: 20px;
      padding: 15px;
      background: #f5f7fa;
      border-radius: 4px;
  }
  
  .search-form .el-form-item {
      margin-bottom: 10px;
  }
  
  .table-section {
      margin-bottom: 20px;
  }
  
  .pagination-section {
      text-align: right;
      margin-top: 20px;
  }
  
  .dialog-footer {
      text-align: right;
  }
  </style>
cc202318   “wangming”   优化库存管理功能