wanshenmean
4 天以前 ce1292c9cf37195b6abd2699dfc5d6cb3e143c9b
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
//此js文件是用来自定义扩展业务代码,可以扩展一些自定义页面或者重新配置生成的代码
 
let extension = {
  components: {
    //查询界面扩展组件
    gridHeader: '',
    gridBody: '',
    gridFooter: '',
    //新建、编辑弹出框扩展组件
    modelHeader: '',
    modelBody: '',
    modelFooter: ''
  },
  tableAction: '',
  buttons: { view: [], box: [], detail: [] },
  methods: {
    onInit() {
      // 添加MES操作列
      this.columns.push({
        title: '操作',
        field: '操作',
        align: 'center',
        width: 280,
        fixed: 'right',
        render: (h, { row, column, index }) => {
          // 锁定状态不显示按钮
          // 状态: 7=出库锁定, 9=移库锁定, 99=组盘撤销, 199=入库撤销
          const lockedStatuses = [7, 9, 99, 199];
          if (lockedStatuses.includes(row.status)) {
            return <span style="color: #909399">暂无可执行操作</span>;
          }
 
          return (
            <div>
              <el-button
                type="primary"
                size="small"
                onClick={($e) => { this.handleBind(row); }}
              >绑定</el-button>
              <el-button
                type="warning"
                size="small"
                style="margin-left: 6px"
                onClick={($e) => { this.handleUnbind(row); }}
              >解绑</el-button>
              <el-button
                type="danger"
                size="small"
                style="margin-left: 6px"
                onClick={($e) => { this.handleNgReport(row); }}
              >NG上报</el-button>
            </div>
          );
        }
      });
    },
 
    // 托盘电芯绑定操作
    async handleBind(row) {
      try {
        await this.$confirm(`确认执行电芯绑定操作?\n电芯码:${row.serialNumber}`, "绑定确认", {
          confirmButtonText: "确认",
          cancelButtonText: "取消",
          type: "warning"
        });
 
        const result = await this.http.post("/api/StockInfoDetail/bindContainer", {
          palletCode: row.palletCode || "P001",
          sfcList: [row.serialNumber],
          location: row.location || "",
          operationType: 1
        }, "正在调用MES接口...");
 
        if (result.status) {
          this.$Message.success(result.message || "电芯绑定成功");
          this.$refs.table.load();
        } else {
          this.$error(result.message || "电芯绑定失败");
        }
      } catch (error) {
        if (error !== "cancel") {
          this.$error(error.message || "网络错误,请稍后重试");
        }
      }
    },
 
    // 托盘电芯解绑操作
    async handleUnbind(row) {
      try {
        await this.$confirm(`确认执行电芯解绑操作?\n电芯码:${row.serialNumber}`, "解绑确认", {
          confirmButtonText: "确认",
          cancelButtonText: "取消",
          type: "warning"
        });
 
        const result = await this.http.post("/api/StockInfoDetail/unbindContainer", {
          palletCode: row.palletCode || "P001",
          sfcList: [row.serialNumber]
        }, "正在调用MES接口...");
 
        if (result.status) {
          this.$Message.success(result.message || "电芯解绑成功");
          this.$refs.table.load();
        } else {
          this.$error(result.message || "电芯解绑失败");
        }
      } catch (error) {
        if (error !== "cancel") {
          this.$error(error.message || "网络错误,请稍后重试");
        }
      }
    },
 
    // 托盘NG电芯上报操作
    async handleNgReport(row) {
      try {
        await this.$confirm(`确认执行NG电芯上报操作?\n电芯码:${row.serialNumber}`, "NG上报确认", {
          confirmButtonText: "确认",
          cancelButtonText: "取消",
          type: "warning"
        });
 
        const result = await this.http.post("/api/StockInfoDetail/containerNgReport", {
          palletCode: row.palletCode || "P001",
          ngSfcList: [{
            sfc: row.serialNumber,
            ngCode: "NG001",
            ngEquipmentCode: "WCS_001",
            ngResourceCode: "RESOURCE_001"
          }]
        }, "正在调用MES接口...");
 
        if (result.status) {
          this.$Message.success(result.message || "NG上报成功");
          this.$refs.table.load();
        } else {
          this.$error(result.message || "NG上报失败");
        }
      } catch (error) {
        if (error !== "cancel") {
          this.$error(error.message || "网络错误,请稍后重试");
        }
      }
    },
 
    onInited() {
      // 框架初始化配置后
    },
    searchBefore(param) {
      return true;
    },
    searchAfter(result) {
      return true;
    },
    addBefore(formData) {
      return true;
    },
    updateBefore(formData) {
      return true;
    },
    rowClick({ row, column, event }) {
      this.$refs.table.$refs.table.toggleRowSelection(row);
    },
    modelOpenAfter(row) {
      // 点击编辑、新建按钮弹出框后
    }
  }
};
 
export default extension;