home.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. <template>
  2. <view class="container">
  3. <view class="top_bg"></view>
  4. <!-- 状态统计区域 后勤管理端 -->
  5. <view class="top_types2" v-if="btns.includes('首页分段器')">
  6. <view class="top">
  7. <uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text" activeColor="#6FB6B8"></uni-segmented-control>
  8. </view>
  9. <view class="bottom">
  10. <view class="bottom_box">
  11. <view class="box_num">{{ workCount }}</view>
  12. <view class="box_info">工单数</view>
  13. </view>
  14. <view class="bottom_box">
  15. <view class="box_num">{{ processCount }}</view>
  16. <view class="box_info">处理中</view>
  17. </view>
  18. <view class="bottom_box">
  19. <view class="box_num">{{ finishCount }}</view>
  20. <view class="box_info">已完成</view>
  21. </view>
  22. <view class="bottom_box">
  23. <view class="box_num">{{ timeoutCount }}</view>
  24. <view class="box_info">已超时</view>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 状态统计区域 维修师傅端 -->
  29. <view class="top_types" v-else>
  30. <view class="types_box">
  31. <view class="box_num">{{ workCount }}</view>
  32. <view class="box_info">工单数</view>
  33. </view>
  34. <view class="types_box">
  35. <view class="box_num">{{ processCount }}</view>
  36. <view class="box_info">处理中</view>
  37. </view>
  38. <view class="types_box">
  39. <view class="box_num">{{ finishCount }}</view>
  40. <view class="box_info">已完成</view>
  41. </view>
  42. <view class="types_box">
  43. <view class="box_num">{{ timeoutCount }}</view>
  44. <view class="box_info">已超时</view>
  45. </view>
  46. </view>
  47. <!-- 排班区域 -->
  48. <view class="watch" v-if="tableData.length">
  49. <view class="watch_title">
  50. <img src="../../static/images/repairsImg/watch.png" />
  51. 排班
  52. </view>
  53. <!-- 表格区域 -->
  54. <uni-table stripe emptyText="暂无更多数据">
  55. <!-- 表头行 -->
  56. <uni-tr>
  57. <uni-th width="80" align="center">姓名</uni-th>
  58. <uni-th width="60" align="center">工种</uni-th>
  59. <uni-th width="80" align="center">接单状态</uni-th>
  60. <uni-th width="70" align="center">值班班次</uni-th>
  61. </uni-tr>
  62. <!-- 表格数据行 -->
  63. <uni-tr v-for="(item, index) in tableData" :key="index">
  64. <!-- 姓名区域 -->
  65. <uni-td align="center">{{ item.userName }}</uni-td>
  66. <!-- 工种区域 -->
  67. <uni-td align="center">{{ item.workTypeName }}</uni-td>
  68. <!-- 状态区域 -->
  69. <uni-td align="center">
  70. <picker :disabled="!btns.includes('表格编辑')" @change="bindPickerChange($event, item)" :range="typeArray">
  71. <view class="watch_color2" v-if="item.state === 1">{{ typeArray[item.state - 1] }}</view>
  72. <view class="watch_color3" v-if="item.state === 2">{{ typeArray[item.state - 1] }}</view>
  73. </picker>
  74. </uni-td>
  75. <!-- 是否值班 -->
  76. <uni-td align="center">
  77. <view @click="handleChange(item, index)">{{ getCutting(item.shifts || []) || '暂无排班' }}</view>
  78. </uni-td>
  79. </uni-tr>
  80. </uni-table>
  81. <!-- 是否值班弹窗区域 -->
  82. <uni-popup ref="popup_work" background-color="#fff">
  83. <view class="watch_pop">
  84. <view class="poop_title">
  85. <view class="cancel" @click="$refs.popup_work.close()">取消</view>
  86. <view class="confirm" @click="handlePopConfirm">确定</view>
  87. </view>
  88. <view class="poop_body">
  89. <view class="body_item" v-for="item in workArray" :key="item.id" @click="handleChangeWork(item)">
  90. <view class="body_item_info">
  91. {{ item.name }}
  92. </view>
  93. <view class="body_item_icon" v-if="defaultList.some((ele) => ele.name == item.name)">✔</view>
  94. </view>
  95. </view>
  96. </view>
  97. </uni-popup>
  98. </view>
  99. <!-- 排行榜区域 -->
  100. <view class="rank" v-if="btns.includes('图表')">
  101. <view class="rank_title">
  102. <img src="../../static/images/repairsImg/rank.png" />
  103. 工单完成排行榜
  104. </view>
  105. <!-- 排行榜柱状图 -->
  106. <view class="rank_charts">
  107. <!-- 加上canvas2d属性后 模拟器上图表显示异常,真机调试没有问题,开发时不添加canvas2d属性,发布时添加canvas2d属性 -->
  108. <qiun-data-charts canvas2d type="bar" :opts="opts" :chartData="chartData" />
  109. </view>
  110. </view>
  111. <!-- 悬浮按钮区域 -->
  112. <view class="fixed">
  113. <img src="../../static/images/repairsImg/add.png" @click="handleGoRepairs" />
  114. <uni-badge :offset="[5, 5]" absolute="rightTop" :text="msgTotal">
  115. <img class="img" src="../../static/images/repairsImg/message.png" @click="handleGoMsg" />
  116. </uni-badge>
  117. </view>
  118. </view>
  119. </template>
  120. <script>
  121. export default {
  122. data() {
  123. return {
  124. // 按钮权限
  125. btns: [],
  126. // 是否值班弹窗默认选中数组
  127. defaultList: [],
  128. // 改变的是第几个索引
  129. changeIndex: 0,
  130. // 排班状态数组
  131. typeArray: ['大量接单', '停止接单'],
  132. // 值班状态数组
  133. workArray: [],
  134. // 分段器数组数据
  135. items: ['团队数据统计', '个人数据统计'],
  136. // 分段器当前索引
  137. current: 0,
  138. // 柱状图数据
  139. chartData: {
  140. categories: [],
  141. series: [
  142. {
  143. name: '好评数',
  144. data: []
  145. },
  146. {
  147. name: '完成数',
  148. data: []
  149. }
  150. ]
  151. },
  152. // 柱状图配置
  153. opts: {
  154. color: ['#1890FF', '#91CB74'],
  155. padding: [15, 30, 0, 5],
  156. xAxis: {
  157. boundaryGap: 'justify',
  158. disableGrid: false,
  159. gridType: 'dash',
  160. gridColor: '#E5E5E5',
  161. min: 0,
  162. axisLine: false
  163. },
  164. extra: {
  165. bar: {
  166. width: 15,
  167. activeBgColor: '#000000',
  168. activeBgOpacity: 0.08,
  169. linearType: 'custom',
  170. barBorderCircle: true,
  171. seriesGap: 2
  172. }
  173. }
  174. },
  175. // 表格数据
  176. tableData: [],
  177. schoolId: '',
  178. userId: '',
  179. // 工单数单数
  180. workCount: '',
  181. // 处理中单数
  182. processCount: '',
  183. // 已完成单数
  184. finishCount: '',
  185. // 已超时单数
  186. timeoutCount: '',
  187. // 当前页
  188. currentPage: 1,
  189. // 每页多少条数据
  190. pageCount: 100,
  191. // 总条数
  192. total: null
  193. }
  194. },
  195. props: ['msgTotal'],
  196. mounted() {
  197. const repairsUserInfo = uni.getStorageSync('repairsUserInfo')
  198. this.btns = repairsUserInfo.btns
  199. this.schoolId = repairsUserInfo.schoolId
  200. this.userId = repairsUserInfo.userId
  201. if (this.btns.includes('图表')) {
  202. this.getChartData()
  203. }
  204. if (this.btns.includes('表格编辑')) {
  205. this.getWatchClass()
  206. }
  207. if (this.btns.includes('表格编辑')) {
  208. this.getTeamCount()
  209. } else {
  210. this.getCount()
  211. }
  212. // 获取表格数据
  213. this.getWatchData()
  214. },
  215. methods: {
  216. // 获取图表数据
  217. async getChartData() {
  218. const res = await this.$myRequest_repairs({
  219. url: '/repairUser/queryPositiveReviewPage',
  220. data: {
  221. currentPage: 1,
  222. pageCount: 100,
  223. schoolId: this.schoolId
  224. }
  225. })
  226. // console.log(res)
  227. if (res.code === '200') {
  228. // 姓名数组
  229. this.chartData.categories = res.data.list.map((ele) => ele.userName)
  230. // 好评数数组
  231. this.chartData.series[0].data = res.data.list.map((ele) => ele.evaluateCount)
  232. // 完成数数组
  233. this.chartData.series[1].data = res.data.list.map((ele) => ele.finishCount)
  234. }
  235. },
  236. // 获取排班班次数组
  237. async getWatchClass() {
  238. const res = await this.$myRequest_repairs({
  239. url: '/repairShiftSettings/queryPageRepairShiftSettings',
  240. data: {
  241. currentPage: 1,
  242. pageCount: 100,
  243. name: ''
  244. }
  245. })
  246. // console.log(res)
  247. if (res.code === '200') {
  248. this.workArray = res.data.list
  249. }
  250. },
  251. // 获取排班数据
  252. async getWatchData() {
  253. const res = await this.$myRequest_repairs({
  254. url: '/repairClassesSettings/queryPageUserClasses',
  255. data: {
  256. currentPage: this.currentPage,
  257. pageCount: this.pageCount,
  258. schoolId: this.schoolId
  259. }
  260. })
  261. // console.log(res)
  262. if (res.code === '200') {
  263. this.total = res.data.totalCount
  264. this.tableData = res.data.list
  265. }
  266. },
  267. // 获取团队数据统计单数
  268. async getTeamCount() {
  269. const res = await this.$myRequest_repairs({
  270. url: '/repairRecord/queryLogisticHomeCount',
  271. data: {
  272. schoolId: this.schoolId
  273. }
  274. })
  275. // console.log(res)
  276. if (res.code === '200') {
  277. this.workCount = res.data.workCount
  278. this.processCount = res.data.processCount
  279. this.finishCount = res.data.finishCount
  280. this.timeoutCount = res.data.timeoutCount
  281. }
  282. },
  283. // 获取个人数据统计单数
  284. async getCount() {
  285. const res = await this.$myRequest_repairs({
  286. url: '/repairRecord/queryMasterHomeCount',
  287. data: {
  288. userId: this.userId
  289. }
  290. })
  291. // console.log(res)
  292. if (res.code === '200') {
  293. this.workCount = res.data.workCount
  294. this.processCount = res.data.processCount
  295. this.finishCount = res.data.finishCount
  296. this.timeoutCount = res.data.timeoutCount
  297. }
  298. },
  299. // 是否值班弹窗确定按钮回调
  300. handlePopConfirm() {
  301. // uni.showModal({
  302. // title: '提示',
  303. // content: '确定修改是否值班状态吗?',
  304. // success: (res) => {
  305. // if (res.confirm) {
  306. // this.tableData[this.changeIndex].shifts = this.defaultList
  307. // console.log('用户点击确定')
  308. // } else if (res.cancel) {
  309. // console.log('用户点击取消')
  310. // }
  311. // }
  312. // })
  313. this.$refs.popup_work.close()
  314. this.tableData[this.changeIndex].shifts = this.defaultList
  315. // console.log(this.tableData[this.changeIndex])
  316. this.handleEdit(this.tableData[this.changeIndex])
  317. },
  318. // 点击值班状态回调
  319. handleChange(item, index) {
  320. if (this.btns.includes('表格编辑')) {
  321. this.$refs.popup_work.open('bottom')
  322. this.changeIndex = index
  323. this.defaultList = JSON.parse(JSON.stringify(item.shifts || []))
  324. }
  325. },
  326. // 切换值班状态回调
  327. handleChangeWork(item) {
  328. let temIndex
  329. let flag = this.defaultList.some((ele, index) => {
  330. if (ele.name == item.name) {
  331. temIndex = index
  332. }
  333. return ele.name == item.name
  334. })
  335. if (flag) {
  336. this.defaultList.splice(temIndex, 1)
  337. } else {
  338. this.defaultList.push(item)
  339. }
  340. // 修改数组的排序,id小的在前面
  341. this.defaultList.sort((a, b) => a.id - b.id)
  342. },
  343. // 切换接单状态回调
  344. bindPickerChange(e, item) {
  345. // uni.showModal({
  346. // title: '提示',
  347. // content: '确定修改接单状态吗?',
  348. // success: (res) => {
  349. // if (res.confirm) {
  350. // item.state = e.detail.value + 1
  351. // console.log('用户点击确定')
  352. // } else if (res.cancel) {
  353. // console.log('用户点击取消')
  354. // }
  355. // }
  356. // })
  357. item.state = e.detail.value * 1 + 1
  358. if (item.state === 1) {
  359. item.stateStr = '大量接单'
  360. } else {
  361. item.stateStr = '停止接单'
  362. }
  363. this.handleEdit(item)
  364. },
  365. // 修改排班表请求
  366. async handleEdit(item) {
  367. const res = await this.$myRequest_repairs({
  368. url: '/repairClassesSettings/updateUserClasses',
  369. method: 'post',
  370. data: {
  371. id: item.id,
  372. userName: item.userName,
  373. userPhone: item.userPhone,
  374. workTypeName: item.workTypeName,
  375. state: item.state,
  376. stateStr: item.stateStr,
  377. classId: item.classId,
  378. shifts: item.shifts
  379. }
  380. })
  381. // console.log(res)
  382. if (res.code === '200') {
  383. uni.showToast({
  384. title: '编辑成功',
  385. icon: 'success'
  386. })
  387. setTimeout(() => {
  388. this.getWatchData()
  389. this.getWatchClass()
  390. }, 1500)
  391. }
  392. },
  393. // 点击悬浮消息按钮回调
  394. handleGoMsg() {
  395. uni.navigateTo({
  396. url: `/pagesRepairs/message/message`
  397. })
  398. },
  399. // 点击悬浮加号按钮回调
  400. handleGoRepairs() {
  401. uni.$emit('goToRepairs', {
  402. show: 'repairs',
  403. title: '报修'
  404. })
  405. },
  406. // 顶部分段器切换回调
  407. onClickItem(e) {
  408. if (this.current != e.currentIndex) {
  409. this.current = e.currentIndex
  410. console.log(this.current)
  411. if (this.current === 0) {
  412. // 团队数据
  413. this.getTeamCount()
  414. } else {
  415. // 个人数据
  416. this.getCount()
  417. }
  418. }
  419. },
  420. // 把数组每一项的第一个文字切割出来
  421. getCutting(list) {
  422. let str = ''
  423. list.forEach((ele, index) => {
  424. if (index !== 0 && list.length > 1) {
  425. str += '、' + ele.name.substring(0, 1)
  426. } else {
  427. str += ele.name.substring(0, 1)
  428. }
  429. })
  430. return str
  431. }
  432. }
  433. }
  434. </script>
  435. <style lang="scss" scoped>
  436. .container {
  437. width: 100vw;
  438. height: calc(100vh - 152rpx);
  439. font-size: 32rpx;
  440. overflow-y: auto;
  441. .top_bg {
  442. height: 165rpx;
  443. background-color: #6fb6b8;
  444. }
  445. .top_types {
  446. display: flex;
  447. justify-content: space-evenly;
  448. margin: auto;
  449. margin-top: -100rpx;
  450. width: 690rpx;
  451. height: 188rpx;
  452. border-radius: 10rpx;
  453. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  454. background-color: #fff;
  455. .types_box {
  456. flex: 1;
  457. display: flex;
  458. flex-direction: column;
  459. justify-content: center;
  460. align-items: center;
  461. .box_num {
  462. font-size: 46rpx;
  463. color: #ff5733;
  464. }
  465. .box_info {
  466. margin-top: 10rpx;
  467. font-size: 34rpx;
  468. }
  469. }
  470. }
  471. .top_types2 {
  472. box-sizing: border-box;
  473. margin: auto;
  474. margin-top: -100rpx;
  475. padding: 0 30rpx;
  476. width: 690rpx;
  477. height: 282rpx;
  478. border-radius: 10rpx;
  479. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  480. background-color: #fff;
  481. .top {
  482. height: 112rpx;
  483. border-bottom: 1rpx solid #e6e6e6;
  484. }
  485. .bottom {
  486. display: flex;
  487. justify-content: space-evenly;
  488. height: 170rpx;
  489. .bottom_box {
  490. flex: 1;
  491. display: flex;
  492. flex-direction: column;
  493. justify-content: center;
  494. align-items: center;
  495. .box_num {
  496. font-size: 46rpx;
  497. color: #ff5733;
  498. }
  499. .box_info {
  500. margin-top: 10rpx;
  501. font-size: 34rpx;
  502. }
  503. }
  504. }
  505. }
  506. .watch {
  507. box-sizing: border-box;
  508. margin: 20rpx auto;
  509. padding: 0 30rpx;
  510. width: 690rpx;
  511. border-radius: 10rpx;
  512. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  513. .watch_title {
  514. display: flex;
  515. align-items: center;
  516. height: 95rpx;
  517. font-size: 36rpx;
  518. border-bottom: 1rpx solid #e6e6e6;
  519. img {
  520. margin-right: 14rpx;
  521. width: 44rpx;
  522. height: 44rpx;
  523. }
  524. }
  525. .watch_color2 {
  526. color: #1e7dfb;
  527. }
  528. .watch_color3 {
  529. color: #ff5733;
  530. }
  531. .watch_td {
  532. display: flex;
  533. }
  534. .watch_pop {
  535. width: 100%;
  536. height: 575rpx;
  537. overflow-y: auto;
  538. background-color: #fff;
  539. .poop_title {
  540. box-sizing: border-box;
  541. padding: 0 30rpx;
  542. display: flex;
  543. align-items: center;
  544. justify-content: space-between;
  545. height: 100rpx;
  546. font-size: 34rpx;
  547. border-bottom: 1rpx solid #f5f5f5;
  548. .cancel {
  549. color: #888888;
  550. }
  551. .confirm {
  552. color: #1e7dfb;
  553. }
  554. }
  555. .poop_body {
  556. margin-top: 50rpx;
  557. .body_item {
  558. position: relative;
  559. display: flex;
  560. justify-content: center;
  561. align-items: center;
  562. height: 100rpx;
  563. border-bottom: 1rpx solid #f5f5f5;
  564. .body_item_info {
  565. }
  566. .body_item_icon {
  567. position: absolute;
  568. top: 30rpx;
  569. right: 85rpx;
  570. color: #1e7dfb;
  571. }
  572. }
  573. }
  574. }
  575. }
  576. .rank {
  577. position: relative;
  578. box-sizing: border-box;
  579. margin: 0 auto 100rpx;
  580. padding: 0 30rpx;
  581. width: 690rpx;
  582. height: 745rpx;
  583. border-radius: 10rpx;
  584. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  585. .rank_title {
  586. display: flex;
  587. align-items: center;
  588. height: 95rpx;
  589. font-size: 36rpx;
  590. border-bottom: 1rpx solid #e6e6e6;
  591. img {
  592. margin-right: 14rpx;
  593. width: 41rpx;
  594. height: 41rpx;
  595. }
  596. }
  597. .rank_charts {
  598. position: absolute;
  599. left: 30rpx;
  600. right: 30rpx;
  601. bottom: 0;
  602. width: 630rpx;
  603. height: 650rpx;
  604. }
  605. }
  606. .fixed {
  607. z-index: 2;
  608. position: fixed;
  609. right: 0;
  610. bottom: 160rpx;
  611. display: flex;
  612. justify-content: space-evenly;
  613. align-items: center;
  614. width: 252rpx;
  615. height: 123rpx;
  616. border-radius: 150rpx 0 0 150rpx;
  617. box-shadow: 0px 0px 7rpx rgba(0, 0, 0, 0.15);
  618. background-color: #fff;
  619. img {
  620. width: 76rpx;
  621. height: 76rpx;
  622. }
  623. .img {
  624. width: 88rpx;
  625. height: 88rpx;
  626. }
  627. }
  628. }
  629. </style>