addSaleOrderSend.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  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. @keyup.enter.native="AddClick"
  148. modal
  149. close-on-press-escape
  150. >
  151. <el-input
  152. placeholder="请输入内容"
  153. v-model="lineText"
  154. style="margin-top: 10px; margin-left: 20px; width: 250px"
  155. @keyup.enter.native="selectClick"
  156. clearable
  157. >
  158. </el-input>
  159. <el-button
  160. type="primary"
  161. class="btn"
  162. @click="selectClick"
  163. style="margin-left: 5px"
  164. >
  165. <i class="el-icon-search"></i>查询
  166. </el-button>
  167. <el-button
  168. type="primary"
  169. class="btn"
  170. @click="AddClick"
  171. style="margin-left: 5px"
  172. >
  173. <i class="el-icon-check"></i>确定
  174. </el-button>
  175. <div class="tablecls">
  176. <!-- 查询所有的路线 -->
  177. <dilTable
  178. v-bind.sync="line"
  179. @radio-change="currentRadioChange5"
  180. ></dilTable>
  181. </div>
  182. </el-drawer>
  183. <!-- 车辆模态框 -->
  184. <el-drawer
  185. :visible.sync="truckDrawer"
  186. :destroy-on-close="false"
  187. direction="rtl"
  188. size="40%"
  189. @keyup.enter.native="AddTruckClick"
  190. :wrapperClosable="false"
  191. modal
  192. close-on-press-escape
  193. >
  194. <el-input
  195. placeholder="请输入内容"
  196. v-model="truckText"
  197. style="margin-top: 10px; margin-left: 20px; width: 250px"
  198. @keyup.enter.native="selectTruckClick"
  199. clearable
  200. >
  201. </el-input>
  202. <el-button
  203. type="primary"
  204. class="btn"
  205. @click="selectTruckClick"
  206. style="margin-left: 5px"
  207. >
  208. <i class="el-icon-search"></i>查询
  209. </el-button>
  210. <el-button
  211. type="primary"
  212. class="btn"
  213. @click="AddTruckClick"
  214. style="margin-left: 5px"
  215. >
  216. <i class="el-icon-check"></i>确定
  217. </el-button>
  218. <div class="tablecls">
  219. <!-- 查询所有的车辆 -->
  220. <dilTable
  221. v-bind.sync="truck"
  222. @selection-change="currentRadioChange1"
  223. ></dilTable>
  224. </div>
  225. </el-drawer>
  226. <!-- 收货地址的模态框 -->
  227. <el-drawer
  228. :visible.sync="addressDrawer"
  229. :destroy-on-close="false"
  230. direction="rtl"
  231. size="40%"
  232. :wrapperClosable="false"
  233. modal
  234. close-on-press-escape
  235. >
  236. <el-input
  237. placeholder="请输入内容"
  238. v-model="addressText"
  239. style="margin-top: 10px; margin-left: 20px; width: 250px"
  240. clearable
  241. >
  242. </el-input>
  243. <el-button
  244. type="primary"
  245. class="btn"
  246. @click="selectAddressClick"
  247. style="margin-left: 5px"
  248. >
  249. <i class="el-icon-search"></i>查询
  250. </el-button>
  251. <el-button
  252. type="primary"
  253. class="btn"
  254. @click="addAddressClick"
  255. style="margin-left: 5px"
  256. >
  257. <i class="el-icon-check"></i>确定
  258. </el-button>
  259. <div class="tablecls">
  260. <!-- 查询所有的收货地址 -->
  261. <dilTable
  262. v-bind.sync="Address"
  263. @radio-change="currentRadioChange2"
  264. ></dilTable>
  265. </div>
  266. </el-drawer>
  267. <div class="button_box">
  268. <el-button @click="cancel">取消</el-button>
  269. <el-button type="primary" @click="makeSure">确定</el-button>
  270. </div>
  271. </div>
  272. </template>
  273. <script>
  274. import PageTitle from "@/components/Page/Title";
  275. import { getCookie } from "@/utils/util.js";
  276. import { sjTime,isNumber } from "@/utils/sharedJsFile";
  277. export default {
  278. components: { PageTitle },
  279. data() {
  280. return {
  281. //线路名称
  282. lineName:null,
  283. lineId:null,
  284. //线路表格单选缓存数据的
  285. cacheLine:{
  286. ROW_ID : 0,
  287. lineDesk : '',
  288. lineId : 0,
  289. lineName : '',
  290. lineNo : '',
  291. lineType : '',
  292. spellNumber : 0,
  293. },
  294. //已经选择车辆物资信息
  295. selectionList:[],
  296. //销售订单物资信息
  297. option: {
  298. // 表格请求数据的地址
  299. requestUrl:"",
  300. // 控制显示当选列
  301. selectionType: "radio",
  302. isPagination: false,
  303. },
  304. //当前选中的物资id
  305. materialId: null,
  306. //当前选中的物资名称
  307. materialName: null,
  308. //选中的线路名称
  309. lineName: null,
  310. //选中的线路id
  311. lineId: null,
  312. //是否打开选择线路的模态框
  313. drawer:false,
  314. //是否打开选择车辆的模态框
  315. truckDrawer:false,
  316. //是否打开收货地址的模态框
  317. addressDrawer:false,
  318. //线路的表格
  319. line: {
  320. requestUrl: "/api/v1/rms/getAllLineDesk?apiId=249&lineType=3",
  321. selectionType: "radio",
  322. },
  323. //车辆的表格
  324. truck: {
  325. requestUrl: "",
  326. selectionType: "select",
  327. },
  328. //收货地址的表格
  329. Address: {
  330. requestUrl: "/api/v1/ams/getAddressDeliveryAddress?apiId=255",
  331. selectionType: "radio",
  332. },
  333. addressText:null,
  334. //线路表格的框计算输入的值
  335. lineText:null,
  336. tableTop: [
  337. {
  338. prop: "capacityNumber",
  339. label: "车牌号",
  340. width: "100",
  341. },
  342. {
  343. prop: "materialName",
  344. label: "物资名称",
  345. width: "140",
  346. },
  347. {
  348. prop: "carrierName",
  349. label: "承运商",
  350. width: "220",
  351. },
  352. {
  353. prop: "lineName",
  354. label: "运输线路",
  355. width: "220",
  356. },
  357. {
  358. prop: "orderPlanWeight",
  359. label: "重量",
  360. width: "140",
  361. slot: true,
  362. },
  363. {
  364. prop: "saleDateOfReceipt",
  365. label: "截止日期",
  366. width: "230",
  367. slot: true,
  368. },
  369. {
  370. prop: "saleShipperAddressName",
  371. label: "收货地址",
  372. width: "300",
  373. slot: true,
  374. },
  375. {
  376. prop: "saleOrderConsignee",
  377. label: "收货客户",
  378. width: "150",
  379. slot: true,
  380. },
  381. {
  382. prop: "saleOrderConsigneeTel",
  383. label: "收货客户电话号码",
  384. slot: true,
  385. width: "150",
  386. },
  387. ],
  388. truckText:null,
  389. //当前多选选中的车辆
  390. selectTruck:[],
  391. //销售订单与物资表主键
  392. saleMaterialId:null,
  393. //记录点击的市哪一个收货地址的浏览
  394. addressIndex:null,
  395. //缓存当前选中的收货地址
  396. addressMap:{},
  397. };
  398. },
  399. created() {
  400. if (getCookie("orgCode") == "chengyunshang") {
  401. this.truck.requestUrl =
  402. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" +
  403. getCookie("userId");
  404. } else {
  405. this.truck.requestUrl =
  406. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" + null;
  407. }
  408. this.option.requestUrl = "/api/v1/ams/getSaleOrderAndMaterialById?apiId=410&saleOrderId=" + this.$route.params.saleOrderId;
  409. },
  410. methods: {
  411. onInput(val){
  412. if(!isNumber(val)){
  413. this.$message.warning('重量/电话号码请输入数字')
  414. }
  415. },
  416. //点击确定按钮的事件
  417. makeSure(){
  418. let state = false;
  419. this.selectionList.forEach((e)=>{
  420. if(!isNumber(e.orderPlanWeight)){
  421. this.$message.error('重量请输入数字')
  422. }else if(e.saleOrderConsigneeTel){
  423. if(!isNumber(e.saleOrderConsigneeTel)){
  424. this.$message.error('电话号码请输入数字')
  425. }else{
  426. e.saleOrderConsigneeTel = e.saleOrderConsigneeTel+"",
  427. state = true
  428. }
  429. }else {
  430. e.saleOrderConsigneeTel = null,
  431. state = true
  432. }
  433. if(e.saleDateOfReceipt){
  434. e.saleDateOfReceipt = sjTime(e.saleDateOfReceipt)
  435. }
  436. })
  437. if(state){
  438. this.axios.post('/api/v1/ams/dispatchTruckOrderBySale',{
  439. saleOrderId:this.$route.params.saleOrderId,
  440. mapList:this.selectionList,
  441. }).then((res)=>{
  442. if(res.data.code == '200'){
  443. this.$message.success('派车成功')
  444. this.cancel();
  445. }
  446. })
  447. }else{
  448. this.$message.warning('重量/电话号码请输入数字')
  449. }
  450. },
  451. //点击取消按钮的事件
  452. cancel(){
  453. this.$router.push('/saleOrder')
  454. },
  455. //点击删除按钮删除当前点击的对象
  456. deleteRow(index){
  457. this.selectionList.splice(index,1)
  458. },
  459. //复制的方法
  460. copyRow(index,row){
  461. let arr = [];
  462. for(var i = 0 ;i<this.selectionList.length; i++){
  463. if(i == index){
  464. arr.push(this.selectionList[i]);
  465. arr.push({
  466. capacityId:row.capacityId,
  467. capacityNumber:row.capacityNumber,
  468. carrierName:row.carrierName,
  469. lineId:row.lineId,
  470. lineName:row.lineName,
  471. materialId:row.materialId,
  472. materialName:row.materialName,
  473. orderPlanWeight:row.orderPlanWeight,
  474. saleDateOfReceipt:row.saleDateOfReceipt,
  475. saleMaterialId:row.saleMaterialId,
  476. saleOrderConsignee:row.saleOrderConsignee,
  477. saleOrderConsigneeTel:row.saleOrderConsigneeTel,
  478. saleShipperAddressName:row.saleShipperAddressName,
  479. saleShippingAddressId:row.saleShippingAddressId,
  480. }
  481. )
  482. }else{
  483. arr.push(this.selectionList[i]);
  484. }
  485. }
  486. this.selectionList = [];
  487. this.selectionList = arr;
  488. },
  489. //收货地址模态窗口的框计算
  490. selectAddressClick(){
  491. this.Address.requestUrl = '/api/v1/ams/getAddressDeliveryAddress?apiId=255&con='+this.addressText;
  492. },
  493. //收货地址模态窗口的点击事件
  494. addAddressClick(){
  495. this.selectionList[this.addressIndex].saleShipperAddressName = this.addressMap.address
  496. this.selectionList[this.addressIndex].saleShippingAddressId = this.addressMap.addressId
  497. this.addressDrawer = false;
  498. let arr = this.selectionList;
  499. this.selectionList = [];
  500. arr.forEach((e)=>{
  501. this.selectionList.push({
  502. //销售订单与物资表主键
  503. capacityId:e.capacityId,
  504. capacityNumber:e.capacityNumber,
  505. carrierName:e.carrierName,
  506. lineId:e.lineId,
  507. lineName:e.lineName,
  508. materialId:e.materialId,
  509. materialName:e.materialName,
  510. orderPlanWeight:e.orderPlanWeight,
  511. saleDateOfReceipt:e.saleDateOfReceipt,
  512. saleMaterialId:e.saleMaterialId,
  513. saleOrderConsignee:e.saleOrderConsignee,
  514. saleOrderConsigneeTel:e.saleOrderConsigneeTel,
  515. saleShipperAddressName:e.saleShipperAddressName,
  516. saleShippingAddressId:e.saleShippingAddressId,
  517. })
  518. })
  519. },
  520. //收货地址点击浏览的事件
  521. select(index){
  522. this.addressDrawer = true;
  523. this.addressIndex = index ;
  524. },
  525. //收货地址模态框单选选中的事件
  526. currentRadioChange2(val){
  527. this.addressMap = {};
  528. this.addressMap = val;
  529. },
  530. //车辆模态框的确定事件
  531. AddTruckClick(){
  532. if(this.selectTruck.length>0){
  533. this.selectTruck.forEach(e => {
  534. this.selectionList.push({
  535. //销售订单与物资表主键
  536. saleMaterialId:this.saleMaterialId,
  537. capacityId:e.capacityId,
  538. capacityNumber:e.capacityNumber,
  539. carrierName:e.carrierName,
  540. materialName:this.materialName,
  541. materialId:this.materialId,
  542. lineName:this.lineName,
  543. lineId:this.lineId,
  544. })
  545. });
  546. this.truckDrawer = false;
  547. //置空当前多选选中的车辆数据
  548. this.selectTruck = [];
  549. }
  550. },
  551. //车辆模态框框计算
  552. selectTruckClick(){
  553. if (getCookie("orgCode") == "chengyunshang") {
  554. this.truck.requestUrl =
  555. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" +
  556. getCookie("userId") + "&index="+this.truckText;
  557. } else {
  558. this.truck.requestUrl =
  559. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" + null + "&index="+this.truckText;
  560. }
  561. },
  562. //车辆表格
  563. currentRadioChange1(select){
  564. this.selectTruck = [];
  565. this.selectTruck = select;
  566. },
  567. //主界面表格单选
  568. currentRadioChange(row) {
  569. this.materialId = row.materialId;
  570. this.materialName = row.materialName;
  571. this.saleMaterialId = row.saleMaterialId;
  572. },
  573. //线路表格的单选事件
  574. currentRadioChange5(row){
  575. //存在lineName,赋值,否则初始化
  576. if(row.lineName){
  577. this.cacheLine = row;
  578. }else{
  579. this.cacheLine = {
  580. ROW_ID : 0,
  581. lineDesk : '',
  582. lineId : 0,
  583. lineName : '',
  584. lineNo : '',
  585. lineType : '',
  586. spellNumber : 0,
  587. }
  588. }
  589. },
  590. onClick(num) {
  591. if (num == 1) {
  592. this.drawer = true;
  593. this.lineText = null;
  594. }else if(num == 2){
  595. //再度初始化选择车辆表头
  596. if (getCookie("orgCode") == "chengyunshang") {
  597. this.truck.requestUrl =
  598. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" +
  599. getCookie("userId") + "&i=" + new Date();
  600. } else {
  601. this.truck.requestUrl =
  602. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" + null + "&i=" + new Date();;
  603. }
  604. //后续操作
  605. if(!this.materialId){
  606. this.$message.warning('请选择物资后,再点击')
  607. }else if(!this.lineId){
  608. this.$message.warning('请选择线路后,再点击')
  609. }else{
  610. this.truckDrawer = true;
  611. this.truckText = null;
  612. }
  613. }
  614. },
  615. //线路表格的框计算
  616. selectClick(){
  617. this.line.requestUrl = '/api/v1/rms/getAllLineDesk?apiId=249&lineType=3&con='+this.lineText;
  618. },
  619. //线路表格的确定事件
  620. AddClick(){
  621. if(this.cacheLine.lineName!=''){
  622. this.drawer = false;
  623. this.lineName = this.cacheLine.lineName +" "+ this.cacheLine.lineDesk;
  624. this.lineId = this.cacheLine.lineId;
  625. }
  626. }
  627. },
  628. };
  629. </script>
  630. <style lang='scss'>
  631. .addSaleOrderSend {
  632. .from {
  633. margin-top: 20px;
  634. .line {
  635. display: flex;
  636. justify-content: center;
  637. align-items: center;
  638. .el-input {
  639. width: 350px;
  640. margin-left: 10px;
  641. margin-right: 10px;
  642. }
  643. }
  644. .vehicle {
  645. display: flex;
  646. justify-content: center;
  647. align-items: center;
  648. margin-top: 20px;
  649. .el-button {
  650. width: 250px;
  651. margin-left: 10px;
  652. margin-right: 10px;
  653. }
  654. .span {
  655. width: 70px;
  656. }
  657. }
  658. }
  659. .tablecls{
  660. margin-top: 20px;
  661. }
  662. .button_box{
  663. display: flex;
  664. justify-content: center;
  665. margin: 20px;
  666. .el-button{
  667. width: 100px;
  668. margin-left: 20px;
  669. }
  670. }
  671. }
  672. </style>