loulijun2021
2023-10-27 7993729a2ecc0c7117b2325daf1b811cca28e7f4
1.库位设置   优化
已修改3个文件
174 ■■■■ 文件已修改
src/api/GeneralBasicData.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/basicSettings/storageList.vue 152 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/basicSettings/warehouseList.vue 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/GeneralBasicData.js
@@ -147,3 +147,11 @@
    params: data
  })
}
// 仓库查找仓位信息
export function WareHouseSelectLocation(data) {
  return request({
    url: 'GeneralBasicData/WareHouseSelectLocation',
    method: 'get',
    params: data
  })
}
src/views/basicSettings/storageList.vue
@@ -63,13 +63,13 @@
        >
          <div class="bodyTopButtonGroup" style="justify-content: space-between">
            <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
            <el-button
              v-waves
              type="success"
              icon="el-icon-download"
              @click="$router.push('./../systemSetting/dataImport?fileCode=7')"
            >导入
            </el-button>
            <!--            <el-button-->
            <!--              v-waves-->
            <!--              type="success"-->
            <!--              icon="el-icon-download"-->
            <!--              @click="$router.push('./../systemSetting/dataImport?fileCode=7')"-->
            <!--            >导入-->
            <!--            </el-button>-->
          </div>
          <div class="bodyTopFormGroup">
@@ -81,10 +81,10 @@
              style="display: flex;"
            >
              <div class="elForm">
                <el-form-item label="仓库编码" style=" display: flex;">
                <el-form-item label="货位编码" style=" display: flex;">
                  <el-input v-model="form.locacode" placeholder="请输入" style="width: 200px" />
                </el-form-item>
                <el-form-item label="仓库名称" style=" display: flex;">
                <el-form-item label="货位名称" style=" display: flex;">
                  <el-input v-model="form.locaname" placeholder="请输入" style="width: 200px" />
                </el-form-item>
                <!--                <el-form-item label="存货规格" style=" display: flex;">-->
@@ -166,12 +166,12 @@
              />
              <el-table-column
                prop="code"
                label="仓库编码"
                label="货位编码"
                sortable="custom"
              />
              <el-table-column
                prop="name"
                label="仓库名称"
                label="货位名称"
                show-overflow-tooltip
                sortable="custom"
              />
@@ -328,10 +328,10 @@
      <el-form ref="dialogForm" class="" inline :rules="dialogFormRules" :model="dialogForm" label-width="110px">
        <!--        <el-divider content-position="left">基本信息</el-divider>-->
        <el-form-item label="仓库编码" prop="locacode">
        <el-form-item label="货位编码" prop="locacode">
          <el-input v-model="dialogForm.locacode" :disabled="operation!=='add'" style="width: 200px" />
        </el-form-item>
        <el-form-item label="仓库名称" prop="locaname">
        <el-form-item label="货位名称" prop="locaname">
          <el-input v-model="dialogForm.locaname" style="width: 200px" />
        </el-form-item>
@@ -342,6 +342,7 @@
            placeholder="请选择"
            filterable
            :popper-append-to-body="false"
            :disabled="!isEdit&&operation==='edit'"
            @change="stckcodeChange"
          >
            <el-option
@@ -420,6 +421,9 @@
  TCunstomerClassTreeDelete,
  TCunstomerData, TCunstomerDelete, TSecLocaAddUpdate, TSecLocaData, TSecLocaDelete, TSecLocaTree
} from '@/api/basicSettings'
import { WareHouseSelectLocation } from '@/api/GeneralBasicData'
const _ = require('lodash')
export default {
  name: 'RoleList',
@@ -453,6 +457,7 @@
        locacode: '',
        locaname: '',
        partspec: '',
        flag: '',
        page: 1,
        rows: 20,
        prop: 'lm_date', // 排序字段
@@ -486,6 +491,8 @@
        parentlocacode: '', // 上级货位编码
        status: '0', // 使用状态: 正常(0)停用(1)
        description: '',
        depth: '', // 层级
        OperType: '' // 操作类型
      },
      dialogFormRules: {
@@ -500,7 +507,9 @@
        ]
      },
      stckcodeArr: [],
      parentlocacodeArr: []
      parentlocacodeArr: [],
      isEdit: true
    }
  },
@@ -516,28 +525,56 @@
  },
  methods: {
    async getTSecLocaTree() {
      const res = await TSecLocaTree()
      this.treeLeftArr = res.data
      this.treeLeftArr.forEach(e => {
      const { data: res } = await TSecLocaTree()
      res.forEach(e => {
        e.name = e.code + ' ' + e.name
      })
      this.stckcodeArr = res.data.filter(i => i.idparent === '-1')
      this.treeLeft = [
        {
          code: '-1',
          name: '全部'
        }
      ]// 左侧树
      this.treeLeft = arrayToTree(this.treeLeft.concat(res.data), {
      //  获取仓库
      const ck = res.filter(i => i.depth === 0)// 层级为0的  是仓库
      const kw = res.filter(i => i.depth !== 0)// 反之 为仓位
      this.stckcodeArr = ck
      const tree = arrayToTree(kw, {
        parentProperty: 'idparent',
        customID: 'code',
        childrenProperty: 'children'
      })
      const group = _.groupBy(tree, i => i.warhouse)
      const newArr = []
      ck.forEach(j => {
        if (Object.keys(group).includes(j.code)) {
          newArr.push({
            code: j.code,
            name: j.name,
            depth: 0,
            idparent: '-1',
            children: group[j.code]
          })
        } else {
          newArr.push({
            code: j.code,
            name: j.name,
            depth: 0,
            idparent: '-1',
            children: []
          })
        }
      })
      this.treeLeft = [
        {
          code: '-1',
          name: '全部',
          idparent: '',
          children: newArr
        }
      ]// 左侧树
      this.$nextTick(() => {
        this.$refs.treeLeftRef.setCurrentKey('-1')
        this.getTSecLocaData(this.$refs.treeLeftRef.getCurrentNode())
      })
      console.log(JSON.parse(JSON.stringify(this.treeLeft)))
    },
    async getTSecLocaData(node) {
      let result = ''
      if (node.code === '-1') {
@@ -550,6 +587,13 @@
      //   result.shift()
      // }
      this.form.stckcode = result.join(',')
      if (this.$refs.treeLeftRef.getCurrentNode().idparent === '') {
        this.form.flag = -1
      } else {
        this.form.flag = this.$refs.treeLeftRef.getCurrentNode().depth
      }
      const res = await TSecLocaData(this.form)
      this.tableData = res.data
@@ -588,18 +632,29 @@
      this.dialogVisible = true
      this.dialogForm.OperType = 'Update'
      this.$nextTick(() => {
        this.dialogForm.data_sources = row.data_sources
        this.dialogForm.locacode = row.code
        this.dialogForm.locaname = row.name
        this.dialogForm.stckcode = row.stckcode
      const temp = this.$refs.treeLeftRef.getCurrentNode()
        this.parentlocacodeArr = this.treeLeftArr.filter(i => i.idparent === this.dialogForm.stckcode)
      if (temp.idparent === '-1' || temp.idparent === '') {
        this.isEdit = temp.depth !== 1
      } else {
        this.isEdit = false
      }
        this.dialogForm.parentlocacode = row.parentname ? row.parentcode : null
        this.dialogForm.status = row.status
        this.dialogForm.description = row.description
      })
      // this.$nextTick(() => {
      this.dialogForm.data_sources = row.data_sources
      this.dialogForm.locacode = row.code
      this.dialogForm.locaname = row.name
      this.dialogForm.stckcode = row.stckcode
      const { data: res } = await WareHouseSelectLocation({ warhousecode: row.stckcode })
      this.parentlocacodeArr = res
      // this.parentlocacodeArr = this.treeLeftArr.filter(i => i.idparent === this.dialogForm.stckcode)
      this.dialogForm.parentlocacode = row.parentname ? row.parentcode : null
      this.dialogForm.status = row.status
      this.dialogForm.description = row.description
      // })
    },
    del(row) {
      this.$confirm('是否确认删除?', '提示', {
@@ -634,6 +689,12 @@
      this.dialogForm.parentlocacode = ''
      this.dialogForm.description = ''
      this.dialogForm.status = '0'
      if (this.$refs.treeLeftRef.getCurrentNode().idparent === '') {
        this.form.flag = ''
      } else {
        this.form.flag = this.$refs.treeLeftRef.getCurrentNode().depth
      }
      this.$refs.dialogForm.clearValidate()
    },
    // 对话框取消
@@ -645,6 +706,17 @@
      this.$refs.dialogForm.validate(valid => {
        if (valid) {
          // console.log(JSON.parse(JSON.stringify(this.dialogForm)), 2)
          if (this.dialogForm.locacode === this.dialogForm.parentlocacode) {
            return this.$message.error('上级货位不能是货位本身!')
          }
          if (this.dialogForm.parentlocacode === '') {
            this.dialogForm.depth = 1
          } else {
            this.dialogForm.depth = parseFloat(this.parentlocacodeArr.find(i => i.code === this.dialogForm.parentlocacode).depth) + 1
          }
          this.$store.state.app.buttonIsDisabled = true
          TSecLocaAddUpdate(this.dialogForm).then(res => {
            if (res.code === '200') {
@@ -652,7 +724,6 @@
              this.dialogVisible = false
              this.$store.state.app.buttonIsDisabled = false
              this.getTSecLocaTree()
              this.getTSecLocaData(this.$refs.treeLeftRef.getCurrentNode())
            } else {
              this.$store.state.app.buttonIsDisabled = false
              this.$notify.error(this.operation === 'add' ? '添加失败!' : '修改失败!')
@@ -662,10 +733,13 @@
      })
    },
    stckcodeChange(val) {
      this.dialogForm.parentlocacode = ''
      const res = this.recursiveLookupArray([], val)// 递归查找数组
    async stckcodeChange(val) {
      const { data: res } = await WareHouseSelectLocation({ warhousecode: val })
      this.parentlocacodeArr = res
      this.dialogForm.parentlocacode = ''
      // const res = this.recursiveLookupArray([], val)// 递归查找数组
      // this.parentlocacodeArr = res
    },
    recursiveLookupArray(newArr, val) {
      const temp = this.treeLeftArr.filter(i => i.idparent === val)
src/views/basicSettings/warehouseList.vue
@@ -5,13 +5,13 @@
        <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
        <div style="display:flex">
          <el-button
            v-waves
            type="success"
            icon="el-icon-download"
            @click="$router.push('./../systemSetting/dataImport?fileCode=6')"
          >导入
          </el-button>
          <!--          <el-button-->
          <!--            v-waves-->
          <!--            type="success"-->
          <!--            icon="el-icon-download"-->
          <!--            @click="$router.push('./../systemSetting/dataImport?fileCode=6')"-->
          <!--          >导入-->
          <!--          </el-button>-->
          <el-button v-waves icon="el-icon-refresh-right" @click="syncERP">同步仓库</el-button>
        </div>
      </div>