lrf402788946 4 éve
szülő
commit
b3f5cb3401
4 módosított fájl, 161 hozzáadás és 40 törlés
  1. 5 0
      src/router/supplier.js
  2. 2 0
      src/store/index.js
  3. 43 40
      src/views/client/index.vue
  4. 111 0
      src/views/supplier/index.vue

+ 5 - 0
src/router/supplier.js

@@ -1,4 +1,9 @@
 export default [
+  {
+    path: '/supplier/index',
+    component: () => import('../views/supplier/index.vue'),
+    meta: { title: '供应商管理' },
+  },
   {
     path: '/supplier/contract',
     component: () => import('../views/supplier/contract.vue'),

+ 2 - 0
src/store/index.js

@@ -9,6 +9,7 @@ import userMenu from '@f/store/auth/userMenu';
 import login from '@f/store/auth/login';
 import dictionary from '@f/store/system/dictionary';
 import driver from '@f/store/personnel/driver';
+import client from '@f/store/client/client';
 import util from '@f/store/util';
 import { menuParams, setMenuParams } from '@f/store/auth/menuParams';
 
@@ -27,5 +28,6 @@ export default new Vuex.Store({
     userMenu,
     dictionary,
     driver,
+    client,
   },
 });

+ 43 - 40
src/views/client/index.vue

@@ -1,14 +1,6 @@
 <template>
   <div id="index">
     <data-table height="600px" :fields="fields" :data="list" :opera="opera" :total="total" @query="search" @delete="toDelete" @edit="toEdit">
-      <!-- <template #options="{item}">
-        <template v-if="item.model == 'car_no'">
-          <el-option v-for="(i, index) in carList" :key="`car-${index}`" :label="i.name" :value="i._id"></el-option>
-        </template>
-        <template v-if="item.model == 'status'">
-          <el-option v-for="(i, index) in statusList" :key="`status-${index}`" :label="i.label" :value="i.label"></el-option>
-        </template>
-      </template> -->
       <template #filterEnd>
         <el-button type="primary" @click="toAdd">添加</el-button>
       </template>
@@ -21,6 +13,8 @@
 
 <script>
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: util } = createNamespacedHelpers('util');
+const { mapActions: client } = createNamespacedHelpers('client');
 export default {
   name: 'index',
   props: {},
@@ -40,50 +34,52 @@ export default {
           method: 'delete',
         },
       ],
-      fields: [
-        { label: '姓名', required: true, model: 'name', filter: true },
-        { required: true, label: '联系电话', model: 'mobile', filter: true },
-        { required: true, label: '地址', model: 'address', filter: true },
-        { required: true, label: '法人', model: 'legal', filter: true },
-        { required: true, label: '开户行', model: 'account_bank' },
-        { required: true, label: '银行账号', model: 'account' },
-        { required: true, label: '税号', model: 'car_type' },
-        // { required: true, label: '状态', model: 'status', filter: 'select', noform: true },
-      ],
+      fields: [],
       statusList: [],
       list: [],
       total: 0,
       form: {},
     };
   },
-  created() {},
+  created() {
+    this.search();
+    this.toGetModel();
+  },
   methods: {
-    async search({ skip = 0, limit = 10 }) {},
-    async toSave({ data }) {
-      console.log(data);
-      // let duplicate = _.cloneDeep(this.form);
-      // const { id } = this.form;
-      // let res;
-      // if (id) {
-      //   res = await this.update(duplicate);
-      // } else {
-      //   res = await this.create(duplicate);
-      // }
-      // if (this.$checkRes(res, '保存成功', '保存失败')) {
-      //   this.toReturn();
-      //   this.search();
-      // }
+    ...client(['query', 'create', 'update', 'delete']),
+    ...util(['getModel']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info, type: '客户' });
+      if (this.$checkRes(res)) {
+        const { data, total } = res;
+        this.$set(this, `list`, data);
+        this.$set(this, `total`, total);
+      }
+    },
+    async toSave() {
+      let duplicate = _.cloneDeep(this.form);
+      const { id } = this.form;
+      let res;
+      if (id) {
+        res = await this.update(duplicate);
+      } else {
+        duplicate.type = '客户';
+        res = await this.create(duplicate);
+      }
+      if (this.$checkRes(res, '保存成功', '保存失败')) {
+        this.toReturn();
+        this.search();
+      }
     },
     async toEdit({ data }) {
       this.dialog = true;
-      console.log('in function:toEdit');
+      this.$set(this, `form`, _.cloneDeep(data));
     },
     async toDelete({ data }) {
-      console.log('in function:delete');
-      // const res = await this.delete(data);
-      // if (this.$checkRes(res, '删除成功')) {
-      //   this.search();
-      // }
+      const res = await this.delete(data.id);
+      if (this.$checkRes(res, '删除成功')) {
+        this.search();
+      }
     },
     toAdd() {
       this.dialog = true;
@@ -92,6 +88,13 @@ export default {
       this.dialog = false;
       this.form = {};
     },
+
+    async toGetModel() {
+      let res = await this.getModel('client');
+      if (this.$checkRes(res)) {
+        this.$set(this, `fields`, res);
+      }
+    },
   },
   computed: {
     ...mapState(['user', 'menuParams']),

+ 111 - 0
src/views/supplier/index.vue

@@ -0,0 +1,111 @@
+<template>
+  <div id="index">
+    <data-table height="600px" :fields="fields" :data="list" :opera="opera" :total="total" @query="search" @delete="toDelete" @edit="toEdit">
+      <template #filterEnd>
+        <el-button type="primary" @click="toAdd">添加</el-button>
+      </template>
+    </data-table>
+    <el-dialog title="供应商信息" :visible.sync="dialog" center width="40%">
+      <data-form v-model="form" :fields="fields" @save="toSave"> </data-form>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: util } = createNamespacedHelpers('util');
+const { mapActions: client } = createNamespacedHelpers('client');
+export default {
+  name: 'index',
+  props: {},
+  components: {},
+  data: function() {
+    return {
+      dialog: false,
+      opera: [
+        {
+          label: '编辑',
+          method: 'edit',
+        },
+        {
+          label: '删除',
+          confirm: true,
+          type: 'danger',
+          method: 'delete',
+        },
+      ],
+      fields: [],
+      statusList: [],
+      list: [],
+      total: 0,
+      form: {},
+    };
+  },
+  created() {
+    this.search();
+    this.toGetModel();
+  },
+  methods: {
+    ...client(['query', 'create', 'update', 'delete']),
+    ...util(['getModel']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info, type: '供应商' });
+      if (this.$checkRes(res)) {
+        const { data, total } = res;
+        this.$set(this, `list`, data);
+        this.$set(this, `total`, total);
+      }
+    },
+    async toSave() {
+      let duplicate = _.cloneDeep(this.form);
+      const { id } = this.form;
+      let res;
+      if (id) {
+        res = await this.update(duplicate);
+      } else {
+        duplicate.type = '供应商';
+        res = await this.create(duplicate);
+      }
+      if (this.$checkRes(res, '保存成功', '保存失败')) {
+        this.toReturn();
+        this.search();
+      }
+    },
+    async toEdit({ data }) {
+      this.dialog = true;
+      this.$set(this, `form`, _.cloneDeep(data));
+    },
+    async toDelete({ data }) {
+      const res = await this.delete(data.id);
+      if (this.$checkRes(res, '删除成功')) {
+        this.search();
+      }
+    },
+    toAdd() {
+      this.dialog = true;
+    },
+    toReturn() {
+      this.dialog = false;
+      this.form = {};
+    },
+
+    async toGetModel() {
+      let res = await this.getModel('client');
+      if (this.$checkRes(res)) {
+        this.$set(this, `fields`, res);
+      }
+    },
+  },
+  computed: {
+    ...mapState(['user', 'menuParams']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>