home.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  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: 10,
  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. userId: this.btns.includes('表格编辑') ? '' : this.userId
  260. }
  261. })
  262. // console.log(res)
  263. if (res.code === '200') {
  264. this.total = res.data.totalCount
  265. this.tableData = res.data.list
  266. }
  267. },
  268. // 获取团队数据统计单数
  269. async getTeamCount() {
  270. const res = await this.$myRequest_repairs({
  271. url: '/repairRecord/queryLogisticHomeCount',
  272. data: {
  273. schoolId: this.schoolId
  274. }
  275. })
  276. // console.log(res)
  277. if (res.code === '200') {
  278. this.workCount = res.data.workCount
  279. this.processCount = res.data.processCount
  280. this.finishCount = res.data.finishCount
  281. this.timeoutCount = res.data.timeoutCount
  282. }
  283. },
  284. // 获取个人数据统计单数
  285. async getCount() {
  286. const res = await this.$myRequest_repairs({
  287. url: '/repairRecord/queryMasterHomeCount',
  288. data: {
  289. userId: this.userId
  290. }
  291. })
  292. // console.log(res)
  293. if (res.code === '200') {
  294. this.workCount = res.data.workCount
  295. this.processCount = res.data.processCount
  296. this.finishCount = res.data.finishCount
  297. this.timeoutCount = res.data.timeoutCount
  298. }
  299. },
  300. // 是否值班弹窗确定按钮回调
  301. handlePopConfirm() {
  302. // uni.showModal({
  303. // title: '提示',
  304. // content: '确定修改是否值班状态吗?',
  305. // success: (res) => {
  306. // if (res.confirm) {
  307. // this.tableData[this.changeIndex].shifts = this.defaultList
  308. // console.log('用户点击确定')
  309. // } else if (res.cancel) {
  310. // console.log('用户点击取消')
  311. // }
  312. // }
  313. // })
  314. this.$refs.popup_work.close()
  315. this.tableData[this.changeIndex].shifts = this.defaultList
  316. // console.log(this.tableData[this.changeIndex])
  317. this.handleEdit(this.tableData[this.changeIndex])
  318. },
  319. // 点击值班状态回调
  320. handleChange(item, index) {
  321. if (this.btns.includes('表格编辑')) {
  322. this.$refs.popup_work.open('bottom')
  323. this.changeIndex = index
  324. this.defaultList = JSON.parse(JSON.stringify(item.shifts || []))
  325. }
  326. },
  327. // 切换值班状态回调
  328. handleChangeWork(item) {
  329. let temIndex
  330. let flag = this.defaultList.some((ele, index) => {
  331. if (ele.name == item.name) {
  332. temIndex = index
  333. }
  334. return ele.name == item.name
  335. })
  336. if (flag) {
  337. this.defaultList.splice(temIndex, 1)
  338. } else {
  339. this.defaultList.push(item)
  340. }
  341. // 修改数组的排序,id小的在前面
  342. this.defaultList.sort((a, b) => a.id - b.id)
  343. },
  344. // 切换接单状态回调
  345. bindPickerChange(e, item) {
  346. // uni.showModal({
  347. // title: '提示',
  348. // content: '确定修改接单状态吗?',
  349. // success: (res) => {
  350. // if (res.confirm) {
  351. // item.state = e.detail.value + 1
  352. // console.log('用户点击确定')
  353. // } else if (res.cancel) {
  354. // console.log('用户点击取消')
  355. // }
  356. // }
  357. // })
  358. item.state = e.detail.value * 1 + 1
  359. if (item.state === 1) {
  360. item.stateStr = '正常接单'
  361. } else {
  362. item.stateStr = '停止接单'
  363. }
  364. this.handleEdit(item)
  365. },
  366. // 修改排班表请求
  367. async handleEdit(item) {
  368. const res = await this.$myRequest_repairs({
  369. url: '/repairClassesSettings/updateUserClasses',
  370. method: 'post',
  371. data: {
  372. id: item.id,
  373. userName: item.userName,
  374. userPhone: item.userPhone,
  375. workTypeName: item.workTypeName,
  376. state: item.state,
  377. stateStr: item.stateStr,
  378. classId: item.classId,
  379. shifts: item.shifts
  380. }
  381. })
  382. // console.log(res)
  383. if (res.code === '200') {
  384. uni.showToast({
  385. title: '编辑成功',
  386. icon: 'success'
  387. })
  388. setTimeout(() => {
  389. this.getWatchData()
  390. this.getWatchClass()
  391. }, 1500)
  392. }
  393. },
  394. // 点击悬浮消息按钮回调
  395. handleGoMsg() {
  396. uni.navigateTo({
  397. url: `/pagesRepairs/message/message`
  398. })
  399. },
  400. // 点击悬浮加号按钮回调
  401. handleGoRepairs() {
  402. uni.$emit('goToRepairs', {
  403. show: 'repairs',
  404. title: '报修'
  405. })
  406. },
  407. // 顶部分段器切换回调
  408. onClickItem(e) {
  409. if (this.current != e.currentIndex) {
  410. this.current = e.currentIndex
  411. // console.log(this.current)
  412. if (this.current === 0) {
  413. // 团队数据
  414. this.getTeamCount()
  415. } else {
  416. // 个人数据
  417. this.getCount()
  418. }
  419. }
  420. },
  421. // 把数组每一项的第一个文字切割出来
  422. getCutting(list) {
  423. let str = ''
  424. list.forEach((ele, index) => {
  425. if (index !== 0 && list.length > 1) {
  426. str += '、' + ele.name.substring(0, 1)
  427. } else {
  428. str += ele.name.substring(0, 1)
  429. }
  430. })
  431. return str
  432. }
  433. }
  434. }
  435. </script>
  436. <style lang="scss" scoped>
  437. .container {
  438. width: 100vw;
  439. height: calc(100vh - 152rpx);
  440. font-size: 32rpx;
  441. overflow-y: auto;
  442. .top_bg {
  443. height: 165rpx;
  444. background-color: #6fb6b8;
  445. }
  446. .top_types {
  447. display: flex;
  448. justify-content: space-evenly;
  449. margin: auto;
  450. margin-top: -100rpx;
  451. width: 690rpx;
  452. height: 188rpx;
  453. border-radius: 10rpx;
  454. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  455. background-color: #fff;
  456. .types_box {
  457. flex: 1;
  458. display: flex;
  459. flex-direction: column;
  460. justify-content: center;
  461. align-items: center;
  462. .box_num {
  463. font-size: 46rpx;
  464. color: #ff5733;
  465. }
  466. .box_info {
  467. margin-top: 10rpx;
  468. font-size: 34rpx;
  469. }
  470. }
  471. }
  472. .top_types2 {
  473. box-sizing: border-box;
  474. margin: auto;
  475. margin-top: -100rpx;
  476. padding: 0 30rpx;
  477. width: 690rpx;
  478. height: 282rpx;
  479. border-radius: 10rpx;
  480. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  481. background-color: #fff;
  482. .top {
  483. height: 112rpx;
  484. border-bottom: 1rpx solid #e6e6e6;
  485. }
  486. .bottom {
  487. display: flex;
  488. justify-content: space-evenly;
  489. height: 170rpx;
  490. .bottom_box {
  491. flex: 1;
  492. display: flex;
  493. flex-direction: column;
  494. justify-content: center;
  495. align-items: center;
  496. .box_num {
  497. font-size: 46rpx;
  498. color: #ff5733;
  499. }
  500. .box_info {
  501. margin-top: 10rpx;
  502. font-size: 34rpx;
  503. }
  504. }
  505. }
  506. }
  507. .watch {
  508. box-sizing: border-box;
  509. margin: 20rpx auto;
  510. padding: 0 30rpx;
  511. width: 690rpx;
  512. border-radius: 10rpx;
  513. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  514. .watch_title {
  515. display: flex;
  516. align-items: center;
  517. height: 95rpx;
  518. font-size: 36rpx;
  519. border-bottom: 1rpx solid #e6e6e6;
  520. img {
  521. margin-right: 14rpx;
  522. width: 44rpx;
  523. height: 44rpx;
  524. }
  525. }
  526. .watch_color2 {
  527. color: #1e7dfb;
  528. }
  529. .watch_color3 {
  530. color: #ff5733;
  531. }
  532. .watch_td {
  533. display: flex;
  534. }
  535. .watch_pop {
  536. width: 100%;
  537. height: 575rpx;
  538. overflow-y: auto;
  539. background-color: #fff;
  540. .poop_title {
  541. box-sizing: border-box;
  542. padding: 0 30rpx;
  543. display: flex;
  544. align-items: center;
  545. justify-content: space-between;
  546. height: 100rpx;
  547. font-size: 34rpx;
  548. border-bottom: 1rpx solid #f5f5f5;
  549. .cancel {
  550. color: #888888;
  551. }
  552. .confirm {
  553. color: #1e7dfb;
  554. }
  555. }
  556. .poop_body {
  557. margin-top: 50rpx;
  558. .body_item {
  559. position: relative;
  560. display: flex;
  561. justify-content: center;
  562. align-items: center;
  563. height: 100rpx;
  564. border-bottom: 1rpx solid #f5f5f5;
  565. .body_item_info {
  566. }
  567. .body_item_icon {
  568. position: absolute;
  569. top: 30rpx;
  570. right: 85rpx;
  571. color: #1e7dfb;
  572. }
  573. }
  574. }
  575. }
  576. }
  577. .rank {
  578. position: relative;
  579. box-sizing: border-box;
  580. margin: 0 auto 100rpx;
  581. padding: 0 30rpx;
  582. width: 690rpx;
  583. height: 945rpx;
  584. border-radius: 10rpx;
  585. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  586. .rank_title {
  587. display: flex;
  588. align-items: center;
  589. height: 95rpx;
  590. font-size: 36rpx;
  591. border-bottom: 1rpx solid #e6e6e6;
  592. img {
  593. margin-right: 14rpx;
  594. width: 41rpx;
  595. height: 41rpx;
  596. }
  597. }
  598. .rank_charts {
  599. position: absolute;
  600. left: 30rpx;
  601. right: 30rpx;
  602. bottom: 0;
  603. width: 630rpx;
  604. height: 850rpx;
  605. }
  606. }
  607. .fixed {
  608. z-index: 2;
  609. position: fixed;
  610. right: 0;
  611. bottom: 160rpx;
  612. display: flex;
  613. justify-content: space-evenly;
  614. align-items: center;
  615. width: 252rpx;
  616. height: 123rpx;
  617. border-radius: 150rpx 0 0 150rpx;
  618. box-shadow: 0px 0px 7rpx rgba(0, 0, 0, 0.15);
  619. background-color: #fff;
  620. img {
  621. width: 76rpx;
  622. height: 76rpx;
  623. }
  624. .img {
  625. width: 88rpx;
  626. height: 88rpx;
  627. }
  628. }
  629. }
  630. </style>