1
This commit is contained in:
237
pages/analysis/sample/sample-look.vue
Normal file
237
pages/analysis/sample/sample-look.vue
Normal file
@@ -0,0 +1,237 @@
|
||||
<template>
|
||||
<view>
|
||||
<navbar-back :autoBack="false" title="任 务 单" @leftClick="customBack"></navbar-back>
|
||||
<u-row class="content-title" gutter="16">
|
||||
<u-col span="4">
|
||||
<view class="content-title-name">
|
||||
<text>任务列表</text>
|
||||
</view>
|
||||
<u-gap height="5" bg-color="#0055A2"></u-gap>
|
||||
</u-col>
|
||||
<u-col span="8">
|
||||
<view class="content-title-name">
|
||||
<text>样品列表</text>
|
||||
</view>
|
||||
<u-gap height="5" bg-color="#0055A2"></u-gap>
|
||||
</u-col>
|
||||
</u-row>
|
||||
<u-row class="content-main-height" gutter="16" align="top">
|
||||
<u-col span="4">
|
||||
<scroll-view
|
||||
scroll-y
|
||||
scroll-with-animation
|
||||
class="content-main-height content-main-left"
|
||||
:scroll-top="scrollTop"
|
||||
>
|
||||
<view
|
||||
v-for="(task, index) in taskList"
|
||||
:key="index"
|
||||
class="u-tab-item"
|
||||
:class="[current == index ? 'u-tab-item-active' : '']"
|
||||
:data-current="index"
|
||||
@tap.stop="swichTask(index)"
|
||||
>
|
||||
<u-row style="width: 100%">
|
||||
<u-col span="2" style="text-align: center">
|
||||
<u-icon name="tags-fill" size="34"></u-icon>
|
||||
</u-col>
|
||||
<u-col span="10">
|
||||
<view>
|
||||
<text style="font-size: 42rpx">{{ task.taskNo }}</text>
|
||||
</view>
|
||||
<view style="margin-top: 20rpx">
|
||||
<text>{{ task.taskName }}</text>
|
||||
</view>
|
||||
<view class="x-f" style="margin-top: 20rpx">
|
||||
<u-icon color="" name="clock"></u-icon>
|
||||
<text style="margin-left: 10rpx">{{ task.taskOperTime }}</text>
|
||||
</view>
|
||||
</u-col>
|
||||
</u-row>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</u-col>
|
||||
<u-col span="8">
|
||||
<view class="content-main-height">
|
||||
<scroll-view scroll-y scroll-with-animation class="content-main-height">
|
||||
<block v-for="(sample, index) in sampleList" :key="index">
|
||||
<view
|
||||
v-if="index == 0 || (index > 0 && sampleList[index].sort != sampleList[index - 1].sort)"
|
||||
style="padding: 10rpx; font-size: 36rpx"
|
||||
>
|
||||
<u-row>
|
||||
<u-col span="2" style="text-align: center">
|
||||
<view>
|
||||
<text>【{{ sample.sort }}】</text>
|
||||
</view>
|
||||
</u-col>
|
||||
<u-col span="10">
|
||||
<view>
|
||||
<text style="padding-left: 20rpx">{{ sample.sampleCode }}</text>
|
||||
</view>
|
||||
<view>
|
||||
<text style="padding-left: 20rpx">{{ sample.sampleName }}</text>
|
||||
</view>
|
||||
</u-col>
|
||||
</u-row>
|
||||
<u-line style="padding: 10rpx" color="#bbb" />
|
||||
</view>
|
||||
</block>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</u-col>
|
||||
</u-row>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
scrollTop: 0, //tab标题的滚动条位置
|
||||
current: 0, // 预设当前项的值
|
||||
menuHeight: 0, // 左边菜单的高度
|
||||
menuItemHeight: 0, // 左边菜单item的高度
|
||||
taskList: [],
|
||||
sampleList: []
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
//获取任务列表
|
||||
this.getAssayTask()
|
||||
},
|
||||
methods: {
|
||||
//返回首页
|
||||
customBack() {
|
||||
uni.reLaunch({
|
||||
url: '/pages/analysis/index/index'
|
||||
})
|
||||
},
|
||||
//切换任务
|
||||
async swichTask(index) {
|
||||
if (index == this.current) return
|
||||
this.current = index
|
||||
// 如果为0,意味着尚未初始化
|
||||
if (this.menuHeight == 0 || this.menuItemHeight == 0) {
|
||||
await this.getElRect('menu-scroll-view', 'menuHeight')
|
||||
await this.getElRect('u-tab-item', 'menuItemHeight')
|
||||
}
|
||||
// 将菜单菜单活动item垂直居中
|
||||
this.scrollTop = index * this.menuItemHeight + this.menuItemHeight / 2 - this.menuHeight / 2
|
||||
|
||||
//获取任务详情
|
||||
this.getAssayTaskDetail(this.taskList[index].taskNo)
|
||||
},
|
||||
// 获取一个目标元素的高度
|
||||
getElRect(elClass, dataVal) {
|
||||
new Promise((resolve, reject) => {
|
||||
const query = uni.createSelectorQuery().in(this)
|
||||
query
|
||||
.select('.' + elClass)
|
||||
.fields({ size: true }, res => {
|
||||
// 如果节点尚未生成,res值为null,循环调用执行
|
||||
if (!res) {
|
||||
setTimeout(() => {
|
||||
this.getElRect(elClass)
|
||||
}, 10)
|
||||
return
|
||||
}
|
||||
this[dataVal] = res.height
|
||||
})
|
||||
.exec()
|
||||
})
|
||||
},
|
||||
getAssayTask() {
|
||||
//显示loading
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
})
|
||||
const param = {
|
||||
assayOper: this.userInfo.realname,
|
||||
operateType: 'task'
|
||||
}
|
||||
this.$u.api
|
||||
.getAssayTaskList(param)
|
||||
.then(res => {
|
||||
this.taskList = res.result
|
||||
if (this.taskList && this.taskList.length > 0) {
|
||||
this.getAssayTaskDetail(this.taskList[0].taskNo)
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
uni.hideLoading()
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
getAssayTaskDetail(taskNo) {
|
||||
this.$u.api
|
||||
.getAssayTaskDetailListByTaskNo({ taskNo: taskNo })
|
||||
.then(res => {
|
||||
this.sampleList = res.result
|
||||
uni.hideLoading()
|
||||
})
|
||||
.catch(err => {
|
||||
uni.hideLoading()
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.content-title {
|
||||
height: 110rpx;
|
||||
width: 100%;
|
||||
font-size: 46rpx;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.content-title-name {
|
||||
padding: 20rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.content-main-height {
|
||||
height: calc(100vh - 250rpx);
|
||||
}
|
||||
|
||||
.content-main-left {
|
||||
background-color: #f6f6f6;
|
||||
}
|
||||
|
||||
.u-tab-item {
|
||||
padding: 10rpx;
|
||||
height: 200rpx;
|
||||
background: #f6f6f6;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 36rpx;
|
||||
color: #444;
|
||||
font-weight: 400;
|
||||
line-height: 1;
|
||||
border-width: 4rpx;
|
||||
border-bottom: dotted;
|
||||
}
|
||||
|
||||
.u-tab-item-active {
|
||||
position: relative;
|
||||
color: #0055a2;
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.u-tab-item-active::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
|
||||
height: 32rpx;
|
||||
left: 0;
|
||||
top: 39rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user