llj
2026-03-06 aba8f174b40ac038712ab28afa099b4d01aa4453
我的待办修复
3个文件已修改
85 ■■■■ 已修改文件
components/ZWDB/HItem.vue 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
components/ZWDB/Hfooter.vue 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/ziwodaiban/todoMain.vue 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
components/ZWDB/HItem.vue
@@ -1,8 +1,8 @@
<template>
    <li class="todo-item">
        <checkbox-group @change="onRadioChange" v-model="checkedIds">
            <label class="radio-option" v-for="(item, index) in todoItem" :key="item.HID" v-show="item.是否启用">
                <checkbox  @change="onCheckboxChange(item.HID)"/>
        <checkbox-group v-for="(item, index) in todoItem" :key="item.HID" @change="onCheckboxChange(item.是否选中,item.HID) ">
            <label class="radio-option"  v-show="item.是否启用">
                <checkbox    :checked="item.是否选中" />
                <text class="item-text" >{{item.代码项目}}</text>
                <button class="delete-btn" @click="deleteItem(item)">删除</button>
            </label>
@@ -31,6 +31,11 @@
            uni.$emit("deleteItem", item.HID);
            console.log("删除项ID:", item.HID);
        },
        onCheckboxChange(checked, HID)
        {
            console.log("当前选中项ID:",checked, HID);
            uni.$emit("changeItem",checked, HID);
        }
    },
    
}
@@ -98,4 +103,4 @@
button.delete-btn::after {
    border: none;
}
</style>我希望通过watch获取到所有勾选的HID
</style>
components/ZWDB/Hfooter.vue
@@ -1,8 +1,7 @@
<template>
    <view class="todo-footer">
    <radio-group>
            <radio />
            <!-- <radio /> -->
            <span><span>已完成{{ completedCount }}</span>/总共{{ total }}</span>
            <button @click="clearAllobj">清除已完成</button>
@@ -12,22 +11,33 @@
<script>
export default {
    props: {
        todoList: {
            type: Array,
            required: true
        }
    },
    data() {
        return {
            completedCount: 0,
            total: 0,
        }
    },
    computed: {
        // completedCount() {
        //     return this.todoList.filter(item => item.completed).length;
        // },
        // total() {
        //     return this.todoList.length;
        // }
        completedCount() {
            return this.todoList.filter(item => item.是否选中).length;
        },
        total() {
            return this.todoList.filter(item => item.是否启用).length;
        }
    },
    methods: {
        clearAllobj()
        {
            if(confirm("确定要清除已完成的事项吗?"))
            {
                this.$emit("clearAll");
            }
        }
    }
}
</script>
pages/ziwodaiban/todoMain.vue
@@ -3,7 +3,7 @@
        <Header @missionAdded="onMissionAdded"></Header>
        <HList :todoList="contentList"></HList>
        <Hfooter></Hfooter>
        <Hfooter :todoList="contentList" @clearAll="clearAll"></Hfooter>
    </view>
</template>
@@ -65,6 +65,7 @@
                            是否启用: element.是否启用,
                            是否可编辑: element.是否可编辑,
                            是否禁用: element.是否禁用,
                            是否选中:false
                        };
                    });
                    this.empty = this.todoList.length === 0;
@@ -119,8 +120,8 @@
            });
        
        },
        deleteMission(deleteID) {
            let res= CommonUtils.doRequest2Sync({
         deleteMission(deleteID) {
            return  CommonUtils.doRequest2Sync({
                url: '/ZWDBController/deleteTODOS',
                data: {
                    user: localStorage.getItem('HUserName'),
@@ -150,20 +151,41 @@
            });
            console.log("删除项ID:", deleteID);
        },
        itemChanged(checkedID)
        itemChanged(checked, HID)
        {
            console.log("状态变化项ID:", checkedID);
        }
            console.log("状态变化项ID:", checked, HID);
            const checktodo=this.contentList.find(item => item.HID === HID);
            checktodo.是否选中=!checked;
            console.log("最后ID:", checktodo.是否选中, HID);
        },
        async clearAll() {
            const completedItems = this.contentList.filter(item => item.是否选中);
            for (let item of completedItems) {
                try {
                await this.deleteMission(item.HID);
                await this.sleep(300);
                } catch (e) {
                console.error('删除失败', e);
                }
            }
            console.log('所有已完成项已删除');
            },
            sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
  }
    },
    mounted() {
        uni.$on("deleteItem", this.deleteMission);
        uni.$on("changeItem", this.itemChanged);
        uni.$on("changeItem", (checked, HID) => {
            this.itemChanged(checked, HID);
        });
    },
    beforeDestroy() {
        uni.$off("deleteItem", this.deleteMission);
        uni.$off("changeItem", this.itemChanged);
        uni.$off("changeItem", (checked, HID) => {
            this.itemChanged(checked, HID);
        });
    },
}
</script>