home.vue 13 KB

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