hldy_app_mini/pages/NursingNew/component/pleasetake/component/takehomep.vue

282 lines
6.8 KiB
Vue

<template>
<view>
<view class="buttons-father">
<view class="boxtwo">
<view class="ipt">
<input type="text" placeholder="物料名称/物料简拼" />
</view>
<view class="scr">
检索
</view>
<view class="shx" @click="ification = true">
<image src="/static/index/requestform/shaixuan.png" mode="aspectFill"></image>
<view class="shx-font">
筛选
</view>
</view>
<view class="shx" @click="chongzhi"
v-if="form.categoryId!=''||form.wlParamInfo!='' " >
<image src="/static/index/requestform/chongzhi.png" mode="aspectFill"></image>
<view class="shx-font">
重置
</view>
</view>
</view>
<view class="boxtwo flexend">
<view class="qlthbtn">
<image src="/static/index/requestform/ql0.png" mode="aspectFill"></image>
<view class="shx-font" @click="changePage(1)">
请领单
</view>
</view>
<view class="qlthbtn">
<image src="/static/index/requestform/ql1.png" mode="aspectFill"></image>
<view class="shx-font" @click="changePage(2)">
回退单
</view>
</view>
<view class="qlthbtn">
<image src="/static/index/requestform/ql2.png" mode="aspectFill"></image>
<view class="shx-font">
退货
</view>
</view>
</view>
</view>
<addwl :Material="addMaterial" @delall="delall" @del="adddel" @submit="submit"></addwl>
<carditem :InvoicingList="listarr" @scrolltolower="scrolltolower" :status="status" @comfig="comfig"></carditem>
<takeing :show="takeshow" :objtake="objtake" @fill="takeshow = false" @right="right"></takeing>
<cgdclass @confirm="confirm" :show="ification" :typenum="0" ref="classication" @fill="ification = false"></cgdclass>
<medetails :show="detaishow" @fill="detaishow = false" @confirm="confirm" :objtake="objtake"></medetails>
<tanchuang @back="tanshow = false" :show="tanshow" font="确定将该物料从本次请领清单中移除吗?" @right="del"></tanchuang>
<takerecord :objtake="objtake" :show="recordshow" @fill="recordshow = false"></takerecord>
<submits></submits>
</view>
</template>
<script setup lang="ts">
import { ref, onMounted, onBeforeUnmount, computed, nextTick, watch, reactive } from 'vue';
import { queryInvoicingList,wlzd,queryGwcInfo,addGwc ,deleteGwcWl,removeAllGwc} from '../api/api.js'
import addwl from '../common/addwl.vue';
import carditem from '../common/carditem.vue';
import takeing from '../common/takeing.vue';
import cgdclass from '../common/cgdclass.vue';
import medetails from '../common/medetails.vue';
import tanchuang from '../common/tanchuang.vue';
import takerecord from '../common/takerecord.vue';
import submits from '../common/submits.vue'
const form = reactive({
pageNo:1,
pageSize:10,
nuId:uni.getStorageSync('nuId'),
elderId:uni.getStorageSync('NUall').id,
wlParamInfo:'',
categoryId:'',
typeId:'',
medicationId:''
})
const takeshow = ref(false)
const ification = ref(false)
const detaishow = ref(false)
const tanshow = ref(false)
const recordshow = ref(false)
const classication = ref<InstanceType<typeof ChildComponent>>()
onMounted(()=>{
config()
wuliao()
console.log(uni.getStorageSync('NUall'))
})
const addMaterial = ref([])
const wuliao = () =>{
let obj = {
nuId:form.nuId,
elderId:form.elderId
}
queryGwcInfo(obj).then(res=>{
console.log(res)
addMaterial.value = res.result
})
}
const listarr = ref([])
const status = ref('loadmore')
const config = ()=>{
console.log(form)
queryInvoicingList(form).then(res=>{
res.result.records.forEach(item=>{
item.zk = false;
item.scrollleft = 0;
})
listarr.value.push(...res.result.records)
status.value = (res.result.total == listarr.value.length ? 'nomore' : 'loadmore')
console.log( listarr.value )
})
}
const scrolltolower = ( ) => {
if (status.value=='loading'||status.value=='nomore') { return }
status.value = 'loading';
form.pageNo++;
config()
}
const submit = ()=>{
}
const adddel = (v)=>{
console.log(v)
listarr.value.forEach(item=>{
if(item.wlId == v.wlId){
objtake.value = item
}
})
tanshow.value = true;
console.log(objtake.value)
}
const del = ()=>{
let obj = {
nuId:form.nuId,
elderId:form.elderId,
wlId:objtake.value.wlId
}
deleteGwcWl(obj).then(res=>{
if(res.success){
tanshow.value = false;
objtake.value.isAdd = null;
objtake.value.qlNum = null;
wuliao();
}else{
uni.showToast({
icon:'none',
title:res.message
})
}
})
}
const delall = () =>{
removeAllGwc({nuId:form.nuId, elderId:form.elderId}).then(res=>{
if(res.success){
wuliao();
listarr.value.forEach(item=>{
item.isAdd = null;
item.qlNum = null;
item.gwcId = null;
})
}else{
uni.showToast({
icon:'none',
title:res.message
})
}
})
}
const objtake = ref({})
const comfig=(v,i,t)=>{
console.log(v,i,t)
switch (t){
case 0:
objtake.value = v;
if(v.isAdd==1){
tanshow.value = true;
}else{
takeshow.value = true;
}
break;
case 1:
objtake.value = v;
recordshow.value = true;
break;
case 2:
objtake.value = v;
detaishow.value = true;
break;
case 3:
let obj = {
nuId:form.nuId,
elderId:form.elderId,
wlId:v.wlId,
izZd:v.zhiDingId?false:true
}
wlzd(obj).then(res=>{
console.log(obj,res)
if(res.success){
// objtake.value = v;
// objtake.value.zk = false;
// objtake.value.scrollleft = 0;
// objtake.value = v.zhiDingId?false:true;
// listarr.value.splice(i,1);
// listarr.value.unshift(v)
listarr.value = [];
form.pageNo = 1;
config()
}else{
uni.showToast({
icon:'none',
title:res.message
})
}
})
break;
default:
break;
}
}
const right = (e,v) =>{
let obj = {
kfId:v.id,
wlId:v.wlId,
qlNum:e,
nuId:form.nuId,
elderId:form.elderId
}
addGwc(obj).then(res=>{
console.log(res)
if(res.success){
takeshow.value = false;
v.isAdd = 1;
v.qlNum = e;
wuliao();
}else{
uni.showToast({
icon:'none',
title:res.message
})
}
})
}
const confirm = (e)=>{
form.categoryId = e.categoryId;
form.typeId = e.typeId;
form.medicationId = e.medicationId;
form.pageNo=1;
listarr.value = [];
config();
ification.value = false;
console.log(e)
}
const chongzhi=()=>{
form.categoryId = '';
form.typeId = '';
form.medicationId = '';
form.pageNo=1;
form.wlParamInfo= '',
listarr.value = [];
classication.value.typescroll(1,-1,{});
classication.value.qingkong();
classication.value.config();
}
const emit = defineEmits(['changePageNumber']) // 也可以用类型签名(见下面)
const changePage = (index:number) => {
emit('changePageNumber', index)
}
</script>
<style lang="less" scoped>
@import "../css/take.less";
</style>