feat: 给AMF/MME对应的IMEI白名单添加批量导入和批量删除功能
This commit is contained in:
84
src/views/ne/neConfig/hooks/useArrayBatchDel.ts
Normal file
84
src/views/ne/neConfig/hooks/useArrayBatchDel.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import { delNeConfigData } from '@/api/ne/neConfig';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { reactive, toRaw } from 'vue';
|
||||
|
||||
/**
|
||||
* 批量删除array
|
||||
* @param param 父级传入 { t, neTypeSelect, fnActiveConfigNode }
|
||||
* @returns
|
||||
*/
|
||||
export default function useArrayBatch({
|
||||
t,
|
||||
neTypeSelect,
|
||||
fnActiveConfigNode,
|
||||
}: any) {
|
||||
/**状态属性 */
|
||||
const batchState = reactive({
|
||||
open: false,
|
||||
loading: false, //批量删除
|
||||
paramName: '',
|
||||
startIndex: 1,
|
||||
num: 1,
|
||||
});
|
||||
|
||||
/**对话框表格信息导入弹出窗口 */
|
||||
function modalBatchOpen(paramName: string) {
|
||||
batchState.paramName = paramName;
|
||||
batchState.open = true;
|
||||
}
|
||||
function modalBatchClose() {
|
||||
if (batchState.loading) {
|
||||
message.error({
|
||||
content: 'Delete is in progress, please wait for it to complete',
|
||||
duration: 3,
|
||||
});
|
||||
return;
|
||||
}
|
||||
batchState.open = false;
|
||||
batchState.loading = false;
|
||||
batchState.startIndex = 1;
|
||||
batchState.num = 1;
|
||||
fnActiveConfigNode('#')
|
||||
}
|
||||
|
||||
async function modalBatchOk() {
|
||||
let okNum = 0;
|
||||
let failNum = 0;
|
||||
const endIndex = batchState.startIndex + batchState.num - 1;
|
||||
for (let i = endIndex; i >= batchState.startIndex; i--) {
|
||||
const res = await delNeConfigData({
|
||||
neType: neTypeSelect.value[0],
|
||||
neId: neTypeSelect.value[1],
|
||||
paramName: batchState.paramName,
|
||||
loc: `${i}`,
|
||||
});
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
okNum++;
|
||||
} else {
|
||||
failNum++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (okNum > 0) {
|
||||
message.success({
|
||||
content: `Successfully deleted ${okNum} items`,
|
||||
duration: 3,
|
||||
});
|
||||
}
|
||||
if (failNum > 0) {
|
||||
message.error({
|
||||
content: `Delete failed, please check the index range`,
|
||||
duration: 3,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
batchState,
|
||||
modalBatchOpen,
|
||||
modalBatchClose,
|
||||
modalBatchOk,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user