addSaleOrderSend.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  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 == 'priceValue'" >
  76. <el-input
  77. style="width: 200px"
  78. v-model="scope.row.priceValue"
  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="70%"
  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="Price"
  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. Price: {
  330. requestUrl: "/api/v1/ams/getAmsContractTransportPrice1?apiId=109&deleted=0",
  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: "priceValue",
  371. label: "运输单价",
  372. width: "300",
  373. slot: true,
  374. },
  375. // {
  376. // prop: "saleShipperAddressName",
  377. // label: "收货地址",
  378. // width: "300",
  379. // slot: true,
  380. // },
  381. {
  382. prop: "saleOrderConsignee",
  383. label: "收货客户",
  384. width: "150",
  385. slot: true,
  386. },
  387. {
  388. prop: "saleOrderConsigneeTel",
  389. label: "收货客户电话号码",
  390. slot: true,
  391. width: "150",
  392. },
  393. ],
  394. truckText:null,
  395. //当前多选选中的车辆
  396. selectTruck:[],
  397. //销售订单与物资表主键
  398. saleMaterialId:null,
  399. //记录点击的市哪一个收货地址的浏览
  400. addressIndex:null,
  401. //缓存当前选中的运输单价
  402. priceMap:{},
  403. };
  404. },
  405. created() {
  406. if (getCookie("orgCode") == "chengyunshang") {
  407. this.truck.requestUrl =
  408. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" +
  409. getCookie("userId");
  410. } else {
  411. this.truck.requestUrl =
  412. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" + null;
  413. }
  414. this.option.requestUrl = "/api/v1/ams/getSaleOrderAndMaterialById?apiId=410&saleOrderId=" + this.$route.params.saleOrderId;
  415. },
  416. methods: {
  417. onInput(val){
  418. if(!isNumber(val)){
  419. this.$message.warning('重量/电话号码请输入数字')
  420. }
  421. },
  422. //点击确定按钮的事件
  423. makeSure(){
  424. let state = false;
  425. this.selectionList.forEach((e)=>{
  426. if(!isNumber(e.orderPlanWeight)){
  427. this.$message.error('重量请输入数字')
  428. }else if(e.saleOrderConsigneeTel){
  429. if(!isNumber(e.saleOrderConsigneeTel)){
  430. this.$message.error('电话号码请输入数字')
  431. }else{
  432. e.saleOrderConsigneeTel = e.saleOrderConsigneeTel+"",
  433. state = true
  434. }
  435. }else {
  436. e.saleOrderConsigneeTel = null,
  437. state = true
  438. }
  439. if(e.saleDateOfReceipt){
  440. e.saleDateOfReceipt = sjTime(e.saleDateOfReceipt)
  441. }
  442. })
  443. if(state){
  444. this.axios.post('/api/v1/ams/dispatchTruckOrderBySale',{
  445. saleOrderId:this.$route.params.saleOrderId,
  446. mapList:this.selectionList,
  447. }).then((res)=>{
  448. console.log("res",res)
  449. if(res.data.code == '200'){
  450. this.$message.success('派车成功')
  451. this.cancel();
  452. }else{
  453. //若该销售订单的净重已达到97%!
  454. this.$confirm("该销售订单的净重已达到97%! 是否仍然派车", "提示", {
  455. confirmButtonText: "确定",
  456. cancelButtonText: "取消",
  457. type: "warning",
  458. center: true,
  459. })
  460. .then(() => {
  461. this.axios.post('/api/v1/ams/dispatchTruckOrderBySale',{
  462. saleOrderId:this.$route.params.saleOrderId,
  463. sendAgain:1,
  464. mapList:this.selectionList,
  465. }).then((res)=>{
  466. if(res.data.code == '200'){
  467. this.$message.success('派车成功')
  468. this.cancel();
  469. }
  470. });
  471. })
  472. .catch(() => {
  473. this.$message({
  474. type: "info",
  475. message: "取消派车!",
  476. });
  477. });
  478. }
  479. })
  480. }else{
  481. this.$message.warning('重量/电话号码请输入数字')
  482. }
  483. },
  484. //点击取消按钮的事件
  485. cancel(){
  486. this.$router.push('/saleOrder')
  487. },
  488. //点击删除按钮删除当前点击的对象
  489. deleteRow(index){
  490. this.selectionList.splice(index,1)
  491. },
  492. //复制的方法
  493. copyRow(index,row){
  494. let arr = [];
  495. for(var i = 0 ;i<this.selectionList.length; i++){
  496. if(i == index){
  497. arr.push(this.selectionList[i]);
  498. arr.push({
  499. capacityId:row.capacityId,
  500. capacityNumber:row.capacityNumber,
  501. carrierName:row.carrierName,
  502. lineId:row.lineId,
  503. lineName:row.lineName,
  504. materialId:row.materialId,
  505. materialName:row.materialName,
  506. orderPlanWeight:row.orderPlanWeight,
  507. saleDateOfReceipt:row.saleDateOfReceipt,
  508. saleMaterialId:row.saleMaterialId,
  509. saleOrderConsignee:row.saleOrderConsignee,
  510. saleOrderConsigneeTel:row.saleOrderConsigneeTel,
  511. priceValue:row.priceValue,
  512. priceId:row.priceId,
  513. saleShippingAddressId:row.saleShippingAddressId,
  514. }
  515. )
  516. }else{
  517. arr.push(this.selectionList[i]);
  518. }
  519. }
  520. this.selectionList = [];
  521. this.selectionList = arr;
  522. },
  523. //收货地址模态窗口的框计算
  524. selectAddressClick(){
  525. this.Price.requestUrl = '/api/v1/ams/getAddressDeliveryAddress?apiId=255&con='+this.addressText;
  526. },
  527. //运输单价模态窗口的点击事件
  528. addAddressClick(){
  529. //priceMap
  530. this.selectionList[this.addressIndex].priceValue = this.priceMap.priceValue
  531. this.selectionList[this.addressIndex].priceId = this.priceMap.priceId
  532. this.addressDrawer = false;
  533. let arr = this.selectionList;
  534. this.selectionList = [];
  535. arr.forEach((e)=>{
  536. this.selectionList.push({
  537. //销售订单与物资表主键
  538. capacityId:e.capacityId,
  539. capacityNumber:e.capacityNumber,
  540. carrierName:e.carrierName,
  541. carrierId:e.carrierId,
  542. lineId:e.lineId,
  543. lineName:e.lineName,
  544. materialId:e.materialId,
  545. materialName:e.materialName,
  546. orderPlanWeight:e.orderPlanWeight,
  547. saleDateOfReceipt:e.saleDateOfReceipt,
  548. saleMaterialId:e.saleMaterialId,
  549. saleOrderConsignee:e.saleOrderConsignee,
  550. saleOrderConsigneeTel:e.saleOrderConsigneeTel,
  551. priceValue:e.priceValue,
  552. priceId:e.priceId,
  553. saleShippingAddressId:e.saleShippingAddressId,
  554. })
  555. })
  556. },
  557. //收货地址点击浏览的事件
  558. select(index){
  559. this.addressDrawer = true;
  560. this.addressIndex = index ;
  561. },
  562. //收货地址模态框单选选中的事件
  563. currentRadioChange2(val){
  564. this.priceMap = {};
  565. this.priceMap = val;
  566. },
  567. //车辆模态框的确定事件
  568. AddTruckClick(){
  569. if(this.selectTruck.length>0){
  570. this.selectTruck.forEach(e => {
  571. this.selectionList.push({
  572. //销售订单与物资表主键
  573. saleMaterialId:this.saleMaterialId,
  574. capacityId:e.capacityId,
  575. carrierId:e.carrierId,
  576. capacityNumber:e.capacityNumber,
  577. carrierName:e.carrierName,
  578. materialName:this.materialName,
  579. materialId:this.materialId,
  580. lineName:this.lineName,
  581. lineId:this.lineId,
  582. })
  583. });
  584. this.truckDrawer = false;
  585. //置空当前多选选中的车辆数据
  586. this.selectTruck = [];
  587. }
  588. },
  589. //车辆模态框框计算
  590. selectTruckClick(){
  591. if (getCookie("orgCode") == "chengyunshang") {
  592. this.truck.requestUrl =
  593. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" +
  594. getCookie("userId") + "&index="+this.truckText;
  595. } else {
  596. this.truck.requestUrl =
  597. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" + null + "&index="+this.truckText;
  598. }
  599. },
  600. //车辆表格
  601. currentRadioChange1(select){
  602. this.selectTruck = [];
  603. this.selectTruck = select;
  604. },
  605. //主界面表格单选
  606. currentRadioChange(row) {
  607. this.materialId = row.materialId;
  608. this.materialName = row.materialName;
  609. this.saleMaterialId = row.saleMaterialId;
  610. },
  611. //线路表格的单选事件
  612. currentRadioChange5(row){
  613. //存在lineName,赋值,否则初始化
  614. if(row.lineName){
  615. this.cacheLine = row;
  616. }else{
  617. this.cacheLine = {
  618. ROW_ID : 0,
  619. lineDesk : '',
  620. lineId : 0,
  621. lineName : '',
  622. lineNo : '',
  623. lineType : '',
  624. spellNumber : 0,
  625. }
  626. }
  627. },
  628. onClick(num) {
  629. if (num == 1) {
  630. this.drawer = true;
  631. this.lineText = null;
  632. }else if(num == 2){
  633. //再度初始化选择车辆表头
  634. if (getCookie("orgCode") == "chengyunshang") {
  635. this.truck.requestUrl =
  636. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" +
  637. getCookie("userId") + "&i=" + new Date();
  638. } else {
  639. this.truck.requestUrl =
  640. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=248&carrierSsoId=" + null + "&i=" + new Date();;
  641. }
  642. //后续操作
  643. if(!this.materialId){
  644. this.$message.warning('请选择物资后,再点击')
  645. }else if(!this.lineId){
  646. this.$message.warning('请选择线路后,再点击')
  647. }else{
  648. this.truckDrawer = true;
  649. this.truckText = null;
  650. }
  651. }
  652. },
  653. //线路表格的框计算
  654. selectClick(){
  655. this.line.requestUrl = '/api/v1/rms/getAllLineDesk?apiId=249&lineType=3&con='+this.lineText;
  656. },
  657. //线路表格的确定事件
  658. AddClick(){
  659. if(this.cacheLine.lineName!=''){
  660. this.drawer = false;
  661. this.lineName = this.cacheLine.lineName +" "+ this.cacheLine.lineDesk;
  662. this.lineId = this.cacheLine.lineId;
  663. }
  664. }
  665. },
  666. };
  667. </script>
  668. <style lang='scss'>
  669. .addSaleOrderSend {
  670. .from {
  671. margin-top: 20px;
  672. .line {
  673. display: flex;
  674. justify-content: center;
  675. align-items: center;
  676. .el-input {
  677. width: 350px;
  678. margin-left: 10px;
  679. margin-right: 10px;
  680. }
  681. }
  682. .vehicle {
  683. display: flex;
  684. justify-content: center;
  685. align-items: center;
  686. margin-top: 20px;
  687. .el-button {
  688. width: 250px;
  689. margin-left: 10px;
  690. margin-right: 10px;
  691. }
  692. .span {
  693. width: 70px;
  694. }
  695. }
  696. }
  697. .tablecls{
  698. margin-top: 20px;
  699. }
  700. .button_box{
  701. display: flex;
  702. justify-content: center;
  703. margin: 20px;
  704. .el-button{
  705. width: 100px;
  706. margin-left: 20px;
  707. }
  708. }
  709. }
  710. </style>