小小儁爺
2024-08-08 d20654ba067e5c0621d4d7d95915cbe47a10fe87
src/views/makeModel/InventoryList.vue
@@ -48,21 +48,28 @@
              <el-input v-model="form.partspec" placeholder="请输入" style="width: 200px" />
            </el-form-item>
            <el-form-item label="存货类型" style=" display: flex;">
              <el-select
                v-model="form.stocktypecode"
              <el-cascader
                ref="cascader"
                :options="stocktypeArr"
                filterable
                :popper-append-to-body="false"
                style="width: 200px"
                placeholder="请选择"
              >
                <!--                @change="val=>stocktypecodeChange(val,'form')"-->
                <el-option
                  v-for="item in stocktypeArr"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                />
              </el-select>
                :props="defaultProps"
                @change="val=>cascaderChange(val,'form')"
              />
              <!--              <el-select-->
              <!--                v-model="form.stocktypecode"-->
              <!--                filterable-->
              <!--                :popper-append-to-body="false"-->
              <!--                style="width: 200px"-->
              <!--                placeholder="请选择"-->
              <!--              >-->
              <!--                &lt;!&ndash;                @change="val=>stocktypecodeChange(val,'form')"&ndash;&gt;-->
              <!--                <el-option-->
              <!--                  v-for="item in stocktypeArr"-->
              <!--                  :key="item.code"-->
              <!--                  :label="item.name"-->
              <!--                  :value="item.code"-->
              <!--                />-->
              <!--              </el-select>-->
            </el-form-item>
            <el-form-item v-if="false" label="物料类型" style=" display: flex;">
              <el-select
@@ -272,22 +279,31 @@
          </el-select>
        </el-form-item>
        <el-form-item label="存货类型" prop="stocktypecode">
          <el-select
            v-model="dialogForm.stocktypecode"
            filterable
            :popper-append-to-body="false"
            style="width: 200px"
            placeholder="请选择"
          >
            <!--            @change="val=>stocktypecodeChange(val,'dialogForm')"-->
            <el-option
              v-for="item in stocktypeArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
          <el-cascader
            ref="cascaderDialog"
            :options="stocktypeArr"
            filterable
            :props="defaultPropsDialog"
            @change="val=>cascaderChange(val,'dialogForm')"
          />
          <!--          <el-select-->
          <!--            v-model="dialogForm.stocktypecode"-->
          <!--            filterable-->
          <!--            :popper-append-to-body="false"-->
          <!--            style="width: 200px"-->
          <!--            placeholder="请选择"-->
          <!--          >-->
          <!--            &lt;!&ndash;            @change="val=>stocktypecodeChange(val,'dialogForm')"&ndash;&gt;-->
          <!--            <el-option-->
          <!--              v-for="item in stocktypeArr"-->
          <!--              :key="item.code"-->
          <!--              :label="item.name"-->
          <!--              :value="item.code"-->
          <!--            />-->
          <!--          </el-select>-->
        </el-form-item>
        <el-form-item label="所属仓库" prop="warehousecode">
          <el-select
@@ -336,85 +352,85 @@
        </el-form-item>
      </el-form>
      <el-collapse>
        <el-collapse-item title="一致性 Consistency" name="1">
          <template slot="title">
            <div>
              <i
                class="el-icon-s-operation"
                :style="{color:$store.state.settings.theme}"
                style="margin: -20px 10px 20px 20px"
              />高级设置:
            </div>
          </template>
          <div
            style="display: flex;flex-direction: column;height: 140px; align-content: center;justify-content: space-between"
          >
            <div style="display: flex;width: 200px;align-content: center;justify-content: flex-end">
              <div>
                <el-tooltip
                  class="item"
                  effect="dark"
                  content=""
                  placement="top"
                >
                  <div slot="content" style="width: 300px">
                    启用管理后库存数量会按标签分开显示,需要做采购到货才能入库,且生产发料需要扫码标签进行发料,不启用批次管理的不需要采购到货,可以直接选择物料采购入库,且入库后会合并显示该物料的库存,生产发料则按库位进行出库。
                  </div>
                  <i class="el-icon-question" :style="{color:$store.state.settings.theme}" />
                </el-tooltip>
              </div>
      <!--      <el-collapse>-->
      <!--        <el-collapse-item title="一致性 Consistency" name="1">-->
      <!--          <template slot="title">-->
      <!--            <div>-->
      <!--              <i-->
      <!--                class="el-icon-s-operation"-->
      <!--                :style="{color:$store.state.settings.theme}"-->
      <!--                style="margin: -20px 10px 20px 20px"-->
      <!--              />高级设置:-->
      <!--            </div>-->
      <!--          </template>-->
      <!--          <div-->
      <!--            style="display: flex;flex-direction: column;height: 140px; align-content: center;justify-content: space-between"-->
      <!--          >-->
      <!--            <div style="display: flex;width: 200px;align-content: center;justify-content: flex-end">-->
      <!--              <div>-->
      <!--                <el-tooltip-->
      <!--                  class="item"-->
      <!--                  effect="dark"-->
      <!--                  content=""-->
      <!--                  placement="top"-->
      <!--                >-->
      <!--                  <div slot="content" style="width: 300px">-->
      <!--                    启用管理后库存数量会按标签分开显示,需要做采购到货才能入库,且生产发料需要扫码标签进行发料,不启用批次管理的不需要采购到货,可以直接选择物料采购入库,且入库后会合并显示该物料的库存,生产发料则按库位进行出库。-->
      <!--                  </div>-->
      <!--                  <i class="el-icon-question" :style="{color:$store.state.settings.theme}" />-->
      <!--                </el-tooltip>-->
      <!--              </div>-->
              <div style="margin: 0 3px">批次管理:</div>
              <el-switch
                v-model="isBatchNo"
              />
            </div>
            <div style="display: flex;width: 200px;align-content: center;justify-content: flex-end">
              <div style="margin: 0 3px">先进先出:</div>
              <el-switch
                v-model="isFifo"
              />
            </div>
            <div style="display: flex;width: 200px;align-content: center;justify-content: flex-end">
              <div>
                <el-tooltip
                  class="item"
                  effect="dark"
                  content=""
                  placement="top"
                >
                  <div slot="content" style="width: 300px">开启后该物料必须做入厂检验或质量判断合格后才能做入厂反则该物料质量状态为待检状态是不允许入厂的。</div>
                  <i class="el-icon-question" :style="{color:$store.state.settings.theme}" />
                </el-tooltip>
              </div>
      <!--              <div style="margin: 0 3px">批次管理:</div>-->
      <!--              <el-switch-->
      <!--                v-model="isBatchNo"-->
      <!--              />-->
      <!--            </div>-->
      <!--            <div style="display: flex;width: 200px;align-content: center;justify-content: flex-end">-->
      <!--              <div style="margin: 0 3px">先进先出:</div>-->
      <!--              <el-switch-->
      <!--                v-model="isFifo"-->
      <!--              />-->
      <!--            </div>-->
      <!--            <div style="display: flex;width: 200px;align-content: center;justify-content: flex-end">-->
      <!--              <div>-->
      <!--                <el-tooltip-->
      <!--                  class="item"-->
      <!--                  effect="dark"-->
      <!--                  content=""-->
      <!--                  placement="top"-->
      <!--                >-->
      <!--                  <div slot="content" style="width: 300px">开启后该物料必须做入厂检验或质量判断合格后才能做入厂反则该物料质量状态为待检状态是不允许入厂的。</div>-->
      <!--                  <i class="el-icon-question" :style="{color:$store.state.settings.theme}" />-->
      <!--                </el-tooltip>-->
      <!--              </div>-->
              <div style="margin: 0 3px">入厂检验:</div>
              <el-switch
                v-model="isInCheck"
              />
            </div>
            <div style="display: flex;width: 200px;align-content: center;justify-content: flex-end">
              <div>
                <el-tooltip
                  class="item"
                  effect="dark"
                  content=""
                  placement="top"
                >
                  <div slot="content" style="width: 300px">开启后该物料必须做出厂检验或质量判断合格后才能做出厂,反则该物料质量状态为待检状态是不允许出厂的。</div>
                  <i class="el-icon-question" :style="{color:$store.state.settings.theme}" />
                </el-tooltip>
              </div>
      <!--              <div style="margin: 0 3px">入厂检验:</div>-->
      <!--              <el-switch-->
      <!--                v-model="isInCheck"-->
      <!--              />-->
      <!--            </div>-->
      <!--            <div style="display: flex;width: 200px;align-content: center;justify-content: flex-end">-->
      <!--              <div>-->
      <!--                <el-tooltip-->
      <!--                  class="item"-->
      <!--                  effect="dark"-->
      <!--                  content=""-->
      <!--                  placement="top"-->
      <!--                >-->
      <!--                  <div slot="content" style="width: 300px">开启后该物料必须做出厂检验或质量判断合格后才能做出厂,反则该物料质量状态为待检状态是不允许出厂的。</div>-->
      <!--                  <i class="el-icon-question" :style="{color:$store.state.settings.theme}" />-->
      <!--                </el-tooltip>-->
      <!--              </div>-->
              <div style="margin: 0 3px">出厂检验:</div>
              <el-switch
                v-model="isOutCheck"
              />
            </div>
          </div>
        </el-collapse-item>
      </el-collapse>
      <!--              <div style="margin: 0 3px">出厂检验:</div>-->
      <!--              <el-switch-->
      <!--                v-model="isOutCheck"-->
      <!--              />-->
      <!--            </div>-->
      <!--          </div>-->
      <!--        </el-collapse-item>-->
      <!--      </el-collapse>-->
      <!--      </div>-->
      <span slot="footer" class="dialog-footer">
        <div class="footerButton">
@@ -720,9 +736,10 @@
import elDragDialog from '@/directive/el-drag-dialog'
import waves from '@/directive/waves'
import TableColumnSettings from '@/components/TableColumnSettings'
import arrayToTree from 'array-to-tree'
export default {
  name: 'CHDA',
  name: 'InventoryList',
  components: {
    Pagination, TableColumnSettings
  },
@@ -981,7 +998,20 @@
      isBatchNo: false, // 是否批次管理
      isFifo: false, // 是否先进先出
      isInCheck: false, // 是否入库检验
      isOutCheck: false// 是否出厂检验
      isOutCheck: false, // 是否出厂检验
      defaultProps: {
        checkStrictly: true,
        expandTrigger: 'hover',
        value: 'code',
        label: 'name'
      },
      defaultPropsDialog: {
        // checkStrictly: true,
        expandTrigger: 'hover',
        value: 'code',
        label: 'name'
      }
    }
  },
  created() {
@@ -1079,6 +1109,34 @@
        }, 10000)
      }
    },
    cascaderChange(val, type) {
      if (type === 'form') {
        this.form.stocktypecode = val[val.length - 1]
      }
      if (type === 'dialogForm') {
        this.dialogForm.stocktypecode = val[val.length - 1]
      }
    },
    // parents:用于返回的数组,childNode:要查询的节点,treeData:json树形数据
    findParent(parents, childNode, treeData) {
      for (let i = 0; i < treeData.length; i++) {
        // 父节点查询条件
        if (treeData[i].code === childNode) {
          // 如果找到结果,保存当前节点
          parents.push(treeData[i].code)
          // 用当前节点再去原数据查找当前节点的父节点
          this.findParent(parents, treeData[i].iparent_id, this.stocktypeArr)
          break
        } else {
          if (treeData[i].children instanceof Array) {
            //   没找到,遍历该节点的子节点
            this.findParent(parents, childNode, treeData[i].children)
          }
        }
      }
      return parents
    },
    async getInventoryFileSelect() {
      const res = await InventoryFileSelect(this.form)
      this.tableData = res.data
@@ -1087,7 +1145,13 @@
    },
    async getStockTypeSelect() {
      const { data: res } = await StockTypeSelect()
      this.stocktypeArr = res
      this.stocktypeArr = arrayToTree(res, {
        parentProperty: 'iparent_id',
        customID: 'code',
        childrenProperty: 'children'
      })
      console.log(this.stocktypeArr, 2)
    },
    async getWareHouseSelect() {
      const { data: res } = await WareHouseSelect()
@@ -1139,6 +1203,7 @@
      this.form.stocktypecode = ''
      this.form.materialtypecode = ''
      this.form.storehousecode = ''
      this.$refs.cascader.checkedValue = ''
      this.getInventoryFileSelect()
    },
    // 新增按钮
@@ -1149,10 +1214,14 @@
    },
    // 修改按钮
    async edit(operation, row) {
      const cascaderCheckedValue = this.findParent([], row.stocktypecode, this.stocktypeArr)
      this.operation = operation
      this.dialogVisible = true
      // await this.stocktypecodeChange(row.stocktypecode, 'dialogForm')
      this.$nextTick(() => {
        this.$refs.cascaderDialog.checkedValue = cascaderCheckedValue.reverse()
        this.dialogForm.id = row.id
        this.dialogForm.materialcode = row.partcode
        this.dialogForm.materialname = row.partname
@@ -1205,6 +1274,7 @@
      this.isFifo = false
      this.isInCheck = false
      this.isOutCheck = false
      this.$refs.cascaderDialog.checkedValue = ''
      this.$refs.dialogForm.clearValidate()
    },
    // 对话框取消