Fixiaobai
2023-10-13 e8308ddac0ba4a1f406e8f63d7e6b6f2541cb770
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
<template>
  <el-dialog
    v-diadrag
    title="执行"
    top="5vh"
    :close-on-click-modal="false"
    :visible.sync="visible"
    width="35%"
  >
    <el-table :data="dataList" stripe style="width: 100%" height="200px" border>
      <el-table-column
        prop="processNo"
        label="编号"
        width="160px"
      ></el-table-column>
      <el-table-column
        prop="defaultLocation"
        label="默认库位"
        width="180px"
      ></el-table-column>
      <el-table-column
        prop="targetLocation"
        label="目标库位"
        label-width="180px"
      >
        <template scope="scope">
          <el-input
            size="small"
            clearable
            v-model="scope.row.targetLocation"
            placeholder=""
          >
            <el-button
              slot="append"
              icon="el-icon-search"
              @click="openSelectTypePart(scope.$index, scope.row)"
            ></el-button
          ></el-input> </template
      ></el-table-column>
    </el-table>
 
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button
        type="primary"
        :disabled="isSubmit"
        v-thinclick="`dataFormSubmit`"
        >确定</el-button
      >
    </span>
    <!-- 库位 -->
    <loactionForm
      :currshowlist.sync="addtableVisible"
      ref="addtable"
      @refreshDataList="getDataState"
    />
  </el-dialog>
</template>
<script>
import {
  showDefaultLocation,
  executeByIds
} from '@/api/quality/unqualifiedprocess'
import loactionForm from './loaction-form'
 
export default {
  data() {
    return {
      visible: false,
      isSubmit: false,
      addtableVisible: false,
      //   paramObject: '',
      tableIndex: null,
      ids: null,
      idNum: [],
      dataList: [
        {
          id: 0,
          handler: null,
          processNo: null,
          defaultLocation: null,
          targetLocation: null
        }
      ],
      dataForm: [
        {
          id: 0,
          handler: null,
          processNo: null,
          defaultLocation: null,
          targetLocation: null
        }
      ]
    }
  },
  components: {
    loactionForm
  },
  methods: {
    init(row) {
      this.$nextTick(() => {
        this.idNum = []
        for (let i = 0; i < row.length; i++) {
          this.idNum.push({ id: row[i].id })
        }
 
        this.ids = []
        row.forEach((item) => {
          this.ids.push(item.id)
        })
        this.showDefaultLocation()
      })
    },
    showDefaultLocation() {
      showDefaultLocation(this.ids).then((res) => {
        this.dataForm = res.data.data
        this.dataList = []
        this.stateNum = []
        console.log(this.dataForm)
        for (let i = 0; i < this.dataForm.length; i++) {
          if (this.dataForm[i].isShow) {
            this.stateNum.push(this.dataForm[i].isShow)
            this.dataList.push(this.dataForm[i])
            this.visible = true
            return
          }
        }
        if (!this.stateNum.indexOf('true') != -1) {
          this.visible = false
          executeByIds(this.idNum).then((data) => {
            this.$message.success('保存成功')
            this.$emit('refreshDataList')
          })
        }
      })
    },
    openSelectTypePart(index, row) {
      //   console.log(row)
      //   if (row.processMode == 1 || row.processMode == 2) {
      //     this.paramObject = '6'
      //   }
      //   if (row.processMode == 4) {
      //     this.paramObject = '4'
      //   }
      //   if (row.processMode == 3) {
      //     this.paramObject = ''
      //   }
      this.addtableVisible = true
      this.tableIndex = index
    },
    getDataState(val) {
      console.log(val)
      if (val) {
        Object.assign(this.dataForm[this.tableIndex], {
          targetLocation: val.locName,
          targetLocationId: val.id
        })
      }
    },
    // 表单提交
    dataFormSubmit() {
      this.isSubmit = true
      executeByIds(this.dataForm)
        .then((data) => {
          this.$message.success('保存成功')
          this.visible = false
          this.isSubmit = false
          this.$emit('refreshDataList')
        })
        .catch((error) => {
          this.isSubmit = false
          console.log(error)
        })
    }
  }
}
</script>