feat:页面修改
This commit is contained in:
@@ -1,237 +0,0 @@
|
||||
<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>
|
||||
@@ -1,423 +0,0 @@
|
||||
<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 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-right">
|
||||
<u-checkbox-group @change="checkboxGroupChange" style="width: 100%">
|
||||
<block v-for="(sample, index) in sampleList" :key="index">
|
||||
<view style="width: 100%; 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="4">
|
||||
<view>
|
||||
<text style="padding-left: 20rpx">{{ sample.sampleCode }}</text>
|
||||
</view>
|
||||
<view>
|
||||
<text style="padding-left: 20rpx"
|
||||
>{{ sample.dataSourceType | getDataSourceTypeShow }}{{ sample.sampleName }}</text
|
||||
>
|
||||
</view>
|
||||
<view>
|
||||
<text v-if="sample.sampleWeight" style="padding-left: 20rpx">{{ sample.sampleWeight }} g</text>
|
||||
</view>
|
||||
</u-col>
|
||||
<u-col span="4">
|
||||
<view>
|
||||
<text style="padding-left: 20rpx">{{ sample.cupNum }}号杯</text>
|
||||
</view>
|
||||
<view>
|
||||
<text style="padding-left: 20rpx">{{ sample.remarks }}</text>
|
||||
</view>
|
||||
<view>
|
||||
<text style="padding-left: 20rpx">{{ sample.measureTime | getWeightTimeShow }}</text>
|
||||
</view>
|
||||
</u-col>
|
||||
<u-col span="2">
|
||||
<view>
|
||||
<u-checkbox
|
||||
@change="checkboxChange"
|
||||
v-model="sample.checked"
|
||||
:label="sample.id"
|
||||
:name="sample.id"
|
||||
>
|
||||
</u-checkbox>
|
||||
<!-- <block v-if="sample.reviewCount > 0 && sample.weightSubmitStatus == 0">
|
||||
<u-button
|
||||
type="warning"
|
||||
@click="recovery(sample.id)"
|
||||
>恢复</u-button>
|
||||
</block>
|
||||
<block v-else>
|
||||
<u-button
|
||||
type="default"
|
||||
@click="review(sample.id)"
|
||||
>复核</u-button>
|
||||
</block> -->
|
||||
</view>
|
||||
</u-col>
|
||||
</u-row>
|
||||
<u-line style="padding: 10rpx" color="#bbb" />
|
||||
</view>
|
||||
</block>
|
||||
</u-checkbox-group>
|
||||
</scroll-view>
|
||||
<view class="content-main-right-operation">
|
||||
<u-row>
|
||||
<u-col span="4"><!-- <u-button class="btn-operation" type="primary">原始记录单打印</u-button> --></u-col>
|
||||
<u-col span="4"
|
||||
><!-- <u-button class="btn-operation" :disabled="reviewNum > 0" type="success" >数据上报</u-button> --></u-col
|
||||
>
|
||||
<u-col span="4">
|
||||
<!-- <u-button class="btn-operation" :disabled="reviewNum == 0" type="warning" @click="taskReview">任务单退回复核</u-button> -->
|
||||
<u-button class="btn-operation" :disabled="reviewList.length <= 0" type="warning" @click="taskReviewAll"
|
||||
>任务单退回复核</u-button
|
||||
>
|
||||
</u-col>
|
||||
</u-row>
|
||||
</view>
|
||||
</view>
|
||||
</u-col>
|
||||
</u-row>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
scrollTop: 0, //tab标题的滚动条位置
|
||||
current: 0, // 预设当前项的值
|
||||
menuHeight: 0, // 左边菜单的高度
|
||||
menuItemHeight: 0, // 左边菜单item的高度
|
||||
currentTaskId: '', //当前选择的任务单id
|
||||
currentTaskNo: '', //当前选中的任务编号
|
||||
reviewNum: 0, //复核数
|
||||
reviewList: [],
|
||||
taskList: [],
|
||||
sampleList: []
|
||||
}
|
||||
},
|
||||
onLoad(param) {
|
||||
if (param.currentTaskNo) {
|
||||
this.currentTaskNo = param.currentTaskNo
|
||||
}
|
||||
//获取任务列表
|
||||
this.getAssayTask()
|
||||
},
|
||||
methods: {
|
||||
//返回上一页
|
||||
customBack() {
|
||||
uni.redirectTo({
|
||||
url: '/pages/analysis/sample/sample-report'
|
||||
})
|
||||
},
|
||||
//开始秤样
|
||||
startWeighSample() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/auncel/auncel-weigh'
|
||||
})
|
||||
},
|
||||
//切换任务
|
||||
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.currentTaskNo = this.taskList[index].taskNo
|
||||
this.currentTaskId = this.taskList[index].id
|
||||
this.getAssayTaskDetail(this.currentTaskNo)
|
||||
},
|
||||
// 获取一个目标元素的高度
|
||||
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: '加载中...'
|
||||
})
|
||||
// this.$u.api
|
||||
// .getAssayTaskListBy({taskStatus:2})
|
||||
const param = {
|
||||
operateType: 'review',
|
||||
taskNo: this.currentTaskNo
|
||||
}
|
||||
this.$u.api
|
||||
.getAssayTaskList(param)
|
||||
.then(res => {
|
||||
this.taskList = res.result
|
||||
this.currentTaskNo = this.taskList[0].taskNo
|
||||
this.currentTaskId = this.taskList[0].id
|
||||
this.getAssayTaskDetail(this.currentTaskNo)
|
||||
uni.hideLoading()
|
||||
})
|
||||
.catch(err => {
|
||||
uni.hideLoading()
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
getAssayTaskDetail(taskNo) {
|
||||
this.reviewNum = 0
|
||||
this.$u.api
|
||||
.getAssayTaskDetailListByTaskNo({ taskNo: taskNo })
|
||||
.then(res => {
|
||||
this.sampleList = res.result
|
||||
this.showLoading = false
|
||||
|
||||
//统计需要复核的数量
|
||||
this.sampleList.forEach(item => {
|
||||
if (item.reviewCount > 0 && item.weightSubmitStatus == 0) {
|
||||
item.checked = true
|
||||
this.reviewNum += 1
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
this.showLoading = false
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
review(id) {
|
||||
this.$u.api
|
||||
.assayTaskDetailReview(id)
|
||||
.then(res => {
|
||||
this.getAssayTaskDetail(this.currentTaskNo)
|
||||
this.showLoading = false
|
||||
})
|
||||
.catch(err => {
|
||||
this.showLoading = false
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
recovery(id) {
|
||||
this.$u.api
|
||||
.assayTaskDetailRecovery(id)
|
||||
.then(res => {
|
||||
this.getAssayTaskDetail(this.currentTaskNo)
|
||||
this.showLoading = false
|
||||
})
|
||||
.catch(err => {
|
||||
this.showLoading = false
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
//任务单退回复核
|
||||
taskReview() {
|
||||
this.$u.api
|
||||
.assayTaskReview(this.currentTaskId)
|
||||
.then(res => {
|
||||
this.showLoading = false
|
||||
|
||||
uni.redirectTo({
|
||||
url: '/pages/sample/sample-report'
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
this.showLoading = false
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
//任务单及样品退回复核
|
||||
taskReviewAll() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定复核当前选中的样品?',
|
||||
cancelColor: '#0055A2',
|
||||
confirmColor: '#0055A2',
|
||||
success: res => {
|
||||
if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
return
|
||||
}
|
||||
console.log('确定。。。')
|
||||
//显示loading
|
||||
uni.showLoading({
|
||||
title: '退回中...'
|
||||
})
|
||||
this.$u.api
|
||||
.reviewWeightTaskByTaskIdAndSampleIds(this.currentTaskId, this.reviewList.join(','))
|
||||
.then(res => {
|
||||
uni.hideLoading()
|
||||
uni.redirectTo({
|
||||
url: '/pages/sample/sample-report'
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
uni.hideLoading()
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
checkboxGroupChange(v) {
|
||||
this.reviewList = v
|
||||
this.reviewNum = v.length
|
||||
//console.log('group change', v);
|
||||
},
|
||||
checkboxChange(e) {
|
||||
/* if(e.value) {
|
||||
this.review(e.name);
|
||||
} else {
|
||||
this.recovery(e.name);
|
||||
} */
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
getWeightTimeShow(time) {
|
||||
if (time == null) return ''
|
||||
return time.split(' ')[1]
|
||||
},
|
||||
getDataSourceTypeShow(val) {
|
||||
if (val == 2) return '【筛上】'
|
||||
if (val == 3) return '【筛下】'
|
||||
return ''
|
||||
}
|
||||
}
|
||||
}
|
||||
</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;
|
||||
}
|
||||
|
||||
.content-main-right {
|
||||
height: calc(100vh - 410rpx);
|
||||
}
|
||||
|
||||
.content-main-right-operation {
|
||||
height: 160rpx;
|
||||
padding-top: 30rpx;
|
||||
}
|
||||
|
||||
.btn-operation {
|
||||
height: 100rpx;
|
||||
font-size: 36rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -1,425 +0,0 @@
|
||||
<!--送样-->
|
||||
<template>
|
||||
<view class="page">
|
||||
<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 :color="taskStyle(task)" 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-right">
|
||||
<block v-for="(sample, index) in sampleList" :key="index">
|
||||
<view style="padding: 10rpx; font-size: 36rpx">
|
||||
<u-row>
|
||||
<u-col span="3" style="text-align: center">
|
||||
<view>
|
||||
<text>【{{ sample.sort }}】</text>
|
||||
</view>
|
||||
<!-- <u-row>-->
|
||||
<!-- <u-col span="6" style="text-align: center;">-->
|
||||
<!-- <u-checkbox v-model="sample.checked" v-if="sample.sampleProcessNo == 'F39'" @change="selectSample(sample)"></u-checkbox>-->
|
||||
<!-- </u-col>-->
|
||||
<!-- <u-col span="6" style="text-align: center;">-->
|
||||
<!-- -->
|
||||
<!-- </u-col>-->
|
||||
<!-- </u-row>-->
|
||||
</u-col>
|
||||
<u-col span="9" class="sample_desc">
|
||||
<view>
|
||||
<view>
|
||||
<text style="padding-left: 20rpx">{{ sample.sampleCode }}</text>
|
||||
</view>
|
||||
<view>
|
||||
<text style="padding-left: 20rpx"
|
||||
>{{ sample.dataSourceType | getDataSourceTypeShow }}{{ sample.sampleName }}</text
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
<view class="sample_desc_warn" v-if="sample.sampleProcessNo != 'F39'">
|
||||
状态异常:{{ sample.sampleProcessNo }}
|
||||
</view>
|
||||
</u-col>
|
||||
</u-row>
|
||||
<u-line style="padding: 10rpx" color="#bbb" />
|
||||
</view>
|
||||
</block>
|
||||
</scroll-view>
|
||||
<view class="content-main-right-operation">
|
||||
<u-row>
|
||||
<u-col span="4"></u-col>
|
||||
<u-col span="4"></u-col>
|
||||
<u-col span="4">
|
||||
<u-button
|
||||
class="btn-operation"
|
||||
:disabled="this.taskList.length <= 0"
|
||||
type="success"
|
||||
@click="confirmReceipt"
|
||||
>确认送样</u-button
|
||||
>
|
||||
</u-col>
|
||||
</u-row>
|
||||
</view>
|
||||
</view>
|
||||
</u-col>
|
||||
</u-row>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
scrollTop: 0, //tab标题的滚动条位置
|
||||
current: 0, // 预设当前项的值
|
||||
menuHeight: 0, // 左边菜单的高度
|
||||
menuItemHeight: 0, // 左边菜单item的高度
|
||||
currentTask: '', //当前选中任务
|
||||
currentTaskNo: '', //当前选中的任务编号
|
||||
currentTaskType: '', //当前任务类型
|
||||
taskList: [],
|
||||
sampleList: []
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
//获取任务列表
|
||||
this.getAssayTask()
|
||||
},
|
||||
methods: {
|
||||
//返回首页
|
||||
customBack() {
|
||||
uni.reLaunch({
|
||||
url: '/pages/analysis/index/index'
|
||||
})
|
||||
},
|
||||
selectSample(sample) {
|
||||
if (sample.checked) sample.checked = false
|
||||
else sample.checked = true
|
||||
},
|
||||
taskStyle(task) {
|
||||
if (task.weightTaskStatus == 0 && task.reviewCount > 0) {
|
||||
return 'red'
|
||||
}
|
||||
if (task.weightTaskStatus == 1 && task.reviewCount > 0) {
|
||||
return 'red'
|
||||
}
|
||||
if (task.weightTaskStatus == 2 && task.reviewCount > 0) {
|
||||
return 'green'
|
||||
}
|
||||
return ''
|
||||
},
|
||||
sampleStyle(sample) {
|
||||
//console.log(sample);
|
||||
if (sample.weightSubmitStatus == 0 && sample.reviewCount > 0) {
|
||||
return 'color: red'
|
||||
}
|
||||
if (sample.weightSubmitStatus == 1 && sample.reviewCount > 0) {
|
||||
//return 'color: #e0861a';
|
||||
return 'color: green'
|
||||
}
|
||||
if (sample.weightSubmitStatus == 2 && sample.reviewCount > 0) {
|
||||
return 'color: green'
|
||||
}
|
||||
return ''
|
||||
},
|
||||
//确认送样
|
||||
confirmReceipt() {
|
||||
//检查是否选中所有
|
||||
// let checkedSampleList = this.sampleList.filter(item => item.checked);
|
||||
// if (checkedSampleList.length != this.sampleList.length) {
|
||||
// this.$helper.showToast({
|
||||
// title: '样品未全部勾选,请检查!'
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
//检查是否所有样品都在F39
|
||||
const checkList = this.sampleList.filter(item => item.sampleProcessNo != 'F39')
|
||||
if (checkList.length > 0) {
|
||||
this.$helper.showToast({
|
||||
title: '部分样品状态异常,请联系技术支持人员处理!'
|
||||
})
|
||||
return
|
||||
}
|
||||
const checkedSampleList = this.sampleList
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确认送样?',
|
||||
cancelColor: '#0055A2',
|
||||
confirmColor: '#0055A2',
|
||||
success: res => {
|
||||
if (res.cancel) {
|
||||
return
|
||||
}
|
||||
const sampleIdList = checkedSampleList.map(item => item.busSubCsampleId)
|
||||
const data = {
|
||||
busAssayTaskId: this.currentTask.id,
|
||||
sampleSourceType: 2,
|
||||
sampleProcessNo: 'F39',
|
||||
isGenSampleHandover: false,
|
||||
sampleIdList: sampleIdList
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '正在提交...'
|
||||
})
|
||||
this.$u.api
|
||||
.execSendSample(data)
|
||||
.then(res => {
|
||||
let msg = '发生错误,请稍后再试!'
|
||||
if (!res.success) {
|
||||
if (res.message) {
|
||||
msg = res.message
|
||||
}
|
||||
this.$helper.showToast({
|
||||
title: msg
|
||||
})
|
||||
return
|
||||
}
|
||||
this.$helper.showToast({
|
||||
title: '操作成功!'
|
||||
})
|
||||
this.getAssayTask()
|
||||
})
|
||||
.catch(err => {
|
||||
this.$helper.showToast({
|
||||
title: '提交失败!'
|
||||
})
|
||||
console.log(err)
|
||||
})
|
||||
.finally(() => {
|
||||
uni.hideLoading()
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
//切换任务
|
||||
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.currentTask = this.taskList[index]
|
||||
this.currentTaskNo = this.taskList[index].taskNo
|
||||
this.currentTaskType = this.taskList[index].taskType
|
||||
this.getAssayTaskDetail(this.currentTaskNo)
|
||||
},
|
||||
// 获取一个目标元素的高度
|
||||
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 = {
|
||||
operateType: 'send',
|
||||
assayOper: this.userInfo.realname
|
||||
}
|
||||
this.$u.api
|
||||
.getAssayTaskList(param)
|
||||
.then(res => {
|
||||
this.taskList = res.result
|
||||
if (!this.taskList || this.taskList.length == 0) {
|
||||
this.sampleList = []
|
||||
return
|
||||
}
|
||||
if (this.taskList && this.taskList.length > 0) {
|
||||
this.current = 0
|
||||
this.currentTask = this.taskList[0]
|
||||
this.currentTaskNo = this.taskList[0].taskNo
|
||||
this.currentTaskType = this.taskList[0].taskType
|
||||
this.getAssayTaskDetail(this.currentTaskNo)
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
.finally(() => {
|
||||
uni.hideLoading()
|
||||
})
|
||||
},
|
||||
getAssayTaskDetail(taskNo) {
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
})
|
||||
const param = {
|
||||
taskNo: taskNo,
|
||||
waiting_receive: '1' //标记是收样
|
||||
}
|
||||
this.$u.api
|
||||
.getAssayTaskDetailListByTaskNo(param)
|
||||
.then(res => {
|
||||
const list = res.result
|
||||
list.forEach(item => {
|
||||
item.checked = false
|
||||
})
|
||||
this.sampleList = list
|
||||
this.showLoading = false
|
||||
})
|
||||
.catch(err => {
|
||||
this.showLoading = false
|
||||
console.log(err)
|
||||
})
|
||||
.finally(() => {
|
||||
uni.hideLoading()
|
||||
})
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
getDataSourceTypeShow(val) {
|
||||
if (val == 2) return '【筛上】'
|
||||
if (val == 3) return '【筛下】'
|
||||
return ''
|
||||
}
|
||||
}
|
||||
}
|
||||
</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;
|
||||
}
|
||||
|
||||
.content-main-right {
|
||||
height: calc(100vh - 410rpx);
|
||||
}
|
||||
|
||||
.content-main-right-operation {
|
||||
height: 160rpx;
|
||||
padding-top: 30rpx;
|
||||
}
|
||||
|
||||
.btn-operation {
|
||||
height: 100rpx;
|
||||
font-size: 36rpx;
|
||||
}
|
||||
|
||||
.sample_desc {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: nowrap; /* 禁止换行 */
|
||||
justify-content: space-between !important;
|
||||
padding-right: 15px !important;
|
||||
}
|
||||
|
||||
.sample_desc_warn {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
@@ -1,319 +0,0 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<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 :color="taskStyle(task)" 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 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-right">
|
||||
<block v-for="(sample, index) in sampleList" :key="index">
|
||||
<view v-if="currentTask.reviewCount == sample.reviewCount" 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.dataSourceType | getDataSourceTypeShow }}{{ sample.sampleName }}</text
|
||||
>
|
||||
</view>
|
||||
<block v-if="sample.sampleWeight && sample.weightSubmitStatus != 0">
|
||||
<view>
|
||||
<text v-if="sample.sampleWeight" style="padding-left: 20rpx">{{ sample.sampleWeight }} g</text>
|
||||
</view>
|
||||
</block>
|
||||
</u-col>
|
||||
</u-row>
|
||||
<u-line style="padding: 10rpx" color="#bbb" />
|
||||
</view>
|
||||
</block>
|
||||
</scroll-view>
|
||||
<view class="content-main-right-operation">
|
||||
<u-row>
|
||||
<u-col span="4"></u-col>
|
||||
<u-col span="4"></u-col>
|
||||
<u-col span="4">
|
||||
<u-button
|
||||
class="btn-operation"
|
||||
:disabled="this.taskList.length <= 0"
|
||||
type="success"
|
||||
@click="startWeighSample"
|
||||
>开始秤样</u-button
|
||||
>
|
||||
</u-col>
|
||||
</u-row>
|
||||
</view>
|
||||
</view>
|
||||
</u-col>
|
||||
</u-row>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
scrollTop: 0, //tab标题的滚动条位置
|
||||
current: 0, // 预设当前项的值
|
||||
menuHeight: 0, // 左边菜单的高度
|
||||
menuItemHeight: 0, // 左边菜单item的高度
|
||||
currentTask: '', //当前选中任务
|
||||
currentTaskNo: '', //当前选中的任务编号
|
||||
currentTaskType: '', //当前任务类型
|
||||
taskList: [],
|
||||
sampleList: []
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
//获取任务列表
|
||||
this.getAssayTask()
|
||||
},
|
||||
methods: {
|
||||
//返回首页
|
||||
customBack() {
|
||||
uni.reLaunch({
|
||||
url: '/pages/analysis/index/index'
|
||||
})
|
||||
},
|
||||
taskStyle(task) {
|
||||
if (task.weightTaskStatus == 0 && task.reviewCount > 0) {
|
||||
return 'red'
|
||||
}
|
||||
if (task.weightTaskStatus == 1 && task.reviewCount > 0) {
|
||||
return 'red'
|
||||
}
|
||||
if (task.weightTaskStatus == 2 && task.reviewCount > 0) {
|
||||
return 'green'
|
||||
}
|
||||
return ''
|
||||
},
|
||||
sampleStyle(sample) {
|
||||
//console.log(sample);
|
||||
if (sample.weightSubmitStatus == 0 && sample.reviewCount > 0) {
|
||||
return 'color: red'
|
||||
}
|
||||
if (sample.weightSubmitStatus == 1 && sample.reviewCount > 0) {
|
||||
//return 'color: #e0861a';
|
||||
return 'color: green'
|
||||
}
|
||||
if (sample.weightSubmitStatus == 2 && sample.reviewCount > 0) {
|
||||
return 'color: green'
|
||||
}
|
||||
return ''
|
||||
},
|
||||
//开始秤样
|
||||
startWeighSample() {
|
||||
uni.navigateTo({
|
||||
url:
|
||||
'/pages/auncel/auncel-weigh?currentTaskNo=' + this.currentTaskNo + '¤tTaskType=' + this.currentTaskType
|
||||
})
|
||||
},
|
||||
//切换任务
|
||||
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.currentTask = this.taskList[index]
|
||||
this.currentTaskNo = this.taskList[index].taskNo
|
||||
this.currentTaskType = this.taskList[index].taskType
|
||||
this.getAssayTaskDetail(this.currentTaskNo)
|
||||
},
|
||||
// 获取一个目标元素的高度
|
||||
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 = {
|
||||
operateType: 'weight',
|
||||
assayOper: this.userInfo.realname
|
||||
}
|
||||
this.$u.api
|
||||
.getAssayTaskList(param)
|
||||
.then(res => {
|
||||
this.taskList = res.result
|
||||
|
||||
if (this.taskList && this.taskList.length > 0) {
|
||||
this.currentTask = this.taskList[0]
|
||||
this.currentTaskNo = this.taskList[0].taskNo
|
||||
this.currentTaskType = this.taskList[0].taskType
|
||||
this.getAssayTaskDetail(this.currentTaskNo)
|
||||
}
|
||||
uni.hideLoading()
|
||||
})
|
||||
.catch(err => {
|
||||
uni.hideLoading()
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
getAssayTaskDetail(taskNo) {
|
||||
this.$u.api
|
||||
.getAssayTaskDetailListByTaskNo({ taskNo: taskNo })
|
||||
.then(res => {
|
||||
this.sampleList = res.result
|
||||
this.showLoading = false
|
||||
})
|
||||
.catch(err => {
|
||||
this.showLoading = false
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
getDataSourceTypeShow(val) {
|
||||
if (val == 2) return '【筛上】'
|
||||
if (val == 3) return '【筛下】'
|
||||
return ''
|
||||
}
|
||||
}
|
||||
}
|
||||
</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;
|
||||
}
|
||||
|
||||
.content-main-right {
|
||||
height: calc(100vh - 410rpx);
|
||||
}
|
||||
|
||||
.content-main-right-operation {
|
||||
height: 160rpx;
|
||||
padding-top: 30rpx;
|
||||
}
|
||||
|
||||
.btn-operation {
|
||||
height: 100rpx;
|
||||
font-size: 36rpx;
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,7 @@
|
||||
<u-input
|
||||
v-if="
|
||||
field.type == 'input' &&
|
||||
(field.decimalCount == null || field.decimalCount == '' || Number(field.decimalCount == null) < 0)
|
||||
(field.decimalCount == null || field.decimalCount == '' || Number(field.decimalCount) < 0)
|
||||
"
|
||||
v-model="field.value"
|
||||
clearable
|
||||
@@ -29,7 +29,7 @@
|
||||
/>
|
||||
<!--数字,限制小数位数-->
|
||||
<u-input
|
||||
v-if="field.type == 'input' && field.decimalCount != null && Number(field.decimalCount == null) >= 0"
|
||||
v-if="field.type == 'input' && field.decimalCount != null && Number(field.decimalCount) >= 0"
|
||||
type="number"
|
||||
clearable
|
||||
@blur="event => checkDecimal(event, field)"
|
||||
@@ -77,482 +77,483 @@
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import request from '@/nx/request'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { calcAnalysisValue } from '@/nx/helper/calcAnalysisValue'
|
||||
import nx from '@/nx'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
title: '编辑指派单',
|
||||
taskInstance: {},
|
||||
scrollTop: 0, //tab标题的滚动条位置
|
||||
currentTaskNo: '', //当前任务样品
|
||||
showDicPicker: false,
|
||||
curDate: Number(new Date()),
|
||||
//字段值对象
|
||||
formValue: {},
|
||||
//后端返回的字段结构
|
||||
sourceFormFields: [],
|
||||
//处理后的字段结构
|
||||
formFields: [],
|
||||
sampleList: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
dynamicFieldPlaceholder(field) {
|
||||
return '请输入'
|
||||
}
|
||||
},
|
||||
onLoad(param) {
|
||||
if (param.currentTaskNo) {
|
||||
this.currentTaskNo = param.currentTaskNo
|
||||
}
|
||||
this.title = '样品分析-任务指派单:' + this.currentTaskNo
|
||||
this.loadHeadFieldsAndValueByTaskNo()
|
||||
this.getSampleList(this.currentTaskNo)
|
||||
},
|
||||
methods: {
|
||||
handleFieldClick(field) {
|
||||
if (field.type == 'date') {
|
||||
if (field.fillingWay == '1') {
|
||||
field.showPicker = true
|
||||
}
|
||||
return
|
||||
}
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
|
||||
// ========== data ==========
|
||||
|
||||
// 标题
|
||||
const title = ref('编辑指派单')
|
||||
// 表单模型
|
||||
const taskInstance = ref({})
|
||||
// tab标题的滚动条位置
|
||||
const scrollTop = ref(0)
|
||||
// 当前任务样品
|
||||
const currentTaskNo = ref('')
|
||||
// 字典选择器显示
|
||||
const showDicPicker = ref(false)
|
||||
// 当前日期(用于日期选择器)
|
||||
const curDate = ref(Number(new Date()))
|
||||
// 字段值对象
|
||||
const formValue = ref({})
|
||||
// 后端返回的字段结构
|
||||
const sourceFormFields = ref([])
|
||||
// 处理后的字段结构
|
||||
const formFields = ref([])
|
||||
// 样品列表
|
||||
const sampleList = ref([])
|
||||
|
||||
// 表单引用
|
||||
const uForm = ref(null)
|
||||
|
||||
// 页面加载
|
||||
onLoad(param => {
|
||||
if (param.currentTaskNo) {
|
||||
currentTaskNo.value = param.currentTaskNo
|
||||
}
|
||||
title.value = '样品分析-任务指派单:' + currentTaskNo.value
|
||||
loadHeadFieldsAndValueByTaskNo()
|
||||
getSampleList(currentTaskNo.value)
|
||||
})
|
||||
|
||||
// ========== methods ==========
|
||||
|
||||
// 点击字段(打开选择器)
|
||||
function handleFieldClick(field) {
|
||||
if (field.type == 'date') {
|
||||
if (field.fillingWay == '1') {
|
||||
field.showPicker = true
|
||||
},
|
||||
checkFeadToDetailField(headToDetailField) {
|
||||
if (headToDetailField && headToDetailField.trim() != '') {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
},
|
||||
getSampleList(taskNo) {
|
||||
this.$u.api
|
||||
.getAssayTaskDetailListByTaskNo({ taskNo: taskNo })
|
||||
.then(res => {
|
||||
this.sampleList = res.result
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err)
|
||||
})
|
||||
},
|
||||
//返回上一页
|
||||
// customBack() {
|
||||
// uni.redirectTo({
|
||||
// url: "/pages/sample/sample-work-detail"
|
||||
// });
|
||||
// },
|
||||
navRightClick() {},
|
||||
//处理小数位数:补0或去除多余位数
|
||||
checkDecimal(e, field) {
|
||||
if (e == '') return
|
||||
const decimalCount = field.decimalCount
|
||||
if (decimalCount == null || decimalCount == '' || isNaN(decimalCount)) return
|
||||
const count = Number(field.decimalCount)
|
||||
}
|
||||
return
|
||||
}
|
||||
field.showPicker = true
|
||||
}
|
||||
|
||||
// 判断是否需要同步到明细字段(加粗显示)
|
||||
function checkFeadToDetailField(headToDetailField) {
|
||||
if (headToDetailField && headToDetailField.trim() != '') {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 获取样品列表
|
||||
function getSampleList(taskNo) {
|
||||
nx.$api.assayTask
|
||||
.getAssayTaskDetailListByTaskNo({ taskNo: taskNo })
|
||||
.then(res => {
|
||||
sampleList.value = res.result
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err)
|
||||
})
|
||||
}
|
||||
|
||||
// 返回上一页(原注释保留,未启用)
|
||||
// function customBack() {
|
||||
// uni.redirectTo({
|
||||
// url: "/pages/sample/sample-work-detail"
|
||||
// });
|
||||
// }
|
||||
|
||||
// 右上角导航点击(空实现)
|
||||
function navRightClick() {}
|
||||
|
||||
// 处理小数位数:补0或去除多余位数
|
||||
function checkDecimal(e, field) {
|
||||
if (e == '') return
|
||||
const decimalCount = field.decimalCount
|
||||
if (decimalCount == null || decimalCount == '' || isNaN(decimalCount)) return
|
||||
const count = Number(field.decimalCount)
|
||||
const value = field.value
|
||||
const pos = value.indexOf('.') + 1
|
||||
let length = value.length - pos
|
||||
if (pos == 0) {
|
||||
length = 0
|
||||
}
|
||||
while (length < count) {
|
||||
if (field.value.indexOf('.') < 0) field.value += '.'
|
||||
field.value = field.value + '0'
|
||||
length++
|
||||
}
|
||||
if (count === 0) {
|
||||
field.value = parseInt(field.value) + ''
|
||||
} else if (length > count) {
|
||||
field.value = field.value.substring(0, pos + count)
|
||||
}
|
||||
}
|
||||
|
||||
// 组装字段(处理默认值、初始化 picker 状态)
|
||||
function assembleFields() {
|
||||
const formFieldsArr = []
|
||||
for (const field of sourceFormFields.value) {
|
||||
//日期类型的默认值
|
||||
if (field.type == 'date') {
|
||||
const value = field.value
|
||||
const pos = value.indexOf('.') + 1
|
||||
let length = value.length - pos
|
||||
if (pos == 0) {
|
||||
length = 0
|
||||
}
|
||||
while (length < count) {
|
||||
if (field.value.indexOf('.') < 0) field.value += '.'
|
||||
field.value = field.value + '0'
|
||||
length++
|
||||
}
|
||||
if (count === 0) {
|
||||
field.value = parseInt(field.value) + ''
|
||||
} else if (length > count) {
|
||||
field.value = field.value.substring(0, pos + count)
|
||||
}
|
||||
},
|
||||
updateFieldValue(name, val) {
|
||||
for (const field of this.formFields) {
|
||||
if (field.prop == name) {
|
||||
field.value = val
|
||||
break
|
||||
}
|
||||
}
|
||||
},
|
||||
assembleFields() {
|
||||
const me = this
|
||||
const formFields = []
|
||||
for (const field of this.sourceFormFields) {
|
||||
//日期类型的默认值
|
||||
if (field.type == 'date') {
|
||||
const value = field.value
|
||||
field.showPicker = false
|
||||
if (value == 'curDate') {
|
||||
field.value = me.$helper.dateFormat(new Date(), 'yyyy-MM-dd')
|
||||
}
|
||||
}
|
||||
if (field.type == 'select') {
|
||||
field.showPicker = false
|
||||
}
|
||||
formFields.push(field)
|
||||
}
|
||||
//先序列化再转json,避免json里定义的方法丢失
|
||||
this.formFields = JSON.parse(JSON.stringify(formFields, replacer), reviver)
|
||||
|
||||
// this.formFields = formFields;
|
||||
},
|
||||
//绑定数据
|
||||
bindFormValue() {
|
||||
const me = this
|
||||
//formValue
|
||||
for (const field of me.formFields) {
|
||||
const prop = field.prop
|
||||
if (prop) {
|
||||
const value = me.formValue[prop]
|
||||
if (value) {
|
||||
field.value = value
|
||||
if (field.type == 'select') {
|
||||
field.valueText = value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
//获取表单字段和值(老数据)
|
||||
loadHeadFieldsAndValueByTaskNo() {
|
||||
const me = this
|
||||
const currentTaskNo = me.currentTaskNo
|
||||
this.$u.api
|
||||
.queryHeadValueByTaskNo({ taskNo: currentTaskNo })
|
||||
.then(res => {
|
||||
const result = res.result
|
||||
const formConf = result.formConf
|
||||
me.sourceFormFields = eval(formConf)
|
||||
me.formValue = JSON.parse(result.formValue)
|
||||
//加载和处理表单字段
|
||||
me.assembleFields()
|
||||
//绑定数据
|
||||
me.bindFormValue()
|
||||
//读取字段里的动态选项
|
||||
me.loadFieldApiData()
|
||||
console.log('formFields', this.formFields)
|
||||
})
|
||||
.catch(err => {
|
||||
//如果没有查到数据,按配置读取新的表单字段
|
||||
me.getHeadFields()
|
||||
})
|
||||
},
|
||||
// 获取表单字段(新数据)
|
||||
getHeadFields() {
|
||||
const me = this
|
||||
const currentTaskNo = this.currentTaskNo
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
})
|
||||
this.$u.api
|
||||
.queryHeadFieldsByTaskNo({ taskNo: currentTaskNo })
|
||||
.then(res => {
|
||||
me.sourceFormFields = me.analysisFormAndFields(res)
|
||||
//加载和处理表单字段
|
||||
me.assembleFields()
|
||||
//读取字段里的动态选项
|
||||
me.loadFieldApiData()
|
||||
})
|
||||
.finally(() => {
|
||||
uni.hideLoading()
|
||||
})
|
||||
},
|
||||
analysisFormAndFields(formRet) {
|
||||
const fieldsArray = []
|
||||
for (const form of formRet) {
|
||||
let content = cloneDeep(form.content)
|
||||
content = eval('(' + content + ')')
|
||||
const column = content.column
|
||||
for (const field of column) {
|
||||
fieldsArray.push(field)
|
||||
}
|
||||
}
|
||||
return fieldsArray
|
||||
},
|
||||
//将抬头字段值同步保存到明细字段
|
||||
saveHeadValueToDetail(onComplete) {
|
||||
//循环抬头字段,提取需哟保存到明细的字段
|
||||
const conf = []
|
||||
for (const field of this.formFields) {
|
||||
const prop = field.prop
|
||||
const headToDetailField = field.headToDetailField
|
||||
if (prop && headToDetailField && headToDetailField.trim() != '') {
|
||||
const value = field.value
|
||||
const r = {
|
||||
prop: field.prop,
|
||||
value: value,
|
||||
headToDetailField: headToDetailField
|
||||
}
|
||||
conf.push(r)
|
||||
}
|
||||
}
|
||||
const data = {
|
||||
taskNo: this.currentTaskNo,
|
||||
conf: conf
|
||||
}
|
||||
this.$u.api.saveHeadValueToDetail(data).then(res => {
|
||||
if (onComplete) onComplete()
|
||||
})
|
||||
},
|
||||
handleSave() {
|
||||
//显示loading
|
||||
uni.showLoading({
|
||||
title: '正在保存...'
|
||||
})
|
||||
//组装数据
|
||||
const formValue = {}
|
||||
for (const field of this.formFields) {
|
||||
const prop = field.prop
|
||||
if (prop) {
|
||||
formValue[prop] = field.value
|
||||
}
|
||||
}
|
||||
const value = {
|
||||
taskNo: this.currentTaskNo,
|
||||
formValue: JSON.stringify(formValue),
|
||||
formConf: JSON.stringify(this.sourceFormFields, replacer)
|
||||
}
|
||||
this.$u.api
|
||||
.saveHeadValue(value)
|
||||
.then(async res => {
|
||||
await this.saveHeadValueToDetail(async () => {
|
||||
if (this.checkPropertyEquality()) {
|
||||
await this.processIds(this.sampleList, 100)
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
// this.$helper.showToast({
|
||||
// title: '保存成功!'
|
||||
// });
|
||||
uni.redirectTo({
|
||||
url: '/pages/analysis/sample/sample-work-detail?currentTaskNo=' + this.currentTaskNo
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
uni.hideLoading()
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
// 检查字段修改前和修改后字段值是否相等
|
||||
checkPropertyEquality() {
|
||||
for (const field of this.formFields) {
|
||||
const prop = field.prop
|
||||
if (prop && field['headToDetailField'] && field['headToDetailField'].trim() !== '') {
|
||||
const flag = this.formValue[prop] !== field.value ? true : false
|
||||
if (flag) return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
},
|
||||
//保存抬头字段
|
||||
saveHeadData() {
|
||||
if (this.checkPropertyEquality()) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '您修改的字段将影响样品分析结果,系统将重新计算',
|
||||
showCancel: false,
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.handleSave()
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.handleSave()
|
||||
}
|
||||
},
|
||||
// 通过样品id查询明细
|
||||
async getSampleDataById(taskDetailId) {
|
||||
let fieldGroup = []
|
||||
const { result, additionalProperties } = await this.$u.api.queryFieldsByTaskDetail({
|
||||
taskDetailId,
|
||||
isSearchSRange: '0'
|
||||
})
|
||||
fieldGroup = result
|
||||
const conAssayTaskId = additionalProperties.conAssayTaskId
|
||||
const busSubCSampleId = additionalProperties.busSubCSampleId
|
||||
const detail = additionalProperties.taskDetail
|
||||
//处理硫值、硫量:未保存过的数据,读取接口返回的硫值、硫量
|
||||
// this.loadSValue(detail);
|
||||
//按公式计算值,并检查原数据与计算后的数据是否一致
|
||||
try {
|
||||
calcAnalysisValue(fieldGroup)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
let valueList = []
|
||||
let cupNum = 0
|
||||
for (const g of fieldGroup) {
|
||||
for (const f of g.fields) {
|
||||
if (f.dicKey == 'bh' || f.dicKey == 'bh_up') cupNum = f.value
|
||||
valueList.push({
|
||||
id: f.detailId,
|
||||
type: f.pOrE,
|
||||
value: f.value,
|
||||
name: f.name,
|
||||
dataType: f.dataType
|
||||
})
|
||||
}
|
||||
}
|
||||
let params = {
|
||||
busSubCSampleId,
|
||||
conAssayTaskId,
|
||||
// measureTime : this.curSample.measureTime,
|
||||
elementParamValueList: valueList,
|
||||
busAssayTaskDetailId: taskDetailId
|
||||
}
|
||||
if (typeof cupNum != 'undefined' && cupNum != null && cupNum != '' && cupNum != 0 && cupNum != '0') {
|
||||
//提交杯号,保存到后台
|
||||
params.cupNum = cupNum
|
||||
}
|
||||
return params
|
||||
},
|
||||
// 提交样品
|
||||
async submitData(data) {
|
||||
try {
|
||||
await this.$u.api.saveDetailValue(data)
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
},
|
||||
async processIds(list, interval) {
|
||||
let index = 0
|
||||
const intervalId = setInterval(async () => {
|
||||
if (index < list.length) {
|
||||
const item = list[index]
|
||||
index++
|
||||
const params = await this.getSampleDataById(item['id'])
|
||||
await this.submitData(params)
|
||||
} else {
|
||||
clearInterval(intervalId) // 所有任务完成后清除定时器
|
||||
uni.redirectTo({
|
||||
url: '/pages/analysis/sample/sample-work-detail?currentTaskNo=' + this.currentTaskNo
|
||||
})
|
||||
}
|
||||
}, interval)
|
||||
},
|
||||
|
||||
async apiRequest(url) {
|
||||
return request({
|
||||
url: url,
|
||||
method: 'GET',
|
||||
custom: {
|
||||
isApiEncryption: true
|
||||
}
|
||||
})
|
||||
},
|
||||
//读取字段里的API选项
|
||||
async loadFieldApiData() {
|
||||
const formFields = this.formFields
|
||||
let changeFlag = false
|
||||
for (const field of formFields) {
|
||||
const dicUrl = field.dicUrl
|
||||
const type = field.type
|
||||
if (dicUrl && dicUrl != '') {
|
||||
//读取API选项
|
||||
try {
|
||||
const res = await this.apiRequest(dicUrl)
|
||||
|
||||
const data = res
|
||||
const confLabel = field.props.label
|
||||
const confValue = field.props.value
|
||||
const emptyItem = { name: '', displayName: '' }
|
||||
emptyItem[confLabel] = ''
|
||||
emptyItem[confValue] = ''
|
||||
//设置valueText、displayName
|
||||
for (const item of data) {
|
||||
if (item[confValue] == field.value) {
|
||||
changeFlag = true
|
||||
field.valueText = item[confLabel]
|
||||
}
|
||||
}
|
||||
// data.unshift(emptyItem) //添加空数据
|
||||
field.options = data
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
if (changeFlag) {
|
||||
const formFields = this.formFields
|
||||
// this.formFields = JSON.parse(JSON.stringify(formFields));
|
||||
this.formFields = JSON.parse(JSON.stringify(formFields, replacer), reviver)
|
||||
}
|
||||
},
|
||||
/*
|
||||
* 选择器组件确认事件
|
||||
* event: 事件默认参数
|
||||
* field: 当前字段
|
||||
* 处理逻辑:
|
||||
* field.value = 选中的值
|
||||
* field.valueText = 选中的文本
|
||||
* todo: 关联字段在动态字段的change事件处理
|
||||
* */
|
||||
pickerConfirm(event, field) {
|
||||
const me = this
|
||||
if (field.type == 'date') {
|
||||
field.value = nx.$dayjs(event.value).format(field.format)
|
||||
field.showPicker = false
|
||||
return
|
||||
}
|
||||
const confLabel = field.props.label
|
||||
const confValue = field.props.value
|
||||
const selected = event.value[0]
|
||||
const value = selected[confValue]
|
||||
const displayName = selected[confLabel]
|
||||
field.value = value
|
||||
field.valueText = displayName
|
||||
if (typeof field.change == 'function') {
|
||||
field.change({ value }, selected, me)
|
||||
}
|
||||
field.showPicker = false
|
||||
},
|
||||
checkLoadSValue() {
|
||||
const vKey = 'sRange'
|
||||
const vF = this.getFieldByKey(vKey)
|
||||
if (vF == null) return false
|
||||
const v = vF.value
|
||||
if (v == null || v == '') return true
|
||||
try {
|
||||
if (v == 0 || number(v) == 0) return true
|
||||
} catch (e) {}
|
||||
return false
|
||||
},
|
||||
//读取硫值、硫量
|
||||
loadSValue(detail) {
|
||||
let flag = this.checkLoadSValue()
|
||||
if (!flag) return
|
||||
const vKey = 'sValue'
|
||||
const rKey = 'sRange'
|
||||
const vF = this.getFieldByKey(vKey)
|
||||
if (vF != null) {
|
||||
vF.value = detail.svalue
|
||||
if (value == 'curDate') {
|
||||
field.value = nx.$dayjs.format('yyyy-MM-dd')
|
||||
}
|
||||
const rF = this.getFieldByKey(rKey)
|
||||
if (rF != null) {
|
||||
rF.value = detail.srange
|
||||
}
|
||||
},
|
||||
getFieldByKey(key) {
|
||||
const group = this.fieldGroup
|
||||
let field = null
|
||||
for (let g of group) {
|
||||
for (let f of g.fields) {
|
||||
const dicKey = f.dicKey
|
||||
if (dicKey && dicKey == key) {
|
||||
field = f
|
||||
break
|
||||
}
|
||||
}
|
||||
if (field.type == 'select') {
|
||||
field.showPicker = false
|
||||
}
|
||||
formFieldsArr.push(field)
|
||||
}
|
||||
//先序列化再转json,避免json里定义的方法丢失
|
||||
formFields.value = JSON.parse(JSON.stringify(formFieldsArr, replacer), reviver)
|
||||
}
|
||||
|
||||
// 绑定数据(将 formValue 填入字段)
|
||||
function bindFormValue() {
|
||||
//formValue
|
||||
for (const field of formFields.value) {
|
||||
const prop = field.prop
|
||||
if (prop) {
|
||||
const value = formValue.value[prop]
|
||||
if (value) {
|
||||
field.value = value
|
||||
if (field.type == 'select') {
|
||||
field.valueText = value
|
||||
}
|
||||
}
|
||||
// console.log('field', JSON.stringify(field));
|
||||
return field
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取表单字段和值(老数据)
|
||||
function loadHeadFieldsAndValueByTaskNo() {
|
||||
nx.$api.assayTask
|
||||
.queryHeadValueByTaskNo({ taskNo: currentTaskNo.value })
|
||||
.then(res => {
|
||||
const result = res.result
|
||||
const formConf = result.formConf
|
||||
sourceFormFields.value = eval(formConf)
|
||||
formValue.value = JSON.parse(result.formValue)
|
||||
//加载和处理表单字段
|
||||
assembleFields()
|
||||
//绑定数据
|
||||
bindFormValue()
|
||||
//读取字段里的动态选项
|
||||
loadFieldApiData()
|
||||
console.log('formFields', formFields.value)
|
||||
})
|
||||
.catch(err => {
|
||||
//如果没有查到数据,按配置读取新的表单字段
|
||||
getHeadFields()
|
||||
})
|
||||
}
|
||||
|
||||
// 获取表单字段(新数据)
|
||||
function getHeadFields() {
|
||||
nx.$api.assayTask.queryHeadFieldsByTaskNo({ taskNo: currentTaskNoVal }).then(res => {
|
||||
sourceFormFields.value = analysisFormAndFields(res)
|
||||
//加载和处理表单字段
|
||||
assembleFields()
|
||||
//读取字段里的动态选项
|
||||
loadFieldApiData()
|
||||
})
|
||||
}
|
||||
|
||||
// 解析表单结构
|
||||
function analysisFormAndFields(formRet) {
|
||||
const fieldsArray = []
|
||||
for (const form of formRet) {
|
||||
let content = cloneDeep(form.content)
|
||||
content = eval('(' + content + ')')
|
||||
const column = content.column
|
||||
for (const field of column) {
|
||||
fieldsArray.push(field)
|
||||
}
|
||||
}
|
||||
return fieldsArray
|
||||
}
|
||||
|
||||
// 将抬头字段值同步保存到明细字段
|
||||
function saveHeadValueToDetail(onComplete) {
|
||||
//循环抬头字段,提取需哟保存到明细的字段
|
||||
const conf = []
|
||||
for (const field of formFields.value) {
|
||||
const prop = field.prop
|
||||
const headToDetailField = field.headToDetailField
|
||||
if (prop && headToDetailField && headToDetailField.trim() != '') {
|
||||
const value = field.value
|
||||
const r = {
|
||||
prop: field.prop,
|
||||
value: value,
|
||||
headToDetailField: headToDetailField
|
||||
}
|
||||
conf.push(r)
|
||||
}
|
||||
}
|
||||
const data = {
|
||||
taskNo: currentTaskNo.value,
|
||||
conf: conf
|
||||
}
|
||||
nx.$api.assayTask.saveHeadValueToDetail(data).then(res => {
|
||||
if (onComplete) onComplete()
|
||||
})
|
||||
}
|
||||
|
||||
// 实际保存逻辑
|
||||
function handleSave() {
|
||||
//组装数据
|
||||
const formValueObj = {}
|
||||
for (const field of formFields.value) {
|
||||
const prop = field.prop
|
||||
if (prop) {
|
||||
formValueObj[prop] = field.value
|
||||
}
|
||||
}
|
||||
const value = {
|
||||
taskNo: currentTaskNo.value,
|
||||
formValue: JSON.stringify(formValueObj),
|
||||
formConf: JSON.stringify(sourceFormFields.value, replacer)
|
||||
}
|
||||
nx.$api.assayTask.saveHeadValue(value).then(async res => {
|
||||
await saveHeadValueToDetail(async () => {
|
||||
if (checkPropertyEquality()) {
|
||||
await processIds(sampleList.value, 100)
|
||||
} else {
|
||||
uni.redirectTo({
|
||||
url: '/pages/analysis/sample/sample-work-detail?currentTaskNo=' + currentTaskNo.value
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 检查字段修改前和修改后字段值是否相等
|
||||
function checkPropertyEquality() {
|
||||
for (const field of formFields.value) {
|
||||
const prop = field.prop
|
||||
if (prop && field['headToDetailField'] && field['headToDetailField'].trim() !== '') {
|
||||
const flag = formValue.value[prop] !== field.value ? true : false
|
||||
if (flag) return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 保存抬头字段(带确认弹窗)
|
||||
function saveHeadData() {
|
||||
if (checkPropertyEquality()) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '您修改的字段将影响样品分析结果,系统将重新计算',
|
||||
showCancel: false,
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
handleSave()
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
handleSave()
|
||||
}
|
||||
}
|
||||
|
||||
// 通过样品id查询明细
|
||||
async function getSampleDataById(taskDetailId) {
|
||||
let fieldGroup = []
|
||||
const { result, additionalProperties } = await nx.$api.assayTask.queryFieldsByTaskDetail({
|
||||
taskDetailId,
|
||||
isSearchSRange: '0'
|
||||
})
|
||||
fieldGroup = result
|
||||
const conAssayTaskId = additionalProperties.conAssayTaskId
|
||||
const busSubCSampleId = additionalProperties.busSubCSampleId
|
||||
const detail = additionalProperties.taskDetail
|
||||
//处理硫值、硫量:未保存过的数据,读取接口返回的硫值、硫量
|
||||
// loadSValue(detail);
|
||||
//按公式计算值,并检查原数据与计算后的数据是否一致
|
||||
try {
|
||||
calcAnalysisValue(fieldGroup)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
let valueList = []
|
||||
let cupNum = 0
|
||||
for (const g of fieldGroup) {
|
||||
for (const f of g.fields) {
|
||||
if (f.dicKey == 'bh' || f.dicKey == 'bh_up') cupNum = f.value
|
||||
valueList.push({
|
||||
id: f.detailId,
|
||||
type: f.pOrE,
|
||||
value: f.value,
|
||||
name: f.name,
|
||||
dataType: f.dataType
|
||||
})
|
||||
}
|
||||
}
|
||||
let params = {
|
||||
busSubCSampleId,
|
||||
conAssayTaskId,
|
||||
// measureTime : this.curSample.measureTime,
|
||||
elementParamValueList: valueList,
|
||||
busAssayTaskDetailId: taskDetailId
|
||||
}
|
||||
if (typeof cupNum != 'undefined' && cupNum != null && cupNum != '' && cupNum != 0 && cupNum != '0') {
|
||||
//提交杯号,保存到后台
|
||||
params.cupNum = cupNum
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
// 提交样品
|
||||
async function submitData(data) {
|
||||
try {
|
||||
await nx.$api.assayTask.saveDetailValue(data)
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// 批量处理样品(带间隔)
|
||||
async function processIds(list, interval) {
|
||||
let index = 0
|
||||
const intervalId = setInterval(async () => {
|
||||
if (index < list.length) {
|
||||
const item = list[index]
|
||||
index++
|
||||
const params = await getSampleDataById(item['id'])
|
||||
await submitData(params)
|
||||
} else {
|
||||
clearInterval(intervalId) // 所有任务完成后清除定时器
|
||||
uni.redirectTo({
|
||||
url: '/pages/analysis/sample/sample-work-detail?currentTaskNo=' + currentTaskNo.value
|
||||
})
|
||||
}
|
||||
}, interval)
|
||||
}
|
||||
|
||||
// 通用 API 请求
|
||||
async function apiRequest(url) {
|
||||
return request({
|
||||
url: url,
|
||||
method: 'GET'
|
||||
})
|
||||
}
|
||||
|
||||
// 读取字段里的API选项
|
||||
async function loadFieldApiData() {
|
||||
const formFieldsVal = formFields.value
|
||||
let changeFlag = false
|
||||
for (const field of formFieldsVal) {
|
||||
const dicUrl = field.dicUrl
|
||||
const type = field.type
|
||||
if (dicUrl && dicUrl != '') {
|
||||
//读取API选项
|
||||
try {
|
||||
const res = await apiRequest(dicUrl)
|
||||
|
||||
const data = res
|
||||
const confLabel = field.props.label
|
||||
const confValue = field.props.value
|
||||
const emptyItem = { name: '', displayName: '' }
|
||||
emptyItem[confLabel] = ''
|
||||
emptyItem[confValue] = ''
|
||||
//设置valueText、displayName
|
||||
for (const item of data) {
|
||||
if (item[confValue] == field.value) {
|
||||
changeFlag = true
|
||||
field.valueText = item[confLabel]
|
||||
}
|
||||
}
|
||||
// data.unshift(emptyItem) //添加空数据
|
||||
field.options = data
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
if (changeFlag) {
|
||||
// 重新序列化以触发响应式更新(保留函数)
|
||||
formFields.value = JSON.parse(JSON.stringify(formFieldsVal, replacer), reviver)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 选择器组件确认事件
|
||||
* event: 事件默认参数
|
||||
* field: 当前字段
|
||||
* 处理逻辑:
|
||||
* field.value = 选中的值
|
||||
* field.valueText = 选中的文本
|
||||
* todo: 关联字段在动态字段的change事件处理
|
||||
* */
|
||||
function pickerConfirm(event, field) {
|
||||
if (field.type == 'date') {
|
||||
field.value = nx.$dayjs(event.value).format(field.format)
|
||||
field.showPicker = false
|
||||
return
|
||||
}
|
||||
const confLabel = field.props.label
|
||||
const confValue = field.props.value
|
||||
const selected = event.value[0]
|
||||
const value = selected[confValue]
|
||||
const displayName = selected[confLabel]
|
||||
field.value = value
|
||||
field.valueText = displayName
|
||||
if (typeof field.change == 'function') {
|
||||
field.change({ value }, selected, { formFields: formFields.value })
|
||||
}
|
||||
field.showPicker = false
|
||||
}
|
||||
|
||||
// 检查是否需要加载硫值(原逻辑保留)
|
||||
function checkLoadSValue() {
|
||||
const vKey = 'sRange'
|
||||
const vF = getFieldByKey(vKey)
|
||||
if (vF == null) return false
|
||||
const v = vF.value
|
||||
if (v == null || v == '') return true
|
||||
try {
|
||||
if (v == 0 || Number(v) == 0) return true
|
||||
} catch (e) {}
|
||||
return false
|
||||
}
|
||||
|
||||
// 读取硫值、硫量(原逻辑保留,未启用)
|
||||
// function loadSValue(detail) {
|
||||
// let flag = checkLoadSValue()
|
||||
// if (!flag) return
|
||||
// const vKey = 'sValue'
|
||||
// const rKey = 'sRange'
|
||||
// const vF = getFieldByKey(vKey)
|
||||
// if (vF != null) {
|
||||
// vF.value = detail.svalue
|
||||
// }
|
||||
// const rF = getFieldByKey(rKey)
|
||||
// if (rF != null) {
|
||||
// rF.value = detail.srange
|
||||
// }
|
||||
// }
|
||||
|
||||
// 根据 key 获取字段(依赖 fieldGroup,但当前无 fieldGroup,保留原逻辑结构)
|
||||
function getFieldByKey(key) {
|
||||
// 注意:原代码中 this.fieldGroup 未定义,此处无法实现,保留函数结构
|
||||
// const group = this.fieldGroup
|
||||
// let field = null
|
||||
// for (let g of group) {
|
||||
// for (let f of g.fields) {
|
||||
// const dicKey = f.dicKey
|
||||
// if (dicKey && dicKey == key) {
|
||||
// field = f
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return field
|
||||
return null
|
||||
}
|
||||
|
||||
// ========== 工具函数(保留原位置) ==========
|
||||
|
||||
// 自定义 replacer,将函数转换为字符串。json序列化和反序列化时避免函数丢失
|
||||
function replacer(key, value) {
|
||||
if (typeof value === 'function') {
|
||||
@@ -571,6 +572,7 @@ function reviver(key, value) {
|
||||
return value
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.navbar-right {
|
||||
font-size: 16px;
|
||||
|
||||
Reference in New Issue
Block a user