Browse Source

修改农资出库、联调接口

master
邓宏 2 months ago
parent
commit
4d6c3aa7f7
  1. 3
      common/utils.js
  2. 147
      pages/home/index.vue
  3. 0
      pages/stock/inOut.vue
  4. 16
      pages/stock/mana.vue
  5. 376
      pages/stock/nzOut.vue
  6. 15
      router/stock.js
  7. 1
      uni_modules/d-form/components/d-form/d-form.vue

3
common/utils.js

@ -17,4 +17,7 @@ export var computeArea=function(val,reat){
latitude: latitude.min+latitude.len/2,
}
}
}
export const code=function(date=''){
return `${new Date(date).format('yyyyMMdd', new Date().format('yyyyMMdd'))}${new Date().format('hhmmss')}`
}

147
pages/home/index.vue

@ -113,77 +113,49 @@
}
}
}
&.mana{
width:calc(50% - 46rpx);
flex-shrink: 0;
margin-top:0;
.title{
color:#333;
font-size:32rpx;
display:flex;
align-items: center;
padding-bottom:24rpx;
border-bottom:2rpx solid #D8D8D8;
[class*=plant-]{
color:#10C176;
&.appMana{
&>._title{
&.line{
display: flex;
justify-content: space-between;
}
.more{
margin-left:auto;
color:#999;
font-size:24rpx;
margin-left:auto;
font-weight: normal;
}
}
.item{
display:flex;
align-items: center;
margin-top:24rpx;
color:#707070;
font-size:24rpx;
&:nth-child(2){ --c:235, 67, 118; }
&:nth-child(3){ --c:255, 195, 83; }
&:nth-child(4){ --c:16, 193, 118; }
&:before{
flex-shrink: 0;
content:" ";
width:20rpx;
height:20rpx;
border-radius: 50%;
background-image:radial-gradient(rgba(var(--c), 1) 2px,rgba(var(--c), 0.2) 2.5px);
margin-right:10rpx;
}
text{
&:nth-child(2){
margin-left:auto;
flex-shrink: 0;
.items{
display: flex;
flex-wrap: wrap;
margin-top:20rpx;
min-height: 120rpx;
&>view{
width:calc(100%/4);
display: flex;
flex-direction: column;
align-items: center;
&:nth-child(n+5){
margin-top:20rpx;
}
image{
width:76rpx;
height:76rpx;
// border-radius: 50%;
// box-shadow: 0 4rpx 6rpx rgba(0, 0, 0, 0.1);
}
text{
margin-top:10rpx;
color:#011A3C;
}
}
}
.u-empty{
min-height:auto;
}
&:first-child{
margin-right:calc(30rpx/2);
}
&:nth-child(2){
margin-left:calc(30rpx/2);
}
}
&.base{
margin-top:0;
background:linear-gradient(#fff,#F1FBF6);
._title{
display:flex;
align-items: center;
font-size:30rpx;
font-weight: bold;
&:before{
content:" ";
width:12rpx;
height:30rpx;
border-radius: 20rpx;
background:#10C176;
margin-right:14rpx;
}
.plant-jiantou_zuoyouqiehuan{
margin-left:auto;
color:#10C176;
@ -250,6 +222,20 @@
}
}
}
&>._title{
display:flex;
align-items: center;
font-size:30rpx;
font-weight: bold;
&:before{
content:" ";
width:12rpx;
height:30rpx;
border-radius: 20rpx;
background:#10C176;
margin-right:14rpx;
}
}
}
.u-popup{
@ -292,37 +278,31 @@
<text class="plant-bijibenjilutongxunlu"/>
<u-image v-for="(v,k) in (massif.images||[]).slice(0,5)" :style="{'--c':k==4&&massif.images.length-5>0?`'+${massif.images.length-5}'`:''}" :key="k" mode="aspectFill" width="56rpx" height="46rpx" radius="8rpx" :src="`${host}/${v}`">
<text slot="error" class="plant-xiaopangchetupianjiazaishibai"/>
<u-loading-icon slot="loading" color="#10c176"/>
</u-image>
<text class="link">>></text>
</view>
<text class="line"/>
<text class="PA-yingyong" @click="$u.route({url:'pages/home/app'})">应用</text>
<!-- <text class="PA-yingyong" @click="$u.route({url:'pages/home/app'})">应用</text> -->
<!-- <text class="plant-nongzi" style="margin-right:64rpx;" @click="$u.route({url:'pages/stock/mana'})">库存</text>
<text class="plant-caigou" @click="$u.route({url:'pages/purchase/apply'})">采购</text> -->
</view>
</view>
<view style="display:flex;">
<view class="card mana">
<view class="title">
<text class="plant-dikuaimianji"/> 地块管理 <text class="more" @click="$u.route({type:'switchTab',url:'pages/massif/index'})">更多>></text>
</view>
<view class="item" v-for="(v,k) in massif.plotList||[]" :key="k">
<text class="over">{{v.plotName}}</text> <text>{{v.realityArea}}</text>
</view>
<u-empty :show="(massif.plotList||[]).length<=0" text=" " width="70%" icon="/static/noData.png"/>
<view class="appMana card">
<view class="_title line">
应用管理
<text class="more" @click="$u.route({url:'pages/home/app'})">更多>></text>
</view>
<view class="card mana">
<view class="title">
<text class="plant-cangkuguanliguanli"/> 仓库管理 <text class="more" @click="$u.route({url:'pages/warehouse/mana'})">更多>></text>
<view class="items">
<view v-for="(v,k) in appList.slice(0,4)" :key="k" @click="toPage(v.url)">
<image :src="`${host}/${v.icon}`"/>
<text>{{v.name}}</text>
</view>
<view class="item" v-for="(v,k) in stockList" :key="k">
<text class="over">{{v.warehouseName}}</text> <text>{{v.warehouseVolume}}</text>
</view>
<u-empty :show="stockList.length<=0" text=" " width="60%" icon="/static/noData.png"/>
</view>
</view>
<view class="card base">
<view class="_title">
{{$store.state.baseInfo.name||'基地管理'}} <text class="plant-jiantou_zuoyouqiehuan" v-if="isAdmin" @click="show=true">切换基地</text>
@ -367,6 +347,7 @@ import request,{host} from '@/common/request'
baseIndex:"",
stockList:[],
adderss:{},
appList:[],//
}
},
computed:{
@ -389,6 +370,7 @@ import request,{host} from '@/common/request'
},
onLoad() {
this.getHeadImg()
this.getApp()
if(this.isAdmin){
this.getPlantBase()
}else{
@ -508,6 +490,23 @@ import request,{host} from '@/common/request'
}
}
},
async getApp(){
var res=await request("/api/application/queryRoleApplication")
if(res.statu){
this.appList=res.data.slice(0,4)
}else{
uni.showModal({
title:"提示",
content:res.msg||"保存失败!",
showCancel:false,
})
}
},
toPage(url){
uni.navigateTo({
url:`/${url}`.replace(/\/\//g,'/')
})
},
//
refreshPosition(){
uni.getLocation({

0
pages/stock/list.vue → pages/stock/inOut.vue

16
pages/stock/mana.vue

@ -156,7 +156,7 @@
<view class="num">
<text>库存量{{v.equivalentInventory||0}}{{v.packgeUnit}}</text>
<view class="btns" v-if="isWareMana">
<button class="cu-btn" :class="v.equivalentInventory>0?'out':'bg-gray'" @click="v.equivalentInventory>0 && toList('out',v)">出库</button>
<button class="cu-btn" :class="v.equivalentInventory>0?'out':'bg-gray'" @click="v.equivalentInventory>0 && toNzOut(v)">出库</button>
<button class="cu-btn in" @click="toList('in',v)">入库</button>
</view>
</view>
@ -242,9 +242,21 @@ export default {
}
}
},
toNzOut(val){
uni.navigateTo({
url:`/pages/stock/nzOut`,
events:{update:()=>{
this.clean()
this.search()
}},
success(res){
res.eventChannel.emit('detail', {...val})
}
})
},
toList(mode,val){
uni.navigateTo({
url:`/pages/stock/list?mode=${mode}&type=${this.searchVal.substanceType}&warehouseId=${this.searchVal.warehouseId||''}`,
url:`/pages/stock/inOut?mode=${mode}&type=${this.searchVal.substanceType}&warehouseId=${this.searchVal.warehouseId||''}`,
events:{update:()=>{
this.clean()
this.search()

376
pages/stock/nzOut.vue

@ -0,0 +1,376 @@
<style lang="scss">
.container{
min-height: 100%;
background:#F6F6F6;
padding:30rpx 0;
.card{
margin-top:0;
&>.title{
display:flex;
align-items: center;
justify-content: space-between;
text:nth-child(2){
color:#777;
}
}
.d-form /deep/{
&>.u-form-item{
position:relative;
.u-form-item__body__right__message{
position:absolute;
bottom:-10rpx;
}
}
}
}
&>.fertilizer{
&>.name{
display:flex;
align-items: center;
margin-bottom:14rpx;
text{
&.goods{
font-size:20rpx;
color:#fff;
background:#10C176;
border-radius: 7rpx;
min-width:80rpx;
padding:0 6rpx;
text-align: center;
height:40rpx;
line-height: 40rpx;
margin-right:16rpx;
box-sizing: border-box;
}
&.name{
margin-right:20rpx;
}
&.spec{
flex-shrink: 0;
margin-left:auto;
color:#777;
}
}
}
&>.company{
display:flex;
align-items: center;
text{
&.type{
flex-shrink: 0;
font-size:20rpx;
color:#FBA83C;
}
&.name{
margin-left:20rpx;
font-size:20rpx;
color:#707070;
}
&.specs{
margin-left:auto;
color:#FBA83C;
font-size:24rpx;
}
}
}
}
&>.specs{
.select{
flex-grow: 1;
height:80rpx;
line-height: 80rpx;
background:#F7F7F7;
border-radius: 24rpx;
padding:0 28rpx;
display:flex;
text{
color:#999;
&:first-child{
flex-grow: 1;
}
&:nth-child(2){
flex-shrink: 0;
transform: rotate(90deg);
}
}
}
.plant-xinjian{
color:#10C176;
border-radius: 24rpx;
margin-left:24rpx;
background:#E7FCF3;
height:80rpx;
line-height: 80rpx;
width:120rpx;
text-align: center;
box-shadow: 6rpx 6rpx 8rpx rgba(16,193,118,0.1);
}
.tip{
color:#FBA83C;
font-size:24rpx;
margin-top:12rpx;
}
}
&>.purchase{
.input{
display:flex;
background:#F7F7F7;
border-radius: 24rpx;
padding:20rpx;
input{
flex-grow: 1;
}
text{
color:#999;
line-height: 40rpx;
margin-left:20rpx;
}
}
}
.outBatch{
display: flex;
flex-direction: column;
justify-content: space-evenly;
&>view{
display: flex;
align-items: center;
justify-content: space-between;
font-size:22rpx;
&.name{
}
&.data{
text{
&:first-child{
color:#999;
}
&:nth-child(2){
color:#FBA83C;
}
}
}
}
}
}
</style>
<template>
<view class="container">
<view class="card fertilizer">
<view class="name">
<text class="goods">{{detail.agriculturalGoods}}</text>
<text class="name over">{{detail.substanceName}}</text>
<text class="spec">{{detail.specDescribe}}</text>
</view>
<view class="company">
<text class="type">{{detail.detailType}}</text>
<text class="name over">{{detail.supplierName}}</text>
<text class="specs">库存{{Math.round(detail.equivalentInventory*detail.unitNum*100)/100}} {{detail.unit}}</text>
</view>
</view>
<!-- <view class="card specs" v-if="formData.substanceType==1">
<view class="title">
<text>规格</text> <text>{{detail.specDescribe}}</text>
</view>
<view class="tip">库存{{detail.equivalentInventory}}{{detail.packgeUnit}}({{Math.round(detail.equivalentInventory*detail.unitNum*100)/100}}{{detail.unit}})</view>
</view> -->
<view class="card">
<u-form class="inline" :model="formData" ref="form" :rules="rules" labelWidth="auto">
<d-form label="出库批次号" field="outBatchNo" required :value="[formData.outBatchNo]" @select="selectOutBatch" type="select" custom :columns="[inBatchList]">
<template slot-scope="{row}">
<view class="outBatch">
<view class="name">
<text>{{row.substanceName}}</text> <text>入库日期{{row.operateTime}}</text>
</view>
<view class="data">
<text>入库批次{{row.inOutBatchNo}}</text> <text>剩余{{row.equivalentAmount}}{{row.unit}}</text>
</view>
</view>
</template>
</d-form>
<d-form label="出库类型" field="outType" required type="select" :columns="outType.list" :value="outType.value" @select="outType.value=$event.map(v=>v.value);formData.outType=outType.value.slice(-1)[0]"/>
<!-- 出库类型为领用出库 -->
<d-form label="领用人" type="select" v-if="formData.outType=='out01'" :columns="[reciveuser]" :value="[formData.reciveUserId]" @select="formData.reciveUserId=$event[0].value;formData.reciveUser=$event[0].label" required field="reciveUserId"/>
<!-- 农资出库出库类型为损坏出库 -->
<block v-if="formData.outType=='out02'">
<d-form label="金额" type="digit" required field="price" v-model="formData.price"/>
<d-form label="处理方式" type="select" :columns="[processMode]" :value="[formData.processMode]" @select="formData.processMode=$event[0].value" required field="processMode"/>
</block>
<d-form label="出库数量" field="equivalentAmount" required :suffix="detail.unit" :value="formData.equivalentAmount" @input="formData.equivalentAmount=$event" type="digit" @blur="outNum"/>
<d-form label="操作日期" field="operationTime" required type="calendar" v-model="formData.operateTime"/>
<d-form label="出库凭证`" type="upImg" :num="3" :value="formData.pic" @imgs="pic=$event"/>
</u-form>
</view>
<button class="cu-btn round bg-green shadow submit" @click="submit">确定</button>
</view>
</template>
<script>
import request from '@/common/request'
export default{
data(){
return{
detail:{},
recoveryBatch:{list:[],value:[],number:0,surplus:0},
outType:{list:[],value:[]},
pic:"",
processMode:[],//
reciveuser:[],//
inBatchList:[],//
formData:{
equivalentAmount:'',//
inOutId:"",
inventoryId:"",
operateTime:"",
outBatchNo:"",//
outType:"",
reciveUser:"",
reciveUserId:"",
surplus:"",
pic:[],
remark:"",
price:"",
processMode:"",
substanceType:1,
},
rules:{
outType:{required:true,validator:(rule,val,call)=>{
if(!val)call(new Error(`出库类型必填!`));
else call()
},trigger:['blur','change']},
outBatchNo:{required:true,validator:(rule,val,call)=>{
if(!val)call(new Error(`出库批次号必填!`));
else call()
},trigger:['blur','change']},
operateTime:{required:true,message:"请选择操作日期!",trigger:['blur','change']},
equivalentAmount:{required:true,validator:(rule,val,call)=>{
if(!(val>0))call(new Error(`请输入出库数量!`));
else call()
},type:"number",trigger:['blur','change']},
reciveUserId:{required:true,message:"请选择领用人!",trigger:['blur','change']},
price:{required:true, type:"number", message:"请输入金额!",tigger:['blur','change']},
processMode:{required:true, message:"请输入处理方式!",tigger:['blur','change']},
},
eventChannel:null,
}
},
onLoad(options){
this.eventChannel=this.getOpenerEventChannel()
this.eventChannel.on("detail", e=>{
this.detail=e
this.formData.inventoryId=e.inventoryId
})
this.init()
},
methods:{
async init(){
//
var res=await request("/common/api/dict/queryDictItemByDictCode",{
method:"post",
//product_
params: {dictCode: "out_type"}
})
if(res.statu){
this.outType.list=[res.data]
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取出库类型选项失败!",
showCancel:false,
})
}
//
var res = await request("/common/api/dict/queryDictItemByDictCode",{
method:"post",
params:{dictCode:"process_mode"}
})
if(res.statu){
this.processMode=res.data
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取买方类型选项失败!",
showCancel:false,
})
}
//
var res=await request("/api/plantPlot/queryBaseUserByBaseId",{
params:{baseId: this.$store.state.baseInfo.id}
})
if(res.statu){
this.reciveuser=res.data
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取领用人选项失败!",
showCancel:false,
})
}
//
var res=await request("/suyuan/Inventory/agriculturalInSurplus",{
params:{inventoryId: this.detail.inventoryId}
})
if(res.statu){
this.inBatchList=res.data.map(v=>({...v, label:v.substanceName, value:v.inOutBatchNo}))
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取出库批次号选项失败!",
showCancel:false,
})
}
},
submit(){
this.$refs.form.validate().then(async valid=>{
if(valid){
var res=await request("/suyuan/Inventory/agriculturalOutOperate",{
method:"post",
body:{
...this.formData,
pic:this.pic,
}
})
if(res.statu){
uni.navigateBack()
this.eventChannel.emit("update")
}else{
uni.showModal({
title:"提示",
content:res.msg||"保存失败!",
showCancel:false,
})
}
}
})
},
searchBuy(){
uni.navigateTo({
url:`/pages/massif/search?data=${this.formData.buyerName||''}`,
events:{update:e=>{
this.formData.buyerName=e.buyerName
this.formData.buyerAddress=e.address
this.formData.buyerType=e.buyerType[1]
this.buyerType.value=e.buyerType
}}
})
},
selectOutBatch([e]){
this.formData.outBatchNo=e.inOutBatchNo
this.formData.inOutId=e.id
this.formData.surplus=e.equivalentAmount
},
outNum(){
if(/\d/.test(this.formData.equivalentAmount)){
this.formData.equivalentAmount=Math.min(this.formData.equivalentAmount, this.formData.surplus)
}
},
},
}
</script>

15
router/stock.js

@ -30,10 +30,21 @@ module.exports=[
}
}
},
{//农资出库
path:"pages/stock/nzOut",
style:{
navigationBarTitleText:"出库",
navigationBarBackgroundColor:"#10C176",
navigationBarTextStyle:"white",
"app-plus":{
titleNView:true
}
}
},
{//出入库列表
path:"pages/stock/list",
path:"pages/stock/inOut",
style:{
navigationBarTitleText:"",
navigationBarTitleText:"出库",
navigationBarBackgroundColor:"#10C176",
navigationBarTextStyle:"white",
"app-plus":{

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

@ -705,6 +705,7 @@ import {computeArea} from '@/common/utils'
}else if(this.type=='text'&&typeof this.filter=='function'){
this.$emit("input",this.filter(e))
}
this.$emit("blur")
},
tapMap(e){
console.log(e,'----e-----')

Loading…
Cancel
Save