Selaa lähdekoodia

Merge branch 'master' of http://1.14.104.71:10880/root/ylrz_his_scrm_adminUI

caoliqin 1 kuukausi sitten
vanhempi
commit
34b936eb93

+ 17 - 0
src/api/course/coursePlaySourceConfig.js

@@ -61,3 +61,20 @@ export function listAll(companyId) {
     params: {companyId}
   })
 }
+
+export function updateAgreementConfig(data) {
+  return request({
+    url: '/course/playSourceConfig/updateAgreementConfig',
+    method: 'post',
+    data: data
+  })
+}
+
+export function queryAgreementConfig(query) {
+  return request({
+    url: '/course/playSourceConfig/queryAgreementConfig',
+    method: 'get',
+    params: query
+  })
+}
+

+ 14 - 0
src/api/course/userWatchCourseStatistics.js

@@ -69,3 +69,17 @@ export function exportUserWatchCourseStatisticsTotal(query) {
     params: query
   })
 }
+export function getCourseList() {
+  return request({
+    url: '/course/userCourse/selectCourseOptionsList',
+    method: 'get'
+  })
+}
+
+export function getVideosByCourse(id) {
+  return request({
+    url: '/course/userCourseVideo/getCourseVideoOptions',
+    method: 'get',
+    params: { courseId: id }
+  })
+}

+ 77 - 0
src/api/his/aiWorkflow.js

@@ -0,0 +1,77 @@
+import request from '@/utils/request'
+
+// 查询AI工作流列表
+export function listWorkflow(query) {
+  return request({
+    url: '/his/aiWorkflow/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询AI工作流详细
+export function getWorkflow(workflowId) {
+  return request({
+    url: '/his/aiWorkflow/' + workflowId,
+    method: 'get'
+  })
+}
+
+// 新增AI工作流
+export function addWorkflow(data) {
+  return request({
+    url: '/his/aiWorkflow/save',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改AI工作流
+export function updateWorkflow(data) {
+  return request({
+    url: '/his/aiWorkflow/save',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改AI工作流状态
+export function updateWorkflowStatus(workflowId, status) {
+  return request({
+    url: '/his/aiWorkflow/status/' + workflowId + '/' + status,
+    method: 'put'
+  })
+}
+
+// 删除AI工作流
+export function delWorkflow(workflowId) {
+  return request({
+    url: '/his/aiWorkflow/' + workflowId,
+    method: 'delete'
+  })
+}
+
+// 复制AI工作流
+export function copyWorkflow(workflowId) {
+  return request({
+    url: '/his/aiWorkflow/copy/' + workflowId,
+    method: 'post'
+  })
+}
+
+// 获取节点类型列表
+export function getNodeTypes() {
+  return request({
+    url: '/his/aiWorkflow/nodeTypes',
+    method: 'get'
+  })
+}
+
+// 导出AI工作流
+export function exportWorkflow(query) {
+  return request({
+    url: '/his/aiWorkflow/export',
+    method: 'get',
+    params: query
+  })
+}

+ 15 - 1
src/api/his/packageOrder.js

@@ -90,4 +90,18 @@ export function exportPackageOrder(query) {
     method: 'get',
     params: query
   })
-}
+}
+export function courseReport(query) {
+  return request({
+    url: '/company/statistics/courseReport',
+    method: 'get',
+    params: query
+  })
+}
+export function exportCourseReport(query) {
+  return request({
+    url: '/company/statistics/exportFsCourseReportVO',
+    method: 'get',
+    params: query
+  })
+}

+ 8 - 0
src/api/qw/user.js

@@ -60,6 +60,14 @@ export function getMyQwCompanyList(query) {
   })
 }
 
+export function getMyQwCompanyListAll() {
+  return request({
+    url: '/qw/user/getMyQwCompanyListAll',
+    method: 'get'
+  })
+}
+
+
 
 export function getQwCompanyList() {
   return request({

+ 25 - 0
src/router/index.js

@@ -239,6 +239,31 @@ export const constantRoutes = [
       isIndependentPage: true // 标记为“独立页”
     }
   },
+  {
+    path: '/his/aiWorkflow',
+  component: () => import('@/layout/index'),
+  hidden: true,
+  children: [
+    {
+      path: '',
+      component: () => import('@/views/his/aiWorkflow/index'),
+      name: 'AiWorkflow',
+      meta: { title: 'AI工作流', icon: 'workflow' }
+    },
+    {
+      path: 'design',
+      component: () => import('@/views/his/aiWorkflow/design'),
+      name: 'AiWorkflowDesign',
+      meta: { title: '工作流设计', activeMenu: '/his/aiWorkflow' }
+    },
+    {
+      path: 'design/:id',
+      component: () => import('@/views/his/aiWorkflow/design'),
+      name: 'AiWorkflowEdit',
+      meta: { title: '编辑工作流', activeMenu: '/his/aiWorkflow' }
+    }
+  ]
+  },
 ]
 
 export default new Router({

+ 5 - 0
src/views/components/course/userCourseCatalogDetails.vue

@@ -8,6 +8,10 @@
         <el-input v-model="queryParams.title" placeholder="请输入小节名称" clearable size="small"
                   @keyup.enter.native="handleQuery"/>
       </el-form-item>
+      <el-form-item label="小节id" prop="videoId">
+        <el-input v-model="queryParams.videoId" placeholder="请输入小节id" clearable size="small"
+                  @keyup.enter.native="handleQuery"/>
+      </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>
@@ -603,6 +607,7 @@ export default {
         pageNum: 1,
         pageSize: 10,
         courseId: null,
+        videoId: null,
         title: null
       },
       addBatchData: {

+ 123 - 1
src/views/course/coursePlaySourceConfig/index.vue

@@ -207,6 +207,13 @@
             v-hasPermi="['course:playSourceConfig:unbind']"
             v-if="scope.row.merchantConfigId"
           >解绑</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-document"
+            @click="handleAgreement(scope.row)"
+            v-hasPermi="['course:playSourceConfig:agreement']"
+          >协议配置</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -339,6 +346,41 @@
       </div>
     </el-dialog>
 
+    <!-- 协议配置对话框 -->
+    <el-dialog title="协议配置" :visible.sync="agreementDialogVisible" width="1000px" append-to-body>
+      <el-form ref="agreementForm" :model="agreementForm" :rules="agreementRules" label-width="150px" style="margin-right: 25px">
+        <el-form-item label="医生注册协议" prop="doctorRegister">
+          <editor v-model="agreementForm.doctorRegister" :min-height="200"/>
+        </el-form-item>
+        <el-form-item label="医生多机构备案协议" prop="doctorFiling">
+          <editor v-model="agreementForm.doctorFiling" :min-height="200"/>
+        </el-form-item>
+        <el-form-item label="用户协议" prop="userRegister">
+          <editor v-model="agreementForm.userRegister" :min-height="200"/>
+        </el-form-item>
+        <el-form-item label="隐私协议" prop="userPrivacy">
+          <editor v-model="agreementForm.userPrivacy" :min-height="200"/>
+        </el-form-item>
+        <el-form-item label="健康客服协议" prop="userHealth">
+          <editor v-model="agreementForm.userHealth" :min-height="200"/>
+        </el-form-item>
+        <el-form-item label="会员服务协议" prop="vipService">
+          <editor v-model="agreementForm.vipService" :min-height="200"/>
+        </el-form-item>
+        <el-form-item label="会员自动续费协议" prop="vipAutomaticService">
+          <editor v-model="agreementForm.vipAutomaticService" :min-height="200"/>
+        </el-form-item>
+        <el-form-item label="用户注销协议" prop="userRemoveService">
+          <editor v-model="agreementForm.userRemoveService" :min-height="200"/>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="agreementDialogVisible = false">取 消</el-button>
+        <el-button type="primary" @click="submitAgreementForm">确 定</el-button>
+      </div>
+    </el-dialog>
+
+
     <!-- 绑定  -->
     <el-dialog :title="bindForm.bindTitle" :visible.sync="bindForm.bindShow" width="800px" append-to-body :before-close="handleBindClose">
       <el-form ref="bindForm" :model="bindForm" :rules="bindRules" label-width="130px">
@@ -380,7 +422,9 @@ import {
   add,
   del,
   updateBindConfig,
-  updateUnbindConfig
+  updateUnbindConfig,
+  updateAgreementConfig,
+  queryAgreementConfig
 } from '@/api/course/coursePlaySourceConfig'
 import {updateIsTownOn} from "@/api/system/config";
 import { allList } from '@/api/company/company'
@@ -416,6 +460,27 @@ export default {
         appid: null,
         status: null
       },
+      // 协议配置相关
+      agreementDialogVisible: false,
+      agreementForm: {
+        appId: null,
+        doctorRegister: '',
+        doctorFiling: '',
+        userRegister: '',
+        userPrivacy: '',
+        userHealth: '',
+        vipService: '',
+        vipAutomaticService: '',
+        userRemoveService: ''
+      },
+      agreementRules: {
+        // doctorRegister: [
+        //   { required: true, message: "医生注册协议不能为空", trigger: "blur" }
+        // ],
+        // userRegister: [
+        //   { required: true, message: "用户协议不能为空", trigger: "blur" }
+        // ]
+      },
       showSearch: true,
       single: true,
       multiple: true,
@@ -519,6 +584,63 @@ export default {
       this.companyOptions = [];
       this.open = false;
     },
+    // 协议配置处理
+    handleAgreement(row) {
+      // 获取当前行的协议相关信息
+      queryAgreementConfig({appid:row.appid}).then(response => {
+        if (response.code === 200) {
+          // 返回agreementData json串
+          let agreementData = JSON.parse(response.data.agreementData);
+          this.agreementForm = {
+            appId: row.appid,
+            doctorRegister: agreementData.doctorRegister || '',
+            doctorFiling: agreementData.doctorFiling || '',
+            userRegister: agreementData.userRegister || '',
+            userPrivacy: agreementData.userPrivacy || '',
+            userHealth: agreementData.userHealth || '',
+            vipService: agreementData.vipService || '',
+            vipAutomaticService: agreementData.vipAutomaticService || '',
+            userRemoveService: agreementData.userRemoveService || ''
+          };
+
+          this.agreementDialogVisible = true;
+        }
+      })
+
+
+    },
+    // 提交协议配置
+    submitAgreementForm() {
+      this.$refs["agreementForm"].validate(valid => {
+        if (valid) {
+          // 调用API更新协议配置
+          const params = {
+            appId: this.agreementForm.appId,
+            agreementData: JSON.stringify({
+              doctorRegister: this.agreementForm.doctorRegister,
+              doctorFiling: this.agreementForm.doctorFiling,
+              userRegister: this.agreementForm.userRegister,
+              userPrivacy: this.agreementForm.userPrivacy,
+              userHealth: this.agreementForm.userHealth,
+              vipService: this.agreementForm.vipService,
+              vipAutomaticService: this.agreementForm.vipAutomaticService,
+              userRemoveService: this.agreementForm.userRemoveService
+            })
+          };
+          updateAgreementConfig(params).then(response => {
+            if (response.code === 200) {
+              this.msgSuccess("协议配置更新成功");
+              this.agreementDialogVisible = false;
+              this.getList(); // 刷新列表
+            } else {
+              this.msgError("协议配置更新失败:" + response.msg);
+            }
+          }).catch(error => {
+            this.msgError("请求失败:" + error.message);
+          });
+        }
+      });
+    },
     handleUnbind(row) {
       this.$confirm('是否确认解绑该配置?', "警告", {
         confirmButtonText: "确定",

+ 10 - 0
src/views/course/userCourse/index.vue

@@ -22,6 +22,15 @@
           />
         </el-select>
       </el-form-item>
+      <el-form-item label="课堂id" prop="courseId">
+        <el-input
+          v-model="queryParams.courseId"
+          placeholder="请输入课堂id"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
       <el-form-item label="课堂名称" prop="courseName">
         <el-input
           v-model="queryParams.courseName"
@@ -558,6 +567,7 @@ export default {
         hotRanking: null,
         integral: null,
         price: null,
+        courseId: null,
         isPrivate: 1,
         companyIdsList:[],
       },

+ 6 - 6
src/views/course/videoResource/index.vue

@@ -198,7 +198,7 @@
     />
 
     <!-- 添加或修改视频素材库对话框 -->
-    <minimizable-dialog :title="title" :visible.sync="open" width="700px" append-to-body :before-close="cancel"
+    <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body :before-close="cancel"
                         @minimize="hasMinimizableDialog = true" @restore="hasMinimizableDialog = false">
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
         <el-form-item label="素材名称" prop="resourceName" style="margin-top: 20px">
@@ -343,7 +343,7 @@
           {{ isUploading ? '上传中...' : '保存' }}
         </el-button>
       </div>
-    </minimizable-dialog>
+    </el-dialog>
 
     <el-dialog
       title="视频预览"
@@ -358,7 +358,7 @@
     </el-dialog>
 
     <!--批量修改弹框-->
-    <minimizable-dialog :title="'批量修改'" :visible.sync="batchUpdateVisible" width="700px" append-to-body :before-close="cancel"
+    <el-dialog :title="'批量修改'" :visible.sync="batchUpdateVisible" width="700px" append-to-body :before-close="cancel"
                         @minimize="hasMinimizableDialog = true" @restore="hasMinimizableDialog = false">
       <el-form ref="form" :model="batchUpdateForm" :rules="rules" label-width="80px">
       <el-form-item label="分类" prop="typeId">
@@ -387,9 +387,9 @@
         <el-button @click="cancelBatch">取 消</el-button>
         <el-button type="primary" @click="submitBatchUpdate">保 存</el-button>
       </div>
-    </minimizable-dialog>
+    </el-dialog>
     <!-- 批量选择视频弹窗 -->
-    <minimizable-dialog :title="'选择视频'" :visible.sync="batchAddVisible" width="1200px" append-to-body class="batch-dialog"
+    <el-dialog :title="'选择视频'" :visible.sync="batchAddVisible" width="1200px" append-to-body class="batch-dialog"
       :close-on-click-modal="false" :before-close="cancelBeforeBatch" @minimize="hasMinimizableDialog = true"
       @restore="hasMinimizableDialog = false">
       <div class="filter-container">
@@ -636,7 +636,7 @@
         </div>
       </el-dialog>
 
-    </minimizable-dialog>
+    </el-dialog>
 
     <!-- 项目选择弹窗 -->
     <el-dialog

+ 6 - 11
src/views/crm/externalContact/index.vue

@@ -787,18 +787,13 @@ import {
   setCustomerCourseSopList,
   unBindUserId, updateExternalContactCall
 } from '@/api/qw/externalContact'
-/*import {getMyQwUserList, getMyQwCompanyList, updateUser,getQwUserListLikeName} from "@/api/qw/user";*/
-import {getMyQwUserList, getMyQwCompanyList, updateUser} from "@/api/qw/user";
-import {listTag, getTag, searchTags,} from "@/api/qw/tag";
+
+import { getMyQwCompanyListAll } from '@/api/qw/user'
+import {listTag, searchTags,} from "@/api/qw/tag";
 import { allListTagGroup} from "@/api/qw/tagGroup";
-/*import mycustomer from '@/views/qw/externalContact/mycustomer'
-import customerDetails from '@/views/qw/externalContact/customerDetails'
-import SopDialog from '@/views/course/sop/SopDialog.vue'
-import  selectUser  from "@/views/qw/externalContact/selectUser.vue";
-import info from "@/views/qw/externalContact/info.vue";
-import { editTalk } from "@/api/qw/externalContactInfo";*/
+
 import PaginationMore from "../../../components/PaginationMore/index.vue";
-/*import userDetails from '@/views/store/components/userDetails.vue';*/
+
 export default {
   name: "ExternalContact",
   /*components:{PaginationMore, mycustomer,customerDetails,SopDialog,selectUser,info,userDetails},*/
@@ -1004,7 +999,7 @@ export default {
     });
 
 
-    getMyQwCompanyList().then(response => {
+    getMyQwCompanyListAll().then(response => {
             this.myQwCompanyList = response.data;
             if(this.myQwCompanyList!=null){
               // this.queryParams.corpId=this.myQwCompanyList[0].dictValue

+ 195 - 0
src/views/his/aiWorkflow/design.scss

@@ -0,0 +1,195 @@
+.workflow-designer {
+  height: 100vh;
+  display: flex;
+  flex-direction: column;
+  background: #f5f5f5;
+
+  .toolbar {
+    height: 50px;
+    background: #fff;
+    border-bottom: 1px solid #e8e8e8;
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    padding: 0 16px;
+
+    .toolbar-left, .toolbar-right {
+      display: flex;
+      align-items: center;
+    }
+  }
+
+  .main-content {
+    flex: 1;
+    display: flex;
+    overflow: hidden;
+  }
+
+  .node-panel {
+    width: 220px;
+    background: #fff;
+    border-right: 1px solid #e8e8e8;
+    overflow-y: auto;
+
+    .panel-title {
+      padding: 12px 16px;
+      font-weight: 600;
+      border-bottom: 1px solid #e8e8e8;
+    }
+
+    .node-category {
+      .category-title {
+        padding: 8px 16px;
+        font-size: 12px;
+        color: #999;
+        background: #fafafa;
+      }
+
+      .node-list {
+        padding: 8px;
+      }
+
+      .node-item {
+        display: flex;
+        align-items: center;
+        padding: 8px 12px;
+        margin-bottom: 8px;
+        background: #fff;
+        border: 1px solid #e8e8e8;
+        border-radius: 4px;
+        cursor: grab;
+        transition: all 0.2s;
+
+        &:hover {
+          box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
+        }
+
+        i {
+          font-size: 18px;
+          margin-right: 8px;
+        }
+
+        span {
+          font-size: 13px;
+        }
+      }
+    }
+  }
+
+  .canvas-container {
+    flex: 1;
+    position: relative;
+    overflow: auto;
+
+    .canvas-svg {
+      min-width: 100%;
+      min-height: 100%;
+      cursor: grab;
+
+      &.dragging-canvas {
+        cursor: grabbing;
+      }
+
+      .node-group {
+        cursor: move;
+
+        rect {
+          transition: stroke-width 0.2s;
+
+          &.selected {
+            stroke-width: 3;
+          }
+        }
+
+        .node-content {
+          display: flex;
+          align-items: center;
+          justify-content: center;
+          height: 100%;
+          padding: 0 12px;
+
+          i {
+            font-size: 18px;
+            margin-right: 6px;
+            flex-shrink: 0;
+          }
+
+          .node-name-input {
+            border: none;
+            background: transparent;
+            outline: none;
+            font-size: 13px;
+            color: #333;
+            text-align: center;
+            min-width: 40px;
+            padding: 2px 4px;
+            
+            &:focus {
+              background: rgba(255, 255, 255, 0.8);
+              border-radius: 2px;
+            }
+          }
+
+          .node-name {
+            font-size: 13px;
+            color: #333;
+            white-space: nowrap;
+            overflow: hidden;
+            text-overflow: ellipsis;
+          }
+        }
+
+        .anchor {
+          opacity: 0;
+          cursor: crosshair;
+          transition: opacity 0.2s;
+        }
+
+        &:hover .anchor {
+          opacity: 1;
+        }
+      }
+
+      .edge-group {
+        cursor: pointer;
+
+        path {
+          transition: stroke-width 0.2s;
+
+          &.selected {
+            stroke-width: 3;
+          }
+        }
+      }
+    }
+  }
+
+  .property-panel {
+    width: 280px;
+    background: #fff;
+    border-left: 1px solid #e8e8e8;
+    overflow-y: auto;
+
+    .panel-title {
+      padding: 12px 16px;
+      font-weight: 600;
+      border-bottom: 1px solid #e8e8e8;
+      display: flex;
+      justify-content: space-between;
+      align-items: center;
+
+      .el-icon-close {
+        cursor: pointer;
+        color: #999;
+
+        &:hover {
+          color: #333;
+        }
+      }
+    }
+
+    .el-form {
+      padding: 16px;
+    }
+  }
+}

+ 665 - 0
src/views/his/aiWorkflow/design.vue

@@ -0,0 +1,665 @@
+<template>
+  <div class="workflow-designer">
+    <!-- 顶部工具栏 -->
+    <div class="toolbar">
+      <div class="toolbar-left">
+        <el-button icon="el-icon-back" size="small" @click="goBack">返回</el-button>
+        <el-divider direction="vertical" />
+        <el-input v-model="form.workflowName" placeholder="工作流名称" size="small" style="width: 200px" />
+        <el-select v-model="form.workflowType" placeholder="类型" size="small" style="width: 120px; margin-left: 10px">
+          <el-option
+            v-for="dict in workflowTypeOptions"
+            :key="dict.dictValue"
+            :label="dict.dictLabel"
+            :value="dict.dictValue"
+          />
+        </el-select>
+      </div>
+      <div class="toolbar-right">
+        <el-input 
+          v-model="form.workflowDesc" 
+          placeholder="工作流描述" 
+          size="small" 
+          style="width: 200px; margin-right: 10px" 
+        />
+        <el-divider direction="vertical" />
+        <el-button icon="el-icon-zoom-in" size="small" @click="zoomIn">放大</el-button>
+        <el-button icon="el-icon-zoom-out" size="small" @click="zoomOut">缩小</el-button>
+        <el-button icon="el-icon-rank" size="small" @click="fitView">适应</el-button>
+        <el-divider direction="vertical" />
+        <el-button type="primary" icon="el-icon-check" size="small" @click="handleSave">保存</el-button>
+      </div>
+    </div>
+
+    <div class="main-content">
+      <!-- 左侧节点面板 -->
+      <div class="node-panel">
+        <div class="panel-title">节点类型</div>
+        <div class="node-category" v-for="category in nodeCategories" :key="category.key">
+          <div class="category-title">{{ category.name }}</div>
+          <div class="node-list">
+            <div
+              class="node-item"
+              v-for="nodeType in category.types"
+              :key="nodeType.typeCode"
+              draggable="true"
+              @dragstart="onDragStart($event, nodeType)"
+              :style="{ borderColor: nodeType.typeColor }"
+            >
+              <i :class="nodeType.typeIcon" :style="{ color: nodeType.typeColor }"></i>
+              <span>{{ nodeType.typeName }}</span>
+            </div>
+          </div>
+        </div>
+      </div>
+
+      <!-- 中间画布区域 -->
+      <div
+        class="canvas-container"
+        ref="canvasContainer"
+        @drop="onDrop"
+        @dragover.prevent
+        @click="onCanvasClick"
+        @mousedown="onCanvasMouseDown"
+      >
+        <svg class="canvas-svg" ref="canvasSvg" :width="canvasSize.width" :height="canvasSize.height"
+          :class="{ 'dragging-canvas': isDraggingCanvas }">
+          <!-- 网格背景 -->
+          <defs>
+            <pattern id="grid" width="20" height="20" patternUnits="userSpaceOnUse">
+              <path d="M 20 0 L 0 0 0 20" fill="none" stroke="#e0e0e0" stroke-width="0.5"/>
+            </pattern>
+          </defs>
+          <rect :width="canvasSize.width" :height="canvasSize.height" fill="url(#grid)" />
+          
+          <!-- 连线 -->
+          <g class="edges-layer" :transform="`translate(${canvasOffset.x}, ${canvasOffset.y}) scale(${scale})`">
+            <g
+              v-for="edge in edges"
+              :key="edge.edgeKey"
+              class="edge-group"
+              @click.stop="selectEdge(edge)"
+            >
+              <path
+                :d="getEdgePath(edge)"
+                :stroke="edge.edgeColor || '#999'"
+                stroke-width="2"
+                fill="none"
+                :class="{ selected: selectedEdge === edge }"
+              />
+              <text
+                v-if="edge.edgeLabel"
+                :x="getEdgeLabelPos(edge).x"
+                :y="getEdgeLabelPos(edge).y"
+                text-anchor="middle"
+                font-size="12"
+                fill="#666"
+              >{{ edge.edgeLabel }}</text>
+            </g>
+          </g>
+
+          <!-- 临时连线 -->
+          <g :transform="`translate(${canvasOffset.x}, ${canvasOffset.y}) scale(${scale})`">
+            <path
+              v-if="tempEdge"
+              :d="tempEdge.path"
+              stroke="#1890ff"
+              stroke-width="2"
+              fill="none"
+              stroke-dasharray="5,5"
+            />
+          </g>
+
+          <!-- 节点 -->
+          <g class="nodes-layer" :transform="`translate(${canvasOffset.x}, ${canvasOffset.y}) scale(${scale})`">
+            <g
+              v-for="node in nodes"
+              :key="node.nodeKey"
+              class="node-group"
+              :transform="`translate(${node.posX}, ${node.posY})`"
+              @mousedown="onNodeMouseDown($event, node)"
+              @click.stop="selectNode(node)"
+            >
+              <rect
+                :width="getNodeWidth(node)"
+                :height="node.height || 40"
+                rx="6"
+                ry="6"
+                :fill="getNodeBgColor(node)"
+                :stroke="node.nodeColor || '#1890ff'"
+                stroke-width="2"
+                :class="{ selected: selectedNode === node }"
+              />
+              <foreignObject :width="getNodeWidth(node)" :height="node.height || 40">
+                <div class="node-content" xmlns="http://www.w3.org/1999/xhtml">
+                  <i :class="node.nodeIcon" :style="{ color: node.nodeColor }"></i>
+                  <input
+                    type="text"
+                    class="node-name-input"
+                    v-model="node.nodeName"
+                    @mousedown.stop
+                    @input="onNodeNameInput(node)"
+                    :style="{ width: getInputWidth(node) + 'px' }"
+                  />
+                </div>
+              </foreignObject>
+              <!-- 连接点 -->
+              <circle :cx="getNodeWidth(node) / 2" cy="0" r="6" fill="#fff" stroke="#1890ff" stroke-width="2"
+                class="anchor top" @mousedown.stop="startConnect($event, node, 'top')" />
+              <circle :cx="getNodeWidth(node) / 2" :cy="node.height || 40" r="6" fill="#fff" stroke="#1890ff" stroke-width="2"
+                class="anchor bottom" @mousedown.stop="startConnect($event, node, 'bottom')" />
+              <circle cx="0" :cy="(node.height || 40) / 2" r="6" fill="#fff" stroke="#1890ff" stroke-width="2"
+                class="anchor left" @mousedown.stop="startConnect($event, node, 'left')" />
+              <circle :cx="getNodeWidth(node)" :cy="(node.height || 40) / 2" r="6" fill="#fff" stroke="#1890ff" stroke-width="2"
+                class="anchor right" @mousedown.stop="startConnect($event, node, 'right')" />
+            </g>
+          </g>
+        </svg>
+      </div>
+
+      <!-- 右侧属性面板 -->
+      <div class="property-panel" v-if="selectedNode || selectedEdge">
+        <div class="panel-title">
+          {{ selectedNode ? '节点属性' : '连线属性' }}
+          <i class="el-icon-close" @click="clearSelection"></i>
+        </div>
+        
+        <!-- 节点属性 -->
+        <el-form v-if="selectedNode" label-width="80px" size="small">
+          <el-form-item label="节点名称">
+            <el-input v-model="selectedNode.nodeName" />
+          </el-form-item>
+          <el-form-item label="节点类型">
+            <el-input :value="getNodeTypeName(selectedNode.nodeType)" disabled />
+          </el-form-item>
+          <el-form-item label="节点颜色">
+            <el-color-picker v-model="selectedNode.nodeColor" />
+          </el-form-item>
+          <el-form-item label="X坐标">
+            <el-input-number v-model="selectedNode.posX" :min="0" />
+          </el-form-item>
+          <el-form-item label="Y坐标">
+            <el-input-number v-model="selectedNode.posY" :min="0" />
+          </el-form-item>
+          <el-form-item>
+            <el-button type="danger" size="mini" @click="deleteNode">删除节点</el-button>
+          </el-form-item>
+        </el-form>
+
+        <!-- 连线属性 -->
+        <el-form v-if="selectedEdge" label-width="80px" size="small">
+          <el-form-item label="连线标签">
+            <el-input v-model="selectedEdge.edgeLabel" />
+          </el-form-item>
+          <el-form-item label="连线颜色">
+            <el-color-picker v-model="selectedEdge.edgeColor" />
+          </el-form-item>
+          <el-form-item label="条件表达式">
+            <el-input v-model="selectedEdge.conditionExpr" type="textarea" :rows="3" />
+          </el-form-item>
+          <el-form-item>
+            <el-button type="danger" size="mini" @click="deleteEdge">删除连线</el-button>
+          </el-form-item>
+        </el-form>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+import { getWorkflow, addWorkflow, updateWorkflow, getNodeTypes } from '@/api/his/aiWorkflow'
+
+export default {
+  name: 'WorkflowDesign',
+  data() {
+    return {
+      // 工作流ID
+      workflowId: null,
+      // 表单数据
+      form: {
+        workflowName: '新建工作流',
+        workflowDesc: '',
+        workflowType: '1',
+        canvasData: ''
+      },
+      // 节点列表
+      nodes: [],
+      // 连线列表
+      edges: [],
+      // 节点类型列表
+      nodeTypes: [],
+      // 节点分类
+      nodeCategories: [],
+      // 选中的节点
+      selectedNode: null,
+      // 选中的连线
+      selectedEdge: null,
+      // 缩放比例
+      scale: 1,
+      // 画布偏移
+      canvasOffset: { x: 0, y: 0 },
+      // 拖拽中的节点
+      draggingNode: null,
+      // 拖拽偏移
+      dragOffset: { x: 0, y: 0 },
+      // 是否正在连线
+      connecting: false,
+      // 连线起点
+      connectStart: null,
+      // 临时连线
+      tempEdge: null,
+      // 画布尺寸
+      canvasSize: { width: 2000, height: 2000 },
+      // 是否正在拖动画布
+      isDraggingCanvas: false,
+      // 画布拖动起始点
+      canvasDragStart: { x: 0, y: 0 },
+      // 工作流类型字典
+      workflowTypeOptions: [
+        { dictValue: '1', dictLabel: '对话流程' },
+        { dictValue: '2', dictLabel: '任务流程' },
+        { dictValue: '3', dictLabel: '审批流程' }
+      ]
+    }
+  },
+  created() {
+    this.workflowId = this.$route.params.id
+    this.loadNodeTypes()
+    if (this.workflowId) {
+      this.loadWorkflow()
+    }
+  },
+  mounted() {
+    document.addEventListener('mousemove', this.onMouseMove)
+    document.addEventListener('mouseup', this.onMouseUp)
+  },
+  beforeDestroy() {
+    document.removeEventListener('mousemove', this.onMouseMove)
+    document.removeEventListener('mouseup', this.onMouseUp)
+  },
+  methods: {
+    /** 加载节点类型 */
+    loadNodeTypes() {
+      getNodeTypes().then(res => {
+        this.nodeTypes = res.data || []
+        this.groupNodeTypes()
+      }).catch(() => {
+        // 如果接口未实现,使用默认节点类型
+        this.nodeTypes = [
+          { typeCode: 'start', typeName: '开始', typeCategory: 'basic', typeIcon: 'el-icon-video-play', typeColor: '#52c41a' },
+          { typeCode: 'end', typeName: '结束', typeCategory: 'basic', typeIcon: 'el-icon-video-pause', typeColor: '#ff4d4f' },
+          { typeCode: 'condition', typeName: '条件判断', typeCategory: 'logic', typeIcon: 'el-icon-question', typeColor: '#faad14' },
+          { typeCode: 'parallel', typeName: '并行网关', typeCategory: 'logic', typeIcon: 'el-icon-share', typeColor: '#722ed1' },
+          { typeCode: 'ai_chat', typeName: 'AI对话', typeCategory: 'ai', typeIcon: 'el-icon-chat-dot-round', typeColor: '#1890ff' },
+          { typeCode: 'ai_analysis', typeName: 'AI分析', typeCategory: 'ai', typeIcon: 'el-icon-data-analysis', typeColor: '#13c2c2' },
+          { typeCode: 'http', typeName: 'HTTP请求', typeCategory: 'integration', typeIcon: 'el-icon-link', typeColor: '#eb2f96' },
+          { typeCode: 'database', typeName: '数据库', typeCategory: 'integration', typeIcon: 'el-icon-coin', typeColor: '#fa8c16' }
+        ]
+        this.groupNodeTypes()
+      })
+    },
+    /** 节点类型分组 */
+    groupNodeTypes() {
+      const categoryMap = {
+        basic: { key: 'basic', name: '基础节点', types: [] },
+        logic: { key: 'logic', name: '逻辑节点', types: [] },
+        ai: { key: 'ai', name: 'AI节点', types: [] },
+        integration: { key: 'integration', name: '集成节点', types: [] }
+      }
+      this.nodeTypes.forEach(t => {
+        const cat = categoryMap[t.typeCategory] || categoryMap.basic
+        cat.types.push(t)
+      })
+      this.nodeCategories = Object.values(categoryMap).filter(c => c.types.length > 0)
+    },
+    /** 加载工作流 */
+    loadWorkflow() {
+      getWorkflow(this.workflowId).then(res => {
+        const data = res.data
+        this.form = {
+          workflowName: data.workflowName,
+          workflowDesc: data.workflowDesc,
+          workflowType: String(data.workflowType),
+          canvasData: data.canvasData
+        }
+        this.nodes = data.nodes || []
+        this.edges = data.edges || []
+      })
+    },
+    /** 返回列表 */
+    goBack() {
+      this.$router.push('/his/aiWorkflow')
+    },
+    /** 放大 */
+    zoomIn() {
+      this.scale = Math.min(2, this.scale + 0.1)
+    },
+    /** 缩小 */
+    zoomOut() {
+      this.scale = Math.max(0.5, this.scale - 0.1)
+    },
+    /** 适应画布 */
+    fitView() {
+      this.scale = 1
+      this.canvasOffset = { x: 0, y: 0 }
+    },
+    /** 生成唯一Key */
+    generateKey() {
+      return 'node_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9)
+    },
+    /** 拖拽开始 */
+    onDragStart(e, nodeType) {
+      e.dataTransfer.setData('nodeType', JSON.stringify(nodeType))
+    },
+    /** 放置节点 */
+    onDrop(e) {
+      const nodeTypeStr = e.dataTransfer.getData('nodeType')
+      if (!nodeTypeStr) return
+      const nodeType = JSON.parse(nodeTypeStr)
+      const rect = this.$refs.canvasContainer.getBoundingClientRect()
+      const x = (e.clientX - rect.left - this.canvasOffset.x) / this.scale
+      const y = (e.clientY - rect.top - this.canvasOffset.y) / this.scale
+      
+      const newNode = {
+        nodeKey: this.generateKey(),
+        nodeName: nodeType.typeName,
+        nodeType: nodeType.typeCode,
+        nodeIcon: nodeType.typeIcon,
+        nodeColor: nodeType.typeColor,
+        posX: Math.round(x - 50),
+        posY: Math.round(y - 20),
+        height: 40,
+        nodeConfig: nodeType.defaultConfig || '{}'
+      }
+      this.nodes.push(newNode)
+      this.selectNode(newNode)
+      // 检测并扩展画布
+      this.checkAndExpandCanvas(newNode)
+    },
+    /** 点击画布 */
+    onCanvasClick() {
+      this.clearSelection()
+    },
+    /** 画布鼠标按下 */
+    onCanvasMouseDown(e) {
+      // 只响应左键且点击在空白区域
+      if (e.button !== 0) return
+      if (e.target.tagName === 'rect' && e.target.getAttribute('fill') === 'url(#grid)') {
+        this.isDraggingCanvas = true
+        this.canvasDragStart = {
+          x: e.clientX,
+          y: e.clientY,
+          scrollLeft: this.$refs.canvasContainer.scrollLeft,
+          scrollTop: this.$refs.canvasContainer.scrollTop
+        }
+        e.preventDefault()
+      }
+    },
+    /** 选中节点 */
+    selectNode(node) {
+      this.selectedNode = node
+      this.selectedEdge = null
+    },
+    /** 选中连线 */
+    selectEdge(edge) {
+      this.selectedEdge = edge
+      this.selectedNode = null
+    },
+    /** 清除选中 */
+    clearSelection() {
+      this.selectedNode = null
+      this.selectedEdge = null
+    },
+    /** 节点鼠标按下 */
+    onNodeMouseDown(e, node) {
+      if (e.target.classList.contains('anchor')) return
+      this.draggingNode = node
+      const rect = this.$refs.canvasContainer.getBoundingClientRect()
+      const scrollLeft = this.$refs.canvasContainer.scrollLeft
+      const scrollTop = this.$refs.canvasContainer.scrollTop
+      this.dragOffset = {
+        x: (e.clientX - rect.left + scrollLeft - this.canvasOffset.x) / this.scale - node.posX,
+        y: (e.clientY - rect.top + scrollTop - this.canvasOffset.y) / this.scale - node.posY
+      }
+    },
+    /** 鼠标移动 */
+    onMouseMove(e) {
+      // 拖动画布
+      if (this.isDraggingCanvas) {
+        const dx = e.clientX - this.canvasDragStart.x
+        const dy = e.clientY - this.canvasDragStart.y
+        this.$refs.canvasContainer.scrollLeft = this.canvasDragStart.scrollLeft - dx
+        this.$refs.canvasContainer.scrollTop = this.canvasDragStart.scrollTop - dy
+        return
+      }
+      // 拖动节点
+      if (this.draggingNode) {
+        const rect = this.$refs.canvasContainer.getBoundingClientRect()
+        const scrollLeft = this.$refs.canvasContainer.scrollLeft
+        const scrollTop = this.$refs.canvasContainer.scrollTop
+        const x = (e.clientX - rect.left + scrollLeft - this.canvasOffset.x) / this.scale - this.dragOffset.x
+        const y = (e.clientY - rect.top + scrollTop - this.canvasOffset.y) / this.scale - this.dragOffset.y
+        this.draggingNode.posX = Math.max(0, Math.round(x))
+        this.draggingNode.posY = Math.max(0, Math.round(y))
+        // 检测并扩展画布
+        this.checkAndExpandCanvas(this.draggingNode)
+      }
+      // 连线
+      if (this.connecting && this.connectStart) {
+        const rect = this.$refs.canvasContainer.getBoundingClientRect()
+        const scrollLeft = this.$refs.canvasContainer.scrollLeft
+        const scrollTop = this.$refs.canvasContainer.scrollTop
+        const endX = (e.clientX - rect.left + scrollLeft - this.canvasOffset.x) / this.scale
+        const endY = (e.clientY - rect.top + scrollTop - this.canvasOffset.y) / this.scale
+        this.tempEdge = {
+          path: this.calcPath(this.connectStart.x, this.connectStart.y, endX, endY)
+        }
+      }
+    },
+    /** 检测并扩展画布 */
+    checkAndExpandCanvas(node) {
+      const nodeWidth = this.getNodeWidth(node)
+      const nodeHeight = node.height || 40
+      const padding = 200 // 边缘预留空间
+      const expandStep = 500 // 每次扩展的大小
+      
+      const nodeRight = node.posX + nodeWidth
+      const nodeBottom = node.posY + nodeHeight
+      
+      // 检测右边缘
+      if (nodeRight + padding > this.canvasSize.width) {
+        this.canvasSize.width += expandStep
+      }
+      // 检测下边缘
+      if (nodeBottom + padding > this.canvasSize.height) {
+        this.canvasSize.height += expandStep
+      }
+    },
+    /** 鼠标松开 */
+    onMouseUp(e) {
+      // 停止拖动画布
+      if (this.isDraggingCanvas) {
+        this.isDraggingCanvas = false
+        return
+      }
+      // 停止连线
+      if (this.connecting) {
+        const targetNode = this.findNodeAtPoint(e.clientX, e.clientY)
+        if (targetNode && targetNode.nodeKey !== this.connectStart.nodeKey) {
+          this.createEdge(this.connectStart.nodeKey, targetNode.nodeKey,
+            this.connectStart.anchor, 'top')
+        }
+        this.connecting = false
+        this.connectStart = null
+        this.tempEdge = null
+      }
+      this.draggingNode = null
+    },
+    /** 开始连线 */
+    startConnect(e, node, anchor) {
+      this.connecting = true
+      const anchorPos = this.getAnchorPos(node, anchor)
+      this.connectStart = {
+        nodeKey: node.nodeKey,
+        anchor: anchor,
+        x: anchorPos.x,
+        y: anchorPos.y
+      }
+    },
+    /** 获取锚点位置 */
+    getAnchorPos(node, anchor) {
+      const w = this.getNodeWidth(node)
+      const h = node.height || 40
+      switch (anchor) {
+        case 'top': return { x: node.posX + w / 2, y: node.posY }
+        case 'bottom': return { x: node.posX + w / 2, y: node.posY + h }
+        case 'left': return { x: node.posX, y: node.posY + h / 2 }
+        case 'right': return { x: node.posX + w, y: node.posY + h / 2 }
+        default: return { x: node.posX + w / 2, y: node.posY + h }
+      }
+    },
+    /** 查找点击位置的节点 */
+    findNodeAtPoint(clientX, clientY) {
+      const rect = this.$refs.canvasContainer.getBoundingClientRect()
+      const scrollLeft = this.$refs.canvasContainer.scrollLeft
+      const scrollTop = this.$refs.canvasContainer.scrollTop
+      const x = (clientX - rect.left + scrollLeft - this.canvasOffset.x) / this.scale
+      const y = (clientY - rect.top + scrollTop - this.canvasOffset.y) / this.scale
+      return this.nodes.find(n => {
+        const w = this.getNodeWidth(n)
+        const h = n.height || 40
+        return x >= n.posX && x <= n.posX + w && y >= n.posY && y <= n.posY + h
+      })
+    },
+    /** 创建连线 */
+    createEdge(sourceKey, targetKey, sourceAnchor, targetAnchor) {
+      const exists = this.edges.find(e => 
+        e.sourceNodeKey === sourceKey && e.targetNodeKey === targetKey)
+      if (exists) return
+      
+      this.edges.push({
+        edgeKey: 'edge_' + Date.now(),
+        sourceNodeKey: sourceKey,
+        targetNodeKey: targetKey,
+        sourceAnchor: sourceAnchor,
+        targetAnchor: targetAnchor,
+        edgeType: 'smoothstep',
+        edgeColor: '#999999'
+      })
+    },
+    /** 获取连线路径 */
+    getEdgePath(edge) {
+      const sourceNode = this.nodes.find(n => n.nodeKey === edge.sourceNodeKey)
+      const targetNode = this.nodes.find(n => n.nodeKey === edge.targetNodeKey)
+      if (!sourceNode || !targetNode) return ''
+      
+      const start = this.getAnchorPos(sourceNode, edge.sourceAnchor || 'bottom')
+      const end = this.getAnchorPos(targetNode, edge.targetAnchor || 'top')
+      return this.calcPath(start.x, start.y, end.x, end.y)
+    },
+    /** 计算贝塞尔曲线路径 */
+    calcPath(x1, y1, x2, y2) {
+      const midY = (y1 + y2) / 2
+      return `M ${x1} ${y1} C ${x1} ${midY}, ${x2} ${midY}, ${x2} ${y2}`
+    },
+    /** 获取连线标签位置 */
+    getEdgeLabelPos(edge) {
+      const sourceNode = this.nodes.find(n => n.nodeKey === edge.sourceNodeKey)
+      const targetNode = this.nodes.find(n => n.nodeKey === edge.targetNodeKey)
+      if (!sourceNode || !targetNode) return { x: 0, y: 0 }
+      const start = this.getAnchorPos(sourceNode, edge.sourceAnchor || 'bottom')
+      const end = this.getAnchorPos(targetNode, edge.targetAnchor || 'top')
+      return { x: (start.x + end.x) / 2, y: (start.y + end.y) / 2 }
+    },
+    /** 获取节点背景色 */
+    getNodeBgColor(node) {
+      const color = node.nodeColor || '#1890ff'
+      return color + '15'
+    },
+    /** 计算节点宽度 */
+    getNodeWidth(node) {
+      const minWidth = 80
+      const padding = 50 // 图标 + 左右padding
+      const charWidth = 14 // 每个字符大约宽度
+      const textWidth = (node.nodeName || '').length * charWidth
+      return Math.max(minWidth, textWidth + padding)
+    },
+    /** 计算输入框宽度 */
+    getInputWidth(node) {
+      const minWidth = 40
+      const charWidth = 14
+      const textWidth = (node.nodeName || '').length * charWidth
+      return Math.max(minWidth, textWidth + 10)
+    },
+    /** 节点名称输入事件 */
+    onNodeNameInput(node) {
+      // 触发视图更新
+      this.$forceUpdate()
+    },
+    /** 获取节点类型名称 */
+    getNodeTypeName(typeCode) {
+      const t = this.nodeTypes.find(n => n.typeCode === typeCode)
+      return t ? t.typeName : typeCode
+    },
+    /** 删除节点 */
+    deleteNode() {
+      if (!this.selectedNode) return
+      this.$confirm('是否确认删除该节点?', '警告', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        const key = this.selectedNode.nodeKey
+        this.nodes = this.nodes.filter(n => n.nodeKey !== key)
+        this.edges = this.edges.filter(e => 
+          e.sourceNodeKey !== key && e.targetNodeKey !== key)
+        this.selectedNode = null
+      }).catch(() => {})
+    },
+    /** 删除连线 */
+    deleteEdge() {
+      if (!this.selectedEdge) return
+      this.$confirm('是否确认删除该连线?', '警告', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.edges = this.edges.filter(e => e.edgeKey !== this.selectedEdge.edgeKey)
+        this.selectedEdge = null
+      }).catch(() => {})
+    },
+    /** 保存工作流 */
+    handleSave() {
+      if (!this.form.workflowName) {
+        this.msgWarning('请输入工作流名称')
+        return
+      }
+      const data = {
+        workflowId: this.workflowId,
+        workflowName: this.form.workflowName,
+        workflowDesc: this.form.workflowDesc,
+        workflowType: this.form.workflowType,
+        canvasData: JSON.stringify({ scale: this.scale, offset: this.canvasOffset }),
+        nodes: this.nodes,
+        edges: this.edges
+      }
+      
+      if (this.workflowId) {
+        updateWorkflow(data).then(() => {
+          this.msgSuccess('保存成功')
+        })
+      } else {
+        addWorkflow(data).then(res => {
+          this.msgSuccess('保存成功')
+          this.workflowId = res.data
+          this.$router.replace('/his/aiWorkflow/design/' + this.workflowId)
+        })
+      }
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+@import './design.scss';
+</style>

+ 282 - 0
src/views/his/aiWorkflow/index.vue

@@ -0,0 +1,282 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
+      <el-form-item label="工作流名称" prop="workflowName">
+        <el-input
+          v-model="queryParams.workflowName"
+          placeholder="请输入工作流名称"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="工作流类型" prop="workflowType">
+        <el-select v-model="queryParams.workflowType" placeholder="请选择类型" clearable size="small">
+          <el-option
+            v-for="dict in workflowTypeOptions"
+            :key="dict.dictValue"
+            :label="dict.dictLabel"
+            :value="dict.dictValue"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="状态" prop="status">
+        <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
+          <el-option
+            v-for="dict in statusOptions"
+            :key="dict.dictValue"
+            :label="dict.dictLabel"
+            :value="dict.dictValue"
+          />
+        </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="['his:aiWorkflow: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="['his:aiWorkflow:remove']"
+        >删除</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          :loading="exportLoading"
+          @click="handleExport"
+          v-hasPermi="['his:aiWorkflow:export']"
+        >导出</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table v-loading="loading" border :data="workflowList" @selection-change="handleSelectionChange">
+      <el-table-column type="selection" width="55" align="center" />
+      <el-table-column label="ID" align="center" prop="workflowId" width="80" />
+      <el-table-column label="工作流名称" align="center" prop="workflowName" min-width="150" show-overflow-tooltip />
+      <el-table-column label="描述" align="center" prop="workflowDesc" min-width="200" show-overflow-tooltip />
+      <el-table-column label="类型" align="center" prop="workflowType" width="100">
+        <template slot-scope="scope">
+          <dict-tag :options="workflowTypeOptions" :value="scope.row.workflowType"/>
+        </template>
+      </el-table-column>
+      <el-table-column label="状态" align="center" prop="status" width="80">
+        <template slot-scope="scope">
+          <el-switch
+            v-model="scope.row.status"
+            :active-value="1"
+            :inactive-value="0"
+            @change="handleStatusChange(scope.row)"
+          />
+        </template>
+      </el-table-column>
+      <el-table-column label="版本" align="center" prop="version" width="60" />
+      <el-table-column label="创建时间" align="center" prop="createTime" width="160">
+        <template slot-scope="scope">
+          <span>{{ parseTime(scope.row.createTime) }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="200">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleEdit(scope.row)"
+            v-hasPermi="['his:aiWorkflow:edit']"
+          >设计</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-document-copy"
+            @click="handleCopy(scope.row)"
+            v-hasPermi="['his:aiWorkflow:add']"
+          >复制</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+            v-hasPermi="['his:aiWorkflow:remove']"
+          >删除</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"
+    />
+  </div>
+</template>
+
+<script>
+import { listWorkflow, delWorkflow, updateWorkflowStatus, copyWorkflow, exportWorkflow } from '@/api/his/aiWorkflow'
+
+export default {
+  name: 'AiWorkflow',
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      // 导出遮罩层
+      exportLoading: false,
+      // 选中数组
+      ids: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 工作流表格数据
+      workflowList: [],
+      // 工作流类型字典
+      workflowTypeOptions: [
+        { dictValue: '1', dictLabel: '对话流程' },
+        { dictValue: '2', dictLabel: '任务流程' },
+        { dictValue: '3', dictLabel: '审批流程' }
+      ],
+      // 状态字典
+      statusOptions: [
+        { dictValue: '1', dictLabel: '启用' },
+        { dictValue: '0', dictLabel: '禁用' }
+      ],
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        workflowName: null,
+        workflowType: null,
+        status: null
+      }
+    }
+  },
+  created() {
+    this.getList()
+    // 如果有字典配置,可以使用以下方式获取
+    // this.getDicts("ai_workflow_type").then(response => {
+    //   this.workflowTypeOptions = response.data
+    // })
+  },
+  methods: {
+    /** 查询工作流列表 */
+    getList() {
+      this.loading = true
+      listWorkflow(this.queryParams).then(response => {
+        this.workflowList = response.rows
+        this.total = response.total
+        this.loading = false
+      })
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1
+      this.getList()
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm('queryForm')
+      this.handleQuery()
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.workflowId)
+      this.single = selection.length !== 1
+      this.multiple = !selection.length
+    },
+    /** 新增按钮操作 */
+    handleAdd() {
+      this.$router.push('/his/aiWorkflow/design')
+    },
+    /** 设计按钮操作 */
+    handleEdit(row) {
+      this.$router.push('/his/aiWorkflow/design/' + row.workflowId)
+    },
+    /** 复制按钮操作 */
+    handleCopy(row) {
+      this.$confirm('是否确认复制该工作流?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        return copyWorkflow(row.workflowId)
+      }).then(() => {
+        this.getList()
+        this.msgSuccess('复制成功')
+      }).catch(() => {})
+    },
+    /** 状态修改 */
+    handleStatusChange(row) {
+      const text = row.status === 1 ? '启用' : '停用'
+      this.$confirm('确认要"' + text + '"该工作流吗?', '警告', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        return updateWorkflowStatus(row.workflowId, row.status)
+      }).then(() => {
+        this.msgSuccess(text + '成功')
+      }).catch(() => {
+        row.status = row.status === 1 ? 0 : 1
+      })
+    },
+    /** 删除按钮操作 */
+    handleDelete(row) {
+      const workflowIds = row.workflowId || this.ids
+      this.$confirm('是否确认删除工作流编号为"' + workflowIds + '"的数据项?', '警告', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        return delWorkflow(workflowIds)
+      }).then(() => {
+        this.getList()
+        this.msgSuccess('删除成功')
+      }).catch(() => {})
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      const queryParams = this.queryParams
+      this.$confirm('是否确认导出所有工作流数据项?', '警告', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.exportLoading = true
+        return exportWorkflow(queryParams)
+      }).then(response => {
+        this.download(response.msg)
+        this.exportLoading = false
+      }).catch(() => {})
+    }
+  }
+}
+</script>

+ 527 - 0
src/views/his/statistics/courseReport.vue

@@ -0,0 +1,527 @@
+<template>
+  <div class="app-container">
+    <!-- 添加维度切换Tab -->
+    <el-tabs v-model="activeDimension" @tab-click="handleDimensionChange">
+      <el-tab-pane label="公司维度" name="company"></el-tab-pane>
+      <el-tab-pane label="课程维度" name="course"></el-tab-pane>
+      <el-tab-pane label="小节维度" name="video"></el-tab-pane>
+    </el-tabs>
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="85px">
+      <el-form-item label="公司名" prop="companyId" v-if="activeDimension === 'company'">
+        <el-select filterable v-model="queryParams.companyId" placeholder="请选择公司名"
+                   clearable size="small">
+          <el-option
+            v-for="item in companys"
+            :key="item.companyId"
+            :label="item.companyName"
+            :value="item.companyId"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="课程" prop="courseId" v-if="activeDimension === 'course'||activeDimension === 'video'">
+        <el-select filterable v-model="queryParams.courseId" placeholder="请选择课程"
+                   clearable size="small" @change="handleCourseChange">
+          <el-option
+            v-for="item in courses"
+            :key="item.courseId"
+            :label="item.dictLabel"
+            :value="item.dictValue"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="小节" prop="videoId" v-if="activeDimension === 'video' && queryParams.courseId">
+        <el-select filterable v-model="queryParams.videoId" placeholder="请选择小节"
+                   clearable size="small">
+          <el-option
+            v-for="item in videos"
+            :key="item.videoId"
+            :label="item.dictLabel"
+            :value="item.dictValue"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <el-form-item label="看课时间" prop="createTime">
+          <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd"
+                          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
+                          @change="xdChange"></el-date-picker>
+        </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="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          :loading="exportLoading"
+          @click="handleExport"
+        >导出</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+    <el-table height="500" v-loading="loading" border :data="packageOrderList">
+      <el-table-column label="销售公司" align="center" prop="companyName" width="120px"
+                       v-if="activeDimension === 'company'"/>
+      <el-table-column label="课程名称" align="center" prop="courseName"
+                       v-if="activeDimension === 'course'"/>
+      <el-table-column label="小节名称" align="center" prop="videoName"
+                       v-if="activeDimension === 'video'"/>
+      <el-table-column label="进线人数" align="center" prop="accessCount"/>
+      <el-table-column label="完课人数" align="center" prop="finishedCount"/>
+      <el-table-column label="完播数" align="center" prop="courseCompleteTimes"/>
+      <el-table-column label="完课率" align="center" prop="finishRate"/>
+    </el-table>
+    <div class="total-summary">
+      <span class="total-title">总计:</span>
+      <span class="total-item">进线人数: {{ calculatedTotalData.accessCount }}</span>
+      <span class="total-item">完课人数: {{ calculatedTotalData.finishedCount }}</span>
+      <span class="total-item">完课率: {{ calculatedTotalData.finishRate}}</span>
+      <span class="total-item">完播数: {{ calculatedTotalData.courseCompleteTimes }}</span>
+    </div>
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+  </div>
+</template>
+
+<script>
+import {
+  listPackageOrder, getPackageOrder, delPackageOrder, addPackageOrder, updatePackageOrder, exportPackageOrder,
+  PackageOrderReport, orderReport, courseReport, exportOrderReport, exportCourseReport
+} from "@/api/his/packageOrder";
+import {getCompanyList} from "@/api/company/company";
+import packageOrderDetails from '../../components/his/packageOrderDetails.vue';
+import {treeselect} from "@/api/company/companyDept";
+import Treeselect from "@riophae/vue-treeselect";
+import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+import {getTask} from "@/api/common";
+import {getCourseList, getVideosByCourse} from "@/api/course/userWatchCourseStatistics";
+
+export default {
+  name: "PackageOrder",
+  components: {packageOrderDetails, Treeselect},
+  data() {
+    return {
+      normalizer: function(node) {
+        return {
+          id: node.id || node.dictValue,
+          label: node.label || node.dictLabel,
+          children: node.children
+        }
+      },
+      // 添加用于存储计算总和的数据
+      calculatedTotalData: {
+        accessCount: 0,
+        finishedCount: 0,
+        finishRate: '0%',
+        courseCompleteTimes: 0,
+      },
+      totalData: {},
+      companys: [],
+      courses: [],  // 课程列表
+      videos: [],   // 小节列表
+      activeDimension: 'company', // 当前激活的维度
+      companyId: undefined,
+      show: {
+        open: false,
+      },
+      sourceOptions: [],
+      actName: "2",
+      // 遮罩层
+      loading: true,
+      startTime: null,
+      // 导出遮罩层
+      exportLoading: false,
+      // 选中数组
+      ids: [],
+      createTime: null,
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      endTime: null,
+      // 总条数
+      total: 0,
+      // 套餐订单表格数据
+      packageOrderList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 是否支付字典
+      isPayOptions: [],
+      // 状态字典
+      statusOptions: [],
+      refundStatusOptions: [],
+      packageSubTypeOptions: [],
+      payTypeOptions: [],
+      deliveryPayStatusOptions: [],
+      deliveryStatusOptions: [],
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        orderSn: null,
+        userId: null,
+        doctorId: null,
+        doctorName: null,
+        phone: null,
+        phoneMk: null,
+        packageId: null,
+        packageName: null,
+        payMoney: null,
+        isPay: null,
+        days: null,
+        status: null,
+        startTime: null,
+        startDate: null,
+        endDate:null,
+        finishTime: null,
+        sTime: null,
+        eTime: null,
+        stTime: null,
+        endTime: null,
+        endStartTime: null,
+        endEndTime: null,
+        companyUserName: null,
+        companyName: null,
+        deptId: null,
+        source: null,
+        dimension: 'company',  // 添加维度参数
+        courseId: null,    // 课程ID
+        videoId: null     // 小节ID
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {}
+    };
+  },
+  created() {
+    // 设置默认时间为前一天
+    const yesterday = new Date();
+    yesterday.setDate(yesterday.getDate() - 1);
+    const formatDate = (date) => {
+      const year = date.getFullYear();
+      const month = String(date.getMonth() + 1).padStart(2, '0');
+      const day = String(date.getDate()).padStart(2, '0');
+      return `${year}-${month}-${day}`;
+    };
+    this.createTime = [formatDate(yesterday), formatDate(yesterday)];
+    this.queryParams.sTime = this.createTime[0];
+    this.queryParams.eTime = this.createTime[1];
+    // 获取课程列表
+    getCourseList().then(response => {
+      this.courses = response.data;
+    })
+    getCompanyList().then(response => {
+      this.companys = response.data;
+      if (this.companys != null && this.companys.length > 0) {
+        this.companyId = this.companys[0].companyId;
+      }
+      this.companys.push({companyId: "-1", companyName: "无"})
+    });
+    this.getList();
+  },
+  methods: {
+    /** 查询套餐订单列表 */
+    getList() {
+      this.loading = true;
+      this.queryParams.dimension = this.activeDimension;
+      let requestParams = { ...this.queryParams };
+      if (this.activeDimension === 'video') {
+        // 在小节维度下,如果已选择小节,只保留videoId,不传递courseId
+        if (requestParams.videoId) {
+          delete requestParams.courseId;
+        }
+      }
+      courseReport(requestParams).then(response => {
+        const rows = response.rows || [];
+        // 标准化数据,为缺失字段提供默认值
+        this.packageOrderList = rows.map(item => ({
+          ...item,
+          // 确保必需字段存在,如果缺失则提供默认值
+          companyName: item.companyName || '-',
+          courseName: item.courseName || '-',
+          videoName: item.videoName || '-',
+          accessCount: item.accessCount || 0,
+          finishedCount: item.finishedCount || 0,
+          courseCompleteTimes: item.courseCompleteTimes || 0,
+          finishRate: item.finishRate || '0%',
+        }));
+        console.log("列表数据:", this.packageOrderList);
+        this.total = response.total;
+        this.calculateTotals();
+      }).catch(error => {
+        // 即使接口返回错误,也要重置加载状态
+        console.error('获取数据失败:', error);
+        this.packageOrderList = [];
+        this.total = 0;
+      }).finally(() => {
+        // 无论成功或失败,都重置加载状态
+        this.loading = false;
+        // 延迟强制更新以确保DOM完全渲染
+        setTimeout(() => {
+          this.$forceUpdate();
+        }, 100);
+      });
+    },
+    calculateTotals() {
+      // 重置总计数据
+      this.calculatedTotalData = {
+        accessCount: 0,
+        finishedCount: 0,
+        courseCompleteTimes: 0,
+        finishRate: '0%',
+      };
+
+      // 遍历当前页数据计算总和
+      this.packageOrderList.forEach(item => {
+        this.calculatedTotalData.accessCount += Number(item.accessCount) || 0;
+        this.calculatedTotalData.finishedCount += Number(item.finishedCount) || 0;
+        this.calculatedTotalData.courseCompleteTimes += Number(item.courseCompleteTimes) || 0;
+      });
+
+      if (this.calculatedTotalData.accessCount > 0) {
+        // 完课率 = 完课人数 / 进线人数
+        this.calculatedTotalData.finishRate = ((this.calculatedTotalData.finishedCount / this.calculatedTotalData.accessCount) * 100).toFixed(2) + '%';
+      } else {
+        this.calculatedTotalData.finishRate = '0.00%';
+      }
+    },
+    /** 维度切换处理 */
+    handleDimensionChange(tab) {
+      this.activeDimension = tab.name;
+      // 更新查询参数中的维度
+      this.queryParams.dimension = tab.name;
+
+      // 重置相关查询参数
+      if (this.activeDimension === 'company') {
+        // 公司维度,清空课程和小节参数
+        this.queryParams.courseId = null;
+        this.queryParams.videoId = null;
+      } else if (this.activeDimension === 'course') {
+        // 课程维度,清空公司和小节参数
+        this.queryParams.companyId = null;
+        this.queryParams.videoId = null;
+      } else if (this.activeDimension === 'video') {
+        // 保留 courseId 的选择状态,但清空 videoId
+        this.queryParams.videoId = null;
+      }
+
+      // 清空小节列表
+      this.videos = [];
+      // 重新获取数据
+      this.getList();
+    },
+    /** 课程变更处理 */
+    handleCourseChange(val) {
+      // 在课程维度和小节维度都需要处理课程变更
+      if (this.activeDimension === 'course' || this.activeDimension === 'video') {
+        this.queryParams.courseId = val;
+        this.queryParams.videoId = null; // 清空已选择的小节
+
+        if (val) {
+          // 根据课程ID获取对应的小节列表
+          this.getVideosByCourseId(val);
+        } else {
+          // 如果清空课程,也清空小节选项
+          this.videos = [];
+        }
+      }
+    },
+
+    /** 根据训练营获取营期数据 */
+    getVideosByCourseId(courseId) {
+      getVideosByCourse(courseId).then((response) => {
+        this.videos = response.data || [];
+      }).catch(error => {
+        console.error('获取小节数据失败:', error);
+        this.videos = [];
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        orderId: null,
+        orderSn: null,
+        userId: null,
+        doctorId: null,
+        packageId: null,
+        packageName: null,
+        payMoney: null,
+        isPay: null,
+        days: null,
+        status: 0,
+        startTime: null,
+        finishTime: null,
+        createTime: null
+      };
+      this.resetForm("form");
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      // 清空所有时间相关变量
+      this.createTime = null;
+      this.startTime = null;
+      this.endTime = null;
+
+      // 重置所有查询参数
+      this.queryParams = {
+        pageNum: null,
+        pageSize: null,
+        orderSn: null,
+        userId: null,
+        doctorId: null,
+        doctorName: null,
+        phone: null,
+        phoneMk: null,
+        packageId: null,
+        packageName: null,
+        payMoney: null,
+        isPay: null,
+        days: null,
+        status: null,
+        startTime: null,
+        finishTime: null,
+        sTime: null,
+        eTime: null,
+        stTime: null,
+        endTime: null,
+        endStartTime: null,
+        endEndTime: null,
+        companyUserName: null,
+        companyName: null,
+        deptId: null,
+        source: null,
+        dimension: this.activeDimension,  // 维持当前维度
+        companyId: null,  // 重置所有维度ID
+        courseId: null,
+        videoId: null,
+      };
+      // 重新获取课程列表
+      getCourseList().then(response => {
+        this.courses = response.data;
+      });
+      this.videos = [];
+      // 立即执行查询
+      this.handleQuery();
+    },
+    xdChange() {
+      if (this.createTime != null) {
+        this.queryParams.sTime = this.createTime[0];
+        this.queryParams.eTime = this.createTime[1];
+      } else {
+        this.queryParams.sTime = null;
+        this.queryParams.eTime = null;
+      }
+    },
+    handleExport() {
+      const queryParams = this.queryParams;
+      this.$confirm('是否确认导出完课统计报表', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        this.exportLoading = true;
+        return exportCourseReport(queryParams);
+      }).then(response => {
+        this.download(response.msg);
+        this.exportLoading = false;
+      }).catch(() => {
+      });
+    },
+    endChange() {
+      if (this.endTime != null) {
+        this.queryParams.endStartTime = this.endTime[0];
+        this.queryParams.endEndTime = this.endTime[1];
+      } else {
+        this.queryParams.endStartTime = null;
+        this.queryParams.endEndTime = null;
+      }
+    }
+  }
+};
+</script>
+
+<style scoped>
+.total-summary {
+  margin-top: 15px;
+  padding: 15px 20px;
+  background: linear-gradient(135deg, #f5f7fa 0%, #e4e7f4 100%);
+  border: 1px solid #dcdfe6;
+  border-radius: 4px;
+  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
+  display: flex;
+  flex-wrap: wrap;
+  align-items: center;
+}
+
+.total-title {
+  font-weight: bold;
+  font-size: 16px;
+  color: #303133;
+  margin-right: 20px;
+  flex-shrink: 0;
+}
+
+.total-item {
+  margin-right: 25px;
+  padding: 5px 10px;
+  background: white;
+  border-radius: 3px;
+  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
+  display: inline-block;
+  margin-bottom: 5px;
+  font-size: 13px;
+  color: #606266;
+}
+
+.total-item::before {
+  content: "";
+  display: inline-block;
+  width: 3px;
+  height: 3px;
+  background: #409eff;
+  border-radius: 50%;
+  margin-right: 5px;
+  vertical-align: middle;
+}
+
+/* 响应式处理 */
+@media (max-width: 768px) {
+  .total-summary {
+    flex-direction: column;
+    align-items: flex-start;
+  }
+
+  .total-title {
+    margin-bottom: 10px;
+  }
+
+  .total-item {
+    margin-right: 10px;
+    margin-bottom: 8px;
+  }
+}
+</style>