😎1、优化打印模板流程 2、更新前端请求文件
This commit is contained in:
parent
b5a309efc5
commit
6df14aa43a
@ -66,4 +66,10 @@ public partial class SysPrint : EntityTenant
|
|||||||
[SugarColumn(ColumnDescription = "备注", Length = 128)]
|
[SugarColumn(ColumnDescription = "备注", Length = 128)]
|
||||||
[MaxLength(128)]
|
[MaxLength(128)]
|
||||||
public string? Remark { get; set; }
|
public string? Remark { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 打印预览测试数据
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "打印预览测试数据", ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
||||||
|
public string? PrintDataDemo { get; set; }
|
||||||
}
|
}
|
||||||
@ -21,6 +21,11 @@ public class PageJobDetailInput : BasePageInput
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string JobId { get; set; }
|
public string JobId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 组名称
|
||||||
|
/// </summary>
|
||||||
|
public string GroupName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 描述信息
|
/// 描述信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -41,8 +41,9 @@ public class SysJobService : IDynamicApiController, ITransient
|
|||||||
public async Task<SqlSugarPagedList<JobDetailOutput>> PageJobDetail(PageJobDetailInput input)
|
public async Task<SqlSugarPagedList<JobDetailOutput>> PageJobDetail(PageJobDetailInput input)
|
||||||
{
|
{
|
||||||
var jobDetails = await _sysJobDetailRep.AsQueryable()
|
var jobDetails = await _sysJobDetailRep.AsQueryable()
|
||||||
.WhereIF(!string.IsNullOrWhiteSpace(input.JobId), u => u.JobId.Contains(input.JobId))
|
.WhereIF(!string.IsNullOrWhiteSpace(input.JobId), u => u.JobId.Contains(input.JobId.Trim()))
|
||||||
.WhereIF(!string.IsNullOrWhiteSpace(input.Description), u => u.Description.Contains(input.Description))
|
.WhereIF(!string.IsNullOrWhiteSpace(input.GroupName), u => u.GroupName.Contains(input.GroupName.Trim()))
|
||||||
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Description), u => u.Description.Contains(input.Description.Trim()))
|
||||||
.Select(d => new JobDetailOutput
|
.Select(d => new JobDetailOutput
|
||||||
{
|
{
|
||||||
JobDetail = d,
|
JobDetail = d,
|
||||||
@ -64,6 +65,15 @@ public class SysJobService : IDynamicApiController, ITransient
|
|||||||
return jobDetails;
|
return jobDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取作业组名称集合 ⏰
|
||||||
|
/// </summary>
|
||||||
|
[DisplayName("获取作业组名称集合")]
|
||||||
|
public async Task<List<string>> ListJobGroup()
|
||||||
|
{
|
||||||
|
return await _sysJobDetailRep.AsQueryable().Distinct().Select(e => e.GroupName).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加作业 ⏰
|
/// 添加作业 ⏰
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import { Configuration } from '../configuration';
|
|||||||
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
|
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
|
||||||
import { AddJobDetailInput } from '../models';
|
import { AddJobDetailInput } from '../models';
|
||||||
import { AddJobTriggerInput } from '../models';
|
import { AddJobTriggerInput } from '../models';
|
||||||
|
import { AdminResultListString } from '../models';
|
||||||
import { AdminResultListSysJobCluster } from '../models';
|
import { AdminResultListSysJobCluster } from '../models';
|
||||||
import { AdminResultListSysJobTrigger } from '../models';
|
import { AdminResultListSysJobTrigger } from '../models';
|
||||||
import { AdminResultSqlSugarPagedListJobDetailOutput } from '../models';
|
import { AdminResultSqlSugarPagedListJobDetailOutput } from '../models';
|
||||||
@ -411,6 +412,49 @@ export const SysJobApiAxiosParamCreator = function (configuration?: Configuratio
|
|||||||
options: localVarRequestOptions,
|
options: localVarRequestOptions,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 获取作业组名称集合 ⏰
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
apiSysJobListJobGroupPost: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
|
const localVarPath = `/api/sysJob/listJobGroup`;
|
||||||
|
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||||
|
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
|
||||||
|
let baseOptions;
|
||||||
|
if (configuration) {
|
||||||
|
baseOptions = configuration.baseOptions;
|
||||||
|
}
|
||||||
|
const localVarRequestOptions :AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
|
||||||
|
const localVarHeaderParameter = {} as any;
|
||||||
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
|
// authentication Bearer required
|
||||||
|
// http bearer authentication required
|
||||||
|
if (configuration && configuration.accessToken) {
|
||||||
|
const accessToken = typeof configuration.accessToken === 'function'
|
||||||
|
? await configuration.accessToken()
|
||||||
|
: await configuration.accessToken;
|
||||||
|
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
const query = new URLSearchParams(localVarUrlObj.search);
|
||||||
|
for (const key in localVarQueryParameter) {
|
||||||
|
query.set(key, localVarQueryParameter[key]);
|
||||||
|
}
|
||||||
|
for (const key in options.params) {
|
||||||
|
query.set(key, options.params[key]);
|
||||||
|
}
|
||||||
|
localVarUrlObj.search = (new URLSearchParams(query)).toString();
|
||||||
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
|
||||||
|
options: localVarRequestOptions,
|
||||||
|
};
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 获取作业分页列表 ⏰
|
* @summary 获取作业分页列表 ⏰
|
||||||
@ -1091,6 +1135,19 @@ export const SysJobApiFp = function(configuration?: Configuration) {
|
|||||||
return axios.request(axiosRequestArgs);
|
return axios.request(axiosRequestArgs);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 获取作业组名称集合 ⏰
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async apiSysJobListJobGroupPost(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<AdminResultListString>>> {
|
||||||
|
const localVarAxiosArgs = await SysJobApiAxiosParamCreator(configuration).apiSysJobListJobGroupPost(options);
|
||||||
|
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||||
|
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
||||||
|
return axios.request(axiosRequestArgs);
|
||||||
|
};
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 获取作业分页列表 ⏰
|
* @summary 获取作业分页列表 ⏰
|
||||||
@ -1343,6 +1400,15 @@ export const SysJobApiFactory = function (configuration?: Configuration, basePat
|
|||||||
async apiSysJobJobTriggerListGet(jobId?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultListSysJobTrigger>> {
|
async apiSysJobJobTriggerListGet(jobId?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultListSysJobTrigger>> {
|
||||||
return SysJobApiFp(configuration).apiSysJobJobTriggerListGet(jobId, options).then((request) => request(axios, basePath));
|
return SysJobApiFp(configuration).apiSysJobJobTriggerListGet(jobId, options).then((request) => request(axios, basePath));
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 获取作业组名称集合 ⏰
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async apiSysJobListJobGroupPost(options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultListString>> {
|
||||||
|
return SysJobApiFp(configuration).apiSysJobListJobGroupPost(options).then((request) => request(axios, basePath));
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 获取作业分页列表 ⏰
|
* @summary 获取作业分页列表 ⏰
|
||||||
@ -1556,6 +1622,16 @@ export class SysJobApi extends BaseAPI {
|
|||||||
public async apiSysJobJobTriggerListGet(jobId?: string, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultListSysJobTrigger>> {
|
public async apiSysJobJobTriggerListGet(jobId?: string, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultListSysJobTrigger>> {
|
||||||
return SysJobApiFp(this.configuration).apiSysJobJobTriggerListGet(jobId, options).then((request) => request(this.axios, this.basePath));
|
return SysJobApiFp(this.configuration).apiSysJobJobTriggerListGet(jobId, options).then((request) => request(this.axios, this.basePath));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 获取作业组名称集合 ⏰
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
* @memberof SysJobApi
|
||||||
|
*/
|
||||||
|
public async apiSysJobListJobGroupPost(options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultListString>> {
|
||||||
|
return SysJobApiFp(this.configuration).apiSysJobListJobGroupPost(options).then((request) => request(this.axios, this.basePath));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 获取作业分页列表 ⏰
|
* @summary 获取作业分页列表 ⏰
|
||||||
|
|||||||
@ -146,6 +146,14 @@ export interface AddPrintInput {
|
|||||||
*/
|
*/
|
||||||
remark?: string | null;
|
remark?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印预览测试数据
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof AddPrintInput
|
||||||
|
*/
|
||||||
|
printDataDemo?: string | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 名称
|
* 名称
|
||||||
*
|
*
|
||||||
|
|||||||
@ -90,6 +90,14 @@ export interface PageJobDetailInput {
|
|||||||
*/
|
*/
|
||||||
jobId?: string | null;
|
jobId?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组名称
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof PageJobDetailInput
|
||||||
|
*/
|
||||||
|
groupName?: string | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述信息
|
* 描述信息
|
||||||
*
|
*
|
||||||
|
|||||||
@ -85,6 +85,14 @@ export interface SysOAuthUser {
|
|||||||
*/
|
*/
|
||||||
isDelete?: boolean;
|
isDelete?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮箱
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof SysOAuthUser
|
||||||
|
*/
|
||||||
|
email?: string | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统用户Id
|
* 系统用户Id
|
||||||
*
|
*
|
||||||
@ -147,14 +155,6 @@ export interface SysOAuthUser {
|
|||||||
*/
|
*/
|
||||||
avatar?: string | null;
|
avatar?: string | null;
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮箱
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof SysOAuthUser
|
|
||||||
*/
|
|
||||||
email?: string | null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手机号码
|
* 手机号码
|
||||||
*
|
*
|
||||||
|
|||||||
@ -153,4 +153,12 @@ export interface SysPrint {
|
|||||||
* @memberof SysPrint
|
* @memberof SysPrint
|
||||||
*/
|
*/
|
||||||
remark?: string | null;
|
remark?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印预览测试数据
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof SysPrint
|
||||||
|
*/
|
||||||
|
printDataDemo?: string | null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -146,6 +146,14 @@ export interface UpdatePrintInput {
|
|||||||
*/
|
*/
|
||||||
remark?: string | null;
|
remark?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印预览测试数据
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof UpdatePrintInput
|
||||||
|
*/
|
||||||
|
printDataDemo?: string | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 名称
|
* 名称
|
||||||
*
|
*
|
||||||
|
|||||||
@ -8,6 +8,11 @@
|
|||||||
<el-input v-model="state.queryParams.jobId" placeholder="作业编号" clearable @keyup.enter.native="handleQuery" />
|
<el-input v-model="state.queryParams.jobId" placeholder="作业编号" clearable @keyup.enter.native="handleQuery" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-form-item label="组名称">
|
||||||
|
<el-select v-model="state.queryParams.groupName" placeholder="组名称" clearable>
|
||||||
|
<el-option v-for="item in state.groupsData" :key="item" :label="item" :value="item" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
||||||
<el-form-item label="描述信息" prop="description">
|
<el-form-item label="描述信息" prop="description">
|
||||||
<el-input v-model="state.queryParams.description" placeholder="描述信息" clearable @keyup.enter.native="handleQuery" />
|
<el-input v-model="state.queryParams.description" placeholder="描述信息" clearable @keyup.enter.native="handleQuery" />
|
||||||
@ -265,6 +270,7 @@ const editJobClusterRef = ref<InstanceType<typeof JobCluster>>();
|
|||||||
const state = reactive({
|
const state = reactive({
|
||||||
queryParams: {
|
queryParams: {
|
||||||
jobId: undefined,
|
jobId: undefined,
|
||||||
|
groupName: undefined,
|
||||||
description: undefined,
|
description: undefined,
|
||||||
},
|
},
|
||||||
jobPageParam: {
|
jobPageParam: {
|
||||||
@ -283,6 +289,7 @@ const state = reactive({
|
|||||||
currentJob: {} as any,
|
currentJob: {} as any,
|
||||||
visible: false,
|
visible: false,
|
||||||
title: '',
|
title: '',
|
||||||
|
groupsData: [] as Array<string>,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 表格参数配置
|
// 表格参数配置
|
||||||
@ -321,7 +328,10 @@ const optionsJob = useVxeTable<JobDetailOutput>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 页面初始化
|
// 页面初始化
|
||||||
onMounted(async () => {});
|
onMounted(async () => {
|
||||||
|
const { data } = await getAPI(SysJobApi).apiSysJobListJobGroupPost();
|
||||||
|
state.groupsData = data.result ?? [];
|
||||||
|
});
|
||||||
|
|
||||||
// 查询api
|
// 查询api
|
||||||
const handleQueryApi = async (page: VxeGridPropTypes.ProxyAjaxQueryPageParams, sort: VxeGridPropTypes.ProxyAjaxQuerySortCheckedParams) => {
|
const handleQueryApi = async (page: VxeGridPropTypes.ProxyAjaxQueryPageParams, sort: VxeGridPropTypes.ProxyAjaxQuerySortCheckedParams) => {
|
||||||
@ -337,6 +347,7 @@ const handleQuery = async () => {
|
|||||||
// 重置操作
|
// 重置操作
|
||||||
const resetQuery = async () => {
|
const resetQuery = async () => {
|
||||||
state.queryParams.jobId = undefined;
|
state.queryParams.jobId = undefined;
|
||||||
|
state.queryParams.groupName = undefined;
|
||||||
state.queryParams.description = undefined;
|
state.queryParams.description = undefined;
|
||||||
await xGridJob.value?.commitProxy('reload');
|
await xGridJob.value?.commitProxy('reload');
|
||||||
};
|
};
|
||||||
@ -362,7 +373,7 @@ const handleDelete = (row: JobDetailOutput) => {
|
|||||||
})
|
})
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
await getAPI(SysJobApi).apiSysJobDeleteJobDetailPost({ jobId: row.jobDetail?.jobId });
|
await getAPI(SysJobApi).apiSysJobDeleteJobDetailPost({ jobId: row.jobDetail?.jobId });
|
||||||
handleQuery();
|
await handleQuery();
|
||||||
ElMessage.success('删除成功');
|
ElMessage.success('删除成功');
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
@ -408,7 +419,7 @@ const delJobTrigger = (row: SysJobTrigger) => {
|
|||||||
})
|
})
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
await getAPI(SysJobApi).apiSysJobDeleteJobTriggerPost({ jobId: row.jobId, triggerId: row.triggerId });
|
await getAPI(SysJobApi).apiSysJobDeleteJobTriggerPost({ jobId: row.jobId, triggerId: row.triggerId });
|
||||||
handleQuery();
|
await handleQuery();
|
||||||
ElMessage.success('删除成功');
|
ElMessage.success('删除成功');
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
@ -520,7 +531,7 @@ const handleFold = () => {
|
|||||||
// 打开作业触发器运行记录
|
// 打开作业触发器运行记录
|
||||||
const openJobTriggerRecord = async (row: any) => {
|
const openJobTriggerRecord = async (row: any) => {
|
||||||
state.currentJob = row;
|
state.currentJob = row;
|
||||||
state.recordPageParam.jobId = row?.jobDetail?.jobId;
|
// state.recordPageParam.jobId = row?.jobDetail?.jobId;
|
||||||
state.isVisibleDrawer = true;
|
state.isVisibleDrawer = true;
|
||||||
await handleQueryRecord();
|
await handleQueryRecord();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -127,6 +127,7 @@ const openDialog = (row: any) => {
|
|||||||
// 加载模板
|
// 加载模板
|
||||||
const loadTemplate = () => {
|
const loadTemplate = () => {
|
||||||
hiprintDesignRef.value?.hiprintTemplate.clear();
|
hiprintDesignRef.value?.hiprintTemplate.clear();
|
||||||
|
hiprintDesignRef.value?.setPrintDataDemo(state.ruleForm.printDataDemo);
|
||||||
if (JSON.stringify(state.ruleForm) !== '{}') {
|
if (JSON.stringify(state.ruleForm) !== '{}') {
|
||||||
hiprintDesignRef.value?.hiprintTemplate.update(JSON.parse(state.ruleForm.template));
|
hiprintDesignRef.value?.hiprintTemplate.update(JSON.parse(state.ruleForm.template));
|
||||||
hiprintDesignRef.value?.initPaper();
|
hiprintDesignRef.value?.initPaper();
|
||||||
@ -156,6 +157,8 @@ const templateSubmit = async () => {
|
|||||||
let templateJson = hiprintDesignRef.value?.hiprintTemplate.getJson();
|
let templateJson = hiprintDesignRef.value?.hiprintTemplate.getJson();
|
||||||
templateJson.panels[0].index = hiprintDesignRef.value?.mode;
|
templateJson.panels[0].index = hiprintDesignRef.value?.mode;
|
||||||
state.ruleForm.template = JSON.stringify(templateJson);
|
state.ruleForm.template = JSON.stringify(templateJson);
|
||||||
|
const printDataDemo = hiprintDesignRef.value?.printDataDemo;
|
||||||
|
state.ruleForm.printDataDemo = printDataDemo;
|
||||||
if (state.ruleForm.id != undefined && state.ruleForm.id > 0) {
|
if (state.ruleForm.id != undefined && state.ruleForm.id > 0) {
|
||||||
await getAPI(SysPrintApi).apiSysPrintUpdatePost(state.ruleForm);
|
await getAPI(SysPrintApi).apiSysPrintUpdatePost(state.ruleForm);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -82,11 +82,19 @@
|
|||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6" class="params_setting_container">
|
<el-col :span="6" class="params_setting_container">
|
||||||
|
<el-tabs type="border-card">
|
||||||
|
<el-tab-pane label="属性" style="height: auto">
|
||||||
<el-card shadow="never" :body-style="{ padding: '0px' }">
|
<el-card shadow="never" :body-style="{ padding: '0px' }">
|
||||||
<el-row class="hinnn-layout-sider">
|
<el-row class="hinnn-layout-sider">
|
||||||
<div id="PrintElementOptionSetting"></div>
|
<div id="PrintElementOptionSetting"></div>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
</el-tab-pane>
|
||||||
|
<el-tab-pane label="测试数据">
|
||||||
|
<el-input v-model="printDataDemo" type="textarea" style="width: 100%" rows="30" placeholder="对整个文档的完整测试数据"></el-input>
|
||||||
|
<el-button @click="formatPrintDataDemo()" style="margin-top: 10px; width: 100%" type="success">格式化字符串</el-button>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
@ -107,7 +115,7 @@ import 'vue-json-pretty/lib/styles.css';
|
|||||||
import { hiprint } from 'vue-plugin-hiprint';
|
import { hiprint } from 'vue-plugin-hiprint';
|
||||||
import providers from './providers';
|
import providers from './providers';
|
||||||
import PrintPreview from './preview.vue';
|
import PrintPreview from './preview.vue';
|
||||||
import printData from './print-data';
|
import printDataDefault from './print-data';
|
||||||
|
|
||||||
var props = defineProps({
|
var props = defineProps({
|
||||||
modeIndex: {
|
modeIndex: {
|
||||||
@ -120,6 +128,7 @@ let hiprintTemplate = ref();
|
|||||||
let mode = ref(0); // 模板选择
|
let mode = ref(0); // 模板选择
|
||||||
|
|
||||||
const preViewRef = ref();
|
const preViewRef = ref();
|
||||||
|
const printDataDemo = ref('');
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
modeList: [] as any,
|
modeList: [] as any,
|
||||||
// 当前纸张
|
// 当前纸张
|
||||||
@ -154,6 +163,14 @@ const state = reactive({
|
|||||||
width: 250,
|
width: 250,
|
||||||
height: 175.6,
|
height: 175.6,
|
||||||
},
|
},
|
||||||
|
'4R': {
|
||||||
|
width: 152,
|
||||||
|
height: 102,
|
||||||
|
},
|
||||||
|
'6R': {
|
||||||
|
width: 203,
|
||||||
|
height: 152,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
scaleValue: 1,
|
scaleValue: 1,
|
||||||
scaleMax: 5,
|
scaleMax: 5,
|
||||||
@ -304,11 +321,20 @@ const otherPaper = () => {
|
|||||||
// 预览
|
// 预览
|
||||||
const preView = () => {
|
const preView = () => {
|
||||||
let { width } = state.curPaper;
|
let { width } = state.curPaper;
|
||||||
|
let printData = null;
|
||||||
|
try {
|
||||||
|
printData = JSON.parse(printDataDemo.value);
|
||||||
|
} catch (e) {
|
||||||
|
console.log('出错:' + e);
|
||||||
|
}
|
||||||
|
if (printData == null) {
|
||||||
|
printData = printDataDefault;
|
||||||
|
}
|
||||||
preViewRef.value.showDialog(hiprintTemplate.value, printData, width);
|
preViewRef.value.showDialog(hiprintTemplate.value, printData, width);
|
||||||
};
|
};
|
||||||
// 直接打印
|
// 直接打印
|
||||||
const print = () => {
|
const print = () => {
|
||||||
console.log('直接打印');
|
preView();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 查看模板JSON
|
// 查看模板JSON
|
||||||
@ -339,8 +365,23 @@ const initPaper = () => {
|
|||||||
hiprintTemplate.value.setPaper(width, height); // 设置纸张大小
|
hiprintTemplate.value.setPaper(width, height); // 设置纸张大小
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 设置预览测试数据
|
||||||
|
const setPrintDataDemo = (strData: string | null | undefined) => {
|
||||||
|
printDataDemo.value = strData as string;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 格式化打印测试数据
|
||||||
|
const formatPrintDataDemo = () => {
|
||||||
|
try {
|
||||||
|
const obj = JSON.parse(printDataDemo.value);
|
||||||
|
printDataDemo.value = JSON.stringify(obj, null, 2);
|
||||||
|
} catch (e) {
|
||||||
|
ElMessageBox.alert('出错:' + e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 导出对象
|
// 导出对象
|
||||||
defineExpose({ hiprintTemplate, initPaper, mode });
|
defineExpose({ hiprintTemplate, printDataDemo, setPrintDataDemo, initPaper, mode });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user