w-salary.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view>
  3. <view class="time_box">
  4. <view class="time">
  5. <picker mode="date" :value="date" fields="month" :start="startDate" :end="endDate" @change="bindDateChange">
  6. <view>{{date}}</view>
  7. </picker>
  8. </view>
  9. <view class="icon">
  10. <uni-icons type="arrowdown" color="#fff"></uni-icons>
  11. </view>
  12. </view>
  13. <view class="money">
  14. <text>9819.38</text>
  15. </view>
  16. <view class="section">
  17. <view class="title">
  18. <view class="name">工资明细</view>
  19. </view>
  20. <view class="list">
  21. <view class="item">
  22. <view class="label">姓名</view>
  23. <view class="info">测试用户</view>
  24. </view>
  25. <view class="item">
  26. <view class="label">出勤工日</view>
  27. <view class="info">21.00</view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="section">
  32. <view class="title">
  33. <view class="name">收入统计</view>
  34. </view>
  35. <view class="content">
  36. <canvas style="width: 620rpx; height: 600rpx;" canvas-id="canvasLineA" id="canvasLineA" class="charts" @touchstart="touchLineA"></canvas>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import uCharts from '@/components/u-charts/u-charts.js';
  43. var _self;
  44. var canvaLineA = null;
  45. export default {
  46. data() {
  47. const currentDate = this.getDate({
  48. format: true
  49. })
  50. return {
  51. date: currentDate,
  52. cWidth: '',
  53. cHeight: '',
  54. pixelRatio: 1,
  55. };
  56. },
  57. onLoad() {
  58. _self = this;
  59. this.cWidth = uni.upx2px(620);
  60. this.cHeight = uni.upx2px(600);
  61. this.getServerData();
  62. },
  63. computed: {
  64. startDate() {
  65. return this.getDate('start');
  66. },
  67. endDate() {
  68. return this.getDate('end');
  69. }
  70. },
  71. methods: {
  72. bindDateChange: function(e) {
  73. this.date = e.target.value
  74. console.log(this.date)
  75. },
  76. getDate(type) {
  77. const date = new Date();
  78. let year = date.getFullYear();
  79. let month = date.getMonth() + 1;
  80. if (type === 'start') {
  81. year = year - 60;
  82. } else if (type === 'end') {
  83. year = year + 2;
  84. }
  85. month = month > 9 ? month : '0' + month;
  86. return `${year}-${month}`;
  87. },
  88. // 收入统计
  89. getServerData() {
  90. let LineA={
  91. categories: ['1', '2', '3', '4', '5', '6','7','8','9','10','11','12'],
  92. series: [{
  93. name: '',
  94. data: [100, 80, 95, 150, 112, 132,100, 80, 95, 150, 112, 132]
  95. }]
  96. };
  97. _self.showLineA("canvasLineA", LineA);
  98. },
  99. showLineA(canvasId, chartData) {
  100. canvaLineA = new uCharts({
  101. $this: _self,
  102. canvasId: canvasId,
  103. type: 'line',
  104. fontSize: 11,
  105. legend: {
  106. show: false
  107. },
  108. dataLabel: false,
  109. dataPointShape: true,
  110. background: '#FFFFFF',
  111. pixelRatio: _self.pixelRatio,
  112. categories: chartData.categories,
  113. series: chartData.series,
  114. animation: true,
  115. xAxis: {
  116. type: 'grid',
  117. gridColor: '#fff',
  118. gridType: 'dash',
  119. dashLength: 8
  120. },
  121. yAxis: {
  122. gridType: 'dash',
  123. gridColor: '#CCCCCC',
  124. dashLength: 8,
  125. splitNumber: 5,
  126. min: 10,
  127. max: 180,
  128. format: (val) => {
  129. return val.toFixed(0) + '元'
  130. }
  131. },
  132. width: _self.cWidth * _self.pixelRatio,
  133. height: _self.cHeight * _self.pixelRatio,
  134. extra: {
  135. line: {
  136. type: 'straight'
  137. }
  138. }
  139. });
  140. },
  141. touchLineA(e) {
  142. canvaLineA.showToolTip(e, {
  143. format: function(item, category) {
  144. return category + ' ' + item.name + ':' + item.data
  145. }
  146. });
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="scss">
  152. page {
  153. box-sizing: border-box;
  154. padding: 30rpx 25rpx;
  155. background-color: #009FE8;
  156. }
  157. .time_box {
  158. margin: 0 auto;
  159. width: 302rpx;
  160. height: 72rpx;
  161. border-radius: 36rpx;
  162. border: 4rpx solid #FFFFFF;
  163. display: flex;
  164. justify-content: center;
  165. align-items: center;
  166. position: relative;
  167. .time {
  168. font-size: 33rpx;
  169. font-family: PingFangSC-Medium, PingFang SC;
  170. font-weight: 500;
  171. color: #FFFFFF;
  172. }
  173. .icon {
  174. position: absolute;
  175. right: 20rpx;
  176. }
  177. }
  178. .money {
  179. margin: 25rpx;
  180. text-align: center;
  181. text {
  182. font-size: 62rpx;
  183. font-family: PingFangSC-Medium, PingFang SC;
  184. font-weight: 500;
  185. color: #FFFFFF;
  186. line-height: 88rpx;
  187. }
  188. }
  189. .section {
  190. margin-top: 12rpx;
  191. width: 700rpx;
  192. background: #FFFFFF;
  193. box-shadow: 0px 3rpx 29rpx 0px rgba(59, 74, 116, 0.14);
  194. border-radius: 10rpx;
  195. box-sizing: border-box;
  196. padding: 40rpx;
  197. .title {
  198. border-left: 8rpx solid #009fe8;
  199. .name {
  200. margin-left: 20rpx;
  201. font-size: 29rpx;
  202. font-family: PingFangSC-Medium, PingFang SC;
  203. font-weight: 500;
  204. color: #2C3E50;
  205. line-height: 42rpx;
  206. }
  207. }
  208. .list {
  209. margin-top: 20rpx;
  210. .item {
  211. height: 80rpx;
  212. border-bottom: 1rpx solid #e0e1e2;
  213. display: flex;
  214. align-items: center;
  215. justify-content: space-between;
  216. .label {
  217. font-size: 29rpx;
  218. font-family: PingFangSC-Regular, PingFang SC;
  219. font-weight: 400;
  220. color: #6C6F74;
  221. }
  222. .info {
  223. font-size: 29rpx;
  224. font-family: PingFangSC-Regular, PingFang SC;
  225. font-weight: 400;
  226. color: #6C6F74;
  227. }
  228. }
  229. }
  230. .content {
  231. width: 620rpx;
  232. padding: 20rpx 0;
  233. }
  234. }
  235. </style>