app/views/educode_sales/ideas/edit.html.erb in educode_sales-0.9.59 vs app/views/educode_sales/ideas/edit.html.erb in educode_sales-0.9.60

- old
+ new

@@ -4,61 +4,83 @@ <div class="layui-form-item" style="padding: 25px"> <div class="layui-row"> <h2 style="padding-left: 25px">方案信息</h2> </div> <div class="layui-row" style="padding-top: 15px"> - <div class="layui-inline"> - <label class="layui-form-label required">单位部门</label> - <div class="layui-input-block" id="department" style="width: 300px;"></div> + <div class="layui-col-md6"> + <labeL class="layui-form-label required">学校/单位:</labeL> + <div class="layui-input-block"> + <input type="text" name="school_name" autocomplete="off" lay-verify="required" lay-reqtext="学校不能为空" placeholder="请输入学校/单位名称" value="<%= @idea&.school_name %>" class="layui-input"> + </div> </div> + <div class="layui-col-md6"> + <labeL class="layui-form-label">院系/部门:</labeL> + <div class="layui-input-block"> + <input type="text" name="department_name" autocomplete="off" placeholder="请输入院系/部门名称" value="<%= @idea&. department_name %>" class="layui-input"> + </div> + </div> </div> <div class="layui-row" style="padding-top: 15px"> <div class="layui-col-md6"> <labeL class="layui-form-label">学校负责人:</labeL> <div class="layui-input-block"> - <input type="text" name="manager_name" autocomplete="off" placeholder="请输入学校/单位名称" value="<%= @idea&.manager_name %>" class="layui-input"> + <input type="text" name="manager_name" autocomplete="off" placeholder="请输入姓名" value="<%= @idea&.manager_name %>" class="layui-input"> </div> </div> <div class="layui-col-md6"> <labeL class="layui-form-label">负责人电话:</labeL> <div class="layui-input-block"> - <input type="text" name="manager_phone" autocomplete="off" placeholder="请输入院系/部门名称" value="<%= @idea&.manager_phone %>" class="layui-input"> + <input type="text" name="manager_phone" autocomplete="off" placeholder="请输入手机号" value="<%= @idea&.manager_phone %>" class="layui-input"> </div> </div> </div> <div class="layui-row" style="padding-top: 15px"> <div class="layui-col-md6"> - <labeL class="layui-form-label required">项目名称:</labeL> + <labeL class="layui-form-label required">销售负责人:</labeL> <div class="layui-input-block"> - <input type="text" name="name" autocomplete="off" lay-verify="required" lay-reqtext="项目名称不能为空" placeholder="请输入项目名称" value="<%= @idea&.name %>" class="layui-input"> + <div id="sale_staff_id"></div> </div> </div> <div class="layui-col-md6"> - <labeL class="layui-form-label required">指派人:</labeL> + <labeL class="layui-form-label">协作人:</labeL> <div class="layui-input-block"> - <%= select_tag "staff_id", options_for_select(EducodeSales::Staff.all.map { |d| [d.user&.real_name, d.id] }, @idea&.staff_id), { 'lay-filter': 'staff_id', include_blank: false } %> + <div id="assist_staff_ids"></div> </div> </div> </div> <div class="layui-row" style="padding-top: 15px"> <div class="layui-col-md6"> - <labeL class="layui-form-label required">优先级:</labeL> + <labeL class="layui-form-label required">项目名称:</labeL> <div class="layui-input-block"> - <%= select_tag "level", options_for_select(EducodeSales::Idea.levels.keys, @idea&.level), { 'lay-filter': 'level', include_blank: false } %> + <input type="text" name="name" autocomplete="off" lay-verify="required" lay-reqtext="项目名称不能为空" placeholder="请输入项目名称" value="<%= @idea&.name %>" class="layui-input"> </div> </div> <div class="layui-col-md6"> - <labeL class="layui-form-label required">状态:</labeL> + <labeL class="layui-form-label required">方案指派人:</labeL> <div class="layui-input-block"> - <%= select_tag "status", options_for_select(EducodeSales::Idea.statuses.keys, @idea&.status), { 'lay-filter': 'status', include_blank: false } %> + <div id="new_staff_id"></div> </div> </div> </div> - <div class="layui-row" style="padding-top: 15px"> - <div class="layui-col-md6"> - <labeL class="layui-form-label required">类型:</labeL> - <div class="layui-input-block"> + <div class="layui-row" style="padding-top: 15px"> + <div class="layui-col-md6"> + <labeL class="layui-form-label required">优先级:</labeL> + <div class="layui-input-block"> + <%= select_tag "level", options_for_select(EducodeSales::Idea.levels.keys, @idea&.level), { 'lay-filter': 'level', include_blank: false } %> + </div> + </div> + <div class="layui-col-md6"> + <labeL class="layui-form-label required">状态:</labeL> + <div class="layui-input-block"> + <%= select_tag "status", options_for_select(EducodeSales::Idea.statuses.keys, @idea&.status), { 'lay-filter': 'status', include_blank: false } %> + </div> + </div> + </div> + <div class="layui-row" style="padding-top: 15px"> + <div class="layui-col-md6"> + <labeL class="layui-form-label required">类型:</labeL> + <div class="layui-input-block"> <%= select_tag "types", options_for_select(EducodeSales::Idea.types.keys, @idea&.types), { 'lay-filter': 'types', include_blank: false } %> </div> </div> <div class="layui-col-md6"> <labeL class="layui-form-label required">部署模式:</labeL> @@ -73,63 +95,145 @@ <div class="layui-input-block"> <input type="number" name="hardware" autocomplete="off" lay-verify="required" lay-reqtext="硬件规模不能为空" placeholder="请输入硬件规模" value="<%= @idea&.hardware %>" class="layui-input"> </div> </div> <div class="layui-col-md6"> - <labeL class="layui-form-label required">项目预算(万):</labeL> + <labeL class="layui-form-label">项目预算(万):</labeL> <div class="layui-input-block"> - <input type="number" name="money" autocomplete="off" lay-verify="required" lay-reqtext="项目预算不能为空" placeholder="请输入项目预算" value="<%= @idea&.money %>" class="layui-input"> + <input type="number" name="money" autocomplete="off" placeholder="请输入项目预算" value="<%= @idea&.money %>" class="layui-input"> </div> </div> </div> <div class="layui-row" style="padding-top: 5px"> <div class="layui-col-md6"> - <labeL class="layui-form-label required">项目规模(人):</labeL> + <labeL class="layui-form-label">并发规模(人):</labeL> <div class="layui-input-block"> - <input type="number" name="project" autocomplete="off" lay-verify="required" lay-reqtext="项目规模不能为空" placeholder="请输入项目规模" value="<%= @idea&.project %>" class="layui-input"> + <input type="number" name="project" autocomplete="off" placeholder="请输入项目规模" value="<%= @idea&.project %>" class="layui-input"> </div> </div> <div class="layui-col-md6"> <labeL class="layui-form-label required">截止时间:</labeL> <div class="layui-input-block"> <input type="text" id="new_time" name="end_time" autocomplete="off" lay-verify="required" lay-reqtext="截止时间不能为空" placeholder="请选择截止时间" value="<%= @idea&.end_time&.to_s(:date) %>" class="layui-input"> </div> </div> </div> + <div class="layui-row" style="padding-top: 5px;display: none"> + <div class="layui-col-md6"> + <labeL class="layui-form-label">文件id:</labeL> + <div class="layui-input-block"> + <input type="text" name="attachment_id" id="attachment_id" autocomplete="off" value="" class="layui-input"> + </div> + </div> + </div> <div class="layui-row" style="padding-top: 15px"> <labeL class="layui-form-label">反馈情况:</labeL> <div class="layui-input-block"> <textarea name="content" placeholder="反馈情况" class="layui-textarea"><%= @idea&.content.to_s %></textarea> </div> </div> + <div class="layui-row" style="padding-top: 15px"> + <div class="layui-col-md6"> + <labeL class="layui-form-label">方案材料:</labeL> + <div class="layui-btn-container"> + <button type="button" class="layui-btn layui-btn-normal" id="test8">选择文件</button> + </div> + </div> + </div> <div class="layui-row" style="padding-top: 30px; float: left"> <div class="layui-input-block"> <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button> </div> </div> </div> </div> </div> <script> - layui.use(['form', 'table', 'upload', 'layer', 'laytpl', 'request', 'selectInput', 'xmSelect'], function () { + function displayFile() { + var input = document.getElementById("fileInput"); + var fileName = document.getElementById("fileName"); + fileName.innerText = "已选择文件:" + input.files[0].name; + uploadFile(); + } + + function uploadFile() { + var input = document.getElementById("fileInput"); + var file = input.files[0]; + var formData = new FormData(); + formData.append("file", file); + + var xhr = new XMLHttpRequest(); + xhr.open("POST", "/api/attachments"); + xhr.onload = function() { + if (xhr.status === 200) { + console.log(xhr.responseText.id); + alert("上传成功!"); + } else { + alert("上传失败!"); + } + }; + xhr.send(formData); + } + + layui.use(['form', 'table', 'upload', 'layer', 'laytpl', 'request', 'selectInput', 'xmSelect', 'upload'], function () { var form = layui.form, layer = layui.layer, request = layui.request, laydate = layui.laydate, table = layui.table, laytpl = layui.laytpl, request = layui.request, xmSelect = layui.xmSelect, + upload = layui.upload, $ = layui.$; selectInput = layui.selectInput; form.render(); //时间常规用法 laydate.render({ elem: '#new_time' }); form.render(); + + upload.render({ + elem: '#test8' + , url: '/missions/upload_files' //此处配置你自己的上传接口即可 + , auto: true + , accept: 'file' //普通文件 + , bindAction: '#test9' + , done: function (res) { + layer.msg('上传成功'); + $("#attachment_id").val(res.attachment_id) + // $("#filename").val(res.filename) + } + }); + + + var staff_list = xmSelect.render({ + el: '#new_staff_id', + data: gon.staffs, + filterable: true, + radio: true, + }) + + var sale_staff_list = xmSelect.render({ + el: '#sale_staff_id', + data: gon.staffs, + filterable: true, + radio: true, + }) + var assist_staff_list = xmSelect.render({ + el: '#assist_staff_ids', + data: gon.staffs, + filterable: true, + multiple:true + }) + + staff_list.setValue(gon.staff_value) + sale_staff_list.setValue(gon.sale_staff_value) + assist_staff_list.setValue(gon.assist_staff_value) + var department_id = gon.value; var department = selectInput.render({ elem: '#department', name: 'department', // 渲染的input的name值 layFilter: 'department_filter', //同layui form参数lay-filter @@ -155,15 +259,18 @@ // 当前弹出层,防止ID被覆盖 var parentIndex = layer.index; //监听提交 form.on('submit(saveBtn)', function (data) { - if (department.getValue() == "" && department_id == "") { - layer.alert("请选择单位部门") - return false; - } else { + // if (department.getValue() == "" && department_id == "") { + // layer.alert("请选择单位部门") + // return false; + // } else { data.field.department_id = department.getValue() || department_id; + data.field.staff_id = staff_list.getValue('valueStr'); + data.field.sale_staff_id = sale_staff_list.getValue('valueStr'); + data.field.assist_staff_ids = assist_staff_list.getValue('valueStr'); request.authPut("missions/ideas/" + parent.id, data.field, function (res) { if (res.success == false) { layer.alert(res.msg) } else { layer.close(parent.edit_index); @@ -172,10 +279,10 @@ done: function () { } }); } }) - } + // } return false; }); }); </script> \ No newline at end of file