修改设备批量添加
This commit is contained in:
parent
22b6895eed
commit
ee10c142a6
@ -180,6 +180,9 @@ const [BatchAddModal, batchAddModalApi] = useVbenModal({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 获取批量添加模态框的状态
|
||||||
|
const batchAddModalState = batchAddModalApi.useStore();
|
||||||
|
|
||||||
// 新增和编辑提交的逻辑
|
// 新增和编辑提交的逻辑
|
||||||
async function submit() {
|
async function submit() {
|
||||||
const isEdit = !!editRow.value.id;
|
const isEdit = !!editRow.value.id;
|
||||||
@ -466,14 +469,25 @@ const getAddressLines = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 监听批量添加表单的地址列表变化
|
// 使用计算属性来实时计算行数
|
||||||
watch(
|
const computedAddressLines = computed(() => {
|
||||||
() => batchAddFormApi.getValues()?.addressList,
|
try {
|
||||||
(newValue) => {
|
const formValues = batchAddFormApi.getValues();
|
||||||
getAddressLines();
|
const addressList = formValues?.addressList;
|
||||||
},
|
if (!addressList || typeof addressList !== 'string') {
|
||||||
{ immediate: true },
|
return 0;
|
||||||
);
|
}
|
||||||
|
const lines = addressList.split('\n').filter((line: string) => line.trim());
|
||||||
|
return lines.length;
|
||||||
|
} catch {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 监听计算属性的变化,更新 addressLines
|
||||||
|
watch(computedAddressLines, (newValue) => {
|
||||||
|
addressLines.value = newValue;
|
||||||
|
}, { immediate: true });
|
||||||
|
|
||||||
// 缓存刷新按钮处理函数
|
// 缓存刷新按钮处理函数
|
||||||
const handleCacheRefresh = async () => {
|
const handleCacheRefresh = async () => {
|
||||||
@ -634,6 +648,14 @@ const toolbarActions = computed(() => [
|
|||||||
共 {{ addressLines }} 行设备地址
|
共 {{ addressLines }} 行设备地址
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<Button @click="batchAddModalApi.close()">
|
||||||
|
{{ $t('common.cancel') }}
|
||||||
|
</Button>
|
||||||
|
<Button type="primary" :loading="batchAddModalState?.confirmLoading" @click="submitBatchAdd">
|
||||||
|
{{ $t('common.confirm') }}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</BatchAddModal>
|
</BatchAddModal>
|
||||||
|
|||||||
@ -674,7 +674,7 @@ export const batchAddDeviceFormSchema: any = computed(() => [
|
|||||||
componentProps: {
|
componentProps: {
|
||||||
rows: 4,
|
rows: 4,
|
||||||
placeholder: $t('common.pleaseInput') + $t('abp.deviceInfos.deviceAddress') + ',每行一个设备地址',
|
placeholder: $t('common.pleaseInput') + $t('abp.deviceInfos.deviceAddress') + ',每行一个设备地址',
|
||||||
showCount: false,
|
showCount: true,
|
||||||
maxLength: 2000,
|
maxLength: 2000,
|
||||||
style: {
|
style: {
|
||||||
resize: 'vertical',
|
resize: 'vertical',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user