|
|
@@ -0,0 +1,104 @@
|
|
|
+<template>
|
|
|
+ <el-dialog title="替换品号" :visible.sync="dialogVisible" width="900px" append-to-body @open="listData" @close="onClose">
|
|
|
+ <el-table
|
|
|
+ ref="multipleTable"
|
|
|
+ :data="replaceList"
|
|
|
+ style="width: 100%"
|
|
|
+ border
|
|
|
+ size="small"
|
|
|
+ @selection-change="onSelectionChange">
|
|
|
+ <el-table-column type="selection" width="55" align="center"></el-table-column>
|
|
|
+ <el-table-column prop="itemname" label="产品名称" min-width="160"></el-table-column>
|
|
|
+ <el-table-column prop="itemno" label="产品编号" min-width="120"></el-table-column>
|
|
|
+ <el-table-column prop="erpitemno" label="erp品号" min-width="120"></el-table-column>
|
|
|
+ <el-table-column prop="erpitemno2" label="替换品号" min-width="120"></el-table-column>
|
|
|
+ <el-table-column prop="model" label="型号" min-width="120"></el-table-column>
|
|
|
+ <el-table-column prop="spec" label="规格" min-width="120"></el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <span slot="footer">
|
|
|
+ <el-button size="small" @click="dialogVisible = false">取 消</el-button>
|
|
|
+ <el-button size="small" type="primary" @click="onSubmit">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ props: {
|
|
|
+ visible: Boolean,
|
|
|
+ data: Object,
|
|
|
+ selection: Array
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ dialogVisible: {
|
|
|
+ get() { return this.visible },
|
|
|
+ set(val) { this.$emit('update:visible', val) }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ replaceList: [],
|
|
|
+ selectedRows: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async listData() {
|
|
|
+ if (!this.selection || this.selection.length === 0) return
|
|
|
+ const itemids = this.selection.map(e => e.itemid)
|
|
|
+ const res = await this.$api.requested({
|
|
|
+ id: 2026051315322802,
|
|
|
+ content: { itemids }
|
|
|
+ })
|
|
|
+ this.replaceList = res.data || []
|
|
|
+ },
|
|
|
+ onSelectionChange(selection) {
|
|
|
+ this.selectedRows = selection
|
|
|
+ },
|
|
|
+ async onSubmit() {
|
|
|
+ if (this.selectedRows.length === 0) {
|
|
|
+ this.$message.warning('请选择要替换的品号')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const items = []
|
|
|
+ let hasEmpty = false
|
|
|
+ for (const row of this.selectedRows) {
|
|
|
+ if (!row.erpitemno2) {
|
|
|
+ this.$message.warning(`${row.itemname || '未知'}不存在备用品号,不进行替换`)
|
|
|
+ hasEmpty = true
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ const matchedLines = this.selection.filter(s => s.itemid === row.itemid)
|
|
|
+ for (const line of matchedLines) {
|
|
|
+ items.push({
|
|
|
+ sa_orderitemsid: line.sa_orderitemsid,
|
|
|
+ itemno: line.itemno,
|
|
|
+ erpitemno: row.erpitemno2
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (items.length === 0) {
|
|
|
+ if (!hasEmpty) {
|
|
|
+ this.$message.warning('没有可替换的品号')
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const res = await this.$api.requested({
|
|
|
+ id: 2026051315353402,
|
|
|
+ content: {
|
|
|
+ sa_orderid: this.data.sa_orderid,
|
|
|
+ items
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.tool.showMessage(res, () => {
|
|
|
+ this.$message.success('替换成功')
|
|
|
+ this.dialogVisible = false
|
|
|
+ this.$emit('onSuccess')
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onClose() {
|
|
|
+ this.replaceList = []
|
|
|
+ this.selectedRows = []
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|