lj-win-report.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. <!--参数:
  2. title-标题 string
  3. ifUseTime-是否使用时间 boolean
  4. beforeDate-开始时间 string
  5. afterDate-结束时间 string
  6. rptype --- 0汇总表 1明细表 number
  7. -->
  8. <template>
  9. <lj-win-common :title="title" :closeWinHandler="closeWinHandler" right-drawer-title="搜索" :rightDrawerInitOpen="rightDrawerInitOpen"
  10. ref="baseWin">
  11. <template slot="header_right">
  12. <slot name="header_right">
  13. <mu-button v-if="showFilter" icon @click="openRightDrawer">
  14. <i class="iconfont icon-filter"></i>
  15. </mu-button>
  16. </slot>
  17. </template>
  18. <div slot="body" style="background-color: #ffffff;padding:0px 0px 10px 0px">
  19. <!-- 报表头部 -->
  20. <div v-if="rptype == 0">
  21. <div class="rpdate" v-if="ifUseTime" >
  22. <span style="font-size:18px" @click="handleClickDateSelect">
  23. <span>{{beforeDateTemp}}~</span>
  24. <span>{{afterDateTemp}}</span>
  25. <span style="font-size:15px">
  26. <svg class="icon" aria-hidden="true">
  27. <use xlink:href="#icon-xuanze1"></use>
  28. </svg>
  29. </span>
  30. </span>
  31. <span v-if="showday==0" class="rpdate_ch" @click="showThisYear">本年</span>
  32. <span v-if="showday==0" class="rpdate_ch" @click="showLastYear">上年</span>
  33. <!-- <span v-if="showday==1" class="rpdate_ch" @click="showThisMonth">本月</span>
  34. <span v-if="showday==1" class="rpdate_ch" @click="showLastMonth">上月</span> -->
  35. </div>
  36. </div>
  37. <!-- 报表明细头部 -->
  38. <div v-else>
  39. <div :class="colortop"></div>
  40. <div style="display: flex;">
  41. <div class="reportdetail_mx_title" :class="colortitle">{{title}}</div>
  42. <div class="reportdetail_mx_subtitle" v-if="ifUseTime" @click="handleClickDateSelect">
  43. <span>{{beforeDateTemp}} ~ {{afterDateTemp}}</span>
  44. <span icon><i class="iconfont icon-xiala2"></i></span>
  45. </div>
  46. </div>
  47. </div>
  48. <!-- 报表内容 -->
  49. <div>
  50. <slot name="content"></slot>
  51. </div>
  52. </div>
  53. <lj-query-list v-if="showFilter" slot="drawer_right" :query-fields="queryFields"
  54. :hard-parms="queryHardParms"
  55. :binding-parms="bindingParms"
  56. @on-query-submit="handleQuerySubmit"
  57. ref="queryList"/>
  58. </lj-win-common>
  59. </template>
  60. <script>
  61. import LjWinCommon from "components/lj-win-common";
  62. import LjCalendar from "components/lj-calendar";
  63. import LjQueryList from "components/lj-query-list";
  64. import {
  65. DatetimeView,
  66. Popup,
  67. PopupHeader
  68. } from 'vux'
  69. export default {
  70. name: "lj-win-report",
  71. components: {
  72. LjWinCommon,
  73. DatetimeView,
  74. Popup,
  75. PopupHeader,
  76. LjCalendar,
  77. LjQueryList
  78. },
  79. props: {
  80. //标题
  81. title: {
  82. type: String,
  83. required: true,
  84. default: "报表"
  85. },
  86. //报表类型; 0-普通报表 1-明细报表
  87. rptype: {
  88. type: Number,
  89. // required: true,
  90. default: 0
  91. },
  92. ifUseTime: {
  93. type: Boolean,
  94. default: false
  95. },
  96. // showFilter: {
  97. // type: Boolean,
  98. // default: false
  99. // },
  100. // 同lj-query-list的queryFields,设置后显示筛选按钮,点击弹出高级筛选框
  101. queryFields: {
  102. type: Array
  103. },
  104. // 同lj-query-list的hardParms
  105. queryHardParms: {
  106. type: Object
  107. },
  108. // 同lj-query-list的bindingParms
  109. bindingParms: {
  110. type: Object
  111. },
  112. rightDrawerInitOpen: {
  113. type: Boolean,
  114. default: false
  115. },
  116. beforeDate: {
  117. type: String,
  118. default: ""
  119. },
  120. afterDate: {
  121. type: String,
  122. default: ""
  123. },
  124. // 明细报表类型 1-红色、2-蓝色、3-绿色、4-紫色、5-金色、6-青色
  125. rpmxtype: {
  126. type: Number,
  127. default: 1
  128. },
  129. closeWinHandler: {
  130. type: Function,
  131. },
  132. // 用于读写用户习惯,此筛选条件对应的key
  133. habitKey: {
  134. type: String
  135. },
  136. //0精确到月 1精确到日
  137. showday: {
  138. type: Number,
  139. default: 0
  140. },
  141. },
  142. data() {
  143. return {
  144. beforeDateTemp: "",
  145. afterDateTemp: "",
  146. queryParams:{}
  147. }
  148. },
  149. created() {
  150. this.beforeDateTemp = this.beforeDate;
  151. this.afterDateTemp = this.afterDate;
  152. if (this.habitKey ) {
  153. let userhabit = $lj.getStorage("reportHabit");
  154. if (!userhabit) {
  155. userhabit = {};
  156. if (this.habitKey) {
  157. userhabit[this.habitKey] = {
  158. beforeDate: this.beforeDate,
  159. afterDate: this.afterDate,
  160. }
  161. $lj.setStorage("reportHabit", userhabit);
  162. }
  163. }
  164. }
  165. },
  166. methods: {
  167. openRightDrawer() {
  168. this.$refs.baseWin.openRightDrawer();
  169. },
  170. handleQuerySubmit(queryParams) {
  171. this.queryParams = queryParams;
  172. this.$refs.baseWin.closeRightDrawer();
  173. this.refresh();
  174. },
  175. refresh(){
  176. var time = {
  177. beforeDate: this.beforeDateTemp,
  178. afterDate: this.afterDateTemp
  179. };
  180. time = Object.assign(this.queryParams,time);
  181. this.$emit('refresh',time);
  182. },
  183. handleClickDateSelect() {
  184. let self = this;
  185. // if(self.showday == 1){
  186. // return;
  187. // }
  188. $lj.removeEventListener("rp_date_select");
  189. $lj.addEventListener("rp_date_select", function (ret) {
  190. if (ret.value) {
  191. self.beforeDateTemp = ret.value.begindate;
  192. self.afterDateTemp = ret.value.enddate;
  193. if (self.habitKey) {
  194. let userhabit = $lj.getStorage("reportHabit");
  195. userhabit[self.habitKey] = {
  196. beforeDate: self.beforeDateTemp,
  197. afterDate: self.afterDateTemp,
  198. }
  199. $lj.setStorage("reportHabit", userhabit);
  200. }
  201. self.refresh();
  202. }
  203. });
  204. $lj.openWin('rp-date-select', {
  205. begindate: this.beforeDateTemp,
  206. enddate: this.afterDateTemp,
  207. mode:this.showday,
  208. })
  209. },
  210. showThisYear() {
  211. var myDate = new Date();
  212. var time = {};
  213. time.beforeDate = myDate.getFullYear() + "-" + 1 + '-' + 1;
  214. time.afterDate = myDate.getFullYear() + "-" + 12 + "-" + 31;
  215. time.beforeDate = $lj.dateformat(time.beforeDate, 'yyyy-MM');
  216. time.afterDate = $lj.dateformat(time.afterDate, 'yyyy-MM');
  217. this.beforeDateTemp = time.beforeDate;
  218. this.afterDateTemp = time.afterDate;
  219. if (this.habitKey) {
  220. let userhabit = $lj.getStorage("reportHabit");
  221. userhabit[this.habitKey] = {
  222. beforeDate: this.beforeDateTemp,
  223. afterDate: this.afterDateTemp,
  224. }
  225. $lj.setStorage("reportHabit", userhabit);
  226. }
  227. // this.$refs.beforeDate.render();
  228. // this.$refs.afterDate.render();
  229. this.refresh();
  230. },
  231. showLastYear() {
  232. var myDate = new Date();
  233. var time = {};
  234. time.beforeDate = (myDate.getFullYear()-1) + "-" + 1 + '-' + 1;
  235. time.afterDate = (myDate.getFullYear()-1) + "-" + 12 + "-" + 31;
  236. time.beforeDate = $lj.dateformat(time.beforeDate, 'yyyy-MM');
  237. time.afterDate = $lj.dateformat(time.afterDate, 'yyyy-MM');
  238. this.beforeDateTemp = time.beforeDate;
  239. this.afterDateTemp = time.afterDate;
  240. if (this.habitKey) {
  241. let userhabit = $lj.getStorage("reportHabit");
  242. userhabit[this.habitKey] = {
  243. beforeDate: this.beforeDateTemp,
  244. afterDate: this.afterDateTemp,
  245. }
  246. $lj.setStorage("reportHabit", userhabit);
  247. }
  248. // this.$refs.beforeDate.render();
  249. // this.$refs.afterDate.render();
  250. this.refresh();
  251. },
  252. showThisMonth(){
  253. var myDate = new Date();
  254. var time = {};
  255. var nowMonth = myDate.getMonth(); //当前月
  256. var LastMonth = myDate.getMonth() - 1; //上月
  257. var nowYear = myDate.getFullYear(); //当前年
  258. time.beforeDate = new Date(nowYear, nowMonth, 1);
  259. time.afterDate = new Date(nowYear, nowMonth + 1, 0);
  260. time.beforeDate = $lj.dateformat(time.beforeDate, 'yyyy-MM-dd');
  261. time.afterDate = $lj.dateformat(time.afterDate, 'yyyy-MM-dd');
  262. this.beforeDateTemp = time.beforeDate;
  263. this.afterDateTemp = time.afterDate;
  264. if (this.habitKey) {
  265. let userhabit = $lj.getStorage("reportHabit");
  266. userhabit[this.habitKey] = {
  267. beforeDate: this.beforeDateTemp,
  268. afterDate: this.afterDateTemp,
  269. }
  270. $lj.setStorage("reportHabit", userhabit);
  271. }
  272. this.refresh();
  273. },
  274. showLastMonth(){
  275. var myDate = new Date();
  276. var time = {};
  277. var nowMonth = myDate.getMonth(); //当前月
  278. var LastMonth = myDate.getMonth() - 1; //上月
  279. var nowYear = myDate.getFullYear(); //当前年
  280. time.beforeDate = new Date(nowYear, LastMonth, 1);
  281. time.afterDate = new Date(nowYear, LastMonth + 1, 0);
  282. time.beforeDate = $lj.dateformat(time.beforeDate, 'yyyy-MM-dd');
  283. time.afterDate = $lj.dateformat(time.afterDate, 'yyyy-MM-dd');
  284. this.beforeDateTemp = time.beforeDate;
  285. this.afterDateTemp = time.afterDate;
  286. if (this.habitKey) {
  287. let userhabit = $lj.getStorage("reportHabit");
  288. userhabit[this.habitKey] = {
  289. beforeDate: this.beforeDateTemp,
  290. afterDate: this.afterDateTemp,
  291. }
  292. $lj.setStorage("reportHabit", userhabit);
  293. }
  294. this.refresh();
  295. },
  296. refreshCurDate(){
  297. }
  298. },
  299. computed: {
  300. showFilter() {
  301. return this.queryFields && this.queryFields.length > 0;
  302. },
  303. colortop: function () {
  304. return {
  305. kindred: this.rpmxtype == 1,
  306. kindblue: this.rpmxtype == 2,
  307. kindgreen: this.rpmxtype == 3,
  308. kindpurple: this.rpmxtype == 4,
  309. kindgold: this.rpmxtype == 5,
  310. kindcyan: this.rpmxtype == 6,
  311. }
  312. },
  313. colortitle: function () {
  314. return {
  315. bgred: this.rpmxtype == 1,
  316. bgblue: this.rpmxtype == 2,
  317. bggreen: this.rpmxtype == 3,
  318. bgpurple: this.rpmxtype == 4,
  319. bggold: this.rpmxtype == 5,
  320. bgcyan: this.rpmxtype == 6,
  321. };
  322. }
  323. }
  324. }
  325. </script>
  326. <style>
  327. .reportcom-header-wap {
  328. width: 100%;
  329. height: 150px;
  330. overflow: hidden;
  331. }
  332. .reportcom-header {
  333. width: 120%;
  334. height: 115px;
  335. background-color: #fd9153;
  336. border-top-left-radius: 0px;
  337. border-top-right-radius: 0px;
  338. border-bottom-right-radius: 50%;
  339. border-bottom-left-radius: 50%;
  340. position: relative;
  341. left: -10%;
  342. padding: 10px 0;
  343. margin-bottom: 10px;
  344. z-index: 9998;
  345. }
  346. .reportcom-header-sub {
  347. width: 130%;
  348. height: 125px;
  349. background-color: #ffba92;
  350. border-top-left-radius: 0px;
  351. border-top-right-radius: 0px;
  352. border-bottom-right-radius: 50%;
  353. border-bottom-left-radius: 50%;
  354. position: relative;
  355. top: -120px;
  356. left: -23%;
  357. padding: 10px 0;
  358. margin-bottom: 10px;
  359. z-index: 9997;
  360. }
  361. .reportcom-header-sub-two {
  362. width: 140%;
  363. height: 125px;
  364. background-color: #fddecc;
  365. border-top-left-radius: 0px;
  366. border-top-right-radius: 0px;
  367. border-bottom-right-radius: 50%;
  368. border-bottom-left-radius: 50%;
  369. position: relative;
  370. top: -240px;
  371. left: -35%;
  372. padding: 10px 0;
  373. margin-bottom: 10px;
  374. z-index: 9996;
  375. }
  376. .reportcom-header-title {
  377. color: #ffffff;
  378. font-size: 20px;
  379. margin-left: 10%;
  380. }
  381. .reportdetail_mx_title {
  382. color: white;
  383. font-size: 15px;
  384. font-weight: bold;
  385. padding: 3px 8px;
  386. margin-left: 20px;
  387. border-bottom-left-radius: 8px;
  388. border-bottom-right-radius: 8px;
  389. }
  390. .reportdetail_mx_subtitle {
  391. position: absolute;
  392. right: 10px;
  393. padding: 3px;
  394. font-size: 15px;
  395. font-weight: bold;
  396. line-height: 20px;
  397. color: grey;
  398. margin-top: 3px;
  399. }
  400. .rpdate_ch {
  401. margin-left: 10px;
  402. padding: 8px 15px;
  403. color: #ffffff;
  404. font-size: 12px;
  405. background-color: #6495ed;
  406. border-radius: 10px;
  407. }
  408. .kindblue {
  409. border-top: 8px solid #0195da;
  410. }
  411. .kindgreen {
  412. border-top: 8px solid #88b04b;
  413. }
  414. .kindred {
  415. border-top: 8px solid #ff6f61;
  416. }
  417. .kindpurple {
  418. border-top: 8px solid #ba68c8;
  419. }
  420. .kindgold {
  421. border-top: 8px solid #FFD700;
  422. }
  423. .kindcyan {
  424. border-top: 8px solid #40E0D0;
  425. }
  426. .bgblue {
  427. background-color: rgb(1, 149, 218);
  428. }
  429. .bggreen {
  430. background-color: rgb(136, 176, 75);
  431. }
  432. .bgred {
  433. background-color: rgb(255, 111, 97)
  434. }
  435. .bgpurple {
  436. background-color: #ba68c8
  437. }
  438. .bggold {
  439. background-color: #FFD700
  440. }
  441. .bgcyan {
  442. background-color: #40E0D0
  443. }
  444. .rpdate {
  445. padding: 15px 8px;
  446. width: 100%;
  447. background-color: #f6f6f6;
  448. }
  449. </style>