<!DOCTYPE html>
<html>
<head>
    <title></title>
    #parse("sys/header.html")
    <style>
        .upload-list {
            display: inline-block;
            width: 60px;
            height: 60px;
            text-align: center;
            line-height: 60px;
            border: 1px solid transparent;
            border-radius: 4px;
            overflow: hidden;
            background: #fff;
            position: relative;
            box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
            margin-right: 4px;
        }

        .upload-list img {
            width: 100%;
            height: 100%;
        }

        .upload-list-cover {
            display: none;
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            background: rgba(0, 0, 0, .6);
        }

        .upload-list:hover .upload-list-cover {
            display: block;
        }

        .upload-list-cover i {
            color: #fff;
            font-size: 20px;
            cursor: pointer;
            margin: 0 2px;
        }
    </style>
</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.thirdPartyMerchCode" placeholder="所属三方商户" filterable >
                        <i-option v-for="thirdMerchant in thirdMerchantBizShowList" :value="thirdMerchant.thirdPartyMerchCode" :key="thirdMerchant.thirdPartyMerchCode">{{thirdMerchant.thirdPartyMerchName}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="3">
                    <i-select v-model="q.storeId" placeholder="门店" filterable label-in-value>
                        <i-option v-for="store in stores" :value="store.id"
                                  :key="store.id">{{store.storeName}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="3">
                    <i-input v-model="q.goodsName" @on-enter="query" placeholder="名称"/>
                </i-col>
                <i-col span="3">
                    <i-input v-model="q.goodsSn" @on-enter="query" placeholder="商品编码"/>
                </i-col>
                <i-col span="3">
                    <i-select v-model="q.category" placeholder="商品分类" filterable @on-change="changeQueryCategories"
                              label-in-value>
                        <i-option v-for="category in queryCategories" :value="category.id"
                                  :key="category.id">{{category.name}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="3">
                    <i-select v-model="q.categoryTwo" placeholder="商品二级分类" filterable label-in-value>
                        <i-option v-for="category in queryCategoriesTwo" :value="category.id"
                                  :key="category.id">{{category.name}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="3">
                    <i-select v-model="q.goodsBizType" placeholder="货品业务类型"
                              label-in-value>
                        <i-option v-for="macro in macros" :value="macro.value" :key="macro.id">{{macro.name}}
                        </i-option>
                    </i-select>
                </i-col>
                <!--<i-col span="4">
                    <i-input v-model="q.productSn" @on-enter="query" placeholder="规格编码"/>
                </i-col>-->
                <i-button @click="query">查询</i-button>
                <i-button @click="reloadSearch">重置</i-button>
            </div>
            <div class="buttons-group" style="float: left">
                <!--#if($shiro.hasPermission("productstorerela:upload"))
                <i-col style="display: inline-grid;">
                    <Upload :show-upload-list="false" :on-success="uploadExcelSuccess" :on-error="uploadExcelError"
                            action="../goods/upload">
                        <i-button type="ghost" icon="ios-cloud-upload-outline">导入</i-button>
                    </Upload>
                </i-col>
                #end-->
                #if($shiro.hasPermission("productstorerela:save"))
                <i-button type="info" @click="add" v-show="!isSupplierShowByThirdSn||roleType"><i class="fa fa-plus"></i>&nbsp;新增</i-button>
                #end
                #if($shiro.hasPermission("productstorerela:update"))
                <i-button type="warning" @click="update" v-show="!isSupplierShowByThirdSn||roleType"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</i-button>
                #end
                #if($shiro.hasPermission("productstorerela:save"))
                <i-button type="info" @click="addSupplierGoods" v-show="isSupplierShowByThirdSn"><i class="fa fa-plus"></i>&nbsp;新增供货商商品</i-button>
                #end
                #if($shiro.hasPermission("productstorerela:update"))
                <i-button type="warning" @click="updateSupplierGoods" v-show="isSupplierShowByThirdSn"><i class="fa fa-pencil-square-o"></i>&nbsp;修改供货商商品</i-button>
                #end
                #if($shiro.hasPermission("productstorerela:delete"))
                <i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
                #end
                #if($shiro.hasPermission("productstorerela:productStoreRelaUpload"))
                <i-col style="display: inline-grid;">
                    <Upload :show-upload-list="false" :on-success="uploadExcelSuccess" :on-error="uploadExcelError" :on-format-error="uploadExcelFormatError"
                            :format="['xls','xlsx']"
                            action="../productstorerela/productStoreRelaUpload">
                        <i-button type="ghost" icon="ios-cloud-upload-outline">门店商品导入</i-button>
                    </Upload>
                </i-col>
                #end
                #if($shiro.hasPermission("productstorerela:down"))
                &nbsp;&nbsp;&nbsp;<a href="../statics/file/store_goods_export_yyyy_mm_dd_v1.0.0.xls">门店商品模板下载</a>&nbsp;&nbsp;&nbsp;&nbsp;
                #end
            </div>
        </Row>
        <table id="jqGrid"></table>
        <div id="jqGridPager"></div>
    </div>

    <Card v-show="!showViewList">
        <p slot="title">{{title}}</p>
        <i-form ref="formValidate" :model="productStoreRela" :rules="ruleValidate" :label-width="80">
            <Form-item label="门店" prop="storeId">
                <i-select v-model="productStoreRela.storeId" placeholder="门店" filterable @on-change="getGoods"
                          label-in-value v-show="isOperatorShow" disabled>
                    <i-option v-for="store in storesList" :value="store.id"
                              :key="store.id">{{store.storeName}}
                    </i-option>
                </i-select>
                <i-select v-model="productStoreRela.storeId" placeholder="门店" filterable @on-change="getGoods"
                          label-in-value v-show="!isOperatorShow">
                    <i-option v-for="store in storesList" :value="store.id"
                              :key="store.id">{{store.storeName}}
                    </i-option>
                </i-select>
            </Form-item>
            <Form-item label="商品" prop="goodsId">
                <i-select v-model="productStoreRela.goodsId" filterable @on-change="changeGoods" label-in-value  v-show="isOperatorShow" disabled>
                    <i-option v-for="goods in goodsList" :value="goods.id" :key="goods.id">{{goods.name}}（{{goods.goodsBizType=='00'?'保税备货':''}}{{goods.goodsBizType=='02'?'保税展示补货':''}}{{goods.goodsBizType=='10'?'门店店提':''}}{{goods.goodsBizType=='11'?'普通货物':''}}）</i-option>
                </i-select>
                <i-select v-model="productStoreRela.goodsId" filterable @on-change="changeGoods" label-in-value  v-show="!isOperatorShow">
                    <i-option v-for="goods in goodsList" :value="goods.id" :key="goods.id">{{goods.name}}（{{goods.goodsBizType=='00'?'保税备货':''}}{{goods.goodsBizType=='02'?'保税展示补货':''}}{{goods.goodsBizType=='10'?'门店店提':''}}{{goods.goodsBizType=='11'?'普通货物':''}}）</i-option>
                </i-select>
            </Form-item>
            <div v-show="isStockShare"><span style="margin-left: 80px;color: red;font-size: 12px;">* 该门店商品所选供应商第三方商户是共享库存，门店库存则为商户商品总库存，不需要编辑</span></div>
            <Form-item label="库存" prop="stockNum" v-show="isStockShare"><!--共享-->
                <Input-number :min="0" :step="1" v-model="productStoreRela.stockNum" placeholder="总库存"
                              style="width: 268px;" disabled/>
            </Form-item>
            <Form-item label="库存" prop="stockNum" v-show="!isStockShare && showInput"><!--不共享-->
                <Input-number :min="0" :step="1" v-model="productStoreRela.stockNum" placeholder="总库存"
                              style="width: 268px;" />
            </Form-item>
            <Form-item v-if="showInput" label="商品类型" prop="categoryId" style="height: 30px;">
                <!--<i-input v-model="goods.categoryName" @on-click="categoryTree" icon="eye" readonly="readonly" placeholder="商品类型"/>-->
                <i-select v-model="productStoreRela.attributeCategory" placeholder="商品分类" @on-change="changeCategories"
                          label-in-value style="width: 268px;height: 30px;">
                    <i-option v-for="category in categories" :value="category.id"
                              :key="category.id">{{category.name}}
                    </i-option>
                </i-select>
                <i-select v-model="productStoreRela.categoryId" placeholder="商品二级分类" @on-change="getAttributes"
                          label-in-value style="width: 268px;height: 30px;">
                    <i-option v-for="category in categoriesTwo" :value="category.id"
                              :key="category.id">{{category.name}}
                    </i-option>
                </i-select>
            </Form-item>
            <Form-item v-if="showInput" label="品牌" prop="brandId">
                <i-select v-model="productStoreRela.brandId" placeholder="品牌"
                          label-in-value style="width: 268px;">
                    <i-option v-for="brand in brands" :value="brand.id" :key="brand.id">{{brand.name}}
                    </i-option>
                </i-select>
            </Form-item>
            <Form-item v-if="showInput" label="运费模版" prop="freightId">
                <i-select v-model="productStoreRela.freightId" placeholder="运费模版"
                          label-in-value style="width: 268px;">
                    <i-option v-for="freight in freights" :value="freight.id" :key="freight.id">{{freight.name}}
                    </i-option>
                </i-select>
            </Form-item>
            <Form-item v-if="showInputSpecification" label="规格" prop="specification">
                <i-input v-model="productStoreRela.specification" placeholder="规格" style="width: 268px;"/>
            </Form-item>
            <Form-item  v-if="showInput" label="零售价" prop="retailPrice">
                <Input-number :min="0.01" :step="0.01" v-model="productStoreRela.retailPrice" placeholder="零售价格"
                              style="width: 268px;"/>
            </Form-item>
            <Form-item v-if="showInput" label="市场价" prop="marketPrice">
                <i-input v-model="productStoreRela.marketPrice" placeholder="市场价"
                              style="width: 268px;"/>
            </Form-item>
            <Form-item v-if="showInput&&isHotShow" label="热销商品排序" prop="hotSortNum">
                <i-input v-model="productStoreRela.hotSortNum" placeholder="热销商品排序"
                         style="width: 268px;"/>
            </Form-item>
            <div v-if="showInput" v-for="(item,index) in attributeEntityList" v-show="item.isDelete==0" style="margin-left: 16px;">
                <div class="row">
                    <div class="col-md-3">
                        <label class="ivu-form-item-label">属性：</label>
                        <div class="col-md-7 input-icon right">
                            <i-select v-model="item.attributeId" filterable>
                                <i-option v-for="attribute in attributes" :value="attribute.id"
                                          :key="attribute.id">{{attribute.name}}
                                </i-option>
                            </i-select>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <label class="ivu-form-item-label">属性值：</label>
                        <div class="col-md-7 input-icon right">
                            <i-input type="text" v-model="item.value"/>
                        </div>
                    </div>
                    <button v-if="index == 0" class="btn btn-primary btn-sm" type="button" @click="addAttrRow">
                        <i class="fa fa-plus"></i>
                    </button>
                    <button class="btn red btn-sm" type="button" @click="delAttrRow(index)">
                        <i class="fa fa-trash-o"></i>
                    </button>
                </div>
            </div>
        </i-form>
        <div style="padding-left: 20px;padding-top: 20px">
            <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>-->
        </div>
    </Card>

    <Card v-show="!showSaveSupplierGoods">
        <p slot="title">{{title}}</p>
        <i-form ref="formValidate" :model="productStoreRela" :rules="ruleValidate" :label-width="120">
            <Form-item label="门店" prop="storeId">
                <i-select v-model="productStoreRela.storeId" placeholder="门店" filterable  @on-change="getDataChangeStore"
                          label-in-value v-show="isSupplierOperatorShow" disabled>
                    <i-option v-for="store in storesBySupplierList" :value="store.id"
                              :key="store.id">{{store.storeName}}
                    </i-option>
                </i-select>
                <i-select v-model="productStoreRela.storeId" placeholder="门店" filterable
                          label-in-value v-show="!isSupplierOperatorShow"  @on-change="getDataChangeStore">
                    <i-option v-for="store in storesBySupplierList" :value="store.id"
                              :key="store.id">{{store.storeName}}
                    </i-option>
                </i-select>
            </Form-item>
            <Form-item label="所属供应商三方商户" prop="supplierThirdId">
                <i-select v-model="productStoreRela.supplierThirdId" placeholder="所属供应商三方商户" filterable label-in-value @on-change="getGoodsByThirdMerchSn" v-show="isSupplierOperatorShow" disabled>
                    <i-option v-for="thirdMerchant in thirdMerchantBizList" :value="thirdMerchant.thirdMerchSn" :key="thirdMerchant.thirdMerchSn">{{thirdMerchant.thirdPartyMerchName}}</i-option>
                </i-select>
                <i-select v-model="productStoreRela.supplierThirdId" placeholder="所属供应商三方商户" filterable label-in-value @on-change="getGoodsByThirdMerchSn" v-show="!isSupplierOperatorShow">
                    <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="goodsId">
                <i-select v-model="productStoreRela.goodsId" filterable @on-change="changeSupplerGoods" label-in-value  v-show="isSupplierOperatorShow" disabled>
                    <i-option v-for="goods in goodss" :value="goods.id" :key="goods.id">{{goods.name}}（{{goods.goodsBizType=='00'?'保税备货':''}}{{goods.goodsBizType=='02'?'保税展示补货':''}}{{goods.goodsBizType=='10'?'门店店提':''}}{{goods.goodsBizType=='11'?'普通货物':''}}）</i-option>
                </i-select>
                <i-select v-model="productStoreRela.goodsId" filterable @on-change="changeSupplerGoods" label-in-value  v-show="!isSupplierOperatorShow">
                    <i-option v-for="goods in goodss" :value="goods.id" :key="goods.id">{{goods.name}}（{{goods.goodsBizType=='00'?'保税备货':''}}{{goods.goodsBizType=='02'?'保税展示补货':''}}{{goods.goodsBizType=='10'?'门店店提':''}}{{goods.goodsBizType=='11'?'普通货物':''}}）</i-option>
                </i-select>
            </Form-item>
            <div v-show="isSupplierStockShare"><span style="margin-left: 80px;color: red;font-size: 12px;">* 该门店商品所选供应商第三方商户是共享库存，门店库存则为商户商品总库存，不需要编辑</span></div>
            <Form-item label="库存" prop="stockNum" v-show="isSupplierStockShare"><!--共享-->
                <Input-number :min="0" :step="1" v-model="productStoreRela.stockNum" placeholder="总库存"
                              style="width: 268px;" disabled/>
            </Form-item>
            <Form-item label="库存" prop="stockNum" v-show="!isSupplierStockShare && showInput"><!--不共享-->
                <Input-number :min="0" :step="1" v-model="productStoreRela.stockNum" placeholder="总库存"
                              style="width: 268px;" />
            </Form-item>
            <Form-item v-if="showInput" label="商品类型" prop="categoryId" style="height: 30px;">
                <!--<i-input v-model="goods.categoryName" @on-click="categoryTree" icon="eye" readonly="readonly" placeholder="商品类型"/>-->
                <i-select v-model="productStoreRela.attributeCategory" placeholder="商品分类" @on-change="changeCategories"
                          label-in-value style="width: 268px;height: 30px;">
                    <i-option v-for="category in categories" :value="category.id"
                              :key="category.id">{{category.name}}
                    </i-option>
                </i-select>
                <i-select v-model="productStoreRela.categoryId" placeholder="商品二级分类" @on-change="getAttributes"
                          label-in-value style="width: 268px;height: 30px;">
                    <i-option v-for="category in categoriesTwo" :value="category.id"
                              :key="category.id">{{category.name}}
                    </i-option>
                </i-select>
            </Form-item>
            <Form-item v-if="showInput" label="品牌" prop="brandId">
                <i-select v-model="productStoreRela.brandId" placeholder="品牌"
                          label-in-value style="width: 268px;">
                    <i-option v-for="brand in brands" :value="brand.id" :key="brand.id">{{brand.name}}
                    </i-option>
                </i-select>
            </Form-item>
            <Form-item v-if="showInput" label="运费模版" prop="freightId">
                <i-select v-model="productStoreRela.freightId" placeholder="运费模版"
                          label-in-value style="width: 268px;">
                    <i-option v-for="freight in freights" :value="freight.id" :key="freight.id">{{freight.name}}
                    </i-option>
                </i-select>
            </Form-item>
            <Form-item v-if="showInputSpecification" label="规格" prop="specification">
                <i-input v-model="productStoreRela.specification" placeholder="规格" style="width: 268px;" v-show="isSupplierOperatorShow" disabled></i-input>
                <i-input v-model="productStoreRela.specification" placeholder="规格" style="width: 268px;" v-show="!isSupplierOperatorShow"></i-input>
            </Form-item>
            <Form-item  v-if="showInput" label="零售价" prop="retailPrice">
                <Input-number :min="0.01" :step="0.01" v-model="productStoreRela.retailPrice" placeholder="零售价格"
                              style="width: 268px;"/>
            </Form-item>
            <Form-item v-if="showInput" label="市场价" prop="marketPrice">
                <i-input v-model="productStoreRela.marketPrice" placeholder="市场价"
                              style="width: 268px;"/>
            </Form-item>
            <Form-item v-if="showInput&&isHotShow" label="热销商品排序" prop="hotSortNum">
                <i-input v-model="productStoreRela.hotSortNum" placeholder="热销商品排序"
                         style="width: 268px;"/>
            </Form-item>
            <div v-if="showInput" v-for="(item,index) in attributeEntityList" v-show="item.isDelete==0" style="margin-left: 16px;">
                <div class="row">
                    <div class="col-md-3">
                        <label class="ivu-form-item-label">属性：</label>
                        <div class="col-md-7 input-icon right">
                            <i-select v-model="item.attributeId" filterable>
                                <i-option v-for="attribute in attributes" :value="attribute.id"
                                          :key="attribute.id">{{attribute.name}}
                                </i-option>
                            </i-select>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <label class="ivu-form-item-label">属性值：</label>
                        <div class="col-md-7 input-icon right">
                            <i-input type="text" v-model="item.value"/>
                        </div>
                    </div>
                    <button v-if="index == 0" class="btn btn-primary btn-sm" type="button" @click="addAttrRow">
                        <i class="fa fa-plus"></i>
                    </button>
                    <button class="btn red btn-sm" type="button" @click="delAttrRow(index)">
                        <i class="fa fa-trash-o"></i>
                    </button>
                </div>
            </div>
        </i-form>
        <div style="padding-left: 20px;padding-top: 20px">
            <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>-->
        </div>
    </Card>
</div>

<!-- 选择类型 -->
<div id="categoryLayer" style="display: none;padding:10px;">
    <ul id="categoryTree" class="ztree"></ul>
</div>

<div id="qrcode" style="display: none;padding: 10px;">
    <div id="qrcodeCanvas" style="margin: 53px 0 0 93px"></div>
</div>


<div id="qrcImg" style="display:none">
    <img class="qrcImg align-center" src="">
    <img class="upLogo align-center-middle" src="" >
</div>

<div id="qrcode2" style="display: none;padding: 10px;">
    <div id="qrcodeCanvas2" style="margin: 20px 0 0 55px"></div>
</div>
<div id="qrcImg2" style="display:none">
    <img class="qrcImg align-center" height="300px" width="300px" src="">
</div>

<script src="${rc.contextPath}/js/shop/storeProductStock.js?_${date.systemTime}"></script>
</body>

<style>
    .align-center {
        position:absolute;
        margin: auto;
        top:0px;
        bottom: 0px;
        right: 0px;
        left: 0px;
    }

    .align-center-middle {
        position:absolute;
        height: 30px;
        width: 30px;
        margin: auto;
        top:0px;
        bottom: 0px;
        right: 0px;
        left: 0px;
    }
</style>
</html>
