feat: cm 标签模板支持配置打码器并增加喷码下发
- labeltemplate 弹窗与列表新增 打码器IP/端口 字段 - cm.js 增加 sendToCoder API 调用 - wpm_bx/wprList 操作列新增"喷码"按钮, 按"喷码模板"模板下发产品编号到打码器, 含 per-row loading 防重入 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
315a513c01
commit
ecd8fd8bec
|
|
@ -93,6 +93,14 @@ export default {
|
|||
`${config.API_URL}/cm/labeltemplate/commands/`,
|
||||
data);
|
||||
}
|
||||
},
|
||||
sendToCoder:{
|
||||
name: "下发到打码器",
|
||||
req: async function(id, data){
|
||||
return await http.post(
|
||||
`${config.API_URL}/cm/labeltemplate/${id}/send_to_coder/`,
|
||||
data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
<scTable ref="table" :apiObj="apiObj" row-key="id" @selection-change="selectionChange" hidePagination>
|
||||
<el-table-column label="#" type="index" width="50"></el-table-column>
|
||||
<el-table-column label="模板名称" prop="name" min-width="100"></el-table-column>
|
||||
<el-table-column label="打码器IP" prop="coder_ip" min-width="130"></el-table-column>
|
||||
<el-table-column label="端口" prop="coder_port" width="80"></el-table-column>
|
||||
<el-table-column label="创建时间" prop="create_time" min-width="150"></el-table-column>
|
||||
<el-table-column label="操作" fixed="right" align="center" width="140">
|
||||
<template #default="scope">
|
||||
|
|
@ -42,6 +44,12 @@
|
|||
:key="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="打码器IP">
|
||||
<el-input v-model="addForm.coder_ip" clearable placeholder="不填则该模板不向打码器下发"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="打码器端口">
|
||||
<el-input-number v-model="addForm.coder_port" :min="1" :max="65535" :controls="false"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="模板代码" prop="commands">
|
||||
<el-input v-model="addForm.commands" clearable :rows="9" type="textarea"></el-input>
|
||||
</el-form-item>
|
||||
|
|
@ -57,6 +65,8 @@
|
|||
id:"",
|
||||
name: "",
|
||||
commands: "",
|
||||
coder_ip: "",
|
||||
coder_port: 3100,
|
||||
};
|
||||
export default {
|
||||
name: 'labeltemplate',
|
||||
|
|
@ -138,6 +148,8 @@
|
|||
this.addForm.id=row.id;
|
||||
this.addForm.name=row.name;
|
||||
this.addForm.commands=row.commands.join("\n");
|
||||
this.addForm.coder_ip=row.coder_ip;
|
||||
this.addForm.coder_port=row.coder_port;
|
||||
this.limitedVisible = true;
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@
|
|||
<template #default="scope">
|
||||
<el-button v-if="mode=='ins'&&mgroupName=='毛坯检测后打码'" @click="QRCode(scope.row)" type="success">二维码</el-button>
|
||||
<el-button @click="printMaterial(scope.row)" type="primary">打签</el-button>
|
||||
<el-button @click="sendToCoder(scope.row)" type="warning" :loading="!!coderLoadingIds[scope.row.id]" :disabled="!!coderLoadingIds[scope.row.id]">喷码</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
|
@ -125,6 +126,7 @@ export default {
|
|||
wprTableHeight:500,
|
||||
printer_name:localStorage.getItem("printer_name"),
|
||||
apiObjPrint:this.$API.cm.labelmat.fromWm,
|
||||
coderLoadingIds:{},
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
|
|
@ -330,6 +332,41 @@ that.$API.wpm.prints.req(printer_ip, obj).then((response) => {
|
|||
that.$message.warning("请先设置打印机");
|
||||
}
|
||||
},
|
||||
//喷码: 通过名为'喷码模板'的标签模板向打码器下发产品编号
|
||||
sendToCoder(row){
|
||||
let that = this;
|
||||
if (that.coderLoadingIds[row.id]) return;
|
||||
that.coderLoadingIds = { ...that.coderLoadingIds, [row.id]: true };
|
||||
let templateName = '喷码模板';
|
||||
let tdata = {
|
||||
number: row.number,
|
||||
name: (row.material_name||'').split('|')[0],
|
||||
ofrom_name: that.ofromName,
|
||||
ofrom_batch: that.ofromBatch,
|
||||
};
|
||||
let release = () => {
|
||||
let map = { ...that.coderLoadingIds };
|
||||
delete map[row.id];
|
||||
that.coderLoadingIds = map;
|
||||
};
|
||||
that.$API.cm.labeltemplate.list.req({search: templateName, page: 0}).then((res) => {
|
||||
let list = Array.isArray(res) ? res : (res && res.results) || [];
|
||||
let template = list.find(t => t.name === templateName);
|
||||
if (!template) {
|
||||
that.$message.error(`未找到标签模板: ${templateName}`);
|
||||
release();
|
||||
return;
|
||||
}
|
||||
if (!template.coder_ip) {
|
||||
that.$message.error(`模板 ${templateName} 未配置打码器IP`);
|
||||
release();
|
||||
return;
|
||||
}
|
||||
that.$API.cm.labeltemplate.sendToCoder.req(template.id, {tdata}).then(() => {
|
||||
that.$message.success("喷码下发成功");
|
||||
}).finally(release);
|
||||
}).catch(release);
|
||||
},
|
||||
//本地更新数据
|
||||
handleSaveSuccess() {
|
||||
this.$refs.tables.refresh();
|
||||
|
|
|
|||
Loading…
Reference in New Issue