guhongwei 4 سال پیش
والد
کامیت
d1671a3417
5فایلهای تغییر یافته به همراه396 افزوده شده و 1 حذف شده
  1. 5 0
      src/components/common/Sidebar.vue
  2. 11 0
      src/router/index.js
  3. 1 1
      src/views/repair/index.vue
  4. 169 0
      src/views/test/index.vue
  5. 210 0
      src/views/test/repairorder.vue

+ 5 - 0
src/components/common/Sidebar.vue

@@ -61,6 +61,11 @@ export default {
           index: 'repair',
           title: '维修信息',
         },
+        {
+          icon: 'el-icon-s-home',
+          index: 'test',
+          title: '测试客户信息',
+        },
       ],
     };
   },

+ 11 - 0
src/router/index.js

@@ -35,6 +35,17 @@ export default new Router({
           component: () => import('../views/repair/index.vue'),
           meta: { title: '维修信息' },
         },
+        {
+          path: '/test',
+          component: () => import('../views/test/index.vue'),
+          meta: { title: '测试客户信息' },
+        },
+        // 维修单
+        {
+          path: '/repairorder',
+          component: () => import('../views/test/repairorder.vue'),
+          meta: { title: '客户维修单' },
+        },
       ],
     },
     {

+ 1 - 1
src/views/repair/index.vue

@@ -117,7 +117,7 @@ export default {
       const res = await this.delete(data.id);
       if (this.$checkRes(res)) {
         this.$message({
-          message: '创建成功',
+          message: '删除成功',
           type: 'success',
         });
         this.toClose();

+ 169 - 0
src/views/test/index.vue

@@ -0,0 +1,169 @@
+<template>
+  <div id="index">
+    <el-row>
+      <el-col :span="24" class="main">
+        <breadcrumb :breadcrumbTitle="this.$route.meta.title"></breadcrumb>
+        <el-col :span="24" class="container">
+          <el-col :span="24" class="btn">
+            <el-button type="primary" size="mini" @click="dialog = true">添加</el-button>
+          </el-col>
+          <dataTable :fields="fields" :data="list" :opera="opera" :total="total" @query="search" @edit="toEdit" @delete="toDelete" @repair="toRepair">
+          </dataTable>
+        </el-col>
+      </el-col>
+    </el-row>
+    <el-dialog :visible.sync="dialog" title="客户信息" @close="toClose">
+      <data-form :data="form" :fields="formFields" :rules="{}" @save="turnSave"> </data-form>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import breadcrumb from '@c/common/breadcrumb.vue';
+import dataTable from '@/components/frame/filter-page-table.vue';
+import dataForm from '@/components/frame/form.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: car } = createNamespacedHelpers('car');
+import bus from '@/components/common/bus';
+export default {
+  name: 'index',
+  props: {},
+  components: {
+    breadcrumb,
+    dataTable,
+    dataForm,
+  },
+  data: function() {
+    return {
+      fields: [
+        { label: '顾客姓名', prop: 'name', filter: 'input' },
+        { label: '车牌号', prop: 'license' },
+        { label: '电话', prop: 'mobile' },
+        { label: '车型', prop: 'model' },
+        { label: '车辆颜色', prop: 'carcolor' },
+        { label: '行驶里程', prop: 'mileage' },
+        { label: 'VIN号', prop: 'vin' },
+        { label: '保险日期', prop: 'insurance' },
+        { label: '驾驶证日期', prop: 'drive' },
+        { label: '行驶证日期', prop: 'travel' },
+      ],
+      opera: [
+        { label: '修改', method: 'edit' },
+        { label: '删除', method: 'delete' },
+        { label: '添加维修', method: 'repair' },
+      ],
+      list: [],
+      total: 0,
+      dialog: false,
+      form: {},
+      formFields: [
+        { label: '顾客姓名', model: 'name' },
+        { label: '车牌号', model: 'license' },
+        { label: '电话', model: 'mobile', type: 'number', options: { maxLength: 11, minLength: 11 } },
+        { label: '车型', model: 'model' },
+        { label: '车辆颜色', model: 'carcolor' },
+        { label: '行驶里程', model: 'mileage' },
+        { label: 'vin号', model: 'vin' },
+        { label: '保险日期', model: 'insurance', type: 'date' },
+        { label: '驾驶证日期', model: 'drive', type: 'date' },
+        { label: '行驶证日期', model: 'travel', type: 'date' },
+      ],
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    ...car(['query', 'delete', 'create', 'update']),
+    // 查询列表
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      } else {
+        this.$message({
+          message: res.errmsg,
+          type: 'error',
+        });
+      }
+    },
+    // 修改
+    toEdit({ data }) {
+      this.$set(this, `form`, data);
+      this.dialog = true;
+    },
+    // 删除
+    async toDelete({ data }) {
+      const res = await this.delete(data.id);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '删除成功',
+          type: 'success',
+        });
+        this.toClose();
+      } else {
+        this.$message({
+          message: res.errmsg,
+          type: 'error',
+        });
+      }
+    },
+    // 查看维修单
+    toRepair({ data }) {
+      this.$router.push({ path: '/repairorder', query: { id: data.id } });
+    },
+    // 保存修改
+    async turnSave({ data }) {
+      if (data.id) {
+        const res = await this.update(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '修改成功',
+            type: 'success',
+          });
+          this.toClose();
+        } else {
+          this.$message({
+            message: res.errmsg,
+            type: 'error',
+          });
+        }
+      } else {
+        const res = await this.create(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '创建成功',
+            type: 'success',
+          });
+          this.toClose();
+        } else {
+          this.$message({
+            message: res.errmsg,
+            type: 'error',
+          });
+        }
+      }
+    },
+    // 取消
+    toClose() {
+      this.form = {};
+      this.dialog = false;
+      this.search();
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.btn {
+  text-align: right;
+  padding: 10px 0;
+}
+</style>

+ 210 - 0
src/views/test/repairorder.vue

@@ -0,0 +1,210 @@
+<template>
+  <div id="repairorder">
+    <el-row>
+      <el-col :span="24" class="main">
+        <breadcrumb :breadcrumbTitle="this.$route.meta.title"></breadcrumb>
+        <el-col :span="24" class="container">
+          <el-col :span="24" class="back">
+            <el-button type="primary" size="mini" @click="$router.push({ path: '/test' })">返回</el-button>
+          </el-col>
+          <el-col :span="24">
+            <el-col :span="6">
+              <span>顾客姓名</span>
+              <span>{{ carinfo.name }}</span>
+            </el-col>
+            <el-col :span="6">
+              <span>顾客电话</span>
+              <span>{{ carinfo.mobile }}</span>
+            </el-col>
+            <el-col :span="6">
+              <span>车牌号</span>
+              <span>{{ carinfo.license }}</span>
+            </el-col>
+            <el-col :span="6">
+              <span>车型</span>
+              <span>{{ carinfo.model }}</span>
+            </el-col>
+            <el-col :span="6">
+              <span>车辆颜色</span>
+              <span>{{ carinfo.carcolor }}</span>
+            </el-col>
+            <el-col :span="6">
+              <span>行驶里程</span>
+              <span>{{ carinfo.mileage }}</span>
+            </el-col>
+            <el-col :span="6">
+              <span>VIN号</span>
+              <span>{{ carinfo.vin }}</span>
+            </el-col>
+            <el-col :span="6">
+              <span>保险日期</span>
+              <span>{{ carinfo.insurance }}</span>
+            </el-col>
+            <el-col :span="6">
+              <span>驾驶证日期</span>
+              <span>{{ carinfo.drive }}</span>
+            </el-col>
+            <el-col :span="6">
+              <span>行驶证日期</span>
+              <span>{{ carinfo.travel }}</span>
+            </el-col>
+          </el-col>
+          <el-col :span="24">
+            <el-col :span="24" class="back">
+              <el-button type="primary" size="mini" @click="add">添加维修单</el-button>
+            </el-col>
+            <el-col :span="24">
+              <el-table :data="list" style="width: 100%" border>
+                <el-table-column prop="name" label="维修项目名" align="center">
+                  <template slot-scope="scope">
+                    <el-input v-model="scope.row.name" placeholder="维修项目名"></el-input>
+                  </template>
+                </el-table-column>
+                <el-table-column prop="type" label="类型" align="center">
+                  <template slot-scope="scope">
+                    <el-input v-model="scope.row.type" placeholder="类型"></el-input>
+                  </template>
+                </el-table-column>
+                <el-table-column prop="parts" label="配件" align="center">
+                  <template slot-scope="scope">
+                    <el-input v-model="scope.row.parts" placeholder="配件"></el-input>
+                  </template>
+                </el-table-column>
+                <el-table-column prop="jobdate" label="工时" align="center">
+                  <template slot-scope="scope">
+                    <el-input v-model="scope.row.jobdate" placeholder="工时"></el-input>
+                  </template>
+                </el-table-column>
+                <el-table-column prop="totalmoney" label="合计" align="center">
+                  <template slot-scope="scope">
+                    <el-input v-model="scope.row.totalmoney" placeholder="合计"></el-input>
+                  </template>
+                </el-table-column>
+                <el-table-column label="操作" align="center">
+                  <template slot-scope="scope">
+                    <el-button size="mini" type="primary" v-if="!scope.row.editing" @click="tosave(scope.$index, scope.row)">保存</el-button>
+                    <el-button size="mini" type="danger" v-if="!scope.row.editing" @click="todelete(scope.$index, scope.row)">删除</el-button>
+                  </template>
+                </el-table-column>
+              </el-table>
+            </el-col>
+          </el-col>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import breadcrumb from '@c/common/breadcrumb.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: car } = createNamespacedHelpers('car');
+const { mapActions: repair } = createNamespacedHelpers('repair');
+export default {
+  name: 'repairorder',
+  props: {},
+  components: { breadcrumb },
+  data: function() {
+    return {
+      // 顾客详情
+      carinfo: {},
+      // 维修单
+      list: [],
+      total: 0,
+    };
+  },
+  async created() {
+    if (this.id) {
+      this.search();
+    }
+  },
+  methods: {
+    ...car(['fetch']),
+    ...repair({ repairquery: 'query', repairdelete: 'delete', repairupdate: 'update', repaircreate: 'create' }),
+    async search({ skip = 0, limit = 5, ...info } = {}) {
+      let res = await this.fetch(this.id);
+      let arr = await this.repairquery({ uid: this.id, skip, limit });
+      if (this.$checkRes(res)) {
+        this.$set(this, `carinfo`, res.data);
+        this.$set(this, `list`, arr.data);
+        this.$set(this, `total`, arr.total);
+      }
+    },
+    // 添加维修单
+    add() {
+      let newValue = {};
+      this.list.push(newValue);
+    },
+    // 保存
+    async tosave(index, row) {
+      let data = row;
+      if (data.id) {
+        const res = await this.repairupdate(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '修改成功',
+            type: 'success',
+          });
+          this.search();
+        } else {
+          this.$message({
+            message: res.errmsg,
+            type: 'error',
+          });
+        }
+      } else {
+        data.uid = this.id;
+        const res = await this.repaircreate(data);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '创建成功',
+            type: 'success',
+          });
+          this.search();
+        } else {
+          this.$message({
+            message: res.errmsg,
+            type: 'error',
+          });
+        }
+      }
+    },
+    // 删除
+    async todelete(index, row) {
+      if (row.id) {
+        const res = await this.repairdelete(row.id);
+        if (this.$checkRes(res)) {
+          this.$message({
+            message: '删除成功',
+            type: 'success',
+          });
+          this.search();
+        } else {
+          this.$message({
+            message: res.errmsg,
+            type: 'error',
+          });
+        }
+      } else {
+        this.list.splice(index, 1);
+      }
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.back {
+  text-align: right;
+  padding: 10px 0;
+}
+</style>