cashier.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" />
  6. <meta name="author" content="siweiyong 2602812659@qq.com"/>
  7. <title>订货下单</title>
  8. <link rel="stylesheet" href="../script/lib/miniui/themes/default/miniui.css">
  9. <link rel="stylesheet" href="../script/lib/layui/css/layui.css" />
  10. <link rel="stylesheet" href="../script/lib/cashier/common.css">
  11. <link rel="stylesheet" href="../script/lib/layui/admin/modules/plugin/formselects/formselects.css" media="all" />
  12. <script src="../script/lib/jquery/jquery.min.js"></script>
  13. <script src="../script/lib/miniui/miniui.js"></script>
  14. <script src="../script/lib/layui/layui.js"></script>
  15. <script><{Dever::script()}></script>
  16. <script src="../script/dever/core.js"></script>
  17. </head>
  18. <body style="background: #F6F7F9;">
  19. <div class="main">
  20. <form class="layui-form" lay-filter="form">
  21. <div class="layui-row">
  22. <div class="main_left layui-col-xs12 layui-col-md3">
  23. <div class="layui-row">
  24. <div class="top">
  25. <i class="layui-icon layui-icon-app"></i>商品列表
  26. </div>
  27. <div class="left_main">
  28. <input id="key" class="mini-textbox" placeholder="请输入商品名称" onenter="onKeyEnter"/>
  29. <a class="mini-button" onclick="search()">查询</a>
  30. <ul id="tree1" class="mini-tree" url="<{$url}>" showTreeIcon="true" textField="name" idField="id" expandOnLoad="true" onNodeClick="onNodeClick">
  31. </ul>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="main_right layui-col-xs12 layui-col-md9">
  36. <div class="layui-row">
  37. <div class="top">
  38. <label>选择工厂:</label>
  39. <div class="layui-input-inline">
  40. <div><select xm-select="factory_id" xm-select-skin="normal" xm-select-search="<{$search}>" xm-select-search-type="dl" xm-select-radio="" class="update_value form-control layui-input layui-select" name="factory_id" id="factory_id" ></select></div>
  41. </div>
  42. <div class="layui-input-inline">
  43. <button class="layui-btn layui-btn-button" type="button" style="vertical-align: middle;margin-bottom: 2px;" onclick="setFactory()">确认选择</button>
  44. </div>
  45. </div>
  46. <div class="goods_list">
  47. <table class="layui-table">
  48. <thead>
  49. <tr>
  50. <th lay-data="{field:'id'}">商品编码</th>
  51. <th lay-data="{field:'name'}">商品名称</th>
  52. <th lay-data="{field:'price', edit: 'text'}">出厂价(元)</th>
  53. <th lay-data="{field:'c_price', edit: 'text'}">成本价(元)</th>
  54. <th lay-data="{field:'number', edit: 'text'}">数量</th>
  55. <th lay-data="{field:'operation'}">操作</th>
  56. </tr>
  57. </thead>
  58. <tbody id="goods">
  59. </tbody>
  60. </table>
  61. </div>
  62. <div class="total ft16">
  63. 合计:【<span> 总金额:<i class="totalMoney">0.00</i> </span>】【<span> 总成本:<i class="totalCMoney">0.00</i> </span>】【<span> 总数量:<i class="totalQuantity">0</i> </span>】
  64. </div>
  65. <table class="reading layui-table" lay-even="">
  66. <tbody>
  67. <tr>
  68. <td>选择仓库</td>
  69. <td colspan="3">
  70. <div class="layui-input-inline">
  71. <select xm-select="store_id" xm-select-skin="normal" xm-select-search="<{$search_store}>" xm-select-search-type="dl" xm-select-radio="" class="update_value form-control layui-input layui-select" name="store_id" id="store_id" ></select>
  72. </div>
  73. <!--
  74. <button class="card_reading layui-btn">读卡</button>
  75. <a href="#" class="registration layui-btn layui-btn-primary">会员登记</a>
  76. -->
  77. </td>
  78. </tr>
  79. <tr>
  80. <td>订单备注:</td>
  81. <td><textarea class="layui-textarea" name="info" id="info" rows="" cols="" maxlength="200" placeholder="请输入订单备注"></textarea></td>
  82. </tr>
  83. <!--
  84. <tr>
  85. <td>会员卡号:</td>
  86. <td></td>
  87. <td>会员姓名:</td>
  88. <td></td>
  89. </tr>
  90. <tr>
  91. <td>会员级别:</td>
  92. <td></td>
  93. <td>有效期:</td>
  94. <td></td>
  95. </tr>
  96. <tr>
  97. <td>可用积分:</td>
  98. <td></td>
  99. <td>可用储值:</td>
  100. <td></td>
  101. </tr>
  102. -->
  103. </tbody>
  104. </table>
  105. <div class="towbtn">
  106. <input type="button" id="settlement" value="订货下单">
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. <div class="mask_box">
  113. <div class="mask"></div>
  114. <div class="box">
  115. <div class="box_top">结算</div>
  116. <div class="box_block box_block1">
  117. <div class="block_left"><label for="">应付金额:</label></div>
  118. <div class="block_right"><input type="text" class="layui-input" value="23131" readonly style="border: none;" /></div>
  119. </div>
  120. <div class="box_block box_block2">
  121. <div class="block_left"><input type="checkbox" name="" />优惠券:</div>
  122. <div class="block_right">
  123. <select class="layui-select" name="" id="">
  124. <option value="0">请选择</option>
  125. <option value="1">1</option>
  126. <option value="2">2</option>
  127. <option value="3">3</option>
  128. <option value="4">4</option>
  129. </select>
  130. </div>
  131. <div class="block_left">还需支付:</div>
  132. <div class="block_right"><input type="text" class="layui-input" value="32432" readonly style="border: none;" /></div>
  133. </div>
  134. <div class="box_block box_block3">
  135. <div class="block_left"><input type="radio" name="payment" /><label for="use_coupon">现金支付:</label></div>
  136. <div class="block_right">
  137. <input type="text" class="layui-input" />
  138. </div>
  139. <br style="clear: both;">
  140. <div class="block_left"><input type="radio" name="payment" /><label for="use_coupon">移动支付:</label></div>
  141. <div class="block_right">
  142. <input type="text" class="layui-input" />
  143. </div>
  144. <br style="clear: both;">
  145. <div class="block_left"><input type="radio" name="payment" /><label for="use_coupon">其他支付:</label></div>
  146. <div class="block_right">
  147. <input type="text" class="layui-input" />
  148. </div>
  149. </div>
  150. <div class="remark_mess">
  151. <div class="block_left">
  152. 备注:
  153. </div>
  154. <div class="block_right">
  155. <textarea class="layui-textarea" name="" rows="" cols="" maxlength="200" placeholder="最多输入200字符"></textarea>
  156. </div>
  157. <br style="clear: both;">
  158. <div class="block_left">
  159. 交易时间:
  160. </div>
  161. <div class="block_right">
  162. <input type="text" value="2018-11-23 08:23:43" class="layui-input" readonly style="border: none;" />
  163. </div>
  164. </div>
  165. <div class="bot">
  166. <input type="button" value="提交">
  167. <input type="text" value="取消">
  168. </div>
  169. </div>
  170. </form>
  171. </div>
  172. <script>
  173. var form;
  174. layui.config(
  175. {
  176. base: '../script/lib/layui/admin/' //静态资源所在路径
  177. ,version: true
  178. }).extend(
  179. {
  180. index: 'lib/index', //主入口模块
  181. formSelects: 'plugin/formselects/formselects'
  182. }).use(['index', 'contlist', 'table', 'form', 'formSelects','layer'], function()
  183. {
  184. var table = layui.table;
  185. form = layui.form;
  186. var formSelects = layui.formSelects;
  187. });
  188. $(function()
  189. {
  190. $("#settlement").click(function(){
  191. var url = '<{$submit}>';
  192. var factory_id = '<{$factory_id}>';
  193. var store_id = $('.xm-select-parent[fs_id="store_id"] span[fsw="xm-select"]').attr('value');
  194. if (!store_id) {
  195. layui.layer.alert('请先选择仓库');
  196. return;
  197. }
  198. layui.layer.confirm('确定订货下单吗?', function() {
  199. var info = $('#info').val();
  200. var goods_string = JSON.stringify(goods);
  201. var data = {};
  202. data = {store_id:store_id, factory_id:factory_id, goods:goods_string, info:info};
  203. $.post(url, data, function(t) {
  204. t = JSON.parse(t);
  205. if (t.status == 1) {
  206. layui.layer.alert('订货下单成功', function(index){
  207. location.href = t.data;
  208. layer.close(index);
  209. });
  210. } else {
  211. layui.layer.alert(t.msg);
  212. }
  213. });
  214. });
  215. //$(".mask_box").show();
  216. })
  217. $(".bot input:nth-child(2)").click(function(){
  218. $(".mask_box").hide();
  219. })
  220. $("#goods").on("keyup", ".goods_num", function() {
  221. var num = parseFloat($(this).val());
  222. if (num < 0) {
  223. num = 1;
  224. $(this).val(1);
  225. }
  226. var id = $(this).parent().attr('value');
  227. goods[id].num = num;
  228. setTotal();
  229. })
  230. })
  231. mini.parse();
  232. var tree = mini.get("tree1");
  233. function search()
  234. {
  235. var key = mini.get("key").getValue();
  236. if (key == "") {
  237. tree.clearFilter();
  238. } else {
  239. key = key.toLowerCase();
  240. tree.filter(function (node) {
  241. var name = node.name ? node.name.toLowerCase() : "";
  242. if (name.indexOf(key) != -1) {
  243. return true;
  244. }
  245. });
  246. }
  247. }
  248. function onKeyEnter(e)
  249. {
  250. search();
  251. }
  252. var goods = {};
  253. function onNodeClick()
  254. {
  255. var tree=mini.get("tree1");
  256. node=tree.getSelectedNode();
  257. if(node.end) {
  258. var key = node.id;
  259. if (!goods[key]) {
  260. goods[key] = node;
  261. goods[key].price = parseFloat(goods[key].price);
  262. goods[key].c_price = parseFloat(goods[key].c_price);
  263. goods[key].min = parseFloat(goods[key].min);
  264. if (goods[key].min) {
  265. goods[key].num = goods[key].min;
  266. } else {
  267. goods[key].min = 1;
  268. goods[key].num = 1;
  269. }
  270. create(node);
  271. setTotal();
  272. } else {
  273. add(key);
  274. }
  275. }
  276. }
  277. function get(key)
  278. {
  279. return $('#goods_' + key);
  280. }
  281. function create(node)
  282. {
  283. console.info(node);
  284. if (!get(node.id).length) {
  285. var addtr = '<tr class="mytr" id="goods_'+node.id+'">';
  286. addtr += '<td class="goods_id">'+node.id+'</td>';
  287. addtr += '<td class="goods_name">'+node.name+'</td>' ;
  288. addtr += '<td class="goods_price">'+node.price+'</td>';
  289. addtr += '<td class="goods_c_price">'+node.c_price+'</td>';
  290. addtr += '<td><div class="jiajian" value='+node.id+'><span class="jian" onclick="dec(\''+node.id+'\')">-</span><input type="text" value="'+node.num+'" class="goods_num"><span class="jia" onclick="add(\''+node.id+'\')">+</span></div></td>';
  291. addtr += '<td><button class="delete_btn" onclick="del(\''+node.id+'\')">删除</button></td>';
  292. addtr += '</tr>';
  293. $("#goods").append(addtr);
  294. }
  295. }
  296. function add(id)
  297. {
  298. goods[id].num += 1;
  299. get(id).find('.goods_num').val(goods[id].num);
  300. setTotal();
  301. }
  302. function dec(id)
  303. {
  304. goods[id].num -= 1;
  305. if (goods[id].num < goods[id].min) {
  306. goods[id].num = goods[id].min;
  307. }
  308. get(id).find('.goods_num').val(goods[id].num);
  309. setTotal();
  310. }
  311. function del(id)
  312. {
  313. delete goods[id];
  314. get(id).remove();
  315. setTotal();
  316. }
  317. /*
  318. //点击 - 单价 - 可编辑
  319. $("#goods").on("click","td.danjia",function(){
  320. if(!$(this).is('.bj')){
  321. var currentPrice = $(this).html();
  322. $(this).focus();
  323. $(this).addClass('bj').html('<input type="tel" class="layui-input" value="'+$(this).text()+'" />').find('input').focus().blur();
  324. }
  325. })
  326. */
  327. function setTotal()
  328. {
  329. var cash = 0;
  330. var c_cash = 0;
  331. var num = 0;
  332. for (var i in goods) {
  333. num += goods[i].num;
  334. cash += goods[i].price * goods[i].num;
  335. c_cash += goods[i].c_price * goods[i].num;
  336. }
  337. $(".totalQuantity").html(num);
  338. $(".totalMoney").html(cash.toFixed(2));
  339. $(".totalCMoney").html(c_cash.toFixed(2));
  340. }
  341. function setFactory()
  342. {
  343. var factory_id = $('.xm-select-parent[fs_id="factory_id"] span[fsw="xm-select"]').attr('value');
  344. if (!factory_id) {
  345. layui.layer.alert('请选择工厂');
  346. return;
  347. }
  348. layui.layer.confirm('确定切换工厂吗?切换后现在选择的商品都将清空', function() {
  349. location.href = '<{$host}>&factory_id=' + factory_id;
  350. });
  351. }
  352. </script>
  353. </body>
  354. </html>