MateriaItemList.vue 6.4 KB
<template>
  <a-card :bordered="false">
    <!-- 抽屉 -->
    <a-drawer
      title="库存详情(注:关联的物料只会显示有库存的)"
      :width="screenWidth"
      @close="onClose"
      :visible="visible"
    >
      <!-- 抽屉内容的border -->
      <div
        :style="{
          padding:'10px',
          border: '1px solid #e9e9e9',
          background: '#fff',
        }">
        <div class="table-page-search-wrapper">
          <a-form layout="inline" :form="form">
            <a-form-item label="物料名称:" :labelCol="{span: 6}" :wrapperCol="{span: 14, offset: 1}">
              <a-input  v-model="queryParam.materialname" disabled></a-input>
            </a-form-item>
          </a-form>
        </div>

        <div>
          <a-table
            ref="table"
            rowKey="id"
            size="middle"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            @change="handleTableChange"
            :rowClassName="getRowClassname"
          >
            <span  v-if="view" slot="action" slot-scope="text, record">
              <a-popconfirm v-has="'bom:lock'" title="确定绑定吗?" @confirm="() => handleBind(record)">
                <a>绑定</a>
              </a-popconfirm>
              <a-divider v-has="'bom:lock'" type="vertical"/>
              <a-popconfirm  v-has="'bom:unlock'" title="确定解绑吗?" @confirm="() => handleUnbind(record)">
                <a>解绑</a>
              </a-popconfirm>
            </span>
           <span slot="tradeNum" slot-scope="qty">
              {{ numFormat(qty) }}
           </span>
          </a-table>
        </div>
      </div>
    </a-drawer>
    <dict-item-modal ref="modalForm" @ok="modalFormOk"></dict-item-modal> <!-- 字典数据 -->

  </a-card>

</template>

<script>
import pick from 'lodash.pick'
import { filterObj } from '@/utils/util'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { locking, unlock} from '@/api/api'
export default {
  name: 'DictItemList',
  mixins: [JeecgListMixin],
  data() {
    return {
      columns: [
        {
          title: '物料编码',
          align: 'center',
          dataIndex: 'materialcode'
        },
        {
          title: '库位编码',
          align: 'center',
          dataIndex: 'locationcode',
        },
        {
          title: '容器编码',
          align: 'center',
          dataIndex: 'containercode'
        }, {
          title: '工作令',
          align: 'center',
          dataIndex: 'moCode'
        }, {
          title: '批号',
          align: 'center',
          dataIndex: 'lot'
        }
        , {
          title: '锁定',
          align: 'center',
          dataIndex: 'lockqty'
        },

        {
          title: '库存',
          align: 'center',
          dataIndex: 'qty',
          scopedSlots: {
            customRender: 'tradeNum'
          }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align:"center",
          fixed:"right",
          width:147,
          scopedSlots: { customRender: 'action' },
        }

      ],
      queryParam: {
        materialcode: '',
        materialname:''
      },
      title: '操作',
      visible: false,
      params:{
        workOrder:'',
        bomCode:'',
        bnum:'',
        inventoryId:''
      },
      screenWidth: 800,
      model: {
      },
      materialcode: '',
      materialname: '',
      view:false,
      labelCol: {
        xs: { span: 5 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 12 },
        sm: { span: 12 }
      },
      form: this.$form.createForm(this),
      validatorRules: {
        itemText: { rules: [{ required: true, message: '请输入名称!' }] },
        itemValue: { rules: [{ required: true, message: '请输入数据值!' }] }
      },
      url: {
        list: '/wmsInventory/wmsInventory/invList',
      },
    }
  },
  created() {
    // 当页面初始化时,根据屏幕大小来给抽屉设置宽度
    this.resetScreenSize()
  },
  methods: {
    edit(record,workNo,flag) {
      if(record.qty=="0"){
        this.$message.error("无库存")
        return false
      }
      this.form.resetFields()
      this.model = Object.assign({}, record)
      if (workNo!=''){
        this.queryParam.materialcode = record.cno
        this.params.workOrder = workNo;
        this.params.bnum = record.bnum;
        this.view = true;
      }else{
        this.queryParam.materialcode = record.code
      }
      if (flag=='1'){
        this.view = false;
      }
      this.queryParam.materialname = record.name+'          总库存:'+this.numFormat(record.qty)
      this.visible = true

      // 当其它模块调用该模块时,调用此方法加载字典数据
      this.loadData()
    },
    handleBind(data){
      // let params = {
      //   "workOrder": this.workNo,
      //   "bomCode":data.materialcode,
      //   "bnum":this.bnum,
      // }
      this.params.bomCode = data.materialcode;
      locking(this.params).then((res)=>{
        if (res.success){
          this.$message.success(res.result);
          this.searchReset();
        }else {
          this.$message.warning(res.message);
        }
      });
    },
    handleUnbind(data){
      // let params = {
      //   "workOrder": this.workNo,
      //   "bomCode":data.materialcode,
      //   "bnum":this.bnum,
      //   "inventoryId":data.id
      //
      // }
      this.params.bomCode = data.materialcode;
      this.params.inventoryId = data.id;
      unlock(this.params).then((res)=>{
        if (res.success){
          this.$message.success(res.result);
          this.searchReset();
        }else {
          this.$message.warning(res.message);
        }
      });
    },
    numFormat(qty){
      if(qty==undefined){
        return '';
      }else{
        return  parseFloat(qty).toFixed(1);
      }
    },


    onClose() {
      this.visible = false
      this.form.resetFields()
      this.dataSource = []
    },

  }
}
</script>
<style lang="less" scoped>
//update--begin--autor:wangshuai-----date:20191204------for:系统管理 数据字典禁用和正常区别开,添加背景颜色 teambition JT-22------
/deep/ .data-rule-invalid {
  background: #f4f4f4;
  color: #bababa;
}

//update--begin--autor:wangshuai-----date:20191204------for:系统管理 数据字典禁用和正常区别开,添加背景颜色 teambition JT-22------
</style>