varietyList.ftl 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>采购页面</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  10. <meta name="apple-mobile-web-app-capable" content="yes">
  11. <meta name="format-detection" content="telephone=no">
  12. <link rel="icon" href="${basePath!}/static/logo.png">
  13. <link rel="stylesheet" href="${basePath!}/static/layui/css/layui.css" media="all" />
  14. <link rel="stylesheet" href="${basePath!}/static/css/public.css" media="all" />
  15. <script src="${basePath!}/static/layui/layui.js" charset="utf-8"></script>
  16. <script src="${basePath!}/static/layui/layui.all.js" charset="utf-8"></script>
  17. <script src="${basePath!}/static/layui/lay/modules/jquery.js"></script>
  18. </head>
  19. <body>
  20. <hr>
  21. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  22. <legend>订单信息</legend>
  23. <div class="layui-form" style="width: 100%; margin-top: 20px;">
  24. <center>
  25. <form class="layui-form" action="">
  26. <div class="layui-form-item" id="materialchoose">
  27. <div class="layui-form-label">物料信息</div>
  28. <div class="layui-input-inline" style="width: 300px;">
  29. <select name="materialType" id="materialType" class="province-selector" data-value="品类" lay-filter="materialType" onclick="dele()" lay-search="">
  30. <option value="">品类</option>
  31. </select>
  32. </div>
  33. <div class="layui-input-inline" style="width: 300px;">
  34. <select name="brand" id ="brand" class="city-selector" data-value="品牌" lay-filter="brand" onclick="selectbrand()" lay-search="">
  35. <option value="">品牌</option>
  36. </select>
  37. </div>
  38. <div class="layui-input-inline" style="width: 200px;">
  39. <select name="materialGroup" id ="materialGroup" class="county-selector" data-value="物料组" lay-filter="materialGroup" lay-search="">
  40. <option value="">物料组</option>
  41. </select>
  42. </div>
  43. <div class="layui-input-inline" style="width: 400px;">
  44. <select name="materialdetil" id ="materialdetil" class="county-selector" data-value="物料描述" lay-filter="materialdetil">
  45. <option value="">物料描述</option>
  46. </select>
  47. </div>
  48. <div class="layui-input-inline" style="width: 200px;">
  49. <select name="materialCode" id ="materialCode" class="county-selector" data-value="物料编码" lay-filter="materialCode">
  50. <option value="">物料编码</option>
  51. </select>
  52. </div>
  53. <div class="layui-input-inline" style="width: 100px;">
  54. <a class="layui-btn layui-btn add" onclick="addtable()">添加</a>
  55. </div>
  56. </div>
  57. </form>
  58. </center>
  59. </div>
  60. <form class="layui-form" method="post" >
  61. <div class="layui-form-item" style="width:5000px;">
  62. <center>
  63. <table class="layui-table" style ="width:5000px; overflow:scroll;" id="table" lay-filter="table" border="1">
  64. <colgroup>
  65. <col width="150">
  66. <col width="200">
  67. <col>
  68. </colgroup>
  69. <thead style="align: center">
  70. <tr style="align: center">
  71. <th style = "width: 200px"> 操作</th>
  72. <th style = "width: 200px"> 镜片位置</th>
  73. <th style = "width: 200px"> 采购/退货</th>
  74. <th style = "width: 200px"> 用户名</th>
  75. <th style = "width: 300px"> 物料编码</th>
  76. <th style = "width: 800px"> 物料描述</th>
  77. <th style = "width: 300px"> 物料价格</th>
  78. <th style = "width: 300px"> 数量</th>
  79. <th style = "width: 300px"> 球镜</th>
  80. <th style = "width: 300px"> 柱镜</th>
  81. <th style = "width: 300px"> 轴位</th>
  82. <th style = "width: 300px"> 瞳距</th>
  83. <th style = "width: 300px"> 瞳高</th>
  84. <th style = "width: 300px"> 下加光</th>
  85. <th style = "width: 300px"> 通道</th>
  86. <th style = "width: 300px"> 棱镜</th>
  87. <th style = "width: 300px"> 镜片度数</th>
  88. <th style = "width: 300px"> 镜片型号/基弧</th>
  89. <th style = "width: 300px"> 是否染色</th>
  90. <th style = "width: 300px"> 色度</th>
  91. <th style = "width: 300px"> 来板染色</th>
  92. <th style = "width: 300px"> 厂家色板</th>
  93. <th style = "width: 300px"> 标准色号</th>
  94. <th style = "width: 300px"> 美薄加工</th>
  95. <th style = "width: 300px"> 丽薄加工</th>
  96. <th style = "width: 300px"> 镜架框形</th>
  97. <th style = "width: 300px"> 镜架高度</th>
  98. <th style = "width: 300px"> 鼻梁间距</th>
  99. <th style = "width: 300px"> 水平宽度</th>
  100. <th style = "width: 300px"> 加工镜架框形</th>
  101. <th style = "width: 300px"> 颜色</th>
  102. <th style = "width: 300px"> 直径</th>
  103. <th style = "width: 300px"> 片型</th>
  104. <th style = "width: 300px"> 片色</th>
  105. <th style = "width: 300px">备注</th>
  106. </tr>
  107. </thead>
  108. <tbody style="text-align: center">
  109. </tbody>
  110. </table>
  111. </center>
  112. <div class="layui-form-item">
  113. <div class="layui-input-block">
  114. <button class="layui-btn" lay-submit lay-filter="formDemo" onclick="adddata(); return false;">立即提交</button>
  115. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  116. </div>
  117. </div>
  118. </div>
  119. </form>
  120. </fieldset>
  121. <script>
  122. layui.use('form', function(){
  123. var form = layui.form;
  124. form.render();
  125. });
  126. layui.use(['form', 'table', "laydate", 'layer','jquery'], function () {
  127. var materialdetil=null;
  128. var material=null;
  129. var form = layui.form;
  130. var table = layui.table;
  131. var $ = layui.$ //重点处
  132. ,layer = layui.layer;
  133. $.ajax({
  134. url: 'varietyLists',
  135. type: 'get',
  136. success: function (data) {
  137. $("#materialType").empty();
  138. $.each($.parseJSON(data), function(idx, obj) {
  139. $("#materialType").append("<option value=\""+obj.varietyId+"\">"+obj.variety+"</option>");
  140. });
  141. layui.form.render("select");
  142. },error:function (xhr, status, error) {
  143. layer.alert('请求失败: ' + error);
  144. }});
  145. form.on('select(materialType)', function(data){
  146. $.ajax({
  147. url: 'varietyDetailsLists',
  148. type: 'post',
  149. data:{'id':data.value},
  150. success: function (data) {
  151. $("#brand").empty();
  152. $("#brand").append('<option value="">品牌</option>');
  153. $.each($.parseJSON(data), function(idx, obj) {
  154. $("#brand").append("<option value=\""+obj.id+"\">"+obj.varietyDetails+"</option>");
  155. });
  156. layui.form.render("select");
  157. },error:function (xhr, status, error) {
  158. layer.alert('请求失败: ' + error);
  159. }});
  160. });
  161. form.on('select(brand)', function(data){
  162. $.ajax({
  163. url: 'group',
  164. type: 'post',
  165. data:{'brand':data.value},
  166. success: function (data) {
  167. $("#materialGroup").empty();
  168. $("#materialGroup").append('<option value="">物料组</option>');
  169. $.each($.parseJSON(data), function(idx, obj) {
  170. $("#materialGroup").append("<option value=\""+obj.materialGroupCode+"\">"+obj.materialGroupName+"</option>");
  171. });
  172. layui.form.render("select");
  173. },error:function (xhr, status, error) {
  174. layer.alert('请求失败: ' + error);
  175. }});
  176. });
  177. form.on('select(materialGroup)', function(data){
  178. $.ajax({
  179. url: 'price',
  180. type: 'post',
  181. data:{'group':data.value},
  182. success: function (data) {
  183. $("#materialdetil").empty();
  184. $("#materialdetil").append('<option value="">物料描述</option>');
  185. $.each($.parseJSON(data), function(idx, obj) {
  186. $("#materialdetil").append("<option value=\""+obj.materialCode+"\">"+obj.materialName+"</option>");
  187. });
  188. layui.form.render("select");
  189. },error:function (xhr, status, error) {
  190. layer.alert('请求失败: ' + error);
  191. }});
  192. });
  193. form.on('select(materialdetil)', function(data){
  194. $.ajax({
  195. url: 'code',
  196. type: 'post',
  197. data:{'code':data.value},
  198. success: function (data) {
  199. $("#materialCode").empty();
  200. $("#materialRealPrice").empty();
  201. $.each($.parseJSON(data), function(idx, obj) {
  202. $("#materialCode").append("<option value=\""+obj.materialCode+"\">"+obj.materialCode+"</option>");
  203. $("#materialRealPrice").append("<option value=\""+obj.retailPrice+"\">"+obj.retailPrice+"</option>");
  204. });
  205. layui.form.render("select");
  206. },error:function (xhr, status, error) {
  207. layer.alert('请求失败: ' + error);
  208. }});
  209. });
  210. //因为动态添加的元素class属性是无效的,所以不能用$('.add').click(function(){});
  211. window.addtable= function(){
  212. var html = '<tr>'+
  213. '<td style = "width: 100px"><input type="button" class="layui-btn layui-btn-radius" onclick="dele(this)" value="删除" /></td>'+
  214. '<td style="width:200px">'+
  215. '<select name="WZ" lay-verify="required">'+
  216. '<option value="">--请选择--</option>'+
  217. '<option value="L">L</option>'+
  218. '<option value="R">R</option>'+
  219. '</select></td>'+
  220. '<td style="width:300px">'+
  221. '<select name="LY" lay-verify="required">'+
  222. '<option value="">--请选择--</option>'+
  223. '<option value="C">采购</option>'+
  224. '<option value="T">退货</option>'+
  225. '</select></td>'+
  226. '<td style = "width: 200px"> <input type="text" name="username" required lay-verify="required" placeholder="用户名字" autocomplete="off" class="layui-input" readonly="true" value="${currentUser.userName!}"+"/></td>'+
  227. '<td style = "width: 200px"> <input type="text" name="materialCode" required lay-verify="required" placeholder="物料编码" autocomplete="off" class="layui-input" readonly="true" value="'+ $('#materialCode option:selected').text()+'"/></td>'+
  228. '<td style = "width: 800px"> <input type="text" name="materialDetile" required lay-verify="required" placeholder="物料描述" autocomplete="off" class="layui-input" readonly="true" value="'+$('#materialdetil option:selected').text()+'"/></td>'+
  229. '<td style = "width: 200px"> <input type="text" name="price" required lay-verify="required" placeholder="价格" autocomplete="off" class="layui-input" readonly="true" value="'+$('#materialRealPrice option:selected').text()+'"/></td>'+
  230. '<td style = "width: 100px"> <input type="text" name="NUM" required lay-verify="required" placeholder="数量" autocomplete="off" class="layui-input" value ="1"/></td>'+
  231. '<td style = "width: 300px"> <input type="text" name="SPH" placeholder="球镜" autocomplete="off" class="layui-input"></td>'+
  232. '<td style = "width: 300px"> <input type="text" name="CYL" placeholder="柱镜" autocomplete="off" class="layui-input"></td>'+
  233. '<td style = "width: 300px"> <input type="text" name="AXIS" placeholder="轴位" autocomplete="off" class="layui-input"></td>'+
  234. '<td style = "width: 300px"> <input type="text" name="PDFOD" placeholder="瞳距" autocomplete="off" class="layui-input"></td>'+
  235. '<td style = "width: 300px"> <input type="text" name="PH" placeholder="瞳高" autocomplete="off" class="layui-input"></td>'+
  236. '<td style = "width: 300px"> <input type="text" name="XADD" placeholder="下加光" autocomplete="off" class="layui-input"></td>'+
  237. '<td style = "width: 300px"> <input type="text" name="YULIU1" placeholder="通道" autocomplete="off" class="layui-input"></td>'+
  238. '<td style = "width: 300px"> <input type="text" name="PRISM" placeholder="棱镜" autocomplete="off" class="layui-input"></td>'+
  239. '<td style = "width: 300px"> <input type="text" name="CVA" placeholder="镜片度数" autocomplete="off" class="layui-input"></td>'+
  240. '<td style = "width: 300px"> <input type="text" name="OPTICBC" placeholder="镜片型号/基弧" autocomplete="off" class="layui-input"></td>'+
  241. '<td style = "width: 300px"> <input type="text" name="RS" placeholder="是否染色" autocomplete="off" class="layui-input"></td>'+
  242. '<td style = "width: 300px"> <input type="text" name="SD" placeholder="色度" autocomplete="off" class="layui-input"></td>'+
  243. '<td style = "width: 300px"> <input type="text" name="LRS" placeholder="来板染色" autocomplete="off" class="layui-input"></td>'+
  244. '<td style = "width: 300px"> <input type="text" name="CRS" placeholder="厂家色板" autocomplete="off" class="layui-input"></td>'+
  245. '<td style = "width: 300px"> <input type="text" name="BRS" placeholder="标准色号" autocomplete="off" class="layui-input"></td>'+
  246. '<td style = "width: 300px"> <input type="text" name="MPRO" placeholder="美薄加工" autocomplete="off" class="layui-input"></td>'+
  247. '<td style = "width: 300px"> <input type="text" name="LBPO" placeholder="丽薄加工" autocomplete="off" class="layui-input"></td>'+
  248. '<td style = "width: 300px"> <input type="text" name="FRAMESHAPE" placeholder="镜架框形" autocomplete="off" class="layui-input"></td>'+
  249. '<td style = "width: 300px"> <input type="text" name="FRAMEHEIGHT" placeholder="镜架高度" autocomplete="off" class="layui-input"></td>'+
  250. '<td style = "width: 300px"> <input type="text" name="FRAMEBRIDGEWIDTH" placeholder="鼻梁间距" autocomplete="off" class="layui-input"></td>'+
  251. '<td style = "width: 300px"> <input type="text" name="SPK" placeholder="水平宽度" autocomplete="off" class="layui-input"></td>'+
  252. '<td style = "width: 300px"> <input type="text" name="JFRAMESHAPE" placeholder="加工镜架框形" autocomplete="off" class="layui-input"></td>'+
  253. '<td style = "width: 300px"> <input type="text" name="COLOR" placeholder="颜色" autocomplete="off" class="layui-input"></td>'+
  254. '<td style = "width: 300px"> <input type="text" name="lEN_DIAMETER" placeholder="直径" autocomplete="off" class="layui-input"></td>'+
  255. '<td style = "width: 300px"> <input type="text" name="PX" placeholder="片型" autocomplete="off" class="layui-input"></td>'+
  256. '<td style = "width: 300px"> <input type="text" name="PS" placeholder="片色" autocomplete="off" class="layui-input"></td>'+
  257. '<td style = "width: 300px"> <input type="text" name="MARK" placeholder="备注" autocomplete="off" class="layui-input"></td>'+
  258. '</tr>';
  259. //添加到表格最后
  260. $(html).appendTo($('#table tbody:last'));
  261. form.render();
  262. }
  263. window.dele= function (obj){
  264. debugger;
  265. var otr = obj.parentNode.parentNode;
  266. // var tab = document.getElementById("tab");
  267. // tab.deleteRow(otr.rowIndex)
  268. var tab = otr.parentNode; //自己的父节点 就是table
  269. tab.removeChild(otr);
  270. }
  271. window.deltable= function() {
  272. if ($('#table tbody tr').length === 1) {
  273. layer.msg('只有一条不允许删除。', {
  274. time : 2000
  275. });
  276. } else {
  277. //删除当前按钮所在的tr
  278. $(this).closest('tr').remove();
  279. }
  280. };
  281. window.adddata= function() {
  282. table=document.getElementById("table");
  283. let tr=table.getElementsByTagName("tr");
  284. var arrayObj = new Array();
  285. for (var i=0; i<tr.length; i++){
  286. let target=tr[i].querySelectorAll("[name]"),obj={};
  287. for (var j=0; j<target.length; j++){
  288. if(target[j].value){
  289. obj[target[j].getAttribute("name")]=target[j].value;
  290. }else{
  291. obj[target[j].getAttribute("name")]=target[j].getAttribute("value");
  292. }
  293. }
  294. arrayObj.push(obj);
  295. }
  296. var json=JSON.stringify(arrayObj);
  297. json = json.replace(/[+]/g, '+');
  298. $.ajax({
  299. url: 'insert',
  300. type: 'post',
  301. data: "list="+json,
  302. async: false,
  303. dataType: "json",
  304. success: function (data) {
  305. layer.msg('提交成功!', {
  306. time : 5000
  307. });
  308. }, error: function (xhr, status, error) {
  309. layer.alert('请求失败: ' + error);
  310. }
  311. });
  312. }
  313. form.on('submit(login)', function (data) {
  314. //alert(data.value);
  315. });
  316. });
  317. </script>
  318. </body>
  319. </html>