1
李喆(开发组)
2025-06-16 c77e9908ed5168d0a6f1623b9585eb30eed760fd
src/views/flow/todolist.vue
@@ -1,13 +1,10 @@
<template>
    <basic-container>
        <avue-crud :option="option" :table-loading="loading" :data="data" ref="crud" v-model="form"
            :permission="permissionList" :before-open="beforeOpen" :before-close="beforeClose" @row-del="rowDel"
             @row-save="rowSave" @search-change="searchChange" @search-reset="searchReset"
            @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
            @refresh-change="refreshChange" @on-load="onLoad">
        <avue-crud :option="option" :table-loading="loading" :data="data" v-model:page="page" v-model="form" ref="crud"
            @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
            @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
            <template #menu-left>
                <el-button type="primary"  plain
                    @click="reassign">重新指派
                <el-button type="primary" plain @click="reassign">重新指派
                </el-button>
            </template>
            <!-- <template #source="{ row }">
@@ -20,7 +17,7 @@
</template>
<script>
import { getLazyList, remove, update, add, getMenu } from '@/api/system/menu';
import { getLazyList, remove, update, add, getMenu } from '@/api/flow/todolist';
import { mapGetters } from 'vuex';
import iconList from '@/config/iconList';
import func from '@/utils/func';
@@ -29,6 +26,11 @@
export default {
    data() {
        return {
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            form: {},
            query: {},
            loading: true,
@@ -41,24 +43,23 @@
            },
            option: {
                addBtn: false,
                lazy: true,
                columnBtn: false,
                tip: false,
                simplePage: true,
                // simplePage: true,
                searchShow: true,
                searchMenuSpan: 6,
                dialogWidth: '60%',
                tree: true,
                // tree: true,
                border: true,
                index: true,
                selection: true,
                viewBtn: true,
                // selection: true,
                // viewBtn: true,
                menuWidth: 320,
                dialogClickModal: false,
                column: [
                    {
                        label: '创建时间',
                        prop: 'time',
                        width: 300,
                        type: 'datetime',
                        search: true,
                        searchRange: true,
@@ -83,14 +84,15 @@
                            },
                        ],
                    },
                    {
                        label: '编号',
                        prop: 'name',
                        width: 300,
                        width: 100,
                    },
                    {
                        label: '流程类型',
                        width: 100,
                        prop: 'path',
                        rules: [
                            {
@@ -102,41 +104,50 @@
                    },
                    {
                        label: '实例编号',
                        width: 100,
                        type: 'tree',
                    },
                    {
                        label: '流程实例名',
                        width: 100,
                        type: 'tree',
                    },
                    {
                        label: '机床',
                        width: 100,
                        type: 'tree',
                    },
                    {
                        label: '创建人',
                        width: 100,
                        type: 'tree',
                    },
                    {
                        label: '创建时间',
                        width: 100,
                        type: 'tree',
                    },
                    {
                        label: '到达时间',
                        width: 100,
                        type: 'tree',
                    },
                    {
                        label: '到达描述',
                        width: 100,
                        type: 'tree',
                    },
                    {
                        label: '文件',
                        width: 100,
                        type: 'tree',
                    },
                    {
                        label: '到达时间',
                        width: 100,
                        type: 'tree',
                    },
                ],
            },
            data: [],
@@ -165,114 +176,19 @@
                editBtn: this.validData(this.permission.menu_edit, false),
            };
        },
        ids() {
            let ids = [];
            this.selectionList.forEach(ele => {
                ids.push(ele.id);
            });
            return ids.join(',');
        },
    },
    methods: {
        reassign () {// 重新指派
        reassign() {// 重新指派
        },
        initData() {
            getMenuTree().then(res => {
                const column = this.findObject(this.option.column, 'parentId');
                column.dicData = res.data.data;
            });
        },
        handleAdd(row) {
            this.parentId = row.id;
            const column = this.findObject(this.option.column, 'parentId');
            column.value = row.id;
            column.addDisabled = true;
            this.$refs.crud.rowAdd();
        },
        rowSave(row, done, loading) {
            add(row).then(
                res => {
                    // 获取新增数据的相关字段
                    const data = res.data.data;
                    row.id = data.id;
                    this.$message({
                        type: 'success',
                        message: '操作成功!',
                    });
                    // 数据回调进行刷新
                    done(row);
                },
                error => {
                    window.console.log(error);
                    loading();
                }
            );
        },
        rowUpdate(row, index, done, loading) {
            update(row).then(
                () => {
                    this.$message({
                        type: 'success',
                        message: '操作成功!',
                    });
                    // 数据回调进行刷新
                    done(row);
                },
                error => {
                    window.console.log(error);
                    loading();
                }
            );
        },
        rowDel(row, index, done) {
            this.$confirm('确定将选择数据删除?', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            })
                .then(() => {
                    return remove(row.id);
                })
                .then(() => {
                    this.$message({
                        type: 'success',
                        message: '操作成功!',
                    });
                    // 数据回调进行刷新
                    done(row);
                });
        },
        handleDelete() {
            if (this.selectionList.length === 0) {
                this.$message.warning('请选择至少一条数据');
                return;
            }
            this.$confirm('确定将选择数据删除?', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            })
                .then(() => {
                    return remove(this.ids);
                })
                .then(() => {
                    // 刷新表格数据并重载
                    this.data = [];
                    this.parentId = 0;
                    this.$refs.crud.refreshTable();
                    this.$refs.crud.toggleSelection();
                    // 表格数据重载
                    this.onLoad(this.page);
                    this.$message({
                        type: 'success',
                        message: '操作成功!',
                    });
                });
        searchChange(params, done) {
            this.query = params;
            this.page.currentPage = 1;
            this.onLoad(this.page, params);
            done();
        },
        searchReset() {
            this.query = {};
            this.parentId = 0;
            this.onLoad(this.page);
        },
        searchChange(params, done) {
@@ -280,33 +196,6 @@
            this.parentId = '';
            this.page.currentPage = 1;
            this.onLoad(this.page, params);
            done();
        },
        selectionChange(list) {
            this.selectionList = list;
        },
        selectionClear() {
            this.selectionList = [];
            this.$refs.crud.toggleSelection();
        },
        beforeOpen(done, type) {
            if (['add', 'edit'].includes(type)) {
                this.initData();
            }
            if (['edit', 'view'].includes(type)) {
                getMenu(this.form.id).then(res => {
                    this.form = Object.assign(res.data.data, {
                        hasChildren: this.form.hasChildren,
                    });
                });
            }
            done();
        },
        beforeClose(done) {
            this.parentId = '';
            const column = this.findObject(this.option.column, 'parentId');
            column.value = '';
            column.addDisabled = false;
            done();
        },
        currentChange(currentPage) {
@@ -318,19 +207,20 @@
        refreshChange() {
            this.onLoad(this.page, this.query);
        },
        onLoad(page, params = {}) {
            const query = {
                ...this.query,
                category: params.category ? flowCategory(params.category) : null,
                mode: this.mode,
            };
            this.loading = true;
            getLazyList(this.parentId, Object.assign(params, this.query)).then(res => {
                this.data = res.data.data;
            getLazyList(page.currentPage, page.pageSize, Object.assign(params, query)).then(res => {
                const data = res.data.data;
                this.page.total = data.total;
                this.data = data.records;
                this.loading = false;
                this.selectionClear();
            });
        },
        treeLoad(tree, treeNode, resolve) {
            const parentId = tree.id;
            // getLazyList(parentId).then(res => {
            //     resolve(res.data.data);
            // });
        },
    },
};