<!DOCTYPE html>
<html>
<head>
    <title>渠道销售分配，分销商针对某个商品sku的销售分配</title>
    #parse("sys/header.html")
</head>
<body>
<div id="rrapp" v-cloak>
	<div v-show="showList">
        <Row :gutter="16">
            <div class="search-group">
                <i-col span="3">
                    <i-select v-model="q.distChnlId" placeholder="分销渠道"  @on-change="queryChangeByDistChnlId">
                        <i-option v-for="chnl in queryMkDistChnlList" :value="chnl.distChnlId" :key="chnl.distChnlId">{{chnl.distFlag}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="3">
                    <i-select v-model="q.distId" placeholder="分销商"  >
                        <i-option v-for="dist in queryMkDistList" :value="dist.distId" :key="dist.distId">{{dist.distName}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="3">
                    <i-select v-model="q.storeId" placeholder="门店"  @on-change="queryChangeGoodsByStore">
                        <i-option v-for="store in queryStoreList" :value="store.id" :key="store.id">{{store.storeName}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="3">
                    <i-select v-model="q.goodsId" placeholder="商品" >
                        <i-option v-for="goods in queryGoodsList" :value="goods.goodsId" :key="goods.goodsId">{{goods.goodsName}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-button @click="query">查询</i-button>
                <i-button @click="reloadSearch">重置</i-button>
            </div>
            <div class="buttons-group">
                #if($shiro.hasPermission("mkdistsellallocation:save"))
                <i-button type="info" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</i-button>
                #end
                #if($shiro.hasPermission("mkdistsellallocation:update"))
                <i-button type="warning" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</i-button>
                #end
                #if($shiro.hasPermission("mkdistsellallocation:delete"))
                <i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
                #end
            </div>
        </Row>
	    <table id="jqGrid"></table>
	    <div id="jqGridPager"></div>
    </div>

    <Card v-show="!showList">
        <p slot="title">{{title}}</p>
		<i-form ref="formValidate" :model="mkDistSellAllocation" :rules="ruleValidate" :label-width="120">
            <!--<Form-item label="分销渠道id" prop="distChnlId">-->
                <!--&lt;!&ndash;<i-input v-model="mkDistSellAllocation.distFlag" placeholder="分销渠道名称"/>&ndash;&gt;-->
                <!--<i-select v-model="mkDistSellAllocation.distChnlId" placeholder="分销渠道名称" style="width: 268px;" @on-change="changeDist" label-in-value>-->
                    <!--<i-option v-for="mkDistChnl in mkDistChnlList" :value="mkDistChnl.distChnlId" :key="mkDistChnl.distChnlId">{{mkDistChnl.distFlag}}-->
                    <!--</i-option>-->
                <!--</i-select>-->
            <!--</Form-item>-->
            <Form-item label="所属三方商户" prop="thirdMerchSn">
                <!--<i-input v-model="mkDistSellAllocation.thirdMerchSn" placeholder="所属三方商户"/>-->
                <i-select v-model="mkDistSellAllocation.thirdMerchSn" placeholder="所属三方商户" style="width: 268px;" @on-change="changeDist" label-in-value>
                    <i-option v-for="thirdMerchant in thirdMerchantBizList" :value="thirdMerchant.thirdMerchSn" :key="thirdMerchant.thirdMerchSn">{{thirdMerchant.thirdPartyMerchName}}</i-option>
                </i-select>
            </Form-item>
            <Form-item label="所属供应商" prop="supplierId">
                <!--<i-input v-model="mkDistSellAllocation.supplierId" placeholder="所属供应商"/>-->
                <i-select v-model="mkDistSellAllocation.supplierId" placeholder="所属供应商" style="width: 268px;" label-in-value>
                    <i-option v-for="supplier in suppliers" :value="supplier.id" :key="supplier.id">{{supplier.childSupplierName}}
                    </i-option>
                </i-select>
            </Form-item>
            <Form-item label="所属门店" prop="storeId">
                <i-select v-model="mkDistSellAllocation.storeId" placeholder="所属门店" style="width: 268px;" label-in-value  @on-change="changeGoods">
                    <i-option v-for="store in storeList" :value="store.id" :key="store.id">{{store.storeName}}
                    </i-option>
                </i-select>
            </Form-item>
            <Form-item label="商品所属分销商" prop="distId">
                <i-select v-model="mkDistSellAllocation.distId" placeholder="分销商" style="width: 268px;" label-in-value>
                    <i-option v-for="mkDist in mkDistList" :value="mkDist.distId" :key="mkDist.distId">{{mkDist.distName}}
                    </i-option>
                </i-select>
            </Form-item>
            <Form-item label="商品id" prop="goodsId">
                <i-select v-model="mkDistSellAllocation.goodsId" placeholder="商品id" style="width: 268px;" @on-change="showTree" label-in-value>
                    <i-option v-for="goods in goodsList" :value="goods.goodsId" :key="goods.goodsId">{{goods.goodsName}}
                    </i-option>
                </i-select>
            </Form-item>
            <Form-item label="分配方式" prop="allocType">
                <i-select v-model="mkDistSellAllocation.allocType" placeholder="分配方式" style="width: 268px;" label-in-value>
                    <i-option value="00" :key="mkDistSellAllocation.id">比例
                    </i-option>
                    <i-option value="10" :key="mkDistSellAllocation.id">金额
                    </i-option>
                </i-select>
            </Form-item>

            <Form-item label="分销额度分配" prop="allocType">
                <div v-for="(item,index) in expendDistList" >
                    <div class="row">
                        <div class="col-md-3">
                            <label class="ivu-form-item-label">{{item.expendDistLvl != '' ? item.expendDistLvl+'级':'上级'}}分销商：</label>
                            <div class="col-md-4 input-icon right">
                                <!--<i-input type="text" v-model="item.expendDistName"/>-->
                                <i-select v-model="item.expendDistId" placeholder="分销商" style="width: 268px;" label-in-value>
                                    <i-option :value="item.expendDistId" :key="item.expendDistId">{{item.expendDistName}}
                                    </i-option>
                                </i-select>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <label class="ivu-form-item-label">{{item.expendDistLvl != '' ? item.expendDistLvl+'级':'上级'}}分销商分配额度（比例/金额）：</label>
                            <div class="col-md-5 input-icon right">
                                <i-input type="text" v-model="item.expendDistLine"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div><span style="color: red">{{expendDistList.length == 0 ? '请先维护选择的商品所属分销商的层级关系':''}}</span></div>
            </Form-item>

            <!--<Form-item label="支出分销商id">-->
                <!--&lt;!&ndash;<i-input v-model="mkDistSellAllocation.expendDistIds" placeholder="支出分销商id"/>&ndash;&gt;-->
                <!--<div style="overflow-y: auto; max-height: 250px;width: 300px; border: 1px solid #cccccc;">-->
                    <!--<ul id="expendDistIdsTree" class="ztree"></ul>-->
                <!--</div>-->
            <!--</Form-item>-->
            <!--<Row>-->
                <!--<i-col span="16" style="margin-top: -10px;">-->
                <!--<span style="margin-left: 120px; color: red; font-size: 12px;">* 额度需与支出分销商对应排序，由,拼接，逗号为英文小写。示例：比例1,比例2,比例3...</span>-->
                <!--</i-col>-->
            <!--</Row>-->
            <!--<Form-item label="支出分销商对应额度（比例/金额）" prop="expendDistLines">-->
                <!--<i-input v-model="mkDistSellAllocation.expendDistLines" placeholder="支出分销商对应额度（比例/金额）"/>-->
            <!--</Form-item>-->
            <Form-item label="是否有效" prop="isValid" label-in-value style="margin-top: 20px;">
                <Radio-group v-model="mkDistSellAllocation.isValid">
                    <Radio label="1">
                        <span>无效</span>
                    </Radio>
                    <Radio label="0">
                        <span>有效</span>
                    </Radio>
                </Radio-group>
            </Form-item>
            <Form-item label="备注" prop="note">
                <i-input v-model="mkDistSellAllocation.note" placeholder="备注"/>
            </Form-item>
            <Form-item>
                <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
                <i-button type="warning" @click="reload" style="margin-left: 8px"/>返回</i-button>
                <i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
            </Form-item>
        </i-form>
	</Card>
</div>

<script src="${rc.contextPath}/js/mk/mkdistsellallocation.js?_${date.systemTime}"></script>
</body>
</html>