index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <div class="educationStatistics">
  3. <NavBar />
  4. <div class="statistics-container">
  5. <org-tree v-model="cascaderValue" @change="getOrgDataList"></org-tree>
  6. <van-row>
  7. <van-col span="24"
  8. ><van-field
  9. v-model="fieldValue"
  10. label-width="6em"
  11. :disabled="showStatus"
  12. label="演练计划名称"
  13. placeholder=""
  14. @click="showStatus = true"
  15. ><van-icon name="arrow-down" slot="button"
  16. /></van-field>
  17. <van-popup v-model="showStatus" round position="bottom">
  18. <van-picker
  19. title="演练计划名称"
  20. show-toolbar
  21. :columns="taskList"
  22. @confirm="onConfirm"
  23. @cancel="onCancel"
  24. confirm-button-text="确定"
  25. :close-on-click-overlay="false"
  26. />
  27. </van-popup>
  28. </van-col>
  29. </van-row>
  30. <van-row>
  31. <van-col span="12">
  32. <van-field
  33. v-model="currentDate"
  34. label-width="5em"
  35. label="开始月份"
  36. placeholder=""
  37. :disabled="showDate"
  38. @click="showDate = true"
  39. >
  40. <van-icon name="arrow-down" slot="button"
  41. /></van-field>
  42. <van-popup v-model="showDate" round position="bottom">
  43. <!-- :columns="yearColumns" -->
  44. <van-datetime-picker
  45. v-model="presentDate"
  46. show-toolbar
  47. @cancel="onCancel"
  48. type="year-month"
  49. @confirm="onDateConfirm"
  50. confirm-button-text="确定"
  51. :default-index="yearSelect"
  52. title="开始月份"
  53. />
  54. </van-popup>
  55. </van-col>
  56. <van-col span="12">
  57. <van-field
  58. v-model="endDate"
  59. label-width="5em"
  60. label="结束月份"
  61. placeholder=""
  62. :disabled="endShowDate"
  63. @click="endShowDate = true"
  64. >
  65. <van-icon name="arrow-down" slot="button"
  66. /></van-field>
  67. <van-popup v-model="endShowDate" round position="bottom">
  68. <!-- :columns="yearColumns" -->
  69. <van-datetime-picker
  70. v-model="presentEndDate"
  71. show-toolbar
  72. @cancel="onCancel"
  73. type="year-month"
  74. @confirm="onEndDateConfirm"
  75. confirm-button-text="确定"
  76. :default-index="yearSelect"
  77. title="结束月份"
  78. />
  79. </van-popup>
  80. </van-col>
  81. </van-row>
  82. <div class="card-list">
  83. <empty v-if="!dataList || dataList.length === 0" />
  84. <ve-table
  85. v-else
  86. maxHeight="calc(100vh - 252px)"
  87. fixedHeader
  88. borderX
  89. borderY
  90. borderAround
  91. :columns="columns"
  92. :table-data="dataList"
  93. />
  94. </div>
  95. </div>
  96. </div>
  97. </template>
  98. <script>
  99. import NavBar from '@/components/NavBar'
  100. import OrgTree from '@/components/orgTree'
  101. import dateCell from '@/components/dateCell'
  102. import selectCell from '@/components/selectCell'
  103. import { getrehearsalList, getTableRehearsalList } from '@/api/drillTask.js'
  104. import { mapGetters } from 'vuex'
  105. import { formatDate } from '@/filters/filter'
  106. import { newDateMonth } from '@/utils/date.js'
  107. import { Toast } from 'vant'
  108. export default {
  109. components: {
  110. NavBar,
  111. OrgTree,
  112. dateCell,
  113. selectCell
  114. },
  115. data() {
  116. return {
  117. // active: '',
  118. cascaderValue: '',
  119. presentDate: '',
  120. presentEndDate: '',
  121. showStatus: false, //状态显示隐藏
  122. endShowDate: false, //状态显示隐藏
  123. // yearColumns: [],
  124. showDate: false, //月份显示隐藏
  125. fieldValue: '', //状态名称
  126. statusValue: '', //状态值
  127. taskList: [], //状态数组
  128. columnsList: [], //状态数组
  129. currentDate: newDateMonth(), //年份
  130. endDate: newDateMonth(), //年份
  131. planList: [],
  132. yearSelect: null,
  133. prop: {
  134. label: 'name',
  135. value: 'id'
  136. },
  137. loading: false,
  138. columns: [
  139. {
  140. field: 'index',
  141. key: 'index',
  142. title: '序号',
  143. width: 50,
  144. align: 'center',
  145. renderBodyCell: ({ row, column, rowIndex }, h) => {
  146. return ++rowIndex
  147. }
  148. },
  149. { field: 'orgName', key: 'a', title: '单位名称', align: 'center' },
  150. { field: 'shouldFinish', key: 'b', title: '应演练数', align: 'center' },
  151. { field: 'finish', key: 'c', title: '已演练数', align: 'center' },
  152. { field: 'score', key: 'd', title: '评分', align: 'center' }
  153. ],
  154. dataList: []
  155. }
  156. },
  157. created() {
  158. this.presentDate = new Date(newDateMonth())
  159. this.presentEndDate = new Date(newDateMonth())
  160. // this.yearData()
  161. // this.getNewMonth()
  162. },
  163. mounted() {
  164. this.initData()
  165. },
  166. computed: {},
  167. methods: {
  168. // getNewMonth() {
  169. // //获取当前月份
  170. // let date = new Date().getMonth() + 1
  171. // //默认填充当前季度
  172. // if (date > 7 && date < 10) {
  173. // this.active='07-01'
  174. // //三季度
  175. // }else if(date > 4 && date < 7){
  176. // //二季度
  177. // this.active='04-01'
  178. // }else if(date > 1 && date < 4){
  179. // //一季度
  180. // this.active='01-01'
  181. // }else{
  182. // this.active='10-01'
  183. // // 四季度
  184. // }
  185. // },
  186. initData() {
  187. this.cascaderValue = JSON.parse(window.sessionStorage.getItem('SET_USER_ORGID')) + ''
  188. this.getPlanList()
  189. },
  190. getPlanList() {
  191. getrehearsalList(this.cascaderValue).then(res => {
  192. if (res.data.length === 0) return this.$toast('暂无演练排名数据')
  193. this.planList = res.data
  194. this.taskList = res.data.map(item => item.name)
  195. this.fieldValue = res.data[0].name
  196. this.statusValue = res.data[0].id
  197. this.getDataList()
  198. })
  199. },
  200. //机构搜索
  201. getOrgDataList(val) {
  202. this.cascaderValue = val
  203. this.getDataList()
  204. },
  205. getDataList() {
  206. if (!this.statusValue) return
  207. let data = {
  208. planId: this.statusValue || '',
  209. orgId: this.cascaderValue || '',
  210. startTime: this.currentDate + '-01',
  211. endTime: this.endDate + '-01'
  212. }
  213. getTableRehearsalList(data).then(res => {
  214. this.dataList = res.data
  215. })
  216. },
  217. //搜索选择状态时触发
  218. onConfirm(value, index) {
  219. this.fieldValue = value
  220. this.planList.forEach(item => {
  221. if (value == item.name) {
  222. this.statusValue = item.id
  223. }
  224. })
  225. this.getDataList()
  226. this.showStatus = false
  227. },
  228. onCancel() {
  229. this.show = false
  230. this.typeStatus = false
  231. this.showDate = false
  232. this.showStatus = false
  233. this.endShowDate = false
  234. },
  235. // yearData() {
  236. // // 获取默认显示的时间
  237. // var nowTime = new Date()
  238. // let year = nowTime.getFullYear()
  239. // let month = nowTime.getMonth()
  240. // let day = nowTime.getDate()
  241. // // 循环数组 填写最小时间和最大时间范围
  242. // for (let i = 1980; i < 2099; i++) {
  243. // this.yearColumns.push(i)
  244. // }
  245. // // 格式化时间并截取
  246. // var years = this.formatDate(new Date(year, month, day))
  247. // var Year = years.slice(0, 4)
  248. // // 将截取的年份赋值给绑定值 用于点击弹出日期窗口后显示当前的时间
  249. // this.yearSelect = this.yearColumns.indexOf(Number(Year))
  250. // },
  251. //日期格式
  252. formatDate(date) {
  253. return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
  254. },
  255. //日期转换
  256. newDate(time) {
  257. var date = new Date(time)
  258. var y = date.getFullYear()
  259. var m = date.getMonth() + 1
  260. m = m < 10 ? '0' + m : m
  261. var d = date.getDate()
  262. d = d < 10 ? '0' + d : d
  263. return y + '-' + m
  264. },
  265. //月份选中触发
  266. onDateConfirm(val) {
  267. if (this.newDate(val + '') > this.endDate) {
  268. return Toast('开始月份不能大于结束月份')
  269. }
  270. this.currentDate = this.newDate(val + '')
  271. this.showDate = false
  272. this.getDataList()
  273. },
  274. //年份选中触发
  275. onEndDateConfirm(val) {
  276. if (this.newDate(val + '') < this.currentDate) {
  277. return Toast('结束月份不能小于开始月份')
  278. }
  279. this.endDate = this.newDate(val + '')
  280. console.log(this.endDate)
  281. this.endShowDate = false
  282. this.getDataList()
  283. },
  284. tbsHandler() {
  285. this.getDataList()
  286. }
  287. }
  288. }
  289. </script>
  290. <style lang="scss">
  291. .van-cell-group {
  292. margin-bottom: 20px;
  293. }
  294. .van-cell-group:last-child {
  295. margin-bottom: 0;
  296. }
  297. .vue-table-root {
  298. tr,
  299. td,
  300. th {
  301. font-size: 25px !important;
  302. color: #666 !important;
  303. }
  304. }
  305. </style>
  306. <style lang="scss" scoped>
  307. .educationStatistics {
  308. }
  309. .statistics-container {
  310. }
  311. .card-list {
  312. padding: 20px;
  313. height: calc(100vh - 420px);
  314. overflow: hidden;
  315. }
  316. .card-num {
  317. display: flex;
  318. align-items: center;
  319. font-size: 28px;
  320. color: #009dff;
  321. }
  322. .flex-box {
  323. display: flex;
  324. align-items: center;
  325. > div {
  326. margin-right: 40px;
  327. }
  328. }
  329. .search-flex {
  330. display: flex;
  331. align-items: center;
  332. justify-content: space-between;
  333. > div {
  334. width: 50%;
  335. }
  336. }
  337. </style>