routeInfo-list.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. <template>
  2. <div style="padding-left: 5px">
  3. <el-breadcrumb separator=">">
  4. <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
  5. <el-breadcrumb-item>
  6. <a href="#">基础信息管理</a>
  7. </el-breadcrumb-item>
  8. <el-breadcrumb-item>
  9. <a href="/routeInfo">线路管理</a>
  10. </el-breadcrumb-item>
  11. </el-breadcrumb>
  12. <el-divider></el-divider>
  13. <el-form
  14. ref="queryForm"
  15. :model="queryModel"
  16. inline
  17. class="demo-form-inline"
  18. >
  19. <el-form-item label="所属公司" prop="companyId">
  20. <el-select-tree
  21. size="mini"
  22. :props="props"
  23. :options="companyResult"
  24. v-model="queryModel.companyId"
  25. height="200"
  26. ></el-select-tree>
  27. </el-form-item>
  28. <el-form-item label="路线名称" prop="name">
  29. <el-input type="text" size="mini" v-model="queryModel.name"></el-input>
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button
  33. type="primary"
  34. size="mini"
  35. icon="ios-search"
  36. @click="changePage(1)"
  37. :loading="loading"
  38. >查询</el-button
  39. >&nbsp;
  40. <el-button
  41. type="info"
  42. size="mini"
  43. style="margin-left: 8px"
  44. @click="handleReset('queryForm')"
  45. >重置</el-button
  46. >&nbsp;
  47. </el-form-item>
  48. </el-form>
  49. <el-divider></el-divider>
  50. <el-row class="button-group">
  51. <el-button
  52. type="primary"
  53. size="small"
  54. plain
  55. icon="el-icon-circle-plus"
  56. @click="handleAdd"
  57. >新增</el-button
  58. >
  59. <el-button
  60. type="primary"
  61. size="small"
  62. plain
  63. icon="el-icon-remove"
  64. :disabled="multipleSelection.length == 0"
  65. @click="handleBatchDelete"
  66. >删除选中项</el-button
  67. >
  68. <el-button
  69. type="primary"
  70. size="small"
  71. plain
  72. icon="el-icon-upload2"
  73. @click="batchImportVisible = true"
  74. >导入</el-button
  75. >
  76. </el-row>
  77. <el-table
  78. ref="formTable"
  79. :data="tableData"
  80. v-loading="loading"
  81. stripe
  82. :height="tableHeight"
  83. @sort-change="sortChange"
  84. @selection-change="handleSelectionChange"
  85. >
  86. <el-table-column type="selection" width="55"></el-table-column>
  87. <el-table-column
  88. prop="companyName"
  89. label="所属单位"
  90. width="130"
  91. ></el-table-column>
  92. <el-table-column
  93. prop="name"
  94. label="路线名称"
  95. width="150"
  96. ></el-table-column>
  97. <el-table-column
  98. prop="regionName"
  99. label="地区"
  100. width="90"
  101. ></el-table-column>
  102. <el-table-column
  103. prop="startTime"
  104. label="开始时间"
  105. width="200"
  106. ></el-table-column>
  107. <el-table-column
  108. prop="endTime"
  109. label="结束时间"
  110. width="200"
  111. ></el-table-column>
  112. <el-table-column label="操作">
  113. <template slot-scope="{ row }">
  114. <el-button size="mini" type="warning" @click="handleEdit(row)"
  115. >编辑</el-button
  116. >
  117. <el-button size="mini" type="success" @click="handleEditPath(row)"
  118. >路线绘制</el-button
  119. >
  120. <el-button size="mini" type="success" @click="handleEditPrice(row)"
  121. >费用查看</el-button
  122. >
  123. <el-button size="mini" type="danger" @click="handleDelete(row)"
  124. >删除</el-button
  125. >
  126. </template>
  127. </el-table-column>
  128. </el-table>
  129. <el-pagination
  130. :current-page.sync="pageIndex"
  131. :total="totalElements"
  132. :page-sizes="pageSizeList"
  133. @current-change="changePage"
  134. @size-change="pageSizeChange"
  135. layout="total, sizes, prev, pager, next, jumper"
  136. ></el-pagination>
  137. <routeInfo-detail
  138. v-if="showModal"
  139. :businessKey="businessKey"
  140. :title="modalTitle"
  141. @close="onDetailModalClose"
  142. ></routeInfo-detail>
  143. <el-dialog
  144. width="80%"
  145. :visible.sync="showMapDialog"
  146. title="路线绘制"
  147. :modal-append-to-body="true"
  148. :append-to-body="true"
  149. style="text-align: left"
  150. :close-on-click-modal="false"
  151. v-loading="mapLoading"
  152. >
  153. <el-amap
  154. ref="roadlineMap"
  155. vid="roadlineMap"
  156. :plugin="plugin"
  157. :center="centerPoint"
  158. :zoom="15"
  159. style="width: 100%; height: 400px"
  160. >
  161. <!--站点-->
  162. <el-amap-marker
  163. :zIndex="1"
  164. v-for="station in stationList"
  165. :key="station.id"
  166. :position="station.position"
  167. :title="station.title"
  168. ></el-amap-marker>
  169. <!--路线-->
  170. <el-amap-polyline
  171. :path="mapPath"
  172. :zIndex="2"
  173. :isOutline="true"
  174. :outlineColor="'#ffeeff'"
  175. :borderWeight="3"
  176. :strokeColor="'#3366FF'"
  177. :strokeOpacity="1"
  178. :strokeWeight="6"
  179. :strokeStyle="'solid'"
  180. :strokeDasharray="[10, 5]"
  181. :lineJoin="'round'"
  182. :lineCap="'round'"
  183. :editable="true"
  184. ></el-amap-polyline>
  185. </el-amap>
  186. <span slot="footer" class="dialog-footer">
  187. <el-button @click="handleConnectStation()">站点连线</el-button>
  188. <el-button @click="handleMapPathConfirm()">确定</el-button>
  189. <el-button @click="showMapDialog = false">关闭</el-button>
  190. </span>
  191. </el-dialog>
  192. <el-dialog
  193. title="导入"
  194. :visible.sync="batchImportVisible"
  195. :modal-append-to-body="false"
  196. style="text-align: left"
  197. :close-on-click-modal="false"
  198. >
  199. <el-form label-width="150px">
  200. <el-form-item label="模板下载">
  201. <el-link
  202. href="http://rccs.oss-cn-hangzhou.aliyuncs.com/smart-bus/excel/routeInfo.xls"
  203. type="primary"
  204. target="_blank"
  205. >点击下载模板</el-link
  206. >
  207. </el-form-item>
  208. <el-form-item label="上传文件">
  209. <el-upload
  210. class="upload-demo"
  211. accept=".xls"
  212. :action="uploadUrlXls"
  213. :data="uploadXlsData"
  214. :headers="headers"
  215. :on-preview="handleBatchImportPreview"
  216. name="uploadFile"
  217. :multiple="true"
  218. :limit="1"
  219. :on-remove="handleBatchImportRemove"
  220. :before-remove="beforeBatchImportRemove"
  221. :before-upload="beforeUpload"
  222. :on-exceed="handleBatchImportExceed"
  223. :on-success="handleBatchImportSuccess"
  224. :file-list="batchImportFileList"
  225. >
  226. <el-button size="small" type="primary" :loading="xlsLoading"
  227. >点击上传</el-button
  228. >
  229. <div slot="tip" class="el-upload__tip">
  230. 只能上传xls文件,且不超过500kb
  231. </div>
  232. </el-upload>
  233. </el-form-item>
  234. </el-form>
  235. <div slot="footer" class="dialog-footer">
  236. <el-button type="primary" @click="batchImportVisible = false"
  237. >关 闭</el-button
  238. >
  239. </div>
  240. </el-dialog>
  241. <!--批量导入E-->
  242. </div>
  243. </template>
  244. <script>
  245. import Constant from "@/constant";
  246. import routeInfoDetail from "./routeInfo-detail";
  247. import routeInfoApi from "@/api/bus/routeInfo";
  248. import SelectTree from "@/components/SelectTree";
  249. import companyInfoApi from "@/api/bus/companyInfo";
  250. import { getToken } from "@/utils/auth"; // get token from cookie
  251. import "nprogress/nprogress.css"; // progress bar style
  252. export default {
  253. name: "BusDriverInfoList",
  254. data() {
  255. var self = this;
  256. return {
  257. activeName: "list",
  258. queryModel: {
  259. name: "",
  260. companyId: "",
  261. },
  262. loading: false,
  263. tableData: [],
  264. treeData: [],
  265. pageIndex: 1,
  266. pageSize: 10,
  267. totalPages: 0,
  268. totalElements: 0,
  269. field: "",
  270. direction: "",
  271. pageSizeList: [10, 20, 30],
  272. multipleSelection: [],
  273. showModal: false,
  274. modalTitle: "",
  275. businessKey: "",
  276. tableHeight: 300,
  277. showDeviceModal: false,
  278. companyId: "",
  279. qrCode: "",
  280. companyResult: [],
  281. props: {
  282. // 配置项(必选)
  283. value: "id",
  284. label: "name",
  285. children: "children",
  286. },
  287. batchImportVisible: false,
  288. batchImportFileList: [],
  289. showMapDialog: false,
  290. showPriceModal: false,
  291. uploadUrlXls: Constant.serverUrl + "/bus/routeInfo/importXls",
  292. uploadXlsData: {
  293. subFolder: "driver",
  294. },
  295. headers: {
  296. Authorization: getToken(),
  297. },
  298. xlsLoading: false,
  299. sceneData: [],
  300. typeData: [],
  301. selectRoute: null,
  302. centerPoint: [112.276585, 30.306401],
  303. stationList: [
  304. { id: 1, position: [112.276585, 30.306401], content: "" },
  305. { id: 2, position: [112.275276, 30.306827], content: "" },
  306. ],
  307. mapPath: [
  308. [112.276585, 30.306401],
  309. [112.275276, 30.306827],
  310. ],
  311. mapLoading: false,
  312. plugin: [
  313. {
  314. pName: "ToolBar",
  315. events: {
  316. init(instance) {
  317. console.log(instance);
  318. },
  319. },
  320. },
  321. ],
  322. };
  323. },
  324. created() {
  325. var self = this;
  326. companyInfoApi.treeList().then(function (response) {
  327. var jsonData = response.data;
  328. if (jsonData.result) {
  329. self.companyResult = jsonData.data;
  330. }
  331. });
  332. this.changePage(1);
  333. },
  334. methods: {
  335. changePage(pageIndex) {
  336. var self = this;
  337. self.loading = true;
  338. self.pageIndex = pageIndex;
  339. var formData = new FormData();
  340. formData.append("pageIndex", self.pageIndex);
  341. formData.append("pageSize", self.pageSize);
  342. if (self.queryModel.companyId != null) {
  343. formData.append("companyId", self.queryModel.companyId);
  344. }
  345. formData.append("name", self.queryModel.name);
  346. routeInfoApi
  347. .pageList(formData)
  348. .then(function (response) {
  349. self.loading = false;
  350. var jsonData = response.data.data;
  351. self.tableData = jsonData.data;
  352. self.totalPages = jsonData.totalPages;
  353. self.totalElements = jsonData.recordsTotal;
  354. //45为分页栏的高度
  355. //页面高度-列表上面的高度-分页栏高度
  356. self.tableHeight =
  357. window.innerHeight - self.$refs.formTable.$el.offsetTop - 100;
  358. })
  359. .catch((error) => {
  360. self.loading = false;
  361. // self.$message.error(error + "");
  362. });
  363. },
  364. pageSizeChange(pageSize) {
  365. this.pageSize = pageSize;
  366. },
  367. sortChange(data) {
  368. this.field = data.column.field;
  369. this.direction = data.order == "ascending" ? "asc" : "desc";
  370. this.changePage(this.pageIndex);
  371. },
  372. handleSelectionChange(val) {
  373. this.multipleSelection = val;
  374. },
  375. handleReset(name) {
  376. this.$refs[name].resetFields();
  377. this.queryModel.companyId = "";
  378. },
  379. handleAdd() {
  380. this.modalTitle = "新增";
  381. this.businessKey = "";
  382. this.showModal = true;
  383. },
  384. handleEdit(record) {
  385. this.modalTitle = "编辑";
  386. this.businessKey = record.id;
  387. this.showModal = true;
  388. },
  389. handleDelete(record) {
  390. var self = this;
  391. self
  392. .$confirm("是否确认删除?", "提示", {
  393. confirmButtonText: "确定",
  394. cancelButtonText: "取消",
  395. type: "warning",
  396. })
  397. .then(() => {
  398. routeInfoApi.remove(record.id).then(function (response) {
  399. var jsonData = response.data;
  400. if (jsonData.result) {
  401. // var index = self.tableData.indexOf(record);
  402. // self.tableData.splice(index, 1);
  403. self.changePage(self.pageIndex);
  404. self.$message({
  405. type: "success",
  406. message: "删除成功!",
  407. });
  408. }
  409. });
  410. });
  411. },
  412. handleBatchDelete() {
  413. var self = this;
  414. var idList = this.multipleSelection.map((record) => {
  415. return record.id;
  416. });
  417. this.$confirm("是否确认删除选中项?", "提示", {
  418. confirmButtonText: "确定",
  419. cancelButtonText: "取消",
  420. type: "warning",
  421. }).then(() => {
  422. routeInfoApi.batchRemove(idList).then(function (response) {
  423. var jsonData = response.data;
  424. if (jsonData.result) {
  425. self.changePage(self.pageIndex);
  426. self.$message({
  427. type: "success",
  428. message: "删除成功!",
  429. });
  430. }
  431. });
  432. });
  433. },
  434. onDetailModalClose(refreshed) {
  435. //保存成功后回调
  436. this.showModal = false;
  437. this.showDeviceModal = false;
  438. this.showPriceModal = false;
  439. if (refreshed) {
  440. this.changePage(this.pageIndex);
  441. }
  442. },
  443. beforeUpload(file, fileList) {
  444. //导入前判断
  445. },
  446. //批量导入-上传成功
  447. handleBatchImportSuccess(response, file, fileList) {
  448. var self = this;
  449. self.xlsLoading = false;
  450. if (response.result) {
  451. self.$message.success(response.message);
  452. this.batchImportFileList = [];
  453. this.changePage(1);
  454. this.uploadCompanyId = "";
  455. this.uploadXlsData.companyId = "";
  456. this.batchImportVisible = false;
  457. } else {
  458. //this.$message.error(response.message);
  459. this.batchImportFileList = [];
  460. this.changePage(1);
  461. this.uploadCompanyId = "";
  462. this.uploadXlsData.companyId = "";
  463. if (response.data != null) {
  464. //下载有错误信息提示的报表
  465. //window.open(response.data);
  466. self.$message({
  467. showClose: true,
  468. dangerouslyUseHTMLString: true,
  469. message:
  470. response.message +
  471. `,<a href="${response.data}" target="_blank">点击下载未导入的数据报表</a>&nbsp;`,
  472. duration: 30000,
  473. });
  474. }
  475. }
  476. },
  477. //批量导入-预览
  478. handleBatchImportPreview(file) {
  479. console.log(file.url);
  480. },
  481. //批量导入-移除
  482. handleBatchImportRemove(file, fileList) {
  483. console.log(file, fileList);
  484. },
  485. //批量导入-移除前操作
  486. beforeBatchImportRemove(file, fileList) {
  487. console.log(file, fileList);
  488. },
  489. //批量导入-文件超出个数限制时的钩子
  490. handleBatchImportExceed(files, fileList) {
  491. this.$message.warning(
  492. `当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
  493. files.length + fileList.length
  494. } 个文件`
  495. );
  496. },
  497. handleMapPathConfirm() {
  498. this.mapLoading = true;
  499. var pathList = this.mapPath.map((item) => {
  500. return item.lng + "," + item.lat;
  501. });
  502. routeInfoApi
  503. .updateMapPath({
  504. id: this.selectRoute.id,
  505. pathList: pathList,
  506. })
  507. .then((response) => {
  508. this.mapLoading = false;
  509. var jsonData = response.data;
  510. if (jsonData.result) {
  511. this.showMapDialog = false;
  512. this.$message.success("保存成功!");
  513. } else {
  514. this.$message.warning("系统错误!" + jsonData.message);
  515. }
  516. });
  517. },
  518. handleConnectStation() {
  519. this.$confirm("是否确认根据站点重新绘制路线?", "提示", {
  520. confirmButtonText: "确定",
  521. cancelButtonText: "取消",
  522. type: "warning",
  523. }).then(() => {
  524. this.mapPath = [];
  525. this.stationList.forEach((item) => {
  526. this.mapPath.push(item.position);
  527. });
  528. });
  529. },
  530. handleEditPath(row) {
  531. //读取当前路线的站点
  532. this.loading = true;
  533. routeInfoApi.edit(row.id).then((response) => {
  534. this.loading = false;
  535. var jsonData = response.data;
  536. var model = jsonData.data;
  537. var _stationList = model.stationList;
  538. if (model.pathList != null) {
  539. this.mapPath = model.pathList.map((item) => {
  540. return item.split(",");
  541. });
  542. this.centerPoint = this.mapPath[0];
  543. } else {
  544. this.mapPath = [];
  545. }
  546. if (_stationList.length <= 1) {
  547. this.$message.warning("请先至少设置2个站点!");
  548. } else {
  549. this.selectRoute = row;
  550. this.showMapDialog = true;
  551. this.stationList = [];
  552. var initMapPath = this.mapPath.length == 0;
  553. _stationList.forEach((item) => {
  554. if (item.location != null && item.location.length > 0) {
  555. var station = {
  556. id: item.id,
  557. title: item.name,
  558. position: item.location.split(","),
  559. };
  560. this.stationList.push(station);
  561. if (initMapPath) {
  562. this.mapPath.push(station.position);
  563. }
  564. }
  565. });
  566. if (this.mapPath.length > 0) {
  567. this.centerPoint = this.mapPath[0];
  568. }
  569. }
  570. });
  571. },
  572. handleEditPrice(record) {
  573. var path = "/bus/routeInfo/priceList";
  574. this.$store.dispatch('tagsView/delView', {
  575. name: "BusRouteInfoList",
  576. path: path
  577. }).then(({ visitedViews }) => {
  578. this.$router.push({
  579. path: path,
  580. query:{
  581. routeId: record.id
  582. }
  583. });
  584. });
  585. },
  586. },
  587. mounted: function () {},
  588. components: {
  589. "routeInfo-detail": routeInfoDetail,
  590. "el-select-tree": SelectTree,
  591. },
  592. };
  593. </script>
  594. <style lang="scss" scoped>
  595. .el-breadcrumb {
  596. margin: 10px;
  597. line-height: 20px;
  598. }
  599. .el-divider {
  600. margin: 5px 0;
  601. }
  602. .demo-form-inline {
  603. margin-left: 10px;
  604. text-align: left;
  605. }
  606. .button-group {
  607. margin-left: 10px;
  608. text-align: left;
  609. }
  610. </style>