cuilei
2025-06-16 1b8b8bafca4fe4c3556bda5e66e3ff6252bd7acc
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="出库单编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="outNum">
              <a-input :disabled="true" v-model="model.outNum" placeholder="系统自动生成"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="出库类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="outStorehouseType">
              <j-dict-select-tag :disabled="disableSubmit || addShow" @change="handleTypeChange" type="list" v-model="model.outStorehouseType" dictCode="out_storehouse_type" placeholder="请选择出库类型"/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="出库时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="outboundTime">
              <j-date :disabled="disableSubmit" :show-time="true" dateFormat="YYYY-MM-DD HH:mm" placeholder="请选择出库时间" v-model="model.outboundTime" style="width: 100%"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="领用事由" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="subjectMatter">
              <a-input :disabled="disableSubmit" v-model="model.subjectMatter" placeholder="请输入领用事由" ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="零件图号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="partDrawingNo">
              <a-input :disabled="disableSubmit" v-model="model.partDrawingNo" placeholder="请输入零件图号" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="零件名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="partName">
              <a-input :disabled="disableSubmit" v-model="model.partName" placeholder="请输入零件名称" ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="零件材料" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="partMaterial">
              <a-input :disabled="disableSubmit" v-model="model.partMaterial" placeholder="请输入零件材料" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="工序(工步号)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionProcessesNo">
              <a-input :disabled="disableSubmit" v-model="model.productionProcessesNo" placeholder="请输入工序(工步号)" ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="加工批次" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="batchCode">
              <a-input :disabled="disableSubmit" v-model="model.batchCode" placeholder="请输入加工批次" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="加工数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="machiningCount">
              <a-input-number :disabled="disableSubmit" v-model="model.machiningCount" placeholder="请输入加工数量" :min="1" style="width: 100%"></a-input-number>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="加工设备" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentCode">
              <a-input :disabled="disableSubmit" v-model="model.equipmentCode" placeholder="请输入加工设备" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="程序名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ncName">
              <a-input :disabled="disableSubmit" v-model="model.ncName" placeholder="请输入程序名" ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="审核人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="reviewer">
              <j-select-user-by-dep :disabled="disableSubmit" v-model="model.reviewer" :store="'username'" :text="'realname'" :multi="false" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item v-if="addShow" label="经手人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="handler">
              <j-select-user-by-dep v-model="model.handler" :store="'id'" :text="'realname'" :multi="false" disabled/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12">
            <a-form-model-item v-if="addShow" label="单子状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderStatus">
              <j-dict-select-tag type="list" v-model="model.orderStatus" dictCode="out_bill_status" placeholder="请选择单子状态" disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item v-if="addShow" label="审核时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="auditDate">
              <j-date placeholder="请选择审核时间" :show-time="true" dateFormat="YYYY-MM-DD HH:mm" v-model="model.auditDate" style="width: 100%" disabled/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12">
            <a-form-model-item v-if="addShow" label="审核意见" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="approvalOpinion">
              <a-input v-model="model.approvalOpinion" placeholder="请输入审核意见" disabled></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
              <a-textarea :disabled="disableSubmit" v-model="model.remark" rows="4" placeholder="请输入备注" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
 
    <a-button v-show="selectBorrowTool" type="primary" :style="{ marginBottom: '8px' }" @click="selectBorrowOutBoundTool">选择出库工具</a-button>
    <a-button v-show="selectSharpenTool" type="primary" :style="{ marginBottom: '8px' }" @click="selectSharpenOutBoundTool">选择刃磨工具</a-button>
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      :scroll="{x:true}"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      :rowSelection="null"
      @change="handleTableChange">
 
      <template v-for="col in columns" :slot="col.dataIndex" slot-scope="text, record, index">
        <div :key="col.dataIndex">
          <a-input-number
            v-if="col.dataIndex === 'outboundQuantity'"
            :disabled="record.accuracyClass === '1'"
            :value="text"
            @change="(e) => handleChange(e, record.key, col, index)"
            :min="1"
          />
 
          <a-input-number
            v-if="col.dataIndex === 'ratedLife'"
            :disabled="record.quantity > 1"
            :value="text"
            @change="(e) => handleChange(e, record.key, col, index)"
            :min="1"
          />
          <a-input-number
            v-if="col.dataIndex === 'useLife'"
            :disabled="record.quantity > 1"
            :value="text"
            @change="(e) => handleChange(e, record.key, col, index)"
            :min="1"
          />
        </div>
      </template>
      <span slot="action" v-if="disableSubmit === false" slot-scope="text, record, index">
        <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record, index)">
          <a>删除</a>
        </a-popconfirm>
      </span>
    </a-table>
    <template slot="footer" v-if="disableSubmit === false">
      <a-button :style="{ marginRight: '8px' }" @click="handleCancel">关闭</a-button>
      <a-button @click="handleOk" :disabled="isDisabled" type="primary">确定</a-button>
    </template>
 
    <j-select-borrow-outbound-tool-modal ref="selectBorrowOutBoundToolModal"></j-select-borrow-outbound-tool-modal>
    <j-select-sharpen-outbound-tool-modal ref="selectSharpenOutBoundToolModal"></j-select-sharpen-outbound-tool-modal>
  </j-modal>
 
</template>
 
<script>
 
  import { httpAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
  import OutboundDetailList from '../../OutboundDetailList.vue'
  import JSelectBorrowOutboundToolModal from './JSelectBorrowOutboundToolModal.vue'
  import JSelectSharpenOutboundToolModal from './JSelectSharpenOutboundToolModal.vue'
  import { getAction } from '../../../../api/manage'
  import title from 'ant-design-vue/lib/skeleton/Title'
 
  export default {
    name: "OutboundOrderModal",
    components: {
      OutboundDetailList,
      JSelectBorrowOutboundToolModal,
      JSelectSharpenOutboundToolModal
    },
    data () {
      return {
        title: '',
        width:1200,
        visible: false,
        disableSubmit: false,
        isDisabled: false,
        addShow: true,
        selectBorrowTool: false,
        selectSharpenTool: false,
        model:{
        },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        //表格参数
        ipagination: {
          current: 1,
          pageSize: 10,
          total: 0,
        },
        dataSource: [],
        loading: false,
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'工具编码',
            align:"center",
            dataIndex: 'toolNum'
          },
          {
            title:'工具编号',
            align:"center",
            dataIndex: 'toolId'
          },
          {
            title:'可用库存',
            align:"center",
            dataIndex: 'quantity'
          },
          {
            title:'申请出库数量',
            align:"center",
            dataIndex: 'outboundQuantity',
            scopedSlots: { customRender: 'outboundQuantity' },
          },
          {
            title:'出库仓库',
            align:"center",
            dataIndex: 'warehouseName'
          },
          {
            title:'出库库位',
            align:"center",
            dataIndex: 'outboundLocation'
          },
        //    {
        //   title:'额定寿命',
        //   align:"center",
        //   dataIndex: 'ratedLife',
        //   scopedSlots: { customRender: 'ratedLife' },
        // },
        // {
        //   title:'使用寿命',
        //   align:"center",
        //   dataIndex: 'useLife',
        //   scopedSlots: { customRender: 'useLife' },
        // },
          // {
          //   title:'出库状态;1.未出库;2.部分出库;3.出库完成',
          //   align:"center",
          //   dataIndex: 'status'
          // },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' },
          }
        ],
        confirmLoading: false,
        validatorRules: {
           outStorehouseType: [
              { required: true, message: '请选择出库类型!'},
           ],
           subjectMatter: [
              { required: true, message: '请输入领用事由!'},
           ],
          reviewer: [
              { required: true, message: '请选择审核人!'},
           ],
          outboundTime: [
              { required: true, message: '请选择出库时间!'},
           ],
        },
        url: {
          list: "/tms/outboundOrder/listOutboundDetailByMainId",
          add: "/tms/outboundOrder/addTotal",
          edit: "/tms/outboundOrder/editTotal",
        }
 
      }
    },
    created () {
    //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    mounted() {
      this.$bus.$on('selectionRows', (data) => {
        for (let i = 0; i < data.length; i++) {
          this.dataSource.push({
            id: data[i].id,
            toolCode:data[i].toolCode,
            toolNum:data[i].toolNum,
            toolId: data[i].toolId,
            quantity: data[i].quantity,
            outboundQuantity: data[i].quantity,
            storageLocation: data[i].warehouseId,
            warehouseName: data[i].warehouseName,
            outboundLocation: data[i].positionCode,
            accuracyClass:data[i].accuracyClass
          })
        }
        this.ipagination.total = this.dataSource.length
      })
    },
    methods: {
      handleTypeChange(value) {
        if (value === '1') {
          this.selectBorrowTool = true
          this.selectSharpenTool = false
          this.dataSource = []
        }
        if (value === '2') {
          this.selectBorrowTool = false
          this.selectSharpenTool = false
          this.dataSource = []
        }
        if (value === '3') {
          this.selectBorrowTool = false
          this.selectSharpenTool = false
          this.dataSource = []
        }
        if (value === '4') {
          this.selectBorrowTool = false
          this.selectSharpenTool = true
          this.dataSource = []
        }
      },
      handleDelete(record, index) {
        this.dataSource.splice(index, 1)
      },
      handleChange(value, key, column, index) {
        console.log(value, key, column, index)
        const temp = [...this.dataSource]
        const target = temp.filter(item => key === item.key)[index];
        if (target) {
          target[column.dataIndex] = value
          this.dataSource = temp
          if(column.dataIndex === 'outboundQuantity'){
            if(target['quantity']<value){
              this.$message.error('申请出库数量不能大于可用库存!')
              this.isDisabled = true
            }else{
              this.isDisabled = false
            }
          }
          this.dataSource = temp
        }
      },
      selectBorrowOutBoundTool() {
        console.log(this.dataSource)
        let ids = ''
        if (this.title === '新增') {
          ids = this.dataSource.map(item => item.id).join(',')
        }
        if (this.title === '编辑') {
         ids = this.dataSource.map(item => item.toolLedgerDetailId).join(',')
        }
        this.$refs.selectBorrowOutBoundToolModal.showOrderModal(ids)
      },
      selectSharpenOutBoundTool() {
        console.log(this.dataSource)
        let ids = ''
        if (this.title === '新增') {
          ids = this.dataSource.map(item => item.id).join(',')
        }
        if (this.title === '编辑') {
          ids = this.dataSource.map(item => item.toolSharpeningId).join(',')
        }
        this.$refs.selectSharpenOutBoundToolModal.showOrderModal(ids)
      },
      add () {
        this.addShow = false
        this.edit(this.modelDefault);
        this.dataSource = []
      },
      edit (record) {
        if (record.id) {
          getAction(this.url.list,{ outStorehouseId : record.id }).then(res => {
            if (res.success) {
              this.dataSource = res.result.records
            }
            if (this.title === '编辑') {
              const type = record.outStorehouseType
              switch (type) {
                case '1':
                  this.selectBorrowTool = true
                  this.selectSharpenTool = false
                  break
                case '2':
                  this.selectBorrowTool = false
                  this.selectSharpenTool = false
                  break
                case '3':
                  this.selectBorrowTool = false
                  this.selectSharpenTool = false
                  break
                case '4':
                  this.selectBorrowTool = false
                  this.selectSharpenTool = true
                  break
              }
            }
          })
        }
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      close () {
        this.$emit('close');
        this.addShow = true
        this.selectBorrowTool = false
        this.selectSharpenTool = false
        this.visible = false;
        this.$refs.form.clearValidate();
      },
      handleTableChange(pagination, filters, sorter) {
        this.ipagination = pagination
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            if (this.dataSource == null || this.dataSource.length === 0) {
              this.$message.warning('请选择出库工具!');
              return
            }
            this.model.outboundDetailList = this.dataSource
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }else{
             return false
          }
        })
      },
      handleCancel () {
        this.close()
      },
 
 
    }
  }
</script>