392 lines
9.8 KiB
Vue
392 lines
9.8 KiB
Vue
<template>
|
|
<view class="content">
|
|
<view class="card-d">
|
|
<u--form labelWidth='130' :model="formData" :rules="rules" ref="form">
|
|
|
|
<view class="c-title">转栏信息</view>
|
|
<view class="c-box">
|
|
<u-form-item label="耳号" prop="animal_sn" borderBottom required>
|
|
<up-input input-align="right" placeholder="请输入耳号" :disabled="mode=='detail'" border="none"
|
|
v-model="formData.animal_sn"></up-input>
|
|
</u-form-item>
|
|
<up-form-item label="转出栏舍" prop="old_fence_house_id" borderBottom required @click="showFun=true">
|
|
<up-input input-align="right" placeholder="请选择转出栏舍" border="none" suffixIcon="arrow-down"
|
|
suffix-icon-style="color: #b6b6b6;" v-model="old_fence_house_id" readonly></up-input>
|
|
</up-form-item>
|
|
<up-form-item label="转入栏舍" prop="new_fence_house_id" borderBottom required @click="showPart=true">
|
|
<up-input input-align="right" placeholder="请选择转入栏舍" border="none" suffixIcon="arrow-down"
|
|
suffix-icon-style="color: #b6b6b6;" v-model="new_fence_house_id" readonly></up-input>
|
|
</up-form-item>
|
|
<!-- <u-form-item label="操作人员" prop="start_date" borderBottom required>
|
|
<up-input input-align="right" placeholder="请输入操作人员姓名" :disabled="mode=='detail'" border="none"
|
|
v-model="formData.breed"></up-input>
|
|
</u-form-item>
|
|
<u-form-item label="转舍时间" prop="start_date" @click="openDate" borderBottom required>
|
|
<up-input input-align="right" placeholder="请选择时间" suffixIcon="arrow-down"
|
|
suffix-icon-style="color: #b6b6b6;" readonly border="none" v-model="formData.start_date"
|
|
style="pointer-events: none;"></up-input>
|
|
</u-form-item> -->
|
|
</view>
|
|
|
|
<view class="c-title">备注信息</view>
|
|
<view class="c-box" style="padding: 0 20rpx;">
|
|
<u-form-item prop="remark" borderBottom>
|
|
<u--textarea v-model="formData.remark" :disabled="mode=='detail'" placeholder="请输入内容"></u--textarea>
|
|
</u-form-item>
|
|
</view>
|
|
|
|
</u--form>
|
|
<u-button class="btn" v-if="mode=='add'" @click="addFn">完成添加</u-button>
|
|
</view>
|
|
<u-action-sheet :show="showFun" keyName="name" closeOnClickOverlay :actions="house_list" title="请选择转出栏舍"
|
|
@close="showFun = false" @select="selectFun"></u-action-sheet>
|
|
<u-action-sheet :show="showPart" keyName="name" closeOnClickOverlay :actions="house_list" title="请选择转入栏舍"
|
|
@close="showPart = false" @select="selectPart"></u-action-sheet>
|
|
<u-datetime-picker :show="show1" :max-date="getNowTime()" v-model="value1" mode="datetime" @confirm="dateConfirmfn"
|
|
:formatter="formatter" @cancel="show1=false"></u-datetime-picker>
|
|
</view>
|
|
|
|
</template>
|
|
|
|
<script setup>
|
|
import {
|
|
Uploads
|
|
} from "@/api/upload.js"
|
|
import {
|
|
reactive,
|
|
ref
|
|
} from "vue";
|
|
import {
|
|
onLoad,
|
|
onReady
|
|
} from "@dcloudio/uni-app"
|
|
import {
|
|
addaction
|
|
} from '@/api/api.js'
|
|
import {
|
|
fenceHouseExchange,
|
|
fenceHouseList
|
|
} from "@/api/manage.js"
|
|
|
|
const form = ref(null)
|
|
const task_id = ref('');
|
|
const pic = reactive([]);
|
|
const show1 = ref(false)
|
|
const formData = reactive({
|
|
animal_sn: "",
|
|
old_fence_house_id: "",
|
|
new_fence_house_id: "",
|
|
remark: "",
|
|
})
|
|
const dateConfirmfn = (e) => {
|
|
formData.start_date = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM ')
|
|
show1.value = false
|
|
}
|
|
const formatter = (type, value) => {
|
|
if (type === 'year') {
|
|
return `${value}年`;
|
|
}
|
|
if (type === 'month') {
|
|
return `${value}月`;
|
|
}
|
|
if (type === 'day') {
|
|
return `${value}日`;
|
|
}
|
|
return value;
|
|
};
|
|
const rules = {
|
|
'user': {
|
|
type: 'string',
|
|
required: true,
|
|
message: '请填写参与人',
|
|
trigger: ['blur', 'change']
|
|
},
|
|
// 'remark': {
|
|
// type: 'string',
|
|
// required: true,
|
|
// message: '请填写备注',
|
|
// trigger: ['blur', 'change']
|
|
// },
|
|
}
|
|
|
|
const showFun = ref(false);
|
|
const old_fence_house_id = ref('');
|
|
const selectFun = (e)=>{
|
|
old_fence_house_id.value = e.name;
|
|
formData.old_fence_house_id = e.id;
|
|
if(formData.old_fence_house_id==formData.new_fence_house_id && formData.new_fence_house_id){
|
|
uni.showToast({
|
|
title: '转出栏舍不可与转入栏舍一致',
|
|
icon: 'none'
|
|
})
|
|
new_fence_house_id.value = '';
|
|
formData.new_fence_house_id = '';
|
|
}
|
|
}
|
|
const showPart = ref(false);
|
|
const new_fence_house_id = ref('');
|
|
const selectPart = (e)=>{
|
|
new_fence_house_id.value = e.name;
|
|
formData.new_fence_house_id = e.id;
|
|
if(formData.old_fence_house_id==formData.new_fence_house_id && formData.old_fence_house_id){
|
|
uni.showToast({
|
|
title: '转出栏舍不可与转入栏舍一致',
|
|
icon: 'none'
|
|
})
|
|
old_fence_house_id.value = '';
|
|
formData.old_fence_house_id = '';
|
|
}
|
|
}
|
|
|
|
const house_list = ref([]);
|
|
const initFenceHouseList = ()=>{
|
|
fenceHouseList({
|
|
page_no:1,
|
|
page_size: 1000
|
|
}).then(res=>{
|
|
res.data.lists = res.data.lists.map(item=>{
|
|
return {
|
|
id: item.id,
|
|
name: item.fence_house_name
|
|
}
|
|
})
|
|
house_list.value = res.data.lists||[];
|
|
// console.log(house_list.value);
|
|
})
|
|
}
|
|
initFenceHouseList();
|
|
|
|
onReady(() => {
|
|
form.value.setRules(rules);
|
|
});
|
|
const navgo = (url) => {
|
|
uni.navigateTo({
|
|
url
|
|
})
|
|
}
|
|
const openDate = () => {
|
|
// calendar.value.open()
|
|
show1.value = true
|
|
// alert(455)
|
|
}
|
|
const value1 = ref(Date.now());
|
|
const getNowTime = () => {
|
|
const now = new Date();
|
|
|
|
|
|
const timestamp = now.getTime();
|
|
// console.log(timestamp)
|
|
return timestamp
|
|
|
|
}
|
|
const addFn = () => {
|
|
form.value.validate().then(res => {
|
|
console.log(res)
|
|
if (res) {
|
|
// 表单验证通过,执行提交操作
|
|
fenceHouseExchange(formData).then((res) => {
|
|
console.log(res)
|
|
if (res.code == 1) {
|
|
uni.$u.toast(res.msg)
|
|
uni.navigateBack({
|
|
delta: 1
|
|
})
|
|
}
|
|
})
|
|
// uni.$u.toast('校验成功')
|
|
}
|
|
|
|
}).catch((err) => {
|
|
uni.$u.toast(err[0].message)
|
|
console.log(err)
|
|
})
|
|
}
|
|
//查看图片
|
|
const perviewFn = (url) => {
|
|
uni.previewImage({
|
|
urls: [url]
|
|
})
|
|
}
|
|
//图片删除
|
|
const delimg = (i) => {
|
|
pic.splice(i, 1);
|
|
}
|
|
//图片上传
|
|
const updateImgFn = async () => {
|
|
|
|
uni.chooseImage({
|
|
count: 1,
|
|
sizeType: ['original', 'compressed'],
|
|
sourceType: ['album', 'camera'],
|
|
success: (res) => {
|
|
Uploads(res.tempFilePaths[0], 'img').then(res => {
|
|
console.log(res)
|
|
if (res.code == 1) {
|
|
pic.push(res.data.url)
|
|
console.log(data.formData)
|
|
|
|
uni.$u.toast('上传成功')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}).catch(err => {
|
|
//console.log('err', err);
|
|
// uni.$u.toast('上传失败')
|
|
})
|
|
},
|
|
fail: function(err) {
|
|
//console.log('choose失败');
|
|
uni.$u.toast('添加失败')
|
|
}
|
|
});
|
|
// let res = await Uploads()
|
|
// data.formData.pic = res.data.image
|
|
}
|
|
const mode = ref('add')
|
|
onLoad((options) => {
|
|
|
|
|
|
|
|
})
|
|
</script>
|
|
|
|
<style lang='scss' scoped>
|
|
page {
|
|
background-color: #fffcf5;
|
|
}
|
|
|
|
.card-d {
|
|
background-color: #fffcf5;
|
|
padding: 0;
|
|
padding-bottom: 80rpx;
|
|
|
|
.c-title {
|
|
font-weight: bold;
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 30rpx;
|
|
padding-bottom: 15rpx;
|
|
|
|
&:before {
|
|
content: '';
|
|
display: inline-block;
|
|
height: 0.8rem;
|
|
width: 6rpx;
|
|
margin-top: 0.2rem;
|
|
margin-right: 10rpx;
|
|
background-color: #feb048;
|
|
border-radius: 6rpx;
|
|
}
|
|
}
|
|
|
|
.c-box {
|
|
background-color: #fff;
|
|
padding-left: 30rpx;
|
|
padding-right: 20rpx;
|
|
padding-bottom: 20rpx;
|
|
box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.c-box-p {
|
|
padding: 20rpx;
|
|
}
|
|
|
|
.btn {
|
|
margin: 20rpx auto;
|
|
width: 694rpx;
|
|
height: 80rpx;
|
|
border-radius: 80rpx;
|
|
background-color: #feb048;
|
|
color: #fff;
|
|
}
|
|
}
|
|
|
|
.tit {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.card-li {
|
|
position: relative;
|
|
margin-bottom: 0;
|
|
|
|
span {
|
|
position: absolute;
|
|
left: -9px;
|
|
color: #f56c6c;
|
|
line-height: 20px;
|
|
font-size: 20px;
|
|
top: 3px;
|
|
}
|
|
|
|
}
|
|
|
|
.confim-btn {
|
|
margin: 0 auto;
|
|
width: 196.26rpx;
|
|
height: 66.59rpx;
|
|
/* border: ; */
|
|
border: #00A15E 1px solid;
|
|
color: #00A15E;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
|
|
}
|
|
|
|
.up-img {
|
|
width: 341.71rpx
|
|
}
|
|
|
|
.today-btn {
|
|
width: 588.79rpx;
|
|
background-color: #00A15E;
|
|
color: white;
|
|
position: fixed;
|
|
bottom: 40rpx;
|
|
/* transform: ; */
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
background: linear-gradient(to right, #00A15E, #4CC593);
|
|
/* margin: 0 auto; */
|
|
}
|
|
|
|
.code-img {
|
|
background-color: #F4F4F4;
|
|
height: 350.47rpx;
|
|
position: relative;
|
|
/* margin-bottom: 100rpx; */
|
|
|
|
.carime-icon {
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
}
|
|
|
|
}
|
|
|
|
.confirm {
|
|
position: fixed;
|
|
height: 84.11rpx;
|
|
display: flex;
|
|
bottom: 30rpx;
|
|
width: 750rpx;
|
|
|
|
.confirm-btn {
|
|
width: 315.42rpx;
|
|
height: 84.11rpx;
|
|
border: #00A15E 1px solid;
|
|
margin: 0 auto;
|
|
border-radius: 80rpx;
|
|
text-align: center;
|
|
line-height: 84rpx;
|
|
}
|
|
}
|
|
</style> |