吉安感知网项目-前端
罗广辉
2026-01-30 bb52b013fa9ffd86124ddc79abd42fb26f48baca
feat: 共享删除修改
3 files modified
82 ■■■■ changed files
applications/drone-command/src/views/permissionManage/permissionDept/ShareDiaLog.vue 40 ●●●● patch | view | raw | blame | history
applications/task-work-order/src/views/orderView/orderManage/inspectionRequest/index.vue 2 ●●● patch | view | raw | blame | history
applications/task-work-order/src/views/orderView/orderManage/orderManage/FormDiaLog.vue 40 ●●●●● patch | view | raw | blame | history
applications/drone-command/src/views/permissionManage/permissionDept/ShareDiaLog.vue
@@ -21,7 +21,11 @@
                                <el-table-column type="index" show-overflow-tooltip width="64" label="序号" />
                                <el-table-column prop="deviceName" show-overflow-tooltip label="设备名称" />
                                <el-table-column prop="deviceSn" show-overflow-tooltip label="设备SN" />
                                <el-table-column prop="deviceType" show-overflow-tooltip label="设备类型" />
                                <el-table-column prop="deviceType" show-overflow-tooltip label="设备类型">
                                    <template v-slot="{ row }">
                                        {{ getDictLabel(row.deviceType, dictObj.deviceType) }}
                                    </template>
                                </el-table-column>
                                <el-table-column prop="belongDeptName" show-overflow-tooltip label="所属部门" />
                            </el-table>
                        </div>
@@ -44,6 +48,8 @@
import { ref, nextTick } from 'vue'
import { ElMessage } from 'element-plus'
import { nonDeptAreaDevicesApi, fwDevicePerShareSaveApi, fwDevicePerShareRemoveApi } from './fwDevicePerShareApi'
import { getDictionaryByCode } from '@/api/system/dictbiz'
import { getDictLabel } from '@ztzf/utils'
const emit = defineEmits(['success'])
const visible = defineModel() // 弹框显隐
@@ -53,7 +59,18 @@
const tableRef = ref(null) // 表格实例
const selectedRows = ref([]) // 当前选中的行
const originalSharedIds = ref([]) // 原始已共享的设备ID集合
const originalSharedMap = ref({}) // 原始已共享的设备ID与shareId的映射
const currentDeptId = ref(null) // 当前操作的部门ID
const dictObj = ref({
    deviceType: [], // 设备类型
})
// 获取字典
function getDictList() {
    getDictionaryByCode('deviceType').then(res => {
        dictObj.value = res.data.data
    })
}
// 选中变化
function handleSelectionChange(rows) {
@@ -71,8 +88,13 @@
    try {
        const res = await nonDeptAreaDevicesApi({ loanToDeptId: currentDeptId.value })
        deviceList.value = res?.data?.data ?? []
        // 记录原始已共享的设备ID
        originalSharedIds.value = deviceList.value.filter(item => item.isShared).map(item => item.id)
        // 记录原始已共享的设备ID和shareId映射
        const sharedDevices = deviceList.value.filter(item => item.isShared)
        originalSharedIds.value = sharedDevices.map(item => item.id)
        originalSharedMap.value = sharedDevices.reduce((map, item) => {
            map[item.id] = item.shareId
            return map
        }, {})
        // 回显已共享的设备勾选状态
        nextTick(() => {
            deviceList.value.forEach(item => {
@@ -95,8 +117,11 @@
        // 计算需要新增的设备(当前选中但原来未共享)
        const toAddDevices = selectedRows.value.filter(item => !originalSharedIds.value.includes(item.id))
        // 计算需要删除的设备(原来共享但当前未选中)
        const toRemoveIds = originalSharedIds.value.filter(id => !currentSelectedIds.includes(id))
        // 计算需要删除的设备(原来共享但当前未选中),使用shareId
        const toRemoveShareIds = originalSharedIds.value
            .filter(id => !currentSelectedIds.includes(id))
            .map(id => originalSharedMap.value[id])
            .filter(Boolean)
        const promises = []
@@ -112,8 +137,8 @@
        }
        // 调用删除接口
        if (toRemoveIds.length > 0) {
            promises.push(fwDevicePerShareRemoveApi({ ids: toRemoveIds.join(',') }))
        if (toRemoveShareIds.length > 0) {
            promises.push(fwDevicePerShareRemoveApi({ ids: toRemoveShareIds.join(',') }))
        }
        if (promises.length > 0) {
@@ -134,6 +159,7 @@
async function open({ row } = {}) {
    currentDeptId.value = row?.id
    selectedRows.value = []
    getDictList()
    await getDeviceList()
}
applications/task-work-order/src/views/orderView/orderManage/inspectionRequest/index.vue
@@ -72,7 +72,7 @@
        </el-form>
        <div class="gd-table-toolbar">
            <el-button v-if="permission.flyOrder_add" :icon="Plus" color="#4C34FF" type="primary" @click="openForm('add')">新增</el-button>
            <el-button v-if="permission.flyOrder_add" :icon="Plus" color="#4C34FF" type="primary" @click="openForm('add')">拆分工单</el-button>
        </div>
        <div class="gd-table-container" v-loading="loading">
applications/task-work-order/src/views/orderView/orderManage/orderManage/FormDiaLog.vue
@@ -176,20 +176,18 @@
            </div>
            <div class="rightBox" v-if="!dialogReadonly">
                <div class="detail-title">推荐设备</div>
                <template v-if="formData.deviceLoadDemand && pointList.length">
                    <el-table
                        ref="deviceTableRef"
                        :data="deviceList"
                        row-key="id"
                        @selection-change="handleDeviceSelectionChange"
                    >
                        <el-table-column type="selection" width="55" :reserve-selection="true" />
                        <el-table-column prop="nickname" label="设备名称" />
                        <el-table-column prop="deviceName" label="设备型号" />
                        <el-table-column prop="devicePayload" label="设备负载" />
                    </el-table>
                </template>
                <div v-else class="tipSelect">请先选择设备需求并在地图上绘制工单范围</div>
                <el-table
                    :empty-text="(formData.deviceLoadDemand && pointList.length) ? '暂无数据' : '请先选择设备需求并在地图上绘制工单范围'"
                    ref="deviceTableRef"
                    :data="(formData.deviceLoadDemand && pointList.length) ? deviceList : []"
                    row-key="id"
                    @selection-change="handleDeviceSelectionChange"
                >
                    <el-table-column type="selection" width="55" :reserve-selection="true" />
                    <el-table-column prop="nickname" label="设备名称" />
                    <el-table-column prop="deviceName" label="设备型号" />
                    <el-table-column prop="devicePayload" label="设备负载" />
                </el-table>
            </div>
        </div>
@@ -637,6 +635,18 @@
</script>
<style lang="scss" scoped>
.el-table{
    height: 0;
    flex: 1;
    :deep(){
        .el-scrollbar__view{
            height: 100%;
        }
        .el-table__empty-text{
            line-height: normal;
        }
    }
}
.content {
    display: flex;
    gap: 0 20px;
@@ -658,6 +668,8 @@
    .rightBox {
        width: 350px;
        display: flex;
        flex-direction: column;
        .title {
            font-weight: 500;
            font-size: 14px;