首页 > 其他分享 >zip.js

zip.js

时间:2023-08-24 11:24:51浏览次数:42  
标签:function vendor attr zip value js item id

function getUrlVar(variable)
{
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
        if(pair[0] == variable){return urldecode(pair[1])}
    }
    return(false);
}
function urldecode(encodedString)
{
    var output = encodedString;
    var binVal, thisString;
    var myregexp = /(%[^%]{2})/;
    function utf8to16(str)
    {
        var out, i, len, c;
        var out, i, len, c;
        var char2, char3;

        out = "";
        len = str.length;
        i = 0;
        while(i < len)
        {
            c = str.charCodeAt(i++);
            switch(c >> 4)
            {
                case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
                out += str.charAt(i-1);
                break;
                case 12: case 13:
                char2 = str.charCodeAt(i++);
                out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
                break;
                case 14:
                    char2 = str.charCodeAt(i++);
                    char3 = str.charCodeAt(i++);
                    out += String.fromCharCode(((c & 0x0F) << 12) |
                        ((char2 & 0x3F) << 6) |
                        ((char3 & 0x3F) << 0));
                    break;
            }
        }
        return out;
    }
    while((match = myregexp.exec(output)) != null
    && match.length > 1
    && match[1] != '')
    {
        binVal = parseInt(match[1].substr(1),16);
        thisString = String.fromCharCode(binVal);
        output = output.replace(match[1], thisString);
    }

    //output = utf8to16(output);
    output = output.replace(/\\+/g, " ");
    output = utf8to16(output);
    return output;
}

var url_id = getUrlVar('id');
var url_no = getUrlVar('no');
var url_type = getUrlVar('type');
var url_vendor_id = getUrlVar('vendor_id');
var url_vendor_txt = getUrlVar('vendor_txt');
var url_category_flow_id = getUrlVar('category_flow_id');
var url_category_flow_txt = getUrlVar('category_flow_txt');
var url_flow_type = getUrlVar('flow_type');

$.fn.serializeObject = function()
{
    var o = {};
    var a = this.serializeArray();
    $.each(a, function() {
        if (o[this.name] !== undefined) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
};

var ajax = function (url, data) {
    return new Promise(function (resolve, reject) {
        $.post(url, data, function (res) {
            if(res.status == 1) {
                resolve(res);
            } else if (res.status == -1) {
                window.location.href = '/CheckList/Public/login?redirect=' + window.location.href;
            } else {
                reject(res);
            }
        }, 'json');
    });
};

Array.prototype.removeByValue = function(val) {
    for(var i = 0; i < this.length; i++) {
        if(this[i] == val) {
            this.splice(i, 1);
            break;
        }
    }
}

var mytab = function (config) {
    this.cfg = {
        id: '',
        current_index: 0,
        data: [
            /*{
                id : 0,
                text : 'Search',
                url_filter : pim_api.URL_FILTER,
                url_content : pim_api.URL_ITEM_LIST
            }*/
        ],
        max_len: 100,
        after_click: function () {}
    };
    this.cfg = $.extend(this.cfg, config);

    if(typeof this.cfg != 'object' || typeof this.cfg.id == 'undefined') {
        console.log('TAB ID NULL error');
        return false;
    }

    this.init = function (index) {
        this._event();
        this.trigger(index);
    },

        this._event = function () {
            var that = this;
            /* $(that.cfg.id).on('click', 'li', function () {
                 console.log(1);
                 $(this).siblings().removeClass('active');
                 $(this).addClass('active');

                 that.cfg.current_index = $(this).index();

                 if(typeof that.cfg.after_click == 'function') {
                     that.cfg.after_click.call(this, that.cfg);
                 }
             });*/
        },

        //append to last
        this.add = function (obj) {
            let index = -1;
            $.each(this.cfg.data, function (k, v) {
                if(v.id == obj.id) {
                    index = k;
                }
            });
            if(index >= 0) {
                this.trigger(index);
                return;
            }

            this.cfg.data.splice(this.cfg.max_len, 0, obj);
            //if(this.cfg.data.length > this.cfg.max_len) {
            //    this.cfg.data.splice(this.cfg.max_len, 1);
            //}
            this.trigger(this.cfg.data.length-1);
            return this;
        },

        //insert before first
        this.add_old = function (obj) {
            let index = -1;
            $.each(this.cfg.data, function (k, v) {
                if(v.id == obj.id) {
                    index = k;
                }
            });
            if(index >= 0) {
                this.trigger(index);
                return;
            }

            this.cfg.data.splice(1, 0, obj);
            if(this.cfg.data.length > this.cfg.max_len) {
                this.cfg.data.splice(this.cfg.max_len, 1);
            }
            this.trigger(1);
            return this;
        },

        this.remove_all = function () {
            this.cfg.data.splice(1);

            this.set_current_index(0);
            this.trigger(0);
        },

        this.remove_all_right = function () {
            if((this.current_index()+1) <= this.get_length()) {
                this.cfg.data.splice(this.current_index()+1);
            }
        },

        this.remove = function (index) {
            if(this.cfg.data.length < index) {
                return;
            }

            this.cfg.data.splice(index, 1);

            //this.set_current_index(0);
            //this.trigger(0);
        },

        this.get_length = function () {
            return this.cfg.data.length;
        },

        this.current_index = function () {
            return this.cfg.current_index;
        },

        this.set_current_index = function (index) {
            this.cfg.current_index = index;
        },

        this.get_current = function () {
            return this.cfg.data[this.current_index()];
        },

        this.trigger = function (index) {
            let that = this;
            setTimeout(function () {
                $(that.cfg.id).find('.tab_el:eq('+index+')').click();
            }, 40);
        },

        this.set = function (index, obj) {
            $.extend(this.cfg.data[index], obj);
        },

        this.remove_diff_type = function (type) {
            let that = this;
            $.each(that.cfg.data, function (k, v) {
                if(v.type != 'system' && v.type != type) {
                    that.cfg.data.splice(k, 1);
                }
            });
        }
};
Vue.component('com_menu_comment', {
    props: ['myclass', 'menudata', 'autolist', 'item_completion_list','comment_list','p_category_flow_id'],
    template: '#com_menu_comment',
    methods: {
        comment_read: function () {
            this.$emit('comment_read');
        }
    }
});

Vue.component('com_menu', {
    props: ['myclass', 'menudata', 'autolist', 'item_completion_list', 'is_mobile'],
    template: '#com_menu',
    methods: {
        load_item_flow: function () {
            this.$emit('load_item_flow');
        }
    }
});
Vue.component('com_menu_item', {
    props: ['deep_index', 'child_count', 'category_flow_id'],
    template: '#com_menu_item'
});
Vue.component('com_upload', {
    props: ['upload_cfg', 'attr', 'attr_val', 'item_vendor_id', 'is_set', 'flag_flow_detail_op_style', 'is_mobile', 'myclass'],
    template: '#com_upload',
    data: function () {
        return {
            per_length: 0,                      //姣忎釜鏂囦欢鍗犵敤鐨勮繘搴︽潯闀垮害
            show_progress: false,
            show_loading: false,

            progress: '1%',
            progress_text: '0%',

            result_msg: '',
            bytesPerPiece : 1024 * 1024 * 50,   //鍒嗘涓婁紶澶у皬涓�50M
            totalPieces: 0,                     //鍒嗘鐗囨暟
            pieceProgress: 0,                   //澶ф枃浠朵笂浼犺繘搴﹁繘搴�

        }
    },
    beforeUpdate: function () {
        let that = this;
    },
    updated: function () {
        let that = this;
        that.$nextTick(function () {
            if(that.is_set ==0) {
                new Swiper('#swiper' + that.item_vendor_id + '_' + that.attr.category_flow_id + '_' + that.attr.id + ' .swiper-img', {
                    slidesPerView: 'auto',
                    spaceBetween: 30,

                    navigation: {
                        nextEl: '.tab-next',
                        prevEl: '.tab-prev',
                    },
                });
            }
        });
    },
    created: function () {
        let that = this;
        $('.photo-area').owlCarousel({
            items: 1,
            loop: false,
            center: true,
            margin: 20,
            nav: true
        });
        that.$nextTick(function () {
            if(that.is_set == 0) {
                new Swiper('#swiper' + that.item_vendor_id + '_' + that.attr.category_flow_id + '_' + that.attr.id + ' .swiper-img', {
                    slidesPerView: 'auto',
                    spaceBetween: 30,

                    navigation: {
                        nextEl: '.tab-next',
                        prevEl: '.tab-prev',
                    },
                });
            }
        });
    },
    methods: {
        on_file_change: function (cfg, attr, item_vendor_id, event) {
            let that = this;
            let obj = event.target;
            let pk = $(obj).closest('.browse-area').data('pk');
            let files = obj.files;
            if(files && FormData && XMLHttpRequest) {
                that.show_progress = true;
                that.ajaxUploadFile(files, 0, cfg, pk, attr, item_vendor_id);
            }
        },
        ajaxUploadLarge: function (files, fKey, cfg, pk, attr, item_vendor_id) {
            let that = this;
            let blob = files[fKey];
            var start = 0;
            var end;
            var index = 0;
            var filesize = blob.size;
            var filename = blob.name;
            that.pieceProgress = 0;
            that.md5File(blob, that.bytesPerPiece).then(function (md5) {
                //璁$畻鏂囦欢鍒囩墖鎬绘暟
                that.totalPieces = Math.ceil(filesize / that.bytesPerPiece);
                let parr = []
                let last = null
                while(start < filesize) {
                    end = start + that.bytesPerPiece;
                    if(end > filesize) {
                        end = filesize;
                    }
                    var chunk = blob.slice(start,end);//鍒囧壊鏂囦欢
                    let formData = new FormData();

                    formData.append(cfg.key, chunk, filename);
                    formData.append("chunk", index);
                    formData.append("chunks", that.totalPieces);
                    formData.append("md5", md5);
                    if (attr.metadata.dir != undefined) {
                        formData.append('dir', attr.metadata.dir);
                    }
                    if (end == filesize) {
                        formData.append("size", filesize);
                        last = formData;
                    } else {
                        parr.push(that.pro(formData, cfg, fKey))
                    }
                    start = end;
                    index++;
                }
                Promise.all(parr).then(res => {
                    if (res.length == parr.length) {
                        //璇锋眰鏈€鍚庝竴涓枃浠�
                        that.pro(last, cfg, fKey).then(function (res) {
                            //瀹屾垚涓婁紶
                            that.getContent(res, cfg, pk, attr, item_vendor_id);
                            that.ajaxUploadFile(files, fKey+1, cfg, pk, attr, item_vendor_id);
                        })
                    }
                })
            })
        },
        md5File: function(file, chunkSize) {
            let that = this;
            return new Promise((resolve, reject) => {
                let blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice;
                let chunks = Math.ceil(file.size / chunkSize);
                let currentChunk = 0;
                let spark = new SparkMD5.ArrayBuffer();
                let fileReader = new FileReader();

                fileReader.onload = function(e) {
                    spark.append(e.target.result);
                    currentChunk++;
                    if (currentChunk < chunks) {
                        loadNext();
                    } else {
                        let md5 = spark.end();
                        resolve(md5);
                    }
                };

                fileReader.onerror = function(e) {
                    reject(e);
                };

                function loadNext() {
                    let start = currentChunk * chunkSize;
                    let end = start + chunkSize;
                    if (end > file.size){
                        end = file.size;
                    }
                    fileReader.readAsArrayBuffer(blobSlice.call(file, start, end));
                }
                loadNext();
            });
        },
        pro: function(formData, cfg, fKey) {
            let that = this;
            let gateway = cfg.gateway;
            return new Promise((resolve, reject) => {
                $.ajax({
                    type: 'post',
                    url: gateway,
                    cache: false,
                    data: formData,
                    processData: false,
                    contentType: false,
                    success: function(res) {
                        that.setPrecent(++that.pieceProgress, fKey)
                        resolve(res)
                    },
                    fail: function() {
                        reject()
                    }
                })
            })
        },
        setPrecent: function(progress, fKey) {
            let that = this;
            var percentComplete = Math.round(that.per_length*fKey + (progress / that.totalPieces) * that.per_length );
            var width = percentComplete.toString() + '%';
            that.progress = width;
            that.progress_text = width;
            if(percentComplete == 100) {
                that.show_loading = true;
                that.show_progress = false;
            }
        },
        ajaxUploadFile: function (files, fKey, cfg, pk, attr, item_vendor_id) {
            let gateway = cfg.gateway;
            let that = this;
            if(!files[fKey]) {
                that.show_progress = false;
                that.progress = '1%';
                that.progress_text = '0%';
                return;
            }
            that.result_msg = '';
            that.per_length = 100/files.length;
            if (files[fKey].size >= 1024 * 1024 * 1024) {
                //瓒呰繃1G鍒嗙墖涓婁紶
                that.ajaxUploadLarge(files, fKey, cfg, pk, attr, item_vendor_id)
            } else {
                var fd = new FormData();
                fd.append(cfg.key, files[fKey]);
                if (attr.metadata.dir != undefined) {
                    fd.append('dir', attr.metadata.dir);
                }
                /*for(var k in cfg.postData) {
                    fd.append(k, cfg.postData[k]);
                }*/
                var xhr = new XMLHttpRequest();
                try {
                    xhr.upload.addEventListener('progress', function (evt) {
                        if(evt.lengthComputable) {
                            var percentComplete = Math.round(that.per_length*fKey+evt.loaded * that.per_length / evt.total);
                            var width = percentComplete.toString() + '%';
                            that.progress = width;
                            that.progress_text = width;
                            if(percentComplete == 100) {
                                that.show_loading = true;
                                that.show_progress = false;
                            }
                        } else {
                            //loading.show();
                            //progress_show.hide();
                        }
                    }, false);
                    xhr.addEventListener('load', function(evt) {
                        if(typeof result == 'object' && result[0]) {
                            that.result_msg = '';
                        }
                        that.getContent(evt.target.responseText, cfg, pk, attr, item_vendor_id);
                        that.ajaxUploadFile(files, fKey+1, cfg, pk, attr, item_vendor_id);
                    }, false);
                    xhr.addEventListener("error", function(evt) {
                        that.result_msg = 'There was an error attempting to upload the file.';
                    }, false);
                    xhr.addEventListener("abort", function(evt) {
                        that.result_msg = 'The upload has been canceled by the user or the browser dropped the connection.';
                    }, false);
                    xhr.open("POST", gateway);
                    xhr.send(fd);
                } catch (e) {
                    console.log('Upload Exception');
                }
            }
        },
        getContent: function (responseText, cfg, pk, attr, item_vendor_id) {
            let that = this;
            if(responseText) {
                that.show_loading = false;
                try {
                    eval('var data=('+responseText+');');
                    if(data.status == 1) {
                        that.$emit('add_new_file', pk, data.data[0], attr, item_vendor_id);
                    }
                } catch(e) {
                    that.result_msg = 'Upload Error';
                }
            }
        },
        delete_a_file: function (pk, index, attr, item_vendor_id) {
            if(!window.confirm('Are you sure to delete?')) {
                return false;
            }
            let obj = event.target;
            this.$emit('delete_a_file', pk, index, attr, item_vendor_id);
        },
        rotate_img: function (path) {
            this.$emit('rotate_img', path);
        },
        gallery: function (attr_val, index) {
            this.$emit('gallery', attr_val, index);
            /*let that = this;
            let e = $(event.target).closest('a');
            e = e[0] ? e : $(event.target).closest('div');
            let qstr = '';
            qstr += 'file_location='+e.data('file_location')+'&attr_id='+e.data('attr_id')+'&category_flow_id='+e.data('category_flow_id');

            let current = app.item_tab_obj.get_current();

            qstr += '&vendor_id='+app.vendor_selected;
            qstr += '&subject='+JSON.stringify(current);

            window.open(pim_config.host+'/Pim/Index/gallery?'+qstr);

            return false;*/
        }
    }
});
Vue.component('com_field', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'upload_cfg', 'is_set', 'flag_flow_detail_op_style', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field',
    methods: {
        gallery: function (attr_val, index) {
            this.$emit('gallery', attr_val, index);
        },
        external_call: function () {
            this.$emit('external_call');
        },
        pdf_extract: function () {
            this.$emit('pdf_extract');
        },
        item_click: function () {
            this.$emit('item_click');
        },
        item_link_click: function () {
            this.$emit('item_link_click');
        }
    }
});
Vue.component('com_field_edit', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'upload_cfg', 'is_set', 'flag_flow_detail_op_style', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit',
    methods: {
        add_new_file: function (pk, data, attr, item_vendor_id) {
            this.$emit('add_new_file', pk, data, attr, item_vendor_id);
        },
        delete_a_file: function (pk, index, attr, item_vendor_id) {
            this.$emit('delete_a_file', pk, index, attr, item_vendor_id);
        },
        rotate_img: function (path) {
            this.$emit('rotate_img', path);
        },
        pick_date: function () {
            this.$emit('pick_date');
        },
        pick_date_time: function () {
            this.$emit('pick_date_time');
        },
        auto_complete: function (item_vendor_id, category_flow_id, attr_id) {
            this.$emit('auto_complete', item_vendor_id, category_flow_id, attr_id);
        },
        auto_complete_dynamic_item_no: function (item_vendor_id, category_flow_id, attr_id) {
            this.$emit('auto_complete_dynamic_item_no', item_vendor_id, category_flow_id, attr_id);
        },
        auto_complete_dynamic_multi: function (item_vendor_id, category_flow_id, attr_id) {
            this.$emit('auto_complete_dynamic_multi', item_vendor_id, category_flow_id, attr_id);
        },
        delete_dynamic_multiselect: function () {
            this.$emit('delete_dynamic_multiselect');
        },
        add_set_element: function () {
            this.$emit('add_set_element');
        },
        del_set_element: function () {
            this.$emit('del_set_element');
        },
        external_call: function () {
            this.$emit('external_call');
        },
        pdf_extract: function () {
            this.$emit('pdf_extract');
        },
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_edit_text', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_text',
    methods: {
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_text', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_text',
    methods: {
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        item_link_click: function () {
            this.$emit('item_link_click');
        }
    }
});
Vue.component('com_field_edit_textarea', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_textarea',
    methods: {
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_textarea', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_textarea'
});
Vue.component('com_field_edit_number', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_number',
    methods: {
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_number', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_number'
});
Vue.component('com_field_edit_unit', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_unit',
    methods: {
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_edit_date', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_date',
    methods: {
        pick_date: function () {
            this.$emit('pick_date');
        },
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_date', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_date'
});
Vue.component('com_field_edit_time', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_time',
    methods: {
        pick_date_time: function () {
            this.$emit('pick_date_time');
        },
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_time', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_time'
});
Vue.component('com_field_edit_select', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_select',
    methods: {
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_select', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_select'
});
Vue.component('com_field_edit_multiselect', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_multiselect',
    methods: {
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_multiselect', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_multiselect'
});
Vue.component('com_field_edit_dynamicselect', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_dynamicselect',
    methods: {
        auto_complete: function (item_vendor_id, category_flow_id, attr_id) {
            this.$emit('auto_complete', item_vendor_id, category_flow_id, attr_id);
        },
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_dynamicselect', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_dynamicselect',
    methods: {
        item_link_click: function () {
            this.$emit('item_link_click');
        }
    }
});
Vue.component('com_field_edit_dynamicmultiselect', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_dynamicmultiselect',
    methods: {
        auto_complete_dynamic_multi: function (item_vendor_id, category_flow_id, attr_id) {
            this.$emit('auto_complete_dynamic_multi', item_vendor_id, category_flow_id, attr_id);
        },
        delete_dynamic_multiselect: function () {
            this.$emit('delete_dynamic_multiselect');
        },
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_dynamicmultiselect', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_dynamicmultiselect',
    methods: {
        item_link_click: function () {
            this.$emit('item_link_click');
        }
    }
});
Vue.component('com_field_edit_image', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'upload_cfg', 'is_set', 'flag_flow_detail_op_style', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_image',
    methods: {
        add_new_file: function (pk, data, attr, item_vendor_id) {
            this.$emit('add_new_file', pk, data, attr, item_vendor_id);
        },
        delete_a_file: function (pk, index, attr, item_vendor_id) {
            this.$emit('delete_a_file', pk, index, attr, item_vendor_id);
        },
        rotate_img: function (path) {
            this.$emit('rotate_img', path);
        },
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_image', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'upload_cfg', 'is_set', 'flag_flow_detail_op_style', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_image',
    methods: {
        gallery: function (attr_val, index) {
            this.$emit('gallery',attr_val, index);
        }
    }
});
Vue.component('com_field_edit_video', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'upload_cfg', 'is_set', 'flag_flow_detail_op_style', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_video',
    methods: {
        add_new_file: function (pk, data, attr, item_vendor_id) {
            this.$emit('add_new_file', pk, data, attr, item_vendor_id);
        },
        delete_a_file: function (pk, index, attr, item_vendor_id) {
            this.$emit('delete_a_file', pk, index, attr, item_vendor_id);
        },
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_video', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'upload_cfg', 'is_set', 'flag_flow_detail_op_style', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_video'
});
Vue.component('com_field_edit_file', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'upload_cfg', 'is_set', 'flag_flow_detail_op_style', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_file',
    methods: {
        add_new_file: function (pk, data, attr, item_vendor_id) {
            this.$emit('add_new_file', pk, data, attr, item_vendor_id);
        },
        delete_a_file: function (pk, index, attr, item_vendor_id) {
            this.$emit('delete_a_file', pk, index, attr, item_vendor_id);
        },
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_file', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'upload_cfg', 'is_set', 'flag_flow_detail_op_style', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_file'
});
Vue.component('com_field_edit_calculatedvalue', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_calculatedvalue',
    methods: {
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_edit_referencevalue', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_referencevalue',
    methods: {
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_edit_checkbox', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_checkbox',
    methods: {
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_checkbox', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_checkbox'
});
Vue.component('com_field_edit_yesno', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_yesno',
    methods: {
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_yesno', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_yesno'
});
Vue.component('com_field_edit_table', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_table',
    methods: {
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_edit_qie', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_qie',
    methods: {
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_set', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'upload_cfg', 'is_set', 'flag_flow_detail_op_style', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_set',
    methods: {
        gallery: function (attr_val, index) {
            this.$emit('gallery', attr_val, index);
        },
        external_call: function () {
            this.$emit('external_call');
        },
        pdf_extract: function () {
            this.$emit('pdf_extract');
        },
        item_click: function () {
            this.$emit('item_click');
        },
        item_link_click: function () {
            this.$emit('item_link_click');
        },
    }
});
Vue.component('com_field_edit_set', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'upload_cfg', 'is_set', 'flag_flow_detail_op_style', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_set',
    methods: {
        add_new_file: function (pk, data, attr, item_vendor_id) {
            this.$emit('add_new_file', pk, data, attr, item_vendor_id);
        },
        delete_a_file: function (pk, index, attr, item_vendor_id) {
            this.$emit('delete_a_file', pk, index, attr, item_vendor_id);
        },
        rotate_img: function (path) {
            this.$emit('rotate_img', path);
        },
        pick_date: function () {
            this.$emit('pick_date');
        },
        pick_date_time: function () {
            this.$emit('pick_date_time');
        },
        auto_complete: function (item_vendor_id, category_flow_id, attr_id) {
            this.$emit('auto_complete', item_vendor_id, category_flow_id, attr_id);
        },
        auto_complete_dynamic_multi: function (item_vendor_id, category_flow_id, attr_id) {
            this.$emit('auto_complete_dynamic_multi', item_vendor_id, category_flow_id, attr_id);
        },
        auto_complete_dynamic_item_no: function (item_vendor_id, category_flow_id, attr_id) {
            this.$emit('auto_complete_dynamic_item_no', item_vendor_id, category_flow_id, attr_id);
        },
        delete_dynamic_multiselect: function () {
            this.$emit('delete_dynamic_multiselect');
        },
        add_set_element: function () {
            this.$emit('add_set_element');
        },
        del_set_element: function () {
            this.$emit('del_set_element');
        },
        external_call: function () {
            this.$emit('external_call');
        },
        pdf_extract: function () {
            this.$emit('pdf_extract');
        },
        item_click: function () {
            this.$emit('item_click');
        },
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_edit_external_call', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_external_call',
    methods: {
        external_call: function () {
            this.$emit('external_call');
        },
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_edit_pdf_extract', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_pdf_extract',
    methods: {
        pdf_extract: function () {
            this.$emit('pdf_extract');
        },
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_edit_relate', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'flag_flow_detail_op_style', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_relate',
    methods: {
        auto_complete_dynamic_item_no: function (item_vendor_id, category_flow_id, attr_id) {
            this.$emit('auto_complete_dynamic_item_no', item_vendor_id, category_flow_id, attr_id);
        },
        delete_dynamic_multiselect: function () {
            this.$emit('delete_dynamic_multiselect');
        },
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_relate', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'flag_flow_detail_op_style', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_relate',
    methods: {
        item_click: function () {
            this.$emit('item_click');
        }
    }
});
Vue.component('com_field_edit_rich_text', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview', 'confirm_correlation_role'],
    template: '#com_field_edit_rich_text',
    methods: {
        item_correlation_confirm: function () {
            this.$emit('item_correlation_confirm');
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            this.$emit('auto_save_attr_value', item_vendor_id, attr);
        }
    }
});
Vue.component('com_field_rich_text', {
    props: ['attr', 'item_value', 'item_vendor_id', 'item_correlation', 'is_set', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_rich_text'
});
Vue.component('com_field_reference_value', {
    props: ['attr', 'item_vendor_id', 'is_set', 'flag_flow_detail_op_style', 'is_mobile', 'myclass', 'is_preview'],
    template: '#com_field_reference_value',
});

Vue.component('com_image_tag', {
    props: ['src', 'myclass', 'width'],
    data: function () {
        return {
            is_tiff: false,
            canvas_img : '',
            cache :{}
        }
    },
    template: '#com_image_tag',
    watch : {
        src : {
            handler(newVal, oldVal){
                let that = this;
                var tiff_reg = /(\.tiff|\.tif)$/;
                if (tiff_reg.test(newVal)) {
                    that.is_tiff = true;
                    that.canvas_img = newVal.replace(tiff_reg, '.jpg');
                } else {
                    that.is_tiff = false;
                    that.canvas_img = '';
                }
            },
            deep:true //true 娣卞害鐩戝惉
        }
    },
    mounted: function () {
        let that = this;
        var tiff_reg = /(\.tiff|\.tif)$/;
        if (tiff_reg.test(that.src)) {
            that.is_tiff = true;
            that.canvas_img = that.src.replace(tiff_reg, '.jpg');
        } else {
            that.is_tiff = false;
            that.canvas_img = '';
        }
    },
    methods: {
        set_cache : function(key, value, expire = -1) {
            let timestamp = Date.parse(new Date()) / 1000;
            if (expire == -1) {
                timestamp = -1;
            } else {
                timestamp = timestamp + expire;
            }
            let res = {
                expire : timestamp,
                data : value
            }
            window.localStorage.setItem(key, JSON.stringify(res));
        },
        get_cache : function(key) {
            let that = this;
            let res = window.localStorage.getItem(key);
            let timestamp = Date.parse(new Date()) / 1000;
            if (res) {
                res = JSON.parse(res);
                if (res == undefined || res.expire == undefined || (res.expire < timestamp && res.expire > 0)) {
                    that.clear_cache(key)
                    return undefined;
                }
                return res.data;
            }
            return undefined;
        },
        clear_cache: function(key = '') {
            if (key != '') {
                window.localStorage.removeItem(key);
            } else {
                window.localStorage.clear();
            }
        },
    }
});

var baseMixin = {
    data: {
        multi_item_no : [],                     //閲嶅item no
        flag_show_multi_item_no : false,        //閫夋嫨閲嶅item no
        multi_group_no : [],                    //閲嶅item no
        flag_show_multi_group_no : false,       //閫夋嫨閲嶅group no
        flag_shadow_div : false,
        flag_close_btn : false,
        flag_photo_shadow_div : false,
    },
    created: function () {

    },
    methods: {
        item_click: function (target_id = 0) {
            //鎵撳紑鏂伴〉闈�
            let that = this;
            if (target_id > 0) {
                let url = pim_config.detail_api + '?item_id=' + target_id;
                window.open(url);
            } else {
                let e = $(event.target).closest('[data-id]');
                let url = pim_config.detail_api + '?item_id=' + $(e).attr('data-id').split('|')[1];
                window.open(url);
            }
        },
        item_link_click: function () {
            let that = this;
            let e = $(event.target).closest('[data-id]');
            if ($(e).attr('data-type') == 2) {
                that.group_link_click();
                return;
            }
            ajax(pim_api.URL_CHECK_ITEM, {item_no : $(e).attr('data-text'), attr_id : $(e).attr('data-attr_id')}).then(function (res) {
                if (res.data.length == 1) {
                    //鍙湁涓€涓�
                    that.item_click(res.data[0].id);
                } else {
                    //闇€瑕侀€夋嫨
                    that.multi_item_no = res.data;
                    that.flag_show_multi_item_no = true;
                    that.flag_shadow_div = true;
                    that.flag_close_btn = true;
                    // $('#ask-source').setPosition();
                    that.$nextTick(function () {
                        selectBox('#ask-source .select-box', -1);
                        $('#ask-source .select-box dt').html('Please Select');
                        $('#ask-source .select-box dt').attr('data-value', '');
                    })
                }
            }, function (res) {
                layer.msg(res.info);
            })
        },
        select_multi_item: function() {
            let that = this;
            let item_id = $('#ask-source .select-box dt').attr('data-value');
            if (item_id != undefined && item_id != '') {
                that.item_click(item_id);
            }
        },
        group_click: function (group_no, item_id, group_id) {
            //鎵撳紑鏂伴〉闈�
            let that = this;
            let url = pim_config.group_api + '?group_no=' + group_no + '&item_id=' + item_id + '&group_id=' + group_id;
            window.open(url);
        },
        group_link_click: function () {
            let that = this;
            let e = $(event.target).closest('[data-id]');
            ajax(pim_api.URL_CHECK_GROUP, {group_no : $(e).attr('data-text')}).then(function (res) {
                if (res.data.length == 1) {
                    //鍙湁涓€涓�
                    that.group_click(res.data[0].group_no, res.data[0].item_id, res.data[0].group_id);
                } else {
                    //闇€瑕侀€夋嫨
                    that.multi_group_no = res.data;
                    that.flag_show_multi_group_no = true;
                    that.flag_shadow_div = true;
                    that.flag_close_btn = true;
                    // $('#ask-group').setPosition();
                    that.$nextTick(function () {
                        selectBox('#ask-group .select-box', -1);
                        $('#ask-group .select-box dt').html('Please Select');
                        $('#ask-group .select-box dt').attr('data-value', '');
                    })
                }
            }, function (res) {
                layer.msg(res.info);
            })
        },
        select_multi_group: function() {
            let that = this;
            let group_data = $('#ask-group .select-box dt').attr('data-value');
            group_data = group_data.split(';');
            that.group_click(group_data[0], group_data[1], group_data[2]);
        },
        add_user_log: function (page, type, data_id = '', params = []) {
            let that = this;
            let post_data = {
                page: page,
                type: type,
                data_id: data_id,
                params: params,
            };
            ajax(pim_api.URL_USER_LOG, post_data);
        },
        gallery: function (photos, index) {
            let that = this;

            that.gallery_data = photos;
            that.gallery_obj_index = index;

            that.gallery_current_src = that.gallery_data[that.gallery_obj_index].web_path;

            if(that.is_mobile) {
                that.flag_show_gallery = true;

                initPhotoSwipeFromDOM('.gallery');
            } else {
                that.flag_show_gallery = true;
                that.flag_photo_shadow_div = true;

                // $("#photo-view").setPosition();
                //$(".shade-div").show();
                //$(".close-btn").show();

                that.$nextTick(function () {
                    setTimeout(function () {
                        mouseScroll($('#scrolllayout'), 10);
                    }, 100);
                });
            }
            return false;
        },
        close_gallery: function () {
            let that = this;
            that.flag_show_gallery = false;
            that.flag_photo_shadow_div = false;
        },//璁剧疆cookie
        set_cookie: function(key, value, exdays = 30) {
            var exdate = new Date(); //鑾峰彇鏃堕棿
            exdate.setTime(exdate.getTime() + 24 * 60 * 60 * 1000 * exdays); //淇濆瓨鐨勫ぉ鏁�
            //瀛楃涓叉嫾鎺ookie
            window.document.cookie = key + "=" + value + ";path=/;expires=" + exdate.toGMTString();
        },
        //璇诲彇cookie
        get_cookie: function(key) {
            let that = this;
            if (document.cookie.length > 0) {
                var arr = document.cookie.split('; '); //杩欓噷鏄剧ず鐨勬牸寮忛渶瑕佸垏鍓蹭竴涓嬭嚜宸卞彲杈撳嚭鐪嬩笅
                for (var i = 0; i < arr.length; i++) {
                    var arr2 = arr[i].split('='); //鍐嶆鍒囧壊
                    //鍒ゆ柇鏌ユ壘鐩稿搴旂殑鍊�
                    if (arr2[0] == key) {
                        return arr2[1];
                    }
                }
            }
            return null;
        },
        //娓呴櫎cookie
        clear_cookie: function() {
            this.set_cookie("", "", -1);
        },
        set_cache : function(key, value, expire = -1) {
            let timestamp = Date.parse(new Date()) / 1000;
            if (expire == -1) {
                timestamp = -1;
            } else {
                timestamp = timestamp + expire;
            }
            let res = {
                expire : timestamp,
                data : value
            }
            window.localStorage.setItem(key, JSON.stringify(res));
        },
        get_cache : function(key) {
            let that = this;
            let res = window.localStorage.getItem(key);
            let timestamp = Date.parse(new Date()) / 1000;
            if (res) {
                res = JSON.parse(res);
                if (res == undefined || res.expire == undefined || (res.expire < timestamp && res.expire > 0)) {
                    that.clear_cache(key)
                    return undefined;
                }
                return res.data;
            }
            return undefined;
        },
        clear_cache: function(key = '') {
            if (key != '') {
                window.localStorage.removeItem(key);
            } else {
                window.localStorage.clear();
            }
        },
        jump_index: function (category_id) {
            let that = this;
            let post_data = {
                top_category_id : category_id,
                category_ids : [],
            }
            ajax(pim_api.URL_USER_CATEGORY_SET, post_data).then(function (res) {
                window.location.href = pim_config.index;
            });
        },
        download_file: function (web_path) {
            let that = this;
            window.open(web_path, '_blank');
        },
        jump_flow: function(flow_id) {
            scrollTo('.panel-r.slimscroll', '.card-' + flow_id);
        },
        auto_list: function () {
            let that = this;
            let p1 = new Promise(function (resolve, reject) {
                let cache = that.get_cache('pim_auto_list');
                if (cache != undefined) {
                    $.extend(that.autolist, cache);
                } else {
                    ajax(pim_api.URL_AUTOLIST, {}).then(function (res) {
                        $.extend(that.autolist, res.data);
                        that.sub_category_list = {};
                        $.each(that.autolist.sub_category, function(k, v) {
                            if (v.list != undefined) {
                                $.each(v.list, function(id, cate) {
                                    if (cate != undefined && id != undefined) {
                                        Vue.set(that.sub_category_list, id, cate);
                                    }
                                });
                            }
                        })
                        that.set_cache('pim_auto_list', res.data, 600);
                    }, function (res) {
                    });
                }
            });
            let p2 = new Promise(function (resolve, reject) {
                ajax(pim_api.URL_AUTOLIST_DYNAMIC, {}).then(function (res) {
                    $.extend(that.autolist, res.data);
                }, function() {});
            });
        },
        init_multi_select: function () {
            let that = this;
            $('.s1').ySelect(
                {
                    placeholder: 'Please Select',
                    searchText: 'Search',
                    showSearch: true,
                    numDisplayed: 100,
                    isCheck:false
                }
            );
            $('.s1').change(function () {
                let val = $(this).ySelectedValuesArr();
                let item_vendor_id = $(this).attr('item_vendor_id');
                let category_flow_id = $(this).attr('category_flow_id');
                let attr_id = $(this).attr('attr_id');
                that.$set(that.item_value[item_vendor_id][category_flow_id][attr_id] , 'val', val);
                that.auto_save_attr_value(item_vendor_id, {id:attr_id, category_flow_id:category_flow_id});
            })
            refresh_event();
            $('.select-box li').click(function () {
                let value = $(this).attr('value');
                let item_vendor_id = $(this).attr('item_vendor_id');
                let category_flow_id = $(this).attr('category_flow_id');
                let attr_id = $(this).attr('attr_id');
                that.$set(that.item_value[item_vendor_id][category_flow_id][attr_id] , 'val', value);
                that.auto_save_attr_value(item_vendor_id, {id:attr_id, category_flow_id:category_flow_id});
            })
        },
        multiple_select_click: function () {
            let that = this;
            let e = $(event.target);
            let val = e.closest('.s1').ySelectedValues(",");
        },
        add_new_file: function (pk, data, attr, item_vendor_id) {
            let that = this;
            if(typeof that.item_value[item_vendor_id][attr.category_flow_id][pk].val == 'undefined' || that.item_value[item_vendor_id][attr.category_flow_id][pk].val == '') {
                that.$set(that.item_value[item_vendor_id][attr.category_flow_id][pk], 'val', []);
            }
            data.icon = get_icon(data.extension);
            data.size_formated = getfilesize(data.size);
            if(attr.metadata.multiple && attr.metadata.multiple == 1) {
                let tmp = that.item_value[item_vendor_id][attr.category_flow_id][pk].val;
                tmp.push(data);
                that.$set(that.item_value[item_vendor_id][attr.category_flow_id][pk], 'val', tmp);
            } else {
                let tmp = [data];
                that.$set(that.item_value[item_vendor_id][attr.category_flow_id][pk], 'val', tmp);
            }
            that.auto_save_attr_value(item_vendor_id, attr);
        },
        external_call: function () {
            let that = this;
            let e = $(event.target).closest('a');
            let url = $.trim(e.data('url'));
            let item_vendor_id = $.trim(e.data('item_vendor_id'));

            var patrn=/{{([a-zA-Z0-9_-]*)}}/;
            while (url.match(patrn)) {
                let str = url.match(patrn)[0];
                let key = url.match(patrn)[1];
                let value = '';
                if (key == 'item_id') {
                    value = that.item_flow.id;
                } else if (key == 'item_no') {
                    value = that.item_flow.no;
                } else if (key == 'item_office') {
                    //sample妯℃澘鐨勫畾鍒跺瓧娈�
                    value = that.item_flow.office;
                } else if (key == 'vendor') {
                    value = 0;
                    $.each(that.vendor_list, function(index, vendor_item) {
                        if (vendor_item.id == item_vendor_id) {
                            value = vendor_item.vendor_id;
                        }
                    });
                    value = that.autolist.vendor[value].vendor_no;
                }  else if (key == 'show_market') {
                    value = '';
                    $.each(that.vendor_list, function(index, vendor_item) {
                        if (vendor_item.id == item_vendor_id) {
                            value = vendor_item.show_market_id;
                        }
                    });
                    value = that.autolist.show_market[value].label;
                }  else if (key == 'office') {
                    value = '';
                    $.each(that.vendor_list, function(index, vendor_item) {
                        if (vendor_item.id == item_vendor_id) {
                            value = vendor_item.office_id;
                        }
                    });
                    value = that.autolist.office[value].label;
                } else {
                    let arr = key.split('-');
                    category_flow_id = arr[0];
                    attr_id = arr[1];
                    if (that.item_value[item_vendor_id] && that.item_value[item_vendor_id][category_flow_id]  && that.item_value[item_vendor_id][category_flow_id][attr_id]) {
                        value = that.item_value[item_vendor_id][category_flow_id][attr_id].val;
                    }
                }
                url = url.replace(str, value);
            }
            window.open(url);
            return;
        },
        external_call_val: function (url, item_vendor_id, cur_category_flow_id, cur_attr_id) {
            let that = this;
            // let e = $(event.target).closest('span');
            // let url = $.trim(e.data('url'));
            // let item_vendor_id = $.trim(e.data('item_vendor_id'));
            // let cur_category_flow_id = $.trim(e.data('category_flow_id'));
            // let cur_attr_id = $.trim(e.data('attr_id'));

            var patrn=/{{([a-zA-Z0-9_-]*)}}/;
            while (url.match(patrn)) {
                let str = url.match(patrn)[0];
                let key = url.match(patrn)[1];
                let value = '';
                if (key == 'item_no') {
                    value = that.item_flow.no;
                } else if (key == 'vendor') {
                    value = 0;
                    $.each(that.vendor_list, function(index, vendor_item) {
                        if (vendor_item.id == item_vendor_id) {
                            value = vendor_item.vendor_id;
                        }
                    });
                    value = that.autolist.vendor[value].vendor_no;
                } else {
                    let arr = key.split('-');
                    category_flow_id = arr[0];
                    attr_id = arr[1];
                    if (that.item_value[item_vendor_id] && that.item_value[item_vendor_id][category_flow_id]  && that.item_value[item_vendor_id][category_flow_id][attr_id]) {
                        value = that.item_value[item_vendor_id][category_flow_id][attr_id].val;
                    }
                }
                url = url.replace(str, value);
            }
            let result = '';
            $.ajaxSettings.async = false;
            $.get(url, function (res) {
                result = res.data;
            }, 'json');
            $.ajaxSettings.async = true;
            return result;
        },
        pdf_extract: function () {
            let that = this;
            let e = $(event.target).closest('[data-url]');
            let subject = that.main_tab[that.main_tab_obj.current_index()].id;
            let url = $.trim(e.data('url'));
            url += (/\?/.test(url) ? '&' : '?')+'subject='+subject+'&vendor_id='+that.vendor_selected;
            url += '&call_from=pim';
            window.open(url);
        },
        delete_a_file: function (pk, index, attr, item_vendor_id) {
            let that = this;
            that.item_value[item_vendor_id][attr.category_flow_id][pk].val.splice(index, 1);
            that.auto_save_attr_value(item_vendor_id, attr);
            // that.$set(that.item_value[item_vendor_id][attr.category_flow_id][pk].val[index], 'deleted', 1);
        },
        rotate_img: function (path) {
            console.log(path);
        },
        add_set_element: function () {
            let that = this;
            let e = $(event.target).closest('.btn-add');
            let item_vendor_id = e.attr('data-item_vendor_id');
            let category_flow_id = e.attr('data-category_flow_id');
            let attr_id = e.attr('data-attr_id');
            $.each(that.flow_data, function (k, v) {
                $.each(v.groups, function (gk, gv) {
                    $.each(gv.attrs, function (ak, av) {
                        if(av.id == e.attr('data-attr_id') && av.category_flow_id == e.attr('data-category_flow_id')) {
                            let tmp = JSON.parse(JSON.stringify(that.flow_data[k].groups[gk].attrs[ak].child_attr));
                            let index = that.item_value[item_vendor_id][category_flow_id][attr_id].set.length;
                            let new_set_line = {};
                            $.each(tmp, function (tk, tv) {
                                let attr =  JSON.parse(JSON.stringify(tv));
                                attr.category_flow_id = av.category_flow_id;
                                let new_id = attr_id+'|'+index+'|'+attr.id;
                                let el_val = '';
                                if($.inArray(attr.type_id, ['8', '10', '16'])!=-1) { el_val = []; }
                                that.item_value[item_vendor_id][category_flow_id][new_id] =  {
                                    val: el_val,
                                    type_id: attr.type_id,
                                    attr: attr
                                };
                                new_set_line[attr.id] = that.item_value[item_vendor_id][category_flow_id][new_id];
                                attr.id = new_id
                            });
                            that.item_value[item_vendor_id][category_flow_id][attr_id].set.push(new_set_line);
                            that.$nextTick(function () {
                                that.init_multi_select();
                                refresh_event();
                            });
                        }
                    });

                });
            });
        },
        del_set_element: function () {
            let that = this;
            let e = $(event.target).closest('.btn-delete');
            let index = $(event.target).closest('tr').data('index');
            let item_vendor_id = e.attr('data-item_vendor_id');
            let category_flow_id = e.attr('data-category_flow_id');
            let attr_id = e.attr('data-attr_id');

            let set_line = that.item_value[item_vendor_id][category_flow_id][attr_id].set[index];
            let length = that.item_value[item_vendor_id][category_flow_id][attr_id].set.length;

            //閲嶆柊澶勭悊 attr_id | index | child_attr_id 鐨勫唴瀹癸紝浠ュ強 set 閲宨ndex涔嬪悗鐨勫唴瀹�
            for(var i = index;i < length -1; i++) {
                //褰撳墠鍏冪礌鐢变笅涓€涓厓绱犱唬鏇�
                $.each(that.item_value[item_vendor_id][category_flow_id][attr_id].set[i], function (set_index, set_value) {
                    let id_arr = set_value.attr.id.split('|');
                    let next_id = id_arr[0]+'|'+(i + 1)+'|'+id_arr[2];
                    that.item_value[item_vendor_id][category_flow_id][set_value.attr.id] = JSON.parse(JSON.stringify(that.item_value[item_vendor_id][category_flow_id][next_id]))
                    that.item_value[item_vendor_id][category_flow_id][set_value.attr.id].attr.id = set_value.attr.id
                    set_value = JSON.parse(JSON.stringify(that.item_value[item_vendor_id][category_flow_id][attr_id].set[i+1][set_index]));
                    set_value.attr.id = id_arr[0]+'|'+i+'|'+id_arr[2];
                })
            }
            //鍓嶉潰鐨勫厓绱犳洿鏂颁负涓嬩竴涓紝鍒犳帀鏈€鍚庝竴涓厓绱�
            let set_attr_id = '';
            $.each(that.item_value[item_vendor_id][category_flow_id][attr_id].set[length - 1], function (set_index, set_value) {
                set_attr_id = set_value.attr.id;
                delete that.item_value[item_vendor_id][category_flow_id][set_value.attr.id]
            })
            that.item_value[item_vendor_id][category_flow_id][attr_id].set.splice(length - 1, 1);
            that.auto_save_attr_value(item_vendor_id, {id:set_attr_id, category_flow_id:category_flow_id});
            return;
        },
        pick_date: function (item_vendor_id) {
            let that = this;
            let e = event.target;
            WdatePicker({
                el: e,
                onpicked: function () {
                    let attr_id = $(this).attr('data-attr_id');
                    let category_flow_id = $(this).attr('data-category_flow_id');
                    let item_vendor_id = $(this).attr('data-item_vendor_id');
                    that.$set(that.item_value[item_vendor_id][category_flow_id][attr_id], 'val', $(this).val());
                    that.auto_save_attr_value(item_vendor_id, {id:attr_id, category_flow_id:category_flow_id});
                }
            });
        },
        pick_date_time: function () {
            let that = this;
            let e = event.target;
            WdatePicker({
                el: e,
                dateFmt: 'yyyy-MM-dd HH:mm:00',
                onpicked: function () {
                    let attr_id = $(this).attr('data-attr_id');
                    let category_flow_id = $(this).attr('data-category_flow_id');
                    let item_vendor_id = $(this).attr('data-item_vendor_id');
                    that.$set(that.item_value[item_vendor_id][category_flow_id][attr_id], 'val', $(this).val());
                    that.auto_save_attr_value(item_vendor_id, {id:attr_id, category_flow_id:category_flow_id});
                }
            });
        },
        item_correlation_confirm: function() {
            let that = this;
            let e = $(event.target);
            let post = {
                item_id: that.item_flow.id,
                item_correlation_attribute_id : that.item_correlation_attribute_tree[e.data('item_vendor_id')][e.data('category_flow_id')][e.data('attr_id')].id
            };
            ajax(pim_api.URL_CONFIRM_ITEM_CORRELATION_ATTRIBUTE, post).then(function (res) {
                that.item_correlation_attribute_tree[e.data('item_vendor_id')][e.data('category_flow_id')][e.data('attr_id')].status = 1;
                layer.close();
            }, function (res) {
                layer.msg(res.info);
                layer.close();
            });
        },
        auto_group_no: function () {
            let that = this;
            let e = $(event.target);
            jq17(e).autocomplete({
                source: pim_api.URL_AUTO_COMPLETE+'?type=group&style=0',
                minLength: 1,
                open: function(){
                    $('.ui-autocomplete').css('z-index', 10001)
                },
                select: function(event, ui) {
                    that.sample_or_item_group = ui.item.label;
                }
            });
        },
        auto_no: function () {
            let that = this;
            let e = $(event.target);
            jq17(e).autocomplete({
                source: pim_api.URL_AUTO_COMPLETE+'?type=item&style=0',
                minLength: 1,
                open: function(){
                    $('.ui-autocomplete').css('z-index', 10001)
                },
                select: function(event, ui) {
                    that.sample_or_item = ui.item.label;
                }
            });
        },
        auto_complete_type: function (type) {
            let that = this;
            let e = $(event.target);
            e.devbridgeAutocomplete({
                serviceUrl: pim_api.URL_AUTO_COMPLETE+'?type='+type+'&style=0',
                minChars: 1,
                delimiter:"",
                triggerSelectOnValidInput: false,
                showNoSuggestionNotice: false,
                paramName: 'term',
                dataType: 'json',
                onSelect: function(suggestion) {
                    e.next("input").val(suggestion.data.id)
                },
                beforeRender(container, suggestions) {
                    let els = container[0].querySelectorAll('.autocomplete-suggestion');
                    suggestions.forEach((item, index) => {
                        if (item.data.class) {
                            els[index].classList.add(item.data.class);
                        }
                    });
                },
                transformResult:function(response) {
                    return {
                        suggestions: $.map(response, function (dataItem) {
                            if (dataItem.label) {
                                return {value: dataItem.label, data: dataItem};
                            }
                        })
                    };
                }
            });
        },
        auto_vendor: function (item_id) {
            let that = this;
            let e = $(event.target);
            jq17(e).autocomplete({
                source: pim_api.URL_AUTO_COMPLETE+'?type=vendor&style=0',
                minLength: 1,
                open: function(){
                    $('.ui-autocomplete').css('z-index', 10001)
                },
                select: function(event, ui) {
                    let post_data = {
                        vendor_no: ui.item.vendor_no,
                        item_id: item_id
                    };
                    let layer_index = layer.load(1,{shade :0.3});
                    ajax(pim_api.URL_ADD_ITEM_VENDOR, post_data).then(function (res) {
                        layer.msg(res.info);
                        layer.close(layer_index);
                        //瑙﹀彂涓€娆$偣鍑�
                        e.val('');
                        e.closest('.search-area').hide();
                        that.item_detail_show(0);  //鏄剧ずitem璇︽儏

                    }).catch(function (res) {
                        layer.msg(res.info);
                        layer.close(layer_index);
                    });

                }
            });
        },
        auto_complete: function (item_vendor_id, category_flow_id, attr_id) {
            let that = this;
            let e = $(event.target);
            let url = e.data('url');
            if(!/^https/.test(url)) {
                url = pim_config.api+$.trim(url);
            }
            jq17(e).autocomplete({
                source: url,
                minLength: 1,
                open: function(){
                    $('.ui-autocomplete').css('z-index', 10001)
                },
                select: function(event, ui) {
                    that.item_value[item_vendor_id][category_flow_id][attr_id].val = ui.item.label;
                    that.auto_save_attr_value(item_vendor_id, {id:attr_id, category_flow_id:category_flow_id});
                }
            });
        },
        auto_complete_related_item_no: function () {
            let that = this;
            let e = $(event.target);
            jq17(e).autocomplete({
                source: pim_api.URL_AUTO_COMPLETE + '?type=item&style=0',
                minLength: 1,
                open: function(){
                    $('.ui-autocomplete').css('z-index', 10001)
                },
                select: function(event, ui) {
                    //related item check
                    item_id =  ui.item.label;
                    let post = {
                        item_bid :ui.item.label,
                        item_aid: that.item_flow.id
                    };
                    ajax(pim_api.URL_ADD_CORRELATION_ITEM, post).then(function (res) {
                        if (res.status == 1) {
                            $('.search-related-item').val('');
                            that.show_data_correlation();
                        }
                    }).catch(function (res) {
                        layer.msg(res.info);
                    });
                    return false;
                }
            });
        },
        auto_complete_dynamic_item_no: function (item_vendor_id, category_flow_id, attr_id) {
            let that = this;
            let e = $(event.target);
            jq17(e).autocomplete({
                source: pim_api.URL_AUTO_COMPLETE + '?type=item&style=0',
                minLength: 1,
                open: function(){
                    $('.ui-autocomplete').css('z-index', 10001)
                },
                select: function(event, ui) {
                    //related item check
                    let post = {
                        item_bid :ui.item.label,
                        item_aid: that.item_flow.id
                    };
                    ajax(pim_api.URL_CHECK_RELATED_ITEM, post).then(function (res) {
                        if (res.status == 1) {
                            that.item_value[item_vendor_id][category_flow_id][attr_id].val.push(ui.item.label);
                            that.auto_save_attr_value(item_vendor_id, {id:attr_id, category_flow_id:category_flow_id});
                            setTimeout(function () {
                                e.val('');
                            }, 5);
                        }
                    }).catch(function (res) {
                        layer.msg(res.info);
                    });
                    return false;
                }
            });
        },
        auto_complete_dynamic_multi: function (item_vendor_id, category_flow_id, attr_id) {
            let that = this;
            let e = $(event.target);
            let url = e.data('url');
            if (url == undefined || url == '') {
                url = pim_api.URL_AUTO_COMPLETE + '?type=item&style=0';
            }
            if(!/^https/.test(url)) {
                url = pim_config.api+url;
            }
            jq17(e).autocomplete({
                source: url,
                minLength: 1,
                open: function(){
                    $('.ui-autocomplete').css('z-index', 10001)
                },
                select: function(event, ui) {
                    that.item_value[item_vendor_id][category_flow_id][attr_id].val.push(ui.item.label);
                    that.auto_save_attr_value(item_vendor_id, {id:attr_id, category_flow_id:category_flow_id});
                    setTimeout(function () {
                        e.val('');
                    }, 5);
                }
            });
        },
        delete_dynamic_multiselect: function () {
            let that = this;
            let e = $(event.target);
            if(!window.confirm('Are you sure to delete it?')) {
                return false;
            }
            that.item_value[e.data('item_vendor_id')][e.data('category_flow_id')][e.data('attr_id')].val.splice(e.data('index'), 1);
            that.auto_save_attr_value(e.data('item_vendor_id'), {id:e.data('attr_id'), category_flow_id:e.data('category_flow_id')});
        },
        auto_save_attr_value: function (item_vendor_id, attr) {
            let that = this;
            if (that.page_type == 'DETAIL') {
                let data = {
                    item_id : that.item_flow.id,
                    item_vendor_id : item_vendor_id,
                    category_flow_id : attr.category_flow_id,
                    attr_id : attr.id,
                }
                let reg = /(\|)/;
                if (String(attr.id).search(reg) != -1) {
                    //set 瀛楁鏇存柊
                    let arr = attr.id.split('|');
                    let set_attr_id = arr[0];
                    let flow_data = that.item_value[item_vendor_id][attr.category_flow_id];
                    let set_value = {};
                    $.each(flow_data, function (attr_id, attr_value) {
                        if (attr_id.search(reg) != -1 && attr.id.split('|')[0] == set_attr_id) {
                            set_value[attr_id] = {val : attr_value.val, type_id : attr_value.type_id}
                        }
                    })
                    data.attr_id = set_attr_id;
                    data.value = JSON.stringify(set_value);
                } else {
                    data.value = that.item_value[item_vendor_id][attr.category_flow_id][attr.id].val;
                }
                ajax(pim_api.URL_SAVE_ATTR_VALUE, data).then(function (res) {
                }, function (res) {
                });
            } else if (that.page_type == 'GROUP') {
                let data = {
                    item_id : that.item_id,
                    group_id : that.group_id,
                    item_vendor_id : item_vendor_id,
                    category_flow_id : attr.category_flow_id,
                    attr_id : attr.id,
                }
                let reg = /(\|)/;
                if (String(attr.id).search(reg) != -1) {
                    //set 瀛楁鏇存柊
                    let arr = attr.id.split('|');
                    let set_attr_id = arr[0];
                    let flow_data = that.item_value[item_vendor_id][attr.category_flow_id];
                    let set_value = {};
                    $.each(flow_data, function (attr_id, attr_value) {
                        if (attr_id.search(reg) != -1 && attr.id.split('|')[0] == set_attr_id) {
                            set_value[attr_id] = {val : attr_value.val, type_id : attr_value.type_id}
                        }
                    })
                    data.attr_id = set_attr_id;
                    data.value = JSON.stringify(set_value);
                } else {
                    data.value = that.item_value[item_vendor_id][attr.category_flow_id][attr.id].val;
                }
                ajax(pim_api.URL_SAVE_GROUP_ATTR_VALUE, data).then(function (res) {
                }, function (res) {
                });
            }
        },
        nav_ctrl: function () {
            let that = this;
            that.flag_show_nav = true;
            that.flag_shadow_div = true;
        },
    }
}


function display_tinymce(html) {
    return "<head><link type='text/css' rel='stylesheet' href='/Public/Js/tinymce2/skins/content/default/content.min.css'>" +
        "<link type='text/css' rel='stylesheet' href='/Public/Js/tinymce2/skins/ui/oxide/content.min.css'></head>" +
        "<body>" + html +
        "</body>"
}

function get_db_file_str(file) {
    if (file.is_img) {
        return "[img]https://" + window.location.host + file.web_path + "[/img]";
    } else {
        return "[pim_file=https://" + window.location.host + file.web_path + ";icon=" + file.icon + ";name=" + file.file_name + ";ext=" + file.extension + ";size=" + file.read_size + "][/pim_file]";
    }
}

// 璁$畻鏂囦欢澶у皬鍑芥暟(淇濈暀涓や綅灏忔暟),Size涓哄瓧鑺傚ぇ灏�
// size锛氬垵濮嬫枃浠跺ぇ灏�
function getfilesize(size) {
    if (!size)
        return "";

    var num = 1024.00; //byte

    if (size < num)
        return size + "B";
    if (size < Math.pow(num, 2))
        return (size / num).toFixed(2) + "K"; //kb
    if (size < Math.pow(num, 3))
        return (size / Math.pow(num, 2)).toFixed(2) + "M"; //M
    if (size < Math.pow(num, 4))
        return (size / Math.pow(num, 3)).toFixed(2) + "G"; //G
    return (size / Math.pow(num, 4)).toFixed(2) + "T"; //T
}

function get_icon(ext) {
    let icon = 'icon-o';
    switch (ext) {
        case 'pdf':
            icon = 'icon-p';
            break;
        case 'mp4':
            icon = 'icon-m';
            break;
        case 'zip':
        case 'rar':
            icon = 'icon-z';
            break;
        case 'xls':
        case 'xlsx':
            icon = 'icon-x';
            break;
        case 'doc':
        case 'docx':
            icon = 'icon-w';
            break;
        case 'txt':
            icon = 'icon-t';
            break;
    }
    return icon;
}

function pim_download(src, name) {
    var a = document.createElement("a");
    a.href = src;//鏈嶅姟鍣ㄤ繚瀛樼殑璺緞
    a.download = name;//涓嬭浇鍚庣殑鏂囦欢鍚嶄负test.doc
    a.click()
}

 

标签:function,vendor,attr,zip,value,js,item,id
From: https://www.cnblogs.com/xmyfsj/p/17653699.html

相关文章

  • JS正则从地址中获取省、市、县
    varadd1='四川省西昌市航天路';varadd2='北京市北京市东城区前门大街1号'varadd3='新疆维吾尔自治区乌鲁木齐市天山区中山路479号';varadd4='四川省成都市双流县幸福社区23号';varadd5='香港特别行政区中西区尖沙嘴路';varreg=/.+?(省......
  • js获取当前时间
    $("#current").html(currentDate(true,true))/*type:true(格式:2018年01月01日) false(格式:2018-01-01)isno:true(包含时分秒:2018-01-0101:01:01) false(不包含时分秒:2018-01-01)*/functioncurrentDate(type,isno){vardate=newDate();varyear=singu......
  • 如何用WinRAR解压文件zip.001
    要合并“分卷.zip.001”~“分卷.zip.018”,步骤如下:新建文本文档,输入:copy/B分卷.zip.*a.zip(如果需要合并的文件为aaaa.zip.001……aaaa.zip.018,就输入copy/Baaaa.zip.*a.zip)将文档保存为批处理文件(如:合并分卷.bat),由于命令中有中文字符,需要保存为ANSI格式  将批处......
  • js知识点学习01
    js知识点学习011.arguements对象(1)什么是arguements对象?由于JavaScript允许函数有不定数目的参数,所以需要一种机制,可以在函数体内部读取所有参数。这就是arguments对象的由来。(2)怎么使用?arguments对象包含了函数运行时的所有参数,arguments[0]就是第一个参数,arguments[......
  • Vue和JSP的区别
    JSP简化的Servlet设计,在HTML标签中嵌套Java代码,用以高效开发Web应用的动态网页JSP 全名为 Java Server Pages,中文名叫 java 服务器页面,其根本是一个简化的 Servlet 设计,它是由Sun Microsystems 公司 倡导、许多公司参与一起建立的一种动态网页技术标准。JSP 技术是在传......
  • FastJson不成想还有个版本2啊:序列化大字符串报错
    背景发现陷入了一个怪圈,写文章的话,感觉只有大bug或比较值得写的内容才会写,每次一写就是几千字,争取写得透彻一些,但这样,我也挺费时间,读者也未必有这么多时间看。我想着,日常遇到的小bug、平时工作中的一些小的心得体会,都还是可以写写,这样也才是最贴近咱们作为一线开发生活的,也不必......
  • 基础入门-算法逆向&散列对称非对称&JS源码逆向&AES&DES&RSA&SHA
    基础入门-算法逆向&散列对称非对称&JS源码逆向&AES&DES&RSA&SHA目录基础入门-算法逆向&散列对称非对称&JS源码逆向&AES&DES&RSA&SHA安全测试中思路单向散列加密-MD5单向散列加密算法的优点有(以MD5为例):单向散列加密的缺点常见的单向散列加密算法有:MD5密文特点:解密需求:对称加密......
  • Fabric.js 元素选中状态的事件与样式
    本文简介带尬猴!你是否在使用Fabric.js时希望能在选中元素后自定义元素样式或选框(控制角和辅助线)的样式?如果是的话,可以放心往下读。本文将手把脚和你一起过一遍Fabric.js在对象元素选中后常用的样式设置。我将对象元素选中后的设置分成3类进行讲解:控制角辅助边其他样......
  • spring web mvc 集成 fastjson2
    maven依赖参考文档https://github.com/alibaba/fastjson2/blob/main/docs/spring_support_cn.md<!-spring5使用这个-><dependency><groupId>com.alibaba.fastjson2</groupId><artifactId>fastjson2-extension-spring5</artifactId&......
  • JS判断字符串不为空:
    一:不为空functionisNotEmptyStr(strval){  if(typeofstrval=='string'&&strval.length>0){    returntrue  }  returnfalse}二:判断字符串为空:functionisEmptyStr(strval){  if(strval==null||strval==undefined||strval===......