From 08abfcfea8247c394b2034cad59734846b403dd9 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期一, 28 十月 2024 22:22:58 +0800 Subject: [PATCH] 计划任务优化 --- src/views/tigerprojects/tsk/tsk_job/index.vue | 246 +++++++++++++++++++++++++++---------------------- 1 files changed, 136 insertions(+), 110 deletions(-) diff --git a/src/views/tigerprojects/tsk/tsk_job/index.vue b/src/views/tigerprojects/tsk/tsk_job/index.vue index ef29c26..32b7d5c 100644 --- a/src/views/tigerprojects/tsk/tsk_job/index.vue +++ b/src/views/tigerprojects/tsk/tsk_job/index.vue @@ -11,27 +11,27 @@ icon: 'clarity:info-standard-line', tooltip: '鏌ョ湅浠诲姟璇︽儏', onClick: handleView.bind(null, record), - name: undefined + name: undefined, }, { //绔嬪嵆寮�濮� tooltip: '绔嬪嵆寮�濮�', icon: 'start|svg', onClick: handleStart.bind(null, record), - name: undefined + name: undefined, }, { //鍋滄杩愯 tooltip: '鍋滄杩愯', icon: 'stop|svg', onClick: handleStop.bind(null, record), - name: undefined + name: undefined, }, { tooltip: '缂栬緫', icon: 'clarity:note-edit-line', onClick: handleEdit.bind(null, record), - name: undefined + name: undefined, }, { tooltip: '鍒犻櫎', @@ -42,7 +42,7 @@ placement: 'left', confirm: handleDelete.bind(null, record), }, - name: undefined + name: undefined, }, ]" /> @@ -51,114 +51,140 @@ <jobDrawer @register="registerDrawer" @success="handleSuccess" /> </div> </template> -<script lang="ts"> - import { defineComponent } from 'vue'; - - import { BasicTable, useTable, TableAction } from '/@/components/Table'; - - import { useDrawer } from '/@/components/Drawer'; - import jobDrawer from './jobDrawer.vue'; - import { useGo } from '/@/hooks/web/usePage'; +<script lang="ts" setup> import { columns, searchFormSchema } from './job.data'; - //api - import { - StartTsk_Job, - StopTsk_Job, - DeleteTsk_Job, - getTsk_JobListByPage, - } from '/@/api/tigerapi/tsk/tsk_job'; + import jobDrawer from './jobDrawer.vue'; + import { FluentJobParam } from '/@/api/tigerapi/model/tskModel'; + import { getListByPage } from '/@/api/tigerapi/system'; + import { AddTskJob, DeleteTsk_Job, StopTsk_Job } from '/@/api/tigerapi/tsk/tsk_job'; + import { useDrawer } from '/@/components/Drawer'; + import { BasicTable, TableAction, useTable } from '/@/components/Table'; + import { useMessage } from '/@/hooks/web/useMessage'; + import { useGo } from '/@/hooks/web/usePage'; + import { useI18n } from '/@/hooks/web/useI18n'; - export default defineComponent({ - name: 'WHManagement', - components: { BasicTable, jobDrawer, TableAction }, - setup() { - const go = useGo(); - const [registerDrawer, { openDrawer }] = useDrawer(); + const go = useGo(); + const { t } = useI18n(); + const { createErrorModal } = useMessage(); + const [registerDrawer, { openDrawer }] = useDrawer(); - const [registerTable, { reload }] = useTable({ - title: '浠诲姟鍒楄〃', - api: getTsk_JobListByPage, - columns, - formConfig: { - labelWidth: 120, - schemas: searchFormSchema, - }, - useSearchForm: true, - showTableSetting: true, - bordered: true, - canResize:true, - showIndexColumn: false, - actionColumn: { - width: 205, - title: '鎿嶄綔', - dataIndex: 'action', - slots: { customRender: 'action' }, - fixed: undefined, - }, - }); - - function handleCreate() { - openDrawer(true, { - isUpdate: false, - }); - } - - function handleEdit(record: Recordable) { - openDrawer(true, { - record, - isUpdate: true, - }); - } - //璇︽儏椤甸潰 - function handleView(record: Recordable) { - console.log(record.ID); - go('/job_detail/' + record.ID + ',' + record.JobName + ''); - } - - function handleStart(record: Recordable) { - //寮�濮嬭繍琛� - const apiAction = StartTsk_Job(record); - apiAction.then((action) => { - if (action.IsSuccessed) { - reload(); - } - }); - } - function handleStop(record: Recordable) { - //绔嬪嵆鍋滄 - const apiAction = StopTsk_Job(record); - apiAction.then((action) => { - if (action.IsSuccessed) { - reload(); - } - }); - } - function handleDelete(record: Recordable) { - handleStop(record); - //鍒犻櫎浠诲姟 - const apiAction = DeleteTsk_Job(record); - apiAction.then((action) => { - if (action.IsSuccessed) { - reload(); - } - }); - } - - function handleSuccess() { - reload(); - } - - return { - registerTable, - registerDrawer, - handleCreate, - handleEdit, - handleView, - handleStart, - handleStop, - handleDelete, - handleSuccess, - }; + const [registerTable, { reload }] = useTable({ + title: '浠诲姟鍒楄〃', + api: getListByPage, + searchInfo: { + TABLE_NAME: 'TSK_JOB', + // option: { + // //鏍规嵁鎹偣鏌ヨ锛屽繀闇�甯﹁繖涓弬鏁� + // UserId: useUserStore().getUserInfo.userId, + // ByOrg: true, + // CurOrg: useUserStore().getUserInfo.orgCode, + // }, + NeedInclude: true, + }, + // afterFetch: afterFetch, + columns, + formConfig: { + labelWidth: 120, + schemas: searchFormSchema, + }, + useSearchForm: true, + showTableSetting: true, + bordered: true, + canResize: true, + showIndexColumn: false, + actionColumn: { + width: 205, + title: '鎿嶄綔', + dataIndex: 'action', + slots: { customRender: 'action' }, + fixed: undefined, }, }); + + /** + * 娣诲姞浠诲姟 + */ + function handleCreate() { + openDrawer(true, { + isUpdate: false, + }); + } + + function handleEdit(record: Recordable) { + openDrawer(true, { + record, + isUpdate: true, + }); + } + + /** + * 璇︽儏椤甸潰 + * @param {Recordable} record - 璁板綍 + */ + function handleView(record: Recordable) { + console.log(record.ID); + go('/job_detail/' + record.ID + ',' + record.JobName + ''); + } + /** + * @description: + * @param {*} record + * @return {*} + */ + function handleStart(record: Recordable) { + const param: FluentJobParam = { + AssemblyName: record.AssemblyName, + Args: JSON.parse(record.Triggers[0].Args), + DataType: record.JobName, + JobName: record.JobName, + }; + const apiAction = AddTskJob(param); + apiAction.then((action) => { + if (action.IsSuccessed) { + reload(); + } else { + createErrorModal({ + title: t('sys.api.errorTip'), + content: apiAction.Message, + getContainer: () => document.body, + }); + } + }); + } + + /** + * @description: 绔嬪嵆鍋滄 + * @param {*} record + * @return {*} + */ + function handleStop(record: Recordable) { + const apiAction = StopTsk_Job(record); + apiAction.then((action) => { + if (action.IsSuccessed) { + reload(); + } + }); + } + + /** + * @description: 鍒犻櫎浠诲姟 + * @param {*} record + * @return {*} + */ + function handleDelete(record: Recordable) { + handleStop(record); + const apiAction = DeleteTsk_Job(record); + apiAction.then((action) => { + if (action.IsSuccessed) { + reload(); + } + }); + } + + /** + * @description: 杩斿洖鎴愬姛 + * @return {*} + */ + function handleSuccess() { + reload(); + } </script> -- Gitblit v1.9.3