300 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			Vue
		
	
	
	
			
		
		
	
	
			300 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			Vue
		
	
	
	
<template>
 | 
						||
  <div class="app-container">
 | 
						||
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
 | 
						||
       <el-form-item label="所属区域" prop="areaId">
 | 
						||
            <el-cascader v-model="queryParams.areaId"
 | 
						||
                :options="treeOptions" :filterable="true" style="width: 240px;" :show-all-levels="false"
 | 
						||
                :props="{ 
 | 
						||
                emitPath: false,// 若设置 false,则只返回该节点的值,只返回最后选择的id
 | 
						||
                checkStrictly: false,//来设置父子节点取消选中关联,从而达到选择任意一级选项的目的
 | 
						||
                value:'id',label:'label'
 | 
						||
                }" clearable @change="handleAreaChange">
 | 
						||
            </el-cascader>
 | 
						||
        </el-form-item>
 | 
						||
        <el-form-item label="货品仓库" prop="warehouseId">
 | 
						||
            <el-select v-model="queryParams.warehouseId" clearable placeholder="请选择货品仓库" style="width: 100%;">
 | 
						||
                <el-option v-for="item in wareHouseOptions"
 | 
						||
                    :key="item.warehouseId"
 | 
						||
                    :label="item.warehouseName"
 | 
						||
                    :value="item.warehouseId"
 | 
						||
                ></el-option>
 | 
						||
            </el-select> 
 | 
						||
        </el-form-item> 
 | 
						||
        <el-form-item label="货品类别" prop="materialTypeIds">
 | 
						||
            <el-cascader v-model="queryParams.materialTypeIds"
 | 
						||
                :options="materialTreeOptions" :filterable="true" style="width: 240px" :show-all-levels="false"
 | 
						||
                :props="{  
 | 
						||
                multiple: true,
 | 
						||
                emitPath: false,// 若设置 false,则只返回该节点的值,只返回最后选择的id
 | 
						||
                checkStrictly: false,//来设置父子节点取消选中关联,从而达到选择任意一级选项的目的
 | 
						||
                value:'id',label:'categoryName' 
 | 
						||
                }" collapse-tags>
 | 
						||
            </el-cascader>
 | 
						||
        </el-form-item>
 | 
						||
        <el-form-item label="货品名称" prop="materialName">
 | 
						||
            <el-input 
 | 
						||
                v-model="queryParams.materialName"
 | 
						||
                placeholder="请输入货品名称"
 | 
						||
                clearable maxlength="30"
 | 
						||
                style="width: 240px" 
 | 
						||
            />
 | 
						||
        </el-form-item> 
 | 
						||
        <!-- <el-form-item label="条码" prop="barCode">
 | 
						||
            <el-input 
 | 
						||
                v-model="queryParams.barCode"
 | 
						||
                placeholder="请输入条码"
 | 
						||
                clearable maxlength="30"
 | 
						||
                style="width: 240px" 
 | 
						||
            />
 | 
						||
        </el-form-item>  -->
 | 
						||
              
 | 
						||
      <el-form-item>
 | 
						||
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
 | 
						||
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
 | 
						||
      </el-form-item>
 | 
						||
    </el-form>
 | 
						||
 | 
						||
    <el-row :gutter="10" class="mb8"> 
 | 
						||
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
 | 
						||
    </el-row>
 | 
						||
 | 
						||
    <el-table v-loading="loading" :data="tableListData" height="800">
 | 
						||
      <el-table-column label="序号" align="center" width="80" type="index">
 | 
						||
        <template slot-scope="scope">
 | 
						||
          <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
 | 
						||
        </template>
 | 
						||
      </el-table-column>
 | 
						||
      <el-table-column label="货品编码" align="center" prop="materialCode" :show-overflow-tooltip="true" />
 | 
						||
      <el-table-column label="货品类别" align="center" prop="materialTypeName" :show-overflow-tooltip="true"/>
 | 
						||
      <el-table-column label="货品名称" align="center" prop="materialName" :show-overflow-tooltip="true" />
 | 
						||
      <el-table-column label="计量单位" align="center" prop="unitName" :show-overflow-tooltip="true" width="120"/>
 | 
						||
      <el-table-column label="货品规格" align="center" prop="size" :show-overflow-tooltip="true" width="120"/> 
 | 
						||
      <el-table-column label="所属区域" align="center" prop="areaName" :show-overflow-tooltip="true" width="120"/> 
 | 
						||
      <el-table-column label="货品仓库" align="center" prop="warehouseName" :show-overflow-tooltip="true" width="120"/>
 | 
						||
      <el-table-column label="当前库存数" align="center" prop="materialNum" :show-overflow-tooltip="true" width="120"/>
 | 
						||
      <!-- <el-table-column label="库存金额" align="center" prop="totalPrice" :show-overflow-tooltip="true" width="120">
 | 
						||
        <template slot-scope="scope">
 | 
						||
          <span>{{ (scope.row.totalPrice/100).toFixed(2) }}</span>
 | 
						||
        </template>
 | 
						||
      </el-table-column> -->
 | 
						||
      <el-table-column label="最小库存" align="center" prop="minNum" :show-overflow-tooltip="true" width="120"/>
 | 
						||
      <el-table-column label="最大库存" align="center" prop="maxNum" :show-overflow-tooltip="true" width="120"/>
 | 
						||
      <el-table-column label="库存状态" align="center" prop="inventoryStatus" :show-overflow-tooltip="true" width="120">
 | 
						||
        <template slot-scope="scope">
 | 
						||
          <span v-if="scope.row.inventoryStatus==1">正常</span>
 | 
						||
          <span v-if="scope.row.inventoryStatus==2">即将缺货</span>
 | 
						||
          <span v-if="scope.row.inventoryStatus==3">超额</span>
 | 
						||
        </template>
 | 
						||
      </el-table-column>
 | 
						||
      <!-- <el-table-column label="总库存数" align="center" prop="totalNum" :show-overflow-tooltip="true" width="120"/> -->
 | 
						||
       <el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width">
 | 
						||
            <template slot-scope="scope"> 
 | 
						||
            <el-button
 | 
						||
                size="mini"
 | 
						||
                type="text" 
 | 
						||
                @click="handleUpdate(scope.row)" 
 | 
						||
            >配置库存</el-button>
 | 
						||
            <el-button
 | 
						||
                size="mini"
 | 
						||
                type="text" 
 | 
						||
                @click="handleView(scope.row)" 
 | 
						||
            >批次详情</el-button> 
 | 
						||
            </template>
 | 
						||
        </el-table-column>
 | 
						||
 | 
						||
    </el-table>
 | 
						||
 | 
						||
    <pagination
 | 
						||
      v-show="total>0"
 | 
						||
      :total="total"
 | 
						||
      :page.sync="queryParams.pageNum"
 | 
						||
      :limit.sync="queryParams.pageSize"
 | 
						||
      @pagination="getList"
 | 
						||
    />
 | 
						||
 | 
						||
    <!-- 添加或修改参数配置对话框 -->
 | 
						||
    <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
 | 
						||
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
 | 
						||
        <el-form-item label="最小库存:" prop="minNum">
 | 
						||
          <el-input 
 | 
						||
            v-model="form.minNum"
 | 
						||
            type="text" clearable
 | 
						||
            placeholder="请输入最小库存"
 | 
						||
            maxlength="7" @input="(v)=>(form.minNum=v.replace(/[^\d]/g,''))"
 | 
						||
          />
 | 
						||
        </el-form-item>  
 | 
						||
        <el-form-item label="最大库存:" prop="maxNum">
 | 
						||
          <el-input v-model="form.maxNum"
 | 
						||
            type="text" clearable 
 | 
						||
            placeholder="请输入最大库存"
 | 
						||
            maxlength="7" @input="(v)=>(form.maxNum=v.replace(/[^\d]/g,''))"
 | 
						||
          />
 | 
						||
        </el-form-item>
 | 
						||
      </el-form>
 | 
						||
      <div slot="footer" class="dialog-footer">
 | 
						||
        <el-button type="primary" @click="submitForm">确 定</el-button>
 | 
						||
        <el-button @click="cancel">取 消</el-button>
 | 
						||
      </div>
 | 
						||
    </el-dialog>
 | 
						||
  </div>
 | 
						||
</template>
 | 
						||
 | 
						||
<script> 
 | 
						||
import { systemAreaTreeApi } from "@/api/base/stall";
 | 
						||
// import { supplierQualificationWarningPageApi } from "@/api/foodManage/supplierManage";
 | 
						||
import { drpWareHousePageApi,systemMaterialTreeApi,getStockMaterialListApi,editStockMaterialApi } from "@/api/foodManage/stockManage";
 | 
						||
 | 
						||
export default {
 | 
						||
  name: "",
 | 
						||
  dicts: [],
 | 
						||
  data() {
 | 
						||
    return {
 | 
						||
      // 遮罩层
 | 
						||
      loading: false,
 | 
						||
      // 选中数组
 | 
						||
      ids: [],
 | 
						||
      // 非单个禁用
 | 
						||
      single: true,
 | 
						||
      // 非多个禁用
 | 
						||
      multiple: true,
 | 
						||
      // 显示搜索条件
 | 
						||
      showSearch: true,
 | 
						||
      // 总条数
 | 
						||
      total: 0,
 | 
						||
      //表格数据
 | 
						||
      tableListData: [],
 | 
						||
      treeOptions: [],
 | 
						||
      wareHouseOptions: [],
 | 
						||
      materialTreeOptions: [],
 | 
						||
      // 弹出层标题
 | 
						||
      title: "",
 | 
						||
      // 是否显示弹出层
 | 
						||
      open: false, 
 | 
						||
      // 查询参数
 | 
						||
      queryParams: {
 | 
						||
        pageNum: 1,
 | 
						||
        pageSize: 10,  
 | 
						||
        areaId: null,
 | 
						||
        warehouseId: null, 
 | 
						||
        materialTypeIds: [], 
 | 
						||
        materialName: "", 
 | 
						||
        barCode: "", 
 | 
						||
      },
 | 
						||
      // 表单参数
 | 
						||
      form: {},
 | 
						||
      // 表单校验
 | 
						||
      rules: { //最小库存 minNum 最大库存 maxNum
 | 
						||
        minNum: [
 | 
						||
          { required: true, message: "最小库存不能为空", trigger: "blur" }
 | 
						||
        ],
 | 
						||
        maxNum: [
 | 
						||
          { required: true, message: "最大库存不能为空", trigger: "blur" }
 | 
						||
        ]
 | 
						||
      }
 | 
						||
    };
 | 
						||
  },
 | 
						||
  created() { 
 | 
						||
    this.getTreeData();
 | 
						||
    this.getMaterialTree()   
 | 
						||
    this.getList();
 | 
						||
  },
 | 
						||
  methods: { 
 | 
						||
      //区域树
 | 
						||
      getTreeData() {
 | 
						||
          systemAreaTreeApi({}).then((response) => {
 | 
						||
              this.treeOptions = response.data;  
 | 
						||
          });
 | 
						||
      },
 | 
						||
      //选中区域-查询食堂
 | 
						||
      handleAreaChange(e){   
 | 
						||
          this.getWareHouseData()
 | 
						||
      },  
 | 
						||
      /** 查询货品下拉结构 */
 | 
						||
      getWareHouseData() { 
 | 
						||
          drpWareHousePageApi({ areaId:this.queryParams.areaId }).then((response) => {
 | 
						||
              this.wareHouseOptions = response.rows||[];
 | 
						||
              this.$set(this.queryParams,'warehouseId',null)  
 | 
						||
          }); 
 | 
						||
      },
 | 
						||
      /** 查询货品类别下拉树结构 */
 | 
						||
      getMaterialTree() {
 | 
						||
          let param = {
 | 
						||
              // goodsType:1
 | 
						||
          }
 | 
						||
          systemMaterialTreeApi(param).then((response) => {
 | 
						||
              this.materialTreeOptions = response.data; 
 | 
						||
          });
 | 
						||
      }, 
 | 
						||
      /** 搜索按钮操作 */
 | 
						||
      handleQuery() {
 | 
						||
          this.queryParams.pageNum = 1;
 | 
						||
          this.getList();
 | 
						||
      },
 | 
						||
      /** 重置按钮操作 */
 | 
						||
      resetQuery() { 
 | 
						||
          this.queryParams = {
 | 
						||
            pageNum: 1,
 | 
						||
            pageSize: 10,  
 | 
						||
            areaId: null,
 | 
						||
            warehouseId: null, 
 | 
						||
            materialTypeIds: [], 
 | 
						||
            materialName: "", 
 | 
						||
            barCode: "", 
 | 
						||
          }
 | 
						||
          this.resetForm("queryForm");
 | 
						||
          this.handleQuery();
 | 
						||
      },
 | 
						||
      /** 查询列表 */
 | 
						||
      getList() {
 | 
						||
          this.loading = true;
 | 
						||
          let param = {
 | 
						||
            "pageNum": this.queryParams.pageNum, 
 | 
						||
            "pageSize": this.queryParams.pageSize,  
 | 
						||
            "areaId": this.queryParams.areaId,
 | 
						||
            "warehouseId": this.queryParams.warehouseId,  
 | 
						||
            "materialTypeIds": this.queryParams.materialTypeIds,  
 | 
						||
            "materialName": this.queryParams.materialName
 | 
						||
          }
 | 
						||
          getStockMaterialListApi(param).then(response => {
 | 
						||
              this.tableListData = response.rows;
 | 
						||
              this.total = Number(response.total);
 | 
						||
              this.loading = false;
 | 
						||
          });
 | 
						||
      },    
 | 
						||
      /** 配置库存按钮操作 */
 | 
						||
      handleUpdate(row) {
 | 
						||
          this.reset();
 | 
						||
          this.form = Object.assign({}, row)  
 | 
						||
          this.open = true;
 | 
						||
          this.title = "配置库存";
 | 
						||
      },
 | 
						||
      /**批次详情按钮操作 */
 | 
						||
      handleView(row){
 | 
						||
        this.$router.push({ path: "/foodManage/stockManage/batchStockDetail",query: {pageJson:JSON.stringify(row)} });
 | 
						||
      },
 | 
						||
      // 取消按钮
 | 
						||
      cancel() {
 | 
						||
          this.open = false;
 | 
						||
          this.reset();
 | 
						||
      },
 | 
						||
      // 表单重置
 | 
						||
      reset() {
 | 
						||
          this.form = {};
 | 
						||
          this.resetForm("form");
 | 
						||
      }, 
 | 
						||
      /** 提交按钮 */
 | 
						||
      submitForm: function() {
 | 
						||
          this.$refs["form"].validate(valid => {
 | 
						||
            if (valid) { 
 | 
						||
              editStockMaterialApi(this.form).then(response => {
 | 
						||
                  this.$modal.msgSuccess("修改成功");
 | 
						||
                  this.open = false;
 | 
						||
                  this.getList();
 | 
						||
              }); 
 | 
						||
            }
 | 
						||
          });
 | 
						||
      },
 | 
						||
  }
 | 
						||
};
 | 
						||
</script>
 |