wang
2024-03-28 04adb88a2ed54cdf4c2958c79972c30109b9b5b6
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
227
228
229
230
231
232
233
234
235
236
237
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
283
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
<template>
  <el-header height="auto">
    <el-descriptions
        class="margin-top"
        title=""
        :column="4"
        :size="'default'"
        border
    >
      <el-descriptions-item label-class-name="label-diy" class-name="content-diy">
        <template #label>
          操作单号
        </template>
        <el-input v-model="form.buyItem" placeholder="单号" disabled></el-input>
      </el-descriptions-item>
 
      <el-descriptions-item label-class-name="label-diy" class-name="content-diy">
        <template #label>
          采购类型
        </template>
        <el-input v-model="form.buyItem" placeholder="采购类型" disabled></el-input>
      </el-descriptions-item>
 
      <el-descriptions-item label-class-name="label-diy" class-name="content-diy">
        <template #label>
          采购部门
        </template>
        <el-input v-model="form.buyItem" placeholder="采购部门" disabled></el-input>
      </el-descriptions-item>
 
      <el-descriptions-item label-class-name="label-diy" class-name="content-diy">
        <template #label>
          供应商
        </template>
        <el-input v-model="form.buyItem" placeholder="供应商" disabled></el-input>
      </el-descriptions-item>
 
      <el-descriptions-item label-class-name="label-diy" class-name="content-diy">
        <template #label>
          采购员
        </template>
        <el-input v-model="form.buyItem" placeholder="采购员" disabled></el-input>
      </el-descriptions-item>
 
      <el-descriptions-item label-class-name="label-diy" class-name="content-diy">
        <template #label>
          采购组织
        </template>
        <el-input v-model="form.buyItem" placeholder="采购组织" disabled></el-input>
      </el-descriptions-item>
 
      <el-descriptions-item label-class-name="label-diy" class-name="content-diy">
        <template #label>
          制表日期
        </template>
        <el-date-picker
            v-model="form.date"
            type="date"
            placeholder="选择制表日期"
        />
      </el-descriptions-item>
 
      <el-descriptions-item label-class-name="label-diy" class-name="content-diy"></el-descriptions-item>
 
    </el-descriptions>
  </el-header>
 
  <el-main style="padding-top: 5px;height:100%">
    <vxe-grid
        max-height="500"
        @filter-change="filterChanged"
        ref="xGrid"
        v-bind="gridOptions"
        v-on="gridEvents"
    >
 
      <!--      @toolbar-button-click="toolbarButtonClickEvent"-->
      <!--      下拉显示所有信息插槽-->
      <template #content="{ row}">
        <ul class="expand-wrapper">
          <li v-for="(item,key,index) in row">
            <span style="font-weight: bold">{{ key + ':  ' }}</span>
            <span>{{ item }}</span>
          </li>
        </ul>
      </template>
 
    </vxe-grid>
 
  </el-main>
 
</template>
 
<script setup>
import {ref, reactive} from 'vue'
 
let router = useRouter()
import {useRouter} from "vue-router";
import { ElMessage, ElMessageBox} from "element-plus";
 
const value = ref('')
 
//组件接收参数
const gridOptions = reactive({
  border: "full",//表格加边框
  keepSource: true,//保持源数据
  align: 'center',//文字居中
  stripe: true,//斑马纹
  rowConfig: {isCurrent: true, isHover: true, height: 50},//鼠标移动或选择高亮
  id: 'CustomerList',
  showFooter: true,//显示脚
  printConfig: {},
  importConfig: {},
  exportConfig: {},
  //开启虚拟滚动
  scrollY: {enabled: true},
  showOverflow: true,
  columnConfig: {
    resizable: true,
    useKey: true
  },
  //筛选配置项
  filterConfig: {
    remote: true
  },
  customConfig: {
    storage: true
  },
  editConfig: {
    trigger: 'click',
    mode: 'row',
    showStatus: true
  },
  //表头参数、列名
  columns: [
    {type: 'seq', fixed: "left", title: ' ', width: 50},
    {type: 'checkbox', fixed: "left", title: '', width: 50},
    {
      field: 'cgdh',
      width: '10%',
      title: '物料编码',
      filters: [{data: ''}],
      sortable: true
    },
    {
      field: 'cgzt',
      width: '10%',
      title: '物料名称',
      filters: [{data: ''}],
      sortable: true
    },
    {
      field: 'gys',
      width: '10%',
      title: '产地',
 
      filters: [{data: ''}],
      sortable: true
    },
    {
      field: 'w',
      width: '8%',
      title: '宽度',
      filters: [{data: ''}],
      sortable: true
    },
    {
      field: 'g',
      width: '8%',
      title: '高度',
      filters: [{data: ''}],
      sortable: true,
 
    },
    {
      field: 'h',
      width: '8%',
      title: '厚度',
      filters: [{data: ''}],
      sortable: true
    },
    {
      field: 'xh',
      width: '8%',
      title: '型号',
      filters: [{data: ''}],
      sortable: true
    },
    {
      field: 'dw',
      width: '8%',
      title: '单位',
      filters: [{data: ''}],
      sortable: true
    },
    {
      field: 'sl',
      width: '8%',
      title: '数量',
      filters: [{data: ''}],
      sortable: true
    },
    {
      field: 'czsl',
      width: '8%',
      title: '操作数量',
      type: 'number',
      editRender: {name: 'input', type: 'number', attrs: {placeholder: ''}}
    },
    {
      field: 'sl',
      width: '12%',
      title: '箱数',
      filters: [{data: ''}],
      sortable: true
    },
    {
      field: 'je',
      width: '8%',
      title: '单片面积',
      filters: [{data: ''}],
      sortable: true
    },
    {
      field: 'je',
      width: '12%',
      title: '单价',
      filters: [{data: ''}],
      sortable: true
    },
    {
      field: 'sl',
      width: '8%',
      title: '总面积',
      filters: [{data: ''}],
      sortable: true
    },
    {
      field: 'yl',
      width: '10%',
      title: '总金额',
      filters: [{data: ''}],
      sortable: true
    },
    {
      field: 'yl',
      width: '10%',
      title: '备注',
      filters: [{data: ''}],
      sortable: true
    }
  ],
  //表头按钮
  toolbarConfig: {
    buttons: [
      {type: 'text'},
      {
        'name': '保存订单',
        status: 'primary',
        'code': 'Save'
      }, {
        'name': '入库',
        status: 'primary',
        'code': 'Storage'
      },
      {
        'name': '退货',
        status: 'primary',
        'code': 'Return'
      },
      {
        'name': '取消',
        status: '',
        'code': 'Cancel'
      }],
    import: false,
    export: true,
    print: true,
    zoom: true,
    custom: true,
    tools: [],
 
  },
  //table body实际数据
  data: [{}, {}, {}],
  //脚合并
  mergeFooterItems: [
    {row: 0, col: 0, rowspan: 1, colspan: 3}
  ],
  //合并脚
  footerMethod({columns, data}) {//页脚函数
    return [
      columns.map((column, columnIndex) => {
        if (columnIndex === 0) {
          return '合计:'
        }
        /* if (props.tableProp.footList.includes(column.field)) {
           return sumNum(data, column.field)
         }*/
        return ''
      })
    ]
  },
 
})
 
const xGrid = ref()
const gridEvents = {
  toolbarButtonClick({code}) {
    const $grid = xGrid.value
    if ($grid) {
      switch (code) {
//保存
        case 'Save': {
          MessageAlertShow('点击了保存订单','操作提示');
          //MessageShow('点击了保存订单!', 'error');
          break;
        }
//取消,返回查询页面
        case 'Cancel': {
          // router.push({path: '/main/purchaseOrder/StoragePurchaseOrder'})
          break
        }
//入库
        case 'Storage': {
          if ($grid.getCheckboxRecords().length === 0) {
            MessageShow('请选择至少一条数据!', 'warning');
            return
          } else {
            MessageConfirmShow('入库', '是否确认对选中的' + $grid.getCheckboxRecords().length + '物料进行入库操作!');
          }
          break
        }
//退货
        case 'Return': {
          if ($grid.getCheckboxRecords().length === 0) {
            MessageShow('请选择至少一条数据!', 'warning');
            return
          } else {
 
            MessageConfirmShow('退货', '是否确认对选中的' + $grid.getCheckboxRecords().length + '物料进行退货操作!');
          }
          break
        }
 
      }
    }
  },
  toolbarToolClick({code}) {
    const $grid = xGrid.value
    if ($grid) {
      switch (code) {
        case 'myPrint': {
          $grid.print()
          break
        }
      }
    }
  },
}
 
//表单数据
const form = reactive({
  name: '',
  region: '',
  date: '',
  delivery: false,
  type: [],
  resource: '',
  desc: '',
  supplier: '',
  buyer: '',
  buyItem: '',
  buyType: ''
 
})
 
 
//页面逻辑代码执行
function logicExecute(type){
  const $grid = xGrid.value
  switch (type) {
    case '入库':
      //入库逻辑代码TODO
      MessageShow('入库成功!', 'success');
      break;
    case '退货':
      //退货逻辑代码TODO
      MessageShow('退货成功!', 'success');
      break;
    default:
      MessageShow('未知操作!', 'error');
      break;
  }
  return true;
}
 
//提示信息
//信息内容,显示方式,显示标题,类型
const MessageShow = (content,type='success') => {
    ElMessage({
      message: content,
      type: type,
      showClose: true,
    })
}
 
//操作确认类信息:操作类型,提示内容,提示标头,提示类型
const MessageConfirmShow = (czType, content, title='操作确认提示', type='warning') => {
  ElMessageBox.confirm(
      content,
      title,
      {
        cancelButtonText: '取消',
        confirmButtonText: '确定',
        type: type,
        center: true,
      }
  )
      //点击了确定
      .then(() => {
 
        return logicExecute(czType);
      })
      //点击了取消
      .catch(() => {
        return false;
      })
}
 
//弹窗信息
const MessageAlertShow=(content,title,type='info')=>{
 
  ElMessageBox.alert(content, title, {
    // 禁止自动对焦
    //autofocus: false,
    confirmButtonText: 'OK',
    /*callback: (action: Action) => {
      MessageShow(`action: ${action}`,type)
    },*/
  })
}
 
</script>
 
 
<style scoped>
:deep(.el-descriptions__table .label-diy) {
  text-align: center;
  width: 100px;
  /*  font-size: large;*/
}
</style>