addTransportPrice.vue 18 KB

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