Fixiaobai
2023-11-17 1f5009ddcc87f7a7db792d40206bdcf5462089ee
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
502
503
504
505
<template>
  <el-dialog
    width="50%"
    title="手动车间订单"
    top="5vh"
    :visible.sync="innerVisible"
    append-to-body
    @close="$emit('update:currshowlist', false)"
    :show="currshowlist"
    class="part-dialog"
    :close-on-click-modal="false"
  >
    <div>
      <div style="margin-bottom:20px;">
        <div style="margin-bottom:10px;">
          <span style="font-weight:bold;">相关需求零件</span>
        </div>
        <div style="display:flex;justify-content:space-between;">
          <div style="width:75%;">
            <el-form
              :inline="true"
              :model="productionScheduleForm"
              class="l-mes"
            >
              <el-form-item label="生产计划号">
                <el-input
                  v-model="productionScheduleForm.mpsNo"
                  disabled
                ></el-input>
              </el-form-item>
              <el-form-item label="需求日期">
                <el-input
                  v-model="productionScheduleForm.requiredDate"
                  disabled
                ></el-input>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <div>
          <el-table
            :data="requiredTable"
            border
            style="width: 100%"
            height="240"
            highlight-current-row
            @row-click="requiredRowClick"
          >
            <el-table-column
              prop="partNo"
              label="相关零件号"
              width="180"
              align="center"
            >
            </el-table-column>
            <el-table-column
              prop="partName"
              label="相关零件描述"
              width="180"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="quantity" label="需求数量" align="center">
            </el-table-column>
            <el-table-column
              prop="releasedQuantity"
              label="已下达数量"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="unit" label="计量单位" align="center">
            </el-table-column>
          </el-table>
        </div>
      </div>
      <div>
        <el-tabs
          class="partplan-orderapply-tabs"
          v-model="activeName"
          type="card"
          @tab-click="handleClick"
        >
          <el-tab-pane label="零件可用性计划" name="partPlan">
            <div>
              <el-form :inline="true" :model="partPlanForm" class="l-mes">
                <el-form-item label="现有数量">
                  <el-input
                    v-model="partPlanForm.existingQuantity"
                    disabled
                  ></el-input>
                </el-form-item>
                <el-form-item label="可用数量">
                  <el-input
                    v-model="partPlanForm.availableQuantity"
                    disabled
                  ></el-input>
                </el-form-item>
                <el-form-item label="计量单位">
                  <el-input v-model="partPlanForm.unit" disabled></el-input>
                </el-form-item>
              </el-form>
            </div>
            <div>
              <el-table
                :data="partPlanTable"
                border
                style="width: 100%"
                height="240"
              >
                <el-table-column
                  prop="expireTime"
                  label="到期日"
                  width="180"
                  align="center"
                >
                </el-table-column>
                <el-table-column
                  prop="orderType"
                  label="类型"
                  width="180"
                  align="center"
                >
                </el-table-column>
                <el-table-column prop="status" label="状态" align="center">
                </el-table-column>
                <el-table-column prop="supply" label="供应" align="center">
                </el-table-column>
                <el-table-column prop="demand" label="需求" align="center">
                </el-table-column>
                <el-table-column prop="reserved" label="已预留" align="center">
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
          <el-tab-pane label="车间订单申请" name="orderApply">
            <div>
              <el-table
                :data="orderApplyTable"
                border
                style="width: 100%"
                height="280"
                highlight-current-row
                @current-change="handleCurrentChange"
                class="order-apply-table"
                ref="orderApplyTable"
              >
                <el-table-column align="center" width="55">
                  <template slot="header" slot-scope="scope">
                    <i
                      class="el-icon-delete"
                      title="清空选中"
                      @click="clearCheckBox"
                    ></i>
                  </template>
                  <template slot-scope="scope">
                    <el-checkbox
                      class="master-manufacturingorder-apply-table-single-checkbox"
                      v-model="scope.row.commonChecked"
                      disabled
                    ></el-checkbox>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="proposalNo"
                  label="申请标识"
                  width="180"
                  align="center"
                >
                </el-table-column>
                <el-table-column
                  prop="applyType"
                  label="车间申请类型"
                  width="180"
                  align="center"
                >
                </el-table-column>
                <el-table-column prop="state" label="状态" align="center">
                </el-table-column>
                <el-table-column prop="soReqQty" label="数量" align="center">
                </el-table-column>
                <el-table-column prop="unit" label="计量单位" align="center">
                </el-table-column>
                <el-table-column
                  prop="beginDate"
                  label="开始日期"
                  align="center"
                >
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="innerVisible = false">取 消</el-button>
      <el-button type="primary" @click="createOrder">创建订单</el-button>
    </div>
    <!--创建车间订单-->
    <CreateOrder
      :currshowlist.sync="showCreateOrder"
      :masterProductionInfo="masterProductionInfo"
      @refreshManualOrder="refreshManualOrder"
      @closedOrder="closedOrder"
    >
    </CreateOrder>
    <!--产出批次-->
    <!--<OutPutBatch
      :currshowlist.sync="showOutPutBatch"
      :createOrderType="createOrderType"
      :outPutBatchList="outPutBatchList"
      @returnBatchData="returnBatchData"
    ></OutPutBatch>-->
  </el-dialog>
</template>
<script>
import {
  getTheoryQuantity,
  queryInventUseablePlanStd
} from '@/api/plan/masterproductionschedule'
import { queryShopOrderReqStd } from '@/api/plan/manufacturingorderapply'
import CreateOrder from './create-order'
export default {
  props: {
    currshowlist: {
      type: Boolean,
      default: false
    },
    manualMasterProduction: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  components: {
    CreateOrder
  },
  data() {
    return {
      innerVisible: false,
      showCreateOrder: false,
      productionScheduleForm: {
        id: null,
        mpsNo: null,
        requiredDate: null,
        manufactureAttr: null
      },
      requiredTable: [],
      activeName: 'partPlan',
      partPlanForm: {
        existingQuantity: null,
        availableQuantity: null,
        unit: null
      },
      partPlanTable: [],
      orderApplyTable: [],
      currRequiredRow: null,
      currOrderApplyRow: null,
      masterProductionInfo: null,
      outPutBatchList: [],
      qtyPlaned: 0,
      createOrderType: 'MANUAL',
      showOutPutBatch: false
    }
  },
  watch: {
    currshowlist() {
      this.innerVisible = this.currshowlist
      if (this.currshowlist) {
        this.initForm()
      }
    }
  },
  methods: {
    // 创建完制造订单的,回调
    refreshManualOrder() {
      this.initForm()
      this.$emit('refreshOrderFromManual')
    },
    // 初始化页面
    initForm() {
      this.currRequiredRow = null
      this.currOrderApplyRow = null
      this.masterProductionInfo = null
      this.requiredTable = []
      this.partPlanTable = []
      this.orderApplyTable = []
      this.partPlanForm = {
        existingQuantity: null,
        availableQuantity: null,
        unit: null
      }
      this.$nextTick(() => {
        this.productionScheduleForm.id = this.manualMasterProduction.id
        this.productionScheduleForm.mpsNo = this.manualMasterProduction.mpsNo
        this.productionScheduleForm.requiredDate = this.manualMasterProduction.requiredDate
        this.productionScheduleForm.manufactureAttr = this.manualMasterProduction.manufactureAttr
        getTheoryQuantity(this.manualMasterProduction.id, []).then(
          (response) => {
            const resData = response.data
            if (resData.code === 0) {
              const theories = resData.data
              if (theories.length > 0) {
                let requiredItem
                theories.forEach((item) => {
                  requiredItem = {
                    partId: item.partId,
                    partNo: item.partNo,
                    partName: item.partName,
                    routingId: item.routingId,
                    bomId: item.bomId,
                    orderQuantity: item.orderQuantity,
                    quantity: item.quantity,
                    releasedQuantity: item.releasedQuantity,
                    unit: item.unit,
                    id: item.id
                  }
                  this.requiredTable.push(requiredItem)
                })
              }
            }
          }
        )
      })
    },
    createOrder() {
      if (this.currRequiredRow != null) {
        this.masterProductionInfo = {
          mpsId: this.productionScheduleForm.id,
          manufactureAttr: this.productionScheduleForm.manufactureAttr,
          partId: this.currRequiredRow.partId,
          partNo: this.currRequiredRow.partNo,
          partName: this.currRequiredRow.partName,
          technologyRoutingId: this.currRequiredRow.routingId,
          bomId: this.currRequiredRow.bomId,
          orderQuantity: this.currRequiredRow.orderQuantity,
          ifsManuorderApplyNo:
            this.currOrderApplyRow != null
              ? this.currOrderApplyRow.proposalNo
              : null,
          scheduleTheoryQuantityId: this.currRequiredRow.id,
          dueDate:
            this.currOrderApplyRow != null
              ? this.currOrderApplyRow.dueDate
              : null,
          beginDate:
            this.currOrderApplyRow != null
              ? this.currOrderApplyRow.beginDate
              : null,
          soReqQty:
            this.currOrderApplyRow != null
              ? this.currOrderApplyRow.soReqQty
              : null,
          outPutBatchList: this.outPutBatchList,
          qtyPlaned: this.qtyPlaned
        }
        this.showCreateOrder = true
      } else {
        this.$message.error('请先选择相关需求零件,再创建车间订单!')
      }
    },
    requiredRowClick(row) {
      this.currRequiredRow = row
      this.getInventUseablePlan(row.partNo)
      this.getProductorderForm(row.partNo)
    },
    // 根据零件号,获取零件可用性计划
    getInventUseablePlan(partNo) {
      this.partPlanTable = []
      this.partPlanForm = {
        existingQuantity: null,
        availableQuantity: null,
        unit: null
      }
      queryInventUseablePlanStd({ partNo: partNo }).then((response) => {
        const resData = response.data
        if (resData.code === 0) {
          const dataForm = resData.data
          const dataFormList = dataForm.DETAILS
          this.partPlanForm.existingQuantity = dataForm.QTY_ONHAND
          this.partPlanForm.availableQuantity = dataForm.QTY_AVAILABLE
          this.partPlanForm.unit = dataForm.UNIT_MEAS
          if (dataFormList && dataFormList.length > 0) {
            let partPlan
            dataFormList.forEach((item) => {
              partPlan = {
                expireTime: item.DATE_REQUIRED,
                orderType: item.ORDER_TYPE,
                status: item.STATUS_DESC,
                supply: item.QTY_SUPPLY,
                demand: item.QTY_DEMAND,
                reserved: item.QTY_RESERVED
              }
              this.partPlanTable.push(partPlan)
            })
          }
        }
      })
    },
    // 根据零件号、车间订单类型为MRP、状态为已创建提议ProposalCreated
    getProductorderForm(partNo) {
      this.orderApplyTable = []
      const queryParam = {
        partNo: partNo,
        workshopTypeCode: 'MRP',
        state: 'ProposalCreated'
      }
      queryShopOrderReqStd(queryParam).then((response) => {
        const resData = response.data
        if (resData.code === 0) {
          const datas = resData.data
          if (datas.length > 0) {
            let data
            for (let i = 0; i < datas.length; i++) {
              data = datas[i]
              this.orderApplyTable.push({
                id: i + 1,
                partNo: data.PART_NO,
                partName: data.PART_DESC,
                applyTypeCode: data.SO_REQ_TYPE_DB,
                stateCode: data.STATE_DB,
                applyType: data.SO_REQ_TYPE,
                state: data.STATE,
                dueDate: data.REVISED_DUE_DATE,
                beginDate: data.PROP_START_DATE,
                createDate: data.DATE_ENTERED,
                createUser: data.PLANNER_BUYER,
                proposalNo: data.PROPOSAL_NO,
                soReqQty: data.SO_REQ_QTY,
                structVersion: data.STRUCT_VERSION,
                unit: data.UNIT_MEAS,
                commonChecked: false
              })
            }
          }
        } else {
          this.$message.error('查询车间订单申请失败!')
        }
      })
    },
    handleClick(tab, event) {},
    // 单行选中
    handleCurrentChange(row) {
      if (row != null) {
        this.orderApplyTable.forEach((item) => {
          // 排他,每次选择时把其他选项都清除
          if (item.id !== row.id) {
            item.commonChecked = false
          } else {
            item.commonChecked = true
          }
        })
      } else {
        this.orderApplyTable.forEach((item) => {
          // 选项都清除
          item.commonChecked = false
        })
      }
      this.currOrderApplyRow = row
    },
    clearCheckBox() {
      this.$refs.orderApplyTable.setCurrentRow()
    },
    closedOrder() {
      this.outPutBatchList = []
      this.qtyPlaned = 0
    },
    // 选中产出批次时的,回调
    returnBatchData(selectedObj) {
      //
      this.outPutBatchList = selectedObj.outPutBatchList
      this.qtyPlaned = selectedObj.qtyPlaned
    }
  }
}
</script>
<style scoped>
.partplan-orderapply-tabs >>> .el-tabs__item {
  font-weight: bold;
}
.master-manufacturingorder-apply-table-single-checkbox
  >>> .el-checkbox__input.is-disabled.is-checked
  .el-checkbox__inner {
  background-color: #006eff;
  border-color: #006eff;
}
.master-manufacturingorder-apply-table-single-checkbox
  >>> .el-checkbox__input.is-disabled
  .el-checkbox__inner {
  background-color: #ffffff;
  cursor: pointer;
}
.master-manufacturingorder-apply-table-single-checkbox
  >>> .el-checkbox__inner::after {
  border: 1px solid #fff !important;
  border-left: 0 !important;
  border-top: 0 !important;
  cursor: pointer !important;
}
.order-apply-table >>> .el-icon-delete {
  cursor: pointer;
  color: red;
}
</style>