<rt-form id="{{vm.form.name}}" name="{{vm.form.name}}" novalidate>
    <div class="row rt-margin-bottom-before-box">
        <div class="col-sm-2">
            <button class="btn btn-link" type="button" id="btnClose" ng-click="vm.form.hide()">
                        <i class="fa fa-sign-out"></i> 关闭
                    </button>
        </div>
        <!-- div[.col-sm-2] -->
        <div class="col-sm-10">
            <div class="pull-right">
                <rt-button id="btnSave" rt-style="link" rt-title="保存" rt-icon="floppy-o" ng-click="vm.form.save(false)" ng-show="(vm.form.type === 'Create' && vm.privilege.IsCreate) || (vm.form.type === 'Edit' && vm.form.data.StateCode.Value == 0 && vm.privilege.IsWrite)">
                </rt-button>
                <rt-button id="btnSaveAndNew" rt-style="link" rt-title="保存并新建" rt-icon="floppy-o" ng-click="vm.form.save(true)" ng-show="(vm.form.type === 'Create' && vm.privilege.IsCreate) || (vm.form.type === 'Edit' && vm.form.data.StateCode.Value == 0 && vm.privilege.IsWrite)">
                </rt-button>
                <rt-button id="btnDelete" rt-style="link" rt-title="删除" rt-icon="trash" ng-click="vm.form.del()" ng-show="vm.form.type === 'Edit' && vm.privilege.IsDelete">
                </rt-button>
                <rt-button id="btnActivate" rt-style="link" rt-title="激活" rt-icon="check" ng-click="vm.form.activate()" ng-show="vm.form.type === 'Edit' && vm.form.data.StateCode.Value == 1 && vm.privilege.IsWrite">
                </rt-button>
                <rt-button id="btnDeactivate" rt-style="link" rt-title="停用" rt-icon="ban" ng-click="vm.form.deactivate()" ng-show="vm.form.type === 'Edit' && vm.form.data.StateCode.Value == 0 && vm.privilege.IsWrite">
                </rt-button>
            </div>
        </div>
        <!-- div[.col-sm-10] -->
    </div>
    <div class="nav-tabs-custom">
        <!-- @@表单 -->
        <ul class="nav nav-tabs">
            <li class="active">
                <a href="#A1{{vm.form.name}}" onclick="return false;" data-toggle="tab">资料</a>
            </li>
            <li ng-if="vm.form.type === 'Edit'">
                <a href="#A2{{vm.form.name}}" onclick="return false;" data-toggle="tab">联系人信息</a>
            </li>
            <li ng-if="vm.form.type === 'Edit'">
                <a href="#A3{{vm.form.name}}" onclick="return false;" data-toggle="tab">下属门店信息</a>
            </li>
            <li>
                <a href="#A4{{vm.form.name}}" onclick="return false;" data-toggle="tab">归属信息</a>
            </li>
        </ul>
        <!-- ui[.nav] -->

        <div class="tab-content">
            <div class="tab-pane active" id="A1{{vm.form.name}}">
                <rt-section rt-title="基本信息">
                    <rt-section-row>
                        <rt-input rt-type="text" rt-title="连锁名称" rt-disabled="vm.form.data.StateCode.Value == 1" rt-required="true" rt-col="4" rt-required="true"
                            ng-model="vm.form.data.name"></rt-input>
                    </rt-section-row>
                    <rt-section-row>
                        <rt-input rt-type="text" rt-title="连锁编码" rt-col="4" rt-required="false" rt-disabled="vm.form.data.StateCode.Value == 1" ng-model="vm.form.data.accountnumber"></rt-input>
                        <rt-lookup2 rt-title="上级客户" rt-disabled="vm.form.data.StateCode.Value == 1" ng-model="vm.form.data.parentaccountid" rt-get-data-name="Account.GetAllChain"
                            rt-order-by="accountnumber" rt-col-list="[{Code:'name',Name:'客户名称'},{Code:'accountnumber',Name:'客户编码'}]"
                            rt-required="false" rt-col="4"></rt-lookup2>
                    </rt-section-row>
                    <rt-section-row>
                        <rt-input rt-type="text" rt-title="传真" rt-disabled="vm.form.data.StateCode.Value == 1" rt-col="4" ng-model="vm.form.data.fax"></rt-input>
                        <rt-input rt-type="text" rt-title="联络电话" rt-disabled="vm.form.data.StateCode.Value == 1" rt-col="4" ng-model="vm.form.data.telephone"></rt-input>
                    </rt-section-row>
                    <rt-section-row>
                        <rt-lookup2 rt-title="省份" rt-disabled="vm.form.data.StateCode.Value == 1" ng-model="vm.form.data.provinceid" rt-get-data-name="Province.GetProvince"
                            rt-order-by="code" rt-col-list="[{Code:'name',Name:'省份名称'},{Code:'code',Name:'省份编码'}]" rt-required="true"
                            rt-col="4"></rt-lookup2>
                        <rt-lookup2 rt-title="城市" rt-disabled="vm.form.data.StateCode.Value == 1||vm.form.data.provinceid==null" ng-model="vm.form.data.cityid"
                            rt-get-data-name="Province.GetCity" rt-order-by="code" rt-col-list="[{Code:'name',Name:'城市名称'},{Code:'code',Name:'城市编码'}]"
                            rt-params="{'@provinceid':vm.form.data.provinceid ? vm.form.data.provinceid.Id :''}" rt-required="true"
                            rt-col="4"></rt-lookup2>
                    </rt-section-row>
                    <rt-section-row>
                        <rt-lookup2 rt-title="区县" rt-disabled="vm.form.data.StateCode.Value == 1||vm.form.data.cityid==null" ng-model="vm.form.data.countyid"
                            rt-get-data-name="Province.GetCounty" rt-order-by="code" rt-col-list="[{Code:'name',Name:'区县名称'},{Code:'code',Name:'区县编码'}]"
                            rt-params="{'@cityid':vm.form.data.cityid ? vm.form.data.cityid.Id :''}" rt-col="4"></rt-lookup2>
                        <rt-picklist rt-title="分级" rt-col="4" rt-required="false" rt-disabled="vm.form.data.StateCode.Value == 1" ng-model="vm.form.data.account_grade_level"
                            rt-options="vm.picklist.account_grade_level"></rt-picklist>
                    </rt-section-row>
                    <rt-section-row>
                        <rt-input rt-type="text" rt-title="地址" rt-disabled="vm.form.data.StateCode.Value == 1" rt-col="10" ng-model="vm.form.data.address"></rt-input>
                    </rt-section-row>
                </rt-section>
                <rt-section rt-title="客户标签">
                    <div class="col-sm-12">
                    <rt-checkbox rt-title="{{tag.value}}" rt-col="1" ng-repeat="tag in vm.form.tagList" ng-model="tag.checked"></rt-checkbox>
                    </div>
                    <rt-section-row>
                        <div class="col-sm-2" style="padding-top:15px;padding-left:10%;">
                            <button class="btn btn-primary" ng-click="vm.addTag()">增加</button>
                        </div>
                        <div class="col-sm-2" style="padding-top:15px;padding-left:10%;">
                            <button class="btn btn-primary" ng-click="vm.delTag()">删除</button>
                        </div>
                    </rt-section-row>
                </rt-section>
                <rt-section rt-title="详细信息">
                    <rt-section-row>
                        <rt-picklist rt-title="连锁类型" rt-col="4" ng-model="vm.form.data.chain_type" rt-disabled="vm.form.data.StateCode.Value == 1"
                            rt-options="vm.picklist.chain_type"></rt-picklist>
                        <rt-input rt-type="Unsignedint" rt-title="终端数量" rt-col="4" rt-disabled="vm.form.data.StateCode.Value == 1" ng-model="vm.form.data.terminal_count"></rt-input>
                    </rt-section-row>
                    <rt-section-row>
                        <rt-input rt-type="Unsignedint" rt-title="直营店数量" rt-col="4" rt-disabled="vm.form.data.StateCode.Value == 1" ng-model="vm.form.data.terminal_count_direct"></rt-input>
                        <rt-input rt-type="Unsignedint" rt-title="加盟店数量" rt-col="4" rt-disabled="vm.form.data.StateCode.Value == 1" ng-model="vm.form.data.terminal_count_franchise"></rt-input>
                    </rt-section-row>
                    <rt-section-row>
                        <rt-input rt-type="decimal" rt-title="年营业额(万元)" rt-col="4" rt-disabled="vm.form.data.StateCode.Value == 1" ng-model="vm.form.data.sales"></rt-input>
                    </rt-section-row>
                </rt-section>
                <rt-section rt-title="状态">
                    <rt-section-row>
                        <rt-picklist rt-title="状态" rt-col="4" ng-model="vm.form.data.StateCode" rt-disabled="true" rt-options="vm.picklist.StateCode"></rt-picklist>
                    </rt-section-row>
                </rt-section>
            </div>
            <!-- div[#1, .tab-pane] -->
            <!--连锁 联系人-->
            <div class="tab-pane" id="A2{{vm.form.name}}">
                <div ng-if="vm.form.type === 'Edit'" rt-include rt-template="Module/Contact/contactListView.html" rt-controller="contactListController"
                    rt-include-params='{"relatedAttr": "accountid"}'></div>
            </div>
            <!--连锁 下属门店-->
            <div class="tab-pane" id="A3{{vm.form.name}}">
                <div ng-if="vm.form.type === 'Edit'" rt-include rt-template="Module/TerminalAccount/terminalaccountListView.html" rt-controller="terminalaccountListController"
                    rt-include-params='{"relatedAttr": "parentaccountid"}'></div>
            </div>
            <!--连锁 归属信息-->
            <div class="tab-pane" id="A4{{vm.form.name}}">
                <div>
                    <div class="listview">
                        <div class="row">
                            <div class="col-sm-8">
                                <div class="btn-group" ng-show="(vm.form.type === 'Create' && vm.privilege.IsCreate) || (vm.form.type === 'Edit' && vm.form.data.StateCode.Value == 0 && vm.privilege.IsWrite)">
                                    <button class="btn btn-link" ng-if="vm.form.type === 'Edit'" ng-click="vm.showForm(vm.form.id,'Module/ChainAccount/salesRegionInfoEditView.html', 'chainaccountEditController')">
                                        <i class="fa fa-plus"></i> 新建
                                    </button>
                                    <button class="btn btn-link" ng-if="vm.form.type === 'Create'" ng-click="vm.showForm2(salesRegionInfoList,'Module/ChainAccount/salesRegionInfoEditView.html', 'chainaccountEditController')">
                                        <i class="fa fa-plus"></i> 新建
                                    </button>
                                    <button class="btn btn-link" ng-click="vm.del()">
                                        <i class="fa fa-trash"></i> 删除
                                    </button>
                                </div>
                            </div>
                        </div>

                        <div class="viewlist">
                            <table class="table table-hover">
                                <thead>
                                    <tr>
                                        <th>
                                            <rt-header-checkbox id="checkboxAll" ng-click="vm.selectAll()"></rt-header-checkbox>
                                        </th>
                                        <!-- @@ 视图表头 -->
                                        <th>小区</th>
                                        <th>代表</th>
                                        <th>部门</th>
                                        <th>品种</th>
                                    </tr>
                                </thead>
                                <tbody id="salesRegion">
                                    <tr ng-repeat="row in salesRegionInfoList">
                                        <td>
                                            <input type="checkbox" id="{{$index}}" ng-click="updateSelection($event,$index)">
                                        </td>
                                        <td>
                                            {{row.sales_regionidname}}
                                        </td>
                                        <td>
                                            {{row.owneridname}}
                                        </td>
                                        <td>
                                            {{row.buidname}}{{row.bigdepartidname}}{{row.businessunitidname}}
                                        </td>
                                        <td>
                                            {{row.product_categoryidname}}
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>

                    <div class="editview borderShadow sidebar sidebar-right sidebar-animate" ng-if="vm.view.type=='default'">
                        <div ui-view class="content"></div>
                    </div>
                </div>
            </div>
        </div>
        <!-- div[.tab-content] -->
    </div>
</rt-form>
<!-- rt-form -->