| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499 |
- <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-user"
- @click="handleBindSales(scope.row)"
- >绑定销售</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"
- />
- <!-- 绑定销售弹窗 -->
- <el-dialog title="绑定销售" :visible.sync="bindSalesOpen" width="500px" append-to-body>
- <!-- 当前绑定的销售 -->
- <div class="current-sales">
- <div class="section-title">当前绑定销售</div>
- <div v-if="currentBindUserList && currentBindUserList.length > 0" class="bind-info">
- <el-tag
- v-for="(user, index) in currentBindUserList"
- :key="index"
- type="success"
- style="margin-right: 8px; margin-bottom: 8px;"
- >
- {{ user.userName || user.user_name }}({{ user.nickName || user.nick_name }})
- </el-tag>
- </div>
- <div v-else class="no-bind">
- <el-tag type="info">暂未绑定销售</el-tag>
- </div>
- </div>
- <!-- 可选销售列表 -->
- <div class="sales-list">
- <div class="section-title">选择销售</div>
- <el-input
- v-model="salesSearchKey"
- placeholder="搜索昵称"
- size="small"
- prefix-icon="el-icon-search"
- clearable
- style="margin-bottom: 10px"
- />
- <el-table
- :data="filteredCompanyUserList"
- v-loading="salesLoading"
- border
- height="300"
- :row-key="getSalesRowKey"
- :row-class-name="salesRowClassName"
- @selection-change="handleSalesSelectionChange"
- ref="salesTable"
- >
- <el-table-column type="selection" width="55" align="center" :selectable="checkSelectable" :reserve-selection="true" />
- <el-table-column label="用户名" align="center" prop="userName" />
- <el-table-column label="昵称" align="center" prop="nickName" />
- </el-table>
- </div>
- <div slot="footer" class="dialog-footer">
- <el-button @click="handleBindSalesCancel">取 消</el-button>
- <el-button type="primary" :disabled="selectedSalesList.length === 0" @click="confirmBindSales">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { listWorkflow, delWorkflow, updateWorkflowStatus, copyWorkflow, exportWorkflow, getBindCompanyUserByWorkflowId, listCompanyUser, updateWorkflowBindCompanyUser } 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
- },
- // 绑定销售弹窗
- bindSalesOpen: false,
- // 销售列表加载
- salesLoading: false,
- // 当前操作的工作流
- currentWorkflow: null,
- // 当前绑定的用户列表
- currentBindUserList: [],
- // 销售列表
- companyUserList: [],
- // 选中的销售列表
- selectedSalesList: [],
- // 销售搜索关键字
- salesSearchKey: ''
- }
- },
- computed: {
- // 过滤后的销售列表
- filteredCompanyUserList() {
- if (!this.salesSearchKey) {
- return this.companyUserList
- }
- const key = this.salesSearchKey.toLowerCase()
- return this.companyUserList.filter(item => {
- return (item.nickName && item.nickName.toLowerCase().includes(key))
- })
- }
- },
- 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(() => {})
- },
- /** 绑定销售按钮操作 */
- handleBindSales(row) {
- this.currentWorkflow = row
- this.currentBindUserList = []
- this.selectedSalesList = []
- this.salesSearchKey = ''
- this.bindSalesOpen = true
- this.salesLoading = true
- console.log(11111)
- // 获取当前绑定的销售列表
- getBindCompanyUserByWorkflowId(row.workflowId).then(res => {
- this.currentBindUserList = res.data.data || []
- }).catch(() => {})
- console.log(this.currentBindUserList)
- // 获取销售列表
- listCompanyUser().then(res => {
- this.companyUserList = res.data || res.rows || []
- this.salesLoading = false
- }).catch(() => {
- this.salesLoading = false
- })
- },
- /** 销售勾选变化 */
- handleSalesSelectionChange(selection) {
- this.selectedSalesList = selection
- },
- /** 获取销售行key */
- getSalesRowKey(row) {
- return row.userId || row.companyUserId || row.id
- },
- /** 取消绑定销售弹窗 */
- handleBindSalesCancel() {
- this.bindSalesOpen = false
- this.selectedSalesList = []
- this.$refs.salesTable && this.$refs.salesTable.clearSelection()
- },
- /** 销售行样式 */
- salesRowClassName({ row }) {
- if (this.isCurrentBindUser(row)) {
- return 'disabled-row'
- }
- return ''
- },
- /** 判断是否为当前绑定用户 */
- isCurrentBindUser(row) {
- if (!this.currentBindUserList || this.currentBindUserList.length === 0) {
- return false
- }
- const rowUserId = row.userId || row.companyUserId || row.user_id
- return this.currentBindUserList.some(user => {
- const bindUserId = user.userId || user.companyUserId || user.user_id
- return bindUserId == rowUserId
- })
- },
- /** 检查是否可选 */
- checkSelectable(row) {
- return !this.isCurrentBindUser(row)
- },
- /** 确认绑定销售 */
- confirmBindSales() {
- if (this.selectedSalesList.length === 0) {
- this.msgWarning('请选择要绑定的销售')
- return
- }
- const workflowId = this.currentWorkflow.workflowId
- const companyUserIds = this.selectedSalesList.map(item => item.userId || item.companyUserId)
-
- this.doBindSales(workflowId, companyUserIds)
- },
- /** 执行绑定销售 */
- doBindSales(workflowId, companyUserIds) {
- updateWorkflowBindCompanyUser({
- workflowId: workflowId,
- companyUserIds: companyUserIds
- }).then(() => {
- this.msgSuccess('绑定成功')
- this.bindSalesOpen = false
- this.getList()
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .current-sales {
- margin-bottom: 20px;
- padding-bottom: 15px;
- border-bottom: 1px solid #eee;
- .section-title {
- font-weight: 600;
- margin-bottom: 10px;
- color: #333;
- }
- .bind-info {
- .el-tag {
- font-size: 14px;
- padding: 8px 15px;
- height: auto;
- line-height: 1.5;
- white-space: normal;
- }
- }
- .no-bind {
- .el-tag {
- font-size: 14px;
- padding: 8px 15px;
- height: auto;
- }
- }
- }
- .sales-list {
- .section-title {
- font-weight: 600;
- margin-bottom: 10px;
- color: #333;
- }
- }
- </style>
- <style lang="scss">
- .el-table .disabled-row {
- background-color: #f5f5f5;
- color: #999;
-
- &:hover > td {
- background-color: #f5f5f5 !important;
- }
- }
- </style>
|