Browse Source

作业执行计划剩余内容接口对接

wyn 3 months ago
parent
commit
bbb44c99a7

+ 0 - 0
src/api/sop/executePlan.ts


+ 12 - 0
src/views/sopm/sop/CreateSop.vue

@@ -348,6 +348,7 @@ const groupList = ref([])//获取当前sopId的分组
 const allPoints = ref<any[]>([])//获取所有点位
 const nodes = ref([]) //储存节点
 const edges = ref([]) // 存储连接线
+const SopInsertVisible=ref(false)
 // 创建查找映射
 const workstationMap = new Map()
 const machineryMap = new Map()
@@ -665,6 +666,12 @@ const submit = async () => {
     } else {
       // 新增操作
       data = await SopApi.insertSop(SopForm)
+      console.log(data,SopInsertVisible.value,'我在这里打印')
+      if(SopInsertVisible.value){
+        return
+      }else{
+        SopInsertVisible.value=false
+      }
       // 新增之后直接给sopStep新增改出局
       const dataNew = await ModeStepApi.getWorkflowStepPage({
         pageNo: 1,
@@ -681,6 +688,7 @@ const submit = async () => {
       successMessage = t('common.createSuccess')
 
       if (data) {
+        console.log(data,'我走了这里')
         Visible.value=true //显示下面的内容
         // 新增成功后,获取完整数据
         try {
@@ -712,6 +720,10 @@ const submit = async () => {
   } catch (error) {
     console.error('保存失败:', error)
     message.error('保存失败')
+    if(error.code==902){
+      // 新增
+      SopInsertVisible.value = true
+    }
   }
 }
 

+ 282 - 159
src/views/sopm/sop/ExecutePlan.vue

@@ -1,14 +1,14 @@
 <template>
   <ContentWrap>
-<!--    顶部标题-->
-      <div class="topTitle">
-        <span class="tab-title">执行计划:CCO-BH-哈哈哈-嘿嘿黑</span>
-        <div class="set-btn" @click="goBack">
-          <img src="../../../assets/images/返回.png" alt=""/>
-          返回
-        </div>
+    <!--    顶部标题-->
+    <div class="topTitle">
+      <span class="tab-title">执行计划:{{route.query.sopName}}</span>
+      <div class="set-btn" @click="goBack">
+        <img src="../../../assets/images/返回.png" alt="" />
+        返回
       </div>
-<!--    规则设置-->
+    </div>
+    <!--    规则设置-->
     <div class="custom-tabs-container">
       <div class="tab-header">
         <span class="tab-title">规则设置</span>
@@ -18,234 +18,350 @@
       <section>
         <span>启用执行计划:</span>
         <el-switch
-        v-model="value"
-        size="small"
-      /></section>
+          v-model="sopExcuteData.status"
+          size="small"
+          :active-value="0"
+          :inactive-value="1"
+        />
+      </section>
       <section>
         <span>执行频率单位:</span>
-        <el-radio-group v-model="radio">
-          <el-radio label="day">天</el-radio>
-          <el-radio label="week">周</el-radio>
-          <el-radio label="month">月</el-radio>
-          <el-radio label="year">年</el-radio>
+        <el-radio-group v-model="sopExcuteData.frequencyUnit">
+          <el-radio label="day" :value="3">天</el-radio>
+          <el-radio label="week" :value="2">周</el-radio>
+          <el-radio label="month" :value="1">月</el-radio>
+          <el-radio label="year" :value="0">年</el-radio>
         </el-radio-group>
       </section>
 
       <!-- 天 -->
-      <section v-if="radio === 'day'">
+      <section v-if="sopExcuteData.frequencyUnit == 3">
         <span> 执行频率:</span>每
         <el-input-number
-          v-model="dayNum"
+          v-model="sopExcuteData.frequency"
           :min="1"
-          :max="10"
+          :max="3650"
           class="mx-4"
           controls-position="right"
-          @change="handleChange"
-        /> 
+        />
+        天
       </section>
 
       <!-- 周 -->
-      <section v-else-if="radio === 'week'">
+      <section v-else-if="sopExcuteData.frequencyUnit == 2">
         <span>执行频率:</span> 每
         <el-input-number
-          v-model="weekNum"
+          v-model="sopExcuteData.frequency"
           :min="1"
-          :max="10"
+          :max="520"
           class="mx-4"
           controls-position="right"
-          @change="handleChange"
-        /> 周 &nbsp;&nbsp;&nbsp;&nbsp; 在
-        <el-select v-model="weekDay" placeholder="选择星期" style="width: 115px">
-          <el-option label="星期一" value="1" />
-          <el-option label="星期二" value="2" />
-          <el-option label="星期三" value="3" />
-          <el-option label="星期四" value="4" />
-          <el-option label="星期五" value="5" />
-          <el-option label="星期六" value="6" />
-          <el-option label="星期日" value="7" />
+        />
+        周 &nbsp;&nbsp;&nbsp;&nbsp; 在 &nbsp;&nbsp;
+        <el-select v-model="sopExcuteData.timePoint" placeholder="选择星期" style="width: 115px">
+          <el-option label="星期一" value="星期一" />
+          <el-option label="星期二" value="星期二" />
+          <el-option label="星期三" value="星期三" />
+          <el-option label="星期四" value="星期四" />
+          <el-option label="星期五" value="星期五" />
+          <el-option label="星期六" value="星期六" />
+          <el-option label="星期日" value="星期日" />
         </el-select>
       </section>
 
       <!-- 月 -->
-      <section v-else-if="radio === 'month'">
+      <section v-else-if="sopExcuteData.frequencyUnit == 1">
         <span>执行频率:</span> 每
         <el-input-number
-          v-model="monthNum"
+          v-model="sopExcuteData.frequency"
           :min="1"
-          :max="10"
+          :max="120"
           class="mx-4"
           controls-position="right"
-          @change="handleChange"
-        /> 月 第
+        />
+        月 第
         <el-input-number
-          v-model="monthDay"
+          v-model="sopExcuteData.timePoint"
           :min="1"
-          :max="31"
+          :max="3650"
           class="mx-4"
           controls-position="right"
-          @change="handleChange"
-        /> 日
+          @change="handleTimePointChange"
+        />
+        日
       </section>
 
       <!-- 年 -->
-      <section v-else-if="radio === 'year'">
+      <section v-else-if="sopExcuteData.frequencyUnit == 0">
         <span>执行频率:</span> 每
         <el-input-number
-          v-model="yearNum"
+          v-model="sopExcuteData.frequency"
           :min="1"
           :max="10"
           class="mx-4"
           controls-position="right"
-          @change="handleChange"
-        /> 年 第
+        />
+        年 第
         <el-input-number
-          v-model="yearDay"
+          v-model="sopExcuteData.timePoint"
           :min="1"
-          :max="365"
+          :max="3650"
           class="mx-4"
           controls-position="right"
-          @change="handleChange"
-        /> 天
+          @change="handleTimePointChange"
+        />
+        天
+      </section>
+      <section
+        ><span>作业开始时间:</span>
+        <el-time-picker
+          v-model="sopExcuteData.startTime"
+          placeholder="请选择"
+          :picker-options="{
+            selectableRange: '00:00:00 - 23:59:59'
+          }"
+          format="HH:mm:ss"
+          value-format="HH:mm:ss"
+        />
+      </section>
+      <section>
+        <span>作业预估时长:</span>
+        <el-time-picker
+          v-model="sopExcuteData.duration"
+          placeholder="请选择"
+          :picker-options="{
+            selectableRange: '00:00:00 - 23:59:59'
+          }"
+          format="HH:mm:ss"
+          value-format="HH:mm:ss"
+        />
       </section>
-      <section> <span>作业开始时间:</span> <el-time-picker v-model="startTime" placeholder="请选择" /></section>
-      <section> <span>作业预估时长:</span> <el-time-picker v-model="estimatedDuration" placeholder="请选择" /></section>
       <section>
         <span> 计划终止:</span>
-        <el-select v-model="select" placeholder="Select" style="width: 115px">
-          <el-option label="Restaurant" value="1" />
-          <el-option label="Order No." value="2" />
-          <el-option label="Tel" value="3" />
+        <el-select v-model="sopExcuteData.endType" placeholder="" style="width: 115px">
+          <el-option
+            v-for="dict in getStrDictOptions(DICT_TYPE.SOP_PLAN_TERMINATE_TYPE)"
+            :key="dict.value"
+            :label="dict.label"
+            :value="dict.value"
+          />
         </el-select>
         <el-date-picker
-          v-model="endTime"
-          type="datetime"
+          style="margin-left: 15px"
+          v-if="sopExcuteData.endType == 0 && sopExcuteData.endType !== '' "
+          v-model="sopExcuteData.endValue"
+          type="date"
+          format="YYYY-MM-DD"
+          value-format="YYYY-MM-DD"
           placeholder="请选择"
         />
-        <el-input-number
-          v-model="num"
-          :min="1"
-          :max="10"
-          class="mx-4"
-          controls-position="right"
-          @change="handleChange"
-        />次后
+<!--        <el-date-picker-->
+<!--          style="margin-left: 15px"-->
+<!--          v-if="sopExcuteData.endType == 0"-->
+<!--          v-model="sopExcuteData.endValue"-->
+<!--          type="datetime"-->
+<!--          format="YYYY-MM-DD HH:mm:ss"-->
+<!--          value-format="YYYY-MM-DD HH:mm:ss"-->
+<!--          placeholder="请选择"-->
+<!--        />-->
+        <div v-if="sopExcuteData.endType == 2">
+          <el-input-number
+            v-model="sopExcuteData.endValue"
+            :min="1"
+            :max="10"
+            class="mx-4"
+            controls-position="right"
+          />
+          次后
+        </div>
       </section>
       <section>
         <span>非工作日:</span>
-        <el-select v-model="select" placeholder="Select" style="width: 115px">
-          <el-option label="Restaurant" value="1" />
-          <el-option label="Order No." value="2" />
-          <el-option label="Tel" value="3" />
+        <el-select v-model="sopExcuteData.nonWorkDay" placeholder="" style="width: 115px">
+          <el-option
+            v-for="dict in getIntDictOptions(DICT_TYPE.SOP_PLAN_NOWORKING)"
+            :key="dict.value"
+            :label="dict.label"
+            :value="dict.value"
+          />
         </el-select>
-        <el-input-number
-          v-model="num"
-          :min="1"
-          :max="10"
-          class="mx-4"
-          controls-position="right"
-          @change="handleChange"
-        />工作日
-      </section>
-
-      <section class="btnstyle">
-        <el-button plain>修改</el-button>
-        <el-button type="primary" plain>新建</el-button>
-        <el-button plain>取消</el-button>
+        <div v-if="sopExcuteData.nonWorkDay == 2 || sopExcuteData.nonWorkDay == 3">
+          <el-input-number
+            v-model="sopExcuteData.nonWorkMoveDay"
+            :min="1"
+            :max="10"
+            class="mx-4"
+            controls-position="right"
+          />
+          工作日
+        </div>
       </section>
+      <div class="btnstyle">
+        <el-button plain v-if="ExcuteplanVisible == false" @click="submit">修改</el-button>
+        <el-button type="primary" plain @click="submit" v-if="ExcuteplanVisible == true"
+          >新建</el-button
+        >
+        <el-button plain @click="goBack">取消</el-button>
+      </div>
     </div>
   </ContentWrap>
-<!--  预览计划-->
-  <ContentWrap>
-
-      <div class="tab-header">
-        <span class="tab-title">执行计划预览</span>
-      </div>
-<!--    表格数据-->
+  <!--  预览计划-->
+  <ContentWrap  v-if="tableData.length > 0">
+    <div class="tab-header">
+      <span class="tab-title">执行计划预览</span>
+    </div>
+    <!--    表格数据-->
     <div class="tableCon">
       <el-table :data="tableData" border style="width: 100%">
-        <el-table-column prop="planDate" label="计划日期" width="180" />
-        <el-table-column prop="startTime" label="计划开始时间" width="180" />
-        <el-table-column prop="endTime" label="预计结束时间" />
+        <el-table-column prop="planDay" label="作业日期" width="180" />
+        <el-table-column prop="startTime" label="作业开始时间" width="180" />
+        <el-table-column prop="duration" label="作业预估时长" />
         <el-table-column prop="workstationName" label="所属区域" />
         <el-table-column prop="machineryName" label="设备/工艺" />
-        <el-table-column prop="type" label="作业类型" />
+        <el-table-column prop="sopTypeName" label="作业类型" />
       </el-table>
     </div>
   </ContentWrap>
 </template>
 
-
 <script setup lang="ts">
 import { ref } from 'vue'
+import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
+import * as ExecutePlan from '@/api/sop/executePlan'
+import * as SopApi from '@/api/sop'
+import { updateSopExecutionPlan } from '@/api/sop/executePlan'
+const { t } = useI18n() // 国际化
 
-const value = ref(true)
-const estimatedDuration = ref()
-const startTime = ref()
-const endTime = ref('')
-const router=useRouter()
-const route=useRoute()
-const radio = ref('month')
-// 各单位下的输入值
-const dayNum = ref(1)
-const weekNum = ref(1)
-const weekDay = ref('')
-const monthNum = ref(1)
-const monthDay = ref(1)
-const yearNum = ref(1)
-const yearDay = ref(1)
-const tableData = [
-  {
-    planDate: '2016-05-03',
-    startTime: '10:23',
-    endTime: '15:23',
-    workstationName: 'CCO-BH',
-    machineryName: '搅拌机-05',
-    type: '换产',
-  },
-  {
-    planDate: '2016-05-03',
-    startTime: '10:23',
-    endTime: '15:23',
-    workstationName: 'CCO-BH',
-    machineryName: '搅拌机-05',
-    type: '换产',
-  },
-  {
-    planDate: '2016-05-03',
-    startTime: '10:23',
-    endTime: '15:23',
-    workstationName: 'CCO-BH',
-    machineryName: '搅拌机-05',
-    type: '换产',
-  },
-  {
-    planDate: '2016-05-03',
-    startTime: '10:23',
-    endTime: '15:23',
-    workstationName: 'CCO-BH',
-    machineryName: '搅拌机-05',
-    type: '换产',
-  },
-]
+const router = useRouter()
+const route = useRoute()
+const message = useMessage() // 消息弹窗
+const tableData = ref([])
+const sopExcuteData = reactive({
+  sopId: route.query.id,
+  status: '',
+  frequencyUnit: '3',
+  frequency: '',
+  timePoint: null,
+  startTime: '',
+  duration: '',
+  endType: '',
+  endValue: '',
+  nonWorkDay: '',
+  nonWorkMoveDay: ''
+})
+const ExcuteplanVisible = ref(false) // 判断sop执行计划是新增还是修改
+// const isPrompt=ref(true)
 
-const goBack=()=>{
+onMounted(() => {
+  // getSopDetail()
+  getSopExcuteData()
+  console.log(route.query.sopName,'sop名称')
+})
+
+// 返回
+const goBack = () => {
   router.push('/sopm/sop')
-  }
-const handleChange = () => {
-  // 可根据需要处理值变更逻辑
-  console.log('改变了执行频率')
 }
 
-console.log(route.query.id,'是否拿到了id')
-</script>
+// 校验是否为闰年
+const isLeapYear = (year) => {
+  return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0
+}
+
+// 获取某年有效的最大天数
+const getValidDayOfYear = (year, dayOfYear) => {
+  const maxDay = isLeapYear(year) ? 366 : 365
+  return Math.min(dayOfYear, maxDay)
+}
+
+// 获取某年某月的最大天数
+const getValidDayOfMonth = (year, month, day) => {
+  const maxDate = new Date(year, month, 0).getDate()
+  return Math.min(day, maxDate)
+}
+
+// 自动修正时间点
+const handleTimePointChange = () => {
+  const { frequencyUnit, frequency, timePoint } = sopExcuteData
+  const now = new Date()
+
+  if (frequencyUnit === '0') {
+    // 年:从当前年开始 + frequency
+    const targetYear = now.getFullYear() + frequency
+    const validDay = getValidDayOfYear(targetYear, timePoint)
+    sopExcuteData.timePoint = validDay
+  }
+
+  if (frequencyUnit === '1') {
+    // 月:从当前月开始 + frequency
+    const baseMonth = now.getMonth() + 1
+    const targetMonth = ((baseMonth - 1 + frequency) % 12) + 1
+    const targetYear = now.getFullYear() + Math.floor((baseMonth - 1 + frequency) / 12)
+    const validDay = getValidDayOfMonth(targetYear, targetMonth, timePoint)
+    sopExcuteData.timePoint = validDay
+  }
+}
 
+// 创建按钮事件
+const submit = async () => {
+  try {
+    let data
+    let successMessage
+    // 新增执行计划
+    if (sopExcuteData.frequencyUnit == '3') {
+      sopExcuteData.timePoint = 0
+    }
+    if (ExcuteplanVisible.value == true) {
+      data = await ExecutePlan.insertSopExecutionPlan(sopExcuteData)
+      if(data){
+        await getSopExcuteData()
+        ExcuteplanVisible.value = false
+      }
+      successMessage = t('common.createSuccess')
+    } else {
+      data = await ExecutePlan.updateSopExecutionPlan(sopExcuteData)
+      if(data){
+        await getSopExcuteData()
+      }
+      successMessage = t('common.updateSuccess')
+      console.log(data, '修改是否成功')
+    }
+    if (data) {
+      message.success(successMessage)
+    }
+  } catch (error) {
+    console.error('保存失败:', error)
+    message.error('保存失败')
+  }
+}
 
+// 获取sop执行计划数据
+const getSopExcuteData = async () => {
+  try {
+    const excuteList = await ExecutePlan.selectSopExecutionPlanBySopId(route.query.id)
+    console.log(excuteList, '有社么数据')
+    if (excuteList) {
+      Object.assign(sopExcuteData, excuteList)
+      tableData.value = excuteList.previewDataList
+    }
+  } catch (error) {
+    console.error('获取失败:', error)
+    if(error.code==902){
+      // 新增
+      ExcuteplanVisible.value = true
+      // isPrompt.value = false //执行计划没有时不提示后端接口消息
+    }
+  }
+}
+console.log(route.query.id, '是否拿到了id')
+</script>
 
 <style scoped lang="scss">
-.topTitle{
+.topTitle {
   width: 100%;
   line-height: 40px;
 }
+
 .set-btn {
   width: 60px;
   height: 30px;
@@ -255,12 +371,14 @@ console.log(route.query.id,'是否拿到了id')
   line-height: 30px;
   float: right;
   cursor: pointer;
-  margin:10px 0;
-  img{
+  margin: 10px 0;
+
+  img {
     width: 14px;
     height: 14px;
   }
 }
+
 .custom-tabs-container {
   border: 1px solid #dcdfe6;
   border-radius: 4px;
@@ -279,6 +397,7 @@ console.log(route.query.id,'是否拿到了id')
   font-weight: 500;
   color: #303133;
 }
+
 //设置规则
 .tab-content {
   width: 100%;
@@ -286,17 +405,21 @@ console.log(route.query.id,'是否拿到了id')
   padding: 20px;
   //background-color: #c81818;
   border-radius: 0 0 4px 4px;
-  section{
+
+  section {
     width: 100%;
     height: 100%;
     margin: 15px 0;
-    span{
+    display: flex;
+
+    span {
       display: inline-block;
       width: 130px;
       //background: #000;
     }
   }
-  .btnstyle{
+
+  .btnstyle {
     text-align: right;
   }
 }

+ 103 - 63
src/views/sopm/sop/index.vue

@@ -58,7 +58,8 @@
           @click="handleDelete()"
           v-hasPermi="['iscs:sop:delete']"
         >
-          <Icon icon="ep:delete" class="mr-5px" /> 批量删除
+          <Icon icon="ep:delete" class="mr-5px" />
+          批量删除
         </el-button>
       </el-form-item>
     </el-form>
@@ -66,52 +67,64 @@
 
   <!-- 列表 -->
   <ContentWrap>
-    <el-table v-loading="loading" :data="sopList" @selection-change="handleSelectionChange" style="width: 100%">
-      <el-table-column type="selection" width="50" align="center" fixed/>
-      <el-table-column label="ID" prop="id"  align="center" width="60" fixed/>
-      <el-table-column label="sop名称" prop="sopName" width="300" fixed/>
-      <el-table-column label="sop类型" prop="sopTypeName" width="100"/>
-      <el-table-column label="所属区域" prop="workstationName" :show-overflow-tooltip="true" width="100"/>
-      <el-table-column label="设备/工艺" prop="machineryName"  align="center" width="200"/>
+    <el-table
+      v-loading="loading"
+      :data="sopList"
+      @selection-change="handleSelectionChange"
+      style="width: 100%"
+    >
+      <el-table-column type="selection" width="50" align="center" fixed />
+      <el-table-column label="ID" prop="id" align="center" width="60" fixed />
+      <el-table-column label="sop名称" prop="sopName" width="300" fixed />
+      <el-table-column label="sop类型" prop="sopTypeName" width="100" />
+      <el-table-column
+        label="所属区域"
+        prop="workstationName"
+        :show-overflow-tooltip="true"
+        width="100"
+      />
+      <el-table-column label="设备/工艺" prop="machineryName" align="center" width="200" />
       <el-table-column label="启用通知" align="center" width="100">
         <template #default="scope">
           <el-switch
-            :model-value="scope.row.sopStatus"
-            active-value="1"
-            inactive-value="0"
-            @update:modelValue="val => handleStatusChange(scope.row, val)"
+            :model-value="scope.row.enableNotifications"
+            :active-value="1"
+            :inactive-value="0"
+            @update:modelValue="(val) => handleNotificationsChange(scope.row, val)"
           />
         </template>
       </el-table-column>
       <el-table-column label="启用执行计划" align="center" width="120">
         <template #default="scope">
           <el-switch
-            :model-value="scope.row.sopStatus"
-            active-value="1"
-            inactive-value="0"
-            @update:modelValue="val => handleStatusChange(scope.row, val)"
+            :model-value="scope.row.enableExecutionPlan"
+            :active-value="1"
+            :inactive-value="0"
+            @update:modelValue="(val) => handleExecutionPlanChange(scope.row, val)"
+            @click="openForm('executPlan', scope.row.id,scope.row.sopName)"
           />
         </template>
       </el-table-column>
-      <el-table-column label="下次作业开始时间" prop="sopContent"  width="150"/>
-<!--      <el-table-column label="是否生效" align="center" width="120">-->
-<!--        <template #default="scope">-->
-<!--          <el-switch-->
-<!--            :model-value="scope.row.sopStatus"-->
-<!--            active-value="1"-->
-<!--            inactive-value="0"-->
-<!--            @update:modelValue="val => handleStatusChange(scope.row, val)"-->
-<!--          />-->
-<!--        </template>-->
-<!--      </el-table-column>-->
-<!--      <el-table-column label="sop内容" prop="sopContent"  />-->
-<!--      <el-table-column label="sop状态" prop="sopStatus"  align="center" />-->
-<!--      <el-table-column label="sop权重序号" prop="sopIndex" />-->
-<!--      <el-table-column label="备注" prop="remark"  align="center" />-->
-      <el-table-column label="操作" align="center" width="500" fixed="right">
+      <el-table-column label="下次作业开始时间" prop="nextExecutDate" width="150" />
+      <!--      <el-table-column label="是否生效" align="center" width="120">-->
+      <!--        <template #default="scope">-->
+      <!--          <el-switch-->
+      <!--            :model-value="scope.row.sopStatus"-->
+      <!--            active-value="1"-->
+      <!--            inactive-value="0"-->
+      <!--            @update:modelValue="val => handleStatusChange(scope.row, val)"-->
+      <!--          />-->
+      <!--        </template>-->
+      <!--      </el-table-column>-->
+      <!--      <el-table-column label="sop内容" prop="sopContent"  />-->
+      <!--      <el-table-column label="sop状态" prop="sopStatus"  align="center" />-->
+      <!--      <el-table-column label="sop权重序号" prop="sopIndex" />-->
+      <!--      <el-table-column label="备注" prop="remark"  align="center" />-->
+      <el-table-column label="操作" align="center" width="550" fixed="right">
         <template #default="{ row }">
           <el-button
             link
+            :icon="Promotion"
             type="danger"
             @click="openForm('update', row.id)"
             v-hasPermi="['iscs:sop:update']"
@@ -129,14 +142,16 @@
           </el-button>
           <el-button
             link
+            :icon="DocumentChecked"
             type="primary"
-            @click="openForm('executPlan', row.id)"
+            @click="openForm('executPlan', row.id,row.sopName)"
             v-hasPermi="['iscs:sop:update']"
           >
             执行计划
           </el-button>
           <el-button
             link
+            :icon="RefreshLeft"
             type="primary"
             @click="openForm('update', row.id)"
             v-hasPermi="['iscs:sop:update']"
@@ -177,17 +192,11 @@
 
 <script lang="ts" setup>
 import * as SopApi from '@/api/sop'
-import {DICT_TYPE, getIntDictOptions} from "@/utils/dict";
-import {
-  Check,
-  Delete,
-  Edit,
- Bell,
-  Search,
-  Star,
-} from '@element-plus/icons-vue'
+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";
 // 添加初始化标志位
-const isInitialized = ref(false);
+const isInitialized = ref(false)
 const router = useRouter()
 
 defineOptions({ name: 'SopManagement' })
@@ -204,30 +213,34 @@ const queryParams = reactive({
   pageNo: 1,
   pageSize: 10,
   sopName: undefined,
-  sopType: undefined,
+  sopType: undefined
 })
 const queryFormRef = ref() // 搜索的表单
-// 是否生效
-const handleStatusChange = async (row, val) => {
+
+// 是否开启通知
+const handleNotificationsChange = async (row, val) => {
   if (!isInitialized.value) return
 
-  const originalValue = row.sopStatus
+  const originalValue = row.enableNotifications
 
   try {
+    // const data = {
+    //   ...row,
+    //   enableNotifications: val
+    // }
     const data = {
-      ...row,
-      sopStatus: val
+      id: row.id,
+      enableNotifications: val
     }
-
-    await SopApi.updateSopStatus(data)
-    ElMessage.success(val == 1 ? '已生效' : '已取消生效')
+    console.log(data,'是什么数据')
+    await SopApi.updateSopEnableNotification(data)
+    ElMessage.success(val == 1 ? '已开启' : '已关闭')
 
     // 成功后更新值(防止 UI 不更新)
-    row.sopStatus = val
-
+    row.enableNotifications = val
   } catch (err) {
     // 接口失败,回滚原始值
-    row.sopStatus = originalValue
+    row.enableNotifications = originalValue
 
     // 强制刷新 UI
     await nextTick()
@@ -236,17 +249,42 @@ const handleStatusChange = async (row, val) => {
     // ElMessage.error('状态更新失败,请重试')
   }
 }
+// 是否打开执行计划
+const handleExecutionPlanChange = async (row, val) => {
+  if (!isInitialized.value) return
+
+  const originalValue = row.enableExecutionPlan
 
+  try {
+    const data = {
+     id:row.id,
+      enableExecutionPlan: val
+    }
 
+    await SopApi.updateSopEnableExecutionPlan(data)
+    ElMessage.success(val == 1 ? '已开启' : '已关闭')
+
+    // 成功后更新值(防止 UI 不更新)
+    row.enableExecutionPlan = val
+  } catch (err) {
+    // 接口失败,回滚原始值
+    row.enableExecutionPlan = originalValue
+
+    // 强制刷新 UI
+    await nextTick()
+
+    // 提示错误
+    // ElMessage.error('状态更新失败,请重试')
+  }
+}
 
 /** 多选框选中数据 */
 
 const handleSelectionChange = (selection: any[]) => {
-  ids.value = selection.map(item => item.id)
+  ids.value = selection.map((item) => item.id)
   multiple.value = !selection.length
 }
 
-
 /** 查询模式列表 */
 const getList = async () => {
   loading.value = true
@@ -273,7 +311,7 @@ const resetQuery = () => {
 }
 
 /** 添加/修改/查看操作 */
-const openForm = (type: string, id?: number) => {
+const openForm = (type: string, id?: number,sopName?:string) => {
   if (type == 'create') {
     router.push({
       name: 'CreateSop',
@@ -284,11 +322,15 @@ const openForm = (type: string, id?: number) => {
       name: 'UpdateSop',
       query: { id: id, type: 'update' }
     })
-  }else if (type == 'executPlan') {
+  } else if (type == 'executPlan') {
     // 执行计划
     router.push({
       name: 'ExecutePlan',
-      query: { id: id, type: 'executPlan' }
+      query: {
+        id: id,
+        sopName: sopName,
+        type: 'executPlan'
+      }
     })
   }
 }
@@ -314,6 +356,4 @@ onMounted(async () => {
   isInitialized.value = true
 })
 </script>
-<style scoped>
-
-</style>
+<style scoped></style>