Advertisement
maprangsoft

Layout e-lisingweb-admin

Oct 5th, 2022
705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 7.29 KB | Source Code | 0 0
  1. <template>
  2.   <v-app id="app" dark>
  3.     <v-navigation-drawer
  4.       color="#0F4E96"
  5.       v-model="drawer"
  6.       :mini-variant="miniVariant"
  7.       :clipped="clipped"
  8.       fixed
  9.       app
  10.     >
  11.       <v-list>
  12.         <v-list-item to="/admin/manage/contract" router exact>
  13.           <v-list-item-action>
  14.             <v-icon color="white">mdi-clipboard-text-outline</v-icon>
  15.           </v-list-item-action>
  16.           <v-list-item-content>
  17.             <v-list-item-title class="white--text" v-text="`ข้อมูลสัญญา`" />
  18.           </v-list-item-content>
  19.         </v-list-item>
  20.  
  21.         <v-list-item @click="$auth.logout()" router exact>
  22.           <v-list-item-action>
  23.             <v-icon color="white">mdi-logout</v-icon>
  24.           </v-list-item-action>
  25.           <v-list-item-content>
  26.             <v-list-item-title class="white--text" v-text="`ออกจากระบบ`" />
  27.           </v-list-item-content>
  28.         </v-list-item>
  29.       </v-list>
  30.     </v-navigation-drawer>
  31.     <v-app-bar :clipped-left="clipped" fixed app>
  32.       <v-app-bar-nav-icon @click.stop="drawer = !drawer" />
  33.       <!-- <v-btn icon @click.stop="miniVariant = !miniVariant">
  34.         <v-icon>mdi-{{ `chevron-${miniVariant ? "right" : "left"}` }}</v-icon>
  35.       </v-btn> -->
  36.       <!-- <v-btn icon @click.stop="clipped = !clipped">
  37.         <v-icon>mdi-application</v-icon>
  38.       </v-btn> -->
  39.       <!-- <v-btn icon @click.stop="fixed = !fixed">
  40.         <v-icon>mdi-minus</v-icon>
  41.       </v-btn> -->
  42.       <v-toolbar-title>
  43.         <v-img
  44.           :src="require('~/assets/images/logo.png')"
  45.           max-width="200"
  46.         ></v-img>
  47.       </v-toolbar-title>
  48.       <v-spacer />
  49.       <!-- <v-btn
  50.         icon
  51.         @click.stop="rightDrawer = !rightDrawer"
  52.       >
  53.         <v-icon>mdi-menu</v-icon>
  54.       </v-btn> -->
  55.     </v-app-bar>
  56.     <v-main>
  57.       <v-container>
  58.         <Nuxt />
  59.       </v-container>
  60.     </v-main>
  61.     <!-- <v-navigation-drawer
  62.       v-model="rightDrawer"
  63.       :right="right"
  64.       temporary
  65.       fixed
  66.     >
  67.       <v-list>
  68.         <v-list-item @click.native="right = !right">
  69.           <v-list-item-action>
  70.             <v-icon light>
  71.               mdi-repeat
  72.             </v-icon>
  73.           </v-list-item-action>
  74.           <v-list-item-title>Switch drawer (click me)</v-list-item-title>
  75.         </v-list-item>
  76.       </v-list>
  77.     </v-navigation-drawer> -->
  78.     <v-footer :absolute="!fixed" app>
  79.       <span>&copy; {{ new Date().getFullYear() }}</span>
  80.     </v-footer>
  81.  
  82.     <v-speed-dial
  83.       v-model="fab"
  84.       :top="top"
  85.       :bottom="bottom"
  86.       :right="right"
  87.       :left="left"
  88.       :direction="direction"
  89.       :open-on-hover="hover"
  90.       :transition="transition"
  91.     >
  92.       <template v-slot:activator>
  93.         <v-btn v-model="fab" color="blue darken-2" dark fab>
  94.           <v-icon v-if="fab"> mdi-close </v-icon>
  95.           <v-icon v-else> mdi-apps </v-icon>
  96.         </v-btn>
  97.       </template>
  98.       <!-- <v-btn fab dark small color="green">
  99.         <v-icon>mdi-pencil</v-icon>
  100.       </v-btn>
  101.       <v-btn fab dark small color="indigo">
  102.         <v-icon>mdi-plus</v-icon>
  103.       </v-btn>
  104.       <v-btn fab dark small color="red">
  105.         <v-icon>mdi-delete</v-icon>
  106.       </v-btn> -->
  107.  
  108.       <v-btn
  109.         fab
  110.         dark
  111.         small
  112.         color="green"
  113.         title="ส่งอีกครั้ง"
  114.         @click="openDialog()"
  115.       >
  116.         <v-icon>mdi-send</v-icon>
  117.       </v-btn>
  118.     </v-speed-dial>
  119.  
  120.     <!-- <SnackBar></SnackBar> -->
  121.     <v-snackbar
  122.       v-model="snackbar"
  123.       :color="snackbarStatus === 'success' ? `green` : `red`"
  124.     >
  125.       {{ snackbarText }}
  126.       <template v-slot:action="{ attrs }">
  127.         <v-btn color="#fff" text v-bind="attrs" @click="snackbar = false">
  128.           ปิด
  129.         </v-btn>
  130.       </template>
  131.     </v-snackbar>
  132.  
  133.     <DialogPersistent
  134.       :dialogOption.sync="dialogData"
  135.       @onResponseFromDialogPersistent="runSignAgain"
  136.     ></DialogPersistent>
  137.   </v-app>
  138. </template>
  139.  
  140. <script>
  141. import DialogPersistent from "~/components/global/DialogPersistent";
  142. import SnackBar from "~/components/global/SnackBar";
  143.  
  144. export default {
  145.   name: "DefaultLayout",
  146.   middleware: "authenticated",
  147.   components: {
  148.     DialogPersistent,
  149.     SnackBar,
  150.   },
  151.   head() {
  152.     return {
  153.       link: [
  154.         {
  155.           rel: "stylesheet",
  156.           href: require("~/assets/css/hint.min.css"),
  157.         },
  158.       ],
  159.     };
  160.   },
  161.  
  162.   data() {
  163.     return {
  164.       //* dialog
  165.       dialogData: {},
  166.  
  167.       //* snackbar
  168.       snackbar: false,
  169.       snackbarText: "",
  170.       snackbarStatus: "",
  171.  
  172.       //* sidebar
  173.       clipped: false,
  174.       drawer: true,
  175.       fixed: false,
  176.       miniVariant: false,
  177.       right: true,
  178.       rightDrawer: false,
  179.       title: "Vuetify.js",
  180.       //* Speed dial
  181.       direction: "top",
  182.       fab: false,
  183.       fling: false,
  184.       hover: true,
  185.       tabs: null,
  186.       top: false,
  187.       right: true,
  188.       bottom: true,
  189.       left: false,
  190.       transition: "slide-y-reverse-transition",
  191.     };
  192.   },
  193.   created() {
  194.     //https://dev.to/viniciuskneves/watch-for-vuex-state-changes-2mgj
  195.     this.unsubscribe = this.$store.subscribe((mutation, state) => {
  196.       if (mutation.type === "request/SET_SERVER_ONLINE") {
  197.  
  198.         if (!state["request"]?.serverOnline?.status) {
  199.           this.snackbarStatus = "error";
  200.           this.snackbarText = state["request"].serverOnline.message;
  201.           this.snackbar = true;
  202.         }
  203.       }
  204.  
  205.       if (mutation.type === "admin/SET_SNACKBAR") {
  206.  
  207.         if (Object.keys(state["admin"].snackbar).length > 0) {
  208.  
  209.           this.snackbarStatus = state["admin"].snackbar.status ?? "error";
  210.           this.snackbarText = state["admin"].snackbar.message;
  211.           this.snackbar = true;
  212.         }
  213.       }
  214.     });
  215.   },
  216.   beforeDestroy() {
  217.     this.unsubscribe();
  218.   },
  219.   methods: {
  220.     openDialog() {
  221.       this.dialogData = {
  222.         status: true,
  223.         title: "ยืนยัน",
  224.         content: "ส่งเอกสารที่ Sign ไม่สำเร็จอีกครั้ง",
  225.       };
  226.     },
  227.     async runSignAgain(obj) {
  228.       if (!obj.status) {
  229.         return;
  230.       }
  231.  
  232.       try {
  233.         const res = await this.$axios.$get(`/api/esignature/processrunsign`);
  234.  
  235.         if (!res.success) {
  236.           this.$store.commit("admin/SET_SNACKBAR", {
  237.             status: "error",
  238.             message: res.message,
  239.           });
  240.           return;
  241.         }
  242.  
  243.         this.$store.commit("admin/SET_SNACKBAR", {
  244.           status: "success",
  245.           message: res.message,
  246.         });
  247.  
  248.         return;
  249.       } catch (error) {
  250.         this.$store.commit("admin/SET_SNACKBAR", {
  251.           status: "error",
  252.           message: error.message,
  253.         });
  254.         console.log("runSignAgain error", error.message);
  255.       }
  256.     },
  257.   },
  258.   watch: {
  259.     top(val) {
  260.       this.bottom = !val;
  261.     },
  262.     right(val) {
  263.       this.left = !val;
  264.     },
  265.     bottom(val) {
  266.       this.top = !val;
  267.     },
  268.     left(val) {
  269.       this.right = !val;
  270.     },
  271.   },
  272. };
  273. </script>
  274.  
  275. <style>
  276. /* This is for documentation purposes and will not be needed in your application */
  277. #app .v-speed-dial {
  278.   z-index: 9999;
  279.   position: fixed;
  280. }
  281.  
  282. #app .v-btn--floating {
  283.   position: relative;
  284. }
  285. </style>
  286.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement