taker_car.vue 12 KB

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