You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
329 lines
7.5 KiB
329 lines
7.5 KiB
<template>
|
|
<view class="add">
|
|
<view class="add-bd">
|
|
<view class="item">
|
|
<view class="l">笼位类型:</view>
|
|
<view class="r">
|
|
<picker mode="selector" :range="cagetypeList" :value="cagetypeIndex" @change="bindDateChange" range-key="title">
|
|
{{cagetypeIndex >= 0?cagetypeList[cagetypeIndex].title:""}}
|
|
<image class="arrow" src="@/static/jiantouxia@2x.png"></image>
|
|
</picker>
|
|
</view>
|
|
</view>
|
|
<view class="item">
|
|
<view class="l">笼位号:</view>
|
|
<view class="r">
|
|
<input type="text" disabled v-model="num" />
|
|
</view>
|
|
</view>
|
|
<view class="item">
|
|
<view class="l">品系:</view>
|
|
<view class="r">
|
|
<picker mode="selector" :range="strainsList" :value="strainsIndex" @change="bindDateChange1" range-key="title">
|
|
{{strainsIndex >= 0?strainsList[strainsIndex].title:""}}
|
|
<image class="arrow" src="@/static/jiantouxia@2x.png"></image>
|
|
</picker>
|
|
</view>
|
|
</view>
|
|
<view class="item">
|
|
<view class="l">笼位颜色:</view>
|
|
<view class="r">
|
|
<view class="li" v-for="index in 6" :class="tabIndex == (index)?'li-'+(index):''"
|
|
@click="tabItem(index)"><view class="y"></view></view>
|
|
</view>
|
|
</view>
|
|
<view class="item">
|
|
<view class="l">实验室:</view>
|
|
<view class="r">
|
|
<picker mode="selector" :range="groupList" :value="groupIndex" @change="bindDateChange2" range-key="title">
|
|
{{groupIndex>= 0?groupList[groupIndex].title:""}}
|
|
<image class="arrow" src="@/static/jiantouxia@2x.png"></image>
|
|
</picker>
|
|
</view>
|
|
</view>
|
|
<view class="item">
|
|
<view class="l">负责人:</view>
|
|
<view class="r">
|
|
<picker mode="selector" :range="userList" :value="userIndex" @change="bindDateChange3" range-key="realname">
|
|
{{userIndex >= 0 ?userList[userIndex].realname:""}}
|
|
<image class="arrow" src="@/static/jiantouxia@2x.png"></image>
|
|
</picker>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="add-fd">
|
|
<view class="btn" @click="toCreate">完成并生成二维</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
tabIndex: 1,
|
|
cagetypeList: [],
|
|
cagetypeIndex: -1,
|
|
strainsList: [],
|
|
strainsIndex: -1,
|
|
groupList: [],
|
|
groupIndex: -1,
|
|
userList: [],
|
|
userIndex: -1,
|
|
info: {},
|
|
num: 0,
|
|
};
|
|
},
|
|
onLoad(o) {
|
|
this.get_api_cage_list();
|
|
this.get_api_cage_getUser();
|
|
this.get_api_basicinfo_group();
|
|
this.get_api_basicinfo_strains();
|
|
this.get_api_cage_getCagetype();
|
|
},
|
|
methods: {
|
|
bindDateChange(e){
|
|
this.cagetypeIndex = e.detail.value
|
|
this.info.type = Number(e.detail.value)+1
|
|
},
|
|
bindDateChange1(e){
|
|
this.strainsIndex = e.detail.value
|
|
this.info.strains = this.strainsList[e.detail.value].title
|
|
},
|
|
bindDateChange2(e){
|
|
this.groupIndex = e.detail.value
|
|
this.info.group = this.groupList[e.detail.value].title
|
|
},
|
|
bindDateChange3(e){
|
|
this.userIndex = e.detail.value
|
|
this.info.user_id = this.userList[e.detail.value].id
|
|
},
|
|
async toCreate() {
|
|
if(this.cagetypeIndex == -1){
|
|
uni.showToast({
|
|
title: "请选择笼位类型",
|
|
icon: "none"
|
|
})
|
|
return ;
|
|
}
|
|
if(this.strainsIndex == -1){
|
|
uni.showToast({
|
|
title: "请选择品系",
|
|
icon: "none"
|
|
})
|
|
return ;
|
|
}
|
|
if(this.groupIndex == -1){
|
|
uni.showToast({
|
|
title: "请选择实验室",
|
|
icon: "none"
|
|
})
|
|
return ;
|
|
}
|
|
if(this.userIndex == -1){
|
|
uni.showToast({
|
|
title: "请选择负责人",
|
|
icon: "none"
|
|
})
|
|
return ;
|
|
}
|
|
const { errorcode, message } = await this.$api.api_cage_add({
|
|
type: this.info.type,
|
|
user_id: this.info.user_id,
|
|
strains: this.info.strains,
|
|
color: this.info.color?this.info.color:'#8fc31f',
|
|
group: this.info.group,
|
|
uid: uni.getStorageSync("userInfo").uid,
|
|
})
|
|
if( errorcode == 200 ){
|
|
uni.showToast({
|
|
title: "添加成功"
|
|
})
|
|
setTimeout(()=>{
|
|
uni.switchTab({
|
|
url: "/pages/index/index"
|
|
})
|
|
},2000)
|
|
}else{
|
|
uni.showToast({
|
|
icon: "none",
|
|
title: message
|
|
})
|
|
}
|
|
},
|
|
tabItem(i){
|
|
this.tabIndex = i;
|
|
this.info.color = (i==1?'#8fc31f':i==2?'#ea5514':i==3?'#e4007f':i==4?'#00913a':i==5?'#c9a063':'#727171')
|
|
},
|
|
|
|
async get_api_cage_list() {
|
|
const { errorcode, data, message } = await this.$api.api_cage_list({
|
|
uid: uni.getStorageSync("userInfo").uid,
|
|
order: "",
|
|
keyword: "",
|
|
page: 1
|
|
})
|
|
if(errorcode == 200){
|
|
this.num = data.count+1;
|
|
}
|
|
},
|
|
async get_api_cage_getCagetype() {
|
|
const { errorcode, data } = await this.$api.api_cage_getCagetype({});
|
|
if(errorcode == 200){
|
|
this.cagetypeList = data;
|
|
}
|
|
},
|
|
async get_api_basicinfo_strains() {
|
|
const { errorcode, data } = await this.$api.api_basicinfo_strains({});
|
|
if(errorcode == 200){
|
|
this.strainsList = data;
|
|
}
|
|
},
|
|
async get_api_basicinfo_group() {
|
|
const { errorcode, data } = await this.$api.api_basicinfo_group({});
|
|
if(errorcode == 200){
|
|
this.groupList = data;
|
|
}
|
|
},
|
|
async get_api_cage_getUser() {
|
|
const { errorcode, data } = await this.$api.api_cage_getUser({uid: uni.getStorageSync("userInfo").uid});
|
|
if(errorcode == 200){
|
|
this.userList = data;
|
|
}
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.add{
|
|
padding-bottom: calc(env(safe-area-inset-bottom)+140rpx);
|
|
overflow: hidden;
|
|
&-bd{
|
|
padding: 0 35rpx;
|
|
overflow: hidden;
|
|
.item{
|
|
width: 100%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 40rpx 0;
|
|
border-bottom: 1px solid #c0c2c2;
|
|
.l{
|
|
width: 150rpx;
|
|
font-size: 28rpx;
|
|
color: #000;
|
|
}
|
|
.r{
|
|
flex: 1;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: flex-end;
|
|
.li{
|
|
width: 60rpx;
|
|
height: 60rpx;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin: 0 12rpx;
|
|
.y{
|
|
width: 50rpx;
|
|
height: 50rpx;
|
|
border-radius: 50%;
|
|
}
|
|
&:nth-child(1){
|
|
.y{
|
|
background-color: #8fc31f;
|
|
}
|
|
}
|
|
&:nth-child(2){
|
|
.y{
|
|
background-color: #ea5514;
|
|
}
|
|
}
|
|
&:nth-child(3){
|
|
.y{
|
|
background-color: #e4007f;
|
|
}
|
|
}
|
|
&:nth-child(4){
|
|
.y{
|
|
background-color: #00913a;
|
|
}
|
|
}
|
|
&:nth-child(5){
|
|
.y{
|
|
background-color: #c9a063;
|
|
}
|
|
}
|
|
&:nth-child(6){
|
|
.y{
|
|
background-color: #727171;
|
|
}
|
|
}
|
|
&-1{
|
|
border: 1px solid #8fc31f;
|
|
}
|
|
&-2{
|
|
border: 1px solid #ea5514;
|
|
}
|
|
&-3{
|
|
border: 1px solid #e4007f;
|
|
}
|
|
&-4{
|
|
border: 1px solid #00913a;
|
|
}
|
|
&-5{
|
|
border: 1px solid #c9a063;
|
|
}
|
|
&-6{
|
|
border: 1px solid #727171;
|
|
}
|
|
}
|
|
input,picker{
|
|
flex: 1;
|
|
font-size: 28rpx;
|
|
color: #000;
|
|
height: 50rpx;
|
|
line-height: 50rpx;
|
|
text-align: right;
|
|
}
|
|
.arrow{
|
|
width: 32rpx;
|
|
height: 19rpx;
|
|
margin-left: 20rpx;
|
|
vertical-align: middle;
|
|
}
|
|
|
|
.date{
|
|
width: 45rpx;
|
|
height: 45rpx;
|
|
margin-left: 20rpx;
|
|
vertical-align: middle;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
&-fd{
|
|
width: 100%;
|
|
padding: 20rpx 35rpx;
|
|
box-sizing: border-box;
|
|
background-color: #f3f5f6;
|
|
position: fixed;
|
|
left: 0;
|
|
bottom: 0;
|
|
z-index: 22;
|
|
padding-bottom: calc(env(safe-area-inset-bottom));
|
|
.btn{
|
|
width: 100%;
|
|
line-height: 90rpx;
|
|
text-align: center;
|
|
background-color: #009944;
|
|
font-size: 32rpx;
|
|
color: #ffffff;
|
|
border-radius: 10rpx;
|
|
}
|
|
}
|
|
}
|
|
</style>
|
|
|