@extends('base.base')
@section('base')
    <!-- 内容区域 -->
    <div class="main-panel">
        <div class="content-wrapper">
            <div class="row">
                <div class="col-12 grid-margin stretch-card">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="card-title">修改提现渠道</h4>

                            <form class="forms-sample" id="form">
                                <div class="form-group">
                                    <label>* 渠道名称(name)</label>
                                    <input type="text" class="form-control required" name="name" 
                                           value="{{ $info->name }}"
                                           placeholder="请输入渠道名称">
                                </div>

                                <div class="form-group">
                                    <label>配置键名(config_key)</label>
                                    <input type="text" class="form-control" name="config_key" 
                                           value="{{ $info->config_key }}"
                                           placeholder="可选，留空将使用渠道名称">
                                </div>

                                <div class="form-group">
                                    <label>* 渠道值(config_value)</label>
                                    <input type="text" class="form-control required" name="config_value" 
                                           value="{{ $info->config_value }}"
                                           placeholder="请输入渠道值">
                                    <small class="form-text text-muted">用于程序中识别渠道的唯一值</small>
                                </div>

                                <div class="form-group">
                                    <label>权重比例(sort) (%)</label>
                                    <input type="number" class="form-control" name="sort" 
                                           value="{{ $info->sort }}" min="0" max="100">
                                    <small class="form-text text-muted">可在列表页统一配置所有渠道权重</small>
                                </div>

                                <div class="form-group">
                                    <label>备注(remarks)</label>
                                    <textarea class="form-control" name="remarks" rows="3" 
                                              placeholder="可选填写备注信息">{{ $info->remarks }}</textarea>
                                </div>

                                <div class="form-group">
                                    <label><h4>状态设置(status)</h4></label> <br>
                                    <label> 
                                        <input type="radio" name="status" value="1" 
                                               @if($info->status == 1) checked @endif> 
                                        开启
                                    </label>
                                    <label style="margin-left: 20px;"> 
                                        <input type="radio" name="status" value="-1"
                                               @if($info->status == -1) checked @endif> 
                                        关闭
                                    </label>
                                </div>

                                <div class="alert alert-warning" role="alert">
                                    <i class="mdi mdi-alert"></i>
                                    <strong>注意:</strong>
                                    修改渠道值可能会影响正在使用该渠道的提现订单，请谨慎操作
                                </div>

                                <button type="button" onclick="commit({{ $info->id }})"
                                        class="btn btn-gradient-primary btn-icon-text">
                                    <i class="mdi mdi-file-check btn-icon-prepend"></i>
                                    提交
                                </button>
                                <button type="button" onclick="cancel()"
                                        class="btn btn-gradient-warning btn-icon-text">
                                    <i class="mdi mdi-reload btn-icon-prepend"></i>
                                    取消
                                </button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        function commit(id) {
            if (!checkForm()) {
                return false;
            }

            var data = $("#form").serializeObject();

            myRequest("/admin/withdrawal/cashier_channel_update/" + id, "post", data, function (res) {
                layer.msg(res.msg);
                setTimeout(function () {
                    window.parent.location.reload();
                }, 1500);
            });
        }

        function cancel() {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        }
    </script>
@endsection
