Fixiaobai
2023-11-15 5ff704af11fc13dd48a48e133652faf1e13d178d
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
<template>
  <el-dialog
    :visible.sync="visible"
    title="主生产计划来源:"
    :close-on-click-modal="false"
  >
    <el-table
      :data="masterPlanSourceDataList"
      class="source-table-calss"
      style="width: 100%"
    >
      <el-table-column
        show-overflow-tooltip
        label="客户订单号"
        prop="customerOrderNo"
      >
      </el-table-column>
      <el-table-column show-overflow-tooltip label="零件号" prop="partNo">
      </el-table-column>
      <el-table-column show-overflow-tooltip label="零件名称" prop="partName">
      </el-table-column>
      <el-table-column label="本次计划数量" prop="qtyPlaned">
        <template slot-scope="scope">
          <div v-if="!scope.row.visible">{{ scope.row.qtyPlaned }}</div>
          <el-input
            v-if="scope.row.visible"
            v-model="scope.row.qtyPlaned"
          ></el-input>
        </template>
      </el-table-column>
      <el-table-column label="期望交货时间" prop="wantedDeliveryDate">
      </el-table-column>
      <el-table-column label="备注" show-overflow-tooltip prop="remark">
      </el-table-column>
      <el-table-column
        header-align="center"
        align="center"
        label="操作"
        fixed="right"
        width="100"
        v-if="stateVisible"
      >
        <template slot-scope="scope">
          <el-button
            v-if="!scope.row.visible"
            type="text"
            size="small"
            icon="el-icon-edit"
            @click="showUpdate(scope.row)"
            >修改数量
          </el-button>
          <el-button
            v-if="scope.row.visible"
            type="text"
            size="small"
            @click="updateQtyPlaned(scope.row)"
            >保存
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div slot="footer" class="dialog-footer">
      <el-button type="info" @click="visible = false">关闭</el-button>
    </div>
  </el-dialog>
</template>
 
<script>
import { updateQtyPlaned } from '@/api/plan/masterproductionschedule'
import { loadMasterPlanSourceByCustomer } from '../../../api/plan/masterproductionschedule'
 
export default {
  data() {
    return {
      visible: false,
      state: '',
      masterPlanSourceDataList: []
    }
  },
  methods: {
    init(id, state) {
      this.visible = true
      this.state = state
      this.$nextTick(() => {
        loadMasterPlanSourceByCustomer(id).then((res) => {
          this.masterPlanSourceDataList = res.data.data
        })
      })
    },
    showUpdate(row) {
      this.$set(row, 'visible', true)
    },
    updateQtyPlaned(row) {
      updateQtyPlaned(row).then((res) => {
        this.$message.success('修改成功')
        this.$set(row, 'visible', false)
        this.$emit('refreshDataList')
      })
    }
  },
  computed: {
    stateVisible() {
      if (this.state && this.state === '01pending') {
        return true
      }
      return false
    }
  }
}
</script>
<style>
.source-table-calss .el-table__body-wrapper {
  height: auto;
}
</style>