123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>价格管理</title>
- <script src="../../js/min-loader-next.js"></script>
- </head>
- <body class="body-content">
- <div class="order-body">
- <div class="order-tiaojian back-gray">
- <div class="tiaojian-part1" id="conditions">
- <div class="fl f12-gray4-op mt4">所选条件:</div>
- </div>
- <div class="tiaojian-part2 fr demoTable">
- <button class="order-bnt1" onclick="loadAA();">查询</button>
- <button class="order-bnt2" onclick="cancle();">重置</button>
- <a href="#" id="toggle" class="top">收起<i class="iconfont up iconSelect_drop-down"></i></a>
- </div>
- </div>
- <form class="layui-form" action="javascript:void(0)" id = "formName" >
- <div class="order-select back-border" id="content" style="display: block;">
- <div class="layui-inline">
- <label class="f12-gray4">类型:</label>
- <div class="layui-input-inline" id ="type">
- </div>
- </div>
- <div class="layui-inline">
- <label class="f12-gray4">价格日期:</label>
- <div class="layui-input-inline" style="position: relative;">
- <input type="text" class="layui-input" id="date" autocomplete="off" placeholder=" - ">
- </div>
- </div>
-
- <div class="d-dashed" style="margin: 10px 0;"></div>
- <div class="layui-inline">
- <label class="f12-gray4">长江价均价:</label>
- <div class="layui-input-inline">
- <input type="text" class="layui-input" id="avgCj" name="avgCj" value="0" style="border:none;color: red" disabled="disabled" class="search-select">
- </div>
- </div>
- <div class="layui-inline">
- <label class="f12-gray4">南储价均价:</label>
- <div class="layui-input-inline">
- <input type="text" class="layui-input" id="avgNc" name="avgNc" value="0" style="border:none;color: red" disabled="disabled" class="search-select">
- </div>
- </div>
- <div class="layui-inline">
- <label class="f12-gray4">上海有色网价均价:</label>
- <div class="layui-input-inline">
- <input type="text" class="layui-input" id="avgSh" name="avgSh" value="0" style="border:none;color: red" disabled="disabled" class="search-select">
- </div>
- </div>
- <div class="layui-inline">
- <label class="f12-gray4">沪铝当月结算价均价:</label>
- <div class="layui-input-inline">
- <input type="text" class="layui-input" id="avgHl" name="avgHl" value="0" style="border:none;color: red" disabled="disabled" class="search-select">
- </div>
- </div>
- </div>
- </form>
-
-
- </div>
- <div class="shadow-content" >
- <div class="gray-title demoTable" >
- <button class="layui-btn left-bnt1 in-b" data-type="addBtn" >
- <i class="layui-icon"></i> 添加
- </button>
- <button class="layui-btn left-bnt1 in-b" data-type="addBatch" id = "addBatch"> 批量导入
- </button>
- <button class="layui-btn left-bnt1 in-b" data-type="financeToExecl" id = "financeToExecl"> 导出
- </button>
- <button class="layui-btn left-bnt1 in-b" data-type="addTypeBtn" >
- <i class="layui-icon"></i> 新增价格类型
- </button>
- </div>
- <table id="tableTest" lay-filter="tableFilter"></table>
- </div>
- <!--操作功能-->
- <script type="text/html" id="barDemo">
- <a class="f12-blue ml0-4" lay-event="edit">编辑</a>
- </script>
-
- <script>
- $("#toggle").click(function() {
- $(this).html($("#content").is(":hidden") ? "收起" + "<i class='iconfont up iconSelect_drop-down'/></i>" : "展开" +
- "<i class='iconfont up iconSelect_drop-down'/></i>");
- $("#content").slideToggle();
- });
- layui.use(['laydate','form'], function(){
- var laydate = layui.laydate;
- //日期范围
- laydate.render({
- elem: '#date'
- ,range: true
- ,format:'yyyyMMdd'
- ,trigger: 'click'
- });
-
- var form = layui.form;
- initSelect('type', "PRICE_TYPE", "type","", true);
- form.render();
- })
-
- function getHtYue(){
- debugger;
- var date = new Date();
- var month = (date.getMonth() + 1);
- var day = date.getDate();
- var year = date.getFullYear();
- var startMonth;
- var endMonth;
- var startYear;
- var endYear;
- var htYue = '';
- //大于25 本月26+下月25
- if (parseInt(day) > 25) {
- //结束月
- endMonth = month+1;
- //开始月
- startMonth = month;
- if (endMonth == "13") {
- endMonth = '01';
- endYear = year + 1;
- } else {
- if(endMonth < 10){
- endMonth = "0"+endMonth;
- }
- endYear = year;
- }
-
- if (startMonth == 0) {
- startMonth = "12";
- startYear = year -1;
- } else {
- if(startMonth < 10){
- startMonth = "0"+startMonth;
- }
- startYear = year;
- }
-
- htYue = ""+startYear + startMonth + '26' + ' - ' + endYear + endMonth + '25';
-
- //合同月赋值
- $("#date").val(htYue);
- return htYue;
- } else{
- //开始月
- startMonth = month-1;
- //结束月
- endMonth = month;
- if (startMonth == 0) {
- startMonth = "12";
- startYear = year -1;
- }else{
- if(startMonth < 10){
- startMonth = '0' + startMonth;
- }
- startYear = year;
- }
- if (endMonth == 13) {
- endMonth = '01';
- endYear = year + 1;
- } else {
- if (endMonth < 10) {
- endMonth = '0' + endMonth;
- }
- endYear = year;
- }
-
- htYue = ""+startYear + startMonth + '26' + ' - ' + endYear + endMonth + '25';
-
- //合同月赋值
- $("#date").val(htYue);
- return htYue;
- }
- }
-
- var table;
- layui.use('table', function(){
- var date = getHtYue();
-
- table = layui.table;
- table.render({
- id : 'tableTest'
- ,elem: '#tableTest'
- ,limit:10
- ,url: 'PriceManageAction/queryPriceInfII' //数据接口
- ,method: 'post'
- ,where:{MINView:"JSON", date : date}
- ,page: true //开启分页
- ,cols: [[ //表头
- {type:'numbers',title: '序号',width:"5%"}
- ,{field: 'dates', title: '日期', width:"15%"}
- ,{field: 'cjPrice', title: '长江价',width:"15%"}
- ,{field: 'ncPrice', title: '南储价', width:"15%"}
- ,{field: 'shPrice', title: '上海有色网价',width:"15%"}
- ,{field: 'hlPrice', title: '沪铝结算价',width:"15%"}
- ,{field: 'operate', title: '操作', width:"20%", toolbar: '#barDemo',fixed:'right'}
- ]]
- ,done: function(res, curr, count){
- var avgPriceList = res.avgPriceList;
-
- var avgCj = "0.00";
- var avgNc = "0.00";
- var avgSh = "0.00";
- var avgHl = "0.00";
- for (let o of avgPriceList) {
- if (o.type == '00') {
- avgNc = o.avgPrice;
- } else if (o.type == '01') {
- avgCj = o.avgPrice;
- } else if (o.type == '06') {
- avgSh = o.avgPrice;
- } else if (o.type == '07') {
- avgHl = o.avgPrice;
- }
- }
- $("#avgCj").val(avgCj);
- $("#avgNc").val(avgNc);
- $("#avgSh").val(avgSh);
- $("#avgHl").val(avgHl);
- }
- ,even: true //开启隔行背景
- });
-
- // 监听工具条(操作)
- table.on('tool(tableFilter)', function(obj){ //注:tool是工具条事件名,tableFilter是table原始容器的属性 lay-filter="对应的值"
- var data = obj.data; //获得当前行数据
- var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
- var tr = obj.tr; //获得当前行 tr 的DOM对象
- var aeiId = data.aeiId;
- if(layEvent === 'delete'){ //删除
- layer.confirm('确认删除当前价格?', function(index){
- layer.close(index);
- //向服务端发送删除指令roleDelete
- $.request({
- action : "PriceManageAction/deletePrice",
- data : {
- aeiId : aeiId,
- State : "01"
- },
- success : function(resData) {
- if (resData.MINStatus == 0) {
- //成功后刷新
- var btn=$(".layui-laypage-btn")[0];
- btn.click();
- layer.alert('操作成功!', {icon: 1});
- } else {
- layer.alert(resData.MINErrorMessage, {
- icon: 5,
- title: "提示"
- });
- }
- },
- error : function(data2){
- layer.alert(data2.MINErrorMessage, {
- icon: 5,
- title: "提示"
- });
- }
- });
- });
- }else if(layEvent === 'edit'){ //编辑
- editDetail(data);
- }
- });
- var $ = layui.$, active = {
- reload: function(){
- loadAA();
- }
- ,reset: function(){
- $('#formName')[0].reset()
- }
- //导出
- ,financeToExecl : function(){debugger;
- var type = $("select[name='type']").val();
- var date = $("#date").val();
- var param = {};
- param.type = type;
- param.date = date;
- exportExcel("../../FinanceToExecl/exportExcelJia?",param);
- }
- //新增
- ,addBtn : function(){
- openMainTabPageParent('050004-01', '新增价格', 'priceManage/addPrice.html?&tabPageId=050004-01', '', '050004', loadAA);
- }
- ,addTypeBtn : function(){
- layer.prompt({title : "请输入价格类型",maxlength: 50},function(value, index, elem){
- if(isEmpty(value)){
- $.ErrorAlert('请输入价格类型!');
- return;
- }
- //向服务端发送删除指令roleDelete
- $.request({
- action : "PriceManageAction/addPriceType",
- data : {
- priceType : value
- },
- success : function(resData) {
- layer.close(index);
- initAppParam(function(){
- layui.use(['form'], function(){
- var form = layui.form;
- initSelect('type', "PRICE_TYPE", "type","", true);
- form.render();
- })
- });
- },
- error : function(data2){
- layer.alert(data2.MINErrorMessage, {
- icon: 5,
- title: "提示"
- });
- }
- });
- });
- }
- //批量导入
- ,addBatch : function(){
- openMainTabPageParent('050004-03', '批量导入', 'priceManage/uploadPrice.html?tabPageId=050004-03','','050004',loadAA);
- }
-
- };
- $('.demoTable .layui-btn').on('click', function(){
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
- });
-
- function loadAA(){
- var type = $("select[name='type']").val();
- var date = $("#date").val();
- //执行重载
- table.reload('tableTest', {
- page: {
- curr: 1 //重新从第 1 页开始
- }
- ,where: {
- type : type,
- date :date
- }
- });
- }
-
- //编辑
- function editDetail(data) {
- setTempVal("editPriceInf", data);
- openMainTabPageParent('050004-02', '编辑价格', 'priceManage/editPrice.html', '', '050004', loadAA);
- }
-
- //重置
- function cancle(){
- $('#formName')[0].reset();
- }
-
- </script>
- </body>
- </html>
|