| <!DOCTYPE HTML> | 
| <html xmlns:th="http://www.thymeleaf.org"> | 
| <head> | 
| <meta charset="utf-8"> | 
| <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> | 
| <meta name="renderer" content="webkit|ie-comp|ie-stand"> | 
| <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | 
| <meta name="viewport" | 
|     content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" /> | 
| <meta http-equiv="Cache-Control" content="no-siteapp" /> | 
| <!-- 本框架基本脚本和样式 --> | 
|     <script type="text/javascript" th:src="@{/js/systools/MBaseVue.js}"></script> | 
|     <link rel="stylesheet" th:href="@{/plugin/element-ui/index.css}"> | 
|     <link rel="stylesheet" th:href="@{/plugin/bootstrap-3.3.5/css/bootstrap.min.css}"> | 
|     <link th:href="@{/css/styleOne/style.min.css}" rel="stylesheet" type="text/css"/> | 
|   | 
|     <script type="text/javascript" th:src="@{/js/plugin/jquery-2.1.4.min.js}"></script> | 
|     <script type="text/javascript" th:src="@{/js/plugin/jquery.query.js}"></script> | 
|     <script type="text/javascript" th:src="@{/js/systools/MJsBase.js}"></script> | 
|     <script type="text/javascript" th:src="@{/plugin/bootstrap-3.3.5/js/bootstrap.min.js}"></script> | 
|     <script type="text/javascript" th:src="@{/js/systools/AjaxProxyVue.js}"></script> | 
|     <script type="text/javascript" th:src="@{/js/plugin/vue.js}"></script> | 
|     <script type="text/javascript" th:src="@{/plugin/element-ui/index.js}"></script> | 
| </head> | 
| <body> | 
| <div id="app" class="ibox-content"> | 
|         <el-form :model="ruleForm" :rules="rules"  class="form-horizontal" id="dataform" ref="ruleForm" label-width="120px"> | 
|             <input autocomplete="off" v-model="ruleForm.id"  type="hidden" name="id"> | 
|   | 
|             <div class="form-group"> | 
|                 <div class="col-sm-4 col-sm-offset-1"> | 
|                     <el-form-item label="活动名称" prop="actName"> | 
|                         <el-input v-model="ruleForm.actName" placeholder="请输入活动名称"></el-input> | 
|                     </el-form-item> | 
|                 </div> | 
|   | 
|                 <div class="col-sm-4 col-sm-offset-1"> | 
|                     <el-form-item label="参与门店" prop="shopIdsArr"> | 
|                         <el-select v-model="ruleForm.shopIdsArr" multiple filterable placeholder="请选择" style="width:100%"> | 
|                             <el-option v-for="item in shopList" :key="item.id" :label="item.shopName" :value="item.id" ></el-option> | 
|                         </el-select> | 
|                     </el-form-item> | 
|                 </div> | 
|             </div> | 
|             <div class="form-group"> | 
|                 <div class="col-sm-3 col-sm-offset-1"> | 
|                     <el-form-item label="选择产品" prop="goodsName"> | 
|                         <el-input v-model="ruleForm.goodsName" :disabled="true"></el-input> | 
|                     </el-form-item> | 
|                 </div> | 
|                 <div class="col-sm-1"> | 
|                     <el-button @click="openSelectGoods">选择产品</el-button> | 
|                 </div> | 
|                 <div class="col-sm-4 col-sm-offset-1"> | 
|                     <el-form-item label="活动时间" prop="actTime"> | 
|                         <el-date-picker v-model="ruleForm.actTime" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange" range-separator="至" | 
|                                 start-placeholder="开始日期" end-placeholder="结束日期"> | 
|                         </el-date-picker> | 
|                     </el-form-item> | 
|                 </div> | 
|             </div> | 
|             <div class="form-group"> | 
|                 <div class="col-sm-4 col-sm-offset-1"> | 
|                     <el-form-item label="最大开团数量" prop="actMax"> | 
|                         <el-input v-model.number="ruleForm.actMax" placeholder="请输入最大开团数量"></el-input> | 
|                     </el-form-item> | 
|                 </div> | 
|   | 
|                 <div class="col-sm-4 col-sm-offset-1"> | 
|                     <el-form-item label="每人限购" prop="giLimitBuy"> | 
|                         <el-input v-model.number="ruleForm.giLimitBuy" placeholder="填写0则无限制"></el-input> | 
|                     </el-form-item> | 
|                 </div> | 
|             </div> | 
|   | 
|             <div class="form-group"> | 
|                 <div class="col-sm-8 col-sm-offset-1"> | 
|                     <el-form-item label="团长优惠"> | 
|                         <el-switch v-model="ruleForm.giHeadDiscount"></el-switch> | 
|                     </el-form-item> | 
|                 </div> | 
|             </div> | 
|             <div class="form-group"> | 
|                 <div class="col-sm-8 col-sm-offset-1"> | 
|                     <el-form-item label="虚拟拼团"> | 
|                         <el-switch v-model="ruleForm.giVirtualGroup"></el-switch> | 
|                     </el-form-item> | 
|                 </div> | 
|             </div> | 
|   | 
|             <div class="form-group"> | 
|                 <div class="col-sm-8 col-sm-offset-1"> | 
|                     <el-form-item label="组团要求" prop="giType"> | 
|                         <el-radio-group v-model="ruleForm.giType"> | 
|                             <el-radio value="1" :label="1">老带新</el-radio> | 
|                             <el-radio value="2" :label="2">老会员</el-radio> | 
|                             <el-radio value="3" :label="3">新会员</el-radio> | 
|                         </el-radio-group> | 
|                     </el-form-item> | 
|                 </div> | 
|             </div> | 
|   | 
|             <div class="form-group"> | 
|                 <div class="col-sm-8 col-sm-offset-1"> | 
|                     <el-form-item label="拼团价"> | 
|                         <el-button type="primary" @click="addGroupPrice">新增价位(最多3个价位)</el-button> | 
|                     </el-form-item> | 
|                 </div> | 
|             </div> | 
|   | 
|             <div class="form-group" v-for="(item,index) in ruleForm.groupInfo.groupPriceList" :key="index"> | 
|                 <div class="col-sm-2 col-sm-offset-2"> | 
|                     <el-form-item label="拼团人数" :prop="'groupInfo.groupPriceList.'+index+'.gpCount'" :rules="rules.gpCount"> | 
|                         <el-input v-model.number="item.gpCount"></el-input> | 
|                     </el-form-item> | 
|                 </div> | 
|                 <div class="col-sm-3"> | 
|                     <el-form-item label="拼团价" :prop="'groupInfo.groupPriceList.'+index+'.gpPrice'" :rules="rules.gpPrice"> | 
|                         <el-input v-model="item.gpPrice"> | 
|                             <template slot="append">元/人</template> | 
|                         </el-input> | 
|                     </el-form-item> | 
|                 </div> | 
|                 <div class="col-sm-3" v-if="ruleForm.giHeadDiscount == 1"> | 
|                     <el-form-item label="团长价" :prop="'groupInfo.groupPriceList.'+index+'.gpHeadPrice'" :rules="rules.gpPrice"> | 
|                         <el-input v-model="item.gpHeadPrice"> | 
|                             <template slot="append">元</template> | 
|                         </el-input> | 
|                     </el-form-item> | 
|                 </div> | 
|                 <div class="col-sm-1" v-show="ruleForm.groupInfo.groupPriceList.length > 1" > | 
|                     <el-button @click="removePrice(item,index)">删除</el-button> | 
|                 </div> | 
|             </div> | 
|   | 
|             <div class="form-group"> | 
|                 <div class="col-sm-8 col-sm-offset-1"> | 
|                     <el-form-item label="活动说明" prop="actRemark"> | 
|                         <el-input type="textarea" v-model="ruleForm.actRemark"></el-input> | 
|                     </el-form-item> | 
|                 </div> | 
|             </div> | 
|   | 
|             <div class="form-group "> | 
|                 <div class="col-sm-12 text-center"> | 
|                     <el-button type="primary" @click="dataSubmit('ruleForm')">保存</el-button> | 
|                     <el-button type="danger" @click="closeForm">关闭</el-button> | 
|                 </div> | 
|             </div> | 
|     </el-form> | 
|     </div> | 
| </body> | 
| <script> | 
|   | 
|     const priceValidator = (rule, value, callback) =>{ | 
|         const reg =  /(?!^0*(\.0{1,2})?$)^\d{1,13}(\.\d{1,2})?$/; | 
|         const flag = reg.test(value); | 
|         if (flag) { | 
|             callback() | 
|         } else { | 
|             callback(new Error('请输入保留两位以内的小数')) | 
|         } | 
|     } | 
|   | 
|     var vm = new Vue({ | 
|         el : "#app", | 
|         data : { | 
|             ruleForm : { | 
|                 id : '', | 
|                 actName : '', | 
|                 shopIds : '', | 
|                 shopIdsArr : '', | 
|                 actTime : '', | 
|                 actMax : '', | 
|                 giLimitBuy : 0, // 表单验证需在ruleForm下 | 
|                 giHeadDiscount : false, // 表单验证需在ruleForm下 | 
|                 giVirtualGroup : false, // 表单验证需在ruleForm下 | 
|                 giType : '', // 表单验证需在ruleForm下 | 
|                 goodsName : '', | 
|                 beginTime : '', | 
|                 endTime : '', | 
|                 groupInfo : { | 
|                     giLimitBuy : 0, | 
|                     giHeadDiscount : '', | 
|                     giType : '', | 
|                     giVirtualGroup : '', | 
|                     goodsId : '', | 
|                     groupPriceList : [ | 
|                         { | 
|                             gpCount : '', | 
|                             gpPrice : '', | 
|                             gpHeadPrice : '' | 
|                         } | 
|                     ] | 
|                 } | 
|             }, | 
|             rules : { | 
|                 shopIdsArr : [ | 
|                     { required: true, message: '请选择参与门店', trigger: 'change' } | 
|                 ], | 
|                 actName : [ | 
|                     { required: true, message: '请输入活动名称', trigger: 'blur' } | 
|                 ], | 
|                 actTime : [ | 
|                     { required: true, message: '请选择日期', trigger: 'blur' } | 
|                 ], | 
|                 actMax : [ | 
|                     { required: true, message: '请输入最大开团数量', trigger: 'blur' }, | 
|                     { type : 'number', message: '请输入数字', trigger: 'blur' } | 
|                 ], | 
|                 giLimitBuy : [ | 
|                     { required: true, message: '请输入最大开团数量', trigger: 'blur' }, | 
|                     { type : 'number', message: '请输入数字', trigger: 'blur' } | 
|                 ], | 
|                 gpCount : [ | 
|                     { required: true, message: '拼团人数不能为空', trigger: 'blur' }, | 
|                     { type : 'number', message: '请输入数字', trigger: 'blur' } | 
|                 ], | 
|                 gpPrice : [ | 
|                     { required: true, message: '请输入保留两位以内的小数', trigger: 'blur' }, | 
|                     { validator : priceValidator, trigger: 'blur' } | 
|                 ], | 
|                 giType : [ | 
|                     { required: true, message: '请选择组团要求', trigger: 'blur' } | 
|                 ], | 
|                 goodsName : [ | 
|                     { required: true, message: '请选择关联产品', trigger: 'blur' } | 
|                 ] | 
|             }, | 
|             shopList : [], | 
|         }, | 
|         created : function() { | 
|             this.initForm(); | 
|         }, | 
|         methods : { | 
|             initForm : function() { | 
|                 var _this = this; | 
|                 $.AjaxProxy().invoke(basePath + "/admin/shopInfo/findShops", function(loj){ | 
|                     _this.shopList = loj[0].result.rows; | 
|                     var id = $.query.get("id"); | 
|                     console.log("----<>", id) | 
|                     if (id != null && id!='') { | 
|                         _this.ruleForm.id = id; | 
|                         _this.initData(id); | 
|                     } | 
|                 }); | 
|             }, | 
|             initData : function (id) { | 
|                 var _this = this; | 
|                 var ruleForm = _this.ruleForm; | 
|                 $.AjaxProxy().invoke(basePath + "/admin/shopActivities/findShopActivitiesById/" + id, function(loj){ | 
|                     console.log(loj[0].result); | 
|                     const result = loj[0].result; | 
|                     const activityInfo = result.mapInfo.shopActivities; | 
|                     const prices = result.mapInfo.groupPrices; | 
|                     ruleForm.actName = activityInfo.actName; | 
|                     ruleForm.actRemark = activityInfo.actRemark; | 
|                     ruleForm.actMax = activityInfo.actMax; | 
|                     ruleForm.giType = activityInfo.groupInfo.giType; | 
|                     ruleForm.goodsName = activityInfo.groupInfo.goodsName; | 
|                     ruleForm.groupInfo.goodsId = activityInfo.groupInfo.goodsId; | 
|                     ruleForm.giHeadDiscount = activityInfo.groupInfo.giHeadDiscount === 1; | 
|                     ruleForm.giVirtualGroup = activityInfo.groupInfo.giVirtualGroup === 1; | 
|                     ruleForm.giLimitBuy = activityInfo.groupInfo.giLimitBuy; | 
|                     ruleForm.shopIdsArr = activityInfo.shopIds.split(",").map(Number); | 
|                     ruleForm.groupInfo.groupPriceList = prices; | 
|                     var timeArr = new Array(); | 
|                     timeArr.push(activityInfo.actBeginTime); | 
|                     timeArr.push(activityInfo.actEndTime); | 
|                     ruleForm.actTime = timeArr; | 
|                 }) | 
|             }, | 
|             addGroupPrice : function () { | 
|                 const _this = this; | 
|                 const size = _this.ruleForm.groupInfo.groupPriceList.length; | 
|                 if (size >= 3) { | 
|                     _this.$notify({ | 
|                         title: '提示', | 
|                         message: '最多可添加3个价位', | 
|                         type: 'warning' | 
|                     }); | 
|                     return; | 
|                 } | 
|                 _this.ruleForm.groupInfo.groupPriceList.push( | 
|                         { | 
|                             gpCount : '', | 
|                             gpPrice : '', | 
|                             gpHeadPrice : '' | 
|                         } | 
|                 ); | 
|             }, | 
|             removePrice : function (item,index) { | 
|                 const _this = this; | 
|                 _this.ruleForm.groupInfo.groupPriceList.splice(index, 1); | 
|             }, | 
|             openSelectGoods : function () { | 
|                 layer.full(layer.open({ | 
|                     type : 2, | 
|                     title : "选择产品", | 
|                     area : [ MUI.SIZE_L, '400px' ], | 
|                     maxmin : true, | 
|                     content : [ basePath + '/admin/redirect/shop/activities/select-product-list' ] | 
|                 })); | 
|             }, | 
|             selectGoods : function (item) { | 
|                 const _this = this; | 
|                 console.log(item); | 
|                 _this.ruleForm.goodsName=item.title; | 
|                 _this.ruleForm.groupInfo.goodsId=item.id; | 
|             }, | 
|             dataSubmit : function (formName) { | 
|                 const _this = this; | 
|                 var result = _this.ruleForm; | 
|                 var flag = false; | 
|                 _this.$refs[formName].validate((valid) => { | 
|                     if (!valid) { | 
|                         console.log('error submit!!'); | 
|                         flag = true; | 
|                         return; | 
|                     } | 
|                 }); | 
|                 if (flag) { | 
|                     return; | 
|                 } | 
|   | 
|                 if (_this.ruleForm.giHeadDiscount) { | 
|                     _this.ruleForm.groupInfo.giHeadDiscount = 1; | 
|                 } else { | 
|                     _this.ruleForm.groupInfo.giHeadDiscount = 2; | 
|                 } | 
|   | 
|                 if (_this.ruleForm.giVirtualGroup) { | 
|                     _this.ruleForm.groupInfo.giVirtualGroup = 1; | 
|                 } else { | 
|                     _this.ruleForm.groupInfo.giVirtualGroup = 2; | 
|                 } | 
|   | 
|                 result.groupInfo.giType = result.giType; | 
|                 result.groupInfo.giLimitBuy = result.giLimitBuy; | 
|                 result.shopIds = result.shopIdsArr.toString(); | 
|                 result.beginTime = result.actTime[0]; | 
|                 result.endTime = result.actTime[1]; | 
|                 console.log(result); | 
|                 AjaxProxy.requst({ | 
|                     app: _this, | 
|                     data: result, | 
|                     url: basePath + '/admin/shopActivities/addGroupActivities', | 
|                     callback: function (data) { | 
|                         parent.layer.close(parent.layer.getFrameIndex(window.name)); | 
|                         parent.myGrid.serchData(); | 
|                     } | 
|                 }); | 
|             }, | 
|             resetSubmit : function (formName) { | 
|                 this.$refs[formName].resetFields(); | 
|             }, | 
|             closeForm : function() { | 
|                 parent.layer.close(parent.layer.getFrameIndex(window.name)); | 
|             } | 
|         }, | 
|     }); | 
| </script> | 
| </body> | 
| </html> |