????
Current Path : C:/inetpub/vhost/donthu.nextform.vn/wwwroot/assets/ |
Current File : C:/inetpub/vhost/donthu.nextform.vn/wwwroot/assets/index-C52_WKpP.js |
var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});import{ao as useService,bX as CanBo,k as jsxRuntimeExports,o as styled,ag as Avatar,r as reactExports,F as useAuth,bh as CHECK_SUCCESS,bi as CHECK_ERROR,bK as lodashExports,bW as iniAddress,C as Card,B as Box,P as Paper,am as Grid,x as IconButton,I as Icon,y as Button,aH as CircularProgress,aG as Stack,bg as CHECK_CONFIRM,bj as CHECK_WARNING}from"./index-y1X-EiI1.js";import{j as useDetailUser,u as useAsync,F as Form,b as CardContent,a as FormControl,A as Address,n as Enums_GioiTinh,D as DataTable}from"./DataTable-BEDH0i35.js";import{u as useCanBo}from"./CanBo.service-1WolgtmP.js";import{B as Badge}from"./Badge-BUU8rl3f.js";import{a as DialogTitle,b as DialogContent,c as DialogActions,D as Dialog}from"./DialogTitle-B28XGy8_.js";import"./Tooltip-C0pwvyhl.js";import"./Popper-BN0GgV3z.js";import"./utils-B_XeHYak.js";import"./TableRow-BfZy-RM-.js";import"./FormGroup-CEJG6asl.js";import"./ListItemText-BvrfP19N.js";import"./Autocomplete-CpStdzj7.js";import"./Close-DnCuke95.js";import"./usePreviousProps-eNEUPQQG.js";import"./Chip-4iuxTgqW.js";import"./warning-BmqNoLzl.js";import"./TablePagination-Dnie0nHQ.js";import"./Toolbar-BZCdaOvb.js";import"./LoadingButton-DgqpHLzy.js";import"./Collapse-YEAu7S3-.js";import"./Alert-AfWalC00.js";import"./Switch-BlzK9Osj.js";import"./SwitchBase-HB81Uehs.js";import"./Checkbox-B8nePMFP.js";import"./AppBar-BrohM22l.js";function useCanBoDefault(){const auth=useService(CanBo,"auth");return{postCanBo:__name(data=>auth.post({url:"/CreateUser",body:data}),"postCanBo")}}__name(useCanBoDefault,"useCanBoDefault");const columns=[{title:"id",field:"id",type:"numeric",dataID:!0,editable:"never",hidden:!0},{title:"id",field:"userId",type:"numeric",dataID:!0,editable:"never",hidden:!0},{title:"CCCD / SĐDanh",field:"cccd",type:"string",dataCheck:!0,searchable:!0},{title:"Tên",field:"hoVaTen",type:"string",searchable:!0},{title:"Giới tính",field:"gioiTinh",type:"string",dataCheck:!0,searchable:!0,render:rowData=>jsxRuntimeExports.jsx("span",{style:{fontSize:12},children:rowData.gioiTinh})},{title:"Chức vụ",field:"chucVu",type:"string",dataCheck:!0,searchable:!0},{title:"Phòng ban",field:"phongBan",type:"string",dataCheck:!0,searchable:!0},{title:"Vai trò",field:"roleName",type:"string",dataCheck:!0,searchable:!0}],formData$1={soDinhDanh:{field_name:"thongTinCaNhan.soDinhDanh",title:"Số định danh",type:"select-creatable",rules:{required:"Vui lòng nhập",maxLength:{value:12,message:"Vui lòng nhập ít nhất 12 số"},minLength:{value:12,message:"Vui lòng nhập ít nhất 12 số"},pattern:{value:/^[0-9]*$/,message:"Phải là số"}}},hoVaTenDem:{field_name:"thongTinCaNhan.hoVaTenDem",title:"Họ và tên đệm",type:"textbox",rules:{required:"Vui lòng nhập"}},ten:{field_name:"thongTinCaNhan.ten",title:"Tên",type:"textbox",rules:{required:"Vui lòng nhập"}},email:{field_name:"thongTinCaNhan.email",title:"Email",type:"textbox",rules:{required:"Vui lòng nhập",pattern:{value:/\S+@\S+\.\S+/,message:"Sai định dạng email"}}},gioiTinh:{field_name:"thongTinCaNhan.gioiTinh",title:"Giới tính",type:"select-custom",rules:{required:"Vui lòng nhập"},options:Enums_GioiTinh},ngayCap:{field_name:"thongTinCaNhan.ngayCap",title:"Ngày cấp",type:"datetime"},noiCapCuThe:{field_name:"thongTinCaNhan.noiCapCuThe",title:"Nơi cấp cụ thể",type:"textbox"},quocTichId:{field_name:"thongTinCaNhan.quocTichId",title:"Quốc tịch",type:"select-async",value_field:"id",value_label:"name",url:"/api/buss/public/DanhMuc/GetQuocGia"},danTocId:{field_name:"thongTinCaNhan.danTocId",title:"Dân tộc",type:"select-async",value_field:"id",value_label:"name",url:"/api/buss/public/DanhMuc/GetDanToc"},dienThoai:{field_name:"thongTinCaNhan.dienThoai",title:"Điện thoại",type:"textbox"},thuongTruCuThe:{field_name:"thongTinCaNhan.thuongTruCuThe",title:"Địa chỉ",type:"textbox"}},formDataCanBo={dmChucVuId:{field_name:"canBo.dmChucVuId",title:"Chức vụ",type:"select-async",value_field:"id",value_label:"name",url:"/api/buss/allow/DMChucVus",rules:{required:"Vui lòng nhập"}},dmPhongBanId:{field_name:"canBo.dmPhongBanId",title:"Phòng ban",type:"select-async",value_field:"id",value_label:"name",url:"/api/buss/allow/DMPhongBans",rules:{required:"Vui lòng nhập"}}},BadgeMain=styled(props=>jsxRuntimeExports.jsx(Badge,{...props}))(({theme})=>({position:"relative",display:"flex",justifyContent:"center"})),MainAvatar=styled(Avatar)(({theme})=>({width:100,height:100,border:"2px solid"})),Index$1=__name(({onClose,open,id})=>{const[data,setData]=reactExports.useState({}),{getCanBoById,postCanBo,updateCanBo}=useCanBo(),{postDetailUser,updateDetailUser}=useDetailUser(),{user}=useAuth(),refForm=reactExports.useRef(),getDataById=reactExports.useCallback(async id2=>{try{const{thongTinCaNhan,...data2}=await getCanBoById(id2,{expand:{thongTinCaNhan:{expand:["thuongTruTinh","thuongTruHuyen","thuongTru"]}}}),dataIni={canBo:data2,thongTinCaNhan:{...thongTinCaNhan,soDinhDanh:{value:thongTinCaNhan.soDinhDanh,label:thongTinCaNhan.soDinhDanh+" - "+thongTinCaNhan.hoVaTenDem+" "+thongTinCaNhan.ten}},province:thongTinCaNhan==null?void 0:thongTinCaNhan.thuongTruTinh,district:thongTinCaNhan==null?void 0:thongTinCaNhan.thuongTruHuyen,ward:thongTinCaNhan==null?void 0:thongTinCaNhan.thuongTru};return setData(dataIni),dataIni}catch{}},[getCanBoById]),handleSubmit=reactExports.useCallback(async dataForm=>{try{let{province,district,ward,thongTinCaNhan,canBo}=dataForm;if(thongTinCaNhan.thuongTruTinhCode=(province==null?void 0:province.code)||void 0,thongTinCaNhan.thuongTruHuyenCode=(district==null?void 0:district.code)||void 0,thongTinCaNhan.thuongTruCode=(ward==null?void 0:ward.code)||void 0,user&&(canBo.organizationId=user.organizationId),id)delete thongTinCaNhan.thuongTru,delete thongTinCaNhan.thuongTruHuyen,delete thongTinCaNhan.thuongTruTinh,dataForm.thongTinCaNhan.soDinhDanh&&(thongTinCaNhan.soDinhDanh=dataForm.thongTinCaNhan.soDinhDanh.value),canBo.thongTinCaNhanId&&await updateDetailUser(canBo.thongTinCaNhanId,thongTinCaNhan),await updateCanBo(id,canBo);else{let newThongTinCaNhan=null;data.canBo.thongTinCaNhanId?(await updateDetailUser(data.canBo.thongTinCaNhanId,thongTinCaNhan),await postCanBo({...canBo,thongTinCaNhanId:data.canBo.thongTinCaNhanId})):(newThongTinCaNhan=await postDetailUser(thongTinCaNhan),await postCanBo({...canBo,thongTinCaNhanId:newThongTinCaNhan.resultObj.id}))}CHECK_SUCCESS("Cập nhật thành công"),onClose()}catch(error){CHECK_ERROR(error)}},[user,id,onClose,updateDetailUser,updateCanBo,data,postDetailUser,postCanBo]),{execute,status}=useAsync(handleSubmit),handleChangeNS=reactExports.useCallback((name,value)=>{switch(name){case"thongTinCaNhan.soDinhDanh":const{id:id2}=value||{};setData(id2?pre=>({...pre,canBo:{thongTinCaNhanId:id2},thongTinCaNhan:value}):pre=>{const data2={...pre};return lodashExports.set(data2,"thongTinCaNhan",{}),lodashExports.set(data2,name,value.value),lodashExports.set(data2,"canBo.thongTinCaNhanId",""),data2});break;default:setData(pre=>({...pre,[name]:value}));break}},[]),getInitData=reactExports.useCallback(()=>Promise.resolve(iniAddress),[]),renderFormCreate=reactExports.useMemo(()=>jsxRuntimeExports.jsxs(reactExports.Fragment,{children:[jsxRuntimeExports.jsx(DialogTitle,{sx:{padding:"0.5rem"},children:"Thêm mới"}),jsxRuntimeExports.jsx(DialogContent,{sx:{padding:"0px"},children:jsxRuntimeExports.jsx(Form,{ref:refForm,onSubmit:execute,defaultValues:()=>id?getDataById(id):getInitData(),children:jsxRuntimeExports.jsx(Card,{children:jsxRuntimeExports.jsx(CardContent,{sx:{background:"#E7EBF0"},children:jsxRuntimeExports.jsx(Box,{children:jsxRuntimeExports.jsx(Paper,{sx:{borderRadius:"0.3rem",padding:"1rem"},children:jsxRuntimeExports.jsxs(Grid,{rowGap:1,container:!0,xs:12,children:[jsxRuntimeExports.jsxs(Grid,{item:!0,xs:6,children:[Object.entries(formData$1).map(([key,value],idx)=>{var _a,_b;return idx<=4?jsxRuntimeExports.jsxs(Grid,{display:"flex",children:[idx<1&&jsxRuntimeExports.jsx(Grid,{item:!0,xs:4,display:"relative",children:jsxRuntimeExports.jsx(BadgeMain,{overlap:"circular",anchorOrigin:{vertical:"bottom",horizontal:"right"},badgeContent:jsxRuntimeExports.jsxs(IconButton,{color:"primary","aria-label":"upload picture",component:"label",children:[jsxRuntimeExports.jsx("input",{hidden:!0,accept:"image/*",type:"file",onChange:()=>{}}),jsxRuntimeExports.jsx(Icon,{children:"photo_camera"})]}),children:jsxRuntimeExports.jsx(MainAvatar,{alt:"Travis Howard",src:"/assets/images/avatar/002-woman.svg"})})}),jsxRuntimeExports.jsx(Grid,{item:!0,xs:idx<1?8:12,children:jsxRuntimeExports.jsx(FormControl,{data:{...value,name:value.field_name,disabled:key==="soDinhDanh"&&!id&&((_a=data.thongTinCaNhan)!=null&&_a.id)?!1:(_b=data.thongTinCaNhan)==null?void 0:_b.id},rules:value.rules,name:value.field_name,value:lodashExports.get(data,value.field_name,null),onChange:handleChangeNS,fullLine:idx<1,defaultValue:value.defaultValue||data[value.field_name]})})]},idx+key):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})}),Object.entries(formDataCanBo).map(([key,value],idx)=>idx<3?jsxRuntimeExports.jsx(Grid,{item:!0,xs:12,children:jsxRuntimeExports.jsx(FormControl,{data:{...value,name:value.field_name},rules:value.rules,name:value.field_name,value:lodashExports.get(data,value.field_name,null),onChange:handleChangeNS,defaultValue:value.defaultValue||data[value.field_name]},idx+key)},idx+2+key):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{}))]}),jsxRuntimeExports.jsx(Grid,{item:!0,xs:6,children:Object.entries(formData$1).map(([key,value],idx,arr)=>idx>=6?jsxRuntimeExports.jsxs(Grid,{item:!0,xs:12,children:[idx===arr.length-1&&jsxRuntimeExports.jsx(Address,{isRequire:!1,value:data.address}),jsxRuntimeExports.jsx(FormControl,{data:{...value,name:value.field_name},rules:value.rules,name:value.field_name,value:lodashExports.get(data,value.field_name,null),onChange:handleChangeNS,defaultValue:value.defaultValue||data[value.field_name]},idx+key)]},idx+3+key):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{}))})]})})})})})})}),jsxRuntimeExports.jsxs(DialogActions,{children:[jsxRuntimeExports.jsx(Button,{size:"small",color:"error",startIcon:jsxRuntimeExports.jsx(Icon,{children:"cancel"}),onClick:onClose,disabled:!1,children:"Hủy"}),jsxRuntimeExports.jsx(Button,{size:"small",type:"button",onClick:()=>{refForm.current.submit()},variant:"outlined",startIcon:status==="pending"?jsxRuntimeExports.jsx(CircularProgress,{size:20}):jsxRuntimeExports.jsx(Icon,{children:"save"}),disabled:status==="pending",children:"Lưu"})]})]}),[data,execute,getDataById,getInitData,handleChangeNS,id,onClose,status]);return jsxRuntimeExports.jsx(Dialog,{fullWidth:!0,disableEnforceFocus:!0,disableAutoFocus:!0,maxWidth:"md",onClose,open:!!open,children:renderFormCreate})},"Index$1"),UpdateForm=reactExports.memo(Index$1),formData={vaiTroId:{field_name:"vaiTroId",title:"Vai trò",type:"select-async",value_field:"id",value_label:"name",url:"/api/admin/allow/Roles?$filter=isRoot eq false &",rules:{required:"Vui lòng chọn"}}},CreateUser=reactExports.memo(({isOpen,onClose})=>{const{postCanBo}=useCanBoDefault(),handleSubmit=reactExports.useCallback(async data=>{try{isOpen&&await postCanBo({...data,canBoId:isOpen.id}),CHECK_SUCCESS("Cấp tài khoản thành công"),onClose()}catch(error){console.log(error)}},[isOpen,onClose,postCanBo]),{execute,status}=useAsync(handleSubmit),refForm=reactExports.useRef(null);return jsxRuntimeExports.jsxs(Dialog,{fullWidth:!0,disableEnforceFocus:!0,disableAutoFocus:!0,maxWidth:"xs",open:!!isOpen,children:[jsxRuntimeExports.jsx(DialogTitle,{children:jsxRuntimeExports.jsxs(Stack,{display:"flex",direction:"row",alignItems:"center",gap:1,children:[jsxRuntimeExports.jsx("p",{style:{fontSize:"1rem",margin:0},children:"Cấp tài khoản cho cán bộ :"}),jsxRuntimeExports.jsx("h4",{style:{margin:0},children:isOpen==null?void 0:isOpen.hoVaTen})]})}),jsxRuntimeExports.jsx(DialogContent,{children:jsxRuntimeExports.jsx(Form,{ref:refForm,onSubmit:execute,children:jsxRuntimeExports.jsx(Stack,{direction:"column",children:Object.entries(formData).map(([key,value],idx)=>jsxRuntimeExports.jsx(Grid,{item:!0,xs:12,children:jsxRuntimeExports.jsx(FormControl,{data:{...value,name:value.field_name},rules:value.rules,name:value.field_name},idx+key)},idx+2+key))})})}),jsxRuntimeExports.jsxs(DialogActions,{children:[jsxRuntimeExports.jsx(Button,{size:"small",onClick:onClose,color:"error",startIcon:jsxRuntimeExports.jsx(Icon,{children:"cancel"}),disabled:!1,children:"Hủy"}),jsxRuntimeExports.jsx(Button,{size:"small",type:"button",onClick:()=>{refForm.current.submit()},variant:"outlined",startIcon:status==="pending"?jsxRuntimeExports.jsx(CircularProgress,{size:20}):jsxRuntimeExports.jsx(Icon,{children:"save"}),disabled:status==="pending",children:"Lưu"})]})]})}),Index=__name(()=>{const tableRef=reactExports.createRef(),[openConfig,setOpenConfig]=reactExports.useState({}),reloadTable=__name(()=>tableRef.current&&tableRef.current.onQueryChange(),"reloadTable"),[openCreateUser,setOpenCreateUser]=reactExports.useState(""),{deleteCanBo}=useCanBo();return jsxRuntimeExports.jsxs(Box,{children:[jsxRuntimeExports.jsx(Grid,{container:!0,children:jsxRuntimeExports.jsx(DataTable,{tableRef,isAuth:!0,url:"/default/allow/CanBoWithRoles",title:"Danh sách cán bộ",columns,selectType:"withColumns",onAdd:{onClick:()=>{setOpenConfig({status:"open"})}},onEdit:{onClick:(e,rowData)=>{setOpenConfig({status:"open",id:rowData.id})}},onDelete:{onClick:(e,rowData)=>{CHECK_CONFIRM(`${rowData.thongTinCaNhan.hoVaTenDem} ${rowData.thongTinCaNhan.ten}`,"Bạn chắc chắn xóa cán bộ này","danger").then(res=>{res&&res.isConfirmed&&deleteCanBo(rowData.id).then(cur=>{reloadTable()}).catch(err=>CHECK_WARNING("Thao tác không thành công"))})}},onActions:[dataRow=>({icon:"display_settings",color:"warning",tooltip:"Tạo tài khoản",disabled:dataRow&&dataRow.userId,onClick:(event,rowData)=>{setOpenCreateUser(rowData)}})]})}),openConfig&&jsxRuntimeExports.jsx(UpdateForm,{open:openConfig.status,id:openConfig.id,onClose:()=>{reloadTable(),setOpenConfig(null)}}),jsxRuntimeExports.jsx(CreateUser,{isOpen:openCreateUser,onClose:()=>{reloadTable(),setOpenCreateUser("")}})]})},"Index");export{Index as default,formData};