addRequirement.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. <template>
  2. <!-- 新增运输作业页面 -->
  3. <div class="addPurRequirement">
  4. <page-title>运输预约</page-title>
  5. <div class="purchaseOrder from">
  6. <span class="text">卸货厂区:</span>
  7. <el-select
  8. v-model="purchaseOrgId"
  9. placeholder="请选择"
  10. @change="onchange()"
  11. ref="selectlb"
  12. >
  13. <el-option
  14. v-for="item in purchaseOrgList"
  15. :key="item.value"
  16. :label="item.label"
  17. :value="item.value"
  18. >
  19. </el-option>
  20. </el-select>
  21. </div>
  22. <div class="material from">
  23. <span class="text">物资:</span>
  24. <el-input class="input" v-model="materialName" disabled> </el-input>
  25. <el-button type="primary" @click="ondrawer(1)">浏览</el-button>
  26. </div>
  27. <div class="forwardingUnit from">
  28. <span class="text">发货单位:</span>
  29. <el-input class="input" v-model="supplierName" disabled> </el-input>
  30. <el-button type="primary" @click="ondrawer(2)">浏览</el-button>
  31. </div>
  32. <div class="shipName from">
  33. <el-form :inline="true" class="demo-form-inline" label-width="80px">
  34. <el-form-item label="船名:">
  35. <el-autocomplete
  36. class="inline-input"
  37. v-model="stateConsignee"
  38. :fetch-suggestions="querySearchConsignee"
  39. placeholder="请输入船名"
  40. :trigger-on-focus="false"
  41. @select="handleSelectConsignee"
  42. @input="onInputShipName"
  43. >
  44. <template slot-scope="{ item }">
  45. <div class="name">{{ item.value }}</div>
  46. </template>
  47. </el-autocomplete>
  48. </el-form-item>
  49. </el-form>
  50. </div>
  51. <div class="forwardingUnit from">
  52. <span class="text">装货点:</span>
  53. <el-input class="input" v-model="loadPointName" disabled> </el-input>
  54. <el-button type="primary" @click="ondrawer(5)">浏览</el-button>
  55. </div>
  56. <div class="forwardingUnit from">
  57. <span class="text">卸货点:</span>
  58. <el-input class="input" v-model="unloadPointName" disabled> </el-input>
  59. <el-button type="primary" @click="ondrawer(4)">浏览</el-button>
  60. </div>
  61. <div class="forwardingUnit from">
  62. <span class="text">采购订单号:</span>
  63. <el-input class="input" v-model="purchaseOrderNo" disabled> </el-input>
  64. <el-button type="primary" @click="ondrawer(6)">浏览</el-button>
  65. </div>
  66. <div class="carrier from">
  67. <el-form :inline="true" class="demo-form-inline" label-width="80px">
  68. <el-form-item label="选择承运商:">
  69. <el-autocomplete
  70. class="inline-input"
  71. v-model="stateCarrier"
  72. :fetch-suggestions="querySearchCarrier"
  73. placeholder="请输入承运商名称"
  74. :trigger-on-focus="false"
  75. @select="handleSelectCarrier"
  76. >
  77. <template slot-scope="{ item }">
  78. <div class="name">{{ item.carrierName }}</div>
  79. </template>
  80. </el-autocomplete>
  81. </el-form-item>
  82. </el-form>
  83. </div>
  84. <!-- 模态窗口 -->
  85. <el-drawer :visible.sync="drawer" :direction="direction" size="40%">
  86. <div style="margin-bottom: 10px">
  87. <el-input
  88. placeholder="请输入内容"
  89. v-model="input"
  90. style="margin-top: 10px; margin-right: 10px; width: 250px"
  91. clearable
  92. ></el-input>
  93. <el-button type="primary" class="btn" @click="onclick(a)">
  94. <i class="el-icon-search"></i>查询
  95. </el-button>
  96. </div>
  97. <div v-show="a == 1">
  98. <dilTable
  99. v-bind.sync="frist"
  100. @radio-change="currentRadioChange1"
  101. ></dilTable>
  102. </div>
  103. <div v-show="a == 2">
  104. <dilTable
  105. v-bind.sync="secend"
  106. @radio-change="currentRadioChange2"
  107. ></dilTable>
  108. </div>
  109. <div v-show="a == 3">
  110. <dilTable
  111. v-bind.sync="third"
  112. @selection-change="currentRadioChange3"
  113. ></dilTable>
  114. </div>
  115. <div v-show="a == 4">
  116. <dilTable
  117. v-bind.sync="unloadPoint"
  118. @radio-change="currentRadioChange4"
  119. ></dilTable>
  120. </div>
  121. <div v-show="a == 5">
  122. <dilTable
  123. v-bind.sync="loadPoint"
  124. @radio-change="currentRadioChange5"
  125. ></dilTable>
  126. </div>
  127. <div v-show="a == 6">
  128. <dilTable
  129. v-bind.sync="purchaseOrder"
  130. @radio-change="currentRadioChange6"
  131. ></dilTable>
  132. </div>
  133. </el-drawer>
  134. <div class="button_box">
  135. <el-button @click="onClickCancel">返回</el-button>
  136. <el-button type="primary" @click="onClickConfirm" :disabled="disabled"
  137. >确认</el-button
  138. >
  139. </div>
  140. </div>
  141. </template>
  142. <script>
  143. import PageTitle from "@/components/Page/Title";
  144. import { sjTime, isNumber, isIntegerNumber } from "@/utils/sharedJsFile";
  145. import { getCookie } from "@/utils/util.js";
  146. export default {
  147. components: { PageTitle },
  148. data() {
  149. return {
  150. disabled: false,
  151. //船名
  152. remark: null,
  153. rangeId: null,
  154. stateConsignee: null,
  155. consigneeId: null,
  156. //车辆表格数据
  157. selectionList: [],
  158. stateCarrier: null,
  159. purchaseOrgId: null,
  160. // 表单
  161. form1: {},
  162. //采购订单号
  163. purchaseOrderNo: "",
  164. //采购订单id
  165. purchaseOrderId: "",
  166. //物资名称
  167. materialName: "",
  168. //发货单位名称
  169. supplierName: "",
  170. //发货单位id
  171. supplierId: null,
  172. carrierId: null,
  173. //物资id
  174. materialId: null,
  175. //是否需要打开模态窗口
  176. drawer: false,
  177. //卸货点id
  178. unloadPointId: "",
  179. //卸货点名称
  180. unloadPointName: "",
  181. //装货点id
  182. loadPointId: null,
  183. loadPointName: null,
  184. a: 1,
  185. direction: "rtl",
  186. input: "",
  187. frist: {
  188. requestUrl: "/api/v1/uc/queryAPOMaterialByLike?apiId=244&startNum=050",
  189. selectionType: "radio",
  190. mapList1: []
  191. },
  192. secend: {
  193. requestUrl:
  194. "/api/v1/uc/getSupplierMesByMaterialId?apiId=247&materialId=",
  195. selectionType: "radio",
  196. mapList2: []
  197. },
  198. third: {
  199. requestUrl: "",
  200. selectionType: "select",
  201. mapList3: []
  202. },
  203. unloadPoint: {
  204. requestUrl: "",
  205. selectionType: "radio"
  206. },
  207. loadPoint: {
  208. requestUrl: "",
  209. selectionType: "radio"
  210. },
  211. purchaseOrder: {
  212. requestUrl: "",
  213. selectionType: "radio"
  214. },
  215. purchaseOrgLable: null,
  216. purchaseOrgList: [
  217. {
  218. value: 1,
  219. label: "一厂"
  220. },
  221. {
  222. value: 2,
  223. label: "二厂"
  224. }
  225. ]
  226. };
  227. },
  228. watch: {
  229. drawer(val) {
  230. if (!val) {
  231. this.input = null;
  232. }
  233. }
  234. },
  235. created() {},
  236. methods: {
  237. onClick(index) {
  238. this.selectionList.splice(index, 1);
  239. },
  240. onInputShipName() {
  241. if (this.materialId == null) {
  242. this.$message.warning("请先选择物资!");
  243. return;
  244. }
  245. },
  246. onBlur() {
  247. this.getPurchaseOrderNo();
  248. },
  249. onchange() {
  250. this.getPurchaseOrderNo();
  251. console.log(this.purchaseOrgId);
  252. if (this.purchaseOrgId == 1) {
  253. this.purchaseOrgLable = "一厂";
  254. this.rangeId = 2;
  255. } else {
  256. this.purchaseOrgLable = "二厂";
  257. this.rangeId = 3;
  258. }
  259. },
  260. getPurchaseOrderNo() {
  261. let map = {
  262. materialId: this.materialId,
  263. supplierId: this.supplierId,
  264. purchaseOrgId: this.purchaseOrgId
  265. };
  266. if (this.stateConsignee) {
  267. map.remark = this.stateConsignee;
  268. }
  269. console.log(map);
  270. if (this.materialId && this.supplierId && this.purchaseOrgId) {
  271. this.axios.post("/api/v1/oms/selectNewOrderId", map).then(res => {
  272. console.log(res);
  273. if (res.data.code == "200") {
  274. if (res.data.data == null) {
  275. this.$message({
  276. message: "没有匹配的采购订单号!",
  277. type: "warning"
  278. });
  279. this.purchaseOrderNo = null;
  280. this.purchaseOrderId = null;
  281. this.remark = null;
  282. this.stateConsignee = null;
  283. this.form1 = [];
  284. } else {
  285. console.log();
  286. console.log(res.data.data);
  287. this.stateConsignee = res.data.data.remark;
  288. this.purchaseOrderId = res.data.data.purchaseOrderId;
  289. this.purchaseOrderNo = res.data.data.purchaseOrderNo;
  290. }
  291. } else {
  292. this.$message.error("请求失败");
  293. }
  294. });
  295. }
  296. },
  297. onclick(a) {
  298. if (a == 1) {
  299. this.frist.requestUrl =
  300. "/api/v1/uc/queryAPOMaterialByLike?apiId=244&startNum=050&index=" +
  301. this.input;
  302. } else if (a == 2) {
  303. this.secend.requestUrl =
  304. "/api/v1/uc/getSupplierMesByMaterialId?apiId=247&materialId=" +
  305. this.materialId +
  306. "&index=" +
  307. this.input;
  308. } else if (a == 4) {
  309. this.unloadPoint.requestUrl =
  310. "/api/v1/uc/getUnloadingMesByLike?apiId=374&index=" +
  311. this.input +
  312. "&i=" +
  313. new Date();
  314. } else if (a == 5) {
  315. this.loadPoint.requestUrl =
  316. "/api/v1/uc/getUnloadingMesByLike?apiId=374&index=" +
  317. this.input +
  318. "&i=" +
  319. new Date();
  320. } else if (a == 6) {
  321. this.purchaseOrder.requestUrl =
  322. "/api/v1/ams/getPurchaseOrderList?apiId=81&sendCompId=" +
  323. this.supplierId +
  324. "&con=" +
  325. this.input +
  326. "&i=" +
  327. new Date();
  328. }
  329. },
  330. ondrawer(num) {
  331. this.drawer = true;
  332. this.a = num;
  333. if (num == 2) {
  334. this.secend.requestUrl =
  335. "/api/v1/uc/getSupplierMesByMaterialId?apiId=247&materialId=" +
  336. this.materialId +
  337. "&i=" +
  338. new Date();
  339. } else if (num == 4) {
  340. this.unloadPoint.requestUrl =
  341. "/api/v1/uc/getUnloadingMesByLike?apiId=374" + "&i=" + new Date();
  342. } else if (num == 5) {
  343. this.loadPoint.requestUrl =
  344. "/api/v1/uc/getUnloadingMesByLike?apiId=374" + "&i=" + new Date();
  345. } else if (num == 6) {
  346. this.purchaseOrder.requestUrl =
  347. "/api/v1/ams/getPurchaseOrderList?apiId=81&sendCompId=" +
  348. this.supplierId +
  349. "&i=" +
  350. new Date();
  351. }
  352. },
  353. //承运商弹出层
  354. handleSelectCarrier(item) {
  355. this.carrierId = item.carrierId;
  356. item.carrierName = this.stateCarrier;
  357. },
  358. //以下是承运商边输边查搜索
  359. querySearchCarrier(queryString, cb) {
  360. this.axios
  361. .post("/api/v1/uc/getCarrierMesByLike?index=" + queryString)
  362. .then(res => {
  363. if (res.data.code == "200") {
  364. var restaurantsCarrier = res.data.data;
  365. console.log(restaurantsCarrier, "restaurantsCarrier");
  366. var results = queryString
  367. ? restaurantsCarrier.filter(this.createFilterCarrier(queryString))
  368. : restaurantsCarrier;
  369. // 调用 callback 返回建议列表的数据
  370. cb(results);
  371. }
  372. });
  373. },
  374. createFilterCarrier(queryString) {
  375. return restaurantsCarrier => {
  376. return (
  377. restaurantsCarrier.value
  378. .toLowerCase()
  379. .indexOf(queryString.toLowerCase()) > -1
  380. );
  381. };
  382. },
  383. //以上是承运商边输边查搜索
  384. // 返回
  385. onClickCancel() {
  386. this.$router.push("/purInwardRequirement");
  387. },
  388. //选择物资
  389. currentRadioChange1(selection) {
  390. this.materialName = selection.materialName;
  391. this.materialId = selection.materialId;
  392. this.getPurchaseOrderNo();
  393. },
  394. //选择发货单位
  395. currentRadioChange2(selection) {
  396. this.supplierName = selection.supplierName;
  397. this.supplierId = selection.supplierId;
  398. this.getPurchaseOrderNo();
  399. },
  400. //选择卸货点
  401. currentRadioChange4(selection) {
  402. this.unloadPointId = selection.warehouseId;
  403. this.unloadPointName = selection.warehouseName;
  404. },
  405. //选择装货点
  406. currentRadioChange5(selection) {
  407. this.loadPointId = selection.warehouseId;
  408. this.loadPointName = selection.warehouseName;
  409. },
  410. //选择采购订单
  411. currentRadioChange6(selection) {
  412. console.log(selection);
  413. if (selection.orgId == 1) {
  414. this.purchaseOrgLable = "一厂";
  415. this.purchaseOrgId = 1;
  416. } else {
  417. this.purchaseOrgLable = "二厂";
  418. this.purchaseOrgId = 2;
  419. }
  420. this.materialName = selection.materialName;
  421. this.materialId = selection.materialId;
  422. this.supplierId = selection.supplierId;
  423. this.supplierName = selection.supplierName;
  424. this.purchaseOrderNo = selection.purchaseOrderNo;
  425. this.purchaseOrderId = selection.purchaseOrderId;
  426. this.stateConsignee = selection.resultForeignShipName;
  427. },
  428. currentRadioChange3(selection) {
  429. this.selectionList = [];
  430. this.selectionList = selection;
  431. },
  432. //收货单位弹出层
  433. handleSelectConsignee(item) {
  434. this.supplierName = item.supplierName;
  435. this.supplierId = item.supplierId;
  436. this.purchaseOrderId = item.purchaseOrderId;
  437. this.purchaseOrderNo = item.purchaseOrderNo;
  438. item.value = this.shipName;
  439. },
  440. //以下是收货单位边输边查搜索
  441. querySearchConsignee(queryString, cb) {
  442. if (this.materialId) {
  443. this.axios
  444. .post(
  445. "/api/v1/uc/getShipNameMesByLike?index=" +
  446. queryString +
  447. "&materialId= " +
  448. parseInt(this.materialId)
  449. )
  450. .then(res => {
  451. if (res.data.code == "200") {
  452. console.log(res);
  453. var restaurantsConsignee = res.data.data;
  454. var results = queryString
  455. ? restaurantsConsignee.filter(
  456. this.createFilterConsignee(queryString)
  457. )
  458. : restaurantsConsignee;
  459. // 调用 callback 返回建议列表的数据
  460. cb(results);
  461. }
  462. });
  463. }
  464. },
  465. createFilterConsignee(queryString) {
  466. return restaurantsConsignee => {
  467. return (
  468. restaurantsConsignee.value
  469. .toLowerCase()
  470. .indexOf(queryString.toLowerCase()) > -1
  471. );
  472. };
  473. },
  474. //以上是返回单位边输边查搜索
  475. // 确认
  476. onClickConfirm() {
  477. console.log(
  478. this.purchaseOrgLable,
  479. this.materialName,
  480. this.supplierName,
  481. this.purchaseOrderNo,
  482. this.unloadPointName,
  483. this.loadPointName,
  484. this.stateCarrier
  485. );
  486. this.disabled = true;
  487. var state = 0;
  488. if (
  489. this.materialId &&
  490. this.supplierId &&
  491. this.purchaseOrderId &&
  492. this.unloadPointId
  493. ) {
  494. state = 1;
  495. } else {
  496. if (!this.materialId) {
  497. this.$message({
  498. message: "请选择物资!",
  499. type: "warning"
  500. });
  501. this.disabled = false;
  502. } else if (!this.supplierId) {
  503. this.$message({
  504. message: "请选择发货单位!",
  505. type: "warning"
  506. });
  507. this.disabled = false;
  508. } else if (!this.purchaseOrderId) {
  509. this.$message({
  510. message: "没有匹配的采购订单号!",
  511. type: "warning"
  512. });
  513. this.disabled = false;
  514. } else if (!this.unloadPointId) {
  515. this.$message({
  516. message: "请选择卸货地点!",
  517. type: "warning"
  518. });
  519. this.disabled = false;
  520. }
  521. }
  522. if (state == 1) {
  523. let map = {
  524. materialId: this.materialId,
  525. purchaseOrderId: this.purchaseOrderId,
  526. unloadPointId: this.unloadPointId,
  527. loadPointId: this.loadPointId,
  528. carrierId: this.carrierId,
  529. rangeId: this.rangeId,
  530. userId: getCookie("orgCode")
  531. };
  532. console.log(map, map);
  533. this.axios
  534. .post("/api/v1/ams/addPurInwardRequirement", map)
  535. .then(res => {
  536. if (res.data.code == "200") {
  537. this.$message({
  538. message: "添加成功!",
  539. type: "success"
  540. });
  541. this.disabled = false;
  542. this.onClickCancel();
  543. }
  544. });
  545. }
  546. }
  547. }
  548. };
  549. </script>
  550. <style lang="scss" scope>
  551. .addPurRequirement {
  552. .contractDetails {
  553. width: 100%;
  554. }
  555. .from {
  556. display: flex;
  557. align-items: center;
  558. justify-content: center;
  559. margin-top: 5px;
  560. margin-bottom: 20px;
  561. }
  562. .remark {
  563. display: flex;
  564. justify-content: center;
  565. .text {
  566. display: inline-block;
  567. width: 100px;
  568. text-align: right;
  569. }
  570. .input {
  571. width: 250px;
  572. margin-right: 20px;
  573. }
  574. }
  575. .lineId {
  576. display: flex;
  577. justify-content: center;
  578. .text {
  579. display: inline-block;
  580. width: 170px;
  581. text-align: right;
  582. }
  583. .input {
  584. width: 250px;
  585. margin-right: 20px;
  586. }
  587. }
  588. .shipName {
  589. display: flex;
  590. justify-content: center;
  591. align-items: center;
  592. .el-form {
  593. .el-form-item {
  594. .el-input {
  595. width: 250px;
  596. }
  597. }
  598. }
  599. }
  600. .material {
  601. display: flex;
  602. justify-content: center;
  603. margin-top: 20px;
  604. .text {
  605. display: inline-block;
  606. width: 170px;
  607. text-align: right;
  608. }
  609. .input {
  610. width: 250px;
  611. margin-right: 20px;
  612. }
  613. }
  614. .orderType {
  615. display: flex;
  616. justify-content: center;
  617. .text {
  618. display: inline-block;
  619. width: 110px;
  620. text-align: right;
  621. }
  622. .select {
  623. width: 250px;
  624. }
  625. .span {
  626. display: inline-block;
  627. width: 30px;
  628. height: 10px;
  629. }
  630. }
  631. .contractTitle {
  632. display: flex;
  633. justify-content: center;
  634. .el-form-item {
  635. display: flex;
  636. justify-content: center;
  637. .el-form-item__label {
  638. display: flex;
  639. align-items: center;
  640. }
  641. .el-input {
  642. width: 250px;
  643. }
  644. }
  645. }
  646. .forwardingUnit {
  647. display: flex;
  648. justify-content: center;
  649. .text {
  650. display: inline-block;
  651. width: 170px;
  652. text-align: right;
  653. }
  654. .input {
  655. width: 250px;
  656. margin-right: 20px;
  657. }
  658. }
  659. .purchaseOrderNo {
  660. display: flex;
  661. justify-content: center;
  662. .text {
  663. display: inline-block;
  664. width: 170px;
  665. text-align: right;
  666. }
  667. .input {
  668. width: 250px;
  669. margin-right: 90px;
  670. }
  671. }
  672. .carrier {
  673. display: flex;
  674. .el-autocomplete {
  675. width: 250px;
  676. }
  677. }
  678. .button_box {
  679. display: flex;
  680. justify-content: center;
  681. align-items: center;
  682. width: 100%;
  683. height: 100px;
  684. }
  685. }
  686. </style>