transportPrice.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. <template>
  2. <!-- 汽运单价页面 -->
  3. <div class="salePlan">
  4. <div class="top">
  5. <el-input placeholder="请输入内容" v-model="input" clearable> </el-input>
  6. <el-button type="primary" class="btn" @click="onclick" :loading="loading">
  7. <i class="el-icon-search"></i>查询
  8. </el-button>
  9. <el-button type="primary" @click="btnclick(0)">
  10. <i class="el-icon-plus"></i>新增
  11. </el-button>
  12. <el-button type="primary" @click="exportAllExcel()"><i class="el-icon-download"></i>导出(Excel)</el-button>
  13. </div>
  14. <el-tabs v-model="activeName">
  15. <!-- 正在启用 -->
  16. <el-tab-pane label="正在启用" name="first">
  17. <dilTable ref="excelDom" v-bind.sync="option" :loading="loading" :isKuang="isKuang" @func="func">
  18. <el-table-column
  19. fixed="right"
  20. label="操作"
  21. width="200px"
  22. align="center"
  23. >
  24. <template slot-scope="scope">
  25. <el-button type="primary" @click="updatePriceclick(scope.row)">修改</el-button>
  26. <el-button type="primary" @click="deletePrice(scope.row)">删除</el-button>
  27. </template>
  28. </el-table-column>
  29. </dilTable>
  30. </el-tab-pane>
  31. <!-- 历史启用 -->
  32. <el-tab-pane label="历史启用" name="second">
  33. <dilTable ref="excelDom" v-bind.sync="option2" :loading="loading" :isKuang="isKuang" @func="func">
  34. </dilTable>
  35. </el-tab-pane>
  36. </el-tabs>
  37. <!-- 承运商模态框 -->
  38. <el-drawer
  39. title="运价修改界面"
  40. :visible.sync="drawer"
  41. direction="rtl"
  42. size="40%"
  43. :show-close="false"
  44. >
  45. <div class="operation1">
  46. <span style="width:10%;align-content: center;">卸货地点</span>
  47. <el-input
  48. v-model="newAddressDeliveryAddress"
  49. style="width:70%"
  50. ></el-input>
  51. <el-button type="primary" style="width:15%" @click="updateAddressDeliveryAddress">提交</el-button>
  52. </div>
  53. <div class="operation2">
  54. <span style="width:10%;align-content: center;">运价</span>
  55. <el-input
  56. v-model="newPriceValue"
  57. style="width:30%"
  58. ></el-input>
  59. <el-button type="primary" style="width:15%" @click="updatePriceValue">提交</el-button>
  60. </div>
  61. <el-input
  62. placeholder="请输入内容"
  63. style="margin-top: 10px; margin-left: 20px;width:250px"
  64. clearable
  65. v-model="index"
  66. >
  67. </el-input
  68. ><el-button
  69. type="primary"
  70. style="margin-left: 4px;"
  71. @click="queryCarrierName"
  72. >
  73. <i class="el-icon-search"></i>查询
  74. </el-button>
  75. <el-button type="primary" @click="updateCarrierNamelist">确定修改承运商</el-button>
  76. <div>
  77. <!-- 查询所有的承运商 -->
  78. <el-table
  79. :data="carrierNameTable"
  80. style="width:100%"
  81. max-height="200px"
  82. :row-key="getRowKeys"
  83. @selection-change="handleSelectionChange"
  84. :border="true"
  85. ref="carrierNameTable"
  86. >
  87. <el-table-column
  88. type="selection"
  89. :reserve-selection="true"
  90. >
  91. </el-table-column>
  92. <el-table-column
  93. type="index"
  94. label="序号"
  95. >
  96. </el-table-column>
  97. <el-table-column
  98. prop="carrierName"
  99. label="承运商"
  100. align="center"
  101. >
  102. </el-table-column>
  103. </el-table>
  104. <el-pagination
  105. @size-change="handleSizeChange"
  106. @current-change="handleCurrentChange"
  107. :current-page="currentPage"
  108. layout="total,prev,pager,next,sizes"
  109. :total="carrierNametotal"
  110. :page-sizes="[10, 50, 100, 1000]"
  111. :page-size="currentPageSize"
  112. >
  113. </el-pagination>
  114. </div>
  115. </el-drawer>
  116. </div>
  117. </template>
  118. <script>
  119. export default {
  120. name: "TransportPrice",
  121. data() {
  122. return {
  123. activeName: "first",
  124. isKuang:false,
  125. loading:false,
  126. input: "",
  127. drawer:false,
  128. //承运商
  129. carrierNameTable:[],
  130. //卸货地点
  131. newAddressDeliveryAddress:'',
  132. //运价
  133. newPriceValue:'',
  134. //执行日期
  135. insertTime:'',
  136. //修改单价或者卸货地址所需信息
  137. datalist:{},
  138. //选中的值
  139. checkedList:[],
  140. //承运商总数目
  141. carrierNametotal:100,
  142. //当前页数
  143. currentPage:1,
  144. //当前页数规格
  145. currentPageSize:10,
  146. //搜索框
  147. index:'',
  148. //承运商的修改
  149. carrierIdArray:[],
  150. option: {
  151. // 表格请求数据的地址
  152. requestUrl:
  153. "/api/v1/ams/getAmsContractTransportPrice1?apiId=109&deleted=0",
  154. },
  155. option2: {
  156. // 表格请求数据的地址
  157. requestUrl:
  158. "/api/v1/ams/getAmsContractTransportPrice1?apiId=109&deleted=1",
  159. },
  160. tableTitle:'汽运单价'
  161. };
  162. },
  163. methods: {
  164. exportAllExcel() {
  165. if (this.activeName == 'first') {
  166. this.tableTitle = '正在启用的运输单价'
  167. this.loading = true;
  168. this.isKuang = true;
  169. if(this.input){
  170. this.axios
  171. .post(
  172. "/api/v1/ams/getAmsContractTransportPrice1?apiId=109&deleted=0&con=" +this.input+"&i="+new Date()
  173. )
  174. .then(res => {
  175. console.log(res.data.data)
  176. this.exportAllList = res.data.data.list
  177. this.noSettleDetailsColumn=res.data.data.columnData
  178. this.exportAllReportToExcel(
  179. this.tableTitle,
  180. this.exportAllList,
  181. this.noSettleDetailsColumn
  182. )
  183. })
  184. }else{
  185. this.axios
  186. .post(
  187. "/api/v1/ams/getAmsContractTransportPrice1?apiId=109&deleted=0&i="+new Date()
  188. )
  189. .then(res => {
  190. console.log(res.data.data)
  191. this.exportAllList = res.data.data.list
  192. this.noSettleDetailsColumn=res.data.data.columnData
  193. this.exportAllReportToExcel(
  194. this.tableTitle,
  195. this.exportAllList,
  196. this.noSettleDetailsColumn
  197. )
  198. })
  199. }
  200. }else if (this.activeName == 'second') {
  201. this.tableTitle = '历史启用的运输单价'
  202. this.loading = true;
  203. this.isKuang = true;
  204. if(this.input){
  205. this.axios
  206. .post(
  207. "/api/v1/ams/getAmsContractTransportPrice1?apiId=109&deleted=1&con=" +this.input+"&i="+new Date()
  208. )
  209. .then(res => {
  210. console.log(res.data.data)
  211. this.exportAllList = res.data.data.list
  212. this.noSettleDetailsColumn=res.data.data.columnData
  213. this.exportAllReportToExcel(
  214. this.tableTitle,
  215. this.exportAllList,
  216. this.noSettleDetailsColumn
  217. )
  218. })
  219. }else{
  220. this.axios
  221. .post(
  222. "/api/v1/ams/getAmsContractTransportPrice1?apiId=109&deleted=1&con=" +this.input+"&i="+new Date()
  223. )
  224. .then(res => {
  225. console.log(res.data.data)
  226. this.exportAllList = res.data.data.list
  227. this.noSettleDetailsColumn=res.data.data.columnData
  228. this.exportAllReportToExcel(
  229. this.tableTitle,
  230. this.exportAllList,
  231. this.noSettleDetailsColumn
  232. )
  233. })
  234. }
  235. } else {
  236. }
  237. this.loading=false
  238. },
  239. //导出excel
  240. exportAllReportToExcel(tableTitle, dataArr, columnData) {
  241. var title = tableTitle
  242. let tHeader = []
  243. let filterVal = []
  244. columnData.forEach(e1 => {
  245. if (tHeader.indexOf(e1.label) === -1) {
  246. tHeader.push(e1.label)
  247. }
  248. if (filterVal.indexOf(e1.prop) === -1) {
  249. filterVal.push(e1.prop)
  250. }
  251. })
  252. //导出为excel
  253. this.downloadLoading = true
  254. require.ensure([], () => {
  255. const {
  256. export_json_to_excel
  257. } = require('@/assets/excel/Export2Excel.js') //这里必须使用绝对路径,使用@/+存放export2Excel的路径
  258. // let list = this.$refs.excelDom.dataTabel;
  259. let data = dataArr.map(v => filterVal.map(j => v[j])) //3.formatJson格式转换
  260. export_json_to_excel(tHeader, data, title) // (title)导出的表格名称
  261. })
  262. },
  263. func(){
  264. this.loading = false;
  265. this.isKuang = false;
  266. },
  267. onclick() {
  268. this.loading = true;
  269. this.isKuang = true;
  270. if(this.input){
  271. this.option.requestUrl ="/api/v1/ams/getAmsContractTransportPrice1?apiId=109&deleted=0&con=" +this.input+"&i="+new Date();
  272. this.option2.requestUrl ="/api/v1/ams/getAmsContractTransportPrice1?apiId=109&deleted=1&con=" +this.input+"&i="+new Date();
  273. }else{
  274. this.option.requestUrl ="/api/v1/ams/getAmsContractTransportPrice1?apiId=109&deleted=0&i="+new Date();
  275. this.option2.requestUrl ="/api/v1/ams/getAmsContractTransportPrice1?apiId=109&deleted=1&con=" +this.input+"&i="+new Date();
  276. }
  277. },
  278. btnclick() {
  279. this.$router.push("/addTransportPrice");
  280. },
  281. updatePriceclick(row) {
  282. this.$router.push({
  283. name:'addTransportPriceNew',
  284. params:{
  285. addressProvince:row.addressProvince,
  286. addressDistrict:row.addressDistrict,
  287. addressTown:row.addressTown,
  288. addressDeliveryAddress:row.addressDeliveryAddress,
  289. priceValue:row.priceValue,
  290. haulDistance:row.haulDistance,
  291. placeId:row.placeId,
  292. priceDate:row.priceDate
  293. }
  294. });
  295. },
  296. //修改运价
  297. //删除运价
  298. deletePrice(row){
  299. let mapValue={
  300. addressProvince:row.addressProvince,
  301. addressDistrict:row.addressDistrict,
  302. addressTown:row.addressTown,
  303. addressDeliveryAddress:row.addressDeliveryAddress
  304. }
  305. this.axios.post("/api/v1/ams/deleteSalelPrice",mapValue)
  306. .then(res=>{
  307. if(res.data.code==200){
  308. this.$message.success("删除成功")
  309. }else{
  310. this.$message.warning("删除失败")
  311. }
  312. })
  313. this.onclick()
  314. },
  315. //修改
  316. async updatePrice(row){
  317. this.drawer=true
  318. this.newAddressDeliveryAddress=row.addressDeliveryAddress
  319. this.newPriceValue=row.priceValue
  320. this.datalist.placeId=row.placeId
  321. this.datalist.addressProvince=row.addressProvince
  322. this.datalist.addressDistrict=row.addressDistrict
  323. this.datalist.addressTown=row.addressTown
  324. this.datalist.addressDeliveryAddress=row.addressDeliveryAddress
  325. let mapValue={
  326. pageSize:this.currentPageSize,
  327. pageNum:this.currentPage,
  328. index:this.index
  329. }
  330. await this.axios.post("/api/v1/ams/getCarrierListByPrice",mapValue).then(res=>{
  331. console.log("进入了查询承运商界面")
  332. console.log(res.data)
  333. this.carrierNameTable=res.data.data
  334. this.carrierNametotal=res.data.data[1].total
  335. })
  336. await this.axios.post("/api/v1/ams/getCarrierListByAddress",this.datalist).
  337. then(res=>{
  338. //this.checkedList=res.data.data
  339. })
  340. //console.log("初始化时选中的数据")
  341. //console.log(this.checkedList)
  342. },
  343. //修改运价
  344. updatePriceValue(){
  345. console.log("查看数据")
  346. console.log(this.newPriceValue)
  347. if(this.newPriceValue==null||this.newPriceValue==""){
  348. this.$message.warning("运价不能为空")
  349. return
  350. }
  351. console.log("进入了修改单价的方法")
  352. this.datalist.newPriceValue=this.newPriceValue
  353. console.log(this.datalist)
  354. this.axios.post("/api/v1/ams/updatePriceValue",this.datalist).
  355. then(res=>{
  356. if(res.data.code==200){
  357. this.$message.success("修改运价成功")
  358. }else{
  359. this.$message.warning("修改运价失败")
  360. }
  361. })
  362. this.onclick()
  363. this.drawer=false
  364. this.$refs.carrierNameTable.clearSelection()
  365. },
  366. //修改卸货地址
  367. updateAddressDeliveryAddress(){
  368. if(this.newAddressDeliveryAddress==null||this.newAddressDeliveryAddress==""){
  369. this.$message.warning("卸货地址不能为空")
  370. return
  371. }
  372. console.log("进入了修改卸货地址的方法")
  373. this.datalist.newAddressDeliveryAddress=this.newAddressDeliveryAddress
  374. console.log(this.datalist)
  375. this.axios.post("/api/v1/ams/updateaddressDeliveryAddress",this.datalist).
  376. then(res=>{
  377. console.log(res)
  378. if(res.data.code==200){
  379. this.$message.success("修改卸货成功")
  380. }else{
  381. this.$message.warning("修改卸货失败")
  382. }
  383. })
  384. this.onclick()
  385. this.drawer=false
  386. this.$refs.carrierNameTable.clearSelection()
  387. },
  388. getRowKeys(row){
  389. return row.carrierId
  390. },
  391. handleSelectionChange(list){
  392. console.log("选中的值")
  393. console.log(list)
  394. this.checkedList=list
  395. console.log(this.checkedList)
  396. },
  397. async handleSizeChange(val) {
  398. console.log(`每页 ${val} 条`);
  399. this.currentPageSize=val
  400. let mapValue={
  401. pageSize:this.currentPageSize,
  402. pageNum:this.currentPage,
  403. index:this.index
  404. }
  405. await this.axios.post("/api/v1/ams/getCarrierListByPrice",mapValue).then(res=>{
  406. console.log("进入了查询承运商界面")
  407. console.log(res.data)
  408. this.carrierNameTable=res.data.data
  409. this.carrierNametotal=res.data.data[1].total
  410. })
  411. },
  412. async handleCurrentChange(val) {
  413. console.log(`当前页: ${val}`);
  414. this.currentPage=val
  415. let mapValue={
  416. pageSize:this.currentPageSize,
  417. pageNum:this.currentPage,
  418. index:this.index
  419. }
  420. await this.axios.post("/api/v1/ams/getCarrierListByPrice",mapValue).then(res=>{
  421. console.log("进入了查询承运商界面")
  422. console.log(res.data)
  423. this.carrierNameTable=res.data.data
  424. this.carrierNametotal=res.data.data[1].total
  425. })
  426. },
  427. async queryCarrierName(){
  428. let mapValue={
  429. pageSize:this.currentPageSize,
  430. pageNum:this.currentPage,
  431. index:this.index
  432. }
  433. await this.axios.post("/api/v1/ams/getCarrierListByPrice",mapValue).then(res=>{
  434. console.log("进入了查询承运商界面")
  435. console.log(res.data)
  436. this.carrierNameTable=res.data.data
  437. this.carrierNametotal=res.data.data[1].total
  438. })
  439. },
  440. //修改承运商
  441. async updateCarrierNamelist(){
  442. for(let i=0;i<this.checkedList.length;i++){
  443. this.carrierIdArray.push(this.checkedList[i].carrierId)
  444. }
  445. this.datalist.carrierIdArray=this.carrierIdArray
  446. await this.axios.post("/api/v1/ams/updateCarrierName",this.datalist).then(res=>{
  447. if(res.data.code==200){
  448. this.$message.success("修改承运商成功")
  449. }else{
  450. this.$message.warning("修改承运商失败")
  451. }
  452. })
  453. console.log("看看数据对不对")
  454. console.log(this.carrierIdArray)
  455. console.log(this.$refs)
  456. this.$refs.carrierNameTable.clearSelection()
  457. this.carrierIdArray=[]
  458. this.drawer=false
  459. this.onclick()
  460. }
  461. /*importExcel(file){
  462. let that = this;
  463. if (!file) {
  464. that.$message({
  465. message: "文件错误!",
  466. type: "warning"
  467. });
  468. return;
  469. }
  470. let excelData =[]
  471. var reader=new FileReader();
  472. var data=null;
  473. var workbook = null;
  474. //设置读取操作
  475. reader.onload = function (e){
  476. console.log(e);
  477. data = e.target.result;
  478. workbook=XLSX.read(data,{type:'binary'});
  479. console.log(workbook)
  480. //只取第一个表的数据
  481. let rows= XLSX.utils.sheet_to_json(
  482. workbook.Sheets[workbook.SheetNames[0]]
  483. );
  484. console.log(rows)
  485. let index=1;
  486. // for (index=1;index<rows.length;index++){
  487. // if (
  488. // typeof workbook.Sheets[workbook.SheetNames[0]]["A"+index] !=
  489. // "undefined"
  490. // ){
  491. // index++;
  492. // break
  493. // }
  494. // }
  495. // console.log("表头行数:" + index);
  496. // if(index>=rows.length){
  497. // that.$message({
  498. // message: "文件错误!",
  499. // type: "warning",
  500. // });
  501. // return
  502. // }
  503. if (
  504. typeof workbook.Sheets[workbook.SheetNames[0]]["A" + index] == 'undefined' ||
  505. typeof workbook.Sheets[workbook.SheetNames[0]]["B" + index] == 'undefined' ||
  506. typeof workbook.Sheets[workbook.SheetNames[0]]["C" + index] == 'undefined' ||
  507. typeof workbook.Sheets[workbook.SheetNames[0]]["D" + index] == 'undefined' ||
  508. typeof workbook.Sheets[workbook.SheetNames[0]]["E" + index] == 'undefined' ||
  509. typeof workbook.Sheets[workbook.SheetNames[0]]["F" + index] == 'undefined' ||
  510. typeof workbook.Sheets[workbook.SheetNames[0]]["G" + index] == 'undefined' ||
  511. typeof workbook.Sheets[workbook.SheetNames[0]]["H" + index] == 'undefined' ||
  512. workbook.Sheets[workbook.SheetNames[0]]["A" + index].v != "序号" ||
  513. workbook.Sheets[workbook.SheetNames[0]]["B" + index].v != "省份" ||
  514. workbook.Sheets[workbook.SheetNames[0]]["C" + index].v != "市/区" ||
  515. workbook.Sheets[workbook.SheetNames[0]]["D" + index].v != "县/镇" ||
  516. workbook.Sheets[workbook.SheetNames[0]]["E" + index].v != "卸货地点" ||
  517. workbook.Sheets[workbook.SheetNames[0]]["F" + index].v != "参考运距(公里)" ||
  518. workbook.Sheets[workbook.SheetNames[0]]["G" + index].v != "运价(元/吨)" ||
  519. workbook.Sheets[workbook.SheetNames[0]]["H" + index].v != "吨公里(元/吨.km)"
  520. ){
  521. if (
  522. typeof workbook.Sheets[workbook.SheetNames[0]]["A" + index] == 'undefined' ||
  523. workbook.Sheets[workbook.SheetNames[0]]["A" + index].v != "序号"
  524. ) {
  525. that.$message({
  526. message: "表格格式错误:序号错误",
  527. type: "warning"
  528. });
  529. }
  530. if (
  531. typeof workbook.Sheets[workbook.SheetNames[0]]["B" + index] == 'undefined' ||
  532. workbook.Sheets[workbook.SheetNames[0]]["B" + index].v != "省份"
  533. ) {
  534. that.$message({
  535. message: "表格格式错误:省份错误",
  536. type: "warning"
  537. });
  538. }
  539. if (
  540. typeof workbook.Sheets[workbook.SheetNames[0]]["C" + index] == 'undefined' ||
  541. workbook.Sheets[workbook.SheetNames[0]]["C" + index].v != "市/区"
  542. ) {
  543. that.$message({
  544. message: "表格格式错误:市/区错误",
  545. type: "warning"
  546. });
  547. }
  548. if (
  549. typeof workbook.Sheets[workbook.SheetNames[0]]["D" + index] == 'undefined' ||
  550. workbook.Sheets[workbook.SheetNames[0]]["D" + index].v != "县/镇"
  551. ) {
  552. that.$message({
  553. message: "表格格式错误:县/镇错误",
  554. type: "warning"
  555. });
  556. }
  557. if (
  558. typeof workbook.Sheets[workbook.SheetNames[0]]["E" + index] == 'undefined' ||
  559. workbook.Sheets[workbook.SheetNames[0]]["E" + index].v != "卸货地点"
  560. ) {
  561. that.$message({
  562. message: "表格格式错误:卸货地点错误",
  563. type: "warning"
  564. });
  565. }
  566. if (
  567. typeof workbook.Sheets[workbook.SheetNames[0]]["F" + index] == 'undefined' ||
  568. workbook.Sheets[workbook.SheetNames[0]]["F" + index].v != "参考运距(公里)"
  569. ) {
  570. that.$message({
  571. message: "表格格式错误:参考运距(公里)错误",
  572. type: "warning"
  573. });
  574. }
  575. if (
  576. typeof workbook.Sheets[workbook.SheetNames[0]]["G" + index] == 'undefined' ||
  577. workbook.Sheets[workbook.SheetNames[0]]["G" + index].v != "运价(元/吨)"
  578. ) {
  579. that.$message({
  580. message: "表格格式错误:运价(元/吨)错误",
  581. type: "warning"
  582. });
  583. }
  584. if (
  585. typeof workbook.Sheets[workbook.SheetNames[0]]["G" + index] == 'undefined' ||
  586. workbook.Sheets[workbook.SheetNames[0]]["H" + index].v != "吨公里(元/吨.km)"
  587. ) {
  588. that.$message({
  589. message: "表格格式错误:吨公里(元/吨.km)错误",
  590. type: "warning"
  591. });
  592. }
  593. }
  594. //读取表格
  595. for (let i = index+1; i <= rows.length+1 ; i++){
  596. console.log(workbook.Sheets[workbook.SheetNames[0]]["B" + i].v)
  597. }
  598. }
  599. reader.readAsBinaryString(file.raw);
  600. }*/
  601. },
  602. };
  603. </script>
  604. <style lang='scss' scoped>
  605. .salePlan {
  606. .top{
  607. padding: 1.25rem 0.375rem;
  608. .el-input {
  609. width: 20%;
  610. margin-right: 1.25rem;
  611. }
  612. }
  613. .operation1{
  614. display: flex;
  615. flex-direction: row;
  616. margin-bottom: 20px;
  617. }
  618. .operation2{
  619. display: flex;
  620. flex-direction: row;
  621. margin-bottom: 20px;
  622. }
  623. }
  624. </style>