addSaleOrderSend.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. <template>
  2. <div class="addSaleOrderSend">
  3. <page-title>新增销售订单派车</page-title>
  4. <!-- 销售订单表的数据 -->
  5. <div class="saleOrder">
  6. <dilTable
  7. v-bind.sync="option"
  8. @radio-change="currentRadioChange"
  9. ></dilTable>
  10. </div>
  11. <!-- 表单选择车辆和线路 -->
  12. <div class="from">
  13. <div class="line">
  14. <span class="text">线路</span>
  15. <el-input
  16. v-model="lineName"
  17. placeholder="请选择线路"
  18. disabled
  19. ></el-input>
  20. <el-button type="primary" @click="onClick(1)">浏览</el-button>
  21. </div>
  22. <div class="vehicle">
  23. <span class="text">车辆</span>
  24. <el-button type="primary" @click="onClick(2)">浏览</el-button>
  25. <span class="span"></span>
  26. </div>
  27. </div>
  28. <!-- 派车表格 -->
  29. <div class="selectionTable from">
  30. <el-table
  31. :data="selectionList"
  32. border
  33. style="width: 100%"
  34. highlight-current-row
  35. >
  36. <el-table-column type="index" label="序号" width="50">
  37. </el-table-column>
  38. <el-table-column
  39. v-for="(item, i) in tableTop"
  40. :key="i"
  41. :prop="item.prop"
  42. :label="item.label"
  43. :width="item.width"
  44. align="center"
  45. show-overflow-tooltip
  46. >
  47. <template slot="scope" v-if="item.label !== '重量'">
  48. <span>{{ item.label }}</span>
  49. </template>
  50. <template slot="scope" v-if="item.label !== '收货地址'">
  51. <span>{{ item.label }}</span>
  52. </template>
  53. <template slot="scope" v-if="item.label !== '收货日期'">
  54. <span>{{ item.label }}</span>
  55. </template>
  56. <template slot="scope" v-if="item.label !== '收货姓名'">
  57. <span>{{ item.label }}</span>
  58. </template>
  59. <template slot="scope" v-if="item.label !== '收货方电话'">
  60. <span>{{ item.label }}</span>
  61. </template>
  62. <!-- 插入输入框 -->
  63. <template slot-scope="scope">
  64. <template v-if="item.slot">
  65. <!-- 物资重量 -->
  66. <template v-if="item.prop == 'orderPlanWeight'">
  67. <el-input
  68. class="textinput"
  69. @input="onInput"
  70. placeholder="请输入内容(必填)"
  71. v-model.number="scope.row.orderPlanWeight"
  72. ></el-input>
  73. </template>
  74. <!-- 收货地址id -->
  75. <template v-if="item.prop == 'saleShipperAddressName'" >
  76. <el-input
  77. style="width: 200px"
  78. v-model="scope.row.saleShipperAddressName"
  79. disabled
  80. >
  81. </el-input>
  82. <el-button
  83. type="primary"
  84. placeholder="请输入内容(必填)"
  85. @click="select(scope.$index,3)"
  86. >浏览</el-button
  87. >
  88. </template>
  89. <!-- 收货日期 -->
  90. <template v-if="item.prop == 'saleDateOfReceipt'">
  91. <el-date-picker
  92. class="textinput3"
  93. type="date"
  94. v-model.number="scope.row.saleDateOfReceipt"
  95. ></el-date-picker>
  96. </template>
  97. <!-- 收货客户 -->
  98. <template v-if="item.prop == 'saleOrderConsignee'">
  99. <el-input
  100. class="textinput4"
  101. placeholder="请输入内容(非必填)"
  102. v-model.number="scope.row.saleOrderConsignee"
  103. ></el-input>
  104. </template>
  105. <!-- 收货客户电话号码 -->
  106. <template v-if="item.prop == 'saleOrderConsigneeTel'">
  107. <el-input
  108. class="textinput5"
  109. placeholder="请输入内容(非必填)"
  110. v-model.number="scope.row.saleOrderConsigneeTel"
  111. @input="onInput"
  112. ></el-input>
  113. </template>
  114. </template>
  115. <template v-else>
  116. <span>{{ scope.row[item.prop] }}</span>
  117. </template>
  118. </template>
  119. </el-table-column>
  120. <!-- 操作列 -->
  121. <el-table-column fixed="right" label="操作" width="100">
  122. <template slot-scope="scope">
  123. <el-button
  124. @click="copyRow(scope.$index,scope.row)"
  125. type="text"
  126. size="big"
  127. >
  128. 复制
  129. </el-button>
  130. <el-button
  131. @click="deleteRow(scope.$index)"
  132. type="text"
  133. icon="el-icon-close"
  134. size="big"
  135. ></el-button>
  136. </template>
  137. </el-table-column>
  138. </el-table>
  139. </div>
  140. <!-- 线路模态框 -->
  141. <el-drawer
  142. :visible.sync="drawer"
  143. :destroy-on-close="false"
  144. direction="rtl"
  145. size="40%"
  146. :wrapperClosable="false"
  147. modal
  148. close-on-press-escape
  149. >
  150. <el-input
  151. placeholder="请输入内容"
  152. v-model="lineText"
  153. style="margin-top: 10px; margin-left: 20px; width: 250px"
  154. clearable
  155. >
  156. </el-input>
  157. <el-button
  158. type="primary"
  159. class="btn"
  160. @click="selectClick"
  161. style="margin-left: 5px"
  162. >
  163. <i class="el-icon-search"></i>查询
  164. </el-button>
  165. <el-button
  166. type="primary"
  167. class="btn"
  168. @click="AddClick"
  169. style="margin-left: 5px"
  170. >
  171. <i class="el-icon-check"></i>确定
  172. </el-button>
  173. <div class="tablecls">
  174. <!-- 查询所有的路线 -->
  175. <dilTable
  176. v-bind.sync="line"
  177. @radio-change="currentRadioChange5"
  178. ></dilTable>
  179. </div>
  180. </el-drawer>
  181. <!-- 车辆模态框 -->
  182. <el-drawer
  183. :visible.sync="truckDrawer"
  184. :destroy-on-close="false"
  185. direction="rtl"
  186. size="40%"
  187. :wrapperClosable="false"
  188. modal
  189. close-on-press-escape
  190. >
  191. <el-input
  192. placeholder="请输入内容"
  193. v-model="truckText"
  194. style="margin-top: 10px; margin-left: 20px; width: 250px"
  195. clearable
  196. >
  197. </el-input>
  198. <el-button
  199. type="primary"
  200. class="btn"
  201. @click="selectTruckClick"
  202. style="margin-left: 5px"
  203. >
  204. <i class="el-icon-search"></i>查询
  205. </el-button>
  206. <el-button
  207. type="primary"
  208. class="btn"
  209. @click="AddTruckClick"
  210. style="margin-left: 5px"
  211. >
  212. <i class="el-icon-check"></i>确定
  213. </el-button>
  214. <div class="tablecls">
  215. <!-- 查询所有的车辆 -->
  216. <dilTable
  217. v-bind.sync="truck"
  218. @selection-change="currentRadioChange1"
  219. ></dilTable>
  220. </div>
  221. </el-drawer>
  222. <!-- 收货地址的模态框 -->
  223. <el-drawer
  224. :visible.sync="addressDrawer"
  225. :destroy-on-close="false"
  226. direction="rtl"
  227. size="40%"
  228. :wrapperClosable="false"
  229. modal
  230. close-on-press-escape
  231. >
  232. <el-input
  233. placeholder="请输入内容"
  234. v-model="addressText"
  235. style="margin-top: 10px; margin-left: 20px; width: 250px"
  236. clearable
  237. >
  238. </el-input>
  239. <el-button
  240. type="primary"
  241. class="btn"
  242. @click="selectAddressClick"
  243. style="margin-left: 5px"
  244. >
  245. <i class="el-icon-search"></i>查询
  246. </el-button>
  247. <el-button
  248. type="primary"
  249. class="btn"
  250. @click="addAddressClick"
  251. style="margin-left: 5px"
  252. >
  253. <i class="el-icon-check"></i>确定
  254. </el-button>
  255. <div class="tablecls">
  256. <!-- 查询所有的收货地址 -->
  257. <dilTable
  258. v-bind.sync="Address"
  259. @radio-change="currentRadioChange2"
  260. ></dilTable>
  261. </div>
  262. </el-drawer>
  263. <div class="button_box">
  264. <el-button @click="cancel">取消</el-button>
  265. <el-button type="primary" @click="makeSure">确定</el-button>
  266. </div>
  267. </div>
  268. </template>
  269. <script>
  270. import PageTitle from "@/components/Page/Title";
  271. import { getCookie } from "@/utils/util.js";
  272. import { sjTime,isNumber } from "@/utils/sharedJsFile";
  273. export default {
  274. components: { PageTitle },
  275. data() {
  276. return {
  277. //线路名称
  278. lineName:null,
  279. lineId:null,
  280. //线路表格单选缓存数据的
  281. cacheLine:[],
  282. //已经选择车辆物资信息
  283. selectionList:[],
  284. //销售订单物资信息
  285. option: {
  286. // 表格请求数据的地址
  287. requestUrl:"",
  288. // 控制显示当选列
  289. selectionType: "radio",
  290. isPagination: false,
  291. },
  292. //当前选中的物资id
  293. materialId: null,
  294. //当前选中的物资名称
  295. materialName: null,
  296. //选中的线路名称
  297. lineName: null,
  298. //选中的线路id
  299. lineId: null,
  300. //是否打开选择线路的模态框
  301. drawer:false,
  302. //是否打开选择车辆的模态框
  303. truckDrawer:false,
  304. //是否打开收货地址的模态框
  305. addressDrawer:false,
  306. //线路的表格
  307. line: {
  308. requestUrl: "/api/v1/rms/getAllLineDesk?apiId=249&lineType=3",
  309. selectionType: "radio",
  310. },
  311. //车辆的表格
  312. truck: {
  313. requestUrl: "",
  314. selectionType: "select",
  315. },
  316. //收货地址的表格
  317. Address: {
  318. requestUrl: "/api/v1/ams/getAddressDeliveryAddress?apiId=255",
  319. selectionType: "radio",
  320. },
  321. addressText:null,
  322. //线路表格的框计算输入的值
  323. lineText:null,
  324. tableTop: [
  325. {
  326. prop: "capacityNumber",
  327. label: "车牌号",
  328. width: "100",
  329. },
  330. {
  331. prop: "materialName",
  332. label: "物资名称",
  333. width: "140",
  334. },
  335. {
  336. prop: "carrierName",
  337. label: "承运商",
  338. width: "220",
  339. },
  340. {
  341. prop: "lineName",
  342. label: "运输线路",
  343. width: "220",
  344. },
  345. {
  346. prop: "orderPlanWeight",
  347. label: "重量",
  348. width: "140",
  349. slot: true,
  350. },
  351. {
  352. prop: "saleShipperAddressName",
  353. label: "收货地址",
  354. width: "300",
  355. slot: true,
  356. },
  357. {
  358. prop: "saleDateOfReceipt",
  359. label: "发货日期",
  360. width: "270",
  361. slot: true,
  362. },
  363. {
  364. prop: "saleOrderConsignee",
  365. label: "收货客户",
  366. width: "150",
  367. slot: true,
  368. },
  369. {
  370. prop: "saleOrderConsigneeTel",
  371. label: "收货客户电话号码",
  372. slot: true,
  373. width: "150",
  374. },
  375. ],
  376. truckText:null,
  377. //当前多选选中的车辆
  378. selectTruck:[],
  379. //销售订单与物资表主键
  380. saleMaterialId:null,
  381. //记录点击的市哪一个收货地址的浏览
  382. addressIndex:null,
  383. //缓存当前选中的收货地址
  384. addressMap:{},
  385. };
  386. },
  387. created() {
  388. if (getCookie("orgCode") == "chengyunshang") {
  389. this.truck.requestUrl =
  390. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" +
  391. getCookie("userId");
  392. } else {
  393. this.truck.requestUrl =
  394. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" + null;
  395. }
  396. this.option.requestUrl = "/api/v1/ams/getSaleOrderAndMaterialById?apiId=410&saleOrderId=" + this.$route.params.saleOrderId;
  397. },
  398. methods: {
  399. onInput(val){
  400. if(!isNumber(val)){
  401. this.$message.warning('重量/电话号码请输入数字')
  402. }
  403. },
  404. //点击确定按钮的事件
  405. makeSure(){
  406. let state = false;
  407. this.selectionList.forEach((e)=>{
  408. console.log(e.orderPlanWeight,"orderPlanWeight")
  409. if(!isNumber(e.orderPlanWeight)){
  410. this.$message.error('重量请输入数字')
  411. }else if(e.saleOrderConsigneeTel){
  412. if(!isNumber(e.saleOrderConsigneeTel)){
  413. this.$message.error('电话号码请输入数字')
  414. }else{
  415. e.saleOrderConsigneeTel = e.saleOrderConsigneeTel+"",
  416. state = true
  417. }
  418. }else {
  419. e.saleOrderConsigneeTel = null,
  420. state = true
  421. }
  422. if(e.saleDateOfReceipt){
  423. e.saleDateOfReceipt = sjTime(e.saleDateOfReceipt)
  424. }
  425. console.log(typeof e.saleDateOfReceipt)
  426. })
  427. console.log(this.selectionList)
  428. if(state){
  429. this.axios.post('/api/v1/ams/dispatchTruckOrderBySale',{
  430. saleOrderId:this.$route.params.saleOrderId,
  431. mapList:this.selectionList,
  432. }).then((res)=>{
  433. if(res.data.code == '200'){
  434. this.$message.success('派车成功')
  435. this.cancel();
  436. }
  437. })
  438. }else{
  439. this.$message.warning('重量/电话号码请输入数字')
  440. }
  441. },
  442. //点击取消按钮的事件
  443. cancel(){
  444. this.$router.push('/saleOrder')
  445. },
  446. //点击删除按钮删除当前点击的对象
  447. deleteRow(index){
  448. this.selectionList.splice(index,1)
  449. },
  450. //复制的方法
  451. copyRow(index,row){
  452. let arr = [];
  453. for(var i = 0 ;i<this.selectionList.length; i++){
  454. if(i == index){
  455. arr.push(this.selectionList[i]);
  456. arr.push({
  457. capacityId:row.capacityId,
  458. capacityNumber:row.capacityNumber,
  459. carrierName:row.carrierName,
  460. lineId:row.lineId,
  461. lineName:row.lineName,
  462. materialId:row.materialId,
  463. materialName:row.materialName,
  464. orderPlanWeight:row.orderPlanWeight,
  465. saleDateOfReceipt:row.saleDateOfReceipt,
  466. saleMaterialId:row.saleMaterialId,
  467. saleOrderConsignee:row.saleOrderConsignee,
  468. saleOrderConsigneeTel:row.saleOrderConsigneeTel,
  469. saleShipperAddressName:row.saleShipperAddressName,
  470. saleShippingAddressId:row.saleShippingAddressId,
  471. }
  472. )
  473. }else{
  474. arr.push(this.selectionList[i]);
  475. }
  476. }
  477. this.selectionList = [];
  478. this.selectionList = arr;
  479. },
  480. //收货地址模态窗口的框计算
  481. selectAddressClick(){
  482. this.Address.requestUrl = '/api/v1/ams/getAddressDeliveryAddress?apiId=255&con='+this.addressText;
  483. },
  484. //收货地址模态窗口的点击事件
  485. addAddressClick(){
  486. this.selectionList[this.addressIndex].saleShipperAddressName = this.addressMap.address
  487. this.selectionList[this.addressIndex].saleShippingAddressId = this.addressMap.addressId
  488. this.addressDrawer = false;
  489. let arr = this.selectionList;
  490. this.selectionList = [];
  491. arr.forEach((e)=>{
  492. this.selectionList.push({
  493. //销售订单与物资表主键
  494. capacityId:e.capacityId,
  495. capacityNumber:e.capacityNumber,
  496. carrierName:e.carrierName,
  497. lineId:e.lineId,
  498. lineName:e.lineName,
  499. materialId:e.materialId,
  500. materialName:e.materialName,
  501. orderPlanWeight:e.orderPlanWeight,
  502. saleDateOfReceipt:e.saleDateOfReceipt,
  503. saleMaterialId:e.saleMaterialId,
  504. saleOrderConsignee:e.saleOrderConsignee,
  505. saleOrderConsigneeTel:e.saleOrderConsigneeTel,
  506. saleShipperAddressName:e.saleShipperAddressName,
  507. saleShippingAddressId:e.saleShippingAddressId,
  508. })
  509. })
  510. },
  511. //收货地址点击浏览的事件
  512. select(index){
  513. this.addressDrawer = true;
  514. this.addressIndex = index ;
  515. },
  516. //收货地址模态框单选选中的事件
  517. currentRadioChange2(val){
  518. this.addressMap = {};
  519. this.addressMap = val;
  520. },
  521. //车辆模态框的确定事件
  522. AddTruckClick(){
  523. console.log(this.selectTruck)
  524. this.selectTruck.forEach(e => {
  525. // console.log(e)
  526. this.selectionList.push({
  527. //销售订单与物资表主键
  528. saleMaterialId:this.saleMaterialId,
  529. capacityId:e.capacityId,
  530. capacityNumber:e.capacityNumber,
  531. carrierName:e.carrierName,
  532. materialName:this.materialName,
  533. materialId:this.materialId,
  534. lineName:this.lineName,
  535. lineId:this.lineId,
  536. })
  537. });
  538. this.truckDrawer = false;
  539. },
  540. //车辆模态框框计算
  541. selectTruckClick(){
  542. if (getCookie("orgCode") == "chengyunshang") {
  543. this.truck.requestUrl =
  544. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" +
  545. getCookie("userId") + "&index="+this.truckText;
  546. } else {
  547. this.truck.requestUrl =
  548. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" + null + "&index="+this.truckText;
  549. }
  550. },
  551. //车辆表格
  552. currentRadioChange1(select){
  553. this.selectTruck = [];
  554. this.selectTruck = select;
  555. },
  556. //主界面表格单选
  557. currentRadioChange(row) {
  558. this.materialId = row.materialId;
  559. this.materialName = row.materialName;
  560. this.saleMaterialId = row.saleMaterialId;
  561. },
  562. //线路表格的单选事件
  563. currentRadioChange5(row){
  564. this.cacheLine = row;
  565. },
  566. onClick(num) {
  567. if (num == 1) {
  568. this.drawer = true;
  569. }else if(num == 2){
  570. if(!this.materialId){
  571. this.$message.warning('请选择物资后,再点击')
  572. }else if(!this.lineId){
  573. this.$message.warning('请选择线路后,再点击')
  574. }else{
  575. this.truckDrawer = true;
  576. }
  577. }
  578. },
  579. //线路表格的框计算
  580. selectClick(){
  581. this.line.requestUrl = '/api/v1/rms/getAllLineDesk?apiId=249&lineType=3&con='+this.lineText;
  582. },
  583. //线路表格的确定事件
  584. AddClick(){
  585. this.drawer = false;
  586. this.lineName = this.cacheLine.lineName +" "+ this.cacheLine.lineDesk;
  587. this.lineId = this.cacheLine.lineId;
  588. }
  589. },
  590. };
  591. </script>
  592. <style lang='scss'>
  593. .addSaleOrderSend {
  594. .from {
  595. margin-top: 20px;
  596. .line {
  597. display: flex;
  598. justify-content: center;
  599. align-items: center;
  600. .el-input {
  601. width: 350px;
  602. margin-left: 10px;
  603. margin-right: 10px;
  604. }
  605. }
  606. .vehicle {
  607. display: flex;
  608. justify-content: center;
  609. align-items: center;
  610. margin-top: 20px;
  611. .el-button {
  612. width: 250px;
  613. margin-left: 10px;
  614. margin-right: 10px;
  615. }
  616. .span {
  617. width: 70px;
  618. }
  619. }
  620. }
  621. .tablecls{
  622. margin-top: 20px;
  623. }
  624. .button_box{
  625. display: flex;
  626. justify-content: center;
  627. margin: 20px;
  628. .el-button{
  629. width: 100px;
  630. margin-left: 20px;
  631. }
  632. }
  633. }
  634. </style>