diff --git a/src/store/index.js b/src/store/index.js index 9fe1eba..63becd8 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1263,6 +1263,50 @@ const store = new Vuex.Store({ Message.error(res.data.msg || '排序更新失败') } return res + }, + + /** + * @description: 删除地图样式 + * @param {Array} idArr 需要删除的样式ID数组 + */ + async fetchDelMapStyle ({ dispatch }, idArr) { + if (!idArr || !idArr.length) { + Message.warning('请选择要删除的样式') + return Promise.reject(new Error('未选择要删除的样式')) + } + + try { + await MessageBox.confirm( + `确定要删除选中的 ${idArr.length} 个地图样式吗?删除后不可恢复!`, + '提示', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + closeOnClickModal: false + } + ) + + const params = new URLSearchParams() + params.append('id', idArr.join(',')) + const res = await api.post('delMapStyle', params, 'Plane') + + if (res.data.status === 1) { + Message.success(res.data.msg || '删除成功') + // 重新获取样式列表 + await dispatch('fetchMapStyleList') + } else { + Message.error(res.data.msg || '删除失败') + } + return res + } catch (error) { + if (error !== 'cancel') { + console.error('删除样式失败:', error) + Message.error('删除失败') + throw error + } + return Promise.reject(new Error('用户取消删除')) + } } }, modules: { diff --git a/src/views/layout/components/main/mapstyle/index.vue b/src/views/layout/components/main/mapstyle/index.vue index 9cb9c8c..1f6b6eb 100644 --- a/src/views/layout/components/main/mapstyle/index.vue +++ b/src/views/layout/components/main/mapstyle/index.vue @@ -1,13 +1,21 @@