1.0
zss
2023-11-15 a96e9c262ebadc2e7e731b28aa5035b0dd2a7aad
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
<template>
  <el-dialog
    width="60%"
    title="检测工艺路线"
    top="5vh"
    :visible.sync="innerVisible"
    append-to-body
    @close="$emit('update:currshowlist', false)"
    :show="currshowlist"
    class="part-dialog"
  >
    <el-table
      border
      v-loading="listLoading"
      :data="dataList"
      height="300px"
      @row-dblclick="doubleClick"
      @row-click="rowClick"
      highlight-current-row
      @current-change="handleCurrentChange"
    >
      <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.rowChecked"
          ></el-checkbox>
        </template>
      </el-table-column>
      <el-table-column prop="routingNo" label="工艺路线编号"></el-table-column>
      <el-table-column prop="partNo" label="零件号"></el-table-column>
      <el-table-column prop="partName" label="零件名称"></el-table-column>
      <el-table-column prop="bomNumber" label="Bom编号"></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 { getObj } from '@/api/technology/document'
 
export default {
  props: {
    currshowlist: {
      type: Boolean,
      default: false
    },
    multiSelect: {
      type: Boolean,
      default: false
    },
    dataFormId: {
      type: Number
    }
  },
  data() {
    return {
      dataList: [],
      listLoading: false,
      currentRow: null,
      multipleSelection: [],
      innerVisible: false,
      visible: false,
      dataRule: {}
    }
  },
  watch: {
    currshowlist() {
      this.innerVisible = this.currshowlist
      if (this.currshowlist) {
        this.getData()
      }
    },
    innerVisible: {
      handler(newValue, oldValue) {
        if (newValue) {
          this.dataList = []
        }
      },
      immediate: true
    }
  },
  methods: {
    // 根据搜索条件搜索ERP零件
    getData() {
      getObj(this.dataFormId).then((response) => {
        const res = response.data
        if (res.code === 0) {
          this.dataList = res.data.bomRoutings
        }
      })
    },
    // handleCurrentChange(val) {
    //   this.currentRow = val
    // },
    doubleClick() {
      this.dataFormSubmit()
    },
    rowClick(row) {
      this.currentRow = row
      this.dataFormId.forEach((item) => {
        if (row.id !== item.id) {
          this.$set(item, 'rowChecked', false)
        } else {
          this.$set(item, 'rowChecked', true)
        }
      })
    },
    handleCurrentChange(row) {
      if (row != null) {
        this.dataList.forEach((item) => {
          // 排他,每次选择时把其他选项都清除
          if (item.id !== row.id) {
            item.rowChecked = false
          } else {
            item.rowChecked = true
          }
        })
      } else {
        this.dataList.forEach((item) => {
          // 选项都清除
          item.rowChecked = false
        })
      }
      this.currentRow = row
    },
    dataFormSubmit() {
      // if (this.currentRow == null) {
      //   this.$message.error('请选择数据')
      //   return
      // }
      // if (this.multiSelect) {
      //   this.$emit('handleSelectionChange', this.multipleSelection)
      // } else {
      this.$emit('listenToPartEvent', this.currentRow)
      // }
      this.innerVisible = false
    }
  }
}
</script>