浏览代码

u殴打特

002201 2 年之前
父节点
当前提交
118c82b4a3

+ 0 - 2
src/views/purchase/apply/see/index.vue

@@ -48,8 +48,6 @@ export default {
     //
     async hide() {
       this.visible = false;
-      this.params = this.resetParams();
-      this.tabName = this.tabColumns[0].key;
     },
     //
     async useDelete(prop) {

+ 25 - 23
src/views/purchase/catalogue/enable/index.vue

@@ -11,30 +11,32 @@ export default {
   methods: {
     //
     open(prop, status) {
-      return this.$confirm("是否启停数据项?", "提示", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "info",
-      })
-        .then(async () => {
-          try {
-            // try
-            const ids = prop.map((item) => item.id);
-            const { msg, code } = await ENABLE({ ids, enableStatus: status });
-            if (code === 200) {
-              this.$emit("success");
-              this.$notify.success(msg);
-            }
-          } catch (err) {
-            // catch
-            console.error(err);
-          } finally {
-            // finally
-          }
+      return new Promise((resolve, reject) => {
+        this.$confirm("是否启停数据项?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "info",
         })
-        .catch((err) => {
-          console.error(err);
-        });
+          .then(async () => {
+            try {
+              // try
+              const ids = prop.map((item) => item.id);
+              const { msg, code } = await ENABLE({ ids, enableStatus: status });
+              if (code === 200) {
+                resolve(true);
+                this.$emit("success");
+                this.$notify.success(msg);
+              }
+            } catch (err) {
+              // catch
+              reject(false);
+              console.error(err);
+            } finally {
+              // finally
+            }
+          })
+          .catch(() => reject(false));
+      });
     },
   },
   created() {},

+ 0 - 32
src/views/purchase/catalogue/hooks/function.js

@@ -1,32 +0,0 @@
-import { ITEM } from "@/api/business/purchase/catalogue";
-
-export default function useMethods() {
-  const fetchItem = async ({ _this, prop }) => {
-    try {
-      // try
-      _this.loading = true;
-      const { code, data } = await ITEM(prop);
-      if (code === 200) {
-        _this.params = data;
-      }
-    } catch (err) {
-      // catch
-      console.error(err);
-    } finally {
-      // finally
-      _this.loading = false;
-    }
-  };
-  const open = ({ _this }) => {
-    _this.visible = true;
-  };
-  const hide = ({ _this }) => {
-    _this.visible = false;
-  };
-
-  return {
-    open,
-    hide,
-    fetchItem,
-  };
-}

+ 25 - 23
src/views/purchase/catalogue/invalid/index.vue

@@ -11,30 +11,32 @@ export default {
   methods: {
     //
     open(prop) {
-      return this.$confirm("是否失效数据项?", "提示", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "info",
-      })
-        .then(async () => {
-          try {
-            // try
-            const ids = prop.map((item) => item.id);
-            const { msg, code } = await INVALID({ ids });
-            if (code === 200) {
-              this.$emit("success");
-              this.$notify.success(msg);
-            }
-          } catch (err) {
-            // catch
-            console.error(err);
-          } finally {
-            // finally
-          }
+      return new Promise((resolve, reject) => {
+        this.$confirm("是否失效数据项?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "info",
         })
-        .catch((err) => {
-          console.error(err);
-        });
+          .then(async () => {
+            try {
+              // try
+              const ids = prop.map((item) => item.id);
+              const { msg, code } = await INVALID({ ids });
+              if (code === 200) {
+                resolve(true);
+                this.$emit("success");
+                this.$notify.success(msg);
+              }
+            } catch (err) {
+              // catch
+              reject(false);
+              console.error(err);
+            } finally {
+              // finally
+            }
+          })
+          .catch(() => reject(false));
+      });
     },
   },
   created() {},

+ 47 - 31
src/views/purchase/catalogue/see/index.vue

@@ -2,7 +2,7 @@
 import Column from "../column";
 import useData from "../hooks/data";
 import useDicts from "../hooks/dicts";
-import useMethods from "../hooks/function";
+import { ITEM } from "@/api/business/purchase/catalogue";
 
 export default {
   name: "SeeDrawer",
@@ -15,44 +15,59 @@ export default {
     };
   },
   computed: {
-    hasPowerEnable: function () {
-      return this.$parent.$parent.hasPowerEnable;
-    },
-    hasPowerInvalid: function () {
-      return this.$parent.$parent.hasPowerInvalid;
+    root: function () {
+      return this.$parent.$parent;
     },
   },
   watch: {},
   methods: {
     //
+    async fetchItem(prop) {
+      try {
+        // try
+        this.loading = true;
+        const { code, data } = await ITEM(prop);
+        if (code === 200) {
+          this.params = data;
+          return true;
+        } else {
+          return false;
+        }
+      } catch (err) {
+        // catch
+        console.error(err);
+      } finally {
+        // finally
+        this.loading = false;
+      }
+    },
+    //
     async open(prop) {
-      const { open, fetchItem } = useMethods();
-      await open({ _this: this });
-      await fetchItem({ _this: this, prop });
+      this.visible = await this.fetchItem(prop);
     },
     //
     async hide() {
-      const { hide } = useMethods();
-      await hide({ _this: this });
+      this.visible = false;
     },
     //
     async useInvalid(prop) {
-      const { useInvalid } = this.$parent.$parent;
-      await useInvalid(prop).then(() => {
-        const [{ id }] = prop;
-        const { fetchItem } = useMethods();
-        fetchItem({ _this: this, prop: id });
-      });
+      await this.root
+        .useInvalid(prop)
+        .then(() => {
+          this.fetchItem(this.params.id);
+        })
+        .catch(() => {});
     },
     //
     async useEnable(prop) {
-      const [{ id, enableStatus }] = prop;
-      const { useEnable } = this.$parent.$parent;
+      const [{ enableStatus }] = prop;
       const status = enableStatus === "2" ? "0" : "2";
-      await useEnable(prop, status).then(() => {
-        const { fetchItem } = useMethods();
-        fetchItem({ _this: this, prop: id });
-      });
+      await this.root
+        .useEnable(prop, status)
+        .then(() => {
+          this.fetchItem(this.params.id);
+        })
+        .catch(() => {});
     },
   },
   created() {},
@@ -70,14 +85,8 @@ export default {
     <template slot="title">
       <span>{{ title }}</span>
       <span>
-        <el-button
-          :size="size"
-          circle
-          icon="el-icon-close"
-          @click="hide"
-        ></el-button>
         <el-tooltip
-          v-if="hasPowerInvalid([params])"
+          v-if="root.hasPowerInvalid([params])"
           effect="dark"
           content="失 效"
           placement="bottom-end"
@@ -90,7 +99,7 @@ export default {
           ></el-button>
         </el-tooltip>
         <el-tooltip
-          v-if="hasPowerEnable([params])"
+          v-if="root.hasPowerEnable([params])"
           effect="dark"
           :content="params.enableStatus === '2' ? '启 用' : '停 用'"
           placement="bottom-end"
@@ -102,6 +111,13 @@ export default {
             @click="useEnable([params])"
           ></el-button>
         </el-tooltip>
+        <el-button
+          :size="size"
+          circle
+          type="danger"
+          icon="el-icon-close"
+          @click="hide"
+        ></el-button>
       </span>
     </template>
     <el-descriptions :size="size" :column="column" border style="margin: 10px">