optimal.vue 19 KB

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