yirongjin
2025-07-23 c2da0b81321e66e3c3706d6833ad4c92c62d0935
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<template>
  <a-modal 
  title="确认操作" 
  :width="500" 
  v-model="visible" 
  :confirmLoading="confirmLoading"
  @ok="handleSubmit"
  @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
    <a-form :form="form">
      <a-form-item label="零件编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-input placeholder="请输入零件编号" :disabled="true" v-decorator="['partCode']" />
            </a-form-item>
      <a-form-item label="小车编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-input placeholder="请输入小车编号" :disabled="true" v-decorator="['containercode']" />
            </a-form-item>
      <a-form-item v-if="this.type != '入库'" label="货位编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-input placeholder="请输入货位编号" :disabled="true" v-decorator="['placecode']" />
            </a-form-item>
      <a-form-item v-if="this.type == '入库'" label="绑定库位" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-input placeholder="请输入货位编号" :disabled="true" v-decorator="['realLocationCode']" />
            </a-form-item>
    <a-form-item v-if="this.type == '出库'" label="出库口" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-select style="width: 100%" placeholder="请选择出库口" allow-Clear="true" v-decorator="['toPlace', {rules: [{ required: true, message: '请选择出库口!' }]}]">
                    <a-select-option v-for="(item,index) in siteNoData" :key="index" :value="item.lineType">{{ item.name }}</a-select-option>
                </a-select>
            </a-form-item>
      <a-form-item v-if="this.type == '入库'" label="入库口" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-select style="width: 100%" placeholder="请选择入库口" allow-Clear="true" v-decorator="['toPlace', {rules: [{ required: true, message: '请选择出库口!' }]}]">
                    <a-select-option v-for="(item,index) in siteNoData" :key="index" :value="item.lineType">{{ item.name }}</a-select-option>
                </a-select>
            </a-form-item>
      <a-form-item v-if="this.type == '移库'" label="目标库位" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-select style="width: 100%" showSearch="true" allow-Clear="true" placeholder="请选择目标库位" v-decorator="['toPlace', {rules: [{ required: true, message: '请选择目标库位!' }]}]">
                    <a-select-option v-for="(item,index) in placeData" :key="index" :value="item.code">{{ item.code }}</a-select-option>
                </a-select>
            </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>
 
<script>
  import {
    WareSiteList
  } from '@/api/modular/main/WareSiteManage'
  import { IexwarehouseManual, IexwarehouseAuto,GetMoveLocation,MovewarehouseManual,InwarehouseManual } from '@/api/modular/main/ExWarehouseManage'
export default {
  data() {
    return {
      labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 15 }
        },
      visible: false,
      confirmLoading: false,
      siteNoData:[],
      form: this.$form.createForm(this),
      type:'',
      placeData:[],
      containercodetemp:'',
    }
  },
  methods: {
    //3.定义一个函数,通过设置detailvisible值为true来让弹窗弹出,这个函数会在父组件的方法中被调用
    handle(record,type) {
      this.visible = true;
      this.type = type;
      this.containercodetemp = record.wareContainerCode;
      this.$nextTick(() => {
        this.form.setFieldsValue(
            {
              containercode: record.wareContainerCode,
              placecode: record.wareLocationCode,
              realLocationCode:record.realLocationCode,
              partCode:record.partCode,
              toPlace:this.toPlace,
            }
          )
      });
      this.getSiteNoData();
      this.getPlaceData();
    },
    getSiteNoData(){
      WareSiteList().then(res => {
            this.siteNoData = res.data
          })
    },
    getPlaceData(){
      let params = {containercode:this.containercodetemp};
      GetMoveLocation(params).then(res => {
              this.placeData = res.data
          })
    },
    handleSubmit () {
      const { form: { validateFields } } = this
        this.confirmLoading = true
        validateFields((errors, values) => {
          if (!errors) {
            for (const key in values) {
                if(values[key]==null){
                        values[key]=0
                }
              if (typeof (values[key]) === 'object') {
                values[key] = JSON.stringify(values[key])
              }
            }
            //let param = {Placecode:this.record.placecode,Containercode:this.record.containercode,toPlace:values.toPlace}
            if(this.type == '出库'){
              IexwarehouseManual(values).then((res) => {
               if (res.success) {
                 this.$message.success('出库成功')
                 this.confirmLoading = false
                 this.$emit('ok', values)
                 this.handleCancel()
               } else {
                 this.$message.error('出库失败:' + JSON.stringify(res.message))
               }
             }).finally((res) => {
               this.confirmLoading = false
             })
            }
            else if (this.type == '入库'){
              InwarehouseManual(values).then((res) => {
               if (res.success) {
                 this.$message.success('入库成功')
                 this.confirmLoading = false
                 this.$emit('ok', values)
                 this.handleCancel()
               } else {
                 this.$message.error('入库失败:' + JSON.stringify(res.message))
               }
             }).finally((res) => {
               this.confirmLoading = false
             })
            }
            else{
              MovewarehouseManual(values).then((res) => {
               if (res.success) {
                 this.$message.success('移库成功')
                 this.confirmLoading = false
                 this.$emit('ok', values)
                 this.handleCancel()
               } else {
                 this.$message.error('移库失败:' + JSON.stringify(res.message))
               }
             }).finally((res) => {
               this.confirmLoading = false
             })
            }
 
            
          } else {
            this.confirmLoading = false
          }
        })
      },
      handleCancel () {
        this.form.resetFields()
        this.visible = false
      }
  },
}
</script>