taker_car.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. <template>
  2. <div class="app-container">
  3. <!-- 筛选条件 -->
  4. <div>
  5. <el-form
  6. :model="searchForm"
  7. ref="searchForm"
  8. label-width="100px"
  9. size="small"
  10. label-position="left"
  11. >
  12. <el-row :gutter="20">
  13. <el-col :xs="24" :sm="12" :lg="6">
  14. <el-form-item label="经销商名称" prop="customerName">
  15. <el-input
  16. v-model="searchForm.customerName"
  17. placeholder="请输入经销商名称"
  18. ></el-input>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :xs="24" :sm="12" :lg="6">
  22. <el-form-item label="车牌" prop="carBrand">
  23. <el-input
  24. v-model="searchForm.carBrand"
  25. placeholder="请输入车牌"
  26. ></el-input>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :xs="24" :sm="12" :lg="12" class="tr">
  30. <el-form-item label="">
  31. <el-button size="small" @click="clearFn">清空</el-button>
  32. <el-button size="small" type="primary" @click="searchFn"
  33. >搜索</el-button
  34. >
  35. </el-form-item>
  36. </el-col>
  37. </el-row>
  38. </el-form>
  39. </div>
  40. <!-- 按钮 -->
  41. <div class="btn-group clearfix">
  42. <div class="fl">
  43. <el-button
  44. v-if="$checkBtnRole('add', $route.meta.roles)"
  45. type="primary"
  46. icon="el-icon-plus"
  47. size="small"
  48. class="add-right"
  49. @click="addDataList"
  50. >新增</el-button
  51. >
  52. <el-popconfirm
  53. v-if="$checkBtnRole('del', $route.meta.roles)"
  54. class="delClass"
  55. @onConfirm="delFn"
  56. title="这是一段内容确定删除吗?"
  57. >
  58. <el-button
  59. :disabled="ids.length < 1"
  60. slot="reference"
  61. type="danger"
  62. icon="el-icon-minus"
  63. size="small"
  64. >批量删除</el-button
  65. >
  66. </el-popconfirm>
  67. </div>
  68. <div class="fr">
  69. <ExportButton :exUrl="'/take-car-record/export'" :exParams="exParams" />
  70. </div>
  71. </div>
  72. <!-- 列表 -->
  73. <div class="mymain-container">
  74. <div class="table">
  75. <el-table
  76. v-loading="listLoading"
  77. :data="dataList"
  78. element-loading-text="Loading"
  79. @select="hanleSelect"
  80. @select-all="hanleSelect"
  81. border
  82. fit
  83. highlight-current-row
  84. stripe
  85. >
  86. <el-table-column
  87. type="selection"
  88. align="center"
  89. min-width="100"
  90. ></el-table-column>
  91. <el-table-column
  92. align="center"
  93. label="经销商名称"
  94. prop="customerName"
  95. min-width="160"
  96. show-overflow-tooltip
  97. ></el-table-column>
  98. <el-table-column
  99. align="center"
  100. label="车辆车牌号"
  101. prop="carBrand"
  102. min-width="160"
  103. show-overflow-tooltip
  104. ></el-table-column>
  105. <el-table-column
  106. align="center"
  107. label="创建者"
  108. prop="createBy"
  109. min-width="160"
  110. show-overflow-tooltip
  111. ></el-table-column>
  112. <el-table-column
  113. align="center"
  114. label="创建时间"
  115. prop="createTime"
  116. min-width="160"
  117. show-overflow-tooltip
  118. ></el-table-column>
  119. <el-table-column
  120. align="center"
  121. label="更新者"
  122. prop="updateBy"
  123. min-width="160"
  124. show-overflow-tooltip
  125. ></el-table-column>
  126. <el-table-column
  127. align="center"
  128. label="更新时间"
  129. prop="updateTime"
  130. min-width="160"
  131. show-overflow-tooltip
  132. ></el-table-column>
  133. <el-table-column
  134. align="center"
  135. label="操作"
  136. min-width="160"
  137. show-overflow-tooltip
  138. fixed="right"
  139. >
  140. <template slot-scope="scope">
  141. <el-button
  142. type="text"
  143. class="textColor"
  144. v-if="$checkBtnRole('edit', $route.meta.roles)"
  145. @click="editFn(scope.row)"
  146. >编辑</el-button
  147. >
  148. <el-popconfirm
  149. @onConfirm="delFn(scope.row.id)"
  150. v-if="$checkBtnRole('del', $route.meta.roles)"
  151. title="这是一段内容确定删除吗?"
  152. >
  153. <el-button type="text" class="textColor" slot="reference"
  154. >删除</el-button
  155. >
  156. </el-popconfirm>
  157. </template>
  158. </el-table-column>
  159. </el-table>
  160. </div>
  161. <!-- 分页 -->
  162. <div class="fr">
  163. <el-pagination
  164. @size-change="handleSizeChange"
  165. @current-change="handleCurrentChange"
  166. :current-page="currentPage"
  167. :page-sizes="[10, 20, 30, 50]"
  168. :page-size="10"
  169. layout="total, sizes, prev, pager, next, jumper"
  170. :total="listTotal"
  171. >
  172. </el-pagination>
  173. </div>
  174. </div>
  175. <!-- 弹窗 -->
  176. <el-dialog
  177. title="提货车辆档案"
  178. :visible.sync="dialogForm"
  179. width="40%"
  180. :show-close="false"
  181. :close-on-click-modal="false"
  182. >
  183. <el-form
  184. ref="addForm"
  185. :rules="rules"
  186. :model="addForm"
  187. label-width="120px"
  188. class="demo-ruleForm"
  189. >
  190. <el-form-item label="经销商名称" prop="customerId">
  191. <el-select
  192. v-model="addForm.customerId"
  193. placeholder="请选择经销商名称"
  194. >
  195. <el-option
  196. v-for="item in dealerList"
  197. :key="item.id"
  198. :label="item.name"
  199. :value="item.id"
  200. >
  201. </el-option>
  202. </el-select>
  203. </el-form-item>
  204. <el-row>
  205. <el-col :span="12">
  206. <el-form-item label="车牌号" prop="carBrand">
  207. <el-input v-model="addForm.carBrand"></el-input> </el-form-item
  208. ></el-col>
  209. <el-col :span="12">
  210. <el-form-item label="联系电话" prop="mobile">
  211. <el-input v-model="addForm.mobile"></el-input> </el-form-item
  212. ></el-col>
  213. </el-row>
  214. <el-row>
  215. <el-col :span="12">
  216. <el-form-item label="车型" prop="carType">
  217. <el-input v-model="addForm.carType"></el-input> </el-form-item
  218. ></el-col>
  219. <el-col :span="12">
  220. <el-form-item label="体积" prop="volume">
  221. <el-input v-model="addForm.volume">
  222. <i class="el-input__icon" slot="suffix">m³ </i>
  223. </el-input>
  224. </el-form-item></el-col
  225. >
  226. </el-row>
  227. </el-form>
  228. <div slot="footer" class="dialog-footer">
  229. <el-button @click="cancelFn">取 消</el-button>
  230. <el-button type="primary" @click="addDataListFn">确 定</el-button>
  231. </div>
  232. </el-dialog>
  233. </div>
  234. </template>
  235. <script>
  236. import {
  237. getCarList,
  238. addDataListApi,
  239. delCarFn,
  240. editDataListApi,
  241. } from "@/api/basic_data/taker";
  242. import { getDealerList } from "@/api/basic_data/dealer";
  243. import { downloadFiles } from "@/utils/util";
  244. export default {
  245. data() {
  246. return {
  247. listLoading: false, // 列表加载loading
  248. currentPage: 1, // 当前页码
  249. pageSize: 10, // 每页数量
  250. listTotal: 0, // 列表总数
  251. addForm: {
  252. customerId: "",
  253. mobile: "",
  254. carType: "",
  255. volume: "",
  256. carBrand: "",
  257. },
  258. rules: {
  259. customerId: [
  260. { required: true, message: "请选择活动区域", trigger: "change" },
  261. ],
  262. mobile: [
  263. {
  264. required: true,
  265. message: "请输入联系电话",
  266. trigger: "blur",
  267. },
  268. {
  269. pattern:
  270. /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/,
  271. message: "联系电话格式不正确",
  272. trigger: "blur",
  273. },
  274. ],
  275. // carType: [{ required: true, message: "车型不能为空", trigger: "blur" }],
  276. // volume: [{ required: true, message: "体积不能为空", trigger: "blur" }],
  277. carBrand: [
  278. { required: true, message: "车牌号不能为空", trigger: "blur" },
  279. ],
  280. },
  281. dialogForm: false,
  282. dataList: [],
  283. searchForm: {
  284. customerName: "",
  285. carBrand: "",
  286. },
  287. dealerList: [],
  288. ids: [],
  289. };
  290. },
  291. computed: {
  292. exParams() {
  293. return {
  294. carBrand: this.searchForm.carBrand,
  295. customerName: this.searchForm.customerName,
  296. };
  297. },
  298. },
  299. async created() {
  300. this.getDataList({ pageNum: 1, pageSize: 10 });
  301. this.getDealerDataList({ pageNum: 1, pageSize: 10 });
  302. },
  303. methods: {
  304. // 筛选部分数据或者单个
  305. hanleSelect(selection) {
  306. // this.ids = selection.map((k) => {
  307. // return k.id;
  308. // });
  309. // console.log(selection);
  310. this.ids = selection.map((v) => v.id);
  311. // console.log(this.ids);
  312. },
  313. // //导出
  314. // exportFn() {
  315. // let screenData = {
  316. // customerName: this.searchForm.customerName,
  317. // carBrand: this.searchForm.carBrand,
  318. // };
  319. // downloadFiles("/take-car-record/export", screenData);
  320. // },
  321. //取消
  322. async cancelFn() {
  323. if (this.addForm.id) {
  324. this.addForm = {
  325. customerId: "",
  326. mobile: "",
  327. carType: "",
  328. volume: "",
  329. carBrand: "",
  330. };
  331. } else {
  332. await this.$refs.addForm.resetFields();
  333. }
  334. this.dialogForm = false;
  335. },
  336. //编辑
  337. editFn(data) {
  338. this.addForm = data;
  339. this.dialogForm = true;
  340. },
  341. //重置
  342. clearFn() {
  343. console.log(this.$refs.searchForm);
  344. this.$refs.searchForm.resetFields();
  345. },
  346. //搜索
  347. async searchFn() {
  348. console.log(this.searchForm);
  349. await this.getDataList({
  350. ...this.searchForm,
  351. pageNum: 1,
  352. pageSize: this.pageSize,
  353. });
  354. },
  355. //删除
  356. async delFn(ids) {
  357. if (ids) {
  358. let arr = [];
  359. arr.push(ids);
  360. let res = arr.toString();
  361. await delCarFn({ ids: res });
  362. } else {
  363. let res = this.ids.toString();
  364. await delCarFn({ ids: res });
  365. }
  366. this.$message.success("删除成功");
  367. this.ids = [];
  368. this.getDataList({ pageNum: this.currentPage, pageSize: this.pageSize });
  369. },
  370. //获取经销商数据
  371. async getDealerDataList(data) {
  372. const res = await getDealerList(data);
  373. this.dealerList = res.data.records;
  374. },
  375. //新增
  376. async addDataList() {
  377. this.addForm = {
  378. customerId: "",
  379. mobile: "",
  380. carType: "",
  381. volume: "",
  382. carBrand: "",
  383. };
  384. this.dialogForm = true;
  385. },
  386. async addDataListFn() {
  387. await this.$refs.addForm.validate();
  388. const res = this.dealerList.filter(
  389. (v) => v.id === this.addForm.customerId
  390. )[0];
  391. if (this.addForm.id) {
  392. await editDataListApi({ ...this.addForm });
  393. this.$message.success("编辑成功");
  394. } else {
  395. await addDataListApi({ ...this.addForm, orgNumber: res.useOrgNumber });
  396. this.$message.success("添加成功");
  397. }
  398. // console.log(res);
  399. //
  400. // this.addForm = {
  401. // customerId: "",
  402. // mobile: "",
  403. // carType: "",
  404. // volume: "",
  405. // carBrand: "",
  406. // };
  407. await this.$refs.addForm.resetFields();
  408. this.getDataList({ pageNum: this.currentPage, pageSize: this.pageSize });
  409. this.dialogForm = false;
  410. },
  411. //获取列表数据
  412. async getDataList(data) {
  413. const res = await getCarList(data);
  414. console.log(res);
  415. this.dataList = res.data.records;
  416. this.listTotal = res.data.total;
  417. },
  418. // 更改每页数量
  419. handleSizeChange(val) {
  420. this.pageSize = val;
  421. this.currentPage = 1;
  422. this.getDataList({ pageNum: 1, pageSize: this.pageSize });
  423. },
  424. // 更改当前页
  425. handleCurrentChange(val) {
  426. this.currentPage = val;
  427. this.getDataList({ pageNum: val, pageSize: this.pageSize });
  428. },
  429. },
  430. };
  431. </script>
  432. <style lang="scss" scoped>
  433. .add-right {
  434. margin-right: 10px;
  435. }
  436. // ::v-deep .el-popover__reference {
  437. // margin-left: 10px;
  438. // }
  439. ::v-deep .el-date-editor {
  440. width: 100%;
  441. }
  442. ::v-deep .el-select {
  443. width: 100%;
  444. }
  445. ::v-deep .el-col-9 .el-button {
  446. padding: 5px;
  447. }
  448. ::v-deep .el-dialog__header {
  449. background-color: #dddddd;
  450. }
  451. </style>