diff --git a/src/commands/system/publish.ts b/src/commands/system/publish.ts index 37d5c1f..b920319 100644 --- a/src/commands/system/publish.ts +++ b/src/commands/system/publish.ts @@ -1,6 +1,7 @@ import { commands, ProgressLocation, window } from 'vscode'; import { CommandConst } from '../../constants'; import { ctx } from '../../context'; +import { SystemRunPickItem } from '../../entities'; import { CoreAPI } from '../../service'; /** @@ -18,11 +19,28 @@ export class SystemPublishCommand { protected async execute(): Promise { const psDevSlnSys = ctx.get('psdevslnsys'); - return window.withProgress({ location: ProgressLocation.Notification, title: '系统发布' }, progress => { + // 加载可刷新的模板 + const promise = new Promise(async resolve => { + const arr: SystemRunPickItem[] = []; + const sysRuns = await CoreAPI.curSystemRuns(); + sysRuns.forEach(item => { + arr.push(new SystemRunPickItem(item)); + }); + resolve(arr); + }); + // 选择模板 + const sysRun = await window.showQuickPick(promise, { + title: '代码发布', + placeHolder: '请选择需要运行的发布模式', + }); + if (!sysRun) { + return; + } + return window.withProgress({ location: ProgressLocation.SourceControl, title: '系统发布' }, progress => { return new Promise(resolve => { setTimeout(async () => { progress.report({ message: '正在建立发布任务...' }); - const res = await CoreAPI.cli('ExecuteSysCLICmd', { pstscmdname: 'devsys_pubcode', psdevslnsysid: psDevSlnSys }); + const res = await CoreAPI.cli('ExecuteSysCLICmd', { pstscmdname: 'devsys_pubcode', psdevslnsysid: psDevSlnSys, data: { sysrun: sysRun.data.pssystemrunname } }); if (res) { window.showInformationMessage(`已建立 <${ctx.get('psdevslnsysname')}> 系统代码发布`); } diff --git a/src/entities/index.ts b/src/entities/index.ts index c0cfda0..84ca0a3 100644 --- a/src/entities/index.ts +++ b/src/entities/index.ts @@ -1,3 +1,4 @@ export { PSMosFile } from './mos-file/ps-mos-file'; export { MosFilePickItem } from './quick-pick-item/mos-file-pick-item'; export { TemplatePickItem } from './quick-pick-item/template-pick-item'; +export { SystemRunPickItem } from './quick-pick-item/sys-run-pick-item'; diff --git a/src/entities/quick-pick-item/sys-run-pick-item.ts b/src/entities/quick-pick-item/sys-run-pick-item.ts new file mode 100644 index 0000000..c1ed32a --- /dev/null +++ b/src/entities/quick-pick-item/sys-run-pick-item.ts @@ -0,0 +1,32 @@ +import { QuickPickItem } from 'vscode'; + +/** + * 系统运行选项 + * + * @author chitanda + * @date 2021-12-13 15:12:27 + * @export + * @class SystemRunPickItem + * @implements {QuickPickItem} + */ +export class SystemRunPickItem implements QuickPickItem { + readonly label: string; + readonly description?: string | undefined; + readonly detail?: string | undefined; + readonly picked?: boolean | undefined; + readonly alwaysShow?: boolean | undefined; + readonly data: Record; + + /** + * Creates an instance of TemplatePickItem. + * @author chitanda + * @date 2021-12-07 11:12:30 + * @param {Record} run + */ + constructor(run: Record) { + this.data = run; + this.label = run.pssystemrunname; + this.description = `服务:${run.pssyssfpubname}`; + this.detail = `应用:${run.pssysappname}`; + } +} diff --git a/src/service/core-api/core-api.service.ts b/src/service/core-api/core-api.service.ts index dc606bd..c270876 100644 --- a/src/service/core-api/core-api.service.ts +++ b/src/service/core-api/core-api.service.ts @@ -67,6 +67,36 @@ export class CoreAPI { return []; } + /** + * 查询当前系统运行 + * + * @author chitanda + * @date 2021-12-13 10:12:40 + * @static + * @return {*} {Promise} + */ + static async curSystemRuns(): Promise { + if (ctx.completed === false) { + await ctx.waitCompleted(); + } + try { + const config: AxiosRequestConfig = { + headers: { + 'psdevslnsys': ctx.get('psdevslnsys') as string, + 'content-type': 'application/json;charset=UTF-8', + }, + }; + const path = `${this.getAddress()}/pssystemruns/fetchcursys`; + const res = await Fetch.get(path, { n_psdevslnid_eq: ctx.get('psdevsln'), size: 1000, page: 0 }, config); + if (res) { + return res.data; + } + } catch (err) { + showErrInfo(err); + } + return []; + } + /** * 获取 core api 服务域 *