index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. <template>
  2. <div>
  3. <NavBar />
  4. <van-row>
  5. <van-col span="24">
  6. <org-tree v-model="cascaderValue" @change="getDataList"></org-tree>
  7. <!-- <van-field
  8. v-model="value1"
  9. is-link
  10. label-width="3em"
  11. clearable
  12. label="机构"
  13. placeholder=""
  14. @click="show = true"
  15. />
  16. <van-popup v-model="show" round position="bottom" :close-on-click-overlay="false">
  17. <van-cascader
  18. v-model="cascaderValue"
  19. title="组织机构"
  20. :options="options"
  21. @close="closeDialog"
  22. @change="changeCascader"
  23. @finish="onFinish"
  24. :field-names="fieldNames"
  25. />
  26. </van-popup> -->
  27. </van-col>
  28. </van-row>
  29. <van-row>
  30. <van-col span="9"
  31. ><van-field
  32. v-model="fieldValue"
  33. label-width="3em"
  34. clearable
  35. label="状态"
  36. placeholder=""
  37. @click="showStatus = true" />
  38. <van-popup v-model="showStatus" round position="bottom">
  39. <van-picker
  40. title="调阅状态"
  41. show-toolbar
  42. :columns="columns"
  43. @confirm="onConfirm"
  44. @cancel="onCancel"
  45. @change="onChange"
  46. :close-on-click-overlay="false"
  47. /> </van-popup
  48. ></van-col>
  49. <van-col span="9">
  50. <van-field
  51. v-model="currentDate"
  52. clearable
  53. label-width="3em"
  54. label="月份"
  55. placeholder=""
  56. @click="showDate = true"
  57. />
  58. <van-popup v-model="showDate" round position="bottom">
  59. <van-datetime-picker
  60. v-model="presentDate"
  61. @cancel="onCancel"
  62. @confirm="onDateConfirm"
  63. type="year-month"
  64. title="月份"
  65. ref="pickers"
  66. />
  67. </van-popup>
  68. </van-col>
  69. <!-- <van-col span="6" class="btnf_box">
  70. <van-button type="info" class="btn" @click="clearSearch" size="small">重置</van-button>
  71. </van-col> -->
  72. </van-row>
  73. <!-- 调阅列表 -->
  74. <div class="bigbox">
  75. <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
  76. <van-panel :title="item.title" v-for="item in taskList" :key="item.id" class="card" status="状态">
  77. <template #header>
  78. <div class="titleClass">
  79. <div class="title">
  80. {{ item.taskName }} <span :class="monitor[item.status]">{{ item.status | statusFilter(this_) }}</span>
  81. </div>
  82. <div>
  83. <van-button type="info" size="small" v-if="item.status == 0" @click="startMonitorHandler(item.id)"
  84. >开始调阅</van-button
  85. >
  86. <van-button
  87. type="info"
  88. size="small"
  89. v-else-if="item.status != 0 && item.status != 3"
  90. @click="lookInfoHandler(item.id, item.status)"
  91. ><van-icon name="arrow"
  92. /></van-button>
  93. </div>
  94. </div>
  95. </template>
  96. <div class="mainItem">
  97. <div>开始时间:</div>
  98. <div class="date">{{ item.planStartTime }}</div>
  99. </div>
  100. <div class="mainItem">
  101. <div>结束时间:</div>
  102. <div class="date">{{ item.planEndTime }}</div>
  103. </div>
  104. </van-panel>
  105. </van-list>
  106. </div>
  107. <!-- 扫描弹框 -->
  108. <scandialog ref="scandialog" @change="resultImg"></scandialog>
  109. </div>
  110. </template>
  111. <script>
  112. import NavBar from '@/components/NavBar'
  113. import { Col, Row, Cascader, Dialog, DatetimePicker, Icon, Picker } from 'vant'
  114. import { deptTreeList, selectListApp, registration } from '@/api/toConsult.js'
  115. import { Toast } from 'vant'
  116. import OrgTree from '@/components/orgTree'
  117. import { newDateMonth } from '@/utils/date.js'
  118. import scandialog from '@/components/nfcPopup/alone.vue'
  119. import { base64ToBlob } from '@/utils/base64TurnImg.js'
  120. import { upload } from '@/api/public'
  121. export default {
  122. data() {
  123. return {
  124. pageNum: 1,
  125. loading: false, //加载状态
  126. finished: false, //是否全部加载完成
  127. str: '',
  128. fieldValue: '全部',
  129. monitor: ['monitor', 'monitored', 'monitoring', 'waringtoring'], //状态样式
  130. value1: JSON.parse(sessionStorage.getItem('SET_USER_ORGNAME')) || '', //输入框model
  131. currentDate: newDateMonth(),
  132. presentDate: '', //当前时间
  133. cascaderValue: JSON.parse(sessionStorage.getItem('SET_USER_ORGID')) || '',
  134. columns: ['全部'],
  135. statusList: [], //调阅状态字典数组
  136. show: false,
  137. this_: this,
  138. showStatus: false,
  139. showDate: false,
  140. showDialog: false,
  141. fieldNames: {
  142. text: 'name',
  143. value: 'id',
  144. children: 'children'
  145. },
  146. taskId: '', //当前点击所属任务ID
  147. taskList: [], //任务数组集合
  148. options: [] //机构数组
  149. }
  150. },
  151. components: {
  152. NavBar,
  153. OrgTree,
  154. scandialog,
  155. Dialog,
  156. Icon,
  157. DatetimePicker,
  158. Picker,
  159. Col,
  160. Row,
  161. Cascader
  162. },
  163. filters: {
  164. statusFilter(value, this_) {
  165. let str = ''
  166. if (this_.statusList.length > 0) {
  167. this_.statusList.forEach(item => {
  168. if (value == item.dictValue) {
  169. str = item.dictLabel
  170. }
  171. })
  172. }
  173. return str
  174. }
  175. },
  176. created() {
  177. this.init()
  178. this.presentDate = this.presentDateCpd
  179. },
  180. computed: {
  181. presentDateCpd() {
  182. return new Date(+newDateMonth().split('-')[0], +newDateMonth().split('-')[1] - 1)
  183. }
  184. },
  185. mounted() {},
  186. methods: {
  187. //机构变化
  188. getDataList(v) {
  189. this.cascaderValue = v
  190. this.selectListAppHandler()
  191. },
  192. //onLoad下拉刷新
  193. onLoad() {
  194. if (this.pageNum == 1) {
  195. this.pageNum = 2
  196. }
  197. this.selectListAppHandler(() => {
  198. this.loading = false
  199. this.pageNum++
  200. })
  201. },
  202. //清空查询条件
  203. clearSearch() {
  204. this.str = ''
  205. this.cascaderValue = ''
  206. this.value1 = ''
  207. this.currentDate = ''
  208. this.fieldValue = ''
  209. this.selectListAppHandler()
  210. },
  211. //nfc拍照功能完成
  212. change(img) {
  213. console.log(img)
  214. },
  215. //初始化
  216. init() {
  217. //获取调阅状态字典
  218. this.getDictHandler('retrieval_task_status', res => {
  219. this.statusList = res
  220. res.forEach(item => {
  221. this.columns.push(item.dictLabel)
  222. })
  223. })
  224. this.selectListAppHandler()
  225. },
  226. selectListAppHandler(type = 0, callBack = () => {}) {
  227. if (!type) {
  228. this.pageNum = 1
  229. }
  230. //获取任务列表
  231. selectListApp({
  232. pageNum: this.pageNum,
  233. pageSize: 10,
  234. status: this.str || '',
  235. orgId: this.cascaderValue || '',
  236. moth: this.currentDate || ''
  237. }).then(res => {
  238. let { code, rows, msg } = res
  239. if (code == 200) {
  240. if (type) {
  241. this.taskList.push(...rows)
  242. if (rows.length == 0) {
  243. //已加载完全部数据
  244. this.finished = true
  245. }
  246. callBack()
  247. } else {
  248. this.finished = false
  249. this.taskList = rows
  250. }
  251. // if(num===1){
  252. // this.loading = false
  253. // this.pageNum++
  254. // }
  255. }
  256. })
  257. },
  258. //扫描NFC
  259. nfcHandler() {
  260. //NFC和图片对应字段先写死后期接入app之后再做更改
  261. let obj = {
  262. nfc: 'nfc',
  263. taskId: this.taskId
  264. }
  265. registration(obj).then(res => {
  266. let { code, data, msg } = res
  267. if (code == 200) {
  268. Toast.success('扫描成功')
  269. this.$router.push('/consultInfo/' + this.taskId)
  270. }
  271. })
  272. },
  273. //扫描图片并上传到服务器和后端
  274. photoHandler(img) {
  275. //上传到服务器
  276. let obj = {
  277. picture: img,
  278. taskId: this.taskId
  279. }
  280. registration(obj).then(res => {
  281. let { code, data, msg } = res
  282. if (code == 200) {
  283. Toast.success('扫描成功')
  284. this.$router.push('/consultInfo/' + this.taskId)
  285. }
  286. })
  287. },
  288. //文件上传
  289. resultImg(img) {
  290. let obj = base64ToBlob(img.base)
  291. let formData = new FormData()
  292. obj.name = '调阅.jpg'
  293. formData.append('file', base64ToBlob(img.base))
  294. upload(formData, 'image')
  295. .then(res => {
  296. debugger
  297. console.log(process.env.NODE_ENV)
  298. /*上传成功*/
  299. let imgUrl = process.env.NODE_ENV === 'development' ? res.data.url : window.origin + res.data.url
  300. this.photoHandler(imgUrl)
  301. // this.$emit("imgUrl", res.data.url);
  302. })
  303. .catch(err => {
  304. /*上传失败*/
  305. })
  306. },
  307. //关闭弹框事件
  308. closeDialog() {
  309. this.show = false
  310. this.selectListAppHandler()
  311. },
  312. // 开始调阅事件
  313. startMonitorHandler(taskId) {
  314. this.taskId = taskId
  315. this.$refs.scandialog.visible = true
  316. },
  317. //查看调阅详情
  318. lookInfoHandler(taskId, status) {
  319. this.taskId = taskId
  320. this.$router.push('/consultInfo/' + taskId + '_' + status)
  321. },
  322. //级联选择当前任意层级触发
  323. changeCascader(val) {
  324. console.log(val)
  325. let { selectedOptions } = val
  326. //级联值
  327. this.cascaderValue = selectedOptions[selectedOptions.length - 1].id
  328. //输入框值
  329. this.value1 = selectedOptions[selectedOptions.length - 1].name
  330. },
  331. onFinish() {},
  332. //搜索选择状态时触发
  333. onConfirm(value, index) {
  334. this.fieldValue = value
  335. this.statusList.forEach(item => {
  336. if (value == item.dictLabel) {
  337. this.str = item.dictValue
  338. }
  339. })
  340. this.showStatus = false
  341. this.selectListAppHandler()
  342. },
  343. //月份选中触发
  344. onDateConfirm() {
  345. this.currentDate = this.newDate(this.presentDate)
  346. this.showDate = false
  347. this.selectListAppHandler()
  348. },
  349. //日期转换
  350. newDate(time) {
  351. var date = new Date(time)
  352. var y = date.getFullYear()
  353. var m = date.getMonth() + 1
  354. m = m < 10 ? '0' + m : m
  355. var d = date.getDate()
  356. d = d < 10 ? '0' + d : d
  357. return y + '-' + m
  358. },
  359. // //日期组件change
  360. // changeHandler(Picker){
  361. // console.log(Picker);
  362. // console.log(Picker.getValues());
  363. // debugger
  364. // },
  365. onChange(picker, value, index) {},
  366. onCancel() {
  367. this.show = false
  368. this.showStatus = false
  369. this.showDate = false
  370. }
  371. }
  372. }
  373. </script>
  374. <style lang="scss" scoped>
  375. .topBox {
  376. border: 1px solid #ccc;
  377. margin: 20px;
  378. display: flex;
  379. .sonLeftBox {
  380. padding: 10px;
  381. flex: 1;
  382. background-color: #fff;
  383. }
  384. }
  385. .monitor {
  386. color: white;
  387. padding-left: 10px;
  388. padding-right: 10px;
  389. font-size: 20px;
  390. bottom: 5%;
  391. right: 2%;
  392. position: absolute;
  393. border-radius: 10px;
  394. background-color: #8cb585;
  395. }
  396. .monitored {
  397. color: white;
  398. padding-left: 10px;
  399. padding-right: 10px;
  400. bottom: 5%;
  401. right: 2%;
  402. position: absolute;
  403. font-size: 20px;
  404. border-radius: 10px;
  405. background-color: #1989fa;
  406. }
  407. .monitoring {
  408. color: white;
  409. padding-left: 10px;
  410. padding-right: 10px;
  411. bottom: 5%;
  412. right: 2%;
  413. position: absolute;
  414. font-size: 20px;
  415. border-radius: 10px;
  416. background-color: #25da0b;
  417. }
  418. .waringtoring {
  419. color: white;
  420. padding-left: 10px;
  421. padding-right: 10px;
  422. bottom: 5%;
  423. right: 2%;
  424. position: absolute;
  425. font-size: 20px;
  426. border-radius: 10px;
  427. background-color: #e46962;
  428. }
  429. .title {
  430. margin: 10px;
  431. margin-left: 0px;
  432. font-size: 40px;
  433. }
  434. .time {
  435. font-size: 32px;
  436. }
  437. .startMonitor {
  438. background-color: #f5f5f9;
  439. color: #1989fa;
  440. width: 160px;
  441. line-height: 200px;
  442. font-size: 36px;
  443. text-align: center;
  444. }
  445. .endMonitor {
  446. background-color: #f5f5f9;
  447. color: #1989fa;
  448. width: 160px;
  449. line-height: 200px;
  450. font-size: 36px;
  451. text-align: center;
  452. }
  453. .img_box {
  454. text-align: center;
  455. .img {
  456. width: 200px;
  457. height: 200px;
  458. }
  459. }
  460. .text {
  461. text-align: center;
  462. font-size: 30px;
  463. margin-top: 30px;
  464. margin-bottom: 100px;
  465. }
  466. .btns {
  467. margin-top: 40px;
  468. margin-bottom: 40px;
  469. display: flex;
  470. justify-content: space-around;
  471. .nfcPhoto {
  472. color: #409bf2;
  473. div {
  474. width: 100%;
  475. text-align: center;
  476. }
  477. }
  478. }
  479. .btnf_box {
  480. background-color: #fff;
  481. }
  482. .van-dialog {
  483. padding: 30px;
  484. }
  485. .spanimg {
  486. display: flex;
  487. justify-content: flex-end;
  488. .close {
  489. width: 50px;
  490. height: 50px;
  491. }
  492. }
  493. .btn {
  494. float: right;
  495. margin-top: 24px;
  496. margin-right: 20px;
  497. box-sizing: border-box;
  498. }
  499. .bigbox {
  500. height: calc(100vh - 380px);
  501. overflow: scroll;
  502. background-color: #fff;
  503. }
  504. .card {
  505. margin: 20px;
  506. margin-bottom: 0px;
  507. box-shadow: 0 8px 12px #ebedf0;
  508. }
  509. .titleClass {
  510. display: flex;
  511. align-items: center;
  512. height: 100%;
  513. padding: 20px;
  514. border-bottom: 1px solid #ccc;
  515. .title {
  516. font-size: 30px;
  517. font-weight: bold;
  518. flex: 1;
  519. line-height: 50px;
  520. }
  521. }
  522. .mainItem {
  523. display: flex;
  524. font-size: 28px;
  525. padding: 20px;
  526. justify-content: revert;
  527. .date {
  528. margin-left: 30px;
  529. }
  530. .condition {
  531. color: #1989fa;
  532. text-decoration: underline;
  533. }
  534. }
  535. </style>