安卓端mainActivity及权限菜单树
不良事件管理系统有五种角色,分别是普通职工、质控办、职能科室主任、非职能科室主任、医院领导。
普通职工权限
质控办权限
领导:相似
职能科室主任
非职能:相似
Okhttp实现代码
OkHttpClient mOkHttpClient = new OkHttpClient();
Request request = new Request.Builder()
.header("token", name2)
.url("http://43.138.24.19/user/getMenuTree")
.method("GET",null).build();
//3,创建call对象并将请求对象添加到调度中
Log.i("request",request.toString());
mOkHttpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.e("测试", e+"");
}
@Override
public void onResponse(Call call, Response response) throws IOException {
Log.e("测试", response.code()+"");
Gson gson = new Gson();
String msg = response.body().string();
Log.v("body", "body=" + msg);
Type listType = new TypeToken<ResponseTypes<List<eventtype>>>() {
}.getType();
final ResponseTypes data2 = gson.fromJson(msg, listType);
//ResponseData data2 = gson.fromJson(msg,ResponseData.class);
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
typeslist = data2.getData2();
;
for (int i = 0; i < typeslist.size(); i++) {
int temp = typeslist.get(i).getId();
Log.v("body", "body=" + temp);
if (temp == 3) {
receive_btn.setVisibility(View.VISIBLE);
}
if (temp == 4) {
analysis2_btn.setVisibility(View.VISIBLE);
}
if (temp == 5) {
analysis_btn.setVisibility(View.VISIBLE);
}
if (temp == 6) {
statistic.setVisibility(View.VISIBLE);
}
if (temp == 7) {
statistic2.setVisibility(View.VISIBLE);
}
}
}catch (Exception e){
Toast.makeText(getApplicationContext(), "请求未成功", Toast.LENGTH_SHORT).show();
}
}
});
}
});
按钮点击事件
report_btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SlideActivity.this, ReportActivity.class);
startActivity(intent);
Toast.makeText(getApplicationContext(), "上报事件", Toast.LENGTH_SHORT).show();
}
});
search_btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(SlideActivity.this, ReportListActivity.class);
startActivity(intent);
Toast.makeText(getApplicationContext(), "查询事件", Toast.LENGTH_SHORT).show();
}
});
receive_btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SlideActivity.this, ExamineListActivity.class);
startActivity(intent);
Toast.makeText(getApplicationContext(), "我的受理", Toast.LENGTH_SHORT).show();
}
});
analysis_btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SlideActivity.this, RectifyListActivity.class);
startActivity(intent);
Toast.makeText(getApplicationContext(), "我的受理", Toast.LENGTH_SHORT).show();
}
});
analysis2_btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SlideActivity.this, InvolvedRectifyListActivity.class);
startActivity(intent);
Toast.makeText(getApplicationContext(), "我的受理", Toast.LENGTH_SHORT).show();
}
});
statistic1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SlideActivity.this, EchatsActivity.class);
startActivity(intent);
Toast.makeText(getApplicationContext(), "统计分析", Toast.LENGTH_SHORT).show();
}
});
statistic21.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SlideActivity.this, DepartmentEchartsActivity.class);
startActivity(intent);
Toast.makeText(getApplicationContext(), "统计分析(科室主任)", Toast.LENGTH_SHORT).show();
}
});
按钮用cardview做圆角
<LinearLayout 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="410dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
android:background="@color/colorWhiteblue"
tools:context=".MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/image_head"
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@mipmap/ic_launcher_round" />
<androidx.cardview.widget.CardView
android:id="@+id/cardview1"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="10dp"
app:cardCornerRadius="15dp"
app:cardBackgroundColor="@color/colorLightblue"
>
<Button
android:id="@+id/main_button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="不良事件上报"
android:textSize="25sp"
android:background="@color/colorWhiteblue"/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/cardview2"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="10dp"
app:cardBackgroundColor="@color/colorLightblue"
app:cardCornerRadius="15dp"
>
<Button
android:id="@+id/main_button2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="不良事件查询"
android:textSize="25sp"
android:background="@color/colorWhiteblue"/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/cardview3"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="10dp"
app:cardBackgroundColor="@color/colorLightblue"
app:cardCornerRadius="15dp"
>
<Button
android:id="@+id/main_button3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="待处理不良事件(质控办)"
android:textSize="25sp"
android:background="@color/colorWhiteblue"/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/cardview4"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="10dp"
android:visibility="gone"
app:cardBackgroundColor="@color/colorLightblue"
app:cardElevation="5dp"
app:cardCornerRadius="15dp">
<Button
android:id="@+id/main_button4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="待处理不良事件(职能科室)"
android:textSize="25sp"
android:background="@color/colorWhiteblue"/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/cardview5"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="10dp"
android:visibility="gone"
app:cardBackgroundColor="@color/colorLightblue"
app:cardElevation="5dp"
app:cardCornerRadius="15dp">
<Button
android:id="@+id/main_button5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="待处理不良事件(非职能科室)"
android:textSize="25sp"
android:background="@color/colorWhiteblue"/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/cardview6"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="10dp"
android:visibility="gone"
app:cardBackgroundColor="@color/colorLightblue"
app:cardCornerRadius="15dp">
<Button
android:id="@+id/main_button6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="查询统计"
android:textSize="25sp"
android:background="@color/colorWhiteblue"/>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/cardview7"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="10dp"
android:visibility="gone"
app:cardBackgroundColor="@color/colorLightblue"
app:cardCornerRadius="15dp">
<Button
android:id="@+id/main_button7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="查询统计(科室主任)"
android:textSize="25sp"
android:background="@color/colorWhiteblue"/>
</androidx.cardview.widget.CardView>
</LinearLayout>
</ScrollView>
</LinearLayout>