routeInfo-price-list.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <div>
  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="#">站点费用管理</a>
  10. </el-breadcrumb-item>
  11. </el-breadcrumb>
  12. <el-divider></el-divider>
  13. <el-row class="button-group">
  14. <el-button
  15. type="primary"
  16. size="small"
  17. icon="ios-search"
  18. @click="changePage()"
  19. :loading="loading"
  20. >刷新</el-button
  21. >
  22. <el-button
  23. type="primary"
  24. size="small"
  25. icon="ios-search"
  26. @click="editPrice()"
  27. :loading="loading"
  28. >编辑</el-button
  29. >
  30. <el-button
  31. type="primary"
  32. size="small"
  33. plain
  34. icon="el-icon-upload2"
  35. @click="batchImportVisible = true"
  36. >导入</el-button
  37. >
  38. <el-button
  39. type="primary"
  40. size="small"
  41. plain
  42. icon="el-icon-download"
  43. :loading="xlsLoading"
  44. @click="downloadAll"
  45. >导出数据</el-button>
  46. </el-row>
  47. <el-table
  48. :data="tableData"
  49. style="min-height: 400px"
  50. v-loading="loading"
  51. stripe
  52. @selection-change="handleSelectionChange"
  53. >
  54. <el-table-column
  55. type="index"
  56. label="序号"
  57. :index="indexMethod"
  58. width="50"
  59. ></el-table-column>
  60. <el-table-column prop="name" label="站名" width="200px"></el-table-column>
  61. <template v-for="col in stationPriceColumns">
  62. <el-table-column
  63. :label="col.name"
  64. :prop="col.id"
  65. :key="col.id"
  66. width="200px"
  67. >
  68. <template slot-scope="{ row }">
  69. <div style="display: flex; flex-direction: column">
  70. <template v-for="(item, index) in row.stationPriceMap[col.id]">
  71. <div v-html="showItem(item, col.id)" :key="index"></div>
  72. </template>
  73. </div>
  74. </template>
  75. </el-table-column>
  76. </template>
  77. </el-table>
  78. <!-- 批量导入s -->
  79. <el-dialog
  80. title="导入"
  81. :visible.sync="batchImportVisible"
  82. :modal-append-to-body="false"
  83. style="text-align: left"
  84. :close-on-click-modal="false"
  85. >
  86. <el-form label-width="150px">
  87. <el-form-item label="模板下载">
  88. <el-link
  89. href="http://ipcps.oss-cn-hangzhou.aliyuncs.com/upload/picture/2019/4/importTemplate.xlsx"
  90. type="primary"
  91. target="_blank"
  92. >点击下载模板</el-link
  93. >
  94. </el-form-item>
  95. <el-form-item label="上传文件">
  96. <el-upload
  97. class="upload-demo"
  98. accept=".xlsx"
  99. :action="uploadUrlXls"
  100. :data="uploadXlsData"
  101. :headers="headers"
  102. :on-preview="handleBatchImportPreview"
  103. name="uploadFile"
  104. :multiple="true"
  105. :limit="1"
  106. :on-remove="handleBatchImportRemove"
  107. :before-remove="beforeBatchImportRemove"
  108. :before-upload="beforeUpload"
  109. :on-exceed="handleBatchImportExceed"
  110. :on-success="handleBatchImportSuccess"
  111. :file-list="batchImportFileList"
  112. >
  113. <el-button size="small" type="primary" :loading="xlsLoading"
  114. >点击上传</el-button
  115. >
  116. <div slot="tip" class="el-upload__tip">
  117. 只能上传xlsx文件,且不超过500kb
  118. </div>
  119. </el-upload>
  120. </el-form-item>
  121. </el-form>
  122. <div slot="footer" class="dialog-footer">
  123. <el-button type="primary" @click="batchImportVisible = false"
  124. >关 闭</el-button
  125. >
  126. </div>
  127. </el-dialog>
  128. <!--批量导入E-->
  129. <routeInfo-price-detail
  130. v-if="showModal"
  131. :title="modalTitle"
  132. :routeId="routeId"
  133. @close="onDetailModalClose"
  134. ></routeInfo-price-detail>
  135. </div>
  136. </template>
  137. <script>
  138. import Constant from "@/constant";
  139. import priceDetail from "./routeInfo-price-detail";
  140. import shiftInfoApi from "@/api/bus/shiftInfo";
  141. import passengerInfoApi from "@/api/bus/passengerInfo";
  142. import priceInfoApi from "@/api/bus/priceInfo";
  143. import { getToken } from "@/utils/auth"; // get token from cookie
  144. export default {
  145. props: ["businessKey", "title"],
  146. data() {
  147. return {
  148. queryModel: {
  149. vehicleShiftId: "",
  150. vehiclePersonId: "",
  151. userId: "",
  152. userName: "",
  153. status: "",
  154. payStatus: "",
  155. },
  156. loading: false,
  157. tableData: [],
  158. pageIndex: 1,
  159. pageSize: 5,
  160. totalPages: 0,
  161. totalElements: 0,
  162. field: "",
  163. direction: "",
  164. pageSizeList: [5, 15, 30],
  165. multipleSelection: [],
  166. showModal: false,
  167. modalTitle: "",
  168. showDialog: true,
  169. stationPriceColumns: [],
  170. batchImportVisible: false,
  171. routeId:"",
  172. uploadUrlXls: Constant.serverUrl + "/bus/priceInfo/importXls",
  173. uploadXlsData: {
  174. subFolder: "driver",
  175. routeId:""
  176. },
  177. headers: {
  178. Authorization: getToken(),
  179. },
  180. batchImportFileList:[],
  181. xlsLoading:false,
  182. };
  183. },
  184. methods: {
  185. indexMethod(index) {
  186. return (this.pageIndex - 1) * this.pageSize + (index + 1);
  187. },
  188. changePage() {
  189. var self = this;
  190. self.loading = true;
  191. var formData = new FormData();
  192. formData.append("routeId", self.routeId);
  193. priceInfoApi
  194. .searchRoutePrice(formData)
  195. .then(function (response) {
  196. self.loading = false;
  197. var jsonData = response.data;
  198. self.tableData = jsonData.stationInfoList;
  199. self.stationPriceColumns = jsonData.stationPriceColumns;
  200. })
  201. .catch((error) => {
  202. self.loading = false;
  203. // self.$message.error(error + "");
  204. });
  205. },
  206. handleSelectionChange(val) {
  207. this.multipleSelection = val;
  208. },
  209. handleReset(name) {
  210. this.$refs[name].resetFields();
  211. },
  212. editPrice() {
  213. this.modalTitle = "编辑";
  214. this.routeId = this.routeId;
  215. this.showModal = true;
  216. },
  217. closeDialog() {
  218. this.$emit("close", false);
  219. },
  220. onDetailModalClose(refreshed) {
  221. //保存成功后回调
  222. this.showModal = false;
  223. if (refreshed) {
  224. this.changePage();
  225. }
  226. },
  227. showItem(item, id) {
  228. return item;
  229. },
  230. beforeUpload(file, fileList) {
  231. //导入前判断
  232. var self = this;
  233. self.uploadXlsData.routeId = self.routeId;
  234. self.xlsLoading = true;
  235. self.loading = true;
  236. },
  237. //批量导入-上传成功
  238. handleBatchImportSuccess(response, file, fileList) {
  239. var self = this;
  240. self.xlsLoading = false;
  241. self.loading = false;
  242. if (response.result) {
  243. self.$message.success(response.message);
  244. this.batchImportFileList = [];
  245. this.changePage();
  246. this.uploadCompanyId = "";
  247. this.uploadXlsData.companyId = "";
  248. this.batchImportVisible = false;
  249. } else {
  250. //this.$message.error(response.message);
  251. this.batchImportFileList = [];
  252. this.changePage();
  253. if (response.data != null) {
  254. //下载有错误信息提示的报表
  255. //window.open(response.data);
  256. self.$message({
  257. showClose: true,
  258. dangerouslyUseHTMLString: true,
  259. message:
  260. response.message +
  261. `,<a href="${response.data}" target="_blank">点击下载未导入的数据报表</a>&nbsp;`,
  262. duration: 30000,
  263. });
  264. }
  265. }
  266. },
  267. //批量导入-预览
  268. handleBatchImportPreview(file) {
  269. console.log(file.url);
  270. },
  271. //批量导入-移除
  272. handleBatchImportRemove(file, fileList) {
  273. console.log(file, fileList);
  274. },
  275. //批量导入-移除前操作
  276. beforeBatchImportRemove(file, fileList) {
  277. console.log(file, fileList);
  278. },
  279. //批量导入-文件超出个数限制时的钩子
  280. handleBatchImportExceed(files, fileList) {
  281. this.$message.warning(
  282. `当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
  283. files.length + fileList.length
  284. } 个文件`
  285. );
  286. },
  287. downloadAll() {
  288. //导出
  289. var self = this;
  290. var formData = new FormData();
  291. formData.append("routeId", self.routeId);
  292. self.xlsLoading = true;
  293. self.loading = true;
  294. priceInfoApi.exportXls(formData).then(function (response) {
  295. self.xlsLoading = false;
  296. self.loading = false;
  297. var jsonData = response.data;
  298. if (jsonData.result) {
  299. if (jsonData.data != null) {
  300. self.$message({
  301. showClose: true,
  302. type: "success",
  303. dangerouslyUseHTMLString: true,
  304. message: `报表已生成,<a href="${jsonData.data}" target="_blank">点击下载报表</a>&nbsp;`,
  305. duration: 30000,
  306. });
  307. }
  308. }
  309. });
  310. },
  311. },
  312. mounted: function () {
  313. var routeId = this.$route.query.routeId;
  314. this.routeId = routeId;
  315. this.changePage();
  316. },
  317. components: {
  318. "routeInfo-price-detail": priceDetail,
  319. },
  320. };
  321. </script>
  322. <style scoped>
  323. .el-divider {
  324. margin: 5px 0;
  325. }
  326. .el-breadcrumb {
  327. margin: 10px;
  328. line-height: 20px;
  329. }
  330. .order-list {
  331. text-align: left;
  332. }
  333. .button-group {
  334. padding: 10px;
  335. text-align: left;
  336. }
  337. </style>