code
stringlengths 1
1.05M
| repo_name
stringlengths 6
83
| path
stringlengths 3
242
| language
stringclasses 222
values | license
stringclasses 20
values | size
int64 1
1.05M
|
|---|---|---|---|---|---|
package com.mycode.finance.mapper;
import com.mycode.finance.entity.Loan;
import com.mycode.finance.entity.LoanExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface LoanMapper {
long countByExample(LoanExample example);
int deleteByExample(LoanExample example);
int deleteByPrimaryKey(Integer id);
int insert(Loan record);
int insertSelective(Loan record);
List<Loan> selectByExample(LoanExample example);
Loan selectByPrimaryKey(Integer id);
List<Loan> selectByExampleWithUserAndAdmin(LoanExample example);
Loan selectByPrimaryKeyWithUserAndAdmin(Integer id);
int updateByExampleSelective(@Param("record") Loan record, @Param("example") LoanExample example);
int updateByExample(@Param("record") Loan record, @Param("example") LoanExample example);
int updateByPrimaryKeySelective(Loan record);
int updateByPrimaryKey(Loan record);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/mapper/LoanMapper.java
|
Java
|
mit
| 940
|
package com.mycode.finance.mapper;
import com.mycode.finance.entity.News;
import com.mycode.finance.entity.NewsExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface NewsMapper {
long countByExample(NewsExample example);
int deleteByExample(NewsExample example);
int deleteByPrimaryKey(Integer id);
int insert(News record);
int insertSelective(News record);
List<News> selectByExample(NewsExample example);
News selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") News record, @Param("example") NewsExample example);
int updateByExample(@Param("record") News record, @Param("example") NewsExample example);
int updateByPrimaryKeySelective(News record);
int updateByPrimaryKey(News record);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/mapper/NewsMapper.java
|
Java
|
mit
| 812
|
package com.mycode.finance.mapper;
import com.mycode.finance.entity.PayMoney;
import com.mycode.finance.entity.PayMoneyExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface PayMoneyMapper {
long countByExample(PayMoneyExample example);
int deleteByExample(PayMoneyExample example);
int deleteByPrimaryKey(Integer id);
int insert(PayMoney record);
int insertSelective(PayMoney record);
List<PayMoney> selectByExample(PayMoneyExample example);
PayMoney selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") PayMoney record, @Param("example") PayMoneyExample example);
int updateByExample(@Param("record") PayMoney record, @Param("example") PayMoneyExample example);
int updateByPrimaryKeySelective(PayMoney record);
int updateByPrimaryKey(PayMoney record);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/mapper/PayMoneyMapper.java
|
Java
|
mit
| 876
|
package com.mycode.finance.mapper;
import com.mycode.finance.entity.Permissions;
import com.mycode.finance.entity.PermissionsExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface PermissionsMapper {
long countByExample(PermissionsExample example);
int deleteByExample(PermissionsExample example);
int deleteByPrimaryKey(Integer id);
int insert(Permissions record);
int insertSelective(Permissions record);
List<Permissions> selectByExample(PermissionsExample example);
Permissions selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") Permissions record, @Param("example") PermissionsExample example);
int updateByExample(@Param("record") Permissions record, @Param("example") PermissionsExample example);
int updateByPrimaryKeySelective(Permissions record);
int updateByPrimaryKey(Permissions record);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/mapper/PermissionsMapper.java
|
Java
|
mit
| 924
|
package com.mycode.finance.mapper;
import com.mycode.finance.entity.TermFinancial;
import com.mycode.finance.entity.TermFinancialExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TermFinancialMapper {
long countByExample(TermFinancialExample example);
int deleteByExample(TermFinancialExample example);
int deleteByPrimaryKey(Integer id);
int insert(TermFinancial record);
int insertSelective(TermFinancial record);
List<TermFinancial> selectByExample(TermFinancialExample example);
TermFinancial selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") TermFinancial record, @Param("example") TermFinancialExample example);
int updateByExample(@Param("record") TermFinancial record, @Param("example") TermFinancialExample example);
int updateByPrimaryKeySelective(TermFinancial record);
int updateByPrimaryKey(TermFinancial record);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/mapper/TermFinancialMapper.java
|
Java
|
mit
| 956
|
package com.mycode.finance.mapper;
import com.mycode.finance.entity.UserChangeMoney;
import com.mycode.finance.entity.UserChangeMoneyExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface UserChangeMoneyMapper {
long countByExample(UserChangeMoneyExample example);
int deleteByExample(UserChangeMoneyExample example);
int deleteByPrimaryKey(Integer id);
int insert(UserChangeMoney record);
int insertSelective(UserChangeMoney record);
List<UserChangeMoney> selectByExample(UserChangeMoneyExample example);
UserChangeMoney selectByPrimaryKey(Integer id);
List<UserChangeMoney> selectByExampleWithUserAndChangeMoney(UserChangeMoneyExample example);
UserChangeMoney selectByPrimaryKeyWithUserAndChangeMoney(Integer id);
int updateByExampleSelective(@Param("record") UserChangeMoney record, @Param("example") UserChangeMoneyExample example);
int updateByExample(@Param("record") UserChangeMoney record, @Param("example") UserChangeMoneyExample example);
int updateByPrimaryKeySelective(UserChangeMoney record);
int updateByPrimaryKey(UserChangeMoney record);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/mapper/UserChangeMoneyMapper.java
|
Java
|
mit
| 1,162
|
package com.mycode.finance.mapper;
import com.mycode.finance.entity.UserFundProduct;
import com.mycode.finance.entity.UserFundProductExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface UserFundProductMapper {
long countByExample(UserFundProductExample example);
int deleteByExample(UserFundProductExample example);
int deleteByPrimaryKey(Integer id);
int insert(UserFundProduct record);
int insertSelective(UserFundProduct record);
List<UserFundProduct> selectByExample(UserFundProductExample example);
UserFundProduct selectByPrimaryKey(Integer id);
List<UserFundProduct> selectByExampleWithUserAndFundProduct(UserFundProductExample example);
UserFundProduct selectByPrimaryKeyWithUserAndFundProduct(Integer id);
int updateByExampleSelective(@Param("record") UserFundProduct record, @Param("example") UserFundProductExample example);
int updateByExample(@Param("record") UserFundProduct record, @Param("example") UserFundProductExample example);
int updateByPrimaryKeySelective(UserFundProduct record);
int updateByPrimaryKey(UserFundProduct record);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/mapper/UserFundProductMapper.java
|
Java
|
mit
| 1,161
|
package com.mycode.finance.mapper;
import com.mycode.finance.entity.User;
import com.mycode.finance.entity.UserExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface UserMapper {
long countByExample(UserExample example);
int deleteByExample(UserExample example);
int deleteByPrimaryKey(Integer id);
int insert(User record);
int insertSelective(User record);
List<User> selectByExample(UserExample example);
User selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example);
int updateByExample(@Param("record") User record, @Param("example") UserExample example);
int updateByPrimaryKeySelective(User record);
int updateByPrimaryKey(User record);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/mapper/UserMapper.java
|
Java
|
mit
| 866
|
package com.mycode.finance.mapper;
import com.mycode.finance.entity.UserPayMoney;
import com.mycode.finance.entity.UserPayMoneyExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface UserPayMoneyMapper {
long countByExample(UserPayMoneyExample example);
int deleteByExample(UserPayMoneyExample example);
int deleteByPrimaryKey(Integer id);
int insert(UserPayMoney record);
int insertSelective(UserPayMoney record);
List<UserPayMoney> selectByExample(UserPayMoneyExample example);
UserPayMoney selectByPrimaryKey(Integer id);
List<UserPayMoney> selectByExampleWithUserAndPayMoney(UserPayMoneyExample example);
UserPayMoney selectByPrimaryKeyWithUserAndPayMoney(Integer id);
int updateByExampleSelective(@Param("record") UserPayMoney record, @Param("example") UserPayMoneyExample example);
int updateByExample(@Param("record") UserPayMoney record, @Param("example") UserPayMoneyExample example);
int updateByPrimaryKeySelective(UserPayMoney record);
int updateByPrimaryKey(UserPayMoney record);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/mapper/UserPayMoneyMapper.java
|
Java
|
mit
| 1,098
|
package com.mycode.finance.mapper;
import com.mycode.finance.entity.UserPermissions;
import com.mycode.finance.entity.UserPermissionsExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface UserPermissionsMapper {
long countByExample(UserPermissionsExample example);
int deleteByExample(UserPermissionsExample example);
int deleteByPrimaryKey(Integer id);
int insert(UserPermissions record);
int insertSelective(UserPermissions record);
List<UserPermissions> selectByExample(UserPermissionsExample example);
UserPermissions selectByPrimaryKey(Integer id);
List<UserPermissions> selectByExampleWithUserAndPermission(UserPermissionsExample example);
UserPermissions selectByPrimaryKeyWithUserAndPermission(Integer id);
int updateByExampleSelective(@Param("record") UserPermissions record, @Param("example") UserPermissionsExample example);
int updateByExample(@Param("record") UserPermissions record, @Param("example") UserPermissionsExample example);
int updateByPrimaryKeySelective(UserPermissions record);
int updateByPrimaryKey(UserPermissions record);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/mapper/UserPermissionsMapper.java
|
Java
|
mit
| 1,159
|
package com.mycode.finance.mapper;
import com.mycode.finance.entity.UserTermFinancial;
import com.mycode.finance.entity.UserTermFinancialExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface UserTermFinancialMapper {
long countByExample(UserTermFinancialExample example);
int deleteByExample(UserTermFinancialExample example);
int deleteByPrimaryKey(Integer id);
int insert(UserTermFinancial record);
int insertSelective(UserTermFinancial record);
List<UserTermFinancial> selectByExample(UserTermFinancialExample example);
UserTermFinancial selectByPrimaryKey(Integer id);
List<UserTermFinancial> selectByExampleWithUserAndTermFinancial(UserTermFinancialExample example);
UserTermFinancial selectByPrimaryKeyWithUserAndTermFinancial(Integer id);
int updateByExampleSelective(@Param("record") UserTermFinancial record, @Param("example") UserTermFinancialExample example);
int updateByExample(@Param("record") UserTermFinancial record, @Param("example") UserTermFinancialExample example);
int updateByPrimaryKeySelective(UserTermFinancial record);
int updateByPrimaryKey(UserTermFinancial record);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/mapper/UserTermFinancialMapper.java
|
Java
|
mit
| 1,203
|
package com.mycode.finance.service;
import com.mycode.finance.entity.AdminPermissions;
import java.util.List;
public interface AdminPermissionsService {
List<AdminPermissions> selectAdminPermissionsByAdminId(Integer adminId);
//AdminPermissions selectAdminPermissionsByPermissionId(Integer permissionId);
Integer insertAdminPermissions(AdminPermissions adminPermissions);
Integer UpdateAdminPermissions(AdminPermissions adminPermissions);
Integer deleteAdminPermissionsByPermissionId(Integer permissionId);
Integer deleteAllAdminPermissionsByAdminId(Integer adminId);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/AdminPermissionsService.java
|
Java
|
mit
| 604
|
package com.mycode.finance.service;
import com.mycode.finance.entity.Admin;
public interface AdminService {
Admin selectAdminByTerms(String username, String password);
Integer updateAdmin(Admin admin);
Admin selectAdminById(Integer id);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/AdminService.java
|
Java
|
mit
| 256
|
package com.mycode.finance.service;
import com.mycode.finance.entity.Bankcard;
import java.util.List;
public interface BankCardService {
List<Bankcard> selectAllBankCard();
List<Bankcard> selectBankCardByUserId(Integer userId);
Bankcard selectBankCardById(Integer id);
Integer insertBankCard(Bankcard bankcard);
Integer updateBankCard(Bankcard bankcard);
Integer deleteBankCardById(Integer id);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/BankCardService.java
|
Java
|
mit
| 430
|
package com.mycode.finance.service;
import com.mycode.finance.entity.Bank;
import java.util.List;
public interface BankService {
List<Bank> selectAllBank();
Bank selectBankById(Integer id);
Integer insertBank(Bank bank);
Integer updateBank(Bank bank);
Integer deleteBankById(Integer id);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/BankService.java
|
Java
|
mit
| 318
|
package com.mycode.finance.service;
import com.mycode.finance.entity.ChangeMoney;
import java.util.List;
public interface ChangeMoneyService {
List<ChangeMoney> selectAllChangeMoney();
ChangeMoney selectChangeMoneyById(Integer id);
Integer insertChangeMoney(ChangeMoney changeMoney);
Integer updateChangeMoney(ChangeMoney changeMoney);
Integer deleteChangeMoneyById(Integer id);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/ChangeMoneyService.java
|
Java
|
mit
| 409
|
package com.mycode.finance.service;
import com.mycode.finance.entity.FlowOfFunds;
import java.util.List;
public interface FlowOfFundsService {
Integer insertFlowOfFunds(FlowOfFunds flowOfFunds);
List<FlowOfFunds> selectFlowOfFundsByUserId(Integer userId);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/FlowOfFundsService.java
|
Java
|
mit
| 271
|
package com.mycode.finance.service;
import com.mycode.finance.entity.FundProduct;
import java.util.List;
public interface FundProductService {
List<FundProduct> selectAllFundProduct();
FundProduct selectFundProductById(Integer id);
Integer insertFundProduct(FundProduct fundProduct);
Integer updateFundProduct(FundProduct fundProduct);
Integer deleteFundProductById(Integer id);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/FundProductService.java
|
Java
|
mit
| 409
|
package com.mycode.finance.service;
import com.mycode.finance.entity.Info;
import java.util.List;
public interface InfoService {
List<Info> selectInfoOrderByUserIdDesc(Integer receiveid);
Info selectInfoById(Integer id);
Integer insertInfo(Info info);
Integer updateInfo(Info info);
Integer deleteInfobyId(Integer id);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/InfoService.java
|
Java
|
mit
| 349
|
package com.mycode.finance.service;
import com.mycode.finance.entity.Loan;
import java.util.List;
public interface LoanService {
Integer insertLoan(Loan loan);
List<Loan> selectLoanByLoanId(Integer loanId);
List<Loan> selectAllLoanByApplyStatusAsc();
List<Loan> selectAllExamedLoan();
Loan selectLoanById(Integer id);
Integer updateLoan(Loan loan);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/LoanService.java
|
Java
|
mit
| 384
|
package com.mycode.finance.service;
import com.mycode.finance.entity.News;
import java.util.List;
public interface NewsService {
List<News> selectAllNews();
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/NewsService.java
|
Java
|
mit
| 167
|
package com.mycode.finance.service;
import com.mycode.finance.entity.PayMoney;
import java.util.List;
public interface PayMoneyService {
List<PayMoney> selectAllPayMoney();
PayMoney selectPayMoneyById(Integer id);
Integer insertPayMoney(PayMoney payMoney);
Integer updatePayMoney(PayMoney payMoney);
Integer deletePayMoneyById(Integer id);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/PayMoneyService.java
|
Java
|
mit
| 370
|
package com.mycode.finance.service;
import com.mycode.finance.entity.Permissions;
import java.util.List;
public interface PermissionsService {
List<Permissions> selectPermissionsByPermission(String permission);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/PermissionsService.java
|
Java
|
mit
| 221
|
package com.mycode.finance.service;
import com.mycode.finance.entity.TermFinancial;
import java.util.List;
public interface TermFinancialService {
List<TermFinancial> selectAllTermFinancial();
TermFinancial selectTermFinancialById(Integer id);
Integer insertTermFinancial(TermFinancial termFinancial);
Integer updateTermFinancial(TermFinancial termFinancial);
Integer deleteTermFinancialById(Integer id);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/TermFinancialService.java
|
Java
|
mit
| 435
|
package com.mycode.finance.service;
import com.mycode.finance.entity.UserChangeMoney;
import java.util.List;
public interface UserChangeMoneyService {
Integer insertUserChangeMoney(UserChangeMoney userChangeMoney);
List<UserChangeMoney> selectUserChangeMoneyByUserId(Integer userId);
Integer updateUserChangeMoney(UserChangeMoney userChangeMoney);
UserChangeMoney selectUserChangeMoneyById(Integer id);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/UserChangeMoneyService.java
|
Java
|
mit
| 428
|
package com.mycode.finance.service;
import com.mycode.finance.entity.UserFundProduct;
import java.util.List;
public interface UserFundProductService {
Integer insertUserFundProduct(UserFundProduct userFundProduct);
List<UserFundProduct> selectUserFundProductByUserId(Integer userId);
Integer updateUserFundProduct(UserFundProduct userFundProduct);
UserFundProduct selectUserFundProductById(Integer id);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/UserFundProductService.java
|
Java
|
mit
| 428
|
package com.mycode.finance.service;
import com.mycode.finance.entity.UserPayMoney;
import java.util.List;
public interface UserPayMoneyService {
Integer insertUserPayMoney(UserPayMoney userPayMoney);
List<UserPayMoney> selectUserPayMoneyByUserId(Integer userId);
Integer updateUserPayMoney(UserPayMoney userPayMoney);
UserPayMoney selectUserPayMoneyById(Integer id);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/UserPayMoneyService.java
|
Java
|
mit
| 393
|
package com.mycode.finance.service;
import com.mycode.finance.entity.UserPermissions;
import java.util.List;
public interface UserPermissionsService {
List<UserPermissions> selectUserPermissionsByUserId(Integer userId);
UserPermissions selectUserPermissionsByPermissionId(Integer permissionId);
Integer insertUserPermissions(UserPermissions userPermissions);
Integer UpdateUserPermissions(UserPermissions userPermissions);
Integer deleteUserPermissionsByPermissionId(Integer permissionId);
Integer deleteAllUserPermissionsByUserId(Integer userId);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/UserPermissionsService.java
|
Java
|
mit
| 583
|
package com.mycode.finance.service;
import com.mycode.finance.entity.User;
import java.util.List;
public interface UserService {
User selectUserByTerms(String username, String password);
List<User> selectUserByStatusDesc();
List<User> selectAllUser();
Integer updateUser(User user);
Integer insertUser(User user);
User selectUserById(Integer id);
Integer deleteUserById(Integer id);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/UserService.java
|
Java
|
mit
| 423
|
package com.mycode.finance.service;
import com.mycode.finance.entity.UserTermFinancial;
import java.util.List;
public interface UserTermFinancialService {
Integer insertUserTermFinancial(UserTermFinancial userTermFinancial);
List<UserTermFinancial> selectUserTermFinancialByUserId(Integer userId);
Integer updateUserTermFinancial(UserTermFinancial userTermFinancial);
UserTermFinancial selectUserTermFinancialById(Integer id);
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/UserTermFinancialService.java
|
Java
|
mit
| 452
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.AdminPermissions;
import com.mycode.finance.entity.AdminPermissionsExample;
import com.mycode.finance.mapper.AdminPermissionsMapper;
import com.mycode.finance.service.AdminPermissionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class AdminPermissionsServiceImpl implements AdminPermissionsService {
@Autowired
AdminPermissionsMapper adminPermissionsMapper;
@Override
public List<AdminPermissions> selectAdminPermissionsByAdminId(Integer adminId) {
AdminPermissionsExample adminPermissionsExample = new AdminPermissionsExample();
adminPermissionsExample.createCriteria().andAdminidEqualTo(adminId);
return adminPermissionsMapper.selectByExampleWithAdminAndPermissions(adminPermissionsExample);
}
@Override
@Transactional
public Integer insertAdminPermissions(AdminPermissions adminPermissions) {
return adminPermissionsMapper.insertSelective(adminPermissions);
}
@Override
@Transactional
public Integer UpdateAdminPermissions(AdminPermissions adminPermissions) {
return adminPermissionsMapper.updateByPrimaryKeySelective(adminPermissions);
}
@Override
@Transactional
public Integer deleteAdminPermissionsByPermissionId(Integer permissionId) {
AdminPermissionsExample adminPermissionsExample = new AdminPermissionsExample();
adminPermissionsExample.createCriteria().andPermissionidEqualTo(permissionId);
return adminPermissionsMapper.deleteByExample(adminPermissionsExample);
}
@Override
public Integer deleteAllAdminPermissionsByAdminId(Integer adminId) {
AdminPermissionsExample adminPermissionsExample = new AdminPermissionsExample();
adminPermissionsExample.createCriteria().andAdminidEqualTo(adminId);
return adminPermissionsMapper.deleteByExample(adminPermissionsExample);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/AdminPermissionsServiceImpl.java
|
Java
|
mit
| 2,109
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.Admin;
import com.mycode.finance.entity.AdminExample;
import com.mycode.finance.mapper.AdminMapper;
import com.mycode.finance.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class AdminServiceImpl implements AdminService {
@Autowired(required = false)
AdminMapper adminMapper;
@Override
public Admin selectAdminByTerms(String username, String password) {
AdminExample adminExample = new AdminExample();
AdminExample.Criteria criteria = adminExample.createCriteria();
if (username!=null){
criteria.andUsernameEqualTo(username);
}
if (password!=null){
criteria.andPasswordEqualTo(password);
}
List<Admin> list = adminMapper.selectByExample(adminExample);
if ("[]".equals(list.toString())){
return null;
}else {
return list.get(0);
}
}
@Override
@Transactional
public Integer updateAdmin(Admin admin) {
int result = adminMapper.updateByPrimaryKeySelective(admin);
return result;
}
@Override
public Admin selectAdminById(Integer id) {
Admin admin = adminMapper.selectByPrimaryKey(id);
return admin;
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/AdminServiceImpl.java
|
Java
|
mit
| 1,476
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.Bankcard;
import com.mycode.finance.entity.BankcardExample;
import com.mycode.finance.mapper.BankcardMapper;
import com.mycode.finance.service.BankCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class BankCardServiceImpl implements BankCardService {
@Autowired
BankcardMapper bankcardMapper;
@Override
public List<Bankcard> selectAllBankCard() {
return bankcardMapper.selectByExampleWithUser(null);
}
@Override
public List<Bankcard> selectBankCardByUserId(Integer userId) {
BankcardExample bankcardExample = new BankcardExample();
bankcardExample.createCriteria().andUseridEqualTo(userId);
return bankcardMapper.selectByExampleWithUser(bankcardExample);
}
@Override
public Bankcard selectBankCardById(Integer id) {
return bankcardMapper.selectByPrimaryKeyWithUser(id);
}
@Override
@Transactional
public Integer insertBankCard(Bankcard bankcard) {
return bankcardMapper.insertSelective(bankcard);
}
@Override
@Transactional
public Integer updateBankCard(Bankcard bankcard) {
return bankcardMapper.updateByPrimaryKeySelective(bankcard);
}
@Override
public Integer deleteBankCardById(Integer id) {
return bankcardMapper.deleteByPrimaryKey(id);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/BankCardServiceImpl.java
|
Java
|
mit
| 1,559
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.Bank;
import com.mycode.finance.mapper.BankMapper;
import com.mycode.finance.service.BankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class BankServiceImpl implements BankService {
@Autowired
BankMapper bankMapper;
@Override
public List<Bank> selectAllBank() {
List<Bank> list = bankMapper.selectByExample(null);
return list;
}
@Override
public Bank selectBankById(Integer id) {
return bankMapper.selectByPrimaryKey(id);
}
@Override
@Transactional
public Integer insertBank(Bank bank) {
return bankMapper.insertSelective(bank);
}
@Override
@Transactional
public Integer updateBank(Bank bank) {
return bankMapper.updateByPrimaryKeySelective(bank);
}
@Override
@Transactional
public Integer deleteBankById(Integer id) {
return bankMapper.deleteByPrimaryKey(id);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/BankServiceImpl.java
|
Java
|
mit
| 1,152
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.ChangeMoney;
import com.mycode.finance.mapper.ChangeMoneyMapper;
import com.mycode.finance.service.ChangeMoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class ChangeMoneyServiceImpl implements ChangeMoneyService {
@Autowired
ChangeMoneyMapper changeMoneyMapper;
@Override
public List<ChangeMoney> selectAllChangeMoney() {
List<ChangeMoney> list = changeMoneyMapper.selectByExample(null);
return list;
}
@Override
public ChangeMoney selectChangeMoneyById(Integer id) {
ChangeMoney changeMoney = changeMoneyMapper.selectByPrimaryKey(id);
return changeMoney;
}
@Override
@Transactional
public Integer insertChangeMoney(ChangeMoney changeMoney) {
return changeMoneyMapper.insertSelective(changeMoney);
}
@Override
@Transactional
public Integer updateChangeMoney(ChangeMoney changeMoney) {
return changeMoneyMapper.updateByPrimaryKeySelective(changeMoney);
}
@Override
@Transactional
public Integer deleteChangeMoneyById(Integer id) {
return changeMoneyMapper.deleteByPrimaryKey(id);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/ChangeMoneyServiceImpl.java
|
Java
|
mit
| 1,382
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.FlowOfFunds;
import com.mycode.finance.entity.FlowOfFundsExample;
import com.mycode.finance.mapper.FlowOfFundsMapper;
import com.mycode.finance.service.FlowOfFundsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class FlowOfFundsServiceImpl implements FlowOfFundsService {
@Autowired
FlowOfFundsMapper flowOfFundsMapper;
@Override
@Transactional
public Integer insertFlowOfFunds(FlowOfFunds flowOfFunds) {
return flowOfFundsMapper.insertSelective(flowOfFunds);
}
@Override
public List<FlowOfFunds> selectFlowOfFundsByUserId(Integer userId) {
FlowOfFundsExample fofe = new FlowOfFundsExample();
fofe.createCriteria().andUseridEqualTo(userId);
fofe.setOrderByClause("id desc");
return flowOfFundsMapper.selectByExample(fofe);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/FlowOfFundsServiceImpl.java
|
Java
|
mit
| 1,056
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.FundProduct;
import com.mycode.finance.mapper.FundProductMapper;
import com.mycode.finance.service.FundProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class FundProductServiceImpl implements FundProductService {
@Autowired
FundProductMapper fundProductMapper;
@Override
public List<FundProduct> selectAllFundProduct() {
return fundProductMapper.selectByExample(null);
}
@Override
public FundProduct selectFundProductById(Integer id) {
return fundProductMapper.selectByPrimaryKey(id);
}
@Override
@Transactional
public Integer insertFundProduct(FundProduct fundProduct) {
return fundProductMapper.insertSelective(fundProduct);
}
@Override
@Transactional
public Integer updateFundProduct(FundProduct fundProduct) {
return fundProductMapper.updateByPrimaryKeySelective(fundProduct);
}
@Override
@Transactional
public Integer deleteFundProductById(Integer id) {
return fundProductMapper.deleteByPrimaryKey(id);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/FundProductServiceImpl.java
|
Java
|
mit
| 1,293
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.Info;
import com.mycode.finance.entity.InfoExample;
import com.mycode.finance.mapper.InfoMapper;
import com.mycode.finance.service.InfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class InfoServiceImpl implements InfoService {
@Autowired
InfoMapper infoMapper;
@Override
public List<Info> selectInfoOrderByUserIdDesc(Integer receiveid) {
InfoExample infoExample = new InfoExample();
infoExample.createCriteria().andReceiveidEqualTo(receiveid);
infoExample.setOrderByClause("i.id desc");
return infoMapper.selectByExampleWithUserAndAdmin(infoExample);
}
@Override
public Info selectInfoById(Integer id) {
return infoMapper.selectByPrimaryKeyWithUserAndAdmin(id);
}
@Override
@Transactional
public Integer insertInfo(Info info) {
return infoMapper.insertSelective(info);
}
@Override
@Transactional
public Integer updateInfo(Info info) {
return infoMapper.updateByPrimaryKeySelective(info);
}
@Override
@Transactional
public Integer deleteInfobyId(Integer id) {
return infoMapper.deleteByPrimaryKey(id);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/InfoServiceImpl.java
|
Java
|
mit
| 1,410
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.Loan;
import com.mycode.finance.entity.LoanExample;
import com.mycode.finance.mapper.LoanMapper;
import com.mycode.finance.service.LoanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class LoanServiceImpl implements LoanService {
@Autowired
LoanMapper loanMapper;
@Override
@Transactional
public Integer insertLoan(Loan loan) {
return loanMapper.insertSelective(loan);
}
@Override
public List<Loan> selectLoanByLoanId(Integer loanId) {
LoanExample loanExample = new LoanExample();
loanExample.createCriteria().andLoanidEqualTo(loanId);
return loanMapper.selectByExampleWithUserAndAdmin(loanExample);
}
@Override
public List<Loan> selectAllLoanByApplyStatusAsc() {
LoanExample loanExample = new LoanExample();
loanExample.setOrderByClause("applyStatus asc");
return loanMapper.selectByExampleWithUserAndAdmin(loanExample);
}
@Override
public List<Loan> selectAllExamedLoan() {
LoanExample loanExample = new LoanExample();
loanExample.createCriteria().andApplystatusEqualTo(2);
return loanMapper.selectByExampleWithUserAndAdmin(loanExample);
}
@Override
public Loan selectLoanById(Integer id) {
return loanMapper.selectByPrimaryKeyWithUserAndAdmin(id);
}
@Override
@Transactional
public Integer updateLoan(Loan loan) {
return loanMapper.updateByPrimaryKeySelective(loan);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/LoanServiceImpl.java
|
Java
|
mit
| 1,716
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.News;
import com.mycode.finance.mapper.NewsMapper;
import com.mycode.finance.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class NewsServiceImpl implements NewsService {
@Autowired(required = false)
NewsMapper newsMapper;
@Override
public List<News> selectAllNews() {
List<News> list = newsMapper.selectByExample(null);
return list;
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/NewsServiceImpl.java
|
Java
|
mit
| 575
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.PayMoney;
import com.mycode.finance.mapper.PayMoneyMapper;
import com.mycode.finance.service.PayMoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class PayMoneyServiceImpl implements PayMoneyService {
@Autowired
PayMoneyMapper payMoneyMapper;
@Override
public List<PayMoney> selectAllPayMoney() {
List<PayMoney> list = payMoneyMapper.selectByExample(null);
return list;
}
@Override
public PayMoney selectPayMoneyById(Integer id) {
PayMoney payMoney = payMoneyMapper.selectByPrimaryKey(id);
return payMoney;
}
@Override
@Transactional
public Integer insertPayMoney(PayMoney payMoney) {
return payMoneyMapper.insertSelective(payMoney);
}
@Override
@Transactional
public Integer updatePayMoney(PayMoney payMoney) {
return payMoneyMapper.updateByPrimaryKeySelective(payMoney);
}
@Override
@Transactional
public Integer deletePayMoneyById(Integer id) {
return payMoneyMapper.deleteByPrimaryKey(id);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/PayMoneyServiceImpl.java
|
Java
|
mit
| 1,294
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.Permissions;
import com.mycode.finance.entity.PermissionsExample;
import com.mycode.finance.mapper.PermissionsMapper;
import com.mycode.finance.service.PermissionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class PermissionsServiceImpl implements PermissionsService {
@Autowired
PermissionsMapper permissionsMapper;
@Override
public List<Permissions> selectPermissionsByPermission(String permission) {
PermissionsExample permissionsExample = new PermissionsExample();
permissionsExample.createCriteria().andPermissionEqualTo(permission);
return permissionsMapper.selectByExample(permissionsExample);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/PermissionsServiceImpl.java
|
Java
|
mit
| 839
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.TermFinancial;
import com.mycode.finance.mapper.TermFinancialMapper;
import com.mycode.finance.service.TermFinancialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class TermFinancialServiceImpl implements TermFinancialService {
@Autowired
TermFinancialMapper termFinancialMapper;
@Override
public List<TermFinancial> selectAllTermFinancial() {
return termFinancialMapper.selectByExample(null);
}
@Override
public TermFinancial selectTermFinancialById(Integer id) {
return termFinancialMapper.selectByPrimaryKey(id);
}
@Override
@Transactional
public Integer insertTermFinancial(TermFinancial termFinancial) {
return termFinancialMapper.insertSelective(termFinancial);
}
@Override
@Transactional
public Integer updateTermFinancial(TermFinancial termFinancial) {
return termFinancialMapper.updateByPrimaryKeySelective(termFinancial);
}
@Override
@Transactional
public Integer deleteTermFinancialById(Integer id) {
return termFinancialMapper.deleteByPrimaryKey(id);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/TermFinancialServiceImpl.java
|
Java
|
mit
| 1,344
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.UserChangeMoney;
import com.mycode.finance.entity.UserChangeMoneyExample;
import com.mycode.finance.mapper.UserChangeMoneyMapper;
import com.mycode.finance.service.UserChangeMoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class UserChangeMoneyServiceImpl implements UserChangeMoneyService {
@Autowired
UserChangeMoneyMapper userChangeMoneyMapper;
@Override
@Transactional
public Integer insertUserChangeMoney(UserChangeMoney userChangeMoney) {
int result = userChangeMoneyMapper.insertSelective(userChangeMoney);
return result;
}
@Override
public List<UserChangeMoney> selectUserChangeMoneyByUserId(Integer userId) {
UserChangeMoneyExample ucme = new UserChangeMoneyExample();
ucme.createCriteria().andUseridEqualTo(userId);
return userChangeMoneyMapper.selectByExampleWithUserAndChangeMoney(ucme);
}
@Override
@Transactional
public Integer updateUserChangeMoney(UserChangeMoney userChangeMoney) {
return userChangeMoneyMapper.updateByPrimaryKeySelective(userChangeMoney);
}
@Override
public UserChangeMoney selectUserChangeMoneyById(Integer id) {
return userChangeMoneyMapper.selectByPrimaryKeyWithUserAndChangeMoney(id);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/UserChangeMoneyServiceImpl.java
|
Java
|
mit
| 1,508
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.UserFundProduct;
import com.mycode.finance.entity.UserFundProductExample;
import com.mycode.finance.mapper.UserFundProductMapper;
import com.mycode.finance.service.UserFundProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class UserFundProductServiceImpl implements UserFundProductService {
@Autowired
UserFundProductMapper userFundProductMapper;
@Override
@Transactional
public Integer insertUserFundProduct(UserFundProduct userFundProduct) {
return userFundProductMapper.insertSelective(userFundProduct);
}
@Override
public List<UserFundProduct> selectUserFundProductByUserId(Integer userId) {
UserFundProductExample ufpe = new UserFundProductExample();
ufpe.createCriteria().andUseridEqualTo(userId);
return userFundProductMapper.selectByExampleWithUserAndFundProduct(ufpe);
}
@Override
@Transactional
public Integer updateUserFundProduct(UserFundProduct userFundProduct) {
return userFundProductMapper.updateByPrimaryKeySelective(userFundProduct);
}
@Override
public UserFundProduct selectUserFundProductById(Integer id) {
return userFundProductMapper.selectByPrimaryKeyWithUserAndFundProduct(id);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/UserFundProductServiceImpl.java
|
Java
|
mit
| 1,479
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.UserPayMoney;
import com.mycode.finance.entity.UserPayMoneyExample;
import com.mycode.finance.mapper.UserPayMoneyMapper;
import com.mycode.finance.service.UserPayMoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class UserPayMoneyServiceImpl implements UserPayMoneyService {
@Autowired
UserPayMoneyMapper userPayMoneyMapper;
@Override
@Transactional
public Integer insertUserPayMoney(UserPayMoney userPayMoney) {
return userPayMoneyMapper.insertSelective(userPayMoney);
}
@Override
public List<UserPayMoney> selectUserPayMoneyByUserId(Integer userId) {
UserPayMoneyExample upme = new UserPayMoneyExample();
upme.createCriteria().andUseridEqualTo(userId);
return userPayMoneyMapper.selectByExampleWithUserAndPayMoney(upme);
}
@Override
@Transactional
public Integer updateUserPayMoney(UserPayMoney userPayMoney) {
return userPayMoneyMapper.updateByPrimaryKeySelective(userPayMoney);
}
@Override
public UserPayMoney selectUserPayMoneyById(Integer id) {
return userPayMoneyMapper.selectByPrimaryKeyWithUserAndPayMoney(id);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/UserPayMoneyServiceImpl.java
|
Java
|
mit
| 1,396
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.UserPermissions;
import com.mycode.finance.entity.UserPermissionsExample;
import com.mycode.finance.mapper.UserPermissionsMapper;
import com.mycode.finance.service.UserPermissionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class UserPermissionsServiceImpl implements UserPermissionsService {
@Autowired
UserPermissionsMapper userPermissionsMapper;
@Override
public List<UserPermissions> selectUserPermissionsByUserId(Integer userId) {
UserPermissionsExample userPermissionsExample = new UserPermissionsExample();
userPermissionsExample.createCriteria().andUseridEqualTo(userId);
return userPermissionsMapper.selectByExampleWithUserAndPermission(userPermissionsExample);
}
@Override
public UserPermissions selectUserPermissionsByPermissionId(Integer permissionId) {
UserPermissionsExample userPermissionsExample = new UserPermissionsExample();
userPermissionsExample.createCriteria().andPermissionidEqualTo(permissionId);
return null;
}
@Override
@Transactional
public Integer insertUserPermissions(UserPermissions userPermissions) {
return userPermissionsMapper.insertSelective(userPermissions);
}
@Override
@Transactional
public Integer UpdateUserPermissions(UserPermissions userPermissions) {
return userPermissionsMapper.updateByPrimaryKeySelective(userPermissions);
}
@Override
@Transactional
public Integer deleteUserPermissionsByPermissionId(Integer permissionId) {
UserPermissionsExample userPermissionsExample = new UserPermissionsExample();
userPermissionsExample.createCriteria().andPermissionidEqualTo(permissionId);
return userPermissionsMapper.deleteByExample(userPermissionsExample);
}
@Override
public Integer deleteAllUserPermissionsByUserId(Integer userId) {
UserPermissionsExample userPermissionsExample = new UserPermissionsExample();
userPermissionsExample.createCriteria().andUseridEqualTo(userId);
return userPermissionsMapper.deleteByExample(userPermissionsExample);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/UserPermissionsServiceImpl.java
|
Java
|
mit
| 2,361
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.User;
import com.mycode.finance.entity.UserExample;
import com.mycode.finance.mapper.UserMapper;
import com.mycode.finance.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {
@Autowired(required = false)
UserMapper userMapper;
@Override
public User selectUserByTerms(String username, String password) {
UserExample userExample =new UserExample();
UserExample.Criteria criteria = userExample.createCriteria();
if (username!=null){
criteria.andUsernameEqualTo(username);
}
if (password!=null){
criteria.andPasswordEqualTo(password);
}
List<User> list = userMapper.selectByExample(userExample);
if ("[]".equals(list.toString())){
return null;
}else {
return list.get(0);
}
}
@Override
public List<User> selectUserByStatusDesc() {
UserExample userExample = new UserExample();
userExample.setOrderByClause("status desc");
return userMapper.selectByExample(userExample);
}
@Override
public List<User> selectAllUser() {
return userMapper.selectByExample(null);
}
@Override
@Transactional
public Integer updateUser(User user) {
int result = userMapper.updateByPrimaryKeySelective(user);
return result;
}
@Override
@Transactional
public Integer insertUser(User user) {
int result = userMapper.insertSelective(user);
return result;
}
@Override
public User selectUserById(Integer id) {
User user = userMapper.selectByPrimaryKey(id);
return user;
}
@Override
@Transactional
public Integer deleteUserById(Integer id) {
return userMapper.deleteByPrimaryKey(id);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/UserServiceImpl.java
|
Java
|
mit
| 2,087
|
package com.mycode.finance.service.impl;
import com.mycode.finance.entity.UserTermFinancial;
import com.mycode.finance.entity.UserTermFinancialExample;
import com.mycode.finance.mapper.UserTermFinancialMapper;
import com.mycode.finance.service.UserTermFinancialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class UserTermFinancialServiceImpl implements UserTermFinancialService {
@Autowired
UserTermFinancialMapper userTermFinancialMapper;
@Override
@Transactional
public Integer insertUserTermFinancial(UserTermFinancial userTermFinancial) {
return userTermFinancialMapper.insertSelective(userTermFinancial);
}
@Override
public List<UserTermFinancial> selectUserTermFinancialByUserId(Integer userId) {
UserTermFinancialExample utfe = new UserTermFinancialExample();
utfe.createCriteria().andUseridEqualTo(userId);
return userTermFinancialMapper.selectByExampleWithUserAndTermFinancial(utfe);
}
@Override
@Transactional
public Integer updateUserTermFinancial(UserTermFinancial userTermFinancial) {
return userTermFinancialMapper.updateByPrimaryKeySelective(userTermFinancial);
}
@Override
public UserTermFinancial selectUserTermFinancialById(Integer id) {
return userTermFinancialMapper.selectByPrimaryKeyWithUserAndTermFinancial(id);
}
}
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/java/com/mycode/finance/service/impl/UserTermFinancialServiceImpl.java
|
Java
|
mit
| 1,534
|
(function($) {
var rotateLeft = function(lValue, iShiftBits) {
return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
}
var addUnsigned = function(lX, lY) {
var lX4, lY4, lX8, lY8, lResult;
lX8 = (lX & 0x80000000);
lY8 = (lY & 0x80000000);
lX4 = (lX & 0x40000000);
lY4 = (lY & 0x40000000);
lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
if (lX4 & lY4) return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
if (lX4 | lY4) {
if (lResult & 0x40000000) return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
else return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
} else {
return (lResult ^ lX8 ^ lY8);
}
}
var F = function(x, y, z) {
return (x & y) | ((~x) & z);
}
var G = function(x, y, z) {
return (x & z) | (y & (~z));
}
var H = function(x, y, z) {
return (x ^ y ^ z);
}
var I = function(x, y, z) {
return (y ^ (x | (~z)));
}
var FF = function(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(F(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var GG = function(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(G(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var HH = function(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(H(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var II = function(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(I(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var convertToWordArray = function(string) {
var lWordCount;
var lMessageLength = string.length;
var lNumberOfWordsTempOne = lMessageLength + 8;
var lNumberOfWordsTempTwo = (lNumberOfWordsTempOne - (lNumberOfWordsTempOne % 64)) / 64;
var lNumberOfWords = (lNumberOfWordsTempTwo + 1) * 16;
var lWordArray = Array(lNumberOfWords - 1);
var lBytePosition = 0;
var lByteCount = 0;
while (lByteCount < lMessageLength) {
lWordCount = (lByteCount - (lByteCount % 4)) / 4;
lBytePosition = (lByteCount % 4) * 8;
lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition));
lByteCount++;
}
lWordCount = (lByteCount - (lByteCount % 4)) / 4;
lBytePosition = (lByteCount % 4) * 8;
lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
return lWordArray;
};
var wordToHex = function(lValue) {
var WordToHexValue = "",
WordToHexValueTemp = "",
lByte, lCount;
for (lCount = 0; lCount <= 3; lCount++) {
lByte = (lValue >>> (lCount * 8)) & 255;
WordToHexValueTemp = "0" + lByte.toString(16);
WordToHexValue = WordToHexValue + WordToHexValueTemp.substr(WordToHexValueTemp.length - 2, 2);
}
return WordToHexValue;
};
var uTF8Encode = function(string) {
string = string.replace(/\x0d\x0a/g, "\x0a");
var output = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
output += String.fromCharCode(c);
} else if ((c > 127) && (c < 2048)) {
output += String.fromCharCode((c >> 6) | 192);
output += String.fromCharCode((c & 63) | 128);
} else {
output += String.fromCharCode((c >> 12) | 224);
output += String.fromCharCode(((c >> 6) & 63) | 128);
output += String.fromCharCode((c & 63) | 128);
}
}
return output;
};
$.extend({
md5: function(string) {
var x = Array();
var k, AA, BB, CC, DD, a, b, c, d;
var S11 = 7,
S12 = 12,
S13 = 17,
S14 = 22;
var S21 = 5,
S22 = 9,
S23 = 14,
S24 = 20;
var S31 = 4,
S32 = 11,
S33 = 16,
S34 = 23;
var S41 = 6,
S42 = 10,
S43 = 15,
S44 = 21;
string = uTF8Encode(string);
x = convertToWordArray(string);
a = 0x67452301;
b = 0xEFCDAB89;
c = 0x98BADCFE;
d = 0x10325476;
for (k = 0; k < x.length; k += 16) {
AA = a;
BB = b;
CC = c;
DD = d;
a = FF(a, b, c, d, x[k + 0], S11, 0xD76AA478);
d = FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
c = FF(c, d, a, b, x[k + 2], S13, 0x242070DB);
b = FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
a = FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
d = FF(d, a, b, c, x[k + 5], S12, 0x4787C62A);
c = FF(c, d, a, b, x[k + 6], S13, 0xA8304613);
b = FF(b, c, d, a, x[k + 7], S14, 0xFD469501);
a = FF(a, b, c, d, x[k + 8], S11, 0x698098D8);
d = FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
c = FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
b = FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
a = FF(a, b, c, d, x[k + 12], S11, 0x6B901122);
d = FF(d, a, b, c, x[k + 13], S12, 0xFD987193);
c = FF(c, d, a, b, x[k + 14], S13, 0xA679438E);
b = FF(b, c, d, a, x[k + 15], S14, 0x49B40821);
a = GG(a, b, c, d, x[k + 1], S21, 0xF61E2562);
d = GG(d, a, b, c, x[k + 6], S22, 0xC040B340);
c = GG(c, d, a, b, x[k + 11], S23, 0x265E5A51);
b = GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
a = GG(a, b, c, d, x[k + 5], S21, 0xD62F105D);
d = GG(d, a, b, c, x[k + 10], S22, 0x2441453);
c = GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
b = GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8);
a = GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6);
d = GG(d, a, b, c, x[k + 14], S22, 0xC33707D6);
c = GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87);
b = GG(b, c, d, a, x[k + 8], S24, 0x455A14ED);
a = GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905);
d = GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8);
c = GG(c, d, a, b, x[k + 7], S23, 0x676F02D9);
b = GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A);
a = HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942);
d = HH(d, a, b, c, x[k + 8], S32, 0x8771F681);
c = HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122);
b = HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C);
a = HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44);
d = HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9);
c = HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60);
b = HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70);
a = HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6);
d = HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA);
c = HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085);
b = HH(b, c, d, a, x[k + 6], S34, 0x4881D05);
a = HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039);
d = HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5);
c = HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8);
b = HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665);
a = II(a, b, c, d, x[k + 0], S41, 0xF4292244);
d = II(d, a, b, c, x[k + 7], S42, 0x432AFF97);
c = II(c, d, a, b, x[k + 14], S43, 0xAB9423A7);
b = II(b, c, d, a, x[k + 5], S44, 0xFC93A039);
a = II(a, b, c, d, x[k + 12], S41, 0x655B59C3);
d = II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92);
c = II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D);
b = II(b, c, d, a, x[k + 1], S44, 0x85845DD1);
a = II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F);
d = II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0);
c = II(c, d, a, b, x[k + 6], S43, 0xA3014314);
b = II(b, c, d, a, x[k + 13], S44, 0x4E0811A1);
a = II(a, b, c, d, x[k + 4], S41, 0xF7537E82);
d = II(d, a, b, c, x[k + 11], S42, 0xBD3AF235);
c = II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB);
b = II(b, c, d, a, x[k + 9], S44, 0xEB86D391);
a = addUnsigned(a, AA);
b = addUnsigned(b, BB);
c = addUnsigned(c, CC);
d = addUnsigned(d, DD);
}
var tempValue = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d);
return tempValue.toLowerCase();
}
});
})(jQuery);
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/static/js/md5.js
|
JavaScript
|
mit
| 9,273
|
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.wangEditor = factory());
}(this, (function () { 'use strict';
/*
poly-fill
*/
var polyfill = function () {
// Object.assign
if (typeof Object.assign != 'function') {
Object.assign = function (target, varArgs) {
// .length of function is 2
if (target == null) {
// TypeError if undefined or null
throw new TypeError('Cannot convert undefined or null to object');
}
var to = Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments[index];
if (nextSource != null) {
// Skip over if undefined or null
for (var nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
};
}
// IE 中兼容 Element.prototype.matches
if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector || function (s) {
var matches = (this.document || this.ownerDocument).querySelectorAll(s),
i = matches.length;
while (--i >= 0 && matches.item(i) !== this) {}
return i > -1;
};
}
};
/*
DOM 操作 API
*/
// 根据 html 代码片段创建 dom 对象
function createElemByHTML(html) {
var div = void 0;
div = document.createElement('div');
div.innerHTML = html;
return div.children;
}
// 是否是 DOM List
function isDOMList(selector) {
if (!selector) {
return false;
}
if (selector instanceof HTMLCollection || selector instanceof NodeList) {
return true;
}
return false;
}
// 封装 document.querySelectorAll
function querySelectorAll(selector) {
var result = document.querySelectorAll(selector);
if (isDOMList(result)) {
return result;
} else {
return [result];
}
}
// 记录所有的事件绑定
var eventList = [];
// 创建构造函数
function DomElement(selector) {
if (!selector) {
return;
}
// selector 本来就是 DomElement 对象,直接返回
if (selector instanceof DomElement) {
return selector;
}
this.selector = selector;
var nodeType = selector.nodeType;
// 根据 selector 得出的结果(如 DOM,DOM List)
var selectorResult = [];
if (nodeType === 9) {
// document 节点
selectorResult = [selector];
} else if (nodeType === 1) {
// 单个 DOM 节点
selectorResult = [selector];
} else if (isDOMList(selector) || selector instanceof Array) {
// DOM List 或者数组
selectorResult = selector;
} else if (typeof selector === 'string') {
// 字符串
selector = selector.replace('/\n/mg', '').trim();
if (selector.indexOf('<') === 0) {
// 如 <div>
selectorResult = createElemByHTML(selector);
} else {
// 如 #id .class
selectorResult = querySelectorAll(selector);
}
}
var length = selectorResult.length;
if (!length) {
// 空数组
return this;
}
// 加入 DOM 节点
var i = void 0;
for (i = 0; i < length; i++) {
this[i] = selectorResult[i];
}
this.length = length;
}
// 修改原型
DomElement.prototype = {
constructor: DomElement,
// 类数组,forEach
forEach: function forEach(fn) {
var i = void 0;
for (i = 0; i < this.length; i++) {
var elem = this[i];
var result = fn.call(elem, elem, i);
if (result === false) {
break;
}
}
return this;
},
// clone
clone: function clone(deep) {
var cloneList = [];
this.forEach(function (elem) {
cloneList.push(elem.cloneNode(!!deep));
});
return $(cloneList);
},
// 获取第几个元素
get: function get(index) {
var length = this.length;
if (index >= length) {
index = index % length;
}
return $(this[index]);
},
// 第一个
first: function first() {
return this.get(0);
},
// 最后一个
last: function last() {
var length = this.length;
return this.get(length - 1);
},
// 绑定事件
on: function on(type, selector, fn) {
// selector 不为空,证明绑定事件要加代理
if (!fn) {
fn = selector;
selector = null;
}
// type 是否有多个
var types = [];
types = type.split(/\s+/);
return this.forEach(function (elem) {
types.forEach(function (type) {
if (!type) {
return;
}
// 记录下,方便后面解绑
eventList.push({
elem: elem,
type: type,
fn: fn
});
if (!selector) {
// 无代理
elem.addEventListener(type, fn);
return;
}
// 有代理
elem.addEventListener(type, function (e) {
var target = e.target;
if (target.matches(selector)) {
fn.call(target, e);
}
});
});
});
},
// 取消事件绑定
off: function off(type, fn) {
return this.forEach(function (elem) {
elem.removeEventListener(type, fn);
});
},
// 获取/设置 属性
attr: function attr(key, val) {
if (val == null) {
// 获取值
return this[0].getAttribute(key);
} else {
// 设置值
return this.forEach(function (elem) {
elem.setAttribute(key, val);
});
}
},
// 添加 class
addClass: function addClass(className) {
if (!className) {
return this;
}
return this.forEach(function (elem) {
var arr = void 0;
if (elem.className) {
// 解析当前 className 转换为数组
arr = elem.className.split(/\s/);
arr = arr.filter(function (item) {
return !!item.trim();
});
// 添加 class
if (arr.indexOf(className) < 0) {
arr.push(className);
}
// 修改 elem.class
elem.className = arr.join(' ');
} else {
elem.className = className;
}
});
},
// 删除 class
removeClass: function removeClass(className) {
if (!className) {
return this;
}
return this.forEach(function (elem) {
var arr = void 0;
if (elem.className) {
// 解析当前 className 转换为数组
arr = elem.className.split(/\s/);
arr = arr.filter(function (item) {
item = item.trim();
// 删除 class
if (!item || item === className) {
return false;
}
return true;
});
// 修改 elem.class
elem.className = arr.join(' ');
}
});
},
// 修改 css
css: function css(key, val) {
var currentStyle = key + ':' + val + ';';
return this.forEach(function (elem) {
var style = (elem.getAttribute('style') || '').trim();
var styleArr = void 0,
resultArr = [];
if (style) {
// 将 style 按照 ; 拆分为数组
styleArr = style.split(';');
styleArr.forEach(function (item) {
// 对每项样式,按照 : 拆分为 key 和 value
var arr = item.split(':').map(function (i) {
return i.trim();
});
if (arr.length === 2) {
resultArr.push(arr[0] + ':' + arr[1]);
}
});
// 替换或者新增
resultArr = resultArr.map(function (item) {
if (item.indexOf(key) === 0) {
return currentStyle;
} else {
return item;
}
});
if (resultArr.indexOf(currentStyle) < 0) {
resultArr.push(currentStyle);
}
// 结果
elem.setAttribute('style', resultArr.join('; '));
} else {
// style 无值
elem.setAttribute('style', currentStyle);
}
});
},
// 显示
show: function show() {
return this.css('display', 'block');
},
// 隐藏
hide: function hide() {
return this.css('display', 'none');
},
// 获取子节点
children: function children() {
var elem = this[0];
if (!elem) {
return null;
}
return $(elem.children);
},
// 获取子节点(包括文本节点)
childNodes: function childNodes() {
var elem = this[0];
if (!elem) {
return null;
}
return $(elem.childNodes);
},
// 增加子节点
append: function append($children) {
return this.forEach(function (elem) {
$children.forEach(function (child) {
elem.appendChild(child);
});
});
},
// 移除当前节点
remove: function remove() {
return this.forEach(function (elem) {
if (elem.remove) {
elem.remove();
} else {
var parent = elem.parentElement;
parent && parent.removeChild(elem);
}
});
},
// 是否包含某个子节点
isContain: function isContain($child) {
var elem = this[0];
var child = $child[0];
return elem.contains(child);
},
// 尺寸数据
getSizeData: function getSizeData() {
var elem = this[0];
return elem.getBoundingClientRect(); // 可得到 bottom height left right top width 的数据
},
// 封装 nodeName
getNodeName: function getNodeName() {
var elem = this[0];
return elem.nodeName;
},
// 从当前元素查找
find: function find(selector) {
var elem = this[0];
return $(elem.querySelectorAll(selector));
},
// 获取当前元素的 text
text: function text(val) {
if (!val) {
// 获取 text
var elem = this[0];
return elem.innerHTML.replace(/<.*?>/g, function () {
return '';
});
} else {
// 设置 text
return this.forEach(function (elem) {
elem.innerHTML = val;
});
}
},
// 获取 html
html: function html(value) {
var elem = this[0];
if (value == null) {
return elem.innerHTML;
} else {
elem.innerHTML = value;
return this;
}
},
// 获取 value
val: function val() {
var elem = this[0];
return elem.value.trim();
},
// focus
focus: function focus() {
return this.forEach(function (elem) {
elem.focus();
});
},
// parent
parent: function parent() {
var elem = this[0];
return $(elem.parentElement);
},
// parentUntil 找到符合 selector 的父节点
parentUntil: function parentUntil(selector, _currentElem) {
var results = document.querySelectorAll(selector);
var length = results.length;
if (!length) {
// 传入的 selector 无效
return null;
}
var elem = _currentElem || this[0];
if (elem.nodeName === 'BODY') {
return null;
}
var parent = elem.parentElement;
var i = void 0;
for (i = 0; i < length; i++) {
if (parent === results[i]) {
// 找到,并返回
return $(parent);
}
}
// 继续查找
return this.parentUntil(selector, parent);
},
// 判断两个 elem 是否相等
equal: function equal($elem) {
if ($elem.nodeType === 1) {
return this[0] === $elem;
} else {
return this[0] === $elem[0];
}
},
// 将该元素插入到某个元素前面
insertBefore: function insertBefore(selector) {
var $referenceNode = $(selector);
var referenceNode = $referenceNode[0];
if (!referenceNode) {
return this;
}
return this.forEach(function (elem) {
var parent = referenceNode.parentNode;
parent.insertBefore(elem, referenceNode);
});
},
// 将该元素插入到某个元素后面
insertAfter: function insertAfter(selector) {
var $referenceNode = $(selector);
var referenceNode = $referenceNode[0];
if (!referenceNode) {
return this;
}
return this.forEach(function (elem) {
var parent = referenceNode.parentNode;
if (parent.lastChild === referenceNode) {
// 最后一个元素
parent.appendChild(elem);
} else {
// 不是最后一个元素
parent.insertBefore(elem, referenceNode.nextSibling);
}
});
}
};
// new 一个对象
function $(selector) {
return new DomElement(selector);
}
// 解绑所有事件,用于销毁编辑器
$.offAll = function () {
eventList.forEach(function (item) {
var elem = item.elem;
var type = item.type;
var fn = item.fn;
// 解绑
elem.removeEventListener(type, fn);
});
};
/*
配置信息
*/
var config = {
// 默认菜单配置
menus: ['head', 'bold', 'fontSize', 'fontName', 'italic', 'underline', 'strikeThrough', 'foreColor', 'backColor', 'link', 'list', 'justify', 'quote', 'emoticon', 'image', 'table', 'video', 'code', 'undo', 'redo'],
fontNames: ['宋体', '微软雅黑', 'Arial', 'Tahoma', 'Verdana'],
colors: ['#000000', '#eeece0', '#1c487f', '#4d80bf', '#c24f4a', '#8baa4a', '#7b5ba1', '#46acc8', '#f9963b', '#ffffff'],
// // 语言配置
// lang: {
// '设置标题': 'title',
// '正文': 'p',
// '链接文字': 'link text',
// '链接': 'link',
// '插入': 'insert',
// '创建': 'init'
// },
// 表情
emotions: [{
// tab 的标题
title: '默认',
// type -> 'emoji' / 'image'
type: 'image',
// content -> 数组
content: [{
alt: '[坏笑]',
src: 'http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/50/pcmoren_huaixiao_org.png'
}, {
alt: '[舔屏]',
src: 'http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/40/pcmoren_tian_org.png'
}, {
alt: '[污]',
src: 'http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/3c/pcmoren_wu_org.png'
}]
}, {
// tab 的标题
title: '新浪',
// type -> 'emoji' / 'image'
type: 'image',
// content -> 数组
content: [{
src: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/7a/shenshou_thumb.gif',
alt: '[草泥马]'
}, {
src: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/60/horse2_thumb.gif',
alt: '[神马]'
}, {
src: 'http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/bc/fuyun_thumb.gif',
alt: '[浮云]'
}]
}, {
// tab 的标题
title: 'emoji',
// type -> 'emoji' / 'image'
type: 'emoji',
// content -> 数组
content: '😀 😃 😄 😁 😆 😅 😂 😊 😇 🙂 🙃 😉 😓 😪 😴 🙄 🤔 😬 🤐'.split(/\s/)
}],
// 编辑区域的 z-index
zIndex: 10000,
// 是否开启 debug 模式(debug 模式下错误会 throw error 形式抛出)
debug: false,
// 插入链接时候的格式校验
linkCheck: function linkCheck(text, link) {
// text 是插入的文字
// link 是插入的链接
return true; // 返回 true 即表示成功
// return '校验失败' // 返回字符串即表示失败的提示信息
},
// 插入网络图片的校验
linkImgCheck: function linkImgCheck(src) {
// src 即图片的地址
return true; // 返回 true 即表示成功
// return '校验失败' // 返回字符串即表示失败的提示信息
},
// 粘贴过滤样式,默认开启
pasteFilterStyle: true,
// 粘贴内容时,忽略图片。默认关闭
pasteIgnoreImg: false,
// 对粘贴的文字进行自定义处理,返回处理后的结果。编辑器会将处理后的结果粘贴到编辑区域中。
// IE 暂时不支持
pasteTextHandle: function pasteTextHandle(content) {
// content 即粘贴过来的内容(html 或 纯文本),可进行自定义处理然后返回
return content;
},
// onchange 事件
// onchange: function (html) {
// // html 即变化之后的内容
// console.log(html)
// },
// 是否显示添加网络图片的 tab
showLinkImg: true,
// 插入网络图片的回调
linkImgCallback: function linkImgCallback(url) {
// console.log(url) // url 即插入图片的地址
},
// 默认上传图片 max size: 5M
uploadImgMaxSize: 5 * 1024 * 1024,
// 配置一次最多上传几个图片
// uploadImgMaxLength: 5,
// 上传图片,是否显示 base64 格式
uploadImgShowBase64: false,
// 上传图片,server 地址(如果有值,则 base64 格式的配置则失效)
// uploadImgServer: '/upload',
// 自定义配置 filename
uploadFileName: '',
// 上传图片的自定义参数
uploadImgParams: {
// token: 'abcdef12345'
},
// 上传图片的自定义header
uploadImgHeaders: {
// 'Accept': 'text/x-json'
},
// 配置 XHR withCredentials
withCredentials: false,
// 自定义上传图片超时时间 ms
uploadImgTimeout: 10000,
// 上传图片 hook
uploadImgHooks: {
// customInsert: function (insertLinkImg, result, editor) {
// console.log('customInsert')
// // 图片上传并返回结果,自定义插入图片的事件,而不是编辑器自动插入图片
// const data = result.data1 || []
// data.forEach(link => {
// insertLinkImg(link)
// })
// },
before: function before(xhr, editor, files) {
// 图片上传之前触发
// 如果返回的结果是 {prevent: true, msg: 'xxxx'} 则表示用户放弃上传
// return {
// prevent: true,
// msg: '放弃上传'
// }
},
success: function success(xhr, editor, result) {
// 图片上传并返回结果,图片插入成功之后触发
},
fail: function fail(xhr, editor, result) {
// 图片上传并返回结果,但图片插入错误时触发
},
error: function error(xhr, editor) {
// 图片上传出错时触发
},
timeout: function timeout(xhr, editor) {
// 图片上传超时时触发
}
},
// 是否上传七牛云,默认为 false
qiniu: false
};
/*
工具
*/
// 和 UA 相关的属性
var UA = {
_ua: navigator.userAgent,
// 是否 webkit
isWebkit: function isWebkit() {
var reg = /webkit/i;
return reg.test(this._ua);
},
// 是否 IE
isIE: function isIE() {
return 'ActiveXObject' in window;
}
};
// 遍历对象
function objForEach(obj, fn) {
var key = void 0,
result = void 0;
for (key in obj) {
if (obj.hasOwnProperty(key)) {
result = fn.call(obj, key, obj[key]);
if (result === false) {
break;
}
}
}
}
// 遍历类数组
function arrForEach(fakeArr, fn) {
var i = void 0,
item = void 0,
result = void 0;
var length = fakeArr.length || 0;
for (i = 0; i < length; i++) {
item = fakeArr[i];
result = fn.call(fakeArr, item, i);
if (result === false) {
break;
}
}
}
// 获取随机数
function getRandom(prefix) {
return prefix + Math.random().toString().slice(2);
}
// 替换 html 特殊字符
function replaceHtmlSymbol(html) {
if (html == null) {
return '';
}
return html.replace(/</gm, '<').replace(/>/gm, '>').replace(/"/gm, '"').replace(/(\r\n|\r|\n)/g, '<br/>');
}
// 返回百分比的格式
// 判断是不是 function
function isFunction(fn) {
return typeof fn === 'function';
}
/*
bold-menu
*/
// 构造函数
function Bold(editor) {
this.editor = editor;
this.$elem = $('<div class="w-e-menu">\n <i class="w-e-icon-bold"></i>\n </div>');
this.type = 'click';
// 当前是否 active 状态
this._active = false;
}
// 原型
Bold.prototype = {
constructor: Bold,
// 点击事件
onClick: function onClick(e) {
// 点击菜单将触发这里
var editor = this.editor;
var isSeleEmpty = editor.selection.isSelectionEmpty();
if (isSeleEmpty) {
// 选区是空的,插入并选中一个“空白”
editor.selection.createEmptyRange();
}
// 执行 bold 命令
editor.cmd.do('bold');
if (isSeleEmpty) {
// 需要将选取折叠起来
editor.selection.collapseRange();
editor.selection.restoreSelection();
}
},
// 试图改变 active 状态
tryChangeActive: function tryChangeActive(e) {
var editor = this.editor;
var $elem = this.$elem;
if (editor.cmd.queryCommandState('bold')) {
this._active = true;
$elem.addClass('w-e-active');
} else {
this._active = false;
$elem.removeClass('w-e-active');
}
}
};
/*
替换多语言
*/
var replaceLang = function (editor, str) {
var langArgs = editor.config.langArgs || [];
var result = str;
langArgs.forEach(function (item) {
var reg = item.reg;
var val = item.val;
if (reg.test(result)) {
result = result.replace(reg, function () {
return val;
});
}
});
return result;
};
/*
droplist
*/
var _emptyFn = function _emptyFn() {};
// 构造函数
function DropList(menu, opt) {
var _this = this;
// droplist 所依附的菜单
var editor = menu.editor;
this.menu = menu;
this.opt = opt;
// 容器
var $container = $('<div class="w-e-droplist"></div>');
// 标题
var $title = opt.$title;
var titleHtml = void 0;
if ($title) {
// 替换多语言
titleHtml = $title.html();
titleHtml = replaceLang(editor, titleHtml);
$title.html(titleHtml);
$title.addClass('w-e-dp-title');
$container.append($title);
}
var list = opt.list || [];
var type = opt.type || 'list'; // 'list' 列表形式(如“标题”菜单) / 'inline-block' 块状形式(如“颜色”菜单)
var onClick = opt.onClick || _emptyFn;
// 加入 DOM 并绑定事件
var $list = $('<ul class="' + (type === 'list' ? 'w-e-list' : 'w-e-block') + '"></ul>');
$container.append($list);
list.forEach(function (item) {
var $elem = item.$elem;
// 替换多语言
var elemHtml = $elem.html();
elemHtml = replaceLang(editor, elemHtml);
$elem.html(elemHtml);
var value = item.value;
var $li = $('<li class="w-e-item"></li>');
if ($elem) {
$li.append($elem);
$list.append($li);
$li.on('click', function (e) {
onClick(value);
// 隐藏
_this.hideTimeoutId = setTimeout(function () {
_this.hide();
}, 0);
});
}
});
// 绑定隐藏事件
$container.on('mouseleave', function (e) {
_this.hideTimeoutId = setTimeout(function () {
_this.hide();
}, 0);
});
// 记录属性
this.$container = $container;
// 基本属性
this._rendered = false;
this._show = false;
}
// 原型
DropList.prototype = {
constructor: DropList,
// 显示(插入DOM)
show: function show() {
if (this.hideTimeoutId) {
// 清除之前的定时隐藏
clearTimeout(this.hideTimeoutId);
}
var menu = this.menu;
var $menuELem = menu.$elem;
var $container = this.$container;
if (this._show) {
return;
}
if (this._rendered) {
// 显示
$container.show();
} else {
// 加入 DOM 之前先定位位置
var menuHeight = $menuELem.getSizeData().height || 0;
var width = this.opt.width || 100; // 默认为 100
$container.css('margin-top', menuHeight + 'px').css('width', width + 'px');
// 加入到 DOM
$menuELem.append($container);
this._rendered = true;
}
// 修改属性
this._show = true;
},
// 隐藏(移除DOM)
hide: function hide() {
if (this.showTimeoutId) {
// 清除之前的定时显示
clearTimeout(this.showTimeoutId);
}
var $container = this.$container;
if (!this._show) {
return;
}
// 隐藏并需改属性
$container.hide();
this._show = false;
}
};
/*
menu - header
*/
// 构造函数
function Head(editor) {
var _this = this;
this.editor = editor;
this.$elem = $('<div class="w-e-menu"><i class="w-e-icon-header"></i></div>');
this.type = 'droplist';
// 当前是否 active 状态
this._active = false;
// 初始化 droplist
this.droplist = new DropList(this, {
width: 100,
$title: $('<p>设置标题</p>'),
type: 'list', // droplist 以列表形式展示
list: [{ $elem: $('<h1>H1</h1>'), value: '<h1>' }, { $elem: $('<h2>H2</h2>'), value: '<h2>' }, { $elem: $('<h3>H3</h3>'), value: '<h3>' }, { $elem: $('<h4>H4</h4>'), value: '<h4>' }, { $elem: $('<h5>H5</h5>'), value: '<h5>' }, { $elem: $('<p>正文</p>'), value: '<p>' }],
onClick: function onClick(value) {
// 注意 this 是指向当前的 Head 对象
_this._command(value);
}
});
}
// 原型
Head.prototype = {
constructor: Head,
// 执行命令
_command: function _command(value) {
var editor = this.editor;
var $selectionElem = editor.selection.getSelectionContainerElem();
if (editor.$textElem.equal($selectionElem)) {
// 不能选中多行来设置标题,否则会出现问题
// 例如选中的是 <p>xxx</p><p>yyy</p> 来设置标题,设置之后会成为 <h1>xxx<br>yyy</h1> 不符合预期
return;
}
editor.cmd.do('formatBlock', value);
},
// 试图改变 active 状态
tryChangeActive: function tryChangeActive(e) {
var editor = this.editor;
var $elem = this.$elem;
var reg = /^h/i;
var cmdValue = editor.cmd.queryCommandValue('formatBlock');
if (reg.test(cmdValue)) {
this._active = true;
$elem.addClass('w-e-active');
} else {
this._active = false;
$elem.removeClass('w-e-active');
}
}
};
/*
menu - fontSize
*/
// 构造函数
function FontSize(editor) {
var _this = this;
this.editor = editor;
this.$elem = $('<div class="w-e-menu"><i class="w-e-icon-text-heigh"></i></div>');
this.type = 'droplist';
// 当前是否 active 状态
this._active = false;
// 初始化 droplist
this.droplist = new DropList(this, {
width: 160,
$title: $('<p>字号</p>'),
type: 'list', // droplist 以列表形式展示
list: [{ $elem: $('<span style="font-size: x-small;">x-small</span>'), value: '1' }, { $elem: $('<span style="font-size: small;">small</span>'), value: '2' }, { $elem: $('<span>normal</span>'), value: '3' }, { $elem: $('<span style="font-size: large;">large</span>'), value: '4' }, { $elem: $('<span style="font-size: x-large;">x-large</span>'), value: '5' }, { $elem: $('<span style="font-size: xx-large;">xx-large</span>'), value: '6' }],
onClick: function onClick(value) {
// 注意 this 是指向当前的 FontSize 对象
_this._command(value);
}
});
}
// 原型
FontSize.prototype = {
constructor: FontSize,
// 执行命令
_command: function _command(value) {
var editor = this.editor;
editor.cmd.do('fontSize', value);
}
};
/*
menu - fontName
*/
// 构造函数
function FontName(editor) {
var _this = this;
this.editor = editor;
this.$elem = $('<div class="w-e-menu"><i class="w-e-icon-font"></i></div>');
this.type = 'droplist';
// 当前是否 active 状态
this._active = false;
// 获取配置的字体
var config = editor.config;
var fontNames = config.fontNames || [];
// 初始化 droplist
this.droplist = new DropList(this, {
width: 100,
$title: $('<p>字体</p>'),
type: 'list', // droplist 以列表形式展示
list: fontNames.map(function (fontName) {
return { $elem: $('<span style="font-family: ' + fontName + ';">' + fontName + '</span>'), value: fontName };
}),
onClick: function onClick(value) {
// 注意 this 是指向当前的 FontName 对象
_this._command(value);
}
});
}
// 原型
FontName.prototype = {
constructor: FontName,
_command: function _command(value) {
var editor = this.editor;
editor.cmd.do('fontName', value);
}
};
/*
panel
*/
var emptyFn = function emptyFn() {};
// 记录已经显示 panel 的菜单
var _isCreatedPanelMenus = [];
// 构造函数
function Panel(menu, opt) {
this.menu = menu;
this.opt = opt;
}
// 原型
Panel.prototype = {
constructor: Panel,
// 显示(插入DOM)
show: function show() {
var _this = this;
var menu = this.menu;
if (_isCreatedPanelMenus.indexOf(menu) >= 0) {
// 该菜单已经创建了 panel 不能再创建
return;
}
var editor = menu.editor;
var $body = $('body');
var $textContainerElem = editor.$textContainerElem;
var opt = this.opt;
// panel 的容器
var $container = $('<div class="w-e-panel-container"></div>');
var width = opt.width || 300; // 默认 300px
$container.css('width', width + 'px').css('margin-left', (0 - width) / 2 + 'px');
// 添加关闭按钮
var $closeBtn = $('<i class="w-e-icon-close w-e-panel-close"></i>');
$container.append($closeBtn);
$closeBtn.on('click', function () {
_this.hide();
});
// 准备 tabs 容器
var $tabTitleContainer = $('<ul class="w-e-panel-tab-title"></ul>');
var $tabContentContainer = $('<div class="w-e-panel-tab-content"></div>');
$container.append($tabTitleContainer).append($tabContentContainer);
// 设置高度
var height = opt.height;
if (height) {
$tabContentContainer.css('height', height + 'px').css('overflow-y', 'auto');
}
// tabs
var tabs = opt.tabs || [];
var tabTitleArr = [];
var tabContentArr = [];
tabs.forEach(function (tab, tabIndex) {
if (!tab) {
return;
}
var title = tab.title || '';
var tpl = tab.tpl || '';
// 替换多语言
title = replaceLang(editor, title);
tpl = replaceLang(editor, tpl);
// 添加到 DOM
var $title = $('<li class="w-e-item">' + title + '</li>');
$tabTitleContainer.append($title);
var $content = $(tpl);
$tabContentContainer.append($content);
// 记录到内存
$title._index = tabIndex;
tabTitleArr.push($title);
tabContentArr.push($content);
// 设置 active 项
if (tabIndex === 0) {
$title._active = true;
$title.addClass('w-e-active');
} else {
$content.hide();
}
// 绑定 tab 的事件
$title.on('click', function (e) {
if ($title._active) {
return;
}
// 隐藏所有的 tab
tabTitleArr.forEach(function ($title) {
$title._active = false;
$title.removeClass('w-e-active');
});
tabContentArr.forEach(function ($content) {
$content.hide();
});
// 显示当前的 tab
$title._active = true;
$title.addClass('w-e-active');
$content.show();
});
});
// 绑定关闭事件
$container.on('click', function (e) {
// 点击时阻止冒泡
e.stopPropagation();
});
$body.on('click', function (e) {
_this.hide();
});
// 添加到 DOM
$textContainerElem.append($container);
// 绑定 opt 的事件,只有添加到 DOM 之后才能绑定成功
tabs.forEach(function (tab, index) {
if (!tab) {
return;
}
var events = tab.events || [];
events.forEach(function (event) {
var selector = event.selector;
var type = event.type;
var fn = event.fn || emptyFn;
var $content = tabContentArr[index];
$content.find(selector).on(type, function (e) {
e.stopPropagation();
var needToHide = fn(e);
// 执行完事件之后,是否要关闭 panel
if (needToHide) {
_this.hide();
}
});
});
});
// focus 第一个 elem
var $inputs = $container.find('input[type=text],textarea');
if ($inputs.length) {
$inputs.get(0).focus();
}
// 添加到属性
this.$container = $container;
// 隐藏其他 panel
this._hideOtherPanels();
// 记录该 menu 已经创建了 panel
_isCreatedPanelMenus.push(menu);
},
// 隐藏(移除DOM)
hide: function hide() {
var menu = this.menu;
var $container = this.$container;
if ($container) {
$container.remove();
}
// 将该 menu 记录中移除
_isCreatedPanelMenus = _isCreatedPanelMenus.filter(function (item) {
if (item === menu) {
return false;
} else {
return true;
}
});
},
// 一个 panel 展示时,隐藏其他 panel
_hideOtherPanels: function _hideOtherPanels() {
if (!_isCreatedPanelMenus.length) {
return;
}
_isCreatedPanelMenus.forEach(function (menu) {
var panel = menu.panel || {};
if (panel.hide) {
panel.hide();
}
});
}
};
/*
menu - link
*/
// 构造函数
function Link(editor) {
this.editor = editor;
this.$elem = $('<div class="w-e-menu"><i class="w-e-icon-link"></i></div>');
this.type = 'panel';
// 当前是否 active 状态
this._active = false;
}
// 原型
Link.prototype = {
constructor: Link,
// 点击事件
onClick: function onClick(e) {
var editor = this.editor;
var $linkelem = void 0;
if (this._active) {
// 当前选区在链接里面
$linkelem = editor.selection.getSelectionContainerElem();
if (!$linkelem) {
return;
}
// 将该元素都包含在选取之内,以便后面整体替换
editor.selection.createRangeByElem($linkelem);
editor.selection.restoreSelection();
// 显示 panel
this._createPanel($linkelem.text(), $linkelem.attr('href'));
} else {
// 当前选区不在链接里面
if (editor.selection.isSelectionEmpty()) {
// 选区是空的,未选中内容
this._createPanel('', '');
} else {
// 选中内容了
this._createPanel(editor.selection.getSelectionText(), '');
}
}
},
// 创建 panel
_createPanel: function _createPanel(text, link) {
var _this = this;
// panel 中需要用到的id
var inputLinkId = getRandom('input-link');
var inputTextId = getRandom('input-text');
var btnOkId = getRandom('btn-ok');
var btnDelId = getRandom('btn-del');
// 是否显示“删除链接”
var delBtnDisplay = this._active ? 'inline-block' : 'none';
// 初始化并显示 panel
var panel = new Panel(this, {
width: 300,
// panel 中可包含多个 tab
tabs: [{
// tab 的标题
title: '链接',
// 模板
tpl: '<div>\n <input id="' + inputTextId + '" type="text" class="block" value="' + text + '" placeholder="\u94FE\u63A5\u6587\u5B57"/></td>\n <input id="' + inputLinkId + '" type="text" class="block" value="' + link + '" placeholder="http://..."/></td>\n <div class="w-e-button-container">\n <button id="' + btnOkId + '" class="right">\u63D2\u5165</button>\n <button id="' + btnDelId + '" class="gray right" style="display:' + delBtnDisplay + '">\u5220\u9664\u94FE\u63A5</button>\n </div>\n </div>',
// 事件绑定
events: [
// 插入链接
{
selector: '#' + btnOkId,
type: 'click',
fn: function fn() {
// 执行插入链接
var $link = $('#' + inputLinkId);
var $text = $('#' + inputTextId);
var link = $link.val();
var text = $text.val();
_this._insertLink(text, link);
// 返回 true,表示该事件执行完之后,panel 要关闭。否则 panel 不会关闭
return true;
}
},
// 删除链接
{
selector: '#' + btnDelId,
type: 'click',
fn: function fn() {
// 执行删除链接
_this._delLink();
// 返回 true,表示该事件执行完之后,panel 要关闭。否则 panel 不会关闭
return true;
}
}]
} // tab end
] // tabs end
});
// 显示 panel
panel.show();
// 记录属性
this.panel = panel;
},
// 删除当前链接
_delLink: function _delLink() {
if (!this._active) {
return;
}
var editor = this.editor;
var $selectionELem = editor.selection.getSelectionContainerElem();
if (!$selectionELem) {
return;
}
var selectionText = editor.selection.getSelectionText();
editor.cmd.do('insertHTML', '<span>' + selectionText + '</span>');
},
// 插入链接
_insertLink: function _insertLink(text, link) {
var editor = this.editor;
var config = editor.config;
var linkCheck = config.linkCheck;
var checkResult = true; // 默认为 true
if (linkCheck && typeof linkCheck === 'function') {
checkResult = linkCheck(text, link);
}
if (checkResult === true) {
editor.cmd.do('insertHTML', '<a href="' + link + '" target="_blank">' + text + '</a>');
} else {
alert(checkResult);
}
},
// 试图改变 active 状态
tryChangeActive: function tryChangeActive(e) {
var editor = this.editor;
var $elem = this.$elem;
var $selectionELem = editor.selection.getSelectionContainerElem();
if (!$selectionELem) {
return;
}
if ($selectionELem.getNodeName() === 'A') {
this._active = true;
$elem.addClass('w-e-active');
} else {
this._active = false;
$elem.removeClass('w-e-active');
}
}
};
/*
italic-menu
*/
// 构造函数
function Italic(editor) {
this.editor = editor;
this.$elem = $('<div class="w-e-menu">\n <i class="w-e-icon-italic"></i>\n </div>');
this.type = 'click';
// 当前是否 active 状态
this._active = false;
}
// 原型
Italic.prototype = {
constructor: Italic,
// 点击事件
onClick: function onClick(e) {
// 点击菜单将触发这里
var editor = this.editor;
var isSeleEmpty = editor.selection.isSelectionEmpty();
if (isSeleEmpty) {
// 选区是空的,插入并选中一个“空白”
editor.selection.createEmptyRange();
}
// 执行 italic 命令
editor.cmd.do('italic');
if (isSeleEmpty) {
// 需要将选取折叠起来
editor.selection.collapseRange();
editor.selection.restoreSelection();
}
},
// 试图改变 active 状态
tryChangeActive: function tryChangeActive(e) {
var editor = this.editor;
var $elem = this.$elem;
if (editor.cmd.queryCommandState('italic')) {
this._active = true;
$elem.addClass('w-e-active');
} else {
this._active = false;
$elem.removeClass('w-e-active');
}
}
};
/*
redo-menu
*/
// 构造函数
function Redo(editor) {
this.editor = editor;
this.$elem = $('<div class="w-e-menu">\n <i class="w-e-icon-redo"></i>\n </div>');
this.type = 'click';
// 当前是否 active 状态
this._active = false;
}
// 原型
Redo.prototype = {
constructor: Redo,
// 点击事件
onClick: function onClick(e) {
// 点击菜单将触发这里
var editor = this.editor;
// 执行 redo 命令
editor.cmd.do('redo');
}
};
/*
strikeThrough-menu
*/
// 构造函数
function StrikeThrough(editor) {
this.editor = editor;
this.$elem = $('<div class="w-e-menu">\n <i class="w-e-icon-strikethrough"></i>\n </div>');
this.type = 'click';
// 当前是否 active 状态
this._active = false;
}
// 原型
StrikeThrough.prototype = {
constructor: StrikeThrough,
// 点击事件
onClick: function onClick(e) {
// 点击菜单将触发这里
var editor = this.editor;
var isSeleEmpty = editor.selection.isSelectionEmpty();
if (isSeleEmpty) {
// 选区是空的,插入并选中一个“空白”
editor.selection.createEmptyRange();
}
// 执行 strikeThrough 命令
editor.cmd.do('strikeThrough');
if (isSeleEmpty) {
// 需要将选取折叠起来
editor.selection.collapseRange();
editor.selection.restoreSelection();
}
},
// 试图改变 active 状态
tryChangeActive: function tryChangeActive(e) {
var editor = this.editor;
var $elem = this.$elem;
if (editor.cmd.queryCommandState('strikeThrough')) {
this._active = true;
$elem.addClass('w-e-active');
} else {
this._active = false;
$elem.removeClass('w-e-active');
}
}
};
/*
underline-menu
*/
// 构造函数
function Underline(editor) {
this.editor = editor;
this.$elem = $('<div class="w-e-menu">\n <i class="w-e-icon-underline"></i>\n </div>');
this.type = 'click';
// 当前是否 active 状态
this._active = false;
}
// 原型
Underline.prototype = {
constructor: Underline,
// 点击事件
onClick: function onClick(e) {
// 点击菜单将触发这里
var editor = this.editor;
var isSeleEmpty = editor.selection.isSelectionEmpty();
if (isSeleEmpty) {
// 选区是空的,插入并选中一个“空白”
editor.selection.createEmptyRange();
}
// 执行 underline 命令
editor.cmd.do('underline');
if (isSeleEmpty) {
// 需要将选取折叠起来
editor.selection.collapseRange();
editor.selection.restoreSelection();
}
},
// 试图改变 active 状态
tryChangeActive: function tryChangeActive(e) {
var editor = this.editor;
var $elem = this.$elem;
if (editor.cmd.queryCommandState('underline')) {
this._active = true;
$elem.addClass('w-e-active');
} else {
this._active = false;
$elem.removeClass('w-e-active');
}
}
};
/*
undo-menu
*/
// 构造函数
function Undo(editor) {
this.editor = editor;
this.$elem = $('<div class="w-e-menu">\n <i class="w-e-icon-undo"></i>\n </div>');
this.type = 'click';
// 当前是否 active 状态
this._active = false;
}
// 原型
Undo.prototype = {
constructor: Undo,
// 点击事件
onClick: function onClick(e) {
// 点击菜单将触发这里
var editor = this.editor;
// 执行 undo 命令
editor.cmd.do('undo');
}
};
/*
menu - list
*/
// 构造函数
function List(editor) {
var _this = this;
this.editor = editor;
this.$elem = $('<div class="w-e-menu"><i class="w-e-icon-list2"></i></div>');
this.type = 'droplist';
// 当前是否 active 状态
this._active = false;
// 初始化 droplist
this.droplist = new DropList(this, {
width: 120,
$title: $('<p>设置列表</p>'),
type: 'list', // droplist 以列表形式展示
list: [{ $elem: $('<span><i class="w-e-icon-list-numbered"></i> 有序列表</span>'), value: 'insertOrderedList' }, { $elem: $('<span><i class="w-e-icon-list2"></i> 无序列表</span>'), value: 'insertUnorderedList' }],
onClick: function onClick(value) {
// 注意 this 是指向当前的 List 对象
_this._command(value);
}
});
}
// 原型
List.prototype = {
constructor: List,
// 执行命令
_command: function _command(value) {
var editor = this.editor;
var $textElem = editor.$textElem;
editor.selection.restoreSelection();
if (editor.cmd.queryCommandState(value)) {
return;
}
editor.cmd.do(value);
// 验证列表是否被包裹在 <p> 之内
var $selectionElem = editor.selection.getSelectionContainerElem();
if ($selectionElem.getNodeName() === 'LI') {
$selectionElem = $selectionElem.parent();
}
if (/^ol|ul$/i.test($selectionElem.getNodeName()) === false) {
return;
}
if ($selectionElem.equal($textElem)) {
// 证明是顶级标签,没有被 <p> 包裹
return;
}
var $parent = $selectionElem.parent();
if ($parent.equal($textElem)) {
// $parent 是顶级标签,不能删除
return;
}
$selectionElem.insertAfter($parent);
$parent.remove();
},
// 试图改变 active 状态
tryChangeActive: function tryChangeActive(e) {
var editor = this.editor;
var $elem = this.$elem;
if (editor.cmd.queryCommandState('insertUnOrderedList') || editor.cmd.queryCommandState('insertOrderedList')) {
this._active = true;
$elem.addClass('w-e-active');
} else {
this._active = false;
$elem.removeClass('w-e-active');
}
}
};
/*
menu - justify
*/
// 构造函数
function Justify(editor) {
var _this = this;
this.editor = editor;
this.$elem = $('<div class="w-e-menu"><i class="w-e-icon-paragraph-left"></i></div>');
this.type = 'droplist';
// 当前是否 active 状态
this._active = false;
// 初始化 droplist
this.droplist = new DropList(this, {
width: 100,
$title: $('<p>对齐方式</p>'),
type: 'list', // droplist 以列表形式展示
list: [{ $elem: $('<span><i class="w-e-icon-paragraph-left"></i> 靠左</span>'), value: 'justifyLeft' }, { $elem: $('<span><i class="w-e-icon-paragraph-center"></i> 居中</span>'), value: 'justifyCenter' }, { $elem: $('<span><i class="w-e-icon-paragraph-right"></i> 靠右</span>'), value: 'justifyRight' }],
onClick: function onClick(value) {
// 注意 this 是指向当前的 List 对象
_this._command(value);
}
});
}
// 原型
Justify.prototype = {
constructor: Justify,
// 执行命令
_command: function _command(value) {
var editor = this.editor;
editor.cmd.do(value);
}
};
/*
menu - Forecolor
*/
// 构造函数
function ForeColor(editor) {
var _this = this;
this.editor = editor;
this.$elem = $('<div class="w-e-menu"><i class="w-e-icon-pencil2"></i></div>');
this.type = 'droplist';
// 获取配置的颜色
var config = editor.config;
var colors = config.colors || [];
// 当前是否 active 状态
this._active = false;
// 初始化 droplist
this.droplist = new DropList(this, {
width: 120,
$title: $('<p>文字颜色</p>'),
type: 'inline-block', // droplist 内容以 block 形式展示
list: colors.map(function (color) {
return { $elem: $('<i style="color:' + color + ';" class="w-e-icon-pencil2"></i>'), value: color };
}),
onClick: function onClick(value) {
// 注意 this 是指向当前的 ForeColor 对象
_this._command(value);
}
});
}
// 原型
ForeColor.prototype = {
constructor: ForeColor,
// 执行命令
_command: function _command(value) {
var editor = this.editor;
editor.cmd.do('foreColor', value);
}
};
/*
menu - BackColor
*/
// 构造函数
function BackColor(editor) {
var _this = this;
this.editor = editor;
this.$elem = $('<div class="w-e-menu"><i class="w-e-icon-paint-brush"></i></div>');
this.type = 'droplist';
// 获取配置的颜色
var config = editor.config;
var colors = config.colors || [];
// 当前是否 active 状态
this._active = false;
// 初始化 droplist
this.droplist = new DropList(this, {
width: 120,
$title: $('<p>背景色</p>'),
type: 'inline-block', // droplist 内容以 block 形式展示
list: colors.map(function (color) {
return { $elem: $('<i style="color:' + color + ';" class="w-e-icon-paint-brush"></i>'), value: color };
}),
onClick: function onClick(value) {
// 注意 this 是指向当前的 BackColor 对象
_this._command(value);
}
});
}
// 原型
BackColor.prototype = {
constructor: BackColor,
// 执行命令
_command: function _command(value) {
var editor = this.editor;
editor.cmd.do('backColor', value);
}
};
/*
menu - quote
*/
// 构造函数
function Quote(editor) {
this.editor = editor;
this.$elem = $('<div class="w-e-menu">\n <i class="w-e-icon-quotes-left"></i>\n </div>');
this.type = 'click';
// 当前是否 active 状态
this._active = false;
}
// 原型
Quote.prototype = {
constructor: Quote,
onClick: function onClick(e) {
var editor = this.editor;
var $selectionElem = editor.selection.getSelectionContainerElem();
var nodeName = $selectionElem.getNodeName();
if (!UA.isIE()) {
if (nodeName === 'BLOCKQUOTE') {
// 撤销 quote
editor.cmd.do('formatBlock', '<P>');
} else {
// 转换为 quote
editor.cmd.do('formatBlock', '<BLOCKQUOTE>');
}
return;
}
// IE 中不支持 formatBlock <BLOCKQUOTE> ,要用其他方式兼容
var content = void 0,
$targetELem = void 0;
if (nodeName === 'P') {
// 将 P 转换为 quote
content = $selectionElem.text();
$targetELem = $('<blockquote>' + content + '</blockquote>');
$targetELem.insertAfter($selectionElem);
$selectionElem.remove();
return;
}
if (nodeName === 'BLOCKQUOTE') {
// 撤销 quote
content = $selectionElem.text();
$targetELem = $('<p>' + content + '</p>');
$targetELem.insertAfter($selectionElem);
$selectionElem.remove();
}
},
tryChangeActive: function tryChangeActive(e) {
var editor = this.editor;
var $elem = this.$elem;
var reg = /^BLOCKQUOTE$/i;
var cmdValue = editor.cmd.queryCommandValue('formatBlock');
if (reg.test(cmdValue)) {
this._active = true;
$elem.addClass('w-e-active');
} else {
this._active = false;
$elem.removeClass('w-e-active');
}
}
};
/*
menu - code
*/
// 构造函数
function Code(editor) {
this.editor = editor;
this.$elem = $('<div class="w-e-menu">\n <i class="w-e-icon-terminal"></i>\n </div>');
this.type = 'panel';
// 当前是否 active 状态
this._active = false;
}
// 原型
Code.prototype = {
constructor: Code,
onClick: function onClick(e) {
var editor = this.editor;
var $startElem = editor.selection.getSelectionStartElem();
var $endElem = editor.selection.getSelectionEndElem();
var isSeleEmpty = editor.selection.isSelectionEmpty();
var selectionText = editor.selection.getSelectionText();
var $code = void 0;
if (!$startElem.equal($endElem)) {
// 跨元素选择,不做处理
editor.selection.restoreSelection();
return;
}
if (!isSeleEmpty) {
// 选取不是空,用 <code> 包裹即可
$code = $('<code>' + selectionText + '</code>');
editor.cmd.do('insertElem', $code);
editor.selection.createRangeByElem($code, false);
editor.selection.restoreSelection();
return;
}
// 选取是空,且没有夸元素选择,则插入 <pre><code></code></prev>
if (this._active) {
// 选中状态,将编辑内容
this._createPanel($startElem.html());
} else {
// 未选中状态,将创建内容
this._createPanel();
}
},
_createPanel: function _createPanel(value) {
var _this = this;
// value - 要编辑的内容
value = value || '';
var type = !value ? 'new' : 'edit';
var textId = getRandom('texxt');
var btnId = getRandom('btn');
var panel = new Panel(this, {
width: 500,
// 一个 Panel 包含多个 tab
tabs: [{
// 标题
title: '插入代码',
// 模板
tpl: '<div>\n <textarea id="' + textId + '" style="height:145px;;">' + value + '</textarea>\n <div class="w-e-button-container">\n <button id="' + btnId + '" class="right">\u63D2\u5165</button>\n </div>\n <div>',
// 事件绑定
events: [
// 插入代码
{
selector: '#' + btnId,
type: 'click',
fn: function fn() {
var $text = $('#' + textId);
var text = $text.val() || $text.html();
text = replaceHtmlSymbol(text);
if (type === 'new') {
// 新插入
_this._insertCode(text);
} else {
// 编辑更新
_this._updateCode(text);
}
// 返回 true,表示该事件执行完之后,panel 要关闭。否则 panel 不会关闭
return true;
}
}]
} // first tab end
] // tabs end
}); // new Panel end
// 显示 panel
panel.show();
// 记录属性
this.panel = panel;
},
// 插入代码
_insertCode: function _insertCode(value) {
var editor = this.editor;
editor.cmd.do('insertHTML', '<pre><code>' + value + '</code></pre><p><br></p>');
},
// 更新代码
_updateCode: function _updateCode(value) {
var editor = this.editor;
var $selectionELem = editor.selection.getSelectionContainerElem();
if (!$selectionELem) {
return;
}
$selectionELem.html(value);
editor.selection.restoreSelection();
},
// 试图改变 active 状态
tryChangeActive: function tryChangeActive(e) {
var editor = this.editor;
var $elem = this.$elem;
var $selectionELem = editor.selection.getSelectionContainerElem();
if (!$selectionELem) {
return;
}
var $parentElem = $selectionELem.parent();
if ($selectionELem.getNodeName() === 'CODE' && $parentElem.getNodeName() === 'PRE') {
this._active = true;
$elem.addClass('w-e-active');
} else {
this._active = false;
$elem.removeClass('w-e-active');
}
}
};
/*
menu - emoticon
*/
// 构造函数
function Emoticon(editor) {
this.editor = editor;
this.$elem = $('<div class="w-e-menu">\n <i class="w-e-icon-happy"></i>\n </div>');
this.type = 'panel';
// 当前是否 active 状态
this._active = false;
}
// 原型
Emoticon.prototype = {
constructor: Emoticon,
onClick: function onClick() {
this._createPanel();
},
_createPanel: function _createPanel() {
var _this = this;
var editor = this.editor;
var config = editor.config;
// 获取表情配置
var emotions = config.emotions || [];
// 创建表情 dropPanel 的配置
var tabConfig = [];
emotions.forEach(function (emotData) {
var emotType = emotData.type;
var content = emotData.content || [];
// 这一组表情最终拼接出来的 html
var faceHtml = '';
// emoji 表情
if (emotType === 'emoji') {
content.forEach(function (item) {
if (item) {
faceHtml += '<span class="w-e-item">' + item + '</span>';
}
});
}
// 图片表情
if (emotType === 'image') {
content.forEach(function (item) {
var src = item.src;
var alt = item.alt;
if (src) {
// 加一个 data-w-e 属性,点击图片的时候不再提示编辑图片
faceHtml += '<span class="w-e-item"><img src="' + src + '" alt="' + alt + '" data-w-e="1"/></span>';
}
});
}
tabConfig.push({
title: emotData.title,
tpl: '<div class="w-e-emoticon-container">' + faceHtml + '</div>',
events: [{
selector: 'span.w-e-item',
type: 'click',
fn: function fn(e) {
var target = e.target;
var $target = $(target);
var nodeName = $target.getNodeName();
var insertHtml = void 0;
if (nodeName === 'IMG') {
// 插入图片
insertHtml = $target.parent().html();
} else {
// 插入 emoji
insertHtml = '<span>' + $target.html() + '</span>';
}
_this._insert(insertHtml);
// 返回 true,表示该事件执行完之后,panel 要关闭。否则 panel 不会关闭
return true;
}
}]
});
});
var panel = new Panel(this, {
width: 300,
height: 200,
// 一个 Panel 包含多个 tab
tabs: tabConfig
});
// 显示 panel
panel.show();
// 记录属性
this.panel = panel;
},
// 插入表情
_insert: function _insert(emotHtml) {
var editor = this.editor;
editor.cmd.do('insertHTML', emotHtml);
}
};
/*
menu - table
*/
// 构造函数
function Table(editor) {
this.editor = editor;
this.$elem = $('<div class="w-e-menu"><i class="w-e-icon-table2"></i></div>');
this.type = 'panel';
// 当前是否 active 状态
this._active = false;
}
// 原型
Table.prototype = {
constructor: Table,
onClick: function onClick() {
if (this._active) {
// 编辑现有表格
this._createEditPanel();
} else {
// 插入新表格
this._createInsertPanel();
}
},
// 创建插入新表格的 panel
_createInsertPanel: function _createInsertPanel() {
var _this = this;
// 用到的 id
var btnInsertId = getRandom('btn');
var textRowNum = getRandom('row');
var textColNum = getRandom('col');
var panel = new Panel(this, {
width: 250,
// panel 包含多个 tab
tabs: [{
// 标题
title: '插入表格',
// 模板
tpl: '<div>\n <p style="text-align:left; padding:5px 0;">\n \u521B\u5EFA\n <input id="' + textRowNum + '" type="text" value="5" style="width:40px;text-align:center;"/>\n \u884C\n <input id="' + textColNum + '" type="text" value="5" style="width:40px;text-align:center;"/>\n \u5217\u7684\u8868\u683C\n </p>\n <div class="w-e-button-container">\n <button id="' + btnInsertId + '" class="right">\u63D2\u5165</button>\n </div>\n </div>',
// 事件绑定
events: [{
// 点击按钮,插入表格
selector: '#' + btnInsertId,
type: 'click',
fn: function fn() {
var rowNum = parseInt($('#' + textRowNum).val());
var colNum = parseInt($('#' + textColNum).val());
if (rowNum && colNum && rowNum > 0 && colNum > 0) {
// form 数据有效
_this._insert(rowNum, colNum);
}
// 返回 true,表示该事件执行完之后,panel 要关闭。否则 panel 不会关闭
return true;
}
}]
} // first tab end
] // tabs end
}); // panel end
// 展示 panel
panel.show();
// 记录属性
this.panel = panel;
},
// 插入表格
_insert: function _insert(rowNum, colNum) {
// 拼接 table 模板
var r = void 0,
c = void 0;
var html = '<table border="0" width="100%" cellpadding="0" cellspacing="0">';
for (r = 0; r < rowNum; r++) {
html += '<tr>';
if (r === 0) {
for (c = 0; c < colNum; c++) {
html += '<th> </th>';
}
} else {
for (c = 0; c < colNum; c++) {
html += '<td> </td>';
}
}
html += '</tr>';
}
html += '</table><p><br></p>';
// 执行命令
var editor = this.editor;
editor.cmd.do('insertHTML', html);
// 防止 firefox 下出现 resize 的控制点
editor.cmd.do('enableObjectResizing', false);
editor.cmd.do('enableInlineTableEditing', false);
},
// 创建编辑表格的 panel
_createEditPanel: function _createEditPanel() {
var _this2 = this;
// 可用的 id
var addRowBtnId = getRandom('add-row');
var addColBtnId = getRandom('add-col');
var delRowBtnId = getRandom('del-row');
var delColBtnId = getRandom('del-col');
var delTableBtnId = getRandom('del-table');
// 创建 panel 对象
var panel = new Panel(this, {
width: 320,
// panel 包含多个 tab
tabs: [{
// 标题
title: '编辑表格',
// 模板
tpl: '<div>\n <div class="w-e-button-container" style="border-bottom:1px solid #f1f1f1;padding-bottom:5px;margin-bottom:5px;">\n <button id="' + addRowBtnId + '" class="left">\u589E\u52A0\u884C</button>\n <button id="' + delRowBtnId + '" class="red left">\u5220\u9664\u884C</button>\n <button id="' + addColBtnId + '" class="left">\u589E\u52A0\u5217</button>\n <button id="' + delColBtnId + '" class="red left">\u5220\u9664\u5217</button>\n </div>\n <div class="w-e-button-container">\n <button id="' + delTableBtnId + '" class="gray left">\u5220\u9664\u8868\u683C</button>\n </dv>\n </div>',
// 事件绑定
events: [{
// 增加行
selector: '#' + addRowBtnId,
type: 'click',
fn: function fn() {
_this2._addRow();
// 返回 true,表示该事件执行完之后,panel 要关闭。否则 panel 不会关闭
return true;
}
}, {
// 增加列
selector: '#' + addColBtnId,
type: 'click',
fn: function fn() {
_this2._addCol();
// 返回 true,表示该事件执行完之后,panel 要关闭。否则 panel 不会关闭
return true;
}
}, {
// 删除行
selector: '#' + delRowBtnId,
type: 'click',
fn: function fn() {
_this2._delRow();
// 返回 true,表示该事件执行完之后,panel 要关闭。否则 panel 不会关闭
return true;
}
}, {
// 删除列
selector: '#' + delColBtnId,
type: 'click',
fn: function fn() {
_this2._delCol();
// 返回 true,表示该事件执行完之后,panel 要关闭。否则 panel 不会关闭
return true;
}
}, {
// 删除表格
selector: '#' + delTableBtnId,
type: 'click',
fn: function fn() {
_this2._delTable();
// 返回 true,表示该事件执行完之后,panel 要关闭。否则 panel 不会关闭
return true;
}
}]
}]
});
// 显示 panel
panel.show();
},
// 获取选中的单元格的位置信息
_getLocationData: function _getLocationData() {
var result = {};
var editor = this.editor;
var $selectionELem = editor.selection.getSelectionContainerElem();
if (!$selectionELem) {
return;
}
var nodeName = $selectionELem.getNodeName();
if (nodeName !== 'TD' && nodeName !== 'TH') {
return;
}
// 获取 td index
var $tr = $selectionELem.parent();
var $tds = $tr.children();
var tdLength = $tds.length;
$tds.forEach(function (td, index) {
if (td === $selectionELem[0]) {
// 记录并跳出循环
result.td = {
index: index,
elem: td,
length: tdLength
};
return false;
}
});
// 获取 tr index
var $tbody = $tr.parent();
var $trs = $tbody.children();
var trLength = $trs.length;
$trs.forEach(function (tr, index) {
if (tr === $tr[0]) {
// 记录并跳出循环
result.tr = {
index: index,
elem: tr,
length: trLength
};
return false;
}
});
// 返回结果
return result;
},
// 增加行
_addRow: function _addRow() {
// 获取当前单元格的位置信息
var locationData = this._getLocationData();
if (!locationData) {
return;
}
var trData = locationData.tr;
var $currentTr = $(trData.elem);
var tdData = locationData.td;
var tdLength = tdData.length;
// 拼接即将插入的字符串
var newTr = document.createElement('tr');
var tpl = '',
i = void 0;
for (i = 0; i < tdLength; i++) {
tpl += '<td> </td>';
}
newTr.innerHTML = tpl;
// 插入
$(newTr).insertAfter($currentTr);
},
// 增加列
_addCol: function _addCol() {
// 获取当前单元格的位置信息
var locationData = this._getLocationData();
if (!locationData) {
return;
}
var trData = locationData.tr;
var tdData = locationData.td;
var tdIndex = tdData.index;
var $currentTr = $(trData.elem);
var $trParent = $currentTr.parent();
var $trs = $trParent.children();
// 遍历所有行
$trs.forEach(function (tr) {
var $tr = $(tr);
var $tds = $tr.children();
var $currentTd = $tds.get(tdIndex);
var name = $currentTd.getNodeName().toLowerCase();
// new 一个 td,并插入
var newTd = document.createElement(name);
$(newTd).insertAfter($currentTd);
});
},
// 删除行
_delRow: function _delRow() {
// 获取当前单元格的位置信息
var locationData = this._getLocationData();
if (!locationData) {
return;
}
var trData = locationData.tr;
var $currentTr = $(trData.elem);
$currentTr.remove();
},
// 删除列
_delCol: function _delCol() {
// 获取当前单元格的位置信息
var locationData = this._getLocationData();
if (!locationData) {
return;
}
var trData = locationData.tr;
var tdData = locationData.td;
var tdIndex = tdData.index;
var $currentTr = $(trData.elem);
var $trParent = $currentTr.parent();
var $trs = $trParent.children();
// 遍历所有行
$trs.forEach(function (tr) {
var $tr = $(tr);
var $tds = $tr.children();
var $currentTd = $tds.get(tdIndex);
// 删除
$currentTd.remove();
});
},
// 删除表格
_delTable: function _delTable() {
var editor = this.editor;
var $selectionELem = editor.selection.getSelectionContainerElem();
if (!$selectionELem) {
return;
}
var $table = $selectionELem.parentUntil('table');
if (!$table) {
return;
}
$table.remove();
},
// 试图改变 active 状态
tryChangeActive: function tryChangeActive(e) {
var editor = this.editor;
var $elem = this.$elem;
var $selectionELem = editor.selection.getSelectionContainerElem();
if (!$selectionELem) {
return;
}
var nodeName = $selectionELem.getNodeName();
if (nodeName === 'TD' || nodeName === 'TH') {
this._active = true;
$elem.addClass('w-e-active');
} else {
this._active = false;
$elem.removeClass('w-e-active');
}
}
};
/*
menu - video
*/
// 构造函数
function Video(editor) {
this.editor = editor;
this.$elem = $('<div class="w-e-menu"><i class="w-e-icon-play"></i></div>');
this.type = 'panel';
// 当前是否 active 状态
this._active = false;
}
// 原型
Video.prototype = {
constructor: Video,
onClick: function onClick() {
this._createPanel();
},
_createPanel: function _createPanel() {
var _this = this;
// 创建 id
var textValId = getRandom('text-val');
var btnId = getRandom('btn');
// 创建 panel
var panel = new Panel(this, {
width: 350,
// 一个 panel 多个 tab
tabs: [{
// 标题
title: '插入视频',
// 模板
tpl: '<div>\n <input id="' + textValId + '" type="text" class="block" placeholder="\u683C\u5F0F\u5982\uFF1A<iframe src=... ></iframe>"/>\n <div class="w-e-button-container">\n <button id="' + btnId + '" class="right">\u63D2\u5165</button>\n </div>\n </div>',
// 事件绑定
events: [{
selector: '#' + btnId,
type: 'click',
fn: function fn() {
var $text = $('#' + textValId);
var val = $text.val().trim();
// 测试用视频地址
// <iframe height=498 width=510 src='http://player.youku.com/embed/XMjcwMzc3MzM3Mg==' frameborder=0 'allowfullscreen'></iframe>
if (val) {
// 插入视频
_this._insert(val);
}
// 返回 true,表示该事件执行完之后,panel 要关闭。否则 panel 不会关闭
return true;
}
}]
} // first tab end
] // tabs end
}); // panel end
// 显示 panel
panel.show();
// 记录属性
this.panel = panel;
},
// 插入视频
_insert: function _insert(val) {
var editor = this.editor;
editor.cmd.do('insertHTML', val + '<p><br></p>');
}
};
/*
menu - img
*/
// 构造函数
function Image(editor) {
this.editor = editor;
var imgMenuId = getRandom('w-e-img');
this.$elem = $('<div class="w-e-menu" id="' + imgMenuId + '"><i class="w-e-icon-image"></i></div>');
editor.imgMenuId = imgMenuId;
this.type = 'panel';
// 当前是否 active 状态
this._active = false;
}
// 原型
Image.prototype = {
constructor: Image,
onClick: function onClick() {
var editor = this.editor;
var config = editor.config;
if (config.qiniu) {
return;
}
if (this._active) {
this._createEditPanel();
} else {
this._createInsertPanel();
}
},
_createEditPanel: function _createEditPanel() {
var editor = this.editor;
// id
var width30 = getRandom('width-30');
var width50 = getRandom('width-50');
var width100 = getRandom('width-100');
var delBtn = getRandom('del-btn');
// tab 配置
var tabsConfig = [{
title: '编辑图片',
tpl: '<div>\n <div class="w-e-button-container" style="border-bottom:1px solid #f1f1f1;padding-bottom:5px;margin-bottom:5px;">\n <span style="float:left;font-size:14px;margin:4px 5px 0 5px;color:#333;">\u6700\u5927\u5BBD\u5EA6\uFF1A</span>\n <button id="' + width30 + '" class="left">30%</button>\n <button id="' + width50 + '" class="left">50%</button>\n <button id="' + width100 + '" class="left">100%</button>\n </div>\n <div class="w-e-button-container">\n <button id="' + delBtn + '" class="gray left">\u5220\u9664\u56FE\u7247</button>\n </dv>\n </div>',
events: [{
selector: '#' + width30,
type: 'click',
fn: function fn() {
var $img = editor._selectedImg;
if ($img) {
$img.css('max-width', '30%');
}
// 返回 true,表示该事件执行完之后,panel 要关闭。否则 panel 不会关闭
return true;
}
}, {
selector: '#' + width50,
type: 'click',
fn: function fn() {
var $img = editor._selectedImg;
if ($img) {
$img.css('max-width', '50%');
}
// 返回 true,表示该事件执行完之后,panel 要关闭。否则 panel 不会关闭
return true;
}
}, {
selector: '#' + width100,
type: 'click',
fn: function fn() {
var $img = editor._selectedImg;
if ($img) {
$img.css('max-width', '100%');
}
// 返回 true,表示该事件执行完之后,panel 要关闭。否则 panel 不会关闭
return true;
}
}, {
selector: '#' + delBtn,
type: 'click',
fn: function fn() {
var $img = editor._selectedImg;
if ($img) {
$img.remove();
}
// 返回 true,表示该事件执行完之后,panel 要关闭。否则 panel 不会关闭
return true;
}
}]
}];
// 创建 panel 并显示
var panel = new Panel(this, {
width: 300,
tabs: tabsConfig
});
panel.show();
// 记录属性
this.panel = panel;
},
_createInsertPanel: function _createInsertPanel() {
var editor = this.editor;
var uploadImg = editor.uploadImg;
var config = editor.config;
// id
var upTriggerId = getRandom('up-trigger');
var upFileId = getRandom('up-file');
var linkUrlId = getRandom('link-url');
var linkBtnId = getRandom('link-btn');
// tabs 的配置
var tabsConfig = [{
title: '上传图片',
tpl: '<div class="w-e-up-img-container">\n <div id="' + upTriggerId + '" class="w-e-up-btn">\n <i class="w-e-icon-upload2"></i>\n </div>\n <div style="display:none;">\n <input id="' + upFileId + '" type="file" multiple="multiple" accept="image/jpg,image/jpeg,image/png,image/gif,image/bmp"/>\n </div>\n </div>',
events: [{
// 触发选择图片
selector: '#' + upTriggerId,
type: 'click',
fn: function fn() {
var $file = $('#' + upFileId);
var fileElem = $file[0];
if (fileElem) {
fileElem.click();
} else {
// 返回 true 可关闭 panel
return true;
}
}
}, {
// 选择图片完毕
selector: '#' + upFileId,
type: 'change',
fn: function fn() {
var $file = $('#' + upFileId);
var fileElem = $file[0];
if (!fileElem) {
// 返回 true 可关闭 panel
return true;
}
// 获取选中的 file 对象列表
var fileList = fileElem.files;
if (fileList.length) {
uploadImg.uploadImg(fileList);
}
// 返回 true 可关闭 panel
return true;
}
}]
}, // first tab end
{
title: '网络图片',
tpl: '<div>\n <input id="' + linkUrlId + '" type="text" class="block" placeholder="\u56FE\u7247\u94FE\u63A5"/></td>\n <div class="w-e-button-container">\n <button id="' + linkBtnId + '" class="right">\u63D2\u5165</button>\n </div>\n </div>',
events: [{
selector: '#' + linkBtnId,
type: 'click',
fn: function fn() {
var $linkUrl = $('#' + linkUrlId);
var url = $linkUrl.val().trim();
if (url) {
uploadImg.insertLinkImg(url);
}
// 返回 true 表示函数执行结束之后关闭 panel
return true;
}
}]
} // second tab end
]; // tabs end
// 判断 tabs 的显示
var tabsConfigResult = [];
if ((config.uploadImgShowBase64 || config.uploadImgServer || config.customUploadImg) && window.FileReader) {
// 显示“上传图片”
tabsConfigResult.push(tabsConfig[0]);
}
if (config.showLinkImg) {
// 显示“网络图片”
tabsConfigResult.push(tabsConfig[1]);
}
// 创建 panel 并显示
var panel = new Panel(this, {
width: 300,
tabs: tabsConfigResult
});
panel.show();
// 记录属性
this.panel = panel;
},
// 试图改变 active 状态
tryChangeActive: function tryChangeActive(e) {
var editor = this.editor;
var $elem = this.$elem;
if (editor._selectedImg) {
this._active = true;
$elem.addClass('w-e-active');
} else {
this._active = false;
$elem.removeClass('w-e-active');
}
}
};
/*
所有菜单的汇总
*/
// 存储菜单的构造函数
var MenuConstructors = {};
MenuConstructors.bold = Bold;
MenuConstructors.head = Head;
MenuConstructors.fontSize = FontSize;
MenuConstructors.fontName = FontName;
MenuConstructors.link = Link;
MenuConstructors.italic = Italic;
MenuConstructors.redo = Redo;
MenuConstructors.strikeThrough = StrikeThrough;
MenuConstructors.underline = Underline;
MenuConstructors.undo = Undo;
MenuConstructors.list = List;
MenuConstructors.justify = Justify;
MenuConstructors.foreColor = ForeColor;
MenuConstructors.backColor = BackColor;
MenuConstructors.quote = Quote;
MenuConstructors.code = Code;
MenuConstructors.emoticon = Emoticon;
MenuConstructors.table = Table;
MenuConstructors.video = Video;
MenuConstructors.image = Image;
/*
菜单集合
*/
// 构造函数
function Menus(editor) {
this.editor = editor;
this.menus = {};
}
// 修改原型
Menus.prototype = {
constructor: Menus,
// 初始化菜单
init: function init() {
var _this = this;
var editor = this.editor;
var config = editor.config || {};
var configMenus = config.menus || []; // 获取配置中的菜单
// 根据配置信息,创建菜单
configMenus.forEach(function (menuKey) {
var MenuConstructor = MenuConstructors[menuKey];
if (MenuConstructor && typeof MenuConstructor === 'function') {
// 创建单个菜单
_this.menus[menuKey] = new MenuConstructor(editor);
}
});
// 添加到菜单栏
this._addToToolbar();
// 绑定事件
this._bindEvent();
},
// 添加到菜单栏
_addToToolbar: function _addToToolbar() {
var editor = this.editor;
var $toolbarElem = editor.$toolbarElem;
var menus = this.menus;
var config = editor.config;
// config.zIndex 是配置的编辑区域的 z-index,菜单的 z-index 得在其基础上 +1
var zIndex = config.zIndex + 1;
objForEach(menus, function (key, menu) {
var $elem = menu.$elem;
if ($elem) {
// 设置 z-index
$elem.css('z-index', zIndex);
$toolbarElem.append($elem);
}
});
},
// 绑定菜单 click mouseenter 事件
_bindEvent: function _bindEvent() {
var menus = this.menus;
var editor = this.editor;
objForEach(menus, function (key, menu) {
var type = menu.type;
if (!type) {
return;
}
var $elem = menu.$elem;
var droplist = menu.droplist;
var panel = menu.panel;
// 点击类型,例如 bold
if (type === 'click' && menu.onClick) {
$elem.on('click', function (e) {
if (editor.selection.getRange() == null) {
return;
}
menu.onClick(e);
});
}
// 下拉框,例如 head
if (type === 'droplist' && droplist) {
$elem.on('mouseenter', function (e) {
if (editor.selection.getRange() == null) {
return;
}
// 显示
droplist.showTimeoutId = setTimeout(function () {
droplist.show();
}, 200);
}).on('mouseleave', function (e) {
// 隐藏
droplist.hideTimeoutId = setTimeout(function () {
droplist.hide();
}, 0);
});
}
// 弹框类型,例如 link
if (type === 'panel' && menu.onClick) {
$elem.on('click', function (e) {
e.stopPropagation();
if (editor.selection.getRange() == null) {
return;
}
// 在自定义事件中显示 panel
menu.onClick(e);
});
}
});
},
// 尝试修改菜单状态
changeActive: function changeActive() {
var menus = this.menus;
objForEach(menus, function (key, menu) {
if (menu.tryChangeActive) {
setTimeout(function () {
menu.tryChangeActive();
}, 100);
}
});
}
};
/*
粘贴信息的处理
*/
// 获取粘贴的纯文本
function getPasteText(e) {
var clipboardData = e.clipboardData || e.originalEvent && e.originalEvent.clipboardData;
var pasteText = void 0;
if (clipboardData == null) {
pasteText = window.clipboardData && window.clipboardData.getData('text');
} else {
pasteText = clipboardData.getData('text/plain');
}
return replaceHtmlSymbol(pasteText);
}
// 获取粘贴的html
function getPasteHtml(e, filterStyle, ignoreImg) {
var clipboardData = e.clipboardData || e.originalEvent && e.originalEvent.clipboardData;
var pasteText = void 0,
pasteHtml = void 0;
if (clipboardData == null) {
pasteText = window.clipboardData && window.clipboardData.getData('text');
} else {
pasteText = clipboardData.getData('text/plain');
pasteHtml = clipboardData.getData('text/html');
}
if (!pasteHtml && pasteText) {
pasteHtml = '<p>' + replaceHtmlSymbol(pasteText) + '</p>';
}
if (!pasteHtml) {
return;
}
// 过滤word中状态过来的无用字符
var docSplitHtml = pasteHtml.split('</html>');
if (docSplitHtml.length === 2) {
pasteHtml = docSplitHtml[0];
}
// 过滤无用标签
pasteHtml = pasteHtml.replace(/<(meta|script|link).+?>/igm, '');
// 去掉注释
pasteHtml = pasteHtml.replace(/<!--.*?-->/mg, '');
// 过滤 data-xxx 属性
pasteHtml = pasteHtml.replace(/\s?data-.+?=('|").+?('|")/igm, '');
if (ignoreImg) {
// 忽略图片
pasteHtml = pasteHtml.replace(/<img.+?>/igm, '');
}
if (filterStyle) {
// 过滤样式
pasteHtml = pasteHtml.replace(/\s?(class|style)=('|").*?('|")/igm, '');
} else {
// 保留样式
pasteHtml = pasteHtml.replace(/\s?class=('|").*?('|")/igm, '');
}
return pasteHtml;
}
// 获取粘贴的图片文件
function getPasteImgs(e) {
var result = [];
var txt = getPasteText(e);
if (txt) {
// 有文字,就忽略图片
return result;
}
var clipboardData = e.clipboardData || e.originalEvent && e.originalEvent.clipboardData || {};
var items = clipboardData.items;
if (!items) {
return result;
}
objForEach(items, function (key, value) {
var type = value.type;
if (/image/i.test(type)) {
result.push(value.getAsFile());
}
});
return result;
}
/*
编辑区域
*/
// 获取一个 elem.childNodes 的 JSON 数据
function getChildrenJSON($elem) {
var result = [];
var $children = $elem.childNodes() || []; // 注意 childNodes() 可以获取文本节点
$children.forEach(function (curElem) {
var elemResult = void 0;
var nodeType = curElem.nodeType;
// 文本节点
if (nodeType === 3) {
elemResult = curElem.textContent;
elemResult = replaceHtmlSymbol(elemResult);
}
// 普通 DOM 节点
if (nodeType === 1) {
elemResult = {};
// tag
elemResult.tag = curElem.nodeName.toLowerCase();
// attr
var attrData = [];
var attrList = curElem.attributes || {};
var attrListLength = attrList.length || 0;
for (var i = 0; i < attrListLength; i++) {
var attr = attrList[i];
attrData.push({
name: attr.name,
value: attr.value
});
}
elemResult.attrs = attrData;
// children(递归)
elemResult.children = getChildrenJSON($(curElem));
}
result.push(elemResult);
});
return result;
}
// 构造函数
function Text(editor) {
this.editor = editor;
}
// 修改原型
Text.prototype = {
constructor: Text,
// 初始化
init: function init() {
// 绑定事件
this._bindEvent();
},
// 清空内容
clear: function clear() {
this.html('<p><br></p>');
},
// 获取 设置 html
html: function html(val) {
var editor = this.editor;
var $textElem = editor.$textElem;
var html = void 0;
if (val == null) {
html = $textElem.html();
// 未选中任何内容的时候点击“加粗”或者“斜体”等按钮,就得需要一个空的占位符 ​ ,这里替换掉
html = html.replace(/\u200b/gm, '');
return html;
} else {
$textElem.html(val);
// 初始化选取,将光标定位到内容尾部
editor.initSelection();
}
},
// 获取 JSON
getJSON: function getJSON() {
var editor = this.editor;
var $textElem = editor.$textElem;
return getChildrenJSON($textElem);
},
// 获取 设置 text
text: function text(val) {
var editor = this.editor;
var $textElem = editor.$textElem;
var text = void 0;
if (val == null) {
text = $textElem.text();
// 未选中任何内容的时候点击“加粗”或者“斜体”等按钮,就得需要一个空的占位符 ​ ,这里替换掉
text = text.replace(/\u200b/gm, '');
return text;
} else {
$textElem.text('<p>' + val + '</p>');
// 初始化选取,将光标定位到内容尾部
editor.initSelection();
}
},
// 追加内容
append: function append(html) {
var editor = this.editor;
var $textElem = editor.$textElem;
$textElem.append($(html));
// 初始化选取,将光标定位到内容尾部
editor.initSelection();
},
// 绑定事件
_bindEvent: function _bindEvent() {
// 实时保存选取
this._saveRangeRealTime();
// 按回车建时的特殊处理
this._enterKeyHandle();
// 清空时保留 <p><br></p>
this._clearHandle();
// 粘贴事件(粘贴文字,粘贴图片)
this._pasteHandle();
// tab 特殊处理
this._tabHandle();
// img 点击
this._imgHandle();
// 拖拽事件
this._dragHandle();
},
// 实时保存选取
_saveRangeRealTime: function _saveRangeRealTime() {
var editor = this.editor;
var $textElem = editor.$textElem;
// 保存当前的选区
function saveRange(e) {
// 随时保存选区
editor.selection.saveRange();
// 更新按钮 ative 状态
editor.menus.changeActive();
}
// 按键后保存
$textElem.on('keyup', saveRange);
$textElem.on('mousedown', function (e) {
// mousedown 状态下,鼠标滑动到编辑区域外面,也需要保存选区
$textElem.on('mouseleave', saveRange);
});
$textElem.on('mouseup', function (e) {
saveRange();
// 在编辑器区域之内完成点击,取消鼠标滑动到编辑区外面的事件
$textElem.off('mouseleave', saveRange);
});
},
// 按回车键时的特殊处理
_enterKeyHandle: function _enterKeyHandle() {
var editor = this.editor;
var $textElem = editor.$textElem;
function insertEmptyP($selectionElem) {
var $p = $('<p><br></p>');
$p.insertBefore($selectionElem);
editor.selection.createRangeByElem($p, true);
editor.selection.restoreSelection();
$selectionElem.remove();
}
// 将回车之后生成的非 <p> 的顶级标签,改为 <p>
function pHandle(e) {
var $selectionElem = editor.selection.getSelectionContainerElem();
var $parentElem = $selectionElem.parent();
if ($parentElem.html() === '<code><br></code>') {
// 回车之前光标所在一个 <p><code>.....</code></p> ,忽然回车生成一个空的 <p><code><br></code></p>
// 而且继续回车跳不出去,因此只能特殊处理
insertEmptyP($selectionElem);
return;
}
if (!$parentElem.equal($textElem)) {
// 不是顶级标签
return;
}
var nodeName = $selectionElem.getNodeName();
if (nodeName === 'P') {
// 当前的标签是 P ,不用做处理
return;
}
if ($selectionElem.text()) {
// 有内容,不做处理
return;
}
// 插入 <p> ,并将选取定位到 <p>,删除当前标签
insertEmptyP($selectionElem);
}
$textElem.on('keyup', function (e) {
if (e.keyCode !== 13) {
// 不是回车键
return;
}
// 将回车之后生成的非 <p> 的顶级标签,改为 <p>
pHandle(e);
});
// <pre><code></code></pre> 回车时 特殊处理
function codeHandle(e) {
var $selectionElem = editor.selection.getSelectionContainerElem();
if (!$selectionElem) {
return;
}
var $parentElem = $selectionElem.parent();
var selectionNodeName = $selectionElem.getNodeName();
var parentNodeName = $parentElem.getNodeName();
if (selectionNodeName !== 'CODE' || parentNodeName !== 'PRE') {
// 不符合要求 忽略
return;
}
if (!editor.cmd.queryCommandSupported('insertHTML')) {
// 必须原生支持 insertHTML 命令
return;
}
// 处理:光标定位到代码末尾,联系点击两次回车,即跳出代码块
if (editor._willBreakCode === true) {
// 此时可以跳出代码块
// 插入 <p> ,并将选取定位到 <p>
var $p = $('<p><br></p>');
$p.insertAfter($parentElem);
editor.selection.createRangeByElem($p, true);
editor.selection.restoreSelection();
// 修改状态
editor._willBreakCode = false;
e.preventDefault();
return;
}
var _startOffset = editor.selection.getRange().startOffset;
// 处理:回车时,不能插入 <br> 而是插入 \n ,因为是在 pre 标签里面
editor.cmd.do('insertHTML', '\n');
editor.selection.saveRange();
if (editor.selection.getRange().startOffset === _startOffset) {
// 没起作用,再来一遍
editor.cmd.do('insertHTML', '\n');
}
var codeLength = $selectionElem.html().length;
if (editor.selection.getRange().startOffset + 1 === codeLength) {
// 说明光标在代码最后的位置,执行了回车操作
// 记录下来,以便下次回车时候跳出 code
editor._willBreakCode = true;
}
// 阻止默认行为
e.preventDefault();
}
$textElem.on('keydown', function (e) {
if (e.keyCode !== 13) {
// 不是回车键
// 取消即将跳转代码块的记录
editor._willBreakCode = false;
return;
}
// <pre><code></code></pre> 回车时 特殊处理
codeHandle(e);
});
},
// 清空时保留 <p><br></p>
_clearHandle: function _clearHandle() {
var editor = this.editor;
var $textElem = editor.$textElem;
$textElem.on('keydown', function (e) {
if (e.keyCode !== 8) {
return;
}
var txtHtml = $textElem.html().toLowerCase().trim();
if (txtHtml === '<p><br></p>') {
// 最后剩下一个空行,就不再删除了
e.preventDefault();
return;
}
});
$textElem.on('keyup', function (e) {
if (e.keyCode !== 8) {
return;
}
var $p = void 0;
var txtHtml = $textElem.html().toLowerCase().trim();
// firefox 时用 txtHtml === '<br>' 判断,其他用 !txtHtml 判断
if (!txtHtml || txtHtml === '<br>') {
// 内容空了
$p = $('<p><br/></p>');
$textElem.html(''); // 一定要先清空,否则在 firefox 下有问题
$textElem.append($p);
editor.selection.createRangeByElem($p, false, true);
editor.selection.restoreSelection();
}
});
},
// 粘贴事件(粘贴文字 粘贴图片)
_pasteHandle: function _pasteHandle() {
var editor = this.editor;
var config = editor.config;
var pasteFilterStyle = config.pasteFilterStyle;
var pasteTextHandle = config.pasteTextHandle;
var ignoreImg = config.pasteIgnoreImg;
var $textElem = editor.$textElem;
// 粘贴图片、文本的事件,每次只能执行一个
// 判断该次粘贴事件是否可以执行
var pasteTime = 0;
function canDo() {
var now = Date.now();
var flag = false;
if (now - pasteTime >= 100) {
// 间隔大于 100 ms ,可以执行
flag = true;
}
pasteTime = now;
return flag;
}
function resetTime() {
pasteTime = 0;
}
// 粘贴文字
$textElem.on('paste', function (e) {
if (UA.isIE()) {
return;
} else {
// 阻止默认行为,使用 execCommand 的粘贴命令
e.preventDefault();
}
// 粘贴图片和文本,只能同时使用一个
if (!canDo()) {
return;
}
// 获取粘贴的文字
var pasteHtml = getPasteHtml(e, pasteFilterStyle, ignoreImg);
var pasteText = getPasteText(e);
pasteText = pasteText.replace(/\n/gm, '<br>');
var $selectionElem = editor.selection.getSelectionContainerElem();
if (!$selectionElem) {
return;
}
var nodeName = $selectionElem.getNodeName();
// code 中只能粘贴纯文本
if (nodeName === 'CODE' || nodeName === 'PRE') {
if (pasteTextHandle && isFunction(pasteTextHandle)) {
// 用户自定义过滤处理粘贴内容
pasteText = '' + (pasteTextHandle(pasteText) || '');
}
editor.cmd.do('insertHTML', '<p>' + pasteText + '</p>');
return;
}
// 先放开注释,有问题再追查 ————
// // 表格中忽略,可能会出现异常问题
// if (nodeName === 'TD' || nodeName === 'TH') {
// return
// }
if (!pasteHtml) {
// 没有内容,可继续执行下面的图片粘贴
resetTime();
return;
}
try {
// firefox 中,获取的 pasteHtml 可能是没有 <ul> 包裹的 <li>
// 因此执行 insertHTML 会报错
if (pasteTextHandle && isFunction(pasteTextHandle)) {
// 用户自定义过滤处理粘贴内容
pasteHtml = '' + (pasteTextHandle(pasteHtml) || '');
}
editor.cmd.do('insertHTML', pasteHtml);
} catch (ex) {
// 此时使用 pasteText 来兼容一下
if (pasteTextHandle && isFunction(pasteTextHandle)) {
// 用户自定义过滤处理粘贴内容
pasteText = '' + (pasteTextHandle(pasteText) || '');
}
editor.cmd.do('insertHTML', '<p>' + pasteText + '</p>');
}
});
// 粘贴图片
$textElem.on('paste', function (e) {
if (UA.isIE()) {
return;
} else {
e.preventDefault();
}
// 粘贴图片和文本,只能同时使用一个
if (!canDo()) {
return;
}
// 获取粘贴的图片
var pasteFiles = getPasteImgs(e);
if (!pasteFiles || !pasteFiles.length) {
return;
}
// 获取当前的元素
var $selectionElem = editor.selection.getSelectionContainerElem();
if (!$selectionElem) {
return;
}
var nodeName = $selectionElem.getNodeName();
// code 中粘贴忽略
if (nodeName === 'CODE' || nodeName === 'PRE') {
return;
}
// 上传图片
var uploadImg = editor.uploadImg;
uploadImg.uploadImg(pasteFiles);
});
},
// tab 特殊处理
_tabHandle: function _tabHandle() {
var editor = this.editor;
var $textElem = editor.$textElem;
$textElem.on('keydown', function (e) {
if (e.keyCode !== 9) {
return;
}
if (!editor.cmd.queryCommandSupported('insertHTML')) {
// 必须原生支持 insertHTML 命令
return;
}
var $selectionElem = editor.selection.getSelectionContainerElem();
if (!$selectionElem) {
return;
}
var $parentElem = $selectionElem.parent();
var selectionNodeName = $selectionElem.getNodeName();
var parentNodeName = $parentElem.getNodeName();
if (selectionNodeName === 'CODE' && parentNodeName === 'PRE') {
// <pre><code> 里面
editor.cmd.do('insertHTML', ' ');
} else {
// 普通文字
editor.cmd.do('insertHTML', ' ');
}
e.preventDefault();
});
},
// img 点击
_imgHandle: function _imgHandle() {
var editor = this.editor;
var $textElem = editor.$textElem;
// 为图片增加 selected 样式
$textElem.on('click', 'img', function (e) {
var img = this;
var $img = $(img);
if ($img.attr('data-w-e') === '1') {
// 是表情图片,忽略
return;
}
// 记录当前点击过的图片
editor._selectedImg = $img;
// 修改选区并 restore ,防止用户此时点击退格键,会删除其他内容
editor.selection.createRangeByElem($img);
editor.selection.restoreSelection();
});
// 去掉图片的 selected 样式
$textElem.on('click keyup', function (e) {
if (e.target.matches('img')) {
// 点击的是图片,忽略
return;
}
// 删除记录
editor._selectedImg = null;
});
},
// 拖拽事件
_dragHandle: function _dragHandle() {
var editor = this.editor;
// 禁用 document 拖拽事件
var $document = $(document);
$document.on('dragleave drop dragenter dragover', function (e) {
e.preventDefault();
});
// 添加编辑区域拖拽事件
var $textElem = editor.$textElem;
$textElem.on('drop', function (e) {
e.preventDefault();
var files = e.dataTransfer && e.dataTransfer.files;
if (!files || !files.length) {
return;
}
// 上传图片
var uploadImg = editor.uploadImg;
uploadImg.uploadImg(files);
});
}
};
/*
命令,封装 document.execCommand
*/
// 构造函数
function Command(editor) {
this.editor = editor;
}
// 修改原型
Command.prototype = {
constructor: Command,
// 执行命令
do: function _do(name, value) {
var editor = this.editor;
// 使用 styleWithCSS
if (!editor._useStyleWithCSS) {
document.execCommand('styleWithCSS', null, true);
editor._useStyleWithCSS = true;
}
// 如果无选区,忽略
if (!editor.selection.getRange()) {
return;
}
// 恢复选取
editor.selection.restoreSelection();
// 执行
var _name = '_' + name;
if (this[_name]) {
// 有自定义事件
this[_name](value);
} else {
// 默认 command
this._execCommand(name, value);
}
// 修改菜单状态
editor.menus.changeActive();
// 最后,恢复选取保证光标在原来的位置闪烁
editor.selection.saveRange();
editor.selection.restoreSelection();
// 触发 onchange
editor.change && editor.change();
},
// 自定义 insertHTML 事件
_insertHTML: function _insertHTML(html) {
var editor = this.editor;
var range = editor.selection.getRange();
if (this.queryCommandSupported('insertHTML')) {
// W3C
this._execCommand('insertHTML', html);
} else if (range.insertNode) {
// IE
range.deleteContents();
range.insertNode($(html)[0]);
} else if (range.pasteHTML) {
// IE <= 10
range.pasteHTML(html);
}
},
// 插入 elem
_insertElem: function _insertElem($elem) {
var editor = this.editor;
var range = editor.selection.getRange();
if (range.insertNode) {
range.deleteContents();
range.insertNode($elem[0]);
}
},
// 封装 execCommand
_execCommand: function _execCommand(name, value) {
document.execCommand(name, false, value);
},
// 封装 document.queryCommandValue
queryCommandValue: function queryCommandValue(name) {
return document.queryCommandValue(name);
},
// 封装 document.queryCommandState
queryCommandState: function queryCommandState(name) {
return document.queryCommandState(name);
},
// 封装 document.queryCommandSupported
queryCommandSupported: function queryCommandSupported(name) {
return document.queryCommandSupported(name);
}
};
/*
selection range API
*/
// 构造函数
function API(editor) {
this.editor = editor;
this._currentRange = null;
}
// 修改原型
API.prototype = {
constructor: API,
// 获取 range 对象
getRange: function getRange() {
return this._currentRange;
},
// 保存选区
saveRange: function saveRange(_range) {
if (_range) {
// 保存已有选区
this._currentRange = _range;
return;
}
// 获取当前的选区
var selection = window.getSelection();
if (selection.rangeCount === 0) {
return;
}
var range = selection.getRangeAt(0);
// 判断选区内容是否在编辑内容之内
var $containerElem = this.getSelectionContainerElem(range);
if (!$containerElem) {
return;
}
// 判断选区内容是否在不可编辑区域之内
if ($containerElem.attr('contenteditable') === 'false' || $containerElem.parentUntil('[contenteditable=false]')) {
return;
}
var editor = this.editor;
var $textElem = editor.$textElem;
if ($textElem.isContain($containerElem)) {
// 是编辑内容之内的
this._currentRange = range;
}
},
// 折叠选区
collapseRange: function collapseRange(toStart) {
if (toStart == null) {
// 默认为 false
toStart = false;
}
var range = this._currentRange;
if (range) {
range.collapse(toStart);
}
},
// 选中区域的文字
getSelectionText: function getSelectionText() {
var range = this._currentRange;
if (range) {
return this._currentRange.toString();
} else {
return '';
}
},
// 选区的 $Elem
getSelectionContainerElem: function getSelectionContainerElem(range) {
range = range || this._currentRange;
var elem = void 0;
if (range) {
elem = range.commonAncestorContainer;
return $(elem.nodeType === 1 ? elem : elem.parentNode);
}
},
getSelectionStartElem: function getSelectionStartElem(range) {
range = range || this._currentRange;
var elem = void 0;
if (range) {
elem = range.startContainer;
return $(elem.nodeType === 1 ? elem : elem.parentNode);
}
},
getSelectionEndElem: function getSelectionEndElem(range) {
range = range || this._currentRange;
var elem = void 0;
if (range) {
elem = range.endContainer;
return $(elem.nodeType === 1 ? elem : elem.parentNode);
}
},
// 选区是否为空
isSelectionEmpty: function isSelectionEmpty() {
var range = this._currentRange;
if (range && range.startContainer) {
if (range.startContainer === range.endContainer) {
if (range.startOffset === range.endOffset) {
return true;
}
}
}
return false;
},
// 恢复选区
restoreSelection: function restoreSelection() {
var selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(this._currentRange);
},
// 创建一个空白(即 ​ 字符)选区
createEmptyRange: function createEmptyRange() {
var editor = this.editor;
var range = this.getRange();
var $elem = void 0;
if (!range) {
// 当前无 range
return;
}
if (!this.isSelectionEmpty()) {
// 当前选区必须没有内容才可以
return;
}
try {
// 目前只支持 webkit 内核
if (UA.isWebkit()) {
// 插入 ​
editor.cmd.do('insertHTML', '​');
// 修改 offset 位置
range.setEnd(range.endContainer, range.endOffset + 1);
// 存储
this.saveRange(range);
} else {
$elem = $('<strong>​</strong>');
editor.cmd.do('insertElem', $elem);
this.createRangeByElem($elem, true);
}
} catch (ex) {
// 部分情况下会报错,兼容一下
}
},
// 根据 $Elem 设置选区
createRangeByElem: function createRangeByElem($elem, toStart, isContent) {
// $elem - 经过封装的 elem
// toStart - true 开始位置,false 结束位置
// isContent - 是否选中Elem的内容
if (!$elem.length) {
return;
}
var elem = $elem[0];
var range = document.createRange();
if (isContent) {
range.selectNodeContents(elem);
} else {
range.selectNode(elem);
}
if (typeof toStart === 'boolean') {
range.collapse(toStart);
}
// 存储 range
this.saveRange(range);
}
};
/*
上传进度条
*/
function Progress(editor) {
this.editor = editor;
this._time = 0;
this._isShow = false;
this._isRender = false;
this._timeoutId = 0;
this.$textContainer = editor.$textContainerElem;
this.$bar = $('<div class="w-e-progress"></div>');
}
Progress.prototype = {
constructor: Progress,
show: function show(progress) {
var _this = this;
// 状态处理
if (this._isShow) {
return;
}
this._isShow = true;
// 渲染
var $bar = this.$bar;
if (!this._isRender) {
var $textContainer = this.$textContainer;
$textContainer.append($bar);
} else {
this._isRender = true;
}
// 改变进度(节流,100ms 渲染一次)
if (Date.now() - this._time > 100) {
if (progress <= 1) {
$bar.css('width', progress * 100 + '%');
this._time = Date.now();
}
}
// 隐藏
var timeoutId = this._timeoutId;
if (timeoutId) {
clearTimeout(timeoutId);
}
timeoutId = setTimeout(function () {
_this._hide();
}, 500);
},
_hide: function _hide() {
var $bar = this.$bar;
$bar.remove();
// 修改状态
this._time = 0;
this._isShow = false;
this._isRender = false;
}
};
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
/*
上传图片
*/
// 构造函数
function UploadImg(editor) {
this.editor = editor;
}
// 原型
UploadImg.prototype = {
constructor: UploadImg,
// 根据 debug 弹出不同的信息
_alert: function _alert(alertInfo, debugInfo) {
var editor = this.editor;
var debug = editor.config.debug;
var customAlert = editor.config.customAlert;
if (debug) {
throw new Error('wangEditor: ' + (debugInfo || alertInfo));
} else {
if (customAlert && typeof customAlert === 'function') {
customAlert(alertInfo);
} else {
alert(alertInfo);
}
}
},
// 根据链接插入图片
insertLinkImg: function insertLinkImg(link) {
var _this2 = this;
if (!link) {
return;
}
var editor = this.editor;
var config = editor.config;
// 校验格式
var linkImgCheck = config.linkImgCheck;
var checkResult = void 0;
if (linkImgCheck && typeof linkImgCheck === 'function') {
checkResult = linkImgCheck(link);
if (typeof checkResult === 'string') {
// 校验失败,提示信息
alert(checkResult);
return;
}
}
editor.cmd.do('insertHTML', '<img src="' + link + '" style="max-width:100%;"/>');
// 验证图片 url 是否有效,无效的话给出提示
var img = document.createElement('img');
img.onload = function () {
var callback = config.linkImgCallback;
if (callback && typeof callback === 'function') {
callback(link);
}
img = null;
};
img.onerror = function () {
img = null;
// 无法成功下载图片
_this2._alert('插入图片错误', 'wangEditor: \u63D2\u5165\u56FE\u7247\u51FA\u9519\uFF0C\u56FE\u7247\u94FE\u63A5\u662F "' + link + '"\uFF0C\u4E0B\u8F7D\u8BE5\u94FE\u63A5\u5931\u8D25');
return;
};
img.onabort = function () {
img = null;
};
img.src = link;
},
// 上传图片
uploadImg: function uploadImg(files) {
var _this3 = this;
if (!files || !files.length) {
return;
}
// ------------------------------ 获取配置信息 ------------------------------
var editor = this.editor;
var config = editor.config;
var uploadImgServer = config.uploadImgServer;
var uploadImgShowBase64 = config.uploadImgShowBase64;
var maxSize = config.uploadImgMaxSize;
var maxSizeM = maxSize / 1024 / 1024;
var maxLength = config.uploadImgMaxLength || 10000;
var uploadFileName = config.uploadFileName || '';
var uploadImgParams = config.uploadImgParams || {};
var uploadImgParamsWithUrl = config.uploadImgParamsWithUrl;
var uploadImgHeaders = config.uploadImgHeaders || {};
var hooks = config.uploadImgHooks || {};
var timeout = config.uploadImgTimeout || 3000;
var withCredentials = config.withCredentials;
if (withCredentials == null) {
withCredentials = false;
}
var customUploadImg = config.customUploadImg;
if (!customUploadImg) {
// 没有 customUploadImg 的情况下,需要如下两个配置才能继续进行图片上传
if (!uploadImgServer && !uploadImgShowBase64) {
return;
}
}
// ------------------------------ 验证文件信息 ------------------------------
var resultFiles = [];
var errInfo = [];
arrForEach(files, function (file) {
var name = file.name;
var size = file.size;
// chrome 低版本 name === undefined
if (!name || !size) {
return;
}
if (/\.(jpg|jpeg|png|bmp|gif|webp)$/i.test(name) === false) {
// 后缀名不合法,不是图片
errInfo.push('\u3010' + name + '\u3011\u4E0D\u662F\u56FE\u7247');
return;
}
if (maxSize < size) {
// 上传图片过大
errInfo.push('\u3010' + name + '\u3011\u5927\u4E8E ' + maxSizeM + 'M');
return;
}
// 验证通过的加入结果列表
resultFiles.push(file);
});
// 抛出验证信息
if (errInfo.length) {
this._alert('图片验证未通过: \n' + errInfo.join('\n'));
return;
}
if (resultFiles.length > maxLength) {
this._alert('一次最多上传' + maxLength + '张图片');
return;
}
// ------------------------------ 自定义上传 ------------------------------
if (customUploadImg && typeof customUploadImg === 'function') {
customUploadImg(resultFiles, this.insertLinkImg.bind(this));
// 阻止以下代码执行
return;
}
// 添加图片数据
var formdata = new FormData();
arrForEach(resultFiles, function (file) {
var name = uploadFileName || file.name;
formdata.append(name, file);
});
// ------------------------------ 上传图片 ------------------------------
if (uploadImgServer && typeof uploadImgServer === 'string') {
// 添加参数
var uploadImgServerArr = uploadImgServer.split('#');
uploadImgServer = uploadImgServerArr[0];
var uploadImgServerHash = uploadImgServerArr[1] || '';
objForEach(uploadImgParams, function (key, val) {
// 因使用者反应,自定义参数不能默认 encode ,由 v3.1.1 版本开始注释掉
// val = encodeURIComponent(val)
// 第一,将参数拼接到 url 中
if (uploadImgParamsWithUrl) {
if (uploadImgServer.indexOf('?') > 0) {
uploadImgServer += '&';
} else {
uploadImgServer += '?';
}
uploadImgServer = uploadImgServer + key + '=' + val;
}
// 第二,将参数添加到 formdata 中
formdata.append(key, val);
});
if (uploadImgServerHash) {
uploadImgServer += '#' + uploadImgServerHash;
}
// 定义 xhr
var xhr = new XMLHttpRequest();
xhr.open('POST', uploadImgServer);
// 设置超时
xhr.timeout = timeout;
xhr.ontimeout = function () {
// hook - timeout
if (hooks.timeout && typeof hooks.timeout === 'function') {
hooks.timeout(xhr, editor);
}
_this3._alert('上传图片超时');
};
// 监控 progress
if (xhr.upload) {
xhr.upload.onprogress = function (e) {
var percent = void 0;
// 进度条
var progressBar = new Progress(editor);
if (e.lengthComputable) {
percent = e.loaded / e.total;
progressBar.show(percent);
}
};
}
// 返回数据
xhr.onreadystatechange = function () {
var result = void 0;
if (xhr.readyState === 4) {
if (xhr.status < 200 || xhr.status >= 300) {
// hook - error
if (hooks.error && typeof hooks.error === 'function') {
hooks.error(xhr, editor);
}
// xhr 返回状态错误
_this3._alert('上传图片发生错误', '\u4E0A\u4F20\u56FE\u7247\u53D1\u751F\u9519\u8BEF\uFF0C\u670D\u52A1\u5668\u8FD4\u56DE\u72B6\u6001\u662F ' + xhr.status);
return;
}
result = xhr.responseText;
if ((typeof result === 'undefined' ? 'undefined' : _typeof(result)) !== 'object') {
try {
result = JSON.parse(result);
} catch (ex) {
// hook - fail
if (hooks.fail && typeof hooks.fail === 'function') {
hooks.fail(xhr, editor, result);
}
_this3._alert('上传图片失败', '上传图片返回结果错误,返回结果是: ' + result);
return;
}
}
if (!hooks.customInsert && result.errno != '0') {
// hook - fail
if (hooks.fail && typeof hooks.fail === 'function') {
hooks.fail(xhr, editor, result);
}
// 数据错误
_this3._alert('上传图片失败', '上传图片返回结果错误,返回结果 errno=' + result.errno);
} else {
if (hooks.customInsert && typeof hooks.customInsert === 'function') {
// 使用者自定义插入方法
hooks.customInsert(_this3.insertLinkImg.bind(_this3), result, editor);
} else {
// 将图片插入编辑器
var data = result.data || [];
data.forEach(function (link) {
_this3.insertLinkImg(link);
});
}
// hook - success
if (hooks.success && typeof hooks.success === 'function') {
hooks.success(xhr, editor, result);
}
}
}
};
// hook - before
if (hooks.before && typeof hooks.before === 'function') {
var beforeResult = hooks.before(xhr, editor, resultFiles);
if (beforeResult && (typeof beforeResult === 'undefined' ? 'undefined' : _typeof(beforeResult)) === 'object') {
if (beforeResult.prevent) {
// 如果返回的结果是 {prevent: true, msg: 'xxxx'} 则表示用户放弃上传
this._alert(beforeResult.msg);
return;
}
}
}
// 自定义 headers
objForEach(uploadImgHeaders, function (key, val) {
xhr.setRequestHeader(key, val);
});
// 跨域传 cookie
xhr.withCredentials = withCredentials;
// 发送请求
xhr.send(formdata);
// 注意,要 return 。不去操作接下来的 base64 显示方式
return;
}
// ------------------------------ 显示 base64 格式 ------------------------------
if (uploadImgShowBase64) {
arrForEach(files, function (file) {
var _this = _this3;
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function () {
_this.insertLinkImg(this.result);
};
});
}
}
};
/*
编辑器构造函数
*/
// id,累加
var editorId = 1;
// 构造函数
function Editor(toolbarSelector, textSelector) {
if (toolbarSelector == null) {
// 没有传入任何参数,报错
throw new Error('错误:初始化编辑器时候未传入任何参数,请查阅文档');
}
// id,用以区分单个页面不同的编辑器对象
this.id = 'wangEditor-' + editorId++;
this.toolbarSelector = toolbarSelector;
this.textSelector = textSelector;
// 自定义配置
this.customConfig = {};
}
// 修改原型
Editor.prototype = {
constructor: Editor,
// 初始化配置
_initConfig: function _initConfig() {
// _config 是默认配置,this.customConfig 是用户自定义配置,将它们 merge 之后再赋值
var target = {};
this.config = Object.assign(target, config, this.customConfig);
// 将语言配置,生成正则表达式
var langConfig = this.config.lang || {};
var langArgs = [];
objForEach(langConfig, function (key, val) {
// key 即需要生成正则表达式的规则,如“插入链接”
// val 即需要被替换成的语言,如“insert link”
langArgs.push({
reg: new RegExp(key, 'img'),
val: val
});
});
this.config.langArgs = langArgs;
},
// 初始化 DOM
_initDom: function _initDom() {
var _this = this;
var toolbarSelector = this.toolbarSelector;
var $toolbarSelector = $(toolbarSelector);
var textSelector = this.textSelector;
var config$$1 = this.config;
var zIndex = config$$1.zIndex;
// 定义变量
var $toolbarElem = void 0,
$textContainerElem = void 0,
$textElem = void 0,
$children = void 0;
if (textSelector == null) {
// 只传入一个参数,即是容器的选择器或元素,toolbar 和 text 的元素自行创建
$toolbarElem = $('<div></div>');
$textContainerElem = $('<div></div>');
// 将编辑器区域原有的内容,暂存起来
$children = $toolbarSelector.children();
// 添加到 DOM 结构中
$toolbarSelector.append($toolbarElem).append($textContainerElem);
// 自行创建的,需要配置默认的样式
$toolbarElem.css('background-color', '#f1f1f1').css('border', '1px solid #ccc');
$textContainerElem.css('border', '1px solid #ccc').css('border-top', 'none').css('height', '300px');
} else {
// toolbar 和 text 的选择器都有值,记录属性
$toolbarElem = $toolbarSelector;
$textContainerElem = $(textSelector);
// 将编辑器区域原有的内容,暂存起来
$children = $textContainerElem.children();
}
// 编辑区域
$textElem = $('<div></div>');
$textElem.attr('contenteditable', 'true').css('width', '100%').css('height', '100%');
// 初始化编辑区域内容
if ($children && $children.length) {
$textElem.append($children);
} else {
$textElem.append($('<p><br></p>'));
}
// 编辑区域加入DOM
$textContainerElem.append($textElem);
// 设置通用的 class
$toolbarElem.addClass('w-e-toolbar');
$textContainerElem.addClass('w-e-text-container');
$textContainerElem.css('z-index', zIndex);
$textElem.addClass('w-e-text');
// 添加 ID
var toolbarElemId = getRandom('toolbar-elem');
$toolbarElem.attr('id', toolbarElemId);
var textElemId = getRandom('text-elem');
$textElem.attr('id', textElemId);
// 记录属性
this.$toolbarElem = $toolbarElem;
this.$textContainerElem = $textContainerElem;
this.$textElem = $textElem;
this.toolbarElemId = toolbarElemId;
this.textElemId = textElemId;
// 记录输入法的开始和结束
var compositionEnd = true;
$textContainerElem.on('compositionstart', function () {
// 输入法开始输入
compositionEnd = false;
});
$textContainerElem.on('compositionend', function () {
// 输入法结束输入
compositionEnd = true;
});
// 绑定 onchange
$textContainerElem.on('click keyup', function () {
// 输入法结束才出发 onchange
compositionEnd && _this.change && _this.change();
});
$toolbarElem.on('click', function () {
this.change && this.change();
});
//绑定 onfocus 与 onblur 事件
if (config$$1.onfocus || config$$1.onblur) {
// 当前编辑器是否是焦点状态
this.isFocus = false;
$(document).on('click', function (e) {
//判断当前点击元素是否在编辑器内
var isChild = $textElem.isContain($(e.target));
//判断当前点击元素是否为工具栏
var isToolbar = $toolbarElem.isContain($(e.target));
var isMenu = $toolbarElem[0] == e.target ? true : false;
if (!isChild) {
//若为选择工具栏中的功能,则不视为成blur操作
if (isToolbar && !isMenu) {
return;
}
if (_this.isFocus) {
_this.onblur && _this.onblur();
}
_this.isFocus = false;
} else {
if (!_this.isFocus) {
_this.onfocus && _this.onfocus();
}
_this.isFocus = true;
}
});
}
},
// 封装 command
_initCommand: function _initCommand() {
this.cmd = new Command(this);
},
// 封装 selection range API
_initSelectionAPI: function _initSelectionAPI() {
this.selection = new API(this);
},
// 添加图片上传
_initUploadImg: function _initUploadImg() {
this.uploadImg = new UploadImg(this);
},
// 初始化菜单
_initMenus: function _initMenus() {
this.menus = new Menus(this);
this.menus.init();
},
// 添加 text 区域
_initText: function _initText() {
this.txt = new Text(this);
this.txt.init();
},
// 初始化选区,将光标定位到内容尾部
initSelection: function initSelection(newLine) {
var $textElem = this.$textElem;
var $children = $textElem.children();
if (!$children.length) {
// 如果编辑器区域无内容,添加一个空行,重新设置选区
$textElem.append($('<p><br></p>'));
this.initSelection();
return;
}
var $last = $children.last();
if (newLine) {
// 新增一个空行
var html = $last.html().toLowerCase();
var nodeName = $last.getNodeName();
if (html !== '<br>' && html !== '<br\/>' || nodeName !== 'P') {
// 最后一个元素不是 <p><br></p>,添加一个空行,重新设置选区
$textElem.append($('<p><br></p>'));
this.initSelection();
return;
}
}
this.selection.createRangeByElem($last, false, true);
this.selection.restoreSelection();
},
// 绑定事件
_bindEvent: function _bindEvent() {
// -------- 绑定 onchange 事件 --------
var onChangeTimeoutId = 0;
var beforeChangeHtml = this.txt.html();
var config$$1 = this.config;
// onchange 触发延迟时间
var onchangeTimeout = config$$1.onchangeTimeout;
onchangeTimeout = parseInt(onchangeTimeout, 10);
if (!onchangeTimeout || onchangeTimeout <= 0) {
onchangeTimeout = 200;
}
var onchange = config$$1.onchange;
if (onchange && typeof onchange === 'function') {
// 触发 change 的有三个场景:
// 1. $textContainerElem.on('click keyup')
// 2. $toolbarElem.on('click')
// 3. editor.cmd.do()
this.change = function () {
// 判断是否有变化
var currentHtml = this.txt.html();
if (currentHtml.length === beforeChangeHtml.length) {
// 需要比较每一个字符
if (currentHtml === beforeChangeHtml) {
return;
}
}
// 执行,使用节流
if (onChangeTimeoutId) {
clearTimeout(onChangeTimeoutId);
}
onChangeTimeoutId = setTimeout(function () {
// 触发配置的 onchange 函数
onchange(currentHtml);
beforeChangeHtml = currentHtml;
}, onchangeTimeout);
};
}
// -------- 绑定 onblur 事件 --------
var onblur = config$$1.onblur;
if (onblur && typeof onblur === 'function') {
this.onblur = function () {
var currentHtml = this.txt.html();
onblur(currentHtml);
};
}
// -------- 绑定 onfocus 事件 --------
var onfocus = config$$1.onfocus;
if (onfocus && typeof onfocus === 'function') {
this.onfocus = function () {
onfocus();
};
}
},
// 创建编辑器
create: function create() {
// 初始化配置信息
this._initConfig();
// 初始化 DOM
this._initDom();
// 封装 command API
this._initCommand();
// 封装 selection range API
this._initSelectionAPI();
// 添加 text
this._initText();
// 初始化菜单
this._initMenus();
// 添加 图片上传
this._initUploadImg();
// 初始化选区,将光标定位到内容尾部
this.initSelection(true);
// 绑定事件
this._bindEvent();
},
// 解绑所有事件(暂时不对外开放)
_offAllEvent: function _offAllEvent() {
$.offAll();
}
};
// 检验是否浏览器环境
try {
document;
} catch (ex) {
throw new Error('请在浏览器环境下运行');
}
// polyfill
polyfill();
// 这里的 `inlinecss` 将被替换成 css 代码的内容,详情可去 ./gulpfile.js 中搜索 `inlinecss` 关键字
var inlinecss = '.w-e-toolbar,.w-e-text-container,.w-e-menu-panel { padding: 0; margin: 0; box-sizing: border-box;}.w-e-toolbar *,.w-e-text-container *,.w-e-menu-panel * { padding: 0; margin: 0; box-sizing: border-box;}.w-e-clear-fix:after { content: ""; display: table; clear: both;}.w-e-toolbar .w-e-droplist { position: absolute; left: 0; top: 0; background-color: #fff; border: 1px solid #f1f1f1; border-right-color: #ccc; border-bottom-color: #ccc;}.w-e-toolbar .w-e-droplist .w-e-dp-title { text-align: center; color: #999; line-height: 2; border-bottom: 1px solid #f1f1f1; font-size: 13px;}.w-e-toolbar .w-e-droplist ul.w-e-list { list-style: none; line-height: 1;}.w-e-toolbar .w-e-droplist ul.w-e-list li.w-e-item { color: #333; padding: 5px 0;}.w-e-toolbar .w-e-droplist ul.w-e-list li.w-e-item:hover { background-color: #f1f1f1;}.w-e-toolbar .w-e-droplist ul.w-e-block { list-style: none; text-align: left; padding: 5px;}.w-e-toolbar .w-e-droplist ul.w-e-block li.w-e-item { display: inline-block; *display: inline; *zoom: 1; padding: 3px 5px;}.w-e-toolbar .w-e-droplist ul.w-e-block li.w-e-item:hover { background-color: #f1f1f1;}@font-face { font-family: \'w-e-icon\'; src: url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAABhQAAsAAAAAGAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABPUy8yAAABCAAAAGAAAABgDxIPBGNtYXAAAAFoAAABBAAAAQQrSf4BZ2FzcAAAAmwAAAAIAAAACAAAABBnbHlmAAACdAAAEvAAABLwfpUWUWhlYWQAABVkAAAANgAAADYQp00kaGhlYQAAFZwAAAAkAAAAJAfEA+FobXR4AAAVwAAAAIQAAACEeAcD7GxvY2EAABZEAAAARAAAAERBSEX+bWF4cAAAFogAAAAgAAAAIAAsALZuYW1lAAAWqAAAAYYAAAGGmUoJ+3Bvc3QAABgwAAAAIAAAACAAAwAAAAMD3gGQAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAQAAA8fwDwP/AAEADwABAAAAAAQAAAAAAAAAAAAAAIAAAAAAAAwAAAAMAAAAcAAEAAwAAABwAAwABAAAAHAAEAOgAAAA2ACAABAAWAAEAIOkG6Q3pEulH6Wbpd+m56bvpxunL6d/qDepc6l/qZepo6nHqefAN8BTxIPHc8fz//f//AAAAAAAg6QbpDekS6UfpZel36bnpu+nG6cvp3+oN6lzqX+pi6mjqcep38A3wFPEg8dzx/P/9//8AAf/jFv4W+Bb0FsAWoxaTFlIWURZHFkMWMBYDFbUVsxWxFa8VpxWiEA8QCQ7+DkMOJAADAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAB//8ADwABAAAAAAAAAAAAAgAANzkBAAAAAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAAAAAAAAAAIAADc5AQAAAAACAAD/wAQAA8AABAATAAABNwEnAQMuAScTNwEjAQMlATUBBwGAgAHAQP5Anxc7MmOAAYDA/oDAAoABgP6ATgFAQAHAQP5A/p0yOxcBEU4BgP6A/YDAAYDA/oCAAAQAAAAABAADgAAQACEALQA0AAABOAExETgBMSE4ATEROAExITUhIgYVERQWMyEyNjURNCYjBxQGIyImNTQ2MzIWEyE1EwEzNwPA/IADgPyAGiYmGgOAGiYmGoA4KCg4OCgoOED9AOABAEDgA0D9AAMAQCYa/QAaJiYaAwAaJuAoODgoKDg4/biAAYD+wMAAAAIAAABABAADQAA4ADwAAAEmJy4BJyYjIgcOAQcGBwYHDgEHBhUUFx4BFxYXFhceARcWMzI3PgE3Njc2Nz4BNzY1NCcuAScmJwERDQED1TY4OXY8PT8/PTx2OTg2CwcICwMDAwMLCAcLNjg5djw9Pz89PHY5ODYLBwgLAwMDAwsIBwv9qwFA/sADIAgGBggCAgICCAYGCCkqKlktLi8vLi1ZKiopCAYGCAICAgIIBgYIKSoqWS0uLy8uLVkqKin94AGAwMAAAAAAAgDA/8ADQAPAABsAJwAAASIHDgEHBhUUFx4BFxYxMDc+ATc2NTQnLgEnJgMiJjU0NjMyFhUUBgIAQjs6VxkZMjJ4MjIyMngyMhkZVzo7QlBwcFBQcHADwBkZVzo7Qnh9fcxBQUFBzH19eEI7OlcZGf4AcFBQcHBQUHAAAAEAAAAABAADgAArAAABIgcOAQcGBycRISc+ATMyFx4BFxYVFAcOAQcGBxc2Nz4BNzY1NCcuAScmIwIANTIyXCkpI5YBgJA1i1BQRUZpHh4JCSIYGB5VKCAgLQwMKCiLXl1qA4AKCycbHCOW/oCQNDweHmlGRVArKClJICEaYCMrK2I2NjlqXV6LKCgAAQAAAAAEAAOAACoAABMUFx4BFxYXNyYnLgEnJjU0Nz4BNzYzMhYXByERByYnLgEnJiMiBw4BBwYADAwtICAoVR4YGCIJCR4eaUZFUFCLNZABgJYjKSlcMjI1al1eiygoAYA5NjZiKysjYBohIEkpKCtQRUZpHh48NJABgJYjHBsnCwooKIteXQAAAAACAAAAQAQBAwAAJgBNAAATMhceARcWFRQHDgEHBiMiJy4BJyY1JzQ3PgE3NjMVIgYHDgEHPgEhMhceARcWFRQHDgEHBiMiJy4BJyY1JzQ3PgE3NjMVIgYHDgEHPgHhLikpPRESEhE9KSkuLikpPRESASMjelJRXUB1LQkQBwgSAkkuKSk9ERISET0pKS4uKSk9ERIBIyN6UlFdQHUtCRAHCBICABIRPSkpLi4pKT0REhIRPSkpLiBdUVJ6IyOAMC4IEwoCARIRPSkpLi4pKT0REhIRPSkpLiBdUVJ6IyOAMC4IEwoCAQAABgBA/8AEAAPAAAMABwALABEAHQApAAAlIRUhESEVIREhFSEnESM1IzUTFTMVIzU3NSM1MxUVESM1MzUjNTM1IzUBgAKA/YACgP2AAoD9gMBAQECAwICAwMCAgICAgIACAIACAIDA/wDAQP3yMkCSPDJAku7+wEBAQEBAAAYAAP/ABAADwAADAAcACwAXACMALwAAASEVIREhFSERIRUhATQ2MzIWFRQGIyImETQ2MzIWFRQGIyImETQ2MzIWFRQGIyImAYACgP2AAoD9gAKA/YD+gEs1NUtLNTVLSzU1S0s1NUtLNTVLSzU1SwOAgP8AgP8AgANANUtLNTVLS/61NUtLNTVLS/61NUtLNTVLSwADAAAAAAQAA6AAAwANABQAADchFSElFSE1EyEVITUhJQkBIxEjEQAEAPwABAD8AIABAAEAAQD9YAEgASDggEBAwEBAAQCAgMABIP7g/wABAAAAAAACAB7/zAPiA7QAMwBkAAABIiYnJicmNDc2PwE+ATMyFhcWFxYUBwYPAQYiJyY0PwE2NCcuASMiBg8BBhQXFhQHDgEjAyImJyYnJjQ3Nj8BNjIXFhQPAQYUFx4BMzI2PwE2NCcmNDc2MhcWFxYUBwYPAQ4BIwG4ChMIIxISEhIjwCNZMTFZIyMSEhISI1gPLA8PD1gpKRQzHBwzFMApKQ8PCBMKuDFZIyMSEhISI1gPLA8PD1gpKRQzHBwzFMApKQ8PDysQIxISEhIjwCNZMQFECAckLS1eLS0kwCIlJSIkLS1eLS0kVxAQDysPWCl0KRQVFRTAKXQpDysQBwj+iCUiJC0tXi0tJFcQEA8rD1gpdCkUFRUUwCl0KQ8rEA8PJC0tXi0tJMAiJQAAAAAFAAD/wAQAA8AAGwA3AFMAXwBrAAAFMjc+ATc2NTQnLgEnJiMiBw4BBwYVFBceARcWEzIXHgEXFhUUBw4BBwYjIicuAScmNTQ3PgE3NhMyNz4BNzY3BgcOAQcGIyInLgEnJicWFx4BFxYnNDYzMhYVFAYjIiYlNDYzMhYVFAYjIiYCAGpdXosoKCgoi15dampdXosoKCgoi15dalZMTHEgISEgcUxMVlZMTHEgISEgcUxMVisrKlEmJiMFHBtWODc/Pzc4VhscBSMmJlEqK9UlGxslJRsbJQGAJRsbJSUbGyVAKCiLXl1qal1eiygoKCiLXl1qal1eiygoA6AhIHFMTFZWTExxICEhIHFMTFZWTExxICH+CQYGFRAQFEM6OlYYGRkYVjo6QxQQEBUGBvcoODgoKDg4KCg4OCgoODgAAAMAAP/ABAADwAAbADcAQwAAASIHDgEHBhUUFx4BFxYzMjc+ATc2NTQnLgEnJgMiJy4BJyY1NDc+ATc2MzIXHgEXFhUUBw4BBwYTBycHFwcXNxc3JzcCAGpdXosoKCgoi15dampdXosoKCgoi15dalZMTHEgISEgcUxMVlZMTHEgISEgcUxMSqCgYKCgYKCgYKCgA8AoKIteXWpqXV6LKCgoKIteXWpqXV6LKCj8YCEgcUxMVlZMTHEgISEgcUxMVlZMTHEgIQKgoKBgoKBgoKBgoKAAAQBl/8ADmwPAACkAAAEiJiMiBw4BBwYVFBYzLgE1NDY3MAcGAgcGBxUhEzM3IzceATMyNjcOAQMgRGhGcVNUbRobSUgGDWVKEBBLPDxZAT1sxizXNC1VJi5QGB09A7AQHh1hPj9BTTsLJjeZbwN9fv7Fj5AjGQIAgPYJDzdrCQcAAAAAAgAAAAAEAAOAAAkAFwAAJTMHJzMRIzcXIyURJyMRMxUhNTMRIwcRA4CAoKCAgKCggP8AQMCA/oCAwEDAwMACAMDAwP8AgP1AQEACwIABAAADAMAAAANAA4AAFgAfACgAAAE+ATU0Jy4BJyYjIREhMjc+ATc2NTQmATMyFhUUBisBEyMRMzIWFRQGAsQcIBQURi4vNf7AAYA1Ly5GFBRE/oRlKjw8KWafn58sPj4B2yJULzUvLkYUFPyAFBRGLi81RnQBRks1NUv+gAEASzU1SwAAAAACAMAAAANAA4AAHwAjAAABMxEUBw4BBwYjIicuAScmNREzERQWFx4BMzI2Nz4BNQEhFSECwIAZGVc6O0JCOzpXGRmAGxgcSSgoSRwYG/4AAoD9gAOA/mA8NDVOFhcXFk41NDwBoP5gHjgXGBsbGBc4Hv6ggAAAAAABAIAAAAOAA4AACwAAARUjATMVITUzASM1A4CA/sCA/kCAAUCAA4BA/QBAQAMAQAABAAAAAAQAA4AAPQAAARUjHgEVFAYHDgEjIiYnLgE1MxQWMzI2NTQmIyE1IS4BJy4BNTQ2Nz4BMzIWFx4BFSM0JiMiBhUUFjMyFhcEAOsVFjUwLHE+PnEsMDWAck5OcnJO/gABLAIEATA1NTAscT4+cSwwNYByTk5yck47bisBwEAdQSI1YiQhJCQhJGI1NExMNDRMQAEDASRiNTViJCEkJCEkYjU0TEw0NEwhHwAAAAcAAP/ABAADwAADAAcACwAPABMAGwAjAAATMxUjNzMVIyUzFSM3MxUjJTMVIwMTIRMzEyETAQMhAyMDIQMAgIDAwMABAICAwMDAAQCAgBAQ/QAQIBACgBD9QBADABAgEP2AEAHAQEBAQEBAQEBAAkD+QAHA/oABgPwAAYD+gAFA/sAAAAoAAAAABAADgAADAAcACwAPABMAFwAbAB8AIwAnAAATESERATUhFR0BITUBFSE1IxUhNREhFSElIRUhETUhFQEhFSEhNSEVAAQA/YABAP8AAQD/AED/AAEA/wACgAEA/wABAPyAAQD/AAKAAQADgPyAA4D9wMDAQMDAAgDAwMDA/wDAwMABAMDA/sDAwMAAAAUAAAAABAADgAADAAcACwAPABMAABMhFSEVIRUhESEVIREhFSERIRUhAAQA/AACgP2AAoD9gAQA/AAEAPwAA4CAQID/AIABQID/AIAAAAAABQAAAAAEAAOAAAMABwALAA8AEwAAEyEVIRchFSERIRUhAyEVIREhFSEABAD8AMACgP2AAoD9gMAEAPwABAD8AAOAgECA/wCAAUCA/wCAAAAFAAAAAAQAA4AAAwAHAAsADwATAAATIRUhBSEVIREhFSEBIRUhESEVIQAEAPwAAYACgP2AAoD9gP6ABAD8AAQA/AADgIBAgP8AgAFAgP8AgAAAAAABAD8APwLmAuYALAAAJRQPAQYjIi8BBwYjIi8BJjU0PwEnJjU0PwE2MzIfATc2MzIfARYVFA8BFxYVAuYQThAXFxCoqBAXFhBOEBCoqBAQThAWFxCoqBAXFxBOEBCoqBDDFhBOEBCoqBAQThAWFxCoqBAXFxBOEBCoqBAQThAXFxCoqBAXAAAABgAAAAADJQNuABQAKAA8AE0AVQCCAAABERQHBisBIicmNRE0NzY7ATIXFhUzERQHBisBIicmNRE0NzY7ATIXFhcRFAcGKwEiJyY1ETQ3NjsBMhcWExEhERQXFhcWMyEyNzY3NjUBIScmJyMGBwUVFAcGKwERFAcGIyEiJyY1ESMiJyY9ATQ3NjsBNzY3NjsBMhcWHwEzMhcWFQElBgUIJAgFBgYFCCQIBQaSBQUIJQgFBQUFCCUIBQWSBQUIJQgFBQUFCCUIBQVJ/gAEBAUEAgHbAgQEBAT+gAEAGwQGtQYEAfcGBQg3Ghsm/iUmGxs3CAUFBQUIsSgIFxYXtxcWFgkosAgFBgIS/rcIBQUFBQgBSQgFBgYFCP63CAUFBQUIAUkIBQYGBQj+twgFBQUFCAFJCAUGBgX+WwId/eMNCwoFBQUFCgsNAmZDBQICBVUkCAYF/eMwIiMhIi8CIAUGCCQIBQVgFQ8PDw8VYAUFCAACAAcASQO3Aq8AGgAuAAAJAQYjIi8BJjU0PwEnJjU0PwE2MzIXARYVFAcBFRQHBiMhIicmPQE0NzYzITIXFgFO/vYGBwgFHQYG4eEGBh0FCAcGAQoGBgJpBQUI/dsIBQUFBQgCJQgFBQGF/vYGBhwGCAcG4OEGBwcGHQUF/vUFCAcG/vslCAUFBQUIJQgFBQUFAAAAAQAjAAAD3QNuALMAACUiJyYjIgcGIyInJjU0NzY3Njc2NzY9ATQnJiMhIgcGHQEUFxYXFjMWFxYVFAcGIyInJiMiBwYjIicmNTQ3Njc2NzY3Nj0BETQ1NDU0JzQnJicmJyYnJicmIyInJjU0NzYzMhcWMzI3NjMyFxYVFAcGIwYHBgcGHQEUFxYzITI3Nj0BNCcmJyYnJjU0NzYzMhcWMzI3NjMyFxYVFAcGByIHBgcGFREUFxYXFhcyFxYVFAcGIwPBGTMyGhkyMxkNCAcJCg0MERAKEgEHFf5+FgcBFQkSEw4ODAsHBw4bNTUaGDExGA0HBwkJCwwQDwkSAQIBAgMEBAUIEhENDQoLBwcOGjU1GhgwMRgOBwcJCgwNEBAIFAEHDwGQDgcBFAoXFw8OBwcOGTMyGRkxMRkOBwcKCg0NEBEIFBQJEREODQoLBwcOAAICAgIMCw8RCQkBAQMDBQxE4AwFAwMFDNRRDQYBAgEICBIPDA0CAgICDAwOEQgJAQIDAwUNRSEB0AINDQgIDg4KCgsLBwcDBgEBCAgSDwwNAgICAg0MDxEICAECAQYMULYMBwEBBwy2UAwGAQEGBxYPDA0CAgICDQwPEQgIAQECBg1P/eZEDAYCAgEJCBEPDA0AAAIAAP+3A/8DtwATADkAAAEyFxYVFAcCBwYjIicmNTQ3ATYzARYXFh8BFgcGIyInJicmJyY1FhcWFxYXFjMyNzY3Njc2NzY3NjcDmygeHhq+TDdFSDQ0NQFtISn9+BcmJy8BAkxMe0c2NiEhEBEEExQQEBIRCRcIDxITFRUdHR4eKQO3GxooJDP+mUY0NTRJSTABSx/9sSsfHw0oek1MGhsuLzo6RAMPDgsLCgoWJRsaEREKCwQEAgABAAAAAAAA9evv618PPPUACwQAAAAAANbEBFgAAAAA1sQEWAAA/7cEAQPAAAAACAACAAAAAAAAAAEAAAPA/8AAAAQAAAD//wQBAAEAAAAAAAAAAAAAAAAAAAAhBAAAAAAAAAAAAAAAAgAAAAQAAAAEAAAABAAAAAQAAMAEAAAABAAAAAQAAAAEAABABAAAAAQAAAAEAAAeBAAAAAQAAAAEAABlBAAAAAQAAMAEAADABAAAgAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAMlAD8DJQAAA74ABwQAACMD/wAAAAAAAAAKABQAHgBMAJQA+AE2AXwBwgI2AnQCvgLoA34EHgSIBMoE8gU0BXAFiAXgBiIGagaSBroG5AcoB+AIKgkcCXgAAQAAACEAtAAKAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAA4ArgABAAAAAAABAAcAAAABAAAAAAACAAcAYAABAAAAAAADAAcANgABAAAAAAAEAAcAdQABAAAAAAAFAAsAFQABAAAAAAAGAAcASwABAAAAAAAKABoAigADAAEECQABAA4ABwADAAEECQACAA4AZwADAAEECQADAA4APQADAAEECQAEAA4AfAADAAEECQAFABYAIAADAAEECQAGAA4AUgADAAEECQAKADQApGljb21vb24AaQBjAG8AbQBvAG8AblZlcnNpb24gMS4wAFYAZQByAHMAaQBvAG4AIAAxAC4AMGljb21vb24AaQBjAG8AbQBvAG8Abmljb21vb24AaQBjAG8AbQBvAG8AblJlZ3VsYXIAUgBlAGcAdQBsAGEAcmljb21vb24AaQBjAG8AbQBvAG8AbkZvbnQgZ2VuZXJhdGVkIGJ5IEljb01vb24uAEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAEkAYwBvAE0AbwBvAG4ALgAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=) format(\'truetype\'); font-weight: normal; font-style: normal;}[class^="w-e-icon-"],[class*=" w-e-icon-"] { /* use !important to prevent issues with browser extensions that change fonts */ font-family: \'w-e-icon\' !important; speak: none; font-style: normal; font-weight: normal; font-variant: normal; text-transform: none; line-height: 1; /* Better Font Rendering =========== */ -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;}.w-e-icon-close:before { content: "\\f00d";}.w-e-icon-upload2:before { content: "\\e9c6";}.w-e-icon-trash-o:before { content: "\\f014";}.w-e-icon-header:before { content: "\\f1dc";}.w-e-icon-pencil2:before { content: "\\e906";}.w-e-icon-paint-brush:before { content: "\\f1fc";}.w-e-icon-image:before { content: "\\e90d";}.w-e-icon-play:before { content: "\\e912";}.w-e-icon-location:before { content: "\\e947";}.w-e-icon-undo:before { content: "\\e965";}.w-e-icon-redo:before { content: "\\e966";}.w-e-icon-quotes-left:before { content: "\\e977";}.w-e-icon-list-numbered:before { content: "\\e9b9";}.w-e-icon-list2:before { content: "\\e9bb";}.w-e-icon-link:before { content: "\\e9cb";}.w-e-icon-happy:before { content: "\\e9df";}.w-e-icon-bold:before { content: "\\ea62";}.w-e-icon-underline:before { content: "\\ea63";}.w-e-icon-italic:before { content: "\\ea64";}.w-e-icon-strikethrough:before { content: "\\ea65";}.w-e-icon-table2:before { content: "\\ea71";}.w-e-icon-paragraph-left:before { content: "\\ea77";}.w-e-icon-paragraph-center:before { content: "\\ea78";}.w-e-icon-paragraph-right:before { content: "\\ea79";}.w-e-icon-terminal:before { content: "\\f120";}.w-e-icon-page-break:before { content: "\\ea68";}.w-e-icon-cancel-circle:before { content: "\\ea0d";}.w-e-icon-font:before { content: "\\ea5c";}.w-e-icon-text-heigh:before { content: "\\ea5f";}.w-e-toolbar { display: -webkit-box; display: -ms-flexbox; display: flex; padding: 0 5px; /* flex-wrap: wrap; */ /* 单个菜单 */}.w-e-toolbar .w-e-menu { position: relative; text-align: center; padding: 5px 10px; cursor: pointer;}.w-e-toolbar .w-e-menu i { color: #999;}.w-e-toolbar .w-e-menu:hover i { color: #333;}.w-e-toolbar .w-e-active i { color: #1e88e5;}.w-e-toolbar .w-e-active:hover i { color: #1e88e5;}.w-e-text-container .w-e-panel-container { position: absolute; top: 0; left: 50%; border: 1px solid #ccc; border-top: 0; box-shadow: 1px 1px 2px #ccc; color: #333; background-color: #fff; /* 为 emotion panel 定制的样式 */ /* 上传图片的 panel 定制样式 */}.w-e-text-container .w-e-panel-container .w-e-panel-close { position: absolute; right: 0; top: 0; padding: 5px; margin: 2px 5px 0 0; cursor: pointer; color: #999;}.w-e-text-container .w-e-panel-container .w-e-panel-close:hover { color: #333;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-title { list-style: none; display: -webkit-box; display: -ms-flexbox; display: flex; font-size: 14px; margin: 2px 10px 0 10px; border-bottom: 1px solid #f1f1f1;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-title .w-e-item { padding: 3px 5px; color: #999; cursor: pointer; margin: 0 3px; position: relative; top: 1px;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-title .w-e-active { color: #333; border-bottom: 1px solid #333; cursor: default; font-weight: 700;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-content { padding: 10px 15px 10px 15px; font-size: 16px; /* 输入框的样式 */ /* 按钮的样式 */}.w-e-text-container .w-e-panel-container .w-e-panel-tab-content input:focus,.w-e-text-container .w-e-panel-container .w-e-panel-tab-content textarea:focus,.w-e-text-container .w-e-panel-container .w-e-panel-tab-content button:focus { outline: none;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-content textarea { width: 100%; border: 1px solid #ccc; padding: 5px;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-content textarea:focus { border-color: #1e88e5;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-content input[type=text] { border: none; border-bottom: 1px solid #ccc; font-size: 14px; height: 20px; color: #333; text-align: left;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-content input[type=text].small { width: 30px; text-align: center;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-content input[type=text].block { display: block; width: 100%; margin: 10px 0;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-content input[type=text]:focus { border-bottom: 2px solid #1e88e5;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-content .w-e-button-container button { font-size: 14px; color: #1e88e5; border: none; padding: 5px 10px; background-color: #fff; cursor: pointer; border-radius: 3px;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-content .w-e-button-container button.left { float: left; margin-right: 10px;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-content .w-e-button-container button.right { float: right; margin-left: 10px;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-content .w-e-button-container button.gray { color: #999;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-content .w-e-button-container button.red { color: #c24f4a;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-content .w-e-button-container button:hover { background-color: #f1f1f1;}.w-e-text-container .w-e-panel-container .w-e-panel-tab-content .w-e-button-container:after { content: ""; display: table; clear: both;}.w-e-text-container .w-e-panel-container .w-e-emoticon-container .w-e-item { cursor: pointer; font-size: 18px; padding: 0 3px; display: inline-block; *display: inline; *zoom: 1;}.w-e-text-container .w-e-panel-container .w-e-up-img-container { text-align: center;}.w-e-text-container .w-e-panel-container .w-e-up-img-container .w-e-up-btn { display: inline-block; *display: inline; *zoom: 1; color: #999; cursor: pointer; font-size: 60px; line-height: 1;}.w-e-text-container .w-e-panel-container .w-e-up-img-container .w-e-up-btn:hover { color: #333;}.w-e-text-container { position: relative;}.w-e-text-container .w-e-progress { position: absolute; background-color: #1e88e5; bottom: 0; left: 0; height: 1px;}.w-e-text { padding: 0 10px; overflow-y: scroll;}.w-e-text p,.w-e-text h1,.w-e-text h2,.w-e-text h3,.w-e-text h4,.w-e-text h5,.w-e-text table,.w-e-text pre { margin: 10px 0; line-height: 1.5;}.w-e-text ul,.w-e-text ol { margin: 10px 0 10px 20px;}.w-e-text blockquote { display: block; border-left: 8px solid #d0e5f2; padding: 5px 10px; margin: 10px 0; line-height: 1.4; font-size: 100%; background-color: #f1f1f1;}.w-e-text code { display: inline-block; *display: inline; *zoom: 1; background-color: #f1f1f1; border-radius: 3px; padding: 3px 5px; margin: 0 3px;}.w-e-text pre code { display: block;}.w-e-text table { border-top: 1px solid #ccc; border-left: 1px solid #ccc;}.w-e-text table td,.w-e-text table th { border-bottom: 1px solid #ccc; border-right: 1px solid #ccc; padding: 3px 5px;}.w-e-text table th { border-bottom: 2px solid #ccc; text-align: center;}.w-e-text:focus { outline: none;}.w-e-text img { cursor: pointer;}.w-e-text img:hover { box-shadow: 0 0 5px #333;}';
// 将 css 代码添加到 <style> 中
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = inlinecss;
document.getElementsByTagName('HEAD').item(0).appendChild(style);
// 返回
var index = window.wangEditor || Editor;
return index;
})));
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/static/js/wangEditor.js
|
JavaScript
|
mit
| 160,493
|
var lightyear = function(){
/**
* 页面loading
*/
var pageLoader = function($mode) {
var $loadingEl = jQuery('#lyear-loading');
$mode = $mode || 'show';
if ($mode === 'show') {
if ($loadingEl.length) {
$loadingEl.fadeIn(250);
} else {
jQuery('body').prepend('<div id="lyear-loading"><div class="spinner-border text-primary" role="status"><span class="sr-only">Loading...</span></div></div>');
}
} else if ($mode === 'hide') {
if ($loadingEl.length) {
$loadingEl.fadeOut(250);
}
}
return false;
};
/**
* 页面小提示
* @param $msg 提示信息
* @param $type 提示类型:'info', 'success', 'warning', 'danger'
* @param $delay 毫秒数,例如:1000
* @param $icon 图标,例如:'fa fa-user' 或 'glyphicon glyphicon-warning-sign'
* @param $from 'top' 或 'bottom'
* @param $align 'left', 'right', 'center'
* @author CaiWeiMing <314013107@qq.com>
*/
var tips = function ($msg, $type, $delay, $icon, $from, $align) {
$type = $type || 'info';
$delay = $delay || 1000;
$from = $from || 'top';
$align = $align || 'center';
$enter = $type == 'danger' ? 'animated shake' : 'animated fadeInUp';
jQuery.notify({
icon: $icon,
message: $msg
},
{
element: 'body',
type: $type,
allow_dismiss: true,
newest_on_top: true,
showProgressbar: false,
placement: {
from: $from,
align: $align
},
offset: 20,
spacing: 10,
z_index: 10800,
delay: $delay,
//timer: 1000,
animate: {
enter: $enter,
exit: 'animated fadeOutDown'
}
});
};
return {
// 页面小提示
notify : function ($msg, $type, $delay, $icon, $from, $align) {
tips($msg, $type, $delay, $icon, $from, $align);
},
// 页面加载动画
loading : function ($mode) {
pageLoader($mode);
}
};
}();
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/static/lyear/js/lightyear.js
|
JavaScript
|
mit
| 2,152
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<meta charset="UTF-8">
<title>topbar</title>
</head>
<body>
<!--左侧导航-->
<aside class="lyear-layout-sidebar" id="leftbaraside">
<div id="logo" class="sidebar-header">
<a class="navbar-brand" style="font-size: 20px"
th:href="@{/admin/index.html}">后台管理系统</a>
</div>
<div class="lyear-layout-sidebar-scroll">
<nav class="sidebar-main">
<ul class="nav nav-drawer">
<li class="nav-item" th:class="${activeUrl=='indexActive'?'nav-item active':'nav-item'}"><a
th:href="@{/admin/index.html}"><i
class="mdi mdi-home"></i>系统首页</a></li>
<li shiro:hasPermission="admin:userInfo" class="nav-item nav-item-has-subnav"
th:class="${activeUrl1=='userInfoActive'?'nav-item nav-item-has-subnav active open':'nav-item nav-item-has-subnav'}">
<a href="javascript:void(0)"><i class="mdi mdi-account-settings-variant"></i>
用户信息管理</a>
<ul class="nav nav-subnav">
<li shiro:hasPermission="admin:userInfoElse" th:class="${activeUrl2=='userInfoActive'?'active':''}"><a
th:href="@{/admin/userinfo/toUserInfo.html}">用户信息</a></li>
<li shiro:hasPermission="admin:bankCard" th:class="${activeUrl2=='bankcardActive'?'active':''}"><a
th:href="@{/admin/userinfo/toBankCard.html}">银行卡</a></li>
<li shiro:hasPermission="admin:reputation" th:class="${activeUrl2=='reputationActive'?'active':''}"><a
th:href="@{/admin/userinfo/toReputation.html}">个人征信</a></li>
</ul>
</li>
<li shiro:hasPermission="admin:finance" class="nav-item nav-item-has-subnav"
th:class="${activeUrl1=='financeActive'?'nav-item nav-item-has-subnav active open':'nav-item nav-item-has-subnav'}"
><a href="javascript:void(0)"><i class="mdi mdi-skype-business"></i>理财产品管理</a>
<ul class="nav nav-subnav">
<li shiro:hasPermission="admin:changeMoney" th:class="${activeUrl2=='changemoneyActive'?'active':''}"><a
th:href="@{/admin/finance/toChangeMoney.html}">零钱理财</a></li>
<li shiro:hasPermission="admin:payMoney" th:class="${activeUrl2=='paymoneyActive'?'active':''}"><a
th:href="@{/admin/finance/toPayMoney.html}">工资理财</a></li>
<li shiro:hasPermission="admin:termFinancial" th:class="${activeUrl2=='termfinancialActive'?'active':''}"><a
th:href="@{/admin/finance/toTermFinancial.html}">期限理财</a></li>
<li shiro:hasPermission="admin:fundProduct" th:class="${activeUrl2=='fundproductActive'?'active':''}"><a
th:href="@{/admin/finance/toFundProduct.html}">基金理财</a></li>
<li shiro:hasPermission="admin:bank" th:class="${activeUrl2=='bankctive'?'active':''}"><a
th:href="@{/admin/finance/toBank.html}">精选银行</a></li>
</ul>
</li>
<li shiro:hasPermission="admin:permission" class="nav-item nav-item-has-subnav"
th:class="${activeUrl1=='permissionActive'?'nav-item nav-item-has-subnav active open':'nav-item nav-item-has-subnav'}"
><a href="javascript:void(0)"><i class="mdi mdi-key-change"></i>权限管理</a>
<ul class="nav nav-subnav">
<li shiro:hasPermission="admin:userPermissions" th:class="${activeUrl2=='userPermissionsActive'?'active':''}"><a
th:href="@{/admin/permission/toUserPermissions.html}">用户权限</a></li>
<li shiro:hasPermission="admin:adminPermissions" th:class="${activeUrl2=='adminPermissionsActive'?'active':''}"><a
th:href="@{/admin/permission/toAdminPermissions.html}">管理员权限</a></li>
</ul>
</li>
<li shiro:hasPermission="admin:loan" class="nav-item nav-item-has-subnav"
th:class="${activeUrl1=='loanActive'?'nav-item nav-item-has-subnav active open':'nav-item nav-item-has-subnav'}"
><a href="javascript:void(0)"><i class="mdi mdi-comment-text"></i>网贷管理</a>
<ul class="nav nav-subnav">
<li shiro:hasPermission="admin:loanExam" th:class="${activeUrl2=='loanexamActive'?'active':''}"><a
th:href="@{/admin/loan/toLoanexam.html}">网贷审核</a></li>
<li shiro:hasPermission="admin:loanInfo" th:class="${activeUrl2=='loaninfoActive'?'active':''}"><a
th:href="@{/admin/loan/toLoaninfo.html}">网贷信息</a></li>
</ul>
</li>
</ul>
</nav>
</div>
</aside>
<!--End 左侧导航-->
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/admin/common/leftbar.html
|
HTML
|
mit
| 5,378
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta charset="UTF-8">
<title>topbar</title>
</head>
<body>
<!--头部信息-->
<header class="lyear-layout-header" id="topbarheader">
<nav class="navbar navbar-default">
<div class="topbar">
<div class="topbar-left">
<div class="lyear-aside-toggler">
<span class="lyear-toggler-bar"></span> <span
class="lyear-toggler-bar"></span> <span class="lyear-toggler-bar"></span>
</div>
<!--/*@thymesVar id="pageTopBarInfo" type="java.lang.String"*/-->
<span class="navbar-page-title" th:text="${pageTopBarInfo}"></span>
</div>
<ul class="topbar-right">
<!--个人信息-->
<li class="dropdown dropdown-profile" style="margin-right: 20px">
<a href="javascript:void(0)" data-toggle="dropdown"> <img
id="img" class="img-avatar img-avatar-48 m-r-10" src="./images/pic.jpg"
th:src="@{/images/pic2.jpg}" th:alt="${session.loginAdmin.username}"/>
<span th:text="${session.loginAdmin.username}">
<span class="caret"></span>
</span>
</a>
<ul class="dropdown-menu dropdown-menu-right">
<li><a th:href="@{/logout(logout='adminLogout')}"><i
class="mdi mdi-logout-variant"></i> 退出登录</a></li>
</ul>
<!--切换主题配色-->
<li class="dropdown dropdown-skin"><span
data-toggle="dropdown" class="icon-palette"><i
class="mdi mdi-palette"></i></span>
<ul class="dropdown-menu dropdown-menu-right"
data-stopPropagation="true">
<li class="drop-title"><p>主题</p></li>
<li class="drop-skin-li clearfix"><span class="inverse">
<input type="radio" name="site_theme" value="default"
id="site_theme_1" checked> <label for="site_theme_1"></label>
</span> <span> <input type="radio" name="site_theme" value="dark"
id="site_theme_2"> <label for="site_theme_2"></label>
</span> <span> <input type="radio" name="site_theme"
value="translucent" id="site_theme_3"> <label
for="site_theme_3"></label>
</span></li>
<li class="drop-title"><p>LOGO</p></li>
<li class="drop-skin-li clearfix"><span class="inverse">
<input type="radio" name="logo_bg" value="default"
id="logo_bg_1" checked> <label for="logo_bg_1"></label>
</span> <span> <input type="radio" name="logo_bg" value="color_2"
id="logo_bg_2"> <label for="logo_bg_2"></label>
</span> <span> <input type="radio" name="logo_bg" value="color_3"
id="logo_bg_3"> <label for="logo_bg_3"></label>
</span> <span> <input type="radio" name="logo_bg" value="color_4"
id="logo_bg_4"> <label for="logo_bg_4"></label>
</span> <span> <input type="radio" name="logo_bg" value="color_5"
id="logo_bg_5"> <label for="logo_bg_5"></label>
</span> <span> <input type="radio" name="logo_bg" value="color_6"
id="logo_bg_6"> <label for="logo_bg_6"></label>
</span> <span> <input type="radio" name="logo_bg" value="color_7"
id="logo_bg_7"> <label for="logo_bg_7"></label>
</span> <span> <input type="radio" name="logo_bg" value="color_8"
id="logo_bg_8"> <label for="logo_bg_8"></label>
</span></li>
<li class="drop-title"><p>头部</p></li>
<li class="drop-skin-li clearfix"><span class="inverse">
<input type="radio" name="header_bg" value="default"
id="header_bg_1" checked> <label for="header_bg_1"></label>
</span> <span> <input type="radio" name="header_bg"
value="color_2" id="header_bg_2"> <label
for="header_bg_2"></label>
</span> <span> <input type="radio" name="header_bg"
value="color_3" id="header_bg_3"> <label
for="header_bg_3"></label>
</span> <span> <input type="radio" name="header_bg"
value="color_4" id="header_bg_4"> <label
for="header_bg_4"></label>
</span> <span> <input type="radio" name="header_bg"
value="color_5" id="header_bg_5"> <label
for="header_bg_5"></label>
</span> <span> <input type="radio" name="header_bg"
value="color_6" id="header_bg_6"> <label
for="header_bg_6"></label>
</span> <span> <input type="radio" name="header_bg"
value="color_7" id="header_bg_7"> <label
for="header_bg_7"></label>
</span> <span> <input type="radio" name="header_bg"
value="color_8" id="header_bg_8"> <label
for="header_bg_8"></label>
</span></li>
<li class="drop-title"><p>侧边栏</p></li>
<li class="drop-skin-li clearfix"><span class="inverse">
<input type="radio" name="sidebar_bg" value="default"
id="sidebar_bg_1" checked> <label for="sidebar_bg_1"></label>
</span> <span> <input type="radio" name="sidebar_bg"
value="color_2" id="sidebar_bg_2"> <label
for="sidebar_bg_2"></label>
</span> <span> <input type="radio" name="sidebar_bg"
value="color_3" id="sidebar_bg_3"> <label
for="sidebar_bg_3"></label>
</span> <span> <input type="radio" name="sidebar_bg"
value="color_4" id="sidebar_bg_4"> <label
for="sidebar_bg_4"></label>
</span> <span> <input type="radio" name="sidebar_bg"
value="color_5" id="sidebar_bg_5"> <label
for="sidebar_bg_5"></label>
</span> <span> <input type="radio" name="sidebar_bg"
value="color_6" id="sidebar_bg_6"> <label
for="sidebar_bg_6"></label>
</span> <span> <input type="radio" name="sidebar_bg"
value="color_7" id="sidebar_bg_7"> <label
for="sidebar_bg_7"></label>
</span> <span> <input type="radio" name="sidebar_bg"
value="color_8" id="sidebar_bg_8"> <label
for="sidebar_bg_8"></label>
</span></li>
</ul>
</li>
<!--切换主题配色-->
</li>
</ul>
</div>
</nav>
</header>
<!--End 头部信息-->
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/admin/common/topbar.html
|
HTML
|
mit
| 8,020
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>后台管理系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="admin/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="admin/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>推荐银行管理</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">银行名称</th>
<th class="info">银行类型</th>
<th class="info">资产</th>
<th class="info">描述</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="finance:${financeList}">
<td th:text="${(finacnePageInfo.pageNum - 1) * finacnePageInfo.pageSize+financeStat.index+1}"></td>
<td th:text="${finance.name}"></td>
<td th:text="${finance.type}"></td>
<td th:text="${finance.assets}"></td>
<!-- <td th:text="${#strings.substring(finance.bankdesc,0,10)}+'...'"></td>-->
<td th:text="${#strings.length(finance.bankdesc)>=10?#strings.substring(finance.bankdesc,0,10)+'...':finance.bankdesc}"></td>
<td>
<button class="btn btn-primary btn-sm update_btn"
th:attr="update-id=${finance.id}">
<span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span> 编辑
</button>
<button class="btn btn-danger btn-sm delete_btn"
th:attr="delete-id=${finance.id},delete-name=${finance.name}">
<span class="glyphicon glyphicon-trash"
aria-hidden="true"></span> 删除
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- 显示分页信息 -->
<div class="row">
<!-- 新增按钮 -->
<div class="col-md-1" style="margin-left: 24px">
<button id="add_modal_btn" class="btn btn-primary">新增</button>
</div>
<div class="col-md-5">
<div class="btn-group">
<button class="btn btn-default">
<span>页次:</span>
</button>
<button class="btn btn-default">
<span th:text="${finacnePageInfo.pageNum}+'/'+${finacnePageInfo.pages}+'页'"></span>
</button>
<button class="btn btn-default">
<span>每页显示:</span>
</button>
<div class="btn-group">
<button id="btnGroupDrop1"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"><span
th:text="${finacnePageInfo.pageSize}"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li th:each="i:${#numbers.sequence(1,10)}">
<a th:text="${i}"
th:href="@{/admin/finance/toBank.html(pageNum=${finacnePageInfo.pageNum},pageSize=${i})}"></a>
</li>
</ul>
</div>
<button class="btn btn-default">
<span>条</span>
</button>
<button class="btn btn-default">
<span>总记录数:</span>
</button>
<button class="btn btn-default">
<span th:text="${finacnePageInfo.total}+'条'"></span>
</button>
</div>
</div>
<!-- 分页条信息 -->
<div class="col-md-5">
<nav aria-label="Page navigation">
<ul class="pagination pagination-lg pull-right"
style="margin-top: 0">
<li>
<a th:href="@{/admin/finance/toBank.html(pageNum=1,pageSize=${finacnePageInfo.pageSize})}">首页</a>
</li>
<li th:if="${finacnePageInfo.hasPreviousPage }"><a
th:href="@{/admin/finance/toBank.html(pageNum=${finacnePageInfo.pageNum}-1,pageSize=${finacnePageInfo.pageSize})}"
aria-label="Previous"> <span aria-hidden="true">«</span>
</a></li>
<li th:each="page_Num:${finacnePageInfo.navigatepageNums }"
th:class="${page_Num == finacnePageInfo.pageNum?'active':''}">
<a th:if="${page_Num == finacnePageInfo.pageNum}"
th:text="${page_Num}"
th:href="@{#}">
</a>
<a th:text="${page_Num}"
th:if="${page_Num != finacnePageInfo.pageNum}"
th:href="@{/admin/finance/toBank.html(pageNum=${page_Num},pageSize=${finacnePageInfo.pageSize})}">
</a>
</li>
<li th:if="${finacnePageInfo.hasNextPage }"><a
th:href="@{/admin/finance/toBank.html(pageNum=${finacnePageInfo.pageNum}+1,pageSize=${finacnePageInfo.pageSize})}"
aria-label="Next"> <span aria-hidden="true">»</span>
</a></li>
<li><a
th:href="@{/admin/finance/toBank.html(pageNum=${finacnePageInfo.pages},pageSize=${finacnePageInfo.pageSize})}">末页</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<!-- 新增推荐银行的模态框 -->
<div class="modal fade bs-example-modal-lg" id="addModal" tabindex="-1"
role="dialog" aria-labelledby="myLargeModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">新增推荐银行信息</h4>
</div>
<div class="modal-body">
<!--要提交的表单 -->
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">银行名称:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="name_add_input" name="name"
placeholder="请输入银行名称:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">银行类别:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="type_add_input" name="type"
placeholder="请输入银行类别:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">资产:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="assets_add_input" name="assets"
placeholder="请输入银行资产:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">银行描述:</label>
<div class="col-sm-10">
<div id="addDescEditor"></div>
<input type="text" name="bankdesc" id="addBankdesc"
style="display: none" />
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary"
id="save_btn">保存
</button>
</div>
</div>
</div>
</div>
<!-- 修改推荐银行的模态框 -->
<div class="modal fade" id="updateModal" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">修改推荐银行信息</h4>
</div>
<div class="modal-body">
<!--要提交的表单 -->
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">银行名称:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="name_update_input" name="name"
placeholder="请输入银行名称:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">银行类别:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="type_update_input" name="type"
placeholder="请输入银行类别:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">资产:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="assets_update_input" name="assets"
placeholder="请输入银行资产:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">银行描述:</label>
<div class="col-sm-10">
<div id="updateDescEditor"></div>
<input type="text" name="bankdesc" id="updateBankdesc"
style="display: none" />
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary"
id="update_btn">更新
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--富文本编辑框js-->
<script th:src="@{/js/wangEditor.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
//点击新增按钮弹出模态框。
$("#add_modal_btn").click(function () {
//限制富文本编辑器在模态框中的显示
var E = window.wangEditor;
var editor = new E('#addDescEditor');
editor.customConfig.zIndex = 100;
editor.customConfig.onchange = function(html) {
// 监控变化,同步更新到 textarea
//alert(html);
textArea = html;
$("#addDescEditor").val(html);
$("#addBankdesc").val(html);
//alert($("#divEditor").val());
}
editor.create();
//初始化显示内容
editor.txt.html("<h1>欢迎编辑,请输入文字...</h1>");
//清除表单数据(表单完整重置(表单的数据,表单的样式))
reset_form("#addModal form");
//弹出模态框
$("#addModal").modal({
//点击增加框背景不删除增加框
backdrop: "static"
});
});
//点击保存,保存新增产品信息。
$("#save_btn").click(function () {
//清空表单样式
clean_form("#addModal form");
var name = $("#name_add_input").val();
var type = $("#type_add_input").val();
var assets = $("#assets_add_input").val();
//匹配中文、英文、数字包括下划线
var nameRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (name.length === 0) {
show_validate_msg("#name_add_input",
"error", "银行名称为空");
return false;
} else if (nameRegex.test(name) === false) {
show_validate_msg("#name_add_input",
"error", "银行名称不合法(产品名称只能由中文、数字、英文和下划线组成)");
return false;
}
//匹配中文、英文、数字包括下划线
var typeRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (type.length === 0) {
show_validate_msg("#type_add_input",
"error", "银行类别为空");
return false;
} else if (typeRegex.test(type) === false) {
show_validate_msg("#type_add_input",
"error", "银行类别不合法(产品名称只能由中文、数字、英文和下划线组成)");
return false;
}
if (assets.length === 0) {
show_validate_msg("#assets_add_input",
"error", "银行资产为空");
return false;
}
//2、发送ajax请求保存产品
$.ajax({
url: "/admin/addBank",
type: "POST",
data: $("#addModal form").serialize(),
success: function (result) {
if (result.code === 100) {
$("#addModal").modal('hide');
$.alert('推荐银行新增成功!');
setTimeout(function () {
var pageNum = [[${finacnePageInfo.pages}]];
var pageSize = [[${finacnePageInfo.pageSize}]];
location.href = "/admin/finance/toBank.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('推荐银行新增失败!');
}
}
});
});
//点击编辑按钮时触发事件
$(document).on("click", ".update_btn", function () {
//根据用户id发送ajax请求,查出信息并显示
getFinanceInfo($(this).attr("update-id"));
//把用户的id传递给模态框的更新按钮
$("#update_btn").attr("update-id", $(this).attr("update-id"));
$("#updateModal").modal({
backdrop: "static"
});
});
//根据id查出信息并显示
function getFinanceInfo(id) {
$.ajax({
url: "/admin/getBankInfoById/" + id,
type: "GET",
success: function (result) {
var bank = result.extend.bank;
//显示数据之前先清除一下校验样式,如果有的话
reset_form("#updateModal form");
$("#name_update_input").val(bank.name);
$("#type_update_input").val(bank.type);
$("#assets_update_input").val(bank.assets);
//初始化富文本编辑框
var E2 = window.wangEditor;
var editor2 = new E2('#updateDescEditor');
editor2.customConfig.zIndex = 100;
editor2.customConfig.onchange = function(html) {
// 监控变化,同步更新到 textarea
//alert(html);
textArea = html;
$("#updateDescEditor").val(html);
$("#updateBankdesc").val(html);
//alert($("#divEditor").val());
};
editor2.create();
editor2.txt.html(bank.bankdesc);
}
});
}
//点击更新,更新信息
$("#update_btn").click(function () {
//清空表单样式
//clean_form("#updateModal form");
var name = $("#name_update_input").val();
var type = $("#type_update_input").val();
var assets = $("#assets_update_input").val();
//匹配中文、英文、数字包括下划线
var nameRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (name.length === 0) {
show_validate_msg("#name_update_input",
"error", "银行名称为空");
return false;
} else if (nameRegex.test(name) === false) {
show_validate_msg("#name_update_input",
"error", "银行名称不合法(产品名称只能由中文、数字、英文和下划线组成)");
return false;
}
//匹配中文、英文、数字包括下划线
var typeRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (type.length === 0) {
show_validate_msg("#type_update_input",
"error", "银行类别为空");
return false;
} else if (typeRegex.test(type) === false) {
show_validate_msg("#type_update_input",
"error", "银行类别不合法(产品名称只能由中文、数字、英文和下划线组成)");
return false;
}
if (assets.length === 0) {
show_validate_msg("#assets_update_input",
"error", "银行资产为空");
return false;
}
//2、发送ajax请求保存更新的理财产品数据
$.ajax({
url: "/admin/updateBank/" + $(this).attr("update-id"),
type: "PUT",
data: $("#updateModal form").serialize(),
success: function (result) {
if (result.code === 100) {
$("#updateModal").modal('hide');
$.alert('推荐银行信息修改成功!');
setTimeout(function () {
var pageNum = [[${finacnePageInfo.pageNum}]];
var pageSize = [[${finacnePageInfo.pageSize}]];
location.href = "/admin/finance/toBank.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('推荐银行信息修改失败!');
}
}
});
});
//单个删除
$(document).on("click", ".delete_btn", function () {
//1、弹出是否确认删除对话框
var id = $(this).attr("delete-id");
var username = $(this).attr("delete-name");
$.alert({
title: '提示:',
content: "确定删除推荐银行 <strong>" + username + "</strong> 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/admin/deleteBankById/" + id,
type: "DELETE",
success: function (result) {
if (result.code === 100) {
$.alert('删除该推荐银行成功!');
setTimeout(function () {
var pageNum = [[${finacnePageInfo.pageNum}]];
var pageSize = [[${finacnePageInfo.pageSize}]];
location.href = "/admin/finance/toBank.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('删除该推荐银行失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
});
//清空表单样式及内容
function reset_form(ele) {
$(ele)[0].reset();
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//清空表单样式
function clean_form(ele) {
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//显示校验结果的提示信息
function show_validate_msg(ele, status, msg) {
//清除当前元素的校验状态
$(ele).parent().removeClass("has-success has-error");
$(ele).next("span").text("");
if ("success" === status) {
$(ele).parent().addClass("has-success");
$(ele).next("span").text(msg);
} else if ("error" === status) {
$(ele).parent().addClass("has-error");
$(ele).next("span").text(msg);
}
}
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/admin/finance/bank.html
|
HTML
|
mit
| 30,831
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>后台管理系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="admin/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="admin/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>零钱理财管理</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">产品名称</th>
<th class="info">七日年化收益率</th>
<th class="info">每万元收益</th>
<th class="info">起投金额</th>
<th class="info">投资期限</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="finance:${financeList}">
<td th:text="${(finacnePageInfo.pageNum - 1) * finacnePageInfo.pageSize+financeStat.index+1}"></td>
<td th:text="${finance.name}"></td>
<td th:text="${#numbers.formatDecimal(finance.annualincome*100,1,3)}+'%'"></td>
<td th:text="${#numbers.formatDecimal(finance.peiincome,1,2)}+'元'"></td>
<td th:text="${finance.invesmoney}+'元'"></td>
<td th:text="${finance.investerm}"></td>
<td>
<button class="btn btn-primary btn-sm update_btn"
th:attr="update-id=${finance.id}">
<span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span> 编辑
</button>
<button class="btn btn-danger btn-sm delete_btn"
th:attr="delete-id=${finance.id},delete-name=${finance.name}">
<span class="glyphicon glyphicon-trash"
aria-hidden="true"></span> 删除
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- 显示分页信息 -->
<div class="row">
<!-- 新增按钮 -->
<div class="col-md-1" style="margin-left: 24px">
<button id="add_modal_btn" class="btn btn-primary">新增</button>
</div>
<div class="col-md-5">
<div class="btn-group">
<button class="btn btn-default">
<span>页次:</span>
</button>
<button class="btn btn-default">
<span th:text="${finacnePageInfo.pageNum}+'/'+${finacnePageInfo.pages}+'页'"></span>
</button>
<button class="btn btn-default">
<span>每页显示:</span>
</button>
<div class="btn-group">
<button id="btnGroupDrop1"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"><span
th:text="${finacnePageInfo.pageSize}"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li th:each="i:${#numbers.sequence(1,10)}">
<a th:text="${i}"
th:href="@{/admin/finance/toChangeMoney.html(pageNum=${finacnePageInfo.pageNum},pageSize=${i})}"></a>
</li>
</ul>
</div>
<button class="btn btn-default">
<span>条</span>
</button>
<button class="btn btn-default">
<span>总记录数:</span>
</button>
<button class="btn btn-default">
<span th:text="${finacnePageInfo.total}+'条'"></span>
</button>
</div>
</div>
<!-- 分页条信息 -->
<div class="col-md-5">
<nav aria-label="Page navigation">
<ul class="pagination pagination-lg pull-right"
style="margin-top: 0">
<li>
<a th:href="@{/admin/finance/toChangeMoney.html(pageNum=1,pageSize=${finacnePageInfo.pageSize})}">首页</a>
</li>
<li th:if="${finacnePageInfo.hasPreviousPage }"><a
th:href="@{/admin/finance/toChangeMoney.html(pageNum=${finacnePageInfo.pageNum}-1,pageSize=${finacnePageInfo.pageSize})}"
aria-label="Previous"> <span aria-hidden="true">«</span>
</a></li>
<li th:each="page_Num:${finacnePageInfo.navigatepageNums }"
th:class="${page_Num == finacnePageInfo.pageNum?'active':''}">
<a th:if="${page_Num == finacnePageInfo.pageNum}"
th:text="${page_Num}"
th:href="@{#}">
</a>
<a th:text="${page_Num}"
th:if="${page_Num != finacnePageInfo.pageNum}"
th:href="@{/admin/finance/toChangeMoney.html(pageNum=${page_Num},pageSize=${finacnePageInfo.pageSize})}">
</a>
</li>
<li th:if="${finacnePageInfo.hasNextPage }"><a
th:href="@{/admin/finance/toChangeMoney.html(pageNum=${finacnePageInfo.pageNum}+1,pageSize=${finacnePageInfo.pageSize})}"
aria-label="Next"> <span aria-hidden="true">»</span>
</a></li>
<li><a
th:href="@{/admin/finance/toChangeMoney.html(pageNum=${finacnePageInfo.pages},pageSize=${finacnePageInfo.pageSize})}">末页</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<!-- 新增零钱理财的模态框 -->
<div class="modal fade" id="addModal" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">新增零钱理财产品</h4>
</div>
<div class="modal-body">
<!--要提交的表单 -->
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">产品名称:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="name_add_input" name="name"
placeholder="请输入产品名称:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">七日年化收益率:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="annualincome_add_input" name="annualincome"
placeholder="请输入七日年化收益率:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">每万元收益:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="peiincome_add_input" name="peiincome"
placeholder="请输入每万元收益:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">起投金额(元):</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="invesmoney_add_input" name="invesmoney"
placeholder="请输入起投金额:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">投资期限:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="investerm_add_input" name="investerm"
placeholder="请输入投资期限:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary"
id="save_btn">保存
</button>
</div>
</div>
</div>
</div>
<!-- 修改用户的模态框 -->
<div class="modal fade" id="updateModal" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">修改零钱理财产品信息</h4>
</div>
<div class="modal-body">
<!--要提交的表单 -->
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">产品名称:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="name_update_input" name="name"
placeholder="请输入产品名称:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">七日年化收益率:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="annualincome_update_input" name="annualincome"
placeholder="请输入七日年化收益率:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">每万元收益:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="peiincome_update_input" name="peiincome"
placeholder="请输入每万元收益:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">起投金额(元):</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="invesmoney_update_input" name="invesmoney"
placeholder="请输入起投金额:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">投资期限:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="investerm_update_input" name="investerm"
placeholder="请输入投资期限:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary"
id="update_btn">更新
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
//点击新增按钮弹出模态框。
$("#add_modal_btn").click(function () {
//清除表单数据(表单完整重置(表单的数据,表单的样式))
reset_form("#addModal form");
//弹出模态框
$("#addModal").modal({
//点击增加框背景不删除增加框
backdrop: "static"
});
});
//点击保存,保存新增产品信息。
$("#save_btn").click(function () {
//清空表单样式
clean_form("#addModal form");
var name = $("#name_add_input").val();
var annualincome = $("#annualincome_add_input").val();
var peiincome = $("#peiincome_add_input").val();
var invesmoney = $("#invesmoney_add_input").val();
var investerm = $("#investerm_add_input").val();
//匹配中文、英文、数字包括下划线(理财产品名称)
var nameRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (name.length === 0) {
show_validate_msg("#name_add_input",
"error", "产品名称为空");
return false;
} else if (nameRegex.test(name) === false) {
show_validate_msg("#name_add_input",
"error", "产品名称不合法(产品名称只能由中文、数字、英文和下划线组成)");
return false;
}
//匹配正数、负数、和小数
var annualincomeRegex = /^(\-|\+)?\d+(\.\d+)?$/;
if (annualincome.length === 0) {
show_validate_msg("#annualincome_add_input",
"error", "七日年化收益率为空");
return false;
} else if (annualincomeRegex.test(annualincome) === false) {
show_validate_msg("#annualincome_add_input",
"error", "七日年化收益率不合法(正数、负数、和小数)");
return false;
}
//匹配有1~2位小数的正实数
var peiincomeRegex = /^[0-9]+(.[0-9]{1,2})?$/;
if (peiincome.length === 0) {
show_validate_msg("#peiincome_add_input",
"error", "每万元收益为空");
return false;
} else if (peiincomeRegex.test(peiincome) === false) {
show_validate_msg("#peiincome_add_input",
"error", "每万元收益不合法(有1~2位小数的正实数)");
return false;
}
//匹配有1~2位小数的正实数
var invesmoneyRegex = /^[0-9]+(.[0-9]{1,2})?$/;
if (invesmoney.length === 0) {
show_validate_msg("#invesmoney_add_input",
"error", "起投金额为空");
return false;
} else if (invesmoneyRegex.test(invesmoney) === false) {
show_validate_msg("#invesmoney_add_input",
"error", "起投金额不合法(有1~2位小数的正实数)");
return false;
}
//匹配中文、英文、数字包括下划线
var investermRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (investerm.length === 0) {
show_validate_msg("#investerm_add_input",
"error", "投资期限为空");
return false;
} else if (investermRegex.test(investerm) === false) {
show_validate_msg("#investerm_add_input",
"error", "投资期限不合法");
return false;
}
//2、发送ajax请求保存产品
$.ajax({
url: "/admin/addChangeMoney",
type: "POST",
data: $("#addModal form").serialize(),
success: function (result) {
if (result.code === 100) {
$("#addModal").modal('hide');
$.alert('零钱理财产品新增成功!');
setTimeout(function () {
var pageNum = [[${finacnePageInfo.pages}]];
var pageSize = [[${finacnePageInfo.pageSize}]];
location.href = "/admin/finance/toChangeMoney.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('零钱理财产品新增失败!');
}
}
});
});
//点击编辑按钮时触发事件
$(document).on("click", ".update_btn", function () {
//根据用户id发送ajax请求,查出信息并显示
getFinanceInfo($(this).attr("update-id"));
//把用户的id传递给模态框的更新按钮
$("#update_btn").attr("update-id", $(this).attr("update-id"));
$("#updateModal").modal({
backdrop: "static"
});
});
//根据id查出信息并显示
function getFinanceInfo(id) {
$.ajax({
url: "/admin/getChangeMoneyInfoById/" + id,
type: "GET",
success: function (result) {
var changeMoney = result.extend.changeMoney;
//显示数据之前先清除一下校验样式,如果有的话
reset_form("#updateModal form");
$("#name_update_input").val(changeMoney.name);
$("#annualincome_update_input").val(changeMoney.annualincome);
$("#peiincome_update_input").val(changeMoney.peiincome);
$("#invesmoney_update_input").val(changeMoney.invesmoney);
$("#investerm_update_input").val(changeMoney.investerm);
}
});
}
//点击更新,更新信息
$("#update_btn").click(function () {
//清空表单样式
clean_form("#updateModal form");
var name = $("#name_update_input").val();
var annualincome = $("#annualincome_update_input").val();
var peiincome = $("#peiincome_update_input").val();
var invesmoney = $("#invesmoney_update_input").val();
var investerm = $("#investerm_update_input").val();
//匹配中文、英文、数字包括下划线(理财产品名称)
var nameRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (name.length === 0) {
show_validate_msg("#name_update_input",
"error", "产品名称为空");
return false;
} else if (nameRegex.test(name) === false) {
show_validate_msg("#name_update_input",
"error", "产品名称不合法(产品名称只能由中文、数字、英文和下划线组成)");
return false;
}
//匹配正数、负数、和小数
var annualincomeRegex = /^(\-|\+)?\d+(\.\d+)?$/;
if (annualincome.length === 0) {
show_validate_msg("#annualincome_update_input",
"error", "七日年化收益率为空");
return false;
} else if (annualincomeRegex.test(annualincome) === false) {
show_validate_msg("#annualincome_update_input",
"error", "七日年化收益率不合法(正数、负数、和小数)");
return false;
}
//匹配有1~2位小数的正实数
var peiincomeRegex = /^[0-9]+(.[0-9]{1,2})?$/;
if (peiincome.length === 0) {
show_validate_msg("#peiincome_update_input",
"error", "每万元收益为空");
return false;
} else if (peiincomeRegex.test(peiincome) === false) {
show_validate_msg("#peiincome_update_input",
"error", "每万元收益不合法(有1~2位小数的正实数)");
return false;
}
//匹配有1~2位小数的正实数
var invesmoneyRegex = /^[0-9]+(.[0-9]{1,2})?$/;
if (invesmoney.length === 0) {
show_validate_msg("#invesmoney_update_input",
"error", "起投金额为空");
return false;
} else if (invesmoneyRegex.test(invesmoney) === false) {
show_validate_msg("#invesmoney_update_input",
"error", "起投金额不合法(有1~2位小数的正实数)");
return false;
}
//匹配中文、英文、数字包括下划线
var investermRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (investerm.length === 0) {
show_validate_msg("#investerm_update_input",
"error", "投资期限为空");
return false;
} else if (investermRegex.test(investerm) === false) {
show_validate_msg("#investerm_update_input",
"error", "投资期限不合法");
return false;
}
//2、发送ajax请求保存更新的理财产品数据
$.ajax({
url: "/admin/updateChangeMoney/" + $(this).attr("update-id"),
type: "PUT",
data: $("#updateModal form").serialize(),
success: function (result) {
if (result.code === 100) {
$("#updateModal").modal('hide');
$.alert('零钱理财产品信息修改成功!');
setTimeout(function () {
var pageNum = [[${finacnePageInfo.pageNum}]];
var pageSize = [[${finacnePageInfo.pageSize}]];
location.href = "/admin/finance/toChangeMoney.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('零钱理财产品信息修改失败!');
}
}
});
});
//单个删除
$(document).on("click", ".delete_btn", function () {
//1、弹出是否确认删除对话框
var id = $(this).attr("delete-id");
var username = $(this).attr("delete-name");
$.alert({
title: '提示:',
content: "确定删除零钱理财产品 <strong>" + username + "</strong> 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/admin/deleteChangeMoneyById/" + id,
type: "DELETE",
success: function (result) {
if (result.code === 100) {
$.alert('删除该零钱理财产品成功!');
setTimeout(function () {
var pageNum = [[${finacnePageInfo.pageNum}]];
var pageSize = [[${finacnePageInfo.pageSize}]];
location.href = "/admin/finance/toChangeMoney.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('删除该零钱理财产品失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
});
//清空表单样式及内容
function reset_form(ele) {
$(ele)[0].reset();
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//清空表单样式
function clean_form(ele) {
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//显示校验结果的提示信息
function show_validate_msg(ele, status, msg) {
//清除当前元素的校验状态
$(ele).parent().removeClass("has-success has-error");
$(ele).next("span").text("");
if ("success" === status) {
$(ele).parent().addClass("has-success");
$(ele).next("span").text(msg);
} else if ("error" === status) {
$(ele).parent().addClass("has-error");
$(ele).next("span").text(msg);
}
}
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/admin/finance/changemoney.html
|
HTML
|
mit
| 35,375
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>后台管理系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="admin/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="admin/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>基金理财管理</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">基金代码</th>
<th class="info">基金简称</th>
<th class="info">基金类型</th>
<th class="info">日增长率</th>
<th class="info">月增长率</th>
<th class="info">年增长率</th>
<th class="info">起投金额</th>
<th class="info">投资期限</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="finance:${financeList}">
<td th:text="${(finacnePageInfo.pageNum - 1) * finacnePageInfo.pageSize+financeStat.index+1}"></td>
<td th:text="${finance.code}"></td>
<td th:text="${finance.funddesc}"></td>
<td th:if="${finance.type==1}" th:text="股票型基金"></td><td th:if="${finance.type==2}" th:text="债券型基金"></td>
<td th:if="${finance.type==3}" th:text="货币型基金"></td><td th:if="${finance.type==4}" th:text="混合型基金"></td>
<td th:text="${#numbers.formatDecimal(finance.dailygrowth*100,1,2)}+'%'"></td>
<td th:text="${#numbers.formatDecimal(finance.monthlygrowth*100,1,2)}+'%'"></td>
<td th:text="${#numbers.formatDecimal(finance.annualgrowth*100,1,2)}+'%'"></td>
<td th:text="${#numbers.formatDecimal(finance.leastmoney,1,2)}+'元'"></td>
<td th:text="${finance.investerm}"></td>
<td>
<button class="btn btn-primary btn-sm update_btn"
th:attr="update-id=${finance.id}">
<span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span> 编辑
</button>
<button class="btn btn-danger btn-sm delete_btn"
th:attr="delete-id=${finance.id},delete-name=${finance.funddesc}">
<span class="glyphicon glyphicon-trash"
aria-hidden="true"></span> 删除
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- 显示分页信息 -->
<div class="row">
<!-- 新增按钮 -->
<div class="col-md-1" style="margin-left: 24px">
<button id="add_modal_btn" class="btn btn-primary">新增</button>
</div>
<div class="col-md-5">
<div class="btn-group">
<button class="btn btn-default">
<span>页次:</span>
</button>
<button class="btn btn-default">
<span th:text="${finacnePageInfo.pageNum}+'/'+${finacnePageInfo.pages}+'页'"></span>
</button>
<button class="btn btn-default">
<span>每页显示:</span>
</button>
<div class="btn-group">
<button id="btnGroupDrop1"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"><span
th:text="${finacnePageInfo.pageSize}"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li th:each="i:${#numbers.sequence(1,10)}">
<a th:text="${i}"
th:href="@{/admin/finance/toFundProduct.html(pageNum=${finacnePageInfo.pageNum},pageSize=${i})}"></a>
</li>
</ul>
</div>
<button class="btn btn-default">
<span>条</span>
</button>
<button class="btn btn-default">
<span>总记录数:</span>
</button>
<button class="btn btn-default">
<span th:text="${finacnePageInfo.total}+'条'"></span>
</button>
</div>
</div>
<!-- 分页条信息 -->
<div class="col-md-5">
<nav aria-label="Page navigation">
<ul class="pagination pagination-lg pull-right"
style="margin-top: 0">
<li>
<a th:href="@{/admin/finance/toFundProduct.html(pageNum=1,pageSize=${finacnePageInfo.pageSize})}">首页</a>
</li>
<li th:if="${finacnePageInfo.hasPreviousPage }"><a
th:href="@{/admin/finance/toFundProduct.html(pageNum=${finacnePageInfo.pageNum}-1,pageSize=${finacnePageInfo.pageSize})}"
aria-label="Previous"> <span aria-hidden="true">«</span>
</a></li>
<li th:each="page_Num:${finacnePageInfo.navigatepageNums }"
th:class="${page_Num == finacnePageInfo.pageNum?'active':''}">
<a th:if="${page_Num == finacnePageInfo.pageNum}"
th:text="${page_Num}"
th:href="@{#}">
</a>
<a th:text="${page_Num}"
th:if="${page_Num != finacnePageInfo.pageNum}"
th:href="@{/admin/finance/toFundProduct.html(pageNum=${page_Num},pageSize=${finacnePageInfo.pageSize})}">
</a>
</li>
<li th:if="${finacnePageInfo.hasNextPage }"><a
th:href="@{/admin/finance/toFundProduct.html(pageNum=${finacnePageInfo.pageNum}+1,pageSize=${finacnePageInfo.pageSize})}"
aria-label="Next"> <span aria-hidden="true">»</span>
</a></li>
<li><a
th:href="@{/admin/finance/toFundProduct.html(pageNum=${finacnePageInfo.pages},pageSize=${finacnePageInfo.pageSize})}">末页</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<!-- 新增理财的模态框 -->
<div class="modal fade" id="addModal" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">新增期限理财产品</h4>
</div>
<div class="modal-body">
<!--要提交的表单 -->
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">基金代码:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="code_add_input" name="code"
placeholder="请输入基金代码:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">基金简称:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="funddesc_add_input" name="funddesc"
placeholder="请输入基金简称:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">基金类型:</label>
<div class="col-sm-6">
<select class="form-control" name="type">
<option value="1" selected>股票型</option>
<option value="2" >债券型</option>
<option value="3" >货币型</option>
<option value="4" >混合型</option>
</select>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">日增长率:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="dailygrowth_add_input" name="dailygrowth"
placeholder="请输入日增长率:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">月增长率:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="monthlygrowth_add_input" name="monthlygrowth"
placeholder="请输入月增长率:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">年增长率:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="annualgrowth_add_input" name="annualgrowth"
placeholder="请输入年增长率:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">起投金额:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="leastmoney_add_input" name="leastmoney"
placeholder="请输入起投金额:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">投资期限:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="investerm_add_input" name="investerm"
placeholder="请输入投资期限:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary"
id="save_btn">保存
</button>
</div>
</div>
</div>
</div>
<!-- 修改理财的模态框 -->
<div class="modal fade" id="updateModal" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">修改基金理财产品信息</h4>
</div>
<div class="modal-body">
<!--要提交的表单 -->
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">基金代码:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="code_update_input" name="code"
placeholder="请输入基金代码:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">基金简称:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="funddesc_update_input" name="funddesc"
placeholder="请输入基金简称:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">基金类型:</label>
<div class="col-sm-6">
<select id="type_update_input" class="form-control" name="type">
<option value="1" selected>股票型</option>
<option value="2" >债券型</option>
<option value="3" >货币型</option>
<option value="4" >混合型</option>
</select>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">日增长率:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="dailygrowth_update_input" name="dailygrowth"
placeholder="请输入日增长率:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">月增长率:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="monthlygrowth_update_input" name="monthlygrowth"
placeholder="请输入月增长率:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">年增长率:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="annualgrowth_update_input" name="annualgrowth"
placeholder="请输入年增长率:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">起投金额:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="leastmoney_update_input" name="leastmoney"
placeholder="请输入起投金额:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">投资期限:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="investerm_update_input" name="investerm"
placeholder="请输入投资期限:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary"
id="update_btn">更新
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
//点击新增按钮弹出模态框。
$("#add_modal_btn").click(function () {
//清除表单数据(表单完整重置(表单的数据,表单的样式))
reset_form("#addModal form");
//弹出模态框
$("#addModal").modal({
//点击增加框背景不删除增加框
backdrop: "static"
});
});
//点击保存,保存新增产品信息。
$("#save_btn").click(function () {
//清空表单样式
clean_form("#addModal form");
var code = $("#code_add_input").val();
var funddesc = $("#funddesc_add_input").val();
var dailygrowth = $("#dailygrowth_add_input").val();
var monthlygrowth = $("#monthlygrowth_add_input").val();
var annualgrowth = $("#annualgrowth_add_input").val();
var leastmoney = $("#leastmoney_add_input").val();
var investerm = $("#investerm_add_input").val();
//匹配 m-n位的数字
var codeRegex = /^\d{6,8}$/;
if (code.length === 0) {
show_validate_msg("#code_add_input",
"error", "基金代码为空");
return false;
} else if (codeRegex.test(code) === false) {
show_validate_msg("#code_add_input",
"error", "基金代码不合法(6-8位数字)");
return false;
}
//匹配中文、英文、数字包括下划线
var funddescRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (funddesc.length === 0) {
show_validate_msg("#funddesc_add_input",
"error", "基金简介为空");
return false;
} else if (funddescRegex.test(funddesc) === false) {
show_validate_msg("#funddesc_add_input",
"error", "基金简介不合法");
return false;
}
//匹配正数、负数、和小数
var dailygrowthRegex = /^(\-|\+)?\d+(\.\d+)?$/;
if (dailygrowth.length === 0) {
show_validate_msg("#dailygrowth_add_input",
"error", "日增长率为空");
return false;
} else if (dailygrowthRegex.test(dailygrowth) === false) {
show_validate_msg("#dailygrowth_add_input",
"error", "日增长率不合法(正数、负数、和小数)");
return false;
}
//匹配正数、负数、和小数
var monthlygrowthRegex = /^(\-|\+)?\d+(\.\d+)?$/;
if (monthlygrowth.length === 0) {
show_validate_msg("#monthlygrowth_add_input",
"error", "月增长率为空");
return false;
} else if (monthlygrowthRegex.test(monthlygrowth) === false) {
show_validate_msg("#monthlygrowth_add_input",
"error", "月增长率不合法(正数、负数、和小数)");
return false;
}
//匹配正数、负数、和小数
var annualgrowthRegex = /^(\-|\+)?\d+(\.\d+)?$/;
if (annualgrowth.length === 0) {
show_validate_msg("#annualgrowth_add_input",
"error", "年增长率为空");
return false;
} else if (annualgrowthRegex.test(annualgrowth) === false) {
show_validate_msg("#annualgrowth_add_input",
"error", "年增长率不合法(正数、负数、和小数)");
return false;
}
//匹配有1~2位小数的正实数
var leastmoneyRegex = /^[0-9]+(.[0-9]{1,2})?$/;
if (leastmoney.length === 0) {
show_validate_msg("#leastmoney_add_input",
"error", "起投金额为空");
return false;
} else if (leastmoneyRegex.test(leastmoney) === false) {
show_validate_msg("#leastmoney_add_input",
"error", "起投金额不合法(有1~2位小数的正实数)");
return false;
}
//匹配中文、英文、数字包括下划线
var investermRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (investerm.length === 0) {
show_validate_msg("#investerm_add_input",
"error", "投资期限为空");
return false;
} else if (investermRegex.test(investerm) === false) {
show_validate_msg("#investerm_add_input",
"error", "投资期限不合法");
return false;
}
//2、发送ajax请求保存产品
$.ajax({
url: "/admin/addFundProduct",
type: "POST",
data: $("#addModal form").serialize(),
success: function (result) {
if (result.code === 100) {
$("#addModal").modal('hide');
$.alert('基金理财产品添加成功!');
setTimeout(function () {
var pageNum = [[${finacnePageInfo.pages}]];
var pageSize = [[${finacnePageInfo.pageSize}]];
location.href = "/admin/finance/toFundProduct.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('基金理财产品添加失败!');
}
}
});
});
//点击编辑按钮时触发事件
$(document).on("click", ".update_btn", function () {
//根据用户id发送ajax请求,查出信息并显示
getFinanceInfo($(this).attr("update-id"));
//把用户的id传递给模态框的更新按钮
$("#update_btn").attr("update-id", $(this).attr("update-id"));
$("#updateModal").modal({
backdrop: "static"
});
});
//根据id查出信息并显示
function getFinanceInfo(id) {
$.ajax({
url: "/admin/getFundProductInfoById/" + id,
type: "GET",
success: function (result) {
var fundProduct = result.extend.fundProduct;
//显示数据之前先清除一下校验样式,如果有的话
reset_form("#updateModal form");
$("#code_update_input").val(fundProduct.code);
$("#funddesc_update_input").val(fundProduct.funddesc);
$("#type_update_input").val([ fundProduct.type ]);
$("#annualgrowth_update_input").val(fundProduct.annualgrowth);
$("#dailygrowth_update_input").val(fundProduct.dailygrowth);
$("#monthlygrowth_update_input").val(fundProduct.monthlygrowth);
$("#leastmoney_update_input").val(fundProduct.leastmoney);
$("#investerm_update_input").val(fundProduct.investerm);
}
});
}
//点击更新,更新信息
$("#update_btn").click(function () {
//清空表单样式
clean_form("#updateModal form");
var code = $("#code_update_input").val();
var funddesc = $("#funddesc_update_input").val();
var dailygrowth = $("#dailygrowth_update_input").val();
var monthlygrowth = $("#monthlygrowth_update_input").val();
var annualgrowth = $("#annualgrowth_update_input").val();
var leastmoney = $("#leastmoney_update_input").val();
var investerm = $("#investerm_update_input").val();
//匹配 m-n位的数字
var codeRegex = /^\d{6,8}$/;
if (code.length === 0) {
show_validate_msg("#code_update_input",
"error", "基金代码为空");
return false;
} else if (codeRegex.test(code) === false) {
show_validate_msg("#code_update_input",
"error", "基金代码不合法(6-8位数字)");
return false;
}
//匹配中文、英文、数字包括下划线
var funddescRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (funddesc.length === 0) {
show_validate_msg("#funddesc_update_input",
"error", "基金简介为空");
return false;
} else if (funddescRegex.test(funddesc) === false) {
show_validate_msg("#funddesc_update_input",
"error", "基金简介不合法");
return false;
}
//匹配正数、负数、和小数
var dailygrowthRegex = /^(\-|\+)?\d+(\.\d+)?$/;
if (dailygrowth.length === 0) {
show_validate_msg("#dailygrowth_update_input",
"error", "日增长率为空");
return false;
} else if (dailygrowthRegex.test(dailygrowth) === false) {
show_validate_msg("#dailygrowth_update_input",
"error", "日增长率不合法(正数、负数、和小数)");
return false;
}
//匹配正数、负数、和小数
var monthlygrowthRegex = /^(\-|\+)?\d+(\.\d+)?$/;
if (monthlygrowth.length === 0) {
show_validate_msg("#monthlygrowth_update_input",
"error", "月增长率为空");
return false;
} else if (monthlygrowthRegex.test(monthlygrowth) === false) {
show_validate_msg("#monthlygrowth_update_input",
"error", "月增长率不合法(正数、负数、和小数)");
return false;
}
//匹配正数、负数、和小数
var annualgrowthRegex = /^(\-|\+)?\d+(\.\d+)?$/;
if (annualgrowth.length === 0) {
show_validate_msg("#annualgrowth_update_input",
"error", "年增长率为空");
return false;
} else if (annualgrowthRegex.test(annualgrowth) === false) {
show_validate_msg("#annualgrowth_update_input",
"error", "年增长率不合法(正数、负数、和小数)");
return false;
}
//匹配有1~2位小数的正实数
var leastmoneyRegex = /^[0-9]+(.[0-9]{1,2})?$/;
if (leastmoney.length === 0) {
show_validate_msg("#leastmoney_update_input",
"error", "起投金额为空");
return false;
} else if (leastmoneyRegex.test(leastmoney) === false) {
show_validate_msg("#leastmoney_update_input",
"error", "起投金额不合法(有1~2位小数的正实数)");
return false;
}
//匹配中文、英文、数字包括下划线
var investermRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (investerm.length === 0) {
show_validate_msg("#investerm_update_input",
"error", "投资期限为空");
return false;
} else if (investermRegex.test(investerm) === false) {
show_validate_msg("#investerm_update_input",
"error", "投资期限不合法");
return false;
}
//2、发送ajax请求保存更新的理财产品数据
$.ajax({
url: "/admin/updateFundProduct/" + $(this).attr("update-id"),
type: "PUT",
data: $("#updateModal form").serialize(),
success: function (result) {
if (result.code === 100) {
$("#updateModal").modal('hide');
$.alert('基金理财产品信息修改成功!');
setTimeout(function () {
var pageNum = [[${finacnePageInfo.pageNum}]];
var pageSize = [[${finacnePageInfo.pageSize}]];
location.href = "/admin/finance/toFundProduct.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('基金理财产品信息修改失败!');
}
}
});
});
//单个删除
$(document).on("click", ".delete_btn", function () {
//1、弹出是否确认删除对话框
var id = $(this).attr("delete-id");
var name = $(this).attr("delete-name");
$.alert({
title: '提示:',
content: "确定删除基金理财产品 <strong>" + name + "</strong> 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/admin/deleteFundProductById/" + id,
type: "DELETE",
success: function (result) {
if (result.code === 100) {
$.alert('删除该基金理财产品成功!');
setTimeout(function () {
var pageNum = [[${finacnePageInfo.pageNum}]];
var pageSize = [[${finacnePageInfo.pageSize}]];
location.href = "/admin/finance/toFundProduct.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('删除该基金理财产品失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
});
//清空表单样式及内容
function reset_form(ele) {
$(ele)[0].reset();
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//清空表单样式
function clean_form(ele) {
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//显示校验结果的提示信息
function show_validate_msg(ele, status, msg) {
//清除当前元素的校验状态
$(ele).parent().removeClass("has-success has-error");
$(ele).next("span").text("");
if ("success" === status) {
$(ele).parent().addClass("has-success");
$(ele).next("span").text(msg);
} else if ("error" === status) {
$(ele).parent().addClass("has-error");
$(ele).next("span").text(msg);
}
}
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/admin/finance/fundproduct.html
|
HTML
|
mit
| 44,070
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>后台管理系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="admin/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="admin/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>工资理财管理</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">产品类型</th>
<th class="info">每月金额设定</th>
<th class="info">自动转入</th>
<th class="info">投资期限</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="finance:${financeList}">
<td th:text="${(finacnePageInfo.pageNum - 1) * finacnePageInfo.pageSize+financeStat.index+1}"></td>
<td th:if="${finance.type==1}" th:text="国债"></td>
<td th:if="${finance.type==2}" th:text="期货"></td>
<td th:text="${#numbers.formatDecimal(finance.monthmoney,1,2)}"></td>
<td th:if="${finance.autointo==1}" th:text="是"></td>
<td th:if="${finance.autointo==2}" th:text="否"></td>
<td th:text="${finance.investerm}"></td>
<td>
<button class="btn btn-primary btn-sm update_btn"
th:attr="update-id=${finance.id}">
<span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span> 编辑
</button>
<button class="btn btn-danger btn-sm delete_btn"
th:attr="delete-id=${finance.id},delete-name=${finance.type}">
<span class="glyphicon glyphicon-trash"
aria-hidden="true"></span> 删除
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- 显示分页信息 -->
<div class="row">
<!-- 新增按钮 -->
<div class="col-md-1" style="margin-left: 24px">
<button id="add_modal_btn" class="btn btn-primary">新增</button>
</div>
<div class="col-md-5">
<div class="btn-group">
<button class="btn btn-default">
<span>页次:</span>
</button>
<button class="btn btn-default">
<span th:text="${finacnePageInfo.pageNum}+'/'+${finacnePageInfo.pages}+'页'"></span>
</button>
<button class="btn btn-default">
<span>每页显示:</span>
</button>
<div class="btn-group">
<button id="btnGroupDrop1"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"><span
th:text="${finacnePageInfo.pageSize}"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li th:each="i:${#numbers.sequence(1,10)}">
<a th:text="${i}"
th:href="@{/admin/finance/toPayMoney.html(pageNum=${finacnePageInfo.pageNum},pageSize=${i})}"></a>
</li>
</ul>
</div>
<button class="btn btn-default">
<span>条</span>
</button>
<button class="btn btn-default">
<span>总记录数:</span>
</button>
<button class="btn btn-default">
<span th:text="${finacnePageInfo.total}+'条'"></span>
</button>
</div>
</div>
<!-- 分页条信息 -->
<div class="col-md-5">
<nav aria-label="Page navigation">
<ul class="pagination pagination-lg pull-right"
style="margin-top: 0">
<li>
<a th:href="@{/admin/finance/toPayMoney.html(pageNum=1,pageSize=${finacnePageInfo.pageSize})}">首页</a>
</li>
<li th:if="${finacnePageInfo.hasPreviousPage }"><a
th:href="@{/admin/finance/toPayMoney.html(pageNum=${finacnePageInfo.pageNum}-1,pageSize=${finacnePageInfo.pageSize})}"
aria-label="Previous"> <span aria-hidden="true">«</span>
</a></li>
<li th:each="page_Num:${finacnePageInfo.navigatepageNums }"
th:class="${page_Num == finacnePageInfo.pageNum?'active':''}">
<a th:if="${page_Num == finacnePageInfo.pageNum}"
th:text="${page_Num}"
th:href="@{#}">
</a>
<a th:text="${page_Num}"
th:if="${page_Num != finacnePageInfo.pageNum}"
th:href="@{/admin/finance/toPayMoney.html(pageNum=${page_Num},pageSize=${finacnePageInfo.pageSize})}">
</a>
</li>
<li th:if="${finacnePageInfo.hasNextPage }"><a
th:href="@{/admin/finance/toPayMoney.html(pageNum=${finacnePageInfo.pageNum}+1,pageSize=${finacnePageInfo.pageSize})}"
aria-label="Next"> <span aria-hidden="true">»</span>
</a></li>
<li><a
th:href="@{/admin/finance/toPayMoney.html(pageNum=${finacnePageInfo.pages},pageSize=${finacnePageInfo.pageSize})}">末页</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<!-- 新增工资理财的模态框 -->
<div class="modal fade" id="addModal" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">新增工资理财产品</h4>
</div>
<div class="modal-body">
<!--要提交的表单 -->
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">产品类型:</label>
<div class="col-sm-6">
<div class="example-box">
<label class="lyear-radio radio-inline">
<input type="radio" name="type"
value="1" checked="checked"><span>国债</span>
</label>
<label class="lyear-radio radio-inline">
<input type="radio" name="type" id="type_add_input"
value="2"> <span>期货</span>
</label>
</div>
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">每月金额设定(元):</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="monthmoney_add_input" name="monthmoney"
placeholder="请输入每月转入的金额:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">自动转入:</label>
<div class="col-sm-6">
<div class="example-box">
<label class="lyear-radio radio-inline">
<input type="radio" name="autointo"
value="1" checked="checked"><span>是</span>
</label>
<label class="lyear-radio radio-inline">
<input type="radio" name="autointo"
value="2"> <span>否</span>
</label>
</div>
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">投资期限:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="investerm_add_input" name="investerm"
placeholder="请输入投资期限:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary"
id="save_btn">保存
</button>
</div>
</div>
</div>
</div>
<!-- 修改用户的模态框 -->
<div class="modal fade" id="updateModal" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">修改零钱理财产品信息</h4>
</div>
<div class="modal-body">
<!--要提交的表单 -->
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">产品类型:</label>
<div class="col-sm-6">
<div class="example-box">
<label class="lyear-radio radio-inline">
<input type="radio" name="type"
value="1" checked="checked"><span>国债</span>
</label>
<label class="lyear-radio radio-inline">
<input type="radio" name="type"
value="2"> <span>期货</span>
</label>
</div>
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">每月金额设定(元):</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="monthmoney_update_input" name="monthmoney"
placeholder="请输入每月转入的金额:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">自动转入:</label>
<div class="col-sm-6">
<div class="example-box">
<label class="lyear-radio radio-inline">
<input type="radio" name="autointo"
value="1" checked="checked"><span>是</span>
</label>
<label class="lyear-radio radio-inline">
<input type="radio" name="autointo"
value="2"> <span>否</span>
</label>
</div>
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">投资期限:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="investerm_update_input" name="investerm"
placeholder="请输入投资期限:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary"
id="update_btn">更新
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
//点击新增按钮弹出模态框。
$("#add_modal_btn").click(function () {
//清除表单数据(表单完整重置(表单的数据,表单的样式))
reset_form("#addModal form");
//弹出模态框
$("#addModal").modal({
//点击增加框背景不删除增加框
backdrop: "static"
});
});
//点击保存,保存新增产品信息。
$("#save_btn").click(function () {
//清空表单样式
clean_form("#addModal form");
var monthmoney = $("#monthmoney_add_input").val();
var investerm = $("#investerm_add_input").val();
//匹配有1~2位小数的正实数
var monthmoneyRegex = /^[0-9]+(.[0-9]{1,2})?$/;
if (monthmoney.length === 0) {
show_validate_msg("#monthmoney_add_input",
"error", "每月转入金额为空");
return false;
} else if (monthmoneyRegex.test(monthmoney) === false) {
show_validate_msg("#monthmoney_add_input",
"error", "每月转入金额不合法(有1~2位小数的正实数)");
return false;
}
//匹配中文、英文、数字包括下划线
var investermRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (investerm.length === 0) {
show_validate_msg("#investerm_add_input",
"error", "投资期限为空");
return false;
} else if (investermRegex.test(investerm) === false) {
show_validate_msg("#investerm_add_input",
"error", "投资期限不合法");
return false;
}
//2、发送ajax请求保存产品
$.ajax({
url: "/admin/addPayMoney",
type: "POST",
data: $("#addModal form").serialize(),
success: function (result) {
if (result.code === 100) {
$("#addModal").modal('hide');
$.alert('工资理财产品添加成功!');
setTimeout(function () {
var pageNum = [[${finacnePageInfo.pages}]];
var pageSize = [[${finacnePageInfo.pageSize}]];
location.href = "/admin/finance/toPayMoney.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('工资理财产品添加失败!');
}
}
});
});
//点击编辑按钮时触发事件
$(document).on("click", ".update_btn", function () {
//根据用户id发送ajax请求,查出信息并显示
getFinanceInfo($(this).attr("update-id"));
//把用户的id传递给模态框的更新按钮
$("#update_btn").attr("update-id", $(this).attr("update-id"));
$("#updateModal").modal({
backdrop: "static"
});
});
//根据id查出信息并显示
function getFinanceInfo(id) {
$.ajax({
url: "/admin/getPayMoneyInfoById/" + id,
type: "GET",
success: function (result) {
var payMoney = result.extend.payMoney;
//显示数据之前先清除一下校验样式,如果有的话
reset_form("#updateModal form");
$("#updateModal input[name=type]").val(
[ payMoney.type ]);
$("#monthmoney_update_input").val(payMoney.monthmoney);
$("#updateModal input[name=autointo]").val(
[ payMoney.autointo ]);
$("#investerm_update_input").val(payMoney.investerm);
}
});
}
//点击更新,更新信息
$("#update_btn").click(function () {
//清空表单样式
clean_form("#updateModal form");
var monthmoney = $("#monthmoney_update_input").val();
var investerm = $("#investerm_update_input").val();
//匹配有1~2位小数的正实数
var monthmoneyRegex = /^[0-9]+(.[0-9]{1,2})?$/;
if (monthmoney.length === 0) {
show_validate_msg("#monthmoney_update_input",
"error", "每月转入金额为空");
return false;
} else if (monthmoneyRegex.test(monthmoney) === false) {
show_validate_msg("#monthmoney_update_input",
"error", "每月转入金额不合法(有1~2位小数的正实数)");
return false;
}
//匹配中文、英文、数字包括下划线
var investermRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (investerm.length === 0) {
show_validate_msg("#investerm_update_input",
"error", "投资期限为空");
return false;
} else if (investermRegex.test(investerm) === false) {
show_validate_msg("#investerm_update_input",
"error", "投资期限不合法");
return false;
}
//2、发送ajax请求保存更新的理财产品数据
$.ajax({
url: "/admin/updatePayMoney/" + $(this).attr("update-id"),
type: "PUT",
data: $("#updateModal form").serialize(),
success: function (result) {
if (result.code === 100) {
$("#updateModal").modal('hide');
$.alert('工资理财产品信息修改成功!');
setTimeout(function () {
var pageNum = [[${finacnePageInfo.pageNum}]];
var pageSize = [[${finacnePageInfo.pageSize}]];
location.href = "/admin/finance/toPayMoney.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('工资理财产品信息修改失败!');
}
}
});
});
//单个删除
$(document).on("click", ".delete_btn", function () {
//1、弹出是否确认删除对话框
var id = $(this).attr("delete-id");
var type = $(this).attr("delete-name");
var name;
if (type==1){
name="国债";
}else if(type==2){
name="期货";
}
$.alert({
title: '提示:',
content: "确定删除该 <strong>" + name + "</strong> 工资理财产品吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/admin/deletePayMoneyById/" + id,
type: "DELETE",
success: function (result) {
if (result.code === 100) {
$.alert('删除该工资理财产品成功!');
setTimeout(function () {
var pageNum = [[${finacnePageInfo.pageNum}]];
var pageSize = [[${finacnePageInfo.pageSize}]];
location.href = "/admin/finance/toPayMoney.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('删除该工资理财产品失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
});
//清空表单样式及内容
function reset_form(ele) {
$(ele)[0].reset();
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//清空表单样式
function clean_form(ele) {
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//显示校验结果的提示信息
function show_validate_msg(ele, status, msg) {
//清除当前元素的校验状态
$(ele).parent().removeClass("has-success has-error");
$(ele).next("span").text("");
if ("success" === status) {
$(ele).parent().addClass("has-success");
$(ele).next("span").text(msg);
} else if ("error" === status) {
$(ele).parent().addClass("has-error");
$(ele).next("span").text(msg);
}
}
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/admin/finance/paymoney.html
|
HTML
|
mit
| 32,279
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>后台管理系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="admin/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="admin/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>期限理财管理</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">产品名称</th>
<th class="info">起投金额</th>
<th class="info">收益方式</th>
<th class="info">七日年化收益率</th>
<th class="info">投资期限</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="finance:${financeList}">
<td th:text="${(finacnePageInfo.pageNum - 1) * finacnePageInfo.pageSize+financeStat.index+1}"></td>
<td th:text="${finance.name}"></td>
<td th:text="${#numbers.formatDecimal(finance.leastmoney,1,2)}+'元'"></td>
<td th:if="${finance.profit==1}" th:text="收益型"></td>
<td th:if="${finance.profit==2}" th:text="净值型"></td>
<td th:text="${#numbers.formatDecimal(finance.annualincome*100,1,3)}+'%'"></td>
<td th:text="${finance.investerm}"></td>
<td>
<button class="btn btn-primary btn-sm update_btn"
th:attr="update-id=${finance.id}">
<span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span> 编辑
</button>
<button class="btn btn-danger btn-sm delete_btn"
th:attr="delete-id=${finance.id},delete-name=${finance.name}">
<span class="glyphicon glyphicon-trash"
aria-hidden="true"></span> 删除
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- 显示分页信息 -->
<div class="row">
<!-- 新增按钮 -->
<div class="col-md-1" style="margin-left: 24px">
<button id="add_modal_btn" class="btn btn-primary">新增</button>
</div>
<div class="col-md-5">
<div class="btn-group">
<button class="btn btn-default">
<span>页次:</span>
</button>
<button class="btn btn-default">
<span th:text="${finacnePageInfo.pageNum}+'/'+${finacnePageInfo.pages}+'页'"></span>
</button>
<button class="btn btn-default">
<span>每页显示:</span>
</button>
<div class="btn-group">
<button id="btnGroupDrop1"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"><span
th:text="${finacnePageInfo.pageSize}"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li th:each="i:${#numbers.sequence(1,10)}">
<a th:text="${i}"
th:href="@{/admin/finance/toTermFinancial.html(pageNum=${finacnePageInfo.pageNum},pageSize=${i})}"></a>
</li>
</ul>
</div>
<button class="btn btn-default">
<span>条</span>
</button>
<button class="btn btn-default">
<span>总记录数:</span>
</button>
<button class="btn btn-default">
<span th:text="${finacnePageInfo.total}+'条'"></span>
</button>
</div>
</div>
<!-- 分页条信息 -->
<div class="col-md-5">
<nav aria-label="Page navigation">
<ul class="pagination pagination-lg pull-right"
style="margin-top: 0">
<li>
<a th:href="@{/admin/finance/toTermFinancial.html(pageNum=1,pageSize=${finacnePageInfo.pageSize})}">首页</a>
</li>
<li th:if="${finacnePageInfo.hasPreviousPage }"><a
th:href="@{/admin/finance/toTermFinancial.html(pageNum=${finacnePageInfo.pageNum}-1,pageSize=${finacnePageInfo.pageSize})}"
aria-label="Previous"> <span aria-hidden="true">«</span>
</a></li>
<li th:each="page_Num:${finacnePageInfo.navigatepageNums }"
th:class="${page_Num == finacnePageInfo.pageNum?'active':''}">
<a th:if="${page_Num == finacnePageInfo.pageNum}"
th:text="${page_Num}"
th:href="@{#}">
</a>
<a th:text="${page_Num}"
th:if="${page_Num != finacnePageInfo.pageNum}"
th:href="@{/admin/finance/toTermFinancial.html(pageNum=${page_Num},pageSize=${finacnePageInfo.pageSize})}">
</a>
</li>
<li th:if="${finacnePageInfo.hasNextPage }"><a
th:href="@{/admin/finance/toTermFinancial.html(pageNum=${finacnePageInfo.pageNum}+1,pageSize=${finacnePageInfo.pageSize})}"
aria-label="Next"> <span aria-hidden="true">»</span>
</a></li>
<li><a
th:href="@{/admin/finance/toTermFinancial.html(pageNum=${finacnePageInfo.pages},pageSize=${finacnePageInfo.pageSize})}">末页</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<!-- 新增理财的模态框 -->
<div class="modal fade" id="addModal" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">新增期限理财产品</h4>
</div>
<div class="modal-body">
<!--要提交的表单 -->
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">产品名称:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="name_add_input" name="name"
placeholder="请输入期限理财产品名称:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">起投金额(元):</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="leastmoney_add_input" name="leastmoney"
placeholder="请输入起投金额:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">收益方式:</label>
<div class="col-sm-6">
<div class="example-box">
<label class="lyear-radio radio-inline">
<input type="radio" name="profit"
value="1" checked="checked"><span>收益型</span>
</label>
<label class="lyear-radio radio-inline">
<input type="radio" name="profit"
value="2"> <span>净值型</span>
</label>
</div>
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">七日年化收益率:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="annualincome_add_input" name="annualincome"
placeholder="请输入七日年化收益率:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">投资期限:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="investerm_add_input" name="investerm"
placeholder="请输入投资期限:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary"
id="save_btn">保存
</button>
</div>
</div>
</div>
</div>
<!-- 修改用户的模态框 -->
<div class="modal fade" id="updateModal" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">修改期限理财产品信息</h4>
</div>
<div class="modal-body">
<!--要提交的表单 -->
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">产品名称:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="name_update_input" name="name"
placeholder="请输入期限理财产品名称:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">起投金额(元):</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="leastmoney_update_input" name="leastmoney"
placeholder="请输入起投金额:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">收益方式:</label>
<div class="col-sm-6">
<div class="example-box">
<label class="lyear-radio radio-inline">
<input type="radio" name="profit"
value="1" checked="checked"><span>收益型</span>
</label>
<label class="lyear-radio radio-inline">
<input type="radio" name="profit"
value="2"> <span>净值型</span>
</label>
</div>
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">七日年化收益率:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="annualincome_update_input" name="annualincome"
placeholder="请输入七日年化收益率:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">投资期限:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="investerm_update_input" name="investerm"
placeholder="请输入投资期限:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary"
id="update_btn">更新
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
//点击新增按钮弹出模态框。
$("#add_modal_btn").click(function () {
//清除表单数据(表单完整重置(表单的数据,表单的样式))
reset_form("#addModal form");
//弹出模态框
$("#addModal").modal({
//点击增加框背景不删除增加框
backdrop: "static"
});
});
//点击保存,保存新增产品信息。
$("#save_btn").click(function () {
//清空表单样式
clean_form("#addModal form");
var name = $("#name_add_input").val();
var leastmoney = $("#leastmoney_add_input").val();
var annualincome = $("#annualincome_add_input").val();
var investerm = $("#investerm_add_input").val();
//匹配中文、英文、数字包括下划线(理财产品名称)
var nameRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (name.length === 0) {
show_validate_msg("#name_add_input",
"error", "产品名称为空");
return false;
} else if (nameRegex.test(name) === false) {
show_validate_msg("#name_add_input",
"error", "产品名称不合法(产品名称只能由中文、数字、英文和下划线组成)");
return false;
}
//匹配有1~2位小数的正实数
var leastmoneyRegex = /^[0-9]+(.[0-9]{1,2})?$/;
if (leastmoney.length === 0) {
show_validate_msg("#leastmoney_add_input",
"error", "起投金额为空");
return false;
} else if (leastmoneyRegex.test(leastmoney) === false) {
show_validate_msg("#leastmoney_add_input",
"error", "起投金额不合法(有1~2位小数的正实数)");
return false;
}
//匹配正数、负数、和小数
var annualincomeRegex = /^(\-|\+)?\d+(\.\d+)?$/;
if (annualincome.length === 0) {
show_validate_msg("#annualincome_add_input",
"error", "七日年化收益率为空");
return false;
} else if (annualincomeRegex.test(annualincome) === false) {
show_validate_msg("#annualincome_add_input",
"error", "七日年化收益率不合法(正数、负数、和小数)");
return false;
}
//匹配中文、英文、数字包括下划线
var investermRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (investerm.length === 0) {
show_validate_msg("#investerm_add_input",
"error", "投资期限为空");
return false;
} else if (investermRegex.test(investerm) === false) {
show_validate_msg("#investerm_add_input",
"error", "投资期限不合法");
return false;
}
//2、发送ajax请求保存产品
$.ajax({
url: "/admin/addTermFinancial",
type: "POST",
data: $("#addModal form").serialize(),
success: function (result) {
if (result.code === 100) {
$("#addModal").modal('hide');
$.alert('期限理财产品添加成功!');
setTimeout(function () {
var pageNum = [[${finacnePageInfo.pages}]];
var pageSize = [[${finacnePageInfo.pageSize}]];
location.href = "/admin/finance/toTermFinancial.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('期限理财产品添加失败!');
}
}
});
});
//点击编辑按钮时触发事件
$(document).on("click", ".update_btn", function () {
//根据用户id发送ajax请求,查出信息并显示
getFinanceInfo($(this).attr("update-id"));
//把用户的id传递给模态框的更新按钮
$("#update_btn").attr("update-id", $(this).attr("update-id"));
$("#updateModal").modal({
backdrop: "static"
});
});
//根据id查出信息并显示
function getFinanceInfo(id) {
$.ajax({
url: "/admin/getTermFinancialInfoById/" + id,
type: "GET",
success: function (result) {
var termFinancial = result.extend.termFinancial;
//显示数据之前先清除一下校验样式,如果有的话
reset_form("#updateModal form");
$("#name_update_input").val(termFinancial.name);
$("#updateModal input[name=profit]").val(
[ termFinancial.profit ]);
$("#leastmoney_update_input").val(termFinancial.leastmoney);
$("#annualincome_update_input").val(termFinancial.annualincome);
$("#investerm_update_input").val(termFinancial.investerm);
}
});
}
//点击更新,更新信息
$("#update_btn").click(function () {
//清空表单样式
clean_form("#updateModal form");
var name = $("#name_update_input").val();
var leastmoney = $("#leastmoney_update_input").val();
var annualincome = $("#annualincome_update_input").val();
var investerm = $("#investerm_update_input").val();
//匹配中文、英文、数字包括下划线(理财产品名称)
var nameRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (name.length === 0) {
show_validate_msg("#name_update_input",
"error", "产品名称为空");
return false;
} else if (nameRegex.test(name) === false) {
show_validate_msg("#name_update_input",
"error", "产品名称不合法(产品名称只能由中文、数字、英文和下划线组成)");
return false;
}
//匹配有1~2位小数的正实数
var leastmoneyRegex = /^[0-9]+(.[0-9]{1,2})?$/;
if (leastmoney.length === 0) {
show_validate_msg("#leastmoney_update_input",
"error", "起投金额为空");
return false;
} else if (leastmoneyRegex.test(leastmoney) === false) {
show_validate_msg("#leastmoney_update_input",
"error", "起投金额不合法(有1~2位小数的正实数)");
return false;
}
//匹配正数、负数、和小数
var annualincomeRegex = /^(\-|\+)?\d+(\.\d+)?$/;
if (annualincome.length === 0) {
show_validate_msg("#annualincome_update_input",
"error", "七日年化收益率为空");
return false;
} else if (annualincomeRegex.test(annualincome) === false) {
show_validate_msg("#annualincome_update_input",
"error", "七日年化收益率不合法(正数、负数、和小数)");
return false;
}
//匹配中文、英文、数字包括下划线
var investermRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (investerm.length === 0) {
show_validate_msg("#investerm_update_input",
"error", "投资期限为空");
return false;
} else if (investermRegex.test(investerm) === false) {
show_validate_msg("#investerm_update_input",
"error", "投资期限不合法");
return false;
}
//2、发送ajax请求保存更新的理财产品数据
$.ajax({
url: "/admin/updateTermFinancial/" + $(this).attr("update-id"),
type: "PUT",
data: $("#updateModal form").serialize(),
success: function (result) {
if (result.code === 100) {
$("#updateModal").modal('hide');
$.alert('期限理财产品信息修改成功!');
setTimeout(function () {
var pageNum = [[${finacnePageInfo.pageNum}]];
var pageSize = [[${finacnePageInfo.pageSize}]];
location.href = "/admin/finance/toTermFinancial.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('期限理财产品信息修改失败!');
}
}
});
});
//单个删除
$(document).on("click", ".delete_btn", function () {
//1、弹出是否确认删除对话框
var id = $(this).attr("delete-id");
var name = $(this).attr("delete-name");
$.alert({
title: '提示:',
content: "确定删除工资理财产品 <strong>" + name + "</strong> 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/admin/deleteTermFinancialById/" + id,
type: "DELETE",
success: function (result) {
if (result.code === 100) {
$.alert('删除该期限理财产品成功!');
setTimeout(function () {
var pageNum = [[${finacnePageInfo.pageNum}]];
var pageSize = [[${finacnePageInfo.pageSize}]];
location.href = "/admin/finance/toTermFinancial.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('删除该期限理财产品失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
});
//清空表单样式及内容
function reset_form(ele) {
$(ele)[0].reset();
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//清空表单样式
function clean_form(ele) {
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//显示校验结果的提示信息
function show_validate_msg(ele, status, msg) {
//清除当前元素的校验状态
$(ele).parent().removeClass("has-success has-error");
$(ele).next("span").text("");
if ("success" === status) {
$(ele).parent().addClass("has-success");
$(ele).next("span").text(msg);
} else if ("error" === status) {
$(ele).parent().addClass("has-error");
$(ele).next("span").text(msg);
}
}
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/admin/finance/termfinancial.html
|
HTML
|
mit
| 35,504
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>后台管理系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="admin/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="admin/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>网贷审核</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">账户</th>
<th class="info">借贷资金</th>
<th class="info">借贷期限</th>
<th class="info">个人信用</th>
<th class="info">审核状态</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="loan:${loanList}">
<td th:text="${(loanPageInfo.pageNum - 1) * loanPageInfo.pageSize+loanStat.index+1}"></td>
<td th:text="${loan.user.username}"></td>
<td th:text="${#numbers.formatDecimal(loan.amount,1,2)}+'元'"></td>
<td th:text="${loan.term}+'天'"></td>
<td th:text="${loan.user.reputation}"></td>
<td th:if="${loan.applystatus==0}" th:text="未审核"></td>
<td th:if="${loan.applystatus==1}" th:text="审核未通过"></td>
<td th:if="${loan.applystatus==2}" th:text="审核通过"></td>
<td>
<button class="btn btn-primary btn-sm pass_update_btn"
th:attr="update-id=${loan.id},update-name=${loan.user.username},
update-amount=${loan.amount},update-applystatus=${loan.applystatus}">
<span class="glyphicon glyphicon-ok"
aria-hidden="true"></span> 审核通过
</button>
<button class="btn btn-danger btn-sm notpass_update_btn"
th:attr="update-id=${loan.id},update-name=${loan.user.username},
update-amount=${loan.amount},update-applystatus=${loan.applystatus}">
<span class="glyphicon glyphicon-remove"
aria-hidden="true"></span> 审核不通过
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- 显示分页信息 -->
<div class="row">
<div class="col-md-5 col-md-offset-1">
<div class="btn-group">
<button class="btn btn-default">
<span>页次:</span>
</button>
<button class="btn btn-default">
<span th:text="${loanPageInfo.pageNum}+'/'+${loanPageInfo.pages}+'页'"></span>
</button>
<button class="btn btn-default">
<span>每页显示:</span>
</button>
<div class="btn-group">
<button id="btnGroupDrop1"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"><span
th:text="${loanPageInfo.pageSize}"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li th:each="i:${#numbers.sequence(1,10)}">
<a th:text="${i}"
th:href="@{/admin/loan/toLoanexam.html(pageNum=${loanPageInfo.pageNum},pageSize=${i})}"></a>
</li>
</ul>
</div>
<button class="btn btn-default">
<span>条</span>
</button>
<button class="btn btn-default">
<span>总记录数:</span>
</button>
<button class="btn btn-default">
<span th:text="${loanPageInfo.total}+'条'"></span>
</button>
</div>
</div>
<!-- 分页条信息 -->
<div class="col-md-5">
<nav aria-label="Page navigation">
<ul class="pagination pagination-lg pull-right"
style="margin-top: 0">
<li>
<a th:href="@{/admin/loan/toLoanexam.html(pageNum=1,pageSize=${loanPageInfo.pageSize})}">首页</a>
</li>
<li th:if="${loanPageInfo.hasPreviousPage }"><a
th:href="@{/admin/loan/toLoanexam.html(pageNum=${loanPageInfo.pageNum}-1,pageSize=${loanPageInfo.pageSize})}"
aria-label="Previous"> <span aria-hidden="true">«</span>
</a></li>
<li th:each="page_Num:${loanPageInfo.navigatepageNums }"
th:class="${page_Num == loanPageInfo.pageNum?'active':''}">
<a th:if="${page_Num == loanPageInfo.pageNum}"
th:text="${page_Num}"
th:href="@{#}">
</a>
<a th:text="${page_Num}"
th:if="${page_Num != loanPageInfo.pageNum}"
th:href="@{/admin/loan/toLoanexam.html(pageNum=${page_Num},pageSize=${loanPageInfo.pageSize})}">
</a>
</li>
<li th:if="${loanPageInfo.hasNextPage }"><a
th:href="@{/admin/loan/toLoanexam.html(pageNum=${loanPageInfo.pageNum}+1,pageSize=${loanPageInfo.pageSize})}"
aria-label="Next"> <span aria-hidden="true">»</span>
</a></li>
<li><a
th:href="@{/admin/loan/toLoanexam.html(pageNum=${loanPageInfo.pages},pageSize=${loanPageInfo.pageSize})}">末页</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
//通过审核
$(document).on("click", ".pass_update_btn", function () {
var id = $(this).attr("update-id");
var username = $(this).attr("update-name");
var amount = $(this).attr("update-amount");
var applystatus = $(this).attr("update-applystatus");
if (applystatus == 2) {
$.alert('用户 <strong>' + username + '</strong> 的' + amount + '元网贷审核已通过');
} else if (applystatus == 1) {
$.alert({
title: '提示:',
content: "用户 <strong>" + username + "</strong> 的" + amount + "元网贷之前审核未通过,现在确认通过审核吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/loan/passApplyStatus/" + id,
type: "put",
success: function (result) {
if (result.code === 100) {
$.alert('通过审核修改成功!');
setTimeout(function () {
var pageNum = [[${loanPageInfo.pageNum}]];
var pageSize = [[${loanPageInfo.pageSize}]];
location.href = "/admin/loan/toLoanexam.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('通过审核修改失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
} else if (applystatus == 0) {
$.alert({
title: '提示:',
content: "确定通过用户 <strong>" + username + "</strong> 的" + amount + "元网贷申请吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/loan/passApplyStatus/" + id,
type: "put",
success: function (result) {
if (result.code === 100) {
$.alert('通过审核修改成功!');
setTimeout(function () {
var pageNum = [[${loanPageInfo.pageNum}]];
var pageSize = [[${loanPageInfo.pageSize}]];
location.href = "/admin/loan/toLoanexam.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('通过审核修改失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
}
});
//未通过审核
$(document).on("click", ".notpass_update_btn", function () {
var id = $(this).attr("update-id");
var username = $(this).attr("update-name");
var amount = $(this).attr("update-amount");
var applystatus = $(this).attr("update-applystatus");
if (applystatus == 1) {
$.alert('用户 <strong>' + username + '</strong> 的' + amount + '元网贷审核未通过,无需重复提交');
} else if (applystatus == 2) {
$.alert('用户 <strong>' + username + '</strong> 的' + amount + '元网贷审核已通过,无法取消');
} else if (applystatus == 0) {
$.alert({
title: '提示:',
content: "确定不通过用户 <strong>" + username + "</strong> 的" + amount + "元网贷申请吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/loan/notPassApplyStatus/" + id,
type: "PUT",
data: {},
success: function (result) {
if (result.code === 100) {
$.alert('未通过审核修改成功!');
setTimeout(function () {
var pageNum = [[${loanPageInfo.pageNum}]];
var pageSize = [[${loanPageInfo.pageSize}]];
location.href = "/admin/loan/toLoanexam.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('未通过审核修改失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
}
});
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/admin/loan/loanexam.html
|
HTML
|
mit
| 17,243
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>后台管理系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="admin/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="admin/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>网贷信息</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">姓名</th>
<th class="info">身份证号</th>
<th class="info">联系方式</th>
<th class="info">借贷资金</th>
<th class="info">借贷期限</th>
<th class="info">借贷状态</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="loan:${loanList}">
<td th:text="${(loanPageInfo.pageNum - 1) * loanPageInfo.pageSize+loanStat.index+1}"></td>
<td th:text="${loan.user.username}"></td>
<td th:text="${loan.user.idcard}"></td>
<td th:text="${loan.user.phone}"></td>
<td th:text="${#numbers.formatDecimal(loan.amount,1,2)}+'元'"></td>
<td th:text="${loan.term}+'天'"></td>
<td th:if="${loan.loanstatus==0}" th:text="未逾期"></td>
<td th:if="${loan.loanstatus==1}" th:text="逾期"></td>
<td th:if="${loan.loanstatus==2}" th:text="已还清"></td>
<td>
<button class="btn btn-primary btn-sm update_btn"
th:attr="update-id=${loan.id},update-name=${loan.user.username},
update-amount=${loan.amount},update-status=${loan.loanstatus}">
<span class="glyphicon glyphicon-time"
aria-hidden="true"></span> 提醒还款
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- 显示分页信息 -->
<div class="row">
<div class="col-md-5 col-md-offset-1">
<div class="btn-group">
<button class="btn btn-default">
<span>页次:</span>
</button>
<button class="btn btn-default">
<span th:text="${loanPageInfo.pageNum}+'/'+${loanPageInfo.pages}+'页'"></span>
</button>
<button class="btn btn-default">
<span>每页显示:</span>
</button>
<div class="btn-group">
<button id="btnGroupDrop1"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"><span
th:text="${loanPageInfo.pageSize}"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li th:each="i:${#numbers.sequence(1,10)}">
<a th:text="${i}"
th:href="@{/admin/loan/toLoanexam.html(pageNum=${loanPageInfo.pageNum},pageSize=${i})}"></a>
</li>
</ul>
</div>
<button class="btn btn-default">
<span>条</span>
</button>
<button class="btn btn-default">
<span>总记录数:</span>
</button>
<button class="btn btn-default">
<span th:text="${loanPageInfo.total}+'条'"></span>
</button>
</div>
</div>
<!-- 分页条信息 -->
<div class="col-md-5">
<nav aria-label="Page navigation">
<ul class="pagination pagination-lg pull-right"
style="margin-top: 0">
<li>
<a th:href="@{/admin/loan/toLoanexam.html(pageNum=1,pageSize=${loanPageInfo.pageSize})}">首页</a>
</li>
<li th:if="${loanPageInfo.hasPreviousPage }"><a
th:href="@{/admin/loan/toLoanexam.html(pageNum=${loanPageInfo.pageNum}-1,pageSize=${loanPageInfo.pageSize})}"
aria-label="Previous"> <span aria-hidden="true">«</span>
</a></li>
<li th:each="page_Num:${loanPageInfo.navigatepageNums }"
th:class="${page_Num == loanPageInfo.pageNum?'active':''}">
<a th:if="${page_Num == loanPageInfo.pageNum}"
th:text="${page_Num}"
th:href="@{#}">
</a>
<a th:text="${page_Num}"
th:if="${page_Num != loanPageInfo.pageNum}"
th:href="@{/admin/loan/toLoanexam.html(pageNum=${page_Num},pageSize=${loanPageInfo.pageSize})}">
</a>
</li>
<li th:if="${loanPageInfo.hasNextPage }"><a
th:href="@{/admin/loan/toLoanexam.html(pageNum=${loanPageInfo.pageNum}+1,pageSize=${loanPageInfo.pageSize})}"
aria-label="Next"> <span aria-hidden="true">»</span>
</a></li>
<li><a
th:href="@{/admin/loan/toLoanexam.html(pageNum=${loanPageInfo.pages},pageSize=${loanPageInfo.pageSize})}">末页</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
//提醒还款
$(document).on("click", ".update_btn", function () {
//1、弹出是否确认删除对话框
var id = $(this).attr("update-id");
var username = $(this).attr("update-name");
var amount = $(this).attr("update-amount");
var loanstatus = $(this).attr("update-status");
if (loanstatus == 2) {
$.alert('用户 <strong>' + username + '</strong> 的' + amount + '元网贷已还清');
return false;
} else if (loanstatus == 0) {
$.alert({
title: '提示:',
content: "用户 <strong>" + username + "</strong> 的" + amount + "元网贷尚未逾期,确认提醒他还款吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/loan/remindPay/" + id,
type: "put",
success: function (result) {
if (result.code === 100) {
$.alert('提醒还款成功!');
setTimeout(function () {
var pageNum = [[${loanPageInfo.pageNum}]];
var pageSize = [[${loanPageInfo.pageSize}]];
location.href = "/admin/loan/toLoaninfo.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('提醒还款失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
} else if (loanstatus == 1) {
$.alert({
title: '提示:',
content: "用户 <strong>" + username + "</strong> 的" + amount + "元网贷已逾期,确认提醒他还款吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/loan/remindPay/" + id,
type: "put",
success: function (result) {
if (result.code === 100) {
$.alert('提醒还款成功!');
setTimeout(function () {
var pageNum = [[${loanPageInfo.pageNum}]];
var pageSize = [[${loanPageInfo.pageSize}]];
location.href = "/admin/loan/toLoaninfo.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('提醒还款失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
}
});
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/admin/loan/loaninfo.html
|
HTML
|
mit
| 14,416
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>动力节点金融</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="admin/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="admin/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>用户在线状态</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">用户名</th>
<th class="info">真实姓名</th>
<th class="info">手机号</th>
<th class="info">邮箱</th>
<th class="info">用户状态</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="user:${userList}">
<td th:text="${(userPageInfo.pageNum - 1) * userPageInfo.pageSize+userStat.index+1}"></td>
<td th:text="${user.username}"></td>
<td th:text="${user.realname}==null?'未填写':${user.realname}"></td>
<td th:text="${user.phone}==null?'未填写':${user.phone}"></td>
<td th:text="${user.email}==null?'未填写':${user.email}"></td>
<td th:if="${user.status==0}" th:text="离线"></td>
<td th:if="${user.status==1}" th:text="在线"></td>
<td>
<button class="btn btn-danger btn-sm edit_btn"
th:attr="edit-id=${user.id},edit-name=${user.username},edit-status=${user.status}">
<span class="glyphicon glyphicon-log-out"
aria-hidden="true"></span> 强制下线
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- 显示分页信息 -->
<div class="row">
<div class="col-md-5 col-md-offset-1">
<div class="btn-group">
<button class="btn btn-default">
<span>页次:</span>
</button>
<button class="btn btn-default">
<span th:text="${userPageInfo.pageNum}+'/'+${userPageInfo.pages}+'页'"></span>
</button>
<button class="btn btn-default">
<span>每页显示:</span>
</button>
<div class="btn-group">
<button id="btnGroupDrop1"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"><span
th:text="${userPageInfo.pageSize}"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li th:each="i:${#numbers.sequence(1,10)}"><a th:text="${i}"
th:href="@{/admin/index.html(pageNum=${userPageInfo.pageNum},pageSize=${i})}"></a>
</li>
</ul>
</div>
<button class="btn btn-default">
<span>条</span>
</button>
<button class="btn btn-default">
<span>总记录数:</span>
</button>
<button class="btn btn-default">
<span th:text="${userPageInfo.total}+'条'"></span>
</button>
</div>
</div>
<!-- 分页条信息 -->
<div class="col-md-5">
<nav aria-label="Page navigation">
<ul class="pagination pagination-lg pull-right"
style="margin-top: 0">
<li>
<a th:href="@{/admin/index.html(pageNum=1,pageSize=${userPageInfo.pageSize})}">首页</a>
</li>
<li th:if="${userPageInfo.hasPreviousPage }"><a
th:href="@{/admin/index.html(pageNum=${userPageInfo.pageNum}-1,pageSize=${userPageInfo.pageSize})}"
aria-label="Previous"> <span aria-hidden="true">«</span>
</a></li>
<li th:each="page_Num:${userPageInfo.navigatepageNums }"
th:class="${page_Num == userPageInfo.pageNum?'active':''}">
<a th:if="${page_Num == userPageInfo.pageNum}"
th:text="${page_Num}"
th:href="@{#}">
</a>
<a th:text="${page_Num}"
th:if="${page_Num != userPageInfo.pageNum}"
th:href="@{/admin/index.html(pageNum=${page_Num},pageSize=${userPageInfo.pageSize})}">
</a>
</li>
<li th:if="${userPageInfo.hasNextPage }"><a
th:href="@{/admin/index.html(pageNum=${userPageInfo.pageNum}+1,pageSize=${userPageInfo.pageSize})}"
aria-label="Next"> <span aria-hidden="true">»</span>
</a></li>
<li><a
th:href="@{/admin/index.html(pageNum=${userPageInfo.pages},pageSize=${userPageInfo.pageSize})}">末页</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
//强制下线
$(document).on("click", ".edit_btn", function () {
var id = $(this).attr("edit-id");
var username = $(this).attr("edit-name");
var status = $(this).attr("edit-status");
if (status == 0) {
$.alert("用户 <strong>" + username + "</strong> 已离线")
} else if (status == 1) {
$.alert({
title: '提示:',
content: "确定让 <strong>" + username + "</strong> 强制下线吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/user/updateUserStatus/" + id,
type: "PUT",
success: function (result) {
if (result.code === 100) {
var pageNum = [[${userPageInfo.pageNum}]];
var pageSize = [[${userPageInfo.pageSize}]];
location.href = "/admin/index.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
} else {
$.alert('用户强制下线操作失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
}
})
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/admin/main.html
|
HTML
|
mit
| 11,877
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>后台管理系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="admin/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="admin/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>管理员权限管理</h4>
</div>
<div class="card-body">
<form>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>
<label class="lyear-checkbox checkbox-primary">
<input name="checkbox" type="checkbox" id="check-all">
<span>全选</span>
</label>
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="p-l-20">
<label th:if="${!#lists.contains(permissionsList,'admin:userInfo')}"
class="lyear-checkbox checkbox-primary">
<input name="permissions[]" type="checkbox"
class="checkbox-parent checkbox-child" dataid="id-1-6"
value="admin:userInfo">
<span>用户信息管理</span>
</label>
<label th:if="${#lists.contains(permissionsList,'admin:userInfo')}"
class="lyear-checkbox checkbox-primary">
<input name="permissions[]" type="checkbox"
class="checkbox-parent checkbox-child" dataid="id-1-6"
checked value="admin:userInfo">
<span>用户信息管理</span>
</label>
</td>
</tr>
<tr>
<td class="p-l-40">
<label th:if="${!#lists.contains(permissionsList,'admin:bankCard')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-6-20" value="admin:bankCard">
<span> 银行卡</span>
</label>
<label th:if="${#lists.contains(permissionsList,'admin:bankCard')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-6-20" value="admin:bankCard">
<span> 银行卡</span>
</label>
<label th:if="${!#lists.contains(permissionsList,'admin:reputation')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-6-21" value="admin:reputation">
<span> 个人征信</span>
</label>
<label th:if="${#lists.contains(permissionsList,'admin:reputation')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-6-21" value="admin:reputation">
<span> 个人征信</span>
</label>
<label th:if="${!#lists.contains(permissionsList,'admin:userInfoElse')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-6-44" value="admin:userInfoElse">
<span> 用户信息</span>
</label>
<label th:if="${#lists.contains(permissionsList,'admin:userInfoElse')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-6-44" value="admin:userInfoElse">
<span> 用户信息</span>
</label>
</td>
</tr>
<tr>
<td class="p-l-20">
<label th:if="${!#lists.contains(permissionsList,'admin:finance')}"
class="lyear-checkbox checkbox-primary">
<input name="permissions[]" type="checkbox"
class="checkbox-parent checkbox-child" dataid="id-1-6"
value="admin:finance">
<span>理财产品管理</span>
</label>
<label th:if="${#lists.contains(permissionsList,'admin:finance')}"
class="lyear-checkbox checkbox-primary">
<input name="permissions[]" type="checkbox"
class="checkbox-parent checkbox-child" dataid="id-1-6"
checked value="admin:finance">
<span>理财产品管理</span>
</label>
</td>
</tr>
<tr>
<td class="p-l-40">
<label th:if="${!#lists.contains(permissionsList,'admin:changeMoney')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-6-20" value="admin:changeMoney">
<span> 零钱理财</span>
</label>
<label th:if="${#lists.contains(permissionsList,'admin:changeMoney')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-6-20" value="admin:changeMoney">
<span> 零钱理财</span>
</label>
<label th:if="${!#lists.contains(permissionsList,'admin:payMoney')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-6-21" value="admin:payMoney">
<span> 工资理财</span>
</label>
<label th:if="${#lists.contains(permissionsList,'admin:payMoney')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-6-21" value="admin:payMoney">
<span> 工资理财</span>
</label>
<label th:if="${!#lists.contains(permissionsList,'admin:termFinancial')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-6-44" value="admin:termFinancial">
<span> 期限理财</span>
</label>
<label th:if="${#lists.contains(permissionsList,'admin:termFinancial')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-6-44" value="admin:termFinancial">
<span> 期限理财</span>
</label>
<label th:if="${!#lists.contains(permissionsList,'admin:fundProduct')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-6-45" value="admin:fundProduct">
<span> 基金理财</span>
</label>
<label th:if="${#lists.contains(permissionsList,'admin:fundProduct')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-6-45" value="admin:fundProduct">
<span> 基金理财</span>
</label>
<label th:if="${!#lists.contains(permissionsList,'admin:bank')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-6-46" value="admin:bank">
<span> 精选银行</span>
</label>
<label th:if="${#lists.contains(permissionsList,'admin:bank')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-6-46" value="admin:bank">
<span> 精选银行</span>
</label>
</td>
</tr>
<tr>
<td class="p-l-20">
<label class="lyear-checkbox checkbox-primary">
<input name="permissions[]" type="checkbox" disabled checked
class="checkbox-parent checkbox-child" dataid="id-1-7"
value="admin:permission">
<span>权限管理</span>
</label>
</td>
</tr>
<tr>
<td class="p-l-40">
<label th:if="${!#lists.contains(permissionsList,'admin:userPermissions')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-7-51" value="admin:userPermissions">
<span> 用户权限</span>
</label>
<label th:if="${#lists.contains(permissionsList,'admin:userPermissions')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-7-51" value="admin:userPermissions">
<span> 用户权限</span>
</label>
<label class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" disabled checked
dataid="id-1-7-51" value="admin:adminPermissions">
<span> 管理员权限</span>
</label>
</td>
</tr>
<tr>
<td class="p-l-20">
<label th:if="${!#lists.contains(permissionsList,'admin:loan')}" class="lyear-checkbox checkbox-primary">
<input name="permissions[]" type="checkbox"
class="checkbox-parent checkbox-child" dataid="id-1-7"
value="admin:loan">
<span> 网贷管理</span>
</label>
<label th:if="${#lists.contains(permissionsList,'admin:loan')}" class="lyear-checkbox checkbox-primary">
<input name="permissions[]" type="checkbox" checked
class="checkbox-parent checkbox-child" dataid="id-1-7"
value="admin:loan">
<span> 网贷管理</span>
</label>
</td>
</tr>
<tr>
<td class="p-l-40">
<label th:if="${!#lists.contains(permissionsList,'admin:loanExam')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-7-51" value="admin:loanExam">
<span> 网贷审核</span>
</label>
<label th:if="${#lists.contains(permissionsList,'admin:loanExam')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-7-51" value="admin:loanExam">
<span> 网贷审核</span>
</label>
<label th:if="${!#lists.contains(permissionsList,'admin:loanInfo')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-7-51" value="admin:loanInfo">
<span> 网贷审核</span>
</label>
<label th:if="${#lists.contains(permissionsList,'admin:loanInfo')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-7-51" value="admin:loanInfo">
<span> 网贷审核</span>
</label>
</td>
</tr>
</tbody>
</table>
<div class="col-md-1">
<button type="button" id="submit_modal_btn" class="btn btn-primary">提交</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--选择框js-->
<script th:src="@{/js/chosen.jquery.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
$("#submit_modal_btn").click(function () {
var permissions = "";
var r=document.getElementsByName("permissions[]");
for(var i=0;i<r.length;i++){
if(r[i].checked){
permissions+=(r[i].value+";")
}
}
$.ajax({
url: "/admin/updateAdminPermissions",
type: "PUT",
data:{
"adminPermissions":permissions
},
success: function (result) {
if (result.code === 100) {
$.alert('提交成功!');
setTimeout(function () {
location.href = "/admin/permission/toAdminPermissions.html";
}, 1000);
} else {
$.alert('提交失败!');
}
}
});
})
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/admin/permission/adminpermissions.html
|
HTML
|
mit
| 24,967
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>后台管理系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="admin/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="admin/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>用户权限管理</h4>
</div>
<div class="card-body">
<form>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>
<label class="lyear-checkbox checkbox-primary">
<input name="checkbox" type="checkbox" id="check-all">
<span>全选</span>
</label>
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="p-l-20">
<label th:if="${!#lists.contains(permissionsList,'user:finance')}"
class="lyear-checkbox checkbox-primary">
<input name="permissions[]" type="checkbox"
class="checkbox-parent checkbox-child" dataid="id-1-6"
value="user:finance">
<span>个人理财</span>
</label>
<label th:if="${#lists.contains(permissionsList,'user:finance')}"
class="lyear-checkbox checkbox-primary">
<input name="permissions[]" type="checkbox"
class="checkbox-parent checkbox-child" dataid="id-1-6"
checked value="user:finance">
<span>个人理财</span>
</label>
</td>
</tr>
<tr>
<td class="p-l-40">
<label th:if="${!#lists.contains(permissionsList,'user:changeMoney')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-6-20" value="user:changeMoney">
<span> 零钱理财</span>
</label>
<label th:if="${#lists.contains(permissionsList,'user:changeMoney')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-6-20" value="user:changeMoney">
<span> 零钱理财</span>
</label>
<label th:if="${!#lists.contains(permissionsList,'user:payMoney')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-6-21" value="user:payMoney">
<span> 工资理财</span>
</label>
<label th:if="${#lists.contains(permissionsList,'user:payMoney')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-6-21" value="user:payMoney">
<span> 工资理财</span>
</label>
<label th:if="${!#lists.contains(permissionsList,'user:termFinancial')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-6-44" value="user:termFinancial">
<span> 期限理财</span>
</label>
<label th:if="${#lists.contains(permissionsList,'user:termFinancial')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-6-44" value="user:termFinancial">
<span> 期限理财</span>
</label>
<label th:if="${!#lists.contains(permissionsList,'user:fundProduct')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-6-45" value="user:fundProduct">
<span> 基金理财</span>
</label>
<label th:if="${#lists.contains(permissionsList,'user:fundProduct')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-6-45" value="user:fundProduct">
<span> 基金理财</span>
</label>
<label th:if="${!#lists.contains(permissionsList,'user:bank')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-6-46" value="user:bank">
<span> 银行推荐</span>
</label>
<label th:if="${#lists.contains(permissionsList,'user:bank')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-6-46" value="user:bank">
<span> 银行推荐</span>
</label>
</td>
</tr>
<tr>
<td class="p-l-20">
<label th:if="${!#lists.contains(permissionsList,'user:tools')}" class="lyear-checkbox checkbox-primary">
<input name="permissions[]" type="checkbox"
class="checkbox-parent checkbox-child" dataid="id-1-7"
value="user:tools">
<span> 金融工具</span>
</label>
<label th:if="${#lists.contains(permissionsList,'user:tools')}" class="lyear-checkbox checkbox-primary">
<input name="permissions[]" type="checkbox" checked
class="checkbox-parent checkbox-child" dataid="id-1-7"
value="user:tools">
<span> 金融工具</span>
</label>
</td>
</tr>
<tr>
<td class="p-l-40">
<label th:if="${!#lists.contains(permissionsList,'user:record')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-7-51" value="user:record">
<span> 资金记录</span>
</label>
<label th:if="${#lists.contains(permissionsList,'user:record')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-7-51" value="user:record">
<span> 资金记录</span>
</label>
<label th:if="${!#lists.contains(permissionsList,'user:loan')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child"
dataid="id-1-7-51" value="user:loan">
<span> 安全网贷</span>
</label>
<label th:if="${#lists.contains(permissionsList,'user:loan')}" class="lyear-checkbox checkbox-primary checkbox-inline">
<input name="permissions[]" type="checkbox"
class="checkbox-child" checked
dataid="id-1-7-51" value="user:loan">
<span> 安全网贷</span>
</label>
</td>
</tr>
</tbody>
</table>
<div class="col-md-1">
<button type="button" id="submit_modal_btn" class="btn btn-primary">提交</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--选择框js-->
<script th:src="@{/js/chosen.jquery.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
$(function () {
//$.alert(permissionsList);
//动态选择框,上下级选中状态变化
$('input.checkbox-parent').on('change', function () {
var dataid = $(this).attr("dataid");
$('input[dataid^=' + dataid + '-]').prop('checked', $(this).is(':checked'));
});
$('input.checkbox-child').on('change', function () {
var dataid = $(this).attr("dataid");
dataid = dataid.substring(0, dataid.lastIndexOf("-"));
var parent = $('input[dataid=' + dataid + ']');
if ($(this).is(':checked')) {
parent.prop('checked', true);
//循环到顶级
while (dataid.lastIndexOf("-") != 2) {
dataid = dataid.substring(0, dataid.lastIndexOf("-"));
parent = $('input[dataid=' + dataid + ']');
parent.prop('checked', true);
}
} else {
//父级
if ($('input[dataid^=' + dataid + '-]:checked').length == 0) {
parent.prop('checked', false);
//循环到顶级
while (dataid.lastIndexOf("-") != 2) {
dataid = dataid.substring(0, dataid.lastIndexOf("-"));
parent = $('input[dataid=' + dataid + ']');
if ($('input[dataid^=' + dataid + '-]:checked').length == 0) {
parent.prop('checked', false);
}
}
}
}
});
// $.each(permissionsList,function (index, permission) {
// alert(permission.permission)
// })
});
$("#submit_modal_btn").click(function () {
var permissions = "";
var r=document.getElementsByName("permissions[]");
for(var i=0;i<r.length;i++){
if(r[i].checked){
permissions+=(r[i].value+";")
}
}
$.ajax({
url: "/admin/updateUserPermissions",
type: "PUT",
data:{
"userPermissions":permissions
},
success: function (result) {
if (result.code === 100) {
$.alert('提交成功!');
setTimeout(function () {
location.href = "/admin/permission/toUserPermissions.html";
}, 1000);
} else {
$.alert('提交失败!');
}
}
});
})
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/admin/permission/userpermissions.html
|
HTML
|
mit
| 18,246
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>后台管理系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="admin/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="admin/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>银行卡管理</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">所属用户</th>
<th class="info">所属银行</th>
<th class="info">类型</th>
<th class="info">银行卡号</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="bankcard:${bankcardList}">
<td th:text="${(bankcardPageInfo.pageNum - 1) * bankcardPageInfo.pageSize+bankcardStat.index+1}"></td>
<td th:text="${bankcard.user.username}"></td>
<td th:text="${bankcard.cardbank}"></td>
<td th:text="${bankcard.type==1?'借记卡':'信用卡'}"></td>
<td th:text="${bankcard.cardnum}"></td>
<td>
<button class="btn btn-primary btn-sm update_btn"
th:attr="update-id=${bankcard.id}">
<span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span> 编辑
</button>
<button class="btn btn-danger btn-sm delete_btn"
th:attr="delete-id=${bankcard.id},delete-name=${bankcard.user.username}">
<span class="glyphicon glyphicon-trash"
aria-hidden="true"></span> 删除
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- 显示分页信息 -->
<div class="row">
<div class="col-md-5 col-md-offset-1">
<div class="btn-group">
<button class="btn btn-default">
<span>页次:</span>
</button>
<button class="btn btn-default">
<span th:text="${bankcardPageInfo.pageNum}+'/'+${bankcardPageInfo.pages}+'页'"></span>
</button>
<button class="btn btn-default">
<span>每页显示:</span>
</button>
<div class="btn-group">
<button id="btnGroupDrop1"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"><span
th:text="${bankcardPageInfo.pageSize}"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li th:each="i:${#numbers.sequence(1,10)}">
<a th:text="${i}"
th:href="@{/admin/userinfo/toBankCard.html(pageNum=${bankcardPageInfo.pageNum},pageSize=${i})}"></a>
</li>
</ul>
</div>
<button class="btn btn-default">
<span>条</span>
</button>
<button class="btn btn-default">
<span>总记录数:</span>
</button>
<button class="btn btn-default">
<span th:text="${bankcardPageInfo.total}+'条'"></span>
</button>
</div>
</div>
<!-- 分页条信息 -->
<div class="col-md-5">
<nav aria-label="Page navigation">
<ul class="pagination pagination-lg pull-right"
style="margin-top: 0">
<li>
<a th:href="@{/admin/userinfo/toBankCard.html(pageNum=1,pageSize=${bankcardPageInfo.pageSize})}">首页</a>
</li>
<li th:if="${bankcardPageInfo.hasPreviousPage }"><a
th:href="@{/admin/userinfo/toBankCard.html(pageNum=${bankcardPageInfo.pageNum}-1,pageSize=${bankcardPageInfo.pageSize})}"
aria-label="Previous"> <span aria-hidden="true">«</span>
</a></li>
<li th:each="page_Num:${bankcardPageInfo.navigatepageNums }"
th:class="${page_Num == bankcardPageInfo.pageNum?'active':''}">
<a th:if="${page_Num == bankcardPageInfo.pageNum}"
th:text="${page_Num}"
th:href="@{#}">
</a>
<a th:text="${page_Num}"
th:if="${page_Num != bankcardPageInfo.pageNum}"
th:href="@{/admin/userinfo/toBankCard.html(pageNum=${page_Num},pageSize=${bankcardPageInfo.pageSize})}">
</a>
</li>
<li th:if="${bankcardPageInfo.hasNextPage }"><a
th:href="@{/admin/userinfo/toBankCard.html(pageNum=${bankcardPageInfo.pageNum}+1,pageSize=${bankcardPageInfo.pageSize})}"
aria-label="Next"> <span aria-hidden="true">»</span>
</a></li>
<li><a
th:href="@{/admin/userinfo/toBankCard.html(pageNum=${bankcardPageInfo.pages},pageSize=${bankcardPageInfo.pageSize})}">末页</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<!-- 修改银行卡的模态框 -->
<div class="modal fade" id="bankcardUpdateModal" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">修改银行卡信息</h4>
</div>
<div class="modal-body">
<!--要提交的表单 -->
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">所属用户:</label>
<div class="col-sm-6">
<p class="form-control-static"
id="username_update_input">
</p>
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">所属银行:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="cardbank_update_input" name="cardbank"
placeholder="请输入所属银行:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">类型:</label>
<div class="col-sm-6">
<label class="lyear-radio radio-inline">
<input type="radio" name="type" id="type_update_input"
value="1"><span>借记卡</span>
</label>
<label class="lyear-radio radio-inline">
<input type="radio" name="type" value="2"
id="type_update_input"><span>信用卡</span>
</label>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">银行卡号:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="cardnum_update_input" name="cardnum"
placeholder="请输入银行卡号:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary"
id="bankcard_update_btn">更新
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
//点击编辑按钮时触发事件
$(document).on("click", ".update_btn", function () {
//根据用户id发送ajax请求,查出用户信息并显示
getBankcardInfo($(this).attr("update-id"));
//把用户的id传递给模态框的更新按钮
$("#bankcard_update_btn").attr("update-id", $(this).attr("update-id"));
$("#bankcardUpdateModal").modal({
backdrop: "static"
});
});
//根据id查出用户信息并显示
function getBankcardInfo(id) {
$.ajax({
url: "/user/getBankCardById/" + id,
type: "GET",
success: function (result) {
var bankcard = result.extend.bankcard;
//显示数据之前先清除一下校验样式,如果有的话
reset_form("#bankcardUpdateModal form");
$("#username_update_input").text(bankcard.user.username);
$("#cardbank_update_input").val(bankcard.cardbank);
$("#cardnum_update_input").val(bankcard.cardnum);
$("#bankcardUpdateModal input[name=type]").val(
[ bankcard.type ]);
}
});
}
//点击更新,更新用户信息
$("#bankcard_update_btn").click(function () {
//清空表单样式
clean_form("#bankcardUpdateModal form");
var cardBank = $("#cardbank_update_input").val();
var cardNum = $("#cardnum_update_input").val();
//匹配汉字(银行名称)
var cardBankRegex = /^[\u4e00-\u9fa5]{0,}$/;
if (cardBank === "") {
show_validate_msg("#cardbank_update_input",
"error", "银行名称为空");
return false;
} else if (cardBankRegex.test(cardBank) === false) {
show_validate_msg("#cardbank_update_input",
"error", "银行名称不合法");
return false;
}
//匹配16-19位的数字
var cardNumRegex = /^\d{16,19}$/;
if (cardNum === "") {
show_validate_msg("#cardnum_update_input",
"error", "银行卡号为空");
return false;
} else if (cardNumRegex.test(cardNum) === false) {
show_validate_msg("#cardnum_update_input",
"error", "银行卡号不合法");
return false;
}
//2、发送ajax请求保存更新的银行卡数据
$.ajax({
url: "/user/updateBankCard/" + $(this).attr("update-id"),
type: "PUT",
data: $("#bankcardUpdateModal form").serialize(),
success: function (result) {
if (result.code === 100) {
$("#bankcardUpdateModal").modal('hide');
$.alert('银行卡信息修改成功!');
setTimeout(function () {
var pageNum = [[${bankcardPageInfo.pageNum}]];
var pageSize = [[${bankcardPageInfo.pageSize}]];
location.href = "/admin/userinfo/toBankCard.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('银行卡信息修改失败!');
}
}
});
});
//单个删除
$(document).on("click", ".delete_btn", function () {
//1、弹出是否确认删除对话框
var id = $(this).attr("delete-id");
var username = $(this).attr("delete-name");
$.alert({
title: '提示:',
content: "确定删除用户 <strong>" + username + "</strong> 的这张银行卡吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/user/deleteBankCard/" + id,
type: "DELETE",
success: function (result) {
if (result.code === 100) {
$.alert('删除该银行卡成功!');
setTimeout(function () {
var pageNum = [[${bankcardPageInfo.pageNum}]];
var pageSize = [[${bankcardPageInfo.pageSize}]];
location.href = "/admin/userinfo/toBankCard.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('删除该银行卡失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
});
//清空表单样式及内容
function reset_form(ele) {
$(ele)[0].reset();
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//清空表单样式
function clean_form(ele) {
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//显示校验结果的提示信息
function show_validate_msg(ele, status, msg) {
//清除当前元素的校验状态
$(ele).parent().removeClass("has-success has-error");
$(ele).next("span").text("");
if ("success" === status) {
$(ele).parent().addClass("has-success");
$(ele).next("span").text(msg);
} else if ("error" === status) {
$(ele).parent().addClass("has-error");
$(ele).next("span").text(msg);
}
}
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/admin/userinfo/bankcard.html
|
HTML
|
mit
| 21,866
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>后台管理系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="admin/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="admin/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>用户信誉管理</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">用户名</th>
<th class="info">信誉</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="user:${userList}">
<td th:text="${(userPageInfo.pageNum - 1) * userPageInfo.pageSize+userStat.index+1}"></td>
<td th:text="${user.username}"></td>
<td th:text="${user.reputation}"></td>
<td>
<button class="btn btn-primary btn-sm update_btn"
th:attr="update-id=${user.id}">
<span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span> 编辑
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- 显示分页信息 -->
<div class="row">
<div class="col-md-5 col-md-offset-1">
<div class="btn-group">
<button class="btn btn-default">
<span>页次:</span>
</button>
<button class="btn btn-default">
<span th:text="${userPageInfo.pageNum}+'/'+${userPageInfo.pages}+'页'"></span>
</button>
<button class="btn btn-default">
<span>每页显示:</span>
</button>
<div class="btn-group">
<button id="btnGroupDrop1"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"><span
th:text="${userPageInfo.pageSize}"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li th:each="i:${#numbers.sequence(1,10)}">
<a th:text="${i}"
th:href="@{/admin/userinfo/toReputation.html(pageNum=${userPageInfo.pageNum},pageSize=${i})}"></a>
</li>
</ul>
</div>
<button class="btn btn-default">
<span>条</span>
</button>
<button class="btn btn-default">
<span>总记录数:</span>
</button>
<button class="btn btn-default">
<span th:text="${userPageInfo.total}+'条'"></span>
</button>
</div>
</div>
<!-- 分页条信息 -->
<div class="col-md-5">
<nav aria-label="Page navigation">
<ul class="pagination pagination-lg pull-right"
style="margin-top: 0">
<li>
<a th:href="@{/admin/userinfo/toReputation.html(pageNum=1,pageSize=${userPageInfo.pageSize})}">首页</a>
</li>
<li th:if="${userPageInfo.hasPreviousPage }"><a
th:href="@{/admin/userinfo/toReputation.html(pageNum=${userPageInfo.pageNum}-1,pageSize=${userPageInfo.pageSize})}"
aria-label="Previous"> <span aria-hidden="true">«</span>
</a></li>
<li th:each="page_Num:${userPageInfo.navigatepageNums }"
th:class="${page_Num == userPageInfo.pageNum?'active':''}">
<a th:if="${page_Num == userPageInfo.pageNum}"
th:text="${page_Num}"
th:href="@{#}">
</a>
<a th:text="${page_Num}"
th:if="${page_Num != userPageInfo.pageNum}"
th:href="@{/admin/userinfo/toReputation.html(pageNum=${page_Num},pageSize=${userPageInfo.pageSize})}">
</a>
</li>
<li th:if="${userPageInfo.hasNextPage }"><a
th:href="@{/admin/userinfo/toReputation.html(pageNum=${userPageInfo.pageNum}+1,pageSize=${userPageInfo.pageSize})}"
aria-label="Next"> <span aria-hidden="true">»</span>
</a></li>
<li><a
th:href="@{/admin/userinfo/toReputation.html(pageNum=${userPageInfo.pages},pageSize=${userPageInfo.pageSize})}">末页</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<!-- 修改用户信誉的模态框 -->
<div class="modal fade" id="userUpdateModal" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">修改用户信息</h4>
</div>
<div class="modal-body">
<!--要提交的表单 -->
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">用户名:</label>
<div class="col-sm-6">
<p class="form-control-static"
id="username_update_input">
</p>
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">信誉:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="reputation_update_input" name="reputation"
placeholder="该用户的信誉还未知?">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary"
id="user_update_btn">更新
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
//点击编辑按钮时触发事件
$(document).on("click", ".update_btn", function () {
//根据用户id发送ajax请求,查出用户信息并显示
getUserInfo($(this).attr("update-id"));
//把用户的id传递给模态框的更新按钮
$("#user_update_btn").attr("update-id", $(this).attr("update-id"));
$("#userUpdateModal").modal({
backdrop: "static"
});
});
//根据id查出用户信息并显示
function getUserInfo(id) {
$.ajax({
url: "/user/getUserById/" + id,
type: "GET",
success: function (result) {
var user = result.extend.user;
//显示数据之前先清除一下校验样式,如果有的话
reset_form("#userUpdateModal form");
$("#username_update_input").text(user.username);
$("#reputation_update_input").val(user.reputation);
}
});
}
//点击更新,更新用户信誉
$("#user_update_btn").click(function () {
//清空表单样式
clean_form("#userUpdateModal form");
var reputation = $("#reputation_update_input").val();
//匹配汉字(信誉)
var reputationRegex = /^[\u4e00-\u9fa5]{1,10}$/;
if (reputationRegex.test(reputation) === false) {
show_validate_msg("#reputation_update_input",
"error", "信誉为:差,良好,优秀");
return false;
}
//2、发送ajax请求保存更新的员工信誉数据
$.ajax({
url: "/user/updateUserProfile/" + $(this).attr("update-id"),
type: "PUT",
data: $("#userUpdateModal form").serialize(),
success: function (result) {
if (result.code === 100) {
$("#userUpdateModal").modal('hide');
$.alert('用户信誉修改成功!');
setTimeout(function () {
var pageNum = [[${userPageInfo.pageNum}]];
var pageSize = [[${userPageInfo.pageSize}]];
location.href = "/admin/userinfo/toReputation.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('用户信誉修改失败!');
}
}
});
});
//清空表单样式及内容
function reset_form(ele) {
$(ele)[0].reset();
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//清空表单样式
function clean_form(ele) {
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//显示校验结果的提示信息
function show_validate_msg(ele, status, msg) {
//清除当前元素的校验状态
$(ele).parent().removeClass("has-success has-error");
$(ele).next("span").text("");
if ("success" === status) {
$(ele).parent().addClass("has-success");
$(ele).next("span").text(msg);
} else if ("error" === status) {
$(ele).parent().addClass("has-error");
$(ele).next("span").text(msg);
}
}
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/admin/userinfo/reputation.html
|
HTML
|
mit
| 16,217
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>后台管理系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="admin/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="admin/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>用户信息</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">用户名</th>
<th class="info">真实姓名</th>
<th class="info">手机号</th>
<th class="info">邮箱</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="user:${userList}">
<td th:text="${(userPageInfo.pageNum - 1) * userPageInfo.pageSize+userStat.index+1}"></td>
<td th:text="${user.username}"></td>
<td th:text="${user.realname}==null?'未填写':${user.realname}"></td>
<td th:text="${user.phone}==null?'未填写':${user.phone}"></td>
<td th:text="${user.email}==null?'未填写':${user.email}"></td>
<td>
<button class="btn btn-primary btn-sm update_btn"
th:attr="update-id=${user.id}">
<span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span> 编辑
</button>
<button class="btn btn-danger btn-sm delete_btn"
th:attr="delete-id=${user.id},delete-name=${user.username}">
<span class="glyphicon glyphicon-trash"
aria-hidden="true"></span> 删除
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- 显示分页信息 -->
<div class="row">
<!-- 新增按钮 -->
<div class="col-md-1" style="margin-left: 24px">
<button id="user_add_modal_btn" class="btn btn-primary">新增</button>
</div>
<div class="col-md-5">
<div class="btn-group">
<button class="btn btn-default">
<span>页次:</span>
</button>
<button class="btn btn-default">
<span th:text="${userPageInfo.pageNum}+'/'+${userPageInfo.pages}+'页'"></span>
</button>
<button class="btn btn-default">
<span>每页显示:</span>
</button>
<div class="btn-group">
<button id="btnGroupDrop1"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"><span
th:text="${userPageInfo.pageSize}"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li th:each="i:${#numbers.sequence(1,10)}">
<a th:text="${i}"
th:href="@{/admin/userinfo/toUserInfo.html(pageNum=${userPageInfo.pageNum},pageSize=${i})}"></a>
</li>
</ul>
</div>
<button class="btn btn-default">
<span>条</span>
</button>
<button class="btn btn-default">
<span>总记录数:</span>
</button>
<button class="btn btn-default">
<span th:text="${userPageInfo.total}+'条'"></span>
</button>
</div>
</div>
<!-- 分页条信息 -->
<div class="col-md-5">
<nav aria-label="Page navigation">
<ul class="pagination pagination-lg pull-right"
style="margin-top: 0">
<li>
<a th:href="@{/admin/userinfo/toUserInfo.html(pageNum=1,pageSize=${userPageInfo.pageSize})}">首页</a>
</li>
<li th:if="${userPageInfo.hasPreviousPage }"><a
th:href="@{/admin/userinfo/toUserInfo.html(pageNum=${userPageInfo.pageNum}-1,pageSize=${userPageInfo.pageSize})}"
aria-label="Previous"> <span aria-hidden="true">«</span>
</a></li>
<li th:each="page_Num:${userPageInfo.navigatepageNums }"
th:class="${page_Num == userPageInfo.pageNum?'active':''}">
<a th:if="${page_Num == userPageInfo.pageNum}"
th:text="${page_Num}"
th:href="@{#}">
</a>
<a th:text="${page_Num}"
th:if="${page_Num != userPageInfo.pageNum}"
th:href="@{/admin/userinfo/toUserInfo.html(pageNum=${page_Num},pageSize=${userPageInfo.pageSize})}">
</a>
</li>
<li th:if="${userPageInfo.hasNextPage }"><a
th:href="@{/admin/userinfo/toUserInfo.html(pageNum=${userPageInfo.pageNum}+1,pageSize=${userPageInfo.pageSize})}"
aria-label="Next"> <span aria-hidden="true">»</span>
</a></li>
<li><a
th:href="@{/admin/userinfo/toUserInfo.html(pageNum=${userPageInfo.pages},pageSize=${userPageInfo.pageSize})}">末页</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<!-- 新增用户的模态框 -->
<div class="modal fade" id="userAddModal" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">新增用户</h4>
</div>
<div class="modal-body">
<!--要提交的表单 -->
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">用户名:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="username_add_input" name="username"
placeholder="请输入用户名:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">密码:</label>
<div class="col-sm-6">
<input type="password" class="form-control"
id="password_add_input" name="password"
placeholder="请输入密码:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">真实姓名:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="realname_add_input" name="realname"
placeholder="请输入真实姓名:">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">手机号:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="phone_add_input" name="phone"
placeholder="请输入手机号:">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">邮箱:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="email_add_input" name="email"
placeholder="请输入邮箱:">
<span class="help-block"></span>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary"
id="user_save_btn">保存
</button>
</div>
</div>
</div>
</div>
<!-- 修改用户的模态框 -->
<div class="modal fade" id="userUpdateModal" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">修改用户信息</h4>
</div>
<div class="modal-body">
<!--要提交的表单 -->
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">用户名:</label>
<div class="col-sm-6">
<p class="form-control-static"
id="username_update_input">
</p>
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">真实姓名:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="realname_update_input" name="realname"
placeholder="该用户还未填写真实姓名:">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">手机号:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="phone_update_input" name="phone"
placeholder="该用户还未填写手机号:">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">邮箱:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="email_update_input" name="email"
placeholder="该用户还未填写邮箱:">
<span class="help-block"></span>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary"
id="user_update_btn">更新
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script th:src="@{/js/md5.js}"></script>
<script type="text/javascript">
//点击新增按钮弹出模态框。
$("#user_add_modal_btn").click(function () {
//清除表单数据(表单完整重置(表单的数据,表单的样式))
reset_form("#userAddModal form");
//弹出模态框
$("#userAddModal").modal({
//点击增加框背景不删除增加框
backdrop: "static"
});
});
//点击保存,保存新增用户信息。
$("#user_save_btn").click(function () {
//清空表单样式
clean_form("#userAddModal form");
var username = $("#username_add_input").val();
var password = $("#password_add_input").val();
var realname = $("#realname_add_input").val();
var phone = $("#phone_add_input").val();
var email = $("#email_add_input").val();
//匹配中文、英文、数字包括下划线(用户名)
var usernameRegex = /^[\u4E00-\u9FA5A-Za-z0-9_]+$/;
if (username.length === 0) {
show_validate_msg("#username_add_input",
"error", "用户名为空");
return false;
} else if (usernameRegex.test(username) === false) {
show_validate_msg("#username_add_input",
"error", "用户名不合法(用户名只能由中文、数字、英文和下划线组成)");
return false;
}
//匹配6-40位由数字、英文字母或者下划线组成的字符串(密码)
var passwordRegex = /^\w{6,40}$/;
if (password.length === 0) {
show_validate_msg("#password_add_input",
"error", "密码为空");
return false;
} else if (passwordRegex.test(password) === false) {
show_validate_msg("#password_add_input",
"error", "输入密码不合法(密码只能由数字、英文和下划线组成)");
return false;
}
//匹配汉字(真实姓名)
var realnameRegex = /^[\u4e00-\u9fa5]{2,10}$/;
if (realname.length !== 0) {
if (realnameRegex.test(realname) === false) {
show_validate_msg("#realname_add_input",
"error", "真实姓名不合法");
return false;
}
}
//匹配手机号码
var phoneRegex = /^1[3,5,8]\d{9}$/;
if (phone.length !== 0) {
if (phoneRegex.test(phone) === false) {
show_validate_msg("#phone_add_input",
"error", "手机号不合法");
return false;
}
}
//匹配邮箱
var emailRegex = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if (email.length !== 0) {
if (emailRegex.test(email) === false) {
show_validate_msg("#email_add_input",
"error", "邮箱不合法");
return false;
}
}
var pwd = $("#password").val();
$("#password").val($.md5(pwd));
//2、发送ajax请求保存用户
$.ajax({
url: "/user/addUser",
type: "POST",
data: $("#userAddModal form").serialize(),
success: function (result) {
if (result.code === 100) {
$("#userAddModal").modal('hide');
$.alert('用户新增成功!');
setTimeout(function () {
var pageNum = [[${userPageInfo.pages}]];
var pageSize = [[${userPageInfo.pageSize}]];
location.href = "/admin/userinfo/toUserInfo.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('用户新增失败!');
}
}
});
});
//点击编辑按钮时触发事件
$(document).on("click", ".update_btn", function () {
//根据用户id发送ajax请求,查出用户信息并显示
getUserInfo($(this).attr("update-id"));
//把用户的id传递给模态框的更新按钮
$("#user_update_btn").attr("update-id", $(this).attr("update-id"));
$("#userUpdateModal").modal({
backdrop: "static"
});
});
//根据id查出用户信息并显示
function getUserInfo(id) {
$.ajax({
url: "/user/getUserById/" + id,
type: "GET",
success: function (result) {
var user = result.extend.user;
//显示数据之前先清除一下校验样式,如果有的话
reset_form("#userUpdateModal form");
$("#username_update_input").text(user.username);
$("#realname_update_input").val(user.realname);
$("#phone_update_input").val(user.phone);
$("#email_update_input").val(user.email);
}
});
}
//点击更新,更新用户信息
$("#user_update_btn").click(function () {
//清空表单样式
clean_form("#userUpdateModal form");
var realname = $("#realname_update_input").val();
var phone = $("#phone_update_input").val();
var email = $("#email_update_input").val();
//匹配汉字(真实姓名)
var realnameRegex = /^[\u4e00-\u9fa5]{2,10}$/;
if (realnameRegex.test(realname) === false) {
show_validate_msg("#realname_update_input",
"error", "真实姓名不合法");
return false;
}
//匹配手机号码
var phoneRegex = /^1[3,5,8]\d{9}$/;
if (phoneRegex.test(phone) === false) {
show_validate_msg("#phone_update_input",
"error", "手机号不合法");
return false;
}
//匹配邮箱
var emailRegex = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if (emailRegex.test(email) === false) {
show_validate_msg("#email_update_input",
"error", "邮箱不合法");
return false;
}
//2、发送ajax请求保存更新的员工数据
$.ajax({
url: "/user/updateUserProfile/" + $(this).attr("update-id"),
type: "PUT",
data: $("#userUpdateModal form").serialize(),
success: function (result) {
if (result.code === 100) {
$("#userUpdateModal").modal('hide');
$.alert('用户信息修改成功!');
setTimeout(function () {
var pageNum = [[${userPageInfo.pageNum}]];
var pageSize = [[${userPageInfo.pageSize}]];
location.href = "/admin/userinfo/toUserInfo.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('用户信息修改失败!');
}
}
});
});
//单个删除
$(document).on("click", ".delete_btn", function () {
//1、弹出是否确认删除对话框
var id = $(this).attr("delete-id");
var username = $(this).attr("delete-name");
$.alert({
title: '提示:',
content: "确定删除用户 <strong>" + username + "</strong> 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/user/deleteUserById/" + id,
type: "DELETE",
success: function (result) {
if (result.code === 100) {
$.alert('删除该用户成功!');
setTimeout(function () {
var pageNum = [[${userPageInfo.pageNum}]];
var pageSize = [[${userPageInfo.pageSize}]];
location.href = "/admin/userinfo/toUserInfo.html?pageNum=" + pageNum + "&pageSize=" + pageSize;
}, 1000);
} else {
$.alert('删除该用户失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
});
//清空表单样式及内容
function reset_form(ele) {
$(ele)[0].reset();
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//清空表单样式
function clean_form(ele) {
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//显示校验结果的提示信息
function show_validate_msg(ele, status, msg) {
//清除当前元素的校验状态
$(ele).parent().removeClass("has-success has-error");
$(ele).next("span").text("");
if ("success" === status) {
$(ele).parent().addClass("has-success");
$(ele).next("span").text(msg);
} else if ("error" === status) {
$(ele).parent().addClass("has-error");
$(ele).next("span").text(msg);
}
}
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/admin/userinfo/userinfo.html
|
HTML
|
mit
| 30,317
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>404界面</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
<style>
body {
background-color: #fff;
}
.error-page {
height: 100%;
position: fixed;
width: 100%;
}
.error-body {
padding-top: 5%;
}
.error-body h1 {
font-size: 210px;
font-weight: 700;
text-shadow: 4px 4px 0 #f5f6fa, 6px 6px 0 #33cabb;
line-height: 210px;
color: #33cabb;
}
.error-body h4 {
margin: 30px 0px;
}
</style>
</head>
<body>
<section class="error-page">
<div class="error-box">
<div class="error-body text-center">
<h1>404</h1>
<h4>很抱歉,但是那个页面看起来已经不存在了。</h4>
<a th:href="@{/toindex.html}"
class="btn btn-primary ">返回首页</a>
</div>
</div>
</section>
<!-- 点线粒子插件 -->
<script color="255,0,255" opacity='0.8'
zIndex="9999" count="99"
th:src="@{/js/canvas-nest.js}"></script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/error/404.html
|
HTML
|
mit
| 1,750
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>500界面</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
<style>
body {
background-color: #fff;
}
.error-page {
height: 100%;
position: fixed;
width: 100%;
}
.error-body {
padding-top: 5%;
}
.error-body h1 {
font-size: 210px;
font-weight: 700;
text-shadow: 4px 4px 0 #f5f6fa, 6px 6px 0 #33cabb;
line-height: 210px;
color: #33cabb;
}
.error-body h4 {
margin: 30px 0px;
}
</style>
</head>
<body>
<section class="error-page">
<div class="error-box">
<div class="error-body text-center">
<h1>500</h1>
<h4>很抱歉,但是那个页面看起来已经不存在了。</h4>
<a th:href="@{/toindex.html}"
class="btn btn-primary ">返回首页</a>
</div>
</div>
</section>
<!-- 点线粒子插件 -->
<script color="255,0,255" opacity='0.8'
zIndex="9999" count="99"
th:src="@{/js/canvas-nest.js}"></script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/error/500.html
|
HTML
|
mit
| 1,750
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>个人理财系统登录界面</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
<style>
.lear-wrapper {
position: relative;
}
.lear-login {
display: flex !important;
min-height: 100vh;
align-items: center !important;
justify-content: center !important;
}
.login-center1 {
background: #fff;
min-width: 38.25rem;
padding: 2.14286em 3.57143em;
border-radius: 5px;
margin: 2.85714em 0;
}
.login-header {
margin-bottom: 1.5rem !important;
}
.login-center .has-feedback.feedback-left .form-control {
padding-left: 38px;
padding-right: 12px;
}
.login-center .has-feedback.feedback-left .form-control-feedback {
left: 0;
right: auto;
width: 38px;
height: 38px;
line-height: 38px;
z-index: 4;
color: #dcdcdc;
}
.login-center .has-feedback.feedback-left.row .form-control-feedback {
left: 15px;
}
</style>
</head>
<body>
<div class="row lear-wrapper">
<div class="lear-login">
<div class="login-center1">
<div class="login-header text-center">
<h1>理财应用</h1>
</div>
<form>
<div class="form-group has-feedback feedback-left">
<input type="text" placeholder="请输入您的用户名" class="form-control"
name="username" id="username"/><span class="help-block"></span>
<span class="mdi mdi-account form-control-feedback"
aria-hidden="true"></span>
</div>
<div class="form-group has-feedback feedback-left">
<input type="password" placeholder="请输入密码" class="form-control"
id="password" name="password"/><span class="help-block"></span>
<span class="mdi mdi-lock form-control-feedback"
aria-hidden="true"></span>
</div>
<div id="captcha_note_parent"
class="form-group has-feedback feedback-left row">
<div class="col-xs-7">
<input type="text" id="captcha" name="captcha"
class="form-control" placeholder="请输入验证码">
</div>
<div class="col-xs-5">
<canvas id="canvas" width="120" height="45"></canvas>
</div>
<span id="captcha_note_child" class="help-block"
style="margin-left: 15px"></span>
</div>
<div class="form-group">
<button id="login_btn" class="btn btn-block btn-primary"
type="button">立即登录
</button>
</div>
</form>
<div style="margin-left: 100px">
<a th:href="@{/toregister.html}">还没有账号?去注册</a>
</div>
</div>
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<script th:src="@{/js/md5.js}"></script>
<!-- 点线粒子插件 -->
<script color="255,0,255" opacity='0.8'
zIndex="9999" count="99"
src="/js/canvas-nest.js" th:src="@{/js/canvas-nest.js}"></script>
<script>
var show_num = [];
$(function () {
$("input[name='username']").blur(verifyUsername);
$("input[name='password']").change(removeLoginDisabled);
//生成图片验证码
drawPic(show_num);
$("#canvas").click(function (e) {
//取消事件的默认动作。
e.preventDefault();
drawPic(show_num);
});
$("#captcha").blur(verifyCaptcha);
$("#login_btn").mousedown(verifyLogin);
//回车登录
$("body").keyup(function (event) {
if (event.keyCode === 13) {//keyCode=13是回车键
verifyLogin();
}
});
});
function verifyCaptcha() {
var captcha_num = $("#captcha").val().toLowerCase();
var real_num = show_num.join("");
$("#captcha_note_parent").removeClass("has-success has-error");
$("#captcha_note_child").text("");
if (captcha_num == "") {
$("#captcha_note_parent").addClass("has-error");
$("#captcha_note_child").text("验证码为空");
$("#login_btn").attr("disabled", "disabled");
return false;
} else if (captcha_num == real_num) {
$("#captcha_note_parent").addClass("has-success");
$("#captcha_note_child").text("验证码正确");
$("#login_btn").removeAttr("disabled");
return true;
} else {
$("#captcha_note_parent").addClass("has-error");
$("#captcha_note_child").text("验证码错误");
$("#login_btn").attr("disabled", "disabled");
return false;
}
}
function verifyUsername() {
//发送ajax请求校验用户名是否可用
var username = document.getElementById("username").value;
var lock = true;
if (username === "") {
show_validate_msg("#username", "error", "用户名为空");
$("#login_btn").attr("disabled", "disabled");
return false;
} else {
$.ajax({
url: "/login/loginVerifyUsername/"+username,
type: "GET",
success: function (result) {
if (result.code === 200) {
show_validate_msg("#username", "error",
"用户名不存在");
$("#login_btn")
.attr("disabled", "disabled");
lock = false;
} else {
show_validate_msg("#username", "success",
"欢迎" + username + "登录");
$("#login_btn").removeAttr("disabled");
}
}
});
return lock;
}
}
function removeLoginDisabled() {
$("#login_btn").removeAttr("disabled");
}
function verifyLogin() {
$("input[name='username']").blur(verifyUsername);
$("#captcha").blur(verifyCaptcha);
if ($("#username").val() == "") {
show_validate_msg("#username", "error", "用户名为空");
$("#login_btn").attr("disabled", "disabled");
return false;
}
if ($("#password").val() == "") {
show_validate_msg("#password", "error", "密码为空");
$("#login_btn").attr("disabled", "disabled");
return false;
}
if ($("#captcha").val() == "") {
$("#captcha_note_parent").addClass("has-error");
$("#captcha_note_child").text("验证码为空");
$("#login_btn").attr("disabled", "disabled");
return false;
}
//alert(verifyUsername);
if (verifyUsername() && verifyCaptcha()) {
var pwd = $("#password").val();
$("#password").val($.md5(pwd));
console.log($("#password").val())
$.ajax({
url: "/login/verifyLogin",
type: "GET",
data: {
"username": $("#username").val(),
"password": $("#password").val()
},
success: function (result) {
if (result.code === 100) {
var url = result.extend.url;
//alert(url);
location.href = url;
} else {
show_validate_msg("#password", "error",
"密码错误");
$("#login_btn")
.attr("disabled", "disabled");
}
}
})
}
}
//显示校验结果的提示信息
function show_validate_msg(ele, status, msg) {
//清除当前元素的校验状态
$(ele).parent().removeClass("has-success has-error");
$(ele).next("span").text("");
if ("success" === status) {
$(ele).parent().addClass("has-success");
$(ele).next("span").text(msg);
} else if ("error" === status) {
$(ele).parent().addClass("has-error");
$(ele).next("span").text(msg);
}
}
/**生成一个随机数**/
function randomNum(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
/**生成一个随机色**/
function randomColor(min, max) {
var r = randomNum(min, max);
var g = randomNum(min, max);
var b = randomNum(min, max);
return "rgb(" + r + "," + g + "," + b + ")";
}
/**绘制验证码图片**/
function drawPic(show_num) {
var canvas = document.getElementById("canvas");
var width = canvas.width;
var height = canvas.height;
var ctx = canvas.getContext('2d');
ctx.textBaseline = 'bottom';
/**绘制背景色**/
ctx.fillStyle = randomColor(280, 280); //颜色若太深可能导致看不清
ctx.fillRect(0, 0, width, height);
/**绘制文字**/
var sCode = "A,B,C,E,F,G,H,J,K,L,M,N,P,Q,R,S,T,W,X,Y,Z,1,2,3,4,5,6,7,8,9,0";
var aCode = sCode.split(",");
for (var i = 0; i < 4; i++) {
var txt = aCode[randomNum(0, aCode.length)];//得到随机的一个内容
show_num[i] = txt.toLowerCase();
ctx.fillStyle = randomColor(50, 160); //随机生成字体颜色
ctx.font = randomNum(15, 40) + 'px SimHei'; //随机生成字体大小
var x = 10 + i * 25;
var y = randomNum(25, 45);
var deg = randomNum(-45, 45);
//修改坐标原点和旋转角度
ctx.translate(x, y);
ctx.rotate(deg * Math.PI / 180);
ctx.fillText(txt, 0, 0);
//恢复坐标原点和旋转角度
ctx.rotate(-deg * Math.PI / 180);
ctx.translate(-x, -y);
}
}
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/login.html
|
HTML
|
mit
| 11,226
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>个人理财系统注册界面</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
<style>
.lear-wrapper {
position: relative;
}
.lear-login {
display: flex !important;
min-height: 100vh;
align-items: center !important;
justify-content: center !important;
}
.login-center1 {
background: #fff;
min-width: 38.25rem;
padding: 2.14286em 3.57143em;
border-radius: 5px;
margin: 2.85714em 0;
}
.login-header {
margin-bottom: 1.5rem !important;
}
.login-center .has-feedback.feedback-left .form-control {
padding-left: 38px;
padding-right: 12px;
}
.login-center .has-feedback.feedback-left .form-control-feedback {
left: 0;
right: auto;
width: 38px;
height: 38px;
line-height: 38px;
z-index: 4;
color: #dcdcdc;
}
.login-center .has-feedback.feedback-left.row .form-control-feedback {
left: 15px;
}
</style>
</head>
<body>
<div class="row lear-wrapper">
<div class="lear-login">
<div class="login-center1">
<div class="login-header text-center">
<h1>——注册账号——</h1>
</div>
<form>
<div class="form-group has-feedback feedback-left">
<input type="text" placeholder="请输入您的用户名" class="form-control"
name="username" id="username"/><span class="help-block"></span>
<span class="mdi mdi-account form-control-feedback"
aria-hidden="true"></span>
</div>
<div class="form-group has-feedback feedback-left">
<input type="password" placeholder="请输入密码" class="form-control"
id="password" name="password"/><span class="help-block"></span>
<span class="mdi mdi-lock form-control-feedback"
aria-hidden="true"></span>
</div>
<div class="form-group has-feedback feedback-left">
<input type="password" placeholder="请重复密码" class="form-control"
id="repassword" name="repassword"/><span class="help-block"></span>
<span class="mdi mdi-lock form-control-feedback"
aria-hidden="true"></span>
</div>
<div id="captcha_note_parent"
class="form-group has-feedback feedback-left row">
<div class="col-xs-7">
<input type="text" id="captcha" name="captcha"
class="form-control" placeholder="请输入验证码">
</div>
<div class="col-xs-5">
<canvas id="canvas" width="120" height="45"></canvas>
</div>
<span id="captcha_note_child" class="help-block"
style="margin-left: 15px"></span>
</div>
<div class="form-group">
<button id="login_btn" class="btn btn-block btn-primary"
type="button">注册
</button>
</div>
</form>
<div style="margin-left: 110px">
<a th:href="@{/tologin.html}">已有账号?去登录</a>
</div>
</div>
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<script th:src="@{/js/md5.js}"></script>
<!-- 点线粒子插件 -->
<script color="255,0,255" opacity='0.8'
zIndex="9999" count="99"
th:src="@{/js/canvas-nest.js}"></script>
<script>
var show_num = [];
$(function () {
$("input[name='username']").blur(verifyUsername);
$("input[name='password']").change(removeLoginDisabled);
$("input[name='repassword']").blur(verifyRepassword);
$("input[name='repassword']").change(removeLoginDisabled);
//生成图片验证码
drawPic(show_num);
$("#canvas").click(function (e) {
//取消事件的默认动作。
e.preventDefault();
drawPic(show_num);
});
$("#captcha").blur(verifyCaptcha);
$("#login_btn").mousedown(verifyLogin);
//回车注册
$("body").keyup(function (event) {
if (event.keyCode === 13) {//keyCode=13是回车键
verifyLogin();
}
});
});
function verifyCaptcha() {
var captcha_num = $("#captcha").val().toLowerCase();
var real_num = show_num.join("");
$("#captcha_note_parent").removeClass("has-success has-error");
$("#captcha_note_child").text("");
if (captcha_num == "") {
$("#captcha_note_parent").addClass("has-error");
$("#captcha_note_child").text("验证码为空");
$("#login_btn").attr("disabled", "disabled");
return false;
} else if (captcha_num == real_num) {
$("#captcha_note_parent").addClass("has-success");
$("#captcha_note_child").text("验证码正确");
$("#login_btn").removeAttr("disabled");
return true;
} else {
$("#captcha_note_parent").addClass("has-error");
$("#captcha_note_child").text("验证码错误");
$("#login_btn").attr("disabled", "disabled");
return false;
}
}
function verifyUsername() {
//发送ajax请求校验用户名是否可用
var username = document.getElementById("username").value;
var lock = true;
if (username === "") {
show_validate_msg("#username", "error", "用户名为空");
$("#login_btn").attr("disabled", "disabled");
return false;
} else {
$.ajax({
url: "/login/loginVerifyUsername/"+username,
type: "GET",
success: function (result) {
if (result.code === 100) {
show_validate_msg("#username", "error",
"用户"+username+"已存在");
$("#login_btn")
.attr("disabled", "disabled");
lock = false;
} else {
show_validate_msg("#username", "success",
"欢迎" + username + "注册");
$("#login_btn").removeAttr("disabled");
}
}
});
return lock;
}
}
function verifyRepassword() {
//判断重复密码是否相同
var password = document.getElementById("password").value;
var repassword = document.getElementById("repassword").value;
if (repassword === "") {
show_validate_msg("#repassword", "error", "重复密码为空");
$("#login_btn").attr("disabled", "disabled");
return false;
} else if (password===""){
show_validate_msg("#repassword", "error", "上一项密码为空");
$("#login_btn").attr("disabled", "disabled");
return false;
}else{
if (repassword===password){
show_validate_msg("#repassword", "success",
"重复密码相同");
$("#login_btn").removeAttr("disabled");
return true;
}else{
show_validate_msg("#repassword", "error", "两次密码不相同");
$("#login_btn").attr("disabled", "disabled");
return false;
}
}
}
function removeLoginDisabled() {
$("#login_btn").removeAttr("disabled");
}
function verifyLogin() {
$("input[name='username']").blur(verifyUsername);
$("#captcha").blur(verifyCaptcha);
$("#repassword").blur(verifyRepassword);
if ($("#username").val() == "") {
show_validate_msg("#username", "error", "用户名为空");
$("#login_btn").attr("disabled", "disabled");
return false;
}
if ($("#password").val() == "") {
show_validate_msg("#password", "error", "密码为空");
$("#login_btn").attr("disabled", "disabled");
return false;
}
if ($("#repassword").val() == "") {
show_validate_msg("#repassword", "error", "重复密码为空");
$("#login_btn").attr("disabled", "disabled");
return false;
}
if ($("#captcha").val() == "") {
$("#captcha_note_parent").addClass("has-error");
$("#captcha_note_child").text("验证码为空");
$("#login_btn").attr("disabled", "disabled");
return false;
}
if (verifyUsername() && verifyCaptcha() && verifyRepassword()) {
var pwd = $("#password").val();
var newpwd = $.md5(pwd);
$("#password").val(newpwd);
$("#repassword").val(newpwd)
$.ajax({
url: "/login/register",
type: "POST",
data: {
"username": $("#username").val(),
"password": $("#password").val()
},
success: function (result) {
if (result.code === 100) {
var url = result.extend.url;
//alert(url);
location.href = url;
} else {
show_validate_msg("#password", "error",
"密码错误");
$("#login_btn")
.attr("disabled", "disabled");
}
}
})
}
}
//显示校验结果的提示信息
function show_validate_msg(ele, status, msg) {
//清除当前元素的校验状态
$(ele).parent().removeClass("has-success has-error");
$(ele).next("span").text("");
if ("success" === status) {
$(ele).parent().addClass("has-success");
$(ele).next("span").text(msg);
} else if ("error" === status) {
$(ele).parent().addClass("has-error");
$(ele).next("span").text(msg);
}
}
/**生成一个随机数**/
function randomNum(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
/**生成一个随机色**/
function randomColor(min, max) {
var r = randomNum(min, max);
var g = randomNum(min, max);
var b = randomNum(min, max);
return "rgb(" + r + "," + g + "," + b + ")";
}
/**绘制验证码图片**/
function drawPic(show_num) {
var canvas = document.getElementById("canvas");
var width = canvas.width;
var height = canvas.height;
var ctx = canvas.getContext('2d');
ctx.textBaseline = 'bottom';
/**绘制背景色**/
ctx.fillStyle = randomColor(280, 280); //颜色若太深可能导致看不清
ctx.fillRect(0, 0, width, height);
/**绘制文字**/
var sCode = "A,B,C,E,F,G,H,J,K,L,M,N,P,Q,R,S,T,W,X,Y,Z,1,2,3,4,5,6,7,8,9,0";
var aCode = sCode.split(",");
for (var i = 0; i < 4; i++) {
var txt = aCode[randomNum(0, aCode.length)];//得到随机的一个内容
show_num[i] = txt.toLowerCase();
ctx.fillStyle = randomColor(50, 160); //随机生成字体颜色
ctx.font = randomNum(15, 40) + 'px SimHei'; //随机生成字体大小
var x = 10 + i * 25;
var y = randomNum(25, 45);
var deg = randomNum(-45, 45);
//修改坐标原点和旋转角度
ctx.translate(x, y);
ctx.rotate(deg * Math.PI / 180);
ctx.fillText(txt, 0, 0);
//恢复坐标原点和旋转角度
ctx.rotate(-deg * Math.PI / 180);
ctx.translate(-x, -y);
}
}
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/register.html
|
HTML
|
mit
| 13,093
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en"
xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<meta charset="UTF-8">
<title>topbar</title>
</head>
<body>
<!--左侧导航-->
<aside class="lyear-layout-sidebar" id="leftbaraside">
<div id="logo" class="sidebar-header">
<a class="navbar-brand" style="font-size: 20px"
th:href="@{/user/index.html}">个人理财系统</a>
</div>
<div class="lyear-layout-sidebar-scroll">
<nav class="sidebar-main">
<ul class="nav nav-drawer">
<li class="nav-item" th:class="${activeUrl=='indexActive'?'nav-item active':'nav-item'}"><a
th:href="@{/user/index.html}"><i
class="mdi mdi-home"></i>系统首页</a></li>
<li shiro:hasPermission="user:finance" class="nav-item nav-item-has-subnav"
th:class="${activeUrl1=='financeActive'?'nav-item nav-item-has-subnav active open':'nav-item nav-item-has-subnav'}">
<a href="javascript:void(0)"><i class="mdi mdi-square-inc-cash"></i>
个人理财</a>
<ul class="nav nav-subnav">
<li shiro:hasPermission="user:changeMoney" th:class="${activeUrl2=='changeMoneyActive'?'active':''}"><a
th:href="@{/user/finance/toChangeMoney.html}">零钱理财</a></li>
<li shiro:hasPermission="user:payMoney" th:class="${activeUrl2=='payMoneyActive'?'active':''}"><a
th:href="@{/user/finance/toPayMoney.html}">工资理财</a></li>
<li shiro:hasPermission="user:termFinancial" th:class="${activeUrl2=='termFinancialActive'?'active':''}"><a
th:href="@{/user/finance/toTermFinancial.html}">期限理财</a></li>
<li shiro:hasPermission="user:fundProduct" th:class="${activeUrl2=='fundProductActive'?'active':''}"><a
th:href="@{/user/finance/toFundProduct.html}">基金理财</a></li>
<li shiro:hasPermission="user:bank" th:class="${activeUrl2=='bankActive'?'active':''}"><a
th:href="@{/user/finance/toBank.html}">银行推荐</a></li>
</ul>
</li>
<li shiro:hasPermission="user:tools" class="nav-item nav-item-has-subnav"
th:class="${activeUrl1=='toolsActive'?'nav-item nav-item-has-subnav active open':'nav-item nav-item-has-subnav'}"
><a href="javascript:void(0)"><i class="mdi mdi-wrench"></i>金融工具</a>
<ul class="nav nav-subnav">
<li shiro:hasPermission="user:record" th:class="${activeUrl2=='recordActive'?'active':''}"><a
th:href="@{/user/tools/toRecord.html}">资金记录</a></li>
<li shiro:hasPermission="user:loan" th:class="${activeUrl2=='applyLoanActive'?'active':''}"><a
th:href="@{/user/tools/toApplyLoan.html}">安全网贷</a></li>
</ul>
</li>
<li class="nav-item nav-item-has-subnav"
th:class="${activeUrl1=='personalActive'?'nav-item nav-item-has-subnav active open':'nav-item nav-item-has-subnav'}"
><a href="javascript:void(0)"><i class="mdi mdi-account-location"></i> 个人中心</a>
<ul class="nav nav-subnav">
<li th:class="${activeUrl2=='myFinanceActive'?'active':''}"><a
th:href="@{/user/personal/toMyFinance.html}">我的理财</a></li>
<li th:class="${activeUrl2=='myLoanActive'?'active':''}"><a th:href="@{/user/personal/toMyLoan.html}">我的借贷</a></li>
<li th:class="${activeUrl2=='bankCardActive'?'active':''}"><a th:href="@{/user/personal/toBankCard.html}">银行卡管理</a></li>
<li th:class="${activeUrl2=='securityActive'?'active':''}"><a th:href="@{/user/personal/toSecurity.html}">账户安全</a></li>
</ul>
</li>
</ul>
</nav>
</div>
</aside>
<!--End 左侧导航-->
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/user/common/leftbar.html
|
HTML
|
mit
| 4,347
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta charset="UTF-8">
<title>topbar</title>
</head>
<body>
<!--头部信息-->
<header class="lyear-layout-header" id="topbarheader">
<nav class="navbar navbar-default">
<div class="topbar">
<div class="topbar-left">
<div class="lyear-aside-toggler">
<span class="lyear-toggler-bar"></span> <span
class="lyear-toggler-bar"></span> <span class="lyear-toggler-bar"></span>
</div>
<!--/*@thymesVar id="pageTopBarInfo" type="java.lang.String"*/-->
<span class="navbar-page-title" th:text="${pageTopBarInfo}"></span>
</div>
<ul class="topbar-right">
<!--个人信息-->
<li class="dropdown dropdown-profile" style="margin-right: 20px">
<a href="javascript:void(0)" data-toggle="dropdown"> <img
id="img" class="img-avatar img-avatar-48 m-r-10" src="./images/pic.jpg"
th:src="@{/images/pic.jpg}" th:alt="${session.loginUser.username}"/>
<span th:text="${session.loginUser.username}">
<span class="caret"></span>
</span>
</a>
<ul class="dropdown-menu dropdown-menu-right">
<li><a th:href="@{/user/personal/toProfile.html}"><i
class="mdi mdi-account"></i> 个人信息</a></li>
<li><a th:href="@{/user/personal/toMyInfo.html}"><i
class="mdi mdi-lock-outline"></i> 我的消息</a></li>
<li class="divider"></li>
<li><a th:href="@{/logout(logout='userLogout')}"><i
class="mdi mdi-logout-variant"></i> 退出登录</a></li>
</ul>
<!--切换主题配色-->
<li class="dropdown dropdown-skin"><span
data-toggle="dropdown" class="icon-palette"><i
class="mdi mdi-palette"></i></span>
<ul class="dropdown-menu dropdown-menu-right"
data-stopPropagation="true">
<li class="drop-title"><p>主题</p></li>
<li class="drop-skin-li clearfix"><span class="inverse">
<input type="radio" name="site_theme" value="default"
id="site_theme_1" checked> <label for="site_theme_1"></label>
</span> <span> <input type="radio" name="site_theme" value="dark"
id="site_theme_2"> <label for="site_theme_2"></label>
</span> <span> <input type="radio" name="site_theme"
value="translucent" id="site_theme_3"> <label
for="site_theme_3"></label>
</span></li>
<li class="drop-title"><p>LOGO</p></li>
<li class="drop-skin-li clearfix"><span class="inverse">
<input type="radio" name="logo_bg" value="default"
id="logo_bg_1" checked> <label for="logo_bg_1"></label>
</span> <span> <input type="radio" name="logo_bg" value="color_2"
id="logo_bg_2"> <label for="logo_bg_2"></label>
</span> <span> <input type="radio" name="logo_bg" value="color_3"
id="logo_bg_3"> <label for="logo_bg_3"></label>
</span> <span> <input type="radio" name="logo_bg" value="color_4"
id="logo_bg_4"> <label for="logo_bg_4"></label>
</span> <span> <input type="radio" name="logo_bg" value="color_5"
id="logo_bg_5"> <label for="logo_bg_5"></label>
</span> <span> <input type="radio" name="logo_bg" value="color_6"
id="logo_bg_6"> <label for="logo_bg_6"></label>
</span> <span> <input type="radio" name="logo_bg" value="color_7"
id="logo_bg_7"> <label for="logo_bg_7"></label>
</span> <span> <input type="radio" name="logo_bg" value="color_8"
id="logo_bg_8"> <label for="logo_bg_8"></label>
</span></li>
<li class="drop-title"><p>头部</p></li>
<li class="drop-skin-li clearfix"><span class="inverse">
<input type="radio" name="header_bg" value="default"
id="header_bg_1" checked> <label for="header_bg_1"></label>
</span> <span> <input type="radio" name="header_bg"
value="color_2" id="header_bg_2"> <label
for="header_bg_2"></label>
</span> <span> <input type="radio" name="header_bg"
value="color_3" id="header_bg_3"> <label
for="header_bg_3"></label>
</span> <span> <input type="radio" name="header_bg"
value="color_4" id="header_bg_4"> <label
for="header_bg_4"></label>
</span> <span> <input type="radio" name="header_bg"
value="color_5" id="header_bg_5"> <label
for="header_bg_5"></label>
</span> <span> <input type="radio" name="header_bg"
value="color_6" id="header_bg_6"> <label
for="header_bg_6"></label>
</span> <span> <input type="radio" name="header_bg"
value="color_7" id="header_bg_7"> <label
for="header_bg_7"></label>
</span> <span> <input type="radio" name="header_bg"
value="color_8" id="header_bg_8"> <label
for="header_bg_8"></label>
</span></li>
<li class="drop-title"><p>侧边栏</p></li>
<li class="drop-skin-li clearfix"><span class="inverse">
<input type="radio" name="sidebar_bg" value="default"
id="sidebar_bg_1" checked> <label for="sidebar_bg_1"></label>
</span> <span> <input type="radio" name="sidebar_bg"
value="color_2" id="sidebar_bg_2"> <label
for="sidebar_bg_2"></label>
</span> <span> <input type="radio" name="sidebar_bg"
value="color_3" id="sidebar_bg_3"> <label
for="sidebar_bg_3"></label>
</span> <span> <input type="radio" name="sidebar_bg"
value="color_4" id="sidebar_bg_4"> <label
for="sidebar_bg_4"></label>
</span> <span> <input type="radio" name="sidebar_bg"
value="color_5" id="sidebar_bg_5"> <label
for="sidebar_bg_5"></label>
</span> <span> <input type="radio" name="sidebar_bg"
value="color_6" id="sidebar_bg_6"> <label
for="sidebar_bg_6"></label>
</span> <span> <input type="radio" name="sidebar_bg"
value="color_7" id="sidebar_bg_7"> <label
for="sidebar_bg_7"></label>
</span> <span> <input type="radio" name="sidebar_bg"
value="color_8" id="sidebar_bg_8"> <label
for="sidebar_bg_8"></label>
</span></li>
</ul>
</li>
<!--切换主题配色-->
</li>
</ul>
</div>
</nav>
</header>
<!--End 头部信息-->
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/user/common/topbar.html
|
HTML
|
mit
| 8,389
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>个人理财系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="user/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="user/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>银行推荐</h4>
</div>
</div>
</div>
<div th:if="${!bankList.isEmpty()}" th:each="bank:${bankList}">
<div class="col-sm-12">
<div class="card">
<div class="card-header bg-primary">
<h4 th:text="${bank.name+' ('+bank.type+')'}"></h4>
<ul class="card-actions">
<li>
<h4 th:text="${'资产:'+bank.assets}"></h4>
</li>
</ul>
</div>
<div class="card-body">
<div th:utext="${bank.bankdesc}"></div>
</div>
</div>
</div>
</div>
<div th:if="${bankList.isEmpty()}" class="card-body">
<div class="table-responsive">
<h4>很抱歉!暂时还没有银行向您推荐</h4>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/user/finance/bank.html
|
HTML
|
mit
| 3,088
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>个人理财系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="user/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="user/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>零钱理财推荐</h4>
</div>
<div th:if="${!changeMoneyList.isEmpty()}" class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">产品名称</th>
<th class="info">七日年化收益率</th>
<th class="info">每万元收益</th>
<th class="info">投资期限</th>
<th class="info">起投金额</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="cm:${changeMoneyList}">
<td th:text="${cmStat.index+1}"></td>
<td th:text="${cm.name}"></td>
<td th:text="${#numbers.formatDecimal(cm.annualincome*100,1,3)}+'%'"></td>
<td th:text="${#numbers.formatDecimal(cm.peiincome,1,2)}+'元'"></td>
<td th:text="${cm.investerm}"></td>
<td th:text="${cm.invesmoney}+'元'"></td>
<td>
<button class="btn btn-primary btn-sm buy_btn"
th:attr="buyBtnId=${cm.id},buyBtnName=${cm.name}">
<span class="glyphicon glyphicon-usd"
aria-hidden="true"></span> 投资
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div th:if="${changeMoneyList.isEmpty()}" class="card-body">
<div class="table-responsive">
<h4>很抱歉!暂时还没有零钱理财向您推荐</h4>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script th:inline="javascript">
$(document).on("click",".buy_btn",function () {
var changeMoneyId = $(this).attr("buyBtnId");
var userId = [[${session.loginUser.id}]];
//alert(userId);
var name = $(this).attr("buyBtnName");
$.alert({
title: '提示:',
content: "确定买入 <strong>"+name+"</strong> 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function(){
$.ajax({
url : "/user/buyChangeMoney",
type : "POST",
data : {
"changeMoneyId":changeMoneyId,
"userId":userId
},
success : function(result) {
if (result.code===100){
$.alert('买入成功!');
}else {
$.alert('买入失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
})
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/user/finance/changemoney.html
|
HTML
|
mit
| 6,289
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>个人理财系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="user/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="user/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>基金理财推荐</h4>
</div>
<div th:if="${!fundProductList.isEmpty()}" class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">基金代码</th>
<th class="info">基金简称</th>
<th class="info">基金类型</th>
<th class="info">日增长率</th>
<th class="info">月增长率</th>
<th class="info">年增长率</th>
<th class="info">起投金额</th>
<th class="info">投资期限</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="fp:${fundProductList}">
<td th:text="${fpStat.index+1}"></td>
<td th:text="${fp.code}"></td>
<td th:text="${fp.funddesc}"></td>
<td th:if="${fp.type==1}" th:text="股票型基金"></td><td th:if="${fp.type==2}" th:text="债券型基金"></td>
<td th:if="${fp.type==3}" th:text="货币型基金"></td><td th:if="${fp.type==4}" th:text="混合型基金"></td>
<td th:text="${#numbers.formatDecimal(fp.dailygrowth*100,1,2)}+'%'"></td>
<td th:text="${#numbers.formatDecimal(fp.monthlygrowth*100,1,2)}+'%'"></td>
<td th:text="${#numbers.formatDecimal(fp.annualgrowth*100,1,2)}+'%'"></td>
<td th:text="${#numbers.formatDecimal(fp.leastmoney,1,2)}+'元'"></td>
<td th:text="${fp.investerm}"></td>
<td>
<button class="btn btn-primary btn-sm buy_btn"
th:attr="buyBtnId=${fp.id},buyBtnName=${fp.funddesc}">
<span class="glyphicon glyphicon-usd"
aria-hidden="true"></span> 投资
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div th:if="${fundProductList.isEmpty()}" class="card-body">
<div class="table-responsive">
<h4>很抱歉!暂时还没有基金理财向您推荐</h4>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script th:inline="javascript">
$(document).on("click",".buy_btn",function () {
var fundProductId = $(this).attr("buyBtnId");
var userId = [[${session.loginUser.id}]];
//alert(userId);
var name = $(this).attr("buyBtnName");
$.alert({
title: '提示:',
content: "确定买入 <strong>"+name+"</strong> 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function(){
$.ajax({
url : "/user/buyFundProduct",
type : "POST",
data : {
"fundProductId":fundProductId,
"userId":userId
},
success : function(result) {
if (result.code===100){
$.alert('买入成功!');
}else {
$.alert('买入失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
})
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/user/finance/fundproduct.html
|
HTML
|
mit
| 7,067
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>个人理财系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="user/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="user/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>工资理财推荐</h4>
</div>
<div th:if="${!payMoneyList.isEmpty()}" class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">产品类型</th>
<th class="info">每月金额设定</th>
<th class="info">自动转入</th>
<th class="info">投资期限</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="pm:${payMoneyList}">
<td th:text="${pmStat.index+1}"></td>
<td th:if="${pm.type==1}" th:text="国债"></td><td th:if="${pm.type==2}" th:text="期货"></td>
<td th:text="${#numbers.formatDecimal(pm.monthmoney,1,2)}"></td>
<td th:if="${pm.autointo==1}" th:text="是"></td><td th:if="${pm.autointo==2}" th:text="否"></td>
<td th:text="${pm.investerm}"></td>
<td>
<button class="btn btn-primary btn-sm buy_btn"
th:attr="buyBtnId=${pm.id},buyBtnName=${pm.type}">
<span class="glyphicon glyphicon-usd"
aria-hidden="true"></span> 投资
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div th:if="${payMoneyList.isEmpty()}" class="card-body">
<div class="table-responsive">
<h4>很抱歉!暂时还没有工资理财向您推荐</h4>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script th:inline="javascript">
$(document).on("click",".buy_btn",function () {
var payMoneyId = $(this).attr("buyBtnId");
var userId = [[${session.loginUser.id}]];
//alert(userId);
var type = $(this).attr("buyBtnName");
var name;
if (type==1){
name="国债"
}else{
name="期货";
}
$.alert({
title: '提示:',
content: "确定买入该 <strong>"+name+"</strong> 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function(){
$.ajax({
url : "/user/buyPayMoney",
type : "POST",
data : {
"payMoneyId":payMoneyId,
"userId":userId
},
success : function(result) {
if (result.code===100){
$.alert('买入成功!');
}else {
$.alert('买入失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
})
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/user/finance/paymoney.html
|
HTML
|
mit
| 6,302
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>个人理财系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="user/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="user/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>期限理财推荐</h4>
</div>
<div th:if="${!termFinancialList.isEmpty()}" class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">产品名称</th>
<th class="info">收益方式</th>
<th class="info">七日年化收益率</th>
<th class="info">起投金额</th>
<th class="info">投资期限</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="tf:${termFinancialList}">
<td th:text="${tfStat.index+1}"></td>
<td th:text="${tf.name}"></td>
<td th:if="${tf.profit==1}" th:text="收益性"></td><td th:if="${tf.profit==2}" th:text="净值型"></td>
<td th:text="${#numbers.formatDecimal(tf.annualincome*100,1,2)}+'%'"></td>
<td th:text="${#numbers.formatDecimal(tf.leastmoney,1,2)}+'元'"></td>
<td th:text="${tf.investerm}"></td>
<td>
<button class="btn btn-primary btn-sm buy_btn"
th:attr="buyBtnId=${tf.id},buyBtnName=${tf.name}">
<span class="glyphicon glyphicon-usd"
aria-hidden="true"></span> 投资
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div th:if="${termFinancialList.isEmpty()}" class="card-body">
<div class="table-responsive">
<h4>很抱歉!暂时还没有期限理财向您推荐</h4>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script th:inline="javascript">
$(document).on("click",".buy_btn",function () {
var termFinancialId = $(this).attr("buyBtnId");
var userId = [[${session.loginUser.id}]];
//alert(userId);
var name = $(this).attr("buyBtnName");
$.alert({
title: '提示:',
content: "确定买入 <strong>"+name+"</strong> 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function(){
$.ajax({
url : "/user/buyTermFinancial",
type : "POST",
data : {
"termFinancialId":termFinancialId,
"userId":userId
},
success : function(result) {
if (result.code===100){
$.alert('买入成功!');
}else {
$.alert('买入失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
})
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/user/finance/termfinancial.html
|
HTML
|
mit
| 6,365
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>个人理财系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="user/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="user/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>新闻资讯</h4>
</div>
</div>
</div>
<div th:if="${!newsList.isEmpty()}" th:each="news:${newsList}">
<div class="col-sm-12">
<div class="card">
<div class="card-header bg-primary">
<h4 th:text="${news.title}"></h4>
<ul class="card-actions">
<li>
<p th:text="${#dates.format(news.createtime, 'yyyy-MM-dd')}"></p>
</li>
</ul>
</div>
<div class="card-body">
<p th:text="${news.newsdesc}">
</p>
</div>
</div>
</div>
</div>
<div th:if="${newsList.isEmpty()}" class="card-body">
<div class="table-responsive">
<h4>很抱歉!暂时还没有新闻向您推荐</h4>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/user/main.html
|
HTML
|
mit
| 3,120
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>个人理财系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="user/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="user/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>银行卡管理</h4>
</div>
</div>
</div>
<div th:if="${!bankCardList.isEmpty()}" th:each="bankcard:${bankCardList}">
<div class="col-sm-12">
<div class="card">
<div class="card-header bg-primary">
<h4 th:if="${bankcard.type==1}" th:text="${bankcard.cardbank+' (借记卡)'}"></h4>
<h4 th:if="${bankcard.type==2}" th:text="${bankcard.cardbank+' (信用卡)'}"></h4>
<ul class="card-actions">
<li>
<button class="btn btn-primary update_btn"
th:attr="update-id=${bankcard.id}">
<span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span> 编辑
</button>
<button class="btn btn-danger delete_btn"
th:attr="delete-id=${bankcard.id},delete-name=${bankcard.cardnum}">
<span class="glyphicon glyphicon-trash"
aria-hidden="true"></span> 删除
</button>
</li>
</ul>
</div>
<div class="card-body">
<h2 th:text="'卡号:'+${bankcard.cardnum}"></h2>
</div>
</div>
</div>
</div>
<div th:if="${bankCardList.isEmpty()}" class="card">
<div class="col-sm-12">
<div class="card">
<div class="card-body">
<h4>很抱歉!您还没有添加银行卡</h4>
</div>
</div>
</div>
</div>
<!-- 新增按钮 -->
<div class="row">
<div class="col-md-1" style="margin-left: 24px">
<button id="bankCard_add_modal_btn" class="btn btn-primary">新增</button>
</div>
</div>
<!-- 新增银行卡的模态框 -->
<div class="modal fade" id="bankCardAddModal" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">新增银行卡</h4>
</div>
<div class="modal-body">
<!--要提交的表单 -->
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">银行:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="cardBank_add_input" name="cardbank"
placeholder="银行卡所属银行:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">类别:</label>
<div class="col-sm-6">
<div class="example-box">
<label class="lyear-radio radio-inline"> <input
type="radio" name="type"
value="1" checked="checked"><span>借记卡</span>
</label> <label class="lyear-radio radio-inline"> <input
type="radio" name="type"
value="2"> <span>信用卡</span>
</label>
</div>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">卡号:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="cardNum_add_input"
name="cardnum" placeholder="请输入银行卡号:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary"
id="bankCard_save_btn">保存
</button>
</div>
</div>
</div>
</div>
<!-- 修改银行卡的模态框 -->
<div class="modal fade" id="bankCardUpdateModal" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">修改银行卡信息</h4>
</div>
<div class="modal-body">
<!--要提交的表单 -->
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">银行:</label>
<div class="col-sm-6">
<input type="text" class="form-control"
id="cardBank_update_input" name="cardbank"
placeholder="银行卡所属银行:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">类别:</label>
<div class="col-sm-6">
<div class="example-box">
<label class="lyear-radio radio-inline"> <input
type="radio" name="type"
value="1" checked="checked"><span>借记卡</span>
</label> <label class="lyear-radio radio-inline"> <input
type="radio" name="type"
value="2"> <span>信用卡</span>
</label>
</div>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">卡号:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="cardNum_update_input"
name="cardnum" placeholder="请输入银行卡号:">
<span class="help-block"></span>
</div>
<div class="col-sm-1">
<em style="color: red">*</em>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary"
id="bankCard_update_btn">更新
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
//点击新增按钮弹出模态框。
$("#bankCard_add_modal_btn").click(function () {
//清除表单数据(表单完整重置(表单的数据,表单的样式))
reset_form("#bankCardAddModal form");
//弹出模态框
$("#bankCardAddModal").modal({
//点击增加框背景不删除增加框
backdrop: "static"
});
});
//点击保存,保存新增银行卡信息。
$("#bankCard_save_btn").click(function () {
var cardBank = $("#cardBank_add_input").val();
var cardNum = $("#cardNum_add_input").val();
//alert(cardNum);
//匹配汉字
var cardBankRegex = /^[\u4e00-\u9fa5]{0,}$/;
if (cardBank === "") {
show_validate_msg("#cardBank_add_input",
"error", "银行名称为空");
return false;
} else if (cardBankRegex.test(cardBank) === false) {
show_validate_msg("#cardBank_add_input",
"error", "银行名称不合法");
return false;
}
//匹配16-19位的数字
var cardNumRegex = /^\d{16,19}$/;
if (cardNum === "") {
show_validate_msg("#cardNum_add_input",
"error", "银行卡号为空");
return false;
} else if (cardNumRegex.test(cardNum) === false) {
show_validate_msg("#cardNum_add_input",
"error", "银行卡号不合法");
return false;
}
//2、发送ajax请求保存银行卡
$.ajax({
url: "/user/addBankCard",
type: "POST",
data: $("#bankCardAddModal form").serialize(),
success: function (result) {
if (result.code === 100) {
//新增银行卡保存成功;
//1、关闭模态框
$("#bankCardAddModal").modal('hide');
//2、弹出成功提示框,并刷新当前界面
$.alert('银行卡新增成功!');
setTimeout(function () {
location.href = "/user/personal/toBankCard.html";
}, 1000);
} else {
$.alert('银行卡新增失败!');
}
}
});
});
//点击编辑按钮时触发事件
$(document).on("click", ".update_btn", function () {
//根据银行卡id发送ajax请求,查出银行卡信息并显示
getBankCard($(this).attr("update-id"));
//把银行卡的id传递给模态框的更新按钮
$("#bankCard_update_btn").attr("update-id", $(this).attr("update-id"));
$("#bankCardUpdateModal").modal({
backdrop: "static"
});
});
//根据id查出银行卡信息并显示
function getBankCard(id) {
$.ajax({
url: "/user/getBankCardById/" + id,
type: "GET",
success: function (result) {
var bankcard = result.extend.bankcard;
//alert(updateDept.dDeptname);
//显示数据之前先清除一下校验样式,如果有的话
$(cardBank_update_input).parent().removeClass(
"has-success has-error");
$(cardBank_update_input).next("span").text("");
$("#cardBank_update_input").val(bankcard.cardbank);
$(cardNum_update_input).parent().removeClass(
"has-success has-error");
$(cardNum_update_input).next("span").text("");
$("#cardNum_update_input").val(bankcard.cardnum);
$("#bankCardUpdateModal input[name=type]").val(
[bankcard.type]);
}
});
}
//点击更新,更新银行卡信息
$("#bankCard_update_btn").click(function () {
var cardBank = $("#cardBank_update_input").val();
var cardNum = $("#cardNum_update_input").val();
//匹配汉字
var cardBankRegex = /^[\u4e00-\u9fa5]{0,}$/;
if (cardBank === "") {
show_validate_msg("#cardBank_update_input",
"error", "银行名称为空");
return false;
} else if (cardBankRegex.test(cardBank) === false) {
show_validate_msg("#cardBank_update_input",
"error", "银行名称不合法");
return false;
}
//匹配16-19位的数字
var cardNumRegex = /^\d{16,19}$/;
if (cardNum === "") {
show_validate_msg("#cardNum_update_input",
"error", "银行卡号为空");
return false;
} else if (cardNumRegex.test(cardNum) === false) {
show_validate_msg("#cardNum_update_input",
"error", "银行卡号不合法");
return false;
}
//2、发送ajax请求保存更新的员银行卡数据
$.ajax({
url: "/user/updateBankCard/" + $(this).attr("update-id"),
type: "PUT",
data: {
"cardbank": cardBank,
"type": $("#bankCardUpdateModal input:radio:checked").val(),
"cardnum": cardNum
},
success: function (result) {
if (result.code === 100) {
$("#bankCardUpdateModal").modal('hide');
$.alert('银行卡信息修改成功!');
setTimeout(function () {
location.href = "/user/personal/toBankCard.html";
}, 1000);
} else {
$.alert('银行卡信息修改失败!');
}
}
});
});
//单个删除
$(document).on("click", ".delete_btn", function () {
//1、弹出是否确认删除对话框
var id = $(this).attr("delete-id");
var cardnum = $(this).attr("delete-name");
$.alert({
title: '提示:',
content: "确定删除 <strong>" + cardnum + "</strong> 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/user/deleteBankCard/" + id,
type: "DELETE",
success: function (result) {
if (result.code === 100) {
$.alert('删除该银行卡成功!');
setTimeout(function () {
location.href = "/user/personal/toBankCard.html";
}, 1000);
} else {
$.alert('删除该银行卡失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
});
//清空表单样式及内容
function reset_form(ele) {
$(ele)[0].reset();
//清空表单样式
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
//显示校验结果的提示信息
function show_validate_msg(ele, status, msg) {
//清除当前元素的校验状态
$(ele).parent().removeClass("has-success has-error");
$(ele).next("span").text("");
if ("success" === status) {
$(ele).parent().addClass("has-success");
$(ele).next("span").text(msg);
} else if ("error" === status) {
$(ele).parent().addClass("has-error");
$(ele).next("span").text(msg);
}
}
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/user/personal/bankcard.html
|
HTML
|
mit
| 22,037
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>个人理财系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="user/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="user/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>我的理财</h4>
</div>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<!--零钱理财 -->
<div class="panel panel-primary">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion"
href="#collapseOne"
aria-expanded="true" aria-controls="collapseOne">
零钱理财
</a>
</h4>
</div>
<div id="collapseOne"
th:class="${session.myFinanceActiveUrl=='changeMoneyActive'?'panel-collapse collapse in':'panel-collapse collapse'}"
class="panel-collapse collapse in" role="tabpanel"
aria-labelledby="headingOne">
<div th:if="${!userChangeMoneyList.isEmpty()}" class="panel-body">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">产品名称</th>
<th class="info">起投金额</th>
<th class="info">起投时间</th>
<th class="info">投资期限</th>
<th class="info">收益</th>
<th class="info">平均收益率</th>
<th class="info">投资状态</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="ucm:${userChangeMoneyList}">
<td th:text="${ucmStat.index+1}"></td>
<td th:text="${ucm.changeMoney.name}"></td>
<td th:text="${#numbers.formatDecimal(ucm.changeMoney.invesmoney,1,2)}+'元'"></td>
<td th:text="${#dates.format(ucm.starttime, 'yyyy-MM-dd')}"></td>
<td th:text="${ucm.changeMoney.investerm}"></td>
<td th:text="${#numbers.formatDecimal(ucm.profit,1,2)}+'元'"></td>
<td th:text="${#numbers.formatDecimal(ucm.averyield*100,1,2)}+'%'"></td>
<td th:if="${ucm.status==1}" th:text="持有中"></td>
<td th:if="${ucm.status==2}" th:text="已失效"></td>
<td th:if="${ucm.status==3}" th:text="已撤销"></td>
<td>
<button class="btn btn-danger btn-sm ucm_btn"
th:attr="ucmBtnStatus=${ucm.status},ucmBtnId=${ucm.id},ucmBtnName=${ucm.changeMoney.name}">
<span class="glyphicon glyphicon-remove"
aria-hidden="true"></span> 撤销
</button>
</td>
</tr>
</tbody>
</table>
</div>
<div th:if="${userChangeMoneyList.isEmpty()}" class="panel-body">
<h4>很抱歉!暂时还没有查询到您的零钱理财信息</h4>
</div>
</div>
</div>
<!--工资理财 -->
<div class="panel panel-primary">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse"
data-parent="#accordion"
href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
工资理财
</a>
</h4>
</div>
<div id="collapseTwo"
th:class="${session.myFinanceActiveUrl=='payMoneyActive'?'panel-collapse collapse in':'panel-collapse collapse'}"
role="tabpanel"
aria-labelledby="headingTwo">
<div th:if="${!userPayMoneyList.isEmpty()}" class="panel-body">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">产品名称</th>
<th class="info">起投金额</th>
<th class="info">起投时间</th>
<th class="info">投资期限</th>
<th class="info">收益</th>
<th class="info">平均收益率</th>
<th class="info">投资状态</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="upm:${userPayMoneyList}">
<td th:text="${upmStat.index+1}"></td>
<td th:if="${upm.payMoney.type==1}" th:text="国债"></td>
<td th:if="${upm.payMoney.type==2}" th:text="期货"></td>
<td th:text="${#numbers.formatDecimal(upm.payMoney.monthmoney,1,2)}+'元'"></td>
<td th:text="${#dates.format(upm.starttime, 'yyyy-MM-dd')}"></td>
<td th:text="${upm.payMoney.investerm}"></td>
<td th:text="${#numbers.formatDecimal(upm.profit,1,2)}+'元'"></td>
<td th:text="${#numbers.formatDecimal(upm.averyield*100,1,2)}+'%'"></td>
<td th:if="${upm.status==1}" th:text="持有中"></td>
<td th:if="${upm.status==2}" th:text="已失效"></td>
<td th:if="${upm.status==3}" th:text="已撤销"></td>
<td>
<button class="btn btn-danger btn-sm upm_btn"
th:attr="upmBtnStatus=${upm.status},upmBtnId=${upm.id},upmBtnName=${upm.payMoney.type}">
<span class="glyphicon glyphicon-remove"
aria-hidden="true"></span> 撤销
</button>
</td>
</tr>
</tbody>
</table>
</div>
<div th:if="${userPayMoneyList.isEmpty()}" class="panel-body">
<h4>很抱歉!暂时还没有查询到您的工资理财信息</h4>
</div>
</div>
</div>
<!--期限理财 -->
<div class="panel panel-primary">
<div class="panel-heading" role="tab" id="headingThree">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse"
data-parent="#accordion"
href="#collapseThree" aria-expanded="false" aria-controls="collapseTwo">
期限理财
</a>
</h4>
</div>
<div id="collapseThree"
th:class="${session.myFinanceActiveUrl=='termFinancialActive'?'panel-collapse collapse in':'panel-collapse collapse'}"
role="tabpanel"
aria-labelledby="headingThree">
<div th:if="${!userTermFinancialList.isEmpty()}" class="panel-body">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">产品名称</th>
<th class="info">起投金额</th>
<th class="info">起投时间</th>
<th class="info">投资期限</th>
<th class="info">收益</th>
<th class="info">平均收益率</th>
<th class="info">投资状态</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="utf:${userTermFinancialList}">
<td th:text="${utfStat.index+1}"></td>
<td th:text="${utf.termFinancial.name}"></td>
<td th:text="${#numbers.formatDecimal(utf.termFinancial.leastmoney,1,2)}+'元'"></td>
<td th:text="${#dates.format(utf.starttime, 'yyyy-MM-dd')}"></td>
<td th:text="${utf.termFinancial.investerm}"></td>
<td th:text="${#numbers.formatDecimal(utf.profit,1,2)}+'元'"></td>
<td th:text="${#numbers.formatDecimal(utf.averyield*100,1,2)}+'%'"></td>
<td th:if="${utf.status==1}" th:text="持有中"></td>
<td th:if="${utf.status==2}" th:text="已失效"></td>
<td th:if="${utf.status==3}" th:text="已撤销"></td>
<td>
<button class="btn btn-danger btn-sm utf_btn"
th:attr="utfBtnStatus=${utf.status},utfBtnId=${utf.id},utfBtnName=${utf.termFinancial.name}">
<span class="glyphicon glyphicon-remove"
aria-hidden="true"></span> 撤销
</button>
</td>
</tr>
</tbody>
</table>
</div>
<div th:if="${userTermFinancialList.isEmpty()}" class="panel-body">
<h4>很抱歉!暂时还没有查询到您的期限理财信息</h4>
</div>
</div>
</div>
<!--基金理财 -->
<div class="panel panel-primary">
<div class="panel-heading" role="tab" id="headingFour">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse"
data-parent="#accordion"
href="#collapseFour" aria-expanded="false" aria-controls="collapseTwo">
基金理财
</a>
</h4>
</div>
<div id="collapseFour"
th:class="${session.myFinanceActiveUrl=='fundProductActive'?'panel-collapse collapse in':'panel-collapse collapse'}"
role="tabpanel"
aria-labelledby="headingFour">
<div th:if="${!userFundProductList.isEmpty()}" class="panel-body">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">产品名称</th>
<th class="info">起投金额</th>
<th class="info">起投时间</th>
<th class="info">投资期限</th>
<th class="info">收益</th>
<th class="info">平均收益率</th>
<th class="info">投资状态</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="ufp:${userFundProductList}">
<td th:text="${ufpStat.index+1}"></td>
<td th:text="${ufp.fundProduct.funddesc}"></td>
<td th:text="${#numbers.formatDecimal(ufp.fundProduct.leastmoney,1,2)}+'元'"></td>
<td th:text="${#dates.format(ufp.starttime, 'yyyy-MM-dd')}"></td>
<td th:text="${ufp.fundProduct.investerm}"></td>
<td th:text="${#numbers.formatDecimal(ufp.profit,1,2)}+'元'"></td>
<td th:text="${#numbers.formatDecimal(ufp.averyield*100,1,2)}+'%'"></td>
<td th:if="${ufp.status==1}" th:text="持有中"></td>
<td th:if="${ufp.status==2}" th:text="已失效"></td>
<td th:if="${ufp.status==3}" th:text="已撤销"></td>
<td>
<button class="btn btn-danger btn-sm ufp_btn"
th:attr="ufpBtnStatus=${ufp.status},ufpBtnId=${ufp.id},ufpBtnName=${ufp.fundProduct.funddesc}">
<span class="glyphicon glyphicon-remove"
aria-hidden="true"></span> 撤销
</button>
</td>
</tr>
</tbody>
</table>
</div>
<div th:if="${userFundProductList.isEmpty()}" class="panel-body">
<h4>很抱歉!暂时还没有查询到您的基金理财信息</h4>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
$(document).on("click", ".ucm_btn", function () {
var userChangeMoneyId = $(this).attr("ucmBtnId");
var status = $(this).attr("ucmBtnStatus");
if (status == 2) {
$.alert('已失效!无须撤销');
} else if (status == 3) {
$.alert('已撤销!');
} else if (status == 1) {
//var userId = [[${session.loginUser.id}]] ;
//alert(userId);
var name = $(this).attr("ucmBtnName");
$.alert({
title: '提示:',
content: "确定撤销 <strong>" + name + "</strong> 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/user/revokeUserChangeMoney",
type: "put",
data: {
"userChangeMoneyId": userChangeMoneyId
},
success: function (result) {
if (result.code === 100) {
$.alert('撤销成功!');
setTimeout(function () {
location.href = "/user/personal/toMyFinance.html";
}, 1000);
} else {
$.alert('撤销失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
}
});
$(document).on("click", ".upm_btn", function () {
var userPayMoneyId = $(this).attr("upmBtnId");
var status = $(this).attr("upmBtnStatus");
if (status == 2) {
$.alert('已失效!无须撤销');
} else if (status == 3) {
$.alert('已撤销!');
} else if (status == 1) {
var type = $(this).attr("upmBtnName");
var name;
if (type == 1) {
name = "国债"
} else {
name = "期货";
}
$.alert({
title: '提示:',
content: "确定撤销该 <strong>" + name + "</strong> 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/user/revokeUserPayMoney",
type: "put",
data: {
"userPayMoneyId": userPayMoneyId
},
success: function (result) {
if (result.code === 100) {
$.alert('撤销成功!');
setTimeout(function () {
location.href = "/user/personal/toMyFinance.html";
}, 1000);
} else {
$.alert('撤销失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
}
});
$(document).on("click", ".utf_btn", function () {
var status = $(this).attr("utfBtnStatus");
if (status == 2) {
$.alert('已失效!无须撤销');
} else if (status == 3) {
$.alert('已撤销!');
} else if (status == 1) {
var userTermFinancialId = $(this).attr("utfBtnId");
var name = $(this).attr("utfBtnName");
$.alert({
title: '提示:',
content: "确定撤销 <strong>" + name + "</strong> 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/user/revokeUserTermFinancial",
type: "put",
data: {
"userTermFinancialId": userTermFinancialId
},
success: function (result) {
if (result.code === 100) {
$.alert('撤销成功!');
setTimeout(function () {
location.href = "/user/personal/toMyFinance.html";
}, 1000);
} else {
$.alert('撤销失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
}
});
$(document).on("click", ".ufp_btn", function () {
var status = $(this).attr("ufpBtnStatus");
if (status == 2) {
$.alert('已失效!无须撤销');
} else if (status == 3) {
$.alert('已撤销!');
} else if (status == 1) {
var userFundProductId = $(this).attr("ufpBtnId");
var name = $(this).attr("ufpBtnName");
$.alert({
title: '提示:',
content: "确定撤销 <strong>" + name + "</strong> 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/user/revokeUserFundProduct",
type: "put",
data: {
"userFundProductId": userFundProductId
},
success: function (result) {
if (result.code === 100) {
$.alert('撤销成功!');
setTimeout(function () {
location.href = "/user/personal/toMyFinance.html";
}, 1000);
} else {
$.alert('撤销失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
}
});
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/user/personal/myfinance.html
|
HTML
|
mit
| 29,328
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>个人理财系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="user/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="user/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>我的消息</h4>
</div>
<div th:if="${!infoList.isEmpty()}" class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">消息标题</th>
<th class="info">消息内容</th>
<th class="info">发送人</th>
<th class="info">发送时间</th>
<th class="info">状态</th>
<th class="info">相关操作</th>
</tr>
</thead>
<tbody>
<tr th:each="info:${infoList}">
<td th:text="${(infoPageInfo.pageNum - 1) * infoPageInfo.pageSize+infoStat.index+1}"></td>
<td th:text="${info.title}"></td>
<td th:text="${info.infodesc}"></td>
<td th:text="${info.admin.username}"></td>
<td th:text="${#dates.format(info.createtime, 'yyyy-MM-dd')}"></td>
<td th:if="${info.status==0}" th:text="未读"></td>
<td th:if="${info.status==1}" th:text="已读"></td>
<td>
<button class="btn btn-primary btn-sm edit_btn"
th:attr="edit-id=${info.id}">
<span class="glyphicon glyphicon-pencil"
aria-hidden="true"></span> 已读
</button>
<button class="btn btn-danger btn-sm delete_btn"
th:attr="delete-id=${info.id},title=${info.title}">
<span class="glyphicon glyphicon-trash"
aria-hidden="true"></span> 删除
</button>
</td>
</tr>
</tbody>
</table>
</div>
<!-- 显示分页信息 -->
<div class="row">
<div class="col-md-5 col-md-offset-1">
<div class="btn-group">
<button class="btn btn-default">
<span>页次:</span>
</button>
<button class="btn btn-default">
<span th:text="${infoPageInfo.pageNum}+'/'+${infoPageInfo.pages}+'页'"></span>
</button>
<button class="btn btn-default">
<span>每页显示:</span>
</button>
<div class="btn-group">
<button id="btnGroupDrop1"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"><span
th:text="${infoPageInfo.pageSize}"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li th:each="i:${#numbers.sequence(1,10)}"><a th:text="${i}"
th:href="@{/user/personal/toMyInfo.html(pageNum=${infoPageInfo.pageNum},pageSize=${i})}"></a>
</li>
</ul>
</div>
<button class="btn btn-default">
<span>条</span>
</button>
<button class="btn btn-default">
<span>总记录数:</span>
</button>
<button class="btn btn-default">
<span th:text="${infoPageInfo.total}+'条'"></span>
</button>
</div>
</div>
<!-- 分页条信息 -->
<div class="col-md-5">
<nav aria-label="Page navigation">
<ul class="pagination pagination-lg pull-right"
style="margin-top: 0">
<li>
<a th:href="@{/user/personal/toMyInfo.html(pageNum=1,pageSize=${infoPageInfo.pageSize})}">首页</a>
</li>
<li th:if="${infoPageInfo.hasPreviousPage }"><a
th:href="@{/user/personal/toMyInfo.html(pageNum=${infoPageInfo.pageNum}-1,pageSize=${infoPageInfo.pageSize})}"
aria-label="Previous"> <span aria-hidden="true">«</span>
</a></li>
<li th:each="page_Num:${infoPageInfo.navigatepageNums }"
th:class="${page_Num == infoPageInfo.pageNum?'active':''}">
<a th:if="${page_Num == infoPageInfo.pageNum}"
th:text="${page_Num}"
th:href="@{#}">
</a>
<a th:text="${page_Num}"
th:if="${page_Num != infoPageInfo.pageNum}"
th:href="@{/user/personal/toMyInfo.html(pageNum=${page_Num},pageSize=${infoPageInfo.pageSize})}">
</a>
</li>
<li th:if="${infoPageInfo.hasNextPage }"><a
th:href="@{/user/personal/toMyInfo.html(pageNum=${infoPageInfo.pageNum}+1,pageSize=${infoPageInfo.pageSize})}"
aria-label="Next"> <span aria-hidden="true">»</span>
</a></li>
<li><a
th:href="@{/user/personal/toMyInfo.html(pageNum=${infoPageInfo.pages},pageSize=${infoPageInfo.pageSize})}">末页</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div th:if="${infoList.isEmpty()}" class="card-body">
<div class="table-responsive">
<h4>很抱歉!暂时还没有收到您的消息</h4>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script type="text/javascript">
//已读
$(document).on("click", ".edit_btn", function () {
var infoId = $(this).attr("edit-id");
$.ajax({
url: "/user/updateInfo/" + infoId,
type: "put",
success: function (result) {
if (result.code === 100) {
location.href = "/user/personal/toMyInfo.html";
}else {
$.alert('读取失败!');
}
}
});
});
//删除
$(document).on("click", ".delete_btn", function () {
var infoId = $(this).attr("delete-id");
var title = $(this).attr("title");
$.alert({
title: '提示:',
content: "确定删除 <strong>"+title+"</strong> 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function(){
$.ajax({
url: "/user/deleteInfo/" + infoId,
type: "DELETE",
success: function (result) {
if (result.code === 100) {
location.href = "/user/personal/toMyInfo.html";
}else {
$.alert('删除失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
})
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/user/personal/myinfo.html
|
HTML
|
mit
| 12,799
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>个人理财系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="user/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="user/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>我的借贷</h4>
</div>
<div th:if="${!loansList.isEmpty()}" class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">借贷资金</th>
<th class="info">借贷期限</th>
<th class="info">固定年借贷率</th>
<th class="info">申请状态</th>
<th class="info">借贷状态</th>
<th class="info">操作</th>
</tr>
</thead>
<tbody>
<tr th:each="loan:${loansList}">
<td th:text="${(myLoansPageInfo.pageNum - 1) * myLoansPageInfo.pageSize+loanStat.index+1}"></td>
<td th:text="${#numbers.formatDecimal(loan.amount,1,2)}+'元'"></td>
<td th:text="${loan.term}+'天'"></td>
<td th:text="${#numbers.formatDecimal(loan.rate*100,1,2)}+'%'"></td>
<td th:if="${loan.applystatus==0}" th:text="未审核"></td>
<td th:if="${loan.applystatus==1}" th:text="审核未通过"></td>
<td th:if="${loan.applystatus==2}" th:text="审核通过"></td>
<td th:if="${loan.loanstatus==0}" th:text="未逾期"></td>
<td th:if="${loan.loanstatus==1}" th:text="逾期"></td>
<td th:if="${loan.loanstatus==2}" th:text="已还清"></td>
<td>
<button class="btn btn-primary btn-sm loan_btn"
th:attr="loanBtnId=${loan.id},loanStatus=${loan.loanstatus},
loanApplystatus=${loan.applystatus},loanBtnName=${#numbers.formatDecimal(loan.amount,1,2)}+'元'">
<span class="glyphicon glyphicon-yen"
aria-hidden="true"></span> 还款
</button>
</td>
</tr>
</tbody>
</table>
</div>
<!-- 显示分页信息 -->
<div class="row">
<!--新增按钮-->
<div class="col-md-1" style="margin-left: 24px">
<button id="loan_add_modal_btn" class="btn btn-primary">新增</button>
</div>
<div class="col-md-5">
<div class="btn-group">
<button class="btn btn-default">
<span>页次:</span>
</button>
<button class="btn btn-default">
<span th:text="${myLoansPageInfo.pageNum}+'/'+${myLoansPageInfo.pages}+'页'"></span>
</button>
<button class="btn btn-default">
<span>每页显示:</span>
</button>
<div class="btn-group">
<button id="btnGroupDrop1"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"><span
th:text="${myLoansPageInfo.pageSize}"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li th:each="i:${#numbers.sequence(1,10)}"><a th:text="${i}"
th:href="@{/user/personal/toMyLoan.html(pageNum=${myLoansPageInfo.pageNum},pageSize=${i})}"></a>
</li>
</ul>
</div>
<button class="btn btn-default">
<span>条</span>
</button>
<button class="btn btn-default">
<span>总记录数:</span>
</button>
<button class="btn btn-default">
<span th:text="${myLoansPageInfo.total}+'条'"></span>
</button>
</div>
</div>
<!-- 分页条信息 -->
<div class="col-md-5">
<nav aria-label="Page navigation">
<ul class="pagination pagination-lg pull-right"
style="margin-top: 0">
<li>
<a th:href="@{/user/personal/toMyLoan.html(pageNum=1,pageSize=${myLoansPageInfo.pageSize})}">首页</a>
</li>
<li th:if="${myLoansPageInfo.hasPreviousPage }"><a
th:href="@{/user/personal/toMyLoan.html(pageNum=${myLoansPageInfo.pageNum}-1,pageSize=${myLoansPageInfo.pageSize})}"
aria-label="Previous"> <span aria-hidden="true">«</span>
</a></li>
<li th:each="page_Num:${myLoansPageInfo.navigatepageNums }"
th:class="${page_Num == myLoansPageInfo.pageNum?'active':''}">
<a th:if="${page_Num == myLoansPageInfo.pageNum}"
th:text="${page_Num}"
th:href="@{#}">
</a>
<a th:text="${page_Num}"
th:if="${page_Num != myLoansPageInfo.pageNum}"
th:href="@{/user/personal/toMyLoan.html(pageNum=${page_Num},pageSize=${myLoansPageInfo.pageSize})}">
</a>
</li>
<li th:if="${myLoansPageInfo.hasNextPage }"><a
th:href="@{/user/personal/toMyLoan.html(pageNum=${myLoansPageInfo.pageNum}+1,pageSize=${myLoansPageInfo.pageSize})}"
aria-label="Next"> <span aria-hidden="true">»</span>
</a></li>
<li><a
th:href="@{/user/personal/toMyLoan.html(pageNum=${myLoansPageInfo.pages},pageSize=${myLoansPageInfo.pageSize})}">末页</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div th:if="${loansList.isEmpty()}" class="card-body">
<div class="table-responsive">
<h4>很抱歉!暂时还没有查询到您的安全网贷信息</h4>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script th:inline="javascript">
//跳转到安全网贷界面
$("#loan_add_modal_btn").click(function () {
location.href = "/user/tools/toApplyLoan.html";
});
//还款
$(document).on("click", ".loan_btn", function () {
var id = $(this).attr("loanBtnId");
var name = $(this).attr("loanBtnName");
var loanApplystatus = $(this).attr("loanApplystatus");
if (loanApplystatus == 0) {
$.alert('请耐心等待管理员审核!');
//return false;
} else if (loanApplystatus == 1) {
$.alert('审核未通过!');
//return false;
} else if (loanApplystatus == 2) {
var loanStatus = $(this).attr("loanStatus");
if (loanStatus == 2) {
$.alert("已还清!");
} else {
$.alert({
title: '提示:',
content: "确定还款 <strong>" + name + "</strong> 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.ajax({
url: "/user/repayment/" + id,
type: "PUT",
success: function (result) {
if (result.code === 100) {
$.alert('还款成功!');
setTimeout(function () {
location.href = "/user/personal/toMyLoan.html";
}, 1000);
} else {
$.alert('还款失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
}
}
});
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/user/personal/myloan.html
|
HTML
|
mit
| 13,941
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>个人理财系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="user/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="user/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>个人信息</h4>
</div>
<div class="card-body">
<form id="profileForm" class="site-form">
<div class="form-group">
<label>用户名</label>
<input type="text"
class="form-control" name="username" id="username"
th:value="${user.username}" disabled="disabled"/>
</div>
<div class="form-group">
<label>真实姓名</label>
<input type="text" class="form-control" name="realname"
id="realname" placeholder="您的真实姓名还未填写"
th:value="${user.realname}">
<span class="help-block"></span>
</div>
<div class="form-group">
<label>身份证号</label>
<input type="text" class="form-control" name="idcard"
id="idcard" placeholder="您的身份证号码还未填写"
th:value="${user.idcard}">
<span class="help-block"></span>
</div>
<div class="form-group">
<label>交易密码</label>
<input type="email" class="form-control" name="paypwd"
id="paypwd" placeholder="您的交易密码(6位数字)还未设置"
th:value="${user.paypwd}">
<span class="help-block"></span>
</div>
<div class="form-group">
<label>手机号</label>
<input type="text" class="form-control" name="phone"
id="phone" placeholder="您的手机号还未填写"
th:value="${user.phone}">
<span class="help-block"></span>
</div>
<div class="form-group">
<label>电子邮箱</label>
<input type="email" class="form-control" name="email"
id="email" placeholder="您的邮箱地址还未填写"
th:value="${user.email}">
<span class="help-block"></span>
</div>
<button id="updateUserBtn" type="button"
class="btn btn-primary">保存
</button>
</form>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script th:inline="javascript">
$(function () {
$("#realname").blur(checkRealname);
$("#idcard").blur(checkIdCard);
$("#paypwd").blur(checkPaypwd);
$("#phone").blur(checkPhone);
$("#email").blur(checkEmail);
$("#updateUserBtn").mousedown(function () {
if (checkRealname() && checkIdCard() && checkPaypwd() && checkPhone() && checkEmail()) {
updateUser();
}
});
});
//校验用户真实姓名
function checkRealname() {
var realname = $("#realname").val();
if (realname.length === 0) {
show_validate_msg("#realname", "error", "Hello!这里还没填呢");
return false;
}
//匹配汉字
var realnameReg = /^[\u4e00-\u9fa5]{0,}$/;
if (realnameReg.test(realname) === false) {
show_validate_msg("#realname", "error", "我猜也没有宁这号人呐");
return false;
}
show_validate_msg("#realname", "success", "宁这名字真不错");
return true;
}
//校验用户身份证号
function checkIdCard() {
var idcard = $("#idcard").val();
if (idcard.length === 0) {
show_validate_msg("#idcard", "error", "Hello!这里还没填呢");
return false;
}
//匹配身份证号
var idcardReg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
if (idcardReg.test(idcard) === false) {
show_validate_msg("#idcard", "error", "我猜宁这身份证号也不对呐");
return false;
}
show_validate_msg("#idcard", "success", "宁这身份证号真不错");
return true;
}
//校验用户支付密码
function checkPaypwd() {
var paypwd = $("#paypwd").val();
if (paypwd.length === 0) {
show_validate_msg("#paypwd", "error", "Hello!这里还没填呢");
return false;
}
//匹配6位正整数
var paypwdReg = /^\d{6}$/;
if (paypwdReg.test(paypwd) === false) {
show_validate_msg("#paypwd", "error", "我猜宁这交易密码不对呐");
return false;
}
show_validate_msg("#paypwd", "success", "宁这密码真不错");
return true;
}
//校验用户支手机号
function checkPhone() {
var phone = $("#phone").val();
if (phone.length === 0) {
show_validate_msg("#phone", "error", "Hello!这里还没填呢");
return false;
}
//匹配手机号
var phoneReg = /^1[3,5,8]\d{9}$/;
if (phoneReg.test(phone) === false) {
show_validate_msg("#phone", "error", "我猜没有宁这手机号呐");
return false;
}
show_validate_msg("#phone", "success", "宁这手机号真不错");
return true;
}
//校验用户邮箱
function checkEmail() {
var email = $("#email").val();
if (email.length === 0) {
show_validate_msg("#email", "error", "Hello!这里还没填呢");
return false;
}
//匹配邮箱
var emailReg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if (emailReg.test(email) === false) {
show_validate_msg("#email", "error", "我猜没有宁这邮箱呐");
return false;
}
show_validate_msg("#email", "success", "宁这邮箱真不错");
return true;
}
//更新用户信息
function updateUser() {
var userId = [[${session.loginUser.id}]];
$.ajax({
url: "/user/updateUserProfile/" + userId,
type: "PUT",
data: $("#profileForm").serialize(),
success: function (result) {
if (result.code === 100) {
$.alert('个人信息修改成功!');
setTimeout(function () {
location.href = "/user/personal/toProfile.html";
}, 1000);
} else {
$.alert('抱歉!哪里好像出现了问题?');
}
}
})
}
//显示校验结果的提示信息
function show_validate_msg(ele, status, msg) {
//清除当前元素的校验状态
$(ele).parent().removeClass("has-success has-error");
$(ele).next("span").text("");
if ("success" == status) {
$(ele).parent().addClass("has-success");
$(ele).next("span").text(msg);
} else if ("error" == status) {
$(ele).parent().addClass("has-error");
$(ele).next("span").text(msg);
}
}
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/user/personal/profile.html
|
HTML
|
mit
| 10,192
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>个人理财系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="user/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="user/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>账户安全</h4>
</div>
<div class="card">
<div class="card-body">
<form>
<div class="form-group">
<label for="oldpwd">旧密码</label>
<input class="form-control" type="password" id="oldpwd" name="oldpwd" placeholder="输入账号的原登录密码..">
<span class="help-block"></span>
</div>
<div class="form-group">
<label for="newpwd">新密码</label>
<input class="form-control" type="password" id="newpwd" name="newpwd" placeholder="输入新的密码">
<span class="help-block"></span>
</div>
<div class="form-group">
<label for="confirmpwd">确认新密码</label>
<input class="form-control" type="password" id="confirmpwd" name="confirmpwd" placeholder="请确认新的密码..">
<span class="help-block"></span>
</div>
<div class="form-group">
<button class="btn btn-primary" id="submit" type="button">修改密码</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script th:src="@{/js/md5.js}"></script>
<script th:inline="javascript">
$(function() {
$("#oldpwd").blur(checkOldpwd);
$("#newpwd").blur(checkNewpwd);
$("#confirmpwd").blur(checkConfirmpwd);
$("#submit").mousedown(function() {
if (checkOldpwd() && checkNewpwd() && checkConfirmpwd()) {
updatePwd();
}
});
});
//校验原始密码是否为空
function checkOldpwd() {
var oldpwd = $("#oldpwd").val();
if (oldpwd.length === 0) {
show_validate_msg("#oldpwd", "error", "老哥,这里还没填呢");
return false;
}
show_validate_msg("#oldpwd", "success", "你觉得这就是你的原始密码了");
return true;
}
//校验新密码
function checkNewpwd() {
var password = $("#newpwd").val();
if (password.length === 0) {
show_validate_msg("#newpwd", "error", "密码不能为空哟");
return false;
}
if (password.length < 6 || password.length > 18) {
show_validate_msg("#newpwd", "error", "密码必须大于或等于6个字符且小于或等于18个字符哟");
return false;
}
//匹配由英文、数字和下划线组成,长度为6至18的字符串
var passwordReg = /\w{5,40}/;
if (passwordReg.test(password) === false) {
show_validate_msg("#newpwd", "error", "密码不能包含英文、数字和下划线之外的字符哟");
return false;
}
show_validate_msg("#newpwd", "success", "新密码看起来不错哟");
return true;
}
//校验重复密码
function checkConfirmpwd() {
if (checkNewpwd()) {
var password = $("#newpwd").val();
var confirmpwd = $("#confirmpwd").val();
if (confirmpwd === password) {
show_validate_msg("#confirmpwd", "success", "哎呀,看起来和前面的一样呢");
return true;
}else if (confirmpwd==="") {
show_validate_msg("#confirmpwd", "error", "小伙子心急了呀,这里还没有填呢");
return false;
} else {
show_validate_msg("#confirmpwd", "error", "哎呀,看起来和前面不一样呢");
return false;
}
} else {
show_validate_msg("#confirmpwd", "error", "小伙子心急了呀,前面的还没有填呢");
return false;
}
}
//ajax修改密码
function updatePwd() {
var userId = [[${session.loginUser.id}]];
var oldpwd = $("#oldpwd").val();
$("#oldpwd").val($.md5(oldpwd));
var newpwd = $("#newpwd").val();
$("#newpwd").val($.md5(newpwd));
$.ajax({
url: "/user/updatePwd",
type: "PUT",
data: {
"id": userId,
"oldpwd":$("#oldpwd").val(),
"newpwd":$("#newpwd").val()
},
success: function(result) {
if (result.code === 100) {
$.alert('密码修改成功!');
setTimeout(function () {
location.href = "/user/personal/toSecurity.html";
}, 1000);
}else {
show_validate_msg("#oldpwd", "error", "很明显,宁这密码不对嘛");
}
}
})
}
//显示校验结果的提示信息
function show_validate_msg(ele, status, msg) {
//清除当前元素的校验状态
$(ele).parent().removeClass("has-success has-error");
$(ele).next("span").text("");
if ("success" == status) {
$(ele).parent().addClass("has-success");
$(ele).next("span").text(msg);
} else if ("error" == status) {
$(ele).parent().addClass("has-error");
$(ele).next("span").text(msg);
}
}
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/user/personal/security.html
|
HTML
|
mit
| 7,888
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>个人理财系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="user/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="user/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>安全网贷申请</h4>
</div>
<div class="card">
<div class="card-body">
<form>
<div class="form-group">
<label for="amount">借贷金额(元)</label>
<input class="form-control" type="text" id="amount" name="amount" placeholder="请输入要申请的借贷金额..">
<span class="help-block"></span>
</div>
<div class="form-group">
<label for="rate">年借贷利率</label>
<input class="form-control" type="text" id="rate" name="rate" th:placeholder="${#numbers.formatDecimal(0.2845*100,1,2)}+'%'" disabled>
</div>
<div class="form-group">
<label for="term">借贷期限(天)</label>
<input class="form-control" type="text" id="term" name="term" placeholder="请输入要申请的借贷期限..">
<span class="help-block"></span>
</div>
<div class="form-group">
<button class="btn btn-primary" id="submit" type="button">申请</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script th:inline="javascript">
$(function() {
$("#amount").blur(checkAmount);
$("#term").blur(checkTerm);
$("#submit").mousedown(function() {
if (checkAmount() && checkTerm()) {
applyLoan();
}
});
});
//校验金额
function checkAmount() {
var amount = $("#amount").val();
if (amount.length === 0) {
show_validate_msg("#amount", "error", "输入金额不能为空!");
return false;
}
//匹配有两位小数的正实数
var amountReg = /^[0-9]+(.[0-9]{2})?$/;
if (amountReg.test(amount) === false) {
show_validate_msg("#amount", "error", "输入金额不合法!");
return false;
}
show_validate_msg("#amount", "success", "就借这么点钱吗???");
return true;
}
//校验期限
function checkTerm() {
var term = $("#term").val();
if (term.length === 0) {
show_validate_msg("#term", "error", "还没说什么时候还钱呢!");
return false;
}
//匹配m-n位的数字
var termReg = /^\d{1,4}$/;
if (termReg.test(term) === false) {
show_validate_msg("#term", "error", "输入期限不合法!");
return false;
}
show_validate_msg("#term", "success", "要记得按时还钱哦!");
return true;
}
//ajax提交网贷申请
function applyLoan() {
var amount = $("#amount").val();
$.alert({
title: '提示:',
content: "确定借贷 <strong>"+amount+"</strong>元 吗?",
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function(){
$.ajax({
url: "/user/applyLoan",
type: "POST",
data: {
"amout": amount,
"term":$("#term").val(),
"rate":"0.2845"
},
success: function(result) {
if (result.code === 100) {
$.alert('申请成功!请等待管理员审核');
setTimeout(function () {
location.href = "/user/tools/toApplyLoan.html";
}, 1000);
} else {
$.alert('申请失败!');
}
}
});
}
},
cancel: {
text: '取消',
action: function () {
$.alert('已取消!');
}
}
}
});
}
//显示校验结果的提示信息
function show_validate_msg(ele, status, msg) {
//清除当前元素的校验状态
$(ele).parent().removeClass("has-success has-error");
$(ele).next("span").text("");
if ("success" == status) {
$(ele).parent().addClass("has-success");
$(ele).next("span").text(msg);
} else if ("error" == status) {
$(ele).parent().addClass("has-error");
$(ele).next("span").text(msg);
}
}
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/user/tools/applyloan.html
|
HTML
|
mit
| 7,406
|
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>个人理财系统</title>
<!-- 引入bootstrap样式 -->
<link th:href="@{/bootstrap/css/bootstrap.css}" rel="stylesheet" type="text/css">
<!--图标库-->
<link th:href="@{/lyear/css/materialdesignicons.min.css}" rel="stylesheet" type="text/css"/>
<!--弹出框样式-->
<link th:href="@{/lyear/jconfirm/jquery-confirm.min.css}" rel="stylesheet" type="text/css"/>
<!--自定义样式-->
<link href="../lyear/css/style.min.css" th:href="@{/lyear/css/style.min.css}" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="lyear-layout-web">
<div class="lyear-layout-container">
<!--左侧导航-->
<div th:replace="user/common/leftbar::#leftbaraside"></div>
<!--头部信息-->
<div th:replace="user/common/topbar::#topbarheader"></div>
<!--页面主要内容-->
<main class="lyear-layout-content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h4>资金记录</h4>
</div>
<div th:if="${!flowOfFundsList.isEmpty()}" class="card-body">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th class="info">序号</th>
<th class="info">金额</th>
<th class="info">类型</th>
<th class="info">来源</th>
<th class="info">时间</th>
<th class="info">备注</th>
</tr>
</thead>
<tbody>
<tr th:each="fof:${flowOfFundsList}">
<td th:text="${(flowOfFundsPageInfo.pageNum - 1) * flowOfFundsPageInfo.pageSize+fofStat.index+1}"></td>
<td th:text="${#dates.format(fof.createtime, 'yyyy-MM-dd')}"></td>
<td th:if="${fof.type==1}" th:text="支出"></td>
<td th:if="${fof.type==2}" th:text="收入"></td>
<td th:text="${fof.source}"></td>
<td th:text="${#dates.format(fof.createtime, 'yyyy-MM-dd')}"></td>
<td th:text="${fof.funddesc}"></td>
</tr>
</tbody>
</table>
</div>
<!-- 显示分页信息 -->
<div class="row">
<div class="col-md-5 col-md-offset-1">
<div class="btn-group">
<button class="btn btn-default">
<span>页次:</span>
</button>
<button class="btn btn-default">
<span th:text="${flowOfFundsPageInfo.pageNum}+'/'+${flowOfFundsPageInfo.pages}+'页'"></span>
</button>
<button class="btn btn-default">
<span>每页显示:</span>
</button>
<div class="btn-group">
<button id="btnGroupDrop1"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false"><span
th:text="${flowOfFundsPageInfo.pageSize}"></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li th:each="i:${#numbers.sequence(1,10)}"><a th:text="${i}"
th:href="@{/user/tools/toRecord.html(pageNum=${flowOfFundsPageInfo.pageNum},pageSize=${i})}"></a>
</li>
</ul>
</div>
<button class="btn btn-default">
<span>条</span>
</button>
<button class="btn btn-default">
<span>总记录数:</span>
</button>
<button class="btn btn-default">
<span th:text="${flowOfFundsPageInfo.total}+'条'"></span>
</button>
</div>
</div>
<!-- 分页条信息 -->
<div class="col-md-5">
<nav aria-label="Page navigation">
<ul class="pagination pagination-lg pull-right"
style="margin-top: 0">
<li>
<a th:href="@{/user/tools/toRecord.html(pageNum=1,pageSize=${flowOfFundsPageInfo.pageSize})}">首页</a>
</li>
<li th:if="${flowOfFundsPageInfo.hasPreviousPage }"><a
th:href="@{/user/tools/toRecord.html(pageNum=${flowOfFundsPageInfo.pageNum}-1,pageSize=${flowOfFundsPageInfo.pageSize})}"
aria-label="Previous"> <span aria-hidden="true">«</span>
</a></li>
<li th:each="page_Num:${flowOfFundsPageInfo.navigatepageNums }"
th:class="${page_Num == flowOfFundsPageInfo.pageNum?'active':''}">
<a th:if="${page_Num == flowOfFundsPageInfo.pageNum}"
th:text="${page_Num}"
th:href="@{#}">
</a>
<a th:text="${page_Num}"
th:if="${page_Num != flowOfFundsPageInfo.pageNum}"
th:href="@{/user/tools/toRecord.html(pageNum=${page_Num},pageSize=${flowOfFundsPageInfo.pageSize})}">
</a>
</li>
<li th:if="${flowOfFundsPageInfo.hasNextPage }"><a
th:href="@{/user/tools/toRecord.html(pageNum=${flowOfFundsPageInfo.pageNum}+1,pageSize=${flowOfFundsPageInfo.pageSize})}"
aria-label="Next"> <span aria-hidden="true">»</span>
</a></li>
<li><a
th:href="@{/user/tools/toRecord.html(pageNum=${flowOfFundsPageInfo.pages},pageSize=${flowOfFundsPageInfo.pageSize})}">末页</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div th:if="${flowOfFundsList.isEmpty()}" class="card-body">
<div class="table-responsive">
<h4>很抱歉!暂时还没有您的资金记录信息</h4>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!--End 页面主要内容-->
</div>
</div>
<!-- 引入jQuery和bootstrap的js -->
<script th:src="@{/js/jquery.js}"></script>
<script th:src="@{/bootstrap/js/bootstrap.js}"></script>
<!--滚动条插件-->
<script th:src="@{/lyear/js/perfect-scrollbar.min.js}"></script>
<!--弹出框js-->
<script th:src="@{/lyear/jconfirm/jquery-confirm.min.js}"></script>
<!--自定义js脚本-->
<script th:src="@{/lyear/js/main.min.js}"></script>
<script th:inline="javascript">
</script>
</body>
</html>
|
2302_81121971/tan
|
项目代码/finance/finance/src/main/resources/templates/views/user/tools/record.html
|
HTML
|
mit
| 10,226
|
#!bin/bash
if [ -d "/home/frappe/frappe-bench/apps/frappe" ]; then
echo "Bench already exists, skipping init"
cd frappe-bench
bench start
else
echo "Creating new bench..."
fi
bench init --skip-redis-config-generation frappe-bench --version version-15
cd frappe-bench
# Use containers instead of localhost
bench set-mariadb-host mariadb
bench set-redis-cache-host redis:6379
bench set-redis-queue-host redis:6379
bench set-redis-socketio-host redis:6379
# Remove redis, watch from Procfile
sed -i '/redis/d' ./Procfile
sed -i '/watch/d' ./Procfile
bench get-app drive --branch main
bench new-site drive.localhost \
--force \
--mariadb-root-password 123 \
--admin-password admin \
--no-mariadb-socket
bench --site drive.localhost install-app drive
bench --site drive.localhost set-config developer_mode 1
bench --site drive.localhost clear-cache
bench --site drive.localhost set-config mute_emails 1
bench use drive.localhost
bench start
|
2302_79757062/drive
|
docker/init.sh
|
Shell
|
agpl-3.0
| 960
|
__version__ = "0.0.1"
|
2302_79757062/drive
|
drive/__init__.py
|
Python
|
agpl-3.0
| 22
|
import frappe
from frappe.utils import validate_email_address, split_emails
@frappe.whitelist(allow_guest=True)
def oauth_providers():
from frappe.utils.html_utils import get_icon_html
from frappe.utils.password import get_decrypted_password
from frappe.utils.oauth import get_oauth2_authorize_url, get_oauth_keys
out = []
providers = frappe.get_all(
"Social Login Key",
filters={"enable_social_login": 1},
fields=["name", "client_id", "base_url", "provider_name", "icon"],
order_by="name",
)
for provider in providers:
client_secret = get_decrypted_password("Social Login Key", provider.name, "client_secret")
if not client_secret:
continue
icon = None
if provider.icon:
if provider.provider_name == "Custom":
icon = get_icon_html(provider.icon, small=True)
else:
icon = f"<img src='{provider.icon}' alt={provider.provider_name}>"
if provider.client_id and provider.base_url and get_oauth_keys(provider.name):
out.append(
{
"name": provider.name,
"provider_name": provider.provider_name,
"auth_url": get_oauth2_authorize_url(provider.name, "/drive/home"),
"icon": icon,
}
)
return out
@frappe.whitelist(allow_guest=True)
def get_server_timezone():
return frappe.db.get_single_value('System Settings', 'time_zone')
|
2302_79757062/drive
|
drive/api/api.py
|
Python
|
agpl-3.0
| 1,533
|
import frappe
import os
import re
import magic
import mimetypes
from werkzeug.utils import secure_filename
from werkzeug.wrappers import Response
from werkzeug.wsgi import wrap_file
from drive.locks.distributed_lock import DistributedLock
from pathlib import Path
from io import BytesIO
from drive.utils.files import get_user_directory
from drive.api.files import create_drive_entity
def create_user_embeds_directory(user=None):
user_directory_name = get_user_directory(user).name
user_directory_embeds_path = Path(
frappe.get_site_path("private/files"), user_directory_name, "embeds"
)
user_directory_embeds_path.mkdir(exist_ok=True)
return user_directory_embeds_path
def get_user_embeds_directory(user=None):
user_directory_name = get_user_directory(user).name
user_directory_embeds_path = Path(
frappe.get_site_path("private/files"), user_directory_name, "embeds"
)
if not os.path.exists(user_directory_embeds_path):
try:
user_directory_embeds_path = create_user_embeds_directory()
except FileNotFoundError:
user_directory_embeds_path = create_user_embeds_directory()
return user_directory_embeds_path
@frappe.whitelist()
def upload_chunked_file(fullpath=None, parent=None, last_modified=None):
"""
Accept chunked file contents via a multipart upload, store the file on
disk, and insert a corresponding DriveEntity doc.
:param fullpath: Full path of the uploaded file
:param parent: Document-name of the parent folder. Defaults to the user directory
:raises PermissionError: If the user does not have write access to the specified parent folder
:raises FileExistsError: If a file with the same name already exists in the specified parent folder
:raises ValueError: If the size of the stored file does not match the specified filesize
:return: DriveEntity doc once the entire file has been uploaded
"""
parent = frappe.form_dict.parent
drive_entity = frappe.get_value(
"Drive Entity",
parent,
["document", "title", "mime_type", "file_size", "owner"],
as_dict=1,
)
try:
embed_directory = get_user_embeds_directory(user=drive_entity.owner)
except FileNotFoundError:
embed_directory = create_user_embeds_directory(user=drive_entity.owner)
embed_directory = Path(
frappe.get_site_path("private/files"),
get_user_directory(user=drive_entity.owner).name,
"embeds",
)
if not frappe.has_permission(
doctype="Drive Entity", doc=parent, ptype="write", user=frappe.session.user
):
frappe.throw("Cannot upload due to insufficient permissions", frappe.PermissionError)
file = frappe.request.files["file"]
name = frappe.form_dict.uuid
title, file_ext = os.path.splitext(frappe.form_dict.file_name)
mime_type = frappe.form_dict.mime_type
current_chunk = int(frappe.form_dict.chunk_index)
total_chunks = int(frappe.form_dict.total_chunk_count)
file_size = int(frappe.form_dict.total_file_size)
save_path = Path(embed_directory) / f"{secure_filename(name+file_ext)}"
if current_chunk == 0 and save_path.exists():
frappe.throw(f"File '{title}' already exists", FileExistsError)
if not mime_type:
mime_type = magic.from_buffer(open(save_path, "rb").read(2048), mime=True)
with save_path.open("ab") as f:
f.seek(int(frappe.form_dict.chunk_byte_offset))
f.write(file.stream.read())
if current_chunk + 1 == total_chunks:
file_size = save_path.stat().st_size
if file_size != int(frappe.form_dict.total_file_size):
save_path.unlink()
frappe.throw("Size on disk does not match specified filesize", ValueError)
drive_entity = create_drive_entity(
name, title, parent, save_path, file_size, file_ext, mime_type, last_modified
)
return str(name + file_ext)
@frappe.whitelist(allow_guest=True)
def get_file_content(embed_name, parent_entity_name, trigger_download=0):
"""
Stream file content and optionally trigger download
:param entity_name: Document-name of the file whose content is to be streamed
:param trigger_download: 1 to trigger the "Save As" dialog. Defaults to 0
:type trigger_download: int
:raises ValueError: If the DriveEntity doc does not exist or is not a file
:raises PermissionError: If the current user does not have permission to read the file
:raises FileLockedError: If the file has been writer-locked
"""
drive_entity = frappe.get_value(
"Drive Entity",
parent_entity_name,
["document", "title", "mime_type", "file_size", "owner"],
as_dict=1,
)
if not drive_entity.document:
raise ValueError
is_public = False
if frappe.db.exists(
{
"doctype": "Drive DocShare",
"share_doctype": "Drive Entity",
"share_name": parent_entity_name,
"public": 1,
}
):
is_public = True
if not is_public:
if not frappe.has_permission(
doctype="Drive Entity",
doc=parent_entity_name,
ptype="read",
user=frappe.session.user,
):
raise frappe.PermissionError("You do not have permission to view this file")
with DistributedLock(drive_entity.path, exclusive=False):
user_embeds_directory = get_user_embeds_directory(user=drive_entity.owner)
embed_path = Path(user_embeds_directory, embed_name)
with open(str(embed_path), "rb") as file:
range_header = frappe.request.headers.get("Range", None)
if range_header:
return stream_file_content(embed_path, range_header)
embed_data = BytesIO(file.read())
response = Response(
wrap_file(frappe.request.environ, embed_data),
direct_passthrough=True,
)
response.headers.set("Content-Disposition", "inline", filename=embed_name)
return response
def stream_file_content(embed_path, range_header):
"""
Stream file content and optionally trigger download
:param entity_name: Document-name of the file whose content is to be streamed
:param drive_entity: Drive Entity record object
"""
# range_header = frappe.request.headers.get("Range", None)
size = os.path.getsize(str(embed_path))
byte1, byte2 = 0, None
m = re.search("(\d+)-(\d*)", range_header)
g = m.groups()
if g[0]:
byte1 = int(g[0])
if g[1]:
byte2 = int(g[1])
length = size - byte1
if byte2 is not None:
length = byte2 - byte1
data = None
with open(embed_path, "rb") as f:
f.seek(byte1)
data = f.read(length)
res = Response(
data, 206, mimetype=mimetypes.guess_type(embed_path)[0], direct_passthrough=True
)
res.headers.add("Content-Range", "bytes {0}-{1}/{2}".format(byte1, byte1 + length - 1, size))
return res
|
2302_79757062/drive
|
drive/api/embed.py
|
Python
|
agpl-3.0
| 7,025
|
import frappe
import os
import re
from urllib.parse import quote
import json
from pypika import Order, Case, functions as fn
from pathlib import Path
from werkzeug.wrappers import Response
from werkzeug.utils import secure_filename, send_file
import uuid
import mimetypes
import hashlib
import json
from drive.utils.files import (
get_user_directory,
create_user_directory,
get_new_title,
get_user_thumbnails_directory,
create_user_thumbnails_directory,
create_thumbnail,
)
from drive.locks.distributed_lock import DistributedLock
from datetime import date, timedelta
import magic
from datetime import datetime
import urllib.parse
from frappe.utils import cint
from drive.api.notifications import notify_mentions
from drive.api.storage import get_storage_allowed
def if_folder_exists(folder_name, parent):
values = {
"title": folder_name,
"is_group": 1,
"is_active": 1,
"owner": frappe.session.user,
"parent_drive_entity": parent,
}
existing_folder = frappe.db.get_value(
"Drive Entity", values, ["name", "title", "is_group", "is_active"], as_dict=1
)
if existing_folder:
return existing_folder.name
new_folder = create_folder(folder_name, parent)
return new_folder.name
@frappe.whitelist()
def get_home_folder_id(user=None):
"""Returns user directory name from user's unique id"""
if not user:
user = frappe.session.user
return get_user_directory(user).name
@frappe.whitelist()
def create_document_entity(title, content, parent=None):
try:
user_directory = get_user_directory()
except FileNotFoundError:
user_directory = create_user_directory()
new_title = get_new_title(title, parent, document=True)
parent = frappe.form_dict.parent or user_directory.name
if not frappe.has_permission(
doctype="Drive Entity",
doc=parent,
ptype="write",
user=frappe.session.user,
):
frappe.throw(
"Cannot access folder due to insufficient permissions",
frappe.PermissionError,
)
drive_doc = frappe.new_doc("Drive Document")
drive_doc.title = new_title
drive_doc.content = content
drive_doc.version = 1
drive_doc.save()
drive_entity = frappe.new_doc("Drive Entity")
drive_entity.title = new_title
drive_entity.name = uuid.uuid4().hex
drive_entity.parent_drive_entity = parent
drive_entity.mime_type = "frappe_doc"
drive_entity.document = drive_doc
drive_entity.file_size = 0
drive_entity.flags.file_created = True
drive_entity.save()
return drive_entity
def create_uploads_directory(user=None):
user_directory_name = get_user_directory(user).name
user_directory_uploads_path = Path(
frappe.get_site_path("private/files"), user_directory_name, "uploads"
)
user_directory_uploads_path.mkdir(exist_ok=True)
return user_directory_uploads_path
def get_user_uploads_directory(user=None):
user_directory_name = get_user_directory(user).name
user_directory_uploads_path = Path(
frappe.get_site_path("private/files"), user_directory_name, "uploads"
)
if not os.path.exists(user_directory_uploads_path):
try:
user_directory_uploads_path = create_uploads_directory()
except FileNotFoundError:
user_directory_uploads_path = create_uploads_directory()
return user_directory_uploads_path
@frappe.whitelist()
def upload_file(fullpath=None, parent=None, last_modified=None):
"""
Accept chunked file contents via a multipart upload, store the file on
disk, and insert a corresponding DriveEntity doc.
:param fullpath: Full path of the uploaded file
:param parent: Document-name of the parent folder. Defaults to the user directory
:raises PermissionError: If the user does not have write access to the specified parent folder
:raises FileExistsError: If a file with the same name already exists in the specified parent folder
:raises ValueError: If the size of the stored file does not match the specified filesize
:return: DriveEntity doc once the entire file has been uploaded
"""
try:
user_directory = get_user_directory()
except FileNotFoundError:
user_directory = create_user_directory()
parent = frappe.form_dict.parent or user_directory.name
if fullpath:
dirname = os.path.dirname(fullpath).split("/")
for i in dirname:
parent = if_folder_exists(i, parent)
if not frappe.has_permission(
doctype="Drive Entity", doc=parent, ptype="write", user=frappe.session.user
):
frappe.throw("Cannot upload due to insufficient permissions", frappe.PermissionError)
file = frappe.request.files["file"]
upload_session = frappe.form_dict.uuid
title = get_new_title(file.filename, parent)
current_chunk = int(frappe.form_dict.chunk_index)
total_chunks = int(frappe.form_dict.total_chunk_count)
save_path = Path(user_directory.path) / f"{parent}_{secure_filename(title)}"
temp_path = (
Path(get_user_uploads_directory(user=frappe.session.user))
/ f"{upload_session}_{secure_filename(title)}"
)
if get_storage_allowed() < int(frappe.form_dict.total_file_size):
frappe.throw("Out of allocated storage", ValueError)
with temp_path.open("ab") as f:
f.seek(int(frappe.form_dict.chunk_byte_offset))
f.write(file.stream.read())
if not f.tell() >= int(frappe.form_dict.total_file_size):
return
else:
pass
if current_chunk + 1 == total_chunks:
file_size = temp_path.stat().st_size
if file_size != int(frappe.form_dict.total_file_size):
temp_path.unlink()
frappe.throw("Size on disk does not match specified filesize", ValueError)
else:
os.rename(temp_path, save_path)
mime_type, _ = mimetypes.guess_type(temp_path)
if mime_type is None:
# Read the first 2KB of the binary stream to determine the file type if string checking failed
# Do a rejection workflow to reject undesired mime types
mime_type = magic.from_buffer(open(save_path, "rb").read(2048), mime=True)
file_name, file_ext = os.path.splitext(title)
name = uuid.uuid4().hex
path = save_path.parent / f"{name}{save_path.suffix}"
save_path.rename(path)
drive_entity = create_drive_entity(
name, title, parent, path, file_size, file_ext, mime_type, last_modified
)
if mime_type.startswith(("image", "video")):
frappe.enqueue(
create_thumbnail,
queue="default",
timeout=None,
now=True,
at_front=True,
# will set to false once reactivity in new UI is solved
entity_name=name,
path=path,
mime_type=mime_type,
)
return drive_entity
def create_drive_entity(name, title, parent, path, file_size, file_ext, mime_type, last_modified):
drive_entity = frappe.get_doc(
{
"doctype": "Drive Entity",
"name": name,
"title": title,
"parent_drive_entity": parent,
"path": str(path),
"file_size": file_size,
"file_ext": file_ext,
"mime_type": mime_type,
}
)
drive_entity.flags.file_created = True
drive_entity.insert()
if last_modified:
dt_object = datetime.fromtimestamp(int(last_modified) / 1000.0)
formatted_datetime = dt_object.strftime("%Y-%m-%d %H:%M:%S.%f")
drive_entity.db_set("modified", formatted_datetime, update_modified=False)
return drive_entity
@frappe.whitelist()
def create_folder(title, parent=None):
"""
Create a new folder.
:param title: Folder name
:param parent: Document-name of the parent folder. Defaults to the user directory
:raises PermissionError: If the user does not have write access to the specified parent folder
:raises FileExistsError: If a folder with the same name already exists in the specified parent folder
:return: DriveEntity doc of the new folder
"""
try:
user_directory = get_user_directory()
except FileNotFoundError:
user_directory = create_user_directory()
parent = parent or user_directory.name
if not frappe.has_permission(
doctype="Drive Entity", doc=parent, ptype="write", user=frappe.session.user
):
frappe.throw(
"Cannot create folder due to insufficient permissions",
frappe.PermissionError,
)
entity_exists = frappe.db.exists(
{"doctype": "Drive Entity", "parent_drive_entity": parent, "title": title}
)
if entity_exists:
suggested_name = get_new_title(title, parent, folder=True)
frappe.throw(
f"Folder '{title}' already exists.\n Suggested: {suggested_name}",
FileExistsError,
)
drive_entity = frappe.get_doc(
{
"doctype": "Drive Entity",
"name": uuid.uuid4().hex,
"title": title,
"is_group": 1,
"parent_drive_entity": parent,
"color": "#525252",
}
)
drive_entity.insert()
return drive_entity
def get_doc_content(drive_document_name):
drive_document = frappe.db.get_value(
"Drive Document",
drive_document_name,
["content", "raw_content", "settings", "version"],
as_dict=1,
)
return drive_document
@frappe.whitelist()
def passive_rename(entity_name, new_title):
frappe.db.set_value("Drive Entity", entity_name, "title", new_title)
return new_title
@frappe.whitelist()
def save_doc(entity_name, doc_name, raw_content, content, file_size, mentions, settings=None):
if not frappe.has_permission(
doctype="Drive Entity",
doc=entity_name,
ptype="write",
user=frappe.session.user,
):
raise frappe.PermissionError("You do not have permission to view this file")
if settings:
frappe.db.set_value("Drive Document", doc_name, "settings", json.dumps(settings))
file_size = len(content.encode("utf-8")) + len(raw_content.encode("utf-8"))
frappe.db.set_value("Drive Document", doc_name, "content", content)
frappe.db.set_value("Drive Document", doc_name, "raw_content", raw_content)
frappe.db.set_value("Drive Document", doc_name, "mentions", json.dumps(mentions))
frappe.db.set_value("Drive Entity", entity_name, "file_size", file_size)
if json.dumps(mentions):
frappe.enqueue(
notify_mentions,
queue="long",
job_id=f"fdoc_{doc_name}",
deduplicate=True,
timeout=None,
now=False,
at_front=False,
entity_name=entity_name,
document_name=doc_name,
)
return
@frappe.whitelist()
def create_doc_version(entity_name, doc_name, snapshot_data, snapshot_message):
if not frappe.has_permission(
doctype="Drive Entity",
doc=entity_name,
ptype="write",
user=frappe.session.user,
):
raise frappe.PermissionError("You do not have permission to view this file")
new_version = frappe.new_doc("Drive Document Version")
new_version.snapshot_data = snapshot_data
new_version.parent_entity = entity_name
new_version.snapshot_message = snapshot_message
new_version.parent_document = doc_name
new_version.snapshot_size = len(snapshot_data.encode("utf-8"))
new_version.save()
return
@frappe.whitelist()
def get_doc_version_list(entity_name):
if not frappe.has_permission(
doctype="Drive Entity",
doc=entity_name,
ptype="write",
user=frappe.session.user,
):
raise frappe.PermissionError("You do not have permission to view this file")
return frappe.get_list(
"Drive Document Version",
filters={"parent_entity": entity_name},
order_by="creation desc",
fields=["*"],
)
@frappe.whitelist()
def preview_doc_version(version_name):
preview_version = frappe.get_doc("Drive Document Version", version_name)
return preview_version
@frappe.whitelist(allow_guest=True)
def get_file_content(entity_name, trigger_download=0): #
"""
Stream file content and optionally trigger download
:param entity_name: Document-name of the file whose content is to be streamed
:param trigger_download: 1 to trigger the "Save As" dialog. Defaults to 0
:type trigger_download: int
:raises ValueError: If the DriveEntity doc does not exist or is not a file
:raises PermissionError: If the current user does not have permission to read the file
:raises FileLockedError: If the file has been writer-locked
"""
if not frappe.has_permission(
doctype="Drive Entity",
doc=entity_name,
ptype="read",
user=frappe.session.user,
):
raise frappe.PermissionError("You do not have permission to view this file")
trigger_download = int(trigger_download)
drive_entity = frappe.get_value(
"Drive Entity",
entity_name,
[
"is_group",
"path",
"title",
"mime_type",
"file_size",
"allow_download",
"is_active",
"owner",
],
as_dict=1,
)
if not drive_entity or drive_entity.is_group:
raise ValueError
if drive_entity.is_active != 1:
raise FileNotFoundError
with DistributedLock(drive_entity.path, exclusive=False):
if frappe.conf.developer_mode:
return send_file(
drive_entity.path,
mimetype=drive_entity.mime_type,
as_attachment=trigger_download,
conditional=True,
max_age=3600,
download_name=drive_entity.title,
environ=frappe.request.environ,
)
else:
folders = drive_entity.path.split(os.path.sep)
new_path = "/protected/" + os.path.sep.join(folders[1:])
response = Response()
response.headers.set("Content-Length", str(drive_entity.file_size))
response.headers.set("X-Accel-Redirect", new_path)
response.headers.set("Content-Disposition", "attachment", filename=drive_entity.title)
return response
def stream_file_content(drive_entity, range_header):
"""
Stream file content and optionally trigger download
:param entity_name: Document-name of the file whose content is to be streamed
:param drive_entity: Drive Entity record object
"""
# range_header = frappe.request.headers.get("Range", None)
size = os.path.getsize(drive_entity.path)
byte1, byte2 = 0, None
m = re.search("(\d+)-(\d*)", range_header)
g = m.groups()
if g[0]:
byte1 = int(g[0])
if g[1]:
byte2 = int(g[1])
length = size - byte1
max_length = 20 * 1024 * 1024 # 20 MB in bytes
if length > max_length:
length = max_length
if byte2 is not None:
length = byte2 - byte1
data = None
with open(drive_entity.path, "rb") as f:
f.seek(byte1)
data = f.read(length)
res = Response(
data, 206, mimetype=mimetypes.guess_type(drive_entity.path)[0], direct_passthrough=True
)
res.headers.add("Content-Range", "bytes {0}-{1}/{2}".format(byte1, byte1 + length - 1, size))
return res
@frappe.whitelist(allow_guest=True)
def list_folder_contents(entity_name=None, order_by="modified", is_active=1, limit=100, offset=0):
"""
Return list of DriveEntity records present in this folder
:param entity_name: Document-name of the folder whose contents are to be listed. Defaults to the user directory
:param order_by: Sort the list of results according to the specified field (eg: 'modified desc'). Defaults to 'title'
:raises NotADirectoryError: If this DriveEntity doc is not a folder
:raises PermissionError: If the user does not have access to the specified folder
:return: List of DriveEntity records
:rtype: list
"""
try:
entity_name = entity_name or get_user_directory().name
except FileNotFoundError:
return []
parent, parent_is_group, parent_is_active = frappe.db.get_value(
"Drive Entity", entity_name, ["name", "is_group", "is_active"]
)
# Parent can be null for $HOME_DIR
if parent:
if not parent_is_group:
frappe.throw("Specified entity is not a folder", NotADirectoryError)
if not parent_is_active:
frappe.throw("Specified folder has been trashed by the owner")
is_public = False
if frappe.db.exists(
{
"doctype": "Drive DocShare",
"share_doctype": "Drive Entity",
"share_name": entity_name,
"public": 1,
}
):
is_public = True
if not is_public:
if not frappe.has_permission(
doctype="Drive Entity",
doc=entity_name,
ptype="read",
user=frappe.session.user,
):
frappe.throw(
"Cannot access folder due to insufficient permissions",
frappe.PermissionError,
)
general_access_val = "public" if is_public else "everyone"
DriveEntity = frappe.qb.DocType("Drive Entity")
DriveFavourite = frappe.qb.DocType("Drive Favourite")
DriveDocShare = frappe.qb.DocType("Drive DocShare")
DriveUser = frappe.qb.DocType("User")
UserGroupMember = frappe.qb.DocType("User Group Member")
selectedFields = [
DriveEntity.name,
DriveEntity.title,
DriveEntity.is_group,
DriveEntity.owner,
DriveUser.full_name,
DriveUser.user_image,
DriveEntity.modified,
DriveEntity.creation,
DriveEntity.file_size,
DriveEntity.file_ext,
DriveEntity.color,
DriveEntity.document,
DriveEntity.mime_type,
DriveEntity.parent_drive_entity,
DriveEntity.allow_download,
DriveEntity.is_active,
DriveEntity.allow_comments,
DriveDocShare.read,
DriveDocShare.user_name,
fn.Max(DriveDocShare.write).as_("write"),
DriveDocShare.public,
DriveDocShare.everyone,
DriveDocShare.share,
DriveFavourite.entity.as_("is_favourite"),
]
query = (
frappe.qb.from_(DriveEntity)
.left_join(DriveDocShare)
.on((DriveDocShare.share_name == DriveEntity.name))
.left_join(UserGroupMember)
.on((UserGroupMember.parent == DriveDocShare.user_name))
.left_join(DriveFavourite)
.on(
(DriveFavourite.entity == DriveEntity.name)
& (DriveFavourite.user == frappe.session.user)
)
.left_join(DriveUser)
.on((DriveEntity.owner == DriveUser.email))
.offset(offset)
.limit(limit)
.select(*selectedFields)
.where(
(DriveEntity.parent_drive_entity == entity_name)
& (DriveEntity.is_active == 1)
& (
(UserGroupMember.user == frappe.session.user)
| (
(DriveDocShare.user_name == frappe.session.user)
| (DriveDocShare[general_access_val] == 1)
| (DriveEntity.owner == frappe.session.user)
)
)
)
.groupby(DriveEntity.name)
.orderby(
Case().when(DriveEntity.is_group == True, 1).else_(2),
Order.desc,
)
.orderby(
order_by.split()[0],
order=Order.desc if order_by.endswith("desc") else Order.asc,
)
)
result = query.run(as_dict=True)
return result
@frappe.whitelist()
def list_owned_entities(
entity_name=None, order_by="modified", is_active=True, limit=100, offset=0
):
"""
Return list of DriveEntity records present in this folder
:param entity_name: Document-name of the folder whose contents are to be listed. Defaults to the user directory
:param order_by: Sort the list of results according to the specified field (eg: 'modified desc'). Defaults to 'title'
:raises NotADirectoryError: If this DriveEntity doc is not a folder
:raises PermissionError: If the user does not have access to the specified folder
:return: List of DriveEntity records
:rtype: list
"""
is_active = json.loads(is_active)
try:
entity_name = entity_name or get_user_directory().name
except FileNotFoundError:
return []
parent_is_group, parent_is_active, parent_owner = frappe.db.get_value(
"Drive Entity", entity_name, ["is_group", "is_active", "owner"]
)
if not parent_is_group:
frappe.throw("Specified entity is not a folder", NotADirectoryError)
if not parent_is_active:
frappe.throw("Specified folder has been trashed by the owner")
if not frappe.session.user == parent_owner:
frappe.throw("Not permitted")
if not frappe.has_permission(
doctype="Drive Entity", doc=entity_name, ptype="write", user=frappe.session.user
):
frappe.throw(
"Not permitted to read",
frappe.PermissionError,
)
# entity_ancestors = get_ancestors_of("Drive Entity", entity_name)
# flag = False
# for z_entity_name in entity_ancestors:
# result = frappe.db.exists("Drive Entity", {"name": z_entity_name, "is_active": 0})
# if result:
# flag = True
# break
# if flag == True:
# frappe.throw("Parent Folder has been deleted")
DriveEntity = frappe.qb.DocType("Drive Entity")
DriveUser = frappe.qb.DocType("User")
DriveFavourite = frappe.qb.DocType("Drive Favourite")
selectedFields = [
DriveEntity.name,
DriveEntity.title,
DriveEntity.is_group,
DriveEntity.owner,
DriveUser.full_name,
DriveUser.user_image,
DriveEntity.modified,
DriveEntity.creation,
DriveEntity.file_size,
DriveEntity.file_ext,
DriveEntity.color,
DriveEntity.document,
DriveEntity.mime_type,
DriveEntity.parent_drive_entity,
DriveEntity.allow_download,
DriveEntity.allow_comments,
DriveEntity.is_active,
DriveFavourite.entity.as_("is_favourite"),
]
query = (
frappe.qb.from_(DriveEntity)
.left_join(DriveFavourite)
.on(
(DriveFavourite.entity == DriveEntity.name)
& (DriveFavourite.user == frappe.session.user)
)
.left_join(DriveUser)
.on((DriveEntity.owner == DriveUser.email))
.offset(offset)
.limit(limit)
.select(*selectedFields)
.where(
(DriveEntity.parent_drive_entity == entity_name) & (DriveEntity.is_active == is_active)
)
.groupby(DriveEntity.name)
.orderby(
Case().when(DriveEntity.is_group == True, 1).else_(2),
Order.desc,
)
.orderby(
order_by.split()[0],
order=Order.desc if order_by.endswith("desc") else Order.asc,
)
)
result = query.run(as_dict=True)
for i in result:
if i.is_group:
child_count = get_children_count(i.name)
i["item_count"] = child_count
return result
@frappe.whitelist()
def list_trashed_entities(
entity_name=None, order_by="modified", is_active=True, limit=100, offset=0
):
"""
Return list of DriveEntity records present in this folder
:param entity_name: Document-name of the folder whose contents are to be listed. Defaults to the user directory
:param order_by: Sort the list of results according to the specified field (eg: 'modified desc'). Defaults to 'title'
:raises NotADirectoryError: If this DriveEntity doc is not a folder
:raises PermissionError: If the user does not have access to the specified folder
:return: List of DriveEntity records
:rtype: list
"""
is_active = json.loads(is_active)
try:
entity_name = entity_name or get_user_directory().name
except FileNotFoundError:
return []
parent_is_group, parent_is_active, parent_owner = frappe.db.get_value(
"Drive Entity", entity_name, ["is_group", "is_active", "owner"]
)
if not parent_is_group:
frappe.throw("Specified entity is not a folder", NotADirectoryError)
if not parent_is_active:
frappe.throw("Specified folder has been trashed by the owner")
if not frappe.session.user == parent_owner:
frappe.throw("Not permitted")
if not frappe.has_permission(
doctype="Drive Entity", doc=entity_name, ptype="write", user=frappe.session.user
):
frappe.throw(
"Not permitted to read",
frappe.PermissionError,
)
# entity_ancestors = get_ancestors_of("Drive Entity", entity_name)
# flag = False
# for z_entity_name in entity_ancestors:
# result = frappe.db.exists("Drive Entity", {"name": z_entity_name, "is_active": 0})
# if result:
# flag = True
# break
# if flag == True:
# frappe.throw("Parent Folder has been deleted")
DriveEntity = frappe.qb.DocType("Drive Entity")
DriveUser = frappe.qb.DocType("User")
DriveFavourite = frappe.qb.DocType("Drive Favourite")
selectedFields = [
DriveEntity.name,
DriveEntity.title,
DriveEntity.is_group,
DriveEntity.owner,
DriveUser.full_name,
DriveUser.user_image,
DriveEntity.modified,
DriveEntity.creation,
DriveEntity.file_size,
DriveEntity.file_ext,
DriveEntity.color,
DriveEntity.document,
DriveEntity.mime_type,
DriveEntity.parent_drive_entity,
DriveEntity.allow_download,
DriveEntity.allow_comments,
DriveEntity.is_active,
DriveFavourite.entity.as_("is_favourite"),
]
query = (
frappe.qb.from_(DriveEntity)
.left_join(DriveFavourite)
.on(
(DriveFavourite.entity == DriveEntity.name)
& (DriveFavourite.user == frappe.session.user)
)
.left_join(DriveUser)
.on((DriveEntity.owner == DriveUser.email))
.offset(offset)
.limit(limit)
.select(*selectedFields)
.where((DriveEntity.is_active == 0) & (DriveEntity.owner == frappe.session.user))
.groupby(DriveEntity.name)
.orderby(
Case().when(DriveEntity.is_group == True, 1).else_(2),
Order.desc,
)
.orderby(
order_by.split()[0],
order=Order.desc if order_by.endswith("desc") else Order.asc,
)
)
result = query.run(as_dict=True)
for i in result:
if i.is_group:
child_count = get_children_count(i.name)
i["item_count"] = child_count
return result
def get_entity(entity_name, fields=None):
"""
Return specific entity
:param entity_name: Document-name of the file or folder
:raises PermissionError: If the user does not have access to the specified entity
:rtype: frappe._dict
"""
fields = fields or ["name", "title", "owner"]
return frappe.db.get_value("Drive Entity", entity_name, fields, as_dict=1)
@frappe.whitelist(allow_guest=True)
def list_entity_comments(entity_name):
Comment = frappe.qb.DocType("Comment")
User = frappe.qb.DocType("User")
selectedFields = [
Comment.comment_by,
Comment.comment_email,
Comment.creation,
Comment.content,
User.user_image,
]
query = (
frappe.qb.from_(Comment)
.inner_join(User)
.on(Comment.comment_email == User.name)
.select(*selectedFields)
.where(
(Comment.comment_type == "Comment")
& (Comment.reference_doctype == "Drive Entity")
& (Comment.reference_name == entity_name)
)
.orderby(Comment.creation, order=Order.asc)
)
return query.run(as_dict=True)
@frappe.whitelist()
def unshare_entities(entity_names, move=False):
"""
Unshare DriveEntities
:param entity_names: List of document-names
:type entity_names: list[str]
:param move: if True, moves entity to root entity of user
:type move: Boolean
:raises ValueError: If decoded entity_names is not a list
"""
if isinstance(entity_names, str):
entity_names = json.loads(entity_names)
if not isinstance(entity_names, list):
frappe.throw(f"Expected list but got {type(entity_names)}", ValueError)
for entity in entity_names:
doc = frappe.get_doc("Drive Entity", entity)
if not doc:
frappe.throw("Entity does not exist", ValueError)
if move:
doc.move()
doc.unshare(frappe.session.user)
def delete_background_job(entity, ignore_permissions):
frappe.delete_doc("Drive Entity", entity, ignore_permissions=ignore_permissions)
@frappe.whitelist()
def delete_entities(entity_names=None, clear_all=None):
"""
Delete DriveEntities
:param entity_names: List of document-names
:type entity_names: list[str]
:raises ValueError: If decoded entity_names is not a list
"""
if clear_all:
entity_names = frappe.db.get_list(
"Drive Entity", {"is_active": ["<", "1"], "owner": frappe.session.user}, pluck="name"
)
if isinstance(entity_names, str):
entity_names = json.loads(entity_names)
if not isinstance(entity_names, list):
frappe.throw(f"Expected list but got {type(entity_names)}", ValueError)
for entity in entity_names:
root_entity = get_ancestors_of(entity)
if root_entity:
root_entity = get_ancestors_of(entity)[0]
else:
root_entity = get_user_directory()
owns_root_entity = frappe.has_permission(
doctype="Drive Entity",
doc=root_entity,
ptype="write",
user=frappe.session.user,
)
has_write_access = frappe.has_permission(
doctype="Drive Entity", doc=entity, ptype="write", user=frappe.session.user
)
ignore_permissions = owns_root_entity or has_write_access
frappe.db.set_value("Drive Entity", entity, "is_active", -1)
frappe.enqueue(
delete_background_job,
queue="default",
timeout=None,
entity=entity,
ignore_permissions=ignore_permissions,
)
@frappe.whitelist()
def list_favourites(order_by="modified", limit=100, offset=0):
"""
Return list of DriveEntity records present in this folder
:param order_by: Sort the list of results according to the specified field (eg: 'modified desc'). Defaults to 'title'
:return: List of DriveEntity records
:rtype: list
"""
DriveFavourite = frappe.qb.DocType("Drive Favourite")
DriveEntity = frappe.qb.DocType("Drive Entity")
DriveDocShare = frappe.qb.DocType("Drive DocShare")
DriveUser = frappe.qb.DocType("User")
UserGroupMember = frappe.qb.DocType("User Group Member")
selectedFields = [
DriveEntity.name,
DriveEntity.title,
DriveEntity.is_group,
DriveEntity.owner,
DriveUser.full_name,
DriveEntity.owner,
DriveEntity.modified,
DriveEntity.creation,
DriveEntity.file_size,
DriveEntity.mime_type,
DriveEntity.color,
DriveEntity.document,
DriveEntity.parent_drive_entity,
DriveEntity.allow_comments,
DriveDocShare.read,
fn.Max(DriveDocShare.write).as_("write"),
DriveDocShare.share,
DriveDocShare.everyone,
DriveFavourite.entity.as_("is_favourite"),
]
query = (
frappe.qb.from_(DriveEntity)
.right_join(DriveFavourite)
.on(
(DriveFavourite.entity == DriveEntity.name)
& (DriveFavourite.user == frappe.session.user)
)
.left_join(DriveDocShare)
.on((DriveDocShare.share_name == DriveEntity.name))
.left_join(UserGroupMember)
.on(
(
(UserGroupMember.parent == DriveDocShare.user_name)
& (UserGroupMember.user == frappe.session.user)
)
| (
(DriveDocShare.user_name == frappe.session.user)
| ((DriveDocShare.everyone == 1) | (DriveDocShare.public == 1))
)
)
.left_join(DriveUser)
.on((DriveEntity.owner == DriveUser.email))
.offset(offset)
.limit(limit)
.select(*selectedFields)
.where(
(DriveEntity.is_active == 1)
& ((DriveEntity.owner == frappe.session.user) | (DriveDocShare.read == 1))
)
.groupby(DriveEntity.name)
.orderby(
Case().when(DriveEntity.is_group == True, 1).else_(2),
Order.desc,
)
.orderby(
order_by.split()[0],
order=Order.desc if order_by.endswith("desc") else Order.asc,
)
)
return query.run(as_dict=True)
@frappe.whitelist()
def add_or_remove_favourites(entity_names=None, clear_all=False):
"""
Favouite or unfavourite DriveEntities for specified user
:param entity_names: List of document-names
:type entity_names: list[str]
:raises ValueError: If decoded entity_names is not a list
"""
if clear_all:
frappe.db.delete("Drive Favourite", {"user": frappe.session.user})
return
if isinstance(entity_names, str):
entity_names = json.loads(entity_names)
if not isinstance(entity_names, list):
frappe.throw(f"Expected list but got {type(entity_names)}", ValueError)
for entity in entity_names:
existing_doc = frappe.db.exists(
{
"doctype": "Drive Favourite",
"entity": entity,
"user": frappe.session.user,
}
)
if existing_doc:
frappe.delete_doc("Drive Favourite", existing_doc)
else:
doc = frappe.get_doc(
{
"doctype": "Drive Favourite",
"entity": entity,
"user": frappe.session.user,
}
)
doc.insert()
# def toggle_is_active(doc):
# doc.is_active = 0 if doc.is_active else 1
# frappe.db.set_value('Drive Entity', doc.name, 'is_active',doc.is_active)
# for child in doc.get_children():
# toggle_is_active(child)
@frappe.whitelist()
def remove_or_restore(entity_names, move=False):
"""
To move entities to or restore entities from the trash
:param entity_names: List of document-names
:type entity_names: list[str]
"""
if isinstance(entity_names, str):
entity_names = json.loads(entity_names)
if not isinstance(entity_names, list):
frappe.throw(f"Expected list but got {type(entity_names)}", ValueError)
def depth_zero_toggle_is_active(doc):
if doc.is_active:
frappe.db.delete("Drive DocShare", {"share_name": doc.name})
doc.is_active = 0
else:
doc.is_active = 1
doc.inherit_permissions()
frappe.db.set_value("Drive Entity", doc.name, "is_active", doc.is_active)
for entity in entity_names:
doc = frappe.get_doc("Drive Entity", entity)
if doc.owner != frappe.session.user:
raise frappe.PermissionError("You do not have permission to remove this file")
if doc.is_active:
entity_ancestors = get_ancestors_of(entity)
if entity_ancestors:
doc.parent_before_trash = entity_ancestors[0]
doc.save()
else:
doc.parent_before_trash = get_user_directory()
doc.save()
if move:
doc.move()
else:
parent_is_active = frappe.db.get_value(
"Drive Entity", doc.parent_before_trash, "is_active"
)
if parent_is_active:
doc.move(doc.parent_before_trash)
else:
doc.move()
depth_zero_toggle_is_active(doc)
# frappe.enqueue(toggle_is_active,queue="default",timeout=None,doc=doc)
@frappe.whitelist(allow_guest=True)
def call_controller_method(entity_name, method):
"""
Call a whitelisted Drive Entity controller method
:param entity_name: Document-name of the document on which the controller method is to be called
:param method: The controller method to be called
:raises ValueError: If the entity does not exist
:return: The result of the controller method
"""
drive_entity = frappe.get_doc("Drive Entity", frappe.local.form_dict.pop("entity_name"))
if not drive_entity:
frappe.throw("Entity does not exist", ValueError)
method = frappe.local.form_dict.pop("method")
drive_entity.is_whitelisted(method)
frappe.local.form_dict.pop("cmd")
return drive_entity.run_method(method, **frappe.local.form_dict)
@frappe.whitelist()
def list_recents(order_by="last_interaction", limit=100, offset=0):
"""
Return list of DriveEntity records present in this folder
:param order_by: Sort the list of results according to the specified field (eg: 'modified desc'). Defaults to 'title'
:return: List of DriveEntity records
:rtype: list
"""
DriveFavourite = frappe.qb.DocType("Drive Favourite")
DriveEntity = frappe.qb.DocType("Drive Entity")
DriveDocShare = frappe.qb.DocType("Drive DocShare")
DriveRecent = frappe.qb.DocType("Drive Entity Log")
DriveUser = frappe.qb.DocType("User")
UserGroupMember = frappe.qb.DocType("User Group Member")
selectedFields = [
DriveEntity.name,
DriveEntity.title,
DriveUser.full_name,
DriveUser.user_image,
DriveEntity.owner,
DriveEntity.is_group,
DriveEntity.file_size,
DriveEntity.mime_type,
DriveEntity.allow_comments,
DriveEntity.allow_download,
DriveEntity.creation,
DriveEntity.document,
DriveFavourite.entity.as_("is_favourite"),
DriveDocShare.user_name,
DriveDocShare.read,
fn.Max(DriveDocShare.write).as_("write"),
DriveDocShare.share,
DriveDocShare.everyone,
DriveRecent.last_interaction.as_("modified"),
]
query = (
frappe.qb.from_(DriveRecent)
.left_join(DriveEntity)
.on(
(DriveRecent.entity_name == DriveEntity.name)
& (DriveRecent.user == frappe.session.user)
)
.left_join(DriveFavourite)
.on(
(DriveFavourite.entity == DriveEntity.name)
& (DriveFavourite.user == frappe.session.user)
)
.left_join(DriveDocShare)
.on((DriveDocShare.share_name == DriveEntity.name))
.left_join(UserGroupMember)
.on(
(
(UserGroupMember.parent == DriveDocShare.user_name)
& (UserGroupMember.user == frappe.session.user)
)
| (
(DriveDocShare.user_name == frappe.session.user)
| ((DriveDocShare.everyone == 1) | (DriveDocShare.public == 1))
)
)
.left_join(DriveUser)
.on((DriveEntity.owner == DriveUser.email))
.offset(offset)
.limit(limit)
.select(*selectedFields)
.where(
(DriveEntity.is_active == 1)
& ((DriveEntity.owner == frappe.session.user) | (DriveDocShare.read == 1))
)
.groupby(DriveEntity.name)
.orderby(DriveRecent.last_interaction, order=Order.desc)
)
return query.run(as_dict=True)
@frappe.whitelist()
def remove_recents(entity_names=None, clear_all=False):
"""
Clear recent DriveEntities for specified user
:param entity_names: List of document-names
:type entity_names: list[str]
:raises ValueError: If decoded entity_names is not a list
"""
if clear_all:
frappe.db.delete("Drive Entity Log", {"user": frappe.session.user})
return
if isinstance(entity_names, str):
entity_names = json.loads(entity_names)
if not isinstance(entity_names, list):
frappe.throw(f"Expected list but got {type(entity_names)}", ValueError)
for entity in entity_names:
existing_doc = frappe.db.exists(
{
"doctype": "Drive Entity Log",
"entity_name": entity,
"user": frappe.session.user,
}
)
if existing_doc:
frappe.delete_doc("Drive Entity Log", existing_doc)
@frappe.whitelist()
def get_children_count(drive_entity):
children_count = frappe.db.count(
"Drive Entity", {"parent_drive_entity": drive_entity, "is_active": 1}
)
return children_count
@frappe.whitelist()
def does_entity_exist(name=None, parent_entity=None):
result = frappe.db.exists(
"Drive Entity", {"parent_drive_entity": parent_entity, "title": name}
)
return bool(result)
def auto_delete_from_trash():
days_before = (date.today() - timedelta(days=30)).isoformat()
result = frappe.db.get_all(
"Drive Entity",
filters={"is_active": 0, "trashed_on": ["<", days_before]},
fields=["name"],
)
delete_entities(result)
@frappe.whitelist()
def toggle_allow_comments(entity_name, new_value):
"""
Toggle allow comments for entity without updating modified
"""
frappe.db.set_value(
"Drive Entity", entity_name, "allow_comments", new_value, update_modified=False
)
return
@frappe.whitelist()
def toggle_allow_download(entity_name, new_value):
"""
Toggle allow download for entity without updating modified
"""
frappe.db.set_value(
"Drive Entity", entity_name, "allow_download", new_value, update_modified=False
)
return
@frappe.whitelist()
def get_title(entity_name):
"""
Toggle allow download for entity
"""
if not frappe.has_permission(
doctype="Drive Entity", doc=entity_name, ptype="write", user=frappe.session.user
):
frappe.throw("Not permitted", frappe.PermissionError)
return frappe.db.get_value("Drive Entity", entity_name, "title")
@frappe.whitelist()
def move(entity_names, new_parent=None):
"""
Move file or folder to the new parent folder
:param new_parent: Document-name of the new parent folder. Defaults to the user directory
:raises NotADirectoryError: If the new_parent is not a folder, or does not exist
:raises FileExistsError: If a file or folder with the same name already exists in the specified parent folder
:return: DriveEntity doc once file is moved
"""
if isinstance(entity_names, str):
entity_names = json.loads(entity_names)
if not isinstance(entity_names, list):
frappe.throw(f"Expected list but got {type(entity_names)}", ValueError)
for entity in entity_names:
doc = frappe.get_doc("Drive Entity", entity)
new_parent = new_parent or get_user_directory(doc.owner).name
if new_parent == doc.parent_drive_entity:
return doc
is_group = frappe.db.get_value("Drive Entity", new_parent, "is_group")
if not is_group:
raise NotADirectoryError()
doc.move(new_parent)
doc.save()
return
@frappe.whitelist()
def search(query, home_dir):
"""
Placeholder search implementation
"""
text = frappe.db.escape(query + "*")
user = frappe.db.escape(frappe.session.user)
omit = frappe.db.escape(home_dir)
result = frappe.db.sql(
f"""
SELECT `tabDrive Entity`.name,
`tabDrive Entity`.title,
`tabDrive Entity`.owner,
`tabDrive Entity`.mime_type,
`tabDrive Entity`.is_group,
`tabDrive Entity`.document,
`tabDrive Entity`.color,
`tabUser`.user_image,
`tabUser`.full_name
FROM `tabDrive Entity`
LEFT JOIN `tabDrive DocShare`
ON `tabDrive DocShare`.`share_name` = `tabDrive Entity`.`name`
LEFT JOIN `tabUser Group Member`
ON `tabUser Group Member`.`parent` = `tabDrive DocShare`.`user_name`
LEFT JOIN `tabUser` ON `tabDrive Entity`.`owner` = `tabUser`.`email`
WHERE (`tabUser Group Member`.`user` = {user}
OR `tabDrive DocShare`.`user_name` = {user}
OR `tabDrive DocShare`.`everyone` = 1
OR `tabDrive Entity`.`owner` = {user})
AND `tabDrive Entity`.`is_active` = 1
AND MATCH(title) AGAINST ({text} IN BOOLEAN MODE)
AND NOT `tabDrive Entity`.`name` LIKE {omit}
GROUP BY `tabDrive Entity`.`name`
""",
as_dict=1,
)
return result
@frappe.whitelist()
def generate_upward_path(entity_name):
"""
Given an ID traverse upwards till the root node
Stops when parent_drive_entity IS NULL
"""
# CONCAT_WS('/', t.title, gp.path),
entity_name = frappe.db.escape(entity_name)
result = frappe.db.sql(
f"""
WITH RECURSIVE generated_path as (
SELECT
`tabDrive Entity`.title,
`tabDrive Entity`.name,
`tabDrive Entity`.parent_drive_entity,
`tabDrive Entity`.owner
FROM `tabDrive Entity`
WHERE `tabDrive Entity`.name = {entity_name}
UNION ALL
SELECT
t.title,
t.name,
t.parent_drive_entity,
t.owner
FROM generated_path as gp
JOIN `tabDrive Entity` as t ON t.name = gp.parent_drive_entity)
SELECT * FROM generated_path;
""",
as_dict=1,
)
return result[::-1]
@frappe.whitelist()
def get_ancestors_of(entity_name):
"""
Return all parent nodes till the root node
"""
# CONCAT_WS('/', t.title, gp.path),
entity_name = frappe.db.escape(entity_name)
result = frappe.db.sql(
f"""
WITH RECURSIVE generated_path as (
SELECT
`tabDrive Entity`.name,
`tabDrive Entity`.parent_drive_entity
FROM `tabDrive Entity`
WHERE `tabDrive Entity`.name = {entity_name}
UNION ALL
SELECT
t.name,
t.parent_drive_entity
FROM generated_path as gp
JOIN `tabDrive Entity` as t ON t.name = gp.parent_drive_entity)
SELECT name FROM generated_path;
""",
as_dict=0,
)
# Match the output of frappe/nested.py get_ancestors_of
flattened_list = [item for sublist in result for item in sublist]
flattened_list.pop(0)
return flattened_list
@frappe.whitelist(allow_guest=True)
def get_shared_breadcrumbs(share_name):
"""
given a node return the root. stops when share_parent IS NULL
given a node and parent travel till
the child of the parent_entity and append the parent_entity
"""
# CONCAT_WS('/', t.title, gp.path),
share_name = frappe.db.escape(share_name)
result = frappe.db.sql(
f"""
WITH RECURSIVE generated_path as (
SELECT
`tabDrive DocShare`.name,
`tabDrive DocShare`.share_name,
`tabDrive DocShare`.share_parent
FROM `tabDrive DocShare`
WHERE `tabDrive DocShare`.name = {share_name}
UNION ALL
SELECT
`tabDrive DocShare`.name,
`tabDrive DocShare`.share_name,
`tabDrive DocShare`.share_parent
FROM generated_path as gp
JOIN `tabDrive DocShare` ON `tabDrive DocShare`.name = gp.share_parent
)
SELECT * FROM generated_path;
""",
as_dict=1,
)
share_breadcrumbs = []
for i in result:
print(i)
share_breadcrumbs.append(
frappe.get_value(
"Drive Entity",
i.share_name,
["name", "title", "parent_drive_entity", "owner"],
as_dict=1,
)
)
return share_breadcrumbs[::-1]
|
2302_79757062/drive
|
drive/api/files.py
|
Python
|
agpl-3.0
| 48,462
|
def mime_to_human(mime_type, is_group):
"""
mimetype to human-readable formats
less descriptive by design, used for filtering
"""
mime_dict = {
# Image
"image/png": "Image",
"image/jpeg": "Image",
"image/svg+xml": "Image",
"image/heic": "Image",
"image/heif": "Image",
"image/avif": "Image",
"image/webp": "Image",
"image/tiff": "Image",
"image/gif": "Image",
# PDF
"application/pdf": "PDF",
# Text
"text/plain": "Text",
"text/html": "Text",
"text/css": "Text",
"text/javascript": "Text",
"application/javascript": "Text",
"text/rich-text": "Text",
"text/x-shellscript": "Text",
"text/markdown": "Text",
"application/json": "Text",
"application/xml": "XML Data",
"application/x-httpd-php": "Text",
"text/x-python": "Text",
"application/x-python-script": "Text",
"application/x-sql": "Text",
"text/x-perl": "Text",
"text/x-csrc": "Text",
"text/x-sh": "Text",
# Document
"application/msword": "Document",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "Document",
"application/vnd.oasis.opendocument.text": "Document",
"application/vnd.apple.pages": "Document",
"application/x-abiword": "Document",
"frappe_doc": "Document",
# Spreadsheet
"application/vnd.ms-excel": "Spreadsheet",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "Spreadsheet",
"application/vnd.oasis.opendocument.spreadsheet": "Spreadsheet",
"text/csv": "Spreadsheet",
"application/vnd.apple.numbers": "Spreadsheet",
# Presentation
"application/vnd.ms-powerpoint": "Presentation",
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "Presentation",
"application/vnd.oasis.opendocument.presentation": "Presentation",
"application/vnd.apple.keynote": "Presentation",
# Audio
"audio/mpeg": "Audio",
"audio/wav": "Audio",
"audio/x-midi": "Audio",
"audio/ogg": "Audio",
"audio/mp4": "Audio",
"audio/mp3": "Audio",
# Video
"video/mp4": "Video",
"video/webm": "Video",
"video/ogg": "Video",
"video/quicktime": "Video",
"video/x-matroska": "Video",
# Book
"application/epub+zip": "Book",
"application/x-mobipocket-ebook": "Book",
# Application
"application/octet-stream": "Application",
"application/x-sh": "Application",
"application/vnd.microsoft.portable-executable": "Application",
# Archive
"application/zip": "Archive",
"application/x-rar-compressed": "Archive",
"application/x-tar": "Archive",
"application/gzip": "Archive",
"application/x-bzip2": "Archive",
}
if is_group:
return "Folder"
else:
mime_type_lower = mime_type.lower()
return mime_dict.get(mime_type_lower, "Unknown")
|
2302_79757062/drive
|
drive/api/format.py
|
Python
|
agpl-3.0
| 3,168
|
import frappe
import json
from drive.utils.files import get_user_directory
from pypika import Order, Criterion, Case, functions as fn
DriveUser = frappe.qb.DocType("User")
UserGroupMember = frappe.qb.DocType("User Group Member")
DriveEntity = frappe.qb.DocType("Drive Entity")
DriveFavourite = frappe.qb.DocType("Drive Favourite")
DriveDocShare = frappe.qb.DocType("Drive DocShare")
DriveRecent = frappe.qb.DocType("Drive Entity Log")
parent_folder = None
query = None
def validate_parent(entity_name):
entity_name, is_group, is_active = frappe.db.get_value(
"Drive Entity", entity_name, ["name", "is_group", "is_active"]
)
if not is_group:
frappe.throw("Specified entity is not a folder", NotADirectoryError)
if not is_active:
frappe.throw("Specified folder has been trashed by the owner")
return
def eval_general_access(entity_name):
is_public = False
if frappe.db.exists(
{
"doctype": "Drive DocShare",
"share_doctype": "Drive Entity",
"share_name": entity_name,
"public": 1,
}
):
is_public = True
return "public" if is_public else "everyone"
@frappe.whitelist(allow_guest=True)
def files(
entity_name=None,
order_by="modified",
is_active=1,
limit=100,
offset=0,
folders_first=True,
favourites_only=False,
recents_only=False,
file_kind_list=[],
mime_type_list=[],
):
selectedFields = [
DriveEntity.name,
DriveEntity.title,
DriveEntity.is_group,
DriveEntity.owner,
DriveUser.full_name,
DriveUser.user_image,
DriveEntity.modified,
DriveEntity.creation,
DriveEntity.file_size,
DriveEntity.file_kind,
DriveEntity.file_ext,
DriveEntity.color,
DriveEntity.document,
DriveEntity.mime_type,
DriveEntity.parent_drive_entity,
DriveEntity.allow_download,
DriveEntity.is_active,
DriveEntity.allow_comments,
DriveDocShare.read,
DriveDocShare.user_name,
DriveDocShare.user_doctype,
DriveDocShare.write,
DriveDocShare.public,
DriveDocShare.everyone,
DriveDocShare.share,
DriveFavourite.entity.as_("is_favourite"),
]
favourites_only = json.loads(favourites_only)
recents_only = json.loads(recents_only)
if isinstance(folders_first, str):
try:
folders_first = json.loads(folders_first)
except json.JSONDecodeError:
frappe.log_error(
"Invalid JSON for folders_first: {}".format(folders_first), "JSONDecodeError"
)
folders_first = True
folders_first = bool(folders_first)
general_access = eval_general_access(entity_name)
if mime_type_list and not entity_name:
entity_name = get_user_directory(frappe.session.user).name
if recents_only:
selectedFields.append(DriveRecent.last_interaction.as_("modified"))
query = (
frappe.qb.from_(DriveEntity)
.left_join(DriveDocShare)
.on((DriveDocShare.share_name == DriveEntity.name))
.left_join(UserGroupMember)
.on((UserGroupMember.parent == DriveDocShare.user_name))
.left_join(DriveUser)
.on((DriveEntity.owner == DriveUser.email))
.offset(offset)
.limit(limit)
.select(*selectedFields)
)
if entity_name:
query = query.where(DriveEntity.parent_drive_entity == entity_name)
query = query.where(
(DriveEntity.is_active == is_active)
& (
(UserGroupMember.user == frappe.session.user)
| (
(DriveDocShare.user_name == frappe.session.user)
| (DriveDocShare[general_access] == 1)
| (DriveEntity.owner == frappe.session.user)
)
)
)
if folders_first:
query = query.orderby(
Case().when(DriveEntity.is_group == True, 1).else_(2),
Order.desc,
)
if favourites_only:
query = query.right_join(DriveFavourite).on(
(DriveFavourite.entity == DriveEntity.name)
& (DriveFavourite.user == frappe.session.user)
)
else:
query = query.left_join(DriveFavourite).on(
(DriveFavourite.entity == DriveEntity.name)
& (DriveFavourite.user == frappe.session.user)
)
if recents_only:
query = (
query.right_join(DriveRecent)
.on(
(DriveRecent.entity_name == DriveEntity.name)
& (DriveRecent.user == frappe.session.user)
)
.orderby(DriveRecent.last_interaction, order=Order.desc)
)
else:
query = query.orderby(
order_by.split()[0],
order=Order.desc if order_by.endswith("desc") else Order.asc,
)
if file_kind_list:
file_kind_list = json.loads(file_kind_list)
file_kind_criterion = [DriveEntity.file_kind == file_kind for file_kind in file_kind_list]
query = query.where(Criterion.any(file_kind_criterion))
if mime_type_list:
mime_type_list = json.loads(mime_type_list)
mime_type_criterion = [DriveEntity.mime_type == mime_type for mime_type in mime_type_list]
query = query.where((Criterion.any(mime_type_criterion)) | (DriveEntity.is_group == True))
query = query.groupby(DriveEntity.name)
result = query.run(as_dict=True)
return result
@frappe.whitelist()
def shared_with_user(
order_by="modified",
limit=100,
offset=0,
folders_first=True,
file_kind_list=[],
mime_type_list=[],
):
"""
Returns the highest level of shared items shared with/by the current user, group or org
:param entity_name: Document-name of the folder whose contents are to be listed.
:raises NotADirectoryError: If this DriveEntity doc is not a folder
:return: List of DriveEntities with permissions
:rtype: list[frappe._dict]
"""
if isinstance(folders_first, str):
try:
folders_first = json.loads(folders_first)
except json.JSONDecodeError:
frappe.log_error(
"Invalid JSON for folders_first: {}".format(folders_first), "JSONDecodeError"
)
folders_first = True
folders_first = bool(folders_first)
DriveDocShare = frappe.qb.DocType("Drive DocShare")
DriveEntity = frappe.qb.DocType("Drive Entity")
DriveFavourite = frappe.qb.DocType("Drive Favourite")
UserGroupMember = frappe.qb.DocType("User Group Member")
DriveUser = frappe.qb.DocType("User")
selectedFields = [
DriveEntity.name,
DriveEntity.title,
DriveEntity.is_group,
DriveEntity.owner,
DriveUser.full_name,
DriveUser.user_image,
DriveEntity.modified,
DriveEntity.creation,
DriveEntity.file_size,
DriveEntity.file_kind,
DriveEntity.file_ext,
DriveEntity.color,
DriveEntity.document,
DriveEntity.mime_type,
DriveEntity.parent_drive_entity,
DriveEntity.allow_download,
DriveEntity.is_active,
DriveEntity.allow_comments,
DriveDocShare.user_name,
DriveDocShare.user_doctype,
DriveDocShare.read,
DriveDocShare.write,
DriveDocShare.everyone,
DriveDocShare.share,
DriveDocShare.share_parent,
DriveFavourite.entity.as_("is_favourite"),
]
query = (
frappe.qb.from_(DriveEntity)
.inner_join(DriveDocShare)
.on((DriveDocShare.share_name == DriveEntity.name))
.left_join(UserGroupMember)
.on((UserGroupMember.parent == DriveDocShare.user_name))
.left_join(DriveFavourite)
.on(
(DriveFavourite.entity == DriveEntity.name)
& (DriveFavourite.user == frappe.session.user)
)
.left_join(DriveUser)
.on((DriveEntity.owner == DriveUser.email))
.offset(offset)
.limit(limit)
.select(*selectedFields)
.where(DriveEntity.is_active == 1)
.where(
(UserGroupMember.user == frappe.session.user)
| (DriveDocShare.user_name == frappe.session.user)
| (DriveDocShare.everyone == 1)
)
.where(DriveDocShare.share_parent.isnull())
.where(DriveEntity.owner != frappe.session.user)
.groupby(DriveEntity.name)
)
if folders_first:
query = query.orderby(
Case().when(DriveEntity.is_group == True, 1).else_(2),
Order.desc,
)
query = query.orderby(
order_by.split()[0],
order=Order.desc if order_by.endswith("desc") else Order.asc,
)
if file_kind_list:
file_kind_list = json.loads(file_kind_list)
file_kind_criterion = [DriveEntity.file_kind == file_kind for file_kind in file_kind_list]
query = query.where(Criterion.any(file_kind_criterion))
if mime_type_list:
mime_type_list = json.loads(mime_type_list)
mime_type_criterion = [DriveEntity.mime_type == mime_type for mime_type in mime_type_list]
query = query.where((Criterion.any(mime_type_criterion)) | (DriveEntity.is_group == True))
return query.run(as_dict=True)
@frappe.whitelist()
def shared_by_user(
order_by="modified",
limit=100,
offset=0,
folders_first=True,
file_kind_list=[],
mime_type_list=[],
):
"""
Return the list of files and folders shared with the current user
:param entity_name: Document-name of the folder whose contents are to be listed.
:raises NotADirectoryError: If this DriveEntity doc is not a folder
:return: List of DriveEntities with permissions
:rtype: list[frappe._dict]
"""
if isinstance(folders_first, str):
try:
folders_first = json.loads(folders_first)
except json.JSONDecodeError:
frappe.log_error(
"Invalid JSON for folders_first: {}".format(folders_first), "JSONDecodeError"
)
folders_first = True
folders_first = bool(folders_first)
DriveDocShare = frappe.qb.DocType("Drive DocShare")
DriveEntity = frappe.qb.DocType("Drive Entity")
DriveFavourite = frappe.qb.DocType("Drive Favourite")
DriveUser = frappe.qb.DocType("User")
selectedFields = [
DriveEntity.name,
DriveEntity.title,
DriveEntity.is_group,
DriveEntity.owner,
DriveUser.full_name,
DriveUser.user_image,
DriveEntity.modified,
DriveEntity.creation,
DriveEntity.file_size,
DriveEntity.file_kind,
DriveEntity.file_ext,
DriveEntity.color,
DriveEntity.document,
DriveEntity.mime_type,
DriveEntity.parent_drive_entity,
DriveEntity.allow_download,
DriveEntity.is_active,
DriveEntity.allow_comments,
DriveDocShare.read,
DriveDocShare.write,
DriveDocShare.everyone,
DriveDocShare.share,
DriveDocShare.owner_parent,
DriveFavourite.entity.as_("is_favourite"),
]
query = (
frappe.qb.from_(DriveEntity)
.left_join(DriveDocShare)
.on(
(DriveDocShare.share_name == DriveEntity.name)
& (DriveEntity.owner == frappe.session.user)
)
.left_join(DriveUser)
.on((DriveEntity.owner == DriveUser.email))
.left_join(DriveFavourite)
.on(
(DriveFavourite.entity == DriveEntity.name)
& (DriveFavourite.user == frappe.session.user)
)
.offset(offset)
.limit(limit)
.select(*selectedFields)
.where(DriveEntity.is_active == 1)
.where(
(DriveDocShare.user_name != frappe.session.user)
| (DriveDocShare.everyone == 1)
| (DriveDocShare.public == 1)
)
.where(DriveDocShare.owner_parent.isnull())
.groupby(DriveEntity.name)
)
if folders_first:
query = query.orderby(
Case().when(DriveEntity.is_group == True, 1).else_(2),
Order.desc,
)
query = query.orderby(
order_by.split()[0],
order=Order.desc if order_by.endswith("desc") else Order.asc,
)
if file_kind_list:
file_kind_list = json.loads(file_kind_list)
file_kind_criterion = [DriveEntity.file_kind == file_kind for file_kind in file_kind_list]
query = query.where(Criterion.any(file_kind_criterion))
if mime_type_list:
mime_type_list = json.loads(mime_type_list)
mime_type_criterion = [DriveEntity.mime_type == mime_type for mime_type in mime_type_list]
query = query.where((Criterion.any(mime_type_criterion)) | (DriveEntity.is_group == True))
return query.run(as_dict=True)
|
2302_79757062/drive
|
drive/api/list.py
|
Python
|
agpl-3.0
| 12,862
|
import frappe
import json
from pypika import Order
@frappe.whitelist()
def get_notifications(only_unread):
"""
Get notifications for current user
:param only_unread: only get notifications where read is False
"""
User = frappe.qb.DocType("User")
Notification = frappe.qb.DocType("Drive Notification")
fields = [
Notification.name,
Notification.to_user,
Notification.from_user,
Notification.read,
Notification.type,
Notification.message,
Notification.entity_type,
Notification.notif_doctype,
Notification.notif_doctype_name,
Notification.creation,
User.user_image,
User.full_name,
]
query = (
frappe.qb.from_(Notification)
.inner_join(User)
.on(Notification.from_user == User.name)
.select(*fields)
.orderby(Notification.creation, order=Order.desc)
)
if only_unread:
query = query.where(Notification.read == 0)
query = query.where(Notification.to_user == frappe.session.user)
result = query.run(as_dict=True)
return result
@frappe.whitelist()
def get_unread_count():
"""
Return a count of records where user is current user and read is False
"""
return frappe.db.count(
"Drive Notification", filters={"to_user": frappe.session.user, "read": 0}
)
@frappe.whitelist()
def mark_as_read(name=None, all=False):
"""
Mark notification for current user as read
:param name: ID of notification record
:param all: Will mark all unread notifications as read
"""
if all:
frappe.db.set_value(
"Drive Notification", {"to_user": frappe.session.user, "read": False}, "read", True
)
return
frappe.db.set_value("Drive Notification", name, "read", True)
return
def notify_mentions(entity_name, document_name):
"""
Create a mention notification for each user mentioned
:param entity_name: ID of entity
:param document_name: ID of document containing mentions
"""
entity = frappe.get_doc("Drive Entity", entity_name)
document = frappe.get_doc("Drive Document", document_name)
if not document.mentions:
return
mentions = json.loads(document.mentions)
for mention in mentions:
if mention["type"] == "User":
author_full_name = frappe.db.get_value(
"User", {"name": mention["author"]}, ["full_name"]
)
message = f' {author_full_name} mentioned you in document "{entity.title}"'
create_notification(mention["author"], mention["id"], "Mention", entity, message)
if mention["type"] == "User Group":
group_users = frappe.get_all(
"User Group Member", filters={"parent": mention["id"]}, fields="user"
)
message = (
f' {author_full_name} mentioned {mention["id"]} group in document "{entity.title}"'
)
for user in group_users:
if user.user == frappe.session.user:
continue
create_notification(mention["author"], user.user, "Mention", entity, message)
def notify_share(entity_name, docshare_name):
"""
Create a share notification for each user
:param entity_name: ID of entity
:param document_name: ID of docshare containing share info
"""
entity = frappe.get_doc("Drive Entity", entity_name)
docshare = frappe.get_doc("Drive DocShare", docshare_name)
author_full_name = frappe.db.get_value("User", {"name": docshare.owner}, ["full_name"])
entity_type = "document" if entity.document else "folder" if entity.is_group else "file"
message = f'{author_full_name} shared {entity_type} "{entity.title}" with you'
if docshare.user_doctype == "User":
create_notification(docshare.owner, docshare.user_name, "Share", entity, message)
if docshare.user_doctype == "User Group":
group_users = frappe.get_all(
"User Group Member", filters={"parent": docshare.user_name}, fields="user"
)
for user in group_users:
if user.user == frappe.session.user:
continue
create_notification(docshare.owner, user.user, "Share", entity, message)
if docshare.everyone:
drive_users = frappe.get_all(
doctype="User",
order_by="full_name",
filters=[
["Has Role", "role", "=", "Drive User"],
["full_name", "not like", "Administrator"],
["full_name", "not like", "Guest"],
],
fields=[
"email",
],
)
for user in drive_users:
if user.email == frappe.session.user:
continue
create_notification(docshare.owner, user.email, "Share", entity, message)
return
def create_notification(from_user, to_user, type, entity, message=None):
"""
Create a notification
:param from_user: notification owner user email
:param to_user: notification receiver user email
:param type: subject of notification
:param entity: drive_entity name
:param message: notification message
"""
from drive.api.permissions import get_user_access
user_access = get_user_access(entity.name, to_user)
if user_access.get("read") == 0:
return
entity_type = "Document" if entity.document else "Folder" if entity.is_group else "File"
notif = frappe.get_doc(
{
"doctype": "Drive Notification",
"from_user": from_user,
"to_user": to_user,
"type": type,
"entity_type": entity_type,
"notif_doctype": "Drive Entity",
"notif_doctype_name": entity.name,
"message": message,
}
)
try:
notif.insert()
except frappe.exceptions.ValidationError as e:
print(f"Error inserting document: {e}")
|
2302_79757062/drive
|
drive/api/notifications.py
|
Python
|
agpl-3.0
| 6,008
|
import frappe
from pypika import Order, Case, functions as fn
from drive.api.files import get_entity
from drive.api.files import get_doc_content
from drive.utils.files import get_user_directory
from drive.utils.user_group import get_entity_shared_with_user_groups
from drive.utils.users import mark_as_viewed
from drive.api.files import get_children_count
from drive.api.files import generate_upward_path
from drive.api.files import get_shared_breadcrumbs
from drive.api.files import get_ancestors_of
from frappe.utils import getdate
@frappe.whitelist()
def get_shared_with_list(entity_name):
"""
Return the list of users with whom this file or folder has been shared
:param entity_name: Document-name of this file or folder
:raises PermissionError: If the user does not have edit permissions
:return: List of users, with permissions and last modified datetime
:rtype: list[frappe._dict]
"""
if not frappe.has_permission(
doctype="Drive Entity", doc=entity_name, ptype="write", user=frappe.session.user
):
raise frappe.PermissionError
entity_owner = frappe.db.get_value("Drive Entity", entity_name, "owner")
users = frappe.db.get_all(
"Drive DocShare",
filters={
"share_doctype": "Drive Entity",
"share_name": entity_name,
"user_doctype": "User",
"user_name": ["not in", [frappe.session.user, entity_owner]],
"everyone": 0,
"public": 0,
"protected": 0,
},
order_by="name",
fields=["user_name", "read", "write", "share"],
)
entity_owner_info = frappe.db.get_value(
"User", entity_owner, ["user_image", "full_name", "email"], as_dict=True
)
for user in users:
user_info = frappe.db.get_value(
"User", user.user_name, ["user_image", "full_name"], as_dict=True
)
user.update(user_info)
return {"owner": entity_owner_info, "users": users}
@frappe.whitelist()
def get_shared_user_group_list(entity_name):
user_group_list = frappe.db.get_list(
"Drive DocShare",
filters={
"share_doctype": "Drive Entity",
"user_doctype": "User Group",
"share_name": ["like", f"%{entity_name}%"],
},
fields=["user_name", "user_doctype", "read", "write"],
)
return user_group_list
@frappe.whitelist()
def get_shared_by_me(get_all=False, order_by="modified", is_active=1, limit=100, offset=0):
"""
Return the list of files and folders shared with the current user
:param entity_name: Document-name of the folder whose contents are to be listed.
:raises NotADirectoryError: If this DriveEntity doc is not a folder
:return: List of DriveEntities with permissions
:rtype: list[frappe._dict]
"""
DriveDocShare = frappe.qb.DocType("Drive DocShare")
DriveEntity = frappe.qb.DocType("Drive Entity")
DriveFavourite = frappe.qb.DocType("Drive Favourite")
DriveUser = frappe.qb.DocType("User")
selectedFields = [
DriveEntity.name,
DriveEntity.title,
DriveEntity.is_group,
DriveUser.full_name,
DriveUser.user_image,
DriveEntity.owner,
DriveEntity.modified,
DriveEntity.creation,
DriveEntity.file_size,
DriveEntity.mime_type,
DriveEntity.parent_drive_entity,
DriveEntity.allow_comments,
DriveEntity.color,
DriveEntity.document,
DriveEntity.allow_download,
DriveDocShare.read,
DriveDocShare.write,
DriveDocShare.everyone,
DriveDocShare.share,
DriveDocShare.owner_parent,
DriveFavourite.entity.as_("is_favourite"),
]
query = (
frappe.qb.from_(DriveEntity)
.left_join(DriveDocShare)
.on(
(DriveDocShare.share_name == DriveEntity.name)
& (DriveEntity.owner == frappe.session.user)
)
.left_join(DriveUser)
.on((DriveEntity.owner == DriveUser.email))
.left_join(DriveFavourite)
.on(
(DriveFavourite.entity == DriveEntity.name)
& (DriveFavourite.user == frappe.session.user)
)
.offset(offset)
.limit(limit)
.select(*selectedFields)
.where(
(DriveEntity.is_active == 1)
& (
(DriveDocShare.user_name != frappe.session.user)
| (DriveDocShare.everyone == 1)
| (DriveDocShare.public == 1)
)
& (DriveDocShare.owner_parent.isnull())
)
.groupby(DriveEntity.name)
.orderby(
Case().when(DriveEntity.is_group == True, 1).else_(2),
Order.desc,
)
.orderby(
order_by.split()[0],
order=Order.desc if order_by.endswith("desc") else Order.asc,
)
)
if get_all:
return query.run(as_dict=True)
return query.run(as_dict=True)
@frappe.whitelist()
def get_shared_with_me(get_all=False, order_by="modified", is_active=1, limit=100, offset=0):
"""
Return the list of files and folders shared with the current user
:param entity_name: Document-name of the folder whose contents are to be listed.
:raises NotADirectoryError: If this DriveEntity doc is not a folder
:return: List of DriveEntities with permissions
:rtype: list[frappe._dict]
"""
DocShare = frappe.qb.DocType("Drive DocShare")
DriveEntity = frappe.qb.DocType("Drive Entity")
DriveFavourite = frappe.qb.DocType("Drive Favourite")
UserGroupMember = frappe.qb.DocType("User Group Member")
DriveUser = frappe.qb.DocType("User")
selectedFields = [
DriveEntity.name,
DriveEntity.title,
DriveEntity.is_group,
DriveEntity.owner,
DriveUser.full_name,
DriveUser.user_image,
DriveEntity.modified,
DriveEntity.creation,
DriveEntity.file_size,
DriveEntity.mime_type,
DriveEntity.parent_drive_entity,
DriveEntity.allow_comments,
DriveEntity.color,
DriveEntity.document,
DriveEntity.allow_download,
DocShare.read,
fn.Max(DocShare.write).as_("write"),
DocShare.everyone,
DocShare.share,
DocShare.share_parent,
DriveFavourite.entity.as_("is_favourite"),
]
query = (
frappe.qb.from_(DriveEntity)
.inner_join(DocShare)
.on((DocShare.share_name == DriveEntity.name))
.left_join(UserGroupMember)
.on((UserGroupMember.parent == DocShare.user_name))
.left_join(DriveFavourite)
.on(
(DriveFavourite.entity == DriveEntity.name)
& (DriveFavourite.user == frappe.session.user)
)
.left_join(DriveUser)
.on((DriveEntity.owner == DriveUser.email))
.offset(offset)
.limit(limit)
.select(*selectedFields)
.where(
(DriveEntity.is_active == 1)
& (
(UserGroupMember.user == frappe.session.user)
| ((DocShare.user_name == frappe.session.user) | (DocShare.everyone == 1))
)
& (DocShare.share_parent.isnull())
& (DriveEntity.owner != frappe.session.user)
)
.groupby(DriveEntity.name)
.orderby(
Case().when(DriveEntity.is_group == True, 1).else_(2),
Order.desc,
)
.orderby(
order_by.split()[0],
order=Order.desc if order_by.endswith("desc") else Order.asc,
)
)
if get_all:
return query.run(as_dict=True)
return query.run(as_dict=True)
@frappe.whitelist()
def get_all_my_entities(fields=None):
"""
Return file data with permissions
:return: DriveEntity with permissions
:rtype: frappe._dict
"""
fields = fields or [
"name",
"title",
"is_group",
"owner",
"modified",
"file_size",
"mime_type",
]
my_entities = frappe.db.get_list(
"Drive Entity",
filters={
"is_active": 1,
"owner": frappe.session.user,
"name": ["!=", get_user_directory().name],
},
fields=fields,
)
shared_entities = get_shared_with_me(get_all=True)
all_entities = shared_entities + my_entities
return list({x["name"]: x for x in all_entities}.values())
@frappe.whitelist(allow_guest=True)
def get_entity_with_permissions(entity_name):
"""
Return file data with permissions
:param entity_name: Name of file document.
:raises IsADirectoryError: If this DriveEntity doc is not a file
:return: DriveEntity with permissions
:rtype: frappe._dict
"""
fields = [
"name",
"title",
"owner",
"is_group",
"is_active",
"modified",
"creation",
"file_size",
"mime_type",
"file_ext",
"allow_comments",
"allow_download",
"document",
"color",
"parent_drive_entity",
"file_kind",
]
if not get_general_access(entity_name):
if not frappe.has_permission(
doctype="Drive Entity", doc=entity_name, ptype="read", user=frappe.session.user
):
frappe.throw("Not permitted", frappe.PermissionError)
entity = get_entity(entity_name, fields)
validate_parent_folder(entity)
if not entity.is_active:
frappe.throw("Specified file has been trashed by the owner")
if entity.owner == frappe.session.user:
valid_until = frappe.db.get_value(
"Drive DocShare",
{"share_name": entity_name},
["valid_until"],
as_dict=0,
)
user_access = {"read": 1, "write": 1, "share": 1, "valid_until": valid_until}
else:
user_access = get_user_access(entity.name)
if user_access.get("read") == 0:
frappe.throw("Unauthorized", frappe.PermissionError)
owner_info = frappe.db.get_value("User", entity.owner, ["user_image", "full_name"], as_dict=True)
breadcrumbs = {"breadcrumbs": get_valid_breadcrumbs(entity, user_access)}
favourite = frappe.db.get_value(
"Drive Favourite",
{
"entity": entity_name,
"user": frappe.session.user,
},
["entity as is_favourite"]
)
mark_as_viewed(entity)
return_obj = entity | user_access | owner_info | breadcrumbs | {"is_favourite": favourite}
if entity.document:
entity_doc_content = get_doc_content(entity.document)
return_obj = return_obj | entity_doc_content
return return_obj
def validate_parent_folder(entity):
"""
Validate if the parent folder exists and is active.
"""
ancestors = get_ancestors_of(entity.name)
for ancestor_name in ancestors:
if frappe.db.exists("Drive Entity", {"name": ancestor_name, "is_active": 0}):
raise IsADirectoryError(f"Parent Folder {ancestor_name} has been deleted")
def get_valid_breadcrumbs(entity, user_access):
"""
Determine user access and generate upward path (breadcrumbs).
"""
file_path = generate_upward_path(entity.name)
if entity.owner != file_path[0].owner:
file_path.pop(0)
if entity.owner != frappe.session.user:
permission_path = get_shared_breadcrumbs(user_access.docshare_name)
x = file_path[: -len(permission_path)]
for i in reversed(x):
if i.owner == frappe.session.user:
permission_path.insert(0, i)
file_path = permission_path
return file_path
@frappe.whitelist()
def get_general_access(entity_name):
"""
Return the general access permissions for the given entity
:param entity_name: Document-name of the entity whose permissions are to be fetched
:return: Dict of general access permissions (read, write)
:rtype: frappe._dict or None
"""
DriveDocShare = frappe.qb.DocType("Drive DocShare")
fields = [
DriveDocShare.name,
DriveDocShare.read,
DriveDocShare.write,
DriveDocShare.share,
DriveDocShare.everyone,
DriveDocShare.public,
]
query = (
frappe.qb.from_(DriveDocShare)
.select(*fields)
.where(
(DriveDocShare.share_name == entity_name)
& ((DriveDocShare.everyone == True) | (DriveDocShare.public == True))
)
.groupby(DriveDocShare.name)
)
return query.run(as_dict=True)
def get_user_access(entity_name, user=None):
"""
Return the user specific access permissions for an entity if it exists or general access permissions
:param entity_name: Document-name of the entity whose permissions are to be fetched
:return: Dict of general access permissions (read, write)
:rtype: frappe._dict or None
"""
fields = ["read", "write", "share", "name as docshare_name", "valid_until"]
if not user:
user = frappe.session.user
if frappe.session.user != "Guest":
user_access = frappe.db.get_value(
"Drive DocShare",
{
"share_doctype": "Drive Entity",
"share_name": entity_name,
"user_doctype": "User",
"user_name": user,
},
fields,
as_dict=1,
)
if user_access:
return user_access
group_access = user_group_entity_access(entity_name, user)
if group_access:
return group_access
everyone_access = frappe.db.get_value(
"Drive DocShare",
{"share_name": entity_name, "everyone": 1},
fields,
as_dict=1,
)
if everyone_access:
return everyone_access
public_access = frappe.db.get_value(
"Drive DocShare",
{"share_name": entity_name, "public": 1},
fields,
as_dict=1,
)
if public_access:
return public_access
else:
public_access = frappe.db.get_value(
"Drive DocShare",
{"share_name": entity_name, "public": 1},
fields,
as_dict=1,
)
if public_access:
return public_access
return {"read": 0, "write": 0}
def user_group_entity_access(entity_name=None, user=None):
"""
Get user group access level for current user and current entity
:param entity_name: Document-name of the folder whose contents are to be listed. Defaults to the user directory
:param order_by: Sort the list of results according to the specified field (eg: 'modified desc'). Defaults to 'title'
:raises NotADirectoryError: If this DriveEntity doc is not a folder
:raises PermissionError: If the user does not have access to the specified folder
:return: List of DriveEntity records
:rtype: list
"""
if not user:
user = frappe.session.user
DriveDocShare = frappe.qb.DocType("Drive DocShare")
UserGroup = frappe.qb.DocType("User Group")
UserGroupMember = frappe.qb.DocType("User Group Member")
selectedFields = [
DriveDocShare.user_name,
DriveDocShare.read,
DriveDocShare.write,
DriveDocShare.share,
DriveDocShare.name.as_("docshare_name"),
]
query = (
frappe.qb.from_(DriveDocShare)
.join(UserGroupMember)
.on((UserGroupMember.parent == DriveDocShare.user_name))
.select(*selectedFields)
.where((DriveDocShare.share_name == entity_name) & (UserGroupMember.user == user))
.groupby(UserGroupMember.name)
)
result = query.run(as_dict=True)
if not result:
return False
return max(result, key=lambda x: x["write"])
def has_app_permission():
user = frappe.session.user
if user == "Administrator":
return True
roles_to_check = {"Drive Admin", "Drive User", "System Manager"}
user_roles = frappe.get_roles(user)
return not roles_to_check.isdisjoint(user_roles)
@frappe.whitelist()
def update_document_invalidation(entity_name, invalidation_date):
x = frappe.get_list(
"Drive DocShare",
filters={"share_name": entity_name, "share_doctype": "Drive Entity"},
order_by="creation desc",
fields=["name", "valid_until", "share_parent"],
)
for i in x:
doc = frappe.get_doc("Drive DocShare", i.name)
doc.valid_until = invalidation_date
doc.save()
@frappe.whitelist()
def update_document_invalidation(entity_name, invalidation_date):
x = frappe.get_list(
"Drive DocShare",
filters={"share_name": entity_name, "share_doctype": "Drive Entity"},
order_by="creation desc",
fields=["name", "valid_until", "share_parent"],
)
for i in x:
doc = frappe.get_doc("Drive DocShare", i.name)
doc.valid_until = invalidation_date
doc.save()
def batch_delete_docshares(docshares):
for document in docshares:
frappe.delete_doc("Drive DocShare", document.name)
def auto_delete_expired_docshares():
current_date = getdate()
expired_documents = frappe.get_list(
"Drive DocShare",
filters=[
["valid_until", "<", current_date],
["valid_until", "is", "set"],
["protected", "!=", 1],
],
order_by="creation desc",
fields=["name", "valid_until"],
)
if expired_documents:
frappe.enqueue(batch_delete_docshares, docshares=expired_documents)
return
|
2302_79757062/drive
|
drive/api/permissions.py
|
Python
|
agpl-3.0
| 17,633
|
import frappe
from pathlib import Path
from pypika import functions as fn
import os
import json
@frappe.whitelist()
def get_max_storage():
"""
Retrieves the maximum storage limit for the user's plan.
The storage limit is returned in bytes, with a block size of 1024.
Returns:
int: The maximum storage limit in bytes.
"""
plan_limit = frappe.conf.get("plan_limit")
if plan_limit:
limit = plan_limit["max_storage_usage"]
limit = int(limit)
return int(limit * 1024**2)
max_storage = frappe.conf.get("max_storage")
if not max_storage:
add_new_site_config_key("max_storage", 5120)
max_storage = frappe.conf.get("max_storage")
max_storage = int(max_storage)
return int(max_storage * 1024**2)
@frappe.whitelist()
def total_storage_used():
DriveEntity = frappe.qb.DocType("Drive Entity")
query = frappe.qb.from_(DriveEntity).select(fn.Sum(DriveEntity.file_size).as_("total_size"))
result = query.run(as_dict=True)
return result
@frappe.whitelist()
def total_storage_used_by_file_kind():
DriveEntity = frappe.qb.DocType("Drive Entity")
query = (
frappe.qb.from_(DriveEntity)
.select(DriveEntity.file_kind, fn.Sum(DriveEntity.file_size).as_("total_size"))
.where(DriveEntity.is_group == 0)
.groupby(DriveEntity.file_kind)
)
return query.run(as_dict=True)
def get_storage_allowed():
limit = get_max_storage()
usage = total_storage_used()
usage = usage[0].total_size or 0
return limit - usage
def total_disk_storage_used():
try:
from drive.utils.files import get_user_directory
user_directory = get_user_directory()
# -sb doesnt work on macos
cmd = f"du -sb {Path(user_directory.path)} | cut -f1"
result = os.popen(cmd)
size = result.read().strip()
except:
size = "0M"
return size
def add_new_site_config_key(key, val):
site_path = frappe.get_site_path()
site_config_path = os.path.join(site_path, "site_config.json")
with open(site_config_path, "r") as f:
site_config = json.load(f)
site_config[str(key)] = str(val)
with open(site_config_path, "w") as f:
json.dump(site_config, f, indent=2)
|
2302_79757062/drive
|
drive/api/storage.py
|
Python
|
agpl-3.0
| 2,270
|
import frappe
@frappe.whitelist()
def create_tag(title, color="gray"):
"""
Create new tag for entity
:param title: Tag name
:param color: Tag color
"""
title_lower = title.lower()
doc = frappe.get_doc(
{
"doctype": "Drive Tag",
"title": title_lower,
"color": color,
}
)
tag_exists = frappe.db.exists(
{"doctype": "Drive Tag", "owner": frappe.session.user, "title": title_lower}
)
if tag_exists:
frappe.throw("Tag already exists")
doc.save()
return doc.name
@frappe.whitelist()
def add_tag(entity, tag):
"""
Add tag to entity
:param entity: Entity name
:param tag: Tag name
"""
doc = frappe.get_doc("Drive Entity", entity)
doc.append("tags", {"tag": tag})
doc.save()
@frappe.whitelist()
def get_entity_tags(entity):
"""
Returns all tags of given entity
:param entity: Entity name
"""
entity = frappe.get_doc("Drive Entity", entity)
return map(
lambda x: frappe.db.get_value("Drive Tag", x.tag, ["name", "title", "color"], as_dict=1),
entity.tags,
)
@frappe.whitelist()
def get_user_tags():
"""
Returns all tags created by current user
"""
return frappe.db.get_list(
"Drive Tag",
filters={"owner": frappe.session.user},
fields=["name", "title", "color"],
)
@frappe.whitelist()
def update_tag_color(tag, color):
"""
Update color for givent tag
:param tag: Tag name
:param color: Color to be update with
"""
doc = frappe.get_doc("Drive Tag", tag)
doc.color = color
doc.save()
@frappe.whitelist()
def remove_tag(entity, tag):
"""
Remove tag from entity
:param entity: Entity name
:param tag: Tag name
"""
entity_doc = frappe.get_doc("Drive Entity", entity)
for tag_doc in entity_doc.tags:
if tag_doc.tag == tag and tag_doc.owner == frappe.session.user:
tag_doc.delete(ignore_permissions=True)
@frappe.whitelist()
def delete_tag(tag):
"""
Delete tag
:param tag: Tag name
"""
frappe.delete_doc("Drive Tag", tag)
|
2302_79757062/drive
|
drive/api/tags.py
|
Python
|
agpl-3.0
| 2,176
|
import frappe
@frappe.whitelist()
def is_enabled():
return bool(
frappe.get_system_settings("enable_telemetry")
and frappe.conf.get("posthog_host")
and frappe.conf.get("posthog_project_id")
)
@frappe.whitelist()
def get_credentials():
return {
"project_id": frappe.conf.get("posthog_project_id"),
"telemetry_host": frappe.conf.get("posthog_host"),
}
|
2302_79757062/drive
|
drive/api/telemetry.py
|
Python
|
agpl-3.0
| 410
|
import frappe
import os
from pathlib import Path
from PIL import Image, ImageOps
from io import BytesIO
from frappe.utils.nestedset import rebuild_tree, get_ancestors_of
from werkzeug.wrappers import Response
from werkzeug.wsgi import wrap_file
from werkzeug.utils import secure_filename
from drive.utils.files import get_user_directory, create_user_directory, get_new_title
from drive.locks.distributed_lock import DistributedLock
from drive.utils.files import (
get_user_directory,
create_user_directory,
get_new_title,
get_user_thumbnails_directory,
create_user_thumbnails_directory,
create_thumbnail,
)
@frappe.whitelist(allow_guest=True)
def create_image_thumbnail(entity_name):
drive_entity = frappe.get_value(
"Drive Entity",
entity_name,
["is_group", "path", "title", "mime_type", "file_size", "owner"],
as_dict=1,
)
if not drive_entity or drive_entity.is_group:
raise ValueError
if not frappe.has_permission(
doctype="Drive Entity", doc=drive_entity.name, ptype="write", user=frappe.session.user
):
frappe.throw("Cannot upload due to insufficient permissions", frappe.PermissionError)
with DistributedLock(drive_entity.path, exclusive=False):
if frappe.cache().exists(entity_name):
cached_thumbnbail = frappe.cache().get_value(entity_name)
response = Response(
wrap_file(frappe.request.environ, cached_thumbnbail),
direct_passthrough=True,
)
response.headers.set("Content-Type", "image/jpeg")
response.headers.set("Content-Disposition", "inline", filename=entity_name)
else:
user_thumbnails_directory = get_user_thumbnails_directory(drive_entity.owner)
thumbnail_getpath = Path(user_thumbnails_directory, entity_name)
with open(str(thumbnail_getpath) + ".thumbnail", "rb") as file:
thumbnail_data = BytesIO(file.read())
response = Response(
wrap_file(frappe.request.environ, thumbnail_data),
direct_passthrough=True,
)
response.headers.set("Content-Type", "image/jpeg")
response.headers.set("Content-Disposition", "inline", filename=entity_name)
frappe.cache().set_value(entity_name, thumbnail_data)
return response
@frappe.whitelist(allow_guest=True)
def create_video_thumbnail(entity_name):
drive_entity = frappe.get_value(
"Drive Entity",
entity_name,
["is_group", "path", "title", "mime_type", "file_size", "owner"],
as_dict=1,
)
if not drive_entity or drive_entity.is_group:
raise ValueError
if not frappe.has_permission(
doctype="Drive Entity", doc=drive_entity.name, ptype="write", user=frappe.session.user
):
frappe.throw("Cannot upload due to insufficient permissions", frappe.PermissionError)
with DistributedLock(drive_entity.path, exclusive=False):
if frappe.cache().exists(entity_name):
cached_thumbnbail = frappe.cache().get_value(entity_name)
response = Response(
wrap_file(frappe.request.environ, cached_thumbnbail),
direct_passthrough=True,
)
response.headers.set("Content-Type", "image/jpeg")
response.headers.set("Content-Disposition", "inline", filename=entity_name)
else:
user_thumbnails_directory = get_user_thumbnails_directory(drive_entity.owner)
thumbnail_getpath = Path(user_thumbnails_directory, entity_name)
with open(str(thumbnail_getpath) + ".thumbnail", "rb") as file:
thumbnail_data = BytesIO(file.read())
response = Response(
wrap_file(frappe.request.environ, thumbnail_data),
direct_passthrough=True,
)
response.headers.set("Content-Type", "image/jpeg")
response.headers.set("Content-Disposition", "inline", filename=entity_name)
frappe.cache().set_value(entity_name, thumbnail_data)
return response
|
2302_79757062/drive
|
drive/api/thumbnail_generator.py
|
Python
|
agpl-3.0
| 4,151
|