Browse Source

feat:添加不同情况保存下的情况

AmandaG 9 months ago
parent
commit
4d106c1d63

+ 100 - 10
src/components/CreateAddRules/src/CreateAddRules.vue

@@ -44,6 +44,8 @@ const IsTwoActive = ref(true)
 const IsThreeActive = ref(true)
 const IsThreeActive = ref(true)
 const IsFourActive = ref(true)
 const IsFourActive = ref(true)
 const UnableSaveVisible = ref(false)
 const UnableSaveVisible = ref(false)
+const SaveVisibleError = ref(false)
+const SaveVisibleDetected = ref(false)
 const SaveedVisible = ref(false)
 const SaveedVisible = ref(false)
 const DelayedDeparturedList = ref()
 const DelayedDeparturedList = ref()
 const DelayedAirdList = ref()
 const DelayedAirdList = ref()
@@ -529,19 +531,48 @@ const missingmessage = ref('')
 const SaveSuceessful = () => {
 const SaveSuceessful = () => {
   $api
   $api
     .MonitoringSave({
     .MonitoringSave({
-      ...savesubscribeobj
+      ...savesubscribeobj,
+      is_similar_rule: false
     })
     })
     .then((res: any) => {
     .then((res: any) => {
       if (res.code === 200) {
       if (res.code === 200) {
-        SaveedVisible.value = true
-        setTimeout(() => {
-          SaveedVisible.value = false
-          sessionStorage.setItem('activeTab', 'Monitoring Settings')
-          router.push({
-            path: '/SystemSettings',
-            query: {}
-          })
-        }, 3000)
+        console.log(res.data)
+        if(res.data.msg == 'Update Successful') {
+          SaveedVisible.value = true
+          setTimeout(() => {
+            SaveedVisible.value = false
+            sessionStorage.setItem('activeTab', 'Monitoring Settings')
+            router.push({
+              path: '/SystemSettings',
+              query: {}
+            })
+          }, 3000)
+        } else if(res.data.msg == 'Similar Rule Detected') {
+          SaveVisibleDetected.value = true
+        } else if(res.data.msg == 'Unable to Save')
+        SaveVisibleError.value = true
+      }
+    })
+}
+
+const HandelSaveVisibleDetected = () => {
+  SaveVisibleDetected.value = false
+  $api
+    .MonitoringSave({
+      ...savesubscribeobj,
+      is_similar_rule: true
+    })
+    .then((res: any) => {
+      if (res.code === 200) {
+          SaveedVisible.value = true
+          setTimeout(() => {
+            SaveedVisible.value = false
+            sessionStorage.setItem('activeTab', 'Monitoring Settings')
+            router.push({
+              path: '/SystemSettings',
+              query: {}
+            })
+          }, 3000)
       }
       }
     })
     })
 }
 }
@@ -1123,6 +1154,65 @@ defineExpose({
     <div style="text-align: center"><el-image :src="submitsucessful" /></div>
     <div style="text-align: center"><el-image :src="submitsucessful" /></div>
     <div style="text-align: center; margin-top: 20px">Saved successfully</div>
     <div style="text-align: center; margin-top: 20px">Saved successfully</div>
   </el-dialog>
   </el-dialog>
+  <!-- 保存失败 -->
+  <el-dialog v-model="SaveVisibleError" width="480">
+      <div>Duplicate Rule Error.</div>
+      <div>This rule exactly matches an existing rule.</div>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button
+            class="el-button--danger"
+            @click="SaveVisibleError = false"
+            style="width: 100px"
+          >
+            OK
+          </el-button>
+        </div>
+      </template>
+      <template #header>
+        <div class="cancel_header">
+          <span class="iconfont_icon iconfont_warning">
+            <svg class="iconfont icon_danger" aria-hidden="true">
+              <use xlink:href="#icon-icon_fail_fill_b"></use>
+            </svg>
+          </span>
+          Unable to Save
+        </div>
+      </template>
+    </el-dialog>
+    <!-- 三项重合提示 -->
+  <el-dialog v-model="SaveVisibleDetected" width="480">
+      <div>A similar configuration rule already exists.</div>
+      <div>Would you like to proceed with creating this rule?</div>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button
+            class="el-button--default"
+            @click="SaveVisibleDetected = false"
+            style="width: 100px"
+          >
+            Cancel
+          </el-button>
+          <el-button
+            class="el-button--warning"
+            @click="HandelSaveVisibleDetected"
+            style="width: 100px"
+          >
+            Save
+          </el-button>
+        </div>
+      </template>
+      <template #header>
+        <div class="cancel_header">
+          <span class="iconfont_icon iconfont_warning">
+            <svg class="iconfont icon_warning" aria-hidden="true">
+              <use xlink:href="#icon-icon_tipsfilled_b"></use>
+            </svg>
+          </span>
+          Similar Rule Detected
+        </div>
+      </template>
+    </el-dialog>
 </template>
 </template>
 
 
 <style lang="scss" scoped>
 <style lang="scss" scoped>

+ 19 - 3
src/views/SystemSettings/src/components/MonitoringTable/src/MonitoringTable.vue

@@ -146,7 +146,18 @@ const deleteMoniTable = (row: any) => {
 }
 }
 
 
 // 编辑表格数据
 // 编辑表格数据
-const handleedit = (row: any) => {
+const handleedit = ({ row }: any) => {
+  sessionStorage.setItem('activeTab', 'Monitoring Settings')
+  sessionStorage.setItem('editTableid', row.id)
+  sessionStorage.setItem('editTablerules_type', row.rules_type)
+  sessionStorage.setItem('editTableoption', row.notifications_option)
+  router.push({
+    path: '/SystemSettings/createnewrule',
+    query: {}
+  })
+}
+
+const handleedittow = (row: any) => {
   sessionStorage.setItem('activeTab', 'Monitoring Settings')
   sessionStorage.setItem('activeTab', 'Monitoring Settings')
   sessionStorage.setItem('editTableid', row.id)
   sessionStorage.setItem('editTableid', row.id)
   sessionStorage.setItem('editTablerules_type', row.rules_type)
   sessionStorage.setItem('editTablerules_type', row.rules_type)
@@ -165,7 +176,12 @@ onMounted(() => {
 
 
 <template>
 <template>
   <div class="SettingTable">
   <div class="SettingTable">
-    <vxe-grid ref="tableRef" :style="{ border: 'none' }" v-bind="tableData">
+    <vxe-grid
+      ref="tableRef"
+      :style="{ border: 'none' }"
+      v-bind="tableData"
+      @cell-dblclick="handleedit"
+    >
       <!-- 空数据时的插槽 -->
       <!-- 空数据时的插槽 -->
       <template #empty v-if="tableData.data.length === 0">
       <template #empty v-if="tableData.data.length === 0">
         <TableEmpty EmptyTitle="Customize your shipment tracking preferences.">
         <TableEmpty EmptyTitle="Customize your shipment tracking preferences.">
@@ -175,7 +191,7 @@ onMounted(() => {
         </TableEmpty>
         </TableEmpty>
       </template>
       </template>
       <template #action="{ row }">
       <template #action="{ row }">
-        <el-button class="el-button--blue" style="height: 24px" @click="handleedit(row)">
+        <el-button class="el-button--blue" style="height: 24px" @click="handleedittow(row)">
           <span class="font_family icon-icon_edit_b"></span>
           <span class="font_family icon-icon_edit_b"></span>
         </el-button>
         </el-button>
         <el-popover trigger="click" :visible="row.visible" placement="left" :width="480">
         <el-popover trigger="click" :visible="row.visible" placement="left" :width="480">