addTransportPrice.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. <template>
  2. <!-- 添加汽运单价 111-->
  3. <div class="addTransportPrice">
  4. <page-title>新增</page-title>
  5. <div class="form">
  6. <div class="form_box">
  7. <dil-form :formId="287" v-model="form1" ref="from1"></dil-form>
  8. <label>运输距离:</label><el-input type="number" v-model="haulDistance" class="el-input"></el-input>
  9. </div>
  10. <div id="liulan">
  11. <el-button type="primary" class="btn" @click="oilPriceFormulaClick">浏览</el-button>
  12. <el-button type="primary" class="btn1" @click="ondrawerOut">浏览</el-button>
  13. <!-- <el-button type="primary" class="btn1" @click="addressClick">浏览</el-button> -->
  14. </div>
  15. </div>
  16. <div class="elForm">
  17. <el-form :inline="true" class="demo-form-inline" label-width="80px">
  18. <el-button type="primary" id="cysbutton" @click="ondrawerOutcys">浏览所属承运商</el-button>
  19. </el-form>
  20. </div>
  21. <!-- 油价联动公式模态框 -->
  22. <el-drawer
  23. title="请选择油价联动公式"
  24. :visible.sync="oilPriceFormulaDrawer"
  25. :direction="direction"
  26. :before-close="handleClose"
  27. close-on-press-escape
  28. modal
  29. wrapperClosable
  30. size="70%"
  31. >
  32. <div class="selectText">
  33. <!-- <span></span> -->
  34. <el-input v-model="LineText" placeholder="请输入内容"></el-input>
  35. <el-button type="primary" @click="selectLineClick" :loading="selectLineLoading"><i class="el-icon-search"></i>查询</el-button>
  36. <el-button type="primary" @click="addoilPriceFormula">确定</el-button>
  37. </div>
  38. <div class="LineTable">
  39. <vue-scroll :ops="ops" style="width:100%;height:100%">
  40. <dilTable
  41. v-bind.sync="oilPriceFormula"
  42. @radio-change="currentRadioChange"
  43. :isKuang="isKuang"
  44. :loading="tableLoading"
  45. :drawer="oilPriceFormulaDrawer"
  46. @func="func"
  47. ></dilTable>
  48. </vue-scroll>
  49. </div>
  50. </el-drawer>
  51. <!-- 收货地址弹出框 -->
  52. <el-dialog title="收货地址" :visible.sync="drawer1" width="90%">
  53. <el-form :inline="true">
  54. <el-form-item>
  55. <label class="el-form-item__label" style="width: auto;">省</label>
  56. <el-select v-model="province" filterable placeholder="请选择" @change="onchangeProvince">
  57. <el-option v-for="item in provinceList" :key="item.id" :label="item.addressProvince" :value="item.id"></el-option>
  58. </el-select>
  59. </el-form-item>
  60. <el-form-item>
  61. <label class="el-form-item__label" style="width: auto;">市</label>
  62. <el-select v-model="city" filterable placeholder="请选择" @change="onchangeCity">
  63. <el-option v-for="item in cityList" :key="item.id" :label="item.addressDistrict" :value="item.id"></el-option>
  64. </el-select>
  65. </el-form-item>
  66. <el-form-item>
  67. <label class="el-form-item__label" style="width: auto;">县(区)</label>
  68. <el-select v-model="county" filterable placeholder="请选择" @change="onchangeCounty">
  69. <el-option v-for="item in countyList" :key="item.id" :label="item.addressTown" :value="item.id"></el-option>
  70. </el-select>
  71. </el-form-item>
  72. <el-form-item>
  73. <label class="el-form-item__label" style="width: auto;">具体收货地址</label>
  74. <el-autocomplete
  75. class="inline-input"
  76. v-model="place"
  77. :fetch-suggestions="querySearch1"
  78. placeholder="请输入具体收货地址"
  79. :trigger-on-focus="false"
  80. @select="handleSelect1"
  81. >
  82. </el-autocomplete>
  83. </el-form-item>
  84. </el-form>
  85. <div slot="footer" class="button-box">
  86. <el-button @click="drawer1 = false">取 消</el-button>
  87. <el-button type="primary" @click="specificAddress">确定</el-button>
  88. </div>
  89. </el-dialog>
  90. <!-- 承运商模态框 -->
  91. <el-drawer
  92. title="选择承运商"
  93. :visible.sync="drawer"
  94. direction="rtl"
  95. size="40%"
  96. :show-close="false"
  97. >
  98. <el-input
  99. placeholder="请输入内容"
  100. v-model="index"
  101. style="margin-top: 10px; margin-left: 20px;width:250px"
  102. clearable
  103. >
  104. </el-input
  105. ><el-button
  106. type="primary"
  107. class="btn"
  108. @click="onclickCarrier"
  109. style="margin-left: 4px;"
  110. >
  111. <i class="el-icon-search"></i>查询
  112. </el-button>
  113. <!-- <el-button @click="open">取消</el-button> -->
  114. <el-button type="primary" @click="selectMakeSure">确定</el-button>
  115. <div class="tablecls">
  116. <!-- 查询所有的承运商 -->
  117. <dilTable
  118. v-bind.sync="carrier"
  119. @selection-change="currentRadioChangecys"
  120. :drawer="drawer"
  121. >
  122. </dilTable>
  123. </div>
  124. </el-drawer>
  125. <!-- 所属承运商表格 -->
  126. <div class="selectionTable from">
  127. <el-table
  128. :data="selectionList"
  129. border
  130. style="width: 100%"
  131. highlight-current-row
  132. >
  133. <el-table-column type="index" label="序号" width="50">
  134. </el-table-column>
  135. <el-table-column
  136. v-for="(item, i) in tableTop"
  137. :key="i"
  138. :prop="item.prop"
  139. :label="item.label"
  140. :width="item.width"
  141. align="center"
  142. show-overflow-tooltip
  143. >
  144. </el-table-column>
  145. <!-- 操作列 -->
  146. <el-table-column fixed="right" label="操作" width="100">
  147. <template slot-scope="scope">
  148. <el-button
  149. @click="deleteRow(scope.$index)"
  150. type="text"
  151. icon="el-icon-close"
  152. size="big"
  153. ></el-button>
  154. </template>
  155. </el-table-column>
  156. </el-table>
  157. </div>
  158. <div class="button_box">
  159. <el-button @click="cancel">取消</el-button>
  160. <el-button type="primary" @click="makeSure">确定</el-button>
  161. </div>
  162. </div>
  163. </template>
  164. <script>
  165. import PageTitle from "@/components/Page/Title";
  166. import { sjTime,isNumber } from "@/utils/sharedJsFile";
  167. export default {
  168. components: { PageTitle },
  169. data() {
  170. return {
  171. haulDistance:"",
  172. carrierIdArray:[],
  173. tableTop: [
  174. {
  175. prop: "carrierName",
  176. label: "承运商"
  177. }
  178. ],
  179. selectionList: [],
  180. carrierTypes:[],
  181. carrier: {
  182. requestUrl: "",
  183. selectionType: "select"
  184. },
  185. //是否显示承运商模态框
  186. drawer: false,
  187. index: "",
  188. //具体收货地址
  189. place:null,
  190. //承运商名称
  191. state: null,
  192. //承运商id
  193. carrierIds: null,
  194. //收货地址id
  195. addressId:null,
  196. //收货地址模态框数据
  197. addressDetailed :null,
  198. addres:{
  199. requestUrl:"",
  200. selectionType: "radio",
  201. },
  202. //是否打开收货地址弹出框
  203. drawer1:false,
  204. //所有省
  205. provinceList: [],
  206. //选中的省
  207. province: '',
  208. //所有市
  209. cityList: [],
  210. //选中的市
  211. city: '',
  212. //所有的县(区)
  213. countyList: [],
  214. //选中的县
  215. county: '',
  216. //是否点击查询
  217. isKuang:false,
  218. //表格加载状态
  219. tableLoading:false,
  220. //公式内容
  221. formulaString:null,
  222. //油价联动公式Id
  223. oilPriceFormulaId:null,
  224. //是否打开油价联动公式的模态窗口
  225. oilPriceFormulaDrawer:false,
  226. //油价联动公式查询条件
  227. LineText:null,
  228. //油价联动公式模态框查询按钮状态
  229. selectLineLoading:false,
  230. //油价联动公式模态窗口的数据
  231. oilPriceFormula:{
  232. requestUrl:"",
  233. selectionType: "radio",
  234. },
  235. //模态窗口的打开的方向
  236. direction: 'rtl',
  237. //表单数据
  238. form1: {
  239. shipperId:1,
  240. priceDate:new Date(),
  241. oilTypeId:10,
  242. capacityTypeId:1,
  243. type: "销售钢材"
  244. },
  245. //提交给后端的数据
  246. // map:{},
  247. ops: {
  248. vuescroll: {},
  249. scrollPanel: {},
  250. rail: {
  251. keepShow: true
  252. },
  253. bar: {
  254. hoverStyle: true,
  255. onlyShowBarOnScroll: false, //是否只有滚动的时候才显示滚动条
  256. background: "#5f9ea0",//滚动条颜色
  257. opacity: 0.8,//滚动条透明度
  258. "overflow-x": "hidden"
  259. }
  260. }
  261. };
  262. },
  263. mounted() {
  264. this.axios
  265. .post(
  266. "/api/v1/rms/getCarrierNameBySSOId?carrierSSOId=" + this.carrierUserId
  267. )
  268. .then((res) => {
  269. if (res.data.code == "200") {
  270. if (res.data.data) {
  271. this.state = res.data.data.carrierName;
  272. this.carrierIds = res.data.data.carrierId;
  273. }
  274. }
  275. });
  276. },
  277. created(){
  278. //获取所有的省
  279. this.getAllProvince();
  280. },
  281. methods: {
  282. //点击删除按钮删除当前点击的对象
  283. deleteRow(index) {
  284. this.selectionList.splice(index, 1);
  285. },
  286. ondrawerOutcys(){
  287. this.carrier.requestUrl =
  288. "/api/v1/uc/getCarrierListByLike?apiId=412&i=" + new Date();
  289. this.drawer = true;
  290. },
  291. currentRadioChangecys(selection) {
  292. this.carrierTypes=[];
  293. for (let i = 0; i < selection.length; i++) {
  294. if (this.carrierTypes.indexOf(selection[i]) === -1) {
  295. this.carrierTypes.push(selection[i]);
  296. }
  297. }
  298. console.log("this.carrierTypes "+JSON.stringify(this.carrierTypes));
  299. },
  300. //承运商确定按钮
  301. selectMakeSure() {
  302. var fatherNum;
  303. var sonNum;
  304. if (this.selectionList.length > this.carrierTypes.length) {
  305. fatherNum=this.selectionList
  306. sonNum=this.carrierTypes
  307. }else{
  308. fatherNum=this.carrierTypes
  309. sonNum=this.selectionList
  310. }
  311. var breaked = false;
  312. for (let i = 0; i < fatherNum.length; i++) {
  313. for (let j = 0; j <sonNum.length; j++) {
  314. if (fatherNum[i].carrierName==sonNum[j].carrierName){
  315. this.$message({
  316. type: "info",
  317. message: "已有【"+sonNum[j].carrierName+"】承运商,无法重复添加~",
  318. })
  319. breaked = true;
  320. break;
  321. }
  322. }
  323. if (breaked) {
  324. break;
  325. }
  326. }
  327. if (breaked) {
  328. return
  329. }
  330. for (let i = 0; i < this.carrierTypes.length; i++) {
  331. this.selectionList.push(this.carrierTypes[i])
  332. }
  333. this.index = null;
  334. this.drawer = false;
  335. },
  336. //模糊查询承运商
  337. onclickCarrier() {
  338. this.carrier.requestUrl =
  339. "/api/v1/uc/getCarrierListByLike?apiId=412&index=" +
  340. this.index +
  341. "&i=" +
  342. new Date();
  343. },
  344. func(res){
  345. this.selectLineLoading = false;
  346. this.isKuang = false;
  347. this.tableLoading = false;
  348. },
  349. //点击外层收货地址选择事件
  350. ondrawerOut(){
  351. this.drawer1 = true;
  352. },
  353. //获取所有省数据
  354. getAllProvince(){
  355. this.axios.post('/api/v1/uc/getAllProvince').then((res)=>{
  356. this.provinceList = res.data.data;
  357. })
  358. },
  359. //省改变
  360. onchangeProvince(){
  361. this.axios.post('/api/v1/uc/getDistrictByProvince?addressProvince='+this.province).then((res)=>{
  362. this.cityList = res.data.data;
  363. })
  364. },
  365. //市改变
  366. onchangeCity(){
  367. this.axios.post('/api/v1/uc/getTownByDistrict?addressDistrict='+this.city).then((res)=>{
  368. this.countyList = res.data.data;
  369. })
  370. },
  371. //县(区)改变
  372. onchangeCounty(){
  373. let mapValue = {
  374. addressProvince : this.province,
  375. addressDistrict : this.city,
  376. addressTown : this.county
  377. }
  378. this.axios.post('/api/v1/uc/getPlaceByAllAddress',mapValue).then((res)=>{
  379. this.addressId = res.data.data[0].addressId;
  380. })
  381. },
  382. selectLineClick(){
  383. this.tableLoading = true;
  384. this.selectLineLoading = true;
  385. this.isKuang = true;
  386. if(this.LineText){
  387. console.log("进入了查询阶段")
  388. console.log(this.LineText)
  389. this.oilPriceFormula.requestUrl = "api/v1/uc/getOilFormula?apiId=444&con="+this.LineText+"&i=" + new Date();
  390. }else{
  391. this.oilPriceFormula.requestUrl = "api/v1/uc/getOilFormula?apiId=444&i=" + new Date();
  392. }
  393. },
  394. //承运商弹出层
  395. handleSelect(item) {
  396. this.carrierIds = item.carrierId;
  397. item.carrierName = this.state;
  398. },
  399. //收货地址弹出层
  400. handleSelect1(item) {
  401. console.log("获取所有下拉值!");
  402. },
  403. //以下是承运商边输边查搜索
  404. querySearch(queryString, cb) {
  405. this.axios
  406. .post("/api/v1/uc/getCarrierMesByLike?index=" + queryString)
  407. .then((res) => {
  408. if (res.data.code == "200") {
  409. var restaurants = res.data.data;
  410. var results = queryString
  411. ? restaurants.filter(this.createFilter(queryString))
  412. : restaurants;
  413. // 调用 callback 返回建议列表的数据
  414. cb(results);
  415. }
  416. });
  417. },
  418. createFilter(queryString) {
  419. return (restaurants) => {
  420. return (
  421. restaurants.value.toLowerCase().indexOf(queryString.toLowerCase()) >
  422. -1
  423. );
  424. };
  425. },
  426. //以上是承运商边输边查搜索
  427. //以下是收货地址边输边查搜索
  428. querySearch1(queryString, cb){
  429. this.axios
  430. .post("/api/v1/ams/getRealAddressByLike?addressId="+this.addressId + "&index=" + queryString)
  431. .then((res) => {
  432. if (res.data.code == "200") {
  433. console.log(res.data.data);
  434. var restaurants = res.data.data;
  435. // console.log(restaurants, "restaurants");
  436. var results = queryString
  437. ? restaurants.filter(this.createFilter1(queryString))
  438. : restaurants;
  439. // 调用 callback 返回建议列表的数据
  440. cb(results);
  441. }
  442. });
  443. },
  444. createFilter1(queryString) {
  445. return (restaurants) => {
  446. return (
  447. restaurants.value.toLowerCase().indexOf(queryString.toLowerCase()) >
  448. -1
  449. );
  450. };
  451. },
  452. //以上是收货地址边输边查搜索
  453. //选定联动公式确定
  454. addoilPriceFormula(){
  455. let mapvalue = {
  456. shipperId : this.form1.shipperId,
  457. oilPriceFormula:this.formulaString,
  458. cargonameId : this.oilPriceFormulaId,
  459. capacityTypeId : this.form1.capacityTypeId,
  460. priceValue : this.form1.priceValue,
  461. priceDate : this.form1.priceDate,
  462. addressName:this.form1.addressName,
  463. type : this.form1.type,
  464. oilpriceBase : this.form1.oilpriceBase,
  465. oilTypeId : this.form1.oilTypeId,
  466. oilpriceChangeThreshold : this.form1.oilpriceChangeThreshold
  467. }
  468. this.form1 = mapvalue;
  469. this.oilPriceFormulaDrawer = false;
  470. },
  471. currentRadioChange(val){
  472. this.formulaString = val.formulaString;
  473. this.oilPriceFormulaId = val.formulaId;
  474. },
  475. //具体地址确定
  476. specificAddress(){
  477. let mapvalue = {
  478. shipperId : this.form1.shipperId,
  479. oilPriceFormula:this.formulaString,
  480. capacityTypeId : this.form1.capacityTypeId,
  481. cargonameId : this.oilPriceFormulaId,
  482. priceValue : this.form1.priceValue,
  483. priceDate : this.form1.priceDate,
  484. addressName:this.province+this.city+this.county+this.place,
  485. type : this.form1.type,
  486. oilpriceBase : this.form1.oilpriceBase,
  487. oilTypeId : this.form1.oilTypeId,
  488. oilpriceChangeThreshold : this.form1.oilpriceChangeThreshold
  489. }
  490. this.form1 = mapvalue;
  491. this.drawer1 = false;
  492. },
  493. //打开线路的模态窗口
  494. oilPriceFormulaClick(){
  495. this.oilPriceFormulaDrawer = true;
  496. this.oilPriceFormula.requestUrl = "/api/v1/uc/getOilFormula?apiId=444"
  497. },
  498. //模态窗口关闭时调用
  499. handleClose(){
  500. if(this.oilPriceFormulaDrawer){
  501. this.oilPriceFormulaDrawer = false;
  502. this.LineText = null;
  503. }
  504. },
  505. makeSure() {
  506. if (this.haulDistance=="" || this.haulDistance==null){
  507. this.$message({
  508. type: "warning",
  509. message: "请输入运输距离!",});
  510. return;
  511. }
  512. if (!this.form1.priceValue){
  513. this.$message({
  514. type: "warning",
  515. message: "请输入运价!",});
  516. return;
  517. }
  518. for (let i = 0; i < this.selectionList.length; i++) {
  519. this.carrierIdArray.push(this.selectionList[i].carrierId)
  520. }
  521. let mapValue={
  522. shipperId : this.form1.shipperId,
  523. carrierId : this.carrierIdArray,
  524. cargonameId : this.oilPriceFormulaId,
  525. capacityTypeId : this.form1.capacityTypeId,
  526. priceValue : this.form1.priceValue,
  527. priceDate : sjTime(this.form1.priceDate),
  528. addressId : this.addressId,
  529. type : this.form1.type,
  530. oilpriceBase : this.form1.oilpriceBase,
  531. oilTypeId : this.form1.oilTypeId,
  532. oilpriceChangeThreshold : this.form1.oilpriceChangeThreshold,
  533. place: this.place,
  534. haulDistance: this.haulDistance
  535. }
  536. this.axios.post("/api/v1/ams/addAmsContractTransportPrice", mapValue).then((res) => {
  537. if (res.data.code == "200") {
  538. this.$router.go(-1);
  539. }
  540. this.$message({
  541. type: "success",
  542. message: "新增运输单价成功!",
  543. });
  544. });
  545. },
  546. // 取消
  547. cancel() {
  548. this.$router.push('/transportPrice');
  549. },
  550. },
  551. };
  552. </script>
  553. <style lang='scss'>
  554. .elForm {
  555. margin-left: 38%;
  556. }
  557. .button-box{
  558. display: flex;
  559. text-align: center;
  560. align-items: center;
  561. justify-content: center;
  562. margin-top: 0.3125rem;
  563. margin-bottom: 1.25rem;
  564. }
  565. .addTransportPrice{
  566. .form{
  567. display: flex;
  568. .form_box{
  569. width: 320px;
  570. margin-left: 38%;
  571. margin-top: 30px;
  572. margin-right: 20px;
  573. .el-form{
  574. .preview-group{
  575. .el-form-item{
  576. .el-form-item__label{
  577. display: inline-block;
  578. width: 70px !important;
  579. }
  580. .el-form-item__content{
  581. .el-select{
  582. width: 250px;
  583. }
  584. .el-input{
  585. width: 250px;
  586. }
  587. }
  588. }
  589. }
  590. }
  591. label{
  592. display: inline-block;
  593. width: 70px !important;
  594. }
  595. .el-input{
  596. width: 250px;
  597. }
  598. }
  599. #liulan{
  600. width: 120px;
  601. margin-top: 30px;
  602. .el-button{
  603. width: 100px !important;
  604. margin-top: 14px;
  605. }
  606. .btn{
  607. margin-top: 106px;
  608. }
  609. .btn1{
  610. margin-top: 13px;
  611. margin-left: 0px;
  612. }
  613. .btn2{
  614. margin-top: 67px;
  615. }
  616. }
  617. }
  618. .button_box{
  619. margin-left: 45%;
  620. }
  621. .selectText{
  622. .el-input{
  623. width: 250px;
  624. }
  625. }
  626. .LineTable{
  627. width: 100%;
  628. height: 480px;
  629. overflow: hidden;
  630. margin-top: 10px;
  631. }
  632. #cysbutton{
  633. margin-left: 70px;
  634. }
  635. }
  636. </style>
  637. <style lang='scss'>
  638. /deep/.__bar-is-vertical {
  639. right: -1px !important;
  640. }
  641. /deep/.__bar-is-horizontal {
  642. display: none !important;
  643. }
  644. </style>