priceManage.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>价格管理</title>
  6. <script src="../../js/min-loader-next.js"></script>
  7. </head>
  8. <body class="body-content">
  9. <div class="order-body">
  10. <div class="order-tiaojian back-gray">
  11. <div class="tiaojian-part1" id="conditions">
  12. <div class="fl f12-gray4-op mt4">所选条件:</div>
  13. </div>
  14. <div class="tiaojian-part2 fr demoTable">
  15. <button class="order-bnt1" onclick="loadAA();">查询</button>
  16. <button class="order-bnt2" onclick="cancle();">重置</button>
  17. <a href="#" id="toggle" class="top">收起<i class="iconfont up iconSelect_drop-down"></i></a>
  18. </div>
  19. </div>
  20. <form class="layui-form" action="javascript:void(0)" id = "formName" >
  21. <div class="order-select back-border" id="content" style="display: block;">
  22. <div class="layui-inline">
  23. <label class="f12-gray4">类型:</label>
  24. <div class="layui-input-inline" id ="type">
  25. </div>
  26. </div>
  27. <div class="layui-inline">
  28. <label class="f12-gray4">价格日期:</label>
  29. <div class="layui-input-inline" style="position: relative;">
  30. <input type="text" class="layui-input" id="date" autocomplete="off" placeholder=" - ">
  31. </div>
  32. </div>
  33. <div class="d-dashed" style="margin: 10px 0;"></div>
  34. <div class="layui-inline">
  35. <label class="f12-gray4">长江价均价:</label>
  36. <div class="layui-input-inline">
  37. <input type="text" class="layui-input" id="avgCj" name="avgCj" value="0" style="border:none;color: red" disabled="disabled" class="search-select">
  38. </div>
  39. </div>
  40. <div class="layui-inline">
  41. <label class="f12-gray4">南储价均价:</label>
  42. <div class="layui-input-inline">
  43. <input type="text" class="layui-input" id="avgNc" name="avgNc" value="0" style="border:none;color: red" disabled="disabled" class="search-select">
  44. </div>
  45. </div>
  46. <div class="layui-inline">
  47. <label class="f12-gray4">上海有色网价均价:</label>
  48. <div class="layui-input-inline">
  49. <input type="text" class="layui-input" id="avgSh" name="avgSh" value="0" style="border:none;color: red" disabled="disabled" class="search-select">
  50. </div>
  51. </div>
  52. <div class="layui-inline">
  53. <label class="f12-gray4">沪铝当月结算价均价:</label>
  54. <div class="layui-input-inline">
  55. <input type="text" class="layui-input" id="avgHl" name="avgHl" value="0" style="border:none;color: red" disabled="disabled" class="search-select">
  56. </div>
  57. </div>
  58. </div>
  59. </form>
  60. </div>
  61. <div class="shadow-content" >
  62. <div class="gray-title demoTable" >
  63. <button class="layui-btn left-bnt1 in-b" data-type="addBtn" >
  64. <i class="layui-icon">&#xe608;</i> 添加
  65. </button>
  66. <button class="layui-btn left-bnt1 in-b" data-type="addBatch" id = "addBatch"> 批量导入
  67. </button>
  68. <button class="layui-btn left-bnt1 in-b" data-type="financeToExecl" id = "financeToExecl"> 导出
  69. </button>
  70. <button class="layui-btn left-bnt1 in-b" data-type="addTypeBtn" >
  71. <i class="layui-icon">&#xe608;</i> 新增价格类型
  72. </button>
  73. </div>
  74. <table id="tableTest" lay-filter="tableFilter"></table>
  75. </div>
  76. <!--操作功能-->
  77. <script type="text/html" id="barDemo">
  78. <a class="f12-blue ml0-4" lay-event="edit">编辑</a>
  79. </script>
  80. <script>
  81. $("#toggle").click(function() {
  82. $(this).html($("#content").is(":hidden") ? "收起" + "<i class='iconfont up iconSelect_drop-down'/></i>" : "展开" +
  83. "<i class='iconfont up iconSelect_drop-down'/></i>");
  84. $("#content").slideToggle();
  85. });
  86. layui.use(['laydate','form'], function(){
  87. var laydate = layui.laydate;
  88. //日期范围
  89. laydate.render({
  90. elem: '#date'
  91. ,range: true
  92. ,format:'yyyyMMdd'
  93. ,trigger: 'click'
  94. });
  95. var form = layui.form;
  96. initSelect('type', "PRICE_TYPE", "type","", true);
  97. form.render();
  98. })
  99. function getHtYue(){
  100. debugger;
  101. var date = new Date();
  102. var month = (date.getMonth() + 1);
  103. var day = date.getDate();
  104. var year = date.getFullYear();
  105. var startMonth;
  106. var endMonth;
  107. var startYear;
  108. var endYear;
  109. var htYue = '';
  110. //大于25 本月26+下月25
  111. if (parseInt(day) > 25) {
  112. //结束月
  113. endMonth = month+1;
  114. //开始月
  115. startMonth = month;
  116. if (endMonth == "13") {
  117. endMonth = '01';
  118. endYear = year + 1;
  119. } else {
  120. if(endMonth < 10){
  121. endMonth = "0"+endMonth;
  122. }
  123. endYear = year;
  124. }
  125. if (startMonth == 0) {
  126. startMonth = "12";
  127. startYear = year -1;
  128. } else {
  129. if(startMonth < 10){
  130. startMonth = "0"+startMonth;
  131. }
  132. startYear = year;
  133. }
  134. htYue = ""+startYear + startMonth + '26' + ' - ' + endYear + endMonth + '25';
  135. //合同月赋值
  136. $("#date").val(htYue);
  137. return htYue;
  138. } else{
  139. //开始月
  140. startMonth = month-1;
  141. //结束月
  142. endMonth = month;
  143. if (startMonth == 0) {
  144. startMonth = "12";
  145. startYear = year -1;
  146. }else{
  147. if(startMonth < 10){
  148. startMonth = '0' + startMonth;
  149. }
  150. startYear = year;
  151. }
  152. if (endMonth == 13) {
  153. endMonth = '01';
  154. endYear = year + 1;
  155. } else {
  156. if (endMonth < 10) {
  157. endMonth = '0' + endMonth;
  158. }
  159. endYear = year;
  160. }
  161. htYue = ""+startYear + startMonth + '26' + ' - ' + endYear + endMonth + '25';
  162. //合同月赋值
  163. $("#date").val(htYue);
  164. return htYue;
  165. }
  166. }
  167. var table;
  168. layui.use('table', function(){
  169. var date = getHtYue();
  170. table = layui.table;
  171. table.render({
  172. id : 'tableTest'
  173. ,elem: '#tableTest'
  174. ,limit:10
  175. ,url: 'PriceManageAction/queryPriceInfII' //数据接口
  176. ,method: 'post'
  177. ,where:{MINView:"JSON", date : date}
  178. ,page: true //开启分页
  179. ,cols: [[ //表头
  180. {type:'numbers',title: '序号',width:"5%"}
  181. ,{field: 'dates', title: '日期', width:"15%"}
  182. ,{field: 'cjPrice', title: '长江价',width:"15%"}
  183. ,{field: 'ncPrice', title: '南储价', width:"15%"}
  184. ,{field: 'shPrice', title: '上海有色网价',width:"15%"}
  185. ,{field: 'hlPrice', title: '沪铝结算价',width:"15%"}
  186. ,{field: 'operate', title: '操作', width:"20%", toolbar: '#barDemo',fixed:'right'}
  187. ]]
  188. ,done: function(res, curr, count){
  189. var avgPriceList = res.avgPriceList;
  190. var avgCj = "0.00";
  191. var avgNc = "0.00";
  192. var avgSh = "0.00";
  193. var avgHl = "0.00";
  194. for (let o of avgPriceList) {
  195. if (o.type == '00') {
  196. avgNc = o.avgPrice;
  197. } else if (o.type == '01') {
  198. avgCj = o.avgPrice;
  199. } else if (o.type == '06') {
  200. avgSh = o.avgPrice;
  201. } else if (o.type == '07') {
  202. avgHl = o.avgPrice;
  203. }
  204. }
  205. $("#avgCj").val(avgCj);
  206. $("#avgNc").val(avgNc);
  207. $("#avgSh").val(avgSh);
  208. $("#avgHl").val(avgHl);
  209. }
  210. ,even: true //开启隔行背景
  211. });
  212. // 监听工具条(操作)
  213. table.on('tool(tableFilter)', function(obj){ //注:tool是工具条事件名,tableFilter是table原始容器的属性 lay-filter="对应的值"
  214. var data = obj.data; //获得当前行数据
  215. var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
  216. var tr = obj.tr; //获得当前行 tr 的DOM对象
  217. var aeiId = data.aeiId;
  218. if(layEvent === 'delete'){ //删除
  219. layer.confirm('确认删除当前价格?', function(index){
  220. layer.close(index);
  221. //向服务端发送删除指令roleDelete
  222. $.request({
  223. action : "PriceManageAction/deletePrice",
  224. data : {
  225. aeiId : aeiId,
  226. State : "01"
  227. },
  228. success : function(resData) {
  229. if (resData.MINStatus == 0) {
  230. //成功后刷新
  231. var btn=$(".layui-laypage-btn")[0];
  232. btn.click();
  233. layer.alert('操作成功!', {icon: 1});
  234. } else {
  235. layer.alert(resData.MINErrorMessage, {
  236. icon: 5,
  237. title: "提示"
  238. });
  239. }
  240. },
  241. error : function(data2){
  242. layer.alert(data2.MINErrorMessage, {
  243. icon: 5,
  244. title: "提示"
  245. });
  246. }
  247. });
  248. });
  249. }else if(layEvent === 'edit'){ //编辑
  250. editDetail(data);
  251. }
  252. });
  253. var $ = layui.$, active = {
  254. reload: function(){
  255. loadAA();
  256. }
  257. ,reset: function(){
  258. $('#formName')[0].reset()
  259. }
  260. //导出
  261. ,financeToExecl : function(){debugger;
  262. var type = $("select[name='type']").val();
  263. var date = $("#date").val();
  264. var param = {};
  265. param.type = type;
  266. param.date = date;
  267. exportExcel("../../FinanceToExecl/exportExcelJia?",param);
  268. }
  269. //新增
  270. ,addBtn : function(){
  271. openMainTabPageParent('050004-01', '新增价格', 'priceManage/addPrice.html?&tabPageId=050004-01', '', '050004', loadAA);
  272. }
  273. ,addTypeBtn : function(){
  274. layer.prompt({title : "请输入价格类型",maxlength: 50},function(value, index, elem){
  275. if(isEmpty(value)){
  276. $.ErrorAlert('请输入价格类型!');
  277. return;
  278. }
  279. //向服务端发送删除指令roleDelete
  280. $.request({
  281. action : "PriceManageAction/addPriceType",
  282. data : {
  283. priceType : value
  284. },
  285. success : function(resData) {
  286. layer.close(index);
  287. initAppParam(function(){
  288. layui.use(['form'], function(){
  289. var form = layui.form;
  290. initSelect('type', "PRICE_TYPE", "type","", true);
  291. form.render();
  292. })
  293. });
  294. },
  295. error : function(data2){
  296. layer.alert(data2.MINErrorMessage, {
  297. icon: 5,
  298. title: "提示"
  299. });
  300. }
  301. });
  302. });
  303. }
  304. //批量导入
  305. ,addBatch : function(){
  306. openMainTabPageParent('050004-03', '批量导入', 'priceManage/uploadPrice.html?tabPageId=050004-03','','050004',loadAA);
  307. }
  308. };
  309. $('.demoTable .layui-btn').on('click', function(){
  310. var type = $(this).data('type');
  311. active[type] ? active[type].call(this) : '';
  312. });
  313. });
  314. function loadAA(){
  315. var type = $("select[name='type']").val();
  316. var date = $("#date").val();
  317. //执行重载
  318. table.reload('tableTest', {
  319. page: {
  320. curr: 1 //重新从第 1 页开始
  321. }
  322. ,where: {
  323. type : type,
  324. date :date
  325. }
  326. });
  327. }
  328. //编辑
  329. function editDetail(data) {
  330. setTempVal("editPriceInf", data);
  331. openMainTabPageParent('050004-02', '编辑价格', 'priceManage/editPrice.html', '', '050004', loadAA);
  332. }
  333. //重置
  334. function cancle(){
  335. $('#formName')[0].reset();
  336. }
  337. </script>
  338. </body>
  339. </html>