Преглед на файлове

在快速补货中,长按货道可进入药品详情页,可进行库存矫正、下架、修改容量

lincl преди 3 години
родител
ревизия
aab945cc05

+ 55 - 0
mini-pro-web/src/directive/longpress.js

@ -0,0 +1,55 @@
//长按指令
export default {
    install(Vue, options = {
      time: 800
    }) {
      Vue.directive('longpress', {
        bind: function(el, binding, vNode) {
            console.log("longpress")
          // 确保提供的表达式是函数
          if (typeof binding.value !== 'function') {
            // 获取组件名称
            const compName = vNode.context.name;
            // 将警告传递给控制台
            let warn = `[longpress:] provided expression '${binding.expression}' is not afunction, but has to be `;
            if (compName) { warn += `Found in component '${compName}' `}
            console.warn(warn);
          }
          // 定义变量
          let pressTimer = null;
          // 定义函数处理程序
          // 创建计时器( 1秒后执行函数 )
          let start = (e) => {
            if (e.type === 'click' && e.button !== 0) {
              return;
            }
            if (pressTimer === null) {
              pressTimer = setTimeout(() => {
                // 执行函数
                handler(e);
              }, options.time)
            }
          }
          // 取消计时器
          let cancel = (e) => {
            // 检查计时器是否有值
            if ( pressTimer !== null ) {
              clearTimeout(pressTimer);
              pressTimer = null;
            }
          }
          // 运行函数
          const handler = (e) => {
            // 执行传递给指令的方法
            binding.value(e)
          };  
          // 添加事件监听器
          el.addEventListener("touchstart", start);
          // 取消计时器
          el.addEventListener("touchend", cancel);
          el.addEventListener("touchmove", cancel);
          el.addEventListener("touchcancel", cancel);
        }
      })
    }
  }

+ 3 - 0
mini-pro-web/src/main.js

@ -36,6 +36,9 @@ Vue.use(CustomComponents)
import CustomUpload from '@/components/CustomUpload'
Vue.component("CustomUpload", CustomUpload)
import longpress from '@/directive/longpress'
Vue.use(longpress)
new Vue({
	data: {
		imWs: null,

+ 24 - 2
mini-pro-web/src/views/replenishment/start/productDetail.vue

@ -7,7 +7,7 @@
            />
        </div>
        <div class="tc c-333 pt20 pb10 plr15 break-all">{{info.drugName}}</div>
        <div class="c-17b3ec tc" @click="gotoUrl('/drugList', {deviceId: info.idDevice})">更换药品</div>
        <div class="c-17b3ec tc"><span @click="gotoUrl('/drugList', {deviceId: info.idDevice})">更换药品</span></div>
        <div class=" tc pt20">
            <span class="mr10">现有数量:{{info.qty}} </span>
            <span class="ml10">货道容量:{{info.cargoCapacity}} </span>
@ -48,7 +48,10 @@ export default{
            setStockShow: false,
            info: '',
            bussiness: 1, //1修改容量 2矫正库存 3上下架
            drugId: ''
            drugId: '',
            drugName: '',
            drugPrice: '',
            from: this.$route.query.from,
        }
    },
    computed:{
@ -60,6 +63,8 @@ export default{
    created() {
        this.$EventBus.$on('drug-sel', data=>{
            this.drugId = data.id
            this.drugName = data.drugName
            this.drugPrice = data.price
            this.bussiness = 4
            this.setStockShow = true
        })
@ -118,6 +123,13 @@ export default{
                    this.$toast.clear()
                    this.$emitRefreshPage('replenishmentStartDeviceDetail')
                    this.$emitRefreshPage('replenishmentDeviceDetail')
                    if(this.from == 'quick'){
                        this.$emitRefreshPage('replenishmentStartQuick', {
                            data,
                            bussiness: bussiness || this.bussiness
                        })
                    }
                    if(bussiness==3){
                        this.$router.back()
                    } else {
@ -148,6 +160,16 @@ export default{
                    this.$emitRefreshPage('replenishmentStartDeviceDetail')
                    this.$emitRefreshPage('replenishmentDeviceDetail')
                    this.selectMediicinecabineInventoryById()
                    if(this.from == 'quick'){
                        this.$emitRefreshPage('replenishmentStartQuick', {
                            drugId: this.drugId,
                            drugName: this.drugName,
                            drugPrice: this.drugPrice,
                            data,
                            bussiness: 4
                        })
                        history.go(-1)
                    }
                })
                .catch(err=>{
                    console.error(err)

+ 52 - 4
mini-pro-web/src/views/replenishment/start/quick.vue

@ -40,7 +40,7 @@
                <template v-if="curItem">
                    <template v-for="(item, k) in curItem.list">
                        <div class="item" v-if="item.state!=20" :key="k">
                            <ProductItem bussuness="quick" @onChange="onChange($event, item)" :data="item" :index="k"/>
                            <ProductItem v-longpress="()=>{gotoDetail(item)}" bussuness="quick" @onChange="onChange($event, item)" :data="item" :index="k"/>
                        </div>
                    </template>
@ -64,7 +64,7 @@
import medicineAbinetApi from '@/api/api-medicineAbinet'
import ProductItem from '@/components/ProductItem'
export default{
    name: 'replenishmentStartDeviceDetail',
    name: 'replenishmentStartQuick',
    components: {
        ProductItem
    },
@ -74,6 +74,7 @@ export default{
            query: this.$route.query,
            selItemList: [],
            allNum: 0,
            curCargo: '',
            deviceInfo: {device: ''},
            deviceId: this.$route.query.deviceId,
@ -107,8 +108,46 @@ export default{
        // this.findDeviceById()
    },
    methods:{
        $refreshData(){
            this.findMediicinecabinetInventoryByDeviceId()
        $refreshData(p){
            if(p){
                var oQty = this.curCargo.cargoCapacity - this.curCargo.qty
                //1修改容量 2矫正库存 3下架药品  4更换药品
                switch(Number(p.bussiness)){
                    case 1: 
                        // 1修改容量
                    case 2: 
                        // 2矫正库存
                        if(p.bussiness==1){
                            this.curCargo.cargoCapacity = p.data
                        } else {
                            this.curCargo.qty = p.data
                        }
                        if(this.curCargo.qty > this.curCargo.cargoCapacity){
                            this.curCargo.qty = this.curCargo.cargoCapacity
                        }
                        if(this.curCargo.isActive){
                            this.allNum = this.allNum - oQty + (this.curCargo.cargoCapacity - this.curCargo.qty)
                        }
                        break;
                    case 3: 
                        // 3下架药品 
                        this.curCargo.shelfStatus = 0
                        this.curCargo.qty = 0
                        if(this.curCargo.isActive){
                            this.allNum = this.allNum - oQty + this.curCargo.cargoCapacity
                        }
                        break;
                    case 4: 
                        // 4更换药品
                        this.curItem.list.splice(this.curItem.list.indexOf(this.curCargo), 1)
                        if(this.curCargo.isActive){
                            this.allNum = this.allNum - oQty
                        }
                        break;
                }
            } else {
                this.findMediicinecabinetInventoryByDeviceId()
            }
        },
        initPage(){
            this.findMediicinecabinetInventoryByDeviceId()
@ -449,6 +488,15 @@ export default{
                    console.error(err)
                })
        },
        gotoDetail(item){
            if(item.shelfStatus==1){
                this.curCargo = item; 
                this.gotoUrl('./productDetail', {
                    id: item.id,
                    from: 'quick'
                })
            }
        }
    },
}
</script>