From 9057e04efad1b7d61c77a72e5c37a504d0aee935 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期五, 26 九月 2025 09:24:03 +0800
Subject: [PATCH] H5静态化

---
 admin/src/components/base/BaseOpera.vue |   74 ++++++++++++++++++++-----------------
 1 files changed, 40 insertions(+), 34 deletions(-)

diff --git a/admin/src/components/base/BaseOpera.vue b/admin/src/components/base/BaseOpera.vue
index 697e7f5..4a364eb 100644
--- a/admin/src/components/base/BaseOpera.vue
+++ b/admin/src/components/base/BaseOpera.vue
@@ -1,5 +1,6 @@
 <script>
 export default {
+  name: 'BaseOpera',
   data () {
     return {
       title: '',
@@ -13,18 +14,12 @@
       }
     }
   },
-  // watch: {
-  //   visible() {
-  //     console.log(this.visible);
-  //   }
-  // },
-  watch: {
-    $route (to, from) {
-      this.close()
-    }
-  },
   methods: {
-    // 閰嶇疆
+    /**
+     * 閰嶇疆
+     *
+     * @param extParams 閰嶇疆鍙傛暟
+     */
     config (extParams = {}) {
       if (extParams == null) {
         throw new Error('Parameter can not be null of method \'config\' .')
@@ -32,17 +27,14 @@
       if (extParams.api == null) {
         throw new Error('Missing config option \'api\'.')
       }
-      if(extParams.api.indexOf('@/',0) === 0){
-        this.api = require(extParams.api)
-      }else {
-        this.api = require('@/api' + extParams.api)
-      }
+      this.api = require('@/api' + extParams.api)
       extParams['field.id'] && (this.configData['field.id'] = extParams['field.id'])
     },
     /**
      * 鎵撳紑绐楀彛
-     * @title 绐楀彛鏍囬
-     * @target 缂栬緫鐨勫璞�
+     *
+     * @param title 绐楀彛鏍囬
+     * @param target 琛屽璞★紙浠呯紪杈戦渶璇ュ弬鏁帮級
      */
     open (title, target) {
       this.title = title
@@ -62,49 +54,63 @@
         }
       })
     },
-    close () {
-      this.visible = false
-    },
-    // 纭鏂板缓/淇敼
+    /**
+     * 纭锛堢偣鍑荤‘璁ゆ寜閽悗瑙﹀彂锛�
+     */
     confirm () {
-      if (this.form.id == null || this.form.id === '') {
+      if (this.form[this.configData['field.id']] == null || this.form[this.configData['field.id']] === '') {
         this.__confirmCreate()
         return
       }
       this.__confirmEdit()
     },
-    // 纭鏂板缓
+    /**
+     * 纭鏂板缓
+     *
+     * @private
+     */
     __confirmCreate () {
       this.$refs.form.validate((valid) => {
-        // debugger
         if (!valid) {
           return
         }
-        // console.log(this.form);
-        // debugger
         // 璋冪敤鏂板缓鎺ュ彛
         this.isWorking = true
+        var that = this
         this.api.create(this.form)
           .then(() => {
-            this.visible = false
-            this.$tip.apiSuccess('鏂板缓鎴愬姛')
-            this.$emit('success')
+            // that.$tip.apiSuccess('鏂板缓鎴愬姛')
+            // that.$dialog.actionConfirmButton('鏄惁鍋滅暀璇ラ〉闈㈢户缁柊寤烘暟鎹紵', '鏂板缓鎴愬姛','缁х画娣诲姞','鍏抽棴杩斿洖')
+            //   .then(() => {
+                that.$refs.form.resetFields()
+                that.visible = false
+                that.form[this.configData['field.id']] = null
+                that.$emit('success')
+              // })
+              // .catch(() => {
+              //   that.visible = false
+              //   that.$emit('success')
+              // })
           })
           .catch(e => {
-            // this.$tip.apiFailed(e)
+            this.$tip.apiFailed(e)
           })
           .finally(() => {
             this.isWorking = false
           })
       })
     },
-    // 纭淇敼
+    /**
+     * 纭淇敼
+     *
+     * @private
+     */
     __confirmEdit () {
       this.$refs.form.validate((valid) => {
         if (!valid) {
           return
         }
-        // 璋冪敤鏂板缓鎺ュ彛
+        // 璋冪敤鏇存柊鎺ュ彛
         this.isWorking = true
         this.api.updateById(this.form)
           .then(() => {
@@ -113,7 +119,7 @@
             this.$emit('success')
           })
           .catch(e => {
-            // this.$tip.apiFailed(e)
+            this.$tip.apiFailed(e)
           })
           .finally(() => {
             this.isWorking = false

--
Gitblit v1.9.3