home.vue 16 KB

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