cuiqian2004
2025-07-10 2db331628bbf94deee446d6e172e98f4db474a33
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
var dateUtils = {
    UNITS: {
        '年': 31557600000,
        '月': 2629800000,
        '天': 86400000,
        '小时': 3600000,
        '分钟': 60000,
        '秒': 1000
    },
    humanize: function(milliseconds) {
        var humanize = '';
        mui.each(this.UNITS, function(unit, value) {
            if (milliseconds >= value) {
                humanize = Math.floor(milliseconds / value) + unit + '前';
                return false;
            }
            return true;
        });
        return humanize; // || '刚刚';
    },
    format: function(dateStr, notime) {
        var date = this.parse(dateStr)
        return this.openinfo_formatter_ttime(dateStr, 'notime');
        /* var diff = Date.now() - date.getTime();
        if (diff < this.UNITS['天']) {
            return this.humanize(diff);
        } else
            return this.openinfo_formatter_ttime(dateStr, notime)
        var _format = function (number) {
            return (number < 10 ? ('0' + number) : number);
        };
        return date.getFullYear() + '/' + _format(date.getMonth() + 1) + '/' + _format(date.getDate()) + '-' + _format(
            date.getHours()) + ':' + _format(date.getMinutes()); */
    },
    parse: function(str) { //将"yyyy-mm-dd HH:MM:ss"格式的字符串,转化为一个Date对象
        var a = str.split(/[^0-9]/);
        if (a.length == 1)
            return new Date(a[0], 1, 1, 0, 0, 1);
        else if (a.length == 2)
            return new Date(a[0], a[1] - 1, 1, 0, 0, 1);
        else if (a.length == 3)
            return new Date(a[0], a[1] - 1, a[2], 0, 0, 1);
        else if (a.length == 4)
            return new Date(a[0], a[1] - 1, a[2], a[3], 0, 1);
        else if (a.length == 5)
            return new Date(a[0], a[1] - 1, a[2], a[3], a[4], 1);
        else if (a.length >= 6)
            return new Date(a[0], a[1] - 1, a[2], a[3], a[4], a[5]);
        else
            return new Date();
    },
    openinfo_formatter_ttime: function(cellvalue, nowhat) {
        var cv_o = cellvalue.split(' ')[0];
        var cv_t = cellvalue.split(' ')[1];
        if (nowhat) {
            cv_t = "";
        }
        var date = new Date();
        var time = cv_o;
        var h_m = "";
        if (cv_t)
            h_m = cv_t.split(':')[0] + ':' + cv_t.split(':')[1];
        if (cv_o.split('-').length == 3)
            if (date.getFullYear() == cv_o.split('-')[0]) {
                time = " " + cv_o.split('-')[1] + '-' + cv_o.split('-')[2];
                if (date.getMonth() + 1 == cv_o.split('-')[1]) {
                    if (date.getDate() == cv_o.split('-')[2])
                        time = "今天";
                    if (date.getDate() - 1 == cv_o.split('-')[2])
                        time = '昨天';
                    if (date.getDate() - 2 == cv_o.split('-')[2])
                        time = '前天';
                }
            } else {
                time = cv_o.split('-')[1] + '-' + cv_o.split('-')[2];
                if (date.getFullYear() - 1 == cv_o.split('-')[0]) {
                    //time = time + " 去年";
                }
                if (date.getFullYear() - 2 == cv_o.split('-')[0]) {
                    //time = time + " 前年";
                }
                time = cv_o.split('-')[0] + '-' + time;
            }
        return time + (h_m ? (" " + h_m) : "");
    },
    getDate: function(type) {
        const date = new Date();
 
        let year = date.getFullYear();
        let month = date.getMonth() + 1;
        let day = date.getDate();
 
        if (type === 'start') {
            year = year - 10;
        } else if (type === 'end') {
            year = year + 10;
        }
        month = month > 9 ? month : '0' + month;;
        day = day > 9 ? day : '0' + day;
 
        return `${year}-${month}-${day}`;
    },
    getShortDate: function(dateStr) {
        var date = new Date()
        if (dateStr) {
            dateStr = dateStr.trim()
 
            if (dateStr != "")
                date = this.parse(dateStr)
        }
        //console.log("getShortDate2",dateStr,date)
        let year = date.getFullYear();
        let month = date.getMonth() + 1;
        return `${year}年${month}月`;
    },
    toDateTimeString: function(date) {
        let year = date.getFullYear();
        let month = date.getMonth() + 1;
        let day = date.getDate();
        let hour = date.getHours();
        let minute = date.getMinutes();
        let second = date.getSeconds();
        month = month > 9 ? month : '0' + month;;
        day = day > 9 ? day : '0' + day;
        hour = hour > 9 ? hour : '0' + hour;
        minute = minute > 9 ? minute : '0' + minute;
        second = second > 9 ? second : '0' + second;
        return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
    },
    toDateString: function(date) {
        let year = date.getFullYear();
        let month = date.getMonth() + 1;
        let day = date.getDate();
        month = month > 9 ? month : '0' + month;;
        day = day > 9 ? day : '0' + day;
        return `${year}-${month}-${day}`;
    },
    toTimeString: function(date) {
        let hour = date.getHours();
        let minute = date.getMinutes();
        let second = date.getSeconds();
        hour = hour > 9 ? hour : '0' + hour;
        minute = minute > 9 ? minute : '0' + minute;
        second = second > 9 ? second : '0' + second;
        return `${hour}:${minute}:${second}`;
    },
    toShortTimeString: function(date) {
        let hour = date.getHours();
        let minute = date.getMinutes();
        hour = hour > 9 ? hour : '0' + hour;
        minute = minute > 9 ? minute : '0' + minute;
        return `${hour}:${minute}`;
    },
    
    toShortDateTimeString: function(date) {
        let month = date.getMonth() + 1;
        let day = date.getDate();
        month = month > 9 ? month : '0' + month;;
        day = day > 9 ? day : '0' + day;
        let hour = date.getHours();
        let minute = date.getMinutes();
        hour = hour > 9 ? hour : '0' + hour;
        minute = minute > 9 ? minute : '0' + minute;
        return `${month}-${day} ${hour}:${minute}`;
    },
    
}
var fileUtils = {
    isPictureType: function(fileName) {
        if (".tiff.pjp.jfif.bmp.gif.svg.png.xbm.dib.jxl.jpeg.svgz.jpg.webp.ico.tif.pjpeg.avif.image".indexOf(
                fileName
                .split('.').pop().toLowerCase()) < 0) //图片
        {
            return false
        }
        return true
    },
    isDocumentType: function(fileName) {
        //#ifdef MP-WEIXIN
        if (".doc.xls.ppt.pdf.docx.xlsx.pptx".indexOf(fileName.split('.').pop().toLowerCase()) < 0) //文档
        {
            return false
        }
        return true
        //#endif
        //#ifdef MP-DINGTALK
        if (".pdf".indexOf(fileName.split('.').pop().toLowerCase()) < 0) //文档
        {
            return false
        }
        return true
        //#endif
        return false
 
    },
    isVideoType: function(fileName) {
        if (".mp4.webm.ogg.video".indexOf(fileName.split('.').pop().toLowerCase()) < 0) //视频
        {
            return false
        }
        return true
    },
    isAudioType: function(fileName) {
        if (".mp3.audio".indexOf(fileName.split('.').pop().toLowerCase()) < 0) //视频
        {
            return false
        }
        return true
    },
    isCanPreviewType: function(fileName) {
        if (this.isDocumentType(fileName) || this.isPictureType(fileName) || this.isVideoType(fileName) || this
            .isAudioType(fileName)) //视频
        {
            return true
        }
        return false
    },
    getTypeBgColor: function(fileName) {
        let color = '#ccc'
        if (this.isPictureType(fileName)) {
            color = '#e5e5e5'
        } else if (this.isVideoType(fileName)) {
            color = '#456476'
        } else if (this.isAudioType(fileName)) {
            color = '#f0f0f0'
        } else if (".doc.docx".indexOf(fileName.split('.').pop().toLowerCase()) > -1) //文档
        {
            color = '#059fff'
        } else if (".xls.xlsx".indexOf(fileName.split('.').pop().toLowerCase()) > -1) //文档
        {
            color = '#16b251'
        } else if (".ppt.pptx".indexOf(fileName.split('.').pop().toLowerCase()) > -1) //文档
        {
            color = '#f9661d'
        } else if (".pdf".indexOf(fileName.split('.').pop().toLowerCase()) > -1) //文档
        {
            color = '#fa493d'
        }
        return color
    },
    getFileSizeStr(size) {
        let sizeStr
        if (size > 1024 * 1024)
            sizeStr = Math.round(size / (1024 * 1024)) + ' MB'
        else if (size > 1024)
            sizeStr = Math.round(size / (1024)) + ' KB'
        else
            sizeStr = (size) + ' B'
        return sizeStr
    },
 
    
}
 
var taskstate = {
    '未读': 'fs-mail_close',
    '已读': 'fs-mail_open',
    '执行': 'fs-run_man',
    '退回': 'fs-goback',
    '完成': 'fs-flag',
    '提交': 'fs-TaskSubmission',
    '搁置': 'fs-pause',
    '出错': 'fs-wrong',
    '终止': 'fs-Due',
    '归档': 'fs-project_doc',
    '计划': 'fs-project_manage',
    '等待': 'fs-wait',
    '编辑': 'fs-PRJ_edit',
    '审核': 'fs-Audit',
    '删除': 'fs-delete_solid_circle',
    '撤回': 'fs-return_key'
};
var eventstate = {
    '问题': 'fs-question2',
    '错误': 'fs-bug',
    '需求': 'fs-CirclPlus',
    '建议': 'fs-suggest',
    '讨论': 'fs-discuss',
}
export default {
    dateUtils,
    fileUtils,
    taskstate,
    eventstate
}