Pages.Dashboard = { _template: 'dashboard.html', template: '
this is dashboard.html
', data: function () { return { lang_choose: localStorage.getItem('lang_choose') || 'th', lang_txt: lang_dashboard, doc_notSign: "0", doc_export: "0", doc_received: "0", doc_All: "0", list_document: [], cert:{}, day_exp_cer:0, startDate: null, endDate: null, init_date: null, last_init_date:null, time_over: false } }, mounted: function () { window.myApp = this // openLeftMenu() this.get_dashboard() this.get_last_document() this.get_cer_info() }, filters: { date(value) { value = value || '' var date = new Date(value) var day = date.getDate() if (Number(day) <= 9) day = "0" + day var month = date.getMonth() + 1 if (Number(month) <= 9) month = "0" + month var year = date.getFullYear() value = day + "/" + month + "/" + year return value || "" }, time(value) { value = value || '' var date = new Date(value) var horus = date.getHours() if (Number(horus) <= 9) horus = "0" + horus var minutes = date.getMinutes() if (Number(minutes) <= 9) minutes = "0" + minutes var seconds = date.getSeconds() if (Number(seconds) <= 9) seconds = "0" + seconds value = horus + ":" + minutes + ":" + seconds return value || "" }, }, methods: { recheck_status_field_user:function(field,signers){ var result = 0 var status_sign = 0 // find signer var sign = signers.filter(function (s) { if(s.is_is_group){ const result = s.user_group.filter(g => g.email == getUsername() && s.needToSign); return result }else{ return s.email == getUsername() && s.needToSign } }) // 0 == ยังไม่เซน , 1 == เซน เซ็นปกติ if(sign.length > 0){ for (i = 0; i < sign.length; i++) { const filed_succ = field.filter(f => f.email == sign[i].email && f.status == 1); if(filed_succ.length > 0 ){ status_sign = 1 } } } return status_sign }, return_status_doc:function(field){ var chk_approve = 0 const result = field.filter(f => f.toolName == "Approve"); if(result.length > 0){ const apv = field.filter(f => f.toolName == "Approve" && f.status == 0); if(apv.length > 0) chk_approve = 1 } return chk_approve }, gotoPage: function (page) { router.push(page); }, replaceString: function(str){ //console.log(str.replace(/(\d{4})-(\d{2})-(\d{2})/g, '$3$2$1')) return str.replace(/(\d{4})-(\d{2})-(\d{2})/g, '$3$2$1'); }, gotoDoc: function (id) { document.location.href = "#/document?id=" + id }, get_date: function(){ that = this console.log(this.init_date) console.log(this.last_init_date) if(that.init_date == null && that.last_init_date == null){ const init_date = new Date() const cal_year = init_date.getFullYear() const cal_month = init_date.getMonth() + 1 const days_in_month = new Date(cal_year, cal_month, 0).getDate() const last_init_date = new Date(init_date.getTime() - days_in_month * 24 * 60 * 60 * 1000) const s_ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(init_date) const s_mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(init_date) const s_da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(init_date) const l_ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(last_init_date) const l_mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(last_init_date) const l_da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(last_init_date) this.endDate = `${s_ye}-${s_mo}-${s_da}` this.startDate = `${l_ye}-${l_mo}-${l_da}` this.init_date = `${s_da}/${s_mo}/${s_ye}` this.last_init_date = `${l_da}/${l_mo}/${l_ye}` console.log('not have rc') }else{ const init_date = that.init_date const last_init_date = that. last_init_date const s_ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(init_date) const s_mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(init_date) const s_da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(init_date) const l_ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(last_init_date) const l_mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(last_init_date) const l_da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(last_init_date) this.endDate = `${s_ye}-${s_mo}-${s_da}` this.startDate = `${l_ye}-${l_mo}-${l_da}` this.init_date = `${s_da}/${s_mo}/${s_ye}` this.last_init_date = `${l_da}/${l_mo}/${l_ye}` console.log('have rc') } //this.endDate = `${s_ye}-${s_mo}-${s_da}` //this.startDate = `${l_ye}-${l_mo}-${l_da}` //this.init_date = `${s_da}/${s_mo}/${s_ye}` //this.last_init_date = `${l_da}/${l_mo}/${l_ye}` }, format_date: function (e) { value = e.value || '' var date = new Date(value) var day = date.getDate() //if (Number(day) <= 9) day = "0" + day var month = date.getMonth() + 1 //if (Number(month) <= 9) month = "0" + month var year = date.getFullYear() value = day + "/" + month + "/" + year e.setAttribute( "data-date-format", value) }, get_dashboard: function (startDate, endDate) { var that = this if(startDate && endDate){ var chk_start_time = new Date( parseInt(startDate.substr(4, 4)), parseInt(startDate.substr(2, 2)) - 1, parseInt(startDate.substr(0, 2))).getTime() var chk_end_time = new Date( parseInt(endDate.substr(4, 4)), parseInt(endDate.substr(2, 2)) - 1, parseInt(endDate.substr(0, 2))).getTime() } console.log('send',chk_start_time) console.log('send',chk_end_time) var data = { email: getUsername() || "N/A", startDate: startDate, endDate: endDate } if ((chk_end_time - chk_start_time) > 31536000000) { alert('Date filter period is over 1 year | ช่วงเวลาการค้นหามากกว่า 1 ปี'); return; }else{ $.ajax({ type: "POST", url: api_host + "dashboard_bla", data: JSON.stringify(data), dataType: "json", success: function (resp) { console.log(resp) if (resp.success) { //that.doc_export = resp.documents_owner || "0" //that.doc_received = resp.documents_signer || "0" //that.doc_notSign = resp.documents_not_sign || "0" //that.doc_All = resp.documents_all || "0" that.doc_export = resp.documents_owner || "0" that.doc_received = resp.documents_signer || "0" that.doc_notSign = resp.documents_not_sign || "0" that.doc_All = resp.documents_all || "0" that.init_date = resp.endDate that.last_init_date = resp.startDate that.get_date() } }, error: function (request, status, error) { alert("|" + status + ' |' + error); } }); } }, get_last_document: function () { var that = this var data = { "company_id": "", "email": getUsername() || "N/A", "cat": 'all' }; $.ajax({ type: "POST", url: api_host + "list_document", data: JSON.stringify(data), dataType: "json", success: function (resp) { if (resp.success) { if (!resp.data.length) resp.data = [] var list = resp.data if (list.length > 0) { list.sort(function (a, b) { return b.createdDtm - a.createdDtm }) if (list.length > 5) list = list.slice(0, 5) } that.list_document = list } }, error: function (request, status, error) { alert("|" + status + ' |' + error); } }); }, open_buy_more: function () { window.open("/bla/web/pricing.html?buy=more&rd=" + new Date().getTime()) }, count_signer: function (signer, fields) { if (fields.length > 0) { var total = 0 for (i = 0; i < signer.length; i++) { if (signer[i].needToSign == true) { var f_owner = fields.filter(function (f) { return (signer[i].email == f.email) }) var f_sign = fields.filter(function (f) { return (signer[i].email == f.email && f.status == 1) }) if (f_sign.length == f_owner.length) { total = total + 1 } } else { total = total + 1 } } return total } else { return signer.length } }, get_cer_info:function(){ var that = this var data = {} $.ajax({ type: "POST", url: api_host + "get_cer_info_BLA", data: JSON.stringify(data), dataType: "json", success: function (resp) { if(resp.success && resp.have_cert){ that.cert = resp.cert var expire_date = that.cert.expire_date var expire_day = expire_date.substring(0,2) var expire_month = expire_date.substring(3,5) var expire_year = expire_date.substring(6,10) var user_day = expire_day var user_month = expire_month var user_year = expire_year var current_day = new Date().getDate() var current_month = new Date().getMonth() var current_year = new Date().getFullYear() var oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds var update_date = new Date(user_year, user_month, user_day); var current_date = new Date(current_year, current_month, current_day); var total = Math.round(Math.abs((update_date - current_date) / oneDay)); that.day_exp_cer = total var show_cert_warning = ('true' != sessionStorage.getItem('cert_expired')) window.show_cert_warning = show_cert_warning if(show_cert_warning) { window.total = total if(current_date.getTime()>update_date.getTime()) { alert('Your certificate has expired.\ncertificateของท่านหมดอายุกรุณาทำการต่ออายุ') sessionStorage.setItem('cert_expired', 'true') } } } }, error: function (request, status, error) { alert("|" + status + ' |' + error); } }); }, } } routes.push({ path: '/dashboard', component: Pages.Dashboard }) var lang_dashboard = { "dashboard_title": { "th": "หน้าแรก", "en": "Home" }, "subscrip_pack": { "th": "ซื้อแพ็คเกจเสริม", "en": "Subscription for Additional Package" }, "pls_register": { "th": "บัญชีของคุณยังไม่ได้ทำการผูกเบอร์โทร", "en": "Please register your mobile number to your login account" }, "renew": { "th": "กรุณาต่ออายุการใช้งาน ในกรณีที่แพ็คเกจของท่านหมดอายุการใช้งานแล้วหากท่านไม่ดำเนินการอายุภายใน 30 วันเอกสารทั้งหมดของท่านจะถูกลบออก", "en": "Please renew subscription for main package. Within 30 days after the expiration date of subscription, you can renew expired subscription at the standard rate. From days 31 after the expiration, all documents of inactive subscription will be deleted permanently." }, "subscrip_renew": { "th": "ต่ออายุแพ็คเกจหลัก", "en": "Subscription Renewal for Main Package" }, "storage_max": { "th": "ขณะนี้พื้นที่จัดเก็บข้อมูล ถึงจำนวนที่กำหนดแล้ว (100GB/100GB)", "en": "Storage has reached the maximum size limit" }, "pack_expi": { "th": "ขณะแพ็คเกจของคุณใกล้หมดอายุการใช้งานแล้ว ใช้ได้ถึงวันที่ 25/09/2561 (เหลืออีก 14 วัน). ต่ออายุแพ็คเกจหลัก", "en": "Your Package will be expired soon.You can use until 25/09/2564 (14 days left)" }, "day_left": { "th": "เหลืออีก", "en": "Days Left" }, "late_date": {"th": "เอกสารย้อนหลัง 7 วัน", "en": "Last 7 days Document"}, "time_over": {"th": "ช่วงเวลาเกิน 1 ปี", "en": "Time period over 1 year"}, "startdate": {"th": "วันเริ่มต้น : ", "en": "Start Date : "}, "enddate": {"th": "ถึงวันที่ : ", "en": "End Date : "}, "upload": { "th": "อัปโหลดไฟล์", "en": "Upload File" }, "file_max": { "th": "ขนาดไฟล์สูงสุดไม่เกิน 25 MB", "en": "File size must be less than 25 MB" }, "storage": { "th": "พื้นที่เก็บข้อมูล", "en": "Storage" }, "used": { "th": "ใช้ไป", "en": "Used" }, "from": { "th": "จาก", "en": "from" }, "all_doc": { "th": "จำนวนเอกสารทั้งหมด", "en": "Total of Documents" }, "active_user": { "th": "จำนวนผู้ใช้งาน", "en": "Total of Active Users" }, "buy_pack": { "th": "ซื้อเพิ่มเติม", "en": "Buy Additional Package" }, "last_doc": { "th": "เอกสารล่าสุด", "en": "Latest Documents" }, "view_doc": { "th": "ดูเอกสารทั้งหมด", "en": "View All Documents" }, "search": {"th": "ค้นหา", "en": "Search"}, "subject": { "th": "เรื่อง", "en": "Subject" }, "sender": { "th": "ผู้ส่ง", "en": "Sender" }, "status": { "th": "สถานะ", "en": "Status" }, "date": { "th": "วัน - เวลา", "en": "Date & Time" }, "view_all_doc": { "th": "ดูเอกสารทั้งหมด", "en": "View All Documents" }, "wait_sign": { "th": "คุณยังไม่ได้เซ็น", "en": "Wating for Signature" }, "sent": { "th": "เอกสารที่ส่งออก", "en": "Sent" }, "inbox": { "th": "เอกสารที่ได้รับ", "en": "Inbox" }, "doc_cancel": { "th": "เอกสารถูกยกเลิก", "en": "Cancelled." }, "doc_exp": { "th": "(หมดอายุ)", "en": "(Expired)" }, "doc_not_complete": { "th": "ยังไม่สมบูรณ์", "en": "Incomplete" }, "doc_complete": { "th": "เสร็จสมบูรณ์", "en": "Complete" }, "not_sign": { "th": "ยังไม่ได้เซ็น", "en": "Incomplete Signing" }, "signed": { "th": "เซ็นแล้ว", "en": "Signed" }, "doc_all": { "th": "เอกสารทั้งหมด", "en": "All documents" }, "doc_not_sign": { "th": "เอกสารที่รอการลงนาม", "en": "Incomplete Signing" }, "doc_inbox": { "th": "เอกสารที่ได้รับ", "en": "Inbox" }, "doc_sent": { "th": "เอกสารที่ส่งออก", "en": "Sent" }, "another": { "th": "อีก", "en": "another" }, "days": { "th": "วัน", "en": "days" }, "noticeKyc": { "th": "ใบรับรองอิเล็กทรอนิกส์ของคุณ จะหมดอายุในวันที่", "en": "Your digital certificate will expire on " }, "noticeKyc2": { "th": "กรุณาอัปเดตการยืนยันตัวตนของคุณ เพื่อต่ออายุใบรับรองอิเล็กทรอนิกส์", "en": "Please update your verification. To renew the digital certificate" } }