/*
 * @Author       : WuWei
 * @LastEditors  : WuWei
 * @Date         : 2023-10-27 10:27:18
 * @LastEditTime : 2023-11-09 14:58:36
 * @Description  : Do not edit
 */
import 'package:bill_package/src/api/asset_bill.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

import '../models/deposite_detail.dart';

class DepositeFeeIndexStore extends GetxController {
  final scrollViewKey = GlobalKey<WisScrollViewState>();
  String? assetId;
  String? assetType;
  String? assetName;
  var detail = DepositeDetailModel().obs;
  onInitData() async {
    assetId = Get.arguments['id'];
    assetType = Get.arguments['type'];
    assetName = Get.arguments['name'];
    await getDetail();
  }

  getDetail() async {
    var res = await AssetBillApi.getDepositeFeeDetail({
      "assetId": assetId,
      "treeSelection": assetType,
    });
    detail.value = res.data ?? DepositeDetailModel();
  }

  toRecord() {
    Get.toNamed(
      'pay_record/index',
      arguments: {
        'appBarTitle': '收支记录',
        'billType': 'depositePay',
        'assetId': assetId,
        'assetType': assetType,
      },
    );
  }

  toSubmit() async {
    await Get.toNamed('receipt/submit', arguments: {
      'assetId': assetId,
      'chargeSubject': assetType,
      'type': 'depositePay',
      'assetName': assetName,
    })!
        .then((value) => {
              getDetail(),
            });
  }
}
