package com.example.beijing_daxing.vm;

import android.view.View;
import android.widget.AdapterView;

import androidx.databinding.BaseObservable;

import com.example.beijing_daxing.been.BaseLocation;
import com.example.beijing_daxing.been.BaseManufacturer;

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

/**
 * @author wanghao
 * @date 2024/1/11  16:21
 */
public class InStoreVM extends BaseObservable {
    private List<String> manus;
    private List<String> locations;
    private int sanLength;
    private List<BaseManufacturer> baseManufacturerList;
    private String binchCode;
    private String selectManuText;
    private String selectLocationText;
    private List<String> epcList;
    private String submitUser;
    private Long manufacturerId;

    public String getSubmitUser() {
        return submitUser;
    }

    public void setSubmitUser(String submitUser) {
        this.submitUser = submitUser;
    }

    public List<String> getEpcList() {
        return epcList;
    }

    public void setEpcList(List<String> epcList) {
        this.epcList = epcList;
    }

    public void selectManus(AdapterView<?> parent, View view, int position, long id) {
        selectManuText = manus.get(position);
        this.manufacturerId = baseManufacturerList.get(position).getManufacturerId();
    }

    public void selectLocation(AdapterView<?> parent, View view, int position, long id) {
        selectLocationText = locations.get(position);
    }

    public String getSelectManuText() {
        return selectManuText;
    }

    public String getSelectLocationText() {
        return selectLocationText;
    }

    public List<String> getManus() {
        return manus;
    }


    public List<String> getLocations() {
        return locations;
    }

    public void initSelect(List<BaseLocation> baseLocationList, List<BaseManufacturer> baseManufacturerList) {
        manus = new ArrayList<>();
        locations = new ArrayList<>();
        this.baseManufacturerList = baseManufacturerList;
        baseLocationList.forEach(t -> this.locations.add(t.getLocationCode()));
        baseManufacturerList.forEach(t -> this.manus.add(t.getManufacturerName()));
        notifyChange();
    }

    public String getBinchCode() {
        return binchCode;
    }

    public void setBinchCode(String binchCode) {
        this.binchCode = binchCode;
    }

    public int getSanLength() {
        return sanLength;
    }

    public void setSanLength(int sanLength) {
        this.sanLength = sanLength;
        notifyChange();
    }

}
