//mysql js
export default{
  data(){
    return {
      mydata:{},
      error:0
    };
  },
  mounted(){
    var mydata=onez.install_get().db||{};
    mydata.server=mydata.server||'localhost';
    mydata.username=mydata.username||'root';
    mydata.password=mydata.password||'';
    mydata.prefix=mydata.prefix||'onez_';
    mydata.name=mydata.name||'';
    
    this.mydata=JSON.parse(JSON.stringify(mydata));
    //onez.data(this,['items']);
  },
  methods:{
    onSubmit(o){
      o.ac='check';
      onez.loading(true);
      this.post(o,(res)=>{
        onez.loading(false);
        if(res.error){
          onez.alert(res.error);
        }else if(res.db){
          onez.install_save({db:res.db});
          this.$emit('next');
        }else{
          onez.alert('未知错误');
        }
      });
    },
    prev(){
      this.$emit('prev');
    },
    next(){
      this.$emit('next');
    }
  }
}