## **添加模板样式**
**栏目位置** : CPS后台 - “基础数据” - “标签样式”

**添加内容**:

## **标记值修改(添加参数)**
需要直接在代码中修改,因为所谓标记值,其实就是一个html的id值 或 class 值,用来标记位置用

或

参数添加位置

## 添加标记值
labelStyles/styleModal.js 文件中修改代码
```
vm.flagValueOptions = {
autoBind: true,
dataTextField: "displayText",
dataValueField: "value",
optionLabel: abp.localization.localize("OptionLabel", "SRMBaseData"),
dataSource: [
{ value: 'addCode', displayText:'图号' },
{ value: 'cartonSN', displayText: '箱号' },
{ value: 'subIndxStr', displayText: '送货行号' },
{ value: 'asnQty', displayText: '送货总数' },
{ value: 'tenancyName', displayText: abp.localization.localize("ReceiveCompay", "SRMASNManage") },
{ value: 'asnCode', displayText: abp.localization.localize("ASNCode", "SRMASNManage") },
{ value: 'deliveryAddress', displayText: abp.localization.localize("DeliveryAddress", "SRMASNManage") },
{ value: 'supplierCode', displayText: abp.localization.localize("SupplierCode", "SRMBasic") },
{ value: 'supplierName', displayText: abp.localization.localize("SupplierName", "SRMBasic") },
{ value: 'poCode', displayText: abp.localization.localize("POCode", "SRMASNManage") },
{ value: 'materialCode', displayText: abp.localization.localize("MCode", "SRMBaseData") },
{ value: 'materialName', displayText: abp.localization.localize("MName", "SRMBaseData") },
{ value: 'materialDesc', displayText: abp.localization.localize("MDesc", "SRMBaseData") },
{ value: 'materialSpec', displayText: abp.localization.localize("MSpec", "SRMASNManage") },
{ value: 'materialUnit', displayText: abp.localization.localize("MUnit", "SRMBaseData") },
{ value: 'packingQty', displayText: abp.localization.localize("ASNQtyPrint", "SRMASNManage") },
{ value: 'printDate', displayText: abp.localization.localize("PrintDate", "SRMBaseData") },
{ value: 'mfgDate', displayText: abp.localization.localize("MFGDate", "SRMASNManage") },
{ value: 'lotNo', displayText: abp.localization.localize("LotNo", "SRMASNManage") },
{ value: 'mRemart', displayText: abp.localization.localize("MRemart", "SRMASNManage") },
{ value: 'mqrCode', displayText: abp.localization.localize("MQRCode", "SRMASNManage") },
]
}
};
```
## **标签使用(打印标签)**
html 代码 添加一个 打印按钮
~~~
<button type="button" class="btn btn-sm btn-default purple-plum" ng-click="vm.printCartonSN()" ><i class="fa fa-print"></i>打印</button>
~~~
js 添加打印事件
头部添加打印声明 appPrinter
```
angular.module('app').controller('mould.views.xxx.index', [
'$scope', 'appPrinter', '$uibModal',
function ($scope, appPrinter,$uibModal) {
```
~~~
vm.printCartonSN = function () {
// 通过接口从后台获取 标签 html 内容
xxxxService.getLabelStyleByCode("GOLDCartonBarCode").then(function (result) {
if (result.data != null) {
var nLabelStyle = result.data.labelContent;
var nLabelHtml = '';
// 添加固定的 html 外部结构
nLabelHtml += "<div style='margin-top:21px;margin-left:21px;margin-right:21px;'>";
for (var i = 0; i < vm.asnCartonSNDetails.length; i++) {
if (i !== 0) nLabelHtml += '<p style="margin:14px;"></p><div style="margin-top: 28px;">';
// 构建表格html 对象
nTable = $(nLabelStyle);
// 对 HTML 标签模块 中的标志参数用 实际的变量值代替
$('.tenancyName', nTable).html(vm.asn.tenancyName);
$('.asnCode', nTable).html(vm.asn.asnCode);
$('.deliveryAddress', nTable).html(vm.asn.deliveryAddress);
$('.supplierName', nTable).html(vm.asn.supplierName);
$('.supplierCode', nTable).html(vm.asn.supplierCode);
$('.poCode', nTable).html(vm.asnCartonSNDetails[i].poCode);
$('.materialCode', nTable).html(vm.asnCartonSNDetails[i].materialCode);
$('.materialName', nTable).html(vm.asnCartonSNDetails[i].materialName);
$('.materialDesc', nTable).html(vm.asnCartonSNDetails[i].materialDesc);
$('.materialUnit', nTable).html(vm.asnCartonSNDetails[i].materialUnit);
$('.packingQty', nTable).html(vm.asnCartonSNDetails[i].packingQty);
$('.printDate', nTable).html(moment().format("YYYY-MM-DD"));
$('.lotNo', nTable).html(vm.asnCartonSNDetails[i].lotNo);
$('.materialSpec', nTable).html("");
$('.mRemart', nTable).html(vm.asnCartonSNDetails[i].remark);
var mfgDate = new Date(vm.asnCartonSNDetails[i].mfDate);
$('.mfgDate', nTable).html(mfgDate.getFullYear() + "-" + (mfgDate.getMonth() + 1) + "-" + mfgDate.getDate());
$("#barCode", nTable).html('');
// 将barcode 转为一维码 方式
//var nBarCode = $("#barCode", nTable).kendoBarcode({
// type: "code128",
// value: vm.asnCartonSNDetails[i].cartonSN,
// width: 300,
// height: 50,
// text: {
// visible: true
// }
//});
// 将barcode 转为 二维码 方式
var nBarCode = $("#barCode", nTable).kendoQRCode({
value: vm.asnCartonSNDetails[i].cartonSN,
//errorCorrection: "H",
size: 80,
//color: "#166a83"
});
$('.barCode', nTable).css("padding-top", "1px").html(nBarCode);
// 输出 qr 二维码方式
$(".mqrCode", nTable).html('');
$(".mqrCode", nTable).html("<img style='margin:3px;float:left;' src='" + vm.asnCartonSNDetails[i].dmCode + "'/>");
nLabelHtml += nTable.get(0).outerHTML;
if (i !== 0) nLabelHtml += "</div>";
}
nLabelHtml += "</div>";
var nPrintHtml = nLabelHtml;
// 弹出打印框
appPrinter.print(nPrintHtml, true);
}
});
};
~~~
后台代码
~~~
/// <summary>
/// 根据标签编码获取标签样式
/// </summary>
/// <returns></returns>
Task<LabelStyle> GetLabelStyleByCode(string labelCode);
~~~
~~~
public async Task<LabelStyle> GetLabelStyleByCode(string labelCode)
{
if (labelCode.IsNullOrEmpty()) {
throw new UserFriendlyException("标签码不能为空");
}
var nLabelStyle = await _labelStyleRepository.FirstOrDefaultAsync(t => t.LabelTypeCode == labelCode);
if (nLabelStyle == null)
{
throw new UserFriendlyException(L("NoDefaultLabelStyle"));
}
return nLabelStyle;
}
~~~
点击打印的效果

## **数据库表**
CFG_LABEL_STYLE (CPS)
SRMLABELSTYLE (SRM)
- 命名规范
- baseService类规范
- 类创建规范
- 函数方法创建规范
- Linq规范
- API规范
- 注释规范
- EF数据迁移操作
- 常规更新
- __MigrationHistory 表没了的情况处理
- __MigrationHistory 数据记录被删
- __MigrationHistory 记录和本地更新文件不匹配
- migrate工具做数据迁移
- 同步服务
- 配置
- 错误
- ORA-03115: 不支持的网络数据类型或表示法
- MES平板常用代码
- 栏目说明
- 异步线程
- 委托(模拟触发事件)
- 添加菜单
- 添加按钮
- GridVIew列表使用
- 配置文件读写
- 弹窗提示
- 消息列表控件
- API网络接口配置
- 设置扫描枪钩子
- ScanerHook 的扫码勾子写法
- 当前全局变量
- 定时器,关闭当前窗口
- 单例模式窗口
- 配置参数
- 输入框回车事件
- 修改GridView 指定行背景颜色
- 调用窗口页面
- form窗体继承
- 控件焦点
- 串口
- 自动选择可用串口
- CPS常用代码
- 栏目说明
- 系统管理(基础模块)
- 基础数据(基础模块)
- 资料配置(基础模块)
- 质检管理
- 生产计划
- 库存交易单据(wms)
- Job 管理
- 设备管理
- 报表查询
- SMT查询
- EWI
- 消息推送服务
- 异步线程Task
- 创建权限
- 增删改查操作
- 修改
- 删除
- 添加
- 单个实体类查询
- 分页查询
- 列表查询
- 批量更新
- 发起HTTP请求
- 授权配置
- 文件上传(以excel导入为例)
- 获取当前目录的物理地址
- 使用GET的Query参数(http请求)
- 只传ID参数写法
- 关于前后端分离
- 前端
- 输入框自动大写
- 前端搜索列表页写法
- routes.js
- index.cshtml
- index.js
- 前端列表选择弹窗
- Grid高度自适应
- 弹窗提示
- 时间类型格式化
- 自动填充
- Grid控件多选处理
- 导出csv
- Grid锁定、冻结CheckBox
- 自定义弹出框写法
- 获取项目名词方法
- 获取当前路由信息
- 获取页面分页信息
- Grid 行详情写法
- EF 与 Dapper 同时使用方法
- EF查询扩展
- Dapper查询方式
- ISqlExecuter 查询方式
- 复杂业务处理方法(请求超时)
- 方法1:前端交互优化
- 方法2:后台任务
- 登录页面无法跳转,报错问题解决
- 重要接口
- 关于只传ID一个参数接口写法
- 添加一个单表查询、或简单页面
- 工序排序问题解决
- 数据库配置
- 工序序号排序
- 设置webconfig配置信息和使用
- 添加cookies
- 用户数据权限写法
- 字符串写法
- 日志打印
- 时间戳打印测试
- abp 依赖注入
- 编码转换
- TFS使用规范
- 申请授权
- 错误问题
- 平板提示“Object reference not ...”错误
- VS断点失效
- 对不起,在处理您的请求期间,产生了一个服务器内部错误
- 生成项目的时候没找到dll
- S2017 签名时出错: 未能对 bin\Debug\app.publish*.exe 签名。SignTool Error: No certificates were found
- CPS 提示“The build restored NuGet packages. Build the project again to include these packages in the build”
- 远程连接 报 CredSSP
- Linq 语句 “Unable to create a constant value of type 'System.Object'. ”
- 无法嵌入相互操作类
- Store update,insert,or delete statement affected
- 模块设计和打印功能
- 方式1:winform端标签模板
- 方式2:CPS网页标签模板
- 方式3:CPS打印Html网页内容
- index.cshtml
- index.js
- print.cshtml
- print.js
- CPS弹窗显示打印内容组件(JS)
- 打印代码
- AGV
- CPS端代码
- MES平板端代码
- 数据库表
- 区域类型
- EDI、WMS(U8反写)
- EDI数据库表
- WMS类型
- EDI类型
- CPS后台添加任务相关代码
- 采购到货
- 采购入库
- 领料出库(材料出库)
- 委外出库(材料出库)
- 生产工单出库(材料出库)
- 条码表
- 其他出库
- 销售出库
- 生产倒冲(材料出库)
- 执行任务(JuQuent.GoldServiceExportU8)
- 采购
- 产成品入库
- 材料出库
- SQL
- 规范语句模型
- 常用查询
- 优化案例
- Linq 转 string 输出
- 消息推送
- 基本架构
- 钉钉消息推送配置
- 微信消息推送配置
- 消息模板设置
- 接口
- 码云api
