//
//  SettlementOrderCancleVm.swift
//  VattiCSS
//
//  Created by Jan on 2023/9/26.
//

import UIKit

class SettlementOrderCancleVm: NSObject {
    var forms:[TCCellBaseProtocol] = []
    var callback:(()->())?
    var remark = ""
    
    func makeForms(){
       var newForms:[TCCellBaseProtocol] = []
        
        newForms += makeInfoForms()
     
        forms = newForms
        callback?()
    }
    func makeInfoForms()->[TCCellBaseProtocol]{
        var newForms:[TCCellBaseProtocol] = []
        do {
            let uiConfigModel = TCFormCellConfigModel.defaultModel()
                .bgColor(.clear)
                .cornerMask([.layerMinXMinYCorner, .layerMaxXMinYCorner])
                .cornerRadius(8)
            let rowCell = TCFormCellModel<TCLineCell>.init(data: (0, 0, UIColor(hexString: "f8f8f8")), config: uiConfigModel, id: nil, frameh: 10)
            newForms.append(rowCell)
        }
        
        do {
            let uiConfigModel = TCFormCellConfigModel.defaultModel()
                .bgColor(.clear)
                .cornerMask([.layerMinXMinYCorner, .layerMaxXMinYCorner])
                .cornerRadius(8)
            let rowCell = TCFormCellModel<TCLineCell>.init(data: (12, 12, UIColor(hexString: "ffffff")), config: uiConfigModel, id: nil, frameh: 5)
            newForms.append(rowCell)
        }
        
        do {
            let uiConfigModel = TCFormCellConfigModel.defaultModel().setBgViewLeading(12).setBgViewTrailing(12).setCellColor(UIColor(hexString: "f8f8f8"))
                .title("原取消因".languageString())
                .titleColor(UIColor(hexString: "666666"))
                .titleFont(UIFont.systemFont(ofSize: 14))
                .canEdit(true)
                .showTip(true)
                .showLine(false)
            let rowCell = TCFormCellModel<TCTextViewCell>.init(data: (remark, "请输入".languageString(), ""), config: uiConfigModel, id: nil, frameh: 150) { [weak self] callValue in
                
                if let value = callValue as? (UIControl.Event,String) {
                    self?.remark = value.1
                }
                
                if let value = callValue as? String {
                    self?.remark = value
                    self?.makeForms()
                }
            }
            newForms.append(rowCell)
        }
        do {
            let uiConfigModel = TCFormCellConfigModel.defaultModel()
                .bgColor(.clear)
                .cornerMask([.layerMinXMaxYCorner, .layerMaxXMaxYCorner])
                .cornerRadius(8)
            let rowCell = TCFormCellModel<TCLineCell>.init(data: (12, 12, UIColor(hexString: "ffffff")), config: uiConfigModel, id: nil, frameh: 10)
            newForms.append(rowCell)
        }

        
       return newForms
    }
}
