😎1、优化打印模板流程 2、更新前端请求文件

This commit is contained in:
zuohuaijun 2024-10-17 13:26:25 +08:00
parent b5a309efc5
commit 6df14aa43a
12 changed files with 208 additions and 24 deletions

View File

@ -66,4 +66,10 @@ public partial class SysPrint : EntityTenant
[SugarColumn(ColumnDescription = "备注", Length = 128)]
[MaxLength(128)]
public string? Remark { get; set; }
/// <summary>
/// 打印预览测试数据
/// </summary>
[SugarColumn(ColumnDescription = "打印预览测试数据", ColumnDataType = StaticConfig.CodeFirst_BigString)]
public string? PrintDataDemo { get; set; }
}

View File

@ -21,6 +21,11 @@ public class PageJobDetailInput : BasePageInput
/// </summary>
public string JobId { get; set; }
/// <summary>
/// 组名称
/// </summary>
public string GroupName { get; set; }
/// <summary>
/// 描述信息
/// </summary>

View File

@ -41,8 +41,9 @@ public class SysJobService : IDynamicApiController, ITransient
public async Task<SqlSugarPagedList<JobDetailOutput>> PageJobDetail(PageJobDetailInput input)
{
var jobDetails = await _sysJobDetailRep.AsQueryable()
.WhereIF(!string.IsNullOrWhiteSpace(input.JobId), u => u.JobId.Contains(input.JobId))
.WhereIF(!string.IsNullOrWhiteSpace(input.Description), u => u.Description.Contains(input.Description))
.WhereIF(!string.IsNullOrWhiteSpace(input.JobId), u => u.JobId.Contains(input.JobId.Trim()))
.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
{
JobDetail = d,
@ -64,6 +65,15 @@ public class SysJobService : IDynamicApiController, ITransient
return jobDetails;
}
/// <summary>
/// 获取作业组名称集合 ⏰
/// </summary>
[DisplayName("获取作业组名称集合")]
public async Task<List<string>> ListJobGroup()
{
return await _sysJobDetailRep.AsQueryable().Distinct().Select(e => e.GroupName).ToListAsync();
}
/// <summary>
/// 添加作业 ⏰
/// </summary>

View File

@ -19,6 +19,7 @@ import { Configuration } from '../configuration';
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
import { AddJobDetailInput } from '../models';
import { AddJobTriggerInput } from '../models';
import { AdminResultListString } from '../models';
import { AdminResultListSysJobCluster } from '../models';
import { AdminResultListSysJobTrigger } from '../models';
import { AdminResultSqlSugarPagedListJobDetailOutput } from '../models';
@ -411,6 +412,49 @@ export const SysJobApiAxiosParamCreator = function (configuration?: Configuratio
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
@ -1091,6 +1135,19 @@ export const SysJobApiFp = function(configuration?: Configuration) {
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
@ -1343,6 +1400,15 @@ export const SysJobApiFactory = function (configuration?: Configuration, basePat
async apiSysJobJobTriggerListGet(jobId?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultListSysJobTrigger>> {
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
@ -1556,6 +1622,16 @@ export class SysJobApi extends BaseAPI {
public async apiSysJobJobTriggerListGet(jobId?: string, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultListSysJobTrigger>> {
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

View File

@ -146,6 +146,14 @@ export interface AddPrintInput {
*/
remark?: string | null;
/**
*
*
* @type {string}
* @memberof AddPrintInput
*/
printDataDemo?: string | null;
/**
*
*

View File

@ -90,6 +90,14 @@ export interface PageJobDetailInput {
*/
jobId?: string | null;
/**
*
*
* @type {string}
* @memberof PageJobDetailInput
*/
groupName?: string | null;
/**
*
*

View File

@ -85,6 +85,14 @@ export interface SysOAuthUser {
*/
isDelete?: boolean;
/**
*
*
* @type {string}
* @memberof SysOAuthUser
*/
email?: string | null;
/**
* Id
*
@ -147,14 +155,6 @@ export interface SysOAuthUser {
*/
avatar?: string | null;
/**
*
*
* @type {string}
* @memberof SysOAuthUser
*/
email?: string | null;
/**
*
*

View File

@ -153,4 +153,12 @@ export interface SysPrint {
* @memberof SysPrint
*/
remark?: string | null;
/**
*
*
* @type {string}
* @memberof SysPrint
*/
printDataDemo?: string | null;
}

View File

@ -146,6 +146,14 @@ export interface UpdatePrintInput {
*/
remark?: string | null;
/**
*
*
* @type {string}
* @memberof UpdatePrintInput
*/
printDataDemo?: string | null;
/**
*
*

View File

@ -8,6 +8,11 @@
<el-input v-model="state.queryParams.jobId" placeholder="作业编号" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
</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-form-item label="描述信息" prop="description">
<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({
queryParams: {
jobId: undefined,
groupName: undefined,
description: undefined,
},
jobPageParam: {
@ -283,6 +289,7 @@ const state = reactive({
currentJob: {} as any,
visible: false,
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
const handleQueryApi = async (page: VxeGridPropTypes.ProxyAjaxQueryPageParams, sort: VxeGridPropTypes.ProxyAjaxQuerySortCheckedParams) => {
@ -337,6 +347,7 @@ const handleQuery = async () => {
//
const resetQuery = async () => {
state.queryParams.jobId = undefined;
state.queryParams.groupName = undefined;
state.queryParams.description = undefined;
await xGridJob.value?.commitProxy('reload');
};
@ -362,7 +373,7 @@ const handleDelete = (row: JobDetailOutput) => {
})
.then(async () => {
await getAPI(SysJobApi).apiSysJobDeleteJobDetailPost({ jobId: row.jobDetail?.jobId });
handleQuery();
await handleQuery();
ElMessage.success('删除成功');
})
.catch(() => {});
@ -408,7 +419,7 @@ const delJobTrigger = (row: SysJobTrigger) => {
})
.then(async () => {
await getAPI(SysJobApi).apiSysJobDeleteJobTriggerPost({ jobId: row.jobId, triggerId: row.triggerId });
handleQuery();
await handleQuery();
ElMessage.success('删除成功');
})
.catch(() => {});
@ -520,7 +531,7 @@ const handleFold = () => {
//
const openJobTriggerRecord = async (row: any) => {
state.currentJob = row;
state.recordPageParam.jobId = row?.jobDetail?.jobId;
// state.recordPageParam.jobId = row?.jobDetail?.jobId;
state.isVisibleDrawer = true;
await handleQueryRecord();
};

View File

@ -127,6 +127,7 @@ const openDialog = (row: any) => {
//
const loadTemplate = () => {
hiprintDesignRef.value?.hiprintTemplate.clear();
hiprintDesignRef.value?.setPrintDataDemo(state.ruleForm.printDataDemo);
if (JSON.stringify(state.ruleForm) !== '{}') {
hiprintDesignRef.value?.hiprintTemplate.update(JSON.parse(state.ruleForm.template));
hiprintDesignRef.value?.initPaper();
@ -153,9 +154,11 @@ const templateCancel = () => {
//
const templateSubmit = async () => {
let templateJson=hiprintDesignRef.value?.hiprintTemplate.getJson();
templateJson.panels[0].index=hiprintDesignRef.value?.mode;
let templateJson = hiprintDesignRef.value?.hiprintTemplate.getJson();
templateJson.panels[0].index = hiprintDesignRef.value?.mode;
state.ruleForm.template = JSON.stringify(templateJson);
const printDataDemo = hiprintDesignRef.value?.printDataDemo;
state.ruleForm.printDataDemo = printDataDemo;
if (state.ruleForm.id != undefined && state.ruleForm.id > 0) {
await getAPI(SysPrintApi).apiSysPrintUpdatePost(state.ruleForm);
} else {

View File

@ -82,11 +82,19 @@
</el-card>
</el-col>
<el-col :span="6" class="params_setting_container">
<el-card shadow="never" :body-style="{ padding: '0px' }">
<el-row class="hinnn-layout-sider">
<div id="PrintElementOptionSetting"></div>
</el-row>
</el-card>
<el-tabs type="border-card">
<el-tab-pane label="属性" style="height: auto">
<el-card shadow="never" :body-style="{ padding: '0px' }">
<el-row class="hinnn-layout-sider">
<div id="PrintElementOptionSetting"></div>
</el-row>
</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-row>
@ -107,7 +115,7 @@ import 'vue-json-pretty/lib/styles.css';
import { hiprint } from 'vue-plugin-hiprint';
import providers from './providers';
import PrintPreview from './preview.vue';
import printData from './print-data';
import printDataDefault from './print-data';
var props = defineProps({
modeIndex: {
@ -120,6 +128,7 @@ let hiprintTemplate = ref();
let mode = ref(0); //
const preViewRef = ref();
const printDataDemo = ref('');
const state = reactive({
modeList: [] as any,
//
@ -154,6 +163,14 @@ const state = reactive({
width: 250,
height: 175.6,
},
'4R': {
width: 152,
height: 102,
},
'6R': {
width: 203,
height: 152,
},
},
scaleValue: 1,
scaleMax: 5,
@ -304,11 +321,20 @@ const otherPaper = () => {
//
const preView = () => {
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);
};
//
const print = () => {
console.log('直接打印');
preView();
};
// JSON
@ -339,8 +365,23 @@ const initPaper = () => {
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>
<style lang="scss" scoped>