zouyu
2023-11-17 d8ac6057eaad648687699e25a575f3b7b8c1b102
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
<template>
  <el-dialog
    width="900px"
    title="退料"
    :visible.sync="innerVisible"
    append-to-body
    @close="$emit('update:currshowlist', false)"
    :show="currshowlist"
  >
    <div class="app-container">
      <div class="avue-crud">
        <el-table
          v-loading="listLoading"
          :key="tableKey"
          :data="dataList"
          border
          style="width: 100%;"
          @cell-dblclick="dblhandleCurrentChange"
        >
          <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="partBatchNo"
            header-align="center"
            align="center"
            label="零件批号"
          >
          </el-table-column>
          <el-table-column
            prop="specs"
            header-align="center"
            align="center"
            label="规格型号"
          >
          </el-table-column>
          <el-table-column
            prop="returnQuantity"
            header-align="center"
            align="center"
            label="退料数量"
          >
            <template scope="scope">
              <el-input
                size="small"
                v-model="scope.row.returnQuantity"
                placeholder="请输入数量"
                @blur="inputblur"
                v-focus
                clearable
              ></el-input>
              <!--<span v-if="!scope.row.returnQuantityFlag">{{scope.row.returnQuantity}}</span>-->
            </template>
          </el-table-column>
          <el-table-column
            prop="returnLocationId"
            header-align="center"
            align="center"
            width="180"
            label="退料库位"
          >
            <template scope="scope">
              <el-select v-model="scope.row.returnLocationId" filterable>
                <el-option
                  v-for="item in optionsList['库位']"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="innerVisible = false">取 消</el-button>
      <el-button type="primary" @click="saveReturnMaterial">退 料</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { returnMaterial, getReturnLocations } from '@/api/product/personboard'
export default {
  props: {
    currshowlist: {
      type: Boolean,
      default: false
    },
    dataList: {
      type: Array
    },
    workstationId: {
      type: Number
    }
  },
  data() {
    return {
      innerVisible: false,
      listLoading: false,
      tableKey: 0,
      optionsList: {
        库位: []
      }
    }
  },
  directives: {
    focus: {
      inserted: function(el, option) {
        var defClass = 'el-input'
        var defTag = 'input'
        var value = option.value || true
        if (typeof value === 'boolean')
          value = { cls: defClass, tag: defTag, foc: value }
        else
          value = {
            cls: value.cls || defClass,
            tag: value.tag || defTag,
            foc: value.foc || false
          }
        // if (el.classList.contains(value.cls) && value.foc)
        el.getElementsByTagName(value.tag)[0].focus()
      }
    }
  },
  methods: {
    dblhandleCurrentChange(row, column, cell, event) {
      switch (column.label) {
        case '退料数量':
          this.$set(row, 'returnQuantityFlag', true)
          break
      }
    },
    inputblur(row, event, column, cell) {
      var _this = this
      const tableD = _this.dataList
      tableD.forEach(function(item) {
        _this.$set(item, 'returnQuantityFlag', false)
      })
    },
    saveReturnMaterial() {
      // 调用退料接口,然后刷新线边仓、投料列表
      var feeds = []
      var feed
      for (var i = 0; i < this.dataList.length; i++) {
        feed = {}
        feed.id = this.dataList[i].id
        feed.systemNo = this.dataList[i].systemNo
        feed.partBatchNo = this.dataList[i].partBatchNo
        feed.partId = this.dataList[i].partId
        feed.returnQuantity = this.dataList[i].returnQuantity
        feed.returnLocationId = this.dataList[i].returnLocationId
        feed.workstationId = this.workstationId
        feeds.push(feed)
      }
      if (feeds.length > 0) {
        // 退料
        returnMaterial(feeds)
          .then((response) => {
            var data = response.data
            if (data.code == 0) {
              this.$message.success('退料成功')
            } else {
              this.$message.error('退料失败')
            }
            // 刷新线边仓、投料列表
            this.$emit('refreshFeedList')
            this.innerVisible = false
          })
          .catch((error) => {})
      }
    },
    getLoc() {
      getReturnLocations(this.workstationId).then((response) => {
        this.optionsList['库位'] = response.data.data.map((e) => {
          return { value: e.id, label: e.locName }
        })
        this.dataList.forEach((e) => {
          this.$set(e, 'returnLocationId', this.optionsList['库位'][0].value)
        })
      })
    }
    /*
      getDataList() {
        this.listLoading = true;
        //查询选中线边仓零件的最新库存
        this.listLoading = false;
      } */
  },
  watch: {
    currshowlist() {
      this.innerVisible = this.currshowlist
      if (this.currshowlist) {
        // this.getList();
        this.getLoc()
      }
    }
  },
  mounted() {
    // this.getDataList();
  }
}
</script>