1
lzhe
2024-06-05 dcf9c9e0410fe1186239e3f8d6f7bdc789c08010
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!--
 * @Author: lzhe lzhe@example.com
 * @Date: 2024-05-24 11:25:26
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-05-27 14:11:14
 * @FilePath: /src/views/console/product-process/process-route/addWorking.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <el-dialog :title="titleMap[mode]" v-model="visible" :width="700" destroy-on-close @closed="$emit('closed')">
        <div class="add-btn">
            <el-button type="primary" @click="addWorking">新建工艺</el-button>
        </div>
        <el-table ref="multipleTableRef" :data="tableData" border style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" />
            <el-table-column prop="code" label="工序编号"></el-table-column>
            <el-table-column prop="name" label="工序名称"></el-table-column>
            <el-table-column prop="typeName" label="工种"></el-table-column>
            <el-table-column prop="description" label="工序描述"></el-table-column>
        </el-table>
        <el-pagination
            style="margin-top: 12px;"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :page-sizes="[15, 50, 100]"
            :page-size="15"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totle">
        </el-pagination>
        <template #footer>
            <el-button @click="visible=false" >取消</el-button>
            <el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="workingSubmit">确定</el-button>
        </template>
    </el-dialog>
</template>
 
<script>
    export default {
        emits: ['success', 'closed'],
        data() {
            return {
                current: 1,
                size: 15,
                totle: 0,
                tableData: [],
                selection: [],
                mode: "add",
                titleMap: {
                    add: '选择工序',
                    edit: '编辑',
                    show: '查看'
                },
                visible: false,
                isSaveing: false,
            }
        },
        mounted() {
        },
        methods: {
            addWorking() {
                this.$router.push({path: `/console/basic-data/work-process`});
            },
            handleSelectionChange(selection) {
                this.selection = selection;
            },
            getTable() {
                this.$HTTP.get(`/api/blade-cps/process/page?current=${this.current}&size=${this.size}&keyword=`).then(res=> {
                    if(res.code == 200) {
                        this.tableData = res.data.records;
                        this.totle = res.data.total;
                    }
                })
            },
            //显示
            open(mode='add'){
                this.getTable();
                this.mode = mode;
                this.visible = true;
                return this
            },
            //表单提交方法
            workingSubmit(){
                this.$emit('success', this.selection, this.mode);
                this.visible = false;
                this.$message.success("操作成功");
                this.selection = [];
            },
            //表单注入数据
            setData(data,res){
                //可以和上面一样单个注入,也可以像下面一样直接合并进去
                this.productList = res;
                Object.assign(this.addWorkingForm, data);
            },
            handleSizeChange(val) {
                this.size = val;
                console.log(`每页 ${val} 条`);
                this.getTable();
            },
            handleCurrentChange(val) {
                this.current = val;
                console.log(`当前页: ${val}`);
                this.getTable();
            }
        }
    }
</script>
 
<style scoped>
.add-btn {
    margin-bottom: 12px;
}
</style>