Browse Source

新增农资 供应商搜索页面

master
邓宏 2 years ago
parent
commit
5e71eac612
  1. 10
      pages/purchase/newAgr.vue
  2. 61
      pages/purchase/search.vue
  3. 6
      pages/stock/list.vue
  4. 11
      router/purchase.js
  5. 2
      uni.scss
  6. 6
      uni_modules/d-form/components/d-form/d-form.vue
  7. 86
      uni_modules/d-picker/components/d-picker/d-picker.vue

10
pages/purchase/newAgr.vue

@ -11,13 +11,14 @@
</style> </style>
<template> <template>
<view class="container"> <view class="container">
<u-form class="card inline" labelWidth="auto" :model="formData" :rules="rules" ref="form"> <u-form class="card inline" errorType="toast" labelWidth="auto" :model="formData" :rules="rules" ref="form">
<d-form <d-form
v-for="(v,k) in fields" v-for="(v,k) in fields"
:key="k" :key="k"
v-bind="v" v-bind="v"
:field="k" :field="k"
:required="!!rules[k]" :required="!!rules[k]"
:value="/^select$/.test(v.type)?fields[k].value:formData[k]"
@input="formData[k]=$event" @input="formData[k]=$event"
@select="fields[k].value=$event.value.map(v=>v.value);formData[k]=$event.value.slice(-1)[0].value"/> @select="fields[k].value=$event.value.map(v=>v.value);formData[k]=$event.value.slice(-1)[0].value"/>
</u-form> </u-form>
@ -34,7 +35,12 @@ export default {
goodsName:{label:"物品名称"}, goodsName:{label:"物品名称"},
massUnits:{label:"物品单位",type:"select",columns:[],value:[]}, massUnits:{label:"物品单位",type:"select",columns:[],value:[]},
goodsType:{label:"物品类型",type:"select",columns:[],value:[]}, goodsType:{label:"物品类型",type:"select",columns:[],value:[]},
supplier:{label:"供应商"}, supplier:{label:"供应商",btnIcon:"plant-sousuo", btnFun:()=>{
uni.navigateTo({
url:`/pages/purchase/search?data=${this.formData.supplier}`,
events:{update:e=>this.formData.supplier=e||this.formData.supplier}
})
}},
detailedType:{label:"详情类型",type:"select",columns:[],value:[]}, detailedType:{label:"详情类型",type:"select",columns:[],value:[]},
remarks:{label:"备注",type:"textarea"}, remarks:{label:"备注",type:"textarea"},
}, },

61
pages/purchase/search.vue

@ -0,0 +1,61 @@
<style lang="scss">
.container{
height:100%;
background:#f6f6f6;
scroll-view{
flex-grow: 1;
height:1rpx;
background:#fff;
view{
color:#777;
padding:20rpx 30rpx;
border-bottom:1rpx solid rgba(221, 221, 221, 0.5);
}
}
}
</style>
<template>
<view class="container flex">
<d-search v-model="searchVal" @search="search"/>
<scroll-view scroll-y>
<view v-for="(v,k) in list" :key="k" @click="select(v)">{{v}}</view>
</scroll-view>
</view>
</template>
<script>
import request from '@/common/request'
export default {
data(){
return{
searchVal:"",
list:[],
eventChannel:null,
}
},
onLoad(options){
this.eventChannel=this.getOpenerEventChannel()
this.searchVal=options.data
this.search()
},
methods:{
async search(){
var res=await request("/api/goods/supplierShow",{
params:{supplier: this.searchVal}
})
if(res.statu){
this.list=res.data
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取供应商列表失败!",
showCancel:false,
})
}
},
select(e){
this.eventChannel.emit("update",e)
uni.navigateBack()
}
}
}
</script>

6
pages/stock/list.vue

@ -220,8 +220,8 @@ export default{
fields:{ fields:{
inOutType:{label:"库类型",type:"select",columns:[],value:[]}, inOutType:{label:"库类型",type:"select",columns:[],value:[]},
inOutBatchNo:{label:"库批次号",btnText:"生成",btnFun:()=>this.formData.inOutBatchNo=`${({in:'RK',out:'CK'})[this.mode]}${new Date().format('yyyyMMdd')}${new Date().getTime()}`}, inOutBatchNo:{label:"库批次号",btnText:"生成",btnFun:()=>this.formData.inOutBatchNo=`${({in:'RK',out:'CK'})[this.mode]}${new Date().format('yyyyMMdd')}${new Date().getTime()}`},
pic:{label:"库凭证",type:"upImg",value:"",num:3},
number:{label:"库数量",placeholder:"请输入采购数量"}, number:{label:"库数量",placeholder:"请输入采购数量"},
pic:{label:"库凭证",type:"upImg",value:"",num:3},
}, },
formData:{ formData:{
inOutType:"", inOutType:"",
@ -234,10 +234,6 @@ export default{
rules:{ rules:{
inOutType:{required:true}, inOutType:{required:true},
inOutBatchNo:{required:true}, inOutBatchNo:{required:true},
// pic:{required:true,validator(rule,val,call){
// if(!this.fields.pic.value)call(new Error(""));
// else call()
// }},
number:{required:true,validator(rule,val,call){ number:{required:true,validator(rule,val,call){
if(!val)call(new Error(`请输入${({in:'入',out:'出'})[this.mode]}库数量!`)); if(!val)call(new Error(`请输入${({in:'入',out:'出'})[this.mode]}库数量!`));
else if(this.mode=='out' && val>this.detail.equivalentInventory)call(new Error(`${({in:'入',out:'出'})[this.mode]}库数量不能大于库存数量!`)); else if(this.mode=='out' && val>this.detail.equivalentInventory)call(new Error(`${({in:'入',out:'出'})[this.mode]}库数量不能大于库存数量!`));

11
router/purchase.js

@ -74,4 +74,15 @@ module.exports=[
} }
} }
}, },
{
path:"pages/purchase/search",
style:{
navigationBarTitleText:"查询列表",
navigationBarBackgroundColor:"#10C176",
navigationBarTextStyle:"white",
"app-plus":{
titleNView:true
}
}
},
] ]

2
uni.scss

@ -77,7 +77,7 @@ $uni-font-size-paragraph:15px;
@import '@/common/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_xnap1h9v4h.css'); @import url('https://at.alicdn.com/t/c/font_3852037_uelrk7bjj2.css');
[class*=plant-]{ [class*=plant-]{
font-family: "plantMana" !important; font-family: "plantMana" !important;
font-size: 16px; font-size: 16px;

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

@ -214,7 +214,7 @@
<u-input :placeholder="placeholder||`请输入${label}`" :type="type" :disabled="disabled" :value="value" @input="$emit('input',$event)" @blur="/^number$|^digit$/.test(type) && $emit('input', parseFloat($event)||'')"> <u-input :placeholder="placeholder||`请输入${label}`" :type="type" :disabled="disabled" :value="value" @input="$emit('input',$event)" @blur="/^number$|^digit$/.test(type) && $emit('input', parseFloat($event)||'')">
<text v-if="suffix" slot="suffix">{{suffix}}</text> <text v-if="suffix" slot="suffix">{{suffix}}</text>
</u-input> </u-input>
<button v-if="btnText" @click="btnFun" class="cu-btn bg-green shadow">{{btnText}}</button> <button v-if="btnText || btnIcon" @click="btnFun" class="cu-btn bg-green shadow" :class="btnIcon">{{btnText}}</button>
</view> </view>
<view v-else-if="type=='map'" class="map plant-dingweixiao" :class="{noData:value.length<=0}" @click="openMap">{{value.length>0?Object.values(value[0]).join():"选择经纬度"}}</view> <view v-else-if="type=='map'" class="map plant-dingweixiao" :class="{noData:value.length<=0}" @click="openMap">{{value.length>0?Object.values(value[0]).join():"选择经纬度"}}</view>
<view v-else-if="type=='select'" class="plant-youbian" :class="{noData: !value[0]}" @click="show=true">{{pickerContent}}</view> <view v-else-if="type=='select'" class="plant-youbian" :class="{noData: !value[0]}" @click="show=true">{{pickerContent}}</view>
@ -354,6 +354,10 @@ import {computeArea} from '@/common/utils'
type:String, type:String,
default:"", default:"",
}, },
btnIcon:{
type:String,
default:""
},
btnFun:{ btnFun:{
type:Function, type:Function,
default:()=>{} default:()=>{}

86
uni_modules/d-picker/components/d-picker/d-picker.vue

@ -5,10 +5,39 @@
display:flex; display:flex;
justify-content: space-between; justify-content: space-between;
padding:10rpx; padding:10rpx;
align-items: center;
&>.search{
flex-grow: 1;
margin:6rpx 20rpx;
border:1rpx solid rgba(221, 221, 221, 0.5);
border-radius: 40rpx;
display:flex;
align-items: center;
input{
flex-grow: 1;
height:50rpx;
}
.plant-zengjia{
flex-shrink: 0;
color:#999;
transform: rotate(45deg);
}
}
&>button{
flex-shrink: 0;
}
} }
picker-view{ picker-view{
height:500rpx; height:500rpx;
&/deep/ .mask{
height:60rpx;
}
&/deep/ .item{
height:60rpx;
line-height: 60rpx;
text-align: center;
}
} }
} }
} }
@ -17,48 +46,65 @@
<u-popup class="dPicker" :show="show" @close="show=false"> <u-popup class="dPicker" :show="show" @close="show=false">
<view class="btns"> <view class="btns">
<button class="cu-btn sm" @click="show=false">取消</button> <button class="cu-btn sm" @click="show=false">取消</button>
<button class="cu-btn sm bg-green" @click="$emit('select',list[sureVal]);show=false">确定</button> <view class="search">
<u-icon name="search" color="#999" size="20"/>
<input auto-blur placeholder="搜索内容" v-model="searchVal"/>
<text class="plant-zengjia" v-if="!!searchVal" @click="searchVal=''"/>
</view> </view>
<picker-view :value="[value]" indicator-style="height:90rpx;" @change="changeVal=$event.detail.value[0]"> <button class="cu-btn sm bg-green" @click="$emit('select',list[changeVal]);show=false">确定</button>
</view>
<picker-view :value="[value]" indicator-class="mask" @change="changeVal=$event.detail.value[0]">
<picker-view-column> <picker-view-column>
<slot v-for="(v) in list" :row="v"/> <template v-for="(v,k) in list">
<view class="item" :key="k" v-if="!searchVal || (new RegExp(searchVal,'i')).test(v)">{{v}}</view>
</template>
</picker-view-column> </picker-view-column>
</picker-view> </picker-view>
</u-popup> </u-popup>
</template> </template>
<script> <script>
import {dataType} from 'black-knight/lib/config/tools' import request from '@/common/request'
export default{ export default{
props:{ props:{
list:{
type:Array,
default:()=>[]
},
value:{
type:[Number],
default:0,
},
}, },
data(){ data(){
return{ return{
show:false, show:false,
changeVal:null, changeVal:0,
} searchVal:"",
}, list:[],
computed:{
sureVal(){
return dataType(this.changeVal,'number')?this.changeVal:this.value
} }
}, },
watch:{ watch:{
show(n){ show(n){
if(!n){ if(!n){
this.changeVal=null this.changeVal=0
} }
}, },
}, },
methods:{ methods:{
open(e){
this.searchVal=e
this.show=true
this.list=[]
this.search()
},
async search(){
var res=await request("/api/goods/supplierShow",{
params:{supplier: ''}
})
if(res.statu){
this.changeVal=0
this.list=res.data
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取供应商列表失败!",
showCancel:false,
})
}
},
}, },
} }
</script> </script>

Loading…
Cancel
Save