Ben Lin
2024-10-27 92cb62d60d38be56312be20cfae8638a5a9aa57a
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,122 @@
    <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 { getListByPage } from '/@/api/tigerapi/system';
  import { DeleteTsk_Job, StartTsk_Job, StopTsk_Job } from '/@/api/tigerapi/tsk/tsk_job';
  import { useDrawer } from '/@/components/Drawer';
  import { BasicTable, TableAction, useTable } from '/@/components/Table';
  import { useGo } from '/@/hooks/web/usePage';
  export default defineComponent({
    name: 'WHManagement',
    components: { BasicTable, jobDrawer, TableAction },
    setup() {
      const go = useGo();
      const [registerDrawer, { openDrawer }] = useDrawer();
  const go = useGo();
  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 apiAction = StartTsk_Job(record);
    apiAction.then((action) => {
      if (action.IsSuccessed) {
        reload();
      }
    });
  }
  /**
   * @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>