浏览代码

dialog-confirm组件封装

songxy 1 年之前
父节点
当前提交
531f80d7c0

+ 77 - 0
client/src/views/OaSystem/components/DialogConfirm/index.vue

@@ -0,0 +1,77 @@
+<template>
+  <div class="dialog_confirm">
+    <el-dialog
+      title="提示"
+      v-model="visible"
+      :width="`${typeof width === 'number' ? width : parseInt(width)}px`"
+    >
+      <template v-if="footer" #footer>
+        <div class="my-header">
+          <el-button type="danger" @click="cancelHandler">{{ cancelButtonText }}</el-button>
+          <el-button type="primary" @click="confirmHandler">{{ confirmButtonText }}</el-button>
+        </div>
+      </template>
+      <p class="content" v-if="!$slots.content">{{ title }}</p>
+      <slot v-else name="content"></slot>
+    </el-dialog>
+  </div>
+  <slotInstance name="reference" />
+</template>
+
+<script lang="ts" setup>
+defineOptions({ name: 'DialogConfirm' })
+
+interface DialogConfirm {
+  title: string
+  width: string | number
+  confirmButtonText: string
+  cancelButtonText: string
+  footer: boolean
+}
+withDefaults(defineProps<DialogConfirm>(), {
+  title: '',
+  width: '400',
+  confirmButtonText: '确认',
+  cancelButtonText: '取消',
+  footer: true
+})
+const emit = defineEmits<{
+  (e: 'confirm'): void
+  (e: 'cancel'): void
+}>()
+const visible = ref<boolean>(false)
+const cancelHandler = () => {
+  visible.value = false
+  emit('cancel')
+}
+const confirmHandler = () => {
+  emit('confirm')
+  visible.value = false
+}
+const slots = useSlots()
+let isBindEvent = false
+const createSlot = (slots) => {
+  return defineComponent({
+    setup() {
+      return () => slots.reference()?.[0]
+    },
+    mounted() {
+      if (this.$el instanceof HTMLElement && !isBindEvent) {
+        this.$el.addEventListener('click', () => {
+          visible.value = true
+        })
+        isBindEvent = true
+      }
+    }
+  })
+}
+const slotInstance = createSlot(slots)
+</script>
+
+<style lang="scss" scoped>
+.dialog_confirm {
+  .content {
+    font-size: 18px;
+  }
+}
+</style>

+ 2 - 2
client/src/views/OaSystem/marketCenter/khglPage/CustomerTable.vue

@@ -52,7 +52,7 @@
             <el-button type="primary" plain round @click="newCustomer(false, scope.row)"
               >编辑</el-button
             >
-            <el-popconfirm
+            <dialog-confirm
               title="确认删除该客户吗?"
               confirmButtonText="确定"
               cancelButtonText="取消"
@@ -63,7 +63,7 @@
               <template #reference>
                 <el-button type="danger" plain round>删除</el-button>
               </template>
-            </el-popconfirm>
+            </dialog-confirm>
             <el-button
               type="primary"
               plain

+ 2 - 2
client/src/views/OaSystem/marketCenter/khxqPage/index.vue

@@ -5,7 +5,7 @@
       <div class="right">
         <el-button type="primary" @click="addSubCustomer">新增下级客户</el-button>
 
-        <el-popconfirm
+        <dialog-confirm
           title="确认删除该客户吗?"
           confirmButtonText="确定"
           cancelButtonText="取消"
@@ -16,7 +16,7 @@
           <template #reference>
             <el-button type="danger">删除客户</el-button>
           </template>
-        </el-popconfirm>
+        </dialog-confirm>
       </div>
     </div>
     <div class="select-content">

+ 2 - 2
client/src/views/OaSystem/newsCenter/newsSetting/index.vue

@@ -45,7 +45,7 @@
           <template #default="scope">
             <div class="operationBox">
               <span @click="onAddEditorHandle(scope.row.id)">编辑</span>
-              <el-popconfirm
+              <dialog-confirm
                 title="确定要删除该条新闻?"
                 width="180px"
                 @confirm="deleteHandle(scope.row)"
@@ -53,7 +53,7 @@
                 <template #reference>
                   <span>删除</span>
                 </template>
-              </el-popconfirm>
+              </dialog-confirm>
               <span v-if="scope.row.isPub === 0" @click="pushEditorHandle(scope.row)">发布</span>
             </div>
           </template>

+ 2 - 2
client/src/views/OaSystem/officeCenter/learnCenter/index.vue

@@ -61,7 +61,7 @@
               <span v-hasPermi="['adm:learnCenter:edit']" @click="onAddEditorHandle(scope.row.id)"
                 >编辑</span
               >
-              <el-popconfirm
+              <dialog-confirm
                 title="确定要删除该条数据?"
                 width="180px"
                 @confirm="deleteHandle(scope.row)"
@@ -69,7 +69,7 @@
                 <template #reference>
                   <span v-hasPermi="['adm:learnCenter:del']">删除</span>
                 </template>
-              </el-popconfirm>
+              </dialog-confirm>
             </div>
           </template>
         </el-table-column>

+ 2 - 2
client/src/views/OaSystem/officeCenter/notice/index.vue

@@ -69,7 +69,7 @@
               <span @click="onAddEditorHandle(scope.row.id)" v-hasPermi="['adm:notice:edit']">
                 编辑
               </span>
-              <el-popconfirm
+              <dialog-confirm
                 title="确定要删除该条数据?"
                 width="180px"
                 @confirm="deleteHandle(scope.row)"
@@ -77,7 +77,7 @@
                 <template #reference>
                   <span v-hasPermi="['adm:notice:del']">删除</span>
                 </template>
-              </el-popconfirm>
+              </dialog-confirm>
             </div>
           </template>
         </el-table-column>

+ 2 - 2
client/src/views/OaSystem/personnelManagement/zpxqspPage/index.vue

@@ -101,13 +101,13 @@
               <div class="operateBtn" @click="handleEditRow(scope.row)">
                 <span>编辑</span>
               </div>
-              <!--              <el-popconfirm title="确定删除本条数据?" @confirm="deleteRow(scope.row.id)">-->
+              <!--              <dialog-confirm title="确定删除本条数据?" @confirm="deleteRow(scope.row.id)">-->
               <!--                <template #reference>-->
               <!--                  <div class="operateBtn">-->
               <!--                    <span>删除</span>-->
               <!--                  </div>-->
               <!--                </template>-->
-              <!--              </el-popconfirm>-->
+              <!--              </dialog-confirm>-->
             </div>
           </template>
         </el-table-column>

+ 2 - 2
client/src/views/OaSystem/projectCenter/projectDetail/components/xmxx/ProjectMember.vue

@@ -178,7 +178,7 @@ const getAssetURL = (img: string) => {
           <i class="edit_icon" @click="handleEditorClick(item)">
             <Icon icon="ep:edit" />
           </i>
-          <el-popconfirm
+          <dialog-confirm
             title="确定删除该成员?"
             v-if="item.isManager != 1"
             width="180px"
@@ -189,7 +189,7 @@ const getAssetURL = (img: string) => {
                 <Icon icon="ep:delete" />
               </i>
             </template>
-          </el-popconfirm>
+          </dialog-confirm>
         </div>
       </li>
     </ul>

+ 2 - 2
client/src/views/OaSystem/projectCenter/projectDetail/components/xmxx/ProjectMileStone.vue

@@ -170,11 +170,11 @@ const confirmHandle = (id: string, index: number) => {
             <el-button @click="handleFinish(scope.row, scope.$index + 1)" type="text"
               >{{ !scope.row.is_edit ? '编辑' : '保存' }}
             </el-button>
-            <el-popconfirm title="确定删除?" @confirm="confirmHandle(scope.row.id, scope.$index)">
+            <dialog-confirm title="确定删除?" @confirm="confirmHandle(scope.row.id, scope.$index)">
               <template #reference>
                 <el-button style="margin-left: 20px" type="text">刪除 </el-button>
               </template>
-            </el-popconfirm>
+            </dialog-confirm>
           </template>
         </el-table-column>
       </el-table>

+ 13 - 23
client/src/views/OaSystem/projectCenter/projectDetail/projectDetail.vue

@@ -34,7 +34,7 @@
             >
               合同签订
             </li>
-            <el-popconfirm
+            <dialog-confirm
               title="当前存在进行中的合同,是否重复发起?"
               v-else-if="contractFlowStatuMap[1]"
               @confirm="handleStartContractSign"
@@ -42,7 +42,7 @@
               <template #reference>
                 <li>合同签订</li>
               </template>
-            </el-popconfirm>
+            </dialog-confirm>
           </template>
           <li
             v-if="projectPermis.projectPermisState.all || projectPermis.projectPermisState.xmLeader"
@@ -72,38 +72,25 @@
           >
             验收
           </li>
-          <el-popconfirm
+          <dialog-confirm
             :title="`是否中止项目【${projectDetail?.['xmbh']}】?`"
-            width="280px"
+            v-if="projectPermis.projectPermisState.all || projectPermis.projectPermisState.xmLeader"
             @confirm="projectTerminateHandler"
           >
             <template #reference>
-              <li
-                v-if="
-                  projectPermis.projectPermisState.all || projectPermis.projectPermisState.xmLeader
-                "
-                v-show="projectDetail?.['xmzt'] === 1"
-              >
-                中止
-              </li>
+              <li v-show="projectDetail?.['xmzt'] === 1"> 中止 </li>
             </template>
-          </el-popconfirm>
-          <el-popconfirm
+          </dialog-confirm>
+          <dialog-confirm
             :title="`是否恢复项目【${projectDetail?.['xmbh']}】?`"
             width="280px"
+            v-if="projectPermis.projectPermisState.all || projectPermis.projectPermisState.xmLeader"
             @confirm="projectRecoverHandler"
           >
             <template #reference>
-              <li
-                v-if="
-                  projectPermis.projectPermisState.all || projectPermis.projectPermisState.xmLeader
-                "
-                v-show="projectDetail?.['xmzt'] === 3"
-              >
-                恢复中止
-              </li>
+              <li v-show="projectDetail?.['xmzt'] === 3"> 恢复中止 </li>
             </template>
-          </el-popconfirm>
+          </dialog-confirm>
           <li
             v-if="projectPermis.projectPermisState.all || projectPermis.projectPermisState.xmLeader"
             v-show="projectDetail?.['xmzt'] === 4"
@@ -190,6 +177,7 @@ import {
   projectTerminate,
   projectRecover
 } from '@/service/project'
+import DialogConfirm from '@/views/OaSystem/components/DialogConfirm/index.vue'
 import XmxxComp from './components/xmxx/index.vue'
 import XmhtComp from './components/xmht/index.vue'
 import XmcbComp from './components/xmcb/index.vue'
@@ -232,6 +220,8 @@ const addSubProject: () => void = () => {
  */
 const projectTerminateHandler = async () => {
   const id = projectDetail.value.id
+  console.log(id)
+  return
   if (!id) {
     console.error('项目ID不存在!')
     return

+ 1 - 1
client_h5/src/App.vue

@@ -53,7 +53,7 @@ const getUserIdByDD = async (data: Required<UserIdParam>) => {
 }
 //@ts-ignore
 const getUserInfoById = async () => {
-    return reqest.get('/system/auth/get-permission-info')
+    return reqest.get('/admin-api/system/auth/get-permission-info')
 }
 </script>
 

+ 0 - 1
client_h5/src/pages/handleCenter/index.vue

@@ -178,7 +178,6 @@ const queryHandlerCaseCenterList = (isPull = false) => {
     ...searchData.value
   }
   getHandlerCaseCenterList(sendData).then((result: any) => { 
-    console.log(result)
     if (result.error_code) {
       finished.value = true;
       return;

+ 0 - 1
client_h5/src/pages/notice/details/index.vue

@@ -35,7 +35,6 @@ const detail = ref({});
     id: idStr
   }
    const result = await request.get(urlApi, { params: params })
-   console.log(result)
    const resultData = result.data;
   if (resultData) {
     detail.value = resultData

+ 0 - 4
client_h5/src/utils/request.ts

@@ -14,10 +14,6 @@ instance.interceptors.request.use(
           
             config.headers.Authorization = `Bearer ${import.meta.env.VITE_AUTHORIZATION ?? localStorage.getItem('ACCESS_TOKEN')}`;
     }
-      console.log("url---------------------------")
-    console.log(config.url)
-    console.log(config.headers.Authorization)
-    console.log(localStorage.getItem('ACCESS_TOKEN'))
         const data = config.data || false
         if (
           config.method?.toUpperCase() === 'POST' &&