home.vue 16 KB

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