...
|
...
|
@@ -68,21 +68,18 @@ |
68
|
68
|
<Button v-if="isShowBtn" class="!bg-gray-200" type="text" @click="handleReturn">
|
69
|
69
|
返回
|
70
|
70
|
</Button>
|
71
|
|
- <Authority :value="[ModelOfMatterPermission.DELETE, ModelCategoryPermission.DELETE]">
|
|
71
|
+ <Authority
|
|
72
|
+ v-if="isShowBtn"
|
|
73
|
+ :value="[ModelOfMatterPermission.DELETE, ModelCategoryPermission.DELETE]"
|
|
74
|
+ >
|
72
|
75
|
<Popconfirm
|
73
|
76
|
title="您确定要批量删除数据"
|
74
|
77
|
ok-text="确定"
|
75
|
78
|
cancel-text="取消"
|
76
|
|
- @confirm="handleDeleteOrBatchDelete(null)"
|
|
79
|
+ @confirm="handleDeleteOrBatchDelete()"
|
|
80
|
+ :disabled="getHasBatchDelete"
|
77
|
81
|
>
|
78
|
|
- <Button
|
79
|
|
- style="display: none"
|
80
|
|
- type="primary"
|
81
|
|
- color="error"
|
82
|
|
- :disabled="hasBatchDelete"
|
83
|
|
- >
|
84
|
|
- 批量删除
|
85
|
|
- </Button>
|
|
82
|
+ <Button type="primary" danger :disabled="getHasBatchDelete"> 批量删除 </Button>
|
86
|
83
|
</Popconfirm>
|
87
|
84
|
</Authority>
|
88
|
85
|
</div>
|
...
|
...
|
@@ -120,11 +117,7 @@ |
120
|
117
|
/>
|
121
|
118
|
</template>
|
122
|
119
|
</BasicTable>
|
123
|
|
- <PhysicalModelModal
|
124
|
|
- :record="$props.record"
|
125
|
|
- @register="registerModal"
|
126
|
|
- @success="handleSuccess"
|
127
|
|
- />
|
|
120
|
+ <PhysicalModelModal :record="$props.record" @register="registerModal" @success="reload" />
|
128
|
121
|
<PhysicalModelTsl :record="$props.record" @register="registerModalTsl" />
|
129
|
122
|
<SelectImport
|
130
|
123
|
:record="$props.record"
|
...
|
...
|
@@ -142,7 +135,6 @@ |
142
|
135
|
ModelCategoryPermission,
|
143
|
136
|
physicalColumn,
|
144
|
137
|
} from '../device.profile.data';
|
145
|
|
- import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
|
146
|
138
|
import { Authority } from '/@/components/Authority';
|
147
|
139
|
import PhysicalModelModal from './cpns/physical/PhysicalModelModal.vue';
|
148
|
140
|
import PhysicalModelTsl from './cpns/physical/PhysicalModelTsl.vue';
|
...
|
...
|
@@ -156,8 +148,11 @@ |
156
|
148
|
releaseModel,
|
157
|
149
|
} from '/@/api/device/modelOfMatter';
|
158
|
150
|
import { OpenModelOfMatterModelParams, OpenModelMode } from './cpns/physical/types';
|
159
|
|
- import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel';
|
160
|
|
- import { ref, unref } from 'vue';
|
|
151
|
+ import {
|
|
152
|
+ ModelOfMatterItemRecordType,
|
|
153
|
+ ModelOfMatterParams,
|
|
154
|
+ } from '/@/api/device/model/modelOfMatterModel';
|
|
155
|
+ import { computed, ref, unref } from 'vue';
|
161
|
156
|
import { isObject } from '/@/utils/is';
|
162
|
157
|
import { useRole } from '/@/hooks/business/useRole';
|
163
|
158
|
import { ExportModelCategory } from '/@/api/device/modelOfMatter';
|
...
|
...
|
@@ -177,50 +172,45 @@ |
177
|
172
|
const [registerModalTsl, { openModal: openModalTsl }] = useModal();
|
178
|
173
|
const [registerModalSelect, { openModal: openModalSelect }] = useModal();
|
179
|
174
|
|
180
|
|
- const [registerTable, { reload, setProps }] = useTable({
|
181
|
|
- api: async (params: Record<'page' | 'pageSize', number>) => {
|
182
|
|
- return await getModelList({
|
183
|
|
- ...params,
|
184
|
|
- id: props.record.id,
|
185
|
|
- selectType: props.record.ifShowClass ? 'category' : undefined,
|
186
|
|
- });
|
187
|
|
- },
|
188
|
|
- columns: props.record.ifShowClass
|
189
|
|
- ? physicalColumn.filter((item) => item.dataIndex !== 'status')
|
190
|
|
- : physicalColumn,
|
191
|
|
- showIndexColumn: false,
|
192
|
|
- clickToRowSelect: false,
|
193
|
|
- showTableSetting: true,
|
194
|
|
- bordered: true,
|
195
|
|
- useSearchForm: true,
|
196
|
|
- formConfig: {
|
197
|
|
- schemas: modelOfMatterForm,
|
198
|
|
- labelWidth: 120,
|
199
|
|
- },
|
200
|
|
- actionColumn: {
|
201
|
|
- width: 200,
|
202
|
|
- title: '操作',
|
203
|
|
- dataIndex: 'action',
|
204
|
|
- slots: { customRender: 'action' },
|
205
|
|
- fixed: 'right',
|
206
|
|
- },
|
207
|
|
- });
|
208
|
|
-
|
209
|
|
- // 刷新
|
210
|
|
- const handleSuccess = () => {
|
211
|
|
- reload();
|
212
|
|
- };
|
213
|
|
- const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete(
|
214
|
|
- props.record.ifShowClass && (unref(isPlatformAdmin) || unref(isSysadmin))
|
215
|
|
- ? deleteModelCategory
|
216
|
|
- : deleteModel,
|
217
|
|
- handleSuccess,
|
218
|
|
- setProps
|
219
|
|
- );
|
|
175
|
+ const [registerTable, { reload, getSelectRowKeys, getRowSelection, clearSelectedRowKeys }] =
|
|
176
|
+ useTable({
|
|
177
|
+ api: async (params: Record<'page' | 'pageSize', number>) => {
|
|
178
|
+ return await getModelList({
|
|
179
|
+ ...params,
|
|
180
|
+ id: props.record.id,
|
|
181
|
+ selectType: props.record.ifShowClass ? 'category' : undefined,
|
|
182
|
+ });
|
|
183
|
+ },
|
|
184
|
+ columns: props.record.ifShowClass
|
|
185
|
+ ? physicalColumn.filter((item) => item.dataIndex !== 'status')
|
|
186
|
+ : physicalColumn,
|
|
187
|
+ showIndexColumn: false,
|
|
188
|
+ clickToRowSelect: false,
|
|
189
|
+ showTableSetting: true,
|
|
190
|
+ bordered: true,
|
|
191
|
+ useSearchForm: true,
|
|
192
|
+ rowKey: 'id',
|
|
193
|
+ formConfig: {
|
|
194
|
+ schemas: modelOfMatterForm,
|
|
195
|
+ labelWidth: 120,
|
|
196
|
+ },
|
|
197
|
+ actionColumn: {
|
|
198
|
+ width: 200,
|
|
199
|
+ title: '操作',
|
|
200
|
+ dataIndex: 'action',
|
|
201
|
+ slots: { customRender: 'action' },
|
|
202
|
+ fixed: 'right',
|
|
203
|
+ },
|
|
204
|
+ rowSelection: {
|
|
205
|
+ getCheckboxProps: (record: ModelOfMatterItemRecordType) => {
|
|
206
|
+ return {
|
|
207
|
+ disabled: record.status === 1,
|
|
208
|
+ };
|
|
209
|
+ },
|
|
210
|
+ },
|
|
211
|
+ });
|
220
|
212
|
|
221
|
|
- selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => {
|
222
|
|
- return { disabled: record.status === 1 };
|
223
|
|
- };
|
|
213
|
+ const getHasBatchDelete = computed(() => !getRowSelection().selectedRowKeys?.length);
|
224
|
214
|
|
225
|
215
|
const handleViewDetail = (record: ModelOfMatterParams) => {
|
226
|
216
|
if (record) {
|
...
|
...
|
@@ -245,6 +235,19 @@ |
245
|
235
|
}
|
246
|
236
|
};
|
247
|
237
|
|
|
238
|
+ const handleDeleteOrBatchDelete = async (record?: ModelOfMatterItemRecordType) => {
|
|
239
|
+ const deleteFn =
|
|
240
|
+ props.record.ifShowClass && (unref(isPlatformAdmin) || unref(isSysadmin))
|
|
241
|
+ ? deleteModelCategory
|
|
242
|
+ : deleteModel;
|
|
243
|
+
|
|
244
|
+ const ids = record ? [record.id] : getSelectRowKeys();
|
|
245
|
+ await deleteFn(ids);
|
|
246
|
+ createMessage.success('删除成功');
|
|
247
|
+ clearSelectedRowKeys();
|
|
248
|
+ reload();
|
|
249
|
+ };
|
|
250
|
+
|
248
|
251
|
const handleOpenTsl = () => {
|
249
|
252
|
openModalTsl(true, {
|
250
|
253
|
isUpdate: true,
|
...
|
...
|
|