home.vue 16 KB

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