Admin
2025-12-02 9e42f0dafa019f5ecf6b0ff425ecb966b002171e
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//此处是对表单的方法,组件,权限操作按钮等进行任意扩展(方法扩展可参照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.columns.push({ field: "操作", title: "操作", align: "center", width: 120, render: this.getRender() })
            this.buttons.splice(2, 0, {
                name: "锁定",
                icon: 'md-lock',
                hidden: false,
                type: 'success',
                onClick: function () {
                    let rows = this.$refs.table.getSelected();
                    if (rows.length == 0) return this.$Message.error("请选择要锁定的行!");
                    let delKeys = rows.map(x => {
                        return x[this.table.key];
                    });
                    if (!delKeys || delKeys.length == 0)
                        return this.$Message.error("没有获取要锁定的行数据!");
                    // console.log(delKeys);
                    // console.log(rows);
                    let tigger = false;
                    this.$confirm("确认要锁定选择的货位吗?", "锁定警告!", {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        type: "warning",
                        center: true,
                    }).then(() => {
                        let params = {
                            MainData: null,
                            DetailData: null,
                            DelKeys: delKeys,
                            Extra: true
                        }
                        this.http.post("/api/dt_locationinfo/DoLocationLockOperate", params, "正在锁定数据....").then(x => {
                            if (!x.status) return this.$Message.error(x.message);
                            this.$Message.success("锁定成功!");
 
                            this.refresh();
                        });
                    });
                }
            });
            this.buttons.splice(3, 0, {
                name: "取消锁定",
                icon: 'md-unlock',
                hidden: false,
                type: 'warning',
                onClick: function () {
                    let rows = this.$refs.table.getSelected();
                    if (rows.length == 0) return this.$error("请选择要取消锁定的行!");
                    let delKeys = rows.map(x => {
                        return x[this.table.key];
                    });
                    if (!delKeys || delKeys.length == 0)
                        return this.$error("没有获取要取消锁定的行数据!");
                    // console.log(delKeys);
                    // console.log(rows);
                    let tigger = false;
                    this.$confirm("确认要取消锁定选择的货位吗?", "取消锁定警告!", {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        type: "warning",
                        center: true,
                    }).then(() => {
                        let params = {
                            MainData: null,
                            DetailData: null,
                            DelKeys: delKeys,
                            Extra: false
                        }
                        this.http.post("/api/dt_locationinfo/DoLocationLockOperate", params, "正在取消锁定数据....").then(x => {
                            if (!x.status) return this.$Message.error(x.message);
                            this.$Message.success("取消锁定成功!");
 
                            this.refresh();
                        });
                    });
                }
            });
        },
        getRender() {//生成最后一列操作列
            return (h, { row, column, index }) => {
                return h("div", { style: { color: '#0c83ff', 'font-size': '13px', cursor: 'pointer' } }, [
                    h(
                        "a",
                        {
                            props: {},
                            style: { "margin-left": "9px", "border-bottom": "1px solid" },
                            onClick: (e) => {
                                e.stopPropagation();
                                this.$refs.table.$refs.table.clearSelection();
                                //设置当前后选中
                                this.$refs.table.$refs.table.toggleRowSelection(row);
                                let title = row["location_islocked"] == '0' ? '锁定' : '解锁';
                                this.$confirm("确认要" + title + "选择的数据吗?", "警告", {
                                    confirmButtonText: "确定",
                                    cancelButtonText: "取消",
                                    type: "warning",
                                    center: true,
                                }).then(() => {
                                    let param = {
                                        MainData: row,
                                        DetailData: null,
                                        DelKeys: null
                                    };
                                    this.http.post("/api/Dt_locationinfo/UpdateState", row, '状态修改中...').then(data => {
                                        if (data.status) {
                                            this.$Message.success((row["location_islocked"] == '0' ? '锁定' : '解锁') + '成功!');
                                            this.refresh();
                                        } else {
                                            this.$Message.error((row["location_islocked"] == '0' ? '锁定' : '解锁') + '成功!');
                                        }
                                    });
                                });
                            }
                        },
                        "锁定/解锁"
                    )
                ]);
            };
        },
    }
};
export default extension;