wechat
lgyg 2023-09-09 23:07:16 +08:00
parent 169e2016ea
commit 949fd62f6b
7 changed files with 1178 additions and 53 deletions

View File

@ -29,6 +29,9 @@
.mt24{
margin-top: 24rpx;
}
.mt12{
margin-top: 12rpx;
}
.mt20{
margin-top: 20rpx;
}
@ -163,7 +166,9 @@
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
}
.status_bar_top {
padding-top: var(--status-bar-height);
}
.input-placeholder,.textarea-placeholder{
color: #c3c3c3;
}
@ -178,9 +183,7 @@
background: url('./static/img/my_arrow_right.png') no-repeat center;
background-size: 100%;
}
.uni-input-input:disabled{
background-color: #f8f8f8;
}
.bg_colorf8{
background-color: #f8f8f8;
}
@ -493,6 +496,7 @@
.buttom_section{
display: flex;
padding: 30rpx;
justify-content: space-around;
.btn{
width: 240rpx;
}
@ -543,6 +547,88 @@
padding: 20rpx;
}
}
.search-box{
background-color: #fff;
padding: 20rpx;
.search-input-vh{
padding: 12rpx 20rpx;
border-radius: 30rpx;
font-size: 28rpx;
&::after{
border-radius: 30rpx;
border-color: #ddd;
}
.placeholder_text{
color: #c3c3c3;
}
}
}
.popup-screen-groups{
padding-top: 46px;
background-color: #fff;
height: 100%;
display: flex;
flex-direction: column;
.row_ul{
padding-top: 30rpx;
}
.row_list{
padding: 0 20rpx;
margin-bottom: 16rpx;
.label_tit{
width: 120rpx;
text-align: right;
margin-right: 20rpx;
&.small{
width: 90rpx;
}
}
}
.scroll-y{
flex: 1;
flex-shrink: 0;
min-height: 1px;
}
.buttom_section{
display: flex;
justify-content: space-around;
padding: 30rpx 24rpx;
.btn{
width: 220rpx;
&.small_btn{
width: 300rpx;
height: 64rpx;
}
}
}
}
.scrollY{
width: 100%;
height: 100%;
}
.u-select-input-list{
position: relative;
flex: 1;
display: flex;
flex-direction: row;
border-radius: 8rpx;
min-height: 72rpx;
border: 1px solid #dcdfe6;
padding: 0 20rpx;
.select_wrapper{
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
font-size: 28rpx;
color: #000;
}
.right-icon{
.u-icon__icon{
margin-left: 10rpx;
color: rgb(192, 196, 204);
}
}
}
</style>

View File

@ -0,0 +1,82 @@
<template>
<view class="yn-select-list">
<view class="u-select-input-list" @click="clickFn">
<view class="select_wrapper">
<view class="placeholder u-line-2" v-if="value==''">{{placeholder}}</view>
<view class="input_value" v-else>{{value}}</view>
</view>
<view class="right-icon u-flex">
<u-icon :name="rightIcon" size="28"></u-icon>
</view>
</view>
</view>
</template>
<script>
export default {
name:"yn-select-input-list",
props: {
value: {
type: String|Number,
default: ''
},
rightIcon:{
type: String,
default: 'arrow-down-fill'
},
placeholder:{
type: String,
default: '请选择内容'
}
},
data() {
return {
};
},
created() {
},
methods:{
selectShowFn(){
this.show = true;
},
clickFn(e){
this.$emit('click',e)
}
}
}
</script>
<style lang="scss" scoped>
.yn-select-list{
display: flex;
flex-direction: column;
flex: 1;
}
.u-select-input-list{
position: relative;
flex: 1;
display: flex;
flex-direction: row;
border-radius: 8rpx;
min-height: 72rpx;
border: 1px solid #dcdfe6;
padding: 0 20rpx;
.select_wrapper{
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
font-size: 28rpx;
color: #000;
}
.right-icon{
.u-icon__icon{
margin-left: 10rpx;
color: rgb(192, 196, 204);
}
}
}
</style>

View File

@ -6,7 +6,8 @@ Vue.use(uView);
import {http,getFullUrl} from '@/api/index.js'
import store from './store/index.js'
Vue.config.productionTip = false
import ynSelectInputList from "@/components/yn-select-input-list/yn-select-input-list.vue"
Vue.component('ynSelectInputList', ynSelectInputList)
Vue.prototype.$http = http
Vue.prototype.$getFullUrl = getFullUrl
App.mpType = 'app'

View File

@ -129,6 +129,16 @@
}
}
,{
"path" : "pages/estate/estate-price",
"style" :
{
"navigationBarTitleText": "稻虾价格",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}
],
"globalStyle": {
"navigationBarTextStyle": "white",

View File

@ -6,12 +6,17 @@
<view class="custom_btn add_btn" @click="addBtn()"></view>
</view>
</u-navbar>
<view class="secreen-section">
<view class="search-box">
<view class="search-input-vh u-border" @click="screenShowFn()">
<view class="placeholder_text">筛选条件</view>
</view>
</view>
</view>
<view class="content-box">
<u-swipe-action class="tb_swipe_list"
v-for="(item, index) in list"
:show="item.show" :index="index" :key="item.id"
:show="item.show" :index="index" :key="index"
@click="click"
@open="open"
:options="options"
@ -32,7 +37,9 @@
<view class="text">监控点{{ item.monitoring_point }}</view>
</view>
<view class="row_box">
<view class="text">状态{{item.status}}</view>
<view class="text">状态<u-tag :text="statusName[item.status]" size="mini"
:type="statusType[item.status]"/></view>
</view>
</view>
</u-swipe-action>
@ -43,8 +50,8 @@
mode="center" :closeable="true" :mask-close-able="false" z-index="910">
<view class="popup-form-ubox">
<view class="top_box">
<view class="title" v-if="setInfo.id"></view>
<view class="title" v-else></view>
<view class="title" v-if="setInfo.id"></view>
<view class="title" v-else></view>
</view>
<scroll-view class="scroll-y" scroll-y="true">
<view class="form_edit" style="padding-left: 50rpx;">
@ -56,7 +63,14 @@
</u-form-item>
<u-form-item label="设备类型" label-width="140" :required='true'>
<view class="input_box">
<u-input v-model="setInfo.type" />
<view class="u-select-list" @click="selectFn1()">
<view class="value u-line-2"
v-if="setInfo.type">{{setInfo.type_name}}</view>
<view class="placeholder" v-else></view>
<view class="right">
<u-icon name="arrow-right" color="#999" size="28"></u-icon>
</view>
</view>
</view>
</u-form-item>
<u-form-item label="排序" label-width="140" :required='true'>
@ -66,7 +80,14 @@
</u-form-item>
<u-form-item label="基地" label-width="140" :required='true'>
<view class="input_box">
<u-input v-model="setInfo.base_name" />
<view class="u-select-list" @click="selectFn2()">
<view class="value u-line-2"
v-if="setInfo.base_name">{{setInfo.base_name}}</view>
<view class="placeholder" v-else></view>
<view class="right">
<u-icon name="arrow-right" color="#999" size="28"></u-icon>
</view>
</view>
</view>
</u-form-item>
<u-form-item label="设备编号" label-width="140" :required='true'>
@ -75,13 +96,28 @@
</view>
</u-form-item>
<u-form-item label="设备厂商" label-width="140" :required='true'>
<view class="input_box">
<u-input v-model="setInfo.supplier" type="number"/>
<view class="u-select-list" @click="selectFn3()">
<view class="value u-line-2"
v-if="setInfo.supplier_key">{{setInfo.supplier_name}}</view>
<view class="placeholder" v-else></view>
<view class="right">
<u-icon name="arrow-right" color="#999" size="28"></u-icon>
</view>
</view>
</view>
</u-form-item>
<u-form-item label="项目" label-width="140" :required='true'>
<u-form-item label="项目" label-width="140">
<view class="input_box">
<u-input v-model="setInfo.project" type="text"/>
<view class="u-select-list" @click="selectFn4()">
<view class="value u-line-2"
v-if="setInfo.project_key">{{setInfo.project_name}}</view>
<view class="placeholder" v-else></view>
<view class="right">
<u-icon name="arrow-right" color="#999" size="28"></u-icon>
</view>
</view>
</view>
</u-form-item>
<u-form-item label="监控点" label-width="140" :required='true'>
@ -89,6 +125,39 @@
<u-input v-model="setInfo.monitoring_point" type="text"/>
</view>
</u-form-item>
<!-- 监控设备字段 -->
<template v-if="setInfo.type==1">
<u-form-item label="设备IP" label-width="140" :required='true'>
<view class="input_box">
<u-input v-model="extendConf.ip" type="text"/>
</view>
</u-form-item>
<u-form-item label="设备端口" label-width="140" :required='true'>
<view class="input_box">
<u-input v-model="extendConf.port" type="text"/>
</view>
</u-form-item>
<u-form-item label="RTSP地址" label-width="140" :required='true'>
<view class="input_box">
<u-input v-model="extendConf.rtsp_url" type="text"/>
</view>
</u-form-item>
<u-form-item label="设备登录名" label-width="160" :required='true'>
<view class="input_box">
<u-input v-model="extendConf.username" type="text"/>
</view>
</u-form-item>
<u-form-item label="设备登录密码" label-width="180" :required='true'>
<view class="input_box">
<u-input v-model="extendConf.password" type="password"/>
</view>
</u-form-item>
<u-form-item label="设备播放通道" label-width="180" :required='true'>
<view class="input_box">
<u-input v-model="extendConf.passage" type="text"/>
</view>
</u-form-item>
</template>
</u-form>
</view>
@ -131,29 +200,94 @@
</view>
<view class="plist u-border-bottom">
<view class="label_t">设备厂商</view>
<view class="flex-1">{{formInfo.supplier}}</view>
<view class="flex-1">{{formInfo.supplier?formInfo.supplier.name:'-'}}</view>
</view>
<view class="plist u-border-bottom">
<view class="label_t">设备项目</view>
<view class="flex-1">{{formInfo.project}}</view>
<view class="flex-1">{{formInfo.project?formInfo.project.name:'-'}}</view>
</view>
<view class="plist u-border-bottom">
<view class="label_t">状态</view>
<view class="flex-1">{{formInfo.status}}</view>
<view class="flex-1">
<u-tag :text="statusName[formInfo.status]" size="mini"
:type="statusType[formInfo.status]"/>
</view>
</view>
</view>
</view>
</u-popup>
<u-select v-model="selectShow" :list="supplierlist"
:default-value="select1Value" mode="single-column"
@confirm="uselectConfirm"></u-select>
<u-select v-model="selectShow1" :list="deviceTypes"
:default-value="selectValue1" mode="single-column"
@confirm="uselectConfirm1"></u-select>
<u-select v-model="selectShow2" :list="basicList"
:default-value="selectValue2" mode="single-column"
@confirm="uselectConfirm2"></u-select>
<u-select v-model="selectShow3" :list="supplierlist"
:default-value="selectValue3" mode="single-column"
@confirm="uselectConfirm3"></u-select>
<u-select v-model="selectShow4" :list="projectlist"
:default-value="selectValue4" mode="single-column"
@confirm="uselectConfirm4"></u-select>
<u-select v-model="selectShow5" :list="statuslist"
:default-value="selectValue5" mode="single-column"
@confirm="uselectConfirm5"></u-select>
<!-- 筛选查询条件 -->
<u-popup v-model="screenShow" mode="top" z-index="9">
<view class="popup-screen-groups">
<view class="status_bar_top"></view>
<scroll-view class="scroll-y" scroll-y="true">
<view class="row_ul u-padding-right-20">
<view class="row_list u-flex">
<view class="label_tit">基地</view>
<yn-select-input-list :value="queryCond.base_name"
@click="selectFn2('q')"></yn-select-input-list>
</view>
<view class="row_list u-flex">
<view class="label_tit">类型</view>
<yn-select-input-list :value="queryCond.type_name"
@click="selectFn1('q')"></yn-select-input-list>
</view>
<view class="row_list u-flex">
<view class="label_tit">状态</view>
<yn-select-input-list :value="queryCond.status_name"
@click="selectFn5('q')"></yn-select-input-list>
</view>
<view class="row_list u-flex">
<view class="label_tit">监控点</view>
<u-input type="text" :border="true" />
</view>
<view class="row_list u-flex">
<view class="label_tit">设备编号</view>
<u-input type="text" :border="true" />
</view>
<view class="row_list u-flex">
<view class="label_tit">设备厂商</view>
<yn-select-input-list :value="queryCond.supplier_name"
@click="selectFn3('q')"></yn-select-input-list>
</view>
<view class="row_list u-flex">
<view class="label_tit">项目</view>
<yn-select-input-list :value="queryCond.project_name"
@click="selectFn4('q')"></yn-select-input-list>
</view>
</view>
</scroll-view>
<view class="buttom_section u-padding-top-40">
<u-button class="btn small_btn" type="default" @click="resetQuery()"></u-button>
<u-button class="btn small_btn" @click="queryBtn()" type="primary">查询</u-button>
</view>
</view>
</u-popup>
</view>
</template>
<script>
import {formatDate,navigateBack} from '@/com/utils.js'
import {navigateBack} from '@/com/utils.js'
export default {
data() {
return {
@ -186,11 +320,17 @@
setInfo:{
id:'',
type:'',
type_name:'',
sort:'',
base_name:'',
agricultural_base_id:'',//id
sn:'',
supplier:'',
supplier_key:'',//k
supplier_name:'',
project:'',
project_key:'',//k
project_name:'',
monitoring_point:'',
},
dropDownShow:false,
@ -214,22 +354,221 @@
],
selectShow:false,
select1Value:[],
// : 0 , 1 线, 2 线, 3
statusType:['error','success ','info','warning '],
statusName:['禁用','在线','离线','故障'],
statuslist:[
{
value: 0,
label: '禁用',
},
{
value: 1,
label: '在线',
},
{
value: 2,
label: '离线',
},
{
value: 3,
label: '故障',
},
],
deviceTypes:[],//
selectShow1:false,
basicList:[],
selectShow2:false,
selectShow3:false,//
selectShow4:false,//
selectShow5:false,
projectlist:[
{
value: 'device-project-cyxdnyyq',
label: '成渝现代高效特色农业带合作园区',
},
{
value: 'device-project-nyncj',
label: '隆昌市农业农村局',
},
{
value: 'device-project-syqshc',
label: '隆昌市石燕桥镇三合村股份经济联合社',
},
{
value: 'device-project-other',
label: '其它',
},
],
selectValue1:[0],
selectValue2:[0],
selectValue3:[0],
selectValue4:[0],
selectValue5:[0],
screenShow:false,
queryCond:{
base:'',
base_name:'',
type:'',
type_name:'',
status:'',
status_name:'',
point:'',
sn:'',
supplier_key:'',
supplier_name:'',
project_key:'',
project_name:''
},
isqueryselect:false,
//
extendConf:{
ip:'',
passage:'',//
password:'',
port:'',
rtsp_url:'',
username:'',//
}
};
},
filters:{
timeFormat(val){
return formatDate(val*1000, 'yyyy-MM-dd hh:mm');
},
},
onLoad() {
this.queryDataList();
this.getDeviceTypes();
this.getAgriculturalBasic();
},
methods: {
uselectConfirm(){
queryBtn(){
this.list = [];
this.queryDataList(true);
this.screenShow = false;
},
screenShowFn(){
this.screenShow = true;
},
selectFn1(type){
this.isqueryselect = false;
let type_name = this.setInfo.type_name;
if(type=='q'){
this.isqueryselect = true;
type_name = this.queryCond.type_name;
}
for(let [index,item] of this.deviceTypes.entries()){
if(type_name==item.label){
this.selectValue1 = [index];
this.setInfo.type = item.value;
break;
}
}
this.selectShow1 = true;
},
selectFn2(type){
this.isqueryselect = false;
let base_id = this.setInfo.agricultural_base_id;
if(type=='q'){
this.isqueryselect = true;
base_id = this.queryCond.base;
}
for(let [index,item] of this.basicList.entries()){
if(base_id==item.value){
this.selectValue = [index];
break;
}
}
this.selectShow2 = true;
},
selectFn3(type){
this.isqueryselect = false;
let supplier_key = this.setInfo.supplier_key;
if(type=='q'){
this.isqueryselect = true;
supplier_key = this.queryCond.supplier_key;
}
for(let [index,item] of this.supplierlist.entries()){
if(supplier_key==item.value){
this.selectValue3 = [index];
break;
}
}
this.selectShow3 = true;
},
selectFn4(type){
this.isqueryselect = false;
let project_key = this.setInfo.project_key;
if(type=='q'){
this.isqueryselect = true;
project_key = this.queryCond.supplier_key;
}
for(let [index,item] of this.projectlist.entries()){
if(project_key==item.value){
this.selectValue4 = [index];
break;
}
}
this.selectShow4 = true;
},
selectFn5(type){
this.isqueryselect = false;
let status = this.queryCond.status;
if(type=='q'){
this.isqueryselect = true;
}
for(let [index,item] of this.statuslist.entries()){
if(status==item.value){
this.selectValue5 = [index];
break;
}
}
this.selectShow5 = true;
},
uselectConfirm1(e){
console.log(e)
if(this.isqueryselect){
this.queryCond.type = e[0].value;
this.queryCond.type_name = e[0].label;
}else{
this.setInfo.type = e[0].value;
this.setInfo.type_name = e[0].label;
}
},
uselectConfirm2(e){
if(this.isqueryselect){
this.queryCond.base = e[0].value;
this.queryCond.base_name = e[0].label;
}else{
this.setInfo.agricultural_base_id = e[0].value;
this.setInfo.base_name = e[0].label;
}
},
uselectConfirm3(e){
if(this.isqueryselect){
this.queryCond.supplier_key = e[0].value;
this.queryCond.supplier_name = e[0].label;
}else{
this.setInfo.supplier_key = e[0].value;
this.setInfo.supplier_name = e[0].label;
}
},
uselectConfirm4(e){
if(this.isqueryselect){
this.queryCond.project_key = e[0].value;
this.queryCond.project_name = e[0].label;
}else{
this.setInfo.project_key = e[0].value;
this.setInfo.project_name = e[0].label;
}
},
uselectConfirm5(e){
if(this.isqueryselect){
this.queryCond.status = e[0].value;
this.queryCond.status_name = e[0].label;
}else{
}
},
dropdownClose(){
this.dropDownShow= false;
},
@ -285,10 +624,16 @@
page: this.page ++,
_t: new Date().getTime()
}
for(let k in this.queryCond){
if(this.queryCond[k]||this.queryCond[k]=='0'){
params[k] = this.queryCond[k];
}
}
this.loading = 'loading';
this.$http.get('/api/devices',{params:params}).then(({data})=>{
console.log(data)
this.screenShow = false;
if(refresh){
this.list = [];
}
@ -306,28 +651,35 @@
}
}).catch(()=>{
this.loading = 'loadmore';
this.screenShow = false;
})
},
//
editInfoBtn(){
let {id,name,sort,is_iframe,is_recommend,is_show,type,content} = this.setInfo;
let {id,agricultural_base_id,sort,monitoring_point,
project_key,sn,type,supplier_key} = this.setInfo;
let params = {
name:name,
agricultural_base_id:agricultural_base_id,
sort:sort,
is_iframe:is_iframe?1:0,
is_recommend:is_recommend?1:0,
is_show:is_show?1:0,
monitoring_point:monitoring_point,
project_key:project_key,
sn:sn,
type:type,
content:content,
supplier_key:supplier_key,
}
if(id){params['id'] = id;}
if(type==1){//
params['extends'] = this.extendConf;
}
if(params['id']){
this.$http.put(`/api/devices/${id}`,params).then(({data})=>{
if(data.code==200){
this.editShow = false;
this.queryDataList(true);
uni.showToast({ title: data.message, icon: 'none' });
}
uni.showToast({ title: data.message, icon: 'none' });
}).catch(()=>{
})
@ -357,26 +709,50 @@
let info = {
id:'',
type:'',
type_name:'',
sort:'',
base_name:'',
agricultural_base_id:'',//id
sn:'',
supplier:'',
supplier_key:'',//k
supplier_name:'',
project:'',
monitoring_point:''
project_key:'',//k
project_name:'',
monitoring_point:'',
}
if(type=='add'){
this.setInfo = info;
}else{
let {id,type,sort,base_name,sn,supplier,project,monitoring_point} = this.formInfo;
info['id'] = id;
info['type'] = type;
info['sort'] = sort;
info['base_name'] = base_name;
info['sn'] = sn;
info['supplier'] = supplier;
info['project'] = project;
info['monitoring_point'] = monitoring_point;
this.setInfo = info;
let {id,type,sort,base_id,base_name,sn,supplier,project,
monitoring_point} = this.formInfo;
try{
for(let item of this.deviceTypes){
if(type == item.label){
info.type = item.value;
break;
}
}
info['id'] = id;
info['type_name'] = type;
info['sort'] = sort;
info['base_name'] = base_name;
info['agricultural_base_id'] = base_id;
info['sn'] = sn;
info['supplier_key'] = supplier?supplier.id:'';
info['supplier_name'] = supplier?supplier.name:'';
info['project_key'] = project?project.id:'';
info['project_name'] = project?project.name:'';
info['monitoring_point'] = monitoring_point;
this.setInfo = info;
if(this.formInfo.extends){
this.extendConf = this.formInfo.extends;
}
}catch(e){
//TODO handle the exception
uni.showToast({ title: '数据错误', icon: 'none' })
}
}
},
//deleteInfoId
@ -391,9 +767,11 @@
if(data.code==200){
this.formInfo = {};//
this.popupShow = false;
this.list.splice(this.cindex,1);
uni.showToast({ title: data.message, icon: 'none' });
// this.list.splice(this.cindex,1);
this.queryDataList(true);
}
uni.showToast({ title: data.message, icon: 'none' });
}).catch(()=>{
})
@ -415,6 +793,67 @@
})
},
//
getDeviceTypes(){
this.$http.get(`/api/device-types`).then(({data})=>{
if(data.code==200){
let _data = data.data;
console.log(_data,'===============ss')
let list = [];
for(let k in _data){
let option = {
value: k,
label: _data[k],
}
list.push(option)
}
console.log(list,'===============ss')
this.deviceTypes = list;
}
}).catch((err)=>{
})
},
//
getAgriculturalBasic(){
const params = { type: 1, per_page: 9999, page: 1 }
this.$http.get(`/api/agricultural-basic`,{params:params}).then(({data})=>{
if(data.code==200){
let _data = data.data;
let list = [];
for(let item of _data){
let option = {
value: item.id,
label: item.name,
}
list.push(option)
}
console.log(list,'===============ss')
this.basicList = list;
}
}).catch((err)=>{
})
},
resetQuery(){
this.queryCond = {
base:'',
base_name:'',
type:'',
type_name:'',
status:'',
status_name:'',
point:'',
sn:'',
supplier_key:'',
supplier_name:'',
project_key:'',
project_name:''
}
},
goback(){
navigateBack()
}

View File

@ -0,0 +1,505 @@
<template>
<view class="bg-page">
<u-navbar title="稻虾价格" :background="background" :custom-back="goback"
:title-color="titleColor" :back-icon-color="titleColor">
<view class="nav_slot_right_box" slot="right">
<view class="custom_btn add_btn" @click="addBtn()"></view>
</view>
</u-navbar>
<view class="secreen-section">
<view class="search-box">
<view class="search-input-vh u-border" @click="screenShowFn()">
<view class="placeholder_text">筛选条件</view>
</view>
</view>
</view>
<view class="content-box u-padding-25">
<u-swipe-action class="tb_swipe_list"
v-for="(item, index) in list"
:show="item.show" :index="index" :key="item.id"
@click="click"
@open="open"
:options="options"
>
<view class="tb_body" @click="showInfo(index)">
<view class="row_box">
<view class="text">年份{{ item.year }}</view>
</view>
<view class="row_box">
<view class="text">季度{{item.quarter}}</view>
</view>
<view class="row_box">
<view class="text">价格{{ item.price }}</view>
</view>
<view class="row_box">
<view class="text">创建人{{ item.created_by?item.created_by.name:'-' }}</view>
</view>
</view>
</u-swipe-action>
<u-loadmore :status="loading" margin-top="60"/>
</view>
<!-- 编辑 -->
<u-popup v-model="editShow" border-radius="28" width="92%" height="700rpx"
mode="center" :closeable="true" :mask-close-able="false" z-index="910">
<view class="popup-form-ubox">
<view class="top_box">
<view class="title" v-if="setInfo.id"></view>
<view class="title" v-else></view>
</view>
<scroll-view class="scroll-y" scroll-y="true">
<view class="form_edit" style="padding-left: 50rpx;">
<u-form>
<u-form-item label="ID" label-width="140" v-if="setInfo.id">
<view class="input_box bg_colorf8 pdlr12">
<u-input v-model="setInfo.id" :disabled="true" />
</view>
</u-form-item>
<u-form-item label="年份" label-width="140" :required='true'>
<view class="input_box">
<view class="u-select-list" @click="selectFn1()">
<view class="value u-line-2"
v-if="setInfo.year">{{setInfo.year}}</view>
<view class="placeholder" v-else></view>
<view class="right">
<u-icon name="arrow-right" color="#999" size="28"></u-icon>
</view>
</view>
</view>
</u-form-item>
<u-form-item label="季度" label-width="140" :required='true'>
<view class="input_box">
<view class="u-select-list" @click="selectFn2()">
<view class="value u-line-2"
v-if="setInfo.quarter_name">{{setInfo.quarter_name}}</view>
<view class="placeholder" v-else></view>
<view class="right">
<u-icon name="arrow-right" color="#999" size="28"></u-icon>
</view>
</view>
</view>
</u-form-item>
<u-form-item label="价格" label-width="140" :required='true'>
<view class="input_box">
<u-input v-model="setInfo.price" />
</view>
</u-form-item>
</u-form>
</view>
</scroll-view>
<view class="buttom_section">
<u-button class="btn" type="default" @click="editShow = false">取消</u-button>
<u-button class="btn" @click="editInfoBtn()" type="primary">确定</u-button>
</view>
</view>
</u-popup>
<u-popup v-model="popupShow" mode="bottom" border-radius="28" z-index="900">
<view class="popup-form-info">
<view class="top_box u-border-bottom">
<view class="handle-btns">
<view class="btn_del" @click="deleteInfoId(formInfo.id)"></view>
<view class="btn_edit" @click="editInfoId(formInfo.id)"></view>
</view>
</view>
<view class="section_c">
<view class="plist u-border-bottom">
<view class="label_t">年份</view>
<view class="flex-1">{{formInfo.year}}</view>
</view>
<view class="plist u-border-bottom">
<view class="label_t">季度</view>
<view class="flex-1">{{formInfo.quarter}}</view>
</view>
<view class="plist u-border-bottom">
<view class="label_t">价格</view>
<view class="flex-1">{{formInfo.price}}</view>
</view>
<view class="plist u-border-bottom">
<view class="label_t">创建人</view>
<view class="flex-1">{{ formInfo.created_by?formInfo.created_by.name:'-' }}</view>
</view>
</view>
</view>
</u-popup>
<!-- 筛选查询条件 -->
<u-popup v-model="screenShow" mode="top" z-index="9">
<view class="popup-screen-groups">
<view class="status_bar_top"></view>
<scroll-view class="scroll-y" scroll-y="true">
<view class="row_ul u-padding-right-20 u-padding-top-40">
<view class="row_list u-flex">
<view class="label_tit small">年份</view>
<yn-select-input-list :value="queryCond.year"
rightIcon="calendar" placeholder="请选择年份"
@click="selectFn1('q')"></yn-select-input-list>
</view>
<view class="row_list u-flex">
<view class="label_tit small">季度</view>
<yn-select-input-list :value="queryCond.quarter_name" placeholder="请选择季度"
@click="selectFn2('q')"></yn-select-input-list>
</view>
</view>
</scroll-view>
<view class="buttom_section u-padding-top-40">
<u-button class="btn small_btn" type="default" @click="resetQuery()"></u-button>
<u-button class="btn small_btn" @click="queryBtn()" type="primary">查询</u-button>
</view>
</view>
</u-popup>
<u-picker mode="time" v-model="selectShow1"
:params="timeParams" :default-time="selectValue1"
@confirm="uselectConfirm1"></u-picker>
<u-select v-model="selectShow2" :list="quarterlist"
:default-value="selectValue2" mode="single-column"
@confirm="uselectConfirm2"></u-select>
</view>
</template>
<script>
import {formatDate,navigateBack} from '@/com/utils.js'
export default {
data() {
return {
background: {
backgroundColor:'#2a7dc9',
},
titleColor:"#ffffff",
per_page:10,
page:1,
list:[],
loading:'loadmore',
options: [
{
text: '编辑',
style: {
backgroundColor: '#007aff'
}
},
{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}
],
popupShow:false,
cindex:-1,//
editShow:false,
formInfo:{},
timeParams: {
year: true,
month: false,
day: false,
hour: false,
minute: false,
second: false
},
screenShow:false,
isqueryselect:false,
setInfo:{
id:'',
year:'',
quarter:'',
quarter_name:'',
price:''
},
editShow:false,
queryCond:{
year:'',
quarter:'',
quarter_name:'',
},
selectShow1:false,
selectShow2:false,
selectValue1:'',
selectValue2:[0],
quarterlist:[
{
label:'第一季度',
value:1,
},
{
label:'第二季度',
value:2,
},
{
label:'第三季度',
value:3,
},
{
label:'第四季度',
value:4,
}
]
};
},
onLoad(){
this.queryDataList();
},
methods:{
addBtn(){
this.setInfoKeys('add');
this.editShow = true;
},
selectFn1(type){
this.isqueryselect = false;
let year = this.setInfo.year;
if(type=='q'){
this.isqueryselect = true;
this.selectShow1 = true;
year = this.queryCond.year;
}
if(year){
this.selectValue1 = `${year}-01-01 00:00:01`;
}
console.log(this.selectValue1)
this.selectShow1 = true;
},
selectFn2(type){
this.isqueryselect = false;
let quarter = this.setInfo.quarter;
if(type=='q'){
this.isqueryselect = true;
quarter = this.queryCond.quarter;
}
for(let [index,item] of this.quarterlist.entries()){
if(quarter==item.value){
this.selectValue2 = [index];
break;
}
}
this.selectShow2 = true;
},
resetQuery(){
this.queryCond = {
year:'',
quarter:'',
quarter_name:'',
}
},
queryBtn(){
this.list = [];
this.queryDataList(true);
},
uselectConfirm1(e){
if(this.isqueryselect){
console.log(e);
this.queryCond.year = e.year;
}else{
this.setInfo.year = e.year;
}
},
uselectConfirm2(e){
if(this.isqueryselect){
console.log(e);
this.queryCond.quarter = e[0].value;
this.queryCond.quarter_name = e[0].label;
}else{
this.setInfo.quarter = e[0].value;
this.setInfo.quarter_name = e[0].label;
}
},
screenShowFn(){
this.screenShow = true;
},
showInfo(index){
this.cindex = index;
let _id = this.list[index].id;
this.queryInfo(_id);
this.formInfo = this.list[index];
this.popupShow = true;
},
open(index){
this.list[index].show = true;
},
click(index, index1) {
console.log(index,index1,this.list[index])
if(index1 == 1) {
this.cindex = index;
let _id = this.list[index].id;
this.deleteInfoId(_id);
} else {//
let _id = this.list[index].id;
this.formInfo = this.list[index];
this.queryInfo(_id);
this.setInfoKeys();
this.editShow = true;
this.list[index].show = false;
}
},
queryDataList(refresh){
if(refresh){
this.loading = 'loadmore';
this.page = 1;
}
if(this.loading=='nomore'){//
return false;
}
let params = {
per_page:this.per_page,
page: this.page ++,
_t: new Date().getTime()
}
for(let k in this.queryCond){
if(this.queryCond[k]||this.queryCond[k]=='0'){
params[k] = this.queryCond[k];
}
}
this.loading = 'loading';
this.$http.get('/api/rice-shrimp-prices',{params:params}).then(({data})=>{
console.log(data)
this.screenShow = false;
if(refresh){
this.list = [];
}
this.loading = 'loadmore';
if(data.code==200){
let _list = data.data|| [];
for(let item of _list){
item.show = false;
}
this.list = this.list.concat(_list);
console.log(this.list);
if(this.list.length>= data.meta.total){
this.loading ='nomore';
}
}
}).catch(()=>{
this.loading = 'loadmore';
this.screenShow = false;
})
},
//
editInfoBtn(){
let {id,} = this.setInfo;
let params = {}
params = this.setInfo;
if(params['id']){
this.$http.put(`/api/rice-shrimp-prices/${id}`,params).then(({data})=>{
if(data.code==200){
this.editShow = false;
this.queryDataList(true);
}
uni.showToast({ title: data.message, icon: 'none' });
}).catch(()=>{
})
}else{
delete params['id'];
this.$http.post(`/api/rice-shrimp-prices`,params).then(({data})=>{
if(data.code==200){
this.queryDataList(true);
this.editShow = false;
uni.showToast({ title: data.message, icon: 'none' });
}else{
uni.showToast({ title: data.message, icon: 'none' });
}
}).catch(()=>{
})
}
},
queryInfo(id){
// this.$http.get(`/api/rice-shrimp-prices/${id}`).then(({data})=>{
// console.log(data,'queryInfo===')
// if(data.code==200){
// this.formInfo = data.data;
// this.setInfoKeys();
// }
// }).catch((err)=>{
// })
},
editInfoId(id){
// this.queryInfo(id);
this.setInfoKeys();
this.editShow = true;
this.popupShow = false;
},
//deleteInfoId
deleteInfoId(id){
uni.showModal({
title: '提示',
content: '是否确定删除?',
success: (res)=> {
if (res.confirm) {
console.log('用户点击确定');
this.$http.delete(`/api/rice-shrimp-prices/${id}`).then(({data})=>{
if(data.code==200){
this.formInfo = {};//
this.popupShow = false;
this.list.splice(this.cindex,1);
// this.queryDataList(true);
}
uni.showToast({ title: data.message, icon: 'none' });
}).catch(()=>{
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
},
setInfoKeys(type){
let info = {
id:'',
year:'',
quarter:'',
quarter_name:'',
price:''
}
if(type=='add'){
this.setInfo = info;
}else{
let {id,year,quarter,price} = this.formInfo;
try{
for(let item of this.quarterlist){
if(quarter == item.value){
info.quarter_name = item.label;
break;
}
}
info['id'] = id;
info['year'] = year;
info['quarter'] = quarter;
info['price'] = price;
this.setInfo = info;
}catch(e){
//TODO handle the exception
uni.showToast({ title: '数据错误', icon: 'none' })
}
}
},
goback(){
navigateBack()
}
},
//
onReachBottom() {
if(this.loading=='loadmore'){
this.queryDataList();
}
},
}
</script>
<style lang="scss">
</style>

View File

@ -70,6 +70,7 @@
},
{
label:'稻虾价格',
url:'/pages/estate/estate-price'
},
{
label:'稻虾每周价格',
@ -157,6 +158,7 @@
align-items: center;
justify-content: center;
padding: 10rpx 15rpx;
height: 100%;
}
}
}