123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- <template>
- <div id="Dashboard">
- <el-row>
- <el-col :span="24" class="main">
- <breadcrumb :breadcrumbTitle="this.$route.meta.title"></breadcrumb>
- <el-col :span="24" class="container">
- <el-col :span="6" class="txt"> </el-col>
- <el-col :span="18" class="btn">
- <el-button type="primary" size="mini" @click="coldialog = true">添加</el-button>
- </el-col>
- <dataTable :fields="newfields" :data="newdata" :opera="newopera" :total="total" @query="search" @edit="edit" @delete="coltoDelete" @repair="to1">
- </dataTable>
- </el-col>
- </el-col>
- </el-row>
- <el-dialog :visible.sync="coldialog" title="客户信息" @close="coltoClose">
- <data-form :data="form1" :fields="colFields" :rules="{}" @save="save"> </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 {
- metaInfo() {
- return { title: this.$route.meta.title };
- },
- name: 'index',
- props: {},
- components: {
- breadcrumb,
- dataTable,
- dataForm,
- },
- data: function() {
- return {
- breadcrumbTitle: '',
- newdata: [
- // {
- // name: '11',
- // license: '22',
- // mobile: '33',
- // model: '44',
- // carcolor: '55',
- // mileage: '66',
- // vin: '77',
- // insurance: '88',
- // drive: '99',
- // travel: '00',
- // },
- ],
- newfields: [
- {
- 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',
- },
- ],
- newopera: [
- {
- label: '修改',
- // icon: 'el-icon-edit',
- method: 'edit',
- },
- {
- label: '删除',
- // icon: 'el-icon-delete',
- method: 'delete',
- },
- {
- label: '添加维修',
- // icon: 'el-icon-delete',
- method: 'repair',
- },
- ],
- total: 0,
- coldialog: false,
- form1: {},
- colFields: [
- {
- 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({ newquery: 'query', newfetch: 'fetch', newdelete: 'delete', newcreate: 'create', newupdate: 'update' }),
- // 查询列表
- async search({ skip = 0, limit = 10, ...info } = {}) {
- const res = await this.newquery({ skip, limit, ...info });
- if (this.$checkRes(res)) {
- this.$set(this, `newdata`, res.data);
- this.$set(this, `total`, res.total);
- } else {
- this.$message({
- message: res.errmsg,
- type: 'error',
- });
- }
- },
- // searchUser() {
- // console.log('我被触发');
- // },
- //关闭
- coltoClose() {
- this.form1 = {};
- this.coldialog = false;
- this.search();
- },
- //修改
- edit({ data }) {
- console.log(data);
- this.coldialog = true;
- this.$set(this, `form1`, data);
- },
- //添加
- async save({ data }) {
- console.log(data);
- if (data.id) {
- const res = await this.newupdate(data);
- if (this.$checkRes(res)) {
- this.$message({
- message: '修改成功',
- type: 'success',
- });
- this.coltoClose();
- } else {
- this.$message({
- message: '修改失败',
- type: 'error',
- });
- }
- } else {
- const res = await this.newcreate(data);
- if (this.$checkRes(res)) {
- this.$message({
- message: '添加成功',
- type: 'success',
- });
- this.coltoClose();
- } else {
- this.$message({
- message: '添加失败',
- type: 'error',
- });
- }
- }
- this.coldialog = false;
- this.search();
- },
- //删除
- async coltoDelete({ data }) {
- const res = await this.newdelete(data.id);
- console.log(res);
- if (this.$checkRes(res)) {
- this.$message({
- message: '刪除成功',
- type: 'success',
- });
- this.coltoClose();
- } else {
- this.$message({
- message: '删除失败',
- type: 'error',
- });
- }
- this.search();
- },
- to1({ data }) {
- this.$router.push({ path: '/company', query: { id: data.id } });
- },
- },
- computed: {
- ...mapState(['user']),
- },
- };
- </script>
- <style lang="less" scoped>
- /deep/.el-table th.is-leaf > .cell {
- padding: 0px;
- }
- /deep/.el-table th.is-leaf:nth-child(10) > .cell {
- padding: 0px;
- }
- .txt {
- margin: 0 0 15px 0;
- padding-left: 34px;
- }
- .btn {
- text-align: right;
- margin: 0 0 15px 0;
- }
- </style>
|