Fixiaobai
2023-10-25 ae87b881865d0b6812aba2a8928cadb9ef6dd62a
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
<template>
  <el-dialog
    width="60%"
    title="IFS库位"
    top="5vh"
    :visible.sync="innerVisible"
    append-to-body
    @close="$emit('update:currshowlist', false)"
    :show="currshowlist"
    class="part-dialog"
  >
    <div style="display:flex;margin-bottom:10px;">
      <div style="display:flex;align-items:center;">
        <div>
          <span>库位号:</span>
        </div>
        <div>
          <el-input
            class="detail-ifs-location-input"
            v-model="dataForm.locationNo"
          ></el-input>
        </div>
      </div>
      <div style="display:flex;align-items:center;margin-left:10px;">
        <div>
          <span>库位描述:</span>
        </div>
        <div>
          <el-input
            class="detail-ifs-location-input"
            v-model="dataForm.locationDesc"
          ></el-input>
        </div>
      </div>
      <div style="margin-left:10px;">
        <el-button type="primary" @click="queryLocation">查询</el-button>
      </div>
    </div>
    <el-table
      class="ifs-location-table"
      :data="ifsLocationData"
      style="width: 100%;"
      height="450px"
      border
      @current-change="handleCurrentChange"
      stripe
      ref="detailIfsLocationTable"
    >
      <el-table-column align="center" width="55" label="单选">
        <template slot-scope="scope">
          <el-checkbox
            class="detail-ifs-location-table-single-checkbox"
            v-model="scope.row.commonChecked"
            disabled
          ></el-checkbox>
        </template>
      </el-table-column>
      <el-table-column type="index" width="50" label="序号"> </el-table-column>
      <el-table-column prop="locationNo" label="库位号" align="center">
      </el-table-column>
      <el-table-column
        prop="locationDesc"
        label="库位描述"
        align="center"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="locationGroupDesc"
        label="库位组描述"
        align="center"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="locationTypeDesc"
        label="库位类型描述"
        align="center"
        show-overflow-tooltip
      >
      </el-table-column>
    </el-table>
    <div slot="footer" class="dialog-footer">
      <el-button @click="innerVisible = false">取 消</el-button>
      <el-button
        type="primary"
        :disabled="isSubmit"
        v-thinclick="`saveSelectRow`"
        >确 定</el-button
      >
    </div>
  </el-dialog>
</template>
<script>
import { getIfsLocationByGroup } from '@/api/warehouse/location'
import { IFSUpdate } from '@/api/warehouse/returnstock'
export default {
  components: {},
  props: {
    currshowlist: {
      type: Boolean,
      default: false
    },
    transportsList: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      innerVisible: false,
      isSubmit: false,
      dataForm: {
        locationNo: null,
        locationDesc: null
      },
      ifsLocationData: [],
      currLocationRow: null
    }
  },
  methods: {
    // 查询ifs库位列表
    queryLocation() {
      this.ifsLocationData = []
      getIfsLocationByGroup({
        locationNo: this.dataForm.locationNo,
        locationDesc: this.dataForm.locationDesc
      }).then((response) => {
        if (response.data.code === 0) {
          const _data = response.data.data
          this.ifsLocationData = _data.map((item, index) => {
            return {
              id: index + 1,
              locationNo: item.LOCATION_NO,
              locationDesc: item.LOCATION_DESC,
              locationGroupDesc: item.LOCATION_GROUP_DESC,
              locationTypeDesc: item.LOCATION_TYPE_DESC,
              commonChecked: false
            }
          })
        }
      })
    },
    // 单行选中
    handleCurrentChange(row) {
      if (row != null) {
        this.ifsLocationData.forEach((item) => {
          // 排他,每次选择时把其他选项都清除
          if (item.id !== row.id) {
            item.commonChecked = false
          } else {
            item.commonChecked = true
          }
        })
      } else {
        this.ifsLocationData.forEach((item) => {
          // 选项都清除
          item.commonChecked = false
        })
      }
      this.currLocationRow = row
    },
    saveSelectRow() {
      this.isSubmit = true
      const transportsMaterials = []
      this.transportsList.forEach((item) => {
        transportsMaterials.push({
          id: item.id,
          stockId: item.stockId,
          ifsBatchNo: item.ifsBatchNo,
          ifsFromLocationName: item.ifsFromLocationName,
          ifsFromLocationNo: item.ifsFromLocationNo,
          partNo: item.partNo,
          partDesc: item.partName,
          reverseQuantity: item.reverseQuantity,
          sn: item.sn,
          reverseApplyId: item.reverseApplyId,
          unit: item.unit,
          state: item.state,
          ifsToLocationName: this.currLocationRow.locationDesc,
          ifsToLocationNo: this.currLocationRow.locationNo
        })
      })
      console.log(transportsMaterials)
      IFSUpdate(transportsMaterials)
        .then((response) => {
          const resData = response.data
          if (resData.code === 0) {
            this.innerVisible = false
            this.$message.success('设定至库位成功')
            this.$emit('refreshDataList')
          } else {
            this.$message.error('设定至库位失败')
          }
          this.isSubmit = false
        })
        .catch(() => {
          this.isSubmit = false
        })
    },
    initData() {
      this.currLocationRow = null
      this.dataForm.locationNo = null
      this.dataForm.locationDesc = null
    }
  },
  watch: {
    currshowlist() {
      this.innerVisible = this.currshowlist
      if (this.currshowlist) {
        this.initData()
        this.ifsLocationData = []
        this.$nextTick(() => {})
      }
    }
  }
}
</script>
<style scoped>
.part-dialog .el-dialog__header {
  padding: 10px 20px 10px;
}
.part-dialog .el-dialog__header .el-dialog__headerbtn {
  top: 10px;
}
.part-dialog .el-dialog__body {
  padding: 5px 20px;
}
 
.part-dialog .el-dialog__footer {
  padding: 5px 20px 10px;
}
 
.part-dialog .el-dialog__body .avue-crud__pagination {
  margin-top: 0px;
  margin-bottom: 5px;
}
.detail-ifs-location-input >>> .el-input__inner {
  border-top: none;
  border-left: none;
  border-right: none;
  padding: 0;
  border-radius: 0;
}
.detail-ifs-location-table-single-checkbox
  >>> .el-checkbox__input.is-disabled.is-checked
  .el-checkbox__inner {
  background-color: #006eff;
  border-color: #006eff;
}
.detail-ifs-location-table-single-checkbox
  >>> .el-checkbox__input.is-disabled
  .el-checkbox__inner {
  background-color: #ffffff;
  cursor: pointer;
}
.detail-ifs-location-table-single-checkbox >>> .el-checkbox__inner::after {
  border: 1px solid #fff !important;
  border-left: 0 !important;
  border-top: 0 !important;
  cursor: pointer !important;
}
</style>