package zbooksoft.fams.controller;
|
|
import com.ruili.wcp.web.model.AjaxResponse;
|
import com.ruili.wcp.web.model.ErrorInfo;
|
import org.apache.shiro.authz.annotation.RequiresUser;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.servlet.ModelAndView;
|
import zbooksoft.fams.service.AssetApplyService;
|
import zbooksoft.fams.service.AssetApplyService.BillType;
|
|
/**
|
* 资产使用流程单据的选择资产弹窗
|
* @author ycq
|
* @date 2026-10-16
|
*/
|
@Controller
|
@RequestMapping("/fams/apply")
|
public class AssetApplyController {
|
|
@Autowired
|
private AssetApplyService assetApplyService;
|
|
/**
|
* 选择资产弹窗页面
|
* @param billType 单据类型枚举名,如 BORROW
|
* @return 弹窗视图
|
*/
|
@RequestMapping(value = "/pickAssets", method = RequestMethod.GET)
|
@RequiresUser
|
public ModelAndView pickAssets(@RequestParam String billType) {
|
BillType type = parseType(billType);
|
ModelAndView mv = new ModelAndView("fams/apply/pickAssets");
|
mv.addObject("billType", type == null ? "" : type.name());
|
mv.addObject("billTitle", type == null ? "" : type.getTitle());
|
mv.addObject("maxAssets", AssetApplyService.MAX_ASSETS_PER_BILL);
|
mv.addObject("maxCandidates", AssetApplyService.MAX_CANDIDATES);
|
return mv;
|
}
|
|
/**
|
* 查可选资产
|
* @param billType 单据类型枚举名
|
* @param sealType 封存解封单的办理类型
|
* @param keyword 关键字
|
* @param billNo 当前单据编号
|
* @return 候选资产
|
*/
|
@RequestMapping(value = "/candidates", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
|
@ResponseBody
|
@RequiresUser
|
public Object candidates(@RequestParam String billType, @RequestParam(required = false) String sealType,
|
@RequestParam(required = false) String keyword, @RequestParam(required = false) String billNo) {
|
BillType type = parseType(billType);
|
if (type == null) {
|
return new AjaxResponse(new ErrorInfo("单据类型不正确"), false);
|
}
|
return new AjaxResponse(assetApplyService.listCandidates(type, sealType, keyword, billNo));
|
}
|
|
private static BillType parseType(String billType) {
|
for (BillType type : BillType.values()) {
|
if (type.name().equals(billType)) {
|
return type;
|
}
|
}
|
return null;
|
}
|
}
|