index.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. <style>
  2. table tr th,table tr td {border: thin #ddd dashed;padding: 5px }
  3. .select2-container {
  4. width: 400px !important;
  5. }
  6. .select2-dropdown {
  7. width: 400px !important;
  8. }
  9. .select2-results__options {
  10. max-height: 200px; /* 固定高度 */
  11. overflow-y: auto; /* 超出时出现滚动条 */
  12. }
  13. .select2-container--default .select2-selection--single .select2-selection__clear{
  14. margin-top: -6px;
  15. }
  16. .select2-container--default .select2-selection--single{
  17. width: 400px !important;
  18. height: 35px !important;
  19. line-height: 38px;
  20. padding: 4px 10px;
  21. font-size: 14px;
  22. border: 1px solid #ccc;
  23. border-radius: 4px;
  24. box-sizing: border-box;
  25. }
  26. .select2-container--open .select2-dropdown--below{
  27. margin-top: -13px;
  28. }
  29. .selection{
  30. top: -13px;
  31. }
  32. </style>
  33. <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  34. <fieldset style="width: 1200px;margin:10px 10px 0px 10px ;padding: 10px 10px 0px 10px ;border:solid thin #c0c0c0">
  35. <legend style="padding: 0px;margin: 0px">生成厂商信息</legend>
  36. <div class="form-group">
  37. <label class="control-label col-xs-2 col-sm-1">生产厂商:</label>
  38. <div class="col-xs-2 col-sm-3">
  39. <input id="c-company_name" data-rule="required" disabled class="form-control" value="{$row['nickname']}" name="company_name" type="text">
  40. </div>
  41. <label class="control-label col-xs-2 col-sm-1">邮政编码:</label>
  42. <div class="col-xs-2 col-sm-3">
  43. <input id="c-postcode" data-rule="required" disabled class="form-control" value="{$row['postcode']}" name="postcode" type="text">
  44. </div>
  45. <label class="control-label col-xs-2 col-sm-1">电&nbsp;&nbsp;话:</label>
  46. <div class="col-xs-2 col-sm-3">
  47. <input id="c-mobile" data-rule="required;mobile" disabled class="form-control" value="{$row['mobile']}" name="mobile" type="text">
  48. </div>
  49. </div>
  50. <div class="form-group">
  51. <label class="control-label col-xs-2 col-sm-1">地&nbsp;&nbsp;&nbsp;&nbsp;址:</label>
  52. <div class="col-xs-2 col-sm-7">
  53. <input id="c-company_address" data-rule="required" disabled class="form-control" value="{$row['company_address']}" name="company_address" type="text">
  54. </div>
  55. <label class="control-label col-xs-2 col-sm-1">厂家编码:</label>
  56. <div class="col-xs-2 col-sm-3">
  57. <input id="c-printer_code" data-rule="required" disabled class="form-control" value="{$row['printer_code']}" name="company_address" type="text">
  58. </div>
  59. </div>
  60. </fieldset>
  61. <fieldset style="width: 1200px;margin:10px 10px 0px 10px ;padding: 10px 10px 0px 10px ;border: solid thin #c0c0c0">
  62. <legend style="padding: 0px;margin: 0px">辅料信息</legend>
  63. <div class="form-group">
  64. <label for="c-product_name" class="control-label col-xs-2 col-sm-2">辅料名称(产品名称)</label>
  65. <div class="col-xs-2 col-sm-4">
  66. <select class="form-control select2" id="c-product_name" name="product_name">
  67. <option value="">==================>选择<===================</option>
  68. {volist name='product' id='vo'}
  69. <option value="{$vo.product_code}" data-cpdh="{$vo.jjcp_cpdh}">{$vo.jjcp_cpmc}</option>
  70. {/volist}
  71. </select>
  72. </div>
  73. <label class="control-label col-xs-2 col-sm-1">辅料代码</label>
  74. <div class="col-xs-2 col-sm-4">
  75. <input type="text" disabled class="form-control" id="c-product_code" name="product_code">
  76. </div>
  77. </div>
  78. </fieldset>
  79. <fieldset style="width: 1200px;margin:10px 10px 0px 10px ;padding: 10px 10px 0px 10px ;border: solid thin #c0c0c0">
  80. <legend style="padding: 0px;margin: 0px">标记参数</legend>
  81. <table style="width: 100%;border: thin #ddd dashed">
  82. <caption style="padding: 0px;margin: 0px">标签序列配置</caption>
  83. <tr>
  84. <th style="width: 40%">字段</th>
  85. <th>值</th>
  86. </tr>
  87. <tr>
  88. <td><span>请选择单位</span></td>
  89. <td style="padding: 5px 0px 0px 5px">
  90. <select id="danwei" name="danwei" style="width: 200px;padding: 5px;">
  91. <option value="1">张</option>
  92. <!-- <option value="2">卷</option>-->
  93. </select>
  94. </td>
  95. </tr>
  96. <tr class="xiang">
  97. <td><span>总数量(个或张)</span></td>
  98. <td style="padding: 5px 0px 0px 5px"><input type="text" name="number" id="c-number" data-rule="required"></td>
  99. </tr>
  100. <tr class="xiang">
  101. <td><span>一托盘多少箱(箱*层)</span></td>
  102. <td style="padding: 5px 0px 0px 5px">
  103. <input type="text" id="tray_num" placeholder="" style="width: 100px;" oninput="calculateTotalBoxes()" min="1" step="1"> 箱/层 ×
  104. <input type="text" id="box_number" placeholder="" style="width: 100px;" oninput="calculateTotalBoxes()" min="1" step="1"> 层/托 =
  105. <!-- <input type="text" id="boxes_per_layer" placeholder="箱数" style="width: 100px;" oninput="calculateTotalBoxes()" min="1" step="1"> 箱 ×-->
  106. <!-- <input type="text" id="layers_per_tray" placeholder="层数" style="width: 100px;" oninput="calculateTotalBoxes()" min="1" step="1"> 层 =-->
  107. <input type="text" id="total_boxes" disabled placeholder="" style="width: 100px;" readonly> 箱/托
  108. </td>
  109. </tr>
  110. <!-- <tr class="xiang">-->
  111. <!-- <td><span>一托盘多少箱(包)</span></td>-->
  112. <!-- <td style="padding: 5px 0px 0px 5px">-->
  113. <!-- <select name="tray_num" id="tray_num" style="width: 200px;padding: 5px;">-->
  114. <!-- <option value="1">========>选择<========</option>-->
  115. <!-- <option value="5">========>5层<========</option>-->
  116. <!-- <option value="24">========>24箱<========</option>-->
  117. <!-- <option value="28">========>28箱<========</option>-->
  118. <!-- <option value="32">========>32箱<========</option>-->
  119. <!-- <option value="40">========>40箱<========</option>-->
  120. <!-- <option value="42">========>42箱<========</option>-->
  121. <!-- <option value="48">========>48箱<========</option>-->
  122. <!-- <option value="60">========>60箱<========</option>-->
  123. <!-- <option value="64">========>64箱<========</option>-->
  124. <!-- <option value="72">========>72箱<========</option>-->
  125. <!-- <option value="80">========>80箱<========</option>-->
  126. <!-- <option value="96">========>96箱<========</option>-->
  127. <!-- <option value="105">========>105箱<========</option>-->
  128. <!-- <option value="108">========>108箱<========</option>-->
  129. <!-- <option value="144">========>144箱<========</option>-->
  130. <!-- <option value="180">========>180箱<========</option>-->
  131. <!-- <option value="240">========>240箱<========</option>-->
  132. <!-- </select>-->
  133. <!-- </td>-->
  134. <!-- </tr>-->
  135. <!-- <tr class="xiang">-->
  136. <!-- <td><span>一托盘多少箱(箱*层)</span></td>-->
  137. <!-- <td style="padding: 5px 0px 0px 5px">-->
  138. <!-- <select name="box_number" id="box_numbers" style="width:200px;padding: 5px">-->
  139. <!-- <option value="1">========选择=========</option>-->
  140. <!-- <option value="25">========25========</option>-->
  141. <!-- <option value="50">========50========</option>-->
  142. <!-- <option value="250">========250张========</option>-->
  143. <!-- <option value="500">========500张========</option>-->
  144. <!-- <option value="1000">=======1000张========</option>-->
  145. <!-- <option value="2000">=======2000张========</option>-->
  146. <!-- <option value="2500">=======2500张========</option>-->
  147. <!-- <option value="3000">=======3000张========</option>-->
  148. <!-- <option value="4000">=======4000张========</option>-->
  149. <!-- <option value="5000">=======5000张========</option>-->
  150. <!-- <option value="8000">=======8000张========</option>-->
  151. <!-- <option value="10000">=======10000张========</option>-->
  152. <!-- <option value="24000">=======24000张========</option>-->
  153. <!-- </select>-->
  154. <!-- </td>-->
  155. <!-- </tr>-->
  156. <tr>
  157. <td><span>每箱数(个或张)</span></td>
  158. <td style="padding: 5px 0px 0px 5px"><input type="text" id="c-small_num" disabled name="small_num" data-rule="required"></td>
  159. </tr>
  160. <!-- <tr class="juan">-->
  161. <!-- <td><span>一托盘多少卷(3位)</span></td>-->
  162. <!-- <td style="padding: 5px 0px 0px 5px"><input type="text" id="c-volume_num" name="volume_num" data-rule="required"><span style="color: red;font-size: 23px;"> *</span></td>-->
  163. <!-- </tr>-->
  164. <tr>
  165. <td><span>每层箱数</span></td>
  166. <td style="padding: 5px 0px 0px 5px">
  167. <input type="text" id="boxes_per_layer" name="boxes_per_layer" data-rule="required" disabled>
  168. <span style="color: red;font-size: 23px;"> *</span>
  169. </td>
  170. </tr>
  171. <tr>
  172. <td><span>每托层数</span></td>
  173. <td style="padding: 5px 0px 0px 5px">
  174. <input type="text" id="layers_per_pallet" name="layers_per_pallet" data-rule="required" disabled>
  175. <span style="color: red;font-size: 23px;"> *</span>
  176. </td>
  177. </tr>
  178. <tr>
  179. <td><span>每托高度</span></td>
  180. <td style="padding: 5px 0px 0px 5px; position: relative;">
  181. <input type="text" id="pallet_height" name="pallet_height" data-rule="required"
  182. style="width: 160px;" placeholder="可选择或输入" autocomplete="off">
  183. <ul id="height-suggestions" style="
  184. position: absolute;
  185. top: 33px;
  186. left: 5px;
  187. width: 160px;
  188. border: 1px solid #ccc;
  189. background: #fff;
  190. list-style: none;
  191. margin: 0;
  192. padding: 0;
  193. display: none;
  194. z-index: 1000;">
  195. <li style="padding: 5px; cursor: pointer;">0.995</li>
  196. <li style="padding: 5px; cursor: pointer;">1.05</li>
  197. <li style="padding: 5px; cursor: pointer;">1.35</li>
  198. </ul>
  199. <span style="color: red; font-size: 23px;"> *</span>
  200. </td>
  201. </tr>
  202. <!-- <tr>-->
  203. <!-- <td><span>托盘规格(例如:0.9 * 1.2)</span></td>-->
  204. <!-- <td style="padding: 5px 0px 0px 5px">-->
  205. <!-- <input type="text" id="pallet_length" name="pallet_length" style="width:80px;" data-rule="required">-->
  206. <!-- &nbsp;-->
  207. <!-- *-->
  208. <!-- &nbsp;-->
  209. <!-- <input type="text" id="pallet_width" name="pallet_width" style="width:80px;" data-rule="required">-->
  210. <!-- <span style="color: red;font-size: 23px;"> *</span>-->
  211. <!-- </td>-->
  212. <!-- </tr>-->
  213. <tr>
  214. <td><span>托盘规格(例如:0.9 * 1.2)</span></td>
  215. <td style="padding: 5px 0px 0px 5px; position: relative;">
  216. <div style="display: inline-block; position: relative;">
  217. <input type="text" id="pallet_length" name="pallet_length" style="width:80px;" placeholder="" autocomplete="off">
  218. <ul id="length-suggestions" style="
  219. position: absolute;
  220. top: 28px;
  221. left: 0;
  222. width: 80px;
  223. border: 1px solid #ccc;
  224. background: #fff;
  225. list-style: none;
  226. margin: 0;
  227. padding: 0;
  228. display: none;
  229. z-index: 1000;">
  230. <li style="padding: 5px; cursor: pointer;">0.9</li>
  231. <li style="padding: 5px; cursor: pointer;">1.0</li>
  232. <li style="padding: 5px; cursor: pointer;">1.1</li>
  233. </ul>
  234. </div>
  235. &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  236. *
  237. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  238. <div style="display: inline-block; position: relative;">
  239. <input type="text" id="pallet_width" name="pallet_width" style="width:80px;" placeholder="" autocomplete="off">
  240. <ul id="width-suggestions" style="
  241. position: absolute;
  242. top: 28px;
  243. left: 0;
  244. width: 80px;
  245. border: 1px solid #ccc;
  246. background: #fff;
  247. list-style: none;
  248. margin: 0;
  249. padding: 0;
  250. display: none;
  251. z-index: 1000;">
  252. <li style="padding: 5px; cursor: pointer;">1.1</li>
  253. <li style="padding: 5px; cursor: pointer;">1.2</li>
  254. <li style="padding: 5px; cursor: pointer;">1.3</li>
  255. </ul>
  256. </div>
  257. <span style="color: red;font-size: 23px;"> *</span>
  258. </td>
  259. </tr>
  260. <tr>
  261. <td><span>大件(总托数)</span></td>
  262. <td style="padding: 5px 0px 0px 5px"><input type="text" id="c-box_num" name="box_num" data-rule="required"><span style="color: red;font-size: 23px;"> *</span></td>
  263. </tr>
  264. <tr>
  265. <td><span>生产日期</span></td>
  266. <td style="padding: 5px 0px 0px 5px">
  267. <input class="" id="c-manufacture_date" value="{:date('Y-m-d')}" style="width: 180px;" name="manufacture_date" type="date" >
  268. <span style="color: red;font-size: 23px;"> *</span>
  269. </td>
  270. </tr>
  271. <tr>
  272. <td><span>打码日期</span></td>
  273. <td style="padding: 5px 0px 0px 5px">
  274. <input class="" type="date" id="c-print_date" style="width: 180px" name="print_date" value="{:date('Y-m-d')}">
  275. <span style="color: red;font-size: 23px;"> *</span>
  276. </td>
  277. </tr>
  278. <tr>
  279. <td><span>产品代号</span></td>
  280. <td style="padding: 5px 0px 0px 5px"><input type="text" id="c-jjcp_cpdh" name="jjcp_cpdh" disabled data-rule="required"></td>
  281. </tr>
  282. <tr>
  283. <td><span>生产批次号</span></td>
  284. <td>
  285. <div style="display: flex; align-items: center;">
  286. <input type="text" name="batch" id="c-batch" data-rule="required" disabled>
  287. <button type="button" id="reset_batch" style="margin-left: 10px;">重置批次号</button>
  288. <span style="color: red; font-size: 23px; margin-left: 5px;">*</span>
  289. </div>
  290. </td>
  291. </tr>
  292. <tr>
  293. <td><span>大件开始流水号</span></td>
  294. <td>
  295. <div style="display: flex; align-items: center;">
  296. <input type="text" name="big_liushui" id="c-big_liushui" data-rule="required" disabled>
  297. <button type="button" id="reset_liushui" style="margin-left: 10px;">重置流水号</button>
  298. <span style="color: red; font-size: 23px; margin-left: 5px;">*</span>
  299. </div>
  300. </td>
  301. </tr>
  302. <tr>
  303. <td><span>大件重量(单位千克数值)有小数时保留2位小数</span></td>
  304. <td style="padding: 5px 0px 0px 5px"><input type="text" id="c-big_weight" name="big_weight" data-rule="required"><span style="color: red;font-size: 23px;"> *</span></td>
  305. </tr>
  306. <tr>
  307. <td><span>小件开始流水号</span></td>
  308. <td style="padding: 5px 0px 0px 5px"><input type="text" id="c-small_start_liushui" name="small_start_liushui" value="1" data-rule="required"><span style="color: red;font-size: 23px;"> *</span></td>
  309. </tr>
  310. <tr>
  311. <td><span>小件重量(单位克 数值)</span></td>
  312. <td style="padding: 5px 0px 0px 5px"><input type="text" id="c-small_weight" name="small_weight" data-rule="required"><span style="color: red;font-size: 23px;"> *</span></td>
  313. </tr>
  314. </table>
  315. </fieldset>
  316. <div class="form-group layer-footer">
  317. <label class="control-label col-xs-12 col-sm-5"></label>
  318. <div class="col-xs-12 col-sm-5">
  319. <br>
  320. <button type="submit" id="submit" class="btn btn-primary btn-embossed">{:__('保存')}</button>
  321. </div>
  322. </div>
  323. </form>
  324. <!-- 引入 select2 样式 -->
  325. <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
  326. <!-- 引入 jQuery -->
  327. <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
  328. <!-- 引入 select2 JS -->
  329. <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
  330. <script>
  331. $(function() {
  332. const $input = $('#pallet_height');
  333. const $list = $('#height-suggestions');
  334. // 显示下拉菜单
  335. $input.on('focus click', function () {
  336. $list.show();
  337. });
  338. // 点击选项
  339. $list.on('click', 'li', function () {
  340. $input.val($(this).text());
  341. $list.hide();
  342. });
  343. // 失焦隐藏
  344. $input.on('blur', function () {
  345. setTimeout(() => $list.hide(), 100); // 延迟防止刚点 li 时被关闭
  346. });
  347. });
  348. function allowNumberAndDot(input) {
  349. input.value = input.value.replace(/[^\d.]/g, '') // 只保留数字和小数点
  350. .replace(/^\./g, '') // 开头不能是小数点
  351. .replace(/\.{2,}/g, '.') // 不能连续两个点
  352. .replace(/(\.\d*)\./g, '$1'); // 只允许一个小数点
  353. }
  354. $('#pallet_length, #pallet_width').on('input', function() {
  355. allowNumberAndDot(this);
  356. });
  357. // 绑定 pallet_length 的下拉选择
  358. $('#pallet_length').on('focus input', function () {
  359. $('#length-suggestions').show();
  360. });
  361. $('#length-suggestions li').on('click', function () {
  362. $('#pallet_length').val($(this).text());
  363. $('#length-suggestions').hide();
  364. });
  365. // 绑定 pallet_width 的下拉选择
  366. $('#pallet_width').on('focus input', function () {
  367. $('#width-suggestions').show();
  368. });
  369. $('#width-suggestions li').on('click', function () {
  370. $('#pallet_width').val($(this).text());
  371. $('#width-suggestions').hide();
  372. });
  373. // 点击空白区域时隐藏建议框
  374. $(document).on('click', function (e) {
  375. if (!$(e.target).closest('#pallet_length, #length-suggestions').length) {
  376. $('#length-suggestions').hide();
  377. }
  378. if (!$(e.target).closest('#pallet_width, #width-suggestions').length) {
  379. $('#width-suggestions').hide();
  380. }
  381. });
  382. function calculateTotalBoxes() {
  383. const boxesPerLayer = parseInt(document.getElementById("tray_num").value) || 0;
  384. const layersPerTray = parseInt(document.getElementById("box_number").value) || 0;
  385. const totalBoxes = boxesPerLayer * layersPerTray;
  386. console.log("totalBoxes".totalBoxes)
  387. document.getElementById("total_boxes").value = totalBoxes;
  388. var trayNum1 = $('#tray_num').val();
  389. console.log('箱:', trayNum1);
  390. $('#boxes_per_layer').val(trayNum1 ? trayNum1 : '');
  391. var trayNum2 = $('#box_number').val();
  392. console.log('层:', trayNum2);
  393. $('#layers_per_pallet').val(trayNum2 ? trayNum2 : '');
  394. var trayNum3 = $('#total_boxes').val();
  395. console.log('总箱数:', trayNum3);
  396. $('#c-small_num').val(trayNum3 ? trayNum3 : '');
  397. }
  398. $('#c-product_name').on('change', function () {
  399. // 获取选中的产品编码和产品代号
  400. var selectedOption = $(this).find('option:selected');
  401. var product_code = selectedOption.val(); // 获取产品编码
  402. var cpdh = selectedOption.data('cpdh'); // 获取产品代号
  403. // 设置产品编码和产品代号到对应的输入框
  404. $('#c-product_code').val(product_code);
  405. $('#c-jjcp_cpdh').val(cpdh);
  406. // 发起 AJAX 请求获取产品信息
  407. $.ajax({
  408. method: "GET",
  409. url: 'qcode_add/product',
  410. data: { product_code: product_code },
  411. success: function (data) {
  412. console.log(data)
  413. // 根据返回的模板值判断单位显示
  414. // if (data.temple === '07') {
  415. $('#danwei').val(1);
  416. $('.juan').hide();
  417. $('.xiang').show();
  418. // } else {
  419. // $('#danwei').val(2);
  420. // $('.xiang').hide();
  421. // $('.juan').show();
  422. // }
  423. // 设置流水号字段,如果为空则默认设置为 1
  424. $('#c-big_liushui').val(data.data.flow || 1);
  425. // 设置批次号字段,如果为空则生成当前年份的默认批次号
  426. if (data.data.bach === '' || data.data.bach === undefined) {
  427. var currentYear = new Date().getFullYear();
  428. var newValue = currentYear + '000000';
  429. $('#c-batch').removeAttr('disabled').val(newValue);
  430. } else {
  431. $('#c-batch').val(data.data.bach);
  432. $('#c-batch').attr('disabled', true);
  433. }
  434. },
  435. error: function () {
  436. console.log("加载数据失败!");
  437. }
  438. });
  439. });
  440. $('#c-product_name').select2({
  441. placeholder: "请选择辅料名称",
  442. allowClear: true,
  443. width: 'style',
  444. dropdownAutoWidth: false,
  445. language: {
  446. noResults: function () {
  447. return "未查询到结果";
  448. }
  449. },
  450. matcher: function(params, data) {
  451. if ($.trim(params.term) === '') {
  452. return data;
  453. }
  454. if (typeof data.text === 'undefined') {
  455. return null;
  456. }
  457. // 模糊匹配:忽略大小写
  458. if (data.text.toLowerCase().indexOf(params.term.toLowerCase()) > -1) {
  459. return data;
  460. }
  461. return null;
  462. }
  463. });
  464. </script>