hldy_app_mini/pages/procurement/material.vue

970 lines
22 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view>
<view class="serchs guodu" :style="tx?'':'width:95vw'">
<view class="ipt">
<input type="text" placeholder="物料名称/物料编码/物料简拼" v-model="form.wlParamInfo" @confirm="search" />
<image src="/static/index/procurement/x.png" mode="aspectFill" v-if="form.wlParamInfo"
@click="search(0)"></image>
</view>
<view @click="search" class="scr guodu">
<image src="/static/index/procurement/sh.png" mode="aspectFill" class="sh"></image>
<image src="/static/index/procurement/shr.png" mode="aspectFill" class="shr"></image>
检索
</view>
<view class="shx guodu" @click="ification=true">
<image src="/static/index/procurement/sx.png" mode="aspectFill"></image>
筛选
</view>
<view class="shx guodu" @click="chongzhi"
v-if="form.categoryId!=''||form.wlParamInfo!=''||form.suppliers!=''">
<image src="/static/index/procurement/cz.png" mode="aspectFill"></image>
重置
</view>
<view class="back guodu" @click="uni.navigateBack()">
<image src="/static/index/procurement/bk.png" mode="aspectFill"></image>
返回
</view>
</view>
<view class="kcyj">
<view class="kjlt" @click="tx=!tx">
库存预警
</view>
<scroll-view scroll-x="true" class="kcscrol guodu"
:style="tx?(qb?'width:46.4vw':'width:55.4vw') : (qb?'width:78.4vw':'width:86.4vw') "
scroll-with-animation :scroll-left="scrollleft" @scroll="onScroll" @scrolltolower="scrolltolower(1)">
<view class="yjbox" v-for="(v,i) in Material" :key="i" @click="clickaddcar(v,i)">
<image :src="v.materialImg?serverUrl+v.materialImg:'/static/index/procurement/k.png'"
mode="aspectFill"></image>
<view>{{v.materialName}}</view>
<text class="ytj" v-if="v.isAdd==1">已添加</text>
<text class="sl" >{{v.ljkcsl}}</text>
</view>
<defaultr cont="暂无数据" v-if="Material.length==0&&timeout" style="position: absolute;width: 10vw;height: 10vw;"></defaultr>
</scroll-view>
<view class="kjlt more guodu" :style="qb?'width:12.15vw':'' " @touchstart="ts" @touchmove="canmove" v-if="Material.length>0">
<view @click="qb=!qb;moredex=0;moveleft()" class="righ0" >
{{!qb?'更多':'收起'}}
<image class="guodu" :style="qb?'transform: rotate(180deg);':''"
src="/static/index/procurement/zjt.png" mode="aspectFill"></image>
</view>
<view class="guodu" :class="qb?(moredex==1?'avt':''):'righ0'" @click="moredex=1;Invenshow=true">查看全部
</view>
<view class="guodu" :class="qb?(moredex==2?'avt':''):'righ0'" @click="moredex=2">添加全部</view>
</view>
<view class="kaprght guodu">
<view class="ksfw guodu" :style="tx?'':'right: -38vw !important;'">
<view class="lcar">
<image :src="'/static/index/procurement/k.png'" mode="aspectFill"></image>
<view class="nm">纸尿裤-拉拉裤纸拉拉裤纸拉拉裤纸拉拉裤纸</view>
</view>
<view class="rcar">
<view class="wul">物料采购</view>
<view class="tm">10:00 - 10:10</view>
<view class="zhxng">
<view>
<image src="/static/index/procurement/xz.png" mode="aspectFill"></image>
<text>协助执行</text>
</view>
<view>
<image src="/static/index/procurement/ap.png" mode="aspectFill"></image>
<text>王金福 / 李贵田</text>
</view>
</view>
<view class="shjs">
<view class="iacts">开始服务</view>
<view>服务结束</view>
</view>
<view class="jx">
<image src="/static/index/procurement/l0.png" mode="aspectFill"></image>
<text>待进行</text>
</view>
</view>
</view>
</view>
</view>
<view class="listcard">
<carditem :InvoicingList="InvoicingList" @addcartory="addcartory" @scrolltolower="scrolltolower"
:status="status" @crk="crk"></carditem>
</view>
<view class="fiedright">
<view @click="uni.navigateTo({ url:'/pages/procurement/materialcar' })">
<image src="/static/index/procurement/gc1.png" mode="aspectFill"></image>
<text v-if="carnum>0">{{carnum>99?'99+':carnum}}</text>
</view>
<view @click="uni.navigateTo({ url:'/pages/procurement/purchaseorder' })">
<image src="/static/index/procurement/cg.png" mode="aspectFill"></image>
</view>
</view>
<!-- num -->
<view class="mengban" style="z-index: 119;" v-if="addflag" @click="qk"></view>
<calculator :show="addflag" @jjnum="jjnum" :caigouobj="caigouobj" @colse="qk" @right="right"></calculator>
<!-- 筛选 -->
<view class="mengban" v-if="ification" @click="qk"></view>
<classification @confirm="confirm" :show="ification" :typenum="0" ref="classication"></classification>
<!-- more -->
<view class="mengban" v-if="Invenshow" @click="Invenshow = false;moredex=0"></view>
<Inventory @addcartory="addcartory" :show="Invenshow" :InvoicingList="Material" :status="statustory"
@tolower="scrolltolower(1)"></Inventory>
<view class="mengban" v-if="detailsshow" @click="detailsshow = false"></view>
<detail :InvoicingList="[caigouobj]" @addcartory="addcartory" :show="detailsshow"></detail>
<view class="mengban" v-if="crkflag" @click="crkflag = false"></view>
<inboundoutbound :crk="crkflag"></inboundoutbound>
<view class="mengban" v-if="moredex==2" @click="moredex=0"></view>
<addall :show="moredex==2" @back="moredex=0" @config="config"></addall>
</view>
</template>
<script setup lang="ts">
import { ref, onMounted, reactive, onBeforeUnmount, computed, nextTick, defineComponent, inject } from 'vue';
import { queryInvoicingList, queryWlInfoByWlId, addShoppingCartList, queryShoppingCartList,queryCgdWaringList } from './api/lunpan.js'
import { onShow, onLoad, onHide, onPageScroll } from "@dcloudio/uni-app"
import calculator from './components/calculator.vue'
import classification from './components/classification.vue'
import Inventory from './components/Inventory.vue'
import carditem from './components/carditem.vue'
import detail from './components/details.vue'
import inboundoutbound from './components/inboundoutbound.vue'
import addall from './components/addall.vue'
import defaultr from './components/default.vue'
const tx = ref(true)
const qb = ref(false)
const addflag = ref(false)
const ification = ref(false)
const Invenshow = ref(false)
const detailsshow = ref(false)
const crkflag = ref(false)
const addalls = ref(false)
const moredex = ref(0)
const InvoicingList = ref([]);
const caigouobj = ref({})
const status = ref('loadmore')
const statustory = ref('loadmore')
const scrolltop = ref(0)
const serverUrl = ref('')
const form = reactive({
nuId: uni.getStorageSync('nuId'),
pageNo: 1,
pageSize: 10,
categoryId: '',
typeId: '',
medicationId: '',
wlParamInfo: '',
isWaring: 0,
suppliers: ''
})
const warn = reactive({
nuId: uni.getStorageSync('nuId'),
pageNo: 1,
pageSize: 10,
categoryId: '',
typeId: '',
medicationId: '',
wlParamInfo: '',
isWaring: 1
})
const classication = ref<InstanceType<typeof ChildComponent>>()
const timeout = ref(false)
onLoad(() => {
setTimeout(()=>{
timeout.value = true
},500)
serverUrl.value = uni.getStorageSync('serverUrl') + '/sys/common/static/';
})
onShow(() => {
form.pageNo = 1;
warn.pageNo = 1;
Material.value = [];
InvoicingList.value = [];
moredex.value = 0;
shoppcar();
getWaringMaterial()
nextTick(() => {
chongzhi()
})
})
const Material = ref([])
const getWaringMaterial = () => {
console.log(warn)
queryCgdWaringList(warn).then(res => {
console.log(res.result)
res.result.records.forEach(item => {
item.zk = false;
item.scrollleft = 0;
})
Material.value.push(...res.result.records);
statustory.value = (res.result.total == Material.value.length ? 'nomore' : 'loadmore')
setout1.value = (res.result.total == Material.value.length ? false : true)
})
}
const config = () => {
form.pageNo = 1;
warn.pageNo = 1;
Material.value = [];
InvoicingList.value = [];
moredex.value = 0;
shoppcar();
queryInvo();
getWaringMaterial()
}
const startX = ref(0)
const ts = (e) => {
startX.value = e.touches[0].clientX
}
const savescrollleft = ref(0)
// 监听用户滚动
function onScroll(e : any) {
savescrollleft.value = e?.detail?.scrollLeft ?? 0
}
const scrollleft = ref(0)
const canmove = (e : any) => {
const moveX = e.touches[0].clientX
const diff = moveX - startX.value
// diff 为负值就是向左滑
if (diff < -60 && !qb.value) { // 👉 60px 阈值,随便改
qb.value = !qb.value;
moredex.value = 0;
// 这么写是解决这个组件的响应丢失的bug
scrollleft.value = savescrollleft.value + 95.99
setTimeout(() => {
scrollleft.value = savescrollleft.value + 96
}, 50)
}
if (diff > 60 && qb.value) { // 👉 60px 阈值,随便改
qb.value = !qb.value;
moredex.value = 0;
scrollleft.value = savescrollleft.value - 95.99
setTimeout(() => {
scrollleft.value = savescrollleft.value - 96
}, 50)
}
}
const moveleft = () => {
if (qb.value) {
scrollleft.value = savescrollleft.value + 95
setTimeout(() => {
scrollleft.value = savescrollleft.value + 96
}, 50)
} else {
scrollleft.value = savescrollleft.value - 95
setTimeout(() => {
scrollleft.value = savescrollleft.value - 96
}, 50)
}
}
const carnum = ref(0)
const shoppcar = () => {
let c = {
nuId: form.nuId,
pageNo: 1,
pageSize: 1
}
queryShoppingCartList(c).then(resr => {
carnum.value = resr.result.total
})
}
const setout1 = ref(true)
const setout2 = ref(true)
let times = null;
const scrolltolower = (t : number) => {
if (t == 1) {
if (setout1.value == false) { return }
setout1.value = false;
statustory.value = 'loading'
warn.pageNo++;
getWaringMaterial()
} else {
if (setout2.value == false) { return }
status.value = 'loading'
setout2.value = false;
form.pageNo++;
queryInvo()
}
// times = setTimeout(() => {
// setout.value = true
// }, 1000)
}
const qk = () => {
ification.value = false;
addflag.value = false;
}
const confirm = (e : any) => {
form.categoryId = e.categoryId;
form.typeId = e.typeId;
form.medicationId = e.medicationId;
form.suppliers = e.suppliers;
form.pageNo = 1;
InvoicingList.value = [];
queryInvo();
qk()
}
const chongzhi = () => {
form.categoryId = '';
form.typeId = '';
form.medicationId = '';
form.suppliers = '';
form.pageNo = 1;
form.wlParamInfo = '',
InvoicingList.value = [];
classication.value.typescroll(1, -1, {});
classication.value.qingkong();
classication.value.config();
}
const search = (x : number) => {
if (x === 0) { form.wlParamInfo = '' }
form.pageNo = 1;
InvoicingList.value = [];
queryInvo();
}
const queryInvo = () => {
queryInvoicingList(form).then(res => {
res.result.records.forEach(item => {
item.zk = false;
item.scrollleft = 0;
})
InvoicingList.value.push(...res.result.records);
status.value = (res.result.total == InvoicingList.value.length ? 'nomore' : 'loadmore')
setout2.value = (res.result.total == InvoicingList.value.length ? false : true)
})
}
const addcartory = (e : any) => {
// e把index覆盖了导致index永远是0
let index = caigouobj.value.index
caigouobj.value = e;
caigouobj.value.index = index
addflag.value = true;
}
const jjnum = (e : number) => {
let n = Number(caigouobj.value.upperLimit) - Number(caigouobj.value.kcsl)
if (n == caigouobj.value.Limitnum && e == 1) { return }
if (caigouobj.value.Limitnum == 1 && e == -1) { return }
caigouobj.value.Limitnum += e;
}
const right = (n : number, nm : any, type : Object) => {
// let d = Number(caigouobj.value.upperLimit)-Number(caigouobj.value.kcsl)
// if(d>=n){
// caigouobj.value.Limitnum = n;
// }else{
// caigouobj.value.Limitnum = d;
// }
// if(n<1){
// caigouobj.value.Limitnum = 1;
// }
connfig(nm, n, type)
}
const timers = ref(true)
const connfig = (nm : any, num : Number, type : Object) => {
if (timers.value == false) { return }
if (caigouobj.value.izEnabled == '1') {
uni.showToast({
icon: 'none',
title: '该物料已关闭,无法采购~'
})
return
}
timers.value = false;
let dt = {
nuId: form.nuId,
purchaseQuantity: num,
suppliersId: nm.id,
suppliersName: nm.name,
wlId: caigouobj.value.wlId,
kcsl: caigouobj.value.kcsl,
wlUnits: type.unit,
referenceUnitPrice: type.price,
dhbl: type.num
}
addShoppingCartList([dt]).then(res => {
uni.showToast({
icon: res.success ? 'success' : 'none',
title: res.message
})
setTimeout(() => {
timers.value = true;
if (res.success) {
addflag.value = false;
detailsshow.value = false;
shoppcar();
warn.pageNo = 1;
Material.value = [];
getWaringMaterial();
if (caigouobj.value.yj) {
Material.value[forthmenuIndex.value].isAdd = 1
} else {
caigouobj.value.isAdd = 1
}
}
}, 700)
})
}
// 双击事件
const forthmenuIndex = ref<number>(0);
const lastTap = ref(0)
// 双击的最大间隔ms可根据体验调整
const DOUBLE_TAP_DELAY = 300;
const setout = ref(null)
const clickaddcar = (v : any, i : number) => {
const now = Date.now()
forthmenuIndex.value = i
if (now - lastTap.value < DOUBLE_TAP_DELAY) {
// 双击成立
clearTimeout(setout.value)
if (v.isAdd == 1) {
return
} else {
caigouobj.value = v;
caigouobj.value.index = i;
caigouobj.value.yj = true;
addcartory(caigouobj.value)
}
// 重置,避免多次触发
lastTap.value = 0
} else {
setout.value = setTimeout(() => {
caigouobj.value = v;
caigouobj.value.index = i;
caigouobj.value.yj = true;
detailsshow.value = true;
}, DOUBLE_TAP_DELAY)
// 记录本次时间,等待下次点击
lastTap.value = now
}
}
const crk = (v, i) => {
crkflag.value = true
}
</script>
<style scoped lang="less">
.fiedright {
width: 5vw;
height: 12vw;
position: fixed;
z-index: 200;
right: 2vw;
bottom: 6vw;
display: flex;
flex-direction: column;
justify-content: space-between;
view {
width: 5vw;
height: 5vw;
background: rgba(255, 255, 255, 0.86);
border-radius: 50%;
border: 1px solid #D9DADC;
display: flex;
justify-content: center;
align-items: center;
position: relative;
text {
min-width: 1.8vw;
height: 1.8vw;
border-radius: 0.8vw;
border: 2px solid #E81D1D;
display: flex;
align-items: center;
justify-content: center;
padding: 0 0.5vw;
font-weight: 400;
font-size: 1.3vw;
color: #E81D1D;
position: absolute;
top: -0.8vw;
right: -0.8vw;
}
image {
width: 3.3vw;
height: 3.3vw;
}
}
}
.listcard {
width: 100%;
height: 70.3vh;
margin-top: 1vw;
.crdcroll {
width: 100%;
height: 100%;
display: grid;
grid-template-columns: 1fr 1fr;
}
}
.kcyj {
width: 100%;
height: 10vw;
display: flex;
margin-top: 1vw;
position: relative;
.kaprght {
width: 32vw;
height: 10vw;
margin-left: 0.6vw;
position: absolute;
right: 0;
bottom: 0;
.ksfw {
width: 100%;
height: 14.5vw;
background: rgba(255, 255, 255, 0.6);
border-radius: 1vw;
border: 1px solid #D9DADC;
padding: 0 1vw;
position: absolute;
bottom: 0;
right: 0;
overflow: hidden;
display: flex;
.lcar {
width: 12.7vw;
position: relative;
image {
width: 10vw;
height: 10vw;
margin: 1vw auto 0;
display: block;
}
.nm {
width: 100%;
height: 1.4vw;
font-weight: 400;
font-size: 1.3vw;
color: #212327;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
padding: 0 1vw;
}
}
.rcar {
width: 19vw;
position: relative;
>.jx {
width: 4.6vw;
height: 1.9vw;
position: absolute;
top: 1vw;
right: 1vw;
font-weight: 400;
font-size: 1.1vw;
display: flex;
justify-content: center;
align-items: center;
>image {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
z-index: 1;
}
>text {
position: relative;
z-index: 2;
color: #FFFFFF;
// margin-top: 2vw;
}
}
}
.shjs {
width: 100%;
margin-top: 0.8vw;
display: flex;
justify-content: space-around;
view {
width: 7.2vw;
height: 2.5vw;
background: #E4E9F4;
border-radius: 1.25vw;
font-weight: 400;
font-size: 1.1vw;
color: #333333;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid #E4E9F4;
}
.iacts {
background: rgba(168, 212, 255, .75);
border: 1px solid #A8D4FF;
color: #249BFA;
}
}
.zhxng {
width: 100%;
height: 2.8vw;
margin-top: 1vw;
display: flex;
padding: 1.1vw 0 1.1vw 0;
view {
display: flex;
align-items: center;
white-space: nowrap;
image {
width: 1.6vw;
height: 1.6vw;
margin-right: 0.3vw;
}
text {
font-weight: 400;
font-size: 1vw;
color: #555555;
margin-right: 0.5vw;
white-space: nowrap;
}
}
}
.wul {
width: 100%;
height: 1.5vw;
font-weight: bold;
font-size: 1.5vw;
color: #555555;
margin: 2vw auto 0;
}
.tm {
width: 100%;
height: 1.8vw;
font-size: 2.2vw;
font-weight: bolder;
color: #555555;
margin-top: 0.5vw;
}
}
}
.kjlt {
width: 3.2vw;
height: 10vw;
background: rgba(255, 255, 255, 0.5);
border-radius: 1.1vw;
writing-mode: vertical-rl;
align-items: center;
display: flex;
justify-content: center;
letter-spacing: 3px;
font-size: 1.4vw;
position: relative;
z-index: 100;
}
.more {
margin-left: 0.8vw;
position: relative;
background: RGBA(239, 240, 244, 1);
.righ0 {
right: 0 !important;
}
view {
writing-mode: vertical-rl;
align-items: center;
display: flex;
justify-content: center;
letter-spacing: 3px;
width: 3.2vw;
height: 10vw;
position: absolute;
top: 0;
border-radius: 1.1vw;
font-size: 1.4vw;
color: #888888;
background: #fff;
&:nth-child(1) {
letter-spacing: 6px;
padding-top: 2vw;
z-index: 5;
image {
width: 1.6vw;
height: 1.6vw;
margin-top: 10px;
}
}
&:nth-child(2) {
right: 4.2vw;
z-index: 3;
}
&:nth-child(3) {
right: 8.5vw;
z-index: 2;
}
}
.avt {
background: rgba(85, 166, 249, 1);
color: #FFFFFF;
}
}
.zkw {
width: 46.4vw !important;
}
.kcscrol {
width: 54.4vw;
height: 10vw;
white-space: nowrap;
margin-left: 0.6vw;
position: relative;
z-index: 99;
.yjbox {
display: inline-block;
width: 14vw;
height: 10vw;
background: rgba(255, 255, 255, 0.5);
border-radius: 1.1vw;
margin-right: 0.6vw;
position: relative;
.sl {
min-width: 1.5vw;
height: 1.8vw;
background: #E3EEF7;
border-radius: 0.9vw;
border: 1px solid rgba(3, 133, 250, 0.34);
font-weight: 400;
font-size: 1.1vw;
color: #1083F8;
text-align: center;
line-height: 1.75vw;
position: absolute;
padding: 0 1.6vw;
top: 0.8vw;
left: 0.8vw;
}
.ytj {
width: 4.5vw;
height: 1.8vw;
background: #E3EEF7;
border-radius: 0.9vw;
border: 1px solid rgba(3, 133, 250, 0.34);
font-weight: 400;
font-size: 1.1vw;
color: #1083F8;
text-align: center;
line-height: 1.75vw;
position: absolute;
top: 0.8vw;
right: 0.8vw;
}
image {
width: 7vw;
height: 7vw;
margin: 0.5vw auto 0.5vw;
display: block;
border-radius: 1vw;
}
>view {
width: 100%;
height: 1.4vw;
font-weight: 400;
font-size: 1.3vw;
color: #212327;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
padding: 0 1vw;
text-align: center;
}
}
}
}
.serchs {
width: 62vw;
height: 3.3vw;
border-radius: 1.6vw;
display: flex;
align-items: center;
margin-top: 0.7vw;
position: relative;
.ipt {
display: flex;
align-items: center;
width: 24.2vw;
background: #E2E4E9;
border-radius: 1.65vw;
height: 3.3vw;
image {
width: 2.2vw;
height: 2.2vw;
margin: 0 0.5vw;
}
input {
width: 25vw;
height: 3.3vw;
font-size: 1.4vw;
padding-left: 1.6vw;
}
}
.back {
width: 7.3vw;
height: 3.3vw;
border-radius: 1.6vw;
background: rgba(255, 255, 255, 1);
border-radius: 1.65vw;
font-weight: 400;
font-size: 1.4vw;
color: rgba(85, 85, 85, 1);
display: flex;
justify-content: center;
align-items: center;
position: absolute;
right: 0.5vw;
top: 0.2vw;
border: 1px solid #D9DADC;
image {
width: 1.5vw;
height: 1.3vw;
margin: 0 0.5vw 0 0;
}
}
.back:active,
.shx:active,
.scr:active {
color: #1083F8;
background: linear-gradient(-45deg, rgba(223, 244, 252, 1), rgba(204, 228, 249, 0.43));
border: 1px solid #1083F8;
}
.scr {
border-radius: 1.65vw;
font-weight: 400;
font-size: 1.4vw;
display: flex;
justify-content: center;
align-items: center;
width: 7.3vw;
height: 3.3vw;
margin: 0 0 0 0.7vw;
background: rgba(255, 255, 255, 0.6);
border: 1px solid #D9DADC;
color: #555555;
image {
width: 1.5vw;
height: 1.3vw;
margin: 0 0.5vw 0 0;
}
}
.shr {
display: none;
}
.scr:active .sh {
display: none;
}
.scr:active .shr {
display: inline-block;
}
.shx {
width: 7.3vw;
height: 3.3vw;
background: #FFFFFF;
border-radius: 1.65vw;
border: 1px solid #D9DADC;
font-weight: 400;
font-size: 1.4vw;
color: #222;
display: flex;
justify-content: center;
align-items: center;
margin: 0 0 0 0.7vw;
color: #555555;
image {
width: 1.5vw;
height: 1.3vw;
margin: 0 0.5vw 0 0;
}
}
}
.guodu {
transition: .4s;
-webkit-transform-style: preserve-3d;
-webkit-overflow-scrolling: touch;
}
.mengban {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
z-index: 100;
background: RGBA(239, 240, 244, 0.55);
}
</style>
<style>
page {
background: RGBA(239, 240, 244, 1);
padding: 2vw;
box-sizing: border-box;
}
</style>