zouyu
2023-11-17 7b10179a35a079a098126a1cb3aea2e8d010704d
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
<template>
  <el-dialog
    width="60%"
    title="销售件"
    top="10vh"
    :visible.sync="innerVisible"
    append-to-body
    @close="$emit('update:currshowlist', false)"
    :show="currshowlist"
    class="part-dialog"
  >
    <el-form
      :model="dataForm"
      :rules="dataRule"
      ref="dataForm"
      label-width="120px"
      class="l-mes"
    >
      <el-row>
        <el-col :span="10">
          <el-form-item label="销售件号" prop="salesPartNo" label-width="60px">
            <el-input
              v-model="dataForm.salesPartNo"
              placeholder="销售件号"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item
            label="销售件描述"
            prop="salesPartName"
            label-width="80px"
          >
            <el-input
              v-model="dataForm.salesPartName"
              placeholder="销售件描述"
            ></el-input>
          </el-form-item>
        </el-col>
 
        <el-col :span="3" :offset="1">
          <el-button @click="getSelectPart">查询</el-button>
        </el-col>
      </el-row>
    </el-form>
    <el-table
      border
      v-loading="listLoading"
      :data="salesPartList"
      height="300px"
      highlight-current-row
      @current-change="handleCurrentChange"
    >
      <el-table-column
        prop="salesPartNo"
        label="销售件号"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="salesPartName"
        label="销售件描述"
        align="center"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column
        prop="partNo"
        label="库存件"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="partName"
        label="库存件描述"
        show-overflow-tooltip
        align="center"
      ></el-table-column>
      <el-table-column
        prop="ifsSalesUnit"
        label="销售计量单位"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="ifsConvFactor"
        label="库存转换因子"
        align="center"
      ></el-table-column>
    </el-table>
    <span slot="footer" class="dialog-footer">
      <el-button @click="innerVisible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>
 
<script>
import {
  querySalesPartStd,
  batchUpdateSalePartNo,
  queryPartPropertiesStd
} from '@/api/plan/customerorder'
 
export default {
  props: {
    currshowlist: {
      type: Boolean,
      default: false
    },
    multiSelect: {
      type: Boolean,
      default: false
    },
    customerOrderList: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      salesPartList: [],
      listLoading: false,
      currentRow: null,
      innerVisible: false,
      dataForm: {
        salesPartNo: '',
        salesPartName: '',
        voltageLevel: null,
        specifications: null,
        modelNumber: null
      },
      dataRule: {},
      voltageLevelLoading: false,
      voltageLevelOptions: [],
      modelNumberLoading: false,
      modelNumberOptions: [],
      specificationsLoading: false,
      specificationsOptions: []
    }
  },
  watch: {
    currshowlist() {
      this.innerVisible = this.currshowlist
      if (this.currshowlist) {
      }
    },
    innerVisible: {
      handler(newValue, oldValue) {
        if (newValue) {
          this.dataForm.salesPartNo = null
          this.dataForm.salesPartName = null
          this.salesPartList = []
        }
      },
      immediate: true
    }
  },
  methods: {
    remoteModelNumberMethod(query) {
      // this.dataForm.modelNumber = null
      if (query !== '') {
        this.modelNumberLoading = true
        const modelNumberParam = {
          key: '型号',
          value: query
        }
        queryPartPropertiesStd(modelNumberParam).then((response) => {
          this.modelNumberLoading = false
          this.modelNumberOptions = response.data.data
        })
      } else {
        this.modelNumberOptions = []
      }
    },
    remoteSpecificationsMethod(query) {
      // this.dataForm.specifications = null
      if (query !== '') {
        this.specificationsLoading = true
        const specificationsParam = {
          key: '规格',
          value: query
        }
        queryPartPropertiesStd(specificationsParam).then((response) => {
          this.specificationsLoading = false
          this.specificationsOptions = response.data.data
        })
      } else {
        this.specificationsOptions = []
      }
    },
    remoteVoltageLevelMethod(query) {
      // this.dataForm.voltageLevel = null
      if (query !== '') {
        this.voltageLevelLoading = true
        const voltageLevelParam = {
          key: '电压等级',
          value: query
        }
        queryPartPropertiesStd(voltageLevelParam).then((response) => {
          this.voltageLevelLoading = false
          this.voltageLevelOptions = response.data.data
        })
      } else {
        this.voltageLevelOptions = []
      }
    },
    // 根据搜索条件搜索ERP零件
    getSelectPart() {
      /* let salesDesc = ''
      if (
        this.dataForm.salesPartName != null &&
        this.dataForm.salesPartName != ''
      ) {
        salesDesc = '%' + this.dataForm.salesPartName + '%'
      }
      const queryParam = {
        CATALOG_NO: this.dataForm.salesPartNo,
        CATALOG_DESC: salesDesc
      } */
      const queryParam = {
        salesPartNo:
          this.dataForm.salesPartNo == null ? '' : this.dataForm.salesPartNo,
        salesPartDesc:
          this.dataForm.salesPartName == null ||
          this.dataForm.salesPartName == ''
            ? ''
            : '%' + this.dataForm.salesPartName + '%'
      }
      querySalesPartStd(queryParam).then((res) => {
        this.salesPartList = []
        const resData = res.data
        if (resData.code === 0) {
          const sales = resData.data
          if (sales) {
            let salesPart
            sales.forEach((item) => {
              salesPart = {
                salesPartNo: item.CATALOG_NO,
                salesPartName: item.CATALOG_DESC,
                partNo: item.PART_NO,
                partName: item.PART_DESC,
                ifsSalesUnit: item.SALES_UNIT_MEAS,
                ifsConvFactor: item.CONV_FACTOR,
                unit: item.UNIT_MEAS
              }
              this.salesPartList.push(salesPart)
            })
          }
        } else {
          this.$message.error('销售件查询出错')
        }
      })
    },
    handleCurrentChange(val) {
      this.currentRow = val
    },
    dataFormSubmit() {
      if (this.currentRow == null) {
        this.$message.error('请选择销售件')
      } else {
        const ids = []
        this.customerOrderList.forEach((item) => {
          ids.push(item.id)
        })
        const setDataForm = {
          partNo: this.currentRow.partNo,
          salesPartNo: this.currentRow.salesPartNo,
          salesPartName: this.currentRow.salesPartName,
          ifsSalesUnit: this.currentRow.ifsSalesUnit,
          ifsConvFactor: this.currentRow.ifsConvFactor,
          unit: this.currentRow.unit,
          updateIds: ids
        }
        batchUpdateSalePartNo(setDataForm).then((response) => {
          const reaData = response.data
          if (reaData.code === 0) {
            this.$emit('refreshCustomerOrder')
            this.innerVisible = false
            this.$message.success('设置销售件成功')
          } else {
            this.$message.error('设置销售件失败')
          }
        })
      }
    }
  }
}
</script>