wanshenmean
8 小时以前 853f7a71577bd8694c848985e1eb21c74d30eba9
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
<template>
  <div>
    <vol-box
      v-model="showDetialBox"
      :lazy="true"
      width="400px"
      :padding="15"
      title="选择机械手"
    >
      <div>
        <el-form>
          <el-form-item required label="机械手:">
            <el-select v-model="selectedRobot" placeholder="请选择机械手" style="width: 100%">
              <el-option
                v-for="item in robotList"
                :key="item.robotCode"
                :label="item.robotName"
                :value="item.robotCode"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-form>
      </div>
      <template #footer>
        <el-button type="primary" size="small" @click="submit">确认</el-button>
        <el-button type="danger" size="small" @click="close">关闭</el-button>
      </template>
    </vol-box>
  </div>
</template>
 
<script>
import VolBox from "@/components/basic/VolBox.vue";
export default {
  components: { VolBox },
  data() {
    return {
      showDetialBox: false,
      robotList: [
        { robotCode: '注液组盘机械手', robotName: '注液组盘机械手' },
        { robotCode: '高温换盘机械手', robotName: '高温换盘机械手' },
        { robotCode: '化成换盘机械手', robotName: '化成换盘机械手' },
        { robotCode: '拆盘机械手', robotName: '拆盘机械手' },
        { robotCode: '成品组盘机械手', robotName: '成品组盘机械手' }
      ],
      selectedRobot: '',
      currentRow: null,
      actionType: null // 'bind' or 'unbind'
    };
  },
  methods: {
    open(action, row) {
      this.actionType = action;
      this.currentRow = row;
      this.selectedRobot = '';
      this.showDetialBox = true;
    },
    close() {
      this.showDetialBox = false;
    },
    async submit() {
      if (!this.selectedRobot) {
        return this.$message.error("请选择机械手");
      }
 
      this.showDetialBox = false;
 
      try {
        if (this.actionType === 'bind') {
          // 组盘确认
          await this.$confirm(
            `确认执行托盘组盘操作?\n托盘编号:${this.currentRow.palletCode}\n机械手:${this.selectedRobot}`,
            "组盘确认",
            {
              confirmButtonText: "确认",
              cancelButtonText: "取消",
              type: "warning"
            }
          );
 
          const result = await this.http.post("/api/StockInfoDetail/BindContainer", {
            palletCode: this.currentRow.palletCode,
            DeviceName: this.selectedRobot
          }, "正在调用MES接口...");
 
          if (result.status) {
            this.$Message.success(result.message || "托盘组盘成功");
            this.$parent.$refs.table.load();
          } else {
            this.$error(result.message || "托盘组盘失败");
          }
        } else if (this.actionType === 'unbind') {
          // 拆盘确认
          await this.$confirm(
            `确认执行托盘拆盘操作?\n托盘编号:${this.currentRow.palletCode}\n机械手:${this.selectedRobot}`,
            "拆盘确认",
            {
              confirmButtonText: "确认",
              cancelButtonText: "取消",
              type: "warning"
            }
          );
 
          const result = await this.http.post("/api/StockInfoDetail/UnbindContainer", {
            palletCode: this.currentRow.palletCode,
            DeviceName: this.selectedRobot
          }, "正在调用MES接口...");
 
          if (result.status) {
            this.$Message.success(result.message || "托盘拆盘成功");
            this.$parent.$refs.table.load();
          } else {
            this.$error(result.message || "托盘拆盘失败");
          }
        }
      } catch (error) {
        if (error !== "cancel") {
          this.$error(error.message || "网络错误,请稍后重试");
        }
      }
    }
  }
};
</script>