|
|
@@ -90,7 +90,7 @@
|
|
|
:model-value="scope.row.enableNotifications"
|
|
|
:active-value="1"
|
|
|
:inactive-value="0"
|
|
|
- @update:modelValue="(val) => handleNotificationsChange(scope.row,val)"
|
|
|
+ @update:modelValue="(val) => handleNotificationsChange(scope.row, val)"
|
|
|
/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
@@ -120,7 +120,7 @@
|
|
|
link
|
|
|
:icon="Bell"
|
|
|
type="primary"
|
|
|
- @click="openForm('NotificationRules', row.id,row.sopName,row.workstationId)"
|
|
|
+ @click="openForm('NotificationRules', row.id, row.sopName, row.workstationId)"
|
|
|
v-hasPermi="['iscs:sop:update']"
|
|
|
>
|
|
|
通知规则
|
|
|
@@ -129,7 +129,7 @@
|
|
|
link
|
|
|
:icon="DocumentChecked"
|
|
|
type="primary"
|
|
|
- @click="openForm('executPlan', row.id,row.sopName)"
|
|
|
+ @click="openForm('executPlan', row.id, row.sopName)"
|
|
|
v-hasPermi="['iscs:sop:update']"
|
|
|
>
|
|
|
执行计划
|
|
|
@@ -173,47 +173,87 @@
|
|
|
@pagination="getList"
|
|
|
/>
|
|
|
</ContentWrap>
|
|
|
+ <!-- 弹框-->
|
|
|
<!-- Notifications 通知规则弹框-->
|
|
|
- <el-dialog v-model="notificationsDialogVisible" title="通知规则" width="500" center>
|
|
|
- <span v-if="notificationsTempVal == 1">
|
|
|
- 请首先设置一个 SOP执行计划,才能启用,点击确定前往设置
|
|
|
- </span>
|
|
|
- <span v-else>
|
|
|
- 您确定要禁用通知吗?
|
|
|
- </span>
|
|
|
+ <el-dialog
|
|
|
+ v-model="notificationsDialogVisible"
|
|
|
+ title="通知规则"
|
|
|
+ width="500"
|
|
|
+ >
|
|
|
+ <!-- 没有设置通知规则且开关是关闭状态-->
|
|
|
+ <span v-if="notificationsTempVal == 1 && row.enableNotifications !== 1">
|
|
|
+ 请首先设置通知规则后,才能启用,点击确定前往设置。
|
|
|
+ </span>
|
|
|
+ <!-- 设置了通知规则开关是关闭状态 -->
|
|
|
+ <span v-if="notificationsTempVal == 0 && row.enableNotifications !== 1">
|
|
|
+ 您确定要启用通知吗?
|
|
|
+ </span>
|
|
|
+ <!-- 设置了通知规则开关是开启状态 -->
|
|
|
+ <span v-if="notificationsTempVal == 0 && row.enableNotifications == 1">
|
|
|
+ 您确定要禁用通知吗?
|
|
|
+ </span>
|
|
|
<template #footer>
|
|
|
<div class="dialog-footer">
|
|
|
- <el-button @click="handleDialogConfirm">确定</el-button>
|
|
|
- <el-button type="primary" @click="notificationsDialogVisible = false">
|
|
|
- 取消
|
|
|
- </el-button>
|
|
|
+ <el-button type="primary" @click="handleDialogConfirm()">确定</el-button>
|
|
|
+ <el-button @click="notificationsDialogVisible = false"> 取消</el-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
|
|
|
<!-- enableExecutionPlan 执行计划弹框-->
|
|
|
- <el-dialog v-model="ExecutionPlanDialogVisible" title="Warning" width="500" center>
|
|
|
- <span>
|
|
|
- It should be noted that the content will not be aligned in center by
|
|
|
- default
|
|
|
+ <el-dialog
|
|
|
+ v-model="ExecutionPlanDialogVisible"
|
|
|
+ title="执行计划"
|
|
|
+ width="500"
|
|
|
+ >
|
|
|
+ <!-- 没有创建过执行计划并且开关是关闭状态-->
|
|
|
+ <span v-if="executePlanNum == false && row.enableExecutionPlan !== 1">
|
|
|
+ 请首先设置一个 SOP执行计划,才能启用,点击确定前往设置
|
|
|
</span>
|
|
|
+ <!-- 创建过执行计划并且开关是关闭状态-->
|
|
|
+ <div v-if="executePlanNum == true && row.enableExecutionPlan == 1">
|
|
|
+ <p style="margin-left: 9px">您确定要禁用执行计划吗?</p>
|
|
|
+ <!-- 且存在未完成的作业记录,-->
|
|
|
+ <section v-if="unFinishedJob == true" style="margin: 10px">
|
|
|
+ <p>如果需要同时取消尚未执行的作业,请勾选"取消作业"后,再点击确定。</p>
|
|
|
+ <el-checkbox
|
|
|
+ v-model="isDeleteJob"
|
|
|
+ label="取消作业"
|
|
|
+ :true-value="1"
|
|
|
+ :false-value="0"
|
|
|
+ style="margin: 8px 0"
|
|
|
+ />
|
|
|
+ </section>
|
|
|
+ </div>
|
|
|
+ <!-- 创建过执行计划,并且开关是关闭状态-->
|
|
|
+ <span v-if="executePlanNum==true && row.enableExecutionPlan !== 1">
|
|
|
+ 您确定要开启执行计划吗?
|
|
|
+ </span>
|
|
|
<template #footer>
|
|
|
<div class="dialog-footer">
|
|
|
-<!-- <el-button @click="handleDialogConfirme()">Cancel</el-button>-->
|
|
|
- <el-button type="primary" @click="ExecutionPlanDialogVisible = false">
|
|
|
- Confirm
|
|
|
- </el-button>
|
|
|
+ <el-button type="primary" @click="handleExecuteDialogConfirme()"> 确定</el-button>
|
|
|
+ <el-button @click="ExecutionPlanDialogVisible = false">取消</el-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
-
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
import * as SopApi from '@/api/sop'
|
|
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
|
|
-import {Promotion, DocumentChecked,Delete, Edit, Bell,RefreshLeft } from '@element-plus/icons-vue'
|
|
|
-import {updateSopEnableExecutionPlan, updateSopEnableNotification} from "@/api/sop";
|
|
|
+import * as NotificationRules from '@/api/sop/notificationRules'
|
|
|
+import {
|
|
|
+ Promotion,
|
|
|
+ DocumentChecked,
|
|
|
+ Delete,
|
|
|
+ Edit,
|
|
|
+ Bell,
|
|
|
+ RefreshLeft
|
|
|
+} from '@element-plus/icons-vue'
|
|
|
+import { updateSopEnableExecutionPlan, updateSopEnableNotification } from '@/api/sop'
|
|
|
+import { getNotifyConfigPage, selectNotifyConfigById } from '@/api/sop/notificationRules'
|
|
|
+import * as ExecutePlan from '@/api/sop/executePlan'
|
|
|
+import { getNotStartJobBySopId } from '@/api/sop/executePlan'
|
|
|
// 添加初始化标志位
|
|
|
const isInitialized = ref(false)
|
|
|
const router = useRouter()
|
|
|
@@ -234,37 +274,60 @@ const queryParams = reactive({
|
|
|
sopType: undefined
|
|
|
})
|
|
|
const queryFormRef = ref() // 搜索的表单
|
|
|
-const notificationsDialogVisible=ref(false) // 通知规则弹框
|
|
|
-const ExecutionPlanDialogVisible=ref(false) //执行计划弹框
|
|
|
+const notificationsDialogVisible = ref(false) // 通知规则弹框
|
|
|
+const ExecutionPlanDialogVisible = ref(false) //执行计划弹框
|
|
|
const row = ref({}) // 当前操作的行数据
|
|
|
const notificationsTempVal = ref(0) // 临时保存用户点击后的值
|
|
|
+const detailData = ref([])
|
|
|
+const executePlanNum = ref(false) //有没有执行计划
|
|
|
+const unFinishedJob = ref(false) //是否有未执行的作业记录
|
|
|
+const isDeleteJob = ref(0)
|
|
|
|
|
|
// 是否开启通知
|
|
|
const handleNotificationsChange = async (r, val) => {
|
|
|
- if (!isMounted.value) {
|
|
|
- // 页面初始化时触发的 change,忽略
|
|
|
- return
|
|
|
- }
|
|
|
+ if (!isMounted.value) return // 页面初始化时触发的 change,忽略
|
|
|
row.value = r
|
|
|
- notificationsTempVal.value = val
|
|
|
+ const detailQuery = { sopId: row.value.id }
|
|
|
+ detailData.value = await NotificationRules.getNotifyConfigPage(detailQuery)
|
|
|
notificationsDialogVisible.value = true
|
|
|
-
|
|
|
+ if (detailData.value.list.length == 0) {
|
|
|
+ notificationsTempVal.value = 1 //没有创建过通知
|
|
|
+ } else {
|
|
|
+ notificationsTempVal.value = 0
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+// 通知规则弹框确认按钮
|
|
|
const handleDialogConfirm = async () => {
|
|
|
- if (notificationsTempVal.value == 1) {
|
|
|
+ // console.log(row.value,'那搭配;')
|
|
|
+ if (notificationsTempVal.value == 1 && row.value.enableNotifications !== 1) {
|
|
|
// 启用通知 -> 跳转去设置页面
|
|
|
notificationsDialogVisible.value = false
|
|
|
router.push({
|
|
|
- name:'NotificationRules',
|
|
|
- query:{
|
|
|
- id:row.value.id,
|
|
|
+ name: 'NotificationRules',
|
|
|
+ query: {
|
|
|
+ id: row.value.id,
|
|
|
sopName: row.value.sopName,
|
|
|
- workstationId:row.value.workstationId,
|
|
|
+ workstationId: row.value.workstationId,
|
|
|
type: 'notificationRules'
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
- } else {
|
|
|
+ } else if (notificationsTempVal.value == 0 && row.value.enableNotifications !== 1) {
|
|
|
+ // 启用通知 -> 调接口更新
|
|
|
+ try {
|
|
|
+ await SopApi.updateSopEnableNotification({
|
|
|
+ id: row.value.id,
|
|
|
+ enableNotifications: 1
|
|
|
+ })
|
|
|
+ ElMessage.success('通知已启用')
|
|
|
+ row.value.enableNotifications = 1 // 更新本地数据
|
|
|
+ getList()
|
|
|
+ } catch (err) {
|
|
|
+ ElMessage.error('启用失败')
|
|
|
+ } finally {
|
|
|
+ notificationsDialogVisible.value = false
|
|
|
+ }
|
|
|
+ } else if (notificationsTempVal.value == 0 && row.value.enableNotifications == 1) {
|
|
|
// 禁用通知 -> 调接口更新
|
|
|
try {
|
|
|
await SopApi.updateSopEnableNotification({
|
|
|
@@ -273,6 +336,7 @@ const handleDialogConfirm = async () => {
|
|
|
})
|
|
|
ElMessage.success('通知已禁用')
|
|
|
row.value.enableNotifications = 0 // 更新本地数据
|
|
|
+ getList()
|
|
|
} catch (err) {
|
|
|
ElMessage.error('禁用失败')
|
|
|
} finally {
|
|
|
@@ -281,34 +345,89 @@ const handleDialogConfirm = async () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 是否打开执行计划
|
|
|
-const handleExecutionPlanChange = async (row, val) => {
|
|
|
- if (!isInitialized.value) return
|
|
|
+const handleExecutionPlanChange = async (r, val) => {
|
|
|
+ if (!isMounted.value) return // 页面初始化时触发的 change,忽略
|
|
|
|
|
|
- const originalValue = row.enableExecutionPlan
|
|
|
+ row.value = r
|
|
|
+ ExecutionPlanDialogVisible.value = true
|
|
|
+ // 判断有没有创建执行记录
|
|
|
+ const excuteList = await ExecutePlan.selectSopExecutionPlanBySopId(row.value.id)
|
|
|
+ console.log(excuteList, '属是素数')
|
|
|
+ if (excuteList == null) {
|
|
|
+ // sop没有计划时赋值为0
|
|
|
+ executePlanNum.value = false
|
|
|
+ } else {
|
|
|
+ executePlanNum.value = true
|
|
|
+ }
|
|
|
+ // 判断有没有未执行的作业记录
|
|
|
+ const isNotFinishJob = await ExecutePlan.getNotStartJobBySopId(row.value.id)
|
|
|
+ console.log(isNotFinishJob, '是否有未执行的作业记录')
|
|
|
+ // 没有创建记录
|
|
|
+ unFinishedJob.value = isNotFinishJob.length > 0
|
|
|
+}
|
|
|
|
|
|
- try {
|
|
|
- const data = {
|
|
|
- id:row.id,
|
|
|
- enableExecutionPlan: val
|
|
|
- }
|
|
|
+// 执行计划弹框确认按钮
|
|
|
+const handleExecuteDialogConfirme = async () => {
|
|
|
+ const hasPlan = executePlanNum.value === true
|
|
|
+ const isEnabled = row.value.enableExecutionPlan == 1
|
|
|
|
|
|
- await SopApi.updateSopEnableExecutionPlan(data)
|
|
|
- ElMessage.success(val == 1 ? '已开启' : '已关闭')
|
|
|
+ console.log(isDeleteJob.value, '值拿到的正确吗')
|
|
|
|
|
|
- // 成功后更新值(防止 UI 不更新)
|
|
|
- row.enableExecutionPlan = val
|
|
|
- } catch (err) {
|
|
|
- // 接口失败,回滚原始值
|
|
|
- row.enableExecutionPlan = originalValue
|
|
|
+ // 没有计划且是关闭状态 ➜ 跳转
|
|
|
+ if (!hasPlan && !isEnabled) {
|
|
|
+ ExecutionPlanDialogVisible.value = false
|
|
|
+ router.push({
|
|
|
+ name: 'ExecutePlan',
|
|
|
+ query: {
|
|
|
+ id: row.value.id,
|
|
|
+ sopName: row.value.sopName,
|
|
|
+ type: 'executPlan'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- // 强制刷新 UI
|
|
|
- await nextTick()
|
|
|
+ // 有计划并处于开启状态 ➜ 禁用计划
|
|
|
+ if (hasPlan && isEnabled) {
|
|
|
+ try {
|
|
|
+ await SopApi.updateSopEnableExecutionPlan({
|
|
|
+ id: row.value.id,
|
|
|
+ enableExecutionPlan: 0,
|
|
|
+ deleteNotStartJob: isDeleteJob.value
|
|
|
+ })
|
|
|
+ ElMessage.success('计划已禁用')
|
|
|
+ row.value.enableExecutionPlan = 0
|
|
|
+ getList()
|
|
|
+ } catch (err) {
|
|
|
+ ElMessage.error('禁用失败')
|
|
|
+ } finally {
|
|
|
+ ExecutionPlanDialogVisible.value = false
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- // 提示错误
|
|
|
- // ElMessage.error('状态更新失败,请重试')
|
|
|
+ // 有计划但处于关闭状态 ➜ 开启计划
|
|
|
+ if (hasPlan && !isEnabled) {
|
|
|
+ try {
|
|
|
+ await SopApi.updateSopEnableExecutionPlan({
|
|
|
+ id: row.value.id,
|
|
|
+ enableExecutionPlan: 1,
|
|
|
+ })
|
|
|
+ ElMessage.success('计划已开启')
|
|
|
+ row.value.enableExecutionPlan = 1
|
|
|
+ getList()
|
|
|
+ } catch (err) {
|
|
|
+ ElMessage.error('开启失败')
|
|
|
+ } finally {
|
|
|
+ ExecutionPlanDialogVisible.value = false
|
|
|
+ }
|
|
|
+ return
|
|
|
}
|
|
|
+
|
|
|
+ // 其它异常状态
|
|
|
+ ElMessage.warning('当前状态异常,请刷新重试')
|
|
|
+ ExecutionPlanDialogVisible.value = false
|
|
|
}
|
|
|
|
|
|
/** 多选框选中数据 */
|
|
|
@@ -343,7 +462,7 @@ const resetQuery = () => {
|
|
|
}
|
|
|
|
|
|
/** 添加/修改/查看操作 */
|
|
|
-const openForm = (type: string, id?: number,sopName?:string,workstationId?:number) => {
|
|
|
+const openForm = (type: string, id?: number, sopName?: string, workstationId?: number) => {
|
|
|
if (type == 'create') {
|
|
|
router.push({
|
|
|
name: 'CreateSop',
|
|
|
@@ -364,14 +483,14 @@ const openForm = (type: string, id?: number,sopName?:string,workstationId?:numbe
|
|
|
type: 'executPlan'
|
|
|
}
|
|
|
})
|
|
|
- } else if(type == 'NotificationRules') {
|
|
|
- // 通知规则
|
|
|
+ } else if (type == 'NotificationRules') {
|
|
|
+ // 通知规则
|
|
|
router.push({
|
|
|
- name:'NotificationRules',
|
|
|
- query:{
|
|
|
- id:id,
|
|
|
+ name: 'NotificationRules',
|
|
|
+ query: {
|
|
|
+ id: id,
|
|
|
sopName: sopName,
|
|
|
- workstationId:workstationId,
|
|
|
+ workstationId: workstationId,
|
|
|
type: 'notificationRules'
|
|
|
}
|
|
|
})
|
|
|
@@ -402,4 +521,6 @@ onMounted(async () => {
|
|
|
isMounted.value = true
|
|
|
})
|
|
|
</script>
|
|
|
-<style scoped></style>
|
|
|
+<style scoped>
|
|
|
+
|
|
|
+</style>
|