2022-04-24 01:48:36 +00:00
|
|
|
import{r as h}from"./record.0fa6aed5.js";import{g as S}from"./dateFormat.a9df66b7.js";import{_ as y,c as b,d as R,T as _}from"./index.ce021ef5.js";import{S as I}from"./Spinner.80e7cf17.js";import{p as E,_ as U}from"./CreateRecordModalButton.d09f1946.js";import{e as D,i as k,o as r,g as m,S as N,F as B,j as x,h as o,t as v,x as C,C as M,k as L,n as j,p as F,m as $,P as T,A as O,B as P}from"./vendor.961f4417.js";const z=D({props:{record:null},setup(d){const p=d,n=b(),a=k("refetchRecords"),u=async()=>{try{const e=p.record,{value:l}=await R.fire({title:"\u8CC7\u6599\u7DE8\u8F2F",html:`
|
|
|
|
${e.input.merchant}-${e.input.item} $${e.input.amount}`)}catch(l){console.error("error",l),_.fire({icon:"error",title:"\u7DE8\u8F2F\u8CC7\u6599\u5931\u6557\uFF01"})}};return(e,l)=>(r(),m("i",{class:"fas fa-edit",onClick:u}))}});var q=y(z,[["__scopeId","data-v-34229604"]]);const G={class:"d-flex mb-3",style:{width:"100vw"}},H={class:"btn btn-info fw-bold"},J=D({props:{propData:null},emits:["closeFunction"],setup(d,{emit:p}){const n=d,a=b(),u=k("refetchRecords"),i=async()=>{var t;const{isConfirmed:l}=await R.fire({icon:"info",title:"\u78BA\u5B9A\u7D50\u7B97\u8CC7\u6599\uFF1F",text:`\u7D50\u7B97\u91D1\u984D\u70BA $${n.propData.closeRecordsAmount} [\u7D50\u7B97\u8005: ${(t=a.currentUser)==null?void 0:t.displayName}]`});l&&e(n.propData.closeRecordsAmount)},e=async l=>{var t;try{if(a.currentUser){const{data:c}=await h.close({records:n.propData.closeRecords.toString(),totalAmount:l,UserId:(t=a.currentUser)==null?void 0:t.id});p("closeFunction","closeRecord"),u(),c.data.recordsNotFound.length||c.data.recordsClosedBefore.length?_.fire({icon:"success",title:"\u6210\u529F\u7D50\u7B97\u8CC7\u6599\uFF01\u6709\u90E8\u5206\u8CC7\u6599\u672A\u80FD\u627E\u5230\u6216\u662F\u5DF2\u7D93\u7D50\u7B97\u904E\u3002"}):_.fire({icon:"success",title:"\u6210\u529F\u7D50\u7B97\u8CC7\u6599\uFF01"}),E(`${a.nickName}${a.icon}\u7D50\u7B97\u7D00\u9304 \u2192 \u7E3D\u91D1\u984D $${l}`)}}catch(c){console.error("error",c),_.fire({icon:"error",title:"\u7D50\u7B97\u8CC7\u6599\u5931\u6557\uFF01"})}};return(l,t)=>(r(),m("div",G,[d.propData.isCloseStatus?(r(),m(B,{key:1},[o("div",H,"\u7D50\u7B97\u91D1\u984D $"+v(d.propData.closeRecordsAmount),1),o("button",{type:"button",class:"btn btn-secondary ms-3",onClick:t[1]||(t[1]=c=>p("closeFunction","cancelBtnClick"))}," \u53D6\u6D88\u7D50\u7B97 "),o("button",{type:"button",class:"btn btn-success ms-3",onClick:i},"\u78BA\u5B9A\u7D50\u7B97")],64)):(r(),m(B,{key:0},[x(U,{view:"Record",class:"me-3"}),o("button",{type:"button",class:"btn btn-danger",onClick:t[0]||(t[0]=c=>p("closeFunction","closeBtnClick"))},"\u958B\u59CB\u7D50\u7B97")],64))]))}});const K=D({props:{record:null},setup(d){const p=d,n=k("refetchRecords"),a=async()=>{try{const{isConfirmed:i}=await R.fire({title:`\u78BA\u5B9A\u522A\u9664\u7D00\u9304[${p.record.item}]\u561B\uFF1F`,showCancelButton:!0});i&&u(p.record.id)}catch(i){console.error("error",i)}},u=async function(i){try{const{data:e}=await h.delete(i);if(e.status!=="success")throw new Error(`[SERVER ERROR] ${e.message}`);n(),_.fire({icon:"success",title:`\u6210\u529F\u522A\u9664\u7D00\u9304[${e.data.item}]`})}catch(e){console.error("error",e),_.fire({icon:"error",title:"\u522A\u9664\u7D00\u9304\u5931\u6557\uFF01"})}};return(i,e)=>(r(),m("i",{class:"fas fa-trash",onClick:a}))}});var Q=y(K,[["__scopeId","data-v-841b8e8a"]]);const V=d=>(O("data-v-072f01d7"),d=d(),P(),d),W={key:0},X={key:0,class:"table table-info table-hover"},Y=V(()=>o("thead",null,[o("tr",null,[o("th",{scope:"col"},"#"),o("th",{scope:"col"}),o("th",{scope:"col"},"\u9805\u76EE"),o("th",{scope:"col"},"\u5546\u5BB6"),o("th",{scope:"col"},"\u91D1\u984D"),o("th",{scope:"col"},"\u65E5\u671F"),o("th",{scope:"col",id:"column-item"},"\u9996\u6B21\u8A18\u9304\u8005"),o("th",{scope:"col",id:"column-item"},"\u9996\u6B21\u8A18\u9304\u6642\u9593"),o("th",{scope:"col",id:"column-item"},"\u66F4\u65B0\u6642\u9593")])],-1)),Z=["onClick"],ee=["checked"],te={id:"column-item"},oe={id:"column-item"},se={id:"column-item"},ue={key:1,class:"img-fluid",src:"https://memeprod.sgp1.digitaloceanspaces.com/user-wtf/1581909112681.jpg",alt:""},ce=D({setup(d){const p=b(),n=C(!0),a=C([]),u=C({isCloseStatus:!1,closeRecords:[],closeRecordsAmount:0}),i=async function(){try{const{data:t}=await h.getAll();a.value=t.data.filter(c=>c.isClosed===!1),n.value=!1}catch(t){console.error("error",t)}},e=(t,c)=>{if(console.log("checkboxClick"),u.value.isCloseStatus){const s=u.value.closeRecords.findIndex(f=>f===t);s!==void 0&&(s!==-1?(u.value.closeRecords.splice(s,1),u.value.closeRecordsAmount-=c):(u.value.closeRecords.push(t),u.value.closeRecordsAmount+=c))}},l=t=>{if(t==="cancelBtnClick
|