beihuogl_dyapplyadd.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. {Template header}
  2. <style>
  3. /* 整个表格容器 — 自适应滚动 + 适度居中 */
  4. .table-wrapper {
  5. max-width: 1280px;
  6. margin: 0 auto;
  7. background: #ffffff;
  8. border-radius: 0px; /* 彻底直角,更素净,也可稍圆角1px?保留直边更简约 */
  9. overflow-x: auto;
  10. box-shadow: none; /* 无阴影,绝对不花哨 */
  11. }
  12. /* 简约表格核心样式:细边框 + 清晰可读 */
  13. .simple-table {
  14. width: 100%;
  15. border-collapse: collapse;
  16. font-size: 0.9rem;
  17. line-height: 1.5;
  18. background-color: #fff;
  19. table-layout: auto; /* 让列宽根据内容自动适应,保持自然 */
  20. min-width: 560px; /* 保证宽屏舒适,但允许滚动 */
  21. }
  22. /* 所有单元格共用边框与内边距 */
  23. .simple-table th,
  24. .simple-table td {
  25. border: 1px solid #e2e6e9; /* 极浅灰边框,干净不突兀 */
  26. padding: 12px 12px;
  27. vertical-align: middle;
  28. text-align: left;
  29. }
  30. /* 表头样式:浅灰底 + 半粗体 + 适中字号 */
  31. .simple-table th {
  32. background-color: #f2f4f7;
  33. font-weight: 600;
  34. font-size: 0.85rem;
  35. letter-spacing: 0.3px;
  36. color: #1f3a4b;
  37. white-space: nowrap;
  38. }
  39. /* 表格行数据:默认纯白底,不额外加花纹,保持极简 */
  40. .simple-table td {
  41. background-color: #ffffff;
  42. color: #1f2f3a;
  43. }
  44. /* 轻微行区分:提升可读性但依然克制(不花哨,仅轻微底色交替) */
  45. .simple-table tbody tr:nth-child(even) td {
  46. background-color: #fafbfc;
  47. }
  48. /* 可选轻量悬浮效果:增加操作反馈但不张扬(符合简约但现代交互) */
  49. .simple-table tbody tr:hover td {
  50. background-color: #f5f7fa;
  51. transition: background 0.15s ease;
  52. }
  53. /* ---------- 输入框样式:干净,适应单元格 ---------- */
  54. .simple-table input {
  55. width: 100%;
  56. box-sizing: border-box;
  57. font-family: inherit;
  58. font-size: 0.85rem;
  59. padding: 8px 10px;
  60. border: 1px solid #cfdde6;
  61. border-radius: 4px; /* 轻微圆角,不过于锐利,但算不上花哨,符合基础UI */
  62. background-color: #ffffff;
  63. transition: border 0.1s ease, background 0.1s;
  64. line-height: 1.4;
  65. margin: 0;
  66. color: #0e2a38;
  67. }
  68. /* 数字输入框统一对齐(保留原生控件,但视觉一致) */
  69. .simple-table input[type="number"] {
  70. -moz-appearance: textfield;
  71. }
  72. .simple-table input[type="number"]::-webkit-inner-spin-button,
  73. .simple-table input[type="number"]::-webkit-outer-spin-button {
  74. opacity: 0.5;
  75. }
  76. /* 聚焦效果:维持简洁,只改变边框颜色,无外发光 */
  77. .simple-table input:focus {
  78. outline: none;
  79. border-color: #7b8c9e;
  80. background-color: #ffffff;
  81. }
  82. /* placeholder 字体颜色柔和 */
  83. .simple-table input::placeholder {
  84. color: #b0bec5;
  85. font-weight: normal;
  86. font-size: 0.8rem;
  87. }
  88. /* 为了单元格内文本与input对齐协调,文本列自然 */
  89. .simple-table td span.text-muted {
  90. font-weight: normal;
  91. color: #2c4b5e;
  92. }
  93. /* 注脚小提示(可选,不干扰表格主体) */
  94. .table-note {
  95. max-width: 1280px;
  96. margin: 1rem auto 0 auto;
  97. padding: 0.6rem 0.8rem;
  98. font-size: 0.75rem;
  99. color: #6c7e8f;
  100. background-color: transparent;
  101. border-top: none;
  102. text-align: left;
  103. letter-spacing: 0.2px;
  104. }
  105. </style>
  106. <body>
  107. <div class="warp">
  108. <div class="title winnone">添加</div>
  109. <form id="formdata">
  110. <ul class="setting">
  111. <li>
  112. <em>申请店铺:</em>
  113. <select name="shop_id" class="service select class" onChange="gradeChange()">
  114. <option value="0" platid="0">无</option>
  115. {loop usershop() as $val}
  116. <option value="{$val['id']}" platid="{$val['type']}">{$val['shopname']}</option>
  117. {/loop}
  118. </select>
  119. </li>
  120. <li>
  121. <em>申请平台:</em>
  122. <select name="plat_id" class="service select class" style="pointer-events: none;">
  123. <option value="0" >无</option>
  124. {loop $plat_list as $val}
  125. <option value="{$val['id']}" >{$val['title']}</option>
  126. {/loop}
  127. </select>
  128. </li>
  129. <li >
  130. <em>申请人:</em>
  131. <input value="" name="sqr" type="text" >
  132. </li>
  133. <li >
  134. <em>预期完成时间:</em>
  135. <input id="yqwc_time" value="" name="yqwc_time" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})" autocomplete="off">
  136. </li>
  137. <li class="length">
  138. <em>备注:</em>
  139. <textarea name="remark" style="height:50px;"></textarea>
  140. </li>
  141. <li class="length" style="padding: 10px;">
  142. <a href="javascript:void(0)" style=" padding: 8px 16px ;color:#fff;background-color:#0099cc;font-size:16px;border-radius:5px;cursor:pointer;" onclick="addGoods()">+添加</a>
  143. <a href="javascript:void(0)" style=" padding: 8px 16px ;color:#fff;background-color:#A52A2A;font-size:16px;border-radius:5px;cursor:pointer;" onclick="selectGood()">+料品列表选择</a>
  144. </li>
  145. <div style="clear:both;"></div>
  146. <div class="table-wrapper">
  147. <table class="simple-table">
  148. <!-- 简约表头:含必要列,其中包含两个输入域列 -->
  149. <thead>
  150. <tr>
  151. <th>品名(必填)</th>
  152. <th>sku</th>
  153. <th style="width:80px;">数量(必填)</th>
  154. <th style="width:40px;">操作</th>
  155. </tr>
  156. </thead>
  157. <tbody id="goodsList">
  158. <tr>
  159. <td> <input type="text" placeholder="请输入中文品名" value="" name="title[]"> </td>
  160. <td> <input type="text" placeholder="请输入库存对应的sku" value="" name="sku[]"> </td>
  161. <td> <input type="number" value="1" step="1" min="0" placeholder="调整数量" name="sq_num[]"> </td>
  162. <td>
  163. <button onclick="delGoods(this)">删除</button>
  164. </td>
  165. </tr>
  166. </tbody>
  167. </table>
  168. </div>
  169. </ul>
  170. </form>
  171. <div class="button"><font class="expressdata">提 交</font> <font class="fh">关 闭</font></div>
  172. </div>
  173. <script>
  174. var addedit="/beihuogl/dyapplyadd/";
  175. function gradeChange(that){
  176. let platid = $("select[name='shop_id']").find('option:selected').attr('platid');
  177. $("select[name='plat_id']").val(platid);
  178. }
  179. function addGoods(){
  180. let tplStr = document.getElementById('edit_content').innerHTML;
  181. // 4. 传递数据进行渲染,并将结果插入 DOM
  182. //let outputHtml = compiledTemplate.fetch({ data: data });
  183. let data = [];
  184. let outputHtml = ejs.render(tplStr, {data: data});
  185. $("#goodsList").append(outputHtml)
  186. }
  187. function delGoods(that){
  188. let len = $('#goodsList tr').length;
  189. if(len <= 1){
  190. layx.msg("至少保留一条录入数据!", {
  191. dialogIcon: 'warn',
  192. position: 'cc'
  193. });
  194. return ;
  195. }
  196. $(that).closest('tr').remove();
  197. }
  198. $(".expressdata").on('click',function(){
  199. let sqr = $("input[name='sqr']").val();
  200. if(sqr.length == 0){
  201. $(".ts p").text("申报人不能为空");
  202. $(".ts").show();
  203. setTimeout('$(".ts").fadeOut()', 1600);
  204. return false;
  205. }
  206. $("input[name='title[]']").each(function(index){
  207. let k = index+1;
  208. if($(this).val().length == 0){
  209. $(".ts p").text("第"+k+"行品名不能为空");
  210. $(".ts").show();
  211. setTimeout('$(".ts").fadeOut()', 1600);
  212. return false;
  213. }
  214. })
  215. $("input[name='sq_num[]']").each(function(index){
  216. let k = index+1;
  217. if($(this).val().length == 0){
  218. $(".ts p").text("第"+k+"行数量不能为空");
  219. $(".ts").show();
  220. setTimeout('$(".ts").fadeOut()', 1600);
  221. return false;
  222. }
  223. })
  224. var data = $("#formdata").serializeArray();
  225. $.post(addedit, data, function(res){
  226. if(res.code == 1){
  227. $(".ts").hide();
  228. $(".express p:eq(0)").html(res.msg+"是否关闭?");
  229. $(".express p:eq(1)").html("<font class='fh'>确 定</font><font class='esc'>取 消</font>");
  230. $(".express").show();
  231. }else{
  232. $(".ts").hide();
  233. $(".ts p").html(res.msg);
  234. $(".ts").fadeIn();
  235. setTimeout('$(".ts").fadeOut()', 800);
  236. }
  237. },'json')
  238. })
  239. function selectGood(){
  240. layx.iframe('childWindowDemo', '选择申报单', "/goodimglibrary/selectgood", {
  241. width: '100%', // 关键:宽度设为父窗口的100%
  242. height: 600, // 设置窗口大小
  243. shade: 0.3, // 设置遮罩
  244. });
  245. }
  246. window.addEventListener('message', function(event) {
  247. // 建议添加来源验证,提高安全性
  248. // if (event.origin !== "https://你的域名.com") return;
  249. if (event.data.type === 'SAVE_EVENT') {
  250. console.log('收到子页面保存消息', event.data.data);
  251. let tplStr = document.getElementById('edit_content_data').innerHTML;
  252. // 4. 传递数据进行渲染,并将结果插入 DOM
  253. //let outputHtml = compiledTemplate.fetch({ data: data });
  254. let outputHtml = ejs.render(tplStr, {data: event.data.data});
  255. $("#goodsList").append(outputHtml)
  256. }
  257. });
  258. </script>
  259. <script type="text/javascript" src="{$theme}js/ejs.min.js"></script>
  260. <script id="edit_content" type="text/html">
  261. <tr>
  262. <td> <input type="text" placeholder="请输入中文品名" value="" name="title[]"> </td>
  263. <td> <input type="text" placeholder="请输入库存对应的sku" value="" name="sku[]"> </td>
  264. <td> <input type="number" value="1" step="1" min="0" placeholder="调整数量" name="sq_num[]"> </td>
  265. <td>
  266. <button onclick="delGoods(this)">删除</button>
  267. </td>
  268. </tr>
  269. </script>
  270. <script id="edit_content_data" type="text/html">
  271. <% for(let key in data) { %>
  272. <tr>
  273. <td> <input type="text" placeholder="请输入中文品名" value="<%= data[key]['zh'] %>" name="title[]"> </td>
  274. <td> <input type="text" placeholder="请输入库存对应的sku" value="<%= data[key]['sku'] %>" name="sku[]"> </td>
  275. <td> <input type="number" value="1" step="1" min="0" placeholder="调整数量" name="sq_num[]"> </td>
  276. <td>
  277. <button onclick="delGoods(this)">删除</button>
  278. </td>
  279. </tr>
  280. <% } %>
  281. </script>
  282. <script type="text/javascript" src="{$theme}js/laydate.js"></script>
  283. {Template footer}