learning.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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. export default {
  135. data() {
  136. return {
  137. orgName: '',
  138. orgShow: false,
  139. presentDate: '', //默认时间
  140. presentEndDate: '', //默认结束时间
  141. pageNum: 1,
  142. loading: false, //加载状态
  143. finished: false, //是否全部加载完毕
  144. yearColumns: [],
  145. orgName: JSON.parse(sessionStorage.getItem('SET_USER_ORGNAME')) || '', //机构名称
  146. cascaderValue: '', //机构ID
  147. show: false, //机构弹框显示隐藏
  148. // active: '01-01',
  149. activeAl: '1',
  150. fieldNames: {
  151. text: 'name',
  152. value: 'id',
  153. children: 'children'
  154. },
  155. taskList: [], //列表数据
  156. typeValue: ' ', //类型值
  157. yearSelect: null,
  158. value1: JSON.parse(sessionStorage.getItem('SET_USER_ID')) || '', //输入框model
  159. showStatus: false, //状态显示隐藏
  160. showDate: false, //月份显示隐藏
  161. endShowDate: false, //月份显示隐藏
  162. fieldValue: '', //演练项目名称
  163. drillType: '',
  164. statusValue: ' ', //状态值
  165. columns: [], //状态数组
  166. columnsList: [], //状态数组
  167. currentDate: newDateMonth(), //年份
  168. endDate: newDateMonth() //年份
  169. }
  170. },
  171. components: {
  172. NavBar,
  173. OrgTree,
  174. Dialog,
  175. Icon,
  176. DatetimePicker,
  177. Picker,
  178. Col,
  179. Row,
  180. Cascader
  181. },
  182. created() {
  183. this.presentDate = new Date(newDateMonth())
  184. this.presentEndDate = new Date(newDateMonth())
  185. },
  186. mounted() {
  187. this.init()
  188. this.cascaderValue = JSON.parse(window.sessionStorage.getItem('SET_USER_ORGID')) + ''
  189. },
  190. methods: {
  191. formatter(type, val) {
  192. if (type === 'month') {
  193. return `${val}月`;
  194. } else if (type === 'year') {
  195. return `${val}年`;
  196. }
  197. return val;
  198. },
  199. //机构搜索
  200. getDataList(val) {
  201. this.cascaderValue = val.id
  202. this.orgName = val.name
  203. this.selectListAppHandler()
  204. },
  205. //初始化
  206. init() {
  207. //获取数据字典
  208. this.getDictHandler('core_drill_type', res => {
  209. this.columnsList = res
  210. this.columns = res.map(item => item.dictLabel)
  211. })
  212. //获取分页列表
  213. this.selectListAppHandler()
  214. },
  215. selectListAppHandler(type = 0, callback = () => {}) {
  216. let obj = {
  217. pageNum: this.pageNum,
  218. pageSize: 10,
  219. }
  220. if (!type) {
  221. obj.pageNum = 1
  222. this.pageNum = 1
  223. this.taskList = []
  224. }
  225. // if (this.statusValue) {
  226. // obj.status = this.statusValue
  227. // }
  228. obj.orgId = this.cascaderValue || JSON.parse(window.sessionStorage.getItem('SET_USER_ORGID')) + '' || ''
  229. if (!this.currentDate || !this.endDate) {
  230. return Toast('请选择一个月份范围')
  231. }
  232. if (this.currentDate) {
  233. obj.startTime = this.currentDate + '-' + '01'
  234. }
  235. if (this.endDate) {
  236. obj.endTime = this.endDate + '-' + '01'
  237. }
  238. if (this.fieldValue) {
  239. obj.drillType = this.drillType
  240. }
  241. if (this.activeAl) {
  242. obj.recStatus = this.activeAl
  243. }
  244. //获取任务列表
  245. getRecTaskList(obj).then(res => {
  246. let { code, rows, total } = res
  247. if (code == 200) {
  248. if (type) {
  249. this.taskList.push(...rows)
  250. if (this.taskList.length >= total) {
  251. //已加载完全部数据
  252. this.finished = true
  253. } else {
  254. callback()
  255. }
  256. } else {
  257. this.taskList.push(...rows)
  258. this.finished = false
  259. this.loading = false
  260. if (this.taskList.length >= total) {
  261. //已加载完全部数据
  262. this.finished = true
  263. }
  264. // this.taskList = rows || []
  265. }
  266. } else {
  267. this.finished = true
  268. this.taskList = []
  269. }
  270. })
  271. },
  272. tbsAlHandler() {
  273. this.selectListAppHandler()
  274. },
  275. //年份选中触发
  276. onDateConfirm(val) {
  277. if (this.newDate(val + '') > this.endDate) {
  278. return Toast('开始月份不能大于结束月份')
  279. }
  280. this.currentDate = this.newDate(val + '')
  281. this.showDate = false
  282. this.selectListAppHandler()
  283. },
  284. //年份选中触发
  285. onEndDateConfirm(val) {
  286. if (this.newDate(val + '') < this.currentDate) {
  287. return Toast('结束月份不能小于开始月份')
  288. }
  289. this.endDate = this.newDate(val + '')
  290. console.log(this.endDate)
  291. this.endShowDate = false
  292. this.selectListAppHandler()
  293. },
  294. newDate(time) {
  295. var date = new Date(time)
  296. var y = date.getFullYear()
  297. var m = date.getMonth() + 1
  298. m = m < 10 ? '0' + m : m
  299. var d = date.getDate()
  300. d = d < 10 ? '0' + d : d
  301. return y + '-' + m
  302. },
  303. //日期格式
  304. formatDate(date) {
  305. return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
  306. },
  307. //onLoad下拉刷新
  308. onLoad() {
  309. if (this.pageNum == 1) {
  310. this.pageNum = 2
  311. }
  312. this.loading = true
  313. this.selectListAppHandler(1, () => {
  314. this.pageNum++
  315. this.loading = false
  316. })
  317. },
  318. //跳转详情
  319. goInfo(id) {
  320. this.$router.push('/rehearsalTasinfo/' + id + '_learning')
  321. },
  322. //搜索选择状态时触发
  323. onConfirm(value, index) {
  324. this.fieldValue = value
  325. this.columnsList.forEach(item => {
  326. if (value == item.dictLabel) {
  327. this.drillType = item.dictValue
  328. }
  329. })
  330. this.selectListAppHandler()
  331. this.showStatus = false
  332. },
  333. onCancel() {
  334. this.show = false
  335. this.typeStatus = false
  336. this.showDate = false
  337. this.showStatus = false
  338. this.endShowDate = false
  339. }
  340. }
  341. }
  342. </script>
  343. <style lang="scss" scoped>
  344. .popup {
  345. height: 40vh;
  346. }
  347. .navBarclas {
  348. height: calc(100vh - 380px);
  349. overflow: scroll;
  350. }
  351. .btnf_box {
  352. background-color: #fff;
  353. }
  354. .card {
  355. margin: 20px;
  356. margin-bottom: 0px;
  357. box-shadow: 0 8px 12px #ebedf0;
  358. }
  359. .btn {
  360. float: right;
  361. margin-top: 24px;
  362. margin-right: 20px;
  363. box-sizing: border-box;
  364. }
  365. .titleClass {
  366. display: flex;
  367. align-items: center;
  368. height: 100%;
  369. padding: 20px;
  370. // border-bottom: 1px solid #1989fa;
  371. .title {
  372. font-size: 30px;
  373. flex: 1;
  374. line-height: 50px;
  375. }
  376. }
  377. .mainItem {
  378. display: flex;
  379. font-size: 28px;
  380. padding: 20px;
  381. justify-content: space-between;
  382. .condition {
  383. color: #1989fa;
  384. text-decoration: underline;
  385. }
  386. }
  387. .conditionCls {
  388. .title {
  389. color: #1989fa;
  390. margin-left: 30px;
  391. // margin-top: 30px;
  392. }
  393. .people {
  394. margin-left: 80px;
  395. margin-bottom: 30px;
  396. margin-top: 30px;
  397. }
  398. }
  399. .topBox {
  400. // overflow: hidden;
  401. }
  402. :deep.van-field--disabled {
  403. color: #323233;
  404. }
  405. :deep.van-field--disabled .van-field__label {
  406. color: #323233;
  407. }
  408. :deep .van-field__control[disabled] {
  409. color: #323233;
  410. -webkit-text-fill-color: #323233;
  411. }
  412. .van-cell__value {
  413. color: black;
  414. text-align: left;
  415. }
  416. </style>