关联大棚
parent
077ee218b5
commit
b88ebaeeee
|
|
@ -49,3 +49,16 @@ export function delAgri(id) {
|
|||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动端添加大棚
|
||||
* @param data
|
||||
* @returns {*}
|
||||
*/
|
||||
export function addAgriMobile(data) {
|
||||
return request({
|
||||
url: '/assets/agri/addAgriFromMobile',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
|
@ -4,18 +4,19 @@
|
|||
<!-- 新增:修改运行时间的弹窗 -->
|
||||
<view class="modal-container">
|
||||
<view class="modal-title">{{ `添加大棚` }}</view>
|
||||
<view class="modal-input-wrap" >
|
||||
<text class="modal-label">大棚名称:</text>
|
||||
<uni-easyinput style="width: 100px" v-model="agriName" placeholder="请输入大棚名称" />
|
||||
</view>
|
||||
<view class="modal-input-wrap" >
|
||||
<text class="modal-label">设备imei:</text>
|
||||
<uni-easyinput style="width: 100px" v-model="imei" placeholder="请输入大棚名称" >
|
||||
<uni-forms ref="form" :model="formData" :rules="rules" label-width="180rpx" validateTrigger="blur">
|
||||
<uni-forms-item label="大棚名称:" name="agriName" required>
|
||||
<uni-easyinput type="text" v-model="formData.agriName" placeholder="请输入大棚名称" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item label="设备imei:" name="imei" required>
|
||||
<uni-easyinput v-model="formData.imei" placeholder="在此输入设备imei号" >
|
||||
<template #right>
|
||||
<yt-scanCode @getScanCode="getScanCode"></yt-scanCode>
|
||||
</template>
|
||||
</uni-easyinput>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</uni-forms>
|
||||
|
||||
<view class="modal-input-wrap" >
|
||||
<text class="modal-label"></text>
|
||||
<uni-icons type="info" size="15" color="#666"/>
|
||||
|
|
@ -33,19 +34,51 @@
|
|||
</template>
|
||||
<script>
|
||||
import UniPopup from "../../uni_modules/uni-popup/components/uni-popup/uni-popup.vue";
|
||||
import {addAgriMobile} from "../../api/system/assets/agri";
|
||||
|
||||
export default {
|
||||
name: "addAgri",
|
||||
components: {UniPopup},
|
||||
data() {
|
||||
return {
|
||||
agriName: null,
|
||||
imei:null,
|
||||
formData: {
|
||||
name:null,
|
||||
email:null
|
||||
agriName: null,
|
||||
imei: null,
|
||||
sourceCode:0
|
||||
},
|
||||
rules:[]
|
||||
rules: {
|
||||
agriName: {
|
||||
rules:[
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请输入温室名称!',
|
||||
}
|
||||
]
|
||||
},
|
||||
// 对name字段进行必填验证
|
||||
imei: {
|
||||
// name 字段的校验规则
|
||||
rules:[
|
||||
// 校验 name 不能为空
|
||||
{
|
||||
required: true,
|
||||
errorMessage: '请输入设备imei!',
|
||||
},
|
||||
// 对name字段进行长度验证
|
||||
{
|
||||
minLength: 15,
|
||||
maxLength: 15,
|
||||
errorMessage: '{label}不合法!需为 {maxLength} 位!',
|
||||
},
|
||||
{
|
||||
pattern: /^\d{15}$/, // 核心正则
|
||||
errorMessage: '请输入15位纯数字编号'
|
||||
}
|
||||
],
|
||||
// 当前表单域的字段中文名,可不填写
|
||||
label:'设备imei'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
|
|
@ -53,8 +86,23 @@ export default {
|
|||
this.$refs.addForm.close();
|
||||
},
|
||||
confirm() {
|
||||
|
||||
this.close()
|
||||
this.$refs.form.validate().then(res => {
|
||||
if (!res) {
|
||||
addAgriMobile(this.formData).then((response) => {
|
||||
if (response.code===200) {
|
||||
uni.showModal({
|
||||
title: `${response.data.code===1?"✅":"⚠️"}操作提示`,
|
||||
content: `${response.data.msg}`,
|
||||
showCancal: false,
|
||||
confirmText: '确定',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
this.close();
|
||||
}).catch(err => {
|
||||
console.log('表单错误信息:', err);
|
||||
})
|
||||
},
|
||||
open() {
|
||||
this.$refs.addForm.open();
|
||||
|
|
@ -65,7 +113,7 @@ export default {
|
|||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
<style scoped >
|
||||
|
||||
/* 新增:弹窗样式 */
|
||||
.modal-container {
|
||||
|
|
@ -95,22 +143,7 @@ export default {
|
|||
width: 140rpx;
|
||||
color: #666;
|
||||
}
|
||||
.modal-current {
|
||||
margin-left: 14rpx;
|
||||
color: #333;
|
||||
}
|
||||
.modal-input {
|
||||
height: 60rpx;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 8rpx;
|
||||
padding: 0 15rpx;
|
||||
font-size: 20rpx !important;
|
||||
width: 80rpx;
|
||||
}
|
||||
.modal-unit {
|
||||
margin-left: 10rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.modal-btn-wrap {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
|
|
@ -135,4 +168,13 @@ export default {
|
|||
color: #6C6C6C;
|
||||
margin-left: 6rpx;
|
||||
}
|
||||
/deep/ .uni-forms-item__label {
|
||||
padding: 0!important;
|
||||
margin-left: 20rpx;
|
||||
width: 154rpx!important;
|
||||
}
|
||||
|
||||
/deep/ .uni-forms-item:nth-child(2) {
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -13,7 +13,8 @@
|
|||
<uni-col :span="17">
|
||||
<!-- confirm:confirm; input:change; cancel:点击取消;
|
||||
clear:点击清除;focus:获取焦点;blur:失去焦点 -->
|
||||
<uni-search-bar :focus="true" bgColor="#fbfdfe"
|
||||
<uni-search-bar :focus="true"
|
||||
bgColor="#fbfdfe"
|
||||
v-model="searchValue"
|
||||
cancelButton="always"
|
||||
@input="input"
|
||||
|
|
@ -60,7 +61,8 @@
|
|||
<text>加载中...</text>
|
||||
</view>
|
||||
<view v-else-if="noMore" class="no-more">没有更多数据了</view>
|
||||
<view class="add-agri" @tap="handleAddAgri">
|
||||
<!-- v-if="store.getters.name !== 'admin'"-->
|
||||
<view class="add-agri" @tap="handleAddAgri" >
|
||||
<image :src="imageSrc" :style="'width:'+80+'rpx;height:'+80+'rpx'"></image>
|
||||
<text class="text">点击添加大棚</text>
|
||||
</view>
|
||||
|
|
@ -84,6 +86,11 @@ import {getNewSpecialData} from "../api/data/specialData";
|
|||
import AddAgri from "./home/addAgri.vue";
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
store() {
|
||||
return store
|
||||
}
|
||||
},
|
||||
components: {AddAgri, CustomRefresher, ZPaging},
|
||||
data() {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,19 @@ export default {
|
|||
icon: 'success'
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 自定义提示窗
|
||||
* @param content
|
||||
* @param tag
|
||||
*/
|
||||
customMsg(content,tag) {
|
||||
uni.showToast({
|
||||
title: content,
|
||||
icon: tag,
|
||||
duration: 3000
|
||||
})
|
||||
},
|
||||
|
||||
// 隐藏消息
|
||||
hideMsg(content) {
|
||||
uni.hideToast()
|
||||
|
|
|
|||
Loading…
Reference in New Issue