|
|
@@ -107,6 +107,12 @@
|
|
|
@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"
|
|
|
@@ -132,11 +138,64 @@
|
|
|
: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 } from '@/api/his/aiWorkflow'
|
|
|
+import { listWorkflow, delWorkflow, updateWorkflowStatus, copyWorkflow, exportWorkflow, getBindCompanyUserByWorkflowId, listCompanyUser, updateWorkflowBindCompanyUser } from '@/api/his/aiWorkflow'
|
|
|
|
|
|
export default {
|
|
|
name: 'AiWorkflow',
|
|
|
@@ -176,7 +235,33 @@ export default {
|
|
|
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() {
|
|
|
@@ -276,7 +361,139 @@ export default {
|
|
|
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>
|