taker_car.vue 10 KB

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