index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <div id="Dashboard">
  3. <el-row>
  4. <el-col :span="24" class="main">
  5. <breadcrumb :breadcrumbTitle="this.$route.meta.title"></breadcrumb>
  6. <el-col :span="24" class="container">
  7. <el-col :span="6" class="txt"> </el-col>
  8. <el-col :span="18" class="btn">
  9. <el-button type="primary" size="mini" @click="coldialog = true">添加</el-button>
  10. </el-col>
  11. <dataTable :fields="newfields" :data="newdata" :opera="newopera" :total="total" @query="search" @edit="edit" @delete="coltoDelete" @repair="to1">
  12. </dataTable>
  13. </el-col>
  14. </el-col>
  15. </el-row>
  16. <el-dialog :visible.sync="coldialog" title="客户信息" @close="coltoClose">
  17. <data-form :data="form1" :fields="colFields" :rules="{}" @save="save"> </data-form>
  18. </el-dialog>
  19. </div>
  20. </template>
  21. <script>
  22. import breadcrumb from '@c/common/breadcrumb.vue';
  23. import dataTable from '@/components/frame/filter-page-table.vue';
  24. import dataForm from '@/components/frame/form.vue';
  25. import { mapState, createNamespacedHelpers } from 'vuex';
  26. const { mapActions: car } = createNamespacedHelpers('car');
  27. import bus from '@/components/common/bus';
  28. export default {
  29. metaInfo() {
  30. return { title: this.$route.meta.title };
  31. },
  32. name: 'index',
  33. props: {},
  34. components: {
  35. breadcrumb,
  36. dataTable,
  37. dataForm,
  38. },
  39. data: function() {
  40. return {
  41. breadcrumbTitle: '',
  42. newdata: [
  43. // {
  44. // name: '11',
  45. // license: '22',
  46. // mobile: '33',
  47. // model: '44',
  48. // carcolor: '55',
  49. // mileage: '66',
  50. // vin: '77',
  51. // insurance: '88',
  52. // drive: '99',
  53. // travel: '00',
  54. // },
  55. ],
  56. newfields: [
  57. {
  58. label: '顾客姓名',
  59. prop: 'name',
  60. filter: 'input',
  61. },
  62. {
  63. label: '车牌号',
  64. prop: 'license',
  65. },
  66. {
  67. label: '电话',
  68. prop: 'mobile',
  69. },
  70. {
  71. label: '车型',
  72. prop: 'model',
  73. },
  74. {
  75. label: '车辆颜色',
  76. prop: 'carcolor',
  77. },
  78. {
  79. label: '行驶里程',
  80. prop: 'mileage',
  81. },
  82. {
  83. label: 'VIN号',
  84. prop: 'vin',
  85. },
  86. {
  87. label: '保险日期',
  88. prop: 'insurance',
  89. },
  90. {
  91. label: '驾驶证日期',
  92. prop: 'drive',
  93. },
  94. {
  95. label: '行驶证日期',
  96. prop: 'travel',
  97. },
  98. ],
  99. newopera: [
  100. {
  101. label: '修改',
  102. // icon: 'el-icon-edit',
  103. method: 'edit',
  104. },
  105. {
  106. label: '删除',
  107. // icon: 'el-icon-delete',
  108. method: 'delete',
  109. },
  110. {
  111. label: '添加维修',
  112. // icon: 'el-icon-delete',
  113. method: 'repair',
  114. },
  115. ],
  116. total: 0,
  117. coldialog: false,
  118. form1: {},
  119. colFields: [
  120. {
  121. label: '顾客姓名',
  122. model: 'name',
  123. },
  124. {
  125. label: '车牌号',
  126. model: 'license',
  127. },
  128. {
  129. label: '电话',
  130. model: 'mobile',
  131. type: 'number',
  132. options: { maxLength: 11, minLength: 11 },
  133. },
  134. {
  135. label: '车型',
  136. model: 'model',
  137. },
  138. {
  139. label: '车辆颜色',
  140. model: 'carcolor',
  141. },
  142. {
  143. label: '行驶里程',
  144. model: 'mileage',
  145. },
  146. {
  147. label: 'vin号',
  148. model: 'vin',
  149. },
  150. {
  151. label: '保险日期',
  152. model: 'insurance',
  153. type: 'date',
  154. },
  155. {
  156. label: '驾驶证日期',
  157. model: 'drive',
  158. type: 'date',
  159. },
  160. {
  161. label: '行驶证日期',
  162. model: 'travel',
  163. type: 'date',
  164. },
  165. ],
  166. };
  167. },
  168. created() {
  169. this.search();
  170. },
  171. methods: {
  172. ...car({ newquery: 'query', newfetch: 'fetch', newdelete: 'delete', newcreate: 'create', newupdate: 'update' }),
  173. // 查询列表
  174. async search({ skip = 0, limit = 10, ...info } = {}) {
  175. const res = await this.newquery({ skip, limit, ...info });
  176. if (this.$checkRes(res)) {
  177. this.$set(this, `newdata`, res.data);
  178. this.$set(this, `total`, res.total);
  179. } else {
  180. this.$message({
  181. message: res.errmsg,
  182. type: 'error',
  183. });
  184. }
  185. },
  186. // searchUser() {
  187. // console.log('我被触发');
  188. // },
  189. //关闭
  190. coltoClose() {
  191. this.form1 = {};
  192. this.coldialog = false;
  193. this.search();
  194. },
  195. //修改
  196. edit({ data }) {
  197. console.log(data);
  198. this.coldialog = true;
  199. this.$set(this, `form1`, data);
  200. },
  201. //添加
  202. async save({ data }) {
  203. console.log(data);
  204. if (data.id) {
  205. const res = await this.newupdate(data);
  206. if (this.$checkRes(res)) {
  207. this.$message({
  208. message: '修改成功',
  209. type: 'success',
  210. });
  211. this.coltoClose();
  212. } else {
  213. this.$message({
  214. message: '修改失败',
  215. type: 'error',
  216. });
  217. }
  218. } else {
  219. const res = await this.newcreate(data);
  220. if (this.$checkRes(res)) {
  221. this.$message({
  222. message: '添加成功',
  223. type: 'success',
  224. });
  225. this.coltoClose();
  226. } else {
  227. this.$message({
  228. message: '添加失败',
  229. type: 'error',
  230. });
  231. }
  232. }
  233. this.coldialog = false;
  234. this.search();
  235. },
  236. //删除
  237. async coltoDelete({ data }) {
  238. const res = await this.newdelete(data.id);
  239. console.log(res);
  240. if (this.$checkRes(res)) {
  241. this.$message({
  242. message: '刪除成功',
  243. type: 'success',
  244. });
  245. this.coltoClose();
  246. } else {
  247. this.$message({
  248. message: '删除失败',
  249. type: 'error',
  250. });
  251. }
  252. this.search();
  253. },
  254. to1({ data }) {
  255. this.$router.push({ path: '/company', query: { id: data.id } });
  256. },
  257. },
  258. computed: {
  259. ...mapState(['user']),
  260. },
  261. };
  262. </script>
  263. <style lang="less" scoped>
  264. /deep/.el-table th.is-leaf > .cell {
  265. padding: 0px;
  266. }
  267. /deep/.el-table th.is-leaf:nth-child(10) > .cell {
  268. padding: 0px;
  269. }
  270. .txt {
  271. margin: 0 0 15px 0;
  272. padding-left: 34px;
  273. }
  274. .btn {
  275. text-align: right;
  276. margin: 0 0 15px 0;
  277. }
  278. </style>