home.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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, index_pop) in workArray" :key="index_pop" @click="handleChangeWork(item)">
  91. <view class="body_item_info">
  92. {{ item }}
  93. </view>
  94. <view class="body_item_icon" v-if="defaultList.includes(item)">✔</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 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. items: ['团队数据统计', '个人数据统计'],
  137. // 分段器当前索引
  138. current: 0,
  139. // 柱状图数据
  140. chartData: {
  141. categories: ['张三', '李四', '王五', '老六', '刘八'],
  142. series: [
  143. {
  144. name: '好评数',
  145. data: [35, 36, 31, 33, 13]
  146. },
  147. {
  148. name: '完成数',
  149. data: [18, 27, 21, 24, 6]
  150. }
  151. ]
  152. },
  153. opts: {
  154. color: ['#1890FF', '#91CB74', '#FAC858', '#EE6666', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc'],
  155. padding: [15, 30, 0, 5],
  156. enableScroll: false,
  157. legend: {},
  158. xAxis: {
  159. boundaryGap: 'justify',
  160. disableGrid: false,
  161. gridType: 'dash',
  162. gridColor: '#E5E5E5',
  163. min: 0,
  164. axisLine: false,
  165. max: 40
  166. },
  167. yAxis: {},
  168. extra: {
  169. bar: {
  170. type: 'group',
  171. width: 15,
  172. meterBorde: 1,
  173. meterFillColor: '#FFFFFF',
  174. activeBgColor: '#000000',
  175. activeBgOpacity: 0.08,
  176. linearType: 'custom',
  177. barBorderCircle: true,
  178. seriesGap: 2,
  179. categoryGap: 2
  180. }
  181. }
  182. },
  183. // 表格数据
  184. // status状态: 0 接单中 1 订单饱和 2 停止接单
  185. // work状态: 0 正常班次 1 值班班次
  186. tableData: [
  187. {
  188. name: '张三',
  189. type: '电工',
  190. status: 0,
  191. work: ['正常班次', '值班班次']
  192. },
  193. {
  194. name: '张三三',
  195. type: '泥工',
  196. status: 1,
  197. work: ['值班班次']
  198. },
  199. {
  200. name: '张三',
  201. type: '电工',
  202. status: 2,
  203. work: ['正常班次']
  204. },
  205. {
  206. name: '张三三',
  207. type: '泥工',
  208. status: 0,
  209. work: ['值班班次']
  210. },
  211. {
  212. name: '张三',
  213. type: '电工',
  214. status: 1,
  215. work: ['值班班次']
  216. },
  217. {
  218. name: '张三三',
  219. type: '泥工',
  220. status: 2,
  221. work: ['正常班次']
  222. }
  223. ]
  224. }
  225. },
  226. mounted() {
  227. console.log('主页页面加载')
  228. const repairsUserInfo = uni.getStorageSync('repairsUserInfo')
  229. this.btns = repairsUserInfo.btns
  230. console.log(this.btns)
  231. },
  232. methods: {
  233. // 是否值班弹窗确定按钮回调
  234. handlePopConfirm() {
  235. uni.showModal({
  236. title: '提示',
  237. content: '确定修改是否值班状态吗?',
  238. success: (res) => {
  239. if (res.confirm) {
  240. this.tableData[this.changeIndex].work = this.defaultList
  241. console.log('用户点击确定')
  242. } else if (res.cancel) {
  243. console.log('用户点击取消')
  244. }
  245. }
  246. })
  247. this.$refs.popup_work.close()
  248. },
  249. // 点击值班状态回调
  250. handleChange(item, index) {
  251. if (this.btns.includes('表格编辑')) {
  252. this.$refs.popup_work.open('bottom')
  253. this.changeIndex = index
  254. this.defaultList = JSON.parse(JSON.stringify(item.work))
  255. }
  256. },
  257. // 切换值班状态回调
  258. handleChangeWork(item) {
  259. if (this.defaultList.includes(item)) {
  260. const temIndex = this.defaultList.indexOf(item)
  261. this.defaultList.splice(temIndex, 1)
  262. } else {
  263. this.defaultList.push(item)
  264. }
  265. },
  266. // 切换排班状态回调
  267. bindPickerChange(e, item) {
  268. uni.showModal({
  269. title: '提示',
  270. content: '确定修改状态吗?',
  271. success: (res) => {
  272. if (res.confirm) {
  273. item.status = e.detail.value
  274. console.log('用户点击确定')
  275. } else if (res.cancel) {
  276. console.log('用户点击取消')
  277. }
  278. }
  279. })
  280. },
  281. // 点击悬浮消息按钮回调
  282. handleGoMsg() {
  283. uni.navigateTo({
  284. url: '/pagesRepairs/message/message'
  285. })
  286. },
  287. // 点击悬浮加号按钮回调
  288. handleGoRepairs() {
  289. uni.$emit('goToRepairs', {
  290. show: 'repairs',
  291. title: '报修'
  292. })
  293. },
  294. // 顶部分段器切换回调
  295. onClickItem(e) {
  296. if (this.current != e.currentIndex) {
  297. this.current = e.currentIndex
  298. console.log(this.current)
  299. }
  300. },
  301. // 把数组每一项的第一个文字切割出来
  302. getCutting(list) {
  303. let str = ''
  304. list.forEach((ele, index) => {
  305. if (index + 1 == list.length && list.length > 1) {
  306. str += '、' + ele.substring(0, 1)
  307. } else {
  308. str += ele.substring(0, 1)
  309. }
  310. })
  311. return str
  312. }
  313. }
  314. }
  315. </script>
  316. <style lang="scss" scoped>
  317. .container {
  318. width: 100vw;
  319. height: calc(100vh - 152rpx);
  320. font-size: 32rpx;
  321. overflow-y: auto;
  322. .top_bg {
  323. height: 165rpx;
  324. background-color: #6fb6b8;
  325. }
  326. .top_types {
  327. display: flex;
  328. justify-content: space-evenly;
  329. margin: auto;
  330. margin-top: -100rpx;
  331. width: 690rpx;
  332. height: 188rpx;
  333. border-radius: 10rpx;
  334. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  335. background-color: #fff;
  336. .types_box {
  337. flex: 1;
  338. display: flex;
  339. flex-direction: column;
  340. justify-content: center;
  341. align-items: center;
  342. .box_num {
  343. font-size: 46rpx;
  344. color: #ff5733;
  345. }
  346. .box_info {
  347. margin-top: 10rpx;
  348. font-size: 34rpx;
  349. }
  350. }
  351. }
  352. .top_types2 {
  353. box-sizing: border-box;
  354. margin: auto;
  355. margin-top: -100rpx;
  356. padding: 0 30rpx;
  357. width: 690rpx;
  358. height: 282rpx;
  359. border-radius: 10rpx;
  360. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  361. background-color: #fff;
  362. .top {
  363. height: 112rpx;
  364. border-bottom: 1rpx solid #e6e6e6;
  365. }
  366. .bottom {
  367. display: flex;
  368. justify-content: space-evenly;
  369. height: 170rpx;
  370. .bottom_box {
  371. flex: 1;
  372. display: flex;
  373. flex-direction: column;
  374. justify-content: center;
  375. align-items: center;
  376. .box_num {
  377. font-size: 46rpx;
  378. color: #ff5733;
  379. }
  380. .box_info {
  381. margin-top: 10rpx;
  382. font-size: 34rpx;
  383. }
  384. }
  385. }
  386. }
  387. .watch {
  388. box-sizing: border-box;
  389. margin: 20rpx auto;
  390. padding: 0 30rpx;
  391. width: 690rpx;
  392. border-radius: 10rpx;
  393. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  394. .watch_title {
  395. display: flex;
  396. align-items: center;
  397. height: 95rpx;
  398. font-size: 36rpx;
  399. border-bottom: 1rpx solid #e6e6e6;
  400. img {
  401. margin-right: 14rpx;
  402. width: 44rpx;
  403. height: 44rpx;
  404. }
  405. }
  406. .watch_color {
  407. color: #6fb6b8;
  408. }
  409. .watch_color2 {
  410. color: #1e7dfb;
  411. }
  412. .watch_color3 {
  413. color: #ff5733;
  414. }
  415. .watch_td {
  416. display: flex;
  417. }
  418. .watch_pop {
  419. width: 100%;
  420. height: 575rpx;
  421. overflow-y: auto;
  422. background-color: #fff;
  423. .poop_title {
  424. box-sizing: border-box;
  425. padding: 0 30rpx;
  426. display: flex;
  427. align-items: center;
  428. justify-content: space-between;
  429. height: 100rpx;
  430. font-size: 34rpx;
  431. border-bottom: 1rpx solid #f5f5f5;
  432. .cancel {
  433. color: #888888;
  434. }
  435. .confirm {
  436. color: #1e7dfb;
  437. }
  438. }
  439. .poop_body {
  440. margin-top: 50rpx;
  441. .body_item {
  442. position: relative;
  443. display: flex;
  444. justify-content: center;
  445. align-items: center;
  446. height: 100rpx;
  447. border-bottom: 1rpx solid #f5f5f5;
  448. .body_item_info {
  449. }
  450. .body_item_icon {
  451. position: absolute;
  452. top: 30rpx;
  453. right: 85rpx;
  454. color: #1e7dfb;
  455. }
  456. }
  457. }
  458. }
  459. }
  460. .rank {
  461. position: relative;
  462. box-sizing: border-box;
  463. margin: 0 auto 100rpx;
  464. padding: 0 30rpx;
  465. width: 690rpx;
  466. height: 745rpx;
  467. border-radius: 10rpx;
  468. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  469. .rank_title {
  470. display: flex;
  471. align-items: center;
  472. height: 95rpx;
  473. font-size: 36rpx;
  474. border-bottom: 1rpx solid #e6e6e6;
  475. img {
  476. margin-right: 14rpx;
  477. width: 41rpx;
  478. height: 41rpx;
  479. }
  480. }
  481. .rank_charts {
  482. position: absolute;
  483. bottom: 0;
  484. width: 100%;
  485. height: 650rpx;
  486. }
  487. }
  488. .fixed {
  489. z-index: 2;
  490. position: fixed;
  491. right: 0;
  492. bottom: 155rpx;
  493. display: flex;
  494. justify-content: space-evenly;
  495. align-items: center;
  496. width: 252rpx;
  497. height: 123rpx;
  498. border-radius: 150rpx 0 0 150rpx;
  499. box-shadow: 0px 0px 7rpx rgba(0, 0, 0, 0.15);
  500. background-color: #fff;
  501. img {
  502. width: 76rpx;
  503. height: 76rpx;
  504. }
  505. .img {
  506. width: 88rpx;
  507. height: 88rpx;
  508. }
  509. }
  510. }
  511. </style>