王震
2023-12-29 b3cdb967634dddba8a88bca2550f7e07c9ac262c
src/views/warehouse/pallettransports/index.vue
@@ -9,6 +9,18 @@
            <template #toolbar>
              <el-button v-if="permissions.warehouse_pallettransports_add" type="primary"
                @click="addOrUpdateHandle()">新增</el-button>
                <el-dropdown style="margin-left: 20px;" @command="handleCommand">
                    <el-button >
                      状态变更<i class="el-icon-arrow-down el-icon--right"></i>
                    </el-button>
                    <el-dropdown-menu slot="dropdown">
                      <el-dropdown-item :key="index"
                        :command="item.label"
                        v-for="(item,index) in taskTypeArr"
                        >{{ item.label }}</el-dropdown-item
                      >
                    </el-dropdown-menu>
                </el-dropdown>
            </template>
          </ttable>
@@ -113,7 +125,7 @@
              <!-- <el-button type="warning" v-if="permissions.warehouse_pallettransports_detail_library" round
                @click="openDetailLocationDialog">一键至库位</el-button> -->
              <el-button type="success" v-if="permissions.warehouse_pallettransports_detail_execute" round
                @click="executeMove">执 行</el-button>
                @click="updateStockFun">执 行</el-button>
            </div>
          </div>
          <div>
@@ -191,6 +203,7 @@
      <!-- 弹窗, 明细的IFS库位列表 -->
      <detailIfsLocationDialog :currshowlist.sync="showDetailLocation" :detailList="detailList"
        @refreshDataList="selectDetailLocationCallback" />
    </basic-container>
  </div>
</template>
@@ -207,6 +220,7 @@
  executeMoveLocation,
  selectAll,
  updateStock,
  updataStatus,
} from '@/api/warehouse/pallettransports'
import { getByPalletTransId } from '@/api/plan/operationtask'
import ttable from '@/views/common/ztt-table.vue'
@@ -222,6 +236,12 @@
export default {
  data() {
    return {
      taskTypeArr: [
        {label:"草稿"},
        {label:"进行中"},
        {label:"已完成"},
    ],
    command:"",
      forbidden:false,
      partDesc: null,
      ajaxFun: palletTransportsFetchList,
@@ -369,6 +389,23 @@
    //     this.palletTransportsDetailData = []
    //   }
    // }
    // palletTransportsChange(val){
    //   console.log("=====");
    //   if(val){
    //       console.log(val);
    //       console.log(this.command,"11111")
    //   }else{
    //     console.log("--");
    //   }
    // }
    command: {
      handler(newVal) {
        if (newVal != '') {
          // 当 aa 为空字符串时触发的操作
          console.log('aa is now empty');
        }
      },
    }
  },
  created() {
     if(this.permissions.warehouse_pallettransports_edit){
@@ -395,7 +432,6 @@
    palletTransportsMaterialSelectionChange() {
      if(this.cid){
        selectAll({transportsId:this.cid}).then((res)=>{
          console.log(res.data.data);
              this.palletTransportsDetailData = res.data.data.map(el =>{
                return{
                  part_no:el.partNo,
@@ -409,9 +445,7 @@
                }
              })
        })
        }
        })}
      // this.palletTransportsMaterialMultipleSelection = val
      // if(val && val.length>0){
      //   let ids =[]
@@ -432,9 +466,28 @@
      //      }
      // }
    },
    //状态
    handleCommand(event){
      let str = ""
      console.log(event);
      if (event == "草稿") {
        str = "draft"
      }else if (event == "进行中") {
        str = "processing"
      }else{
        str = "finished"
      }
     if (this.cid) {
      updataStatus({id:this.cid,state:str}).then((res) =>{
        this.$refs.pallettransportsTable.getDataList()
      })
     }else{
        this.$message.error('请选择' + str + '的对象')
     }
    },
             // 单行选中
         handleCurrentChange(row) {
        console.log(row,"--->1");
        this.palletTransportsMaterialMultipleSelection = row
               // this.palletTransportsMaterialData.forEach((item) => {
               //    // 排他,每次选择时把其他选项都清除
@@ -646,7 +699,6 @@
    // 获取移库明细数据列表
    getPalletTransportsDetailData() {
      let transportsDetails =[]
      console.log(this.palletTransportsMaterialMultipleSelection,"----+");
      transportsDetails = this.palletTransportsMaterialMultipleSelection.map(el =>{
        return{
          partNo:el.partNo,
@@ -749,20 +801,25 @@
    },
    //改变
    moveLocation(val){
      console.log(val,"---->");
      let num = Number(val.transfer_quantity)
      if (val.state !="02submitted") {
            if(num >= 0){
              updateStock({id:val.id,transferQuantity:num}).then((res) =>{
              console.log(res,"------>1");
            this.getPalletTransportsMaterialData()
          })
        }else{
        this.$message.error('移库不能小于0')
      this.palletTransportsDetailMultipleSelection.forEach(el =>{
          el.transfer_quantity = num
      })
    },
    updateStockFun(){
      let data = []
      data = this.palletTransportsDetailMultipleSelection.map(el =>{
          return {
              id:el.id,
              transferQuantity:el.transfer_quantity
          }
      })
      updateStock(data).then((res) =>{
        if(res.data.code===0){
          this.getPalletTransportsMaterialData()
          this.executeMove()
        }
      }else{
        this.$message.error('移库已经执行')
      }
      })
    },
    // 执行移库
    executeMove() {
@@ -778,7 +835,6 @@
            flag = false
          }
        })
        console.log("-----------",flag,ids);
        if (flag) {
          executeMoveLocation(ids).then((response) => {
            const resData = response.data
@@ -802,6 +858,7 @@
      } else {
        this.$message.error('请选择移库明细')
      }
    },
    selectDetailLocationCallback() {
      this.getPalletTransportsDetailData()
@@ -812,7 +869,6 @@
      this.showDetailStock = true
    },
    palletTransportsDetailSelectionChange(val) {
      console.log(val,"-=-=-=");
      this.palletTransportsDetailMultipleSelection = val
    },
    getOptasks() {