purInwardTruckOrder.vue 13 KB

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