|
|
@@ -9,7 +9,6 @@ import android.content.Intent;
|
|
|
import android.net.Uri;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
-import android.os.Handler;
|
|
|
import android.text.Editable;
|
|
|
import android.text.TextWatcher;
|
|
|
import android.util.Log;
|
|
|
@@ -25,6 +24,7 @@ import android.widget.LinearLayout;
|
|
|
import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.andreabaccega.widget.FormEditText;
|
|
|
import com.lidroid.xutils.ViewUtils;
|
|
|
import com.lidroid.xutils.view.annotation.ViewInject;
|
|
|
@@ -33,6 +33,7 @@ import com.xzjmyk.pm.activity.AppConstant;
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.bean.oa.SelectBean;
|
|
|
import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.model.oa.CostFormModel;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.ListUtils;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.view.NScrollerGridView;
|
|
|
@@ -91,9 +92,10 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
private DetailsTableAdapter dtAdapter;
|
|
|
private List<String> detailsData; // popwindow要展示的消费明细类型
|
|
|
private List<String> selected_detailsData; //点击后要返回的消费明细类型
|
|
|
- private List<String> table_list_type; //表格里面新增的消费明细类型
|
|
|
- private List<Double> table_list_money;//表格里面新增的消费明细金额
|
|
|
private double sum_money = 0.0; // 最后算的的总金额
|
|
|
+ private List<CostFormModel> costFormModel_list;
|
|
|
+ private CostFormModel costFormModel;
|
|
|
+ private String money_editString = "";
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
@@ -125,6 +127,9 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
mGridView.setAdapter(mAdapter);
|
|
|
|
|
|
detail_table_ll.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ costFormModel_list = new ArrayList<>();
|
|
|
+ costFormModel = new CostFormModel();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -152,21 +157,18 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
|
|
|
private void doAutoCalculateJudge() {
|
|
|
sum_money = 0.0;
|
|
|
- if (ListUtils.isEmpty(table_list_money)){
|
|
|
- ToastMessage("请输入消费金额");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (table_list_type.size() > table_list_money.size()){
|
|
|
- ToastMessage("请输入完整的消费明细金额");
|
|
|
- return;
|
|
|
- }
|
|
|
- Log.i("table_list_money",table_list_money.toString()+"");
|
|
|
- for (int i = 0; i < table_list_money.size(); i++) {
|
|
|
- sum_money = sum_money + Double.valueOf(table_list_money.get(i));
|
|
|
- if (i == (table_list_money.size() - 1)){
|
|
|
- sum_money_tv.setText(CommonUtil.getTwoPointDouble(sum_money)+"");
|
|
|
+ Log.i("costFormModel_list",JSON.toJSONString(costFormModel_list));
|
|
|
+ for (int i = 0; i < costFormModel_list.size(); i++) {
|
|
|
+ if (costFormModel_list.get(i).getCost_money() > 0){
|
|
|
+ sum_money = sum_money + Double.valueOf(costFormModel_list.get(i).getCost_money());
|
|
|
+ if (i == (costFormModel_list.size() - 1)){
|
|
|
+ sum_money_tv.setText(CommonUtil.getTwoPointDouble(sum_money)+"");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ ToastMessage("请输入消费金额");
|
|
|
+ return;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -221,22 +223,23 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+
|
|
|
btn_sure.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
closePopupWindow();
|
|
|
- if (ListUtils.isEmpty(selected_detailsData)) return;
|
|
|
+ if (ListUtils.isEmpty(selected_detailsData)) return;
|
|
|
+
|
|
|
for (int i = 0; i < selected_detailsData.size(); i++) {
|
|
|
- table_list_type.add(selected_detailsData.get(i));
|
|
|
+ costFormModel = new CostFormModel();
|
|
|
+ costFormModel.setCost_type(selected_detailsData.get(i));
|
|
|
detailsData.remove(selected_detailsData.get(i));
|
|
|
+ costFormModel_list.add(costFormModel);
|
|
|
if (i == (selected_detailsData.size()-1)){
|
|
|
- dtAdapter.setTable_list_type(table_list_type);
|
|
|
- dtAdapter.setTable_list_money(table_list_money);
|
|
|
+ dtAdapter.setModels(costFormModel_list);
|
|
|
dtAdapter.notifyDataSetChanged();
|
|
|
detail_table_ll.setVisibility(View.VISIBLE);
|
|
|
- Log.i("selected_detailsData",selected_detailsData.toString()+"se");
|
|
|
- Log.i("detailsData",detailsData.toString()+"de");
|
|
|
- Log.i("table_list_type",table_list_type.toString()+"tlt");
|
|
|
+ Log.i("costFormModel_list", JSON.toJSONString(costFormModel_list)+"tlt");
|
|
|
}
|
|
|
}
|
|
|
selected_detailsData.clear();
|
|
|
@@ -262,8 +265,6 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
gv_details_list.setAdapter(gAdapter);
|
|
|
|
|
|
dtAdapter = new DetailsTableAdapter();
|
|
|
- table_list_type = new ArrayList<>();
|
|
|
- table_list_money = new ArrayList<>();
|
|
|
table_details_list.setAdapter(dtAdapter);
|
|
|
}
|
|
|
|
|
|
@@ -314,33 +315,23 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
|
|
|
|
|
|
private class DetailsTableAdapter extends BaseAdapter{
|
|
|
- private Context context;
|
|
|
- private List<String> table_list_type;
|
|
|
- private List<Double> table_list_money;
|
|
|
|
|
|
- public List<String> getTable_list_type() {
|
|
|
- return table_list_type;
|
|
|
- }
|
|
|
+ private List<CostFormModel> models;
|
|
|
|
|
|
- public void setTable_list_type(List<String> table_list_type) {
|
|
|
- this.table_list_type = table_list_type;
|
|
|
+ public List<CostFormModel> getModels() {
|
|
|
+ return models;
|
|
|
}
|
|
|
-
|
|
|
- public List<Double> getTable_list_money() {
|
|
|
- return table_list_money;
|
|
|
- }
|
|
|
- public void setTable_list_money(List<Double> table_list_money) {
|
|
|
- this.table_list_money = table_list_money;
|
|
|
+ public void setModels(List<CostFormModel> models) {
|
|
|
+ this.models = models;
|
|
|
}
|
|
|
-
|
|
|
@Override
|
|
|
public int getCount() {
|
|
|
- return ListUtils.isEmpty(table_list_type) ? 0 : table_list_type.size();
|
|
|
+ return ListUtils.isEmpty(models) ? 0 : models.size();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Object getItem(int position) {
|
|
|
- return ListUtils.isEmpty(table_list_type) ? 0 : table_list_type.get(position);
|
|
|
+ return ListUtils.isEmpty(models) ? 0 : models.get(position);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -351,18 +342,21 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
@Override
|
|
|
public View getView(final int position, View convertView, ViewGroup parent) {
|
|
|
ViewHolder viewHolder = null;
|
|
|
- if (convertView == null){
|
|
|
+// if (convertView == null){
|
|
|
viewHolder = new ViewHolder();
|
|
|
convertView = View.inflate(ExpenseReimbursementActivity.this, R.layout.expense_details_table_item,null);
|
|
|
viewHolder.details_type = (TextView) convertView.findViewById(R.id.details_type_tv);
|
|
|
viewHolder.details_money = (FormEditText) convertView.findViewById(R.id.details_money_tv);
|
|
|
viewHolder.details_delete = (ImageView) convertView.findViewById(R.id.details_delete_im);
|
|
|
convertView.setTag(viewHolder);
|
|
|
- }else {
|
|
|
- viewHolder = (ViewHolder) convertView.getTag();
|
|
|
+// }else {
|
|
|
+// viewHolder = (ViewHolder) convertView.getTag();
|
|
|
+// }
|
|
|
+ CostFormModel data= models.get(position);
|
|
|
+ viewHolder.details_type.setText(data.getCost_type() + "");
|
|
|
+ if (models.get(position).getCost_money() > 0){
|
|
|
+ viewHolder.details_money.setText(data.getCost_money() +"");
|
|
|
}
|
|
|
- viewHolder.details_type.setText(getTable_list_type().get(position) + "");
|
|
|
-// viewHolder.details_money.setText(getTable_list_money().get(position)+"");
|
|
|
|
|
|
viewHolder.details_delete.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
@@ -375,30 +369,18 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
.setPositiveButton(mContext.getString(R.string.common_sure), new DialogInterface.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
- table_list_type.remove(position);
|
|
|
- if (!ListUtils.isEmpty(table_list_money) && table_list_money.get(position) != null){
|
|
|
- table_list_money.remove(position);
|
|
|
- }
|
|
|
- if (ListUtils.isEmpty(table_list_type)){
|
|
|
- detail_table_ll.setVisibility(View.GONE);
|
|
|
- }else {
|
|
|
- notifyDataSetChanged();
|
|
|
- }
|
|
|
+ models.remove(position);
|
|
|
+ if (ListUtils.isEmpty(models)) {
|
|
|
+ detail_table_ll.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ notifyDataSetChanged();
|
|
|
}
|
|
|
+
|
|
|
}).show();
|
|
|
}
|
|
|
});
|
|
|
- /*String s = viewHolder.details_money.getText().toString();
|
|
|
- if (!StringUtils.isEmpty(s)){
|
|
|
- double numberstrChche = Double.parseDouble(s);
|
|
|
- if (table_list_money == null){
|
|
|
- table_list_money.add(position, CommonUtil.getTwoPointDouble(numberstrChche));
|
|
|
- }else {
|
|
|
- table_list_money.remove(position);
|
|
|
- table_list_money.add(position,CommonUtil.getTwoPointDouble(numberstrChche));
|
|
|
- }
|
|
|
- }*/
|
|
|
|
|
|
+ final ViewHolder finalViewHolder = viewHolder;
|
|
|
viewHolder.details_money.addTextChangedListener(new TextWatcher() {
|
|
|
@Override
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
|
|
@@ -407,25 +389,9 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
@Override
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
if (StringUtils.isEmpty(s.toString())) return;
|
|
|
- double numberstrChche = Double.parseDouble(s.toString());
|
|
|
- money_edit_position = position;
|
|
|
- /*if (table_list_money == null ){
|
|
|
- table_list_money.add(position, CommonUtil.getTwoPointDouble(numberstrChche));
|
|
|
- }else if (table_list_money.get(position) == null){
|
|
|
- table_list_money.add(position, CommonUtil.getTwoPointDouble(numberstrChche));
|
|
|
- }else {
|
|
|
- table_list_money.remove(position);
|
|
|
- table_list_money.add(position,CommonUtil.getTwoPointDouble(numberstrChche));
|
|
|
- }*/
|
|
|
-
|
|
|
- if(delayRun!=null){
|
|
|
- //每次editText有变化的时候,则移除上次发出的延迟线程
|
|
|
- dthandler.removeCallbacks(delayRun);
|
|
|
- }
|
|
|
+ if (!finalViewHolder.details_money.testValidity()) return;
|
|
|
money_editString = s.toString();
|
|
|
-
|
|
|
- //延迟800ms,如果不再输入字符,则执行该线程的run方法
|
|
|
- dthandler.postDelayed(delayRun, 1000);
|
|
|
+ models.get(position).setCost_money(Double.valueOf(money_editString));
|
|
|
}
|
|
|
});
|
|
|
return convertView;
|
|
|
@@ -436,27 +402,7 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
ImageView details_delete;
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- private Runnable delayRun = new Runnable() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- if (table_list_money == null ) {
|
|
|
- table_list_money.add(CommonUtil.getTwoPointDouble(Double.valueOf(money_editString)));
|
|
|
- }else {
|
|
|
- if (money_edit_position < table_list_money.size()){
|
|
|
- table_list_money.remove(money_edit_position);
|
|
|
- table_list_money.add(money_edit_position,CommonUtil.getTwoPointDouble(Double.valueOf(money_editString)));
|
|
|
- }else if (money_edit_position == table_list_money.size()){
|
|
|
- table_list_money.add(CommonUtil.getTwoPointDouble(Double.valueOf(money_editString)));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
}
|
|
|
- private int money_edit_position;
|
|
|
- private String money_editString = "";
|
|
|
- private Handler dthandler = new Handler();
|
|
|
/**
|
|
|
*新增弹出PopupWindow表格适配器
|
|
|
*/
|