ny
昨天 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
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
<script lang="ts" setup>
import { nextTick } from 'vue';
 
import { BasicModal, useModalInner } from '@jnpf/ui/modal';
import { BasicVxeTable, useVxeTable } from '@jnpf/ui/vxeTable';
 
import { getGoodsList } from '#/api/extend/order';
import { $t } from '#/locales';
 
const emit = defineEmits(['register', 'select']);
const [registerModal, { closeModal }] = useModalInner(init);
 
const [registerTable, { getForm, getSelectRows, clearSelectedRowKeys }] = useVxeTable({
  api: getGoodsList,
  columns: [
    { title: '商品名称', dataIndex: 'text' },
    { title: '商品编码', dataIndex: 'code', width: 100 },
    { title: '规格型号', dataIndex: 'specifications', width: 80 },
    { title: '单位', dataIndex: 'unit', width: 80 },
    { title: '售价', dataIndex: 'price', width: 80 },
  ],
  useSearchForm: true,
  formConfig: {
    baseColProps: { span: 8 },
    schemas: [
      {
        field: 'keyword',
        label: $t('common.keyword'),
        component: 'Input',
        componentProps: {
          placeholder: $t('common.enterKeyword'),
          submitOnPressEnter: true,
        },
      },
    ],
  },
  tableSetting: { size: false, setting: false },
  pagination: false,
  immediate: false,
  rowSelection: { type: 'checkbox' },
});
function init() {
  getForm().resetFields();
  nextTick(() => {
    clearSelectedRowKeys();
  });
}
function handleSubmit() {
  const selectedData = getSelectRows();
  emit('select', selectedData);
  closeModal();
}
</script>
<template>
  <BasicModal v-bind="$attrs" @register="registerModal" title="选择商品" @ok="handleSubmit" :width="800" class="jnpf-list-modal">
    <BasicVxeTable @register="registerTable" class="jnpf-sub-table" />
  </BasicModal>
</template>