Browse Source

工序追溯

chen 1 năm trước cách đây
mục cha
commit
6d66c4669a

+ 1 - 1
main.js

@@ -56,7 +56,7 @@ const api = {
 	},
 	apiHost: function() {
 		//接口地址
-		// return 'http://127.0.0.1/'
+		// return 'http://192.168.31.75/'
 		return 'https://ai.my-123.cn/api/'
 	},
 	

+ 5 - 0
pages.json

@@ -29,6 +29,11 @@
 			"style": {
 			}
 		}	,
+		{
+			"path": "pages/product/process",
+			"style": {
+			}
+		}	,
 		{
 			"path": "pages/product/reworkRecord",
 			"style": {

+ 20 - 0
pages/index/index.vue

@@ -26,6 +26,22 @@
 		          </view>
 		        </view>
 		      </tn-list-cell>
+		      <tn-list-cell v-if="permission == 1 || permission == 3">
+		        <view class="message tn-margin-left message tn-margin-top tn-margin-bottom" @click="toPage(6)">
+		          <view class="message__left">
+					<view class="tn-icon-relation tn-cool-bg-color-2 item-icon"></view>
+		          </view>
+		          <view class="message__middle">
+		            <view class="message__name">工序追溯</view>
+		            <view class="message__content tn-text-ellipsis">检验工序追溯信息、预警信息提示</view>
+		          </view>
+		          <view class="message__right">
+		            <view class="message__tips tn-margin-right">
+		              <text class="message__tips__icon tn-icon-sound-close tn-icon-right"></text>
+		            </view>
+		          </view>
+		        </view>
+		      </tn-list-cell>
 		      <tn-list-cell v-if="permission == 1 || permission == 3">
 		        <view class="message tn-margin-left message tn-margin-top tn-margin-bottom" @click="toPage(2)">
 		          <view class="message__left">
@@ -136,6 +152,10 @@
 				uni.navigateTo({
 					url:"/pages/product/query?status=-1" 
 				})
+			}else if(type==6){ 
+				uni.navigateTo({
+					url:"/pages/product/process" 
+				})
 			}
 		}
     }

+ 139 - 3
pages/product/details.vue

@@ -1,5 +1,5 @@
 <template>
-  <view >
+  <view class="page">
 	  <tn-nav-bar fixed>产品详情</tn-nav-bar>
 	  <view class="" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
 		  <view class="tn-margin">
@@ -33,7 +33,7 @@
 				    <view class="list__left">
 				      <view class="list__left__text tn-color-gray--dark">状态</view>
 				    </view>
-				    <view class="list__right">{{details.status==1?'维修中':details.status==2?'已下线':details.status==3?'已入库':details.status==0?'作废':''}}</view>
+				    <view class="list__right">{{details.status==1?'维修中':details.status==2?'已下线':details.status==3?'已入库':details.status==0?'作废':details.status==-1?'生产中':''}}</view>
 				  </view>
 				</tn-list-cell>
 				<tn-list-cell>
@@ -186,6 +186,24 @@
 					  </view>
 					</tn-list-cell>
 				  </template>
+				  <template v-if="details.isEnableProcess==1">
+					  <view class="list tn-border-solid">
+					    <view class="tn-flex tn-border-solid-bottom tn-main-gradient-blue--reverse">
+					  	<view class="tn-flex-2 tn-text-center">工序</view>
+					  	<view class="tn-flex-2 tn-text-center">状态</view>
+					  	<view class="tn-flex-2 tn-text-center">是否达标</view>
+					  	<view class="tn-flex-2 tn-text-center">操作时间</view>
+					    </view>
+					    <block  v-for="(item,index) in details.productProcessList ">
+					  	  <view class="tn-flex tn-border-solid-bottom" >
+					  		<view class="tn-flex-2 tn-text-center tn-color-blue"  @click="showProcessDetail(item)">{{item.processName}}({{item.processCode}})</view>
+					  		<view class="tn-flex-2 tn-text-center">{{item.status==1?'已完成':'未完成'}}</view>
+					  		<view class="tn-flex-2 tn-text-center">{{item.isStandards==1?'达标':item.isStandards==-1?'达标':item.isStandards==0?'未达标':''}}</view>
+							<view class="tn-flex-2 tn-text-center">{{item.status==1?item.updateTime:''}}</view>
+					  	  </view>
+					    </block>
+					  </view>
+				  </template>
 				  
 				  
 				  <template v-if="details.status==2 && (details.aiStatus==0 || details.aiStatus==1 )">
@@ -201,6 +219,106 @@
 			  </view>
 		  </view>
 	  </view>
+	  
+	  <tn-popup
+	    v-model="showProcess"
+	    :marginTop="vuex_custom_bar_height"
+	    length="50%"
+	    mode="center"
+	    :borderRadius="20"
+	    :closeBtn="true"
+		width="80%"
+	    :maskCloseable="true"
+	  >
+		  <view class="tn-padding" style="max-height: 60vh;">
+			<tn-list-cell>
+			  <view class="list-icon-text">
+				<view class="list__left">
+				  <view class="list__left__text tn-color-gray--dark">工序</view>
+				</view>
+				<view class="list__right">{{productProcess.processName}}({{productProcess.processCode}}</view>
+			  </view>
+			</tn-list-cell>
+			<tn-list-cell>
+			  <view class="list-icon-text">
+				<view class="list__left">
+				  <view class="list__left__text tn-color-gray--dark">是否追溯</view>
+				</view>
+				<view class="list__right">{{productProcess.isRetrospect==1?'是':'否'}}</view>
+			  </view>
+			</tn-list-cell>
+			<tn-list-cell  v-if="productProcess.isStandards">
+			  <view class="list-icon-text">
+				<view class="list__left">
+				  <view class="list__left__text tn-color-gray--dark">是否达标</view>
+				</view>
+				<view class="list__right">{{productProcess.isStandards==1?'达标':productProcess.isStandards==-1?'达标':productProcess.isStandards==0?'未达标':''}}</view>
+			  </view>
+			</tn-list-cell>
+			<tn-list-cell>
+			  <view class="list-icon-text">
+				<view class="list__left">
+				  <view class="list__left__text tn-color-gray--dark">是否拍照</view>
+				</view>
+				<view class="list__right">{{productProcess.isPhotograph==1?'是':'否'}}</view>
+			  </view>
+			</tn-list-cell>
+			<tn-list-cell v-if="productProcess.images && productProcess.isPhotograph==1">
+			  <view class="list-icon-text">
+				<view class="list__left">
+				  <view class="list__left__text tn-color-gray--dark">拍照图片</view>
+				</view>
+				<view class="list__right">
+					<view
+					  class="tn-image-upload__item tn-image-upload__item-preview"
+					  :style="{width: $tn.string.getLengthUnitValue(150),height: $tn.string.getLengthUnitValue(150)}"
+					  v-for="(item,index) in productProcess.images.split(',')">
+					<image
+					  class="tn-image-upload__item-preview__image"
+					  :src="item"
+					  :mode="imageMode"
+					  @tap.stop="doPreviewImage(item)"
+					></image>
+					</view>
+				</view>
+			  </view>
+			</tn-list-cell>
+			<tn-list-cell>
+			  <view class="list-icon-text">
+				<view class="list__left">
+				  <view class="list__left__text tn-color-gray--dark">操作人</view>
+				</view>
+				<view class="list__right">{{productProcess.operatorName}}</view>
+			  </view>
+			</tn-list-cell>
+			<tn-list-cell>
+			  <view class="list-icon-text">
+				<view class="list__left">
+				  <view class="list__left__text tn-color-gray--dark">操作时间</view>
+				</view>
+				<view class="list__right">{{productProcess.updateTime}}</view>
+			  </view>
+			</tn-list-cell>
+			
+			<template v-if="productProcess.isRetrospect==1">
+			  <view class="list  tn-border-solid">
+				<view class="tn-flex tn-border-solid-bottom tn-main-gradient-blue--reverse">
+				<view class="tn-flex-2 tn-text-center">追溯范围</view>
+				<view class="tn-flex-2 tn-text-center">标准值</view>
+				<view class="tn-flex-2 tn-text-center">实际值</view>
+				</view>
+				<block  v-for="(item,index) in productProcess.details ">
+				  <view class="tn-flex tn-border-solid-bottom" >
+					<view class="tn-flex-2 tn-text-center ">{{item.processItemName}}</view>
+					<view class="tn-flex-2 tn-text-center" v-if="item.valueType=='2'">{{item.minValue}}~{{item.maxValue}} {{item.unit?item.unit:''}}</view>
+					<view class="tn-flex-2 tn-text-center" v-else>{{item.processItemValue}}{{item.unit?item.unit:''}}</view>
+					<view class="tn-flex-2 tn-text-center">{{item.value}}</view>
+				  </view>
+				</block>
+			  </view>
+			</template>
+		  </view>
+	  </tn-popup>
   </view>
 </template>
 
@@ -209,6 +327,8 @@
     data(){
       return {
 		  details:{},
+		  showProcess:false,
+		  productProcess:{},
 	  }
     },
 	onLoad(option){
@@ -226,7 +346,10 @@
 			}).catch((res) => {
 			})
 		},
-		
+		showProcessDetail(item){
+			this.showProcess = true;
+			this.productProcess=item;
+		},
 		productOkOrNg(isNg){
 			this.btnLoad = true;
 			let that = this,
@@ -287,6 +410,19 @@
 	}
 	
 	
+	.page{
+		.list{
+			.tn-flex{
+				padding-top: 30rpx;
+				padding-bottom: 30rpx;
+				view{
+					
+				}
+			}
+		}
+	}
+	
+	
 	.tn-image-upload {
 	  display: flex;
 	  flex-direction: row;

+ 2 - 2
pages/product/inStock.vue

@@ -249,8 +249,8 @@
 		  for(var i=0;i<item.inStockNum;i++){
 		  	products.push(JSON.parse(JSON.stringify(that.info)))
 		  }
-		  that.showWaterCooling=(","+item.inStockFormItem+",").includes(",cold_qr_code,"); 
-		  that.showAirtight=(","+item.inStockFormItem+",").includes(",cold_qr_code,"); 
+		  that.showWaterCooling=(","+item.inStockFormItem+",").includes(",water_cooling,"); 
+		  that.showAirtight=(","+item.inStockFormItem+",").includes(",airtight,"); 
 		  that.showColdQrCode=(","+item.inStockFormItem+",").includes(",cold_qr_code,"); 
 		  
 		  that.products = products

+ 340 - 0
pages/product/process.vue

@@ -0,0 +1,340 @@
+<template>
+  <view >
+	  <tn-nav-bar fixed>下线查询</tn-nav-bar>
+	  <view class="" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
+		  <view v-if="!errorMsg && !process" class="tn-border-solid">
+			<view class="tn-flex tn-flex-col-bottom tn-margin">
+			  <view class="tn-flex-3 align-content-item  tn-text-center ">
+				  <view class="content tn-flex tn-flex-direction-row tn-flex-col-center">
+					<view class="content__title">产品二维码:</view>
+					<view class="content__data tn-flex-1">
+					  <tn-input v-model="qrCode" type="text" placeholder="请扫描产品二维码" border :height="60" >
+					  </tn-input>
+					</view>
+				  </view>
+			  </view>
+			  <view class="tn-flex-1 align-content-item  tn-text-right">
+				  <tn-button backgroundColor="#01BEFF"  fontColor="tn-color-white" icon="tn-icon-scan"  @click="openScan">
+					  <span class="tn-icon-scan tn-margin-right-xs"></span>扫码
+				  </tn-button>
+			  </view>
+			</view>
+		  </view>
+		  <view v-if="!errorMsg && !process" class="tn-margin">
+			  <tn-button :shadow="true" width="100%"  backgroundColor="#01BEFF"  fontColor="#FFFFFF" margin="10rpx 0" @click="getProductProcess">开始追溯</tn-button>
+		  </view>
+		  <view v-if="errorMsg" class="tn-padding tn-bg-white tn-border-solid-top">
+			<tn-empty  icon="../../../static/image/cart.jpg" :text="errorMsg" :imgWidth="200" :imgHeight="200" class="tn-margin-top-xl "></tn-empty>
+			  <tn-button :shadow="true" width="100%"  backgroundColor="#01BEFF"  fontColor="#FFFFFF" margin="30rpx 0" @click="initProcess">返回</tn-button>
+		  </view>
+			<view v-if="process">
+				<!-- <tn-tabs :list="[{name:'产品信息'}]" :current="0" ></tn-tabs> -->
+				<view class="tn-margin tn-border-solid-top tn-no-margin-top">
+					<tn-list-cell>
+					  <view class="list-icon-text">
+						<view class="list__left">
+						  <view class="list__left__text tn-color-gray--dark">产品名称</view>
+						</view>
+						<view class="list__right">{{product?product.productName:productModel.productName}}</view>
+					  </view>
+					</tn-list-cell>
+					<tn-list-cell>
+					  <view class="list-icon-text">
+						<view class="list__left">
+						  <view class="list__left__text tn-color-gray--dark">产品型号</view>
+						</view>
+						<view class="list__right">{{product?product.productModel:productModel.productModel}}</view>
+					  </view>
+					</tn-list-cell>
+					<tn-list-cell>
+					  <view class="list-icon-text">
+						<view class="list__left">
+						  <view class="list__left__text tn-color-gray--dark">二维码编号</view>
+						</view>
+						<view class="list__right">{{qrCode}}</view>
+					  </view>
+					</tn-list-cell>
+					<tn-list-cell>
+					  <view class="list-icon-text">
+						<view class="list__left">
+						  <view class="list__left__text tn-color-gray--dark">产品状态</view>
+						</view>
+						<view class="list__right">{{product?(product.status==1?'维修中':product.status==2?'已下线':product.status==3?'已入库':product.status==0?'作废':product.status==-1?'生产中':''):'未建档'}}</view>
+					  </view>
+					</tn-list-cell>
+					<tn-list-cell>
+					  <view class="list-icon-text">
+						<view class="list__left">
+						  <view class="list__left__text tn-color-gray--dark">当前工序</view>
+						</view>
+						<view class="list__right">{{process.processName}}({{process.processCode}})</view>
+					  </view>
+					</tn-list-cell>
+				</view>
+				<template v-if="process.isRetrospect==1">
+					<tn-tabs :list="[{name:'工序追溯'}]" :current="0" ></tn-tabs>
+					<view class="tn-margin tn-padding-left tn-padding-right tn-border-solid-top tn-no-margin-top">
+						<template v-for="(item, index) in process.details">
+							<tn-form-item :label="item.processItemName" :labelWidth="200" labelPosition="left" required >
+								<template v-if="item.valueType==1" >
+									<tn-radio-group v-model="item.value" style="display: flex;justify-content: flex-end;">
+									  <tn-radio name="OK">OK</tn-radio>
+									  <tn-radio name="NG" >NG</tn-radio>
+									</tn-radio-group>
+								</template>
+								<template v-else>
+									<tn-input type="number" v-model="item.value" :placeholder="'请输入'+item.processItemName" inputAlign="right"></tn-input>
+								</template>
+							</tn-form-item>
+							
+							<!-- <el-form-item label="研究方向"  :prop="'list.'+index+'.name'" :rules="{required:true,message:'研究方向不能为空',trigger:'blur'}">
+								<el-input v-model="item.name" placeholder="请输入研究方向" />
+							</el-form-item> -->
+						</template>
+						<tn-form-item label="上传图片" prop="images" :labelWidth="200" :required="true" v-if="isReworkRecord">
+							<tn-image-upload :fileList="images" :action="action" :header="header" @on-success="imageUploadChange" slot="right"></tn-image-upload>
+						</tn-form-item>
+						<tn-form-item label="问题描述" prop="problemDesc" :labelWidth="200" labelPosition="left" required  v-if="isReworkRecord">
+						  <tn-input type="text"  v-model="problemDesc" placeholder="请输入问题描述" inputAlign="right"></tn-input>
+						</tn-form-item>
+					</view>
+				</template>
+				<view class="tn-flex tn-margin" v-if="process.isPhotograph==0">
+				  <view class="tn-flex-1 tn-padding-sm">
+					<tn-button :shadow="true" width="100%"  backgroundColor="tn-bg-teal" fontColor="#FFFFFF" @click="initProcess" margin="10rpx 0">返回</tn-button>
+				  </view>
+				  <view class="tn-flex-1 tn-padding-sm">
+					<tn-button :shadow="true" width="100%"  backgroundColor="#01BEFF" fontColor="#FFFFFF" @click="submit" margin="10rpx 0">提交</tn-button>
+				  </view>
+				</view>
+				<view v-else>
+				  <view class="tn-padding-sm tn-margin-top tn-color-red">当前工序为拍照工序,请通过相机作业</view>
+				  <view class="tn-padding-sm">
+					<tn-button :shadow="true" width="100%"  backgroundColor="tn-bg-teal" fontColor="#FFFFFF" @click="initProcess" margin="10rpx 0">返回</tn-button>
+				  </view>
+				  
+				</view>
+			</view>
+		</view>  
+  </view>
+</template>
+
+<script setup>
+  export default {
+    data(){
+      return {
+		labelWidth: 170,
+		action: this.api.apiHost()+"wx/communal/api/upload",
+		header:{
+			'Authorization':'Basic d3hBcHBsZXQ6d3hBcHBsZXRfc2VjcmV0',
+			'tenant_id':'000000',
+			'Blade-Auth': "bearer "+this.api.getToken(),
+		},
+		qrCode:'',
+		errorMsg:'',
+		product:'',
+		productModel:'',
+		process:'',
+		isReworkRecord:false,
+		images:[],
+		problemDesc:'',
+      }
+    },
+	onLoad(options){
+	},
+	onShow(){
+	},
+    methods: {
+		openScan(){
+			// 允许从相机和相册扫码
+			let that = this;
+			uni.scanCode({
+				success: function (res) {
+					that.qrCode = res.result
+					that.getProductProcess()
+				}
+			});
+		},
+		imageUploadChange(data,index,datas){
+			this.images = datas;
+		},
+		getProductProcess(){
+			if(!this.qrCode){
+				this.api.toast("请填写产品二维码")
+				return;
+			}
+			let that = this,
+			url = "wx/product/api/getProductProcess",
+			params = {
+				qrCode:that.qrCode
+			}
+			that.api.request(url, params,"get").then((res) => {
+				console.log(res)
+				that.product = res.product
+				that.productModel = res.productModel
+				that.process = res.process
+				if(that.process.isRetrospect==1){
+					that.process.details.forEach(function(item) {
+						if(item.valueType=='1'){
+							item.value='OK'
+						}
+					});
+				}
+			}).catch((res) => {
+				that.errorMsg = res.data.msg;
+			})
+		},
+		initProcess(){
+			this.qrCode=''
+			this.errorMsg=''
+			this.product=''
+			this.productModel=''
+			this.process=''
+			this.images = []
+			this.problemDesc=''
+			this.isReworkRecord = false
+		},
+		submit(){
+			if(this.checkParam()){
+				this.process.isStandards = (this.process.isRetrospect==0?-1:this.isReworkRecord?0:1)
+				let urls = [];
+				for(let i=0;i<this.images.length;i++){
+					let url = this.images[i].url
+					urls.push(url)
+				}
+				let that = this,
+				url = "wx/product/api/processSubmit",
+				params = {
+					qrCode:that.qrCode,
+					images:urls.join(","),
+					productProcess:that.process,
+					problemDesc:that.problemDesc,
+				}
+				that.api.request(url, params,'post','').then((res) => {
+					that.api.toast("操作成功")
+					that.initProcess();
+				}).catch((res) => {
+				})
+			}
+		},
+		checkParam(){
+			if(this.process.isPhotograph==1){
+				this.api.toast("当前工序为拍照工序,请通过相机作业");
+				return false;
+			}
+			if(this.process.isRetrospect==1){
+				for(let item of this.process.details){
+					if(!item.value){
+						this.api.toast("请填写工序追溯内容");
+						return false;
+					}
+				}
+				let msg=[]
+				for(let item of this.process.details){
+					if(item.valueType=='2'){
+						debugger
+						if(parseFloat(item.maxValue) < parseFloat(item.value) ||  parseFloat(item.minValue) > parseFloat(item.value) ){
+							msg.push(item.processItemName+"不达标,不在范围内")
+						}
+					}else{
+						if(item.value != 'OK'){
+							msg.push(item.processItemName+"不达标")
+						}
+					}
+				}
+				if(msg.length>0){
+					this.isReworkRecord = true;
+					if(this.images.length==0){
+						uni.showModal({
+							title: '提示',
+							showCancel:false,
+							content: msg.join(";\n")+";请上传图片发起维修"
+						});
+						return false;
+					}
+				}else{
+					this.images = [];
+					if(this.isReworkRecord == true){
+						uni.showModal({
+							title: '提示',
+							showCancel:false,
+							content: "工序追溯内容已达标,无需上传图片"
+						});
+						this.isReworkRecord = false
+						return false;
+					}
+				}
+			}
+			return true;
+		}
+    }
+  }
+</script>
+
+<style lang="scss" scoped>
+	
+	.list-icon-text, .list-image-text {
+	  display: flex;
+	  align-items: center;
+	  justify-content: space-between;
+	}
+	
+	.list {
+	  &__left {
+	    display: flex;
+	    align-items: center;
+	    justify-content: flex-start;
+		min-width: 140rpx;
+	    
+	    &__icon, &__image {
+	      margin-right: 18rpx;
+	    }
+	  }
+	  
+	  &__right {
+	    display: flex;
+	    align-items: center;
+	    justify-content: flex-end;
+		flex-wrap: wrap;
+		word-break: break-all;
+	  }
+	}
+	
+	
+	.tn-image-upload {
+	  display: flex;
+	  flex-direction: row;
+	  flex-wrap: wrap;
+	  align-items: center;
+	  
+	  &__item {
+	    /* #ifndef APP-NVUE */
+	    display: flex;
+	    /* #endif */
+	    align-items: center;
+	    justify-content: center;
+	    width: 200rpx;
+	    height: 200rpx;
+	    overflow: hidden;
+	    margin: 12rpx;
+	    margin-left: 0;
+	    background-color: $tn-font-holder-color;
+	    position: relative;
+	    border-radius: 10rpx;
+	    
+	    &-preview {
+	      border: 1rpx solid $tn-border-solid-color;
+	      
+	      
+	      &__image {
+	        display: block;
+	        width: 100%;
+	        height: 100%;
+	        border-radius: 10rpx;
+	      }
+	    }
+	    
+	  }
+	  
+	}
+</style>

+ 1 - 1
pages/product/query.vue

@@ -43,7 +43,7 @@
 					  </view>
 					  <view class="tn-flex-1  tn-text-right ">
 						  <view v-if="item.status==-1" class="tn-btn-class tn-btn  tn-round tn-main-gradient-orangered--reverse tn-text-center" style="height: 50rpx;line-height:50rpx;">
-							  NG待处理
+							  生产中
 						  </view>
 						  <view v-if="item.status==0" class="tn-btn-class tn-btn  tn-round tn-main-gradient-orange tn-text-center" style="height: 50rpx;line-height:50rpx;">
 							  作废

+ 1 - 1
tuniao-ui/components/tn-input/tn-input.vue

@@ -255,7 +255,7 @@
         // 默认值
         defaultValue: this.value,
         // 输入框高度
-        inputHeight: 70,
+        inputHeight: 40,
         // textarea的高度
         textareaHeight: 100,
         // 标记验证的状态

+ 1 - 1
tuniao-ui/theme.scss

@@ -3,7 +3,7 @@
 // 故uni.scss只建议放scss变量名相关样式,其他的样式可以通过main.js或者App.vue引入
 
 // 组件配置
-$tn-form-item-height: 70rpx;
+$tn-form-item-height: 50rpx;
 
 
 // 主颜色