zss
2023-11-17 2518e47a3ac999978fbf14612c967c3bbf421d25
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
<template>
  <div class="mod-config">
    <basic-container>
      <div class="avue-crud">
        <div style="text-align:right;">
          <el-button
            type="text"
            size="small"
            icon="el-icon-circle-plus-outline"
            style="color:#f56c6c;margin-right:10px;"
            @click="addMaterial()"
            >添加物料
          </el-button>
        </div>
        <el-table :data="dataList" border v-loading="dataListLoading">
          <el-table-column
            prop="partNo"
            header-align="center"
            align="center"
            label="零件号"
          >
          </el-table-column>
          <el-table-column
            prop="partName"
            header-align="center"
            align="center"
            label="零件名称"
          >
          </el-table-column>
          <el-table-column
            prop="optaskNo"
            header-align="center"
            align="center"
            label="工单编号"
          >
          </el-table-column>
          <el-table-column
            prop="quantityRequired"
            header-align="center"
            align="center"
            label="需求数量"
          >
          </el-table-column>
          <el-table-column
            prop="quantityIssued"
            header-align="center"
            align="center"
            label="已投料数量"
          >
          </el-table-column>
          <el-table-column
            prop="qpa"
            header-align="center"
            align="center"
            label="单位产出所需数量"
          >
          </el-table-column>
          <el-table-column
            header-align="center"
            align="center"
            label="操作"
            fixed="right"
            width="130"
          >
            <template slot-scope="scope">
              <el-button
                type="text"
                size="small"
                icon="el-icon-edit"
                @click="editMaterial(scope.row, scope.$index)"
                >修改
              </el-button>
              <el-button
                type="text"
                style="color:red;"
                size="small"
                icon="el-icon-delete"
                @click="deleteMaterial(scope.row, scope.$index)"
                >删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
 
      <!-- 弹窗, 新增 / 修改 -->
      <EditMaterialDialog
        :currshowlist.sync="showEditMaterial"
        :materialObj="materialObj"
        @refreshOperationMaterialList="refreshOperationMaterialList"
      />
    </basic-container>
  </div>
</template>
 
<script>
import { mapGetters } from 'vuex'
import {
  getOperationMaterialById,
  delOperationTaskMaterial
} from '../../../api/plan/operationtask'
import EditMaterialDialog from './editMaterial.vue'
 
export default {
  props: {
    operationId: {
      type: Number,
      default: 0
    },
    routingOperationId: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      dataForm: {
        key: ''
      },
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      addOrUpdateVisible: false,
      showEditMaterial: false,
      materialObj: {
        id: null,
        opTaskId: null
      }
    }
  },
  components: { EditMaterialDialog },
  watch: {
    routingOperationId: {
      handler(newValue, oldValue) {
        this.getDataList(this.operationId)
      },
      immediate: true
    }
  },
  computed: {
    ...mapGetters(['permissions'])
  },
  methods: {
    // 获取数据列表
    getDataList(id) {
      this.visible = true
      this.$nextTick(() => {
        getOperationMaterialById(id).then((response) => {
          this.dataList = response.data.data
        })
      })
    },
    refreshOperationMaterialList() {
      getOperationMaterialById(this.operationId).then((response) => {
        this.dataList = response.data.data
      })
    },
    // 添加物料
    addMaterial() {
      this.materialObj.id = null
      this.materialObj.opTaskId = this.operationId
 
      this.showEditMaterial = true
    },
    // 编辑物料
    editMaterial(row, index) {
      this.materialObj.id = row.id
      this.materialObj.opTaskId = this.operationId
 
      this.showEditMaterial = true
    },
    // 删除物料
    deleteMaterial(row, index) {
      delOperationTaskMaterial(row.id).then((response) => {
        this.$message.success('删除成功')
        this.refreshOperationMaterialList()
      })
    }
  }
}
</script>