taker_car.vue 12 KB

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