app/views/educode_sales/businesses/new.html.erb in educode_sales-1.10.8 vs app/views/educode_sales/businesses/new.html.erb in educode_sales-1.10.9

- old
+ new

@@ -12,17 +12,24 @@ </div> <div class="layui-inline" > <a href="/missions/customers" style=" color: #0000FF">添加单位/部门</a> </div> <br> - <div class="layui-inline" style="padding-top: 20px"> + <!-- <div class="layui-inline" style="padding-top: 20px"> <label class="layui-form-label ">商机来源</label> <input type="text" name="source" autocomplete="off" class="layui-input" style="width: 300px;" placeholder="请输入商机来源"> - </div> + </div> --> <div class="layui-inline" style="padding-top: 20px"> - <p style="padding-left: 40px">请填写提供本商机的人名(如‘张明’);如果为非头歌用户,请增加单位信息(如‘张明,华为公司’)</p> + <label class="layui-form-label required">商机来源</label> + <div class="layui-inline"> + <%= select_tag "source_way", options_for_select(EducodeSales::Business.source_ways.keys), { include_blank: true, "lay-filter": 'source_id', "lay-verify": "required" } %> + </div> + <div class="layui-inline" style="line-height: 38px;" id="source_wraper"> + <div id="customer_id" style="width: 360px"></div> + </div> </div> + <br> <div class="layui-inline" style="padding-top: 20px"> <label class="layui-form-label required">项目类型</label> <div class="layui-input-inline"> <%= select_tag "clazz_id", options_for_select(@clazz), { 'lay-filter': 'clazz_id', class: 'required', include_blank: true } %> @@ -68,10 +75,89 @@ return cb(res) }) } }); + var source_way = ""; + form.on('select(source_id)', function(data){ + source_way = data.value; + setSourceWay(data.value); + $("#" + customer_select._input)[0].value = ""; + }); + + + function setSourceWay(value) { + if (value == '400电话' || value == '商务邮箱') { + $("#source_wraper").hide() + } else { + $("#source_wraper").show() + var text = ""; + switch (value) { + case '会议活动': + text = "请选择活动运营"; + break; + case '公司资源': + text = "请填写公司领导、部门其他同事姓名"; + break; + case '渠道代理': + text = "请选择渠道"; + break; + case '合作伙伴': + text = "请填写合作伙伴公司名称"; + break; + case '招标信息': + text = "请填写招标信息"; + break; + case '客户': + text = "请选择客户"; + break; + case '朋友': + text = "请填写姓名"; + break; + } + $("#" + customer_select._input)[0].placeholder = text; + } + } + + var sourcable_id = ""; + var customer_select = selectInput.render({ + elem: '#customer_id', + name: 'sourcable_type', // 渲染的input的name值 + layFilter: 'test', //同layui form参数lay-filter + // layVerify: 'required', //同layui form参数lay-verify + layVerType: 'tips', // 同layui form参数lay-verType + layReqText: '请填写文本', //同layui form参数lay-ReqText + hasSelectIcon: false, + placeholder: '请输入商机来源', // 渲染的inputplaceholder值 + remoteSearch: true, // 是否启用远程搜索 默认是false,和远程搜索回调保存同步 + remoteMethod: function (value, cb) { // 远程搜索的回调函数 + if (!value) { + sourcable_id = ""; + return cb([]); + } + if (['会议活动', '渠道代理', '客户'].includes(source_way)) { + var type = ""; + if (source_way == '客户') { + type = 'customer'; + } else if (source_way == '渠道代理') { + type = 'place'; + } else if (source_way == '会议活动') { + type = 'active'; + } + request.get('missions/search_customer?q=' + value + "&type=" + type, {}, function (res) { + if (res.data.length == 0) { + customer_select.emptyValue(); + return cb([]) + } + return cb(res) + }) + } + } + }); + + + // 当前弹出层,防止ID被覆盖 var parentIndex = layer.index; //监听提交 form.on('submit(create_business)', function (data) { @@ -81,9 +167,12 @@ request.authPost("missions/businesses", { department_id: add_department.getValue(), name: data.field.name, source: data.field.source, clazz_id: data.field.clazz_id, + source_way: data.field.source_way, + sourcable_type: data.field.sourcable_type, + sourcable_id: customer_select.getValue() || sourcable_id, }, function (res) { if (res.success == false) { layer.alert(res.msg) } else { \ No newline at end of file