shikeying
2023-04-03 d8887d36d08e3a0a5068763c8460b0b4f16e87ee
待办任务审批测试界面
3个文件已添加
2个文件已修改
891 ■■■■■ 已修改文件
src/api/activiti/task.js 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/etaa/question_bank.js 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/activiti/task/done_list.vue 194 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/activiti/task/index.vue 126 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/etaa/question_bank/index.vue 459 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/activiti/task.js
@@ -9,6 +9,41 @@
  })
}
// 已办任务列表。2023-04-01
export function listDone(query) {
  return request({
    url: '/wf/task/list/done',
    method: 'get',
    params: query
  })
}
// 流程审批历史列表。2023-04-03
export function listApprove(processInstanceId) {
  return request({
    url: '/wf/task/showApprove/' + processInstanceId,
    method: 'get'
    // params: query
  })
}
// 待办任务详情。2023-04-03
export function todoDetail(todoTask) {
  return request({
    url: '/wf/task/todoDetail',
    method: 'post',
    data: todoTask
  })
}
// 提交待办任务。2023-04-03
export function transmission(workflowForm) {
  return request({
    url: '/wf/task/transmission',
    method: 'post',
    data: workflowForm
  })
}
// 查询表单
export function formDataShow(taskID) {
  return request({
src/api/etaa/question_bank.js
New file
@@ -0,0 +1,77 @@
import request from '@/utils/request'
export function listQuestionType() {
  return request({
    url: '/etaa/question_bank/select/get_question_type',
    method: 'get'
    // params: query
  })
}
// 查询部试题表
export function listQuestion(query) {
  return request({
    url: '/etaa/question_bank/list',
    method: 'get',
    params: query
  })
}
// 试题分类树,目前放在数据字典中
export function listCatalogTreeList(dictType) {
  return request({
    url: '/permit/dict/list_tree/' + dictType,
    method: 'get'
  })
}
//
// // 查询部门详细
// export function getDept(deptId) {
//   return request({
//     url: '/system/dept/view/' + deptId,
//     method: 'get'
//   })
// }
//
// // 查询部门下拉树结构
// export function treeselect(deptId) {
//   return request({
//     // url: '/system/dept/treeselect',
//     url: '/system/dept/select/tree_dept/' + deptId,
//     method: 'get'
//   })
// }
//
// // 根据角色ID查询部门树结构
// export function roleDeptTreeselect(roleId) {
//   return request({
//     url: '/system/dept/roleDeptTreeselect/' + roleId,
//     method: 'get'
//   })
// }
//
// // 新增部门
// export function addDept(data) {
//   return request({
//     url: '/system/dept/add',
//     method: 'post',
//     data: data
//   })
// }
//
// // 修改部门
// export function updateDept(data) {
//   return request({
//     url: '/system/dept/edit',
//     method: 'post',
//     data: data
//   })
// }
//
// // 删除部门
// export function delDept(deptId) {
//   return request({
//     url: '/system/dept/remove/' + deptId,
//     method: 'get'
//   })
// }
src/views/activiti/task/done_list.vue
New file
@@ -0,0 +1,194 @@
<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="tastList">
      <!--      <el-table-column label="流程ID" align="center" prop="id"/>-->
      <el-table-column label="流程名称" align="left" prop="title"/>
      <el-table-column label="任务名称" align="left" prop="taskName"/>
      <el-table-column label="任务标识" align="left" prop="taskDefineKey"/>
      <el-table-column label="执行人" align="left" prop="assignee"/>
      <el-table-column label="代理人" align="left" prop="owner"/>
      <el-table-column label="任务开始" align="left" prop="startTime"/>
      <el-table-column label="任务完成" align="left" prop="endTime"/>
      <el-table-column label="流程结束" align="left" prop="processEnd"/>
      <el-table-column label="业务编号" align="left" prop="businessKey"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="showApprove(scope.row)"
            v-hasPermi="['wf:task:**']"
          >查看
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 展示审批历史 -->
    <el-dialog :title="title" :visible.sync="open" v-if="open" width="800px" append-to-body>
<!--      <leaveHistoryForm :businessKey="businessKey" v-if="'leave'==definitionKey"/>-->
<!--      <el-form :model="form" ref="form" label-width="100px" class="demo-dynamic">-->
<!--        <el-form-item-->
<!--          v-for="(domain, index) in form.formData"-->
<!--          :label="domain.controlLable"-->
<!--          :key="index"-->
<!--        >-->
<!--          <el-radio-group v-model="domain.controlValue" v-if="'radio'==domain.controlType">-->
<!--            <el-radio v-for="(defaults,indexd) in domain.controlDefault.split('&#45;&#45;__&#45;&#45;')"-->
<!--                      :label=indexd-->
<!--                      :key="indexd"-->
<!--                      >{{defaults}}-->
<!--            </el-radio>-->
<!--          </el-radio-group>-->
<!--          <el-input type="textarea" v-model="domain.controlValue" v-if="'textarea'==domain.controlType"-->
<!--          ></el-input>-->
<!--        </el-form-item>-->
<!--      </el-form>-->
      <div  v-for="(approve, index) in approveList"
            :key="index" >
        <h2>
          ----------------------------------
          {{approve.taskName}}
        </h2>
        <h3>任务开始:{{approve.startTime}},任务结束:{{approve.endTime}}</h3>
        <h3 v-if="approve.taskCount==1">办理人:{{approve.assignee}},意见:{{approve.approveSummary}}</h3>
        <h3 v-if="approve.taskCount==1">办理时间:{{approve.approveTime}}</h3>
        <el-form v-for="(approveItem, indexH) in approve.children" :key="indexH" label-width="80px" v-if="approve.taskCount>1">
          <h3>办理人:{{approveItem.assignee}},意见:{{approveItem.approveSummary}}</h3>
          <h3>办理时间:{{approveItem.approveTime}}</h3>
<!--          <el-form-item :label=approveItem.assignee v-if="approveItem.assignee !=''">-->
<!--            <el-input v-model="approveItem.approveTime"/>-->
<!--          </el-form-item>-->
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
<!--        <el-button type="primary" @click="submitForm">确 定</el-button>-->
        <el-button @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  import {listDone, listApprove, formDataShow, formDataSave} from "@/api/activiti/task";
  // import leaveHistoryForm from "@/views/workflow/leave/leaveHistoryForm";
  export default {
    name: "DoneTask",
    // components: {leaveHistoryForm},
    data() {
      return {
        id:'',
        definitionKey: '',
        businessKey: '',
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 请假表格数据
        tastList: [],
        // 审批历史集合,2023-04-03
        approveList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
        },
        // 表单参数
        form: {
          formData:[]
        },
        // 表单校验
        rules: {}
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询请假列表 */
      getList() {
        this.loading = true;
        listDone(this.queryParams).then(response => {
          this.tastList = response.data;
          this.total = response.total;
          this.loading = false;
        });
      },
      /** 查询审批历史集合 */
      getApproveList(processInstanceId){
        this.loading = true;
        listApprove(processInstanceId).then(response => {
          this.approveList = response.data;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.definitionKey = '',
          this.businessKey = '',
          this.form = {
            formData:[],
          };
        this.resetForm("form");
      },
      /** 展示审批列表 */
      showApprove(row) {
        console.log("processInstanceId = " + row.processInstanceId)
        this.reset();
        this.definitionKey = row.definitionKey;
        this.businessKey = row.businessKey;
        this.id=row.id;
        this.getApproveList(row.processInstanceId);
        this.open = true;
        this.title = "审批历史";
      }
      // /** 提交按钮 */
      // submitForm() {
      //   formDataSave(this.id,this.form.formData).then(response => {
      //     this.$modal.msgSuccess("审批成功");
      //     this.open = false;
      //     this.getList();
      //   });
      // },
    }
  };
</script>
src/views/activiti/task/index.vue
@@ -1,14 +1,13 @@
<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="tastList">
      <!--      <el-table-column label="流程ID" align="center" prop="id"/>-->
      <el-table-column label="流程名称" align="center" prop="instanceName"/>
      <el-table-column label="任务节点名称" align="center" prop="name"/>
      <el-table-column label="任务状态" align="center" prop="status"/>
      <el-table-column label="办理人" align="center" prop="assignee"/>
      <el-table-column label="创建时间" align="center" prop="createdDate"/>
      <el-table-column label="流程名称" align="center" prop="title"/>
      <el-table-column label="任务节点名称" align="center" prop="taskName"/>
      <el-table-column label="任务状态" align="center" prop=""/>
      <el-table-column label="办理人" align="center" prop="userId"/>
      <el-table-column label="创建时间" align="center" prop="createTime"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
@@ -16,7 +15,7 @@
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="examineAndApprove (scope.row)"
            @click="showTodoDetail(scope.row)"
            v-hasPermi="['wf:task:**']"
          >审批
          </el-button>
@@ -34,30 +33,40 @@
    <!-- 审批对话框 -->
    <el-dialog :title="title" :visible.sync="open" v-if="open" width="500px" append-to-body>
      <leaveHistoryForm :businessKey="businessKey" v-if="'leave'==definitionKey"/>
<!--      <leaveHistoryForm :businessKey="businessKey" v-if="'leave'==definitionKey"/>-->
      <el-form :model="form" ref="form" label-width="100px" class="demo-dynamic">
        <el-form-item
          v-for="(domain, index) in form.formData"
          :label="domain.controlLable"
          :key="index"
        >
          <el-radio-group v-model="domain.controlValue" v-if="'radio'==domain.controlType">
            <el-radio v-for="(defaults,indexd) in domain.controlDefault.split('--__--')"
                      :label=indexd
                      :key="indexd"
                      >{{defaults}}
            </el-radio>
          </el-radio-group>
          <el-input type="textarea" v-model="domain.controlValue" v-if="'textarea'==domain.controlType"
          ></el-input>
        <el-form-item label="流程名称">
          <el-input v-model="todoTask.title"/>
        </el-form-item>
        <el-form-item label="任务名称">
          <el-input v-model="todoTask.taskName"/>
        </el-form-item>
        <el-form-item label="业务主键" prop="businessKey">
<!--          <el-input v-model="todoTask.businessKey"/>-->
          <el-input v-model="form.businessKey"/>
        </el-form-item>
        <el-form-item label="流程标识" prop="processDefinitionKey">
<!--          <el-input v-model="todoTask.processDefinitionKey"/>-->
          <el-input v-model="form.processDefinitionKey"/>
        </el-form-item>
        <el-form-item label="任务ID" prop="taskInstanceId">
<!--          <el-input v-model="todoTask.id"/>-->
          <el-input v-model="form.taskInstanceId"/>
        </el-form-item>
        <el-form-item label="审批选项" prop="approveResult">
          <el-radio-group v-model="form.approveResult">
            <el-radio value="yes">同意</el-radio>
            <el-radio value="no">退回</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="审批意见" prop="approveSummary">
          <el-input v-model="form.approveSummary" placeholder="输入审批意见" maxlength="90" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button type="primary" @click="submitForm">转 发</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
@@ -65,19 +74,19 @@
</template>
<script>
  import {listTask, formDataShow, formDataSave} from "@/api/activiti/task";
  import leaveHistoryForm from "@/views/workflow/leave/leaveHistoryForm";
  import {listTask, todoDetail, transmission, formDataShow, formDataSave} from "@/api/activiti/task";
  // import leaveHistoryForm from "@/views/workflow/leave/leaveHistoryForm";
  export default {
    name: "Leave",
    components: {leaveHistoryForm},
    components: {},
    data() {
      return {
        id:'',
        definitionKey: '',
        businessKey: '',
        // 当前待办任务详细(点击的详情),2023-04-03
        todoTask: undefined,
        // 遮罩层
        loading: true,
        // 选中数组
@@ -103,7 +112,13 @@
        },
        // 表单参数
        form: {
          formData:[]
          businessKey: undefined,
          processDefinitionKey: undefined,
          assignee: undefined,
          taskInstanceId: undefined,
          approveResult: undefined,
          approveSummary: '',
          approveTime: undefined
        },
        // 表单校验
        rules: {}
@@ -130,59 +145,40 @@
      },
      // 表单重置
      reset() {
        this.definitionKey = '',
          this.businessKey = '',
          this.form = {
            formData:[],
          };
        this.definitionKey = '';
        this.businessKey = '';
        this.form = {};
        this.resetForm("form");
      },
      /** 审批按钮操作 */
      examineAndApprove(row) {
        console.log(row)
      showTodoDetail(row) {
        console.log(row);
        this.reset();
        this.definitionKey = row.definitionKey;
        this.businessKey = row.businessKey;
        this.id=row.id;
        formDataShow(row.id).then(response => {
        todoDetail(row).then(response => {
          // FormProperty_3qipis2--__!!radio--__!!审批意见--__!!i--__!!同意--__--不同意
          // FormProperty_0lffpcm--__!!textarea--__!!批注--__!!f--__!!null
          let datas = response.data;
          let formData = []
          for (let i = 0; i < datas.length; i++) {
            let strings = datas[i].split('--__!!')
            let controlValue = null
            let controlDefault = null
            switch (strings[1]) {
              case 'radio':
                controlValue = 0;
                controlDefault = strings[4]
                break;
              // default:
            }
            formData.push({
              controlId: strings[0],
              controlType: strings[1],
              controlLable: strings[2],
              controlIsParam: strings[3],
              controlValue: controlValue,
              controlDefault: controlDefault
            })
          }
          this.form.formData = formData;
          this.todoTask = response.data;
          this.form.businessKey = this.todoTask.businessKey;
          this.form.taskInstanceId = this.todoTask.id;
          this.form.processDefinitionKey = this.todoTask.processDefinitionKey;
          // this.form.formData = formData;
          this.open = true;
          this.title = "审批";
        });
      },
      /** 提交按钮 */
      submitForm() {
        formDataSave(this.id,this.form.formData).then(response => {
        transmission(this.form).then(response => {
          this.$modal.msgSuccess("审批成功");
          this.open = false;
          this.getList();
        });
      },
      }
    }
  };
</script>
src/views/etaa/question_bank/index.vue
New file
@@ -0,0 +1,459 @@
<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <el-col :span="6" :xs="24">
        <div class="head-container">
          <el-tree
            :data="catalogListOptions"
            :props="defaultProps"
            :expand-on-click-node="false"
            :filter-node-method="filterNode"
            ref="tree"
            default-expand-all
            highlight-current
            @node-click="handleNodeClick"
          />
        </div>
      </el-col>
      <el-col :span="18" :xs="24">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
          <el-form-item label="顶级单位" prop="orgId">
            <el-select v-model="queryParams.orgId" placeholder="选择顶级单位" @change="getList()">
              <el-option
                v-for="org in this.rootOrgList"
                :key="org.id"
                :label="org.dept_name"
                :value="org.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="试题类型" prop="questionType">
            <el-select v-model="queryParams.questionType" placeholder="试题类型">
              <el-option
                v-for="d in this.questionTypeList"
                :key="d.key"
                :label="d.value"
                :value="d.key"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="试题题目" prop="content">
            <el-input
              v-model="queryParams.content"
              placeholder="试题内容"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
<!--          <el-form-item label="专业分类" prop="majorCode">-->
<!--            <el-select v-model="queryParams.majorCode" placeholder="请选择专业分类" clearable>-->
<!--              <el-option-->
<!--                v-for="dict in dict.type.sys_job_status"-->
<!--                :key="dict.value"-->
<!--                :label="dict.label"-->
<!--                :value="dict.value"-->
<!--              />-->
<!--            </el-select>-->
<!--          </el-form-item>-->
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd"
              v-hasPermi="['exam:online:add']"
            >添加</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              plain
              icon="el-icon-delete"
              size="mini"
              :disabled="multiple"
              @click="handleDelete"
              v-hasPermi="['exam:online:delBatch']"
            >删除</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="warning"
              plain
              icon="el-icon-search"
              size="mini"
              @click="handleExport"
              v-hasPermi="['exam:online:exist']"
            >查重</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="warning"
              plain
              icon="el-icon-upload2"
              size="mini"
              @click="handleExport"
              v-hasPermi="['exam:online:upload']"
            >导入</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="info"
              plain
              icon="el-icon-download"
              size="mini"
              @click=""
              v-hasPermi="['exam:online:download']"
            >模板下载</el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>
        <el-table v-loading="loading" :data="examList" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" align="left" />
          <el-table-column label="ID" align="left" prop="id" :show-overflow-tooltip="true" />
          <el-table-column label="归属" align="left" prop="parameter.orgName"/>
          <el-table-column label="大类" align="left" prop="parameter.rootCatalogName"/>
          <el-table-column label="子分类" align="left" prop="parameter.majorCatalogName"/>
          <el-table-column label="题目" align="left" prop="content" :show-overflow-tooltip="true" />
          <el-table-column label="试题类型" align="left" prop="parameter.questionTypeName"/>
          <el-table-column label="创建人" align="left" prop="createUserId" :show-overflow-tooltip="true" />
          <el-table-column label="创建时间" align="left" prop="parameter.createTimeName" />
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['exam:online:edit']"
              >修改</el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)"
                v-hasPermi="['exam:online:del']"
              >删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>
    <!-- 添加或修改定时任务对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="所属分类" prop="majorId">
              <el-select v-model="form.majorId" placeholder="请选择所属分类">
                <el-option
                  v-for="dict in dict.type.sys_job_group"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="题目类型" prop="type">
              <el-select v-model="form.type" placeholder="请选择题目类型">
                <el-option
                  v-for="dict in dict.type.sys_job_group"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="题目" prop="content">
              <el-input v-model="form.content" placeholder="请输入题目"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 试题库详细 -->
    <el-dialog title="试题库详细" :visible.sync="openView" width="700px" append-to-body>
      <el-form ref="form" :model="form" label-width="120px" size="mini">
        <el-row>
          <el-col :span="12">
            <el-form-item label="所属分类:">{{ form.id }}</el-form-item>
            <el-form-item label="题目类型:">{{ form.jobName }}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="题目:">{{ "" }}</el-form-item>
            <el-form-item label="答案:">{{ form.createTime }}</el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="openView = false">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  // import { listJob, getJob, delJob, addJob, updateJob, runJob, changeJobStatus } from "@/api/monitor/job";
  import { listOrgRoot, listOrgRootTree } from '@/api/system/dept'
  import { listCatalogTreeList, listQuestion, listQuestionType } from '@/api/etaa/question_bank'
  export default {
  // components: { Crontab },
  name: "questionBank",
  dicts: ['sys_job_status'],
  data() {
    return {
      // 日期范围
      dateRange: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      examList: [],
      // 2022-12-30 根机构列表,个人只能列出自己所在根机构
      rootOrgList:[],
      // 2022-12-30 超级管理员选择的顶级机构ID
      selectedRootOrgId: undefined,
      // 试题类别列表,2023-03-11
      questionTypeList: [],
      // 2023-03-13 试题类别树数据选项
      catalogListOptions: undefined,
      /** 分类树数据结构 */
      defaultProps: {
        children: "children",
        label: "label"
      },
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否显示详细弹出层
      openView: false,
      // 是否显示Cron表达式弹出层
      openCron: false,
      // 传入的表达式
      expression: "",
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        content: undefined,
        catalogId: undefined,
        orgId: undefined,
        questionType: undefined
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        content: [
          { required: true, message: "题目不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.getRootOrgList();
    this.getQuestionTypeList();
  },
  methods: {
    /** 获取试题类别集合 2023-03-11 */
    getQuestionTypeList(){
      listQuestionType().then(response => {
        // console.log(response.data);
        this.questionTypeList = response.data;
      });
    },
    /** 获取顶级机构列表选择框 2022-12-30 */
    getRootOrgList(){
      this.loading = true;
      listOrgRoot().then(response => {
        this.rootOrgList = response.data;
        this.selectedRootOrgId = this.rootOrgList[0].id;
        this.queryParams.orgId = this.selectedRootOrgId;
        this.loading = false;
      }).then(() => {
        this.listCatalogTree();
        this.getList();
      }).catch(function() {
        this.loading = false;
      });
    },
    // 试题类别树
    listCatalogTree(){
      listCatalogTreeList("question_root_catalog").then(response => {
        console.log(response.data);
        this.catalogListOptions = response.data;
      });
    },
    /** 查询列表 */
    getList() {
      this.loading = true;
      listQuestion(this.queryParams).then(response => {
        this.examList = response.data;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 筛选节点
    filterNode(value, data) {
      if (!value) return true;
      console.log("value = " + value + ", data = " + data);
      return data.label.indexOf(value) !== -1;
    },
    // 节点单击事件
    handleNodeClick(data) {
      this.queryParams.catalogId = data.id;
      this.handleQuery();
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        content: undefined,
        concurrent: 1,
        status: "0"
      };
      this.dateRange = [];// 时间范围
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.orgId = this.selectedRootOrgId;
      this.queryParams.questionType = undefined;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    // 状态修改
    handleStatusChange(row) {
      let text = row.status === "0" ? "启用" : "停用";
      this.$modal.confirm('确认要"' + text + '""' + row.name + '"任务吗?').then(function() {
        return changeJobStatus(row.id, row.status);
      }).then(() => {
        this.$modal.msgSuccess(text + "成功");
      }).catch(function() {
        row.status = row.status === "0" ? "1" : "0";
      });
    },
    /** 任务详细信息 */
    handleView(row) {
      // getJob(row.id).then(response => {
      //   this.form = response.data;
      //   this.openView = true;
      // });
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加试题库";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getJob(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改试题库";
      });
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != undefined) {
            updateJob(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addJob(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const jobIds = row.id || this.ids;
      this.$modal.confirm('是否确认删除编号为"' + jobIds + '"的数据项?').then(function() {
        return delJob(jobIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('monitor/job/export', {
        ...this.queryParams
      }, `job_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>