voyageList.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. <template>
  2. <div class="line-container-p24">
  3. <div style="display: flex; justify-content: space-between">
  4. <div class="df aic">
  5. <div
  6. @click="changeVoyageType(0)"
  7. :class="
  8. status == 0
  9. ? 'currentbtn radio-btns left-radius'
  10. : 'radio-btns left-radius'
  11. "
  12. >
  13. 全部航次
  14. </div>
  15. <div
  16. style="border-left: none"
  17. @click="changeVoyageType(1)"
  18. :class="status == 1 ? 'currentbtn radio-btns' : 'radio-btns'"
  19. >
  20. 装货中
  21. </div>
  22. <div
  23. style="border-left: none"
  24. @click="changeVoyageType(2)"
  25. :class="status == 2 ? 'currentbtn radio-btns' : 'radio-btns'"
  26. >
  27. 运输中
  28. </div>
  29. <div
  30. style="border-left: none"
  31. @click="changeVoyageType(3)"
  32. :class="status == 3 ? 'currentbtn radio-btns' : 'radio-btns'"
  33. >
  34. 卸货中
  35. </div>
  36. <div
  37. @click="changeVoyageType(4)"
  38. :class="
  39. status == 4
  40. ? 'currentbtn radio-btns right-radius'
  41. : 'radio-btns right-radius '
  42. "
  43. style="margin-right: 40px; border-left: none"
  44. >
  45. 历史航次
  46. </div>
  47. <!-- <div style="color: #333; margin-right: 10px; font-size: 14px">
  48. 预计到港时间:
  49. </div>
  50. <el-radio-group v-model="sortradio">
  51. <el-radio :label="-1">默认排序</el-radio>
  52. <el-radio :label="0">降序</el-radio>
  53. <el-radio :label="1">升序</el-radio>
  54. </el-radio-group> -->
  55. <el-input
  56. placeholder="请输入船名/MMSI"
  57. prefix-icon="el-icon-search"
  58. v-model="term"
  59. clearable
  60. style="width: 330px"
  61. ></el-input>
  62. <div class="search-btn" @click="getVoyageList()">查询</div>
  63. </div>
  64. <!-- <div class="cargo-owner-add" @click="voyageAddDialogVisible = true">
  65. 添加航次
  66. </div> -->
  67. </div>
  68. <el-dialog v-model="voyageAddDialogVisible" title="添加航次">
  69. <el-form
  70. :rules="rules"
  71. label-position="right"
  72. label-width="80px"
  73. ref="addVoyageForm"
  74. :model="voyageForm"
  75. :before-close="resetAddVoyageForm"
  76. >
  77. <div class="df ffw">
  78. <!-- <el-form-item prop="voyageName" label="航次名称">
  79. <el-input v-model="voyageForm.voyageName"></el-input>
  80. </el-form-item>
  81. <el-form-item label=""></el-form-item> -->
  82. <el-form-item prop="shipName" label="船舶">
  83. <!-- <el-input v-model="voyageForm.shipOwnerId"></el-input> -->
  84. <el-autocomplete
  85. v-model="voyageForm.shipName"
  86. :fetch-suggestions="searchShip"
  87. placeholder="选择船舶"
  88. @blur="clear('shipId')"
  89. @select="selectShip"
  90. />
  91. </el-form-item>
  92. <el-form-item prop="cargoOwnerName" label="货主">
  93. <el-autocomplete
  94. v-model="voyageForm.cargoOwnerName"
  95. :fetch-suggestions="searchCargoOwner"
  96. @blur="clear('cargoOwnerId')"
  97. placeholder="选择货主"
  98. @select="selectCargoOwner"
  99. />
  100. </el-form-item>
  101. <el-form-item prop="startTime" label="开始时间">
  102. <el-date-picker
  103. v-model="voyageForm.startTime"
  104. type="date"
  105. value-format="YYYY/MM/DD"
  106. placeholder="航次开始时间"
  107. ></el-date-picker>
  108. </el-form-item>
  109. <el-form-item prop="endTime" label="结束时间">
  110. <el-date-picker
  111. v-model="voyageForm.endTime"
  112. type="date"
  113. value-format="YYYY/MM/DD"
  114. placeholder="航次结束时间"
  115. disabled
  116. ></el-date-picker>
  117. </el-form-item>
  118. <el-form-item prop="loadPort" label="装货港">
  119. <el-autocomplete
  120. v-model="voyageForm.loadPort"
  121. :fetch-suggestions="getCol"
  122. @blur="clear('loadPort')"
  123. placeholder="选择装货港"
  124. @select="selectLoadPort"
  125. />
  126. </el-form-item>
  127. <el-form-item prop="dischargeProt" label="卸货港">
  128. <el-autocomplete
  129. v-model="voyageForm.dischargeProt"
  130. :fetch-suggestions="getCol"
  131. @blur="clear('dischargeProt')"
  132. placeholder="选择卸货港"
  133. @select="selectDischargeProt"
  134. />
  135. </el-form-item>
  136. <el-form-item prop="cargo" label="货种">
  137. <el-input v-model="voyageForm.cargo"></el-input>
  138. </el-form-item>
  139. <el-form-item prop="tons" label="吨位">
  140. <el-input v-model="voyageForm.tons"></el-input>
  141. </el-form-item>
  142. </div>
  143. </el-form>
  144. <template #footer>
  145. <span class="dialog-footer">
  146. <el-button @click="resetAddVoyageForm">取消</el-button>
  147. <el-button type="primary" @click="addVoyage">确定</el-button>
  148. </span>
  149. </template>
  150. </el-dialog>
  151. <el-table :data="tableData" stripe style="width: 100%; margin-top: 24px">
  152. <el-table-column
  153. type="index"
  154. label="序号"
  155. min-width="80"
  156. align="center"
  157. ></el-table-column>
  158. <el-table-column
  159. prop="voyageName"
  160. label="航次名称"
  161. min-width="140"
  162. align="center"
  163. ></el-table-column>
  164. <el-table-column
  165. prop="loadDiscPort"
  166. label="装货港-卸货港"
  167. min-width="200"
  168. align="center"
  169. ></el-table-column>
  170. <el-table-column
  171. prop="setSailTime"
  172. label="开航时间"
  173. min-width="180"
  174. align="center"
  175. ></el-table-column>
  176. <el-table-column
  177. prop="expectedArrivalTime"
  178. label="预计到港时间"
  179. min-width="180"
  180. align="center"
  181. ></el-table-column>
  182. <el-table-column
  183. prop="daysInPort"
  184. label="在港天数"
  185. min-width="80"
  186. align="center"
  187. ></el-table-column>
  188. <el-table-column
  189. prop="todayPhotoCount"
  190. label="今日照片"
  191. min-width="80"
  192. align="center"
  193. ></el-table-column>
  194. <el-table-column
  195. prop="cargo"
  196. label="货种"
  197. min-width="80"
  198. align="center"
  199. ></el-table-column>
  200. <el-table-column
  201. prop="tons"
  202. label="吨位(吨)"
  203. min-width="80"
  204. align="center"
  205. ></el-table-column>
  206. <el-table-column
  207. prop="waybillStatus"
  208. sortable
  209. label="签单状态"
  210. min-width="100"
  211. align="center"
  212. >
  213. <template v-slot="scope">
  214. {{
  215. scope.row.waybillStatus == 0
  216. ? ""
  217. : scope.row.waybillStatus == 1
  218. ? "未签单"
  219. : "已签单"
  220. }}
  221. </template>
  222. </el-table-column>
  223. <!-- <el-table-column
  224. prop="transStatus"
  225. label="船舶状态"
  226. min-width="100"
  227. align="center"
  228. ></el-table-column> -->
  229. <el-table-column
  230. prop="hasInsurance"
  231. label="保险单状态"
  232. min-width="100"
  233. align="center"
  234. >
  235. <template v-slot="scope">
  236. {{ scope.row.hasInsurance == 0 ? "未购买" : "已购买" }}
  237. </template>
  238. </el-table-column>
  239. <el-table-column
  240. sortable
  241. prop="createTime"
  242. label="创建时间"
  243. min-width="100"
  244. align="center"
  245. >
  246. <template v-slot="scope">
  247. {{ subTimeStr(scope.row.createTime) }}
  248. </template>
  249. </el-table-column>
  250. <el-table-column
  251. prop="remark"
  252. label="备注"
  253. min-width="100"
  254. align="center"
  255. ></el-table-column>
  256. <el-table-column
  257. v-auth="'VOYAGEDETAIL'"
  258. label="操作"
  259. min-width="80"
  260. align="center"
  261. >
  262. <template v-slot="scope">
  263. <el-button
  264. @click="voyageDetail(scope.row.id, tableData)"
  265. type="text"
  266. size="small"
  267. >
  268. 查看详情
  269. </el-button>
  270. </template>
  271. </el-table-column>
  272. </el-table>
  273. <div style="width: 100%; text-align: right; margin-top: 43px">
  274. <el-pagination
  275. background
  276. layout="prev, pager, next"
  277. :total="total"
  278. @current-change="pageChange"
  279. ></el-pagination>
  280. </div>
  281. </div>
  282. </template>
  283. <script setup>
  284. import { ref, h, reactive, toRefs, onMounted } from "vue";
  285. import { ElNotification, ElMessageBox, ElMessage } from "element-plus";
  286. import store from "../../store";
  287. import router from "../../router";
  288. import md5 from "md5";
  289. import api from "../../apis/fetch";
  290. import _ from "lodash";
  291. import { subTimeStr } from "../../utils/utils";
  292. let currentPage = ref(1);
  293. let term = ref("");
  294. let tableData = ref([]);
  295. let total = ref(0);
  296. let status = ref(0);
  297. async function getVoyageList() {
  298. tableData.value = [];
  299. let res = await api.getVoyageList({
  300. loginAccountId: localStorage.loginAccountId,
  301. cargoOwnerId: localStorage.userId,
  302. shipId: 0,
  303. status: status.value,
  304. term: term.value,
  305. currentPage: currentPage.value,
  306. size: 10,
  307. });
  308. term.value = "";
  309. if (res.data.status == 0) {
  310. tableData.value = res.data.result;
  311. total.value = res.data.total;
  312. } else {
  313. ElNotification({
  314. type: "error",
  315. title: res.data.msg,
  316. });
  317. }
  318. }
  319. function changeVoyageType(s) {
  320. term.value = "";
  321. currentPage.value = 1;
  322. status.value = s;
  323. getVoyageList();
  324. }
  325. async function voyageDetail(id) {
  326. router.push({
  327. path: "/voyage/voyageDetail",
  328. query: {
  329. id,
  330. },
  331. });
  332. }
  333. function pageChange(e) {
  334. currentPage.value = e;
  335. getVoyageList();
  336. }
  337. function goToVoyageAdd() {
  338. router.push({
  339. path: "/voyage/voyageAdd",
  340. });
  341. }
  342. let voyageAddDialogVisible = ref(false);
  343. const rules = reactive({
  344. rules: {
  345. voyageName: [
  346. { required: false, message: "请填写航次名称", trigger: "blur" },
  347. ],
  348. shipName: [{ required: true, message: "请选择船舶", trigger: "blur" }],
  349. cargoOwnerName: [
  350. { required: true, message: "请选择货主", trigger: "blur" },
  351. ],
  352. startTime: [{ required: true, message: "请填写开始时间", trigger: "blur" }],
  353. loadPort: [{ required: true, message: "请填写装货港", trigger: "blur" }],
  354. dischargeProt: [
  355. { required: true, message: "请填写卸货港", trigger: "blur" },
  356. ],
  357. cargo: [{ required: true, message: "请填写货种", trigger: "blur" }],
  358. tons: [{ required: true, message: "请填写吨位", trigger: "blur" }],
  359. },
  360. });
  361. let voyageForm = reactive({
  362. voyageForm: {
  363. voyageName: "",
  364. cargoOwnerId: "",
  365. cargoOwnerName: "",
  366. startTime: "",
  367. endTime: "",
  368. loadPort: "",
  369. dischargeProt: "",
  370. cargo: "",
  371. tons: "",
  372. loadPortId: "",
  373. dischargeProtId: "",
  374. shipId: "",
  375. shipName: "",
  376. },
  377. });
  378. function clear(type) {
  379. setTimeout(() => {
  380. switch (type) {
  381. case "shipId": {
  382. let index = ref(-1);
  383. for (let i in shipsCache.value) {
  384. if (voyageForm.voyageForm.shipName == shipsCache.value[i].shipName) {
  385. index.value = i;
  386. break;
  387. }
  388. }
  389. if (index.value != -1) {
  390. voyageForm.voyageForm.shipId = shipsCache.value[index.value].shipId;
  391. } else {
  392. let b = shipsCache.value.some((item) => {
  393. return (
  394. item.shipId == voyageForm.voyageForm.shipId &&
  395. item.shipName == voyageForm.voyageForm.shipName
  396. );
  397. });
  398. voyageForm.voyageForm["shipId"] = "";
  399. voyageForm.voyageForm["shipName"] = "";
  400. }
  401. break;
  402. }
  403. case "cargoOwnerId": {
  404. let index = ref(-1);
  405. for (let i in cargoOwnersCache.value) {
  406. if (
  407. voyageForm.voyageForm.cargoOwnerName ==
  408. cargoOwnersCache.value[i].userName
  409. ) {
  410. index.value = i;
  411. break;
  412. }
  413. }
  414. if (index.value != -1) {
  415. voyageForm.voyageForm.cargoOwnerId =
  416. cargoOwnersCache.value[index.value].userId;
  417. } else {
  418. let b = cargoOwnersCache.value.some((item) => {
  419. return (
  420. item.userId == voyageForm.voyageForm.cargoOwnerId &&
  421. item.userName == voyageForm.voyageForm.cargoOwnerName
  422. );
  423. });
  424. if (!b) {
  425. voyageForm.voyageForm["cargoOwnerId"] = "";
  426. voyageForm.voyageForm["cargoOwnerName"] = "";
  427. }
  428. }
  429. break;
  430. }
  431. case "loadPort": {
  432. let index = ref(-1);
  433. for (let i in colCache.value) {
  434. if (voyageForm.voyageForm.loadPort == colCache.value[i].value) {
  435. index.value = i;
  436. break;
  437. }
  438. }
  439. if (index.value != -1) {
  440. voyageForm.voyageForm.loadPortId = colCache.value[index.value].key;
  441. } else {
  442. let b = colCache.value.some((item) => {
  443. return (
  444. item.value == voyageForm.voyageForm.loadPort &&
  445. item.key == voyageForm.voyageForm.loadPortId
  446. );
  447. });
  448. if (!b) {
  449. voyageForm.voyageForm["loadPort"] = "";
  450. voyageForm.voyageForm["loadPortId"] = "";
  451. }
  452. }
  453. break;
  454. }
  455. case "dischargeProt": {
  456. let index = ref(-1);
  457. for (let i in colCache.value) {
  458. if (voyageForm.voyageForm.dischargeProt == colCache.value[i].value) {
  459. index.value = i;
  460. break;
  461. }
  462. }
  463. if (index.value != -1) {
  464. voyageForm.voyageForm.dischargeProtId =
  465. colCache.value[index.value].key;
  466. } else {
  467. let b = colCache.value.some((item) => {
  468. return (
  469. item.value == voyageForm.voyageForm.dischargeProt &&
  470. item.key == voyageForm.voyageForm.dischargeProtId
  471. );
  472. });
  473. if (!b) {
  474. voyageForm.voyageForm["dischargeProt"] = "";
  475. voyageForm.voyageForm["dischargeProtId"] = "";
  476. }
  477. }
  478. break;
  479. }
  480. }
  481. }, 200);
  482. }
  483. let addVoyageForm = ref(null);
  484. async function addVoyage() {
  485. addVoyageForm.value.validate(async (valid) => {
  486. if (valid) {
  487. console.log("提交", voyageForm.voyageForm);
  488. let res = await api.addVoyage({
  489. ...voyageForm.voyageForm,
  490. });
  491. if (res.data.status == 0) {
  492. ElNotification({
  493. title: res.data.msg,
  494. type: "success",
  495. });
  496. resetAddVoyageForm();
  497. getVoyageList();
  498. } else {
  499. console.log(res);
  500. ElNotification({
  501. title: res.data.msg,
  502. type: "error",
  503. });
  504. }
  505. } else {
  506. console.log("未提交", voyageForm.voyageForm);
  507. }
  508. });
  509. }
  510. let shipsCache = ref([]);
  511. let colCache = ref([]);
  512. let cargoOwnersCache = ref([]);
  513. const searchShip = _.debounce(
  514. async (queryString, cb) => {
  515. if (!queryString) return;
  516. let res = await api.searchShip({
  517. term: queryString,
  518. });
  519. let ships = [];
  520. if (res.data.status == 0) {
  521. ships = res.data.result;
  522. for (let i of ships) {
  523. i.value = `${i.shipName}`;
  524. }
  525. shipsCache.value = ships;
  526. cb(ships);
  527. }
  528. },
  529. 1000,
  530. { leading: true }
  531. );
  532. const selectShip = (item) => {
  533. voyageForm.voyageForm.shipId = item.shipId;
  534. };
  535. const searchCargoOwner = _.debounce(
  536. async (queryString, cb) => {
  537. if (!queryString) return;
  538. let res = await api.searchUser({
  539. term: queryString,
  540. identity: 2,
  541. });
  542. let cargoOwners = [];
  543. if (res.data.status == 0) {
  544. cargoOwners = res.data.result;
  545. for (let i of cargoOwners) {
  546. i.value = `${i.userName}`;
  547. }
  548. cargoOwnersCache.value = cargoOwners;
  549. cb(cargoOwners);
  550. }
  551. },
  552. 1000,
  553. { leading: true }
  554. );
  555. const selectCargoOwner = (item) => {
  556. voyageForm.voyageForm.cargoOwnerId = item.userId;
  557. };
  558. const getCol = _.debounce(
  559. async (queryString, cb) => {
  560. if (!queryString) return;
  561. let res = await api.getCol({
  562. term: queryString,
  563. });
  564. if (res.data.status == 0) {
  565. colCache.value = [...colCache.value, ...res.data.result];
  566. colCache.value = _.uniqBy(colCache.value, "key");
  567. cb(res.data.result);
  568. }
  569. },
  570. 1000,
  571. { leading: true }
  572. );
  573. const selectLoadPort = (item) => {
  574. voyageForm.voyageForm.loadPortId = item.key;
  575. voyageForm.voyageForm.loadPort = item.value;
  576. };
  577. const selectDischargeProt = (item) => {
  578. voyageForm.voyageForm.dischargeProtId = item.key;
  579. voyageForm.voyageForm.dischargeProt = item.value;
  580. };
  581. function resetAddVoyageForm() {
  582. voyageAddDialogVisible.value = false;
  583. addVoyageForm.value.resetFields();
  584. }
  585. let sortradio = ref(0);
  586. onMounted(() => {
  587. getVoyageList();
  588. });
  589. </script>
  590. <style scoped>
  591. .search-btn {
  592. display: inline-block;
  593. width: 60px;
  594. height: 32px;
  595. background: #0094fe;
  596. border-radius: 2px;
  597. font-size: 14px;
  598. font-family: PingFangSC-Regular, PingFang SC;
  599. font-weight: 400;
  600. color: #ffffff;
  601. text-align: center;
  602. line-height: 32px;
  603. margin-left: 10px;
  604. cursor: pointer;
  605. }
  606. .cargo-owner-add {
  607. width: 80px;
  608. height: 32px;
  609. border-radius: 2px;
  610. border: 1px solid #0094fe;
  611. font-size: 14px;
  612. font-family: PingFangSC-Regular, PingFang SC;
  613. font-weight: 400;
  614. color: #0094fe;
  615. line-height: 32px;
  616. text-align: center;
  617. cursor: pointer;
  618. }
  619. :deep().el-dialog {
  620. width: 560px;
  621. padding: 20px 50px;
  622. border-radius: 6px;
  623. }
  624. :deep() .el-dialog__title {
  625. font-size: 18px;
  626. font-family: PingFangSC-Regular, PingFang SC;
  627. font-weight: 400;
  628. color: #0094fe;
  629. }
  630. .normal-label {
  631. font-size: 14px;
  632. font-family: PingFangSC-Regular, PingFang SC;
  633. font-weight: 400;
  634. color: #353a42;
  635. margin-right: 10px;
  636. }
  637. .show-input {
  638. width: 280px;
  639. height: 32px;
  640. background: #ffffff;
  641. border-radius: 2px;
  642. border: 1px solid #dee0e3;
  643. font-size: 14px;
  644. font-family: PingFangSC-Regular, PingFang SC;
  645. font-weight: 400;
  646. color: #333333;
  647. line-height: 32px;
  648. padding-left: 12px;
  649. margin-right: 40px;
  650. }
  651. .radio-btns {
  652. height: 38px;
  653. width: 70px;
  654. border: 1px solid #1486f9;
  655. line-height: 38px;
  656. text-align: center;
  657. font-size: 14px;
  658. font-family: PingFangSC-Regular, PingFang SC;
  659. font-weight: 400;
  660. color: #0094fe;
  661. cursor: pointer;
  662. }
  663. .left-radius {
  664. border-top-left-radius: 19px;
  665. border-bottom-left-radius: 19px;
  666. width: 80px;
  667. }
  668. .right-radius {
  669. border-top-right-radius: 19px;
  670. border-bottom-right-radius: 19px;
  671. width: 80px;
  672. }
  673. .currentbtn {
  674. background: #1486f9;
  675. color: #fff;
  676. }
  677. .search-btn {
  678. display: inline-block;
  679. width: 60px;
  680. height: 38px;
  681. background: #0094fe;
  682. border-radius: 2px;
  683. font-size: 14px;
  684. font-family: PingFangSC-Regular, PingFang SC;
  685. font-weight: 400;
  686. color: #ffffff;
  687. text-align: center;
  688. line-height: 38px;
  689. margin-left: 10px;
  690. cursor: pointer;
  691. }
  692. .voyage-add {
  693. width: 80px;
  694. height: 36px;
  695. border-radius: 2px;
  696. border: 1px solid #0094fe;
  697. font-size: 14px;
  698. font-family: PingFangSC-Regular, PingFang SC;
  699. font-weight: 400;
  700. color: #0094fe;
  701. line-height: 36px;
  702. text-align: center;
  703. cursor: pointer;
  704. }
  705. :deep() .el-dialog {
  706. width: 800px;
  707. }
  708. :deep() .el-form-item {
  709. margin-right: 22px;
  710. width: 300px;
  711. }
  712. :deep() .el-autocomplete {
  713. width: 220px;
  714. }
  715. .el-radio {
  716. margin-right: 10px;
  717. }
  718. .el-radio:last-child {
  719. margin-right: 20px;
  720. }
  721. </style>