guhongwei 4 سال پیش
والد
کامیت
ee4db16eb6
4فایلهای تغییر یافته به همراه124 افزوده شده و 24 حذف شده
  1. 42 7
      src/views/jg/detail.vue
  2. 20 5
      src/views/jg/index.vue
  3. 43 7
      src/views/yw/detail.vue
  4. 19 5
      src/views/yw/index.vue

+ 42 - 7
src/views/jg/detail.vue

@@ -22,6 +22,7 @@
 <script>
 import dataForm from '@common/src/components/frame/form.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: adminLogin } = createNamespacedHelpers('adminLogin');
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -50,17 +51,48 @@ export default {
         passwd: [{ required: true, message: '请输入密码' }],
       },
       // 管理员列表
-      pidList: [
-        { id: '1', name: '管理员1' },
-        { id: '2', name: '管理员2' },
-      ],
+      pidList: [],
     };
   },
-  created() {},
+  async created() {
+    await this.search();
+  },
   methods: {
+    ...adminLogin(['query', 'fetch', 'create', 'update']),
+    async search() {
+      let res = await this.query({ role: '1' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `pidList`, res.data);
+      }
+      if (this.id) {
+        let res = await this.fetch(this.id);
+        if (this.$checkRes(res)) {
+          this.$set(this, `form`, res.data);
+        }
+      }
+    },
     // 提交
-    toSave({ data }) {
-      console.log(data);
+    async toSave({ data }) {
+      data.role = '2';
+      if (data.id) {
+        let res = await this.update(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '信息修改成功',
+            type: 'success',
+          });
+          this.back();
+        }
+      } else {
+        let res = await this.create(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '信息创建成功',
+            type: 'success',
+          });
+          this.back();
+        }
+      }
     },
     // 返回
     back() {
@@ -69,6 +101,9 @@ export default {
   },
   computed: {
     ...mapState(['user']),
+    id() {
+      return this.$route.query.id;
+    },
   },
   watch: {},
 };

+ 20 - 5
src/views/jg/index.vue

@@ -16,6 +16,8 @@
 <script>
 import dataTable from '@common/src/components/frame/filter-page-table.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: adminLogin } = createNamespacedHelpers('adminLogin');
+
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -51,17 +53,30 @@ export default {
     await this.search();
   },
   methods: {
+    ...adminLogin(['query', 'delete']),
     // 查询列表
-    search({ skip = 0, limit = 10, ...info } = {}) {
-      console.log('列表');
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      if (this.user.role == '1' || this.user.role == '2') info.pid = this.user.id;
+      let res = await this.query({ skip, limit, role: '2', ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
     },
     // 修改
     toEdit({ data }) {
-      console.log('修改');
+      this.$router.push({ path: '/jg/detail', query: { id: data.id } });
     },
     // 删除
-    toDelete({ data }) {
-      console.log('删除');
+    async toDelete({ data }) {
+      let res = await this.delete(data.id);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '信息修改成功',
+          type: 'success',
+        });
+        this.search();
+      }
     },
     // 添加数据
     add() {

+ 43 - 7
src/views/yw/detail.vue

@@ -22,6 +22,7 @@
 <script>
 import dataForm from '@common/src/components/frame/form.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: adminLogin } = createNamespacedHelpers('adminLogin');
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -50,17 +51,49 @@ export default {
         passwd: [{ required: true, message: '请输入密码' }],
       },
       // 机构管理员列表
-      pidList: [
-        { id: '1', name: '机构管理员1' },
-        { id: '2', name: '机构管理员2' },
-      ],
+      pidList: [],
     };
   },
-  created() {},
+  async created() {
+    await this.search();
+  },
   methods: {
+    ...adminLogin(['query', 'fetch', 'create', 'update']),
+    async search() {
+      let res = await this.query({ role: '2' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `pidList`, res.data);
+      }
+      if (this.id) {
+        let res = await this.fetch(this.id);
+        if (this.$checkRes(res)) {
+          this.$set(this, `form`, res.data);
+        }
+      }
+    },
     // 提交
-    toSave({ data }) {
-      console.log(data);
+    // 提交
+    async toSave({ data }) {
+      data.role = '3';
+      if (data.id) {
+        let res = await this.update(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '信息修改成功',
+            type: 'success',
+          });
+          this.back();
+        }
+      } else {
+        let res = await this.create(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '信息创建成功',
+            type: 'success',
+          });
+          this.back();
+        }
+      }
     },
     // 返回
     back() {
@@ -69,6 +102,9 @@ export default {
   },
   computed: {
     ...mapState(['user']),
+    id() {
+      return this.$route.query.id;
+    },
   },
   watch: {},
 };

+ 19 - 5
src/views/yw/index.vue

@@ -16,6 +16,7 @@
 <script>
 import dataTable from '@common/src/components/frame/filter-page-table.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: adminLogin } = createNamespacedHelpers('adminLogin');
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -51,17 +52,30 @@ export default {
     await this.search();
   },
   methods: {
+    ...adminLogin(['query', 'delete']),
     // 查询列表
-    search({ skip = 0, limit = 10, ...info } = {}) {
-      console.log('列表');
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      if (this.user.role == '1' || this.user.role == '2') info.pid = this.user.id;
+      let res = await this.query({ skip, limit, role: '3', ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
     },
     // 修改
     toEdit({ data }) {
-      console.log('修改');
+      this.$router.push({ path: '/yw/detail', query: { id: data.id } });
     },
     // 删除
-    toDelete({ data }) {
-      console.log('删除');
+    async toDelete({ data }) {
+      let res = await this.delete(data.id);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '信息修改成功',
+          type: 'success',
+        });
+        this.search();
+      }
     },
     // 添加数据
     add() {