Browse Source

正式账号报销类型,图片压缩,下载的图片查看删除错位解决

FANGLH 8 years ago
parent
commit
5cf5551c44

+ 118 - 22
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/oa/ExpenseReimbursementActivity.java

@@ -14,6 +14,7 @@ import android.os.Handler;
 import android.os.Message;
 import android.text.Editable;
 import android.text.TextWatcher;
+import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.Gravity;
 import android.view.LayoutInflater;
@@ -21,10 +22,12 @@ import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.WindowManager;
 import android.view.inputmethod.InputMethodManager;
 import android.widget.AdapterView;
 import android.widget.BaseAdapter;
 import android.widget.Button;
+import android.widget.EditText;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.PopupWindow;
@@ -72,8 +75,10 @@ import com.xzjmyk.pm.activity.ui.erp.util.ListUtils;
 import com.xzjmyk.pm.activity.ui.erp.util.LogUtil;
 import com.xzjmyk.pm.activity.ui.erp.view.NScrollerGridView;
 import com.xzjmyk.pm.activity.ui.tool.MultiImagePreviewActivity;
+import com.xzjmyk.pm.activity.ui.tool.SingleImagePreviewActivity;
 import com.xzjmyk.pm.activity.util.CameraUtil;
 import com.xzjmyk.pm.activity.util.DisplayUtil;
+import com.xzjmyk.pm.activity.util.ImageUtil;
 import com.xzjmyk.pm.activity.util.PermissionUtil;
 import com.xzjmyk.pm.activity.util.StringUtils;
 import com.xzjmyk.pm.activity.util.ToastUtil;
@@ -234,9 +239,6 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
                         //{"fp_id": 38366,"success": true,"fpd_id": [[28859,1]]}
                         keyValue = JSON.parseObject(result).getIntValue("fp_id");
                         sendPicture();
-//                        commitSuccess(keyValue);
-                        //TODO 测试接口返回数据
-//                        getUpdateData(keyValue);
                     }
                     LogUtil.prinlnLongMsg("0x05result",result);
                     break;
@@ -275,6 +277,9 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
                         if (!ListUtils.isEmpty(selected_detailsData))
                             selected_detailsData.remove(cd_table_position);
 
+                        if ("S".equals(dg_type)){
+                            costFormModel_list.remove(cd_table_position);
+                        }
                         if (costFormModel_list.size() == 0){
                             detail_table_ll.setVisibility(View.GONE);
                             sum_money_tv.setText(null);
@@ -768,7 +773,7 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
                     dg_type = mGridconfigsBean.get(i).getDg_type();
                     if ("S".equals(dg_type)){
                         url= Constants.getAppBaseUrl(ct) + "mobile/common/getComboValue.action";
-                        ViewUtil.httpSendRequest(ct, url, params_Details, erhandler, headers1, 0x16, null, null, "get");
+                        ViewUtil.httpSendRequest(ct, url, params_Details, erhandler, headers1, 0x04, null, null, "get");
                     }else if ("DF".equals(dg_type)){
                         url = Constants.getAppBaseUrl(ct) + "common/dbfind.action";
                         ViewUtil.httpSendRequest(ct, url, params_Details, erhandler, headers1, 0x04, null, null, "get");
@@ -876,7 +881,11 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
                 doSingleSelect(money_combdatas,2,getString(R.string.currency),SELECT_CURRENCY);
                 break;
             case R.id.add_details_tv:
-                showPopupWindow();
+                if ("S".equals(dg_type)){
+                  showEditWindow();
+                }else if ("DF".equals(dg_type)){
+                    showPopupWindow();
+                }
                 putDownInput();
                 break;
             case R.id.automatic_calculation_tv:
@@ -960,9 +969,80 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
 
         }
     }
+    private PopupWindow etpopupWindow = null;
+    private void showEditWindow() {
+// 一个自定义的布局,作为显示的内容
+        View contentView = LayoutInflater.from(ct).inflate(
+                R.layout.item_select_cost_details, null);
+
+        // 设置按钮的点击事件
+        final EditText detail_et = (EditText) contentView.findViewById(R.id.input_cost_detail_et);
+        DisplayMetrics dm = getResources().getDisplayMetrics();
+        int w_screen = dm.widthPixels;
+        int h_screen = dm.heightPixels;
+        w_screen = DisplayUtil.dip2px(this, 300);
+        h_screen = DisplayUtil.dip2px(this, 150);
+        contentView.findViewById(R.id.cancel_ll).setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                etpopupWindow.dismiss();
+            }
+        });
+        contentView.findViewById(R.id.sure_ll).setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                if (StringUtils.isEmpty(detail_et.getText().toString())){
+                    ToastMessage(getString(R.string.input_cost_name));
+                    return;
+                }else {
+                    costFormModel = new CostFormModel();
+                    costFormModel.setCost_type(detail_et.getText().toString());
+                    costFormModel_list.add(costFormModel);
 
+                    dtAdapter.setModels(costFormModel_list);
+                    dtAdapter.notifyDataSetChanged();
+                    detail_table_ll.setVisibility(View.VISIBLE);
+                    Log.i("costFormModel_list", JSON.toJSONString(costFormModel_list)+"et");
+                    etpopupWindow.dismiss();
+                }
+            }
+        });
+        etpopupWindow = new PopupWindow(contentView, w_screen, h_screen, true);
+        etpopupWindow.setTouchable(true);
+        etpopupWindow.setOutsideTouchable(false);
+        // 如果不设置PopupWindow的背景,无论是点击外部区域还是Back键都无法dismiss弹框
+        etpopupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.pop_round_bg));
+        // 设置好参数之后再show
+        etpopupWindow.showAtLocation(contentView, Gravity.CENTER, 0, 0);
+        setbg(0.4f);
+    }
 
-
+    private void setbg(float alpha) {
+        setBackgroundAlpha(this, alpha);
+        if (etpopupWindow == null) return;
+        etpopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
+            @Override
+            public void onDismiss() {
+                setBackgroundAlpha(ExpenseReimbursementActivity.this, 1f);
+            }
+        });
+    }
+    /**
+     * 设置页面的透明度
+     * 兼容华为手机(在个别华为手机上 设置透明度会不成功)
+     *
+     * @param bgAlpha 透明度   1表示不透明
+     */
+    public void setBackgroundAlpha(Activity activity, float bgAlpha) {
+        WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
+        lp.alpha = bgAlpha;
+        if (bgAlpha == 1) {
+            activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);//不移除该Flag的话,在有视频的页面上的视频会出现黑屏的bug
+        } else {
+            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);//此行代码主要是解决在华为手机上半透明效果无效的bug
+        }
+        activity.getWindow().setAttributes(lp);
+    }
     private void c_onclick(String s) {
         if(isClickEqu)
         {
@@ -1399,9 +1479,14 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
                                         cd_table_position = position;
                                         doDeleteCostDetailshttp(position);
                                     }else {
-                                        if (!ListUtils.isEmpty(selected_detailsData)) {
-                                            selected_detailsData.remove(position);
+
+                                        if ("S".equals(dg_type)){
                                             models.remove(position);
+                                        }else if ("DF".equals(dg_type)){
+                                            if (!ListUtils.isEmpty(selected_detailsData)) {
+                                                selected_detailsData.remove(position);
+                                                models.remove(position);
+                                            }
                                         }
                                         if (ListUtils.isEmpty(models)) {
                                             detail_table_ll.setVisibility(View.GONE);
@@ -1427,7 +1512,7 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
                     if (StringUtils.isEmpty(s.toString())) return;
                     if (finalViewHolder.details_money.testValidity()){
                         money_editString = s.toString();
-                        models.get(position).setCost_money(Double.valueOf(money_editString));
+                        models.get(position).setCost_money(Double.valueOf(money_editString)); //TODO有bug
                         doAutoCalculateJudge();
                     }
 
@@ -1588,12 +1673,6 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
 //                    "&master=" + CommonUtil.getSharedPreferences(ct, "erp_master");
 //        }
 
-        private String getImageUrl(int id) {
-            return Constants.getAppBaseUrl(ct) + "common/downloadbyId.action?id=" + id + "&sessionId=" +
-                    CommonUtil.getSharedPreferences(ct, "sessionId") +
-                    "&sessionUser=" + CommonUtil.getSharedPreferences(ct, "erp_username") +
-                    "&master=" + CommonUtil.getSharedPreferences(ct, "erp_master");
-        }
         @Override
         public View getView(final int position, View convertView, ViewGroup parent) {
             if (getItemViewType(position) == 0) {// 普通的视图
@@ -1623,7 +1702,12 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
             }
         }
     }
-
+    private String getImageUrl(int id) {
+        return Constants.getAppBaseUrl(ct) + "common/downloadbyId.action?id=" + id + "&sessionId=" +
+                CommonUtil.getSharedPreferences(ct, "sessionId") +
+                "&sessionUser=" + CommonUtil.getSharedPreferences(ct, "erp_username") +
+                "&master=" + CommonUtil.getSharedPreferences(ct, "erp_master");
+    }
     /**
      * 通用跳转界面单选方法
      * @param combdatas
@@ -1709,11 +1793,22 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
                     public void onClick(DialogInterface dialog, int which) {
                         Log.i("dP_position",mPosition+"");
                         if (which == 0) {// 查看
-                            Intent intent = new Intent(ct, MultiImagePreviewActivity.class);
-                            intent.putExtra(AppConstant.EXTRA_IMAGES, mPhotoList);
-                            intent.putExtra(AppConstant.EXTRA_POSITION, mPosition);
-                            intent.putExtra(AppConstant.EXTRA_CHANGE_SELECTED, false);
-                            startActivity(intent);
+                            if (mCostUpdatePModel != null && !ListUtils.isEmpty(mCostUpdatePModel.getFiles())
+                                    && mPosition < mCostUpdatePModel.getFiles().size()){
+                                Toast.makeText(ct,"下载的图片,不可与本地选择的图片滑动查看",Toast.LENGTH_LONG).show();
+                                Intent intent = new Intent(mContext, SingleImagePreviewActivity.class);
+                                intent.putExtra(AppConstant.EXTRA_IMAGE_URI,
+                                        getImageUrl(mCostUpdatePModel.getFiles().get(mPosition).getFp_id()));
+                                startActivity(intent);
+
+                            }else {
+                                Intent intent = new Intent(ct, MultiImagePreviewActivity.class);
+                                intent.putExtra(AppConstant.EXTRA_IMAGES, mPhotoList);
+                                intent.putExtra(AppConstant.EXTRA_POSITION, mPosition);
+                                intent.putExtra(AppConstant.EXTRA_CHANGE_SELECTED, false);
+                                startActivity(intent);
+                            }
+
                         } else {// 删除
                             deletePhoto(mPosition);
                         }
@@ -1825,8 +1920,8 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
         LogUtil.prinlnLongMsg("mPhotoListsP",JSON.toJSONString(mPhotoList));
         for (int i = 0; i < mPhotoList.size(); i++) {
             String path = mPhotoList.get(i);
+            now_p = i;
             sendPictureRequest(path);
-             now_p = i;
         }
 
     }
@@ -1847,6 +1942,7 @@ public class ExpenseReimbursementActivity extends BaseActivity implements View.O
             }
 
         }
+        waterBitmapToFile = ImageUtil.compressBitmapToFile(path,100,240,320);
         RequestParams params = new RequestParams();
         if (platform){
             params.addQueryStringParameter("master", CommonUtil.getSharedPreferences(MyApplication.getInstance().getApplicationContext(), "companyEnUu"));

+ 5 - 4
WeiChat/src/main/res/layout/activity_expense_reimbursement.xml

@@ -101,7 +101,7 @@
                 android:background="@color/item_line" />
 
             <RelativeLayout
-                android:id="@+id/ry_set_startTime"
+                android:id="@+id/currency_rl"
                 style="@style/IMTbleLine2"
                 android:layout_height="40dp"
                 android:background="@color/white">
@@ -116,7 +116,7 @@
 
                 <com.andreabaccega.widget.FormEditText xmlns:editTextFormExample="http://schemas.android.com/apk/res-auto"
                     android:id="@+id/reimbursement_currency_fet"
-                    android:layout_width="wrap_content"
+                    android:layout_width="100dp"
                     android:layout_height="wrap_content"
                     android:layout_alignParentRight="true"
                     android:layout_centerVertical="true"
@@ -158,13 +158,14 @@
 
                 <TextView
                     android:id="@+id/add_details_tv"
-                    android:layout_width="wrap_content"
+                    android:layout_width="100dp"
                     android:layout_height="wrap_content"
                     android:layout_alignParentRight="true"
                     android:text="@string/new_add"
                     android:textColor="@color/blue"
                     android:padding="10dp"
-                    android:layout_marginRight="5dp"/>
+                    android:layout_marginRight="5dp"
+                    android:gravity="right"/>
             </RelativeLayout>
 
 

+ 91 - 0
WeiChat/src/main/res/layout/item_select_cost_details.xml

@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:gravity="center_horizontal"
+    android:orientation="vertical"
+    android:paddingLeft="10dp"
+    android:paddingRight="10dp"
+    android:paddingTop="10dp"
+    android:background="@drawable/pop_round_bg">
+
+    <TextView
+        android:id="@+id/title_tv"
+        android:layout_width="match_parent"
+        android:layout_height="20dp"
+        android:gravity="center"
+        android:text="@string/add_cost_details1"
+        android:textColor="@color/text_main"
+        android:textSize="@dimen/text_main" />
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="60dp"
+        android:gravity="center"
+        android:orientation="horizontal">
+
+        <EditText
+            android:id="@+id/input_cost_detail_et"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:background="@null"
+            android:ellipsize="end"
+            android:maxLines="1"
+            android:textColor="@color/text_main"
+            android:textSize="@dimen/text_main"
+            android:hint="@string/input_cost_name"
+            android:padding="10dp"
+            android:gravity="center"
+            android:maxLength="10"/>
+    </LinearLayout>
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="2px"
+        android:layout_marginTop="5dp"
+        android:background="@color/item_line" />
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="40dp"
+        android:orientation="horizontal"
+        android:textColor="@color/text_main"
+        android:textSize="@dimen/text_main">
+
+      <LinearLayout
+          android:id="@+id/cancel_ll"
+          android:layout_width="0dp"
+          android:layout_height="match_parent"
+          android:layout_weight="1"
+          android:gravity="center"
+        >
+          <TextView
+              android:layout_width="wrap_content"
+              android:layout_height="wrap_content"
+              android:text="@string/common_cancel"
+              android:textColor="@color/text_main"
+              android:textSize="@dimen/text_main"
+              android:padding="10dp"/>
+      </LinearLayout>
+
+        <View
+            android:layout_width="2px"
+            android:layout_height="match_parent"
+            android:background="@color/item_line" />
+        <LinearLayout
+            android:id="@+id/sure_ll"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            android:gravity="center"
+            >
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/common_sure"
+                android:textColor="@color/text_main"
+                android:textSize="@dimen/text_main"
+                android:padding="10dp"/>
+        </LinearLayout>
+    </LinearLayout>
+</LinearLayout>

+ 2 - 0
WeiChat/src/main/res/values-en/strings.xml

@@ -1405,4 +1405,6 @@
     <string name = "select_money_type"> Please select the currency </string>
     <string name = "add_cost_details"> Please add consumption details </string>
     <string name="sure_delete_this_details">Are you sure you want to delete the consumption details? </string>
+    <string name = "input_cost_name"> Enter the consumption detail name </string>
+    <string name = "add_cost_details1"> add a consumption detail </string>
 </resources>

+ 2 - 0
WeiChat/src/main/res/values-zh-rCN/strings.xml

@@ -1512,4 +1512,6 @@
     <string name="comment_count">评论数(<xliff:g id="count">%1$d</xliff:g>)</string>
     <string name="count_down">倒计时:</string>
     <string name="recording_completed">录制完成</string>
+    <string name="input_cost_name">请输入消费明细名称</string>
+    <string name="add_cost_details1">添加消费明细</string>
 </resources>

+ 2 - 0
WeiChat/src/main/res/values-zh-rTW/strings.xml

@@ -1506,4 +1506,6 @@
     <string name="comment_count">評論數(<xliff:g id="count">%1$d</xliff:g>)</string>
     <string name="count_down">倒數計時:</string>
     <string name="recording_completed">錄製完成</string>
+    <string name="input_cost_name">請輸入消費明細名稱</string>
+    <string name="add_cost_details1">添加消費明細</string>
 </resources>

+ 2 - 0
WeiChat/src/main/res/values/strings.xml

@@ -1799,4 +1799,6 @@
 
     <string name="count_down">倒计时:</string>
     <string name="recording_completed">录制完成</string>
+    <string name="input_cost_name">请输入消费明细名称</string>
+    <string name="add_cost_details1">添加消费明细</string>
 </resources>