Selaa lähdekoodia

tags/old_version_1
fyf 1 vuosi sitten
vanhempi
commit
6b54a5b1b5
13 muutettua tiedostoa jossa 1365 lisäystä ja 2 poistoa
  1. +3
    -0
      app/src/main/AndroidManifest.xml
  2. +2
    -0
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  3. +23
    -1
      app/src/main/java/com/bonait/bnframework/business/MainInit.java
  4. +11
    -0
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  5. +49
    -1
      app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java
  6. +241
    -0
      app/src/main/java/com/bonait/bnframework/common/view/AddUserDialog.java
  7. +93
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/adapter/user_adapter.java
  8. +35
    -0
      app/src/main/java/com/bonait/bnframework/modules/mine/fragment/MyFragment.java
  9. +370
    -0
      app/src/main/java/com/bonait/bnframework/modules/mine/fragment/UserActivity.java
  10. +223
    -0
      app/src/main/res/layout/activity_user.xml
  11. +114
    -0
      app/src/main/res/layout/datatab/layout/user_item.xml
  12. +9
    -0
      app/src/main/res/layout/fragment_my.xml
  13. +192
    -0
      app/src/main/res/layout/item/layout/dialog_user.xml

+ 3
- 0
app/src/main/AndroidManifest.xml Näytä tiedosto

@@ -33,6 +33,9 @@
tools:ignore="GoogleAppIndexingWarning"
tools:node="merge"
tools:replace="android:icon">
<activity
android:name=".modules.mine.fragment.UserActivity"
android:exported="false" />
<activity
android:name=".modules.home.fragment.from.DiyMemoryActivity"
android:exported="false" />


+ 2
- 0
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java Näytä tiedosto

@@ -825,6 +825,8 @@ public class ExecuteTheRecipe {
WritePLC("初始化",false,null);

ExecuteTheRecipe.WritePLC("温控开关", false, null);//开关闭合
ExecuteTheRecipe.WritePLC("暂停开关", false, null);//开关闭合

} catch (InterruptedException e) {
ToastUtils.info("异常信息:" + e.getMessage());
}


+ 23
- 1
app/src/main/java/com/bonait/bnframework/business/MainInit.java Näytä tiedosto

@@ -190,9 +190,31 @@ public class MainInit {
user.account = "admin";
user.pass = "123456";
user.deviceID = ConfigName.getInstance().DeviceId;
user.userID = "20230415-fyf";
user.userID = "超级管理员";
user.exp = "管理员";
QueryDB.AddUser(user);

BPA_USER user1 = new BPA_USER();
user1.name = "一般用户";
user1.account = "ybyh";
user1.pass = "123456";
user1.deviceID = ConfigName.getInstance().DeviceId;
user1.userID = "一般用户";
user1.exp = "一般用户";
QueryDB.AddUser(user1);


BPA_USER user2 = new BPA_USER();
user2.name = "研发用户";
user2.account = "yfyh";
user2.pass = "123456";
user2.deviceID = ConfigName.getInstance().DeviceId;
user2.userID = "研发用户";
user2.exp = "研发用户";
QueryDB.AddUser(user2);



//10个料仓
if (QueryDB.GetSilosALL().size() == 0) {
for (int i = 0; i < 5; i++) {


+ 11
- 0
app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java Näytä tiedosto

@@ -252,6 +252,7 @@ public class ConfigName {
add(new Res_PLCADDRESS("加热", "M10.6", 0, 1));
add(new Res_PLCADDRESS("加热功率", "VW100", 1, 1));
add(new Res_PLCADDRESS("温控开关", "M17.6", 1, 1));
add(new Res_PLCADDRESS("暂停开关", "M17.7", 1, 1));

//主料
add(new Res_PLCADDRESS("主料", "M17.4", 0, 1));
@@ -402,6 +403,7 @@ public class ConfigName {
add(new Res_PLCADDRESS("加热", "M10.6", 0, 1));
add(new Res_PLCADDRESS("加热功率", "VW100", 1, 1));
add(new Res_PLCADDRESS("温控开关", "M17.6", 1, 1));
add(new Res_PLCADDRESS("暂停开关", "M17.7", 1, 1));

//主料
add(new Res_PLCADDRESS("主料", "M17.4", 0, 1));
@@ -611,6 +613,7 @@ public class ConfigName {
add(new Res_PLCADDRESS("加热", "M10.6", 0, 1));
add(new Res_PLCADDRESS("加热功率", "VW100", 1, 1));
add(new Res_PLCADDRESS("温控开关", "M17.6", 1, 1));
add(new Res_PLCADDRESS("暂停开关", "M17.7", 1, 1));

//主料
add(new Res_PLCADDRESS("主料", "M17.4", 0, 1));
@@ -996,4 +999,12 @@ public class ConfigName {
*/
public String versionSelectionEnum = "大炒版本";
//endregion

//region 用户角色
public List<String> UserRole = new ArrayList<String>() {{
add("一般用户");
add("研发用户");
add("超级管理员");
}};
//eneregion
}

+ 49
- 1
app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java Näytä tiedosto

@@ -4,6 +4,7 @@ import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import android.widget.TableRow;

import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.file.DBHelper;
@@ -1740,6 +1741,23 @@ public class QueryDB {
/**
* ID查询用户
*
* @param
* @return
*/
public static boolean GetUserIsCZ(String account,String name) {
String orderby = Desc_Time_Up;//先按排序 创建时间倒序
String where = "isDelete=? and (account=? or name=?)";
String[] args = new String[]{"0", account, name};
ArrayList<BPA_USER> data = new ArrayList<>();
ArrayList<Object> obj = Get(BPA_USER.class, where, args, orderby);
for (Object k : obj) {
data.add((BPA_USER) k);
}
return data.size()>0;
}
/**
* 判断用户名称是否存在
*
* @param id
* @return
*/
@@ -1758,8 +1776,8 @@ public class QueryDB {
Log.d("ID查询用户信息", "ID查询用户信息异常: " + e.getMessage());
return null;
}

}

/**
* 修改签名
* @param id
@@ -1786,6 +1804,22 @@ public class QueryDB {
}
return user;
}

/**
* 修改用户名
*
* @param id
* @param data
*/
public static BPA_USER UpdateAccount(String id, String data) {
BPA_USER user = GetUserID(id);
if (user != null) {
user.account = data;
Update(BPA_USER.class, user);
}
return user;
}

/**
* 修改密码
* @param id
@@ -1799,6 +1833,20 @@ public class QueryDB {
}
return user;
}

/**
* 修改权限
* @param id
* @param data
*/
public static BPA_USER UpdateUserRole(String id, String data) {
BPA_USER user = GetUserID(id);
if (user != null) {
user.userID = data;
Update(BPA_USER.class, user);
}
return user;
}
//endregion

//region BPA_MENU 菜单表


+ 241
- 0
app/src/main/java/com/bonait/bnframework/common/view/AddUserDialog.java Näytä tiedosto

@@ -0,0 +1,241 @@
package com.bonait.bnframework.common.view;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.model.mode.BomTypeInfo;
import com.bonait.bnframework.common.model.mode.FoodMenuInfo;
import com.bonait.bnframework.common.model.mode.GoodsParentTypeInfo;
import com.bonait.bnframework.common.model.mode.GoodsTypeInfo;
import com.bonait.bnframework.common.model.mode.GoodsUintInfo;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class AddUserDialog extends Dialog {
private Button yes, no;//确定按钮

//用户名称 账户名称 用户密码 再次确认密码 用户角色
private EditText edittext, edittext1, edittext2, edittext3, edittext4;

//确定文本和取消文本的显示内容
private String yesStr, noStr;

private onNoOnclickListener noOnclickListener;//取消按钮被点击了的监听器
private onYesOnclickListener yesOnclickListener;//确定按钮被点击了的监听器

/**
* 设置取消按钮的显示内容和监听
*
* @param str
* @param onNoOnclickListener
*/
public void setNoOnclickListener(String str, onNoOnclickListener onNoOnclickListener) {
if (str != null) {
noStr = str;
}
this.noOnclickListener = onNoOnclickListener;
}

/**
* 设置确定按钮的显示内容和监听
*
* @param str
* @param onYesOnclickListener
*/
public void setYesOnclickListener(String str, onYesOnclickListener onYesOnclickListener) {
if (str != null) {
yesStr = str;
}
this.yesOnclickListener = onYesOnclickListener;
}

public AddUserDialog(Context context) {
super(context, R.style.Dialog_Msg);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_user);
//按空白处不能取消动画
setCanceledOnTouchOutside(false);

//初始化界面控件
initView();
//初始化界面数据
initData();
//初始化界面控件的事件
initEvent();

}

/**
* 初始化界面的确定和取消监听器
*/
private void initEvent() {
//设置确定按钮被点击后,向外界提供监听
yes.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (DataVerification()) {
if (yesOnclickListener != null) {
yesOnclickListener.onYesClick(
edittext.getText().toString()
, edittext1.getText().toString()
, edittext2.getText().toString()
, edittext4.getText().toString()
);
}
}
}
});

no.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (noOnclickListener != null) {
noOnclickListener.onNoClick();
}
}
});

edittext4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
checkboxEdit(edittext4);
}
});
}

/**
* 多选下拉框
*/
private void checkboxEdit(EditText edit) {
final String[] items = ConfigName.getInstance().UserRole.toArray(new String[0]);
final int checkIndex = 0;
new QMUIDialog.CheckableDialogBuilder(getContext())
.addItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
edit.setText(items[which]);
dialog.dismiss();
}
})
.setCheckedIndex(checkIndex)
.show();
}

/**
* 初始化界面控件的显示数据
*/
private void initData() {
//如果设置按钮的文字
if (yesStr != null) {
yes.setText(yesStr);
}
}

/**
* 初始化界面控件
*/
private void initView() {
yes = (Button) findViewById(R.id.yes);
no = (Button) findViewById(R.id.no);
edittext = (EditText) findViewById(R.id.edittext);
edittext1 = (EditText) findViewById(R.id.edittext1);
edittext2 = (EditText) findViewById(R.id.edittext2);
edittext3 = (EditText) findViewById(R.id.edittext3);
edittext4 = (EditText) findViewById(R.id.edittext4);

}

/**
* 数据验证
*
* @return
*/
public boolean DataVerification() {
boolean IsSucees = false;
try {
if (edittext.getText().toString().isEmpty()) {
ToastUtils.info("用户名称不能为空!");
return false;
}
if (edittext1.getText().toString().isEmpty()) {
ToastUtils.info("账户名称不能为空!");
return false;
}
if (edittext2.getText().toString().isEmpty()) {
ToastUtils.info("用户密码不能为空!");
return false;
}
if (edittext3.getText().toString().isEmpty()) {
ToastUtils.info("用户密码不能为空!");
return false;
}

if (!edittext3.getText().toString().equals(edittext2.getText().toString())) {
ToastUtils.info("两次密码输入不一致!");
return false;
}
if (edittext4.getText().toString().isEmpty()) {
ToastUtils.info("用户角色不能为空!");
return false;
}
return true;
} catch (Exception ex) {
ToastUtils.error("数据验证异常!" + ex.getMessage());
return IsSucees;
}
}

public void SetAdapter(Spinner spinner, Map<String, String> map) {
ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(map.keySet()));
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
spinner.setAdapter(adapter);
}

/**
* 设置确定按钮和取消被点击的接口
*/
public interface onYesOnclickListener {
public void onYesClick(String name, String acc, String pass, String qx);
}

public interface onNoOnclickListener {
public void onNoClick();
}

@Override
public void show() {
super.show();
/**
* 设置宽度全屏,要设置在show的后面
*/
WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
getWindow().getDecorView().setPadding(0, 0, 0, 0);
getWindow().setAttributes(layoutParams);
}
}


+ 93
- 0
app/src/main/java/com/bonait/bnframework/modules/home/adapter/user_adapter.java Näytä tiedosto

@@ -0,0 +1,93 @@
package com.bonait.bnframework.modules.home.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_USER;
import com.bonait.bnframework.common.helper.I.MyClickListener;

import java.util.List;

public class user_adapter extends ArrayAdapter<BPA_USER> {
/**
* 内部点击事件
*/
private MyClickListener mListener;
private List<BPA_USER> datas;
int resource1;
public user_adapter(@NonNull Context context, int resource, @NonNull List<BPA_USER> objects, MyClickListener listener) {
super(context, resource, objects);
mListener = listener;
datas=objects;
this.resource1=resource;
}
//每个子项被滚动到屏幕内的时候会被调用
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
BPA_USER bpa_material = (BPA_USER) getItem(position);//得到当前项选中item实例
//为每一个子项加载设定的布局
View view = LayoutInflater.from(getContext()).inflate(resource1, parent, false);
//分别获取 image view 和 textview 的实例
TextView name = view.findViewById(R.id.name);
TextView zhanghao = view.findViewById(R.id.zhanghao);
TextView mima = view.findViewById(R.id.mima);
TextView quanxian = view.findViewById(R.id.quanxian);

Button button = view.findViewById(R.id.button_item);

// 设置要显示的图片和文字
name.setText(bpa_material.name+"");
zhanghao.setText(bpa_material.account+"");
mima.setText(bpa_material.pass+"");
quanxian.setText(bpa_material.userID+"");
name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(mListener!=null) mListener.clickListener(view,bpa_material);
}
});

zhanghao.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(mListener!=null) mListener.clickListener(view,bpa_material);
}
});

mima.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(mListener!=null) mListener.clickListener(view,bpa_material);
}
});

quanxian.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(mListener!=null) mListener.clickListener(view,bpa_material);
}
});


button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(mListener!=null) mListener.clickListener(view,bpa_material);
}
});


return view;
}
}

+ 35
- 0
app/src/main/java/com/bonait/bnframework/modules/mine/fragment/MyFragment.java Näytä tiedosto

@@ -64,6 +64,8 @@ public class MyFragment extends BaseFragment {
@BindView(R.id.stv_huifu)
SuperTextView stv_huifu;

@BindView(R.id.stv_user)
SuperTextView stv_user;

@BindView(R.id.stv_announcement)
SuperTextView stvAnnouncement;
@@ -153,6 +155,18 @@ public class MyFragment extends BaseFragment {
skipToNoticeActivity();
}
});
/**
* 用户管理
*/
stv_user.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
@Override
public void onClickListener(SuperTextView superTextView) {
Intent intent = new Intent(context, UserActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});

/**
* 用户名点击
*/
@@ -173,6 +187,13 @@ public class MyFragment extends BaseFragment {
.addAction("确定", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
String name = ConfigName.getInstance().user.name;
String ac = ConfigName.getInstance().user.account;
if (name.equals("admin") || ac.equals("admin")) {
ToastUtils.warning("对不起,admin账户禁止操作!");
return;
}

CharSequence text = builder.getEditText().getText();
if (text != null && text.length() > 0) {
BPA_USER user= QueryDB.UpdateUserName(ConfigName.getInstance().user.id,text.toString());
@@ -207,6 +228,13 @@ public class MyFragment extends BaseFragment {
.addAction("确定", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
String name = ConfigName.getInstance().user.name;
String ac = ConfigName.getInstance().user.account;
if (name.equals("admin") || ac.equals("admin")) {
ToastUtils.warning("对不起,admin账户禁止操作!");
return;
}

CharSequence text = builder.getEditText().getText();
if (text != null && text.length() > 0) {
BPA_USER user= QueryDB.UpdateUserSign(ConfigName.getInstance().user.id,text.toString());
@@ -240,6 +268,13 @@ public class MyFragment extends BaseFragment {
.addAction("确定", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
String name = ConfigName.getInstance().user.name;
String ac = ConfigName.getInstance().user.account;
if (name.equals("admin") || ac.equals("admin")) {
ToastUtils.warning("对不起,admin账户禁止操作!");
return;
}

CharSequence text = builder.getEditText().getText();
if (text != null && text.length() > 0) {
BPA_USER user= QueryDB.UpdateUserPass(ConfigName.getInstance().user.id,text.toString());


+ 370
- 0
app/src/main/java/com/bonait/bnframework/modules/mine/fragment/UserActivity.java Näytä tiedosto

@@ -0,0 +1,370 @@
package com.bonait.bnframework.modules.mine.fragment;

import androidx.appcompat.app.AppCompatActivity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.InputType;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
import com.bonait.bnframework.common.db.mode.BPA_SILOS;
import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_USER;
import com.bonait.bnframework.common.helper.I.IRunT;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.http.callback.json.JsonDialogCallback;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.model.ResAPI;
import com.bonait.bnframework.common.model.mode.ActionJsonMode;
import com.bonait.bnframework.common.model.mode.BatchingInfo;
import com.bonait.bnframework.common.model.mode.BomTechnologyActionInfo;
import com.bonait.bnframework.common.model.mode.CloudGood;
import com.bonait.bnframework.common.model.mode.GoodsTechnology;
import com.bonait.bnframework.common.model.mode.TechnologyAction;
import com.bonait.bnframework.common.model.mode.UpdateBomInfo;
import com.bonait.bnframework.common.model.mode.UpdateCloudGood;
import com.bonait.bnframework.common.oss.OssHelper;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.common.view.AddUserDialog;
import com.bonait.bnframework.common.view.GoodEditDialog;
import com.bonait.bnframework.modules.home.adapter.user_adapter;
import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpHeaders;
import com.lzy.okgo.model.Response;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import okhttp3.MediaType;
import okhttp3.RequestBody;

public class UserActivity extends BaseActivity implements MyClickListener {
@BindView(R.id.topbar)
QMUITopBarLayout mTopBar;

@BindView(R.id.add_wl)
Button add_wl;
@BindView(R.id.datatab)
ListView datatab;
/**
* 用户数据
*/
ArrayList<BPA_USER> bpa_users = new ArrayList<>();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user);
//属性绑定
ButterKnife.bind(this);
initTopBar();
InitView();
}

private void initTopBar() {
mTopBar.setTitle("账户管理");
mTopBar.addLeftImageButton(R.mipmap.fanhui, R.id.topbar).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
}

/**
* 初始化界面
*/
public void InitView() {
Initdata();
}

@OnClick({R.id.add_wl, R.id.synchronous})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.add_wl://新增用户

final AddUserDialog editDialog = new AddUserDialog(this);
editDialog.setTitle("角色列表");
editDialog.setYesOnclickListener("确定", new AddUserDialog.onYesOnclickListener() {
@Override
public void onYesClick(String name, String acc, String pass, String qx) {

if (name.toString().equals("admin") || acc.toString().equals("admin")) {
ToastUtils.warning("不能设置账号为admin!");
return;
}

BPA_USER bpa_user = new BPA_USER();
bpa_user.name = name;
bpa_user.account = acc;
bpa_user.pass = pass;
bpa_user.deviceID = ConfigName.getInstance().DeviceId;
bpa_user.userID =qx;//更改为,用户权限 // 一般用户 研发用户 超级管理员
if(QueryDB.GetUserIsCZ(bpa_user.account,bpa_user.name))
{
ToastUtils.warning("已有该账户,请重新填写账户信息!");
return;
}
QueryDB.AddUser(bpa_user);
ToastUtils.info("新增成功");
Initdata();
editDialog.dismiss();
}
});
editDialog.setNoOnclickListener("取消", new AddUserDialog.onNoOnclickListener() {
@Override
public void onNoClick() {
editDialog.dismiss();
}
});
editDialog.show();
break;

case R.id.synchronous://新增用户

String title = "温馨提示!";
String message = "客官确定要恢复出厂账户吗?";
AlertDialogUtils.showDialog(this, title, message, new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
ArrayList<BPA_USER> users=QueryDB.GetUserALL();
for (BPA_USER item:users)
{
QueryDB.DeleteUser(item);
}
BPA_USER user = new BPA_USER();
user.id = "20230415-fyf";
user.name = "管理员";
user.account = "admin";
user.pass = "123456";
user.deviceID = ConfigName.getInstance().DeviceId;
user.userID = "超级管理员";
user.exp = "管理员";
QueryDB.AddUser(user);

BPA_USER user1 = new BPA_USER();
user1.name = "一般用户";
user1.account = "ybyh";
user1.pass = "123456";
user1.deviceID = ConfigName.getInstance().DeviceId;
user1.userID = "一般用户";
user1.exp = "一般用户";
QueryDB.AddUser(user1);


BPA_USER user2 = new BPA_USER();
user2.name = "研发用户";
user2.account = "yfyh";
user2.pass = "123456";
user2.deviceID = ConfigName.getInstance().DeviceId;
user2.userID = "研发用户";
user2.exp = "研发用户";
QueryDB.AddUser(user2);

ToastUtils.info("恢复出厂成功!");
Initdata();
dialog.dismiss();
}
});
break;
}
}


/**
* 初始化数据加载
*/
public void Initdata() {
try {
bpa_users = QueryDB.GetUserALL();
user_adapter adapter = new user_adapter(getBaseContext(), R.layout.user_item, bpa_users, this);
datatab.setAdapter(adapter);
} catch (Exception e) {

}
}

@Override
public void clickListener(View v, Object data) {
String name = ((BPA_USER) data).name;
String ac = ((BPA_USER) data).account;
if (name.equals("admin") || ac.equals("admin")) {
ToastUtils.warning("对不起,admin账户禁止操作!");
return;
}
switch (v.getId()) {
case R.id.name://修改物料名称按钮
final QMUIDialog.EditTextDialogBuilder builder = new QMUIDialog.EditTextDialogBuilder(this);
builder.setTitle("用户名称")
.setPlaceholder("在此输入用户名称")
.setDefaultText(((BPA_USER) data).name)
.setInputType(InputType.TYPE_CLASS_TEXT)
.addAction("取消", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
dialog.dismiss();
}
})
.addAction("确定", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
CharSequence text = builder.getEditText().getText();
if (text != null && text.length() > 0) {
if (text.toString().equals("admin")) {
ToastUtils.warning("不能设置账号为admin!");
return;
}

if(QueryDB.GetUserIsCZ(((BPA_USER) data).account,text.toString()))
{
ToastUtils.warning("已有该账户,请重新填写账户信息!");
return;
}
QueryDB.UpdateUserName(((BPA_USER) data).id, text.toString());
Initdata();
ToastUtils.info("修改成功");
dialog.dismiss();
} else {
//请填入昵称
ToastUtils.warning("不能为空!");
}
}
})
.show();
break;
case R.id.zhanghao://修改物料名称按钮
final QMUIDialog.EditTextDialogBuilder builder1 = new QMUIDialog.EditTextDialogBuilder(this);
builder1.setTitle("用户账号")
.setPlaceholder("在此输入用户账号")
.setDefaultText(((BPA_USER) data).account)
.setInputType(InputType.TYPE_CLASS_TEXT)
.addAction("取消", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
dialog.dismiss();
}
})
.addAction("确定", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
CharSequence text = builder1.getEditText().getText();
if (text != null && text.length() > 0) {
if (text.toString().equals("admin")) {
ToastUtils.warning("不能设置账号为admin!");
return;
}
if(QueryDB.GetUserIsCZ(text.toString(),((BPA_USER) data).name))
{
ToastUtils.warning("已有该账户,请重新填写账户信息!");
return;
}

QueryDB.UpdateAccount(((BPA_USER) data).id, text.toString());
Initdata();
ToastUtils.info("修改成功");
dialog.dismiss();
} else {
//请填入昵称
ToastUtils.info("不能为空!");
}
}
})
.show();
break;
case R.id.mima://修改物料名称按钮
final QMUIDialog.EditTextDialogBuilder builder2 = new QMUIDialog.EditTextDialogBuilder(this);
builder2.setTitle("用户密码")
.setPlaceholder("在此输入用户密码")
.setDefaultText(((BPA_USER) data).pass)
.setInputType(InputType.TYPE_CLASS_TEXT)
.addAction("取消", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
dialog.dismiss();
}
})
.addAction("确定", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
CharSequence text = builder2.getEditText().getText();
if (text != null && text.length() > 0) {
QueryDB.UpdateUserPass(((BPA_USER) data).id, text.toString());
Initdata();
ToastUtils.info("修改成功");
dialog.dismiss();
} else {
//请填入昵称
ToastUtils.info("不能为空!");
}
}
})
.show();
break;

case R.id.quanxian://修改物料名称按钮
final String [] items=ConfigName.getInstance().UserRole.toArray(new String[0]);
int checkIndex=1;
String qx=((BPA_USER) data).userID;
for (int k=0;k<ConfigName.getInstance().UserRole.size();k++)
{
if(qx!=null && !qx.isEmpty() && qx.contains(items[k]))
{
checkIndex=k;
}
}
new QMUIDialog.CheckableDialogBuilder(this)
.addItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String names=items[which];
if (names != null && !names.isEmpty()) {
QueryDB.UpdateUserRole(((BPA_USER) data).id, names);
Initdata();
ToastUtils.info("修改成功");
dialog.dismiss();
} else {
//请填入昵称
ToastUtils.info("不能为空!");
return;
}
dialog.dismiss();
}
})
.setCheckedIndex(checkIndex)
.show();
break;

case R.id.button_item://删除按钮
QueryDB.DeleteUser((BPA_USER) data);
Initdata();
ToastUtils.info("删除成功");
break;
}
}

@Override
public void clickListenerNew(View v, int k, Object data) {

}
}

+ 223
- 0
app/src/main/res/layout/activity_user.xml Näytä tiedosto

@@ -0,0 +1,223 @@
<?xml version="1.0" encoding="utf-8"?>
<com.qmuiteam.qmui.widget.QMUIWindowInsetLayout 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="match_parent"
android:background="@color/app_color_blue"
android:fitsSystemWindows="true"
android:orientation="vertical"
tools:context=".modules.mine.fragment.UserActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/qmui_topbar_height"
android:background="@color/qmui_config_color_white">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/main_background"
android:orientation="vertical">

<!-- 物料信息管理 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/qmui_config_color_white"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_10"
android:paddingRight="@dimen/dp_10">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp">

<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="(温馨提示:点击行可修改内容.)"
android:textColor="@color/amber_primary_dark"
android:textSize="12dp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:orientation="horizontal">

<Button
android:id="@+id/add_wl"
android:layout_width="100dp"
android:layout_height="26dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginLeft="@dimen/dp_10"
android:background="@drawable/bg_btn_login_selected"
android:text="+增加用户"
android:textColor="@color/white"
android:textSize="14dp" />

<Button
android:id="@+id/synchronous"
android:layout_width="100dp"
android:layout_height="26dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginLeft="@dimen/dp_10"
android:background="@drawable/button1"
android:text="恢复出厂"
android:textSize="14dp"/>
</LinearLayout>

</RelativeLayout>

</LinearLayout>

</LinearLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- 表头 -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="36dp"
android:background="@color/gray">

<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:gravity="center"
android:stretchColumns="0">

<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">

<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"
android:text="用户名称"
android:textAlignment="center"
android:textColor="@color/white"
android:textStyle="bold" />
</RelativeLayout>

<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"
android:text="用户账号"
android:textAlignment="center"
android:textColor="@color/white"
android:textStyle="bold" />
</RelativeLayout>

<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"
android:text="用户密码"
android:textAlignment="center"
android:textColor="@color/white"
android:textStyle="bold" />
</RelativeLayout>

<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"
android:text="用户权限"
android:textAlignment="center"
android:textColor="@color/white"
android:textStyle="bold" />
</RelativeLayout>

<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"
android:text="操作"
android:textAlignment="center"
android:textColor="@color/white"
android:textStyle="bold" />
</RelativeLayout>
</TableRow>
</TableLayout>
</RelativeLayout>
<!-- 数据 -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/datatab"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>

<com.qmuiteam.qmui.widget.QMUITopBarLayout
android:id="@+id/topbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/app_color_blue" />
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>

+ 114
- 0
app/src/main/res/layout/datatab/layout/user_item.xml Näytä tiedosto

@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
xsi:schemaLocation="http://schemas.android.com/apk/res/android ">

<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:stretchColumns="0">

<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">

<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">

<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:text="回锅肉"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="12dp" />
</RelativeLayout>

<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">

<TextView
android:id="@+id/zhanghao"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:text="账号"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="12dp" />
</RelativeLayout>

<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">

<TextView
android:id="@+id/mima"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:text="密码"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="12dp" />
</RelativeLayout>

<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">

<TextView
android:id="@+id/quanxian"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:text="权限"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="12dp" />
</RelativeLayout>

<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<Button
android:id="@+id/button_item"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_width="60dp"
android:layout_height="20dp"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:background="@drawable/button"
android:focusable="false"
android:text="删除"
android:textSize="12dp"
android:textColor="@color/black"/>
</RelativeLayout>

</TableRow>
</TableLayout>
</RelativeLayout>

+ 9
- 0
app/src/main/res/layout/fragment_my.xml Näytä tiedosto

@@ -99,6 +99,15 @@
stv:sLeftTextString="通知"
stv:sRightIconRes="@drawable/icon_right" />

<com.allen.library.SuperTextView
android:id="@+id/stv_user"
android:layout_width="match_parent"
android:layout_height="@dimen/ll_height"
stv:sBottomDividerLineMarginLeft="@dimen/dp_40"
stv:sLeftIconRes="@drawable/user_gl"
stv:sLeftTextString="用户管理"
stv:sRightIconRes="@drawable/icon_right" />

<com.allen.library.SuperTextView
android:id="@+id/stv_update"
android:layout_width="match_parent"


+ 192
- 0
app/src/main/res/layout/item/layout/dialog_user.xml Näytä tiedosto

@@ -0,0 +1,192 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#A5000000">

<LinearLayout
android:layout_width="260dp"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/common_bg_with_radius_and_border"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="15dp"
android:gravity="center"
android:text="新增用户"
android:textColor="@color/black"
android:textSize="@dimen/TitleSize"/>
<LinearLayout
android:layout_gravity="center"
android:layout_marginBottom="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="用户名称"
android:textColor="@color/black"
android:layout_marginRight="@dimen/dp_10"/>
<EditText
android:id="@+id/edittext"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@drawable/input_bj"
android:hint="请输入名称"
android:inputType="text"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp" />
</LinearLayout>

<LinearLayout
android:layout_gravity="center"
android:layout_marginBottom="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="账号名称"
android:textColor="@color/black"
android:layout_marginRight="@dimen/dp_10"/>
<EditText
android:id="@+id/edittext1"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@drawable/input_bj"
android:hint="请输入名称"
android:inputType="text"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp" />
</LinearLayout>

<LinearLayout
android:layout_gravity="center"
android:layout_marginBottom="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="用户密码"
android:textColor="@color/black"
android:layout_marginRight="@dimen/dp_10"/>
<EditText
android:id="@+id/edittext2"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@drawable/input_bj"
android:hint="请输入密码"
android:inputType="numberPassword"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp" />
</LinearLayout>

<LinearLayout
android:layout_gravity="center"
android:layout_marginBottom="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="密码确认"
android:textColor="@color/black"
android:layout_marginRight="@dimen/dp_10"/>
<EditText
android:id="@+id/edittext3"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@drawable/input_bj"
android:hint="请输入密码"
android:inputType="numberPassword"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp" />
</LinearLayout>

<LinearLayout
android:layout_gravity="center"
android:layout_marginBottom="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="用户角色"
android:textColor="@color/black"
android:layout_marginRight="@dimen/dp_10"/>
<EditText
android:id="@+id/edittext4"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@drawable/input_bj"
android:hint=""
android:inputType="text"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp"
android:focusable="false"/>
</LinearLayout>

<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginTop="15dp"
android:background="#E4E4E4" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal">

<Button
android:id="@+id/no"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@null"
android:gravity="center"
android:singleLine="true"
android:text="取消"
android:textColor="@color/colorPrimary"
/>

<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="#E4E4E4" />

<Button
android:id="@+id/yes"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@null"
android:gravity="center"
android:singleLine="true"
android:text="确 定"
android:textColor="@color/red_primary"
/>

</LinearLayout>
</LinearLayout>

</RelativeLayout>

Ladataan…
Peruuta
Tallenna