purInwardTruckOrder.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. //运输派单
  2. <template>
  3. <div class="transportOrder">
  4. <div class="transportOrder_top">
  5. <el-input placeholder="请输入内容" v-model="input" clearable> </el-input>
  6. <el-button type="primary" class="btn" @click="getRequestUrl">
  7. <i class="el-icon-search"></i>查询
  8. </el-button>
  9. <el-badge
  10. :value="addPlanCount"
  11. class="item"
  12. v-if="activeName == 'first'"
  13. style="margin-left:10px"
  14. >
  15. <el-button type="primary" @click="Insert" v-if="activeName == 'first'">
  16. <i class="el-icon-plus"></i>新增
  17. </el-button>
  18. </el-badge>
  19. </div>
  20. <el-dialog
  21. title="车辆信息"
  22. :visible.sync="dialogTableVisible"
  23. :before-close="handleClose"
  24. >
  25. <dilTable
  26. v-bind.sync="truck"
  27. @radio-change="currentRadioChange1"
  28. ></dilTable>
  29. <span slot="footer" class="dialog-footer">
  30. <el-button @click="dialogTableVisible = false">取 消</el-button>
  31. <el-button type="primary" @click="updateTruckCapacity()"
  32. >确 定</el-button
  33. >
  34. </span>
  35. </el-dialog>
  36. <div class="transportOrder_bottom">
  37. <el-tabs v-model="activeName">
  38. <!-- 已下发 -->
  39. <el-tab-pane label="未接收" name="first">
  40. <dilTable v-bind.sync="first">
  41. <el-table-column fixed="right" label="操作" width="100">
  42. <template slot-scope="scope">
  43. <el-button @click="updateClick(scope)" type="text" size="small">
  44. 修改
  45. </el-button>
  46. <el-button @click="deleteClick(scope)" type="text" size="small">
  47. 删除
  48. </el-button>
  49. </template>
  50. </el-table-column>
  51. </dilTable>
  52. </el-tab-pane>
  53. <!-- 已接收 -->
  54. <el-tab-pane label="已接收" name="Received">
  55. <dilTable v-bind.sync="Received">
  56. <el-table-column fixed="right" label="操作" width="100">
  57. <template slot-scope="scope">
  58. <el-button @click="deleteClick(scope)" type="text" size="small">
  59. 关闭
  60. </el-button>
  61. </template>
  62. </el-table-column>
  63. </dilTable>
  64. </el-tab-pane>
  65. <!-- 已完成 -->
  66. <el-tab-pane label="已完成" name="completed">
  67. <dilTable v-bind.sync="completed"> </dilTable>
  68. </el-tab-pane>
  69. <!-- 已派单 -->
  70. <el-tab-pane label="已派单" name="dispatched">
  71. <dilTable v-bind.sync="dispatched">
  72. <el-table-column fixed="right" label="操作" width="100">
  73. <template slot-scope="scope">
  74. <el-button
  75. @click="continueDispatch(scope)"
  76. type="text"
  77. size="small"
  78. v-if="scope.row.enable1 == 1"
  79. >
  80. 继续分解
  81. </el-button>
  82. </template>
  83. </el-table-column>
  84. </dilTable>
  85. </el-tab-pane>
  86. </el-tabs>
  87. </div>
  88. </div>
  89. </template>
  90. <script>
  91. import { getCookie } from "@/utils/util.js";
  92. export default {
  93. data() {
  94. return {
  95. //模态窗的框计算
  96. inputText: null,
  97. //是否弹出对话框
  98. dialogTableVisible: false,
  99. //输入框的值
  100. input: null,
  101. //选项卡的当前选中的值
  102. activeName: "first",
  103. //已下发的表格
  104. first: {
  105. requestUrl: ""
  106. },
  107. //车辆信息的表格
  108. truck: {
  109. requestUrl: "",
  110. // 控制显示当选列
  111. selectionType: "radio"
  112. },
  113. Received: {
  114. requestUrl: ""
  115. },
  116. completed: {
  117. requestUrl: ""
  118. },
  119. dispatched: {
  120. requestUrl: ""
  121. },
  122. //车辆的表格
  123. truck: {
  124. requestUrl: "",
  125. selectionType: "radio"
  126. },
  127. //当前选中的订单id
  128. selectOrderId: null,
  129. //选中的车辆号
  130. capacityNumber: "",
  131. //选中的运力id
  132. capacityId: null,
  133. //是否关闭模态框
  134. drawer: false,
  135. //模态框从左往右打开
  136. direction: "rtl",
  137. orderId: null,
  138. //多选的选中的订单id
  139. selectionList: [],
  140. //区别点击的是添加运力,还是修改
  141. index: null,
  142. // wssUrl: "wss:wl.dasteel.cn:32322/websocket/socketServer",
  143. // actiones: { username: "湘M99999" } //传入后台的数据
  144. addPlanCount: 0,
  145. timer: null
  146. };
  147. },
  148. created() {
  149. if (getCookie("orgCode") == "chengyunshang") {
  150. this.truck.requestUrl =
  151. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId=" +
  152. getCookie("userId");
  153. } else {
  154. this.truck.requestUrl =
  155. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId=" + null;
  156. }
  157. if (getCookie("orgCode") == "chengyunshang") {
  158. this.first.requestUrl =
  159. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=4&planEnableStatus=1&carrierId=" +
  160. getCookie("userId");
  161. this.Received.requestUrl =
  162. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=5&carrierId=" +
  163. getCookie("userId");
  164. this.completed.requestUrl =
  165. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=2&carrierId=" +
  166. getCookie("userId");
  167. this.dispatched.requestUrl =
  168. "/api/v1/ams/getPurRequirementList?apiId=431&requirementStatus=1&planStatus=3&carrierSsoId=" +
  169. getCookie("userId");
  170. } else if (
  171. getCookie("orgCode") == "dagangadmin" ||
  172. getCookie("orgCode") == "zidonghuabu"
  173. ) {
  174. this.first.requestUrl =
  175. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=4&planEnableStatus=1";
  176. this.Received.requestUrl =
  177. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=5";
  178. this.completed.requestUrl =
  179. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=2";
  180. this.dispatched.requestUrl =
  181. "/api/v1/ams/getPurRequirementList?apiId=431&requirementStatus=1&planStatus=3";
  182. } else {
  183. this.first.requestUrl =
  184. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=4&planEnableStatus=1&userId="+getCookie("orgCode");
  185. this.Received.requestUrl =
  186. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=5&userId="+getCookie("orgCode");
  187. this.completed.requestUrl =
  188. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=2&userId="+getCookie("orgCode");
  189. this.dispatched.requestUrl =
  190. "/api/v1/ams/getPurRequirementList?apiId=431&requirementStatus=1&planStatus=3&userId="+getCookie("orgCode");
  191. }
  192. // this.initWebSocket();
  193. },
  194. mounted() {
  195. this.getAddPlan();
  196. this.timer = setInterval(this.getAddPlan, 10000);
  197. },
  198. beforeDestroy() {
  199. clearInterval(this.timer);
  200. },
  201. methods: {
  202. getAddPlan() {
  203. this.axios
  204. .post(
  205. "/api/v1/ams/getPurRequirementList?apiId=431&requirementStatus=1&enableStatus=1&planStatus=2&pageNum=1&pageSize=10"
  206. )
  207. .then(res => {
  208. console.log("data:", res.data.data);
  209. this.addPlanCount = res.data.data.total;
  210. });
  211. },
  212. //建立websocket连接
  213. initWebSocket() {
  214. //试图调用websocket
  215. //初始化weosocket
  216. const wssUrl = this.wssUrl;
  217. this.websock = new WebSocket(wssUrl);
  218. this.websock.onmessage = this.websocketonmessage;
  219. this.websock.onopen = this.websocketonopen;
  220. this.websock.onerror = this.websocketonerror;
  221. // this.websock.onclose = this.websocketclose;
  222. },
  223. //发送数据
  224. websocketonopen() {
  225. this.websocketsend();
  226. },
  227. //接收数据
  228. websocketonmessage(e) {
  229. console.log("收到信息");
  230. let data = e.data;
  231. console.log(data);
  232. let websocketKey = data.messageContent;
  233. let userName = "湘M99999";
  234. let message =
  235. "{'messageContent': '" +
  236. websocketKey +
  237. ":" +
  238. userName +
  239. "','messageType':1,'receivePerson': 'app','sendPerson': 'self'}";
  240. this.websocketsend(message);
  241. },
  242. //连接建立失败重连
  243. websocketonerror() {
  244. this.initWebSocket();
  245. },
  246. //发送数据
  247. websocketsend(message) {
  248. this.websock.send({ message, async success() {} });
  249. },
  250. //关闭连接
  251. websocketclose(e) {
  252. console.log("断开连接", e);
  253. },
  254. continueDispatch(scope) {
  255. this.$router.push("/addPurInwardOrderCon/" + scope.row.planId);
  256. },
  257. onclick() {
  258. console.log();
  259. },
  260. handleClose(done) {
  261. done();
  262. this.$message.info("取消修改运力");
  263. },
  264. getRequestUrl() {
  265. if (getCookie("orgCode") == "chengyunshang") {
  266. this.first.requestUrl =
  267. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=4&planEnableStatus=1&carrierId=" +
  268. this.carrierUserId +
  269. "&test=" +
  270. new Date()+
  271. "&con="+this.input,
  272. this.Received.requestUrl =
  273. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=5&planEnableStatus=1&carrierId=" +
  274. this.carrierUserId +
  275. "&test=" +
  276. new Date()+
  277. "&con="+this.input,
  278. this.completed.requestUrl =
  279. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=2&carrierId=" +
  280. getCookie("userId")+
  281. "&con="+this.input;
  282. } else if (
  283. getCookie("orgCode") == "dagangadmin" ||
  284. getCookie("orgCode") == "zidonghuabu"
  285. ) {
  286. this.first.requestUrl =
  287. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=4&planEnableStatus=1" +
  288. "&test=" +
  289. new Date()+
  290. "&con="+this.input;
  291. this.Received.requestUrl =
  292. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=5" +
  293. "&test=" +
  294. new Date()+
  295. "&con="+this.input;
  296. this.completed.requestUrl =
  297. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=2"+
  298. "&test=" +
  299. new Date()+
  300. "&con="+this.input;
  301. } else {
  302. this.first.requestUrl =
  303. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=4&planEnableStatus=1" +
  304. "&test=" +
  305. new Date()+
  306. "&con="+this.input+
  307. "&userId="+getCookie("orgCode");
  308. this.Received.requestUrl =
  309. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=5" +
  310. "&test=" +
  311. new Date()+
  312. "&con="+this.input+
  313. "&userId="+getCookie("orgCode");
  314. this.completed.requestUrl =
  315. "/api/v1/oms/getPurInwardOrderList?apiId=432&orderStatus=2"+
  316. "&test=" +
  317. new Date()+
  318. "&con="+this.input+
  319. "&userId="+getCookie("orgCode");
  320. }
  321. },
  322. getTruckRequestUrl() {
  323. if (getCookie("orgCode") == "chengyunshang") {
  324. this.truck.requestUrl =
  325. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId=" +
  326. getCookie("userId") +
  327. "&test=" +
  328. new Date();
  329. } else {
  330. this.truck.requestUrl =
  331. "/api/v1/uc/getAllCapacityByCarrierLike?apiId=429&carrierSsoId=" +
  332. null +
  333. "&test=" +
  334. new Date();
  335. }
  336. },
  337. currentRadioChange1(row) {
  338. console.log(row);
  339. this.capacityId = row.capacityId;
  340. },
  341. //删除运输订单
  342. deleteClick(scope) {
  343. let map = {
  344. orderId: scope.row.orderId,
  345. userId: getCookie("userId")
  346. };
  347. this.$confirm("是否删除?", "提示", {
  348. confirmButtonText: "确定",
  349. cancelButtonText: "取消",
  350. type: "warning"
  351. })
  352. .then(() => {
  353. this.axios.post("/api/v1/oms/closeOmstruckOrder", map).then(res => {
  354. if (res.data.code == 200) {
  355. this.$message({
  356. type: "success",
  357. message: "删除成功!"
  358. });
  359. this.getRequestUrl();
  360. } else {
  361. this.$message({
  362. message: "删除失败",
  363. type: "warning"
  364. });
  365. }
  366. });
  367. })
  368. .catch(() => {
  369. this.$message({
  370. type: "info",
  371. message: "已取消删除"
  372. });
  373. });
  374. },
  375. //修改运输订单
  376. updateClick(scope) {
  377. this.getTruckRequestUrl();
  378. this.orderId = scope.row.orderId;
  379. this.dialogTableVisible = true;
  380. console.log(scope.row.orderId);
  381. },
  382. updateTruckCapacity() {
  383. if (this.capacityId == null) {
  384. this.$message.error("未选中运力");
  385. return;
  386. }
  387. this.axios
  388. .post("/api/v1/oms/updateCapacityId", {
  389. capacityId: this.capacityId,
  390. orderId: this.orderId
  391. })
  392. .then(res => {
  393. if (res.data.code == "200") {
  394. this.$message.success("修改运力成功");
  395. this.getRequestUrl();
  396. this.dialogTableVisible = false;
  397. } else {
  398. this.$message.error("修改运力失败");
  399. }
  400. });
  401. },
  402. handleClick(tab, event) {
  403. this.getRequestUrl();
  404. },
  405. Insert() {
  406. this.$router.push("addPurInwardOrder");
  407. }
  408. }
  409. };
  410. </script>
  411. <style lang="scss">
  412. .transportOrder {
  413. .transportOrder_top {
  414. width: 100%;
  415. height: 100px;
  416. display: flex;
  417. align-items: center;
  418. padding-left: 50px;
  419. .el-input {
  420. width: 20%;
  421. }
  422. }
  423. .transportOrder_bottom {
  424. margin-left: 20px;
  425. margin-top: 20px;
  426. }
  427. .drawer_top {
  428. width: 100%;
  429. height: 50px;
  430. padding-left: 20px;
  431. display: flex;
  432. align-items: center;
  433. }
  434. }
  435. </style>