optimal.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  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="0" title="普通案例"></van-tab>
  86. <van-tab name="1" title="行社优秀"></van-tab>
  87. <van-tab name="3" title="地区优秀"></van-tab>
  88. <van-tab name="5" title="省级优秀"></van-tab>
  89. </van-tabs>
  90. </van-col>
  91. <van-col span="24" v-if="subTabList && subTabList.length > 0">
  92. <van-tabs v-model="activeSubTab" @click="tbsSubHandler">
  93. <van-tab :key="item.name" v-for="item in subTabList" :name="item.name" :title="item.title"></van-tab>
  94. </van-tabs>
  95. </van-col>
  96. </van-row>
  97. </div>
  98. <div class="navBarclas">
  99. <van-list
  100. v-model="loading"
  101. :immediate-check="false"
  102. :finished="finished"
  103. finished-text="没有更多了"
  104. @load="onLoad"
  105. >
  106. <van-panel :title="item.title" v-for="item in taskList" :key="item.id" class="card" status="状态">
  107. <template #header>
  108. <div class="titleClass">
  109. <div class="title">{{ item.title }}</div>
  110. <div>
  111. <van-button
  112. type="info"
  113. v-if="canCancel(item)"
  114. size="small"
  115. @click="cancelPromo(item.id)"
  116. >{{ cancelBtnText }}</van-button
  117. >
  118. <van-button style="margin-left: 10px" type="info" v-if="canPromo(item)" size="small" @click="commentSign(item.id)">{{
  119. promoBtnText
  120. }}</van-button>
  121. </div>
  122. </div>
  123. </template>
  124. <div>
  125. <div class="mainItem" @click="goInfo(item.id)">
  126. <div>单位名称</div>
  127. <div>{{ item.orgName }}</div>
  128. </div>
  129. <div class="mainItem" @click="goInfo(item.id)">
  130. <div>演练项目</div>
  131. <div>{{ item.typeText }}</div>
  132. </div>
  133. <div class="mainItem" @click="goInfo(item.id)">
  134. <div>评分</div>
  135. <div>{{ item.commentScore }}</div>
  136. </div>
  137. <div class="mainItem" @click="goInfo(item.id)">
  138. <div>评优状态</div>
  139. <div>{{ item.recStatusText }}</div>
  140. </div>
  141. </div>
  142. </van-panel>
  143. </van-list>
  144. </div>
  145. </div>
  146. </template>
  147. <script>
  148. import NavBar from '@/components/NavBar'
  149. import { Col, Row, Cascader, Dialog, DatetimePicker, Icon, Picker } from 'vant'
  150. import { submitRecTask, getlearningListPage } from '@/api/optimalLearning.js'
  151. import { Toast } from 'vant'
  152. import OrgTree from '@/components/orgTree'
  153. import { newDateMonth } from '@/utils/date.js'
  154. export default {
  155. data() {
  156. return {
  157. orgName: '',
  158. orgShow: false,
  159. presentDate: '', //默认时间
  160. presentEndDate: '', //默认结束时间
  161. pageNum: 1,
  162. loading: false, //加载状态
  163. finished: false, //是否全部加载完毕
  164. yearColumns: [],
  165. orgName: JSON.parse(sessionStorage.getItem('SET_USER_ORGNAME')) || '', //机构名称
  166. cascaderValue: '', //机构ID
  167. show: false, //机构弹框显示隐藏
  168. // active: '01-01',
  169. activeAl: '0',
  170. activeSubTab: '0',
  171. fieldNames: {
  172. text: 'name',
  173. value: 'id',
  174. children: 'children'
  175. },
  176. taskList: [], //列表数据
  177. typeValue: ' ', //类型值
  178. yearSelect: null,
  179. value1: JSON.parse(sessionStorage.getItem('SET_USER_ID')) || '', //输入框model
  180. showStatus: false, //状态显示隐藏
  181. showDate: false, //月份显示隐藏
  182. endShowDate: false, //月份显示隐藏
  183. fieldValue: '', //演练项目名称
  184. drillType: '',
  185. statusValue: ' ', //状态值
  186. columns: [], //状态数组
  187. columnsList: [], //状态数组
  188. currentDate: newDateMonth(), //年份
  189. endDate: newDateMonth(), //年份
  190. subTabList: [],
  191. promoBtnText: '推优', // 推优按钮文字
  192. cancelBtnText: '取消行社优秀', // 取消推优按钮文字
  193. canBtnStatus: null
  194. }
  195. },
  196. components: {
  197. NavBar,
  198. OrgTree,
  199. Dialog,
  200. Icon,
  201. DatetimePicker,
  202. Picker,
  203. Col,
  204. Row,
  205. Cascader
  206. },
  207. created() {
  208. this.presentDate = new Date(newDateMonth())
  209. this.presentEndDate = new Date(newDateMonth())
  210. },
  211. mounted() {
  212. this.init()
  213. this.getBtnText()
  214. this.cascaderValue = JSON.parse(window.sessionStorage.getItem('SET_USER_ORGID')) + ''
  215. },
  216. methods: {
  217. formatter(type, val) {
  218. if (type === 'month') {
  219. return `${val}月`
  220. } else if (type === 'year') {
  221. return `${val}年`
  222. }
  223. return val
  224. },
  225. //机构搜索
  226. getDataList(val) {
  227. this.cascaderValue = val.id
  228. this.orgName = val.name
  229. this.selectListAppHandler()
  230. },
  231. //初始化
  232. init() {
  233. //获取数据字典
  234. this.getDictHandler('core_drill_type', res => {
  235. this.columnsList = res
  236. this.columns = res.map(item => item.dictLabel)
  237. })
  238. //根据登录人机构 初始化默认选中Tab页
  239. this.initDefaultActiveTab();
  240. // 根据第一层默认选中的Tab页 初始化第二层Tab 页值
  241. this.getSubTabList(this.activeAl)
  242. //获取分页列表
  243. this.selectListAppHandler()
  244. },
  245. initDefaultActiveTab(){
  246. let orgType = window.sessionStorage.getItem('SET_USER_ORGTYPE')
  247. // 省联社
  248. if(orgType==1){
  249. this.activeAl="3";
  250. this.activeSubTab="4"
  251. }
  252. // 地区办事处
  253. if(orgType==2)
  254. {
  255. this.activeAl="1";
  256. this.activeSubTab="2"
  257. }
  258. // 行社
  259. if(orgType==3)
  260. {
  261. this.activeAl="0";
  262. this.activeSubTab="0";
  263. }
  264. },
  265. //0:正常案例、1:行社优秀案例、2:已推荐地区优秀案例、3:地区优秀案例、4:已推荐省级优秀案例、5:省级优秀案例
  266. //6 不推荐(保留普通案例) 7 不推荐(保留行社优秀案例) 8 不推荐(保留地区优秀案例)'
  267. canCancel(item) {
  268. let orgType = window.sessionStorage.getItem('SET_USER_ORGTYPE')
  269. // 行社用户
  270. if (orgType == 3) {
  271. if (item.recStatus == 1 || item.recStatus == 2) {
  272. return true
  273. } else {
  274. return false
  275. }
  276. // 办事处用户
  277. } else if (orgType == 2) {
  278. if (item.recStatus == 3 || item.recStatus == 4) {
  279. return true
  280. } else {
  281. return false
  282. }
  283. // 省联社用户
  284. } else if (orgType == 1) {
  285. if (item.recStatus == 5) {
  286. return true
  287. } else {
  288. return false
  289. }
  290. }
  291. },
  292. canPromo(item) {
  293. let orgType = window.sessionStorage.getItem('SET_USER_ORGTYPE')
  294. // 地区
  295. if (orgType == '2') {
  296. if (item.recStatus == 2 || item.recStatus == 3) {
  297. return true
  298. } else {
  299. return false
  300. }
  301. // 行社
  302. } else if (orgType == 3) {
  303. if (item.recStatus == 0 || item.recStatus == 1) {
  304. return true
  305. } else {
  306. return false
  307. }
  308. // 省联社
  309. } else if (orgType == 1) {
  310. if (item.recStatus == 4) {
  311. return true
  312. } else {
  313. return false
  314. }
  315. // 省联社
  316. }
  317. },
  318. getBtnText() {
  319. this.canBtnStatus = null
  320. if (this.activeAl == '0' && this.activeSubTab == '0') {
  321. this.promoBtnText = '推优'
  322. this.cancelBtnText = ''
  323. }
  324. if (this.activeAl == '0' && this.activeSubTab == '6') {
  325. this.promoBtnText = '重新推优'
  326. this.cancelBtnText = ''
  327. }
  328. if (this.activeAl == '1' && this.activeSubTab == '1') {
  329. this.promoBtnText = '推荐地区优秀'
  330. this.cancelBtnText = '取消行社优秀'
  331. this.canBtnStatus = '6'
  332. }
  333. if (this.activeAl == '1' && this.activeSubTab == '7') {
  334. this.promoBtnText = '重新推荐地区优秀'
  335. this.cancelBtnText = '取消行社优秀'
  336. this.canBtnStatus = '6'
  337. }
  338. if (this.activeAl == '1' && this.activeSubTab == '2') {
  339. this.promoBtnText = '行社推地区优秀评定'
  340. this.cancelBtnText = '取消地区优秀推荐'
  341. this.canBtnStatus = '7'
  342. }
  343. if (this.activeAl == '3' && this.activeSubTab == '3') {
  344. this.promoBtnText = '推荐省级优秀'
  345. this.cancelBtnText = '取消地区优秀'
  346. this.canBtnStatus = '7'
  347. }
  348. if (this.activeAl == '3' && this.activeSubTab == '8') {
  349. this.promoBtnText = '重新推荐省级优秀'
  350. this.cancelBtnText = '取消地区优秀'
  351. this.canBtnStatus = '7'
  352. }
  353. if (this.activeAl == '3' && this.activeSubTab == '4') {
  354. this.promoBtnText = '地区推省级优秀评定'
  355. this.cancelBtnText = '取消省级优秀推荐'
  356. this.canBtnStatus = '8'
  357. }
  358. if (this.activeAl == '5') {
  359. this.promoBtnText='';
  360. this.cancelBtnText = '取消省级优秀';
  361. this.canBtnStatus = '8';
  362. }
  363. },
  364. getSubTabList(activeTab,needReSetActiveSubTab) {
  365. if (activeTab === '0') {
  366. if(needReSetActiveSubTab) this.activeSubTab = '0'
  367. this.subTabList = [
  368. { name: '0', title: '可推荐行社优秀' },
  369. { name: '6', title: '不推荐行社优秀' }
  370. ]
  371. }
  372. if (activeTab === '1') {
  373. if(needReSetActiveSubTab) this.activeSubTab = '1'
  374. this.subTabList = [
  375. { name: '1', title: '可推荐地区优秀' },
  376. { name: '7', title: '不推荐地区优秀' },
  377. { name: '2', title: '已推荐地区优秀' }
  378. ]
  379. }
  380. if (activeTab === '3') {
  381. if(needReSetActiveSubTab) this.activeSubTab = '3'
  382. this.subTabList = [
  383. { name: '3', title: '可推荐省级优秀' },
  384. { name: '8', title: '不推荐省级优秀' },
  385. { name: '4', title: '已推荐省级优秀' }
  386. ]
  387. }
  388. if (activeTab === '5') {
  389. if(needReSetActiveSubTab) this.activeSubTab = null
  390. this.subTabList = []
  391. }
  392. },
  393. selectListAppHandler(type = 0, callback = () => {}) {
  394. let obj = {
  395. pageNum: this.pageNum,
  396. pageSize: 10
  397. }
  398. if (!type) {
  399. obj.pageNum = 1
  400. this.pageNum = 1
  401. this.taskList = []
  402. }
  403. obj.orgId = this.cascaderValue || JSON.parse(window.sessionStorage.getItem('SET_USER_ORGID')) + '' || ''
  404. if (!this.currentDate || !this.endDate) {
  405. return Toast('请选择一个月份范围')
  406. }
  407. if (this.currentDate) {
  408. obj.startTime = this.currentDate + '-' + '01'
  409. }
  410. if (this.endDate) {
  411. obj.endTime = this.endDate + '-' + '01'
  412. }
  413. if (this.fieldValue) {
  414. obj.drillType = this.drillType
  415. }
  416. if (this.activeAl) {
  417. obj.recStatus = this.activeAl
  418. }
  419. if (this.activeSubTab) {
  420. //6 不推荐(保留普通案例) 7 不推荐(保留行社优秀案例) 8 不推荐(保留地区优秀案例)
  421. if (this.activeSubTab === '6' || this.activeSubTab === '7' || this.activeSubTab === '8') {
  422. obj.unRecStatus = this.activeSubTab
  423. }
  424. //推荐状态:0:正常案例、1:行社优秀案例、2:已推荐地区优秀案例、3:地区优秀案例、4:已推荐省级优秀案例、5:省级优秀案例',
  425. else if (this.activeSubTab === '2' || this.activeSubTab === '4') {
  426. obj.recStatus = this.activeSubTab
  427. }
  428. }
  429. //获取任务列表
  430. getlearningListPage(obj).then(res => {
  431. let { code, rows, total } = res
  432. if (code == 200) {
  433. if (type) {
  434. this.taskList.push(...rows)
  435. if (this.taskList.length >= total) {
  436. //已加载完全部数据
  437. this.finished = true
  438. } else {
  439. callback()
  440. }
  441. } else {
  442. this.taskList.push(...rows)
  443. this.finished = false
  444. this.loading = false
  445. if (this.taskList.length >= total) {
  446. //已加载完全部数据
  447. this.finished = true
  448. }
  449. // this.taskList = rows || []
  450. }
  451. } else {
  452. this.finished = true
  453. this.taskList = []
  454. }
  455. })
  456. },
  457. tbsAlHandler(activeTab) {
  458. console.log('tbsAlHandler', activeTab)
  459. this.getSubTabList(activeTab,true)
  460. this.getBtnText()
  461. this.selectListAppHandler()
  462. },
  463. tbsSubHandler() {
  464. this.getBtnText()
  465. this.selectListAppHandler()
  466. },
  467. //年份选中触发
  468. onDateConfirm(val) {
  469. if (this.newDate(val + '') > this.endDate) {
  470. return Toast('开始月份不能大于结束月份')
  471. }
  472. this.currentDate = this.newDate(val + '')
  473. this.showDate = false
  474. this.selectListAppHandler()
  475. },
  476. //年份选中触发
  477. onEndDateConfirm(val) {
  478. if (this.newDate(val + '') < this.currentDate) {
  479. return Toast('结束月份不能小于开始月份')
  480. }
  481. this.endDate = this.newDate(val + '')
  482. console.log(this.endDate)
  483. this.endShowDate = false
  484. this.selectListAppHandler()
  485. },
  486. newDate(time) {
  487. var date = new Date(time)
  488. var y = date.getFullYear()
  489. var m = date.getMonth() + 1
  490. m = m < 10 ? '0' + m : m
  491. var d = date.getDate()
  492. d = d < 10 ? '0' + d : d
  493. return y + '-' + m
  494. },
  495. //日期格式
  496. formatDate(date) {
  497. return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`
  498. },
  499. //onLoad下拉刷新
  500. onLoad() {
  501. if (this.pageNum == 1) {
  502. this.pageNum = 2
  503. }
  504. this.loading = true
  505. this.selectListAppHandler(1, () => {
  506. this.pageNum++
  507. this.loading = false
  508. })
  509. },
  510. //跳转详情
  511. // goInfo(id) {
  512. // this.$router.push('/rehearsalTasinfo/' + id + '_learning')
  513. // },
  514. //评优推优跳转
  515. commentSign(id) {
  516. this.$router.push('/commentSign/' + id + '_comment' + '_' + this.activeAl)
  517. },
  518. // 取消优秀 / 取消推优
  519. cancelPromo(id) {
  520. Dialog.confirm({
  521. title: '',
  522. message: `是否` + this.cancelBtnText + '?'
  523. })
  524. .then(() => {
  525. console.log("cancelPromo",1);
  526. let submitData={
  527. drillTaskId: id,
  528. recStatus: this.canBtnStatus
  529. };
  530. console.log("cancelPromo",submitData);
  531. submitRecTask(submitData).then(res => {
  532. console.log("cancelPromo res",res);
  533. if (res) {
  534. Toast(this.cancelBtnText + '成功')
  535. }
  536. setTimeout(() => {
  537. this.selectListAppHandler()
  538. }, 1000)
  539. })
  540. .catch((err) => {
  541. console.log("cancelPromo err",res);
  542. })
  543. })
  544. .catch(() => {
  545. // on cancel
  546. })
  547. },
  548. //跳转详情
  549. goInfo(id) {
  550. this.$router.push('/commentSign/' + id + '_info1')
  551. },
  552. //搜索选择状态时触发
  553. onConfirm(value, index) {
  554. this.fieldValue = value
  555. this.columnsList.forEach(item => {
  556. if (value == item.dictLabel) {
  557. this.drillType = item.dictValue
  558. }
  559. })
  560. this.selectListAppHandler()
  561. this.showStatus = false
  562. },
  563. onCancel() {
  564. this.show = false
  565. this.typeStatus = false
  566. this.showDate = false
  567. this.showStatus = false
  568. this.endShowDate = false
  569. }
  570. }
  571. }
  572. </script>
  573. <style lang="scss" scoped>
  574. .popup {
  575. height: 40vh;
  576. }
  577. .navBarclas {
  578. height: calc(100vh - 380px);
  579. overflow: scroll;
  580. }
  581. .btnf_box {
  582. background-color: #fff;
  583. }
  584. .card {
  585. margin: 20px;
  586. margin-bottom: 0px;
  587. box-shadow: 0 8px 12px #ebedf0;
  588. }
  589. .btn {
  590. float: right;
  591. margin-top: 24px;
  592. margin-right: 20px;
  593. box-sizing: border-box;
  594. }
  595. .titleClass {
  596. display: flex;
  597. align-items: center;
  598. height: 100%;
  599. padding: 20px;
  600. // border-bottom: 1px solid #1989fa;
  601. .title {
  602. font-size: 30px;
  603. flex: 1;
  604. line-height: 50px;
  605. }
  606. }
  607. .mainItem {
  608. display: flex;
  609. font-size: 28px;
  610. padding: 20px;
  611. justify-content: space-between;
  612. .condition {
  613. color: #1989fa;
  614. text-decoration: underline;
  615. }
  616. }
  617. .conditionCls {
  618. .title {
  619. color: #1989fa;
  620. margin-left: 30px;
  621. // margin-top: 30px;
  622. }
  623. .people {
  624. margin-left: 80px;
  625. margin-bottom: 30px;
  626. margin-top: 30px;
  627. }
  628. }
  629. .topBox {
  630. // overflow: hidden;
  631. }
  632. :deep.van-field--disabled {
  633. color: #323233;
  634. }
  635. :deep.van-field--disabled .van-field__label {
  636. color: #323233;
  637. }
  638. :deep .van-field__control[disabled] {
  639. color: #323233;
  640. -webkit-text-fill-color: #323233;
  641. }
  642. .van-cell__value {
  643. color: black;
  644. text-align: left;
  645. }
  646. </style>