Просмотр исходного кода

Merge branches 'developer' and 'master' of ssh://10.10.100.21/source/uu-android into feature_fanglh

FANGLH 7 лет назад
Родитель
Сommit
a30ca6350a
73 измененных файлов с 3482 добавлено и 462 удалено
  1. 6 3
      WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/crm/ClientActivity.java
  2. 5 2
      WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/oa/OAActivity.java
  3. 8 3
      WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/oa/SelectAimActivity.java
  4. 7 2
      WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/secretary/BookingAddActivity.java
  5. 9 1
      WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/adapter/WorkMenuParentAdapter.java
  6. BIN
      WeiChat/src/main/res/drawable-hdpi/uuu.png
  7. BIN
      WeiChat/src/main/res/drawable-xhdpi/uuu.png
  8. BIN
      WeiChat/src/main/res/drawable-xxhdpi/uuu.png
  9. 2 2
      WeiChat/src/main/res/values-zh-rCN/strings.xml
  10. 2 2
      WeiChat/src/main/res/values/strings.xml
  11. 5 5
      WeiChat/version.properties
  12. 1 1
      app_core/common/build.gradle
  13. 3 0
      app_core/common/src/main/java/com/common/system/MacUtil.java
  14. 1 0
      app_core/common/src/main/java/com/core/app/Constants.java
  15. 1 1
      app_core/common/src/main/java/com/core/utils/CommonUtil.java
  16. BIN
      app_core/common/src/main/res/drawable-hdpi/uuu.png
  17. BIN
      app_core/common/src/main/res/drawable-xhdpi/uuu.png
  18. BIN
      app_core/common/src/main/res/drawable-xxhdpi/uuu.png
  19. 1 1
      app_core/common/src/main/res/values-en/strings.xml
  20. 2 2
      app_core/common/src/main/res/values-zh-rCN/strings.xml
  21. 2 2
      app_core/common/src/main/res/values-zh-rTW/strings.xml
  22. 2 2
      app_core/common/src/main/res/values/strings.xml
  23. 1 1
      app_modular/applogin/src/main/java/com/modular/login/adapter/IndustryAdapter.java
  24. 1 0
      app_modular/appme/src/main/java/com/uas/appme/settings/activity/SelectIpActivity.java
  25. 2 2
      app_modular/appme/src/main/res/values-en/strings.xml
  26. 2 2
      app_modular/appme/src/main/res/values/strings.xml
  27. 9 1
      app_modular/appmessages/src/main/java/com/modular/appmessages/fragment/ApprovalListFragment.java
  28. 474 5
      app_modular/apputils/src/main/java/com/modular/apputils/activity/BillDetailsActivity.java
  29. 11 2
      app_modular/apputils/src/main/java/com/modular/apputils/activity/BillInputActivity.java
  30. 1 0
      app_modular/apputils/src/main/java/com/modular/apputils/activity/SimpleWebActivity.java
  31. 28 1
      app_modular/apputils/src/main/java/com/modular/apputils/adapter/BillAdapter.java
  32. 28 0
      app_modular/apputils/src/main/java/com/modular/apputils/adapter/BillDetailsAdapter.java
  33. 715 0
      app_modular/apputils/src/main/java/com/modular/apputils/adapter/BillUpdateAdapter.java
  34. 8 1
      app_modular/apputils/src/main/java/com/modular/apputils/model/ApprovalList.java
  35. 13 6
      app_modular/apputils/src/main/java/com/modular/apputils/model/BillGroupModel.java
  36. 278 0
      app_modular/apputils/src/main/java/com/modular/apputils/presenter/BillDetailsPresenter.java
  37. 3 0
      app_modular/apputils/src/main/java/com/modular/apputils/presenter/BillPresenter.java
  38. 7 1
      app_modular/apputils/src/main/java/com/modular/apputils/presenter/imp/IBillDetails.java
  39. 138 0
      app_modular/apputils/src/main/java/com/modular/apputils/widget/BillUpdatePopup.java
  40. 0 0
      app_modular/apputils/src/main/res/drawable/shape_b2b_gray_light_line_bg.xml
  41. 3 1
      app_modular/apputils/src/main/res/layout/item_bill_input_select.xml
  42. 57 0
      app_modular/apputils/src/main/res/layout/pop_bill_input_update.xml
  43. 1 0
      app_modular/apputils/src/main/res/values-en/strings.xml
  44. 1 0
      app_modular/apputils/src/main/res/values-zh-rCN/strings.xml
  45. 1 0
      app_modular/apputils/src/main/res/values-zh-rTW/strings.xml
  46. 1 0
      app_modular/apputils/src/main/res/values/strings.xml
  47. 3 2
      app_modular/appworks/src/main/java/com/uas/appworks/CRM/erp/activity/BusinessActivity.java
  48. 7 2
      app_modular/appworks/src/main/java/com/uas/appworks/CRM/erp/activity/DeviceDataFormAddActivity.java
  49. 4 4
      app_modular/appworks/src/main/java/com/uas/appworks/CRM/erp/adapter/HListViewOneAdapter.java
  50. 8 3
      app_modular/appworks/src/main/java/com/uas/appworks/OA/erp/activity/form/DataFormDetailActivity.java
  51. 6 2
      app_modular/appworks/src/main/java/com/uas/appworks/OA/erp/activity/form/TravelDataFormDetailActivity.java
  52. 8 2
      app_modular/appworks/src/main/java/com/uas/appworks/OA/erp/presenter/MissionPresenter.java
  53. 6 2
      app_modular/appworks/src/main/java/com/uas/appworks/activity/CommonDataFormActivity.java
  54. 6 2
      app_modular/appworks/src/main/java/com/uas/appworks/activity/WorkDataFormActivity.java
  55. 5 0
      app_modular/appworks/src/main/java/com/uas/appworks/activity/businessManage/BusinessOvertimeListActivity.java
  56. 5 0
      app_modular/appworks/src/main/java/com/uas/appworks/activity/businessManage/BusinessRankListActivity.java
  57. 5 0
      app_modular/appworks/src/main/java/com/uas/appworks/activity/businessManage/BusinessRecordListActivity.java
  58. 43 6
      app_modular/appworks/src/main/java/com/uas/appworks/activity/businessManage/businessManageHome/BusinessManageHomeActivity.java
  59. 4 0
      app_modular/appworks/src/main/java/com/uas/appworks/activity/businessManage/businessManageHome/BusinessManageHomeContract.java
  60. 22 0
      app_modular/appworks/src/main/java/com/uas/appworks/activity/businessManage/businessManageHome/BusinessManageHomePresenterImpl.java
  61. 13 0
      app_modular/appworks/src/main/java/com/uas/appworks/adapter/BillListDetailsAdapter.java
  62. 6 2
      app_modular/appworks/src/main/java/com/uas/appworks/crm3_0/activity/ContactDynamicAddActivity.java
  63. 1 0
      app_modular/appworks/src/main/java/com/uas/appworks/crm3_0/activity/CustomerManageActivity.java
  64. 30 8
      app_modular/appworks/src/main/java/com/uas/appworks/crm3_0/activity/CustomerVisitActivity.java
  65. 157 59
      app_modular/appworks/src/main/java/com/uas/appworks/crm3_0/activity/CustomerVisitBillInputActivity.java
  66. 889 9
      app_modular/appworks/src/main/java/com/uas/appworks/crm3_0/activity/CustomerVisitDetailsActivity.java
  67. 38 1
      app_modular/appworks/src/main/java/com/uas/appworks/crm3_0/activity/VisitRecordBillInputActivity.java
  68. 344 298
      app_modular/appworks/src/main/java/com/uas/appworks/dao/MissionDao.java
  69. 10 1
      app_modular/appworks/src/main/java/com/uas/appworks/model/VisitPlan.java
  70. 6 5
      app_modular/appworks/src/main/java/com/uas/appworks/presenter/CustomerManagePresenter.java
  71. 1 1
      app_modular/appworks/src/main/res/layout/item_customer_details_3_0.xml
  72. 14 0
      app_modular/appworks/src/main/res/layout/pop_business_home_menu.xml
  73. 1 1
      version.gradle

+ 6 - 3
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/crm/ClientActivity.java

@@ -245,7 +245,7 @@ public class ClientActivity extends BaseActivity implements View.OnClickListener
         initSaleBarChart();
         initListener();
         mMonths = getResources().getStringArray(R.array.month_list);
-        sales=getResources().getStringArray(R.array.sale_list);
+        sales = getResources().getStringArray(R.array.sale_list);
     }
 
     private void initListener() {
@@ -489,7 +489,10 @@ public class ClientActivity extends BaseActivity implements View.OnClickListener
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
-        getMenuInflater().inflate(R.menu.menu_crm, menu);
+        String master = CommonUtil.getMaster();
+        if (!("DATACENTER".equals(master) || "N_SHYZ".equals(master) || "N_AJC".equals(master))) {
+            getMenuInflater().inflate(R.menu.menu_crm, menu);
+        }
         return true;
     }
 
@@ -579,7 +582,7 @@ public class ClientActivity extends BaseActivity implements View.OnClickListener
 
     private void setData1(int count, float[] ydata) {
         ArrayList<String> xVals = new ArrayList<String>();
-        String[] sale_list= getResources().getStringArray(R.array.sale_list);
+        String[] sale_list = getResources().getStringArray(R.array.sale_list);
         xVals.add(sale_list[0]);
         xVals.add(sale_list[2]);
         xVals.add(sale_list[4]);

+ 5 - 2
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/oa/OAActivity.java

@@ -882,8 +882,11 @@ public class OAActivity extends SupportToolBarActivity implements View.OnClickLi
             list.add(map);
             map = new HashMap<>();
         }
-        map.put("item_name", getString(R.string.crm_add_visitrecord));
-        list.add(map);
+        String master = CommonUtil.getMaster();
+        if (!("DATACENTER".equals(master) || "N_SHYZ".equals(master) || "N_AJC".equals(master))) {
+            map.put("item_name", getString(R.string.crm_add_visitrecord));
+            list.add(map);
+        }
         if (menusMap != null) {
             if (menusMap.size() != 0) {
                 for (int i = 0; i < menusMap.size(); i++) {

+ 8 - 3
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/oa/SelectAimActivity.java

@@ -33,7 +33,7 @@ import java.util.List;
 /*选择拜访目的地*/
 public class SelectAimActivity extends OABaseActivity implements ISelectAim {
 
-//    @ViewInject(R.id.search_edit)
+    //    @ViewInject(R.id.search_edit)
     @ViewInject(R.id.voiceSearchView)
     private VoiceSearchView voiceSearchView;
     @ViewInject(R.id.mapView)
@@ -44,7 +44,6 @@ public class SelectAimActivity extends OABaseActivity implements ISelectAim {
     private SelectAimPresenter presenter;
 
 
-
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -58,14 +57,20 @@ public class SelectAimActivity extends OABaseActivity implements ISelectAim {
     private void initData() {
         Intent intent = getIntent();
         int type = 0;
+        String search = "";
         if (intent != null) {
             type = intent.getIntExtra("type", 0);
             String title = intent.getStringExtra("title");
             if (!StringUtil.isEmpty(title))
-              setTitle(title);
+                setTitle(title);
+            search = intent.getStringExtra("search");
         }
         presenter = new SelectAimPresenter(this);
         presenter.start(type);
+
+        if (!StringUtil.isEmpty(search)) {
+            voiceSearchView.setText(search);
+        }
     }
 
     private void initEvent() {

+ 7 - 2
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/secretary/BookingAddActivity.java

@@ -304,6 +304,11 @@ public class BookingAddActivity extends SupportToolBarActivity implements View.O
             bt_commit.setEnabled(true);
             return;
         }
+
+        if (StringUtil.isEmpty(com.core.utils.CommonUtil.getName())) {
+            ToastMessage("当前登录人姓名为空,不能新增预约");
+            return;
+        }
 //        showLoading();
         String content = "";
         content = et_book_content.getText().toString();
@@ -418,10 +423,10 @@ public class BookingAddActivity extends SupportToolBarActivity implements View.O
                             } else {
                                 invite(phone, "8636ba7f-a1b4-4062-8571-782035101167");
                             }
-                            if (!TextUtils.isEmpty(mWhichPage)&&mWhichPage.equals("ScheduleActivity")){
+                            if (!TextUtils.isEmpty(mWhichPage) && mWhichPage.equals("ScheduleActivity")) {
                                 setResult(0x11);
                                 finish();
-                            }else{
+                            } else {
                                 startActivity(new Intent(BookingAddActivity.this, BookingListActivity.class)
                                         .putExtra("curDate", startTime)
                                         .putExtra("whichPage", mWhichPage));

+ 9 - 1
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/adapter/WorkMenuParentAdapter.java

@@ -127,7 +127,9 @@ public class WorkMenuParentAdapter extends BaseAdapter {
                         }
                     } else {
                         Intent intent = getWorkIntent(typeListBeen.get(position));
-                        context.startActivity(intent);
+                        if (intent != null) {
+                            context.startActivity(intent);
+                        }
                     }
                 } catch (Exception e) {
                     Log.e("workException", e.getMessage());
@@ -276,6 +278,12 @@ public class WorkMenuParentAdapter extends BaseAdapter {
                 }
                 intent.putExtra("title", title);
                 break;
+            case "com.modular.crm.ClientActivity":
+                if ("ZT".equals(CommonUtil.getMaster())) {
+                    ToastUtil.showToast(context, "应贵公司要求,暂不开放");
+                    return null;
+                }
+                break;
             default:
                 break;
         }

BIN
WeiChat/src/main/res/drawable-hdpi/uuu.png


BIN
WeiChat/src/main/res/drawable-xhdpi/uuu.png


BIN
WeiChat/src/main/res/drawable-xxhdpi/uuu.png


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

@@ -323,8 +323,8 @@
     <string name="business_followup">我的商机</string>
     <string name="business_followup_people">商机跟进人</string>
     <string name="color_text">颜色</string>
-    <string name="business_number">商机数量</string>
-    <string name="business_Conversion_rate">商机转化率</string>
+    <string name="business_number">数量/金额</string>
+    <string name="business_Conversion_rate">转化率</string>
 
     <string name="business_stage">商机阶段</string>
     <string name="First_communication">初次沟通</string>

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

@@ -865,8 +865,8 @@
     <string name="business_followup">我的商机</string>
     <string name="business_followup_people">商机跟进人</string>
     <string name="color_text">颜色</string>
-    <string name="business_number">商机数量</string>
-    <string name="business_Conversion_rate">商机转化率</string>
+    <string name="business_number">数量/金额</string>
+    <string name="business_Conversion_rate">转化率</string>
 
     <string name="business_stage">商机阶段</string>
     <string name="First_communication">初次沟通</string>

+ 5 - 5
WeiChat/version.properties

@@ -1,5 +1,5 @@
-#Thu Jan 03 17:42:18 CST 2019
-debugName=971
-versionName=666
-debugCode=971
-versionCode=221
+#Thu Apr 04 10:47:08 CST 2019
+debugName=972
+versionName=671
+debugCode=972
+versionCode=226

+ 1 - 1
app_core/common/build.gradle

@@ -76,5 +76,5 @@ dependencies {
     compile files('libs/hellocharts-library-1.5.8.jar')
     compile deps.wechatSdk
     compile 'com.github.hss01248:NotifyUtil:1.0.1'
-//    compile deps.basePopup
+    compile deps.basePopup
 }

+ 3 - 0
app_core/common/src/main/java/com/common/system/MacUtil.java

@@ -173,6 +173,9 @@ public class MacUtil {
 
     private static String convertToMac(byte[] mac) {
         StringBuilder sb = new StringBuilder();
+        if (mac == null) {
+            return "";
+        }
         for (int i = 0; i < mac.length; i++) {
             byte b = mac[i];
             int value = 0;

+ 1 - 0
app_core/common/src/main/java/com/core/app/Constants.java

@@ -571,6 +571,7 @@ public class Constants {
         String MY_DOIT = "isMe";//是否我负责
         String CALLER = "mCaller";
         String STATUS = "mStatus";
+        String BILL_STATUS = "bill_status";
         String CONDITION = "mCondition";
         String ID = "mId";
         String TITLE = "mTitlte";

+ 1 - 1
app_core/common/src/main/java/com/core/utils/CommonUtil.java

@@ -630,7 +630,7 @@ public class CommonUtil {
             }
         }
         if (StringUtil.isEmpty(name)) {
-//            name = MyApplication.getInstance().mLoginUser.getNickName();
+            name = MyApplication.getInstance().mLoginUser.getNickName();
         }
         return StringUtil.isEmpty(name) ? "" : name;
     }

BIN
app_core/common/src/main/res/drawable-hdpi/uuu.png


BIN
app_core/common/src/main/res/drawable-xhdpi/uuu.png


BIN
app_core/common/src/main/res/drawable-xxhdpi/uuu.png


+ 1 - 1
app_core/common/src/main/res/values-en/strings.xml

@@ -318,7 +318,7 @@
     <string name="business_followup">My Niche</string>
     <string name="business_followup_people"> business followers </string>
     <string name="color_text"> color </string>
-    <string name="business_number">count</string>
+    <string name="business_number">count/money</string>
     <string name="business_Conversion_rate"> Percent</string>
     <string name="business_stage"> Step </string>
     <string name="First_communication"> Initial communication </string>

+ 2 - 2
app_core/common/src/main/res/values-zh-rCN/strings.xml

@@ -326,8 +326,8 @@
     <string name="business_followup">我的商机</string>
     <string name="business_followup_people">商机跟进人</string>
     <string name="color_text">颜色</string>
-    <string name="business_number">商机数量</string>
-    <string name="business_Conversion_rate">商机转化率</string>
+    <string name="business_number">数量/金额</string>
+    <string name="business_Conversion_rate">转化率</string>
 
     <string name="business_stage">商机阶段</string>
     <string name="First_communication">初次沟通</string>

+ 2 - 2
app_core/common/src/main/res/values-zh-rTW/strings.xml

@@ -314,8 +314,8 @@
     <string name="business_followup">商機跟進</string>
     <string name="business_followup_people">商機跟進人</string>
     <string name="color_text">顏色</string>
-    <string name="business_number">商機數量</string>
-    <string name="business_Conversion_rate">商機轉化率</string>
+    <string name="business_number">數量/金額</string>
+    <string name="business_Conversion_rate">轉化率</string>
     <string name="business_stage">商機階段</string>
     <string name="First_communication">初次溝通</string>
     <string name="Product_show">產品演示</string>

+ 2 - 2
app_core/common/src/main/res/values/strings.xml

@@ -869,8 +869,8 @@
     <string name="business_followup">我的商机</string>
     <string name="business_followup_people">商机跟进人</string>
     <string name="color_text">颜色</string>
-    <string name="business_number">商机数量</string>
-    <string name="business_Conversion_rate">商机转化率</string>
+    <string name="business_number">数量/金额</string>
+    <string name="business_Conversion_rate">转化率</string>
 
     <string name="business_stage">商机阶段</string>
     <string name="First_communication">初次沟通</string>

+ 1 - 1
app_modular/applogin/src/main/java/com/modular/login/adapter/IndustryAdapter.java

@@ -20,9 +20,9 @@ import java.util.List;
 
 public class IndustryAdapter extends SecondaryListAdapter<IndustryAdapter.GroupItemViewHolder, IndustryAdapter.SubItemViewHolder> {
     private Context mContext;
+    private List<Integer> mFlags;
     private List<SecondaryListBean<String, String>> mDatas;
     private OnSubItemClickListener mOnSubItemClickListener;
-    private List<Integer> mFlags;
 
     public IndustryAdapter(Context context) {
         mContext = context;

+ 1 - 0
app_modular/appme/src/main/java/com/uas/appme/settings/activity/SelectIpActivity.java

@@ -76,6 +76,7 @@ public class SelectIpActivity extends BaseActivity {
             selectBeans.add(new SelectBean("黄信", "http://192.168.253.35:8080/ERP/"));
             selectBeans.add(new SelectBean("刘鹏", "http://192.168.253.243:8080/ERP/"));
             selectBeans.add(new SelectBean("UAS研发系统(测试)", "https://218.17.158.219:9443/uas_dev/"));
+            selectBeans.add(new SelectBean("周鼎文", "http://192.168.253.52:8080/ERP/"));
         }
 
         @Override

+ 2 - 2
app_modular/appme/src/main/res/values-en/strings.xml

@@ -865,8 +865,8 @@
     <string name="business_followup">我的商机</string>
     <string name="business_followup_people">商机跟进人</string>
     <string name="color_text">颜色</string>
-    <string name="business_number">商机数量</string>
-    <string name="business_Conversion_rate">商机转化率</string>
+    <string name="business_number">数量/金额</string>
+    <string name="business_Conversion_rate">转化率</string>
 
     <string name="business_stage">商机阶段</string>
     <string name="First_communication">初次沟通</string>

+ 2 - 2
app_modular/appme/src/main/res/values/strings.xml

@@ -865,8 +865,8 @@
     <string name="business_followup">我的商机</string>
     <string name="business_followup_people">商机跟进人</string>
     <string name="color_text">颜色</string>
-    <string name="business_number">商机数量</string>
-    <string name="business_Conversion_rate">商机转化率</string>
+    <string name="business_number">数量/金额</string>
+    <string name="business_Conversion_rate">转化率</string>
 
     <string name="business_stage">商机阶段</string>
     <string name="First_communication">初次沟通</string>

+ 9 - 1
app_modular/appmessages/src/main/java/com/modular/appmessages/fragment/ApprovalListFragment.java

@@ -229,6 +229,8 @@ public class ApprovalListFragment extends ViewPagerLazyFragment implements OnSma
                     e.setNodeDealMan(JSONUtil.getText(object, "JP_NODEDEALMANNAME"));
                     e.setLauncherCode(JSONUtil.getText(object, "JP_LAUNCHERID"));
                     e.setOperatedDescription(JSONUtil.getText(object, "JN_OPERATEDDESCRIPTION"));
+                    e.setJp_form(JSONUtil.getText(object, "JP_FORM"));
+
                     approvalLists.add(setSubTitle(e));
                 }
             }
@@ -328,7 +330,13 @@ public class ApprovalListFragment extends ViewPagerLazyFragment implements OnSma
                 intent.putExtra("imid", model.getImid());
                 intent.putExtra("title", title);
                 intent.putExtra("type", tabItem);
-                intent.putExtra("master", model.getMaster());
+                String jp_form = model.getJp_form();
+                String master = model.getMaster();
+                if (!TextUtils.isEmpty(jp_form) && !TextUtils.isEmpty(master) && jp_form.contains(master)) {
+                    intent.putExtra("master", model.getMaster());
+                } else {
+                    intent.putExtra("master", CommonUtil.getMaster());
+                }
                 intent.putExtra("nodeid", Integer.valueOf(model.getNodeId()));
                 startActivity(intent);
             }

+ 474 - 5
app_modular/apputils/src/main/java/com/modular/apputils/activity/BillDetailsActivity.java

@@ -1,6 +1,10 @@
 package com.modular.apputils.activity;
 
+import android.app.Activity;
+import android.content.DialogInterface;
 import android.content.Intent;
+import android.net.Uri;
+import android.os.Build;
 import android.os.Bundle;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
@@ -8,28 +12,57 @@ import android.text.TextUtils;
 import android.view.Menu;
 import android.view.MenuItem;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.common.LogUtil;
+import com.common.data.CalendarUtil;
+import com.common.data.JSONUtil;
 import com.common.data.ListUtils;
+import com.common.data.StringUtil;
+import com.common.file.FileUtils;
+import com.common.ui.CameraUtil;
 import com.core.app.Constants;
+import com.core.app.MyApplication;
 import com.core.base.OABaseActivity;
+import com.core.model.SelectBean;
+import com.core.utils.CommonUtil;
+import com.core.utils.ToastUtil;
+import com.core.utils.time.wheel.DateTimePicker;
+import com.core.widget.view.Activity.ImgFileListActivity;
+import com.core.widget.view.Activity.SelectActivity;
 import com.modular.apputils.R;
 import com.modular.apputils.adapter.BillDetailsAdapter;
 import com.modular.apputils.model.BillGroupModel;
 import com.modular.apputils.presenter.BillDetailsPresenter;
 import com.modular.apputils.presenter.imp.IBillDetails;
+import com.modular.apputils.widget.BillUpdatePopup;
 import com.modular.apputils.widget.VeriftyDialog;
 import com.module.recyclerlibrary.ui.refresh.EmptyRecyclerView;
 
+import java.io.File;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
-public class BillDetailsActivity extends OABaseActivity implements IBillDetails {
+public class BillDetailsActivity extends OABaseActivity implements IBillDetails, BillUpdatePopup.OnUpdateSelectListener {
+    public final int REQUESTCODE_C = 0x21;
+    public final int REQUESTCODE_DB_FIND = 0x22;
+    public final int REQUESTCODE_ENCLOSURE = 0x23;
+    public final int REQUESTCODE_C_NET = 0x24;
+    public final int REQUESTCODE_ENCLOSURE_LOW = 0x25;
+    public final int REQUEST_CODE_CAPTURE_PHOTO = 0x26;
+    public final int REQUEST_CODE_SELECT_MORE = 0x27;
 
     protected RecyclerView mRecyclerView;
     protected BillDetailsPresenter mBillDetailsPresenter;
     protected String status;
     protected BillDetailsAdapter mBillDetailsAdapter;
     protected boolean isMe;//是否是自己的单据
-
+    protected BillUpdatePopup mBillUpdatePopup;
+    public int selectPosition = -1;
+    private List<BillGroupModel> mUpdateGroupModels = new ArrayList<>();
 
     public BillDetailsAdapter newBillDetailsAdapter(List<BillGroupModel> groupModels) {
         return new BillDetailsAdapter(ct, groupModels);
@@ -58,8 +91,18 @@ public class BillDetailsActivity extends OABaseActivity implements IBillDetails
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
-        if (isMe && (TextUtils.isEmpty(status) || !status.equals("已审核"))) {
+        /*if (isMe && (TextUtils.isEmpty(status) || !status.equals("已审核"))) {
             getMenuInflater().inflate(R.menu.menu_input_edit, menu);
+        }*/
+
+        if (isMe) {
+            if ("已审核".equals(status) || "已转入".equals(status)) {
+                if (mBillDetailsAdapter != null && !ListUtils.isEmpty(mBillDetailsAdapter.getUpdateBillModels())) {
+                    getMenuInflater().inflate(com.modular.apputils.R.menu.menu_input_update, menu);
+                }
+            } else {
+                getMenuInflater().inflate(com.modular.apputils.R.menu.menu_input_edit, menu);
+            }
         }
         return super.onCreateOptionsMenu(menu);
     }
@@ -79,6 +122,18 @@ public class BillDetailsActivity extends OABaseActivity implements IBillDetails
                             }
                         }
                     });
+        } else if (item.getItemId() == R.id.update) {
+            if (mBillDetailsAdapter != null && !ListUtils.isEmpty(mBillDetailsAdapter.getUpdateBillModels())) {
+                try {
+                    mUpdateGroupModels = CommonUtil.deepCopy(mBillDetailsAdapter.getBillGroupModels());
+                } catch (Exception e) {
+                    mUpdateGroupModels = mBillDetailsAdapter.getBillGroupModels();
+                    e.printStackTrace();
+                }
+                mBillUpdatePopup.setGroupModels(mUpdateGroupModels).showPopupWindow();
+            } else {
+                toast(getString(R.string.no_fields_to_update));
+            }
         }
         return super.onOptionsItemSelected(item);
     }
@@ -88,14 +143,20 @@ public class BillDetailsActivity extends OABaseActivity implements IBillDetails
         EmptyRecyclerView mEmptyRecyclerView = findViewById(R.id.mEmptyRecyclerView);
         mRecyclerView = mEmptyRecyclerView.getRecyclerView();
         mRecyclerView.setLayoutManager(new LinearLayoutManager(ct));
+
+        mBillUpdatePopup = new BillUpdatePopup(mContext, this);
     }
 
 
     @Override
     public void updateStatus(String status) {
-        this.status = status;
-        if (status.equals("已审核")) {
+        if (status == null) {
             supportInvalidateOptionsMenu();
+        } else {
+            this.status = status;
+            if (status.equals("已审核")) {
+                supportInvalidateOptionsMenu();
+            }
         }
     }
 
@@ -131,4 +192,412 @@ public class BillDetailsActivity extends OABaseActivity implements IBillDetails
             }
         }
     }
+
+    @Override
+    public void updateDetail(List<BillGroupModel> mGroupModels) {
+        setAdapter(mGroupModels);
+    }
+
+    @Override
+    public void updateFileOk() {
+        dimssLoading();
+        mBillDetailsPresenter.saveAndSubmit(mBillDetailsAdapter.getBillGroupModels());
+    }
+
+    @Override
+    public void onUpdateSelect(int position, BillGroupModel.BillModel model) {
+        if (TextUtils.isEmpty(model.getType())) {
+            return;
+        }
+        if (!ListUtils.isEmpty(model.getLocalDatas())) {
+            //本地数据不为空的情况下
+            selectByLocal(position, model);
+        } else {
+            //本地数据为空,获取网络数据
+            switch (model.getType()) {
+                case "C"://单项选择
+                    getComboValue(position, model);
+                    break;
+                case "DT"://时间选择
+                    showDateDialog(true, position);
+                    break;
+                case "D"://日期选择
+                case "T"://时间选择
+                    showDateDialog(false, position);
+                    break;
+                case "SF":
+                case "DF":
+                    //DBFind 选择
+                    findBydbFind(model);
+                    break;
+                case "MF":
+                    //多选
+                    findMore(position, model);
+                    break;
+
+            }
+        }
+    }
+
+    @Override
+    public void onUpdateEnclosure(int position, BillGroupModel.BillModel model) {
+        selectPosition = position;
+        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
+            toSelectEnclosure();
+        } else {
+            showSelectPictureDialog(model);
+        }
+    }
+
+    @Override
+    public void onUpdateConfirm(List<BillGroupModel> billGroupModels, List<BillGroupModel.BillModel> updateBillModels) {
+        mUpdateGroupModels = billGroupModels;
+        mBillDetailsPresenter.saveAndSubmit(billGroupModels);
+    }
+
+
+    private void toSelectEnclosure() {
+        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
+        intent.setType("*/*");//无类型限制
+        intent.addCategory(Intent.CATEGORY_OPENABLE);
+        startActivityForResult(intent, REQUESTCODE_ENCLOSURE);
+    }
+
+    private void toSelectEnclosure(BillGroupModel.BillModel model) {
+        Intent intent = new Intent(ct, ImgFileListActivity.class);
+        intent.putExtra("MAX_SIZE", 9);
+        intent.putExtra("CURRENT_SIZE", ListUtils.getSize(model.getLocalDatas()));
+        startActivityForResult(intent, REQUESTCODE_ENCLOSURE_LOW);
+    }
+
+    private void showSelectPictureDialog(final BillGroupModel.BillModel model) {
+        String[] items = new String[]{getString(com.modular.apputils.R.string.c_take_picture), getString(com.modular.apputils.R.string.c_photo_album)};
+        android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(this).setSingleChoiceItems(items, 0,
+                new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        if (which == 0) {
+                            try {
+                                takePhoto();
+                            } catch (Exception e) {
+                                String message = e.getMessage();
+                                if (!StringUtil.isEmpty(message) && message.contains("Permission")) {
+                                    ToastUtil.showToast(ct, com.modular.apputils.R.string.not_system_permission);
+                                }
+                            }
+                        } else {
+                            toSelectEnclosure(model);
+                        }
+                        dialog.dismiss();
+                    }
+                });
+        builder.show();
+    }
+
+    private Uri mNewPhotoUri;
+
+    private void takePhoto() throws Exception {
+        Uri mNewPhotoUri = CameraUtil.getOutputMediaFileUri(mContext, MyApplication.getInstance().mLoginUser.getUserId(), CameraUtil.MEDIA_TYPE_IMAGE);
+        if (mNewPhotoUri != null) {
+            CameraUtil.captureImage((Activity) ct,
+                    mNewPhotoUri,
+                    REQUEST_CODE_CAPTURE_PHOTO);
+        } else {
+            ToastUtil.showToast(this, "uri is null");
+        }
+    }
+
+    private void findMore(int position, BillGroupModel.BillModel model) {
+        HashMap param = new HashMap<>();
+        String[] fields = new String[]{"sa_custname"};
+        BillGroupModel mGroupModel = mBillDetailsAdapter.getBillGroupModel(model.getGroupIndex());
+        boolean isForm = mGroupModel == null || mGroupModel.isForm();
+
+        param.put("caller", mBillDetailsPresenter.getCaller());
+        param.put("page", "1");
+        param.put("which", "form");
+        param.put("condition", "1=1");
+        param.put("pageSize", "1000");
+        param.put("field", model.getField());
+        Bundle bundle = new Bundle();
+        bundle.putSerializable("param", param);
+        Intent intent = new Intent(ct, SelectActivity.class);
+        intent.putExtra("type", 1);
+        intent.putExtra("isSingle", false);
+        intent.putExtra("reid", com.modular.apputils.R.style.OAThemeMeet);
+        intent.putExtras(bundle);
+        intent.putExtra("key", "combdatas");
+        intent.putExtra("showKey", model.getField());
+        intent.putExtra("fields", fields);
+        intent.putExtra("action", "common/dbfind.action");
+        intent.putExtra("title", model.getCaption());
+        intent.putExtra("id", model.getGroupIndex());
+        intent.putExtra("isForm", isForm);
+        startActivityForResult(intent, REQUEST_CODE_SELECT_MORE);
+    }
+
+
+    /**
+     * 选择本地数据选项
+     *
+     * @param position 索引
+     * @param model    点击对象
+     */
+    public void selectByLocal(int position, BillGroupModel.BillModel model) {
+        ArrayList<SelectBean> beans = new ArrayList<>();
+        SelectBean bean;
+        for (BillGroupModel.LocalData localData : model.getLocalDatas()) {
+            bean = new SelectBean();
+            bean.setJson(localData.display);
+            bean.setShowName(localData.value);
+            bean.setName(localData.value);
+            bean.setIndex(position);
+            beans.add(bean);
+        }
+        Intent intent = new Intent(ct, SelectActivity.class);
+        intent.putExtra("type", 2);
+        intent.putParcelableArrayListExtra("data", beans);
+        intent.putExtra("title", model.getCaption());
+        startActivityForResult(intent, REQUESTCODE_C);
+    }
+
+    public void getComboValue(int position, BillGroupModel.BillModel model) {
+        HashMap param = new HashMap<>();
+        param.put("caller", mBillDetailsPresenter.getCaller());
+        param.put("field", model.getField());
+        Bundle bundle = new Bundle();
+        bundle.putSerializable("param", param);
+        Intent intent = new Intent(ct, SelectActivity.class);
+        intent.putExtra("type", 1);
+        intent.putExtra("reid", com.modular.apputils.R.style.OAThemeMeet);
+        intent.putExtras(bundle);
+        intent.putExtra("key", "combdatas");
+        intent.putExtra("showKey", "DISPLAY");
+        intent.putExtra("action", "mobile/common/getComboValue.action");
+        intent.putExtra("title", model.getCaption());
+        intent.putExtra("id", position);//需要把zum
+        startActivityForResult(intent, REQUESTCODE_C_NET);
+    }
+
+    /**
+     * 选择日期
+     */
+    public void showDateDialog(final boolean needTime, final int position) {
+        DateTimePicker picker = new DateTimePicker(this, needTime ? DateTimePicker.HOUR_OF_DAY : DateTimePicker.YEAR_MONTH_DAY);
+        picker.setRange(CalendarUtil.getYear() - 100, CalendarUtil.getYear() + 20);
+        if (needTime) {
+            picker.setSelectedItem(CalendarUtil.getYear(), CalendarUtil.getMonth(), CalendarUtil.getDay(), CalendarUtil.getHour(), CalendarUtil.getMinute());
+        } else {
+            picker.setSelectedItem(CalendarUtil.getYear(), CalendarUtil.getMonth(), CalendarUtil.getDay());
+        }
+        picker.setOnDateTimePickListener(new DateTimePicker.OnYearMonthDayTimePickListener() {
+            @Override
+            public void onDateTimePicked(String year, String month, String day, String hour, String minute) {
+                String date = year + "-" + month + "-" + day;
+                String dateTime = date + " " + hour + ":" + minute + ":00";
+                mBillUpdatePopup.updateBillModelValues(position, needTime ? dateTime : date, needTime ? dateTime : date);
+            }
+        });
+        picker.setOnCancelListener(new DateTimePicker.OnCancelListener() {
+            @Override
+            public void onCancel() {
+                mBillUpdatePopup.updateBillModelValues(position, "", "");
+            }
+        });
+        picker.show();
+    }
+
+    /**
+     * dbfind 查找
+     *
+     * @param model
+     */
+    public void findBydbFind(BillGroupModel.BillModel model) {
+        String gridCaller = "";
+        String fieldKey = model.getField();
+        BillGroupModel mGroupModel = mBillDetailsAdapter.getBillGroupModel(model.getGroupIndex());
+        boolean isForm = mGroupModel == null || mGroupModel.isForm();
+        if (!isForm && !StringUtil.isEmpty(model.getFindFunctionName())) {
+            String[] mFindFunctionNames = model.getFindFunctionName().split("\\|");
+            if (mFindFunctionNames != null && mFindFunctionNames.length > 1) {
+                gridCaller = mFindFunctionNames[0];
+//                fieldKey = mFindFunctionNames[1];
+            }
+        }
+        String mCondition = "";
+        /*if (dbFindCondition != null && dbFindCondition.containsKey(fieldKey)) {
+            mCondition = dbFindCondition.get(fieldKey);
+        }*/
+        startActivityForResult(new Intent(ct, SelectNetAcitivty.class)
+                        .putExtra("fieldKey", fieldKey)
+                        .putExtra("caller", mGroupModel == null ? mBillDetailsPresenter.getCaller()
+                                : mGroupModel.getBillCaller())
+                        .putExtra("gCaller", gridCaller)
+                        .putExtra("mCondition", mCondition)
+                        .putExtra("isDevice", false)
+                        .putExtra("isForm", isForm)
+                        .putExtra("groupId", model.getGroupIndex())
+                , REQUESTCODE_DB_FIND);
+    }
+
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        if (data == null) return;
+        switch (requestCode) {
+            case REQUEST_CODE_SELECT_MORE:
+                if (resultCode == 0x21) {//多选框
+                    int groupIndex = data.getIntExtra("id", 0);
+                    boolean isForm = data.getBooleanExtra("isForm", true);
+                    ArrayList<SelectBean> muliData = data.getParcelableArrayListExtra("data");
+                    JSONObject object = null;
+                    if (!ListUtils.isEmpty(muliData)) {
+                        object = JSON.parseObject(muliData.get(0).getJson());
+                        String dbFind = muliData.get(0).getDbfinds();
+                        for (int i = 1; i < muliData.size(); i++) {
+                            SelectBean b = muliData.get(i);
+                            JSONObject bObject = JSON.parseObject(b.getJson());
+                            for (Map.Entry<String, Object> entry : bObject.entrySet()) {
+                                String oldText = object.getString(entry.getKey());
+                                object.put(entry.getKey(), oldText + "#" + entry.getValue());
+                            }
+                        }
+                        if (!TextUtils.isEmpty(dbFind)) {
+                            JSONArray fbFindArray = JSON.parseArray(dbFind);
+                            if (!ListUtils.isEmpty(fbFindArray)) {
+                                for (int i = 0; i < fbFindArray.size(); i++) {
+                                    String dbGridField = JSONUtil.getText(fbFindArray.getJSONObject(i), "dbGridField");
+                                    String field = JSONUtil.getText(fbFindArray.getJSONObject(i), "field");
+                                    if (object.containsKey(dbGridField)) {
+                                        object.put(field, object.get(dbGridField));
+                                        object.remove(dbGridField);
+                                    }
+                                }
+                            }
+                        }
+                    }
+//                    mBillAdapter.updateBillModelValues(id, values, values);
+                    LogUtil.i("gong", "object=" + object);
+                    LogUtil.i("gong", "groupIndex=" + groupIndex);
+                    handlerSelectDbFind(object, groupIndex, isForm);
+                }
+                break;
+            case REQUESTCODE_C_NET:
+                SelectBean mSelectBeanC = data.getParcelableExtra("data");
+                int position = data.getIntExtra("id", -1);
+                if (mSelectBeanC != null && position >= 0) {
+                    String display = StringUtil.isEmpty(mSelectBeanC.getName()) ? "" : mSelectBeanC.getName();
+                    String value = StringUtil.isEmpty(mSelectBeanC.getName()) ? "" : mSelectBeanC.getName();
+                    mBillUpdatePopup.updateBillModelValues(position, value, display);
+                }
+                break;
+            case REQUESTCODE_C:
+                mSelectBeanC = data.getParcelableExtra("data");
+                if (mSelectBeanC != null) {
+                    position = mSelectBeanC.getIndex();
+                    String value = StringUtil.isEmpty(mSelectBeanC.getShowName()) ? "" : mSelectBeanC.getShowName();
+                    String display = StringUtil.isEmpty(mSelectBeanC.getJson()) ? "" : mSelectBeanC.getJson();
+                    mBillUpdatePopup.updateBillModelValues(position, value, display);
+                }
+                break;
+            case REQUESTCODE_DB_FIND:
+                String json = data.getStringExtra("data");
+                int groupIndex = data.getIntExtra("groupId", 0);
+                boolean isForm = data.getBooleanExtra("isForm", true);
+                handlerSelectDbFind(JSON.parseObject(json), groupIndex, isForm);
+                break;
+            case REQUESTCODE_ENCLOSURE:
+                if (resultCode == Activity.RESULT_OK) {
+                    String path;
+                    Uri uri = data.getData();
+                    if ("file".equalsIgnoreCase(uri.getScheme())) {//使用第三方应用打开
+                        path = uri.getPath();
+                    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {//4.4以后
+                        path = FileUtils.getPath(this, uri);
+                    } else {//4.4以下下系统调用方法
+                        path = FileUtils.getRealPathFromURI(this, uri);
+                    }
+                    LogUtil.i("gong", "uri=" + uri.toString());
+                    File file = null;
+                    if (!TextUtils.isEmpty(path)) {
+                        file = new File(path);
+                    }
+                    if (file != null && file.exists() && file.isFile()) {
+                        String value = file.getName();
+                        String display = path;
+                        mBillUpdatePopup.getBillUpdateAdapter().addBillModelData(selectPosition, value, display);
+                        selectPosition = -1;
+                    }
+
+                }
+            case REQUEST_CODE_CAPTURE_PHOTO:
+                if (resultCode == Activity.RESULT_OK) {
+                    if (mNewPhotoUri != null) {
+                        String value = mNewPhotoUri.getPath();
+                        String display = value;
+                        mBillUpdatePopup.getBillUpdateAdapter().addBillModelData(selectPosition, value, display);
+                        selectPosition = -1;
+                    } else {
+                        ToastUtil.showToast(this, com.modular.apputils.R.string.c_take_picture_failed);
+                    }
+                }
+                break;
+            case REQUESTCODE_ENCLOSURE_LOW:
+                List<String> filePaths = data.getStringArrayListExtra("files");
+                if (!ListUtils.isEmpty(filePaths)) {
+                    File file = null;
+                    List<BillGroupModel.LocalData> localDatas = new ArrayList<>();
+                    for (String filePath : filePaths) {
+                        if (!TextUtils.isEmpty(filePath)) {
+                            file = new File(filePath);
+                        }
+                        if (file != null && file.exists() && file.isFile()) {
+                            BillGroupModel.LocalData localData = new BillGroupModel.LocalData();
+                            localData.value = file.getName();
+                            localData.display = filePath;
+                            localDatas.add(localData);
+                        }
+                    }
+                    mBillUpdatePopup.getBillUpdateAdapter().addBillModelData(selectPosition, localDatas);
+                    selectPosition = -1;
+                }
+                break;
+        }
+    }
+
+    protected void handlerSelectDbFind(JSONObject object, int groupId, boolean isForm) {
+        if (isForm) {
+            List<BillGroupModel.BillModel> formBillModels = mBillUpdatePopup.getBillUpdateAdapter().getFormBillModels();
+
+            if (!ListUtils.isEmpty(formBillModels)) {
+                for (BillGroupModel.BillModel billModel : formBillModels) {
+                    if (object.containsKey(billModel.getField())) {
+                        billModel.setValue(JSONUtil.getText(object, billModel.getField()));
+                    }
+                }
+            }
+        } else {
+            BillGroupModel mBillGroupModel = mBillUpdatePopup.getBillUpdateAdapter().getBillGroupModel(groupId);
+            if (mBillGroupModel != null) {
+                if (!ListUtils.isEmpty(mBillGroupModel.getShowBillFields())) {
+                    for (BillGroupModel.BillModel e : mBillGroupModel.getShowBillFields()) {
+                        if (object.containsKey(e.getField())) {
+                            e.setValue(JSONUtil.getText(object, e.getField()));
+                        }
+                    }
+                }
+                if (!ListUtils.isEmpty(mBillGroupModel.getHideBillFields())) {
+                    for (BillGroupModel.BillModel e : mBillGroupModel.getHideBillFields()) {
+                        if (object.containsKey(e.getField())) {
+                            e.setValue(JSONUtil.getText(object, e.getField()));
+                        }
+                    }
+                }
+            }
+        }
+
+        mBillUpdatePopup.getBillUpdateAdapter().notifyDataSetChanged();
+    }
+
 }

+ 11 - 2
app_modular/apputils/src/main/java/com/modular/apputils/activity/BillInputActivity.java

@@ -383,6 +383,10 @@ public class BillInputActivity extends OABaseActivity implements IBill, BillAdap
      * @param model
      */
     public void findBydbFind(BillGroupModel.BillModel model) {
+        findBydbFind(model, "");
+    }
+
+    public void findBydbFind(BillGroupModel.BillModel model, String condition) {
         String gridCaller = "";
         String fieldKey = model.getField();
         BillGroupModel mGroupModel = mBillAdapter.getBillGroupModel(model.getGroupIndex());
@@ -395,9 +399,14 @@ public class BillInputActivity extends OABaseActivity implements IBill, BillAdap
             }
         }
         String mCondition = "";
-        if (dbFindCondition != null && dbFindCondition.containsKey(fieldKey)) {
-            mCondition = dbFindCondition.get(fieldKey);
+        if (TextUtils.isEmpty(condition)) {
+            if (dbFindCondition != null && dbFindCondition.containsKey(fieldKey)) {
+                mCondition = dbFindCondition.get(fieldKey);
+            }
+        } else {
+            mCondition = condition;
         }
+
         startActivityForResult(new Intent(ct, SelectNetAcitivty.class)
                         .putExtra("fieldKey", fieldKey)
                         .putExtra("caller", mGroupModel == null ? mBillPresenter.getFormCaller()

+ 1 - 0
app_modular/apputils/src/main/java/com/modular/apputils/activity/SimpleWebActivity.java

@@ -65,6 +65,7 @@ public class SimpleWebActivity extends OABaseActivity implements ReaderCallback
         webView.getSettings().setDatabaseEnabled(true);
         webView.getSettings().setAppCacheEnabled(true);
         webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
+        webView.getSettings().setTextZoom(100);
 
         Intent intent = getIntent();
         String url = intent.getStringExtra("url");

+ 28 - 1
app_modular/apputils/src/main/java/com/modular/apputils/adapter/BillAdapter.java

@@ -44,6 +44,8 @@ public class BillAdapter extends RecyclerView.Adapter<BillAdapter.BaseViewHolder
     protected List<BillGroupModel.BillModel> mFormBillModels;
     //可更新的字段列表
     protected List<BillGroupModel.BillModel> mUpdateBillModels;
+    //所有字段列表
+    protected List<BillGroupModel.BillModel> mAllBillModels;
     protected OnAdapterListener mOnAdapterListener;
     protected int mTabIndex = -1;
     private int mTabPosition = 0;
@@ -56,6 +58,12 @@ public class BillAdapter extends RecyclerView.Adapter<BillAdapter.BaseViewHolder
         changeBillModel();
     }
 
+    public BillAdapter(List<BillGroupModel.BillModel> showBillModels, Context ct, OnAdapterListener mOnAdapterListener) {
+        this.ct = ct;
+        this.mShowBillModels = showBillModels;
+        this.mOnAdapterListener = mOnAdapterListener;
+    }
+
     public void updateBillModelValues(int position, String values, String display) {
         if (position >= 0 && position < ListUtils.getSize(mShowBillModels)) {
             mShowBillModels.get(position).setValue(values);
@@ -92,6 +100,14 @@ public class BillAdapter extends RecyclerView.Adapter<BillAdapter.BaseViewHolder
         changeBillModel();
     }
 
+    public void setShowBillModels(List<BillGroupModel.BillModel> showBillModels) {
+        this.mShowBillModels = showBillModels;
+    }
+
+    public List<BillGroupModel.BillModel> getmAllBillModels() {
+        return mAllBillModels;
+    }
+
     /**
      * 当外界的因素引起mBillGroupModels变化时候,通过遍历将mBillGroupModels转成mShowBillModels进行显示
      */
@@ -111,6 +127,11 @@ public class BillAdapter extends RecyclerView.Adapter<BillAdapter.BaseViewHolder
         } else {
             mUpdateBillModels.clear();
         }
+        if (mAllBillModels == null) {
+            mAllBillModels = new ArrayList<>();
+        } else {
+            mAllBillModels.clear();
+        }
 
         for (int i = 0; i < mBillGroupModels.size(); i++) {
             BillGroupModel e = mBillGroupModels.get(i);
@@ -152,6 +173,12 @@ public class BillAdapter extends RecyclerView.Adapter<BillAdapter.BaseViewHolder
                         mFormBillModels.addAll(e.getHideBillFields());
                     }
                 }
+                if (e.getShowBillFields() != null && !e.getShowBillFields().isEmpty()) {
+                    mAllBillModels.addAll(e.getShowBillFields());
+                }
+                if (e.getHideBillFields() != null && !e.getHideBillFields().isEmpty()) {
+                    mAllBillModels.addAll(e.getHideBillFields());
+                }
             }
         }
     }
@@ -431,7 +458,7 @@ public class BillAdapter extends RecyclerView.Adapter<BillAdapter.BaseViewHolder
             if (model.getType().equals("N")) {
                 mInputViewHolder.valuesEd.setInputType(InputType.TYPE_CLASS_NUMBER);
             } else {
-                mInputViewHolder.valuesEd.setInputType(InputType.TYPE_CLASS_TEXT);
+                mInputViewHolder.valuesEd.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_CLASS_TEXT);
             }
             if (model.getReadOnly().equals("T")) {
                 mInputViewHolder.valuesEd.setFocusable(false);

+ 28 - 0
app_modular/apputils/src/main/java/com/modular/apputils/adapter/BillDetailsAdapter.java

@@ -42,6 +42,7 @@ public class BillDetailsAdapter extends RecyclerView.Adapter<BillDetailsAdapter.
     private Context ct;
     private List<BillGroupModel> mBillGroupModels;
     private List<BillGroupModel.BillModel> mShowBillModels;
+    private List<BillGroupModel.BillModel> mUpdateBillModels;
     protected int mTabIndex = -1;
     private int mTabPosition;
     private List<BillGroupModel> mOldTabModels;
@@ -57,10 +58,27 @@ public class BillDetailsAdapter extends RecyclerView.Adapter<BillDetailsAdapter.
         changeBillModel();
     }
 
+    public BillGroupModel getBillGroupModel(int groupIndex) {
+        if (ListUtils.isEmpty(mBillGroupModels)) {
+            return null;
+        } else {
+            for (BillGroupModel billGroupModel : mBillGroupModels) {
+                if (billGroupModel.getGroupIndex() == groupIndex) {
+                    return billGroupModel;
+                }
+            }
+            return null;
+        }
+    }
+
     public List<BillGroupModel.BillModel> getShowBillModels() {
         return mShowBillModels;
     }
 
+    public List<BillGroupModel.BillModel> getUpdateBillModels() {
+        return mUpdateBillModels;
+    }
+
     public List<BillGroupModel> getBillGroupModels() {
         return mBillGroupModels;
     }
@@ -74,6 +92,12 @@ public class BillDetailsAdapter extends RecyclerView.Adapter<BillDetailsAdapter.
         } else {
             mShowBillModels.clear();
         }
+        if (mUpdateBillModels == null) {
+            mUpdateBillModels = new ArrayList<>();
+        } else {
+            mUpdateBillModels.clear();
+        }
+
         for (int i = 0; i < mBillGroupModels.size(); i++) {
             BillGroupModel e = mBillGroupModels.get(i);
             if (e != null) {
@@ -94,6 +118,10 @@ public class BillDetailsAdapter extends RecyclerView.Adapter<BillDetailsAdapter.
                         mShowBillModels.add(mTitleBillModel);
                     }
                     mShowBillModels.addAll(e.getShowBillFields());
+
+                    if (e.getUpdateBillFields() != null && !e.getUpdateBillFields().isEmpty()) {
+                        mUpdateBillModels.addAll(e.getUpdateBillFields());
+                    }
                 }
             }
         }

+ 715 - 0
app_modular/apputils/src/main/java/com/modular/apputils/adapter/BillUpdateAdapter.java

@@ -0,0 +1,715 @@
+package com.modular.apputils.adapter;
+
+import android.content.Context;
+import android.support.annotation.LayoutRes;
+import android.support.annotation.NonNull;
+import android.support.design.widget.TabLayout;
+import android.support.v7.widget.RecyclerView;
+import android.text.Editable;
+import android.text.InputType;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.common.LogUtil;
+import com.common.data.ListUtils;
+import com.core.widget.listener.EditChangeListener;
+import com.core.widget.view.MyGridView;
+import com.me.imageloader.ImageLoaderUtil;
+import com.modular.apputils.R;
+import com.modular.apputils.model.BillGroupModel;
+import com.modular.apputils.utils.BillTypeChangeUtils;
+import com.modular.apputils.widget.VeriftyDialog;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 可更新字段弹框适配器
+ */
+public class BillUpdateAdapter extends RecyclerView.Adapter<BillUpdateAdapter.BaseViewHolder> implements View.OnClickListener {
+
+    public Context ct;
+    protected List<BillGroupModel> mBillGroupModels;
+    protected List<BillGroupModel.BillModel> mShowBillModels;
+    //主表的字段列表
+    protected List<BillGroupModel.BillModel> mFormBillModels;
+    //可更新的字段列表
+    protected List<BillGroupModel.BillModel> mUpdateBillModels;
+    protected OnAdapterListener mOnAdapterListener;
+
+    public BillUpdateAdapter(Context ct, List<BillGroupModel> mBillGroupModels, OnAdapterListener mOnAdapterListener) {
+        this.ct = ct;
+        this.mBillGroupModels = mBillGroupModels;
+        this.mOnAdapterListener = mOnAdapterListener;
+        changeBillModel();
+    }
+
+    public void updateBillModelValues(int position, String values, String display) {
+        if (position >= 0 && position < ListUtils.getSize(mUpdateBillModels)) {
+            mUpdateBillModels.get(position).setValue(values);
+            mUpdateBillModels.get(position).setDisplay(display);
+            notifyItemChanged(position);
+        }
+    }
+
+    public void addBillModelData(int position, String values, String display) {
+        if (position >= 0 && position < ListUtils.getSize(mUpdateBillModels)) {
+            if (mUpdateBillModels.get(position).getLocalDatas() == null) {
+                mUpdateBillModels.get(position).setLocalDatas(new ArrayList<BillGroupModel.LocalData>());
+            }
+            BillGroupModel.LocalData data = new BillGroupModel.LocalData();
+            data.value = values;
+            data.display = display;
+            mUpdateBillModels.get(position).getLocalDatas().add(data);
+            notifyItemChanged(position);
+        }
+    }
+
+    public void addBillModelData(int position, List<BillGroupModel.LocalData> datas) {
+        if (position >= 0 && position < ListUtils.getSize(mUpdateBillModels)) {
+            if (mUpdateBillModels.get(position).getLocalDatas() == null) {
+                mUpdateBillModels.get(position).setLocalDatas(new ArrayList<BillGroupModel.LocalData>());
+            }
+            mUpdateBillModels.get(position).getLocalDatas().addAll(datas);
+            notifyItemChanged(position);
+        }
+    }
+
+    public void setBillGroupModels(List<BillGroupModel> mBillGroupModels) {
+        this.mBillGroupModels = mBillGroupModels;
+        changeBillModel();
+    }
+
+    public List<BillGroupModel.BillModel> getUpdateBillModels() {
+        return mUpdateBillModels;
+    }
+
+    /**
+     * 当外界的因素引起mBillGroupModels变化时候,通过遍历将mBillGroupModels转成mUpdateBillModels进行显示
+     */
+    private void changeBillModel() {
+        if (mShowBillModels == null) {
+            mShowBillModels = new ArrayList<>();
+        } else {
+            mShowBillModels.clear();
+        }
+        if (mFormBillModels == null) {
+            mFormBillModels = new ArrayList<>();
+        } else {
+            mFormBillModels.clear();
+        }
+        if (mUpdateBillModels == null) {
+            mUpdateBillModels = new ArrayList<>();
+        } else {
+            mUpdateBillModels.clear();
+        }
+
+        for (int i = 0; i < mBillGroupModels.size(); i++) {
+            BillGroupModel e = mBillGroupModels.get(i);
+            if (e != null) {
+                List<BillGroupModel.GridTab> gridTabs = e.getGridTabs();
+                if (gridTabs != null && gridTabs.size() > 0) {
+                    BillGroupModel.BillModel mTabBillModel = new BillGroupModel.BillModel();
+                    mTabBillModel.setType(BillGroupModel.Constants.TYPE_TAB);
+                    mTabBillModel.setTabList(gridTabs);
+                    mTabBillModel.setGroupIndex(i);
+                    mShowBillModels.add(mTabBillModel);
+                } else {
+                    if (e.getShowBillFields() != null && !e.getShowBillFields().isEmpty()) {
+                        if (!TextUtils.isEmpty(e.getGroup())) {
+                            BillGroupModel.BillModel mTitleBillModel = new BillGroupModel.BillModel();
+                            mTitleBillModel.setGroupIndex(i);
+                            mTitleBillModel.setType(BillGroupModel.Constants.TYPE_TITLE);
+                            mTitleBillModel.setCaption(e.getGroup());
+                            mTitleBillModel.setAllowBlank(e.isDeleteAble() ? "T" : "F");
+                            mShowBillModels.add(mTitleBillModel);
+                        }
+                        mShowBillModels.addAll(e.getShowBillFields());
+
+                        if (!e.isForm() && e.isLastInType()) {
+                            mShowBillModels.add(getAddModel(i));
+                        }
+                    }
+
+                    if (e.getUpdateBillFields() != null && !e.getUpdateBillFields().isEmpty()) {
+                        mUpdateBillModels.addAll(e.getUpdateBillFields());
+                    }
+                }
+
+                if (e.isForm()) {
+                    if (e.getShowBillFields() != null) {
+                        mFormBillModels.addAll(e.getShowBillFields());
+                    }
+                    if (e.getHideBillFields() != null) {
+                        mFormBillModels.addAll(e.getHideBillFields());
+                    }
+                }
+            }
+        }
+    }
+
+    private BillGroupModel.BillModel getAddModel(int index) {
+        BillGroupModel.BillModel mTitleBillModel = new BillGroupModel.BillModel();
+        mTitleBillModel.setGroupIndex(index);
+        mTitleBillModel.setType(BillGroupModel.Constants.TYPE_ADD);
+        mTitleBillModel.setCaption("添加单据");
+        return mTitleBillModel;
+    }
+
+    public List<BillGroupModel> getBillGroupModels() {
+        return mBillGroupModels;
+    }
+
+    public BillGroupModel getBillGroupModel(int groupIndex) {
+        if (ListUtils.isEmpty(mBillGroupModels)) {
+            return null;
+        } else {
+            for (BillGroupModel billGroupModel : mBillGroupModels) {
+                if (billGroupModel.getGroupIndex() == groupIndex) {
+                    return billGroupModel;
+                }
+            }
+            return null;
+        }
+    }
+
+    public List<BillGroupModel.BillModel> getFormBillModels() {
+        return mFormBillModels;
+    }
+
+    public List<BillGroupModel.BillModel> getShowBillModels() {
+        return mShowBillModels;
+    }
+
+    @Override
+    public int getItemViewType(int position) {
+        if (mUpdateBillModels != null && mUpdateBillModels.size() > position) {
+            int itemViewType = BillTypeChangeUtils.getItemViewType(mUpdateBillModels.get(position).getType());
+            return itemViewType;
+        }
+        return super.getItemViewType(position);
+    }
+
+    @NonNull
+    @Override
+    public BaseViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+        BaseViewHolder viewHolder = null;
+        switch (viewType) {
+            case 0:
+                viewHolder = new TitleViewHolder(parent, R.layout.item_bill_title);
+                break;
+            case 1:
+                viewHolder = new InputViewHolder(parent, R.layout.item_bill_input_select);
+                break;
+            case 2:
+                viewHolder = new EnclosureViewHolder(parent, R.layout.item_bill_enclosure);
+                break;//附件类型
+            case 110:
+                viewHolder = new AddViewHolder(parent, R.layout.item_bill_add);
+                break;
+            case 111:
+                viewHolder = new TabViewHolder(parent, R.layout.item_bill_tab);
+                break;
+            default:
+                viewHolder = new BaseViewHolder(parent, R.layout.item_bill_title) {
+                    @Override
+                    public void initView(View view) {
+
+                    }
+                };
+        }
+        return viewHolder;
+    }
+
+
+    @Override
+    public int getItemCount() {
+        return mUpdateBillModels == null ? 0 : mUpdateBillModels.size();
+    }
+
+
+    private LayoutInflater mLayoutInflater;
+
+    public LayoutInflater getLayoutInflater() {
+        if (mLayoutInflater == null) {
+            mLayoutInflater = LayoutInflater.from(ct);
+        }
+        return mLayoutInflater;
+    }
+
+
+    public abstract class BaseViewHolder extends RecyclerView.ViewHolder {
+
+        public BaseViewHolder(ViewGroup parent, @LayoutRes int layoutId) {
+            this(getLayoutInflater().inflate(layoutId, parent, false));
+        }
+
+        public abstract void initView(View view);
+
+        public BaseViewHolder(View itemView) {
+            super(itemView);
+            initView(itemView);
+        }
+    }
+
+    public class AddViewHolder extends BaseViewHolder {
+        private TextView addTv;
+
+        public AddViewHolder(ViewGroup parent, int layoutId) {
+            super(parent, layoutId);
+        }
+
+        @Override
+        public void initView(View view) {
+            addTv = (TextView) view.findViewById(R.id.addTv);
+        }
+    }
+
+    //选择和输入类型
+    public class InputViewHolder extends BaseViewHolder {
+        public TextView captionTv;
+        public TextView muchInputTv;
+        public ImageView selectIv;
+        public EditText valuesEd;
+
+        public InputViewHolder(ViewGroup parent, int layoutId) {
+            super(parent, layoutId);
+        }
+
+        @Override
+        public void initView(View itemView) {
+            captionTv = (TextView) itemView.findViewById(R.id.captionTv);
+            muchInputTv = (TextView) itemView.findViewById(R.id.muchInputTv);
+            selectIv = (ImageView) itemView.findViewById(R.id.selectIv);
+            valuesEd = (EditText) itemView.findViewById(R.id.valuesEd);
+        }
+    }
+
+    //附件类型
+    class EnclosureViewHolder extends BaseViewHolder {
+        private TextView captionTv;
+        private TextView muchInputTv;
+        private MyGridView ffGv;
+
+        public EnclosureViewHolder(ViewGroup parent, int layoutId) {
+            super(parent, layoutId);
+        }
+
+        @Override
+        public void initView(View itemView) {
+            captionTv = (TextView) itemView.findViewById(R.id.captionTv);
+            muchInputTv = (TextView) itemView.findViewById(R.id.muchInputTv);
+            ffGv = (MyGridView) itemView.findViewById(R.id.ffGv);
+        }
+    }
+
+    class TitleViewHolder extends BaseViewHolder {
+        private TextView tvTitle;
+        private TextView deleteTv;
+
+        public TitleViewHolder(ViewGroup parent, int layoutId) {
+            super(parent, layoutId);
+        }
+
+        @Override
+        public void initView(View view) {
+            tvTitle = (TextView) view.findViewById(R.id.tv_title);
+            deleteTv = (TextView) view.findViewById(R.id.deleteTv);
+        }
+
+    }
+
+    class TabViewHolder extends BaseViewHolder {
+        TabLayout mTabLayout;
+
+        public TabViewHolder(ViewGroup parent, int layoutId) {
+            super(parent, layoutId);
+        }
+
+        @Override
+        public void initView(View view) {
+            mTabLayout = (TabLayout) view.findViewById(R.id.bill_tab_tl);
+            mTabLayout.setTabMode(TabLayout.MODE_FIXED);
+            /*final List<BillGroupModel.GridTab> tabList = mShowBillModels.get(mTabIndex).getTabList();
+            if (tabList != null && tabList.size() > 0) {
+                for (int i = 0; i < tabList.size(); i++) {
+                    BillGroupModel.GridTab gridTab = tabList.get(i);
+                    if (gridTab != null) {
+                        mTabLayout.addTab(mTabLayout.newTab().setText(gridTab.getTitle()));
+                    }
+                }
+            }*/
+        }
+
+    }
+
+
+    @Override
+    public void onBindViewHolder(@NonNull BaseViewHolder holder, int position) {
+        BillGroupModel.BillModel model = null;
+        if (mUpdateBillModels != null && mUpdateBillModels.size() > position) {
+            model = mUpdateBillModels.get(position);
+        }
+        try {
+            if (holder instanceof InputViewHolder) {
+                bindInputView((InputViewHolder) holder, model, position);
+            } else if (holder instanceof TitleViewHolder) {
+                bindTitleView((TitleViewHolder) holder, model, position);
+            } else if (holder instanceof AddViewHolder) {
+                bindAddView((AddViewHolder) holder, model, position);
+            } else if (holder instanceof EnclosureViewHolder) {
+                bindEnclosureView((EnclosureViewHolder) holder, model, position);
+            } else if (holder instanceof TabViewHolder) {
+                bindTabView((TabViewHolder) holder, model, position);
+            }
+        } catch (Exception e) {
+            LogUtil.i("gong", position + "  e=" + e.getMessage());
+        }
+
+    }
+
+    private void bindTabView(TabViewHolder holder, final BillGroupModel.BillModel model, final int position) {
+        if (holder.mTabLayout.getTag() != null && holder.mTabLayout.getTag() instanceof MyTabChangeListener) {
+            holder.mTabLayout.removeOnTabSelectedListener((TabLayout.OnTabSelectedListener) holder.mTabLayout.getTag());
+        }
+        MyTabChangeListener myTabChangeListener = new MyTabChangeListener(holder.mTabLayout, position);
+        holder.mTabLayout.addOnTabSelectedListener(myTabChangeListener);
+        holder.mTabLayout.setTag(myTabChangeListener);
+    }
+
+    //绑定附件字段
+    private void bindEnclosureView(EnclosureViewHolder holder, BillGroupModel.BillModel model, int position) {
+        if (model != null) {
+            holder.captionTv.setText(model.getCaption());
+            holder.muchInputTv.setVisibility(model.getAllowBlank().equals("F") ? View.VISIBLE : View.GONE);
+            EnclosureAdapter mEnclosureAdapter = null;
+            if (holder.ffGv.getTag(R.id.tag_key) != null && holder.ffGv.getTag(R.id.tag_key) instanceof EnclosureAdapter) {
+                mEnclosureAdapter = (EnclosureAdapter) holder.ffGv.getTag(R.id.tag_key);
+                mEnclosureAdapter.setLocalDatas(model.getLocalDatas());
+                mEnclosureAdapter.setPosition(position);
+            } else {
+                mEnclosureAdapter = new EnclosureAdapter(position, model.getLocalDatas());
+            }
+            holder.ffGv.setAdapter(mEnclosureAdapter);
+            holder.ffGv.setTag(model);
+            holder.ffGv.setTag(R.id.tag_key2, position);
+        }
+    }
+
+
+    private void bindAddView(AddViewHolder mAddViewHolder, BillGroupModel.BillModel model, int position) throws Exception {
+        if (model != null) {
+            mAddViewHolder.addTv.setTag(model.getGroupIndex());
+            mAddViewHolder.addTv.setOnClickListener(this);
+        }
+    }
+
+    public void bindInputView(InputViewHolder mInputViewHolder, BillGroupModel.BillModel model, int position) throws Exception {
+        if (model != null) {
+            if (mInputViewHolder.valuesEd.getTag() != null && mInputViewHolder.valuesEd.getTag() instanceof TextChangListener) {
+                mInputViewHolder.valuesEd.removeTextChangedListener((TextChangListener) mInputViewHolder.valuesEd.getTag());
+            }
+            mInputViewHolder.captionTv.setText(model.getCaption());
+            mInputViewHolder.muchInputTv.setVisibility(model.getAllowBlank().equals("F") ? View.VISIBLE : View.GONE);
+            mInputViewHolder.valuesEd.setText(model.getValue());
+            if (model.getType().equals("N")) {
+                mInputViewHolder.valuesEd.setInputType(InputType.TYPE_CLASS_NUMBER);
+            } else {
+                mInputViewHolder.valuesEd.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_CLASS_TEXT);
+            }
+            if (model.getReadOnly().equals("T")) {
+                mInputViewHolder.valuesEd.setFocusable(false);
+                mInputViewHolder.valuesEd.setClickable(true);
+                mInputViewHolder.valuesEd.setOnClickListener(null);
+                if (BillTypeChangeUtils.isSelect(model.getType())) {
+                    mInputViewHolder.valuesEd.setHint("请选择");
+                    mInputViewHolder.selectIv.setVisibility(View.VISIBLE);
+                } else {
+                    mInputViewHolder.valuesEd.setHint("请输入");
+                    mInputViewHolder.selectIv.setVisibility(View.GONE);
+                }
+            } else if (BillTypeChangeUtils.isSelect(model.getType())) {
+                //选择类型
+                mInputViewHolder.valuesEd.setHint("请选择");
+                mInputViewHolder.valuesEd.setFocusable(false);
+                mInputViewHolder.valuesEd.setClickable(true);
+                mInputViewHolder.selectIv.setVisibility(View.VISIBLE);
+                mInputViewHolder.valuesEd.setTag(R.id.tag, position);
+                mInputViewHolder.valuesEd.setTag(R.id.tag2, model);
+                mInputViewHolder.valuesEd.setOnClickListener(this);
+            } else {
+                //输入类型
+                mInputViewHolder.valuesEd.setHint("请输入");
+                mInputViewHolder.selectIv.setVisibility(View.GONE);
+                mInputViewHolder.valuesEd.setFocusable(true);
+                mInputViewHolder.valuesEd.setClickable(false);
+                mInputViewHolder.valuesEd.setFocusableInTouchMode(true);
+                TextChangListener mTextChangListener = new TextChangListener(mInputViewHolder.valuesEd, position);
+                mInputViewHolder.valuesEd.setTag(mTextChangListener);
+                mInputViewHolder.valuesEd.addTextChangedListener(mTextChangListener);
+                mInputViewHolder.valuesEd.setOnClickListener(null);
+            }
+
+        }
+    }
+
+    public void bindTitleView(TitleViewHolder mTitleViewHolder, BillGroupModel.BillModel model, int position) throws Exception {
+        if (model != null) {
+            if (model.getAllowBlank().equals("F")) {
+                mTitleViewHolder.deleteTv.setVisibility(View.GONE);
+                mTitleViewHolder.deleteTv.setOnClickListener(null);
+            } else {
+                mTitleViewHolder.deleteTv.setVisibility(View.VISIBLE);
+                mTitleViewHolder.deleteTv.setTag(model.getGroupIndex());
+                mTitleViewHolder.deleteTv.setOnClickListener(this);
+            }
+            mTitleViewHolder.tvTitle.setText(model.getCaption());
+        }
+    }
+
+    @Override
+    public void onClick(View view) {
+        if (view.getId() == R.id.deleteTv) {
+            if (view.getTag() != null && view.getTag() instanceof Integer) {
+                showDeleteGroup((Integer) view.getTag());
+            }
+        } else if (view.getId() == R.id.valuesEd) {
+            if (mOnAdapterListener != null) {
+                if (view.getTag(R.id.tag2) != null && view.getTag(R.id.tag2) instanceof BillGroupModel.BillModel) {
+                    int position = view.getTag(R.id.tag) != null && view.getTag(R.id.tag) instanceof Integer ? ((int) view.getTag(R.id.tag)) : 0;
+                    mOnAdapterListener.toSelect(position, (BillGroupModel.BillModel) view.getTag(R.id.tag2));
+                }
+            }
+
+        } else if (view.getId() == R.id.addTv) {
+            if (view.getTag() != null && view.getTag() instanceof Integer) {
+                int groupIndex = (int) view.getTag();
+                addGroups(groupIndex);
+            }
+        } else if (R.id.btn_del == view.getId()) {
+            if (view.getTag(R.id.tag_key) != null && view.getTag(R.id.tag_key2) != null
+                    && view.getTag(R.id.tag_key) instanceof Integer && view.getTag(R.id.tag_key2) instanceof Integer) {
+                int position = (int) view.getTag(R.id.tag_key2);//当前在主列表的item
+                int index = (int) view.getTag(R.id.tag_key);//当前在子列表的item
+                if (position >= 0 && position < ListUtils.getSize(mUpdateBillModels)
+                        && ListUtils.getSize(mUpdateBillModels.get(position).getLocalDatas()) > index) {
+                    mUpdateBillModels.get(position).getLocalDatas().remove(index);
+                    notifyItemChanged(position);
+                }
+            }
+        } else if (R.id.content == view.getId()) {
+            if (view.getTag(R.id.tag_key2) != null && view.getTag(R.id.tag_key2) instanceof Integer) {
+                int position = (int) view.getTag(R.id.tag_key2);//当前在主列表的item
+                if (mOnAdapterListener != null && position >= 0 && position < ListUtils.getSize(mUpdateBillModels)) {
+                    mOnAdapterListener.toEnclosureSelect(position, mUpdateBillModels.get(position));
+                }
+            }
+        }
+    }
+
+    protected void addGroups(int mGroupIndex) {
+        BillGroupModel mBillGroupModel = mBillGroupModels.get(mGroupIndex);
+        mBillGroupModel.setLastInType(false);
+        int oldGridIndex = mBillGroupModel.getGridIndex();
+        boolean isForm = mBillGroupModel.isForm();
+
+        BillGroupModel newBillGroupModel = new BillGroupModel();
+        newBillGroupModel.setForm(isForm);
+        if (isForm) {
+            newBillGroupModel.setGroup(mBillGroupModel.getGroup());
+        } else {
+            newBillGroupModel.setGroup("明细" + (oldGridIndex + 1));
+        }
+        newBillGroupModel.setGridIndex(oldGridIndex + 1);
+        newBillGroupModel.setDeleteAble(true);
+        newBillGroupModel.setLastInType(true);
+        for (BillGroupModel.BillModel e : mBillGroupModel.getShowBillFields()) {
+            newBillGroupModel.addShow(new BillGroupModel.BillModel(e));
+        }
+        mBillGroupModels.add(mGroupIndex + 1, newBillGroupModel);
+        setBillGroupModels(mBillGroupModels);
+
+        /*if (mTabIndex != -1) {
+            BillGroupModel.BillModel tabModel = mShowBillModels.get(mTabIndex);
+            if (tabModel != null) {
+                tabModel.getTabList().get(mTabPosition)
+                        .setBillGroupModels(mBillGroupModels.subList(tabModel.getGroupIndex() + 1, mBillGroupModels.size()));
+            }
+        }*/
+
+        notifyDataSetChanged();
+    }
+
+    public class TextChangListener extends EditChangeListener {
+        EditText ed;
+        private int position;
+
+        public TextChangListener(EditText ed, int position) {
+            this.ed = ed;
+            this.position = position;
+        }
+
+        @Override
+        public void afterTextChanged(Editable s) {
+            if (this.position >= 0 && mUpdateBillModels != null && mUpdateBillModels.size() > this.position && ed != null) {
+                String valueEt = ed.getText().toString();
+                mUpdateBillModels.get(this.position).setValue(valueEt == null ? "" : valueEt);
+            }
+        }
+    }
+
+
+    public class MyTabChangeListener implements TabLayout.OnTabSelectedListener {
+        private TabLayout mTabLayout;
+        private int mPosition;
+
+        public MyTabChangeListener(TabLayout tabLayout, int position) {
+            mTabLayout = tabLayout;
+            mPosition = position;
+        }
+
+        @Override
+        public void onTabSelected(TabLayout.Tab tab) {
+            /*if (this.mPosition >= 0 && mShowBillModels != null && mShowBillModels.size() > this.mPosition && mTabLayout != null) {
+                mTabPosition = tab.getPosition();
+                BillGroupModel.BillModel model = mShowBillModels.get(mPosition);
+                if (model != null) {
+                    List<BillGroupModel.GridTab> tabList = model.getTabList();
+                    int tabGroupIndex = model.getGroupIndex();
+
+                    List<BillGroupModel> newGroupModels = new ArrayList<>();
+                    List<BillGroupModel> billGroupModels = mBillGroupModels.subList(0, tabGroupIndex + 1);
+                    mOldTabModels = mBillGroupModels.subList(tabGroupIndex + 1, mBillGroupModels.size());
+
+                    newGroupModels.addAll(billGroupModels);
+                    BillGroupModel.GridTab gridTab = tabList.get(mTabPosition);
+                    if (gridTab != null) {
+                        List<BillGroupModel> tabGroupModels = gridTab.getBillGroupModels();
+
+                        newGroupModels.addAll(tabGroupModels);
+                    }
+                    setBillGroupModels(newGroupModels);
+                    notifyDataSetChanged();
+                }
+            }*/
+        }
+
+        @Override
+        public void onTabUnselected(TabLayout.Tab tab) {
+
+        }
+
+        @Override
+        public void onTabReselected(TabLayout.Tab tab) {
+
+        }
+    }
+
+
+    private void showDeleteGroup(final int groupIndex) {
+        new VeriftyDialog.Builder(ct)
+                .setTitle(ct.getString(R.string.app_name))
+                .setContent("是否确认删除该单据?")
+                .build(new VeriftyDialog.OnDialogClickListener() {
+                    @Override
+                    public void result(boolean clickSure) {
+                        if (clickSure) {
+                            if (mBillGroupModels != null && mBillGroupModels.size() > groupIndex && groupIndex >= 0) {
+                                deleteGroup(groupIndex);
+                            }
+                        }
+                    }
+                });
+    }
+
+    public void deleteGroup(int groupIndex) {
+        boolean isLastItem = mBillGroupModels.get(groupIndex).isLastInType();
+        if (isLastItem && groupIndex - 1 > 0 && !mBillGroupModels.get(groupIndex - 1).isForm()) {
+            mBillGroupModels.get(groupIndex - 1).setLastInType(true);
+        }
+        mBillGroupModels.remove(groupIndex);
+        setBillGroupModels(mBillGroupModels);
+        notifyDataSetChanged();
+    }
+
+
+    public interface OnAdapterListener {
+        void toSelect(int position, BillGroupModel.BillModel model);
+
+        void toEnclosureSelect(int position, BillGroupModel.BillModel model);
+    }
+
+    private class EnclosureAdapter extends BaseAdapter {
+        private int position;
+        private List<BillGroupModel.LocalData> localDatas;
+
+        public EnclosureAdapter(int position, List<BillGroupModel.LocalData> localDatas) {
+            this.position = position;
+            this.localDatas = localDatas;
+        }
+
+        public void setPosition(int position) {
+            this.position = position;
+        }
+
+        public void setLocalDatas(List<BillGroupModel.LocalData> localDatas) {
+            this.localDatas = localDatas;
+        }
+
+        @Override
+        public int getCount() {
+            return ListUtils.getSize(localDatas) < 9 ? (ListUtils.getSize(localDatas) + 1) : ListUtils.getSize(localDatas);
+        }
+
+        @Override
+        public Object getItem(int i) {
+            return localDatas.get(i);
+        }
+
+        @Override
+        public long getItemId(int i) {
+            return i;
+        }
+
+        @Override
+        public View getView(int i, View view, ViewGroup viewGroup) {
+            view = getLayoutInflater().inflate(R.layout.item_bill_enclosure_item, null);
+            ImageView content = (ImageView) view.findViewById(R.id.content);
+            TextView tvName = (TextView) view.findViewById(R.id.tv_name);
+            Button btnDel = (Button) view.findViewById(R.id.btn_del);
+            if (ListUtils.getSize(localDatas) > i) {
+                BillGroupModel.LocalData data = localDatas.get(i);
+                btnDel.setVisibility(View.VISIBLE);
+                String name = data.value == null ? "" : data.value;
+                tvName.setText(name);
+                btnDel.setTag(R.id.tag_key2, position);
+                btnDel.setTag(R.id.tag_key, i);
+                btnDel.setOnClickListener(BillUpdateAdapter.this);
+                if (isImage(name)) {
+                    ImageLoaderUtil.getInstance().loadImage(data.display, content);
+                }
+            } else {
+                tvName.setText("");
+                btnDel.setVisibility(View.GONE);
+                content.setImageResource(R.drawable.add_picture);
+
+                content.setTag(R.id.tag_key2, position);
+                content.setOnClickListener(BillUpdateAdapter.this);
+            }
+            return view;
+        }
+    }
+
+    private boolean isImage(String name) {
+        return name.toUpperCase().endsWith("JPEG")
+                || name.toUpperCase().endsWith("JPG")
+                || name.toUpperCase().endsWith("PNG");
+    }
+}

+ 8 - 1
app_modular/apputils/src/main/java/com/modular/apputils/model/ApprovalList.java

@@ -18,7 +18,8 @@ public class ApprovalList {
     private String operatedDescription;//变更处理人
     private int subTitleColor;
     private String subTitle;
-    private String  codeValue;
+    private String codeValue;
+    private String jp_form;
 
     public String getCodeValue() {
         return codeValue;
@@ -148,7 +149,13 @@ public class ApprovalList {
         this.operatedDescription = operatedDescription;
     }
 
+    public String getJp_form() {
+        return jp_form;
+    }
 
+    public void setJp_form(String jp_form) {
+        this.jp_form = jp_form;
+    }
 
     public boolean hasContext(CharSequence constraint) {
         return contain(constraint, imid, nodeId, caller, keyValue, master, name,

+ 13 - 6
app_modular/apputils/src/main/java/com/modular/apputils/model/BillGroupModel.java

@@ -2,6 +2,7 @@ package com.modular.apputils.model;
 
 import com.common.data.StringUtil;
 
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -12,7 +13,7 @@ import java.util.Map;
  * 单据由几个组组成  1.主表可以存在多个组  2.一个明细表由一个组组成
  * 注:由于类中类太多了,后续根据需求进行优化
  */
-public class BillGroupModel {
+public class BillGroupModel implements Serializable {
 
     private boolean isDeleteAble;//是否可以删除
     private boolean isForm;//是否为主表
@@ -71,6 +72,13 @@ public class BillGroupModel {
         showBillFields.add(e);
     }
 
+    public void addUpdate(BillModel e) {
+        if (updateBillFields == null) {
+            updateBillFields = new ArrayList<>();
+        }
+        updateBillFields.add(e);
+    }
+
     public boolean isDeleteAble() {
         return isDeleteAble;
     }
@@ -169,7 +177,7 @@ public class BillGroupModel {
         mGridTabs = gridTabs;
     }
 
-    public static class BillTitleModel {
+    public static class BillTitleModel implements Serializable{
         private int groupIndex;//组索引
         private boolean isDelete;
         private String showName;
@@ -206,7 +214,7 @@ public class BillGroupModel {
     /**
      * 字段详情
      */
-    public static class BillModel {
+    public static class BillModel implements Serializable{
         private int id;//id
         private int groupIndex;//所在组索引
         private float detno = 1000000;//序号
@@ -424,7 +432,7 @@ public class BillGroupModel {
         }
     }
 
-    public static class GridTab {
+    public static class GridTab implements Serializable{
         private String title;
         private String caller;
         private int position;
@@ -467,12 +475,11 @@ public class BillGroupModel {
     /**
      * 当C类型时候,本地选择数据
      */
-    public static class LocalData {
+    public static class LocalData implements Serializable {
         public String value = "";//显示的值  ||附件时候表示 路径,文件名
         public String display = "";//上传的值 ||附件时候表示上传的附件id
     }
 
-
     public interface Constants {
         String TYPE_TITLE = "LOCAL_TITLE";
         String TYPE_ADD = "LOCAL_ADD";

+ 278 - 0
app_modular/apputils/src/main/java/com/modular/apputils/presenter/BillDetailsPresenter.java

@@ -2,7 +2,9 @@ package com.modular.apputils.presenter;
 
 import android.content.Context;
 import android.content.Intent;
+import android.support.annotation.Nullable;
 import android.text.TextUtils;
+import android.widget.Toast;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
@@ -15,6 +17,16 @@ import com.core.app.Constants;
 import com.core.app.MyApplication;
 import com.core.base.BaseToolBarActivity;
 import com.core.utils.CommonUtil;
+import com.lidroid.xutils.HttpUtils;
+import com.lidroid.xutils.exception.HttpException;
+import com.lidroid.xutils.http.RequestParams;
+import com.lidroid.xutils.http.ResponseInfo;
+import com.lidroid.xutils.http.callback.RequestCallBack;
+import com.lidroid.xutils.http.client.HttpRequest;
+import com.me.network.app.base.HttpCallback;
+import com.me.network.app.base.HttpParams;
+import com.me.network.app.http.Method;
+import com.modular.apputils.R;
 import com.modular.apputils.activity.BillInputActivity;
 import com.modular.apputils.listener.OnSmartHttpListener;
 import com.modular.apputils.model.BillGroupModel;
@@ -23,10 +35,12 @@ import com.modular.apputils.network.Parameter;
 import com.modular.apputils.network.Tags;
 import com.modular.apputils.presenter.imp.IBillDetails;
 
+import java.io.File;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -257,6 +271,8 @@ public class BillDetailsPresenter extends BaseNetPresenter {
             }
             LogUtil.i("gong", "showBillModels=" + JSON.toJSONString(showBillModels));
             mIBillDetails.setAdapter(showBillModels);
+
+            mIBillDetails.updateStatus(null);
         } catch (Exception e) {
 
         }
@@ -460,6 +476,8 @@ public class BillDetailsPresenter extends BaseNetPresenter {
         String defValue = JSONUtil.getText(object, "fd_defaultvalue");//默认值
         String allowBlank = JSONUtil.getText(object, "fd_allowblank");//是否允许为空(注:当作为标题的时候T:表示可以删除 F:表示不可删除)
         String findFunctionName = JSONUtil.getText(object, "dg_findfunctionname");
+        String updatable = JSONUtil.getText(object, "fd_modify", "dg_modify");
+
         if (logicType.equals("necessaryField")) {
             allowBlank = "F";
         }
@@ -514,6 +532,7 @@ public class BillDetailsPresenter extends BaseNetPresenter {
         mBillModel.setField(field);
         mBillModel.setDefValue(defValue);
         mBillModel.setAllowBlank(allowBlank);
+        mBillModel.setUpdatable("T".equals(updatable));
         return mBillModel;
     }
 
@@ -618,7 +637,266 @@ public class BillDetailsPresenter extends BaseNetPresenter {
                 mGroupModel.addHide(mBillModel);
             }
 
+
         }
         return statusKey;
     }
+
+
+    public void saveAndSubmit(List<BillGroupModel> mGroupModels) {
+        mIBillDetails.showLoading();
+        List<BillGroupModel.BillModel> formFields = new ArrayList<>();
+        List<List<BillGroupModel.BillModel>> gridBillMap = new ArrayList<>();
+        List<BillGroupModel.GridTab> otherGridList = new ArrayList<>();
+        for (BillGroupModel e : mGroupModels) {
+            if (e.isForm()) {
+                if (e.getShowBillFields() != null) {
+                    formFields.addAll(e.getShowBillFields());
+                }
+                if (e.getHideBillFields() != null) {
+                    formFields.addAll(e.getHideBillFields());
+                }
+
+            } else {
+                List<BillGroupModel.GridTab> gridTabs = e.getGridTabs();
+                if (gridTabs != null && gridTabs.size() > 0) {
+                    otherGridList = gridTabs;
+                    break;
+                }
+                List<BillGroupModel.BillModel> gridBillFields = new ArrayList<>();
+                if (e.getShowBillFields() != null) {
+                    gridBillFields.addAll(e.getShowBillFields());
+                }
+                if (e.getHideBillFields() != null) {
+                    gridBillFields.addAll(e.getHideBillFields());
+                }
+                gridBillMap.add(gridBillFields);
+            }
+        }
+        if (otherGridList == null || otherGridList.size() <= 0) {
+            saveAndSubmit(mGroupModels, formFields, gridBillMap);
+        } else {
+//            saveAndSubmit(formFields, otherGridList, 0);
+        }
+    }
+
+    public void saveAndSubmit(final List<BillGroupModel> mGroupModels, List<BillGroupModel.BillModel> formFields, List<List<BillGroupModel.BillModel>> gridBillMap) {
+        Map<String, Object> formStore = new HashMap<>();
+        for (BillGroupModel.BillModel e : formFields) {
+            if (TextUtils.isEmpty(e.getValue()) && e.getIsdefault() == -1 &&
+                    ("necessaryField".equals(e.getAllowBlank()) || "F".equals(e.getAllowBlank()))) {
+                mIBillDetails.showToast(e.getCaption() + "为必填项");
+                mIBillDetails.showLoading();
+                return;
+            }
+            if (isEnclosureNeedSubmit(e)) {
+                pushEnclosure(e);
+                return;
+            }
+            formStore.put(e.getField(), e.getDisplay());
+        }
+
+        List<Map<String, Object>> gridStoreList = analysisGrid(gridBillMap);
+        if (gridStoreList == null) {
+            return;
+        }
+        if (formStore == null || gridStoreList == null) {
+            mIBillDetails.dimssLoading();
+            return;
+        }
+
+        String formStoreStr = JSONUtil.map2JSON(formStore);
+        String gridStoreStr = JSONUtil.map2JSON(gridStoreList);
+
+        LogUtil.i("update", "formStoreStr=" + formStoreStr);
+        LogUtil.i("update", "gridStoreStr=" + gridStoreStr);
+
+        String sessionId = CommonUtil.getSharedPreferences(ct, "sessionId");
+        String emCode = CommonUtil.getEmcode();
+        com.me.network.app.http.HttpRequest.getInstance().sendRequest(CommonUtil.getAppBaseUrl(ct),
+                new HttpParams.Builder()
+                        .url("common/mobile/modifydata.action")
+                        .flag(0)
+                        .method(Method.POST)
+                        .addParam("caller", mCaller)
+                        .addParam("formStore", formStoreStr)
+                        .addParam("gridStore", gridStoreStr)
+                        .addParam("sessionId", sessionId)
+                        .addParam("sessionUser", emCode)
+                        .addHeader("sessionUser", emCode)
+                        .addHeader("Cookie", "JSESSIONID=" + sessionId)
+                        .build(), new HttpCallback() {
+                    @Override
+                    public void onSuccess(int flag, Object o) throws Exception {
+                        Toast.makeText(ct, R.string.update_success, Toast.LENGTH_SHORT).show();
+                        mIBillDetails.dimssLoading();
+
+                        mIBillDetails.updateDetail(mGroupModels);
+                    }
+
+                    @Override
+                    public void onFail(int flag, String failStr) throws Exception {
+                        mIBillDetails.dimssLoading();
+                        Toast.makeText(ct, failStr, Toast.LENGTH_SHORT).show();
+                    }
+                });
+    }
+
+    public void saveAndSubmit(List<BillGroupModel.BillModel> formFields, List<BillGroupModel.GridTab> otherGridList, int flag) {
+        Map<String, Object> formStore = new HashMap<>();
+        for (BillGroupModel.BillModel e : formFields) {
+            if (TextUtils.isEmpty(e.getValue()) && e.getIsdefault() == -1 &&
+                    ("necessaryField".equals(e.getAllowBlank()) || "F".equals(e.getAllowBlank()))) {
+                mIBillDetails.showToast(e.getCaption() + "为必填项");
+                mIBillDetails.dimssLoading();
+                return;
+            }
+            if (isEnclosureNeedSubmit(e)) {
+                pushEnclosure(e);
+                return;
+            }
+            formStore.put(e.getField(), e.getDisplay());
+        }
+
+        List<Map<String, Object>> otherGridStoreList = new ArrayList<>();
+        for (BillGroupModel.GridTab gridTab : otherGridList) {
+            if (gridTab != null) {
+                List<BillGroupModel> tabGroupModels = gridTab.getBillGroupModels();
+                String otherCaller = gridTab.getCaller();
+                if (tabGroupModels != null && tabGroupModels.size() > 0) {
+                    List<List<BillGroupModel.BillModel>> otherGridMap = new ArrayList<>();
+                    for (BillGroupModel tabGroupModel : tabGroupModels) {
+                        List<BillGroupModel.BillModel> otherGrid = new ArrayList<>();
+                        List<BillGroupModel.BillModel> otherShowFields = tabGroupModel.getShowBillFields();
+                        List<BillGroupModel.BillModel> otherHideFields = tabGroupModel.getHideBillFields();
+
+                        if (otherShowFields != null) {
+                            otherGrid.addAll(otherShowFields);
+                        }
+                        if (otherHideFields != null) {
+                            otherGrid.addAll(otherHideFields);
+                        }
+                        otherGridMap.add(otherGrid);
+                    }
+                    List<Map<String, Object>> otherGridStoreItem = analysisGrid(otherGridMap);
+                    if (otherGridStoreItem == null) {
+                        return;
+                    }
+                    String otherGridStoreItemStr = JSONUtil.map2JSON(otherGridStoreItem);
+                    JSONArray otherGridStoreItemArray = JSON.parseArray(otherGridStoreItemStr);
+
+                    Map<String, Object> OtherGridStoreItemMap = new HashMap<>();
+                    OtherGridStoreItemMap.put("dgcaller", otherCaller);
+                    OtherGridStoreItemMap.put("dgData", otherGridStoreItemArray);
+
+                    otherGridStoreList.add(OtherGridStoreItemMap);
+                }
+            }
+        }
+
+        String formStoreStr = JSONUtil.map2JSON(formStore);
+        String otherGridStoreListStr = JSONUtil.map2JSON(otherGridStoreList);
+        LogUtil.prinlnLongMsg("billJson", formStoreStr);
+        LogUtil.prinlnLongMsg("billJson", otherGridStoreListStr);
+
+        /*requestCompanyHttp(new Parameter.Builder()
+                        .url(mId == 0 ? "mobile/oa/commonSaveAndSubmit.action" : "mobile/commonUpdate.action")
+                        .mode(Method.POST)
+                        .addParams("caller", mCaller)
+                        .addParams("keyid", String.valueOf(mId))
+                        .addParams("formStore", formStoreStr)
+                        .addParams("othergridStore", otherGridStoreListStr)
+                        .record(SAVE_AND_SUBMIT)
+                , this);*/
+    }
+
+
+    @Nullable
+    private List<Map<String, Object>> analysisGrid(List<List<BillGroupModel.BillModel>> gridBillMap) {
+        List<Map<String, Object>> gridStoreList = new ArrayList<>();
+        for (List<BillGroupModel.BillModel> e : gridBillMap) {
+            if (!ListUtils.isEmpty(e)) {
+                Map<String, Object> gridStore = new HashMap<>();
+                for (BillGroupModel.BillModel billModel : e) {
+                    if (TextUtils.isEmpty(billModel.getValue())
+                            && ("necessaryField".equals(billModel.getAllowBlank())
+                            || "F".equals(billModel.getAllowBlank())) && billModel.getIsdefault() == -1) {
+                        mIBillDetails.showToast(billModel.getCaption() + "为必填项");
+                        mIBillDetails.dimssLoading();
+                        return null;
+                    }
+                    if (isEnclosureNeedSubmit(billModel)) {
+                        pushEnclosure(billModel);
+                        return null;
+                    }
+                    gridStore.put(billModel.getField(), billModel.getDisplay());
+                }
+                gridStoreList.add(gridStore);
+            }
+        }
+        return gridStoreList;
+    }
+
+    public boolean isEnclosureNeedSubmit(BillGroupModel.BillModel billModel) {
+        return billModel.getType().equals("FF") && TextUtils.isEmpty(billModel.getValue()) && !ListUtils.isEmpty(billModel.getLocalDatas());
+
+    }
+
+    public void pushEnclosure(BillGroupModel.BillModel mBillModel) {
+        mBillModel.setLength(0);
+        uploadFile(mBillModel);
+    }
+
+    //上传文件
+    private void uploadFile(final BillGroupModel.BillModel mBillModel) {
+        String path = null;
+        if (mBillModel.getLength() < ListUtils.getSize(mBillModel.getLocalDatas())) {
+            //没有上传完成
+            BillGroupModel.LocalData data = mBillModel.getLocalDatas().get(mBillModel.getLength());
+            path = data.display;
+        } else {
+            mIBillDetails.showToast("开始上传完成=" + mBillModel.getLength());
+            mIBillDetails.updateFileOk();
+            return;
+        }
+        mIBillDetails.showToast("开始上传附件!!");
+        File mFile = new File(path);
+        RequestParams params = new RequestParams();
+        params.addQueryStringParameter("master", CommonUtil.getSharedPreferences(ct, "erp_master"));
+        params.addHeader("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
+        params.addBodyParameter("em_code", CommonUtil.getSharedPreferences(ct, "erp_username"));
+        params.addBodyParameter("type", "common");
+        params.addBodyParameter("file", mFile);
+        String url = CommonUtil.getAppBaseUrl(ct) + "mobile/uploadAttachs.action";
+        final HttpUtils http = new HttpUtils();
+        http.send(HttpRequest.HttpMethod.POST, url, params, new RequestCallBack<String>() {
+            @Override
+            public void onStart() {
+            }
+
+            @Override
+            public void onLoading(long total, long current, boolean isUploading) {
+            }
+
+            @Override
+            public void onSuccess(ResponseInfo<String> responseInfo) {
+                String result = responseInfo.result;
+                LogUtil.i("gong", "result-" + result);
+                if (JSONUtil.validate(result) && JSON.parseObject(result).getBoolean("success")) {
+                    mBillModel.setLength(mBillModel.getLength() + 1);
+                    JSONObject resultObject = JSON.parseObject(result);
+                    String phoneId = JSONUtil.getText(resultObject, "id");
+                    mBillModel.setValue(mBillModel.getValue() + "" + StringUtil.getLastBracket(phoneId) + ";");
+                    uploadFile(mBillModel);
+                }
+            }
+
+            @Override
+            public void onFailure(HttpException error, String msg) {
+                mIBillDetails.showToast("附件上传失败");
+            }
+        });
+
+    }
+
 }

+ 3 - 0
app_modular/apputils/src/main/java/com/modular/apputils/presenter/BillPresenter.java

@@ -855,6 +855,8 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
         String defValue = JSONUtil.getText(object, "fd_defaultvalue");//默认值
         String allowBlank = JSONUtil.getText(object, "fd_allowblank");//是否允许为空(注:当作为标题的时候T:表示可以删除 F:表示不可删除)
         String findFunctionName = JSONUtil.getText(object, "dg_findfunctionname");
+        String updatable = JSONUtil.getText(object, "fd_modify", "dg_modify");
+
         if (TextUtils.isEmpty(defValue) && hashMap != null && hashMap.containsKey(field)) {
             defValue = hashMap.get(field);
         }
@@ -897,6 +899,7 @@ public class BillPresenter extends BaseNetPresenter implements OnSmartHttpListen
         mBillModel.setField(field);
         mBillModel.setDefValue(defValue);
         mBillModel.setAllowBlank(allowBlank);
+        mBillModel.setUpdatable(updatable == "T");
         return mBillModel;
     }
 

+ 7 - 1
app_modular/apputils/src/main/java/com/modular/apputils/presenter/imp/IBillDetails.java

@@ -2,11 +2,17 @@ package com.modular.apputils.presenter.imp;
 
 import com.core.base.HttpImp;
 import com.modular.apputils.model.BillGroupModel;
-import java.util.ArrayList;
+
 import java.util.List;
 
 public interface IBillDetails extends HttpImp {
     void updateStatus(String status);
+
     void setAdapter(List<BillGroupModel> groupModels);
+
     void setFilePaths(List<BillGroupModel.LocalData> mLocalDatas);
+
+    void updateDetail(List<BillGroupModel> mGroupModels);
+
+    void updateFileOk();
 }

+ 138 - 0
app_modular/apputils/src/main/java/com/modular/apputils/widget/BillUpdatePopup.java

@@ -0,0 +1,138 @@
+package com.modular.apputils.widget;
+
+import android.content.Context;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.view.animation.Animation;
+import android.widget.TextView;
+
+import com.modular.apputils.R;
+import com.modular.apputils.adapter.BillUpdateAdapter;
+import com.modular.apputils.model.BillGroupModel;
+import com.modular.apputils.utils.RecyclerItemDecoration;
+
+import java.util.List;
+
+import razerdp.basepopup.BasePopupWindow;
+import razerdp.util.InputMethodUtils;
+
+/**
+ * @author RaoMeng
+ * @describe
+ * @date 2019/1/6 14:57
+ */
+public class BillUpdatePopup extends BasePopupWindow implements View.OnClickListener, BillUpdateAdapter.OnAdapterListener {
+    private Context mContext;
+    private RecyclerView mRecyclerView;
+    private TextView mCancelTextView, mConfirmTextView;
+    private BillUpdateAdapter mBillUpdateAdapter;
+    private OnUpdateSelectListener mOnUpdateSelectListener;
+
+    public BillUpdatePopup(Context context, OnUpdateSelectListener onUpdateSelectListener) {
+        super(context);
+        mContext = context;
+        this.mOnUpdateSelectListener = onUpdateSelectListener;
+
+        setAllowDismissWhenTouchOutside(false);
+//        setBlurBackgroundEnable(true);
+
+        initViews(context);
+
+        mCancelTextView.setOnClickListener(this);
+        mConfirmTextView.setOnClickListener(this);
+    }
+
+    private void initViews(Context context) {
+        mRecyclerView = findViewById(R.id.pop_bill_input_update_rv);
+        mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
+        mRecyclerView.addItemDecoration(new RecyclerItemDecoration(1));
+
+        mCancelTextView = findViewById(R.id.pop_bill_input_update_cancel_tv);
+        mConfirmTextView = findViewById(R.id.pop_bill_input_update_confirm_tv);
+    }
+
+    public List<BillGroupModel> getGroupModels() {
+        return mBillUpdateAdapter.getBillGroupModels();
+    }
+
+    public BillGroupModel getBillGroupModel(int groupIndex) {
+        return mBillUpdateAdapter.getBillGroupModel(groupIndex);
+    }
+
+    public void notifyDataSetChanged() {
+        mBillUpdateAdapter.notifyDataSetChanged();
+    }
+
+    public BillUpdatePopup setGroupModels(List<BillGroupModel> groupModels) {
+        if (groupModels != null) {
+            if (mBillUpdateAdapter == null) {
+                mBillUpdateAdapter = new BillUpdateAdapter(mContext, groupModels, this);
+                mRecyclerView.setAdapter(mBillUpdateAdapter);
+            } else {
+                mBillUpdateAdapter.setBillGroupModels(groupModels);
+                mBillUpdateAdapter.notifyDataSetChanged();
+            }
+        }
+        return this;
+    }
+
+    public BillUpdateAdapter getBillUpdateAdapter() {
+        return mBillUpdateAdapter;
+    }
+
+    public void updateBillModelValues(int position, String values, String display) {
+        mBillUpdateAdapter.updateBillModelValues(position, values, display);
+    }
+
+    @Override
+    public View onCreateContentView() {
+        return createPopupById(R.layout.pop_bill_input_update);
+    }
+
+    @Override
+    protected Animation onCreateShowAnimation() {
+        return getDefaultScaleAnimation(true);
+    }
+
+    @Override
+    protected Animation onCreateDismissAnimation() {
+        return getDefaultScaleAnimation(false);
+    }
+
+    @Override
+    public void onClick(View view) {
+        int i = view.getId();
+        if (i == R.id.pop_bill_input_update_cancel_tv) {
+            InputMethodUtils.close(mRecyclerView);
+            dismiss();
+        } else if (i == R.id.pop_bill_input_update_confirm_tv) {
+            if (mOnUpdateSelectListener != null) {
+                mOnUpdateSelectListener.onUpdateConfirm(mBillUpdateAdapter.getBillGroupModels(),mBillUpdateAdapter.getUpdateBillModels());
+            }
+        } else {
+        }
+    }
+
+    @Override
+    public void toSelect(int position, BillGroupModel.BillModel model) {
+        if (mOnUpdateSelectListener != null) {
+            mOnUpdateSelectListener.onUpdateSelect(position, model);
+        }
+    }
+
+    @Override
+    public void toEnclosureSelect(int position, BillGroupModel.BillModel model) {
+        if (mOnUpdateSelectListener != null) {
+            mOnUpdateSelectListener.onUpdateEnclosure(position, model);
+        }
+    }
+
+    public interface OnUpdateSelectListener {
+        void onUpdateSelect(int position, BillGroupModel.BillModel model);
+
+        void onUpdateEnclosure(int position, BillGroupModel.BillModel model);
+
+        void onUpdateConfirm(List<BillGroupModel> billGroupModels,List<BillGroupModel.BillModel> updateBillModels);
+    }
+}

+ 0 - 0
app_modular/appworks/src/main/res/drawable/shape_b2b_gray_light_line_bg.xml → app_modular/apputils/src/main/res/drawable/shape_b2b_gray_light_line_bg.xml


+ 3 - 1
app_modular/apputils/src/main/res/layout/item_bill_input_select.xml

@@ -1,6 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<android.support.constraint.ConstraintLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:background="@color/white"

+ 57 - 0
app_modular/apputils/src/main/res/layout/pop_bill_input_update.xml

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="320dp"
+    android:layout_gravity="center"
+    android:background="@drawable/shape_b2b_gray_light_line_bg"
+    android:layout_margin="45dp"
+    android:orientation="vertical">
+
+    <TextView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center"
+        android:padding="12dp"
+        android:text="可更新字段"
+        android:textColor="#333333"
+        android:textSize="14sp" />
+
+    <android.support.v7.widget.RecyclerView
+        android:id="@+id/pop_bill_input_update_rv"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1" />
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:padding="10dp">
+
+        <TextView
+            android:id="@+id/pop_bill_input_update_cancel_tv"
+            android:layout_width="0dp"
+            android:layout_height="32dp"
+            android:layout_marginLeft="30dp"
+            android:layout_weight="1"
+            android:background="@drawable/selector_cancel_bg"
+            android:gravity="center"
+            android:text="@string/cancel"
+            android:textColor="@color/selector_cancel_text_color"
+            android:textSize="14sp" />
+
+        <TextView
+            android:id="@+id/pop_bill_input_update_confirm_tv"
+            android:layout_width="0dp"
+            android:layout_height="32dp"
+            android:layout_marginLeft="30dp"
+            android:layout_marginRight="30dp"
+            android:layout_weight="1"
+            android:background="@drawable/selector_confirm_bg"
+            android:gravity="center"
+            android:text="@string/updata"
+            android:textColor="@color/white"
+            android:textSize="14sp" />
+    </LinearLayout>
+</LinearLayout>

+ 1 - 0
app_modular/apputils/src/main/res/values-en/strings.xml

@@ -3,4 +3,5 @@
     <string name="str_error_wechat_pay_success">支付成功</string>
     <string name="str_error_wechat_pay_fail">支付失败</string>
     <string name="str_error_wechat_pay_cancel">支付已取消</string>
+    <string name="no_fields_to_update">没有可更新的字段</string>
 </resources>

+ 1 - 0
app_modular/apputils/src/main/res/values-zh-rCN/strings.xml

@@ -3,4 +3,5 @@
     <string name="str_error_wechat_pay_success">支付成功</string>
     <string name="str_error_wechat_pay_fail">支付失败</string>
     <string name="str_error_wechat_pay_cancel">支付已取消</string>
+    <string name="no_fields_to_update">没有可更新的字段</string>
 </resources>

+ 1 - 0
app_modular/apputils/src/main/res/values-zh-rTW/strings.xml

@@ -3,4 +3,5 @@
     <string name="str_error_wechat_pay_success">支付成功</string>
     <string name="str_error_wechat_pay_fail">支付失败</string>
     <string name="str_error_wechat_pay_cancel">支付已取消</string>
+    <string name="no_fields_to_update">没有可更新的字段</string>
 </resources>

+ 1 - 0
app_modular/apputils/src/main/res/values/strings.xml

@@ -17,4 +17,5 @@
     <string name="hot_news">热点事件</string>
     <string name="kou_hao">标新 ,立异</string>
     <string name="advertisement">新一代梅赛德斯</string>
+    <string name="no_fields_to_update">没有可更新的字段</string>
 </resources>

+ 3 - 2
app_modular/appworks/src/main/java/com/uas/appworks/CRM/erp/activity/BusinessActivity.java

@@ -68,7 +68,7 @@ public class BusinessActivity extends BaseActivity implements View.OnClickListen
     private ArrayList<ArrayList<String>> gridlists = new ArrayList<ArrayList<String>>();
     private String mWhichPage = "";
     private String gridData = "  [\n" +
-            "[\"颜色\",\"商机阶段\",\"商机数量\",\"商机转化率\"],\n" +
+            "[\"颜色\",\"商机阶段\",\"数量/金额\",\"转化率\"],\n" +
             "[\"#FF0000\",\"0\",\"0\",\"0\"],\n" +
             "[\"#00CCFF\",\"0\",\"0\",\"0\"],\n" +
             "[\"#FFFF00\",\"0\",\"0\",\"0\"],\n" +
@@ -256,11 +256,12 @@ public class BusinessActivity extends BaseActivity implements View.OnClickListen
                 String color = chances.getJSONObject(i).getString("color");
                 int detno = chances.getJSONObject(i).getInteger("detno");
                 int count = chances.getJSONObject(i).getInteger("count");
+                double amount = chances.getJSONObject(i).getDouble("count");
                 items.add("#" + color);
                 colors.add("#" + color);
                 // items.add(String.valueOf(i + 1));
                 items.add(currentprocess);
-                items.add(String.valueOf(count));
+                items.add(String.valueOf(count) + "/" + CommonUtil.doubleFormat(amount));
                 counts.add(count);
                 countToatal = countToatal + count;
                 items.add(percent);

+ 7 - 2
app_modular/appworks/src/main/java/com/uas/appworks/CRM/erp/activity/DeviceDataFormAddActivity.java

@@ -1047,8 +1047,13 @@ public class DeviceDataFormAddActivity extends SupportToolBarActivity implements
                                     sa_custaddress = i + 1;
                                 }
                             }
-                            mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custname - 1).setValue(cu_name);
-                            mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custaddress - 1).setValue(cu_address);
+
+                            if (sa_custname>0){
+                                mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custname - 1).setValue(cu_name);
+                            }
+                            if (sa_custaddress>0){
+                                mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custaddress - 1).setValue(cu_address);
+                            }
                             mAdapter.notifyDataSetChanged();
                         }
                     });

+ 4 - 4
app_modular/appworks/src/main/java/com/uas/appworks/CRM/erp/adapter/HListViewOneAdapter.java

@@ -59,13 +59,13 @@ public class HListViewOneAdapter extends BaseAdapter {
             for (int j=0;j<items.size();j++){
                 float weight=1.0f;
                 if (j==0){
-                    weight=0.1f;
+                    weight=0.2f;
                 }else if(j==2){
-                    weight=0.1f;
+                    weight=0.6f;
                 }else if (j==3){
-                    weight=0.1f;
+                    weight=0.2f;
                 }else{
-                    weight=3.5f;
+                    weight=3f;
                 }
                 TextView tv= CreateTextView(ct,weight);
                 holder.tv_item[j]=tv;

+ 8 - 3
app_modular/appworks/src/main/java/com/uas/appworks/OA/erp/activity/form/DataFormDetailActivity.java

@@ -1163,6 +1163,7 @@ public class DataFormDetailActivity extends BaseActivity implements View.OnClick
                     model.text.setText(data.getName());
                     model.selectIv.setVisibility(View.GONE);
                     if (data.getType().equals("D") ||
+                            data.getType().equals("DT") ||
                             data.getType().equals("C") ||
                             data.getType().equals("MF") ||
                             data.getType().equals("SF") ||
@@ -1191,7 +1192,7 @@ public class DataFormDetailActivity extends BaseActivity implements View.OnClick
                                 ToastUtil.showToast(ct, R.string.networks_out);
                                 return;
                             }
-                            if (data.getType().equals("D")) {
+                            if (data.getType().equals("D") || data.getType().equals("DT") ) {
                                 boolean hasMenu = false;
                                 if ("Ask4Leave".equals(caller)) hasMenu = true;
                                 Log.d("date:", startDate_v + "," + endDate_v);
@@ -1594,8 +1595,12 @@ public class DataFormDetailActivity extends BaseActivity implements View.OnClick
                                     sa_custaddress = i + 1;
                                 }
                             }
-                            mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custname - 1).setValue(cu_name);
-                            mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custaddress - 1).setValue(cu_address);
+                            if (sa_custname>0){
+                                mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custname - 1).setValue(cu_name);
+                            }
+                            if (sa_custaddress>0){
+                                mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custaddress - 1).setValue(cu_address);
+                            }
                             mAdapter.notifyDataSetChanged();
                         }
                     });

+ 6 - 2
app_modular/appworks/src/main/java/com/uas/appworks/OA/erp/activity/form/TravelDataFormDetailActivity.java

@@ -1531,8 +1531,12 @@ public class TravelDataFormDetailActivity extends BaseActivity implements View.O
                                     sa_custaddress = i + 1;
                                 }
                             }
-                            mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custname - 1).setValue(cu_name);
-                            mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custaddress - 1).setValue(cu_address);
+                            if (sa_custname>0){
+                                mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custname - 1).setValue(cu_name);
+                            }
+                            if (sa_custaddress>0){
+                                mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custaddress - 1).setValue(cu_address);
+                            }
                             mAdapter.notifyDataSetChanged();
                         }
                     });

+ 8 - 2
app_modular/appworks/src/main/java/com/uas/appworks/OA/erp/presenter/MissionPresenter.java

@@ -653,8 +653,14 @@ public class MissionPresenter implements IMissionPresenter, OnHttpResultListener
             if (iMission != null) {
 //                loadMissionByDB();
 
-//                iMission.dimssLoading();
-//                iMission.showModels(models);
+                iMission.dimssLoading();
+                List<MissionModel> models = new ArrayList<>();
+                MissionModel entity = new MissionModel();
+                entity.setType(1);
+                entity.setLocation(UasLocationHelper.getInstance().getUASLocation().getName());//当前位置
+                entity.setRecorddate(TimeUtils.f_long_2_str(System.currentTimeMillis()));//当前时间
+                models.add(entity);
+                iMission.showModels(models);
             }
             return; //获取到拜访计划数据
         } else {

+ 6 - 2
app_modular/appworks/src/main/java/com/uas/appworks/activity/CommonDataFormActivity.java

@@ -1514,8 +1514,12 @@ public class CommonDataFormActivity extends BaseActivity implements View.OnClick
                                     sa_custaddress = i + 1;
                                 }
                             }
-                            mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custname - 1).setValue(cu_name);
-                            mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custaddress - 1).setValue(cu_address);
+                            if (sa_custname>0){
+                                mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custname - 1).setValue(cu_name);
+                            }
+                            if (sa_custaddress>0){
+                                mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custaddress - 1).setValue(cu_address);
+                            }
                             mAdapter.notifyDataSetChanged();
                         }
                     });

+ 6 - 2
app_modular/appworks/src/main/java/com/uas/appworks/activity/WorkDataFormActivity.java

@@ -1511,8 +1511,12 @@ public class WorkDataFormActivity extends BaseActivity implements View.OnClickLi
                                     sa_custaddress = i + 1;
                                 }
                             }
-                            mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custname - 1).setValue(cu_name);
-                            mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custaddress - 1).setValue(cu_address);
+                            if (sa_custname>0){
+                                mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custname - 1).setValue(cu_name);
+                            }
+                            if (sa_custaddress>0){
+                                mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custaddress - 1).setValue(cu_address);
+                            }
                             mAdapter.notifyDataSetChanged();
                         }
                     });

+ 5 - 0
app_modular/appworks/src/main/java/com/uas/appworks/activity/businessManage/BusinessOvertimeListActivity.java

@@ -122,6 +122,11 @@ public class BusinessOvertimeListActivity extends MvpBaseActivity<BusinessManage
 
     }
 
+    @Override
+    public void requestOptionSuccess(String resultJson) {
+
+    }
+
     @Override
     public void requestFail(int flag, String failStr) {
         if (mPageIndex == 1){

+ 5 - 0
app_modular/appworks/src/main/java/com/uas/appworks/activity/businessManage/BusinessRankListActivity.java

@@ -121,6 +121,11 @@ public class BusinessRankListActivity extends MvpBaseActivity<BusinessManageHome
 
     }
 
+    @Override
+    public void requestOptionSuccess(String resultJson) {
+
+    }
+
     @Override
     public void requestFail(int flag, String failStr) {
         if (mPageIndex == 1){

+ 5 - 0
app_modular/appworks/src/main/java/com/uas/appworks/activity/businessManage/BusinessRecordListActivity.java

@@ -124,6 +124,11 @@ public class BusinessRecordListActivity extends MvpBaseActivity<BusinessManageHo
 
     }
 
+    @Override
+    public void requestOptionSuccess(String resultJson) {
+
+    }
+
     @Override
     public void requestFail(int flag, String failStr) {
         if (mPageIndex == 1){

+ 43 - 6
app_modular/appworks/src/main/java/com/uas/appworks/activity/businessManage/businessManageHome/BusinessManageHomeActivity.java

@@ -4,6 +4,7 @@ import android.content.Intent;
 import android.graphics.drawable.BitmapDrawable;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
@@ -21,6 +22,7 @@ import com.core.app.Constants;
 import com.core.base.activity.MvpBaseActivity;
 import com.core.utils.CommonUtil;
 import com.core.utils.time.wheel.OASigninPicker;
+import com.me.network.app.http.HttpRequest;
 import com.modular.apputils.utils.RecyclerItemDecoration;
 import com.scwang.smartrefresh.layout.api.RefreshLayout;
 import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
@@ -54,7 +56,7 @@ public class BusinessManageHomeActivity extends MvpBaseActivity<BusinessManageHo
     private RefreshLayout mRefreshLayout;
     private TextView mDataTimeTextView, mDataRefreshTextView,
             mRecordRefreshTextView, mOvertimeRefreshTextView,
-            mRankRefreshTextView, mAddProjectBtn, mAddOemBtn,
+            mRankRefreshTextView, mAddProjectBtn, mAddOemBtn, mAddCompanyBtn,
             mNewlyTextView, mChangeTextView, mWinTextView, mLoseTextView, mInvalidTextView,
             mFollowTextView;
     private String mDataDateTime, mDataRefreshTime, mRecordRefreshTime, mOvertimeRefreshTime, mRankRefreshTime;
@@ -138,6 +140,7 @@ public class BusinessManageHomeActivity extends MvpBaseActivity<BusinessManageHo
 
         mAddProjectBtn = menuView.findViewById(R.id.business_home_menu1);
         mAddOemBtn = menuView.findViewById(R.id.business_home_menu2);
+        mAddCompanyBtn = menuView.findViewById(R.id.business_home_menu3);
 
         mMenuPopupWindow = new PopupWindow(menuView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
         mMenuPopupWindow.setBackgroundDrawable(new BitmapDrawable());
@@ -175,6 +178,7 @@ public class BusinessManageHomeActivity extends MvpBaseActivity<BusinessManageHo
         mHeaderFunnelLayout.setOnClickListener(this);
         mAddProjectBtn.setOnClickListener(this);
         mAddOemBtn.setOnClickListener(this);
+        mAddCompanyBtn.setOnClickListener(this);
 
         mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
             @Override
@@ -244,6 +248,15 @@ public class BusinessManageHomeActivity extends MvpBaseActivity<BusinessManageHo
                 mMenuPopupWindow.dismiss();
             }
             DisplayUtil.backgroundAlpha(mContext, 1f);
+        } else if (i == R.id.business_home_menu3) {
+            startActivity(new Intent(ct, BusinessBillInputActivity.class)
+                    .putExtra(Constants.Intents.CALLER, "BusinessChance")
+                    .putExtra(Constants.Intents.TITLE, getString(R.string.str_company_business_list))
+                    .putExtra(Constants.Intents.ID, 0));
+            if (mMenuPopupWindow != null) {
+                mMenuPopupWindow.dismiss();
+            }
+            DisplayUtil.backgroundAlpha(mContext, 1f);
         }
     }
 
@@ -256,11 +269,7 @@ public class BusinessManageHomeActivity extends MvpBaseActivity<BusinessManageHo
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         if (item.getItemId() == R.id.add_item) {
-            if (mMenuPopupWindow != null) {
-                View view = getWindow().findViewById(item.getItemId());
-                mMenuPopupWindow.showAsDropDown(view);
-                DisplayUtil.backgroundAlpha(mContext, 0.5f);
-            }
+            mPresenter.getOptionList(this, "sys", "isNewBusinessChance");
             return true;
         }
         return super.onOptionsItemSelected(item);
@@ -318,6 +327,24 @@ public class BusinessManageHomeActivity extends MvpBaseActivity<BusinessManageHo
         analysisRank(rankBeans);
     }
 
+    @Override
+    public void requestOptionSuccess(String resultJson) {
+        if (TextUtils.isEmpty(resultJson)) {
+            mAddCompanyBtn.setVisibility(View.VISIBLE);
+            mAddProjectBtn.setVisibility(View.GONE);
+            mAddOemBtn.setVisibility(View.GONE);
+        } else {
+            mAddCompanyBtn.setVisibility(View.GONE);
+            mAddProjectBtn.setVisibility(View.VISIBLE);
+            mAddOemBtn.setVisibility(View.VISIBLE);
+        }
+        if (mMenuPopupWindow != null) {
+            View view = getWindow().findViewById(R.id.add_item);
+            mMenuPopupWindow.showAsDropDown(view);
+            DisplayUtil.backgroundAlpha(mContext, 0.5f);
+        }
+    }
+
     private <T extends Object> List<T> getCountList(List<T> tList, int count) {
         List<T> resultList = new ArrayList<>();
         if (tList != null) {
@@ -376,6 +403,16 @@ public class BusinessManageHomeActivity extends MvpBaseActivity<BusinessManageHo
     @Override
     public void requestFail(int flag, String failStr) {
         toast(failStr);
+        if (flag == BusinessManageHomePresenterImpl.REQUEST_OPTION_LIST) {
+            mAddCompanyBtn.setVisibility(View.VISIBLE);
+            mAddProjectBtn.setVisibility(View.GONE);
+            mAddOemBtn.setVisibility(View.GONE);
+        }
+        if (mMenuPopupWindow != null) {
+            View view = getWindow().findViewById(R.id.add_item);
+            mMenuPopupWindow.showAsDropDown(view);
+            DisplayUtil.backgroundAlpha(mContext, 0.5f);
+        }
     }
 
     private void showDateDialog(String year, String month, final TextView tv) {

+ 4 - 0
app_modular/appworks/src/main/java/com/uas/appworks/activity/businessManage/businessManageHome/BusinessManageHomeContract.java

@@ -29,6 +29,8 @@ public class BusinessManageHomeContract {
         void requestAllSuccess(String resultJson, List<BusinessRecordBean> businessRecordBeans,
                                List<BusinessOverTimeBean> businessOverTimeBeans, List<BusinessRankBean> businessRankBeans);
 
+        void requestOptionSuccess(String resultJson);
+
         void requestFail(int flag, String failStr);
     }
 
@@ -42,5 +44,7 @@ public class BusinessManageHomeContract {
         void getBusinessRank(Context context, int pageIndex, int pageSize);
 
         void getBusinessAll(Context context, String dataTime, String salesmanCode);
+
+        void getOptionList(Context context, String caller, String code);
     }
 }

+ 22 - 0
app_modular/appworks/src/main/java/com/uas/appworks/activity/businessManage/businessManageHome/BusinessManageHomePresenterImpl.java

@@ -34,6 +34,7 @@ public class BusinessManageHomePresenterImpl extends BaseMvpPresenter<BusinessMa
     public static final int REQUEST_BUSINESS_OVERTIME = 60;
     public static final int REQUEST_BUSINESS_RANK = 61;
     public static final int REQUEST_BUSINESS_ALL = 62;
+    public static final int REQUEST_OPTION_LIST = 63;
 
     @Override
     public void onMvpAttachView(BusinessManageHomeContract.IBusinessManageHomeView view, Bundle savedInstanceState) {
@@ -121,6 +122,21 @@ public class BusinessManageHomePresenterImpl extends BaseMvpPresenter<BusinessMa
                         .build(), this);
     }
 
+    @Override
+    public void getOptionList(Context context, String caller, String code) {
+        getMvpView().showLoading("");
+
+        HttpRequest.getInstance().sendRequest(CommonUtil.getAppBaseUrl(context),
+                new HttpParams.Builder()
+                        .url("ma/setting/config.action")
+                        .flag(REQUEST_OPTION_LIST)
+                        .method(Method.GET)
+                        .addParam("caller", caller)
+                        .addParam("code", code)
+                        .addHeader("Cookie", CommonUtil.getErpCookie(context))
+                        .build(), this);
+    }
+
     @Override
     public void onSuccess(int flag, Object o) throws Exception {
         getMvpView().hideLoading();
@@ -184,6 +200,9 @@ public class BusinessManageHomePresenterImpl extends BaseMvpPresenter<BusinessMa
                     getMvpView().requestAllSuccess("", new ArrayList<BusinessRecordBean>(), new ArrayList<BusinessOverTimeBean>(), new ArrayList<BusinessRankBean>());
                 }
                 break;
+            case REQUEST_OPTION_LIST:
+                getMvpView().requestOptionSuccess(result);
+                break;
             default:
                 break;
         }
@@ -290,6 +309,9 @@ public class BusinessManageHomePresenterImpl extends BaseMvpPresenter<BusinessMa
                 LogUtil.prinlnLongMsg("raoAllFail", failStr);
                 getMvpView().requestFail(flag, failStr);
                 break;
+            case REQUEST_OPTION_LIST:
+                getMvpView().requestFail(flag, failStr);
+                break;
             default:
                 break;
         }

+ 13 - 0
app_modular/appworks/src/main/java/com/uas/appworks/adapter/BillListDetailsAdapter.java

@@ -34,6 +34,19 @@ public class BillListDetailsAdapter extends BaseAdapter {
         changeBillModel();
     }
 
+    public BillGroupModel getBillGroupModel(int groupIndex) {
+        if (ListUtils.isEmpty(groupModels)) {
+            return null;
+        } else {
+            for (BillGroupModel billGroupModel : groupModels) {
+                if (billGroupModel.getGroupIndex() == groupIndex) {
+                    return billGroupModel;
+                }
+            }
+            return null;
+        }
+    }
+
     public List<BillGroupModel.BillModel> getUpdateBillModels() {
         return mUpdateBillModels;
     }

+ 6 - 2
app_modular/appworks/src/main/java/com/uas/appworks/crm3_0/activity/ContactDynamicAddActivity.java

@@ -1573,8 +1573,12 @@ public class ContactDynamicAddActivity extends BaseActivity implements View.OnCl
                                     sa_custaddress = i + 1;
                                 }
                             }
-                            mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custname - 1).setValue(cu_name);
-                            mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custaddress - 1).setValue(cu_address);
+                            if (sa_custname>0){
+                                mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custname - 1).setValue(cu_name);
+                            }
+                            if (sa_custaddress>0){
+                                mAdapter.getmListData().get(currentGroupId).getDatas().get(sa_custaddress - 1).setValue(cu_address);
+                            }
                             mAdapter.notifyDataSetChanged();
                         }
                     });

+ 1 - 0
app_modular/appworks/src/main/java/com/uas/appworks/crm3_0/activity/CustomerManageActivity.java

@@ -391,6 +391,7 @@ public class CustomerManageActivity extends OABaseActivity implements ICustomerM
                 mBillListConfig.setCondition(mCondition);
                 billListConfigs.add(mBillListConfig);
                 startActivity(new Intent(ct, BillListActivity.class)
+                        .putExtra(Constants.Intents.INPUT_CLASS, VisitRecordBillInputActivity.class)
                         .putExtra(Constants.Intents.CONFIG, billListConfigs)
                         .putExtra(Constants.Intents.TITLE, "拜访报告")
                         .putExtra(Constants.Intents.DETAILS_CLASS, BillDetailsActivity.class)

+ 30 - 8
app_modular/appworks/src/main/java/com/uas/appworks/crm3_0/activity/CustomerVisitActivity.java

@@ -23,6 +23,7 @@ import com.common.data.JSONUtil;
 import com.common.data.ListUtils;
 import com.core.app.Constants;
 import com.core.base.BaseActivity;
+import com.core.base.BaseToolBarActivity;
 import com.core.utils.CommonUtil;
 import com.core.utils.ToastUtil;
 import com.me.network.app.http.Method;
@@ -243,6 +244,8 @@ public class CustomerVisitActivity extends BaseActivity {
                 String status = JSONUtil.getText(object, "mpd_zdstatus", "status");
                 String doman = JSONUtil.getText(object, "doman");
                 String domanCode = JSONUtil.getText(object, "domanCode");
+                String billstatus = JSONUtil.getText(object, "mp_status");
+
                 mVisitPlan.setId(id);
                 mVisitPlan.setCode(code);
                 mVisitPlan.setRecordDay(DateFormatUtil.long2Str(entryDate, DateFormatUtil.YMD));
@@ -255,6 +258,8 @@ public class CustomerVisitActivity extends BaseActivity {
                 mVisitPlan.setStatus(status);
                 mVisitPlan.setDoman(doman);
                 mVisitPlan.setDomanCode(domanCode);
+                mVisitPlan.setBillStatus(billstatus);
+
                 visitPlanArrayList.add(mVisitPlan);
             }
             datas.put(monthInt, visitPlanArrayList);
@@ -359,7 +364,13 @@ public class CustomerVisitActivity extends BaseActivity {
             }
 //            holder.dateTv.setText(mVisitPlan.getRecordDay());
             holder.doManTv.setText(mVisitPlan.getDoman());
-            holder.statusTv.setText(mVisitPlan.getStatus());
+            String status = mVisitPlan.getStatus();
+            String billStatus = mVisitPlan.getBillStatus();
+            if ("已转单".equals(status)) {
+                holder.statusTv.setText(status);
+            } else {
+                holder.statusTv.setText(billStatus);
+            }
             holder.itemView.setTag(mVisitPlan);
             holder.itemView.setOnClickListener(mOnItemClickListener);
         }
@@ -369,13 +380,24 @@ public class CustomerVisitActivity extends BaseActivity {
             public void onClick(View view) {
                 if (view.getTag() != null && view.getTag() instanceof VisitPlan) {
                     VisitPlan mVisitPlan = (VisitPlan) view.getTag();
-                    startActivity(new Intent(ct, CustomerVisitDetailsActivity.class)
-                            .putExtra(Constants.Intents.TITLE, "客户拜访详情")
-                            .putExtra(Constants.Intents.MY_DOIT, myVisitRb.isChecked())
-                            .putExtra(Constants.Intents.STATUS, mVisitPlan.getStatus())
-                            .putExtra(Constants.Intents.ID, mVisitPlan.getId())
-                            .putExtra(Constants.Intents.CALLER, "MobileOutPlans")
-                    );
+                    String billStatus = mVisitPlan.getBillStatus();
+                    if ("在录入".equals(billStatus)) {
+                        startActivity(new Intent(ct, CustomerVisitBillInputActivity.class)
+                                .putExtra(Constants.Intents.CALLER, "MobileOutPlans")
+                                .putExtra(Constants.Intents.TITLE, "客户拜访计划")
+                                .putExtra(Constants.Intents.DETAILS_CLASS, CustomerVisitDetailsActivity.class)
+                                .putExtra(Constants.Intents.INPUT_CLASS, CustomerVisitBillInputActivity.class)
+                                .putExtra(Constants.Intents.ID, mVisitPlan.getId()));
+                    } else {
+                        startActivity(new Intent(ct, CustomerVisitDetailsActivity.class)
+                                .putExtra(Constants.Intents.TITLE, "客户拜访详情")
+                                .putExtra(Constants.Intents.MY_DOIT, myVisitRb.isChecked())
+                                .putExtra(Constants.Intents.STATUS, mVisitPlan.getStatus())
+                                .putExtra(Constants.Intents.BILL_STATUS, billStatus)
+                                .putExtra(Constants.Intents.ID, mVisitPlan.getId())
+                                .putExtra(Constants.Intents.CALLER, "MobileOutPlans")
+                        );
+                    }
                     dataUpdate = true;
                 }
             }

+ 157 - 59
app_modular/appworks/src/main/java/com/uas/appworks/crm3_0/activity/CustomerVisitBillInputActivity.java

@@ -2,6 +2,7 @@ package com.uas.appworks.crm3_0.activity;
 
 import android.content.Intent;
 import android.os.Handler;
+import android.text.TextUtils;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.widget.PopupWindow;
@@ -30,7 +31,6 @@ import com.uas.applocation.UasLocationHelper;
 import com.uas.appworks.R;
 import com.uas.appworks.adapter.CustomerVisitBillAdapter;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -41,9 +41,9 @@ import java.util.Map;
 public class CustomerVisitBillInputActivity extends BillInputActivity {
     private UUHttpHelper mUUHttpHelper;
     private final int TAG_COMPANY_SELECT = 0x651;
-    private PopupWindow popupWindow;
+    private final int TAG_ADDRESS_SELECT = 0x652;
     private int keyValue;
-    private SelectAimModel address;
+    private SelectAimModel address;//当前地址
 
     @Override
     public boolean onPrepareOptionsMenu(Menu menu) {
@@ -72,25 +72,56 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
     private void submitBill() {
         String mp_cuname = "";
         String mp_address = "";
-        List<BillGroupModel.BillModel> showBillModels = mBillAdapter.getShowBillModels();
-        for (BillGroupModel.BillModel billModel : showBillModels) {
-            if ("mp_address".equals(billModel.getField())) {
+        String mp_longitude = "";
+        String mp_latitude = "";
+
+        List<BillGroupModel.BillModel> allBillModels = mBillAdapter.getmAllBillModels();
+        for (BillGroupModel.BillModel billModel : allBillModels) {
+            if ("mp_address".equals(billModel.getField()) && isShow(billModel)) {
                 mp_address = billModel.getValue();
             }
-            if (StringUtil.hasOneEqual(billModel.getField(), "mp_cuname", "mp_xmmc_user")) {
+            if (StringUtil.hasOneEqual(billModel.getField(), "mp_cuname", "mp_xmmc_user") &&
+                    !TextUtils.isEmpty(billModel.getValue()) && isShow(billModel)) {
                 mp_cuname = billModel.getValue();
             }
+            if ("mp_longitude".equals(billModel.getField())) {
+                mp_longitude = billModel.getValue();
+            }
+            if ("mp_latitude".equals(billModel.getField())) {
+                mp_latitude = billModel.getValue();
+            }
+        }
+
+        if (StringUtil.isEmpty(mp_address)) {
+            toast("当前地址不能为空");
+            return;
         }
 
-        if (!StringUtil.isEmpty(mp_cuname) || !StringUtil.isEmpty(mp_address)) {
-            if (address == null) {
-                address = new SelectAimModel();
+//        if (!StringUtil.isEmpty(mp_cuname) || !StringUtil.isEmpty(mp_address)) {
+        if (address == null) {
+            address = new SelectAimModel();
+        }
+        address.setName(mp_cuname);
+        address.setAddress(mp_address);
+        if (address.getLatLng() == null) {
+            try {
+                float lng = Float.parseFloat(mp_longitude);
+                float lat = Float.parseFloat(mp_latitude);
+                if (lat != 0 || lat != 0) {
+                    LatLng latLng = new LatLng(lat, lng);
+                    address.setLatLng(latLng);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
             }
-            address.setName(mp_cuname);
-            address.setAddress(mp_address);
         }
 
-        loadLatLng(StringUtil.isEmpty(mp_address) ? mp_cuname : mp_address);
+//        loadLatLng(StringUtil.isEmpty(mp_address) ? mp_cuname : mp_address);
+        saveAddressAndSubmit();
+    }
+
+    private boolean isShow(BillGroupModel.BillModel mBillModel) {
+        return mBillModel.getIsdefault() == -1 && !mBillModel.getType().equals("H");
     }
 
     @Override
@@ -131,7 +162,8 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
                     for (BillGroupModel.BillModel billModel : groupModel.getShowBillFields()) {
                         switch (billModel.getField()) {
                             case "mp_address":
-                                billModel.setDefValue(UasLocationHelper.getInstance().getUASLocation().getAddress());
+//                                billModel.setDefValue(UasLocationHelper.getInstance().getUASLocation().getAddress());
+                                billModel.setType("DF");
                                 break;
                             case "mpd_actdate":
                             case "mpd_outdate":
@@ -140,7 +172,8 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
                             default: {
                                 switch (billModel.getCaption()) {
                                     case "当前地址":
-                                        billModel.setDefValue(UasLocationHelper.getInstance().getUASLocation().getAddress());
+//                                        billModel.setDefValue(UasLocationHelper.getInstance().getUASLocation().getAddress());
+                                        billModel.setType("DF");
                                         break;
                                     case "实际离开时间":
                                     case "实际到达时间":
@@ -164,10 +197,51 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
 
     @Override
     public void toSelect(int position, BillGroupModel.BillModel model) {
-        if (model.getCaption().equals("公司名称") || "mpd_company".equals(model.getField())) {
+        if ((model.getCaption().equals("公司名称") || "mpd_company".equals(model.getField()))) {
             selectPosition = model.getGroupIndex();
             Intent intent = new Intent("com.modular.form.SelectAimActivity");
             startActivityForResult(intent, TAG_COMPANY_SELECT);
+        } else if (("mp_address".equals(model.getField()))) {
+            List<BillGroupModel.BillModel> allBillModels = mBillAdapter.getmAllBillModels();
+            String companyName = "";
+            for (BillGroupModel.BillModel billModel : allBillModels) {
+                if (StringUtil.hasOneEqual(billModel.getField(), "mp_cuname", "mp_xmmc_user") &&
+                        !TextUtils.isEmpty(billModel.getValue()) && isShow(billModel)) {
+                    companyName = billModel.getValue();
+                }
+            }
+            selectPosition = model.getGroupIndex();
+            Intent intent = new Intent("com.modular.form.SelectAimActivity");
+            intent.putExtra("search", companyName);
+            startActivityForResult(intent, TAG_ADDRESS_SELECT);
+        } else if ("mp_bccode".equals(model.getField())) {
+            String master = CommonUtil.getMaster();
+            if ("DATACENTER".equals(master) || "N_SHYZ".equals(master) || "N_AJC".equals(master)) {
+                List<BillGroupModel.BillModel> allBillModels = mBillAdapter.getmAllBillModels();
+                String mp_cucode = "", mp_xmbh_user = "", mp_prjandcus_user = "";
+                for (BillGroupModel.BillModel billModel : allBillModels) {
+                    if (!TextUtils.isEmpty(billModel.getValue())) {
+                        if ("mp_cucode".equals(billModel.getField())) {
+                            mp_cucode = billModel.getValue();
+                        }
+                        if ("mp_xmbh_user".equals(billModel.getField())) {
+                            mp_xmbh_user = billModel.getValue();
+                        }
+                    }
+                    if ("mp_prjandcus_user".equals(billModel.getField())) {
+                        mp_prjandcus_user = billModel.getValue();
+                    }
+                }
+
+                if (TextUtils.isEmpty(mp_cucode) && TextUtils.isEmpty(mp_xmbh_user)) {
+                    toast("请先选择客户编号或项目编号");
+                    return;
+                }
+                String condition = "sign=\'" + mp_prjandcus_user + "\'";
+                findBydbFind(model, condition);
+            } else {
+                super.toSelect(position, model);
+            }
         } else {
             super.toSelect(position, model);
         }
@@ -177,18 +251,9 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
-        if (requestCode == TAG_COMPANY_SELECT && data != null) {//选择公司
+        if ((requestCode == TAG_COMPANY_SELECT || requestCode == TAG_ADDRESS_SELECT) && data != null) {//选择公司
             SelectAimModel chcheAimModel = data.getParcelableExtra("data");
-            if (popupWindow != null) {
-                popupWindow.dismiss();
-                popupWindow = null;
-            }
-            popupWindow = PopupWindowHelper.create(this, getString(R.string.perfect_company_name), chcheAimModel, new PopupWindowHelper.OnClickListener() {
-                @Override
-                public void result(SelectAimModel model) {
-                    sureSelectAim(model);
-                }
-            }, null);
+            sureSelectAim(chcheAimModel);
         }
     }
 
@@ -204,7 +269,7 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
             return;
         }
         String company = StringUtil.isEmpty(entity.getName()) ? "" : entity.getName();
-        String address = StringUtil.isEmpty(entity.getAddress()) ? "" : entity.getAddress();
+        String companyAddress = StringUtil.isEmpty(entity.getAddress()) ? "" : entity.getAddress();
         BillGroupModel mBillGroupModel = mBillAdapter.getBillGroupModel(selectPosition);
         if (mBillGroupModel != null) {
             if (entity.getLatLng() != null) {
@@ -219,7 +284,13 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
                     if ("mpd_company".equals(e.getField()) || "公司名称".equals(e.getCaption())) {
                         e.setValue(company);
                     } else if ("mpd_address".equals(e.getField()) || "公司地址".equals(e.getCaption())) {
-                        e.setValue(address);
+                        e.setValue(companyAddress);
+                    } else if ("mp_address".equals(e.getField()) || "当前地址".equals(e.getCaption())) {
+                        e.setValue(companyAddress);
+                        if (address == null) {
+                            address = new SelectAimModel();
+                        }
+                        address.setLatLng(entity.getLatLng());
                     }
                 }
             }
@@ -228,7 +299,13 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
                     if ("mpd_company".equals(e.getField()) || "公司名称".equals(e.getCaption())) {
                         e.setValue(company);
                     } else if ("mpd_address".equals(e.getField()) || "公司地址".equals(e.getCaption())) {
-                        e.setValue(address);
+                        e.setValue(companyAddress);
+                    } else if ("mp_address".equals(e.getField()) || "当前地址".equals(e.getCaption())) {
+                        e.setValue(companyAddress);
+                        if (address == null) {
+                            address = new SelectAimModel();
+                        }
+                        address.setLatLng(entity.getLatLng());
                     }
                 }
             }
@@ -286,12 +363,12 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
                     @Override
                     public void run() {
                         if (mContext == null) return;
-                        startActivity(new Intent(ct, CustomerVisitDetailsActivity.class)
+                        /*startActivity(new Intent(ct, CustomerVisitDetailsActivity.class)
                                 .putExtra(Constants.Intents.TITLE, "客户拜访详情")
                                 .putExtra(Constants.Intents.MY_DOIT, true)
                                 .putExtra(Constants.Intents.STATUS, "已提交")
                                 .putExtra(Constants.Intents.ID, keyValue)
-                                .putExtra(Constants.Intents.CALLER, "MobileOutPlans"));
+                                .putExtra(Constants.Intents.CALLER, "MobileOutPlans"));*/
                         finish();
                         overridePendingTransition(com.modular.apputils.R.anim.anim_activity_in, com.modular.apputils.R.anim.anim_activity_out);
                     }
@@ -306,6 +383,7 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
         if (mUUHttpHelper == null) {
             mUUHttpHelper = new UUHttpHelper(CommonUtil.getAppBaseUrl(ct));
         }
+        progressDialog.show();
         mUUHttpHelper.requestCompanyHttp(new Parameter.Builder()
                         .url("mobile/crm/getLngAndLat.action")
                         .addParams("address", address.trim())
@@ -335,6 +413,10 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
         formStore.put("Md_latitude", latitude);//纬度
         String emcode = CommonUtil.getEmcode();
         formStore.put("Md_emcode", emcode);//纬度
+
+        if (mUUHttpHelper == null) {
+            mUUHttpHelper = new UUHttpHelper(CommonUtil.getAppBaseUrl(ct));
+        }
         mUUHttpHelper.requestCompanyHttp(new Parameter.Builder()
                         .url("mobile/addOutAddress.action")
                         .addParams("caller", "lp")
@@ -347,6 +429,7 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
     private OnSmartHttpListener mOnSmartHttpListener = new OnSmartHttpListener() {
         @Override
         public void onSuccess(int what, String message, Tags tag) throws Exception {
+            progressDialog.dismiss();
             switch (what) {
                 case 11:
                     LogUtil.i("gong", "message=" + message);
@@ -358,33 +441,7 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
                         address.setLatLng(latLng);
                     }
 
-                    List<BillGroupModel> billGroupModels = mBillAdapter.getBillGroupModels();
-                    if (address != null && address.getLatLng() != null) {
-                        Map<String, Object> map = new HashMap<>();
-                        map.put("company", address.getName());
-                        map.put("companyAddress", address.getAddress());
-                        map.put("visitTime", DateFormatUtil.long2Str(DateFormatUtil.YMD_HMS));
-                        map.put("latitude", address.getLatLng().latitude);
-                        map.put("longitude", address.getLatLng().longitude);
-                        saveOutAddress(map);
-
-                        BillGroupModel latLngGroupModel = new BillGroupModel();
-                        latLngGroupModel.setForm(true);
-
-                        BillGroupModel.BillModel latBillModel = new BillGroupModel.BillModel();
-                        latBillModel.setField("mp_latitude");
-                        latBillModel.setDisplay(address.getLatLng().latitude + "");
-                        BillGroupModel.BillModel lngBillModel = new BillGroupModel.BillModel();
-                        lngBillModel.setField("mp_longitude");
-                        lngBillModel.setDisplay(address.getLatLng().longitude + "");
-
-                        latLngGroupModel.addHide(latBillModel);
-                        latLngGroupModel.addHide(lngBillModel);
-
-                        billGroupModels.add(latLngGroupModel);
-                    }
-
-                    mBillPresenter.saveAndSubmit(billGroupModels);
+                    saveAddressAndSubmit();
                     break;
                 case 13:
                     saveAddress();
@@ -394,11 +451,52 @@ public class CustomerVisitBillInputActivity extends BillInputActivity {
 
         @Override
         public void onFailure(int what, String message, Tags tag) throws Exception {
+            progressDialog.dismiss();
             if (what == 13) {
                 saveAddress();
             }
         }
     };
 
+    private void saveAddressAndSubmit() {
+        List<BillGroupModel> billGroupModels = mBillAdapter.getBillGroupModels();
+        if (address == null || address.getLatLng() == null) {
+            toast("地址信息为空,请重新选择当前地址");
+            return;
+        }
+
+        BillGroupModel latLngGroupModel = new BillGroupModel();
+        latLngGroupModel.setForm(true);
+
+        BillGroupModel.BillModel deviceModel = new BillGroupModel.BillModel();
+        deviceModel.setField("mp_sourceequipment");
+        deviceModel.setDisplay("Android");
+        latLngGroupModel.addHide(deviceModel);
+        if (address != null && address.getLatLng() != null) {
+            Map<String, Object> map = new HashMap<>();
+            map.put("company", address.getName());
+            map.put("companyAddress", address.getAddress());
+            map.put("visitTime", DateFormatUtil.long2Str(DateFormatUtil.YMD_HMS));
+            map.put("latitude", address.getLatLng().latitude);
+            map.put("longitude", address.getLatLng().longitude);
+            saveOutAddress(map);
+
+            BillGroupModel.BillModel latBillModel = new BillGroupModel.BillModel();
+            latBillModel.setField("mp_latitude");
+            latBillModel.setDisplay(address.getLatLng().latitude + "");
+
+            BillGroupModel.BillModel lngBillModel = new BillGroupModel.BillModel();
+            lngBillModel.setField("mp_longitude");
+            lngBillModel.setDisplay(address.getLatLng().longitude + "");
+
+            latLngGroupModel.addHide(latBillModel);
+            latLngGroupModel.addHide(lngBillModel);
+
+        }
+        billGroupModels.add(latLngGroupModel);
+
+        mBillPresenter.saveAndSubmit(billGroupModels);
+    }
+
 
 }

+ 889 - 9
app_modular/appworks/src/main/java/com/uas/appworks/crm3_0/activity/CustomerVisitDetailsActivity.java

@@ -1,7 +1,12 @@
 package com.uas.appworks.crm3_0.activity;
 
+import android.app.Activity;
+import android.content.DialogInterface;
 import android.content.Intent;
+import android.net.Uri;
+import android.os.Build;
 import android.os.Bundle;
+import android.support.annotation.Nullable;
 import android.text.TextUtils;
 import android.view.Menu;
 import android.view.MenuItem;
@@ -9,33 +14,72 @@ import android.view.View;
 import android.widget.ListView;
 import android.widget.PopupWindow;
 import android.widget.TextView;
+import android.widget.Toast;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.common.LogUtil;
+import com.common.data.CalendarUtil;
+import com.common.data.DateFormatUtil;
 import com.common.data.JSONUtil;
 import com.common.data.ListUtils;
+import com.common.data.StringUtil;
+import com.common.file.FileUtils;
+import com.common.ui.CameraUtil;
 import com.core.app.Constants;
+import com.core.app.MyApplication;
 import com.core.base.BaseToolBarActivity;
 import com.core.base.OABaseActivity;
+import com.core.model.SelectBean;
 import com.core.utils.CommonUtil;
+import com.core.utils.ToastUtil;
+import com.core.utils.time.wheel.DateTimePicker;
+import com.core.widget.view.Activity.ImgFileListActivity;
+import com.core.widget.view.Activity.SelectActivity;
+import com.core.widget.view.model.SelectAimModel;
+import com.lidroid.xutils.HttpUtils;
+import com.lidroid.xutils.exception.HttpException;
+import com.lidroid.xutils.http.RequestParams;
+import com.lidroid.xutils.http.ResponseInfo;
+import com.lidroid.xutils.http.callback.RequestCallBack;
+import com.lidroid.xutils.http.client.HttpRequest;
+import com.me.network.app.base.HttpCallback;
+import com.me.network.app.base.HttpParams;
 import com.me.network.app.http.Method;
+import com.modular.apputils.activity.SelectNetAcitivty;
 import com.modular.apputils.listener.OnSmartHttpListener;
 import com.modular.apputils.model.BillGroupModel;
 import com.modular.apputils.network.Parameter;
 import com.modular.apputils.network.Tags;
+import com.modular.apputils.utils.PopupWindowHelper;
 import com.modular.apputils.utils.UUHttpHelper;
+import com.modular.apputils.widget.BillUpdatePopup;
 import com.modular.apputils.widget.VeriftyDialog;
 import com.uas.appworks.R;
 import com.uas.appworks.adapter.BillListDetailsAdapter;
 
+import java.io.File;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
-public class CustomerVisitDetailsActivity extends OABaseActivity {
+public class CustomerVisitDetailsActivity extends OABaseActivity implements BillUpdatePopup.OnUpdateSelectListener {
     private final int LOAD_FORM = 0x11;
     private final int TURN_VISIT_RECORD = 0x12;
     private final int UN_SUBMIT = 0x13;
+    private final int SAVE_OUT_ADDRESS = 0x14;
+
+    public final int REQUESTCODE_C = 0x21;
+    public final int REQUESTCODE_DB_FIND = 0x22;
+    public final int REQUESTCODE_ENCLOSURE = 0x23;
+    public final int REQUESTCODE_C_NET = 0x24;
+    public final int REQUESTCODE_ENCLOSURE_LOW = 0x25;
+    public final int REQUEST_CODE_CAPTURE_PHOTO = 0x26;
+    public final int REQUEST_CODE_SELECT_MORE = 0x27;
+
+    private final int TAG_ADDRESS_SELECT = 0x652;
 
     private ListView mListView;
     private String mCaller;
@@ -47,18 +91,24 @@ public class CustomerVisitDetailsActivity extends OABaseActivity {
     private boolean isMe;
     private String mBillStatus;
     private List<BillGroupModel> mBillGroupModels;
+    private BillUpdatePopup mBillUpdatePopup;
+    public int selectPosition = -1;
+    private List<BillGroupModel> mUpdateGroupModels = new ArrayList<>();
+    private SelectAimModel address;//当前地址
 
     @Override
     public boolean onPrepareOptionsMenu(Menu menu) {
         menu.clear();
-        if (isMe) {
-            if ("已审核".equals(mBillStatus)) {
+        if (TextUtils.isEmpty(mBillStatus)) {
+            return super.onPrepareOptionsMenu(menu);
+        } else if ("已审核".equals(mBillStatus)) {
+            if (TextUtils.isEmpty(status) || (!"已完成".equals(status) && !"已转单".equals(status))) {
                 if (mListAdapter != null && !ListUtils.isEmpty(mListAdapter.getUpdateBillModels())) {
                     getMenuInflater().inflate(com.modular.apputils.R.menu.menu_input_update, menu);
                 }
-            } else {
-                getMenuInflater().inflate(com.modular.apputils.R.menu.menu_input_edit, menu);
             }
+        } else {
+            getMenuInflater().inflate(com.modular.apputils.R.menu.menu_input_edit, menu);
         }
         return super.onPrepareOptionsMenu(menu);
     }
@@ -85,7 +135,13 @@ public class CustomerVisitDetailsActivity extends OABaseActivity {
                     });
         } else if (item.getItemId() == R.id.update) {
             if (mListAdapter != null && !ListUtils.isEmpty(mListAdapter.getUpdateBillModels())) {
-
+                try {
+                    mUpdateGroupModels = CommonUtil.deepCopy(mListAdapter.getGroupModels());
+                } catch (Exception e) {
+                    mUpdateGroupModels = mListAdapter.getGroupModels();
+                    e.printStackTrace();
+                }
+                mBillUpdatePopup.setGroupModels(mUpdateGroupModels).showPopupWindow();
             } else {
                 toast(R.string.no_fields_to_update);
             }
@@ -115,6 +171,7 @@ public class CustomerVisitDetailsActivity extends OABaseActivity {
         mUUHttpHelper = new UUHttpHelper(CommonUtil.getAppBaseUrl(ct));
         mListView = findViewById(R.id.mListView);
         statusTv = findViewById(R.id.statusTv);
+        mBillUpdatePopup = new BillUpdatePopup(mContext, this);
         start(getIntent());
     }
 
@@ -196,6 +253,8 @@ public class CustomerVisitDetailsActivity extends OABaseActivity {
                     );
                     finish();
                     break;
+                case SAVE_OUT_ADDRESS:
+                    break;
             }
             dimssLoading();
         }
@@ -219,8 +278,6 @@ public class CustomerVisitDetailsActivity extends OABaseActivity {
         if (!ListUtils.isEmpty(formdatas)) {
             JSONObject formdata = formdatas.getJSONObject(0);//主表数据
             mBillStatus = JSONUtil.getText(formdata, "mp_status");
-            //刷新optionsmenu
-            supportInvalidateOptionsMenu();
 
             JSONArray formconfigs = JSONUtil.getJSONArray(datas, "formconfigs");//主表配置
             BillGroupModel mGroupModel = new BillGroupModel();
@@ -260,6 +317,9 @@ public class CustomerVisitDetailsActivity extends OABaseActivity {
             }
         }
         setAdapter(mBillGroupModels);
+
+        //刷新optionsmenu
+        supportInvalidateOptionsMenu();
     }
 
     private View.OnClickListener mOnClickListener = new View.OnClickListener() {
@@ -304,6 +364,8 @@ public class CustomerVisitDetailsActivity extends OABaseActivity {
             String findFunctionName = JSONUtil.getText(config, "DG_FINDFUNCTIONNAME");
             String allowBlank = JSONUtil.getText(config, "FD_ALLOWBLANK", "DG_ALLOWBLANK");
             String logicType = JSONUtil.getText(config, "FD_LOGICTYPE", "DG_LOGICTYPE");
+            String updatable = JSONUtil.getText(config, "FD_MODIFY", "DG_MODIFY");
+
             JSONArray combostore = JSONUtil.getJSONArray(config, "COMBOSTORE");//本地值
             BillGroupModel.BillModel mBillModel = new BillGroupModel.BillModel();
             mBillModel.setFindFunctionName(findFunctionName);
@@ -312,11 +374,17 @@ public class CustomerVisitDetailsActivity extends OABaseActivity {
             mBillModel.setIsdefault(isdefault);
             mBillModel.setDbfind(dbFind);
             mBillModel.setGroupIndex(mGroupModel.getGroupIndex());
-            mBillModel.setType(type);
+            if ("mp_address".equals(field)) {
+                mBillModel.setType("DF");
+            } else {
+                mBillModel.setType(type);
+            }
             mBillModel.setLogicType(logicType);
             mBillModel.setField(field);
             mBillModel.setAllowBlank(allowBlank);
             mBillModel.setValue(JSONUtil.getText(object, field));
+            mBillModel.setUpdatable("T".equals(updatable));
+
             if (!ListUtils.isEmpty(combostore)) {
                 List<BillGroupModel.LocalData> localDatas = new ArrayList<>();
                 for (int j = 0; j < combostore.size(); j++) {
@@ -330,6 +398,10 @@ public class CustomerVisitDetailsActivity extends OABaseActivity {
             }
             if (mBillModel.getIsdefault() == -1 && !mBillModel.getType().equals("H")) {
                 mGroupModel.addShow(mBillModel);
+
+                if ("T".equals(updatable)) {
+                    mGroupModel.addUpdate(mBillModel);
+                }
             } else {
                 mGroupModel.addHide(mBillModel);
             }
@@ -346,4 +418,812 @@ public class CustomerVisitDetailsActivity extends OABaseActivity {
             mListAdapter.notifyDataSetChanged();
         }
     }
+
+    @Override
+    public void onUpdateSelect(int position, BillGroupModel.BillModel model) {
+        if (("mp_address".equals(model.getField()))) {
+            selectPosition = model.getGroupIndex();
+            Intent intent = new Intent("com.modular.form.SelectAimActivity");
+            startActivityForResult(intent, TAG_ADDRESS_SELECT);
+            return;
+        }
+        if (TextUtils.isEmpty(model.getType())) {
+            return;
+        }
+        if (!ListUtils.isEmpty(model.getLocalDatas())) {
+            //本地数据不为空的情况下
+            selectByLocal(position, model);
+        } else {
+            //本地数据为空,获取网络数据
+            switch (model.getType()) {
+                case "C"://单项选择
+                    getComboValue(position, model);
+                    break;
+                case "DT"://时间选择
+                    showDateDialog(true, position);
+                    break;
+                case "D"://日期选择
+                case "T"://时间选择
+                    showDateDialog(false, position);
+                    break;
+                case "SF":
+                case "DF":
+                    //DBFind 选择
+                    findBydbFind(model);
+                    break;
+                case "MF":
+                    //多选
+                    findMore(position, model);
+                    break;
+
+            }
+        }
+    }
+
+    @Override
+    public void onUpdateEnclosure(int position, BillGroupModel.BillModel model) {
+        selectPosition = position;
+        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
+            toSelectEnclosure();
+        } else {
+            showSelectPictureDialog(model);
+        }
+    }
+
+    @Override
+    public void onUpdateConfirm(List<BillGroupModel> billGroupModels, List<BillGroupModel.BillModel> updateBillModels) {
+        mUpdateGroupModels = billGroupModels;
+        if (!CommonUtil.isRepeatClick(4000)) {
+            submitBill();
+        }
+//        saveAndSubmit(billGroupModels);
+    }
+
+    private void submitBill() {
+        String mp_cuname = "";
+        String mp_address = "";
+        List<BillGroupModel.BillModel> showBillModels = mBillUpdatePopup.getBillUpdateAdapter().getShowBillModels();
+        for (BillGroupModel.BillModel billModel : showBillModels) {
+            if ("mp_address".equals(billModel.getField())) {
+                mp_address = billModel.getValue();
+
+                if (StringUtil.isEmpty(mp_address) && billModel.isUpdatable()) {
+                    toast("当前地址不能为空");
+                    return;
+                }
+            }
+            if (StringUtil.hasOneEqual(billModel.getField(), "mp_cuname", "mp_xmmc_user")) {
+                mp_cuname = billModel.getValue();
+            }
+        }
+
+
+//        if (!StringUtil.isEmpty(mp_cuname) || !StringUtil.isEmpty(mp_address)) {
+        if (address == null) {
+            address = new SelectAimModel();
+        }
+        address.setName(mp_cuname);
+        address.setAddress(mp_address);
+
+        saveAddressAndSubmit();
+    }
+
+    private void saveAddressAndSubmit() {
+        List<BillGroupModel> billGroupModels = mBillUpdatePopup.getGroupModels();
+        /*if (address == null || address.getLatLng() == null) {
+            toast("地址信息为空,请重新选择当前地址");
+            return;
+        }*/
+
+        BillGroupModel latLngGroupModel = new BillGroupModel();
+        latLngGroupModel.setForm(true);
+
+        BillGroupModel.BillModel deviceModel = new BillGroupModel.BillModel();
+        deviceModel.setField("mp_sourceequipment");
+        deviceModel.setDisplay("Android");
+        latLngGroupModel.addHide(deviceModel);
+        if (address != null && address.getLatLng() != null) {
+            Map<String, Object> map = new HashMap<>();
+            map.put("company", address.getName());
+            map.put("companyAddress", address.getAddress());
+            map.put("visitTime", DateFormatUtil.long2Str(DateFormatUtil.YMD_HMS));
+            map.put("latitude", address.getLatLng().latitude);
+            map.put("longitude", address.getLatLng().longitude);
+            saveOutAddress(map);
+
+
+            BillGroupModel.BillModel latBillModel = new BillGroupModel.BillModel();
+            latBillModel.setField("mp_latitude");
+            latBillModel.setDisplay(address.getLatLng().latitude + "");
+            BillGroupModel.BillModel lngBillModel = new BillGroupModel.BillModel();
+            
+            lngBillModel.setField("mp_longitude");
+            lngBillModel.setDisplay(address.getLatLng().longitude + "");
+
+            latLngGroupModel.addHide(latBillModel);
+            latLngGroupModel.addHide(lngBillModel);
+        }
+        billGroupModels.add(latLngGroupModel);
+
+        saveAndSubmit(billGroupModels);
+    }
+
+    //保存外勤计划目的地
+    private void saveOutAddress(Map<String, Object> tagMap) {
+        String company = (String) tagMap.get("company");
+        String companyAddress = (String) tagMap.get("companyAddress");
+        String visitTime = (String) tagMap.get("visitTime");
+        double longitude = (double) tagMap.get("longitude");
+        double latitude = (double) tagMap.get("latitude");
+
+        Map<String, Object> formStore = new HashMap<>();
+        formStore.put("Md_company", company);//拜访公司
+        if (companyAddress.length() >= 200) {
+            companyAddress = companyAddress.substring(0, 190);
+        }
+        formStore.put("Md_address", companyAddress);//拜访地址
+        formStore.put("Md_visitcount", 1);//固定为1,由后台加1
+        formStore.put("Md_visittime", visitTime);//预计时间
+        formStore.put("Md_longitude", longitude);//经度
+        formStore.put("Md_latitude", latitude);//纬度
+        String emcode = CommonUtil.getEmcode();
+        formStore.put("Md_emcode", emcode);//纬度
+        mUUHttpHelper.requestCompanyHttp(new Parameter.Builder()
+                        .url("mobile/addOutAddress.action")
+                        .addParams("caller", "lp")
+                        .mode(Method.POST).record(SAVE_OUT_ADDRESS)
+                        .addParams("formStore", JSONUtil.map2JSON(formStore))
+                , mOnSmartHttpListener
+        );
+    }
+
+    public void saveAndSubmit(List<BillGroupModel> mGroupModels) {
+        showLoading();
+        List<BillGroupModel.BillModel> formFields = new ArrayList<>();
+        List<List<BillGroupModel.BillModel>> gridBillMap = new ArrayList<>();
+        List<BillGroupModel.GridTab> otherGridList = new ArrayList<>();
+        for (BillGroupModel e : mGroupModels) {
+            if (e.isForm()) {
+                if (e.getShowBillFields() != null) {
+                    formFields.addAll(e.getShowBillFields());
+                }
+                if (e.getHideBillFields() != null) {
+                    formFields.addAll(e.getHideBillFields());
+                }
+
+            } else {
+                List<BillGroupModel.GridTab> gridTabs = e.getGridTabs();
+                if (gridTabs != null && gridTabs.size() > 0) {
+                    otherGridList = gridTabs;
+                    break;
+                }
+                List<BillGroupModel.BillModel> gridBillFields = new ArrayList<>();
+                if (e.getShowBillFields() != null) {
+                    gridBillFields.addAll(e.getShowBillFields());
+                }
+                if (e.getHideBillFields() != null) {
+                    gridBillFields.addAll(e.getHideBillFields());
+                }
+                gridBillMap.add(gridBillFields);
+            }
+        }
+        if (otherGridList == null || otherGridList.size() <= 0) {
+            saveAndSubmit(mGroupModels, formFields, gridBillMap);
+        } else {
+//            saveAndSubmit(formFields, otherGridList, 0);
+        }
+    }
+
+    public void saveAndSubmit(final List<BillGroupModel> mGroupModels, List<BillGroupModel.BillModel> formFields, List<List<BillGroupModel.BillModel>> gridBillMap) {
+        Map<String, Object> formStore = new HashMap<>();
+        for (BillGroupModel.BillModel e : formFields) {
+            if (e.isUpdatable() && TextUtils.isEmpty(e.getValue()) && e.getIsdefault() == -1 &&
+                    ("necessaryField".equals(e.getAllowBlank()) || "F".equals(e.getAllowBlank()))) {
+                toast(e.getCaption() + "为必填项");
+                dimssLoading();
+                return;
+            }
+            if (isEnclosureNeedSubmit(e)) {
+                pushEnclosure(e);
+                return;
+            }
+            formStore.put(e.getField(), e.getDisplay());
+        }
+
+        List<Map<String, Object>> gridStoreList = analysisGrid(gridBillMap);
+        if (gridStoreList == null) {
+            return;
+        }
+        if (formStore == null || gridStoreList == null) {
+            dimssLoading();
+            return;
+        }
+
+        String formStoreStr = JSONUtil.map2JSON(formStore);
+        String gridStoreStr = JSONUtil.map2JSON(gridStoreList);
+
+        LogUtil.i("update", "formStoreStr=" + formStoreStr);
+        LogUtil.i("update", "gridStoreStr=" + gridStoreStr);
+
+        String sessionId = CommonUtil.getSharedPreferences(ct, "sessionId");
+        String emCode = CommonUtil.getEmcode();
+        com.me.network.app.http.HttpRequest.getInstance().sendRequest(CommonUtil.getAppBaseUrl(mContext),
+                new HttpParams.Builder()
+                        .url("common/mobile/modifydata.action")
+                        .flag(0)
+                        .method(Method.POST)
+                        .addParam("caller", mCaller)
+                        .addParam("formStore", formStoreStr)
+                        .addParam("gridStore", gridStoreStr)
+                        .addParam("sessionId", sessionId)
+                        .addParam("sessionUser", emCode)
+                        .addHeader("sessionUser", emCode)
+                        .addHeader("Cookie", "JSESSIONID=" + sessionId)
+                        .build(), new HttpCallback() {
+                    @Override
+                    public void onSuccess(int flag, Object o) throws Exception {
+                        dimssLoading();
+                        setAdapter(mGroupModels);
+
+                        Toast.makeText(ct, R.string.update_success, Toast.LENGTH_SHORT).show();
+
+                        if (mBillUpdatePopup != null) {
+                            mBillUpdatePopup.dismiss();
+                        }
+
+                        loadFormandGridDetail();
+                    }
+
+                    @Override
+                    public void onFail(int flag, String failStr) throws Exception {
+                        progressDialog.dismiss();
+                        Toast.makeText(ct, failStr, Toast.LENGTH_SHORT).show();
+                    }
+                });
+    }
+
+    public void saveAndSubmit(List<BillGroupModel.BillModel> formFields, List<BillGroupModel.GridTab> otherGridList, int flag) {
+        Map<String, Object> formStore = new HashMap<>();
+        for (BillGroupModel.BillModel e : formFields) {
+            if (TextUtils.isEmpty(e.getValue()) && e.getIsdefault() == -1 &&
+                    ("necessaryField".equals(e.getAllowBlank()) || "F".equals(e.getAllowBlank()))) {
+                toast(e.getCaption() + "为必填项");
+                progressDialog.dismiss();
+                return;
+            }
+            if (isEnclosureNeedSubmit(e)) {
+                pushEnclosure(e);
+                return;
+            }
+            formStore.put(e.getField(), e.getDisplay());
+        }
+
+        List<Map<String, Object>> otherGridStoreList = new ArrayList<>();
+        for (BillGroupModel.GridTab gridTab : otherGridList) {
+            if (gridTab != null) {
+                List<BillGroupModel> tabGroupModels = gridTab.getBillGroupModels();
+                String otherCaller = gridTab.getCaller();
+                if (tabGroupModels != null && tabGroupModels.size() > 0) {
+                    List<List<BillGroupModel.BillModel>> otherGridMap = new ArrayList<>();
+                    for (BillGroupModel tabGroupModel : tabGroupModels) {
+                        List<BillGroupModel.BillModel> otherGrid = new ArrayList<>();
+                        List<BillGroupModel.BillModel> otherShowFields = tabGroupModel.getShowBillFields();
+                        List<BillGroupModel.BillModel> otherHideFields = tabGroupModel.getHideBillFields();
+
+                        if (otherShowFields != null) {
+                            otherGrid.addAll(otherShowFields);
+                        }
+                        if (otherHideFields != null) {
+                            otherGrid.addAll(otherHideFields);
+                        }
+                        otherGridMap.add(otherGrid);
+                    }
+                    List<Map<String, Object>> otherGridStoreItem = analysisGrid(otherGridMap);
+                    if (otherGridStoreItem == null) {
+                        return;
+                    }
+                    String otherGridStoreItemStr = JSONUtil.map2JSON(otherGridStoreItem);
+                    JSONArray otherGridStoreItemArray = JSON.parseArray(otherGridStoreItemStr);
+
+                    Map<String, Object> OtherGridStoreItemMap = new HashMap<>();
+                    OtherGridStoreItemMap.put("dgcaller", otherCaller);
+                    OtherGridStoreItemMap.put("dgData", otherGridStoreItemArray);
+
+                    otherGridStoreList.add(OtherGridStoreItemMap);
+                }
+            }
+        }
+
+        String formStoreStr = JSONUtil.map2JSON(formStore);
+        String otherGridStoreListStr = JSONUtil.map2JSON(otherGridStoreList);
+        LogUtil.prinlnLongMsg("billJson", formStoreStr);
+        LogUtil.prinlnLongMsg("billJson", otherGridStoreListStr);
+
+        /*requestCompanyHttp(new Parameter.Builder()
+                        .url(mId == 0 ? "mobile/oa/commonSaveAndSubmit.action" : "mobile/commonUpdate.action")
+                        .mode(Method.POST)
+                        .addParams("caller", mCaller)
+                        .addParams("keyid", String.valueOf(mId))
+                        .addParams("formStore", formStoreStr)
+                        .addParams("othergridStore", otherGridStoreListStr)
+                        .record(SAVE_AND_SUBMIT)
+                , this);*/
+    }
+
+
+    @Nullable
+    private List<Map<String, Object>> analysisGrid(List<List<BillGroupModel.BillModel>> gridBillMap) {
+        List<Map<String, Object>> gridStoreList = new ArrayList<>();
+        for (List<BillGroupModel.BillModel> e : gridBillMap) {
+            if (!ListUtils.isEmpty(e)) {
+                Map<String, Object> gridStore = new HashMap<>();
+                for (BillGroupModel.BillModel billModel : e) {
+                    if (TextUtils.isEmpty(billModel.getValue())
+                            && ("necessaryField".equals(billModel.getAllowBlank())
+                            || "F".equals(billModel.getAllowBlank())) && billModel.getIsdefault() == -1) {
+                        toast(billModel.getCaption() + "为必填项");
+                        progressDialog.dismiss();
+                        return null;
+                    }
+                    if (isEnclosureNeedSubmit(billModel)) {
+                        pushEnclosure(billModel);
+                        return null;
+                    }
+                    gridStore.put(billModel.getField(), billModel.getDisplay());
+                }
+                gridStoreList.add(gridStore);
+            }
+        }
+        return gridStoreList;
+    }
+
+    public boolean isEnclosureNeedSubmit(BillGroupModel.BillModel billModel) {
+        return billModel.getType().equals("FF") && TextUtils.isEmpty(billModel.getValue()) && !ListUtils.isEmpty(billModel.getLocalDatas());
+
+    }
+
+    public void pushEnclosure(BillGroupModel.BillModel mBillModel) {
+        mBillModel.setLength(0);
+        uploadFile(mBillModel);
+    }
+
+    //上传文件
+    private void uploadFile(final BillGroupModel.BillModel mBillModel) {
+        String path = null;
+        if (mBillModel.getLength() < ListUtils.getSize(mBillModel.getLocalDatas())) {
+            //没有上传完成
+            BillGroupModel.LocalData data = mBillModel.getLocalDatas().get(mBillModel.getLength());
+            path = data.display;
+        } else {
+            toast("开始上传完成=" + mBillModel.getLength());
+            progressDialog.dismiss();
+            saveAndSubmit(mListAdapter.getGroupModels());
+            return;
+        }
+        toast("开始上传附件!!");
+        File mFile = new File(path);
+        RequestParams params = new RequestParams();
+        params.addQueryStringParameter("master", CommonUtil.getSharedPreferences(ct, "erp_master"));
+        params.addHeader("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
+        params.addBodyParameter("em_code", CommonUtil.getSharedPreferences(ct, "erp_username"));
+        params.addBodyParameter("type", "common");
+        params.addBodyParameter("file", mFile);
+        String url = CommonUtil.getAppBaseUrl(ct) + "mobile/uploadAttachs.action";
+        final HttpUtils http = new HttpUtils();
+        http.send(HttpRequest.HttpMethod.POST, url, params, new RequestCallBack<String>() {
+            @Override
+            public void onStart() {
+            }
+
+            @Override
+            public void onLoading(long total, long current, boolean isUploading) {
+            }
+
+            @Override
+            public void onSuccess(ResponseInfo<String> responseInfo) {
+                String result = responseInfo.result;
+                LogUtil.i("gong", "result-" + result);
+                if (JSONUtil.validate(result) && JSON.parseObject(result).getBoolean("success")) {
+                    mBillModel.setLength(mBillModel.getLength() + 1);
+                    JSONObject resultObject = JSON.parseObject(result);
+                    String phoneId = JSONUtil.getText(resultObject, "id");
+                    mBillModel.setValue(mBillModel.getValue() + "" + StringUtil.getLastBracket(phoneId) + ";");
+                    uploadFile(mBillModel);
+                }
+            }
+
+            @Override
+            public void onFailure(HttpException error, String msg) {
+                toast("附件上传失败");
+            }
+        });
+
+    }
+
+    private void toSelectEnclosure() {
+        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
+        intent.setType("*/*");//无类型限制
+        intent.addCategory(Intent.CATEGORY_OPENABLE);
+        startActivityForResult(intent, REQUESTCODE_ENCLOSURE);
+    }
+
+    private void toSelectEnclosure(BillGroupModel.BillModel model) {
+        Intent intent = new Intent(ct, ImgFileListActivity.class);
+        intent.putExtra("MAX_SIZE", 9);
+        intent.putExtra("CURRENT_SIZE", ListUtils.getSize(model.getLocalDatas()));
+        startActivityForResult(intent, REQUESTCODE_ENCLOSURE_LOW);
+    }
+
+    private void showSelectPictureDialog(final BillGroupModel.BillModel model) {
+        String[] items = new String[]{getString(com.modular.apputils.R.string.c_take_picture), getString(com.modular.apputils.R.string.c_photo_album)};
+        android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(this).setSingleChoiceItems(items, 0,
+                new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        if (which == 0) {
+                            try {
+                                takePhoto();
+                            } catch (Exception e) {
+                                String message = e.getMessage();
+                                if (!StringUtil.isEmpty(message) && message.contains("Permission")) {
+                                    ToastUtil.showToast(ct, com.modular.apputils.R.string.not_system_permission);
+                                }
+                            }
+                        } else {
+                            toSelectEnclosure(model);
+                        }
+                        dialog.dismiss();
+                    }
+                });
+        builder.show();
+    }
+
+    private Uri mNewPhotoUri;
+
+    private void takePhoto() throws Exception {
+        Uri mNewPhotoUri = CameraUtil.getOutputMediaFileUri(mContext, MyApplication.getInstance().mLoginUser.getUserId(), CameraUtil.MEDIA_TYPE_IMAGE);
+        if (mNewPhotoUri != null) {
+            CameraUtil.captureImage((Activity) ct,
+                    mNewPhotoUri,
+                    REQUEST_CODE_CAPTURE_PHOTO);
+        } else {
+            ToastUtil.showToast(this, "uri is null");
+        }
+    }
+
+    private void findMore(int position, BillGroupModel.BillModel model) {
+        HashMap param = new HashMap<>();
+        String[] fields = new String[]{"sa_custname"};
+        BillGroupModel mGroupModel = mListAdapter.getBillGroupModel(model.getGroupIndex());
+        boolean isForm = mGroupModel == null || mGroupModel.isForm();
+
+        param.put("caller", mCaller);
+        param.put("page", "1");
+        param.put("which", "form");
+        param.put("condition", "1=1");
+        param.put("pageSize", "1000");
+        param.put("field", model.getField());
+        Bundle bundle = new Bundle();
+        bundle.putSerializable("param", param);
+        Intent intent = new Intent(ct, SelectActivity.class);
+        intent.putExtra("type", 1);
+        intent.putExtra("isSingle", false);
+        intent.putExtra("reid", com.modular.apputils.R.style.OAThemeMeet);
+        intent.putExtras(bundle);
+        intent.putExtra("key", "combdatas");
+        intent.putExtra("showKey", model.getField());
+        intent.putExtra("fields", fields);
+        intent.putExtra("action", "common/dbfind.action");
+        intent.putExtra("title", model.getCaption());
+        intent.putExtra("id", model.getGroupIndex());
+        intent.putExtra("isForm", isForm);
+        startActivityForResult(intent, REQUEST_CODE_SELECT_MORE);
+    }
+
+
+    /**
+     * 选择本地数据选项
+     *
+     * @param position 索引
+     * @param model    点击对象
+     */
+    public void selectByLocal(int position, BillGroupModel.BillModel model) {
+        ArrayList<SelectBean> beans = new ArrayList<>();
+        SelectBean bean;
+        for (BillGroupModel.LocalData localData : model.getLocalDatas()) {
+            bean = new SelectBean();
+            bean.setJson(localData.display);
+            bean.setShowName(localData.value);
+            bean.setName(localData.value);
+            bean.setIndex(position);
+            beans.add(bean);
+        }
+        Intent intent = new Intent(ct, SelectActivity.class);
+        intent.putExtra("type", 2);
+        intent.putParcelableArrayListExtra("data", beans);
+        intent.putExtra("title", model.getCaption());
+        startActivityForResult(intent, REQUESTCODE_C);
+    }
+
+    public void getComboValue(int position, BillGroupModel.BillModel model) {
+        HashMap param = new HashMap<>();
+        param.put("caller", mCaller);
+        param.put("field", model.getField());
+        Bundle bundle = new Bundle();
+        bundle.putSerializable("param", param);
+        Intent intent = new Intent(ct, SelectActivity.class);
+        intent.putExtra("type", 1);
+        intent.putExtra("reid", com.modular.apputils.R.style.OAThemeMeet);
+        intent.putExtras(bundle);
+        intent.putExtra("key", "combdatas");
+        intent.putExtra("showKey", "DISPLAY");
+        intent.putExtra("action", "mobile/common/getComboValue.action");
+        intent.putExtra("title", model.getCaption());
+        intent.putExtra("id", position);//需要把zum
+        startActivityForResult(intent, REQUESTCODE_C_NET);
+    }
+
+    /**
+     * 选择日期
+     */
+    public void showDateDialog(final boolean needTime, final int position) {
+        DateTimePicker picker = new DateTimePicker(this, needTime ? DateTimePicker.HOUR_OF_DAY : DateTimePicker.YEAR_MONTH_DAY);
+        picker.setRange(CalendarUtil.getYear() - 100, CalendarUtil.getYear() + 20);
+        if (needTime) {
+            picker.setSelectedItem(CalendarUtil.getYear(), CalendarUtil.getMonth(), CalendarUtil.getDay(), CalendarUtil.getHour(), CalendarUtil.getMinute());
+        } else {
+            picker.setSelectedItem(CalendarUtil.getYear(), CalendarUtil.getMonth(), CalendarUtil.getDay());
+        }
+        picker.setOnDateTimePickListener(new DateTimePicker.OnYearMonthDayTimePickListener() {
+            @Override
+            public void onDateTimePicked(String year, String month, String day, String hour, String minute) {
+                String date = year + "-" + month + "-" + day;
+                String dateTime = date + " " + hour + ":" + minute + ":00";
+                mBillUpdatePopup.updateBillModelValues(position, needTime ? dateTime : date, needTime ? dateTime : date);
+            }
+        });
+        picker.setOnCancelListener(new DateTimePicker.OnCancelListener() {
+            @Override
+            public void onCancel() {
+                mBillUpdatePopup.updateBillModelValues(position, "", "");
+            }
+        });
+        picker.show();
+    }
+
+    /**
+     * dbfind 查找
+     *
+     * @param model
+     */
+    public void findBydbFind(BillGroupModel.BillModel model) {
+        String gridCaller = "";
+        String fieldKey = model.getField();
+        BillGroupModel mGroupModel = mListAdapter.getBillGroupModel(model.getGroupIndex());
+        boolean isForm = mGroupModel == null || mGroupModel.isForm();
+        if (!isForm && !StringUtil.isEmpty(model.getFindFunctionName())) {
+            String[] mFindFunctionNames = model.getFindFunctionName().split("\\|");
+            if (mFindFunctionNames != null && mFindFunctionNames.length > 1) {
+                gridCaller = mFindFunctionNames[0];
+//                fieldKey = mFindFunctionNames[1];
+            }
+        }
+        String mCondition = "";
+        /*if (dbFindCondition != null && dbFindCondition.containsKey(fieldKey)) {
+            mCondition = dbFindCondition.get(fieldKey);
+        }*/
+        startActivityForResult(new Intent(ct, SelectNetAcitivty.class)
+                        .putExtra("fieldKey", fieldKey)
+                        .putExtra("caller", mGroupModel == null ? mCaller
+                                : mGroupModel.getBillCaller())
+                        .putExtra("gCaller", gridCaller)
+                        .putExtra("mCondition", mCondition)
+                        .putExtra("isDevice", false)
+                        .putExtra("isForm", isForm)
+                        .putExtra("groupId", model.getGroupIndex())
+                , REQUESTCODE_DB_FIND);
+    }
+
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        if (data == null) return;
+        switch (requestCode) {
+            case REQUEST_CODE_SELECT_MORE:
+                if (resultCode == 0x21) {//多选框
+                    int groupIndex = data.getIntExtra("id", 0);
+                    boolean isForm = data.getBooleanExtra("isForm", true);
+                    ArrayList<SelectBean> muliData = data.getParcelableArrayListExtra("data");
+                    JSONObject object = null;
+                    if (!ListUtils.isEmpty(muliData)) {
+                        object = JSON.parseObject(muliData.get(0).getJson());
+                        String dbFind = muliData.get(0).getDbfinds();
+                        for (int i = 1; i < muliData.size(); i++) {
+                            SelectBean b = muliData.get(i);
+                            JSONObject bObject = JSON.parseObject(b.getJson());
+                            for (Map.Entry<String, Object> entry : bObject.entrySet()) {
+                                String oldText = object.getString(entry.getKey());
+                                object.put(entry.getKey(), oldText + "#" + entry.getValue());
+                            }
+                        }
+                        if (!TextUtils.isEmpty(dbFind)) {
+                            JSONArray fbFindArray = JSON.parseArray(dbFind);
+                            if (!ListUtils.isEmpty(fbFindArray)) {
+                                for (int i = 0; i < fbFindArray.size(); i++) {
+                                    String dbGridField = JSONUtil.getText(fbFindArray.getJSONObject(i), "dbGridField");
+                                    String field = JSONUtil.getText(fbFindArray.getJSONObject(i), "field");
+                                    if (object.containsKey(dbGridField)) {
+                                        object.put(field, object.get(dbGridField));
+                                        object.remove(dbGridField);
+                                    }
+                                }
+                            }
+                        }
+                    }
+//                    mBillAdapter.updateBillModelValues(id, values, values);
+                    LogUtil.i("gong", "object=" + object);
+                    LogUtil.i("gong", "groupIndex=" + groupIndex);
+                    handlerSelectDbFind(object, groupIndex, isForm);
+                }
+                break;
+            case REQUESTCODE_C_NET:
+                SelectBean mSelectBeanC = data.getParcelableExtra("data");
+                int position = data.getIntExtra("id", -1);
+                if (mSelectBeanC != null && position >= 0) {
+                    String display = StringUtil.isEmpty(mSelectBeanC.getName()) ? "" : mSelectBeanC.getName();
+                    String value = StringUtil.isEmpty(mSelectBeanC.getName()) ? "" : mSelectBeanC.getName();
+                    mBillUpdatePopup.updateBillModelValues(position, value, display);
+                }
+                break;
+            case REQUESTCODE_C:
+                mSelectBeanC = data.getParcelableExtra("data");
+                if (mSelectBeanC != null) {
+                    position = mSelectBeanC.getIndex();
+                    String value = StringUtil.isEmpty(mSelectBeanC.getShowName()) ? "" : mSelectBeanC.getShowName();
+                    String display = StringUtil.isEmpty(mSelectBeanC.getJson()) ? "" : mSelectBeanC.getJson();
+                    mBillUpdatePopup.updateBillModelValues(position, value, display);
+                }
+                break;
+            case REQUESTCODE_DB_FIND:
+                String json = data.getStringExtra("data");
+                int groupIndex = data.getIntExtra("groupId", 0);
+                boolean isForm = data.getBooleanExtra("isForm", true);
+                handlerSelectDbFind(JSON.parseObject(json), groupIndex, isForm);
+                break;
+            case REQUESTCODE_ENCLOSURE:
+                if (resultCode == Activity.RESULT_OK) {
+                    String path;
+                    Uri uri = data.getData();
+                    if ("file".equalsIgnoreCase(uri.getScheme())) {//使用第三方应用打开
+                        path = uri.getPath();
+                    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {//4.4以后
+                        path = FileUtils.getPath(this, uri);
+                    } else {//4.4以下下系统调用方法
+                        path = FileUtils.getRealPathFromURI(this, uri);
+                    }
+                    LogUtil.i("gong", "uri=" + uri.toString());
+                    File file = null;
+                    if (!TextUtils.isEmpty(path)) {
+                        file = new File(path);
+                    }
+                    if (file != null && file.exists() && file.isFile()) {
+                        String value = file.getName();
+                        String display = path;
+                        mBillUpdatePopup.getBillUpdateAdapter().addBillModelData(selectPosition, value, display);
+                        selectPosition = -1;
+                    }
+
+                }
+            case REQUEST_CODE_CAPTURE_PHOTO:
+                if (resultCode == Activity.RESULT_OK) {
+                    if (mNewPhotoUri != null) {
+                        String value = mNewPhotoUri.getPath();
+                        String display = value;
+                        mBillUpdatePopup.getBillUpdateAdapter().addBillModelData(selectPosition, value, display);
+                        selectPosition = -1;
+                    } else {
+                        ToastUtil.showToast(this, com.modular.apputils.R.string.c_take_picture_failed);
+                    }
+                }
+                break;
+            case REQUESTCODE_ENCLOSURE_LOW:
+                List<String> filePaths = data.getStringArrayListExtra("files");
+                if (!ListUtils.isEmpty(filePaths)) {
+                    File file = null;
+                    List<BillGroupModel.LocalData> localDatas = new ArrayList<>();
+                    for (String filePath : filePaths) {
+                        if (!TextUtils.isEmpty(filePath)) {
+                            file = new File(filePath);
+                        }
+                        if (file != null && file.exists() && file.isFile()) {
+                            BillGroupModel.LocalData localData = new BillGroupModel.LocalData();
+                            localData.value = file.getName();
+                            localData.display = filePath;
+                            localDatas.add(localData);
+                        }
+                    }
+                    mBillUpdatePopup.getBillUpdateAdapter().addBillModelData(selectPosition, localDatas);
+                    selectPosition = -1;
+                }
+                break;
+            case TAG_ADDRESS_SELECT:
+                SelectAimModel chcheAimModel = data.getParcelableExtra("data");
+                sureSelectAim(chcheAimModel);
+                break;
+        }
+    }
+
+    private void sureSelectAim(SelectAimModel entity) {
+        if (entity == null || selectPosition < 0 || selectPosition > ListUtils.getSize(mBillUpdatePopup.getGroupModels())) {
+            selectPosition = -1;
+            return;
+        }
+        String company = StringUtil.isEmpty(entity.getName()) ? "" : entity.getName();
+        String companyAddress = StringUtil.isEmpty(entity.getAddress()) ? "" : entity.getAddress();
+        BillGroupModel mBillGroupModel = mBillUpdatePopup.getBillGroupModel(selectPosition);
+        if (mBillGroupModel != null) {
+            if (!ListUtils.isEmpty(mBillGroupModel.getShowBillFields())) {
+                for (BillGroupModel.BillModel e : mBillGroupModel.getShowBillFields()) {
+                    if ("mp_address".equals(e.getField()) || "当前地址".equals(e.getCaption())) {
+                        e.setValue(companyAddress);
+                        if (address == null) {
+                            address = new SelectAimModel();
+                        }
+                        address.setLatLng(entity.getLatLng());
+                    }
+                }
+            }
+            if (!ListUtils.isEmpty(mBillGroupModel.getHideBillFields())) {
+                for (BillGroupModel.BillModel e : mBillGroupModel.getHideBillFields()) {
+                    if ("mp_address".equals(e.getField()) || "当前地址".equals(e.getCaption())) {
+                        e.setValue(companyAddress);
+                        if (address == null) {
+                            address = new SelectAimModel();
+                        }
+                        address.setLatLng(entity.getLatLng());
+                    }
+                }
+            }
+        }
+        mBillUpdatePopup.notifyDataSetChanged();
+    }
+
+    protected void handlerSelectDbFind(JSONObject object, int groupId, boolean isForm) {
+        List<BillGroupModel> groupModels = mListAdapter.getGroupModels();
+        if (isForm) {
+            List<BillGroupModel.BillModel> formBillModels = mBillUpdatePopup.getBillUpdateAdapter().getFormBillModels();
+
+            if (!ListUtils.isEmpty(formBillModels)) {
+                for (BillGroupModel.BillModel billModel : formBillModels) {
+                    if (object.containsKey(billModel.getField())) {
+                        billModel.setValue(JSONUtil.getText(object, billModel.getField()));
+                    }
+                }
+            }
+        } else {
+            BillGroupModel mBillGroupModel = mBillUpdatePopup.getBillUpdateAdapter().getBillGroupModel(groupId);
+            if (mBillGroupModel != null) {
+                if (!ListUtils.isEmpty(mBillGroupModel.getShowBillFields())) {
+                    for (BillGroupModel.BillModel e : mBillGroupModel.getShowBillFields()) {
+                        if (object.containsKey(e.getField())) {
+                            e.setValue(JSONUtil.getText(object, e.getField()));
+                        }
+                    }
+                }
+                if (!ListUtils.isEmpty(mBillGroupModel.getHideBillFields())) {
+                    for (BillGroupModel.BillModel e : mBillGroupModel.getHideBillFields()) {
+                        if (object.containsKey(e.getField())) {
+                            e.setValue(JSONUtil.getText(object, e.getField()));
+                        }
+                    }
+                }
+            }
+        }
+
+        List<BillGroupModel> groupModels1 = mListAdapter.getGroupModels();
+
+        mBillUpdatePopup.getBillUpdateAdapter().notifyDataSetChanged();
+    }
+
 }

+ 38 - 1
app_modular/appworks/src/main/java/com/uas/appworks/crm3_0/activity/VisitRecordBillInputActivity.java

@@ -3,16 +3,19 @@ package com.uas.appworks.crm3_0.activity;
 
 import android.content.Intent;
 import android.os.Handler;
+import android.text.TextUtils;
 
 import com.core.app.Constants;
 import com.core.utils.CommonUtil;
 import com.modular.apputils.activity.BillDetailsActivity;
 import com.modular.apputils.activity.BillInputActivity;
 import com.modular.apputils.activity.BillListActivity;
+import com.modular.apputils.model.BillGroupModel;
 import com.modular.apputils.model.BillListConfig;
 import com.uas.appworks.R;
 
 import java.util.ArrayList;
+import java.util.List;
 
 //拜访报告录入界面
 public class VisitRecordBillInputActivity extends BillInputActivity {
@@ -78,8 +81,42 @@ public class VisitRecordBillInputActivity extends BillInputActivity {
         }, 2000);
     }
 
+    @Override
+    public void toSelect(int position, BillGroupModel.BillModel model) {
+        if ("cup_name".equals(model.getField())) {
+            String master = CommonUtil.getMaster();
+            if ("DATACENTER".equals(master) || "N_SHYZ".equals(master) || "N_AJC".equals(master)) {
+                List<BillGroupModel.BillModel> allBillModels = mBillAdapter.getmAllBillModels();
+                String vr_cuuu = "", vr_prjcode = "", vr_prjandcus_user = "";
+                for (BillGroupModel.BillModel billModel : allBillModels) {
+                    if (!TextUtils.isEmpty(billModel.getValue())) {
+                        if ("vr_cuuu".equals(billModel.getField())) {
+                            vr_cuuu = billModel.getValue();
+                        }
+                        if ("vr_prjcode".equals(billModel.getField())) {
+                            vr_prjcode = billModel.getValue();
+                        }
+                    }
+                    if ("vr_prjandcus_user".equals(billModel.getField())) {
+                        vr_prjandcus_user = billModel.getValue();
+                    }
+                }
 
-//    @Override
+                if (TextUtils.isEmpty(vr_cuuu) && TextUtils.isEmpty(vr_prjcode)) {
+                    toast("请先选择客户编号或项目编号");
+                    return;
+                }
+                String condition = "sign=\'" + vr_prjandcus_user + "\'";
+                findBydbFind(model, condition);
+            } else {
+                super.toSelect(position, model);
+            }
+        } else {
+            super.toSelect(position, model);
+        }
+    }
+
+    //    @Override
 //    public void toSelect(int position, BillGroupModel.BillModel model) {
 //        if ("C".equals(model.getType()) && "vr_group".equals(model.getField())) {
 //            LogUtil.i("gong", "position=" + position);

+ 344 - 298
app_modular/appworks/src/main/java/com/uas/appworks/dao/MissionDao.java

@@ -4,7 +4,7 @@ import android.content.ContentValues;
 import android.database.Cursor;
 import android.database.SQLException;
 import android.database.sqlite.SQLiteDatabase;
-import android.util.Log;
+import android.support.annotation.NonNull;
 
 import com.alibaba.fastjson.JSON;
 import com.baidu.mapapi.model.LatLng;
@@ -14,7 +14,6 @@ import com.common.data.ListUtils;
 import com.common.data.StringUtil;
 import com.core.api.wxapi.ApiPlatform;
 import com.core.api.wxapi.ApiUtils;
-import com.core.app.AppConfig;
 import com.core.app.MyApplication;
 import com.core.db.DatabaseManager;
 import com.core.model.MissionModel;
@@ -37,319 +36,366 @@ import java.util.List;
 
 public class MissionDao {
 
-	private String tibleName = "mission";
-	private static MissionDao instance;
+    private String tibleName = "mission";
+    private static MissionDao instance;
 
-	public static MissionDao getInstance() {
-		if (instance == null) {
-			synchronized (MissionDao.class) {
-				instance = new MissionDao();
-			}
-		}
-		return instance;
-	}
+    public static MissionDao getInstance() {
+        if (instance == null) {
+            synchronized (MissionDao.class) {
+                instance = new MissionDao();
+            }
+        }
+        return instance;
+    }
 
-	public MissionDao() {
-	}
+    public MissionDao() {
+    }
 
 
-	/**
-	 * 修改状态
-	 *
-	 * @param id     id
-	 * @param status 状态值
-	 * @return
-	 */
-	public boolean upStatus(int id, int status) {
-		SQLiteDatabase db = null;
-		long i = 0;
-		try {
-			String master = getMaster();
-			String emcode = getEmcode();
-			if (StringUtil.isEmpty(master) || StringUtil.isEmpty(emcode)) return false;
-			db = DatabaseManager.getInstance().openDatabase();
-			ContentValues values = new ContentValues();
-			values.put("status", status);
-			String where = "master=? and emcode=? and id=? ";
-			String[] whereArgs = {master, emcode, String.valueOf(id)};
-			i = db.update(tibleName, values, where, whereArgs);
-		} catch (SQLException e) {
-			LogUtil.i("SQLException=" + e.getMessage());
-		} catch (Exception e) {
-			LogUtil.i("Exception=" + e.getMessage());
-		} finally {
-			if (db != null)
-				DatabaseManager.getInstance().closeDatabase();
-			return i > 0;
-		}
-	}
+    /**
+     * 修改状态
+     *
+     * @param id     id
+     * @param status 状态值
+     * @return
+     */
+    public boolean upStatus(int id, int status) {
+        SQLiteDatabase db = null;
+        long i = 0;
+        try {
+            String master = getMaster();
+            String emcode = getEmcode();
+            if (StringUtil.isEmpty(master) || StringUtil.isEmpty(emcode)) return false;
+            db = DatabaseManager.getInstance().openDatabase();
+            ContentValues values = new ContentValues();
+            values.put("status", status);
+            String where = "master=? and emcode=? and id=? ";
+            String[] whereArgs = {master, emcode, String.valueOf(id)};
+            i = db.update(tibleName, values, where, whereArgs);
+        } catch (SQLException e) {
+            LogUtil.i("SQLException=" + e.getMessage());
+        } catch (Exception e) {
+            LogUtil.i("Exception=" + e.getMessage());
+        } finally {
+            if (db != null)
+                DatabaseManager.getInstance().closeDatabase();
+            return i > 0;
+        }
+    }
 
-	//获取当天全部数据
-	public List<MissionModel> queryByEnCode() {
-		SQLiteDatabase db = null;
-		Cursor cursor = null;
-		List<MissionModel> missions = null;
-		try {
-			String master = getMaster();
-			String emcode = getEmcode();
-			String date = DateFormatUtil.long2Str(DateFormatUtil.YMD);
-			if (StringUtil.isEmpty(master) || StringUtil.isEmpty(emcode)) return missions;
-			db = DatabaseManager.getInstance().openDatabase();
-			String[] columns = {"id", "company",
-					"companyAddr", "latitude",
-					"longitude", "visittime",
-					"realvisitTime", "realLeaveTime",
-					"status", "distance",
-					"location", "recorddate",
-					"remark", "type"};
-			String selection = "master =? and emcode=? and date=?";
-			String[] selecttionArg = {master, emcode, date};
-			cursor = db.query(tibleName, columns, selection, selecttionArg, null, null, null);
-			MissionModel mission = null;
-			missions = new ArrayList<>();
-			while (cursor.moveToNext()) {
-				mission = new MissionModel();
-				mission.setId(cursor.getInt(0));
-				mission.setCompanyName(cursor.getString(1));
-				mission.setCompanyAddr(cursor.getString(2));
-				double latitude = cursor.getDouble(3);
-				double longitude = cursor.getDouble(4);
-				if (latitude > 0 && longitude > 0)
-					mission.setLatLng(new LatLng(latitude, longitude));
-				mission.setVisitTime(cursor.getString(5));
-				mission.setRealTime(cursor.getString(6));
-				mission.setRealLeave(cursor.getString(7));
-				mission.setStatus(cursor.getInt(8));
-				mission.setDistance(cursor.getDouble(9));
-				mission.setLocation(cursor.getString(10));
-				mission.setRecorddate(cursor.getString(11));
-				mission.setRemark(cursor.getString(12));
-				mission.setType(cursor.getInt(13));
-				missions.add(mission);
-			}
-			cursor.close();
-		} catch (SQLException e) {
-			LogUtil.i("SQLException=" + e.getMessage());
-		} catch (Exception e) {
-			LogUtil.i("Exception=" + e.getMessage());
-		} finally {
-			if (db != null)
-				DatabaseManager.getInstance().closeDatabase();
-			return missions;
-		}
-	}
+    //获取当天全部数据
+    public List<MissionModel> queryByEnCode() {
+        SQLiteDatabase db = null;
+        List<MissionModel> missions = null;
+        try {
+            String master = getMaster();
+            String emcode = getEmcode();
+            if (StringUtil.isEmpty(master) || StringUtil.isEmpty(emcode)) return missions;
+            db = DatabaseManager.getInstance().openDatabase();
 
-	public boolean updataOrCreate(MissionModel mission) {
-		if (mission == null || StringUtil.isEmpty(mission.getVisitTime())) return false;
-		SQLiteDatabase db = null;
-		long i = 0;
-		try {
-			String master = getMaster();
-			String emcode = getEmcode();
-			if (StringUtil.isEmpty(master) || StringUtil.isEmpty(emcode)) return false;
-			db = DatabaseManager.getInstance().openDatabase();
-			ContentValues values = null;
-			LogUtil.i("MissionPlanEntity");
-			//对象为空或是拜访时间没有情况下不插入数据库
-			values = new ContentValues();
-			values.put("id", mission.getId());
-			values.put("master", master);
-			values.put("emcode", emcode);
-			values.put("company", mission.getCompanyName());
-			values.put("companyAddr", mission.getCompanyAddr());
-			if (mission.getLatLng() != null) {
-				values.put("latitude", mission.getLatLng().latitude);
-				values.put("longitude", mission.getLatLng().longitude);
-			}
-			values.put("visittime", mission.getVisitTime());
-			values.put("realvisitTime", mission.getRealTime());
-			values.put("realLeaveTime", mission.getRealLeave());
-			values.put("distance", mission.getDistance());
-			values.put("location", mission.getLocation());
-			values.put("remark", mission.getRemark());
-			values.put("recorddate", mission.getRecorddate());
-			values.put("date", getDateByString(mission.getVisitTime()));//拜访日期
-			i = db.insert(tibleName, "status", values);
-			if (i == -1) {
-				String where = "master=? and emcode=? and id=? ";
-				String[] whereArgs = {master, emcode, String.valueOf(mission.getId())};
-				i = db.update(tibleName, values, where, whereArgs);
-				LogUtil.i("update i=" + i);
-			}
-			LogUtil.i("i====" + i);
-		} catch (SQLException e) {
-			LogUtil.i("SQLException=" + e.getMessage());
-		} catch (Exception e) {
-			LogUtil.i("Exception=" + e.getMessage());
-		} finally {
-			if (db != null)
-				DatabaseManager.getInstance().closeDatabase();
-			return i > 0;
-		}
-	}
+            missions = getMissionModels(db, master, emcode);
+        } catch (SQLException e) {
+            LogUtil.i("SQLException=" + e.getMessage());
+        } catch (Exception e) {
+            LogUtil.i("Exception=" + e.getMessage());
+        } finally {
+            if (db != null)
+                DatabaseManager.getInstance().closeDatabase();
+            return missions;
+        }
+    }
 
-	public boolean updataOrCreate(List<MissionModel> entities) {
-		if (ListUtils.isEmpty(entities)) return false;
-		LogUtil.i("updataOrCreate");
-		SQLiteDatabase db = null;
-		long i = 0;
-		try {
-			String master = getMaster();
-			String emcode = getEmcode();
-			if (StringUtil.isEmpty(master) || StringUtil.isEmpty(emcode)) return false;
-			db = DatabaseManager.getInstance().openDatabase();
-			db.beginTransaction();//开启事务
+    @NonNull
+    private List<MissionModel> getMissionModels(SQLiteDatabase db, String master, String emcode) {
+        String date = DateFormatUtil.long2Str(DateFormatUtil.YMD);
+        String[] columns = {"id", "company",
+                "companyAddr", "latitude",
+                "longitude", "visittime",
+                "realvisitTime", "realLeaveTime",
+                "status", "distance",
+                "location", "recorddate",
+                "remark", "type"};
+        String selection = "master =? and emcode=? and date=?";
+        String[] selecttionArg = {master, emcode, date};
+        Cursor cursor = db.query(tibleName, columns, selection, selecttionArg, null, null, null);
+        MissionModel mission = null;
+        List<MissionModel> missions = new ArrayList<>();
+        while (cursor.moveToNext()) {
+            mission = new MissionModel();
+            mission.setId(cursor.getInt(0));
+            mission.setCompanyName(cursor.getString(1));
+            mission.setCompanyAddr(cursor.getString(2));
+            double latitude = cursor.getDouble(3);
+            double longitude = cursor.getDouble(4);
+            if (latitude > 0 && longitude > 0)
+                mission.setLatLng(new LatLng(latitude, longitude));
+            mission.setVisitTime(cursor.getString(5));
+            mission.setRealTime(cursor.getString(6));
+            mission.setRealLeave(cursor.getString(7));
+            mission.setStatus(cursor.getInt(8));
+            mission.setDistance(cursor.getDouble(9));
+            mission.setLocation(cursor.getString(10));
+            mission.setRecorddate(cursor.getString(11));
+            mission.setRemark(cursor.getString(12));
+            mission.setType(cursor.getInt(13));
+            missions.add(mission);
+        }
+        cursor.close();
+        return missions;
+    }
 
-			ContentValues values = null;
-			for (MissionModel mission : entities) {
-				LogUtil.i("MissionPlanEntity");
-				//对象为空或是拜访时间没有情况下不插入数据库
-				if (mission == null || StringUtil.isEmpty(mission.getVisitTime())) {
-					continue;
-				}
-				values = new ContentValues();
-				values.put("id", mission.getId());
-				values.put("master", master);
-				values.put("emcode", emcode);
-				values.put("company", mission.getCompanyName());
-				values.put("companyAddr", mission.getCompanyAddr());
-				if (mission.getLatLng() != null) {
-					values.put("latitude", mission.getLatLng().latitude);
-					values.put("longitude", mission.getLatLng().longitude);
-				}
-				values.put("visittime", mission.getVisitTime());
-				values.put("realvisitTime", mission.getRealTime());
-				values.put("realLeaveTime", mission.getRealLeave());
-				values.put("distance", mission.getDistance());
-				values.put("location", mission.getLocation());
-				values.put("remark", mission.getRemark());
-				values.put("type", mission.getType());
-				values.put("recorddate", mission.getRecorddate());
-				values.put("date", getDateByString(mission.getVisitTime()));//拜访日期
-				i = db.insert(tibleName, "status", values);
-				if (i == -1) {
-					String where = "master=? and emcode=? and id=? ";
-					String[] whereArgs = {master, emcode, String.valueOf(mission.getId())};
-					i = db.update(tibleName, values, where, whereArgs);
-					LogUtil.i("update i=" + i);
-				}
-				LogUtil.i("i====" + i);
-			}
-			db.setTransactionSuccessful();
-		} catch (SQLException e) {
-			LogUtil.i("SQLException=" + e.getMessage());
-		} catch (Exception e) {
-			LogUtil.i("Exception=" + e.getMessage());
-		} finally {
-			db.endTransaction();
-			if (db != null)
-				DatabaseManager.getInstance().closeDatabase();
-			return i > 0;
-		}
-	}
+    public boolean updataOrCreate(MissionModel mission) {
+        if (mission == null || StringUtil.isEmpty(mission.getVisitTime())) return false;
+        SQLiteDatabase db = null;
+        long i = 0;
+        try {
+            String master = getMaster();
+            String emcode = getEmcode();
+            if (StringUtil.isEmpty(master) || StringUtil.isEmpty(emcode)) return false;
+            db = DatabaseManager.getInstance().openDatabase();
+            ContentValues values = null;
+            LogUtil.i("MissionPlanEntity");
+            //对象为空或是拜访时间没有情况下不插入数据库
+            values = new ContentValues();
+            values.put("id", mission.getId());
+            values.put("master", master);
+            values.put("emcode", emcode);
+            values.put("company", mission.getCompanyName());
+            values.put("companyAddr", mission.getCompanyAddr());
+            if (mission.getLatLng() != null) {
+                values.put("latitude", mission.getLatLng().latitude);
+                values.put("longitude", mission.getLatLng().longitude);
+            }
+            values.put("visittime", mission.getVisitTime());
+            values.put("realvisitTime", mission.getRealTime());
+            values.put("realLeaveTime", mission.getRealLeave());
+            values.put("distance", mission.getDistance());
+            values.put("location", mission.getLocation());
+            values.put("remark", mission.getRemark());
+            values.put("recorddate", mission.getRecorddate());
+            values.put("date", getDateByString(mission.getVisitTime()));//拜访日期
+            i = db.insert(tibleName, "status", values);
+            if (i == -1) {
+                String where = "master=? and emcode=? and id=? ";
+                String[] whereArgs = {master, emcode, String.valueOf(mission.getId())};
+                i = db.update(tibleName, values, where, whereArgs);
+                LogUtil.i("update i=" + i);
+            }
+            LogUtil.i("i====" + i);
+        } catch (SQLException e) {
+            LogUtil.i("SQLException=" + e.getMessage());
+        } catch (Exception e) {
+            LogUtil.i("Exception=" + e.getMessage());
+        } finally {
+            if (db != null)
+                DatabaseManager.getInstance().closeDatabase();
+            return i > 0;
+        }
+    }
 
-	//更新
-	public boolean updata(MissionModel mission) {
-		LogUtil.i("update" + JSON.toJSONString(mission));
-		SQLiteDatabase db = null;
-		long i = 0;
-		try {
-			String master = getMaster();
-			String emcode = getEmcode();
-			if (StringUtil.isEmpty(master) || StringUtil.isEmpty(emcode)) return false;
-			db = DatabaseManager.getInstance().openDatabase();
-			ContentValues values = new ContentValues();
-			if (mission.getLatLng() != null) {
-				values.put("latitude", mission.getLatLng().latitude);
-				values.put("longitude", mission.getLatLng().longitude);
-			}
-			values.put("visittime", mission.getVisitTime());
-			values.put("realvisitTime", mission.getRealTime());
-			values.put("realLeaveTime", mission.getRealLeave());
-			values.put("status", mission.getStatus());
-			String where = "master=? and emcode=? and id=? ";
-			String[] whereArgs = {master, emcode, String.valueOf(mission.getId())};
-			i = db.update(tibleName, values, where, whereArgs);
-		} catch (SQLException e) {
-			LogUtil.i("SQLException=" + e.getMessage());
-		} catch (Exception e) {
-			LogUtil.i("Exception=" + e.getMessage());
-		} finally {
-			if (db != null)
-				DatabaseManager.getInstance().closeDatabase();
-			return i > 0;
-		}
-	}
+    public boolean updataOrCreate(List<MissionModel> entities) {
+        if (ListUtils.isEmpty(entities)) return false;
+        LogUtil.i("updataOrCreate");
+        SQLiteDatabase db = null;
+        long i = 0;
+        try {
+            String master = getMaster();
+            String emcode = getEmcode();
+            if (StringUtil.isEmpty(master) || StringUtil.isEmpty(emcode)) return false;
+            db = DatabaseManager.getInstance().openDatabase();
+            db.beginTransaction();//开启事务
 
+            ContentValues values = null;
+            for (MissionModel mission : entities) {
+                LogUtil.i("MissionPlanEntity");
+                //对象为空或是拜访时间没有情况下不插入数据库
+                if (mission == null || StringUtil.isEmpty(mission.getVisitTime())) {
+                    continue;
+                }
+                values = new ContentValues();
+                values.put("id", mission.getId());
+                values.put("master", master);
+                values.put("emcode", emcode);
+                values.put("company", mission.getCompanyName());
+                values.put("companyAddr", mission.getCompanyAddr());
+                if (mission.getLatLng() != null) {
+                    values.put("latitude", mission.getLatLng().latitude);
+                    values.put("longitude", mission.getLatLng().longitude);
+                }
+                values.put("visittime", mission.getVisitTime());
+                values.put("realvisitTime", mission.getRealTime());
+                values.put("realLeaveTime", mission.getRealLeave());
+                values.put("distance", mission.getDistance());
+                values.put("location", mission.getLocation());
+                values.put("remark", mission.getRemark());
+                values.put("type", mission.getType());
+                values.put("recorddate", mission.getRecorddate());
+                values.put("date", getDateByString(mission.getVisitTime()));//拜访日期
+                i = db.insert(tibleName, "status", values);
+                if (i == -1) {
+                    String where = "master=? and emcode=? and id=? ";
+                    String[] whereArgs = {master, emcode, String.valueOf(mission.getId())};
+                    i = db.update(tibleName, values, where, whereArgs);
+                    LogUtil.i("update i=" + i);
+                }
+                LogUtil.i("i====" + i);
+            }
 
-	private String getDateByString(String date) {
-		if (StringUtil.isEmpty(date)) return "";
-		return TimeUtils.s_long_2_str(TimeUtils.f_str_2_long(date));
-	}
+            //删除多余数据
+            List<MissionModel> dbMissions = getMissionModels(db, master, emcode);
+            for (MissionModel dbMission : dbMissions) {
+                boolean exist = false;
+                for (MissionModel mission : entities) {
+                    if (dbMission.getId() == mission.getId()) {
+                        exist = true;
+                        break;
+                    }
+                }
+                if (!exist) {
+                    deleteMission(dbMission.getId() + "", db, master, emcode);
+                }
+            }
 
-	public boolean clearAll(long date) {
-		LogUtil.i("clearAll");
-		SQLiteDatabase db = null;
-		boolean clearOk = false;
-		try {
-			String master = getMaster();
-			String emcode = getEmcode();
-			if (StringUtil.isEmpty(master) || StringUtil.isEmpty(emcode)) return false;
-			db = DatabaseManager.getInstance().openDatabase();
-			String where = "master=? and emcode=? and date<=?";
-			String[] whereArg = {master, emcode, TimeUtils.s_long_2_str(date)};
-			int i = db.delete(tibleName, where, whereArg);
-			clearOk = i > 0;
-		} catch (SQLException e) {
-			if (e != null)
-				LogUtil.i("clearAll SQLException" + e.getMessage());
-		} catch (Exception e) {
-			if (e != null)
-				LogUtil.i("clearAll Exception" + e.getMessage());
-		} finally {
-			DatabaseManager.getInstance().closeDatabase();
-			return clearOk;
-		}
-	}
+            db.setTransactionSuccessful();
+        } catch (SQLException e) {
+            LogUtil.i("SQLException=" + e.getMessage());
+        } catch (Exception e) {
+            LogUtil.i("Exception=" + e.getMessage());
+        } finally {
+            db.endTransaction();
+            if (db != null)
+                DatabaseManager.getInstance().closeDatabase();
+            return i > 0;
+        }
+    }
 
+    //更新
+    public boolean updata(MissionModel mission) {
+        LogUtil.i("update" + JSON.toJSONString(mission));
+        SQLiteDatabase db = null;
+        long i = 0;
+        try {
+            String master = getMaster();
+            String emcode = getEmcode();
+            if (StringUtil.isEmpty(master) || StringUtil.isEmpty(emcode)) return false;
+            db = DatabaseManager.getInstance().openDatabase();
+            ContentValues values = new ContentValues();
+            if (mission.getLatLng() != null) {
+                values.put("latitude", mission.getLatLng().latitude);
+                values.put("longitude", mission.getLatLng().longitude);
+            }
+            values.put("visittime", mission.getVisitTime());
+            values.put("realvisitTime", mission.getRealTime());
+            values.put("realLeaveTime", mission.getRealLeave());
+            values.put("status", mission.getStatus());
+            String where = "master=? and emcode=? and id=? ";
+            String[] whereArgs = {master, emcode, String.valueOf(mission.getId())};
+            i = db.update(tibleName, values, where, whereArgs);
+        } catch (SQLException e) {
+            LogUtil.i("SQLException=" + e.getMessage());
+        } catch (Exception e) {
+            LogUtil.i("Exception=" + e.getMessage());
+        } finally {
+            if (db != null)
+                DatabaseManager.getInstance().closeDatabase();
+            return i > 0;
+        }
+    }
 
-	private String getMaster() {
-		boolean isB2b = ApiUtils.getApiModel() instanceof ApiPlatform;
-		String master = isB2b ? CommonUtil.getSharedPreferences(MyApplication.getInstance().getApplicationContext(), "companyEnUu") : CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_master");
-		return master;
+    public boolean deleteByid(int mpd_id) {
+        if (StringUtil.isEmpty(mpd_id + "")) return false;
+        String id = mpd_id + "";
+        SQLiteDatabase db = null;
+        long i = 0;
+        try {
+            String master = CommonUtil.getMaster();
+            String emcode = CommonUtil.getEmcode();
+            if (StringUtil.isEmpty(master) || StringUtil.isEmpty(emcode)) return false;
+            db = DatabaseManager.getInstance().openDatabase();
+            i = deleteMission(id, db, master, emcode);
+        } catch (Exception e) {
+        } finally {
+            if (db != null)
+                DatabaseManager.getInstance().closeDatabase();
+            return i > 0;
+        }
+    }
 
-	}
+    private long deleteMission(String id, SQLiteDatabase db, String master, String emcode) {
+        String where = "master=? and emcode=? and id=? ";
+        String[] whereArgs = {master, emcode, id};
+        long i = db.delete(tibleName, where, whereArgs);
+        return i;
+    }
 
-	private String getEmcode() {
-		boolean isB2b = ApiUtils.getApiModel() instanceof ApiPlatform;
-		String emcode = isB2b ? CommonUtil.getSharedPreferences(MyApplication.getInstance().getApplicationContext(), "b2b_uu") : CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_username");
-		return emcode;
-	}
+    private String getDateByString(String date) {
+        if (StringUtil.isEmpty(date)) return "";
+        return TimeUtils.s_long_2_str(TimeUtils.f_str_2_long(date));
+    }
 
-	public boolean hasMoreMision() {
-		SQLiteDatabase db = null;
-		boolean clearOk = false;
-		try {
-			String master = getMaster();
-			String emcode = getEmcode();
-			if (StringUtil.isEmpty(master) || StringUtil.isEmpty(emcode)) return false;
-			db = DatabaseManager.getInstance().openDatabase();
-			String[] columns = {"realvisitTime,realLeaveTime"};
-			String selecttion = "master =? and emcode=? and date=? and ( realvisitTime is null or realLeaveTime is null)";
-			String[] selectArg = {master, emcode, TimeUtils.s_long_2_str(System.currentTimeMillis())};
-			Cursor c = db.query(tibleName, columns, selecttion, selectArg, null, null, null);
-			clearOk = c.moveToNext();
-		} catch (SQLException e) {
-			if (e != null)
-				LogUtil.i("clearAll SQLException" + e.getMessage());
-		} catch (Exception e) {
-			if (e != null)
-				LogUtil.i("clearAll Exception" + e.getMessage());
-		} finally {
-			DatabaseManager.getInstance().closeDatabase();
-			return clearOk;
-		}
-	}
+    public boolean clearAll(long date) {
+        LogUtil.i("clearAll");
+        SQLiteDatabase db = null;
+        boolean clearOk = false;
+        try {
+            String master = getMaster();
+            String emcode = getEmcode();
+            if (StringUtil.isEmpty(master) || StringUtil.isEmpty(emcode)) return false;
+            db = DatabaseManager.getInstance().openDatabase();
+            String where = "master=? and emcode=? and date<=?";
+            String[] whereArg = {master, emcode, TimeUtils.s_long_2_str(date)};
+            int i = db.delete(tibleName, where, whereArg);
+            clearOk = i > 0;
+        } catch (SQLException e) {
+            if (e != null)
+                LogUtil.i("clearAll SQLException" + e.getMessage());
+        } catch (Exception e) {
+            if (e != null)
+                LogUtil.i("clearAll Exception" + e.getMessage());
+        } finally {
+            DatabaseManager.getInstance().closeDatabase();
+            return clearOk;
+        }
+    }
+
+
+    private String getMaster() {
+        boolean isB2b = ApiUtils.getApiModel() instanceof ApiPlatform;
+        String master = isB2b ? CommonUtil.getSharedPreferences(MyApplication.getInstance().getApplicationContext(), "companyEnUu") : CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_master");
+        return master;
+
+    }
+
+    private String getEmcode() {
+        boolean isB2b = ApiUtils.getApiModel() instanceof ApiPlatform;
+        String emcode = isB2b ? CommonUtil.getSharedPreferences(MyApplication.getInstance().getApplicationContext(), "b2b_uu") : CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_username");
+        return emcode;
+    }
+
+    public boolean hasMoreMision() {
+        SQLiteDatabase db = null;
+        boolean clearOk = false;
+        try {
+            String master = getMaster();
+            String emcode = getEmcode();
+            if (StringUtil.isEmpty(master) || StringUtil.isEmpty(emcode)) return false;
+            db = DatabaseManager.getInstance().openDatabase();
+            String[] columns = {"realvisitTime,realLeaveTime"};
+            String selecttion = "master =? and emcode=? and date=? and ( realvisitTime is null or realLeaveTime is null)";
+            String[] selectArg = {master, emcode, TimeUtils.s_long_2_str(System.currentTimeMillis())};
+            Cursor c = db.query(tibleName, columns, selecttion, selectArg, null, null, null);
+            clearOk = c.moveToNext();
+        } catch (SQLException e) {
+            if (e != null)
+                LogUtil.i("clearAll SQLException" + e.getMessage());
+        } catch (Exception e) {
+            if (e != null)
+                LogUtil.i("clearAll Exception" + e.getMessage());
+        } finally {
+            DatabaseManager.getInstance().closeDatabase();
+            return clearOk;
+        }
+    }
 
 
 }

+ 10 - 1
app_modular/appworks/src/main/java/com/uas/appworks/model/VisitPlan.java

@@ -10,10 +10,11 @@ public class VisitPlan {
     private String customerAddress;
     private long startTime;
     private long endTime;
-    private String status;
+    private String status;//转单状态
     private String doman;
     private String domanCode;
     private String recordDay;
+    private String billStatus;//单据状态
 
     public String getRecordDay() {
         return recordDay == null ? "" : recordDay;
@@ -110,4 +111,12 @@ public class VisitPlan {
     public void setDomanCode(String domanCode) {
         this.domanCode = domanCode;
     }
+
+    public String getBillStatus() {
+        return billStatus;
+    }
+
+    public void setBillStatus(String billStatus) {
+        this.billStatus = billStatus;
+    }
 }

+ 6 - 5
app_modular/appworks/src/main/java/com/uas/appworks/presenter/CustomerManagePresenter.java

@@ -149,14 +149,15 @@ public class CustomerManagePresenter extends BaseNetPresenter {
 
     private void handlerShowCustomerItems(JSONObject jsonObject) {
         List<EasyBaseModel> models = new ArrayList<>();
-        int lNum = JSONUtil.getInt(jsonObject, "lNum");//客户联系人
+        int lNum = jsonObject.containsKey("allNum") ?
+                JSONUtil.getInt(jsonObject, "allNum") : JSONUtil.getInt(jsonObject, "cNum");//客户联系人
         int cNum = JSONUtil.getInt(jsonObject, "cNum");//新增客户
         int vNum = JSONUtil.getInt(jsonObject, "vNum");//客户拜访数
         int oNum = JSONUtil.getInt(jsonObject, "oNum");//外勤数
-        models.add(new EasyBaseModel().setTitle("客户总数").setSubTitle(String.valueOf(cNum)));
+        models.add(new EasyBaseModel().setTitle("客户总数").setSubTitle(String.valueOf(lNum)));
         models.add(new EasyBaseModel().setTitle("新增客户数").setSubTitle(String.valueOf(cNum)));
         models.add(new EasyBaseModel().setTitle("客户拜访数").setSubTitle(String.valueOf(vNum)));
-        models.add(new EasyBaseModel().setTitle("外勤记录").setSubTitle(String.valueOf(oNum)));
+        models.add(new EasyBaseModel().setTitle("拜访客户数").setSubTitle(String.valueOf(oNum)));
         iCustomerManage.setShowCustomerAdapter(models);
     }
 
@@ -167,7 +168,7 @@ public class CustomerManagePresenter extends BaseNetPresenter {
                 JSONObject object = array.getJSONObject(i);
                 int id = JSONUtil.getInt(object, "id");
                 String name = JSONUtil.getText(object, "name");//客户名称
-                String birthday = DateFormatUtil.long2Str(JSONUtil.getTime(object, "birthday"),DateFormatUtil.YMD_HMS);//跟进时间
+                String birthday = DateFormatUtil.long2Str(JSONUtil.getTime(object, "birthday"), DateFormatUtil.YMD_HMS);//跟进时间
                 String state = JSONUtil.getText(object, "state");//状态
                 models.add(new EasyBaseModel().setId(id).setTitle(name).setSubTitle(birthday).setIconUrl(state));
             }
@@ -182,7 +183,7 @@ public class CustomerManagePresenter extends BaseNetPresenter {
                 JSONObject object = array.getJSONObject(i);
                 int id = JSONUtil.getInt(object, "id");
                 String name = JSONUtil.getText(object, "name");//客户名称
-                String fpTime = DateFormatUtil.long2Str(JSONUtil.getTime(object, "fpTime"),DateFormatUtil.YMD_HMS);//跟进时间
+                String fpTime = DateFormatUtil.long2Str(JSONUtil.getTime(object, "fpTime"), DateFormatUtil.YMD_HMS);//跟进时间
                 String state = JSONUtil.getText(object, "state");//状态
                 models.add(new EasyBaseModel().setId(id).setTitle(name).setSubTitle("最后跟进时间:" + fpTime).setIconUrl(state));
             }

+ 1 - 1
app_modular/appworks/src/main/res/layout/item_customer_details_3_0.xml

@@ -39,7 +39,7 @@
         <TextView
             android:id="@+id/valuesTv"
             android:layout_width="0dp"
-            android:layout_height="0dp"
+            android:layout_height="wrap_content"
             android:layout_marginLeft="@dimen/padding"
             android:background="@null"
             android:gravity="right|center"

+ 14 - 0
app_modular/appworks/src/main/res/layout/pop_business_home_menu.xml

@@ -12,6 +12,7 @@
         android:layout_height="wrap_content"
         android:paddingTop="10dp"
         android:paddingBottom="10dp"
+        android:visibility="gone"
         android:gravity="center"
         android:text="项目商机"/>
     <View
@@ -24,6 +25,19 @@
         android:layout_height="wrap_content"
         android:paddingTop="10dp"
         android:paddingBottom="10dp"
+        android:visibility="gone"
         android:gravity="center"
         android:text="OEM商机"/>
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="1dp"
+        android:background="#cccccc"/>
+    <TextView
+        android:id="@+id/business_home_menu3"
+        android:layout_width="160dp"
+        android:layout_height="wrap_content"
+        android:paddingTop="10dp"
+        android:paddingBottom="10dp"
+        android:gravity="center"
+        android:text="公司商机"/>
 </LinearLayout>

+ 1 - 1
version.gradle

@@ -8,7 +8,7 @@ ext {
     android = [
             compileSdkVersion: 26,
             buildToolsVersion: '27.0.0',
-            minSdkVersion    : 15,
+            minSdkVersion    : 17,
             targetSdkVersion : 26,
             javaVersion      : JavaVersion.VERSION_1_8,
             versionCode      : 158,