learning.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <template>
  2. <div>
  3. <div class="topBox">
  4. <NavBar />
  5. <van-row>
  6. <van-col span="24">
  7. <org-tree v-model="cascaderValue" :name="'sss'" @changeItem="getDataList"></org-tree>
  8. </van-col>
  9. </van-row>
  10. <van-row>
  11. <van-col span="12">
  12. <!-- <van-field
  13. v-model="currentDate"
  14. label-width="5em"
  15. label="开始月份"
  16. placeholder=""
  17. :disabled="showDate"
  18. @click="showDate = true"
  19. >
  20. <van-icon name="arrow-down" slot="button"
  21. /></van-field> -->
  22. <van-cell title="开始月份" @click="showDate = true" is-link arrow-direction="down" :value="currentDate" />
  23. <van-popup v-model="showDate" round position="bottom">
  24. <!-- :columns="yearColumns" -->
  25. <van-datetime-picker
  26. v-model="presentDate"
  27. show-toolbar
  28. @cancel="onCancel"
  29. :formatter="formatter"
  30. type="year-month"
  31. @confirm="onDateConfirm"
  32. confirm-button-text="确定"
  33. :default-index="yearSelect"
  34. title="开始月份"
  35. />
  36. </van-popup>
  37. </van-col>
  38. <van-col span="12">
  39. <!-- <van-field
  40. v-model="endDate"
  41. label-width="5em"
  42. label="结束月份"
  43. placeholder=""
  44. :disabled="endShowDate"
  45. @click="endShowDate = true"
  46. >
  47. <van-icon name="arrow-down" slot="button"
  48. /></van-field> -->
  49. <van-cell title="结束月份" @click="endShowDate = true" is-link arrow-direction="down" :value="endDate" />
  50. <van-popup v-model="endShowDate" round position="bottom">
  51. <!-- :columns="yearColumns" -->
  52. <van-datetime-picker
  53. v-model="presentEndDate"
  54. show-toolbar
  55. @cancel="onCancel"
  56. type="year-month"
  57. :formatter="formatter"
  58. @confirm="onEndDateConfirm"
  59. confirm-button-text="确定"
  60. :default-index="yearSelect"
  61. title="结束月份"
  62. />
  63. </van-popup>
  64. </van-col>
  65. </van-row>
  66. <van-row>
  67. <van-col span="24">
  68. <van-cell title="演练项目" @click="showStatus = true" is-link arrow-direction="down" :value="fieldValue" />
  69. <van-popup v-model="showStatus" round position="bottom">
  70. <van-picker
  71. title="演练项目"
  72. show-toolbar
  73. :columns="columns"
  74. @confirm="onConfirm"
  75. confirm-button-text="确定"
  76. @cancel="onCancel"
  77. :close-on-click-overlay="false"
  78. />
  79. </van-popup>
  80. </van-col>
  81. </van-row>
  82. <van-row>
  83. <van-col span="24">
  84. <van-tabs v-model="activeAl" @click="tbsAlHandler">
  85. <van-tab name="1" title="行社优秀案例"></van-tab>
  86. <van-tab name="3" title="地区优秀案例"></van-tab>
  87. <van-tab name="5" title="省级优秀案例"></van-tab>
  88. </van-tabs>
  89. </van-col>
  90. </van-row>
  91. </div>
  92. <!-- //卡片内容区域 -->
  93. <div class="navBarclas">
  94. <van-list
  95. v-model="loading"
  96. :immediate-check="false"
  97. :finished="finished"
  98. finished-text="没有更多了"
  99. @load="onLoad"
  100. >
  101. <van-panel :title="item.title" v-for="item in taskList" :key="item.id" class="card" status="状态">
  102. <template #header>
  103. <div class="titleClass">
  104. <div class="title">{{ item.title }}</div>
  105. </div>
  106. </template>
  107. <div>
  108. <div class="mainItem" @click="goInfo(item.id)">
  109. <div>单位名称</div>
  110. <div>{{ item.orgName }}</div>
  111. </div>
  112. <div class="mainItem" @click="goInfo(item.id)">
  113. <div>演练项目</div>
  114. <div>{{ item.typeText }}</div>
  115. </div>
  116. <div class="mainItem" @click="goInfo(item.id)">
  117. <div>演练时间</div>
  118. <div v-if="item.drillStartTime">{{ item.drillStartTime }}-{{ item.drillEndTime }}</div>
  119. </div>
  120. </div>
  121. </van-panel>
  122. </van-list>
  123. </div>
  124. </div>
  125. </template>
  126. <script>
  127. import NavBar from '@/components/NavBar'
  128. import { Col, Row, Cascader, Dialog, DatetimePicker, Icon, Picker } from 'vant'
  129. import { getRecTaskList } from '@/api/optimalLearning.js'
  130. import { deptTreeList } from '@/api/toConsult.js'
  131. import { Toast } from 'vant'
  132. import OrgTree from '@/components/orgTree'
  133. import { newDateMonth } from '@/utils/date.js'
  134. import dayjs from "dayjs";
  135. export default {
  136. data() {
  137. return {
  138. orgName: '',
  139. orgShow: false,
  140. presentDate: '', //默认时间
  141. presentEndDate: '', //默认结束时间
  142. pageNum: 1,
  143. loading: false, //加载状态
  144. finished: false, //是否全部加载完毕
  145. yearColumns: [],
  146. orgName: JSON.parse(sessionStorage.getItem('SET_USER_ORGNAME')) || '', //机构名称
  147. cascaderValue: '', //机构ID
  148. show: false, //机构弹框显示隐藏
  149. // active: '01-01',
  150. activeAl: '1',
  151. fieldNames: {
  152. text: 'name',
  153. value: 'id',
  154. children: 'children'
  155. },
  156. taskList: [], //列表数据
  157. typeValue: ' ', //类型值
  158. yearSelect: null,
  159. value1: JSON.parse(sessionStorage.getItem('SET_USER_ID')) || '', //输入框model
  160. showStatus: false, //状态显示隐藏
  161. showDate: false, //月份显示隐藏
  162. endShowDate: false, //月份显示隐藏
  163. fieldValue: '', //演练项目名称
  164. drillType: '',
  165. statusValue: ' ', //状态值
  166. columns: [], //状态数组
  167. columnsList: [], //状态数组
  168. currentDate: newDateMonth(dayjs().startOf('quarter').subtract(4, 'month')), //上一个季度的第一个月
  169. endDate: newDateMonth() //年份
  170. }
  171. },
  172. components: {
  173. NavBar,
  174. OrgTree,
  175. Dialog,
  176. Icon,
  177. DatetimePicker,
  178. Picker,
  179. Col,
  180. Row,
  181. Cascader
  182. },
  183. created() {
  184. this.presentDate = new Date(newDateMonth())
  185. this.presentEndDate = new Date(newDateMonth())
  186. },
  187. mounted() {
  188. this.init()
  189. this.cascaderValue = JSON.parse(window.sessionStorage.getItem('SET_USER_ORGID')) + ''
  190. },
  191. methods: {
  192. formatter(type, val) {
  193. if (type === 'month') {
  194. return `${val}月`;
  195. } else if (type === 'year') {
  196. return `${val}年`;
  197. }
  198. return val;
  199. },
  200. //机构搜索
  201. getDataList(val) {
  202. this.cascaderValue = val.id
  203. this.orgName = val.name
  204. this.selectListAppHandler()
  205. },
  206. //初始化
  207. init() {
  208. //获取数据字典
  209. this.getDictHandler('core_drill_type', res => {
  210. this.columnsList = res
  211. this.columns = res.map(item => item.dictLabel)
  212. })
  213. //获取分页列表
  214. this.selectListAppHandler()
  215. },
  216. selectListAppHandler(type = 0, callback = () => {}) {
  217. let obj = {
  218. pageNum: this.pageNum,
  219. pageSize: 10,
  220. }
  221. if (!type) {
  222. obj.pageNum = 1
  223. this.pageNum = 1
  224. this.taskList = []
  225. }
  226. // if (this.statusValue) {
  227. // obj.status = this.statusValue
  228. // }
  229. obj.orgId = this.cascaderValue || JSON.parse(window.sessionStorage.getItem('SET_USER_ORGID')) + '' || ''
  230. if (!this.currentDate || !this.endDate) {
  231. return Toast('请选择一个月份范围')
  232. }
  233. if (this.currentDate) {
  234. obj.startTime = this.currentDate + '-' + '01'
  235. }
  236. if (this.endDate) {
  237. obj.endTime = this.endDate + '-' + '01'
  238. }
  239. if (this.fieldValue) {
  240. obj.drillType = this.drillType
  241. }
  242. if (this.activeAl) {
  243. obj.recStatus = this.activeAl
  244. }
  245. //获取任务列表
  246. getRecTaskList(obj).then(res => {
  247. let { code, rows, total } = res
  248. if (code == 200) {
  249. if (type) {
  250. this.taskList.push(...rows)
  251. if (this.taskList.length >= total) {
  252. //已加载完全部数据
  253. this.finished = true
  254. } else {
  255. callback()
  256. }
  257. } else {
  258. this.taskList.push(...rows)
  259. this.finished = false
  260. this.loading = false
  261. if (this.taskList.length >= total) {
  262. //已加载完全部数据
  263. this.finished = true
  264. }
  265. // this.taskList = rows || []
  266. }
  267. } else {
  268. this.finished = true
  269. this.taskList = []
  270. }
  271. })
  272. },
  273. tbsAlHandler() {
  274. this.selectListAppHandler()
  275. },
  276. //年份选中触发
  277. onDateConfirm(val) {
  278. if (this.newDate(val + '') > this.endDate) {
  279. return Toast('开始月份不能大于结束月份')
  280. }
  281. this.currentDate = this.newDate(val + '')
  282. this.showDate = false
  283. this.selectListAppHandler()
  284. },
  285. //年份选中触发
  286. onEndDateConfirm(val) {
  287. if (this.newDate(val + '') < this.currentDate) {
  288. return Toast('结束月份不能小于开始月份')
  289. }
  290. this.endDate = this.newDate(val + '')
  291. console.log(this.endDate)
  292. this.endShowDate = false
  293. this.selectListAppHandler()
  294. },
  295. newDate(time) {
  296. var date = new Date(time)
  297. var y = date.getFullYear()
  298. var m = date.getMonth() + 1
  299. m = m < 10 ? '0' + m : m
  300. var d = date.getDate()
  301. d = d < 10 ? '0' + d : d
  302. return y + '-' + m
  303. },
  304. //日期格式
  305. formatDate(date) {
  306. return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
  307. },
  308. //onLoad下拉刷新
  309. onLoad() {
  310. if (this.pageNum == 1) {
  311. this.pageNum = 2
  312. }
  313. this.loading = true
  314. this.selectListAppHandler(1, () => {
  315. this.pageNum++
  316. this.loading = false
  317. })
  318. },
  319. //跳转详情
  320. goInfo(id) {
  321. this.$router.push('/rehearsalTasinfo/' + id + '_learning')
  322. },
  323. //搜索选择状态时触发
  324. onConfirm(value, index) {
  325. this.fieldValue = value
  326. this.columnsList.forEach(item => {
  327. if (value == item.dictLabel) {
  328. this.drillType = item.dictValue
  329. }
  330. })
  331. this.selectListAppHandler()
  332. this.showStatus = false
  333. },
  334. onCancel() {
  335. this.show = false
  336. this.typeStatus = false
  337. this.showDate = false
  338. this.showStatus = false
  339. this.endShowDate = false
  340. }
  341. }
  342. }
  343. </script>
  344. <style lang="scss" scoped>
  345. .popup {
  346. height: 40vh;
  347. }
  348. .navBarclas {
  349. height: calc(100vh - 380px);
  350. overflow: scroll;
  351. }
  352. .btnf_box {
  353. background-color: #fff;
  354. }
  355. .card {
  356. margin: 20px;
  357. margin-bottom: 0px;
  358. box-shadow: 0 8px 12px #ebedf0;
  359. }
  360. .btn {
  361. float: right;
  362. margin-top: 24px;
  363. margin-right: 20px;
  364. box-sizing: border-box;
  365. }
  366. .titleClass {
  367. display: flex;
  368. align-items: center;
  369. height: 100%;
  370. padding: 20px;
  371. // border-bottom: 1px solid #1989fa;
  372. .title {
  373. font-size: 30px;
  374. flex: 1;
  375. line-height: 50px;
  376. }
  377. }
  378. .mainItem {
  379. display: flex;
  380. font-size: 28px;
  381. padding: 20px;
  382. justify-content: space-between;
  383. .condition {
  384. color: #1989fa;
  385. text-decoration: underline;
  386. }
  387. }
  388. .conditionCls {
  389. .title {
  390. color: #1989fa;
  391. margin-left: 30px;
  392. // margin-top: 30px;
  393. }
  394. .people {
  395. margin-left: 80px;
  396. margin-bottom: 30px;
  397. margin-top: 30px;
  398. }
  399. }
  400. .topBox {
  401. // overflow: hidden;
  402. }
  403. :deep.van-field--disabled {
  404. color: #323233;
  405. }
  406. :deep.van-field--disabled .van-field__label {
  407. color: #323233;
  408. }
  409. :deep .van-field__control[disabled] {
  410. color: #323233;
  411. -webkit-text-fill-color: #323233;
  412. }
  413. .van-cell__value {
  414. color: black;
  415. text-align: left;
  416. }
  417. </style>