detail.js
//console.log($('#main').width()); var list_row = parseInt(($('#main').width()-30)/250)*4; var item_tab_arr = {}; var app = new Vue({ el: '#page', mixins: [baseMixin], data: { page_type : 'DETAIL', is_mobile: 0, promise: [], flag_show_container: true, flag_filter_shadow_div: false, flag_show_nav: false, flag_show_filter: true, flag_show_filter_set: false, flag_show_related_items: false, flag_related_items_add: false, flag_related_items_edit: false, flag_related_items_op_type: 1,// 1 add, 2 edit /*flag_show_photo: true, flag_show_list: false, flag_show_group: false, flag_show_item: true,*/ flag_show_item_detail: false, flag_show_result: true, //search result flag_show_overview: false, flag_show_flow_detail: false, // flag_flow_detail_op_style: 1, flag_flow_detail_op_style: {}, flag_add_new_element: false, flag_show_export_button: false, flag_show_main_tab: false, flag_show_comment_box: true, flag_show_edit_vendor: false, //assign vendor flag_show_flow_tree: false, flag_show_gallery: false, flag_create_items_element: false, //鎵归噺鏂板item鐨刴odal flag_data_revision_element: false, //鎵归噺鏇存柊item鐨刴odal flag_flow_data_revision_element: false, //鎵归噺鏇存柊item鐨刦low鐨刴odal flag_copy_item_element: false, //coyp item 鐨刴odal flag_show_search_item_no: false, //蹇嵎鎼滅储item flag_show_data_correlation: false, //蹇嵎鎼滅储item flag_show_item_relate_list: false, //item correlation 鏄剧ずlist 杩樻槸鏄剧ず闆嗗悎鐨勮鎯� flag_show_add_related_item: false, //item correlation 鏄剧ず娣诲姞item confirm_correlation_role : false, //item correlation 鏉冮檺 flag_show_data_dimension : false, //鏂板缁村害 flag_add_flow_version_element : false, //鏂板flow version flag_show_flow_version_element : false, //flow version 鍒楄〃 //navigator nav: [], nav_icon_arr: [], main_tab_obj: null, main_tab: pim_config.main_tab, main_tab_max_len: 12, current_main_tab_index: -1, item_list: [], sub_category_list: [], //0 item, 1 group, 2 vendor item, 3 vendor group main_tab_type: -1, item_tab_obj: null, item_tab: pim_config.item_tab, item_tab_max_len: 12, current_item_tab_index: -1, //home page, item display type display_type: 'Gallery', //overview //current_item_info: {}, //overview_attr: [], //overview_val: [], item_completion: 0, item_completion_list: [], current_op_index: 1, op_switch: 0, flowtree: [], autolist: [], //flow_detail flow_attr: [], flow_attr_val: [], flow_attr_val_cp: [], item_flow: [], //flow_data_v2 flow_data: [], overview_flow_data: [], overview_vendor_flow_data: [], item_correlation: [], item_correlation_attribute_tree: [], item_value: [], item_value_cp: [], vendor_list: [], vendor_value: [], vendor_value_cp: [], current_item_vendor_id: 0, current_overview_item_vendor_id: -1, flag_overview_expand: 0, dimension_attributes: [], data_dimension: [], //related items related_items: {items: [{}], subject_str: '', group: {}, el_type:-1}, item_id: 0, sample_or_item: '', sample_or_item_group: '', related_items_search_result: [], //search filter_data: {}, main_post_filter_data: { view_by: 'Item', display_type: 'Gallery', page:1, total_page:1, list_row: 10, kw: '', top_category_id: 0, //椤剁骇鍒嗙被id锛岀敤浜庡乏渚у鑸爮鐨勭瓫閫� }, post_filter_data: { attr:{}, collect:{val:0}, //鏀惰棌绛涢€� }, list_sort: {}, //with user set sort field order list_sort_order: [], //filter template filter_template_list: { }, show_filter_template_flag: false, show_save_filter_flag: false, //add vendor new_vendor_info: { vendor_no: '' }, vendor_selected: 0, vendor_selected_text: 'All Vendors', upload_cfg: { gateway: pim_api.URL_UPLOAD, key: 'file', showButton: false, allowRemove: false, allowRotate: false }, //column set column_set_group_id:-1, column_set_kw:'', //excel set excel_set_group_id:-1, excel_set_kw:'', excel_tpl_type:'user', //comment // comment_sort:'desc', comment_category_show:false, comment_category_flow_id:-1, comment_list:{ total_unread_num:0, data:{} }, //add new element category_list: [], category_tree: {}, new_element_type: 0, //gallery gallery_data: [], gallery_obj_index: 0, gallery_current_src: '', main_nav_swiper: null, item_nav_swiper: null, collect_item_num: 0, //鍒嗛〉 page_config: { page: 0, total_page: 1, list_row: 20, prev: false, next: false, page_list: [ 1 ] }, //copy item copy_item_data: { 'id' : 0, 'no' : '', }, // 鏄剧ず鐨刬tem data correlation current_item_correlations : [], current_item_correlation_items : [], current_item_correlation_attributes : [], current_item_correlation_id : 0, index : false, flag_discussion_show : false, //discussion鏄剧ず discussions : [], //discussion鍒楄〃 flag_show_comment : false, //discussion鍒楄〃杩樻槸comment鍒楄〃 comment_tree : [], //comment鍒楄〃 discussion_sort : false, //discussion鎺掑簭 false => asc, true => desc comment_sort : false, //comment鎺掑簭 false => asc, true => desc current_discussion : {}, //褰撳墠閫変腑鐨刣iscussion flag_discussion_expand : false, //鏄惁灞曞紑 discussion_data : { topic : '', comment : '', high_priority : false, upload_file : [], discussion_type : 0, }, comment_data : { parent_id : 0, top_comment_id : 0, comment : '', high_priority : 0, upload_file : [], }, //item images card_image_expand : 0, check_all_fields : false, image_fields : [], image_list : [], image_date_list : [], image_vendors : [], image_dimension_attributes : [], image_field_checkbox : [], image_vendor_checkbox : {}, image_checkbox : [], max_image_date_rows : 6, flow_version_flow_index : 0, flow_version_vendor_item_id : 0, flow_version_vendor_item : {}, flow_version_list : [], flow_version_index : -1, flow_version_value : {}, flow_version_show_num : 6, }, mounted: function () { let that = this; if(typeof is_mobile != 'undefined' && is_mobile==1) { that.is_mobile = 1; } else { if(/*$(window).width()<1320 || */navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)) { that.is_mobile = 1; } else { that.is_mobile = 0; } } $.ajaxSettings.async = false; that.auto_list(); $.ajaxSettings.async = true; //鍒濆鍖杋tem璇︽儏椤电殑鏁版嵁 that.init_item_detail(); that.confirm_correlation_role = confirm_correlation_role == '1' ? true : false; //鍒濆鍖杁iscussion 2021 10 29 Discussion1鐗堝厛涓嶇敤锛屽睆钄界浉鍏虫搷浣� // that.flag_discussion_show = that.get_cookie('detail_flag_discussion_show') ? that.get_cookie('detail_flag_discussion_show') == 'true' ? true : false : false; // that.init_discussion(item_id); }, updated: function () { }, watch : { filter_data: { handler(newVal, oldVal){ let that = this; $.each(newVal.user_filter, function(k, v) { if (!that.post_filter_data.attr.hasOwnProperty(v)) { if (['7', '8', '16', '17'].indexOf(that.autolist.attribute[v].type_id) != -1) { that.$set(that.post_filter_data.attr, v, { val : [], title : [] }) } else { that.$set(that.post_filter_data.attr, v, { val : '', title : '' }) } } }) }, deep:true //true 娣卞害鐩戝惉 }, // item images image_field_checkbox: { handler(newVal, oldVal){ let that = this; that.$nextTick(function () { $.each(that.image_date_list, function (k, image_date) { let is_data_show = 0; $.each(image_date.images, function (kk, image) { let is_no_show = false; $.each(that.image_vendor_checkbox, function (attr_id, v) { is_no_show = is_no_show || (v.length > 0 && (v.indexOf(image.dimensions[attr_id]) == -1)); }) console.log(is_no_show); image.is_show = !is_no_show && (that.image_field_checkbox.length == 0 || that.image_field_checkbox.indexOf(image.field) != -1) is_data_show += (image.is_show ? 1 : 0); }) image_date.is_show = is_data_show > 0 ? true : false; }) }) that.image_checkbox = []; }, deep:true //true 娣卞害鐩戝惉 }, image_vendor_checkbox: { handler(newVal, oldVal){ let that = this; that.$nextTick(function () { $.each(that.image_date_list, function (k, image_date) { let is_data_show = 0; $.each(image_date.images, function (kk, image) { let is_no_show = false; $.each(that.image_vendor_checkbox, function (attr_id, v) { is_no_show = is_no_show || (v.length > 0 && (v.indexOf(image.dimensions[attr_id]) == -1)); }) image.is_show = !is_no_show && (that.image_field_checkbox.length == 0 || that.image_field_checkbox.indexOf(image.field) != -1) is_data_show += (image.is_show ? 1 : 0); }) image_date.is_show = is_data_show > 0 ? true : false; }) }) that.image_checkbox = []; }, deep:true //true 娣卞害鐩戝惉 }, check_all_fields : { handler(newVal, oldVal){ let that = this; that.$nextTick(function () { if (newVal) { $.each(that.image_fields, function (k, v) { if ($.inArray(v.key, that.image_field_checkbox) == -1) { that.image_field_checkbox.push(v.key) } }); } else { that.image_field_checkbox = []; } that.image_checkbox = []; }) }, deep:true //true 娣卞害鐩戝惉 } }, computed: { show_export_button: { get: function () { /*let is_filter = 0; $.each(this.post_filter_data, function(fk, fv) { if(fk == 'attr') { if(fv.length>0) { is_filter = 1; return; } } else { if(fv.val.length>0) { is_filter = 1; return; } } }); if(is_filter || this.main_post_filter_data.kw!='') { this.flag_show_export_button = true; } else { this.flag_show_export_button = false; }*/ return this.flag_show_export_button; }, set: function (v) { this.flag_show_export_button = v; } }, cms_style: { get: function () { if (typeof this.item_flow.category != 'undefined' && this.item_flow.category.is_cms == 1) { return {background : 'white'}; } return {}; } } }, methods: { init_item_detail : function () { let that = this; that.comment_category_flow_id=-1; if(that.current_op_index==2){ that.comment_category_show=true; }else{ that.comment_category_show=false; } if(that.is_mobile) { that.comment_category_show = false; } that.main_tab_type = 0; //that.flag_show_item = false; that.flag_show_item_detail = true; that.flag_show_overview = true; that.flag_show_result = false; that.item_detail_show(0); //鏄剧ずitem璇︽儏 that.item_image(); //鏄剧ずitem images // that.get_complete(); // that.get_complete_list(); //鐢熸垚宸︿晶瀵艰埅鏍� let post_data = { subject_id: 'item|' + item_id, } ajax(pim_api.URL_ITEM_FLOWTREE, post_data).then(function (res) { that.flowtree = res.data; that.$nextTick(function () { setTimeout(function () { $($('.panel-l .menu-list li .d-firstNav')[0]).trigger('click'); }, 100); }) }, function (res) {}).then(function (resolve) { }).catch(function () { console.log(e) }); }, get_complete: function (params) { let that = this; let post_data = {}; post_data = { subject_id: that.main_tab_obj.get_current().id, vendor_id: that.vendor_selected }; if(params) { post_data = $.extend(post_data, params); } ajax(pim_api.URL_ITEM_COMPLETION, post_data).then(function (res) { if(res.status == 1) { that.item_completion = res.data.completion; return new Promise(function (resolve, reject) { resolve(that.item_completion); }); } }, function (res) { }).then(function (res) { if(document.querySelector('.operation span.chart')) { new EasyPieChart(document.querySelector('.operation span.chart'), { easing: 'easeOutElastic', delay: 3000, barColor: '#8ecef4', trackColor: '#f1f1f1', scaleColor: false, lineWidth: 3, trackWidth: 3, lineCap: 'butt', onStep: function (from, to, percent) { this.el.children[0].innerHTML = Math.round(percent); } }); } }, function () {}); }, get_complete_list: function () { let that = this; let current_main_tab = that.main_tab_obj.get_current(); let post_data = {}; post_data = { subject_id: current_main_tab.id, vendor_id: that.vendor_selected }; ajax(pim_api.URL_ITEM_COMPLETION_LIST, post_data).then(function (res) { that.item_completion_list = res.data.complete_list; return new Promise(function (resolve, reject) { resolve(that.item_completion_list); }); }, function (res) {}).then(function (resolve) { that.get_comment_list(); ajax(pim_api.URL_ITEM_FLOWTREE, post_data).then(function (res) { that.flowtree = res.data; }, function (res) {}).then(function (resolve) { }).catch(function () { console.log(e) }); }); }, firstNav_click: function () { let e = $(event.target).closest('.d-firstNav'); event.stopPropagation(); dropSwift(e, '.d-firstDrop'); let p = e.parent(); p.parent().find('.selected').removeClass('selected'); p.addClass('selected'); // 婊氬姩鍙充晶椤甸潰 let child = $(event.target).closest('.row').data('child'); let target = $(event.target).closest('.row').data('target'); if (target) { if (target == '.card-overview') { $('.panel-r .card').hide(); $('.panel-r .card-overview').show(); } else { $('.panel-r .card').show(); //$('.panel-r .card-overview').hide(); } if (child == 0) { scrollTo('.panel-r.slimscroll', target); } } }, secondNav_click: function () { let e = $(event.target).closest('.d-secondNav'); event.stopPropagation(); dropSwift(e, '.d-secondDrop'); let p = e.parent(); p.parent().find('.cur').removeClass('cur'); p.addClass('cur'); // 婊氬姩鍙充晶椤甸潰 let target = $(event.target).closest('.second-row').data('target'); if (target) { scrollTo('.panel-r.slimscroll', target); } }, item_detail_show: function (index = 0) { //鐩存帴鏄剧ず璇︽儏椤电殑鏁版嵁 let that = this; let post_data = { item_id : item_id, } load = layer.load(); that.item_flow = []; ajax(that.item_tab[index].url_content, post_data).then(function (res) { // NProgress.done(); layer.close(load); if (res.status == 1) { that.$set(that, 'flow_data', res.data.flow_data) that.$set(that, 'overview_flow_data', res.data.overview_flow_data) that.$set(that, 'overview_vendor_flow_data', res.data.overview_vendor_flow_data) that.$set(that, 'item_correlation', res.data.item_correlation) that.$set(that, 'item_correlation_attribute_tree', res.data.item_correlation_attribute_tree) that.$set(that, 'item_value', res.data.item_value) that.$set(that, 'vendor_list', res.data.vendor) that.$set(that, 'vendor_value', res.data.vendor_value) that.$set(that, 'item_flow', res.data.item) that.$set(that, 'dimension_attributes', res.data.item.category.dimension_attributes) that.format_field_val(); that.$nextTick(function () { refresh_event(); }) return new Promise(function (resolve, reject) { resolve(res.data); }); } else { layer.msg(res.info); } }, function (res) { layer.close(load); layer.msg(res.info); }).then(function (res) { that.flag_show_overview = true; that.flag_show_flow_detail = false; }, function (res) { }); }, format_field_val: function () { let that = this; let item_value_tmp = {}; let tmp = {}; let val = {}; let correlation_attr = {}; if (that.vendor_list.length > 0 && that.current_item_vendor_id == 0) { that.current_item_vendor_id = that.vendor_list[0].id; } if (that.overview_flow_data.length > 0) { that.current_overview_item_vendor_id = 0; } if (that.vendor_list.length > 0 && that.overview_flow_data.length == 0 && that.overview_vendor_flow_data.length > 0 && that.current_overview_item_vendor_id == 0) { that.current_overview_item_vendor_id = that.vendor_list[0].id; } $.each(that.flow_data, function (ak, av) { if (!av.hasOwnProperty('flag_flow_detail_op_style')) { that.$set(av, 'current_item_vendor_id', 0); that.$set(av, 'flag_flow_comment_show', 0); that.$set(av, 'flow_comment_sort', 'DESC'); that.$set(av, 'comments', {init : 0, list : [], total : 0}); //鐢ㄤ簬榛樿鏄剧ず that.$set(av, 'flag_flow_detail_op_style', 1); that.$set(av, 'flag_flow_detail_expand', 0); that.$set(av, 'upload_cfg', { gateway: pim_api.URL_UPLOAD, key: 'file', showButton: false, allowRemove: false, allowRotate: false }); //鐢ㄤ簬flow 鏄剧ず that.$set(av, 0, {}); that.$set(av[0], 'flag_flow_detail_op_style', 1); that.$set(av[0], 'upload_cfg', { gateway: pim_api.URL_UPLOAD, key: 'file', showButton: false, allowRemove: false, allowRotate: false }); correlation_attr = that.item_correlation_attribute_tree[0] ? (that.item_correlation_attribute_tree[0][av.category_flow_id] ? that.item_correlation_attribute_tree[0][av.category_flow_id] : []) : []; that.$set(av[0], 'correlation_attr', correlation_attr); //鐢ㄦ埛vendor flow 鏄剧ず $.each(that.vendor_list, function(index, vendor_item) { that.$set(av, vendor_item.id, {}); that.$set(av[vendor_item.id], 'flag_flow_detail_op_style', 1); that.$set(av[vendor_item.id], 'upload_cfg', { gateway: pim_api.URL_UPLOAD, key: 'file', showButton: false, allowRemove: false, allowRotate: false }); correlation_attr = that.item_correlation_attribute_tree[vendor_item.id] ? (that.item_correlation_attribute_tree[vendor_item.id][av.category_flow_id] ? that.item_correlation_attribute_tree[vendor_item.id][av.category_flow_id] : []) : []; that.$set(av[vendor_item.id], 'correlation_attr', correlation_attr); }); } if (!tmp[av.category_flow_id] && tmp[av.category_flow_id] != {}) { tmp[av.category_flow_id] = {} }; $.each(av.groups, function (gk, gv) { $.each(gv.attrs, function (akk, avv) { //initial value for multi select value and dynamic multi select if(avv.type_id == 20) { $.each(avv.child_attr, function (elk, el) { let el_val = ''; if($.inArray(el.type_id, ['8', '10', '16'])!=-1) { el_val = []; } // tmp[av.category_flow_id][el.id] = { // val: el_val, // type_id: el.type_id // }; }); tmp[av.category_flow_id][avv.id] = { val: [], type_id: avv.type_id, set: [] }; } else { let val = ''; if($.inArray(avv.type_id, ['8', '10', '16', '23'])!=-1) { val = []; } tmp[av.category_flow_id][avv.id] = { val: val, type_id: avv.type_id }; } }); }) }); $.each(that.overview_flow_data, function (ak, av) { that.$set(av, 0, {}); that.$set(av[0], 'flag_flow_detail_op_style', 1); that.$set(av[0], 'flag_flow_detail_expand', 0); that.$set(av[0], 'upload_cfg', { gateway: pim_api.URL_UPLOAD, key: 'file', showButton: false, allowRemove: false, allowRotate: false }); correlation_attr = that.item_correlation_attribute_tree[0] ? (that.item_correlation_attribute_tree[0][av.category_flow_id] ? that.item_correlation_attribute_tree[0][av.category_flow_id] : []) : []; that.$set(av[0], 'correlation_attr', correlation_attr); }); $.each(that.overview_vendor_flow_data, function (ak, av) { //鐢ㄦ埛vendor flow 鏄剧ず $.each(that.vendor_list, function(index, vendor_item) { that.$set(av, vendor_item.id, {}); that.$set(av[vendor_item.id], 'flag_flow_detail_op_style', 1); that.$set(av[vendor_item.id], 'flag_flow_detail_expand', 0); that.$set(av[vendor_item.id], 'upload_cfg', { gateway: pim_api.URL_UPLOAD, key: 'file', showButton: false, allowRemove: false, allowRotate: false }); correlation_attr = that.item_correlation_attribute_tree[vendor_item.id] ? (that.item_correlation_attribute_tree[vendor_item.id][av.category_flow_id] ? that.item_correlation_attribute_tree[vendor_item.id][av.category_flow_id] : []) : []; that.$set(av[vendor_item.id], 'correlation_attr', correlation_attr); }); }); val = JSON.parse(JSON.stringify(tmp)); $.each(tmp, function (cate_flow_id, item) { $.each(item, function (ak, av) { if(typeof that.item_value[cate_flow_id] != 'undefined' && typeof that.item_value[cate_flow_id][ak] != 'undefined') { val[cate_flow_id][ak] = that.item_value[cate_flow_id][ak]; } if (that.item_correlation_attribute_tree[0] && that.item_correlation_attribute_tree[0][cate_flow_id] && that.item_correlation_attribute_tree[0][cate_flow_id][ak]) { if (that.item_correlation_attribute_tree[0][cate_flow_id][ak].status == 0 && (!val[cate_flow_id][ak] || !val[cate_flow_id][ak].val || val[cate_flow_id][ak].val.length == 0)) { if($.inArray(that.autolist.attribute[ak].type_id, ['8', '10', '16', '23'])!=-1 && that.item_correlation[that.item_correlation_attribute_tree[0][cate_flow_id][ak].item_correlation_id].value == '') { that.item_correlation[that.item_correlation_attribute_tree[0][cate_flow_id][ak].item_correlation_id].value = []; } val[cate_flow_id][ak].val = that.item_correlation[that.item_correlation_attribute_tree[0][cate_flow_id][ak].item_correlation_id].value } } if (av.type_id == 20) { //set if (val[cate_flow_id][ak].set != undefined) { $.each(val[cate_flow_id][ak].set, function (set_line, set_arr) { $.each(set_arr, function (set_k, set_v) { val[cate_flow_id][set_v.attr.id] = set_v; }); }) } else { val[cate_flow_id][ak].val = []; val[cate_flow_id][ak].set = []; val[cate_flow_id][ak].type_id = 20; } } else if (av.type_id == 24) { val[cate_flow_id][ak].display_val = display_tinymce(val[cate_flow_id][ak].val); } }) }); item_value_tmp[0] = val; $.each(that.vendor_list, function(index, vendor_item) { val = JSON.parse(JSON.stringify(tmp)); $.each(tmp, function (cate_flow_id, item) { $.each(item, function (ak, av) { if(typeof that.vendor_value[vendor_item.id][cate_flow_id] != 'undefined' && typeof that.vendor_value[vendor_item.id][cate_flow_id][ak] != 'undefined') { val[cate_flow_id][ak] = that.vendor_value[vendor_item.id][cate_flow_id][ak]; } if (that.item_correlation_attribute_tree[vendor_item.id] && that.item_correlation_attribute_tree[vendor_item.id][cate_flow_id] && that.item_correlation_attribute_tree[vendor_item.id][cate_flow_id][ak]) { if (that.item_correlation_attribute_tree[vendor_item.id][cate_flow_id][ak].status == 0 && (!val[cate_flow_id][ak] || !val[cate_flow_id][ak].val || val[cate_flow_id][ak].val.length == 0)) { if($.inArray(that.autolist.attribute[ak].type_id, ['8', '10', '16', '23'])!=-1 && that.item_correlation[that.item_correlation_attribute_tree[vendor_item.id][cate_flow_id][ak].item_correlation_id].value == '') { that.item_correlation[that.item_correlation_attribute_tree[vendor_item.id][cate_flow_id][ak].item_correlation_id].value = []; } val[cate_flow_id][ak].val = that.item_correlation[that.item_correlation_attribute_tree[vendor_item.id][cate_flow_id][ak].item_correlation_id].value } } if (av.type_id == 20) { //set if (val[cate_flow_id][ak].set != undefined) { $.each(val[cate_flow_id][ak].set, function (set_line, set_arr) { $.each(set_arr, function (set_k, set_v) { val[cate_flow_id][set_v.attr.id] = set_v; }); }) } else { val[cate_flow_id][ak].val = []; val[cate_flow_id][ak].set = []; val[cate_flow_id][ak].type_id = 20; } } else if (av.type_id == 24) { val[cate_flow_id][ak].display_val = display_tinymce(val[cate_flow_id][ak].val); } }) }); item_value_tmp[vendor_item.id] = val; }) that.item_value = item_value_tmp; $.extend(true, that.item_value_cp, that.item_value); }, handle_operate: function () { let that = this; let e = $(event.target); let index = $(e).closest('li').index(); if(that.is_mobile) { index = $(e).closest('span').index(); if(index==0) { that.flag_show_comment_box = false; if(that.current_op_index==0) { that.current_op_index = -1; that.flag_show_flow_tree = false; } else { that.current_op_index = 0; that.flag_show_flow_tree = true; } } else if(index==1) { that.flag_show_flow_tree = false; if(that.current_op_index==1) { that.current_op_index = -1; that.flag_show_comment_box = false; } else { that.current_op_index = 1; that.flag_show_comment_box = true; } } } else { if(index==2 && that.current_op_index==2){ that.current_op_index = 1; }else{ that.current_op_index = index; } that.op_switch = 1; if(that.current_op_index==2){ that.comment_category_show=true; }else{ that.comment_category_show=false; } if(that.op_switch){ $('.overview-content .comment-box').removeClass('w1'); }else{ $('.overview-content .comment-box').addClass('w1'); } } //$.extend(true, that.flow_attr_val_cp, that.flow_attr_val); that.$nextTick(function () { that.init_multi_select(); }) }, handle_switch: function () { let that = this; let e = $(event.target); that.op_switch = !that.op_switch; if(that.op_switch){ $('.overview-content .comment-box').removeClass('w1'); }else{ $('.overview-content .comment-box').addClass('w1'); } }, load_item_flow: function () { return; let that = this; let e = $(event.target); if($(e).closest('li').attr('data-child_count') > 0) { return; } let data = { id: 'flow|'+e.attr('data-category_flow_id'), item_flow_id: e.attr('data-item_flow_id'), category_flow_id: e.attr('data-category_flow_id'), text: e.attr('data-text'), url_content: pim_api.URL_FLOW_DETAIL, remove: true, type: e.attr('data-type'), }; let index = that.item_tab_obj.add(data); if(that.is_mobile) { that.init_more_nav_el('.tab-swiper2'); } //that.item_tab_obj.remove_diff_type($(e).data('type')); }, edit_flow_detail: function (flow_index, item_vendor_id) { let that = this; let e = $(event.target); if (that.flow_data[flow_index][item_vendor_id].flag_flow_detail_op_style == 2) { that.$set(that.flow_data[flow_index][item_vendor_id], 'flag_flow_detail_op_style', 1); that.$set(that.flow_data[flow_index][item_vendor_id].upload_cfg, 'showButton', false); that.$set(that.flow_data[flow_index][item_vendor_id].upload_cfg, 'allowRemove', false); } else { that.$set(that.flow_data[flow_index][item_vendor_id], 'flag_flow_detail_op_style', 2); that.$set(that.flow_data[flow_index][item_vendor_id].upload_cfg, 'showButton', true); that.$set(that.flow_data[flow_index][item_vendor_id].upload_cfg, 'allowRemove', true); } //$.extend(true, that.flow_attr_val_cp, that.flow_attr_val); that.$nextTick(function () { that.init_multi_select(); }) }, save_flow_detail: function (flow_index, category_flow_id, item_vendor_id) { let that = this; let e = $(event.target); let item_value = {}; item_value[item_vendor_id] = that.item_value[item_vendor_id][category_flow_id]; if (item_vendor_id !=0) { //flow 閲岄潰鍙兘鏈塿endor瀛楁鍜岄潪vendor瀛楁 item_value[0] = that.item_value[0][category_flow_id]; } // let post_data = $(e).closest('form').serializeArray()+'&attr_info='+JSON.stringify(item_value); let form_data = $(e).closest('form').serializeArray(); var post_data = {}; $.each(form_data,function(i,v){ post_data[v.name] = v.value; }) post_data['attr_info'] = JSON.stringify(item_value); let layer_index = layer.load(); ajax(pim_api.URL_SAVE_FLOW_DETAIL, post_data).then(function (res) { layer.close(layer_index); show_success_modal(function () { that.item_detail_show(0); }) }, function (res) { layer.close(layer_index); layer.msg(res.info); }); }, edit_overview_detail: function (type, item_vendor_id) { let that = this; if (type == 'item') { if (that.overview_flow_data[0][item_vendor_id].flag_flow_detail_op_style == 2) { that.$set(that.overview_flow_data[0][item_vendor_id], 'flag_flow_detail_op_style', 1); that.$set(that.overview_flow_data[0][item_vendor_id].upload_cfg, 'showButton', false); that.$set(that.overview_flow_data[0][item_vendor_id].upload_cfg, 'allowRemove', false); } else { that.$set(that.overview_flow_data[0][item_vendor_id], 'flag_flow_detail_op_style', 2); that.$set(that.overview_flow_data[0][item_vendor_id].upload_cfg, 'showButton', true); that.$set(that.overview_flow_data[0][item_vendor_id].upload_cfg, 'allowRemove', true); } } else { if (that.overview_vendor_flow_data[0][item_vendor_id].flag_flow_detail_op_style == 2) { that.$set(that.overview_vendor_flow_data[0][item_vendor_id], 'flag_flow_detail_op_style', 1); that.$set(that.overview_vendor_flow_data[0][item_vendor_id].upload_cfg, 'showButton', false); that.$set(that.overview_vendor_flow_data[0][item_vendor_id].upload_cfg, 'allowRemove', false); } else { that.$set(that.overview_vendor_flow_data[0][item_vendor_id], 'flag_flow_detail_op_style', 2); that.$set(that.overview_vendor_flow_data[0][item_vendor_id].upload_cfg, 'showButton', true); that.$set(that.overview_vendor_flow_data[0][item_vendor_id].upload_cfg, 'allowRemove', true); } } //$.extend(true, that.flow_attr_val_cp, that.flow_attr_val); that.$nextTick(function () { that.init_multi_select(); }) if(that.is_mobile) { refresh_event(); } }, save_overview_detail: function (type, item_vendor_id) { let that = this; let e = $(event.target); let item_value = {}; if (type == 'item') { $.each(that.overview_flow_data, function (flow_index, flow_data) { if (flow_data.can_edit == 1) { item_value[flow_data.category_flow_id] = that.item_value[item_vendor_id][flow_data.category_flow_id] } }) } else { $.each(that.overview_vendor_flow_data, function (flow_index, flow_data) { if (flow_data.can_edit == 1) { item_value[flow_data.category_flow_id] = that.item_value[item_vendor_id][flow_data.category_flow_id] } }) } let form_data = $(e).closest('form').serializeArray(); var post_data = {}; $.each(form_data,function(i,v){ post_data[v.name] = v.value; }) post_data.attr_info = JSON.stringify(item_value); let layer_index = layer.load(); ajax(pim_api.URL_SAVE_OVERVIEW_DETAIL, post_data).then(function (res) { layer.close(layer_index); show_success_modal(function () { that.item_detail_show(0); }) }, function (res) { layer.close(layer_index); layer.msg(res.info); }); }, remove_main_tab: function () { let that = this; let e = $(event.target); let index = $(e).closest('.tab_el').index(); let eid = $(e).closest('.tab_el').attr('id'); let current_index = that.main_tab_obj.current_index(); that.main_tab_obj.remove(index); if(index == current_index) { that.current_main_tab_index = that.main_tab_obj.get_length()-1; that.main_tab_obj.set_current_index(that.main_tab_obj.get_length()-1); that.main_tab_obj.trigger(that.main_tab_obj.get_length()-1); } else if(index < current_index) { that.current_main_tab_index = current_index - 1; that.main_tab_obj.set_current_index(current_index-1); } else { } item_tab_arr[eid] = null; if(that.is_mobile) { that.init_more_nav_el('.tab-swiper'); } }, remove_item_tab: function () { let that = this; let e = $(event.target); let index = $(e).closest('.tab_el').index(); let current_index = that.item_tab_obj.current_index(); that.item_tab_obj.remove(index); if(index == current_index) { that.current_item_tab_index = that.item_tab_obj.get_length()-1; that.item_tab_obj.set_current_index(that.item_tab_obj.get_length()-1); that.item_tab_obj.trigger(that.item_tab_obj.get_length()-1); } else if(index < current_index) { that.current_item_tab_index = current_index - 1; that.item_tab_obj.set_current_index(current_index-1); } else { } if(that.is_mobile) { that.init_more_nav_el('.tab-swiper2'); } }, show_filter: function () { let that = this; that.flag_show_filter = true; }, show_filter_choose: function (key) { let that = this; let e = $(event.target).closest('.filter-criteria-selector'); let filter_attr = $('.choose-area,.match-area'); let choose_group = $('.choose-area.filter-' + key); // 鍙充晶寮瑰嚭閫夋嫨鑿滃崟 let match_group = e.find('.match-area'); if (e.hasClass('cur')) { e.removeClass('cur'); filter_attr.hide(); match_group.prev().show(); } else { $('.filter-criteria-selector.cur .match-area').prev().show(); e.addClass('cur').siblings().removeClass('cur'); filter_attr.hide(); choose_group.show(); match_group.show(); match_group.prev().hide(); e.find('.btn-choose') .addClass('close-choose') .one('click', function () { e.removeClass('cur'); }); } }, set_filter_data: function (type, event) { let that = this; let e = $(event.target); if(type == 1) { that.main_post_filter_data.view_by = $(e).closest('.item').data('value'); //table list $('tr.list_attr_val_full').hide(); $('td.switch-btn').removeClass('cur selected'); $('td.switch-btn .hollow-arrow').removeClass('up'); if(that.is_mobile) { that.flag_show_filter = false; } } else if(type == 2) { //鍒囨崲鍒楄〃瑙嗗浘 $('#show_tab').hide(); that.main_post_filter_data.display_type = $(e).closest('li').data('value'); return; } else if(type == 3) { let ul = $(e).closest('.multiselect-menu').find('.filter_list'); if(that.is_mobile) { ul = $(e).closest('#filter-box').find('.filter_list'); } that.flag_filter_shadow_div = false; var name = $(e).data('name'); var title = []; var value = []; ul.find(':checkbox:checked').each(function(i,v){ //if($(this).val() == -1) return; title.push($(this).data('title')); value.push($(this).val()); }); that.$set(that.post_filter_data, name, { 'val': value, 'title': title }); if(that.is_mobile) { that.flag_show_filter = false; } else { $(e).closest('.multiselect-menu').hide(); } } else if(type == 4) { //鎼滅储 // var kw = $(e).closest('div.search').find('input').val(); // that.main_post_filter_data.kw = kw; } else if(type == 5) { //attr select let ul = $(e).closest('.choose-area').find('.filter_list'); var name = $(e).data('name'); var value = []; var title = []; ul.find(':checkbox:checked').each(function(i,v){ value.push($(this).val()); title.push($(this).data('title')); }); that.$set(that.post_filter_data['attr'], name, { 'val': value, 'title': title }); $('.filter-criteria-selector.filter-selector-' + name).trigger('click'); // $(e).closest('.choose-area').prev('.filter-criteria-selector').trigger('click'); } else if(type == 6) { //attr range let ul = $(e).closest('ul'); that.$set(that.post_filter_data['attr'], ul.data('name'), { 'from': ul.find('.data_from').val(), 'to': ul.find('.data_to').val() }); $(e).closest('.menu').hide(); }else if(type == 7) { //attr value let ul = $(e).closest('.match-area'); var name = $(e).data('name'); that.$set(that.post_filter_data['attr'], name, { 'val': ul.find('input.field').val(), 'condition': ul.find('.select-box dt').text() }); // ev.stopPropagation(); $(e).closest('.filter-criteria-selector').trigger('click'); } else if(type == 8) { //attr remove var name = $(e).data('name'); that.$set(that.post_filter_data['attr'], name, null); that.filter_data.user_filter.removeByValue(name); } else if(type == 9) { //that.post_filter_data = { // attr:{} //}; let main_filter_key = []; $.each(that.filter_data.main_filter, function (fk, fv) { main_filter_key.push(fv.name); }); $.each(that.post_filter_data.attr, function (p , v) { if(p == 'category_id' || main_filter_key.indexOf(p) != -1 || that.filter_data.default_filter.indexOf(p) != -1) { that.$set(that.post_filter_data.attr, p, { 'title': [], 'val': [], }); } else { that.$delete(that.post_filter_data.attr, p); } }) if(typeof that.filter_data.user_filter != 'undefined') { that.filter_data.user_filter = []; } } else if (type == 10) { //宸︿晶鑿滃崟閫夋嫨category => top_category_id that.main_post_filter_data.top_category_id = $(e).closest('li').attr('data-category-id'); } else if (type == 11) { //绛涢€夋敹钘廼tem鍒楄〃 that.post_filter_data.collect.val = 1 - that.post_filter_data.collect.val; } else if (type == 12) { //鍒犻櫎filter attr } else if (type == 13) { //宸︿晶鑿滃崟鍙栨秷閫夋嫨category that.main_post_filter_data.top_category_id = 0; } that.user_filter_set(); that.page_config.page = 0; //娓呯┖鍒楄〃 that.item_list = []; that.main_tab_obj.trigger(0); }, set_filter_page:function(){ let that = this; let index = that.main_tab_obj.current_index(); that.main_tab_obj.trigger(index); }, user_filter_set:function(){ let that = this; ajax(pim_api.URL_FILTER_SET, {attr_id : that.filter_data.user_filter}).then(function (res) { if(res.status==1){ $('#filter_set_box').hide(); that.$nextTick(function () { refresh_event(); }); that.flag_show_filter_set=false; }else{ layer.msg(res.info); } }, function(res) { }); }, hide_shadow_div: function () { let that = this; that.flag_shadow_div = false; that.flag_show_nav = false; that.flag_close_btn = false; that.flag_add_new_element = false; that.flag_create_items_element = false; that.flag_data_revision_element = false; that.flag_flow_data_revision_element = false; that.flag_copy_item_element = false; that.flag_show_multi_item_no = false; that.flag_show_multi_group_no = false; that.flag_show_data_dimension = false; that.flag_add_flow_version_element = false; that.flag_show_flow_version_element = false; if(that.is_mobile) { if(that.flag_related_items_add) { that.flag_related_items_add = false; that.flag_show_related_items = true; that.flag_shadow_div = true; that.flag_close_btn = true; that.flag_show_container = false; } else { that.flag_show_related_items = false; that.flag_show_container = true; } } else { that.flag_show_container = true; that.flag_show_gallery = false; } }, hide_filter_shadow_div: function () { let that = this; that.flag_filter_shadow_div = false; $('.multiselect-menu').hide() if(that.is_mobile) { } else { that.flag_show_container = true; that.flag_show_gallery = false; } }, init_select_category_tree: function() { let that = this; ajax(pim_api.URL_GET_CATEGORY_TREE, {}).then(function (res) { that.$set(that.category_list, 'category', res.data); that.$set(that.category_list, 'sub_category', []); }); }, change_sub_category: function (category_id) { let that = this; if (that.category_list.category[`${category_id}`] !== undefined && that.category_list.category[`${category_id}`].sub !== undefined) { that.$set(that.category_list, 'sub_category', (that.category_list.category[`${category_id}`].sub)); } else { that.$set(that.category_list, 'sub_category', []); } let sub_category = $(event.target).closest(".select-box").parent('li').next().find('.select-box'); that.$nextTick(function () { refresh_event(); reset_select(sub_category); }); }, close_all_tabs: function () { let that = this; that.item_tab_obj.remove_all(); }, close_right_tabs: function () { let that = this; that.item_tab_obj.remove_all_right(); }, quick_goto: function () { let that = this; let e = $(event.target); if($(e).data('type') == 1) { if(that.is_mobile) { $(e).closest('.item').find('.photo img').click(); } else { $(e).closest('.item').find('.photo').click(); } let count = setInterval(function () { if(that.flag_show_item_detail) { $('#vendor_list .hd .btn').click(); clearInterval(count); } }, 100); } else if($(e).data('type') == 2) { if(that.is_mobile) { $(e).closest('.item').find('.photo img').click(); let count = setInterval(function () { if(that.flag_show_item_detail) { $('#btn_show_related_items').click(); clearInterval(count); } }, 100); let count2 = setInterval(function () { let obj = $('.related-items').find('[data-item_id='+$(e).data('item_id')+']'); if(that.flag_show_related_items && obj[0]) { obj.click(); clearInterval(count2); } }, 100); } else { $(e).closest('.item').find('.photo').click(); let count = setInterval(function () { let obj = $('.related-items').find('[data-item_id='+$(e).data('item_id')+']'); if(that.flag_show_related_items && obj[0]) { obj.click(); clearInterval(count); } }, 100); } } }, click_top_category: function () { let that = this; let e = $(event.target).closest('li'); if (e.hasClass('selected')) { let category_id = e.attr('data-category-id'); that.post_filter_data.attr.category_id = {val : [], title : []}; that.set_filter_data(13, event); 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) { that.$set(that.sub_category_list, id, cate); } }); } }) } else { let category_id = e.attr('data-category-id'); that.post_filter_data.attr.category_id = {val : [], title : []}; that.set_filter_data(10, event); that.sub_category_list = (that.autolist.sub_category[`${category_id}`] && that.autolist.sub_category[`${category_id}`]['list'] != undefined) ? that.autolist.sub_category[`${category_id}`]['list'] : []; } $('#sub_category_filter .group li').removeClass('selected'); $('#sub_category_filter .group :checkbox').each(function () { $(this).prop('checked', false); }) return; }, change_import_file: function(event) { let that = this; let e = $(event.target); let files = event.target.files; let file_arr = files[0].name.split('.') e.parent().next().find('.name .pre').html(file_arr[0]); e.parent().next().find('.name .pos').html('.' + file_arr[1]); e.parent().next().find('.file-size').html(getfilesize(files[0].size) + "KB"); e.parent().next().find('.rows').show(); }, del_import_file: function(event) { let e = $(event.target); e.closest('.rows').hide(); e.closest('.popup-box').find('input[type=file]').val([]); }, show_flow_data_revision_modal: function () { let that = this; that.flag_flow_data_revision_element = true; if(that.is_mobile) { that.flag_show_result = false; that.flag_show_main_tab = false; } else { that.flag_shadow_div = true; that.flag_close_btn = true; } $('#flow-data-revision').show(); }, flow_data_revision_import: function () { let that = this; let e = $('#flow-data-revision').find("input[type=file]")[0]; let files = e.files; if (files.length < 1) { layer.msg('Please Input File!'); return false; } var fd = new FormData(); fd.append("import_file", files[0]); fd.append("item_id", that.item_flow.id); $.ajax({ url: pim_api.URL_IMPORT_ITEM_FLOW_UPDATE, type:'POST', data:fd, processData:false, //tell jQuery not to process the data contentType: false, //tell jQuery not to set contentType dataType:'json', success:function (res) { if (res.status == 1) { that.flag_flow_data_revision_element = false; show_success_modal(function () { that.item_detail_show(0) }) } else { layer.msg(res.info); } }, error:function(){ layer.msg('system error'); } }) }, download_flow_excel: function () { let that = this; let e = $(event.target); let data = $(e).closest('form').serialize(); window.open(pim_api.URL_DOWNLOAD_FLOW_EXCEL + '?' + data, '_blank'); }, download_flow_zip: function () { let that = this; let e = $(event.target); let data = $(e).closest('form').serialize(); window.open(pim_api.URL_DOWNLOAD_FLOW_ZIP + '?' + data, '_blank'); }, confirm_flow_status: function (flow_index, item_vendor_id) { let that = this; if (that.flow_data[flow_index].confirm_status[item_vendor_id].confirm_status == 1) { return; } let e = $(event.target); let post_data = $(e).closest('form').serialize(); var layer_index = layer.load(1,{shade :0.3}); ajax(pim_api.URL_CONFIRM_FLOW_STATUS, post_data).then(function (res) { // layer.msg(res.info); layer.close(layer_index); show_success_modal(function () { that.$set(that.flow_data[flow_index].confirm_status[item_vendor_id], 'confirm_status', 1); }) }, function (res) { layer.msg(res.info); layer.close(layer_index); }); }, handle_column_sort: function (key) { let that = this; let e = $(event.target).closest('.sort'); e.children().removeClass('cur'); if (that.list_sort.hasOwnProperty(key)) { let sort = that.list_sort[key].sort; switch (sort) { case 'asc': sort = 'desc'; e.children().eq(1).addClass('cur'); break; case 'desc': sort = ''; break; default: sort = 'asc'; e.children().eq(0).addClass('cur'); break; } that.$set(that.list_sort[key], 'sort', sort) let del_k = -1; $.each(that.list_sort_order, function (k, v) { if (v.key == key) { if(sort == '') { del_k = k; } else { that.list_sort_order[k].sort = sort; } } }) if (del_k != -1) { that.list_sort_order.splice(del_k, 1); that.$delete(that.list_sort, key); } } else { let sort = { key : key, sort: 'asc', }; that.$set(that.list_sort, key, sort); that.list_sort_order.push(sort); e.children().eq(0).addClass('cur'); } that.set_filter_data(-1, event) // this.main_tab_obj.init(0); }, hidden_input: function() { let that = this; let e = $(event.target); e.closest(".select-box").prev().val(e.data('id')); }, show_img_list_detail: function() { let that = this; let e = $(event.target); if (e.closest(".item").find('.details').is(":hidden")) { e.closest(".item").find('.details').show(); } else { e.closest(".item").find('.details').hide(); } }, download_item_excel: function(id) { let that = this; let e = $(event.target); window.open(pim_api.URL_DOWNLOAD_ITEM_EXCEL + '?item_id=' + id, '_blank'); }, click_item_vendor_flow: function(item_vendor_id) { let that = this; let e = $(event.target); let old_scrollTop = document.querySelector('.panel-r.slimscroll').scrollTop; let old_offsetTop = e.closest('.card ')[0].offsetTop; that.current_item_vendor_id = item_vendor_id; that.$nextTick(function () { let offsetTop = e.closest('.card ')[0].offsetTop; scrollToOffset('.panel-r.slimscroll', old_scrollTop + offsetTop - old_offsetTop); }) return; }, click_overview_flow: function(item_vendor_id) { let that = this; that.current_overview_item_vendor_id = item_vendor_id; return; }, fast_search_item: function() { let that = this; that.flag_show_search_item_no = !that.flag_show_search_item_no; }, flow_expand: function(flow_index) { let that = this; that.$set(that.flow_data[flow_index], 'flag_flow_detail_expand', 1); }, flow_contract: function(flow_index) { let that = this; that.$set(that.flow_data[flow_index], 'flag_flow_detail_expand', 0); }, overview_expand: function(expand) { let that = this; that.flag_overview_expand = expand; }, show_data_correlation: function() { let that = this; let post = { item_id : that.item_flow.id }; ajax(pim_api.URL_GET_ITEM_CORRELATION, post).then(function (res) { that.current_item_correlations = res.data.correlations; that.current_item_correlation_items = res.data.items; that.current_item_correlation_id = 0; that.current_item_correlation_attributes = []; that.flag_show_item_relate_list = true; that.flag_show_data_correlation = true; that.flag_show_add_related_item = false; }, function (res) { layer.msg(res.info); return false; }); }, show_item_relate_list: function () { let that = this; that.flag_show_item_relate_list = true; }, quit_data_correlation: function () { let that = this; that.flag_show_data_correlation = false; }, select_data_correction: function(correlation_id) { let that = this; let e = $(event.target); that.current_item_correlation_id = correlation_id; that.current_item_correlation_attributes = that.current_item_correlations[correlation_id].items; that.flag_show_item_relate_list = false; }, add_related_item: function() { let that = this; let e = $(event.target); that.flag_show_add_related_item = true; }, del_item_correlation: function(item_id) { let that = this; let post = { item_aid : that.item_flow.id, item_bid : item_id, }; if(!window.confirm('Are you sure to delete?')) { return false; } ajax(pim_api.URL_DEL_CORRELATION_ITEM, post).then(function (res) { that.show_data_correlation(); }, function (res) { layer.msg(res.info); }); }, del_item_correlation_attribute: function(item_correlation_attribute_id, item_id, correlation_attr_index) { let that = this; let e = $(event.target); let post = { item_correlation_attribute_id : item_correlation_attribute_id }; if(!window.confirm('Are you sure to delete?')) { return false; } ajax(pim_api.URL_DEL_ITEM_CORRELATION_ATTRIBUTE, post).then(function (res) { that.current_item_correlation_attributes[item_id].splice(correlation_attr_index, 1); // if (that.current_item_correlation_attributes[item_id].length == 0) { // that.$delete(that.current_item_correlation_attributes, item_id); // } }, function (res) { layer.msg(res.info); }); }, download_item_relationship: function(item_id) { let that = this; window.open(pim_api.URL_DOWNLOAD_ITEM_RELATIONSHIP + '?item_id=' + item_id, '_blank'); }, filter_complete: function () { let that = this; let e = $(event.target); var val = e.val().toLowerCase(); var obj = e.closest('.choose-area').find('.filters-column li'); obj.hide(); obj.each(function(i,v){ if($(this).find('.txt').text()=='ALL' || $(this).find('.txt').text().toLowerCase().search(val)!=-1){ $(this).show(); } }); }, collapsed_flow_menu: function () { let that = this; let e = $(event.target); let btn = e.closest('.details-content').find('.ctrl-btn'); let menu = btn.next(); if (btn.hasClass('close')) { btn.removeClass('close').addClass('open'); menu.addClass('collapsed'); } else { btn.removeClass('open').addClass('close'); menu.removeClass('collapsed'); } }, show_vendor_val_list : function(item_id) { let that = this; let e = $(event.target); let vendor_item = $("[data-level=aa][item_id=" + item_id + "]"); if (e.hasClass('down')) { e.removeClass('down').addClass('up'); vendor_item.show(); } else { e.removeClass('up').addClass('down'); vendor_item.hide(); } }, push_to_pk : function(item_vendor_id) { let that = this let load = layer.load(); let post = { item_vendor_id : item_vendor_id, item_id : that.item_flow.id } ajax(pim_api.URL_PUSH_TO_PK, post).then(function (res) { layer.close(load); layer.msg(res.info); }, function (res) { layer.close(load); layer.msg(res.info); }); }, pull_ad : function(category_flow_id) { let that = this let load = layer.load(); let post = { category_flow_id : category_flow_id, item_id : that.item_flow.id } ajax(pim_api.URL_PULL_AD, post).then(function (res) { layer.close(load); layer.msg(res.info); that.item_detail_show(); }, function (res) { layer.close(load); layer.msg(res.info); }); }, show_data_dimension : function() { let that = this; that.flag_show_data_dimension = true; let e = $(event.target); let p = new Promise(function (resolve, reject) { that.flag_show_data_dimension = true; that.flag_shadow_div = true; that.flag_close_btn = true; resolve(); }).then(function (res) { // $('.shade-div').show(); // $('.close-btn').show(); $('#add-dimension .form-list input').val(''); }, function (res) { }); }, save_item_dimension : function () { let that = this; let e = $(event.target).closest('button'); let post_data = $('#add_item_dimension').formSerialize(); let layer_index = layer.load(1,{shade :0.3}); ajax(pim_api.URL_ADD_ITEM_VENDOR, post_data).then(function (res) { layer.close(layer_index); that.hide_shadow_div(); show_success_modal(function () { that.item_detail_show(0); //鏄剧ずitem璇︽儏 }) }).catch(function (res) { layer.msg(res.info); layer.close(layer_index); }); }, del_item_vendor: function (item_vendor_id, e) { if(!window.confirm('Are you sure to delete?')) { return false; } let load = layer.load(); let that = this; let post_data = { item_vendor_id: item_vendor_id }; ajax(pim_api.URL_DEL_ITEM_VENDOR, post_data).then(function (res) { layer.close(load); layer.msg(res.info, { time: 1000 //2绉掑叧闂紙濡傛灉涓嶉厤缃紝榛樿鏄�3绉掞級 }, function () { window.location.reload(); }); return; that.$set(that, 'current_item_vendor_id', 0); that.item_detail_show(0); }).catch(function (res) { layer.close(load); }); }, show_discussion : function () { let that = this; that.flag_discussion_show = !that.flag_discussion_show; that.set_cookie('detail_flag_discussion_show', that.flag_discussion_show); if (that.flag_discussion_show) { //鍒濆discussion that.init_discussion(); } }, init_discussion: function(item_id) { let that = this; let data = { item_id : item_id ? item_id : that.item_flow.id, sort : that.discussion_sort ? 'ASC' : 'DESC' } ajax(pim_api.URL_GET_DISCUSSIONS, data).then(function (res) { that.discussions = res.data; let discussion_id = that.get_cookie('detail_discussion_id'); that.$nextTick(function () { if (discussion_id != null && discussion_id != 0) { $('#discussion_' + discussion_id).click(); } }) }).catch(function (res) { layer.msg(res.info); }); }, init_comment: function() { let that = this; that.reset_comment(); let data = { discussion_id : that.current_discussion.id, sort : that.comment_sort ? 'ASC' : 'DESC' } ajax(pim_api.URL_GET_COMMENTS, data).then(function (res) { that.comment_tree = res.data; }).catch(function (res) { layer.msg(res.info); }); that.set_cookie('detail_discussion_id', that.current_discussion.id); that.$nextTick(function () { $(".pic_group").fancybox(); }) }, add_discussion: function() { let that = this; let data = { item_id : that.item_flow.id, item_no : that.item_flow.no, } $.extend(data, that.discussion_data); ajax(pim_api.URL_ADD_DISCUSSION, data).then(function (res) { that.reset_discussion(); that.init_discussion(); }).catch(function (res) { layer.msg(res.info); }); }, add_comment: function() { let that = this; let data = { discussion_id : that.current_discussion.id, } $.extend(data, that.comment_data); ajax(pim_api.URL_ADD_COMMENT, data).then(function (res) { that.init_comment(); }).catch(function (res) { layer.msg(res.info); }); }, change_upload_file: function(type) { let that = this; let e = $(event.target); let files = event.target.files; $.each(files, function (k, file) { var fd = new FormData(); fd.append("file", file); $.ajax({ url: pim_api.URL_UPLOAD, type:'POST', data:fd, processData:false, //tell jQuery not to process the data contentType: false, //tell jQuery not to set contentType dataType:'json', success:function (res) { if (res.status == 1) { res.data[0].file_name = res.data[0].name.split('.')[0] res.data[0].read_size = getfilesize(res.data[0].size); res.data[0].icon = get_icon(res.data[0].extension); if (type == 'discussion') { that.discussion_data.upload_file.push(res.data[0]); that.discussion_data.comment += '\n' + get_db_file_str(res.data[0]); } else { that.comment_data.upload_file.push(res.data[0]); that.comment_data.comment += '\n' + get_db_file_str(res.data[0]); } } }, error:function(){ } }) }); //娓呯┖鏂囦欢 e.val(""); }, remove_upload_file: function(k, file, type) { let that = this; let str = get_db_file_str(file); if (type == 'discussion') { that.discussion_data.upload_file.splice(k, 1); that.discussion_data.comment = that.discussion_data.comment.replace(str, ''); } else { that.comment_data.upload_file.splice(k, 1); that.comment_data.comment = that.comment_data.comment.replace(str, ''); } }, del_comment: function (comment_id) { let that = this; layer.confirm('Are you sure to delete?',{title:'Msg', btn: ['Sure','Cancel']}, function(index){ ajax(pim_api.URL_DEL_COMMENT, {comment_id : comment_id}).then(function (res) { if(res.status==1){ layer.msg('Delete Success!'); that.init_comment(); }else{ layer.msg('Delete Failed!'); } }).catch(function (res) { layer.msg(res.info); }); }); }, reset_comment: function() { let that = this; that.comment_data.comment = ''; that.comment_data.high_priority = false; that.comment_data.upload_file = []; that.comment_data.parent_id = 0; that.comment_data.top_comment_id = 0; that.set_cookie('detail_discussion_id', 0); }, reset_discussion: function() { let that = this; that.discussion_data.topic = ''; that.discussion_data.comment = ''; that.discussion_data.high_priority = false; that.discussion_data.upload_file = []; }, show_flow_comment: function(flow_index) { let that = this; if (that.flow_data[flow_index].flag_flow_comment_show == 0 && that.flow_data[flow_index].comments.init == 0) { that.init_flow_comment(flow_index); } that.$set(that.flow_data[flow_index], 'flag_flow_comment_show', that.flow_data[flow_index].flag_flow_comment_show == 1 ? 0 : 1); }, build_flow_comment_data: function(category_flow_id, top_comment_id, parent_id) { let that = this; return {comment : '', high_priority : false, top_comment_id : top_comment_id, parent_id : parent_id, attachments : [], item_id : that.item_flow.id, type : 'item', category_flow_id : category_flow_id, at_uids : []} }, init_flow_comment: function(flow_index) { let that = this; ajax(pim_api.URL_GET_FLOW_COMMENTS, {item_id : that.item_flow.id, type : 'item', category_flow_id : that.flow_data[flow_index].category_flow_id, sort : that.flow_data[flow_index].flow_comment_sort}).then(function (res) { if(!that.flow_data[flow_index].hasOwnProperty('comments')) { that.$set(that.flow_data[flow_index], 'comments', {}); } that.$set(that.flow_data[flow_index].comments, 'init', 1); that.$set(that.flow_data[flow_index].comments, 'list', res.data.comments); that.$set(that.flow_data[flow_index].comments, 'total', res.data.total); that.$set(that.flow_data[flow_index].comments, 'comment_data', that.build_flow_comment_data(that.flow_data[flow_index].category_flow_id, 0, 0)); that.$nextTick(function () { $(".pic_group_" + flow_index).fancybox(); }) }).catch(function (res) { layer.msg(res.info); }); }, change_flow_comment_file: function (flow_index, attachments) { let that = this; let e = $(event.target); let files = event.target.files; $.each(files, function (k, file) { var fd = new FormData(); fd.append("file", file); $.ajax({ url: pim_api.URL_UPLOAD, type:'POST', data:fd, processData:false, //tell jQuery not to process the data contentType: false, //tell jQuery not to set contentType dataType:'json', success:function (res) { if (res.status == 1) { res.data[0].is_img = res.data[0].is_img ? 1 : 0; res.data[0].file_name = res.data[0].name.split('.')[0] res.data[0].file_size = getfilesize(res.data[0].size); res.data[0].icon = get_icon(res.data[0].extension); attachments.push(res.data[0]); } }, error:function(){ } }) }); //娓呯┖鏂囦欢 e.val(""); }, remove_flow_comment_file: function (f_index, attachments) { attachments.splice(f_index, 1); }, add_flow_comment: function (comment_data, flow_index) { let that = this; ajax(pim_api.URL_ADD_FLOW_COMMENT, comment_data).then(function (res) { show_success_modal(function () { that.init_flow_comment(flow_index); }) }).catch(function (res) { layer.msg(res.info); }); }, del_flow_comment: function(id, flow_index) { let that = this; layer.confirm('Are you sure to delete?',{title:'Msg', btn: ['Sure','Cancel']}, function(index){ ajax(pim_api.URL_DEL_FLOW_COMMENT, {flow_comment_id : id}).then(function (res) { if(res.status==1){ layer.msg('Delete Success!'); that.init_flow_comment(flow_index); }else{ layer.msg('Delete Failed!'); } }).catch(function (res) { layer.msg(res.info); }); }); }, reply_flow_comment: function(flow_index, top_comment, top_comment_id, parent_id) { let that = this; if(!top_comment.hasOwnProperty('comment_data')) { that.$set(top_comment, 'comment_data', that.build_flow_comment_data(that.flow_data[flow_index].category_flow_id, top_comment_id, parent_id)) } top_comment.flag_show_reply = top_comment.flag_show_reply == 1 ? 0 : 1; }, update_flow_comment_txt: function() { let that = this; that.$nextTick(function () { if (event.target.scrollHeight > 40) { event.target.style.height = event.target.scrollHeight + "px"; } }) }, init_flow_comment_autocomplete: function (comment_data) { let that = this; $(event.target).devbridgeAutocomplete({ lookup: that.autolist.user, minChars: 1, delimiter: "@", onSelect: function (suggestion) { if(comment_data.at_uids.indexOf(suggestion.id) == -1) { comment_data.at_uids.push(suggestion.id); } }, triggerSelectOnValidInput: false, showNoSuggestionNotice: false //noSuggestionNotice: 'Sorry, no matching results' }); }, flow_comment_sort_set: function (flow_index) { let that = this; that.flow_data[flow_index].flow_comment_sort = that.flow_data[flow_index].flow_comment_sort == 'ASC' ? 'DESC' : 'ASC'; that.init_flow_comment(flow_index); }, //item images item_image : function(){ let that = this; let post_data = { item_id : item_id } //let load = layer.load(); //鏄剧ずgroup image ajax(pim_api.URL_SAMPLE_IMAGE, post_data).then(function (res) { //layer.close(load); if (res.status == 1) { that.$set(that, 'image_fields', res.data.fields); that.$set(that, 'image_list', res.data.image_list); that.$set(that, 'image_date_list', res.data.image_date_list); that.$set(that, 'image_dimension_attributes', res.data.dimension_attributes); $.each(res.data.dimension_attributes, function (k, v) { that.$set(that.image_vendor_checkbox, v.attribute_id, []); }) return new Promise(function (resolve, reject) { resolve(res.data); }); } }, function (res) { }).then(function (res) { }, function (res) { }); }, download_image : function () { let that = this; if (that.image_checkbox.length <=0) { return; } window.open(pim_api.URL_DOWNLOAD_PHOTOS + '?group_no=' + that.item_flow.no + '&photos=' + that.image_checkbox.join(',') , '_blank'); }, download_image_in_pdf : function () { let that = this; if (that.image_checkbox.length <=0) { return; } window.open(pim_api.URL_DOWNLOAD_PHOTOS_IN_PDF + '?group_no=' + that.item_flow.no + '&photos=' + that.image_checkbox.join(',') , '_blank'); }, card_expand : function(key, val) { let that = this; that.$set(this, key, val) }, show_flow_version : function (flow_index, vendor_item_id) { let that = this; that.flag_add_flow_version_element = true; that.flow_version_flow_index = flow_index; that.flow_version_vendor_item_id = vendor_item_id; let e = $(event.target); let p = new Promise(function (resolve, reject) { that.flag_add_flow_version_element = true; that.flag_shadow_div = true; that.flag_close_btn = true; resolve(); }).then(function (res) { // $('.shade-div').show(); // $('.close-btn').show(); }, function (res) { }); }, save_flow_version : function () { let that = this; let post_data = { item_id : that.item_flow.id, item_vendor_id : that.flow_version_vendor_item_id, category_flow_id : that.flow_data[that.flow_version_flow_index].category_flow_id } let load = layer.load(); //鏄剧ずgroup image ajax(pim_api.URL_ADD_FLOW_VERSION, post_data).then(function (res) { //layer.close(load); if (res.status == 1) { layer.close(load); that.hide_shadow_div(); } else { layer.msg(res.info) } }, function (res) { }).then(function (res) { }, function (res) { }); }, show_flow_version_list : function (flow_index, vendor_item_id) { let that = this that.flow_version_flow_index = flow_index; that.flow_version_vendor_item_id = vendor_item_id; let post_data = { item_id : that.item_flow.id, item_vendor_id : that.flow_version_vendor_item_id, category_flow_id : that.flow_data[that.flow_version_flow_index].category_flow_id } if (that.flow_version_vendor_item_id > 0) { $.each(that.vendor_list, function(k, item_vendor) { if (item_vendor.id == that.flow_version_vendor_item_id) { that.flow_version_vendor_item = item_vendor; } }) } ajax(pim_api.URL_GET_FLOW_VERSION, post_data).then(function (res) { //layer.close(load); if (res.status == 1) { that.flow_version_show_num = 6; that.flow_version_list = res.data; that.flow_version_index = that.flow_version_list.length > 0 ? 0 : -1; //鎶妚ersion涓殑value淇濆瓨鍒皏ersion_item_value(鏍煎紡鍜宨tem_value涓€鏍�)涓紝鏂逛究缁勪欢鍙栧€硷紝item_vendor_id 鍙� v_ + version_id that.flow_version_field_format(); let p = new Promise(function (resolve, reject) { that.flag_show_flow_version_element = true; that.flag_shadow_div = true; that.flag_close_btn = true; resolve(); }).then(function (res) { // $('.shade-div').show(); // $('.close-btn').show(); }, function (res) { }); } else { layer.msg(res.info) } }); }, flow_version_field_format: function () { let that = this; let item_value_tmp = {}; let tmp = {}; let val = {}; let av = that.flow_data[that.flow_version_flow_index]; tmp[av.category_flow_id] = {}; $.each(av.groups, function (gk, gv) { $.each(gv.attrs, function (akk, avv) { //initial value for multi select value and dynamic multi select if(avv.type_id == 20) { $.each(avv.child_attr, function (elk, el) { let el_val = ''; if($.inArray(el.type_id, ['8', '10', '16'])!=-1) { el_val = []; } // tmp[av.category_flow_id][el.id] = { // val: el_val, // type_id: el.type_id // }; }); tmp[av.category_flow_id][avv.id] = { val: [], type_id: avv.type_id, set: [] }; } else { let val = ''; if($.inArray(avv.type_id, ['8', '10', '16', '23'])!=-1) { val = []; } tmp[av.category_flow_id][avv.id] = { val: val, type_id: avv.type_id }; } }); }) let flow_version_value = {}; $.each(that.flow_version_list, function (index, flow_version) { flow_version.item_vendor_id = 'v_' + flow_version.id; av[flow_version.item_vendor_id] = {}; that.$set(av[flow_version.item_vendor_id], 'upload_cfg', { gateway: pim_api.URL_UPLOAD, key: 'file', showButton: false, allowRemove: false, allowRotate: false }); val = JSON.parse(JSON.stringify(tmp)); $.each(tmp, function (cate_flow_id, item) { $.each(item, function (ak, av) { if(typeof flow_version.value[ak] != 'undefined') { val[cate_flow_id][ak] = flow_version.value[ak]; } if (av.type_id == 20) { //set if (val[cate_flow_id][ak].set != undefined) { $.each(val[cate_flow_id][ak].set, function (set_line, set_arr) { $.each(set_arr, function (set_k, set_v) { val[cate_flow_id][set_v.attr.id] = set_v; }); }) } else { val[cate_flow_id][ak].val = []; val[cate_flow_id][ak].set = []; val[cate_flow_id][ak].type_id = 20; } } else if (av.type_id == 24) { val[cate_flow_id][ak].display_val = display_tinymce(val[cate_flow_id][ak].val); } }) }); flow_version_value[flow_version.item_vendor_id] = val; }) that.flow_version_value = flow_version_value; $.extend(true, that.item_value_cp, that.item_value); }, set_flow_version_show_num : function() { let that = this; if (that.flow_version_show_num <= 6) { that.flow_version_show_num = 999; } else { that.flow_version_show_num = 6; } } } }); //vue end let init_editor = false; let editor_save_timestamp = 0; function refresh_event() { selectBox('.select-box', -1); selectBox('.filter-store-select-box', -1); if (init_editor == false && document.querySelector( '#editor' )) { //瀵屾枃鏈粍浠� tinymce.init({ selector: '#editor', plugins : 'print preview searchreplace autolink image link table charmap hr advlist lists wordcount imagetools indent2em code imagetools powerpaste autoresize', //鏁扮粍鏂瑰紡 toolbar: 'forecolor backcolor bold italic underline strikethrough | formatselect fontselect fontsizeselect | indent2em alignleft aligncenter alignright alignjustify outdent indent | link bullist numlist image table codesample |code undo redo', images_upload_url: pim_api.URL_EDITOR_UPLOAD, powerpaste_word_import: 'propmt',// 鍙傛暟鍙互鏄痯ropmt, merge, clear锛屾晥鏋滆嚜琛屽垏鎹㈠姣� powerpaste_html_import: 'propmt',// propmt, merge, clear powerpaste_allow_local_images: true, paste_data_images: true, autoresize_on_init: true, setup: editor => { this.editor = editor; editor.on('change', () => { let timestamp = new Date().getTime(); const content = editor.getContent(); let category_flow_id = $('#editor').data('category_flow_id'); let attr_id = $('#editor').data('attr_id'); let item_vendor_id = $('#editor').data('item_vendor_id'); Vue.set(app.item_value[item_vendor_id][category_flow_id][attr_id], 'val', content); Vue.set(app.item_value[item_vendor_id][category_flow_id][attr_id], 'display_val', display_tinymce(content)); document.getElementById("myiframe").contentWindow.location.reload(); console.log(timestamp - editor_save_timestamp) if (timestamp - editor_save_timestamp > 3000) { //3绉掕嚜鍔╯ave涓€娆� editor_save_timestamp = timestamp; app.auto_save_attr_value(item_vendor_id, {id:attr_id, category_flow_id:category_flow_id}); } }); window.editor = editor; } }); init_editor = true; } } function reset_select(select) { let dt = select.children("dt"); dt.html('Please Select'); select.prev().val(0); } $(function () { $('.js_select2').select2(); $('#category').on('change',function(){ $('#sub_category').empty(); var cate = $(this).val(); if(cate_tree[cate]){ $.each(cate_tree[cate]['sub'],function(i,v){ $('#sub_category').append('<option value="'+v.id+'">'+v.title+'</option>'); }) } }); $('.cancel_btn').click(function(){ layer.closeAll(); }); function empty_main() { $('#main').find('#item_info_box').remove(); $('#main').find('.tab-content').remove(); } $('#main').on('click', '.actions-btn', function () { let $menu = $(this).closest('.item').find('.menu'); if ($menu.is(':hidden')) { $menu.show(); } else { $menu.hide(); } return ; }); $('#main').on('click', '.tabs .remove-btn', function () { //var index = $(this).cloest('li').index(); $(this).closest('.tabs').find('li:first').click(); $(this).closest('li').remove(); }); $('#main').on('click', '.show_detail_edit', function () { var url = "/CheckList/Pim/Index/detail?id="+$(this).data('id')+"&item_flow_id="+$(this).data('item_flow_id'); window.open(url,'_blank'); }); $('#main').on('click', '.flow_toggle', function () { var ch_obj = $(this).closest('.p_nav').next('.c_nav'); if(ch_obj.is(':visible')) { $(this).removeClass('icon-minus').addClass('icon-add'); ch_obj.slideUp('fast'); } else { $(this).removeClass('icon-add').addClass('icon-minus'); ch_obj.slideToggle(); } }); function init_ui() { $('.js_select2:visible').select2(); $('.js_datetime_ui:visible').each(function(){ laydate.render({ elem: this, trigger: 'click', type: 'datetime', lang: 'en' }); }); $('.js_date_ui:visible').each(function(){ laydate.render({ elem: this, trigger: 'click', lang: 'en' }); }); }; //鍥炲埌椤堕儴 $(document).on('click','.btn-top', function () { $('.overview-content .panel-l').animate({ scrollTop: 0 }, 400); }); $(document).on('focus','.comment .textarea',function(){ $('.comment-box .inner').addClass('active'); }); $(document).on('blur','.comment .textarea',function(){ $('.comment-box .inner').removeClass('active'); }); //寮瑰嚭妗� // $('.btn-column').on('click', function () { // $('.fullpage').addClass('active'); // }); $('.fullpage .cancel').on('click', function () { $('.fullpage').removeClass('active'); }); $(".cancel-btn").on('click',function(){ app.hide_shadow_div(); }); // $(document).on('click',function(e){ // let target = $(e.target); // if(target.closest(".pop-btn").length != 0 || target.closest(".popup-box").length != 0) return; // app.hide_shadow_div(); // }) //鍒楄〃椤电殑鎼滅储鎸夐挳锛屽湪鐐瑰嚮鍏朵粬鍦版柟鐨勬椂鍊欐敹璧锋潵 document.addEventListener('click',function(ev){ if (ev.target.parentElement.classList.contains('item-search') || ev.target.classList.contains('btn-add') || ev.target.parentElement.classList.contains('btn-add')) { return; } app.flag_show_search_item_no = false; }); //璇︽儏椤电殑related鐐瑰嚮灏忕澶翠箣澶栫殑鍦版柟鏀惰捣涓嬫媺閫夐」 document.addEventListener('click',function(ev){ if ((ev.target.parentElement.classList.contains('switch-btn') && ev.target.classList.contains('icon-triangle')) || ev.target.parentElement.classList.contains('drop-box')) { return; } $('.r-items .switch-btn').next().hide(); $('.upload-file .switch-btn').next().hide(); }); //flow card 婊氬姩鏃惰仈鍔ㄥ乏渚у鑸爮 $('.panel-r.slimscroll').on('scroll',function(ev){ let $this = $(this); let card = ''; $this.find(".card").each(function(index){ let rect = ($(this)[0].getBoundingClientRect()); if( rect.top < 160 && rect.top > 0){ card = $(this).data('card'); } }); if (card.length != 0) { //宸﹁竟瀵艰埅鏍忛€変腑card let e = $('.panel-l .menu-list [data-target=".card-' + card +'"]'); if (e.hasClass('d-firstNav')) { //褰撳墠鑿滃崟鍜宑ard鏄悓涓€涓垯涓嶆搷浣� let current_card = e.parent().parent().find('.selected .d-firstNav').data('card'); if (current_card == card) { return; } //涓€绾ц彍鍗曪紝鐩存帴淇敼 dropSwift(e, '.d-firstDrop'); let p = e.parent(); p.parent().find('.selected').removeClass('selected'); p.addClass('selected'); } else { // 鍒ゆ柇褰撳墠涓€绾ф槸鍚︽湁鐐瑰嚮 if (!e.parent().parent().parent().hasClass('selected')) { //閫変腑鐨勬槸鍏朵粬涓€绾э紝闇€瑕佸師鏈墦寮€鐨勪竴绾у拰涓嬫媺鑿滃崟锛屾墦寮€鏂扮殑涓€绾у拰涓嬫媺鑿滃崟 if (e.parent().parent().parent().parent().find('.selected').length > 0) { dropSwift(e.parent().parent().parent().parent().find('.selected .d-firstNav'), '.d-firstDrop'); e.parent().parent().parent().parent().find('.selected').removeClass('selected'); } dropSwift(e.parent().parent().prev(), '.d-firstDrop'); e.parent().parent().parent().addClass('selected'); } e.parent().parent().parent().find('.d-firstDrop .cur').removeClass('cur'); e.parent().parent().find('.cur').removeClass('cur'); e.parent().addClass('cur'); } } }); $('.comment-txt').on('input', function () { this.style.height = '40px'; this.style.height = this.scrollHeight + "px"; console.log(123); }); $('.panel-r').scroll(function(ev){ $('.autocomplete-suggestions').css('display','none'); }); }); //uploads files function remove_upload_file(obj){ $(obj).closest('.js_upload_col').remove(); window.event? window.event.cancelBubble = true : event.stopPropagation(); return false; } function do_upload_file(obj,upload_type){ var oParent = $('#flow_comment_box'); var files_obj = obj.files; var files_count = $(files_obj).length; var is_upload = 0; oParent.find('.js_upload_input').attr('disabled',true); oParent.find('.loading').show(); $(files_obj).each(function(index,file){ var fd = new FormData(); fd.append("upload_file", file); $.ajax({ url: pim_config.api+'/uploadFile', type:'POST', data:fd, processData:false, //tell jQuery not to process the data contentType: false, //tell jQuery not to set contentType dataType:'json', success:function (res) { if (res.status == 1) { var data_val = ' extension="'+res.data.extension+'" url="'+res.data.url+'" file_name="'+res.data.file_name+'" type="'+res.data.type+'"'; data_val += ' icon="'+res.data.icon+'"'; data_val += ' file_size="'+res.data.file_size+'"'; if(res.data.type.search(/^image/i)!=-1){ html = '<div class="edit-item pic js_upload_col" '+data_val+'>' +'<img src="/CheckList/'+res.data.url+'" >' +'<span class="btn-remove" onclick="remove_upload_file(this);"><i></i></span>' +'</div>'; oParent.find(".flow_comment_file").append(html); }else{ html = '<div class="edit-item file file js_upload_col" '+data_val+' onclick="window.open(\'/CheckList/Home/DownLoad/index?path='+res.data.url+'|'+res.data.file_name+'\',\'_blank\')">' +'<i class="icon '+res.data.icon+'"></i>' +'<div class="rows">' +'<div class="file-name">' +'<a href="javascript:;">' +'<span class="pre" title="'+res.data.file_name+'">' +res.data.file_name +'</span>' +'<span class="pos">'+res.data.extension+'</span>' +'</a>' +'<div class="file-size">'+(res.data.file_size/1024/1024).toFixed(2)+'Mb</div>' +'</div>' +'<span class="icon-download"></span>' +'</div>' +'<span class="btn-remove" onclick="remove_upload_file(this);"><i></i></span></div>'; oParent.find(".flow_comment_file").append(html); } } is_upload++; if(is_upload==files_count){ oParent.find('.js_upload_input').attr('disabled',false); oParent.find('.loading').hide(); } }, error:function(){ is_upload++; if(is_upload==files_count){ oParent.find('.js_upload_input').attr('disabled',false); oParent.find('.loading').hide(); } } }) }); if(is_upload==files_count){ oParent.find('.js_upload_input').attr('disabled',false); oParent.find('.loading').hide(); } $(obj).val(''); } //related show items function show_drop_box(obj, parent = '.r-items') { let drop_box = $(obj).closest(parent).find('.drop-box'); if (drop_box.is(':hidden')) { drop_box.show(); } else { drop_box.hide(); } } //excel set function excel_select_clear(){ $('#excel_list li').prependTo($('#excel_selection')); $('#excel_tpl_list li').removeClass('selected'); excel_table_head(); } function excel_table_head(){ $('#tabReport .excel_table_head th:not([type="normal"])').remove(); $('#tabReport .excel_table_body td:not([type="normal"])').remove(); $('#excel_list li').each(function () { $('#tabReport .excel_table_head').append('<th>' + $(this).attr('data-title') + '</th>'); $('#tabReport .excel_table_body').append('<td>-</td>'); }); } function post_form(URL, PARAMTERS) { //鍒涘缓form琛ㄥ崟 var temp_form = document.createElement("form"); temp_form.action = URL; temp_form.target = "_blank"; temp_form.method = "post"; temp_form.style.display = "none"; //娣诲姞鍙傛暟 var opt = document.createElement("textarea"); opt.name = 'param'; opt.value = JSON.stringify(PARAMTERS); temp_form.appendChild(opt); document.body.appendChild(temp_form); //鎻愪氦鏁版嵁 temp_form.submit(); } function dateFormat(fmt, date) { let ret; const opt = { "Y+": date.getFullYear().toString(), // 骞� "m+": (date.getMonth() + 1).toString(), // 鏈� "d+": date.getDate().toString(), // 鏃� "H+": date.getHours().toString(), // 鏃� "M+": date.getMinutes().toString(), // 鍒� "S+": date.getSeconds().toString() // 绉� // 鏈夊叾浠栨牸寮忓寲瀛楃闇€姹傚彲浠ョ户缁坊鍔狅紝蹇呴』杞寲鎴愬瓧绗︿覆 }; for (let k in opt) { ret = new RegExp("(" + k + ")").exec(fmt); if (ret) { fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0"))) }; }; return fmt; } function resetFilter() { $(document).on('change','.multiselect-menu .filter_list :checkbox, #filter-box .filter_list :checkbox',function(){ if($(this).val()==-1){ if($(this).is(':checked')){ $(this).closest('.filter_list').find(':checkbox').prop('checked',true); }else{ $(this).closest('.filter_list').find(':checkbox').prop('checked',false); } }else{ if(!$(this).is(':checked') && $(this).closest('.filter_list').find(':checkbox[value="-1"]').is(':checked')){ $(this).closest('.filter_list').find(':checkbox[value="-1"]').prop('checked',false); } if($(this).is(':checked') && !$(this).closest('.filter_list').find(':checkbox[value="-1"]').is(':checked') && $(this).closest('.filter_list').find(':checkbox[value!="-1"]:checked').length==$(this).closest('.filter_list').find(':checkbox[value!="-1"]').length){ $(this).closest('.filter_list').find(':checkbox[value="-1"]').prop('checked',true); } } //console.log(app.post_filter_data.office_id.val); }); } function setIframeHeight(iframe) { if (iframe) { var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow; if (iframeWin.document.body) { iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight; if ($('#editor_ifr').height() != 'undefined' && iframe.height == 0) { //浠巈dit鐘舵€佸垏鎹㈠埌棰勮鐘舵€侊紝闇€瑕佹寜瀵屾枃鏈紪杈戝櫒鐨勯珮搴︾粰iframe鏇存柊楂樺害 iframe.height = $('#editor_ifr').height(); } } } }