|
@@ -1,14 +1,6 @@
|
|
<template>
|
|
<template>
|
|
<div id="index">
|
|
<div id="index">
|
|
<data-table height="600px" :fields="fields" :data="list" :opera="opera" :total="total" @query="search" @delete="toDelete" @edit="toEdit">
|
|
<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>
|
|
<template #filterEnd>
|
|
<el-button type="primary" @click="toAdd">添加</el-button>
|
|
<el-button type="primary" @click="toAdd">添加</el-button>
|
|
</template>
|
|
</template>
|
|
@@ -21,6 +13,8 @@
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
|
+const { mapActions: util } = createNamespacedHelpers('util');
|
|
|
|
+const { mapActions: client } = createNamespacedHelpers('client');
|
|
export default {
|
|
export default {
|
|
name: 'index',
|
|
name: 'index',
|
|
props: {},
|
|
props: {},
|
|
@@ -40,50 +34,52 @@ export default {
|
|
method: 'delete',
|
|
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: [],
|
|
statusList: [],
|
|
list: [],
|
|
list: [],
|
|
total: 0,
|
|
total: 0,
|
|
form: {},
|
|
form: {},
|
|
};
|
|
};
|
|
},
|
|
},
|
|
- created() {},
|
|
|
|
|
|
+ created() {
|
|
|
|
+ this.search();
|
|
|
|
+ this.toGetModel();
|
|
|
|
+ },
|
|
methods: {
|
|
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 }) {
|
|
async toEdit({ data }) {
|
|
this.dialog = true;
|
|
this.dialog = true;
|
|
- console.log('in function:toEdit');
|
|
|
|
|
|
+ this.$set(this, `form`, _.cloneDeep(data));
|
|
},
|
|
},
|
|
async toDelete({ 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() {
|
|
toAdd() {
|
|
this.dialog = true;
|
|
this.dialog = true;
|
|
@@ -92,6 +88,13 @@ export default {
|
|
this.dialog = false;
|
|
this.dialog = false;
|
|
this.form = {};
|
|
this.form = {};
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+ async toGetModel() {
|
|
|
|
+ let res = await this.getModel('client');
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ this.$set(this, `fields`, res);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
...mapState(['user', 'menuParams']),
|
|
...mapState(['user', 'menuParams']),
|