941 lines
26 KiB
Vue
941 lines
26 KiB
Vue
<template>
|
||
<view>
|
||
<view class="topTab" >
|
||
<view class="tab-header" style="z-index: 999;">
|
||
<view class="left" >
|
||
<image @click="customNavigateBack" src="@/static/img/back.png" mode=""></image>
|
||
</view>
|
||
<view class="center">
|
||
添加样品
|
||
</view>
|
||
<view class="right" style="justify-content: flex-end;">
|
||
<view class="text-btn" @click="scanCode">
|
||
<image src="@/static/images/scan.png" style="width: 50rpx;height: 50rpx;" mode=""></image>
|
||
</view>
|
||
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="page-content">
|
||
<u-loading-page loading-text="loading..." :loading="isLoading" style="z-index: 99;"></u-loading-page>
|
||
<view class="main-header">
|
||
<view style="color: #A6A6A6;font-size: 24rpx;width: 110rpx;margin-left: 20rpx;">送样单位</view>
|
||
<view style="margin:0 20rpx;font-size: 24rpx;">{{customName}}</view>
|
||
</view>
|
||
|
||
<view class="main-box">
|
||
<!-- 列表 -->
|
||
<view class="list-box" >
|
||
<u-list v-if="listData.length>0" height="78vh">
|
||
<u-list-item v-for="(item, index) in listData" :key="index" >
|
||
<view class="list-item">
|
||
<view class="item-left" @click="checkDevice(item)" >
|
||
<u-checkbox-group v-model="item.checked" style="transform:scale(1.4)" @change="checkDevice(item)">
|
||
<u-checkbox :customStyle="{marginTop: '20rpx'}" shape="circle" :label="''" :name="item.devCode"></u-checkbox>
|
||
</u-checkbox-group>
|
||
</view>
|
||
<view class="item-content">
|
||
<view class="content-box">
|
||
<view class="top-box" @click="checkDevice(item)">
|
||
<text style="font-weight: bold;">{{item.sampleTools}}</text>
|
||
<text style="margin-left: 10rpx;">{{item.devModule}}</text>
|
||
<text style="color: #999999;float: right;font-size: 20rpx;"></text>
|
||
</view>
|
||
<view class="item-text" @click="checkDevice(item)">
|
||
<text class="label">样品编号:</text>
|
||
<text class="info">{{item.devCode}}</text>
|
||
</view>
|
||
<view class="item-text">
|
||
<text class="label">送样部门:</text>
|
||
<text class="info">{{item.sampleDepartment}}</text>
|
||
<image src="../../static/images/del.png" @click="delDevice(index)" style="width: 30rpx;height: 30rpx;float: right;margin-right: 20rpx;" alt="">
|
||
<image src="../../static/images/edit2.png" @click="editDevice(item,index)" style="width: 30rpx;height: 30rpx;float: right;margin-right: 20rpx;" alt="">
|
||
</view>
|
||
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</u-list-item>
|
||
</u-list>
|
||
<view style="width: 100%;height: 80vh;display: flex;flex-direction:column;justify-content: center;align-items: center;" v-if="listData.length==0">
|
||
<image src="../../static/images/noDevices.png" style="width: 60%;height: 20vh;" alt="">
|
||
<view style="color: rgba(0, 0, 0, 0.45);">未添加样品</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="bottom-box" :class="showMore ? 'active' : ''">
|
||
<!-- 打开按钮 -->
|
||
<view class="open-btn" @click="openMore">
|
||
<image src="../../static/images/open2.png" v-if="showMore" style="width: 100rpx;height: 30rpx;" alt="">
|
||
<image src="../../static/images/open.png" v-if="!showMore" style="width: 100rpx;height: 30rpx;" alt="">
|
||
</view>
|
||
<!-- 折叠区域 -->
|
||
<view style="width: 100%;height: 100%;position: absolute;top: 0;">
|
||
|
||
<view class="add-form">
|
||
<u--form ref="uForm" labelPosition="left" labelWidth="80px" style="margin:0 40rpx;" :model="addForm" :rules="rules" >
|
||
<u-form-item label="样品类型" prop="sampleTools" borderBottom required @click="showType=true" >
|
||
<u--input v-model="addForm.sampleTools" suffixIcon="arrow-right" readonly suffixIconStyle="color: #909399;fontSize:24px;" border="none"></u--input>
|
||
</u-form-item>
|
||
<u-form-item label="规格型号" prop="devModule" borderBottom required>
|
||
<u--input v-model="addForm.devModule" border="none" maxlength="20"></u--input>
|
||
</u-form-item>
|
||
<u-form-item label="样品数量" prop="devNumber" borderBottom required>
|
||
<u--input v-model="addForm.devNumber" border="none" type="number" placeholder="请输入1~100的数字" maxlength="3" ></u--input>
|
||
</u-form-item>
|
||
<view style="width: 100%;display: flex;align-items: center;justify-content: space-between;" >
|
||
<view style="width: 70%;">
|
||
<u-form-item label="送样部门" prop="sampleDepartment" borderBottom required @click="showDept=true">
|
||
<u--input v-model="addForm.sampleDepartment" readonly suffixIcon="arrow-right" suffixIconStyle="color: #0052D9;fontSize:24px;" border="none"></u--input>
|
||
</u-form-item>
|
||
</view>
|
||
<view class="more-add-btn" @click="addConfirm">
|
||
确定
|
||
</view>
|
||
</view>
|
||
<u-form-item label="总金额" prop="totalAmount" borderBottom>
|
||
<u--input v-model="totalAmount" border="none" type="text" disabled></u--input>
|
||
</u-form-item>
|
||
</u--form>
|
||
<!-- 样品类型 -->
|
||
<u-picker :show="showType" :columns="toolsList" keyName="name"
|
||
@confirm="typeConfirm" title="样品类型"
|
||
@cancel="showType = false"
|
||
></u-picker>
|
||
<!-- 规格型号 -->
|
||
<!-- <u-picker :show="showModel" :columns="modelColumns"
|
||
@confirm="modelConfirm" title="规格型号"
|
||
@cancel="showModel = false"
|
||
></u-picker> -->
|
||
|
||
<u-picker :show="showDept" :columns="deptList" keyName="name"
|
||
@confirm="deptConfirm" title="送样部门"
|
||
@cancel="showDept = false"
|
||
></u-picker>
|
||
</view>
|
||
</view>
|
||
<!-- 固定底部 -->
|
||
<view style="width: 100%;height: 120rpx;position: absolute;bottom: 0;display: flex;background-color: #FFF;">
|
||
<view style="margin-left: 60rpx;font-size: 24rpx;margin-top: 10rpx;">
|
||
<u-checkbox-group v-model="checkAll" @change="checkedAll" style="transform:scale(1.4)">
|
||
<u-checkbox :customStyle="{marginTop: '20rpx'}" labelSize="12px" shape="circle" label="全选" name="1"></u-checkbox>
|
||
</u-checkbox-group>
|
||
</view>
|
||
<view style="margin-left: 20rpx;font-size: 24rpx;margin-top: 28rpx;">(已选{{chosenNum}})</view>
|
||
<view class="sumbit-btn" @click="sumbitSample">立即上传</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 修改弹窗 -->
|
||
<u-popup :show="editPopup" mode="center" @close="closeEdit">
|
||
<view style="width:650rpx;height: 100%;position: relative;background-color: #fff;">
|
||
<view class="edit-header">
|
||
<view style="width: 5%;height: 80rpx;"></view>
|
||
<view style="width: 85%;height: 80rpx;line-height: 80rpx;font-weight: bold;">收样信息修改</view>
|
||
<u-icon style="width: 10%;" name="close" color="#000" size="32" @click="closeEdit"></u-icon>
|
||
</view>
|
||
<view class="edit-form">
|
||
<u--form ref="edForm" labelPosition="left" labelWidth="80px" style="margin: 40rpx;80rpx" :model="editForm" :rules="editRules" >
|
||
<u-form-item label="送样部门" prop="sampleDepartment" borderBottom required @click="showDept2=true">
|
||
<u--input v-model="editForm.sampleDepartment" readonly border="none" suffixIcon="arrow-right" readonly suffixIconStyle="color: #909399;fontSize:24px;"></u--input>
|
||
</u-form-item>
|
||
<u-form-item label="样品类型" prop="sampleTools" borderBottom required @click="showType2=true" >
|
||
<u--input v-model="editForm.sampleTools" suffixIcon="arrow-right" readonly suffixIconStyle="color: #909399;fontSize:24px;" border="none"></u--input>
|
||
</u-form-item>
|
||
<u-form-item label="规格型号" prop="devModule" borderBottom required>
|
||
<u--input v-model="editForm.devModule" border="none" maxlength="20"></u--input>
|
||
</u-form-item>
|
||
<u-form-item label="样品编号" prop="devCode" borderBottom required>
|
||
<u--input v-model="editForm.devCode" border="none" maxlength="20" disabled></u--input>
|
||
</u-form-item>
|
||
</u--form>
|
||
|
||
<!-- 样品类型 -->
|
||
<u-picker :show="showType2" :columns="toolsList" keyName="name"
|
||
@confirm="typeConfirm2" title="样品类型"
|
||
@cancel="showType2 = false"
|
||
></u-picker>
|
||
<u-picker :show="showDept2" :columns="deptList" keyName="name"
|
||
@confirm="deptConfirm2" title="送样部门"
|
||
@cancel="showDept2 = false"
|
||
></u-picker>
|
||
<!-- 规格型号 -->
|
||
<!-- <u-picker :show="showModel2" :columns="modelColumns"
|
||
@confirm="modelConfirm2" title="样品类型"
|
||
@cancel="showModel2 = false"
|
||
></u-picker> -->
|
||
</view>
|
||
|
||
<view class="edit-submit-box">
|
||
<u-button shape="square" class="submit-edit-1" @click="closeEdit">取 消</u-button>
|
||
<u-button type="primary" shape="square" class="submit-edit-2" @click="editConfirm">确 认</u-button>
|
||
</view>
|
||
</view>
|
||
</u-popup>
|
||
|
||
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import { getDeptSelectedById,getToolsSelect,addSamples,getSampleLabelByQrCode,getAmount } from '@/service/url.js';
|
||
import tabHeader from '@/components/tab-Header.vue';
|
||
import eselect from '@/components/eselect.vue';
|
||
import AES from "@/utils/cryptoJs/aes.js";
|
||
export default {
|
||
components: {
|
||
tabHeader,
|
||
eselect,
|
||
},
|
||
data() {
|
||
return {
|
||
signAmount:0,
|
||
totalAmount:0,
|
||
addData:{},
|
||
collectId:'',
|
||
customName:'',
|
||
batchCode:'',//编辑时需要批次编号
|
||
customId:'',
|
||
//部门选择数据
|
||
deptList: [],
|
||
//样品类型数据
|
||
toolsList: [],
|
||
// item:{
|
||
// id:'111111122222222',
|
||
// time:'2024-07-10 10:17',
|
||
// name1:"安全帽 普通型(无面罩 )",
|
||
// name2:"XJG-CZG-01",
|
||
// name3:"曹村供电所",
|
||
// name5:"人脸验证已通过!",
|
||
// state:'1'
|
||
// },
|
||
//新增折叠面板
|
||
showMore:false,
|
||
checkAll:[],
|
||
chosenNum:0,
|
||
addForm:{
|
||
sampleToolsId:'',
|
||
sampleTools:'',
|
||
devModule:'',
|
||
devNumber:'1',
|
||
sampleDepartment:'',
|
||
departmentId:'',
|
||
},
|
||
showDept: false,
|
||
showType: false,
|
||
// showModel: false,
|
||
// modelColumns: [['无面罩01', '双钩01', '摄像机S2', '样品S3']],
|
||
|
||
rules: {
|
||
'sampleTools': {
|
||
type: 'string',
|
||
required: true,
|
||
message: '请选择样品类型',
|
||
trigger: ['blur', 'change']
|
||
},
|
||
'devModule': {
|
||
type: 'string',
|
||
required: true,
|
||
message: '请输入规格型号',
|
||
trigger: ['blur', 'change']
|
||
},
|
||
'devNumber': [
|
||
{
|
||
type: 'string',
|
||
required: true,
|
||
message: '请填写样品数量',
|
||
trigger: ['blur', 'change']
|
||
},
|
||
{
|
||
pattern: /^[0-9]+$/,
|
||
message: '请填写正整数',
|
||
trigger: ['blur', 'change']
|
||
},
|
||
{
|
||
transform(value) {
|
||
if(Number(value)>100){
|
||
value=100;
|
||
}
|
||
if(Number(value)<1){
|
||
value=1;
|
||
}
|
||
return value;
|
||
},
|
||
message: '请填写1~100之间的数字',
|
||
trigger: ['blur', 'change']
|
||
}
|
||
],
|
||
'sampleDepartment': {
|
||
type: 'string',
|
||
required: true,
|
||
message: '请选择部门',
|
||
trigger: ['blur', 'change']
|
||
},
|
||
},
|
||
|
||
//修改弹窗
|
||
editPopup: false,
|
||
editIndex:0,
|
||
showType2: false,
|
||
showDept2: false,
|
||
editForm:{
|
||
sampleToolsId:'',
|
||
sampleTools:'',
|
||
devModule:'',
|
||
devCode:'',
|
||
sampleDepartment:'',
|
||
departmentId:'',
|
||
},
|
||
editRules: {
|
||
'sampleTools': {
|
||
type: 'string',
|
||
required: true,
|
||
message: '请选择样品类型',
|
||
trigger: ['blur', 'change']
|
||
},
|
||
'devModule': {
|
||
type: 'string',
|
||
required: true,
|
||
message: '请输入规格型号',
|
||
trigger: ['blur', 'change']
|
||
},
|
||
'devCode': {
|
||
type: 'string',
|
||
required: true,
|
||
message: '请填写样品编号',
|
||
trigger: ['blur', 'change']
|
||
},
|
||
'sampleDepartment': {
|
||
type: 'string',
|
||
required: true,
|
||
message: '请选择部门',
|
||
trigger: ['blur', 'change']
|
||
},
|
||
},
|
||
|
||
listData:[],
|
||
page:1,
|
||
isLoading:false
|
||
|
||
};
|
||
},
|
||
onLoad(option) {
|
||
console.log(option)
|
||
if(option.addData){
|
||
this.addData=JSON.parse(option.addData)||{};
|
||
// console.log(this.addData)
|
||
this.customName=this.addData.customName;
|
||
this.customId=this.addData.customId;
|
||
}else{
|
||
this.collectId = option.id || '';
|
||
this.customName = option.customName|| ''
|
||
this.customId= option.customId;
|
||
this.batchCode = option.batchCode|| ''
|
||
}
|
||
|
||
this.getDeptSelectedById()
|
||
this.getToolsSelect()
|
||
},
|
||
methods: {
|
||
customNavigateBack() {
|
||
// 自定义返回逻辑
|
||
const pages = getCurrentPages(); // 获取页面栈
|
||
const len = pages.length;
|
||
let backPage = ''; // 要返回的页面路径
|
||
for (let i = len - 2; i >= 0; i--) {
|
||
// 从倒数第二个页面开始遍历,找到第一个不是当前页面的页面
|
||
if (pages[i].route !== 'pages/A/A') {
|
||
backPage = pages[i].route;
|
||
break;
|
||
}
|
||
}
|
||
if (backPage) {
|
||
uni.navigateBack({
|
||
delta: len - 1 - pages.findIndex(page => page.route === backPage) // 返回到已存在的页面
|
||
});
|
||
}
|
||
},
|
||
matchScore(e){
|
||
// console.log(e)
|
||
// console.log(this.signAmount)
|
||
if(!/^[0-9]+$/.test(e)){
|
||
this.addForm.devNumber=Number(e.replace(/\D/g,''));
|
||
if(this.addForm.devNumber>100){
|
||
this.addForm.devNumber=100;
|
||
}else if(this.addForm.devNumber<1||this.addForm.devNumber==0){
|
||
this.addForm.devNumber=1;
|
||
}
|
||
}else{
|
||
if(Number(e)>100){
|
||
this.addForm.devNumber=100;
|
||
}
|
||
if(Number(e)<1||e==''){
|
||
this.addForm.devNumber=1;
|
||
}
|
||
}
|
||
this.totalAmount=(Number(this.addForm.devNumber)*Number(this.signAmount)).toFixed(2);
|
||
},
|
||
//单位部门下拉数据
|
||
getDeptSelectedById(){
|
||
let obj = {
|
||
"customId":this.customId,
|
||
}
|
||
let param = {
|
||
encryptedData: AES.encrypt(JSON.stringify(obj))
|
||
// encryptedData: JSON.stringify(obj)
|
||
}
|
||
this.$http.post(getDeptSelectedById,param).then(res => {
|
||
if (res) {
|
||
console.log(res)
|
||
if(res.code == 200){
|
||
this.deptList.push(res.data);
|
||
}else{
|
||
this.deptList=[];
|
||
}
|
||
}
|
||
}).catch(error => {
|
||
console.log(error)
|
||
// this.$utils.showHttpError(error)
|
||
})
|
||
// console.log(this.listData)
|
||
|
||
|
||
},
|
||
//工器具类型下拉数据
|
||
getToolsSelect(){
|
||
let obj = {
|
||
"keyWord":"",
|
||
}
|
||
let param = {
|
||
encryptedData: AES.encrypt(JSON.stringify(obj))
|
||
// encryptedData: JSON.stringify(obj)
|
||
}
|
||
this.$http.post(getToolsSelect,param).then(res => {
|
||
if (res) {
|
||
if(res.code == '200'){
|
||
this.toolsList.push(res.data);
|
||
}else{
|
||
this.toolsList=[]
|
||
}
|
||
}
|
||
}).catch(error => {
|
||
console.log(error)
|
||
})
|
||
},
|
||
// 全选
|
||
checkedAll(n){
|
||
if(n.length>0){
|
||
this.listData.forEach(item=>{
|
||
item.checked=[item.devCode]
|
||
})
|
||
this.chosenNum=this.listData.length;
|
||
}else{
|
||
this.listData.forEach(item=>{
|
||
item.checked=[]
|
||
})
|
||
this.chosenNum=0;
|
||
}
|
||
},
|
||
// 单选
|
||
checkDevice(chosen){
|
||
this.listData.forEach(item=>{
|
||
if(item.devCode==chosen.devCode){
|
||
if(item.checked.length==0){
|
||
item.checked=[item.devCode]
|
||
this.chosenNum=this.chosenNum+1
|
||
}else{
|
||
item.checked=[]
|
||
this.checkAll=[]
|
||
this.chosenNum=this.chosenNum-1
|
||
}
|
||
}
|
||
})
|
||
},
|
||
delDevice(index){
|
||
// this.delIndex=index;
|
||
this.listData.splice(index,1)
|
||
this.chosenNum=0;
|
||
this.listData.forEach(item=>{
|
||
if(item.checked.length>0){
|
||
this.chosenNum=this.chosenNum+1
|
||
}
|
||
})
|
||
},
|
||
// 折叠面板打开
|
||
openMore(){
|
||
this.showMore = !this.showMore;
|
||
this.addForm.sampleToolsId="";
|
||
this.addForm.sampleTools="";
|
||
this.addForm.devModule="";
|
||
this.addForm.devNumber="1";
|
||
this.addForm.departmentId="";
|
||
this.addForm.sampleDepartment="";
|
||
this.totalAmount=0;
|
||
this.signAmount=0;
|
||
|
||
setTimeout(()=>{
|
||
this.$refs.uForm.clearValidate()
|
||
},500)
|
||
|
||
},
|
||
// 样品类型下拉选-新增
|
||
typeConfirm(e){
|
||
this.showType = false;
|
||
this.addForm.sampleToolsId = e.value[0].id;
|
||
this.addForm.sampleTools = e.value[0].name;
|
||
this.$refs.uForm.validateField('sampleTools')
|
||
let obj = { "sampleTools":e.value[0].name }
|
||
let param = {
|
||
encryptedData: AES.encrypt(JSON.stringify(obj))
|
||
}
|
||
this.$http.post(getAmount,param).then(res => {
|
||
if (res) {
|
||
console.log(res)
|
||
if(res.code == 200){
|
||
this.signAmount=Number(res.data);
|
||
this.totalAmount=(Number(this.addForm.devNumber)*Number(res.data)).toFixed(2);
|
||
}
|
||
}
|
||
}).catch(error => {
|
||
console.log(error)
|
||
// this.$utils.showHttpError(error)
|
||
})
|
||
|
||
|
||
|
||
|
||
|
||
|
||
},
|
||
//规格型号下拉选-新增
|
||
// modelConfirm(e){
|
||
// console.log('confirm', e)
|
||
// this.showModel = false;
|
||
// this.addForm.devModule = e.value[0]
|
||
// this.$refs.uForm.validateField('devModule')
|
||
// },
|
||
deptConfirm(e){
|
||
// console.log('confirm', e)
|
||
this.showDept = false;
|
||
this.addForm.sampleDepartment = e.value[0].name;
|
||
this.addForm.departmentId = e.value[0].id;
|
||
this.$refs.uForm.validateField('sampleDepartment')
|
||
},
|
||
addConfirm(){
|
||
// console.log(this.addForm)
|
||
this.$refs.uForm.validate().then(validate => {
|
||
// console.log(this.addForm.devNumber)
|
||
let sum = Number(this.addForm.devNumber)//需要添加多少个
|
||
var num=this.listData.length;//列表中同样品类型已有数量
|
||
// console.log(num)
|
||
|
||
for(let i=1;i<=sum;i++){
|
||
let obj = {
|
||
customId:this.addData.customId,
|
||
customName:this.addData.customName,
|
||
sampleUser:this.addData.sampleUser,
|
||
sampleTime:this.addData.sampleTime,
|
||
departmentId:this.addForm.departmentId,
|
||
sampleDepartment:this.addForm.sampleDepartment,
|
||
sampleToolsId:this.addForm.sampleToolsId,
|
||
sampleTools:this.addForm.sampleTools,
|
||
devModule:this.addForm.devModule,
|
||
max:Number(this.addForm.devNumber)+num,
|
||
devCode:'00'+(num+i),
|
||
checked:[]
|
||
}
|
||
if(this.batchCode&&this.batchCode!=''){
|
||
obj.batchCode=this.batchCode;
|
||
}
|
||
if(this.checkAll.length>0){
|
||
obj.checked=[obj.devCode];
|
||
this.chosenNum=this.chosenNum+1;
|
||
}
|
||
this.listData.push(obj)
|
||
}
|
||
// console.lo
|
||
|
||
this.showMore = !this.showMore;
|
||
}).catch(errors => {
|
||
|
||
})
|
||
},
|
||
// 打开修改弹窗
|
||
editDevice(item,index){
|
||
// console.log('editDevice',item)
|
||
this.editPopup=true;
|
||
this.editIndex=index;
|
||
this.editForm = Object.assign({},item)
|
||
// this.$refs.edForm.clearValidate()
|
||
},
|
||
// 样品类型下拉选-修改
|
||
typeConfirm2(e){
|
||
// console.log('confirm', e)
|
||
this.showType2 = false;
|
||
this.editForm.sampleToolsId = e.value[0].id
|
||
this.editForm.sampleTools = e.value[0].name
|
||
this.$refs.edForm.validateField('sampleTools')
|
||
},
|
||
//送样部门下拉选-修改
|
||
deptConfirm2(e){
|
||
this.showDept2 = false;
|
||
this.editForm.sampleDepartment = e.value[0].name;
|
||
this.editForm.departmentId = e.value[0].id;
|
||
this.$refs.edForm.validateField('sampleDepartment')
|
||
},
|
||
closeEdit(){
|
||
this.editPopup=false;
|
||
},
|
||
editConfirm(){
|
||
// console.log(this.editForm)
|
||
this.$refs.edForm.validate().then(validate => {
|
||
this.listData[this.editIndex]=this.editForm;
|
||
this.editPopup = false;
|
||
uni.showToast({
|
||
title: "修改成功",
|
||
icon: "none"
|
||
})
|
||
}).catch(errors => {
|
||
uni.showToast({
|
||
title: "校验失败",
|
||
icon: "none"
|
||
})
|
||
})
|
||
},
|
||
|
||
//扫码二维码-添加数据
|
||
scanCode() {
|
||
uni.scanCode({
|
||
success: (res) => {
|
||
console.log('扫码结果:' + res.result);
|
||
let obj = {
|
||
"customerCode":res.result,
|
||
}
|
||
let param = {
|
||
encryptedData: AES.encrypt(JSON.stringify(obj))
|
||
// encryptedData: JSON.stringify(obj)
|
||
}
|
||
this.$http.post(getSampleLabelByQrCode,param).then(response => {
|
||
if (response) {
|
||
console.log(response)
|
||
if(response.code == 200){
|
||
let obj = {
|
||
customId:response.data.customId,
|
||
customName:response.data.customName,
|
||
sampleUser:response.data.sampleUser,
|
||
sampleTime:response.data.sampleTime,
|
||
departmentId:response.data.departmentId,
|
||
sampleDepartment:response.data.sampleDepartment,
|
||
sampleToolsId:response.data.sampleToolsId,
|
||
sampleTools:response.data.sampleTools,
|
||
devModule:response.data.devModule,
|
||
devCode:response.data.devCode,
|
||
checked:[]
|
||
}
|
||
if(this.batchCode&&this.batchCode!=''){
|
||
obj.batchCode=this.batchCode
|
||
}
|
||
var index = this.listData.findIndex(item => {return item.devCode == obj.devCode})
|
||
if (index != -1) {
|
||
uni.showToast({
|
||
title: "样品编码已存在",
|
||
icon: "none"
|
||
})
|
||
}else{
|
||
if(this.customId==obj.customId){
|
||
uni.showModal({
|
||
title: '扫码样品已添加',
|
||
showCancel: false
|
||
});
|
||
if(this.checkAll.length>0){
|
||
obj.checked=[obj.devCode];
|
||
this.chosenNum=this.chosenNum+1;
|
||
}
|
||
this.listData.push(obj)
|
||
}else{
|
||
uni.showModal({
|
||
title: "扫码样品单位与送样单位不一致",
|
||
showCancel: false
|
||
});
|
||
}
|
||
|
||
}
|
||
}else{
|
||
|
||
}
|
||
}
|
||
}).catch(error => {
|
||
console.log(error)
|
||
// this.$utils.showHttpError(error)
|
||
})
|
||
},
|
||
fail: (err) => {
|
||
console.error('扫码失败:' + err);
|
||
uni.showToast({
|
||
title: '扫码取消',
|
||
icon: 'none'
|
||
});
|
||
}
|
||
});
|
||
},
|
||
//立即上传
|
||
sumbitSample(){
|
||
// console.log(this.listData)
|
||
let paramsList = []
|
||
this.listData.forEach(item=>{
|
||
if(item.checked.length>0){
|
||
paramsList.push(item)
|
||
}
|
||
})
|
||
// console.log(paramsList)
|
||
if(paramsList.length>0){
|
||
this.isLoading=true;
|
||
let obj={
|
||
paramsList:paramsList
|
||
}
|
||
let param = {
|
||
encryptedData: AES.encrypt(JSON.stringify(obj))
|
||
// encryptedData: JSON.stringify(obj)
|
||
}
|
||
this.$http.post(addSamples,param).then(res => {
|
||
if (res) {
|
||
if(res.code == '200'){
|
||
if(this.batchCode&&this.batchCode!=''){
|
||
setTimeout(()=>{
|
||
uni.navigateBack({
|
||
delta: 1 // 返回到详情页面
|
||
});
|
||
this.isLoading=false;
|
||
},1000)
|
||
}else{
|
||
setTimeout(()=>{
|
||
uni.navigateBack({
|
||
delta: 2 // 返回到列表页面
|
||
});
|
||
this.isLoading=false;
|
||
},1000)
|
||
}
|
||
}else{
|
||
this.isLoading=false;
|
||
}
|
||
}
|
||
}).catch(error => {
|
||
this.isLoading=false;
|
||
console.log(error)
|
||
})
|
||
}else{
|
||
uni.showToast({title: "请选择样品",icon: "none"})
|
||
}
|
||
}
|
||
},
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
|
||
.searchInput{
|
||
height: 100%;
|
||
}
|
||
.page-content{
|
||
width: 100%;
|
||
height: 90vh;
|
||
position: absolute;
|
||
top:9vh;
|
||
padding: 0rpx 0;
|
||
background-color: #F3F3F3;
|
||
.search{
|
||
width: 100%;
|
||
height: 120rpx;
|
||
margin: 0rpx auto;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
background-color: #FFF;
|
||
}
|
||
.addBtn{
|
||
width: 120rpx;
|
||
height: 50rpx;
|
||
line-height: 50rpx;
|
||
text-align: center;
|
||
color: #fff;
|
||
border-radius: 30rpx;
|
||
font-size: 20rpx;
|
||
background-color: #0052D9;
|
||
margin-right: 10rpx;
|
||
}
|
||
.main-header{
|
||
width: 100%;
|
||
height: auto;
|
||
display: flex;
|
||
align-items: center;
|
||
background-color: #FFF;
|
||
padding-bottom: 20rpx;
|
||
}
|
||
.main-box{
|
||
width: 100%;
|
||
height: auto;
|
||
|
||
.list-box{
|
||
width: 94%;
|
||
height: auto;
|
||
overflow: hidden;
|
||
margin: 20rpx auto;
|
||
|
||
.list-item{
|
||
width: 100%;
|
||
height: auto;
|
||
background: #F7F9FA;
|
||
border-radius: 20rpx;
|
||
margin: 20rpx 0;
|
||
display: flex;
|
||
.item-left{
|
||
width: 12%;
|
||
height: auto;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: flex-start;
|
||
}
|
||
.item-content{
|
||
width: 88%;
|
||
height: auto;
|
||
font-size: 24rpx;
|
||
|
||
.content-box{
|
||
width: 94%;
|
||
height: auto;
|
||
margin: 20rpx 0;
|
||
|
||
.top-box{
|
||
margin-top: 15rpx;
|
||
margin-left: 20rpx;
|
||
}
|
||
.item-text{
|
||
margin-left: 20rpx;
|
||
margin-top: 15rpx;
|
||
.label{
|
||
color: #999999;
|
||
}
|
||
.info{
|
||
color: #666666;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
.active{
|
||
min-height: 42vh!important;
|
||
transition: min-height 0.8s ease;
|
||
border-top-right-radius: 40rpx;
|
||
border-top-left-radius: 40rpx;
|
||
box-shadow: 0 0px 18px rgba(0, 0, 0, 0.3);
|
||
}
|
||
.bottom-box{
|
||
width: 100%;
|
||
min-height: 120rpx;
|
||
transition: min-height 0.8s ease;
|
||
background-color: #FFF;
|
||
position: fixed;
|
||
bottom: 0;
|
||
.add-form{
|
||
width: 98%;
|
||
height: auto;
|
||
padding: 10rpx;
|
||
background-color: #FFF;
|
||
border-top-right-radius: 60rpx;
|
||
border-top-left-radius: 60rpx;
|
||
}
|
||
.sumbit-btn{
|
||
width: 160rpx;
|
||
height: 70rpx;
|
||
margin-right: 20rpx;
|
||
line-height: 70rpx;
|
||
text-align: center;
|
||
color: #FFF;
|
||
background: #0052D9;
|
||
position: absolute;right: 20rpx;top: 20rpx;
|
||
border-radius: 10rpx;
|
||
|
||
}
|
||
.open-btn{
|
||
width: 100%;
|
||
height: 40rpx;
|
||
position: absolute;
|
||
top: -30rpx;
|
||
display: flex;
|
||
justify-content: center;
|
||
}
|
||
}
|
||
.more-add-btn{
|
||
width: 120rpx;height: 60rpx;line-height: 60rpx;text-align: center;font-size: 26rpx;background: #CFE1FF;color: #0052D9;border-radius: 10rpx;
|
||
}
|
||
}
|
||
|
||
.submit-box {
|
||
width: 100%;
|
||
height: 100rpx;
|
||
padding-bottom: 20rpx;
|
||
position: fixed;
|
||
bottom: 0;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
background-color: #FFF;
|
||
.submit-add{
|
||
width: 80%;
|
||
margin: 0 auto;
|
||
height: 65rpx;
|
||
font-size: 26rpx;
|
||
background: #0052D9;
|
||
box-shadow: 0px 4px 2px 0px rgba(81,147,254,0.15);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
.edit-header{
|
||
width: 100%;
|
||
height: 80rpx;
|
||
margin: 0 auto;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
background-color: #fff;
|
||
}
|
||
.edit-form{
|
||
width: 100%;
|
||
height: 32vh;
|
||
background-color: #fff;
|
||
}
|
||
.edit-submit-box {
|
||
width: 100%;
|
||
height: 100rpx;
|
||
position: absolute;
|
||
bottom: 0;
|
||
display: flex;
|
||
padding-bottom: 20rpx;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
background-color: #FFF;
|
||
.submit-edit-1{
|
||
width:45%;
|
||
margin: 0 auto;
|
||
height: 65rpx;
|
||
font-size: 26rpx;
|
||
background: #F5F5F5;
|
||
}
|
||
.submit-edit-2{
|
||
width: 45%;
|
||
margin: 0 auto;
|
||
height: 65rpx;
|
||
font-size: 26rpx;
|
||
background: #0052D9;
|
||
}
|
||
}
|
||
|
||
</style>
|