addSaleOrderSend.vue 19 KB

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