designer_report.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. {extend name="public/layout"}
  2. {block name="body"}
  3. <link rel="stylesheet" href="__LAYUI__/layui/css/layui.css" media="all">
  4. <link rel="stylesheet" " href=" /static/css/common.css">
  5. <script src="/static/js/jquery.min.js"></script>
  6. <style>
  7. body {
  8. background-color: #F3F3F3;
  9. padding-bottom: 40px;
  10. }
  11. .message_title {
  12. border: 1px solid #F0F0F0;
  13. background: #FCFCFC;
  14. margin-top: 5px;
  15. margin-bottom: 10px;
  16. position: relative;
  17. min-width: 800px;
  18. padding: 18px;
  19. }
  20. .wdatepicker2 {
  21. width: fit-content;
  22. margin: 50px auto;
  23. position: relative;
  24. }
  25. select {
  26. height: 26px;
  27. line-height: auto;
  28. vertical-align: middle;
  29. box-sizing: content-box;
  30. font-size: 13px;
  31. -webkit-appearance: menulist-button;
  32. border: #CCC solid 1px;
  33. }
  34. .wdatebtn {
  35. width: 180px;
  36. height: 28px;
  37. line-height: 26px;
  38. text-align: center;
  39. border: 1px solid #4479ba;
  40. vertical-align: top;
  41. }
  42. #searchbtn,
  43. #searchbtn1 {
  44. vertical-align: top;
  45. }
  46. .btn {
  47. cursor: pointer;
  48. color: #000;
  49. background: url(__STATIC__/img/btn_bg.gif) repeat-x;
  50. border: 1px solid #C0C0C0;
  51. padding: 0 12px;
  52. *padding: 0 6px;
  53. height: 28px;
  54. }
  55. .abouts {
  56. width: 99%;
  57. position: relative;
  58. margin-bottom: 15px;
  59. margin-top: 5px;
  60. }
  61. .wdatepicker {
  62. top: 15px;
  63. right: 69px;
  64. position: absolute;
  65. z-index:99;
  66. }
  67. .abouts h1 {
  68. text-align: center;
  69. margin-bottom: 20px;
  70. margin-top: 20px;
  71. letter-spacing: 2px;
  72. font-family: Arial, Helvetica, sans-serif;
  73. }
  74. .tableother {
  75. text-align: center;
  76. }
  77. .maintable {
  78. table-layout: fixed;
  79. _width: 100%;
  80. width: 100%;
  81. border: 1px solid #DFDFDF;
  82. border-collapse: separate !important;
  83. background-color: #FFF;
  84. border-right: 0;
  85. border-bottom: 2px solid #DFDFDF;
  86. }
  87. .maintable th {
  88. background-color: #F2F3F7;
  89. border-right: 1px solid #DFDFDF;
  90. border-bottom: 1px solid #DFDFDF;
  91. line-height: 25px;
  92. padding: 5px;
  93. text-align: center;
  94. font-family: Arial;
  95. font-size: 12px;
  96. letter-spacing: 1px;
  97. color: #333
  98. }
  99. .maintable td {
  100. border-right: 1px solid #DFDFDF;
  101. border-bottom: 1px solid #EAEAEC;
  102. padding: 7px;
  103. line-height: 25px;
  104. font-size: 13px;
  105. position: relative;
  106. }
  107. .tablelist th,
  108. .tablelist td {
  109. overflow: hidden;
  110. white-space: nowrap;
  111. text-overflow: ellipsis;
  112. word-wrap: break-word;
  113. }
  114. .tbcenter td {
  115. text-align: center
  116. }
  117. .maintable h2 {
  118. border-bottom: 1px solid #999;
  119. margin: 0;
  120. font-weight: bold;
  121. font-size: 15px;
  122. margin-bottom: 10px;
  123. margin-top: 5px;
  124. text-indent: 3px;
  125. font-family: Arial;
  126. letter-spacing: 1px;
  127. }
  128. .maintable td label {
  129. cursor: pointer
  130. }
  131. .baobaonum1 {
  132. color: #CCC
  133. }
  134. .baobaonum1 a {
  135. color: #CCC
  136. }
  137. .fontnormal {
  138. font-weight: normal;
  139. }
  140. .ablock td a {
  141. width: 100%;
  142. height: 28px;
  143. display: block;
  144. }
  145. .ablock2 {
  146. background-color: #d0af4c;
  147. font-weight: bold;
  148. }
  149. .ablock2 a {
  150. width: 100%;
  151. height: 100%;
  152. display: block;
  153. text-decoration: none
  154. }
  155. .ablock2 a:hover {
  156. color: #0000FF;
  157. text-decoration: underline
  158. }
  159. #loading-mask {
  160. position: fixed;
  161. top: 0;
  162. left: 0;
  163. width: 100%;
  164. height: 100%;
  165. background: rgba(0, 0, 0, 0.7);
  166. z-index: 15000;
  167. display: none
  168. }
  169. #loading-mask div {
  170. width: 25%;
  171. height: 179px;
  172. position: absolute;
  173. top: 40%;
  174. left: 50%;
  175. -webkit-transform: translate(-50%, -50%);
  176. transform: translate(-50%, -50%);
  177. border-radius: 10px;
  178. background-color: #FFFFFF;
  179. text-align: center
  180. }
  181. #loading-mask div img {
  182. padding-top: 40px;
  183. }
  184. #loading-mask div p {
  185. padding-top: 25px;
  186. color: #006600
  187. }
  188. .weekday {
  189. position: absolute;
  190. right: 0;
  191. bottom: -5px;
  192. text-decoration: none;
  193. font-size: 8px;
  194. color: #CCC;
  195. font-style: normal;
  196. }
  197. .wdatefast2 a {
  198. padding-left: 6px;
  199. padding-right: 6px;
  200. color: #0033CC;
  201. }
  202. .wdatefast {
  203. width: 290px;
  204. height: 35px;
  205. line-height: 35px;
  206. top: 38px;
  207. right: 48px;
  208. position: absolute;
  209. background-color: #FCFCFC;
  210. text-indent: 20px;
  211. font-family: Arial;
  212. }
  213. .wdatefast a {
  214. padding-left: 6px;
  215. padding-right: 6px;
  216. }
  217. </style>
  218. <body class="clearfix">
  219. <div class="dailybox">
  220. <div class="message_title " style="margin-bottom:8px;">
  221. 您当前的操作 · <b><span class="red2">{$data.company_name}每天报表明细</span></b>
  222. <div class="wdatepicker" style="display:none;">
  223. <select class="left" name="org_id" id="org_id" {if $is_manager neq 1} style="display:none;"{/if}>
  224. <option value="">==所有部门==</option>
  225. {volist name="org_data" id="vo"}
  226. <option value="{$vo.id}">{$vo.name}</option>
  227. {/volist}
  228. </select>
  229. <select class="left" name="source_id" id="source_id1">
  230. <option value="">==来源账户==</option>
  231. {volist name="soudata" id="vo"}
  232. <option value="{$vo.id}">{$vo.name}</option>
  233. {/volist}
  234. </select>
  235. <select class="left validbox" name="wuxiao" id="valid">
  236. <option value="">==包含==</option>
  237. <option value="1">统计无效</option>
  238. </select>
  239. <input name="nowyear" type="text" id="nowyear1" class="wdatebtn left" readonly="readonly" placeholder="开始时间 到 结束时间">
  240. <button id="searchbtn1" class="btn left" type="button">查 看</button>
  241. <div class="wdatefast">
  242. 推荐检索:
  243. <a class="nowmonth" href="javascript:void(0)">本月度</a>
  244. <a class="lastmonth" href="javascript:void(0)">上个月</a>
  245. <a class="nowyearbtn" href="javascript:void(0)">本年度</a>
  246. </div>
  247. </div>
  248. </div>
  249. <div class="wdatepicker2 tcenter">
  250. <div id="seafrom" class="inline-block clearfix" style="margin:0px">
  251. <select class="left" name="org_ids" id="org_ids" {if $is_manager neq 1} style="display:none;"{/if}>
  252. <option value="">==所有部门==</option>
  253. {volist name="org_data" id="vo"}
  254. <option value="{$vo.id}">{$vo.name}</option>
  255. {/volist}
  256. </select>
  257. <select class="left" name="source_id" id="source_id">
  258. <option value="">==来源账户==</option>
  259. {volist name="soudata" id="vo"}
  260. <option value="{$vo.id}">{$vo.name}</option>
  261. {/volist}
  262. </select>
  263. <select class="left" name="wuxiao" id="wuxiao">
  264. <option value="">==包含==</option>
  265. <option value="1">统计无效</option>
  266. </select>
  267. <input name="nowyear" type="text" id="nowyear" class="wdatebtn left" readonly="readonly" placeholder="开始时间 到 结束时间">
  268. <button id="searchbtn" class="btn left" type="button">查 看</button>
  269. </div>
  270. <div class="wdatefast2">
  271. 推荐检索:
  272. <a class="nowmonth" href="javascript:void(0)">本月度</a>
  273. <a class="lastmonth" href="javascript:void(0)">上个月</a>
  274. <a class="nowyearbtn" href="javascript:void(0)">本年度</a>
  275. </div>
  276. </div>
  277. <div class="abouts tablemsgbox" style="display:none;">
  278. <h1>{$data.company_name}设计师<span class="month"></span>月份日报</h1>
  279. <table class="maintable tableother">
  280. <thead>
  281. <tr>
  282. <th rowspan="2">客服</th>
  283. <th colspan="10">基本数据</th>
  284. <th colspan="4" class="validnumbox" style="display:none;">注销</th>
  285. </tr>
  286. <tr>
  287. <th class="thtopline">线索量</th>
  288. <th class="thtopline">有效线索量</th>
  289. <th class="thtopline">有效率</th>
  290. <th class="thtopline">待确认</th>
  291. <th class="thtopline">见面量</th>
  292. <th class="thtopline">见面率</th>
  293. <th class="thtopline">预定合同</th>
  294. <th class="thtopline">成单率</th>
  295. <th class="thtopline">施工合同</th>
  296. <!-- <th class="thtopline" title="套餐整装或基础合同额">基本金额</th>
  297. <th class="thtopline" title="软装、电器、定制等合同额">其他金额</th> -->
  298. <th class="thtopline">业绩总额</th>
  299. <th class="thtopline fontnormal validnumbox" style="display:none;">无效</th>
  300. <th class="thtopline fontnormal validnumbox" style="display:none;">有效</th>
  301. <th class="thtopline fontnormal validnumbox" style="display:none;">见面</th>
  302. <th class="thtopline fontnormal validnumbox" style="display:none;">定金</th>
  303. </tr>
  304. </thead>
  305. <tbody class="tbodybox">
  306. </tbody>
  307. </table>
  308. </div>
  309. <div class="abouts" style="text-align:right; color:#999; padding-bottom:15px; line-height:23px;">
  310. 注:<br>
  311. 1、基本数据:线索是根据信息录入的报名认时间统计。<br>
  312. 2、基本数据:加微是根据信息录入的时报名时间统计。<br>
  313. 3、基本数据:见面到访是根据首次洽谈的时间统计。<br>
  314. 4、基本数据:预定合同是根据定金时间统计,和报名、见面到访时间无关。<br>
  315. 5、基本数据:施工合同是根据合同时间统计,和报名、见面到访时间无关。<br>
  316. 6、注销:线索是根据变更线索无效的默认时间统计,和线索报名无关。<br>
  317. 7、注销:见面到访是根据首次洽谈时间统计,和线索报名时间无关。
  318. </div>
  319. </div>
  320. <div id="loading-mask">
  321. <div><img src="__STATIC__/img/large-loading.gif" />
  322. <p>...加载中...</p>
  323. </div>
  324. </div>
  325. </body>
  326. <script src="__LAYUI__/layui/layui.js"></script>
  327. {/block}{block name="js"}
  328. <script type="text/html" id="designer_name">
  329. {{# if(d.designer){ }}
  330. <span>{{d.designer.name}}</span>
  331. {{# }else{ }}
  332. <span style="color: #cccccc;">无</span>
  333. {{# } }}
  334. </script>
  335. <script type="text/javascript">
  336. var reload = null, resizefun = null;
  337. layui.config({
  338. base: '__LAYUI__/',
  339. urlbase: '/sys'
  340. }).extend({
  341. index: 'lib/index' //主入口模块
  342. }).use(['table', 'laydate'], function () {
  343. var table = layui.table, laydate = layui.laydate,
  344. $ = layui.$;
  345. let date=new Date();
  346. let year=date.getFullYear();
  347. let month = date.getMonth()*1+1;
  348. let time='', validtype='',source_id='',org_id='';
  349. laydate.render({
  350. elem: '#nowyear' //指定元素
  351. , type: 'date'
  352. , range: '到'
  353. , trigger: 'click'//呼出事件改成click
  354. , max:0
  355. });
  356. $('.nowyearbtn').click(function () {
  357. let date = new Date();
  358. let year = date.getFullYear();
  359. time = year + '-1-1' + ' 到 ' + year+'-12-31';
  360. source_id=$('#source_id').val();
  361. validtype = $('#wuxiao').val();
  362. org_id=$('#org_ids').val();
  363. laydate.render({
  364. elem: '#nowyear1'
  365. , type: 'date'
  366. , range: '到'
  367. , trigger: 'click'//呼出事件改成click
  368. , value: time
  369. , max:0
  370. });
  371. $('.wdatepicker2').hide();
  372. $('.wdatepicker').show();
  373. $('.tablemsgbox').show();
  374. dailyfun(time);
  375. })
  376. $('.lastmonth').click(function () {
  377. source_id=$('#source_id').val();
  378. org_id=$('#org_ids').val();
  379. validtype = $('#wuxiao').val();
  380. const getLastMonthLast = () => {
  381. const date = new Date()
  382. // 获取上个月的最后一天是几号day
  383. const day = new Date(date.getFullYear(), date.getMonth(), 0).getDate()
  384. const enddate = new Date(date.getFullYear(), date.getMonth() - 1, day)
  385. return enddate
  386. }
  387. $('.wdatefast').show();
  388. time = getPreMonth()+'-1 到 '+ getPreMonth()+'-'+ getLastMonthLast().getDate();
  389. laydate.render({
  390. elem: '#nowyear1' //指定元素
  391. , type: 'date'
  392. , range: '到'
  393. , trigger: 'click'//呼出事件改成click
  394. , value: time
  395. , max:0
  396. });
  397. $('.wdatepicker2').hide();
  398. $('.wdatepicker').show();
  399. $('.tablemsgbox').show();
  400. dailyfun(time);
  401. })
  402. $('.nowmonth').click(function () {
  403. source_id=$('#source_id').val();
  404. org_id=$('#org_ids').val();
  405. validtype = $('#wuxiao').val();
  406. let date = new Date();
  407. let year = date.getFullYear();
  408. let month = date.getMonth() * 1 + 1;
  409. time = year+'-'+ month+'-1'+ ' 到 ' + getLastDay();
  410. laydate.render({
  411. elem: '#nowyear1' //指定元素
  412. , type: 'date'
  413. , range: '到'
  414. , value: time
  415. , trigger: 'click'//呼出事件改成click
  416. , max:0
  417. });
  418. $('.wdatepicker2').hide();
  419. $('.wdatepicker').show();
  420. $('.tablemsgbox').show();
  421. dailyfun(time);
  422. })
  423. $("#searchbtn1").click(function () {
  424. if (!$('#nowyear1').val()) {
  425. alert('提示:请务必选择统计时间')
  426. return false;
  427. }
  428. validtype= $('#valid').val();
  429. time = $('#nowyear1').val();
  430. source_id=$('#source_id1').val();
  431. org_id=$('#org_id').val();
  432. $('.month').html(time.split('-')[1]);
  433. laydate.render({
  434. elem: '#nowyear1' //指定元素
  435. , type: 'date'
  436. , range: '到'
  437. , value: time
  438. , trigger: 'click'//呼出事件改成click
  439. , max:0
  440. });
  441. $('.wdatepicker2').hide();
  442. $('.wdatepicker').show();
  443. $('.tablemsgbox').show();
  444. dailyfun(time);
  445. })
  446. $('#searchbtn').click(function(){
  447. if(!$('#nowyear').val()){
  448. alert('提示:请务必选择统计时间')
  449. return false;
  450. }
  451. validtype = $('#wuxiao').val();
  452. time= $('#nowyear').val();
  453. source_id=$('#source_id').val();
  454. org_id=$('#org_ids').val();
  455. laydate.render({
  456. elem: '#nowyear1' //指定元素
  457. , type: 'date'
  458. , range: '到'
  459. , value: time
  460. , trigger: 'click'//呼出事件改成click
  461. , max:0
  462. });
  463. $('.wdatepicker2').hide();
  464. $('.wdatepicker').show();
  465. $('.tablemsgbox').show();
  466. dailyfun(time);
  467. })
  468. resizefun = function () {
  469. dailyfun(time);
  470. };
  471. reload = function () {
  472. dailyfun(time);
  473. };
  474. function dailyfun(time) {
  475. $('#loading-mask').show();
  476. $.ajax({
  477. url: '{:url("community/designer_report")}'
  478. , data: {
  479. date: time,
  480. source_id:source_id,
  481. org_id:org_id
  482. }
  483. , type: 'post'
  484. , success: function (res) {
  485. if (res.code == 0) {
  486. let str="";
  487. if(!validtype){
  488. for(let j=0;j<$('.validnumbox').length;j++){
  489. $($('.validnumbox')[j]).hide();
  490. }
  491. }else{
  492. for (let j = 0; j < $('.validnumbox').length; j++) {
  493. $($('.validnumbox')[j]).show();
  494. }
  495. }
  496. for(let i in res.data){
  497. if(res.data[i].name!='求和'){
  498. str+=`<tr>
  499. <td>${res.data[i].name}</td>
  500. <td title="线索量" class="${res.data[i].clue_cont ? '' : 'baobaonum1'}">${ res.data[i].clue_cont}</td>
  501. <td title="有效线索量" class="${res.data[i].valid_cont ? '' : 'baobaonum1'}">${res.data[i].valid_cont}</td>
  502. <td title="有效率" class="${res.data[i].valid_percen ? '' : 'baobaonum1'}">${res.data[i].valid_percen}%</td>
  503. <td title="待确认" class="${res.data[i].dai_confirmed ? '' : 'baobaonum1'}">${res.data[i].dai_confirmed}</td>
  504. <td title="见面量" class="${res.data[i].meet_cont ? '' : 'baobaonum1'}">${res.data[i].meet_cont}</td>
  505. <td title="见面率" class="${res.data[i].meet_percen ? '' : 'baobaonum1'}">${res.data[i].meet_percen}%</td>
  506. <td title="预定合同量" class="${res.data[i].deposit_cont ?'':'baobaonum1'}">${res.data[i].deposit_cont}</td>
  507. <td title="成单率" class="${res.data[i].deposit_percen ? '' : 'baobaonum1'}">${res.data[i].deposit_percen}%</td>
  508. <td title="施工合同量" class="${res.data[i].sign_cont ?'':'baobaonum1'}">${res.data[i].sign_cont}</td>
  509. <td title="业绩总额" class="${res.data[i].basic_money ?'':'baobaonum1'}">${res.data[i].basic_money}</td>
  510. <td title="无效线索注销量" class="validnumbox ${res.data[i].invalid_no ?'':'baobaonum1'}">${res.data[i].invalid_no}</td>
  511. <td title="有效线索注销量" class="validnumbox ${res.data[i].invalid_yes ?'':'baobaonum1'}">${res.data[i].invalid_yes}</td>
  512. <td title="见面注销量" class="validnumbox ${res.data[i].invalid_meet ?'':'baobaonum1'}">${res.data[i].invalid_meet}</td>
  513. <td title="定金注销量" class="validnumbox ${res.data[i].invalid_deposit ?'':'baobaonum1'}">${res.data[i].invalid_deposit}</td>
  514. </tr>`;
  515. }else{
  516. str+=`<tr id="totalRow">
  517. <td>${res.data[i].name}</td>
  518. <td class="sum_xiansuo ${res.data[i].clue_cont ? '' : 'baobaonum1'}">${res.data[i].clue_cont}</td>
  519. <td class="sum_youxiao ${res.data[i].valid_cont ? '' : 'baobaonum1'}">${res.data[i].valid_cont}</td>
  520. <td class="sum_youxiao_percent ${res.data[i].valid_percen ? '' : 'baobaonum1'}">${res.data[i].valid_percen}%</td>
  521. <td class="sum_youxiao_percent ${res.data[i].dai_confirmed ? '' : 'baobaonum1'}">${res.data[i].dai_confirmed}</td>
  522. <td class="sum_daofang ${res.data[i].meet_cont ? '' : 'baobaonum1'}">${res.data[i].meet_cont}</td>
  523. <td class="sum_daofanglv_percent ${res.data[i].meet_percen ? '' : 'baobaonum1'}">${res.data[i].meet_percen}%</td>
  524. <td class="${res.data[i].deposit_cont ?'':'baobaonum1'}">${res.data[i].deposit_cont}</td>
  525. <td class="sum_youxiao_percent ${res.data[i].deposit_percen ? '' : 'baobaonum1'}">${res.data[i].deposit_percen}%</td>
  526. <td class="${res.data[i].sign_cont ?'':'baobaonum1'}">${res.data[i].sign_cont}</td>
  527. <td class="${res.data[i].basic_money ?'':'baobaonum1'}">${res.data[i].basic_money}</td>
  528. <td class="validnumbox ${res.data[i].invalid_no?'':'baobaonum1'}">${res.data[i].invalid_no}</td>
  529. <td class="validnumbox ${res.data[i].invalid_yes ?'':'baobaonum1'}">${res.data[i].invalid_yes}</td>
  530. <td class="validnumbox ${res.data[i].invalid_meet ?'':'baobaonum1'}">${res.data[i].invalid_meet}</td>
  531. <td class="validnumbox ${res.data[i].invalid_deposit ?'':'baobaonum1'}">${res.data[i].invalid_deposit}</td>
  532. </tr>`;
  533. }
  534. }
  535. $('.tbodybox').html(str);
  536. if (!validtype) {
  537. for (let j = 0; j < $('.validnumbox').length; j++) {
  538. $($('.validnumbox')[j]).hide();
  539. }
  540. } else {
  541. for (let j = 0; j < $('.validnumbox').length; j++) {
  542. $($('.validnumbox')[j]).show();
  543. }
  544. }
  545. $(".maintable td").mouseover(function () {
  546. if ($(this).text() == 0 || $(this).text() > 500) { $(this).html($(this).text()) }
  547. if ($(this).children("a").length > 0) { $(this).addClass("ablock2"); }
  548. }).mouseout(function () { $(this).removeClass("ablock2"); });
  549. $('.divlayer').on('click', function () {
  550. let date= time;
  551. layer.open({
  552. type: 2,
  553. title: '信息',
  554. shadeClose: true,
  555. scrollbar: false,
  556. shade: 0.8,
  557. area: ['99%', '96%'],
  558. content: "{:url('community/account_detail')}?date="+ date +'&state='+ $(this).attr('text'),
  559. });
  560. });
  561. }else if(res.code == 403){
  562. $(".exitbtn").trigger("click");
  563. } else {
  564. alert(res.msg)
  565. }
  566. $('#loading-mask').hide();
  567. }
  568. });
  569. }
  570. })
  571. // 本月最后一天
  572. function getLastDay() {
  573. var y = new Date().getFullYear(); //获取年份
  574. var m = new Date().getMonth() + 1; //获取月份
  575. var d = new Date(y, m, 0).getDate(); //获取当月最后一日
  576. m = m < 10 ? '0' + m : m; //月份补 0
  577. d = d < 10 ? '0' + d : d; //日数补 0
  578. return [y, m, d].join("-")
  579. }
  580. function getNowMonth() {
  581. var date = new Date();
  582. var year = date.getFullYear();
  583. var month = date.getMonth() + 1;
  584. month = month > 9 ? month : "0" + month;
  585. var nowMonth = year + "-" + month;
  586. return nowMonth;
  587. }
  588. /**获取上一个月 */
  589. function getPreMonth() {
  590. var arr = getNowMonth().split("-");
  591. var year = arr[0]; //获取当前日期的年份
  592. var month = arr[1]; //获取当前日期的月份
  593. var year2 = year;
  594. var month2 = parseInt(month) - 1;
  595. if (month2 == 0) {
  596. //1月的上一月是前一年的12月
  597. year2 = parseInt(year2) - 1;
  598. month2 = 12;
  599. }
  600. var preMonth = year2 + "-" + month2;
  601. return preMonth;
  602. }
  603. </script>
  604. {/block}