/webccr/src/com/emis/caesarui/webccr/ui/table/PromotionTable.java
https://bitbucket.org/sanliou/synccr · Java · 187 lines · 154 code · 22 blank · 11 comment · 21 complexity · 6c7b0f61e62dcf6945b47c3585088931 MD5 · raw file
- package com.emis.caesarui.webccr.ui.table;
- import com.emis.caesar.emisLog;
- import com.emis.caesar.senao.unit.sale.TSaleItem;
- import com.emis.caesar.senao.util.CcrUtil;
- import com.emis.caesarui.webccr.core.PromotionInfoList;
- import com.emis.caesarui.webccr.core.promote.MG;
- import com.emis.caesarui.webccr.core.promote.MM;
- import com.emis.caesarui.webccr.core.promote.PMBase;
- import com.emis.caesarui.webccr.webccr;
- import com.emis.util.emisUtil;
- import com.vaadin.data.Property;
- import com.vaadin.event.ItemClickEvent;
- import com.vaadin.shared.MouseEventDetails;
- import com.vaadin.ui.*;
- import java.util.ArrayList;
- import java.util.HashMap;
- /**
- * 促銷選單
- */
- public class PromotionTable extends BaseTable {
- PromoTableD1 promoTableD1 = null;
- PromoTableD2 promoTableD2 = null;
- ArrayList<TSaleItem> SaleItemPool = new ArrayList();
- private TextField tRemark;
- private TextField tPno;
- private Label SP_COMMENT;
- public static final int INDEX_CHK_1 = 0;
- public static final int INDEX_CHK_2 = 1;
- public static final int INDEX_SHM_CNT = 2;
- public static final int INDEX_MM_NO = 3;
- public static final int INDEX_MM_AMT = 4;
- public static final int INDEX_MM_NAME = 5;
- public static final int INDEX_TIME = 6;
- public static final String COLUMN_CHK_1 = "累點";
- public static final String COLUMN_CHK_2 = "分期";
- public static final String COLUMN_SHM_CNT = "適用二手機";
- public static final String COLUMN_MM_NO = "活動單號";
- public static final String COLUMN_MM_AMT = "促銷總金額";
- public static final String COLUMN_MM_NAME = "活動說明";
- public static final String COLUMN_TIME = "活動時間";
- /**
- * 列頭
- */
- public static final String[] sColumns = new String[] { COLUMN_CHK_1, COLUMN_CHK_2,
- COLUMN_SHM_CNT, COLUMN_MM_NO,
- COLUMN_MM_AMT, COLUMN_MM_NAME,
- COLUMN_TIME};
- public static final Class[] oClss = new Class[] { CheckBox.class, CheckBox.class,
- String.class, String.class,
- Integer.class, String.class,
- String.class, String.class};
- public PromotionTable() {
- super(sColumns,oClss);
- // 設定表格中表頭的字居中
- for (int i = 0; i < sColumns.length; i++) {
- this.setColumnAlignment(sColumns[i], Align.CENTER);
- }
- // 設定表格寬度
- this.setColumnWidth(COLUMN_CHK_1, 60);
- this.setColumnWidth(COLUMN_CHK_2, 60);
- this.setColumnWidth(COLUMN_SHM_CNT, 110);
- this.setColumnWidth(COLUMN_TIME, 110);
- this.setNullSelectionAllowed(false); // 選後 不能不選
- // 監控選取的促銷單
- this.addValueChangeListener(new ValueChangeListener() {
- @Override
- public void valueChange(Property.ValueChangeEvent event) {
- PMBase pmb = (PMBase) event.getProperty().getValue();
- try {
- if (promoTableD1 != null && promoTableD2 != null) {
- promoTableD1.removeAllItems();
- promoTableD2.removeAllItems();
- if (pmb != null) {
- promoTableD1.query(pmb, SaleItemPool);
- promoTableD2.query(pmb, SaleItemPool);
- SP_COMMENT.setValue(((MM) pmb).getGEN_SP_COMMENT());
- tPno.focus();
- }
- }
- } catch (Exception e) {
- // ((webccr) UI.getCurrent()).getlog().error(webccr.class, e);
- CcrUtil.setMessage(emisUtil.getStackTrace(e));
- }
- }
- });
- }
- public Object query(PromotionInfoList pmList) {
- Object _oItem = null;
- int _iCnt =0;
- removeAllItems();
- try {
- this.setPageLength(999);
- for (int i = 0; i < pmList.size(); i++) {
- PMBase pmb = (PMBase) pmList.get(i);
- Object[] _oRow = null; // 欄位
- if (pmb instanceof MM) {
- _iCnt++;
- MM mm = (MM) pmb;
- CheckBox _oChkBox_1 = new CheckBox("");
- _oChkBox_1.setData(mm.getM_ADD_POINT());
- _oChkBox_1.setEnabled(false);
- if ("Y".equals(mm.getM_ADD_POINT())) {
- _oChkBox_1.setValue(true);
- } else {
- _oChkBox_1.setValue(false);
- }
- CheckBox _oChkBox_2 = new CheckBox("");
- _oChkBox_2.setData(mm.getINSP_NO());
- _oChkBox_2.setEnabled(false);
- if (("".equals(emisUtil.parseString(mm.getINSP_NO())))) {
- _oChkBox_2.setValue(false);
- } else {
- _oChkBox_2.setValue(true);
- }
- String SHM_CNT = "不限";
- if ("1".equals(mm.getSHM_CNT())) {
- SHM_CNT = "一次";
- } else if ("2".equals(mm.getSHM_CNT())) {
- SHM_CNT = "多次";
- }
- int PM_TOTAL = emisUtil.parseInt(mm.getPM_TOTAL());
- int iPM_TOTAL = CcrUtil.getStorePrice(
- ((webccr) UI.getCurrent()).getFoCCR().getStore().getFLDxS_TAX(), "1", "", PM_TOTAL);
- _oRow = new Object[sColumns.length];
- _oRow[INDEX_CHK_1] = _oChkBox_1;
- _oRow[INDEX_CHK_2] = _oChkBox_2;
- _oRow[INDEX_SHM_CNT] = SHM_CNT;
- _oRow[INDEX_MM_NO] = mm.getPM_NO();
- _oRow[INDEX_MM_AMT] = iPM_TOTAL; // W_MM_H.PM_TOTAL
- _oRow[INDEX_MM_NAME] = mm.getName();
- _oRow[INDEX_TIME] = mm.getTIME_S() + "-" + mm.getTIME_E();
- }
- if (_oRow != null) {
- if (_iCnt == 1) {
- _oItem = addItem(_oRow, pmb);
- } else {
- addItem(_oRow, pmb);
- }
- }
- }
- } catch (Exception e) {
- // ((webccr) UI.getCurrent()).getlog().error(webccr.class, e);
- CcrUtil.setMessage(emisUtil.getStackTrace(e));
- }
- return _oItem;
- }
- public void setPromoTabD1(PromoTableD1 promoTableD1_) {
- promoTableD1 = promoTableD1_;
- }
- public void setPromoTabD2(PromoTableD2 promoTableD2_) {
- this.promoTableD2 = promoTableD2_;
- }
- public void setTSaleItemPoll(ArrayList<TSaleItem> saleItemPool) {
- this.SaleItemPool = saleItemPool;
- }
- public void settRemark(TextField tRemark) {
- this.tRemark = tRemark;
- }
- public void settPno(TextField tPno) {
- this.tPno = tPno;
- }
- public void setSP_COMMENT(Label SP_COMMENT) {
- this.SP_COMMENT = SP_COMMENT;
- }
- }