|
|
@@ -9,8 +9,6 @@ import android.content.Intent;
|
|
|
import android.net.Uri;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
-import android.text.Editable;
|
|
|
-import android.text.TextWatcher;
|
|
|
import android.util.Log;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.LayoutInflater;
|
|
|
@@ -32,6 +30,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.util.CommonUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.ListUtils;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.view.NScrollerGridView;
|
|
|
import com.xzjmyk.pm.activity.ui.tool.MultiImagePreviewActivity;
|
|
|
@@ -62,6 +61,10 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
private Button btn_save;
|
|
|
@ViewInject(R.id.gv_details_list)
|
|
|
private NScrollerGridView gv_details_list;
|
|
|
+ @ViewInject(R.id.sum_money_tv)
|
|
|
+ private TextView sum_money_tv;
|
|
|
+ @ViewInject(R.id.detail_table_ll)
|
|
|
+ private LinearLayout detail_table_ll;
|
|
|
private MyGridView mGridView;
|
|
|
private GridViewAdapter mAdapter;
|
|
|
private ArrayList<String> mPhotoList;
|
|
|
@@ -71,12 +74,9 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
private static final int SELECT_REIMBURSEMENT_TYPE = 3;
|
|
|
private static final int SELECT_CURRENCY = 4;
|
|
|
private PopupWindow setWindow = null;//
|
|
|
- private List<String> detailsData; // 要展示的消费明细
|
|
|
- private List<String> selected_detailsData; //点击后要返回的消费明细
|
|
|
private GridDataAdapter gAdapter;
|
|
|
private String[] TypeDatas = {"类型1","类型2","类型3","类型4","类型5"};
|
|
|
private String[] CurrencyDatas = {"币种1","币种2","币种3","币种4","币种5"};
|
|
|
-
|
|
|
@ViewInject(R.id.details_data_tv)
|
|
|
private TextView details_data_tv;
|
|
|
private Boolean initDetailDatas_initialization = false;
|
|
|
@@ -85,8 +85,11 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
@ViewInject(R.id.table_details_list)
|
|
|
private MyListView table_details_list;
|
|
|
private DetailsTableAdapter dtAdapter;
|
|
|
- private List<String> table_list_type;
|
|
|
- private List<Double> table_list_money;
|
|
|
+ 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; // 最后算的的总金额
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
@@ -112,16 +115,17 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
|
|
|
mGridView = (MyGridView) findViewById(R.id.grid_view);
|
|
|
findViewById(R.id.add_details_tv).setOnClickListener(this);
|
|
|
+ findViewById(R.id.automatic_calculation_tv).setOnClickListener(this);
|
|
|
mPhotoList = new ArrayList<String>();
|
|
|
mAdapter = new GridViewAdapter();
|
|
|
mGridView.setAdapter(mAdapter);
|
|
|
+
|
|
|
+ detail_table_ll.setVisibility(View.GONE);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
switch (v.getId()){
|
|
|
- case R.id.reimbursement_title_fet:
|
|
|
- break;
|
|
|
case R.id.reimbursement_type_fet:
|
|
|
doSingleSelect(TypeDatas,2,getString(R.string.Reimbursement_type),SELECT_REIMBURSEMENT_TYPE);
|
|
|
break;
|
|
|
@@ -131,16 +135,52 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
case R.id.add_details_tv:
|
|
|
showPopupWindow();
|
|
|
break;
|
|
|
+ case R.id.automatic_calculation_tv:
|
|
|
+// doAutoCalculateJudge();
|
|
|
+ break;
|
|
|
case R.id.btn_save:
|
|
|
+ if (reimbursement_title_fet.testValidity() ){
|
|
|
+
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void doAutoCalculateJudge() {
|
|
|
+ if (!ListUtils.isEmpty(table_list_money)) table_list_money.clear();
|
|
|
+ for (int i = 0; i < table_list_type.size(); i++) {
|
|
|
+ if (dtAdapter.getTable_list_money().get(i) != null){
|
|
|
+ table_list_money.add(CommonUtil.getTwoPointDouble(Double.valueOf(dtAdapter.getTable_list_money().get(i).toString())));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ ToastMessage("请输入消费金额");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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)+"");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void showPopupWindow() {
|
|
|
if (setWindow == null) initPopupWindow();
|
|
|
setWindow.showAtLocation(getWindow().getDecorView().
|
|
|
findViewById(android.R.id.content), Gravity.BOTTOM, 0, 0);
|
|
|
- if (VERSION_CODES < 24)
|
|
|
+ if (VERSION_CODES < 24) // API版本太高不断刷新View亮度,会有黑缝隙bug
|
|
|
DisplayUtil.backgroundAlpha(this, 0.4f);
|
|
|
}
|
|
|
private void closePopupWindow() {
|
|
|
@@ -175,10 +215,8 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
GridDataAdapter.ViewModle modle = (GridDataAdapter.ViewModle) view.getTag();
|
|
|
-// gAdapter.setSelected(position);
|
|
|
-
|
|
|
// TODO 记录当下点击的位置
|
|
|
- if (selected_detailsData.contains(detailsData.get(position))){
|
|
|
+ if (!ListUtils.isEmpty(selected_detailsData) && selected_detailsData.contains(detailsData.get(position))){
|
|
|
selected_detailsData.remove(detailsData.get(position));
|
|
|
}else {
|
|
|
selected_detailsData.add(detailsData.get(position));
|
|
|
@@ -192,27 +230,29 @@ 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;
|
|
|
- details_data_tv.setText(selected_detailsData.toString());
|
|
|
for (int i = 0; i < selected_detailsData.size(); i++) {
|
|
|
table_list_type.add(selected_detailsData.get(i));
|
|
|
detailsData.remove(selected_detailsData.get(i));
|
|
|
if (i == (selected_detailsData.size()-1)){
|
|
|
dtAdapter.setTable_list_type(table_list_type);
|
|
|
- dtAdapter.setTable_list_money(table_list_money);
|
|
|
+// dtAdapter.setTable_list_money(table_list_money);
|
|
|
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");
|
|
|
}
|
|
|
}
|
|
|
- closePopupWindow();
|
|
|
+ selected_detailsData.clear();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
private void initAddDatas() {
|
|
|
if (!ListUtils.isEmpty(selected_detailsData)) selected_detailsData.clear();
|
|
|
+ //TODO 接口返回
|
|
|
if (initDetailDatas_initialization) return;
|
|
|
for (int i = 0; i < 22; i++) {
|
|
|
detailsData.add("明细" + i);
|
|
|
@@ -342,31 +382,46 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
@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_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();
|
|
|
}
|
|
|
- notifyDataSetChanged();
|
|
|
}
|
|
|
}).show();
|
|
|
}
|
|
|
});
|
|
|
- viewHolder.details_money.addTextChangedListener(new TextWatcher() {
|
|
|
- @Override
|
|
|
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void afterTextChanged(Editable s) {
|
|
|
- double numberstrChche = Double.parseDouble(s.toString());
|
|
|
- table_list_money.add(numberstrChche);
|
|
|
+ /*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));
|
|
|
}
|
|
|
- });
|
|
|
+ }*/
|
|
|
+
|
|
|
+// viewHolder.details_money.addTextChangedListener(new TextWatcher() {
|
|
|
+// @Override
|
|
|
+// public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
|
|
+// @Override
|
|
|
+// public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
|
|
+// @Override
|
|
|
+// public void afterTextChanged(Editable s) {
|
|
|
+// if (StringUtils.isEmpty(s.toString())) return;
|
|
|
+// double numberstrChche = Double.parseDouble(s.toString());
|
|
|
+// 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));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// });
|
|
|
return convertView;
|
|
|
}
|
|
|
class ViewHolder{
|
|
|
@@ -513,6 +568,7 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
|
|
|
* @param requestCode
|
|
|
*/
|
|
|
private void doSingleSelect(String[] Datas, int type, String title, int requestCode) {
|
|
|
+ //TODO Datas为接口返回
|
|
|
ArrayList<SelectBean> formBeaan = new ArrayList<>();
|
|
|
SelectBean selectBean;
|
|
|
for (int i = 0; i < Datas.length; i++) {
|