人员工资
This commit is contained in:
parent
5b44c19501
commit
7f30109975
|
|
@ -6,6 +6,7 @@ import kd.bos.bill.AbstractBillPlugIn;
|
|||
import kd.bos.bill.BillShowParameter;
|
||||
import kd.bos.bill.OperationStatus;
|
||||
import kd.bos.cache.CacheFactory;
|
||||
import kd.bos.cache.TempFileCache;
|
||||
import kd.bos.cache.tempfile.TempFileCacheDownloadable;
|
||||
import kd.bos.dataentity.OperateOption;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
|
|
@ -19,10 +20,13 @@ import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
|||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.fileservice.FileService;
|
||||
import kd.bos.fileservice.FileServiceFactory;
|
||||
import kd.bos.form.ConfirmCallBackListener;
|
||||
import kd.bos.form.MessageBoxOptions;
|
||||
import kd.bos.form.control.AttachmentPanel;
|
||||
import kd.bos.form.control.Control;
|
||||
import kd.bos.form.control.EntryGrid;
|
||||
import kd.bos.form.control.Toolbar;
|
||||
import kd.bos.form.control.events.BeforeItemClickEvent;
|
||||
import kd.bos.form.control.events.ClickListener;
|
||||
import kd.bos.form.control.events.UploadEvent;
|
||||
import kd.bos.form.control.events.UploadListener;
|
||||
|
|
@ -36,6 +40,7 @@ import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
|
@ -67,6 +72,37 @@ public class SalaryPlugin extends AbstractBillPlugIn implements Plugin, UploadLi
|
|||
super.registerListener(e);
|
||||
AttachmentPanel toolbar = this.getControl("attachmentpanel");
|
||||
toolbar.addUploadListener(this);
|
||||
this.addItemClickListeners("zcgj_advcontoolbarap");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeItemClick(BeforeItemClickEvent evt) {
|
||||
//工具栏上的所有按钮的点击都会激活itemClick和beforeItemClick方法, 需 //要开发人员实现不同按钮的逻辑
|
||||
if (evt.getItemKey().equals("zcgj_downexcel")) {
|
||||
evt.setCancel(true);
|
||||
downExcel();
|
||||
}
|
||||
super.beforeItemClick(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义模板文件下载
|
||||
*/
|
||||
public void downExcel(){
|
||||
//文件位置resources/template/salary.xlsx
|
||||
try (InputStream in = this.getClass().getResourceAsStream("/template/salary.xlsx")) {
|
||||
if (in == null) {
|
||||
throw new RuntimeException("未找到模板文件:/template/salary.xlsx");
|
||||
}
|
||||
byte[] data = org.apache.commons.io.IOUtils.toByteArray(in);
|
||||
TempFileCache tempFileCache = CacheFactory.getCommonCacheFactory().getTempFileCache();
|
||||
String newFileName = "人员工资表导入模板-"+System.currentTimeMillis()+".xlsx";
|
||||
String url = tempFileCache.saveAsUrl(newFileName, data, data.length);
|
||||
this.getView().download(url);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("下载工资模板失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue