自动化立体仓库 - WMS系统
whycq
2024-11-25 bcb19e8c93c3cabf0d8eb3ee34ed819b3c5a10ef
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<div class="layui-card-header">本地便签</div>
<div class="note-wrapper"></div>
<div class="note-empty">
    <i class="layui-icon layui-icon-face-surprised"></i>
    <p>没有便签</p>
</div>
<div class="btn-circle" id="noteAddBtn" title="添加便签" style="position: absolute;">
    <i class="layui-icon layui-icon-add-1"></i>
</div>
 
<script>
    layui.use(['layer', 'form', 'util', 'admin'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var util = layui.util;
        var admin = layui.admin;
        var dataList = [];  // 便签列表
        var $noteWrapper = $('.note-wrapper');
 
        /* 渲染列表 */
        function renderList() {
            $noteWrapper.empty();
            dataList = layui.data(admin.setter.tableName).notes;
            if (dataList === undefined) dataList = [];
            for (var i = 0; i < dataList.length; i++) {
                var item = dataList[i];
                $noteWrapper.prepend([
                    '<div class="note-item" data-id="', item.id, '">',
                    '   <div class="note-item-content">', util.escape(item.content), '</div>',
                    '   <div class="note-item-time">', item.time, '</div>',
                    '   <i class="layui-icon layui-icon-close-fill note-item-del"></i>',
                    '</div>'
                ].join(''));
            }
            $('.note-empty').css('display', dataList.length === 0 ? 'block' : 'none');
            // 点击修改
            $('.note-item').click(function () {
                var index = parseInt($(this).attr('data-id'));
                showNote(dataList[index]);
            });
            // 点击删除
            $('.note-item-del').click(function (e) {
                var id = parseInt($(this).parent().attr('data-id'));
                layer.confirm('确认删除吗?', {
                    skin: 'layui-layer-admin',
                    shade: .1,
                    shadeClose: true
                }, function (index) {
                    layer.close(index);
                    dataList.splice(id, 1);
                    for (var i = 0; i < dataList.length; i++) dataList[i].id = i;
                    putDataList();
                    renderList();
                });
                e.stopPropagation();
            });
        }
 
        renderList();
 
        /* 添加 */
        $('#noteAddBtn').click(function () {
            showNote();
        });
 
        // 显示编辑弹窗
        function showNote(data) {
            var id = data ? data.id : undefined, content = data ? data.content : '';
            admin.open({
                id: 'layer-note-edit',
                title: '便签',
                type: 1,
                area: 'auto',
                offset: '50px',
                shadeClose: true,
                content: '<textarea id="noteEditText" placeholder="请输入内容" style="width: 280px;height: 150px;border: none;color: #666666;word-wrap: break-word;padding: 10px 20px;resize: vertical;">' + content + '</textarea>',
                success: function () {
                    $('#noteEditText').change(function () {
                        content = $(this).val();
                    });
                },
                end: function () {
                    if (id !== undefined) {
                        if (!content) {
                            dataList.splice(id, 1);
                            for (var i = 0; i < dataList.length; i++) dataList[i].id = i;
                        } else if (content !== dataList[id].content) {
                            dataList[id].content = content;
                            dataList[id].time = util.toDateString(new Date(), 'yyyy-MM-dd HH:mm');
                        }
                    } else if (content) {
                        dataList.push({
                            id: dataList.length, content: content,
                            time: util.toDateString(new Date(), 'yyyy-MM-dd HH:mm')
                        });
                    }
                    putDataList();
                    renderList();
                }
            });
        }
 
        /* 更新本地缓存 */
        function putDataList() {
            layui.data(admin.setter.tableName, {key: 'notes', value: dataList});
        }
 
    });
</script>
 
<style>
    .note-wrapper {
        padding: 15px 0 15px 15px;
        background-color: #fbfbfb;
        position: absolute;
        top: 43px;
        left: 0;
        right: 0;
        bottom: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
 
    .note-wrapper .note-item {
        display: inline-block;
        width: 110px;
        padding: 12px;
        cursor: pointer;
        position: relative;
        border-radius: 8px;
        margin: 0 15px 15px 0;
        border: 1px solid #eeeeee;
        background-color: #ffffff;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        -webkit-transition: all .3s ease;
        -moz-transition: all .3s ease;
        -ms-transition: all .3s ease;
        -o-transition: all .3s ease;
        transition: all .3s ease;
    }
 
    .note-wrapper .note-item:hover {
        box-shadow: 0 0 8px rgba(0, 0, 0, .05);
        -webkit-transform: scale(1.02);
        -moz-transform: scale(1.02);
        -ms-transform: scale(1.02);
        -o-transform: scale(1.02);
        transform: scale(1.02);
    }
 
    .note-wrapper .note-item .note-item-content {
        color: #666;
        height: 80px;
        font-size: 14px;
        overflow: hidden;
        word-break: break-all;
    }
 
    .note-wrapper .note-item .note-item-time {
        color: #999;
        font-size: 12px;
        margin-top: 8px;
    }
 
    .note-wrapper .note-item .note-item-del {
        position: absolute;
        top: 2px;
        right: 2px;
        color: #FF5722;
        font-size: 24px;
        height: 24px;
        width: 24px;
        background-color: #fff;
        border-radius: 50%;
        visibility: hidden;
        -webkit-transition: all .3s ease;
        -moz-transition: all .3s ease;
        -ms-transition: all .3s ease;
        -o-transition: all .3s ease;
        transition: all .3s ease;
        opacity: 0;
    }
 
    .note-wrapper .note-item:hover .note-item-del {
        visibility: visible;
        opacity: 1;
    }
 
    .note-empty {
        color: #999;
        padding: 80px 0;
        text-align: center;
        display: none;
        position: relative;
        z-index: 1
    }
 
    .note-empty .layui-icon {
        font-size: 60px;
        margin-bottom: 10px;
        display: inline-block;
    }
</style>