wankeda
2025-05-26 0864509e1eb593c3dedb66196ec19fe51437922b
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:jxx
//此处是对表单的方法,组件,权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
let extension = {
    components: {//动态扩充组件或组件路径
        //表单header、content、footer对应位置扩充的组件
        gridHeader: '',//{ template: "<div>扩展组xx件</div>" },
        gridBody: '',
        gridFooter: '',
        //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
        modelHeader: '',
        modelBody: '',
        modelFooter: ''
    },
    buttons: { view: [], box: [], detail: [] },//扩展的按钮
    methods: {//事件扩展
        onInit() {
            this.pagination.order = "asc"; 
            
            this.columns.forEach(row => {
                if (row.field == "stationCode") {
                    row.sort = true;
                } else if (row.field == "lastInTime") {
                    row.sort = true;
                }
 
                if (row.field == "getStatus") {
                    row.getColor = (row, column) => {
                        if (row.getStatus == -1) {
                            return "info";
                        } else if (row.getStatus == 0) {
                            return "success";
                        } else if (row.getStatus == 1) {
                            return "waring";
                        }
                    }
                } else if (row.field == "enable") {
                    row.getColor = (row, column) => {
                        if (row.enable == 1) {
                            return "success";
                        } else {
                            return "error";
                        }
                    }
                }
            })
            this.buttons.splice(1, 0, {
                name: "取消禁用",
                icon: 'md-refresh',
                type: 'primary',
                onClick: function () {
                    let rows = this.$refs.table.getSelected();
                    if (rows.length == 0) return this.$error("请选择要取消禁用的数据");
 
                    this.$confirm('确认要取消禁用吗?', '警告', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning',
                        center: true
                    }).then(() => {
                        let data = [];
                        let parm = {
                            "data": data,
                            "type": "1"
                        }
                        rows.forEach(t => data.push(t.id))
                        this.http.post("/api/dt_stationinfo/SetStationEnable", parm, "取消禁用中...").then(x => {
                            if (x.status) {
                                this.$Message.success("取消禁用成功!");
                                this.refresh();
                            } else {
                                this.$Message.error(x.message);
                            }
                        })
                    });
                }
            })
 
            this.buttons.splice(1, 0, {
                name: "禁用",
                icon: 'md-refresh',
                type: 'danger',
                onClick: function () {
                    let rows = this.$refs.table.getSelected();
                    if (rows.length == 0) return this.$error("请选择要禁用的数据");
 
                    this.$confirm('确认要禁用吗?', '警告', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning',
                        center: true
                    }).then(() => {
                        let data = [];
                        let parm = {
                            "data": data,
                            "type": "0"
                        }
                        rows.forEach(t => data.push(t.id))
                        this.http.post("/api/dt_stationinfo/SetStationEnable", parm, "锁定中...").then(x => {
                            if (x.status) {
                                this.$Message.success("禁用成功!");
                                this.refresh();
                            } else {
                                this.$Message.error(x.message);
                            }
                        })
                    });
                }
            })
        }
    }
};
export default extension;