| | |
| | | package com.lotaai.canguiayw; |
| | | |
| | | import android.content.Context; |
| | | import android.graphics.Canvas; |
| | | import android.graphics.Color; |
| | | import android.graphics.Paint; |
| | | import android.graphics.Rect; |
| | | import android.os.Bundle; |
| | | import android.text.Editable; |
| | | import android.text.InputType; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.Button; |
| | | import android.widget.EditText; |
| | | import android.widget.Toast; |
| | | |
| | | import androidx.fragment.app.Fragment; |
| | | |
| | | import com.bin.david.form.core.SmartTable; |
| | | import com.bin.david.form.core.TableConfig; |
| | | import com.bin.david.form.data.CellInfo; |
| | | import com.bin.david.form.data.column.Column; |
| | | import com.bin.david.form.data.format.bg.IBackgroundFormat; |
| | | import com.bin.david.form.data.format.draw.IDrawFormat; |
| | | import com.bin.david.form.data.style.FontStyle; |
| | | import com.bin.david.form.data.table.TableData; |
| | | import com.blankj.utilcode.util.ScreenUtils; |
| | | import com.lotaai.canguiayw.sqllitedb.Order; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | public class CunCanFragment extends Fragment { |
| | | |
| | | private View root; |
| | | private Context context; |
| | | private EditText editText; |
| | | private SmartTable orderDetailTable; |
| | | |
| | | @Override |
| | | public void onCreate(Bundle savedInstanceState) { |
| | |
| | | root = inflater.inflate(R.layout.framgment_cuncan, container, false); |
| | | } |
| | | context = container.getContext(); |
| | | editText = (EditText)root.findViewById(R.id.edt_borrow_case_number); |
| | | editText.setInputType(InputType.TYPE_NULL); // 屏蔽软键盘 |
| | | View.OnClickListener clickListener = new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | int index = editText.getSelectionEnd(); |
| | | Editable editable = editText.getText(); |
| | | int key = v.getId(); |
| | | if (key == R.id.borrow_bt_delete) { |
| | | if (0 != index) { |
| | | editable.delete(index - 1, index); |
| | | } |
| | | } else if (key == R.id.borrow_bt_confirm) { |
| | | // 调用后台 |
| | | String gridNo = editable.toString(); |
| | | if (null == gridNo || "".equals(gridNo.trim())) { |
| | | Toast.makeText(context, "取餐码不能为空。", Toast.LENGTH_SHORT).show(); |
| | | return; |
| | | } else { |
| | | if (gridNo.length() > 5) { |
| | | Toast.makeText(context, "取餐码输入错误,请重试。", Toast.LENGTH_SHORT).show(); |
| | | return; |
| | | } |
| | | } |
| | | } else { |
| | | Button button = (Button) v; |
| | | editable.insert(index, button.getText()); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | View view1 = root.findViewById(R.id.borrow_bt1); |
| | | View view2 = root.findViewById(R.id.borrow_bt2); |
| | | View view3 = root.findViewById(R.id.borrow_bt3); |
| | | View view4 = root.findViewById(R.id.borrow_bt4); |
| | | View view5 = root.findViewById(R.id.borrow_bt5); |
| | | View view6 = root.findViewById(R.id.borrow_bt6); |
| | | View view7 = root.findViewById(R.id.borrow_bt7); |
| | | View view8 = root.findViewById(R.id.borrow_bt8); |
| | | View view9 = root.findViewById(R.id.borrow_bt9); |
| | | View view0 = root.findViewById(R.id.borrow_bt0); |
| | | View view11 = root.findViewById(R.id.borrow_bt_delete); |
| | | View view12 = root.findViewById(R.id.borrow_bt_confirm); |
| | | view1.setOnClickListener(clickListener); |
| | | view2.setOnClickListener(clickListener); |
| | | view3.setOnClickListener(clickListener); |
| | | view4.setOnClickListener(clickListener); |
| | | view5.setOnClickListener(clickListener); |
| | | view6.setOnClickListener(clickListener); |
| | | view7.setOnClickListener(clickListener); |
| | | view8.setOnClickListener(clickListener); |
| | | view9.setOnClickListener(clickListener); |
| | | view0.setOnClickListener(clickListener); |
| | | view11.setOnClickListener(clickListener); |
| | | view12.setOnClickListener(clickListener); |
| | | |
| | | //初始化ttable |
| | | initOrderDetailTableView(); |
| | | return root; |
| | | } |
| | | |
| | | |
| | | public void initOrderDetailTableView(){ |
| | | Column<String> xuhaoCol = new Column<>("", "gridNo"); |
| | | xuhaoCol.setMinWidth(10); |
| | | xuhaoCol.setComputeWidth(1); |
| | | Column<String> nameCol = new Column<>("名称", "orderNo"); |
| | | nameCol.setComputeWidth(10); |
| | | Column<String> numCol = new Column<>("量", "putInDate"); |
| | | numCol.setWidth(10); |
| | | nameCol.setComputeWidth(1); |
| | | |
| | | List<Order> lists = new ArrayList<>(); |
| | | // for (int i = 1;i <= 20; i++) { |
| | | // Order order = new Order(); |
| | | // order.setGridNo(Integer.toString(i)); |
| | | // order.setOrderNo("new year char grenn" ); |
| | | // Date dd = new Date(); |
| | | // order.setPutInDate(6); |
| | | // order.setState(0); |
| | | // order.setTakeCode("56897"); |
| | | // lists.add(order); |
| | | // } |
| | | |
| | | TableData<Order> tableData = new TableData<Order>("订单详情",lists, xuhaoCol,nameCol, numCol); |
| | | //设置数据 |
| | | orderDetailTable = root.findViewById(R.id.table); |
| | | orderDetailTable.getConfig().setShowTableTitle(true); |
| | | orderDetailTable.getConfig().setTableTitleStyle(new FontStyle(30,Color.WHITE)); |
| | | // // 设置表格标题名称文字样式 |
| | | // setTable.getConfig().setTableTitleStyle(new FontStyle(30, Color.GREEN)); |
| | | orderDetailTable.getConfig().setMinTableWidth(ScreenUtils.getScreenWidth()/2 -40); |
| | | // 设置表格标题文字样式 |
| | | orderDetailTable.getConfig().setColumnTitleStyle(new FontStyle(30, Color.WHITE)); |
| | | |
| | | IBackgroundFormat backgroundFormat = new IBackgroundFormat() { |
| | | @Override |
| | | public void drawBackground(Canvas canvas, Rect rect, Paint paint) { |
| | | canvas.drawColor(getResources().getColor(R.color.DarkGray)); |
| | | } |
| | | }; |
| | | orderDetailTable.getConfig().setColumnTitleBackground(backgroundFormat); |
| | | // 设置表格主体内容文字样式 |
| | | orderDetailTable.getConfig().setContentStyle(new FontStyle(30, Color.WHITE)); |
| | | // setTable.setZoom(true,1,0.5f); //开启缩放功能 |
| | | orderDetailTable.getConfig().setShowXSequence(false); //去掉表格顶部字母 |
| | | orderDetailTable.getConfig().setShowYSequence(false); //去掉左侧数字 |
| | | |
| | | // 设置表格主标题 |
| | | orderDetailTable.setTableData(tableData); |
| | | |
| | | } |
| | | } |