zhouwx
2025-02-13 0bc2784f60f30108cf6fa133b774703bda861721
src/views/hazardousChemicals/warehouseManage/components/addRawDialog.vue
@@ -51,6 +51,20 @@
            />
          </el-select>
        </el-form-item>
        <el-form-item label="存储柜:" prop="cupboardId" >
          <el-select
              v-model="state.form.cupboardId"
              placeholder="请选择存储柜"
              style="width: 100%"
          >
            <el-option
                v-for="item in state.cupList"
                :key="item.id"
                :label="item.cupboardName"
                :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="数量:" prop="num" >
          <el-input v-model.trim="state.form.num" oninput="value=value.replace(/^\.+|[^\d]/g,'')" placeholder="请输入最小包装数量" @input="changeNum"></el-input>
        </el-form-item>
@@ -76,7 +90,7 @@
<script setup>
import {reactive, ref, toRefs} from 'vue'
import {ElMessage} from "element-plus";
import {addWarehouse, checkName, editWarehouse, getWarehouse} from "@/api/hazardousChemicals/warehouse";
import {addWarehouse, checkName, editWarehouse, getCupById, getWarehouse} from "@/api/hazardousChemicals/warehouse";
import {verifyPhone} from "@/utils/validate";
import {checkBasicName, getBasicList} from "@/api/hazardousChemicals/basicInfo";
import {addProductRecord, editProductRecord, getProductRecord} from "@/api/hazardousChemicals/productRecord";
@@ -111,6 +125,8 @@
    basicName:'',
    warehouseName: '',
    warehouseId: null,
    cupboardName: '',
    cupboardId: null,
    num: null,
    batchNo: ''
@@ -119,11 +135,12 @@
    num: [{ required: true, trigger: "blur", validator: validateNum }],
    warehouseName: [{ required: true, trigger: "blur", message: '请选择入库仓库' }],
    basicName: [{ required: true, trigger: "blur", message: '请选择入库成品' }],
    // batchNo: [{ required: true, trigger: "blur", message: '请输入批号' }]
    cupboardId: [{ required: true, trigger: "blur", message: '请选择存储柜' }]
  },
  rawList: [],
  wareHouseList: [],
  message: ''
  message: '',
  cupList: []
})
@@ -134,6 +151,7 @@
  title.value = type === 'add' ? '新增' : type ==='edit' ? '编辑':'' ;
  if(type === 'edit' ) {
    state.form = JSON.parse(JSON.stringify(value));
    await getCupList(value.warehouseId)
    state.form.basicName = value.hazmatBasic.name + '—' + value.hazmatBasic.productSn + ' (' + value.hazmatBasic.metering + value.hazmatBasic.unit+') '
    state.form.warehouseName = value.warehouse.name;
    choosePro.value = value.hazmatBasic
@@ -182,7 +200,12 @@
  }
  const res = await getWarehouse(param)
  if(res.code == 200){
    state.wareHouseList = res.data.list
    state.wareHouseList = res.data.list.map(item => {
      return {
        ...item,
        children: item.warehouseCupboards && item.warehouseCupboards.length>0 ? item.warehouseCupboards : null
      }
    })
  }else{
    ElMessage.warning(res.message)
  }
@@ -246,11 +269,21 @@
  state.message = `您将入库 { ${choosePro.value.name.substring(0,choosePro.value.name.lastIndexOf('—'))    } },编号:{ ${choosePro.value.productSn} },最小包装${choosePro.value.metering}${choosePro.value.unit},类别:${minPackageType}。 \n 共计:${state.form.num}${minPackageType}`
}
const selectWareValue = (val) => {
  state.form.cupboardId = null
  state.wareHouseList.forEach(item => {
    if(item.name === val){
      state.form.warehouseId = item.id
      getCupList(item.id)
    }
  })
}
const getCupList = async (val) => {
  const res = await getCupById(val)
  if(res.code == 200) {
    state.cupList = res.data
  }else {
    ElMessage.warning(res.message)
  }
}
const handleClose = () => {
@@ -267,7 +300,9 @@
    warehouseName: '',
    warehouseId: null,
    num: null,
    batchNo: ''
    batchNo: '',
    cupboardName: '',
    cupboardId: null,
  }
  state.rawList = [];
  state.wareHouseList = [];