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
| <!--职务选择框-->
| <template>
| <div>
| <BasicModal
| v-bind="$attrs"
| @register="register"
| :title="modalTitle"
| width="900px"
| wrapClassName="j-user-select-modal"
| @ok="handleOk"
| destroyOnClose
| @visible-change="visibleChange"
| >
| <a-row>
| <a-col :span="showSelected ? 18 : 24">
| <BasicTable
| :columns="columns"
| :bordered="true"
| :useSearchForm="true"
| :formConfig="formConfig"
| :api="getPositionList"
| :searchInfo="searchInfo"
| :rowSelection="rowSelection"
| :indexColumnProps="indexColumnProps"
| v-bind="getBindValue"
| ></BasicTable>
| </a-col>
| <a-col :span="showSelected ? 6 : 0">
| <BasicTable
| v-bind="selectedTable"
| :dataSource="selectRows"
| :useSearchForm="true"
| :formConfig="{ showActionButtonGroup: false, baseRowStyle: { minHeight: '40px' } }"
| >
| <!--操作栏-->
| <template #action="{ record }">
| <a href="javascript:void(0)" @click="handleDeleteSelected(record)"><Icon icon="ant-design:delete-outlined"></Icon></a>
| </template>
| </BasicTable>
| </a-col>
| </a-row>
| </BasicModal>
| </div>
| </template>
| <script lang="ts">
| import { defineComponent, ref, unref } from 'vue';
| import { BasicModal, useModalInner } from '/@/components/Modal';
| import { getPositionList } from '/@/api/common/api';
| import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
| import { useSelectBiz } from '/@/components/Form/src/jeecg/hooks/useSelectBiz';
| import { useAttrs } from '/@/hooks/core/useAttrs';
| import { selectProps } from '/@/components/Form/src/jeecg/props/props';
|
| export default defineComponent({
| name: 'PositionSelectModal',
| components: {
| //此处需要异步加载BasicTable
| BasicModal,
| BasicTable: createAsyncComponent(() => import('/@/components/Table/src/BasicTable.vue'), {
| loading: true,
| }),
| },
| props: {
| ...selectProps,
| //选择框标题
| modalTitle: {
| type: String,
| default: '职务选择',
| },
| },
| emits: ['register', 'getSelectResult'],
| setup(props, { emit, refs }) {
| //注册弹框
| const [register, { closeModal }] = useModalInner();
| const attrs = useAttrs();
| //表格配置
| const config = {
| canResize: false,
| bordered: true,
| size: 'small',
| rowKey: 'code',
| };
| const getBindValue = Object.assign({}, unref(props), unref(attrs), config);
| const [{ rowSelection, visibleChange, indexColumnProps, getSelectResult, handleDeleteSelected, selectRows }] = useSelectBiz(
| getPositionList,
| getBindValue
| );
| const searchInfo = ref(props.params);
| //查询form
| const formConfig = {
| labelCol: {
| span: 8,
| },
| baseColProps: {
| xs: 24,
| sm: 10,
| md: 10,
| lg: 10,
| xl: 10,
| xxl: 10,
| },
| schemas: [
| {
| label: '职务名称',
| field: 'name',
| component: 'JInput',
| colProps: { span: 10 },
| },
| ],
| };
| //定义表格列
| const columns = [
| {
| title: '职务编码',
| dataIndex: 'code',
| width: 40,
| align: 'left',
| },
| {
| title: '职务名称',
| dataIndex: 'name',
| width: 40,
| },
| {
| title: '职务等级',
| dataIndex: 'postRank_dictText',
| width: 40,
| },
| ];
| //已选择的table信息
| const selectedTable = {
| pagination: false,
| showIndexColumn: false,
| scroll: { y: 390 },
| size: 'small',
| canResize: false,
| bordered: true,
| rowKey: 'id',
| columns: [
| {
| title: '职务名称',
| dataIndex: 'name',
| width: 40,
| },
| {
| title: '操作',
| dataIndex: 'action',
| align: 'center',
| width: 40,
| slots: { customRender: 'action' },
| },
| ],
| };
| /**
| * 确定选择
| */
| function handleOk() {
| getSelectResult((options, values) => {
| //回传选项和已选择的值
| emit('getSelectResult', options, values);
| //关闭弹窗
| closeModal();
| });
| }
| return {
| handleOk,
| getPositionList,
| register,
| visibleChange,
| getBindValue,
| formConfig,
| indexColumnProps,
| columns,
| rowSelection,
|
| selectedTable,
| selectRows,
| handleDeleteSelected,
| };
| },
| });
| </script>
|
|