????
Current Path : C:/inetpub/vhost/sdoc.nextform.vn/www/assets/ |
Current File : C:/inetpub/vhost/sdoc.nextform.vn/www/assets/IndexDetail-eec5aba6.js |
var A=Object.defineProperty;var P=(o,t,n)=>t in o?A(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var u=(o,t,n)=>(P(o,typeof t!="symbol"?t+"":t,n),n);import{r as d,F as $,j as e,z as w,i as D,n as V,R as E,x as R,m as g,C as K,E as B}from"./index-727ccf4d.js";import{B as m}from"./Button-9330b92c.js";import{B as M}from"./ButtonDropdown-8c17a411.js";import{D as L,a as Y,b as y}from"./DropdownToggle-56b088f2.js";import{F as k}from"./FullScreenDialog-84a3de57.js";import{D as F}from"./DataTable-2f4d7f97.js";import{R as O}from"./Row-4ad47f29.js";import{C as x}from"./Col-ed66bf37.js";import{I as z,d as H}from"./InputNumber-dceb4c1c.js";import"./InputTime-0a0b65be.js";import{P as Q,C as q}from"./DialogCustomize-4c6977d9.js";import{D as S}from"./DropdownList-ca18995c.js";import{F as _}from"./FontAwesome4-32fe4385.js";import{C as G}from"./CardBody-4a2e5616.js";import{C as W}from"./CardHeader-dcb844ec.js";import{a as X}from"./useTheme-41684c89.js";import{w as J,c as U}from"./capitalize-f7a57a5c.js";import{M as Z,b as ee}from"./SelectCustom-701e5fac.js";import ne from"./Index-de659ae6.js";var te={root:{overflow:"hidden"}},oe=d.forwardRef(function(t,n){var s=t.classes,i=t.className,l=t.raised,h=l===void 0?!1:l,c=X(t,["classes","className","raised"]);return d.createElement(Q,$({className:U(s.root,i),elevation:h?8:1,ref:n},c))});const se=J(te,{name:"MuiCard"})(oe);const ie=({LoaiDonVi_Id:o,nhomDoiTuongId:t,reloadTable:n})=>{const[s,i]=d.useState(!1),l=()=>{i(!0),w("Bạn có chắc chắn muốn thực hiện","Thông báo").then(()=>{D(`QuyTrinh/ThemDoiTuongs?LoaiDonVi_Id=${o}&NhomDoiTuong=${t}`,"POST",null,{odata:!1}).then(h=>{i(!1),V("Thành công!"),n()})})};return e.jsx(e.Fragment,{children:o&&t&&e.jsxs(m,{disabled:s,onClick:l,className:"btn-add-all-donvi",children:[e.jsx(_,{fa:"list"}),"Thêm tất cả"]})})},ae=ie,le=[{field:"Id",dataID:!0,type:"numeric",hidden:!0},{title:"STT",field:"STT",type:"string",defaultSort:"asc"},{title:"Mã đơn vị",field:"MaDonVi",type:"string",dataCheck:!0,searchable:!0,defaultSort:"asc"},{title:"Tên đơn vị",field:"TenDonVi",type:"string",dataCheck:!0,searchable:!0},{title:"Cấp ngân sách",field:"DM_CapNganSach.Name",type:"string",dataRef:["CapNganSach_Id"],customCol:!0,cellStyle:{width:100},editComponent:o=>e.jsx(S,{url:"DM_CapNganSach",valueField:"Id",textField:"Name",value:o.value,onChange:t=>t?o.onChange(t):o.onChange(null)})}],j=E.createRef(),T=()=>j.current&&j.current.onQueryChange();class re extends d.Component{constructor(n){super(n);u(this,"handleKeyPress",(n,s)=>{this.setState({TenDonVi:n.target.value},s.onFilterChanged(8,n===null?null:n.value))});u(this,"handleSelect",n=>{let s={DonVi_Id:n.ID,NhomDoiTuong_Id:this.props.nhomDoiTuongId};D("RP_NhomDoiTuong_DonVi","POST",JSON.stringify(s)).then(()=>{T(),this.props.reloadList()})});this.state={DonVi_Id:null,TenDonVi:null,MaDonVi:null,LoaiDonVi_Id:null}}render(){const{TenDonVi:n,MaDonVi:s,CapNganSach_Id:i,LoaiDonVi_Id:l}=this.state,{nhomDoiTuongId:h}=this.props,c=[];return(h||l)&&c.push(`nhomDoiTuongId=${h}&tenDonVi=${n}&maDonVi=${s}&capNganSach_Id=${i}&LoaiDonVi_Id=${l}`),e.jsx("div",{className:"index-create-nhom-doi-tuong",children:e.jsx(q,{title:"Thêm đơn vị trong hệ thống",open:this.props.open,handleClose:this.props.onClose,maxWidth:"md",children:e.jsx(F,{tableRef:j,onRefresh:!1,urlExt:"NhomDoiTuong/GetDonVisKhongThuocNhomDonVi",where:c.join(" and "),columns:le,SearchAdvanced:r=>e.jsxs(O,{className:"mt-4",children:[e.jsx(x,{lg:"3",md:"3",children:e.jsx(z,{defaultValue:n,placeholder:"Tìm theo tên đơn vị",onKeyPress:a=>a.charCode===13&&this.handleKeyPress(a,r)})}),e.jsx(x,{lg:"3",md:"3",children:e.jsx(S,{url:"DM_CapNganSach",valueField:"Id",placeholder:"Chọn cấp ngân sách",textField:"Name",value:i,onChange:a=>this.setState({CapNganSach_Id:a},()=>T())})}),e.jsx(x,{lg:"3",md:"3",children:e.jsx(S,{url:"LoaiDonVis",valueField:"ID",placeholder:"Chọn loại đơn vị",textField:"TenLoaiDonVi",value:l,onChange:a=>this.setState({LoaiDonVi_Id:a},()=>T())})}),e.jsx(x,{lg:"3",md:"3",children:e.jsx(ae,{nhomDoiTuongId:h,LoaiDonVi_Id:l,reloadTable:T})})]}),selectType:"withColumns",onActions:[{icon:"check",tooltip:"Chọn",onClick:(r,a)=>this.handleSelect(a)}]})})})}}function he({open:o,onClose:t,nhomDoiTuongId:n,reloadList:s}){const[i,l]=d.useState(null),h=d.useRef(),c=()=>{if(i&&i.file){const r=new FormData(h.current);r.append("nhomDoiTuongId",n),R("NhomDoiTuong/InsertAllDonVi","POST",r).then(a=>{V("Cập nhật thông tin thành công","Thông báo"),s(),t()}).catch(a=>g("Đã xảy ra lỗi","Thông báo"))}else K("Vui lòng chọn file excel trước khi lưu")};return e.jsx(k,{className:"themDonVi",size:"sm",open:o,onClose:t,maxWidth:"md",children:e.jsxs(se,{size:"sm",style:{maxWidth:"50%",maxHeight:"100%",marginLeft:"27%"},children:[e.jsx(W,{style:{backgroundColor:"rgb(3,56,99)",color:"#fff"},children:e.jsx("strong",{children:"Nhập từ tập tin Excel"})}),e.jsxs(G,{children:[e.jsx("p",{children:e.jsxs("span",{children:["Bước 1: Chọn",e.jsxs("a",{href:"/assets/FileMau/tap-tin-mau.xlsx",download:!0,children:[" ","tập tin mẫu"]})," ","và điền thông tin đơn vị vào tập tin mẫu"," "]})}),e.jsx("p",{children:e.jsx("span",{children:"Bước 2: Chọn tập tin Excel đã điền đầy đủ các thông tin đơn vị cần thêm"})}),e.jsx(x,{xs:"8",children:e.jsx("form",{ref:h,children:e.jsx(H,{name:"file",onChange:r=>l({file:r}),title:"Chọn tập tin excel đã điền đầy đủ",accept:"application/xlsx"})})}),e.jsx("p",{style:{marginTop:"5px"},children:e.jsxs("span",{children:["Bước 3: Nhấn nút ",e.jsx(m,{size:"sm",color:"success",onClick:c,children:"Lưu và Thêm"})," để thêm đơn vị vào nhóm đối tượng"]})})]})]})})}function ce(o){const{DonVi_Id:t,TenDonVi:n,isOpen:s,onClose:i}=o;return e.jsx(Z,{isOpen:s,toggle:i,size:"xl",zIndex:"1300",children:e.jsx(ee,{children:e.jsx(ne,{DonVi_Id:t,TenDonVi:n})})})}const de=[{field:"Id",dataID:!0,type:"guid",hidden:!0},{title:"STT",field:"SYS_DonVi.STT",type:"string",defaultSort:"asc",hidden:!0},{title:"Mã đơn vị",field:"SYS_DonVi.MaDonVi",type:"string",dataCheck:!0,searchable:!0,defaultSort:"asc"},{field:"SYS_DonVi.ID",type:"string",dataCheck:!0,hidden:!0},{title:"Tên đơn vị",field:"SYS_DonVi.TenDonVi",type:"string",dataCheck:!0,searchable:!0},{title:"Tài khoản quản trị",field:"SYS_DonVi.SYS_TaiKhoan.*",type:"string",dataCheck:!0,cellStyle:{textAlign:"center",display:"flex",justifyContent:"center"},render:o=>{const t=o.SYS_DonVi.SYS_TaiKhoan.find(n=>n.TaiKhoanQuanTri===!0);return t?e.jsx("div",{children:t.MaTaiKhoan}):e.jsx("div",{className:"alert alert-warning",style:{marginBottom:0,padding:0,width:"70%"},children:"Chưa có tài khoản quản trị!"})}},{title:"Nhóm đối trượng",field:"RP_NhomDoiTuong.*",type:"string",hidden:!0}],I=E.createRef(),C=()=>I.current&&I.current.onQueryChange();class ke extends d.Component{constructor(n){super(n);u(this,"reloadTableParent",()=>{this.props.reloadTableIndex&&this.props.reloadTableIndex()});u(this,"onCreateAccount",n=>{n.SYS_DonVi.SYS_TaiKhoan.find(i=>i.TaiKhoanQuanTri===!0)?g("Đơn vị đã có tài khoản. Không thể tạo!"):D(`QuanLyTaiKhoan/ThemTaiKhoanChoDonVi?DonVi_Id=${n.SYS_DonVi.ID}`,"POST",JSON.stringify({}),{odata:!1}).then(()=>{C(),this.reloadTableParent()}).catch(()=>g("Lỗi!"))});u(this,"onDeleteImportExcelFalse",()=>w("Bạn chắc chắn muốn xóa tất cả đơn vị khỏi nhóm đối tượng?","Thông báo").then(()=>{const{nhomDoiTuongId:n}=this.props;D(`NhomDoiTuong/XoaDonVis?Id=${n}`,"DELETE",null,{odata:!1}).then(()=>{C(),V("Xóa thành công","Thông báo")}).catch(()=>g("Xóa không thành công","Thông báo"))}));this.state={openCreate:!1,openTextArea:!1,openPhongBan:!1,DonVi_Id:null,TenDonVi:null}}render(){const{nhomDoiTuongId:n,IsChonPhongBan:s}=this.props,{openPhongBan:i,DonVi_Id:l,TenDonVi:h}=this.state;return e.jsx(k,{title:`${this.props.Name}`,open:this.props.open,onClose:this.props.onClose,children:e.jsxs("div",{className:"index-detail-ndt bg-white rounded p-3",children:[e.jsxs("div",{className:"d-flex mb-3",children:[e.jsx(b,{nhomDoiTuongId:n,importExcel:!0,title:e.jsxs("span",{children:["Import excel = ",e.jsx("b",{children:"True"})]})}),e.jsx(b,{nhomDoiTuongId:n,importExcel:!1,title:e.jsxs("span",{children:["Import excel = ",e.jsx("b",{children:"False"})]})}),e.jsxs("div",{className:"d-flex gap-2",children:[e.jsx(m,{size:"sm",color:"primary",onClick:()=>this.setState({openCreate:!0,ID:null}),children:"Thêm từ hệ thống"}),e.jsx(m,{size:"sm",color:"success",onClick:()=>this.setState({openTextArea:!0}),children:"Thêm từ excel"}),e.jsxs(m,{size:"sm",color:"danger",onClick:()=>this.onDeleteImportExcelFalse(),children:["Xóa tất cả đơn vị Import ",e.jsx("b",{children:"False"})]})]})]}),e.jsx(F,{tableRef:I,title:e.jsx("div",{className:"d-flex justify-content-between w-100",children:e.jsx("div",{children:"DANH SÁCH ĐƠN VỊ"})}),url:"RP_NhomDoiTuong_DonVi",columns:[...de,{field:"Id",title:"Tạo tài khoản",type:"numeric",cellStyle:{width:"12rem"},render:c=>{const r=c.SYS_DonVi.SYS_TaiKhoan.find(a=>a.TaiKhoanQuanTri===!0);return e.jsx(e.Fragment,{children:!r&&e.jsxs(m,{onClick:()=>this.onCreateAccount(c),className:"btn-create-tk",children:[e.jsx(_,{fa:"plus"})," Tạo tài khoản"]})})}}],where:`NhomDoiTuong_Id eq ${n}`,selectType:"withColumns",onAdd:{disabled:!0},onDelete:{},onActions:[{icon:"list",tooltip:"Phòng ban",onClick:(c,r)=>{var a,f;return this.setState({openPhongBan:!0,DonVi_Id:(a=r.SYS_DonVi)==null?void 0:a.ID,TenDonVi:(f=r.SYS_DonVi)==null?void 0:f.TenDonVi})},hidden:!s}]}),i&&e.jsx(ce,{isOpen:i,onClose:()=>this.setState({openPhongBan:!1,DonVi_Id:null,TenDonVi:null}),DonVi_Id:l,TenDonVi:h}),e.jsx(re,{ID:this.props.ID,nhomDoiTuongId:n,open:this.state.openCreate,onClose:()=>this.setState({openCreate:!1}),reloadList:C}),e.jsx(he,{open:this.state.openTextArea,reloadList:C,nhomDoiTuongId:n,onClose:()=>this.setState({openTextArea:!1})})]})})}}const b=d.memo(o=>{const{nhomDoiTuongId:t,title:n,importExcel:s}=o,[i,l]=d.useState(!1),[h,c]=d.useState(0),r="NhomDoiTuong/GetNhomDoiTuong";d.useEffect(()=>{t&&f()},[t,s]);const a=()=>l(!i),f=()=>{D(`RP_NhomDoiTuong_DonVi?$filter=NhomDoiTuong_Id eq ${t} and IsImportExcel eq ${s}`,"GET",null).then(p=>c(p.value.length))},N=(p="pdf")=>{let v=p;p==="excel"&&(v="xlsx"),t&&B(`${r}?Id=${t}&IsDownload=true&IsImportExcel=${s}&mode=download_${p}&pageSize=A4&landscape=false`,`Tải xuống.${v}`,"GET",null,!0).then(()=>{}).catch(()=>g("Đã xảy ra lỗi tải file!","Thông báo"))};return e.jsxs(M,{isOpen:i,toggle:a,className:"me-2",children:[e.jsxs(L,{caret:!0,color:"success",size:"sm",children:[e.jsx(_,{fa:"print"})," ",n," (",h," đơn vị)"]}),e.jsxs(Y,{children:[e.jsx(y,{onClick:()=>N(),children:"PDF"}),e.jsx(y,{onClick:()=>N("excel"),children:"Excel"})]})]})});export{ke as I};