Blame view

src/views/config/inventory/cycleCountPreference/index.vue 14.4 KB
yuanshuhui authored
1
2
<template>
  <div class="app-container">
yuanshuhui authored
3
4
5
6
7
8
9
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="120px"
    >
yuanshuhui authored
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
      <el-form-item label="盘点首选项编码" prop="code">
        <el-input
          v-model="queryParams.code"
          placeholder="请输入盘点首选项编码"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="提示货位" prop="promptLocation">
        <el-input
          v-model="queryParams.promptLocation"
          placeholder="请输入提示货位"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="提示物料" prop="promptItem">
        <el-input
          v-model="queryParams.promptItem"
          placeholder="请输入提示物料"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="提示容器" prop="promptLpn">
        <el-input
          v-model="queryParams.promptLpn"
          placeholder="请输入提示容器"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="更新人" prop="lastUpdatedBy">
        <el-input
          v-model="queryParams.lastUpdatedBy"
          placeholder="请输入更新人"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建人" prop="createdBy">
        <el-input
          v-model="queryParams.createdBy"
          placeholder="请输入创建人"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
yuanshuhui authored
71
72
73
74
75
76
77
78
79
80
        <el-button
          type="cyan"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
yuanshuhui authored
81
82
83
84
85
86
87
88
89
90
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
yuanshuhui authored
91
          v-hasPermi="['config:cycleCountPreference:add']"
yuanshuhui authored
92
93
          >新增</el-button
        >
yuanshuhui authored
94
95
96
97
98
99
100
101
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
yuanshuhui authored
102
          v-hasPermi="['config:cycleCountPreference:edit']"
yuanshuhui authored
103
104
          >修改</el-button
        >
yuanshuhui authored
105
106
107
108
109
110
111
112
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
yuanshuhui authored
113
          v-hasPermi="['config:cycleCountPreference:remove']"
yuanshuhui authored
114
115
          >删除</el-button
        >
yuanshuhui authored
116
      </el-col>
yuanshuhui authored
117
118
119
120
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
yuanshuhui authored
121
122
    </el-row>
yuanshuhui authored
123
124
125
126
127
    <el-table
      v-loading="loading"
      :data="preferenceList"
      @selection-change="handleSelectionChange"
    >
yuanshuhui authored
128
      <el-table-column type="selection" width="55" align="center" />
yuanshuhui authored
129
      <el-table-column label="id" align="center" prop="id" min-width="55" />
yuanshuhui authored
130
131
132
133
134
135
136
137
138
139
140
141
142
      <el-table-column
        label="盘点首选项编码"
        align="center"
        prop="code"
        min-width="120"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="盘点首选项名称"
        align="center"
        prop="name"
        min-width="120"
      />
yuanshuhui authored
143
      <el-table-column label="仓库编码" align="center" prop="warehouseCode" />
yuanshuhui authored
144
145
146
147
148
149
150
151
152
153
154
155
156
      <el-table-column
        label="系统提示库位"
        align="center"
        prop="promptLocation"
        min-width="100"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            :type="scope.row.promptLocation | sysFilter"
            round
            >{{ sysFormat(scope.row, scope.column) }}</el-button
          >
yuanshuhui authored
157
158
        </template>
      </el-table-column>
yuanshuhui authored
159
160
161
162
163
164
      <el-table-column
        label="系统提示容器"
        align="center"
        prop="promptLpn"
        min-width="100"
      >
yuanshuhui authored
165
        <template slot-scope="scope">
yuanshuhui authored
166
167
168
169
170
171
          <el-button
            size="mini"
            :type="scope.row.promptLpn | sysFilter"
            round
            >{{ sysFormat(scope.row, scope.column) }}</el-button
          >
yuanshuhui authored
172
173
        </template>
      </el-table-column>
yuanshuhui authored
174
175
176
177
178
179
180
181
182
183
184
185
186
      <el-table-column
        label="系统提示物料"
        align="center"
        prop="promptItem"
        min-width="100"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            :type="scope.row.promptItem | sysFilter"
            round
            >{{ sysFormat(scope.row, scope.column) }}</el-button
          >
yuanshuhui authored
187
188
        </template>
      </el-table-column>
yuanshuhui authored
189
190
191
192
193
194
195
196
197
198
199
200
201
      <el-table-column
        label="显示差异数量"
        align="center"
        prop="prompAdjustQty"
        min-width="100"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            :type="scope.row.prompAdjustQty | sysFilter"
            round
            >{{ sysFormat(scope.row, scope.column) }}</el-button
          >
yuanshuhui authored
202
203
        </template>
      </el-table-column>
yuanshuhui authored
204
205
206
207
208
209
210
211
212
213
214
215
216
      <el-table-column
        label="显示库存数量"
        align="center"
        prop="promptQuantity"
        min-width="100"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            :type="scope.row.promptQuantity | sysFilter"
            round
            >{{ sysFormat(scope.row, scope.column) }}</el-button
          >
yuanshuhui authored
217
218
        </template>
      </el-table-column>
yuanshuhui authored
219
220
221
222
223
224
225

      <el-table-column
        label="创建时间"
        align="center"
        prop="created"
        min-width="160"
      >
yuanshuhui authored
226
227
228
229
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.created) }}</span>
        </template>
      </el-table-column>
yuanshuhui authored
230
231
232
233
234
235
236
      <el-table-column
        label="创建用户"
        align="center"
        prop="createdBy"
        :show-overflow-tooltip="true"
      />
yuanshuhui authored
237
      <el-table-column label="有效" align="center" prop="enable">
yuanshuhui authored
238
239
240
241
242
243
244
        <template slot-scope="scope">
          <el-button
            size="mini"
            :type="scope.row.enable | enableFilter"
            round
            >{{ enableFormat(scope.row, scope.column) }}</el-button
          >
yuanshuhui authored
245
246
        </template>
      </el-table-column>
yuanshuhui authored
247
248
249
250
251
252
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        width="140"
      >
yuanshuhui authored
253
254
255
256
257
258
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
yuanshuhui authored
259
            v-hasPermi="['config:cycleCountPreference:edit']"
yuanshuhui authored
260
261
            >修改</el-button
          >
yuanshuhui authored
262
263
264
265
266
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
yuanshuhui authored
267
            v-hasPermi="['config:cycleCountPreference:remove']"
yuanshuhui authored
268
269
            >删除</el-button
          >
yuanshuhui authored
270
271
272
273
274
        </template>
      </el-table-column>
    </el-table>

    <pagination
yuanshuhui authored
275
      v-show="total > 0"
yuanshuhui authored
276
277
278
279
280
281
282
283
284
285
286
287
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改盘点首选项对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-form-item label="ID" prop="id" v-if="form.id != undefined">
          <el-input v-model="form.id" :disabled="true" />
        </el-form-item>
yuanshuhui authored
288
289
290
291
292
        <el-form-item
          label="盘点首选项编码"
          prop="code"
          v-if="form.code != undefined"
        >
yuanshuhui authored
293
          <el-input v-model="form.code" :disabled="true" />
yuanshuhui authored
294
        </el-form-item>
yuanshuhui authored
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
        <el-form-item label="盘点首选项名称" prop="name">
          <el-input v-model="form.name" placeholder="请输入盘点首选项名称" />
        </el-form-item>
        <el-form-item label="系统提示货位" prop="promptLocation">
          <el-switch v-model="form.promptLocation"></el-switch>
        </el-form-item>
        <el-form-item label="系统提示容器" prop="promptLpn">
          <el-switch v-model="form.promptLpn"></el-switch>
        </el-form-item>
        <el-form-item label="系统提示物料" prop="promptItem">
          <el-switch v-model="form.promptItem"></el-switch>
        </el-form-item>
        <el-form-item label="显示差异数量" prop="prompAdjustQty">
          <el-switch v-model="form.prompAdjustQty"></el-switch>
        </el-form-item>
        <el-form-item label="显示库存数量" prop="promptQuantity">
          <el-switch v-model="form.promptQuantity"></el-switch>
        </el-form-item>
        <el-form-item label="是否有效" prop="enable">
yuanshuhui authored
314
315
316
317
318
          <el-switch
            v-model="form.enable"
            active-value="0"
            inactive-value="1"
          ></el-switch>
yuanshuhui authored
319
320
321
322
323
324
325
326
327
328
329
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
yuanshuhui authored
330
331
332
333
334
335
336
import {
  listPreference,
  addPreference,
  getPreference,
  updatePreference,
  delPreference,
} from "@/api/config/inventory/cycleCountPreference";
yuanshuhui authored
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359

export default {
  name: "Config",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 盘点首选项表格数据
      preferenceList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
yuanshuhui authored
360
361
362
      // 系统正确错误数据字典
      sysOptions: [],
      // 是否有效数据字典
yuanshuhui authored
363
364
      enableOptions: [],
yuanshuhui authored
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        code: undefined,
        promptLocation: undefined,
        promptItem: undefined,
        promptLpn: undefined,
        lastUpdatedBy: undefined,
        createdBy: undefined,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        name: [
yuanshuhui authored
381
382
383
384
385
          {
            required: true,
            message: "盘点首选项名称不能为空",
            trigger: ["blur", "change"],
          },
yuanshuhui authored
386
        ],
yuanshuhui authored
387
      },
yuanshuhui authored
388
389
390
391
    };
  },
  created() {
    this.getList();
yuanshuhui authored
392
    this.getDicts("sys_true_false").then((response) => {
yuanshuhui authored
393
394
      this.sysOptions = response.data;
    });
yuanshuhui authored
395
    this.getDicts("enable").then((response) => {
yuanshuhui authored
396
      this.enableOptions = response.data;
yuanshuhui authored
397
398
399
400
401
402
    });
  },
  methods: {
    /** 查询客户列表 */
    getList() {
      this.loading = true;
yuanshuhui authored
403
404
405
406
407
      listPreference(this.queryParams).then((response) => {
        this.preferenceList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
yuanshuhui authored
408
409
    },
    // 系统内置字典翻译
yuanshuhui authored
410
411
412
    sysFormat(row, column) {
      return this.selectDictLabel(this.sysOptions, row.promptLocation);
    },
yuanshuhui authored
413
    // 是否有效字典翻译
yuanshuhui authored
414
415
    enableFormat(row, column) {
      return this.selectDictLabel(this.enableOptions, row.enable);
yuanshuhui authored
416
417
418
419
420
421
422
423
424
425
426
427
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        code: undefined,
        name: undefined,
yuanshuhui authored
428
429
430
431
432
        promptLocation: true,
        promptLpn: true,
        promptItem: true,
        prompAdjustQty: true,
        promptQuantity: true,
yuanshuhui authored
433
        enable: "0",
yuanshuhui authored
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加盘点首选项";
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
yuanshuhui authored
456
457
458
      this.ids = selection.map((item) => item.id);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
yuanshuhui authored
459
460
461
462
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
yuanshuhui authored
463
464
      const preferenceId = row.id || this.ids;
      getPreference(preferenceId).then((response) => {
yuanshuhui authored
465
        this.form = response.data;
yuanshuhui authored
466
        this.form.enable = response.data.enable.toString();
yuanshuhui authored
467
468
469
470
471
        this.open = true;
        this.title = "修改盘点首选项";
      });
    },
    /** 提交按钮 */
yuanshuhui authored
472
473
    submitForm: function () {
      this.$refs["form"].validate((valid) => {
yuanshuhui authored
474
475
        if (valid) {
          if (this.form.id != undefined) {
yuanshuhui authored
476
            updatePreference(this.form).then((response) => {
yuanshuhui authored
477
478
479
480
481
482
483
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }
            });
          } else {
yuanshuhui authored
484
            addPreference(this.form).then((response) => {
yuanshuhui authored
485
486
487
488
489
490
491
492
493
494
495
496
497
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const preferenceIds = row.id || this.ids;
yuanshuhui authored
498
499
500
501
      this.$confirm(
        '是否确认删除盘点首选项id为"' + preferenceIds + '"的数据项?',
        "警告",
        {
yuanshuhui authored
502
503
          confirmButtonText: "确定",
          cancelButtonText: "取消",
yuanshuhui authored
504
505
506
507
          type: "warning",
        }
      )
        .then(function () {
yuanshuhui authored
508
          return delPreference(preferenceIds);
yuanshuhui authored
509
510
        })
        .then(() => {
yuanshuhui authored
511
512
          this.getList();
          this.msgSuccess("删除成功");
yuanshuhui authored
513
514
        })
        .catch(function () {});
yuanshuhui authored
515
    },
yuanshuhui authored
516
  },
yuanshuhui authored
517
518
};
</script>