zouyu
2023-12-14 bc16d211c5a2b31f0e3127a102748806151eaecb
src/views/warehouse/changestock/index.vue
@@ -2,22 +2,13 @@
  <div class="mod-config">
    <basic-container>
      <div style="margin-left: 15px;">
        <el-form class="l-mes" style="width:100%" :model="searchForm" label-width="80px" label-position="right">
        <el-row>
          <el-col :span="1">
            <div>
              <el-divider direction="vertical"></el-divider>
              <div
                style="float: left;height: 18px;font-size: 14px;line-height: 18px;font-weight: bold"
              >
                <span>零件</span>
              </div>
            </div>
          </el-col>
          <el-col :span="3">
            <div>
            <el-col :span="5">
              <el-form-item label="零件">
              <el-input
                class="change-stock-input"
                v-model="partNoStock"
                  v-model="searchForm.partNoStock"
                placeholder="零件"
                style="width: 100%"
                disabled
@@ -28,94 +19,47 @@
                  @click="openPartDialog()"
                ></el-button>
              </el-input>
            </div>
              </el-form-item>
          </el-col>
          <el-col :span="1" :offset="1">
            <div>
              <el-divider direction="vertical"></el-divider>
              <div
                style="float: left;height: 18px;font-size: 14px;line-height: 18px;font-weight: bold"
              >
                <span>库位</span>
              </div>
            </div>
          </el-col>
          <el-col :span="3">
            <div>
            <el-col :span="5">
              <el-form-item label="库位">
              <el-input
                class="change-stock-input"
                v-model="locationNoStock"
                  v-model="searchForm.locationNoStock"
                placeholder="库位号"
                @focus="openPicker(locationNoStock)"
                style="width: 100%"
                disabled
              >
                <i
                  slot="suffix"
                  v-show="locationNoStock"
                  @click="clearForm(locationNoStock)"
                  class="el-input__icon el-icon-error err-style"
                ></i>
                <el-button
                  slot="append"
                  icon="el-icon-search"
                  @click="openLocationDialog()"
                ></el-button>
              </el-input>
            </div>
              </el-form-item>
          </el-col>
          <el-col :span="2">
            <div style="display:flex;justify-content:flex-end;">
              <div
                style="height: 18px;font-size: 14px;line-height: 18px;font-weight: bold;width:60px;"
              >
                <span>批次号</span>
              </div>
              <div>
                <el-divider direction="vertical"></el-divider>
              </div>
            </div>
          </el-col>
          <el-col :span="3">
            <div>
            <el-col :span="5">
              <el-form-item label="批次号">
              <el-input
                class="change-stock-input"
                v-model="partBatchNoStock"
                  v-model="searchForm.partBatchNoStock"
                placeholder="批次号"
                @focus="openPicker(partBatchNoStock)"
                style="width: 100%"
                disabled
              >
                <i
                  slot="suffix"
                  v-show="partBatchNoStock"
                  @click="clearStock(partBatchNoStock)"
                  class="el-input__icon el-icon-error err-style"
                ></i>
                <el-button
                  slot="append"
                  icon="el-icon-search"
                  @click="openStockDialog()"
                ></el-button>
              </el-input>
            </div>
              </el-form-item>
          </el-col>
          <el-col :span="2">
            <div style="display:flex;justify-content:flex-end;">
              <div
                style="height: 18px;font-size: 14px;line-height: 18px;font-weight: bold;width:60px;"
              >
                <span>可用数量</span>
              </div>
              <div>
                <el-divider direction="vertical"></el-divider>
              </div>
            </div>
          </el-col>
          <el-col :span="3">
            <div>
            <el-col :span="5">
              <el-form-item label="可用数量">
              <el-select
                v-model="stockList.condition"
                  style="width:100%"
                  v-model="searchForm.condition"
                placeholder="请选择"
                @change="conditionChange"
              >
@@ -127,9 +71,9 @@
                >
                </el-option>
              </el-select>
            </div>
              </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-col :span="3" :offset="1">
            <div style="text-align:center;">
              <el-button @click="clearConditions">清空</el-button
              ><el-button
@@ -141,6 +85,7 @@
            </div>
          </el-col>
        </el-row>
        </el-form>
        <div style="margin-top: 15px;">
          <el-divider direction="vertical"></el-divider>
          <div
@@ -148,11 +93,11 @@
          >
            <span>实时库存</span>
          </div>
          <el-button type="primary" @click="addOrUpdateHandle()"
          <el-button size="mini" type="primary" @click="addOrUpdateHandle()"
            >新增</el-button
          >
          <el-button type="primary" @click="addStockSubmit()">接收</el-button>
          <el-button type="primary" @click="deleteStockSubmit()"
          <el-button size="mini" type="primary" @click="addStockSubmit()">接收</el-button>
          <el-button size="mini" type="primary" @click="deleteStockSubmit()"
            >发放</el-button
          >
@@ -307,6 +252,12 @@
export default {
  data() {
    return {
      searchForm: {
        partNoStock: null,
        locationNoStock: null,
        partBatchNoStock: null,
        condition: '>0',
      },
      stockList: {
        condition: '>0',
        locationNo: null,
@@ -322,9 +273,6 @@
      paramObj: {},
      dataRule: {},
      addOrUpdateVisible: false,
      partNoStock: null,
      locationNoStock: null,
      partBatchNoStock: null,
      showPart: false,
      showLocation: false,
      showStock: false,
@@ -355,7 +303,7 @@
    }
  },
  watch: {
    partNoStock: {
    'searchForm.partNoStock': {
      handler(newValue, oldValue) {
        if (newValue != null && newValue != undefined) {
          // this.getData()
@@ -364,7 +312,7 @@
      deep: true,
      immediate: true
    },
    locationNoStock: {
    'searchForm.locationNoStock': {
      handler(newValue, oldValue) {
        if (newValue != null && newValue != undefined) {
          // this.getData()
@@ -373,7 +321,7 @@
      deep: true,
      immediate: true
    },
    partBatchNoStock: {
    'searchForm.partBatchNoStock': {
      handler(newValue, oldValue) {
        if (newValue != null && newValue != undefined) {
          // this.getData()
@@ -386,16 +334,16 @@
  methods: {
    // 清空所有查询条件
    clearConditions() {
      this.partNoStock = null
      this.searchForm.partNoStock = null
      this.stockList.partNo = null
      this.paramObj.partId = null
      this.stockList.partName = null
      this.stockList.partId = null
      this.locationNoStock = null
      this.searchForm.locationNoStock = null
      this.stockList.locationNo = null
      this.stockList.locationId = null
      this.paramObj.locationId = null
      this.partBatchNoStock = null
      this.searchForm.partBatchNoStock = null
      this.stockList.partBatchNo = null
    },
    // 根据查询条件,搜索
@@ -403,15 +351,15 @@
      this.getData()
    },
    // 可用数量条件变更后,触发查询
    conditionChange() {
      // this.getData()
    conditionChange(val) {
      this.stockList.condition = val
    },
    // 零件
    openPartDialog() {
      this.showPart = true
    },
    getData() {
      if (this.partNoStock != null) {
      if (this.searchForm.partNoStock != null) {
        getStockCount(this.stockList).then((resp) => {
          const respData = resp.data.data
          if (respData && respData > 100) {
@@ -433,29 +381,10 @@
        this.$message.error('请先选择一个零件')
      }
    },
    openPicker() {
      document.activeElement.blur() // 主动触发onblur事件,是原生的js哟
    },
    clearForm() {
      this.locationNoStock = null
      this.stockList.locationNo = this.locationNoStock
      this.stockList.locationId = null
      this.paramObj.locationId = null
      // this.getData()
    },
    clearStock() {
      this.partBatchNoStock = null
      this.stockList.partBatchNo = this.partBatchNoStock
      this.locationNoStock = null
      this.stockList.locationNo = this.locationNoStock
      this.stockList.locationId = null
      this.paramObj.locationId = null
      // this.getData()
    },
    selectPart(param) {
      if (param) {
        this.partNoStock = param.partNo
        this.stockList.partNo = this.partNoStock
        this.searchForm.partNoStock = param.partNo
        this.stockList.partNo = this.searchForm.partNoStock
        this.paramObj.partId = param.id
        this.stockList.partName = param.partName
        this.stockList.partId = param.id
@@ -469,14 +398,15 @@
      // }
    },
    selectLocation(param) {
      console.log(param);
      if (param) {
        this.locationNoStock = param.locNo
        this.stockList.locationNo = this.locationNoStock
        this.searchForm.locationNoStock = param.locNo
        this.stockList.locationNo = this.searchForm.locationNoStock
        this.stockList.locationId = param.id
        this.paramObj.locationId = param.id
      } else {
        this.locationNoStock = null
        this.stockList.locationNo = this.locationNoStock
        this.searchForm.locationNoStock = null
        this.stockList.locationNo = this.searchForm.locationNoStock
        this.stockList.locationId = null
        this.paramObj.locationId = null
        // this.getData()
@@ -492,25 +422,25 @@
    dataFormSubmit() {},
    selectStock(param) {
      if (param) {
        this.partBatchNoStock = param.partBatchNo
        this.stockList.partBatchNo = this.partBatchNoStock
        this.searchForm.partBatchNoStock = param.partBatchNo
        this.stockList.partBatchNo = this.searchForm.partBatchNoStock
        this.stockList.locationNo = param.locationNo
        this.locationNoStock = param.locationNo
        this.searchForm.locationNoStock = param.locationNo
        this.stockList.locationId = param.locationId
        this.paramObj.locationId = param.locationId
        this.partNoStock = param.partNo
        this.stockList.partNo = this.partNoStock
        this.searchForm.partNoStock = param.partNo
        this.stockList.partNo = this.searchForm.partNoStock
        this.paramObj.partId = param.partId
        this.stockList.partName = param.partName
        this.stockList.partId = param.partId
      } else {
        this.partBatchNoStock = null
        this.stockList.partBatchNo = this.partBatchNoStock
        this.locationNoStock = null
        this.stockList.locationNo = this.locationNoStock
        this.searchForm.partBatchNoStock = null
        this.stockList.partBatchNo = this.searchForm.partBatchNoStock
        this.searchForm.locationNoStock = null
        this.stockList.locationNo = this.searchForm.locationNoStock
        this.stockList.locationId = null
        this.paramObj.locationId = null
        this.partNoStock = null
        this.searchForm.partNoStock = null
        this.stockList.partNo = null
        this.paramObj.partId = null
        this.stockList.partName = null