Browse Source

联调接口

master
邓宏 2 years ago
parent
commit
cbae7277e6
  1. 6
      App.vue
  2. 0
      common/main.css
  3. 4
      common/request.js
  4. 184
      components/colorui/animation.css
  5. 69
      components/colorui/components/cu-custom.vue
  6. 72
      components/cu-navbar.vue
  7. 2
      main.js
  8. 27
      pages.js
  9. 15
      pages.json
  10. 29
      pages/demo.nvue
  11. 3
      pages/home/login.vue
  12. 10
      pages/massif/detail.vue
  13. 12
      pages/massif/info.vue
  14. 26
      pages/massif/mana/index.vue
  15. 16
      pages/massif/mana/plantPlan.vue
  16. 33
      pages/massif/plant_info.vue
  17. 12
      pages/massif/plant_plan.vue
  18. 28
      pages/purchase/agrProdList.vue
  19. 12
      pages/purchase/apply.vue
  20. 107
      pages/purchase/newAgr.vue
  21. 31
      pages/purchase/specs.vue
  22. 4
      uni.scss
  23. 38
      uni_modules/d-form/components/d-form/d-form.vue

6
App.vue

@ -20,9 +20,9 @@
if(this.$store.getters.token){ if(this.$store.getters.token){
}else{ }else{
uni.reLaunch({ // uni.reLaunch({
url:"pages/home/login", // url:"pages/home/login",
}) // })
} }
}, },
onShow: function() { onShow: function() {

0
components/colorui/main.css → common/main.css

4
common/request.js

@ -3,8 +3,8 @@ import store from "@/store"
export function host(host='default',suffix='/plant_manage'){ export function host(host='default',suffix='/plant_manage'){
return( return(
process.env.NODE_ENV === 'development'?{ process.env.NODE_ENV === 'development'?{
// default:`http://10.0.0.217${suffix}` //陈 default:`http://xvff42.natappfree.cc${suffix}` //陈
default:`http://mq3s8b.natappfree.cc${suffix}` //马 // default:`http://mq3s8b.natappfree.cc${suffix}` //马
}:{ }:{
default:`http://qv6mj8.natappfree.cc${suffix}` default:`http://qv6mj8.natappfree.cc${suffix}`
} }

184
components/colorui/animation.css

@ -1,184 +0,0 @@
/*
Animation 微动画
基于ColorUI组建库的动画模块 by 文晓港 2019年3月26日19:52:28
*/
/* css 滤镜 控制黑白底色gif的 */
.gif-black{
mix-blend-mode: screen;
}
.gif-white{
mix-blend-mode: multiply;
}
/* Animation css */
[class*=animation-] {
animation-duration: .5s;
animation-timing-function: ease-out;
animation-fill-mode: both
}
.animation-fade {
animation-name: fade;
animation-duration: .8s;
animation-timing-function: linear
}
.animation-scale-up {
animation-name: scale-up
}
.animation-scale-down {
animation-name: scale-down
}
.animation-slide-top {
animation-name: slide-top
}
.animation-slide-bottom {
animation-name: slide-bottom
}
.animation-slide-left {
animation-name: slide-left
}
.animation-slide-right {
animation-name: slide-right
}
.animation-shake {
animation-name: shake
}
.animation-reverse {
animation-direction: reverse
}
@keyframes fade {
0% {
opacity: 0
}
100% {
opacity: 1
}
}
@keyframes scale-up {
0% {
opacity: 0;
transform: scale(.2)
}
100% {
opacity: 1;
transform: scale(1)
}
}
@keyframes scale-down {
0% {
opacity: 0;
transform: scale(1.8)
}
100% {
opacity: 1;
transform: scale(1)
}
}
@keyframes slide-top {
0% {
opacity: 0;
transform: translateY(-100%)
}
100% {
opacity: 1;
transform: translateY(0)
}
}
@keyframes slide-bottom {
0% {
opacity: 0;
transform: translateY(100%)
}
100% {
opacity: 1;
transform: translateY(0)
}
}
@keyframes shake {
0%,
100% {
transform: translateX(0)
}
10% {
transform: translateX(-9px)
}
20% {
transform: translateX(8px)
}
30% {
transform: translateX(-7px)
}
40% {
transform: translateX(6px)
}
50% {
transform: translateX(-5px)
}
60% {
transform: translateX(4px)
}
70% {
transform: translateX(-3px)
}
80% {
transform: translateX(2px)
}
90% {
transform: translateX(-1px)
}
}
@keyframes slide-left {
0% {
opacity: 0;
transform: translateX(-100%)
}
100% {
opacity: 1;
transform: translateX(0)
}
}
@keyframes slide-right {
0% {
opacity: 0;
transform: translateX(100%)
}
100% {
opacity: 1;
transform: translateX(0)
}
}

69
components/colorui/components/cu-custom.vue

@ -1,69 +0,0 @@
<template>
<view>
<view class="cu-custom" :style="[{height:CustomBar + 'px'}]">
<view class="cu-bar fixed" :style="style" :class="[bgImage!=''?'none-bg text-white bg-img':'',bgColor]">
<view class="action" @tap="BackPage" v-if="isBack">
<text class="cuIcon-back"></text>
<slot name="backText"></slot>
</view>
<view class="content" :style="[{top:StatusBar + 'px'}]">
<slot name="content"></slot>
</view>
<slot name="right"></slot>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
StatusBar: this.StatusBar,
CustomBar: this.CustomBar
};
},
name: 'cu-custom',
computed: {
style() {
var StatusBar= this.StatusBar;
var CustomBar= this.CustomBar;
var bgImage = this.bgImage;
var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
if (this.bgImage) {
style = `${style}background-image:url(${bgImage});`;
}
return style
}
},
props: {
bgColor: {
type: String,
default: ''
},
isBack: {
type: [Boolean, String],
default: false
},
bgImage: {
type: String,
default: ''
},
},
methods: {
BackPage() {
if (getCurrentPages().length < 2 && 'undefined' !== typeof __wxConfig) {
let url = '/' + __wxConfig.pages[0]
return uni.redirectTo({url})
}
uni.navigateBack({
delta: 1
});
}
}
}
</script>
<style>
</style>

72
components/cu-navbar.vue

@ -1,72 +0,0 @@
<style lang="scss" scoped>
.cu-navbar{
height:calc(var(--status-bar-height) + 100rpx);
flex-shrink: 0;
&>.cu-bar{
position:fixed;
z-index: 200;
top:0;
left:0;
width:100%;
box-sizing: content-box;
padding-top:var(--status-bar-height);
height:100rpx;
background-color:var(--bg);
color:var(--c);
&>.left{
transform: rotate(180deg);
padding:10rpx;
text.plant-youbian{
font-size:45rpx;
}
}
&>.content{
top:var(--status-bar-height);
}
&>.action /deep/{
&>button{
background:rgba(255, 255, 255, 0.1);
width:96rpx;
height:48rpx;
line-height: 48rpx;
text-align: center;
font-size:30rpx;
padding:0;
color:#fff;
}
}
}
}
</style>
<template>
<view class="cu-navbar">
<view class="cu-bar">
<view class="left">
<text v-if="isBack" class="plant-youbian" @click="$u.route({type:'back'})"/>
</view>
<view class="content">
{{text}}
</view>
<view class="action">
<slot name="right"/>
</view>
</view>
</view>
</template>
<script>
export default {
props:{
isBack:{
type:Boolean,
default:false,
},
text:{
type:String,
default:"",
}
},
created(){
},
}
</script>

2
main.js

@ -2,11 +2,9 @@ import Vue from 'vue'
import App from './App' import App from './App'
import store from './store' import store from './store'
import uView from 'uview-ui'; import uView from 'uview-ui';
// import cuNavbar from './components/cu-navbar.vue'
import {defineObj} from 'black-knight/lib/config/custom' import {defineObj} from 'black-knight/lib/config/custom'
Vue.use(uView) Vue.use(uView)
// Vue.component("cuNavbar", cuNavbar)
Vue.prototype.$store=store Vue.prototype.$store=store
Vue.config.productionTip = false Vue.config.productionTip = false

27
pages.js

@ -9,6 +9,19 @@ module.exports = hot((pagesJson)=>{
...require("./router/massif.js"), ...require("./router/massif.js"),
...require('./router/purchase.js'), ...require('./router/purchase.js'),
...require('./router/stock.js'), ...require('./router/stock.js'),
// {
// "path":"pages/demo",
// "style":{
// "navigationBarTitleText":"测试地图",
// "navigationBarBackgroundColor":"#10C176",
// "navigationBarTextStyle":"white",
// "app-plus":{
// "titleNView":true,
// "nvueCompiler":"uni-app",
// "nvueStyleCompiler":"uni-app"
// }
// }
// },
], ],
tabBar:{ tabBar:{
color:"#999", color:"#999",
@ -21,5 +34,19 @@ module.exports = hot((pagesJson)=>{
{pagePath:"pages/home/my",text:"我的",iconPath: "/static/tab_my.png",selectedIconPath: "/static/tab_my_active.png"}, {pagePath:"pages/home/my",text:"我的",iconPath: "/static/tab_my.png",selectedIconPath: "/static/tab_my_active.png"},
] ]
}, },
condition : {
current: 0,
list: [
// {name:"测试页面",path:"pages/demo"},
{name: "登录",path: "pages/home/login","query": ""},
{name: "首页",path: "pages/home/index","query": ""},
{name: "仓库管理",path: "pages/warehouse/mana","query": ""},
{name: "仓库基本信息",path: "pages/warehouse/info","query": ""},
{name: "仓库详情",path: "pages/warehouse/detail","query": ""},
{name: "地块管理",path: "pages/massifMana","query": ""},
{name: "地块详情",path: "pages/massifDetail","query": ""},
{name: "地块基本信息",path: "pages/massifInfo","query": ""}
]
}
} }
}) })

15
pages.json

@ -9,17 +9,8 @@
"backgroundColor": "#F8F8F8" "backgroundColor": "#F8F8F8"
}, },
"uniIdRouter": {}, "uniIdRouter": {},
"condition" : { // "condition" : {
"current": 0, //(list ) "current": 0,
"list": [ "list": []
{"name": "登录","path": "pages/home/login","query": ""},
{"name": "首页","path": "pages/home/index","query": ""},
{"name": "仓库管理","path": "pages/warehouse/mana","query": ""},
{"name": "仓库基本信息","path": "pages/warehouse/info","query": ""},
{"name": "仓库详情","path": "pages/warehouse/detail","query": ""},
{"name": "地块管理","path": "pages/massifMana","query": ""},
{"name": "地块详情","path": "pages/massifDetail","query": ""},
{"name": "地块基本信息","path": "pages/massifInfo","query": ""}
]
} }
} }

29
pages/demo.nvue

@ -0,0 +1,29 @@
<style lang="scss">
.content{
width:750rpx;
height:1050rpx;
background:red;
map{
width:750rpx;
height:1050rpx;
}
}
</style>
<template>
<view class="content">
<map enable-satellite style="width:750rpx;height:1050rpx;"/>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>

3
pages/home/login.vue

@ -73,6 +73,9 @@ export default {
} }
}, },
onLoad(){ onLoad(){
uni.navigateTo({
url:"/pages/demo"
})
if(process.env.NODE_ENV === 'development'){ if(process.env.NODE_ENV === 'development'){
this.formData.username="13383434048" this.formData.username="13383434048"
this.formData.password="1qaz@WSX" this.formData.password="1qaz@WSX"

10
pages/massif/detail.vue

@ -32,11 +32,9 @@
width:100%; width:100%;
display:flex; display:flex;
flex-wrap: wrap; flex-wrap: wrap;
image{ &>view{
height:160rpx;
margin:0 20rpx 20rpx 0;
width:calc((100% - 40rpx)/3); width:calc((100% - 40rpx)/3);
border-radius: 8rpx; margin:0 20rpx 20rpx 0;
&:nth-child(3n){ &:nth-child(3n){
margin-right:0; margin-right:0;
} }
@ -74,7 +72,9 @@
<view class="item inline"> <view class="item inline">
<text>地块图片</text> <text>地块图片</text>
<view class="imgs"> <view class="imgs">
<image mode="aspectFill" v-for="(v,k) in detail.image" :key="k" :src="`${imgUrl}/${v}`"/> <u-image mode="aspectFill" radius="8rpx" width="100%" height="160rpx" v-for="(v,k) in detail.image" :key="k" :src="`${imgUrl}/${v}`">
<text slot="error" style="font-size:60rpx" class="plant-xiaopangchetupianjiazaishibai"/>
</u-image>
</view> </view>
</view> </view>
<view class="item"> <view class="item">

12
pages/massif/info.vue

@ -17,7 +17,7 @@
:value="(/^dateRange$|^select$/.test(v.type)?fields[k].value:formData[k])" :value="(/^dateRange$|^select$/.test(v.type)?fields[k].value:formData[k])"
@input="formData[k]=$event" @input="formData[k]=$event"
@selectRDate="selectDate" @selectRDate="selectDate"
@select="fields[k].value=$event.indexs;formData[k]=$event.value[0].value" @select="fields[k].value=$event.value.map(v=>v.value);formData[k]=$event.value[0].value"
@imgs="fields[k].value=$event"/> @imgs="fields[k].value=$event"/>
</u-form> </u-form>
<button class="cu-btn round bg-green shadow submit" @click="sumbit">保存</button> <button class="cu-btn round bg-green shadow submit" @click="sumbit">保存</button>
@ -29,7 +29,7 @@ import request from '@/common/request'
data(){ data(){
return{ return{
fields:{ fields:{
plantBaseName:{label:"基地名称",type:"select",columns:[[]],value:[null]}, plantBaseInfoId:{label:"基地名称",type:"select",columns:[[]],value:[]},
plotNumber:{label:"地块编号"}, plotNumber:{label:"地块编号"},
plotName:{label:"地块名称"}, plotName:{label:"地块名称"},
drawArea:{label:"地块面积(亩)",type:'digit'}, drawArea:{label:"地块面积(亩)",type:'digit'},
@ -40,7 +40,7 @@ import request from '@/common/request'
address:{label:"详细地址",type:"textarea"}, address:{label:"详细地址",type:"textarea"},
}, },
formData:{ formData:{
plantBaseName:"", plantBaseInfoId:"",
plotNumber:"", plotNumber:"",
plotName:"", plotName:"",
drawArea:'', drawArea:'',
@ -53,7 +53,7 @@ import request from '@/common/request'
address:"", address:"",
}, },
rules:{ rules:{
plantBaseName:{required:true, message:"基地名称必填!", trigger:"change"}, plantBaseInfoId:{required:true, message:"基地名称必填!", trigger:"change"},
plotNumber:{required:true, message:"地块编号必填!", trigger:"blur"}, plotNumber:{required:true, message:"地块编号必填!", trigger:"blur"},
plotName:{required:true, message:"地块名称必填!", trigger:"blur"}, plotName:{required:true, message:"地块名称必填!", trigger:"blur"},
drawArea:{required:true, type:'number', message:"地块面积必填!", trigger:"blur"}, drawArea:{required:true, type:'number', message:"地块面积必填!", trigger:"blur"},
@ -82,7 +82,7 @@ import request from '@/common/request'
params:{companyId:this.$store.getters.userInfo.companyId} params:{companyId:this.$store.getters.userInfo.companyId}
}) })
if(res.statu){ if(res.statu){
this.fields.plantBaseName.columns = [res.data.map(v=>({label:v.baseName,value:v.id}))] this.fields.plantBaseInfoId.columns = [res.data.map(v=>({label:v.baseName,value:v.id}))]
}else{ }else{
uni.showModal({ uni.showModal({
title:"提示", title:"提示",
@ -129,7 +129,7 @@ import request from '@/common/request'
if(res.statu){ if(res.statu){
this.formData=res.data this.formData=res.data
this.fields.date.value=[res.data.beginTime, res.data.endTime] this.fields.date.value=[res.data.beginTime, res.data.endTime]
this.fields.plantBaseName.value=[this.fields.plantBaseName.columns[0].findIndex(v=>v.value==res.data.plantBaseName)] this.fields.plantBaseInfoId.value=[res.data.plantBaseInfoId]//[this.fields.plantBaseInfoId.columns[0].findIndex(v=>v.value==res.data.plantBaseName)]
this.fields.image.value=res.data.image.join(',') this.fields.image.value=res.data.image.join(',')
}else{ }else{
uni.showModal({ uni.showModal({

26
pages/massif/mana/index.vue

@ -16,7 +16,7 @@
</style> </style>
<template> <template>
<view class="container"> <view class="container">
<map/> <map id="amap"/>
<u-tabs :list="tabs" :current="tabIndex" activeStyle="color:#10C176;" lineColor="#10C176" lineWidth="50" :scrollable="false" @change="tabIndex=$event.index"/> <u-tabs :list="tabs" :current="tabIndex" activeStyle="color:#10C176;" lineColor="#10C176" lineWidth="50" :scrollable="false" @change="tabIndex=$event.index"/>
@ -45,5 +45,29 @@ export default {
onLoad(options){ onLoad(options){
this.plantId=options.id this.plantId=options.id
}, },
onReady(){
/* #ifdef APP-PLUS */
var a=uni.createMapContext("amap",this)
var maps=a.$getAppMap()
maps.setMapType(plus.maps.MapType.MAPTYPE_SATELLITE)
maps.onclick=(e)=>{
console.log(e,'-------maps--click---------')
}
var polygon=new plus.maps.Polygon([
new plus.maps.Point(116.39524,39.925301),
new plus.maps.Point(116.400444,39.925285),
new plus.maps.Point(116.400558,39.923282),
new plus.maps.Point(116.395502,39.923082),
])
polygon.setLineWidth(0)
polygon.setFillColor("#ff0000")
polygon.setFillOpacity(0.3)
maps.addOverlay(polygon)
/* #endif */
},
methods:{
}
} }
</script> </script>

16
pages/massif/mana/plantPlan.vue

@ -3,15 +3,13 @@
.card{ .card{
&>.info{ &>.info{
display:flex; display:flex;
image{ &>.u-transition{
width:170rpx;
height:140rpx;
margin-right:20rpx;
position:relative; position:relative;
border-radius: 20rpx; margin-right:20rpx;
&:before{ &:before{
content:attr(data-type); content:attr(data-type);
position:absolute; position:absolute;
z-index: 30;
top:0; top:0;
left:0; left:0;
border-radius: 20rpx 20rpx 20rpx 0; border-radius: 20rpx 20rpx 20rpx 0;
@ -21,6 +19,10 @@
min-width:80rpx; min-width:80rpx;
text-align: center; text-align: center;
} }
&/deep/ image{
color:red;
border-radius: 20rpx!important;
}
} }
&>.detail{ &>.detail{
flex-grow: 1; flex-grow: 1;
@ -91,7 +93,9 @@
<view class="plant_plan"> <view class="plant_plan">
<view class="card" v-for="(v,k) in list" :key="k"> <view class="card" v-for="(v,k) in list" :key="k">
<view class="info" @click="reDetail(v.id)"> <view class="info" @click="reDetail(v.id)">
<image :src="`${host}/${v.images}`" :data-type="v.plantType"/> <u-image :data-type="v.plantType" width="170rpx" height="140rpx" mode="aspectFill" src="https://cdn.uviewui.com/uview/album/1.jpg">
<view slot="error" style="font-size: 24rpx;">加载失败</view>
</u-image>
<view class="detail"> <view class="detail">
<view class="name"> <view class="name">
<text>{{v.plantStandard}}</text> <text class="over">{{v.varietyName}}</text> <text class="plant-youbian"/> <text>{{v.plantStandard}}</text> <text class="over">{{v.varietyName}}</text> <text class="plant-youbian"/>

33
pages/massif/plant_info.vue

@ -43,15 +43,14 @@ export default {
harvestTime:"", harvestTime:"",
status:"", status:"",
plantSchedulId:"",//id plantSchedulId:"",//id
plotId:"", plotId:"",//id
}, },
rules:{ rules:{
harvestNum: {required:true, message:"必填!", trigger:"blur"}, harvestNum: {required:true, type:"number", message:"采收数量必填!", trigger:"blur"},
harvestBatch:{required:true, message:"必填!", trigger:"blur"}, harvestBatch:{required:true, message:"收获批次号必填!", trigger:"blur"},
principal:{required:true, message:"必填!", trigger:"blur"}, principal:{required:true, message:"负责人必填!", trigger:"blur"},
harvestTime:{required:true, message:"必填!", trigger:"blur"}, harvestTime:{required:true, message:"采收时间必填!", trigger:"blur"},
status:{required:true, message:"必填!", trigger:"blur"}, status:{required:true, message:"采收状态必填!", trigger:"blur"},
plantSchedulId:{required:true, message:"必填!", trigger:"blur"},
} }
} }
}, },
@ -73,7 +72,25 @@ export default {
}) })
} }
}, },
submit(){}, submit(){
this.$refs.form.validate().then(async valid=>{
if(valid){
var res=await request("/api/plantHarvest/add",{
method:"post",
body: this.formData
})
if(res.statu){
}else{
uni.showModal({
title:"提示",
content:res.msg||"保存失败失败!",
showCancel:false,
})
}
}
})
},
}, },
} }
</script> </script>

12
pages/massif/plant_plan.vue

@ -12,8 +12,7 @@
</style> </style>
<template> <template>
<view class="container"> <view class="container">
<!-- errorType="toast" --> <u-form class="card inline" errorType="toast" :model="{...formData,images:fields.images.value}" :rules="rules" ref="form" labelWidth="auto">
<u-form class="card inline" :model="{...formData,images:fields.images.value}" :rules="rules" ref="form" labelWidth="auto">
<d-form <d-form
v-for="(v,k) in fields" v-for="(v,k) in fields"
:key="k" :key="k"
@ -21,7 +20,7 @@
:field="k" :field="k"
:required="!!rules[k]" :required="!!rules[k]"
:value="/^select$/.test(v.type)?fields[k].value:formData[k]" :value="/^select$/.test(v.type)?fields[k].value:formData[k]"
@select="$set(fields.plantType, 'value', $event.indexs);formData.plantType=$event.value[1].value" @select="fields.plantType.value=$event.value.map(v=>v.value);formData[k]=$event.value[1].value"
@input="formData[k]=$event" @input="formData[k]=$event"
@imgs="fields[k].value=$event"/> @imgs="fields[k].value=$event"/>
</u-form> </u-form>
@ -35,7 +34,7 @@ export default {
return{ return{
fields:{ fields:{
varietyName:{label:"品种名称"}, varietyName:{label:"品种名称"},
plantType:{label:"作物类型",type:"select",columns:[[]],value:[null,null]}, plantType:{label:"作物类型",type:"select",columns:[[]],value:[]},
plantArea:{label:"种植面积(亩)",type:"digit"}, plantArea:{label:"种植面积(亩)",type:"digit"},
startTime:{label:"种植开始日期",type:"calendar"}, startTime:{label:"种植开始日期",type:"calendar"},
harvestTime:{label:"预估采收日期",type:"calendar"}, harvestTime:{label:"预估采收日期",type:"calendar"},
@ -130,9 +129,8 @@ export default {
}) })
if(res.statu){ if(res.statu){
this.formData=res.data this.formData=res.data
this.fields.images.value=res.data.images.join(',') this.fields.images.value=res.data.images?.join?.(',')||''
this.fields.plantType.value=[this.fields.plantType.columns[0].findIndex(v=>v.value==res.data.plantType[0])] this.fields.plantType.value=res.data.plantType
this.fields.plantType.value[1]=this.fields.plantType.columns[0][this.fields.plantType.value[0]].children.findIndex(v=>v.value==res.data.plantType[1])
}else{ }else{
uni.showModal({ uni.showModal({
title:"提示", title:"提示",

28
pages/purchase/agrProdList.vue

@ -1,6 +1,6 @@
<style lang="scss"> <style lang="scss">
.container{ .container{
min-height:100%; height:100%;
background:#f6f6f6; background:#f6f6f6;
scroll-view{ scroll-view{
@ -19,12 +19,13 @@
font-size:20rpx; font-size:20rpx;
color:#fff; color:#fff;
background:#10C176; background:#10C176;
width:80rpx; min-width:70rpx;
height:40rpx; height:40rpx;
text-align: center; text-align: center;
line-height: 40rpx; line-height: 40rpx;
border-radius: 0 20rpx 0 20rpx; border-radius: 0 20rpx 0 20rpx;
margin-right:10rpx; margin-right:10rpx;
padding:0 8rpx;
} }
&.plant-youbian{ &.plant-youbian{
margin-left: auto; margin-left: auto;
@ -49,18 +50,18 @@
<template> <template>
<view class="container flex"> <view class="container flex">
<d-navbar text="农资列表" isBack style="--bg:#10C176;--c:#fff;"> <d-navbar text="农资列表" isBack style="--bg:#10C176;--c:#fff;">
<text slot="right" class="plant-xinjian" @click="$u.route({url:'pages/purchase/newAgr'})"/> <text slot="right" class="plant-xinjian" @click="toAddPage"/>
</d-navbar> </d-navbar>
<d-search v-model="searchVal.goodsName" @search="search"/> <d-search v-model="searchVal.goodsName" @search="clean();search()"/>
<scroll-view scroll-y @scrolltolower="search"> <scroll-view scroll-y @scrolltolower="search">
<view class="card" v-for="(v,k) in list" :key="k" @click="$u.route({url:'pages/purchase/specs'})"> <view class="card" v-for="(v,k) in list" :key="k" @click="$u.route({url:'pages/purchase/specs',params:{id:v.id}})">
<view class="name"> <view class="name">
<text>化肥</text> 中量元素水溶肥 <text class="plant-youbian"/> <text>{{v.goodsName}}</text> {{v.detailedType}} <text class="plant-youbian"/>
</view> </view>
<view class="company"> <view class="company">
<text>微量元素肥</text> <text>云南云天化股份有限公司</text> <text>{{v.detailedParentName}}</text> <text>{{v.supplier}}</text>
</view> </view>
</view> </view>
<u-empty v-if="list.length==0" icon="http://cdn.uviewui.com/uview/empty/data.png"/> <u-empty v-if="list.length==0" icon="http://cdn.uviewui.com/uview/empty/data.png"/>
@ -85,6 +86,11 @@ export default {
this.search() this.search()
}, },
methods:{ methods:{
clean(){
this.list=[]
this.total=0
this.searchVal.pageNo=1
},
async search(){ async search(){
if(this.total==0||this.list.length<this.total){ if(this.total==0||this.list.length<this.total){
var res=await request("/api/goods/goodsList",{ var res=await request("/api/goods/goodsList",{
@ -101,7 +107,13 @@ export default {
}) })
} }
} }
} },
toAddPage(){
uni.navigateTo({
url:"/pages/purchase/newAgr",
events:{update:()=>{ this.clean();this.search() }}
})
},
} }
} }
</script> </script>

12
pages/purchase/apply.vue

@ -125,7 +125,7 @@
<view class="title_mast" data-type="审核中">申请状态</view> <view class="title_mast" data-type="审核中">申请状态</view>
</view> </view>
<button class="cu-btn round bg-green shadow submit">确定提交</button> <button class="cu-btn round bg-green shadow submit" @click="submit">确定提交</button>
</view> </view>
</template> </template>
<script> <script>
@ -152,7 +152,15 @@ export default {
showCancel:false, showCancel:false,
}) })
} }
} },
async submit(){
var res=await request("/api/purchase/applicantStatus",{
params:{
status:2,
purchaseId:"",
}
})
},
} }
} }
</script> </script>

107
pages/purchase/newAgr.vue

@ -11,31 +11,118 @@
</style> </style>
<template> <template>
<view class="container"> <view class="container">
<u-form class="card inline" labelWidth="auto" :model="formData" :rules="rules"> <u-form class="card inline" labelWidth="auto" :model="formData" :rules="rules" ref="form">
<d-form v-for="(v,k) in fields" :key="k" v-bind="v" :field="k" :required="!!rules[k]"/> <d-form
v-for="(v,k) in fields"
:key="k"
v-bind="v"
:field="k"
:required="!!rules[k]"
@input="formData[k]=$event"
@select="fields[k].value=$event.value.map(v=>v.value);formData[k]=$event.value.slice(-1)[0].value"/>
</u-form> </u-form>
<button class="cu-btn round bg-green shadow submit">保存</button> <button class="cu-btn round bg-green shadow submit" @click="submit">保存</button>
</view> </view>
</template> </template>
<script> <script>
import request from '@/common/request'
export default { export default {
data(){ data(){
return{ return{
fields:{ fields:{
name:{label:"物品名称"}, goodsName:{label:"物品名称"},
unit:{label:"物品单位",type:"select"}, massUnits:{label:"物品单位",type:"select",columns:[],value:[]},
type:{label:"物品类型",type:"select"}, goodsType:{label:"物品类型",type:"select",columns:[],value:[]},
supplier:{label:"供应商"}, supplier:{label:"供应商"},
detailedType:{label:"详情类型",type:"select",columns:[],value:[]},
remarks:{label:"备注",type:"textarea"}, remarks:{label:"备注",type:"textarea"},
}, },
formData:{name:""}, formData:{
goodsName:"",
massUnits:"",
goodsType:"",
supplier:"",
detailedType:"",
remark:"",
},
rules:{ rules:{
name:{required:true, message:"物品名称必填!", trigger:"blur"}, goodsName:{required:true, message:"物品名称必填!", trigger:"blur"},
unit:{required:true, message:"物品单位必选!", trigger:"blur"}, massUnits:{required:true, message:"物品单位必选!", trigger:"blur"},
type:{required:true, message:"物品类型必选!", trigger:"blur"}, goodsType:{required:true, message:"物品类型必选!", trigger:"blur"},
supplier:{required:true, message:"供应商必填!", trigger:"blur"}, supplier:{required:true, message:"供应商必填!", trigger:"blur"},
detailedType:{required:true, message:"详情类型必选!", trigger:"blur"},
},
eventChannel:null,
}
},
onLoad(options){
this.eventChannel=this.getOpenerEventChannel()
this.init()
},
methods:{
async init(){
var res=await request("/api/goods/units",{
method:"post",
params:{code:'mass_units'}
})
if(res.statu){
this.fields.massUnits.columns=[res.data.map(v=>({label:v.text,value:v.value}))]
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取物品单位下拉选项失败!",
showCancel:false,
})
}
var res=await request("/api/goods/units",{
method:"post",
params:{code:'goods_type'}
})
if(res.statu){
this.fields.goodsType.columns=[res.data.map(v=>({label:v.text,value:v.value}))]
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取物品类型下拉选项失败!",
showCancel:false,
})
}
var res=await request("/api/goods/categoryValue",{
method:"post",
params:{code:'B04'}
})
if(res.statu){
this.fields.detailedType.columns=[res.data]
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取物品类型下拉选项失败!",
showCancel:false,
})
} }
},
submit(){
this.$refs.form.validate().then(async valid=>{
if(valid){
var res=await request("/goods/goods/add",{
method:"post",
body: this.formData
})
if(res.statu){
this.eventChannel.emit("update")
uni.navigateBack()
}else{
uni.showModal({
title:"提示",
content:res.msg||"保存失败!",
showCancel:false,
})
}
}
})
} }
} }
} }

31
pages/purchase/specs.vue

@ -111,13 +111,13 @@
<view class="container"> <view class="container">
<view class="card fertilizer"> <view class="card fertilizer">
<view class="name"> <view class="name">
<text>化肥</text> <text>{{purchase.goodsName}}</text>
<text>中量元素水溶肥</text> <text>{{purchase.detailedType}}</text>
<text class="plant-jiantou_zuoyouqiehuan"/> <text class="plant-jiantou_zuoyouqiehuan"/>
</view> </view>
<view class="company"> <view class="company">
<text>云南云天化股份有限公司</text> <text>{{purchase.detailedParentName}}</text>
<text>微量元素肥</text> <text>{{purchase.supplier}}</text>
</view> </view>
</view> </view>
@ -153,14 +153,27 @@ import request from '@/common/request'
export default{ export default{
data(){ data(){
return{ return{
purchase:null,
} }
}, },
onLoad(){}, onLoad(options){
this.init(options.id)
},
methods:{ methods:{
async init(){ async init(id){
var res=await request("") var res=await request("/api/goods/goodsList",{
} params:{id}
})
if(res.statu && res.data.records[0]){
this.purchase=res.data.records[0]
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取农资详情失败!",
showCancel:false,
})
}
},
} }
} }
</script> </script>

4
uni.scss

@ -75,9 +75,9 @@ $uni-font-size-subtitle:26px;
$uni-color-paragraph: #3F536E; // 文章段落颜色 $uni-color-paragraph: #3F536E; // 文章段落颜色
$uni-font-size-paragraph:15px; $uni-font-size-paragraph:15px;
@import '@/components/colorui/main.css'; @import '@/common/main.css';
@import 'uview-ui/theme.scss'; @import 'uview-ui/theme.scss';
@import url('https://at.alicdn.com/t/c/font_3852037_4hl5eh2pi96.css'); @import url('https://at.alicdn.com/t/c/font_3852037_xtabq0losfb.css');
[class*=plant-]{ [class*=plant-]{
font-family: "plantMana" !important; font-family: "plantMana" !important;
font-size: 16px; font-size: 16px;

38
uni_modules/d-form/components/d-form/d-form.vue

@ -151,7 +151,7 @@
</u-input> </u-input>
<button v-if="btnText" @click="btnFun" class="cu-btn bg-green shadow">{{btnText}}</button> <button v-if="btnText" @click="btnFun" class="cu-btn bg-green shadow">{{btnText}}</button>
</view> </view>
<view v-if="type=='select'" class="plant-youbian" :class="{noData: !/^\d+$/.test(value[0])}" @click="show=true">{{pickerContent}}</view> <view v-if="type=='select'" class="plant-youbian" :class="{noData: !value[0]}" @click="show=true">{{pickerContent}}</view>
<u-upload v-if="type=='upImg'" :fileList="imgs" previewFullImage multiple :maxCount="num" @delete="delImg" @afterRead="afterRead"> <u-upload v-if="type=='upImg'" :fileList="imgs" previewFullImage multiple :maxCount="num" @delete="delImg" @afterRead="afterRead">
<view class="album"> <view class="album">
<text class="plant-paizhao">添加照片</text> <text class="plant-paizhao">添加照片</text>
@ -177,13 +177,14 @@
<view class="tip" v-if="tip">{{tip}}</view> <view class="tip" v-if="tip">{{tip}}</view>
</u-form-item> </u-form-item>
<!-- :defaultIndex="(value||[]).map(v=>v||0)" -->
<u-picker <u-picker
v-if="type=='select'" v-if="type=='select'"
:columns="columns" :columns="columns"
:show="show" :show="show"
keyName="label" keyName="label"
ref="picker" ref="picker"
:defaultIndex="(value||[]).map(v=>v||0)" :defaultIndex="pickerValue"
closeOnClickOverlay closeOnClickOverlay
@close="show=false" @close="show=false"
@cancel="show=false" @cancel="show=false"
@ -212,6 +213,7 @@
<script> <script>
import request,{host} from '@/common/request' import request,{host} from '@/common/request'
import {dataType} from 'black-knight/lib/config/tools'
function setPickerCol(columns, value, n){ function setPickerCol(columns, value, n){
if(columns.length<=0)return if(columns.length<=0)return
@ -221,6 +223,15 @@ import request,{host} from '@/common/request'
setPickerCol(columns[v].children, value, ++n) setPickerCol(columns[v].children, value, ++n)
} }
} }
function setPickerVal(columns, value){
if(dataType(columns,'array')){
for(var i=0;i<columns.length;i++){
if(columns[i].value==value[0])return [{...columns[i],_index:i}].concat(setPickerVal(columns[i].children, value.slice(1)))
}
return [null]
}
return []
}
export default{ export default{
props:{ props:{
@ -307,16 +318,17 @@ import request,{host} from '@/common/request'
if(this.type=='upImg')return this.value.map((v,index)=>({url:`${host(undefined,"/plant_manage/sys/common/static")}/${v}`,status:"success",index,type:'saved'})).concat(this.imgList.map((v,index)=>Object.assign(v,{index,type:'unsaved'}))) if(this.type=='upImg')return this.value.map((v,index)=>({url:`${host(undefined,"/plant_manage/sys/common/static")}/${v}`,status:"success",index,type:'saved'})).concat(this.imgList.map((v,index)=>Object.assign(v,{index,type:'unsaved'})))
return [] return []
}, },
pickerContent(){ pickerContent(){//
if(/^\d+$/.test(this.value[0])){ if(this.type=='select'){
if(/^\d+$/.test(this.value[1])){ return setPickerVal(this.columns[0], this.value).findLast(v=>v)?.label||`请选择${this.label}`
return this.columns[0][this.value[0]].children[this.value[1]].label
}else{
return this.columns[0][this.value[0]].label
}
}else{
return this.placeholder||`请选择${this.label}`
} }
return ''
},
pickerValue(){//
if(this.type=='select'){
return setPickerVal(this.columns[0], this.value).map(v=>v?._index||0)
}
return []
}, },
}, },
created(){ created(){
@ -365,8 +377,8 @@ import request,{host} from '@/common/request'
this.$emit('imgs',this.imgs.map(v=>({saved:v.url,unsaved:v.tempUrl})[v.type]).join(',')) this.$emit('imgs',this.imgs.map(v=>({saved:v.url,unsaved:v.tempUrl})[v.type]).join(','))
}, },
pickerChange(e){ pickerChange(e){
if(e.value[e.columnIndex]?.children?.length>0){ if(e.value[e.columnIndex].hasOwnProperty('children')){
this.$refs.picker.setColumnValues(e.columnIndex+1,e.value[0].children) this.$refs.picker.setColumnValues(e.columnIndex+1,e.value[0].children||[])
} }
}, },
}, },

Loading…
Cancel
Save