jabin 2 سال پیش
والد
کامیت
8954f824ad
3فایلهای تغییر یافته به همراه207 افزوده شده و 182 حذف شده
  1. 23 8
      pages/home/components/navigation.vue
  2. 181 172
      pages/home/home.vue
  3. 3 2
      pages/index/index.scss

+ 23 - 8
pages/home/components/navigation.vue

@@ -9,7 +9,9 @@
 </template>
 
 <script>
-	import { getTodoTaskPage } from '@/api/wt/index.js'
+	import {
+		getTodoTaskPage
+	} from '@/api/wt/index.js'
 	export default {
 		props: {
 			workOrder: {
@@ -18,8 +20,7 @@
 		},
 		data() {
 			return {
-				workList: [
-					{
+				workList: [{
 						class: 'iconfont icon-bianji',
 						title: '我的工单',
 						link_url: '/pages/home/myTicket/myTicket',
@@ -54,11 +55,19 @@
 				workOrderNum: 0
 			}
 		},
+		watch: {
+			workOrder: {
+				handler(newV, oldV) {
+					this.workList[0].badge = String(newV.total)
+				},
+				deep: true
+			}
+		},
 		created() {
 			this.getCount()
-			this.$nextTick(()=>{
-				this.workList[0].badge = String(this.workOrder.total)
-			})
+			// this.$nextTick(()=>{
+			// 	this.workList[0].badge = String(this.workOrder.total)
+			// })
 		},
 		methods: {
 			toNav(url) {
@@ -111,6 +120,7 @@
 			margin-top: 5rpx;
 			align-items: center;
 			flex: 1;
+
 			span {
 				padding: 18rpx;
 				color: #ffffff;
@@ -120,8 +130,9 @@
 
 			.badge {
 				position: absolute;
-				top: 0;
-				left: 115rpx;
+				top: -8rpx;
+				left: 125rpx;
+				font-size: 24rpx;
 				padding: 0rpx 10rpx;
 				border-radius: 38rpx;
 				background-color: #ff4949;
@@ -129,15 +140,19 @@
 				font-style: normal;
 			}
 		}
+
 		.nav-item:nth-child(1) span {
 			background-color: $uni-color-success;
 		}
+
 		.nav-item:nth-child(2) span {
 			background-color: $uni-color-warning;
 		}
+
 		.nav-item:nth-child(3) span {
 			background-color: $uni-color-primary;
 		}
+
 		.nav-item:nth-child(4) span {
 			background-color: $uni-color-error;
 		}

+ 181 - 172
pages/home/home.vue

@@ -1,182 +1,191 @@
 <template>
-  <view>
-    <uni-nav-bar
-      fixed="true"
-      statusBar="true"
-      right-icon="scan"
-      title="工作台"
-      @clickLeft="back"
-      @clickRight="HandlScanCode"
-    ></uni-nav-bar>
-    <!-- <uni-nav-bar fixed="true" statusBar="true" title="工作台"></uni-nav-bar> -->
-    <navigation :workOrder="workOrder" ref="navigationRef"></navigation>
-    <!-- 设备主管 -->
-    <equipment v-if="roleId == 102" ref="equipmentRef"></equipment>
-    <!-- 运维 -->
-    <Mocha v-if="roleId == 157" ref="mochaRef"></Mocha>
-    <!-- 模具舟皿 -->
-    <mould v-if="roleId == 155" ref="mouldRef"></mould>
-    <!-- 备品备件 -->
-    <sparePart v-if="roleId == 150" ref="sparePartRef"></sparePart>
-    <!-- <ScanCode ref="ScanCode" :model="'uni'"></ScanCode> -->
-  </view>
+	<view>
+		<uni-nav-bar fixed="true" statusBar="true" right-icon="scan" title="工作台" @clickLeft="back"
+			@clickRight="HandlScanCode"></uni-nav-bar>
+		<!-- <uni-nav-bar fixed="true" statusBar="true" title="工作台"></uni-nav-bar> -->
+		<navigation :workOrder="workOrder" ref="navigationRef"></navigation>
+		<!-- 设备主管 -->
+		<equipment v-if="roleId == 102" ref="equipmentRef"></equipment>
+		<!-- 运维 -->
+		<Mocha v-if="roleId == 157" ref="mochaRef"></Mocha>
+		<!-- 模具舟皿 -->
+		<mould v-if="roleId == 155" ref="mouldRef"></mould>
+		<!-- 备品备件 -->
+		<sparePart v-if="roleId == 150" ref="sparePartRef"></sparePart>
+		<!-- <ScanCode ref="ScanCode" :model="'uni'"></ScanCode> -->
+	</view>
 </template>
 
 <script>
-import navigation from './components/navigation.vue'
-import equipment from './pages/equipment/equipment.vue'
-import Mocha from './pages/Mocha/Mocha.vue'
-import mould from './pages/mould/mould.vue'
-import sparePart from './pages/sparePart/sparePart.vue'
-import ScanCode from '@/components/ScanCode.vue'
-import { postJ, post, get } from '@/utils/api'
-import { statistics } from '@/api/myTicket'
-export default {
-  components: {
-    navigation,
-    equipment,
-    Mocha,
-    mould,
-    sparePart,
-    ScanCode
-  },
-  onShow () {
-    this.init()
-    let _this = this
-    uni.$off('scancodedate') // 每次进来先 移除全局自定义事件监听器
-    uni.$on('scancodedate', function (data) {
-      console.log(data, '-----scancodedate')
-      _this.cbScancodedate(data)
-    })
-	this.getStatistics()
-    // this.Scancodedate()
-  },
-  onUnload () {
-    uni.$off('scancodedate')
-  },
-  onHide () {
-    uni.$off('scancodedate')
-  },
-  data () {
-    return {
-      roleId: null,
-      timer: null,
-      qrContent: null,
-      barType: null,
-      // 扫码后的设备信息
-      equipmentInfo: '',
-      qrContent: '',
-      barType: '',
-	  workOrder: {},  // 工单统计数据
-    }
-  },
-  created () {
-    uni.getStorage({
-      key: 'userInfo',
-      success: res => {
-        this.roleId = res.data.role.id
-      }
-    })
-  },
-  methods: {
-	getStatistics(){  // 获取工单统计数
-		statistics().then(res=>{
-			this.workOrder = res
-		})
-	},
-    init () {
-      this.$refs.navigationRef && this.$refs.navigationRef.getCount()
-      this.$refs.equipmentRef && this.$refs.equipmentRef.getData()
-      this.$refs.mochaRef && this.$refs.mochaRef.getData()
-      this.$refs.mouldRef &&
-        (this.$refs.mouldRef.getBoatInventoryCountList(),
-        this.$refs.mouldRef.getModeInventoryCountList())
-      this.$refs.sparePartRef && this.$refs.sparePartRef.getData()
-      this.timer = setTimeout(() => {
-        this.init()
-      }, 6000) 
-    },
-    // 相机扫码
-    HandlScanCode () {
-      let _this = this
-      uni.scanCode({
-        success: function (res) {
-          _this.Scancodedate(res.result)
-        }
-      })
-      //_this.Scancodedate('res')
-    },
-    // 根据条码请求设备数据
-    getData () {
-      let par = {
-        barType: this.barType,
-        qrContent: this.qrContent
-      }
-      this.equipmentInfo = {}
-      return postJ(this.apiUrl + '/scan/getAssetInfo', par)
-        .then(res => {
-          console.log(res.data)
-          this.equipmentInfo = res.data
-        })
-        .catch(err => {
-          console.log(err, 'err-----------------')
-          uni.showToast({
-            title: '系统错误!',
-            icon: 'none',
-            duration: 2000
-          })
-        })
-    },
-    // 扫码枪扫码
-    cbScancodedate (data) {
-      this.Scancodedate(data.code)
-    },
-    async Scancodedate (code) {
-      this.qrContent = code.trim()
-      // this.qrContent = 'w01000002100001@_@0' //code.trim()
-      //this.qrContent = '005/w01000001120041/锤锤专用02-不拆包-批量/规格01//成型/成型工序@_@0'
-      this.barType = this.setBarType(this.qrContent)
-      await this.getData()
+	import navigation from './components/navigation.vue'
+	import equipment from './pages/equipment/equipment.vue'
+	import Mocha from './pages/Mocha/Mocha.vue'
+	import mould from './pages/mould/mould.vue'
+	import sparePart from './pages/sparePart/sparePart.vue'
+	import ScanCode from '@/components/ScanCode.vue'
+	import {
+		postJ,
+		post,
+		get
+	} from '@/utils/api'
+	import {
+		statistics
+	} from '@/api/myTicket'
+	export default {
+		components: {
+			navigation,
+			equipment,
+			Mocha,
+			mould,
+			sparePart,
+			ScanCode
+		},
+		onShow() {
+			this.init()
+			let _this = this
+			uni.$off('scancodedate') // 每次进来先 移除全局自定义事件监听器
+			uni.$on('scancodedate', function(data) {
+				console.log(data, '-----scancodedate')
+				_this.cbScancodedate(data)
+			})
+			this.getStatistics()
+			// this.Scancodedate()
+		},
+		onLoad() {
+			this.getStatistics()
+		},
+		onUnload() {
+			uni.$off('scancodedate')
+		},
+		onHide() {
+			uni.$off('scancodedate')
+		},
+		data() {
+			return {
+				roleId: null,
+				timer: null,
+				qrContent: null,
+				barType: null,
+				// 扫码后的设备信息
+				equipmentInfo: '',
+				qrContent: '',
+				barType: '',
+				workOrder: {
+					maintenanceNum: 0,
+					patrolInspection: 0,
+					quantityNum: 0,
+					repairsNum: 0,
+					total: 0
+				}, // 工单统计数据
+			}
+		},
+		created() {
+			uni.getStorage({
+				key: 'userInfo',
+				success: res => {
+					this.roleId = res.data.role.id
+				}
+			})
+		},
+		methods: {
+			getStatistics() { // 获取工单统计数
+				statistics().then(res => {
+					this.workOrder = res
+				})
+			},
+			init() {
+				this.$refs.navigationRef && this.$refs.navigationRef.getCount()
+				this.$refs.equipmentRef && this.$refs.equipmentRef.getData()
+				this.$refs.mochaRef && this.$refs.mochaRef.getData()
+				this.$refs.mouldRef &&
+					(this.$refs.mouldRef.getBoatInventoryCountList(),
+						this.$refs.mouldRef.getModeInventoryCountList())
+				this.$refs.sparePartRef && this.$refs.sparePartRef.getData()
+				this.timer = setTimeout(() => {
+					this.init()
+				}, 6000)
+			},
+			// 相机扫码
+			HandlScanCode() {
+				let _this = this
+				uni.scanCode({
+					success: function(res) {
+						_this.Scancodedate(res.result)
+					}
+				})
+				//_this.Scancodedate('res')
+			},
+			// 根据条码请求设备数据
+			getData() {
+				let par = {
+					barType: this.barType,
+					qrContent: this.qrContent
+				}
+				this.equipmentInfo = {}
+				return postJ(this.apiUrl + '/scan/getAssetInfo', par)
+					.then(res => {
+						console.log(res.data)
+						this.equipmentInfo = res.data
+					})
+					.catch(err => {
+						console.log(err, 'err-----------------')
+						uni.showToast({
+							title: '系统错误!',
+							icon: 'none',
+							duration: 2000
+						})
+					})
+			},
+			// 扫码枪扫码
+			cbScancodedate(data) {
+				this.Scancodedate(data.code)
+			},
+			async Scancodedate(code) {
+				this.qrContent = code.trim()
+				// this.qrContent = 'w01000002100001@_@0' //code.trim()
+				//this.qrContent = '005/w01000001120041/锤锤专用02-不拆包-批量/规格01//成型/成型工序@_@0'
+				this.barType = this.setBarType(this.qrContent)
+				await this.getData()
 
-      if (this.equipmentInfo.assetCode) {
-        if (this.equipmentInfo.assetType != 1) {
-          uni.showToast({
-            title: '请扫描生产设备码!',
-            icon: 'none',
-            duration: 2000
-          })
+				if (this.equipmentInfo.assetCode) {
+					if (this.equipmentInfo.assetType != 1) {
+						uni.showToast({
+							title: '请扫描生产设备码!',
+							icon: 'none',
+							duration: 2000
+						})
 
-          return
-        }
-        let par = {
-          info: encodeURIComponent(JSON.stringify(this.equipmentInfo)),
-          qrContent: this.qrContent
-        }
-        par = this.URLSearchParams(par)
-        console.log('qrwewett')
-        uni.navigateTo({
-          url: '/pages/equipment_ledger/index?' + par
-        })
-      }
-    },
-    // 设置barType
-    setBarType (val) {
-      let index = val.indexOf('@_@')
-      let result = 0
-      if (index !== -1) {
-        let item = val.substr(index + 3, 1)
-        if (item) {
-          result = Number(item)
-        }
-      }
-      return result
-    }
-  }
-}
+						return
+					}
+					let par = {
+						info: encodeURIComponent(JSON.stringify(this.equipmentInfo)),
+						qrContent: this.qrContent
+					}
+					par = this.URLSearchParams(par)
+					console.log('qrwewett')
+					uni.navigateTo({
+						url: '/pages/equipment_ledger/index?' + par
+					})
+				}
+			},
+			// 设置barType
+			setBarType(val) {
+				let index = val.indexOf('@_@')
+				let result = 0
+				if (index !== -1) {
+					let item = val.substr(index + 3, 1)
+					if (item) {
+						result = Number(item)
+					}
+				}
+				return result
+			}
+		}
+	}
 </script>
 
 <style lang="scss" scoped>
-page {
-  background-color: $page-bg;
-}
+	page {
+		background-color: $page-bg;
+	}
 </style>

+ 3 - 2
pages/index/index.scss

@@ -31,8 +31,9 @@ page{
 			}
 			.badge {
 				position: absolute;
-				top: 0;
-				left: 115rpx;
+				top: -8rpx;
+				left: 125rpx;
+				font-size: 24rpx;
 				padding: 0rpx 10rpx;
 				border-radius: 38rpx;
 				background-color: #ff4949;