Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

TimeAll.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <div class="page_timeAll">
  3. <div class="cell clearfix">
  4. <el-select
  5. v-model="listQuery.value"
  6. placeholder="请选择"
  7. style="width:120px;margin-right:20px"
  8. @change="selectChange"
  9. >
  10. <el-option
  11. v-for="item in options"
  12. :key="item.value"
  13. :label="item.label"
  14. :value="item.value"
  15. ></el-option>
  16. </el-select>
  17. <label class="title">
  18. <span class="name">日期查询</span> :
  19. </label>
  20. <el-date-picker
  21. v-model="listQuery.start_time"
  22. prefix-icon="el-icon-date"
  23. @change="changeTime"
  24. :editable="false"
  25. style="width: 196px;"
  26. type="date"
  27. placeholder="选择日期时间"
  28. align="right"
  29. format="yyyy-MM-dd"
  30. value-format="yyyy-MM-dd"
  31. :picker-options="pickerOptions"
  32. ></el-date-picker>
  33. <span class>-</span>
  34. <el-date-picker
  35. v-model="listQuery.end_time"
  36. prefix-icon="el-icon-date"
  37. @change="changeEndTime"
  38. :editable="false"
  39. style="width: 196px;"
  40. type="date"
  41. placeholder="选择日期时间"
  42. align="right"
  43. format="yyyy-MM-dd"
  44. value-format="yyyy-MM-dd"
  45. :picker-options="pickerOptions"
  46. ></el-date-picker>
  47. </div>
  48. <div class="tableTitle">统计图</div>
  49. <div>
  50. <line-chart :options="chart"></line-chart>
  51. </div>
  52. <div class="tableTitle">统计表</div>
  53. <div>
  54. <el-table :data="tableData" border style="width: 100%" :row-style="{ color: '#303133' }" :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}">
  55. <el-table-column
  56. fixed
  57. label="日期"
  58. width="100"
  59. property="date"
  60. align="center"
  61. ></el-table-column>
  62. <el-table-column
  63. :label="modeItem.name"
  64. property="number"
  65. align="center"
  66. min-width="100"
  67. v-for="(modeItem, index) in activeModes"
  68. :key="index"
  69. >
  70. <template slot-scope="scope">
  71. {{ scope.row.data[modeItem.id].number ? scope.row.data[modeItem.id].number : "" }}
  72. </template>
  73. </el-table-column>
  74. <el-table-column
  75. fixed="right"
  76. label="总次数"
  77. width="80"
  78. property="total"
  79. align="center"
  80. ></el-table-column>
  81. </el-table>
  82. <el-pagination
  83. align="right"
  84. @size-change="handleSizeChange"
  85. @current-change="handleCurrentChange"
  86. :current-page="listQuery.page"
  87. :page-sizes="[20, 40, 60, 80,100]"
  88. :page-size="10"
  89. background
  90. style="margin-top:20px;"
  91. layout="total, sizes, prev, pager, next, jumper"
  92. :total="total"
  93. ></el-pagination>
  94. </div>
  95. </div>
  96. </template>
  97. <script>
  98. import echarts from "echarts";
  99. import LineChart from "../../components/LineChart";
  100. import {geStatistics} from "@/api/common/common"
  101. export default {
  102. components: {
  103. LineChart
  104. },
  105. data() {
  106. return {
  107. options: [
  108. {
  109. value: 0,
  110. label: "全部"
  111. },
  112. {
  113. value: 1,
  114. label: "留治"
  115. },
  116. {
  117. value: 2,
  118. label: "转出"
  119. },
  120. ],
  121. chart: {
  122. tooltip: {},
  123. legend: {
  124. data: ["次"],
  125. left: 0
  126. },
  127. xAxis: {
  128. data: []
  129. },
  130. yAxis: {
  131. axisLabel: {
  132. formatter: "{value} %"
  133. },
  134. show: false
  135. },
  136. series: [
  137. {
  138. name: "次",
  139. type: "bar",
  140. data: [],
  141. barWidth: 30,
  142. label: {
  143. normal: {
  144. show: true,
  145. position: "top",
  146. formatter: "{c}次"
  147. }
  148. },
  149. //配置样式
  150. itemStyle: {
  151. //通常情况下:
  152. //每个柱子的颜色即为colorList数组里的每一项,如果柱子数目多于colorList的长度,则柱子颜色循环使用该数组
  153. normal: {
  154. color: function(params) {
  155. //我这边就两个柱子,大体就两个柱子颜色渐变,所以数组只有两个值,多个颜色就多个值
  156. var colorList = [
  157. ["#A9E0F3", "#9FBDFC"],
  158. ["#A9E0F3", "#9FBDFC"],
  159. ["#A9E0F3", "#9FBDFC"],
  160. ["#FFD7C0", "#FF9994"],
  161. ["#FFD7C0", "#FF9994"],
  162. ["#FFD7C0", "#FF9994"],
  163. ["#D7C3FD", "#B3A8F7"],
  164. ["#D7C3FD", "#B3A8F7"],
  165. ["#D7C3FD", "#B3A8F7"]
  166. ];
  167. var index = params.dataIndex;
  168. if (params.dataIndex >= colorList.length) {
  169. index = params.dataIndex % colorList.length;
  170. }
  171. return new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  172. { offset: 0, color: colorList[index][0] },
  173. // { offset: 0.5, color: colorList[index][1] },
  174. { offset: 1, color: colorList[index][1] }
  175. ]);
  176. },
  177. barBorderRadius: [5, 5, 0, 0] //柱状角成椭圆形
  178. },
  179. //鼠标悬停时:
  180. // emphasis: {
  181. // shadowBlur: 10,
  182. // shadowOffsetX: 0,
  183. // shadowColor: "rgba(0, 0, 0, 0.5)"
  184. // }
  185. }
  186. }
  187. ]
  188. },
  189. modeOptions:[],
  190. total:0,
  191. listQuery: {
  192. start_time: "",
  193. end_time: "",
  194. page: 1,
  195. limit: 20,
  196. value: 0,
  197. mode_id:"",
  198. },
  199. tableData:[],
  200. modesData: {
  201. xAxis: [],
  202. series: []
  203. },
  204. pickerOptions: {
  205. disabledDate(time) {
  206. let threeMonths = new Date(new Date().setFullYear(new Date().getFullYear()-1)).getTime() - 24 * 3600 * 1000;
  207. return time.getTime() > Date.now() || time.getTime() < threeMonths;;
  208. }
  209. },
  210. };
  211. },
  212. methods: {
  213. changeTime(val) {
  214. var time = this.getTimestamp(val) - this.getTimestamp(this.listQuery.end_time);
  215. if (time > 0) {
  216. this.$message.error("结束时间不能小于开始时间");
  217. this.listQuery.start_time = "";
  218. } else {
  219. this.geStatistics()
  220. }
  221. },
  222. changeEndTime(val) {
  223. var time =
  224. this.getTimestamp(val) - this.getTimestamp(this.listQuery.start_time);
  225. if (time < 0) {
  226. this.$message.error("结束时间不能小于开始时间");
  227. this.listQuery.end_time = "";
  228. } else {
  229. this.geStatistics()
  230. }
  231. },
  232. getTimestamp(time) {
  233. // 把时间日期转成时间戳
  234. return new Date(time).getTime() / 1000;
  235. },
  236. handleSizeChange(limit) {
  237. this.listQuery.limit = limit;
  238. this.geStatistics();
  239. },
  240. handleCurrentChange(page) {
  241. this.listQuery.page = page;
  242. this.geStatistics();
  243. },
  244. selectChange(val){
  245. this.listQuery.value =val
  246. this.geStatistics()
  247. },
  248. geStatistics(){
  249. this.modesData.series = []
  250. this.modesData.xAxis = []
  251. geStatistics(this.listQuery).then(response=>{
  252. if(response.data.state === 1){
  253. var dtd = response.data.data.statistics
  254. // console.log("dtd",dtd)
  255. var dd = {};
  256. for (const index in dtd) {
  257. if (!(dtd[index].date in dd)) {
  258. dd[dtd[index].date] = {};
  259. }
  260. if (!(dtd[index].mode_id in dd[dtd[index].date]) && dtd[index].mode_id != "0") {
  261. dd[dtd[index].date][dtd[index].mode_id] = dtd[index];
  262. }
  263. }
  264. console.log("ddd",dd)
  265. for (const key in dd) {
  266. var total = 0;
  267. for (const mkey in this.modeOptions) {
  268. if (mkey in dd[key]) {
  269. dd[key][mkey].mode = this.modeOptions[mkey].name;
  270. var number = parseInt(dd[key][mkey].number);
  271. if (isNaN(number) || number == 0) {
  272. dd[key][mkey].number = "";
  273. number = 0;
  274. }
  275. total += number;
  276. } else {
  277. dd[key][mkey] = {
  278. mode: this.modeOptions[mkey].name,
  279. mode_id: mkey,
  280. number: 0
  281. };
  282. }
  283. }
  284. this.tableData.push({ date: key, data: dd[key], total: total });
  285. }
  286. console.log("tabledata",this.tableData)
  287. var ttd = response.data.data.ttd
  288. // console.log("ttd",ttd)
  289. var modeMap = {};
  290. var batotal = 0;
  291. for (const index in ttd) {
  292. if (ttd[index].mode_id == "0") {
  293. continue;
  294. }
  295. modeMap[ttd[index].mode_id] = ttd[index];
  296. }
  297. // console.log(111,modeMap)
  298. for (const key in this.modeOptions) {
  299. this.modesData.xAxis.push(this.modeOptions[key].name);
  300. if (key in modeMap) {
  301. this.modesData.series.push(parseInt(modeMap[key].number));
  302. batotal += parseInt(modeMap[key].number);
  303. } else {
  304. this.modesData.series.push(0);
  305. }
  306. }
  307. this.chart.series[0].data = this.modesData.series
  308. this.chart.xAxis.data = this.modesData.xAxis
  309. // console.log(this.chart.series[0].data)
  310. // console.log(this.chart.xAxis.data)
  311. this.total = response.data.data.total
  312. // console.log("total",this.total)
  313. }
  314. })
  315. },
  316. },
  317. created(){
  318. this.modeOptions = this.$store.getters.treatment_mode;
  319. console.log("-----",this.modeOptions)
  320. var nowDate = new Date();
  321. var nowYear = nowDate.getFullYear();
  322. var nowMonth = nowDate.getMonth() + 1;
  323. var nowDay = nowDate.getDate();
  324. this.listQuery.end_time =
  325. nowYear +
  326. "-" +
  327. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  328. "-" +
  329. (nowDay < 10 ? "0" + nowDay : nowDay);
  330. nowDate.setMonth(nowDate.getMonth() - 3);
  331. nowYear = nowDate.getFullYear();
  332. nowMonth = nowDate.getMonth() + 1;
  333. nowDay = nowDate.getDate();
  334. this.listQuery.start_time =
  335. nowYear +
  336. "-" +
  337. (nowMonth < 10 ? "0" + nowMonth : nowMonth) +
  338. "-" +
  339. (nowDay < 10 ? "0" + nowDay : nowDay);
  340. //获取统计列表数据
  341. this.geStatistics()
  342. console.log("activeModes",this.activeModes)
  343. },
  344. computed: {
  345. activeModes: function() {
  346. var modes = [];
  347. for (const key in this.modeOptions) {
  348. if (this.listQuery.mode_id == key || this.listQuery.mode_id == "") {
  349. modes.push(this.modeOptions[key]);
  350. }
  351. }
  352. return modes;
  353. }
  354. },
  355. };
  356. </script>
  357. <style lang="scss" scoped>
  358. .tableTitle {
  359. font-size: 16px;
  360. color: #000;
  361. font-weight: bold;
  362. margin-bottom: 10px;
  363. }
  364. </style>
  365. <style lang="scss">
  366. .page_timeAll {
  367. .cell {
  368. text-align: center;
  369. }
  370. .el-table{
  371. ::-webkit-scrollbar{
  372. height: 15px;
  373. }
  374. }
  375. }
  376. </style>