voyageList.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  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="100"
  174. align="center"
  175. ></el-table-column>
  176. <el-table-column
  177. prop="expectedArrivalTime"
  178. label="预计到港时间"
  179. min-width="100"
  180. align="center"
  181. ></el-table-column>
  182. <el-table-column
  183. prop="abnormalStatus"
  184. label="航次状态"
  185. min-width="80"
  186. align="center"
  187. >
  188. <template v-slot="scope">
  189. {{ scope.row.abnormalStatus == 0 ? "正常" : "异常" }}
  190. </template>
  191. </el-table-column>
  192. <el-table-column
  193. prop="daysInPort"
  194. label="在港天数"
  195. min-width="80"
  196. align="center"
  197. ></el-table-column>
  198. <el-table-column
  199. prop="todayPhotoCount"
  200. label="今日照片"
  201. min-width="80"
  202. align="center"
  203. ></el-table-column>
  204. <el-table-column
  205. prop="cargo"
  206. label="货种"
  207. min-width="80"
  208. align="center"
  209. ></el-table-column>
  210. <el-table-column
  211. prop="tons"
  212. label="吨位(吨)"
  213. min-width="80"
  214. align="center"
  215. ></el-table-column>
  216. <el-table-column
  217. prop="waybillStatus"
  218. sortable
  219. label="签单状态"
  220. min-width="100"
  221. align="center"
  222. >
  223. <template v-slot="scope">
  224. {{
  225. scope.row.waybillStatus == 0
  226. ? ""
  227. : scope.row.waybillStatus == 1
  228. ? "未签单"
  229. : "已签单"
  230. }}
  231. </template>
  232. </el-table-column>
  233. <!-- <el-table-column
  234. prop="transStatus"
  235. label="船舶状态"
  236. min-width="100"
  237. align="center"
  238. ></el-table-column> -->
  239. <el-table-column
  240. prop="hasInsurance"
  241. label="保险单状态"
  242. min-width="100"
  243. align="center"
  244. >
  245. <template v-slot="scope">
  246. {{ scope.row.hasInsurance == 0 ? "未购买" : "已购买" }}
  247. </template>
  248. </el-table-column>
  249. <el-table-column
  250. sortable
  251. prop="createTime"
  252. label="创建时间"
  253. min-width="100"
  254. align="center"
  255. >
  256. <template v-slot="scope">
  257. {{ subTimeStr(scope.row.createTime) }}
  258. </template>
  259. </el-table-column>
  260. <el-table-column
  261. prop="remark"
  262. label="备注"
  263. min-width="100"
  264. align="center"
  265. ></el-table-column>
  266. <el-table-column
  267. v-auth="'VOYAGEDETAIL'"
  268. label="操作"
  269. min-width="80"
  270. align="center"
  271. >
  272. <template v-slot="scope">
  273. <el-button
  274. @click="voyageDetail(scope.row.id, tableData)"
  275. type="text"
  276. size="small"
  277. >
  278. 查看详情
  279. </el-button>
  280. </template>
  281. </el-table-column>
  282. </el-table>
  283. <div style="width: 100%; text-align: right; margin-top: 43px">
  284. <el-pagination
  285. background
  286. layout="prev, pager, next"
  287. :total="total"
  288. @current-change="pageChange"
  289. ></el-pagination>
  290. </div>
  291. </div>
  292. </template>
  293. <script setup>
  294. import { ref, h, reactive, toRefs, onMounted } from "vue";
  295. import { ElNotification, ElMessageBox, ElMessage } from "element-plus";
  296. import store from "../../store";
  297. import router from "../../router";
  298. import md5 from "md5";
  299. import api from "../../apis/fetch";
  300. import _ from "lodash";
  301. import { subTimeStr } from "../../utils/utils";
  302. let currentPage = ref(1);
  303. let term = ref("");
  304. let tableData = ref([]);
  305. let total = ref(0);
  306. let status = ref(0);
  307. async function getVoyageList() {
  308. tableData.value = [];
  309. let res = await api.getVoyageList({
  310. loginAccountId: localStorage.loginAccountId,
  311. cargoOwnerId: localStorage.userId,
  312. shipId: 0,
  313. status: status.value,
  314. term: term.value,
  315. currentPage: currentPage.value,
  316. size: 10,
  317. });
  318. term.value = "";
  319. if (res.data.status == 0) {
  320. tableData.value = res.data.result;
  321. total.value = res.data.total;
  322. } else {
  323. ElNotification({
  324. type: "error",
  325. title: res.data.msg,
  326. });
  327. }
  328. }
  329. function changeVoyageType(s) {
  330. term.value = "";
  331. currentPage.value = 1;
  332. status.value = s;
  333. getVoyageList();
  334. }
  335. async function voyageDetail(id) {
  336. router.push({
  337. path: "/voyage/voyageDetail",
  338. query: {
  339. id,
  340. },
  341. });
  342. }
  343. function pageChange(e) {
  344. currentPage.value = e;
  345. getVoyageList();
  346. }
  347. function goToVoyageAdd() {
  348. router.push({
  349. path: "/voyage/voyageAdd",
  350. });
  351. }
  352. let voyageAddDialogVisible = ref(false);
  353. const rules = reactive({
  354. rules: {
  355. voyageName: [
  356. { required: false, message: "请填写航次名称", trigger: "blur" },
  357. ],
  358. shipName: [{ required: true, message: "请选择船舶", trigger: "blur" }],
  359. cargoOwnerName: [
  360. { required: true, message: "请选择货主", trigger: "blur" },
  361. ],
  362. startTime: [{ required: true, message: "请填写开始时间", trigger: "blur" }],
  363. loadPort: [{ required: true, message: "请填写装货港", trigger: "blur" }],
  364. dischargeProt: [
  365. { required: true, message: "请填写卸货港", trigger: "blur" },
  366. ],
  367. cargo: [{ required: true, message: "请填写货种", trigger: "blur" }],
  368. tons: [{ required: true, message: "请填写吨位", trigger: "blur" }],
  369. },
  370. });
  371. let voyageForm = reactive({
  372. voyageForm: {
  373. voyageName: "",
  374. cargoOwnerId: "",
  375. cargoOwnerName: "",
  376. startTime: "",
  377. endTime: "",
  378. loadPort: "",
  379. dischargeProt: "",
  380. cargo: "",
  381. tons: "",
  382. loadPortId: "",
  383. dischargeProtId: "",
  384. shipId: "",
  385. shipName: "",
  386. },
  387. });
  388. function clear(type) {
  389. setTimeout(() => {
  390. switch (type) {
  391. case "shipId": {
  392. let index = ref(-1);
  393. for (let i in shipsCache.value) {
  394. if (voyageForm.voyageForm.shipName == shipsCache.value[i].shipName) {
  395. index.value = i;
  396. break;
  397. }
  398. }
  399. if (index.value != -1) {
  400. voyageForm.voyageForm.shipId = shipsCache.value[index.value].shipId;
  401. } else {
  402. let b = shipsCache.value.some((item) => {
  403. return (
  404. item.shipId == voyageForm.voyageForm.shipId &&
  405. item.shipName == voyageForm.voyageForm.shipName
  406. );
  407. });
  408. voyageForm.voyageForm["shipId"] = "";
  409. voyageForm.voyageForm["shipName"] = "";
  410. }
  411. break;
  412. }
  413. case "cargoOwnerId": {
  414. let index = ref(-1);
  415. for (let i in cargoOwnersCache.value) {
  416. if (
  417. voyageForm.voyageForm.cargoOwnerName ==
  418. cargoOwnersCache.value[i].userName
  419. ) {
  420. index.value = i;
  421. break;
  422. }
  423. }
  424. if (index.value != -1) {
  425. voyageForm.voyageForm.cargoOwnerId =
  426. cargoOwnersCache.value[index.value].userId;
  427. } else {
  428. let b = cargoOwnersCache.value.some((item) => {
  429. return (
  430. item.userId == voyageForm.voyageForm.cargoOwnerId &&
  431. item.userName == voyageForm.voyageForm.cargoOwnerName
  432. );
  433. });
  434. if (!b) {
  435. voyageForm.voyageForm["cargoOwnerId"] = "";
  436. voyageForm.voyageForm["cargoOwnerName"] = "";
  437. }
  438. }
  439. break;
  440. }
  441. case "loadPort": {
  442. let index = ref(-1);
  443. for (let i in colCache.value) {
  444. if (voyageForm.voyageForm.loadPort == colCache.value[i].value) {
  445. index.value = i;
  446. break;
  447. }
  448. }
  449. if (index.value != -1) {
  450. voyageForm.voyageForm.loadPortId = colCache.value[index.value].key;
  451. } else {
  452. let b = colCache.value.some((item) => {
  453. return (
  454. item.value == voyageForm.voyageForm.loadPort &&
  455. item.key == voyageForm.voyageForm.loadPortId
  456. );
  457. });
  458. if (!b) {
  459. voyageForm.voyageForm["loadPort"] = "";
  460. voyageForm.voyageForm["loadPortId"] = "";
  461. }
  462. }
  463. break;
  464. }
  465. case "dischargeProt": {
  466. let index = ref(-1);
  467. for (let i in colCache.value) {
  468. if (voyageForm.voyageForm.dischargeProt == colCache.value[i].value) {
  469. index.value = i;
  470. break;
  471. }
  472. }
  473. if (index.value != -1) {
  474. voyageForm.voyageForm.dischargeProtId =
  475. colCache.value[index.value].key;
  476. } else {
  477. let b = colCache.value.some((item) => {
  478. return (
  479. item.value == voyageForm.voyageForm.dischargeProt &&
  480. item.key == voyageForm.voyageForm.dischargeProtId
  481. );
  482. });
  483. if (!b) {
  484. voyageForm.voyageForm["dischargeProt"] = "";
  485. voyageForm.voyageForm["dischargeProtId"] = "";
  486. }
  487. }
  488. break;
  489. }
  490. }
  491. }, 200);
  492. }
  493. let addVoyageForm = ref(null);
  494. async function addVoyage() {
  495. addVoyageForm.value.validate(async (valid) => {
  496. if (valid) {
  497. console.log("提交", voyageForm.voyageForm);
  498. let res = await api.addVoyage({
  499. ...voyageForm.voyageForm,
  500. });
  501. if (res.data.status == 0) {
  502. ElNotification({
  503. title: res.data.msg,
  504. type: "success",
  505. });
  506. resetAddVoyageForm();
  507. getVoyageList();
  508. } else {
  509. console.log(res);
  510. ElNotification({
  511. title: res.data.msg,
  512. type: "error",
  513. });
  514. }
  515. } else {
  516. console.log("未提交", voyageForm.voyageForm);
  517. }
  518. });
  519. }
  520. let shipsCache = ref([]);
  521. let colCache = ref([]);
  522. let cargoOwnersCache = ref([]);
  523. const searchShip = _.debounce(
  524. async (queryString, cb) => {
  525. if (!queryString) return;
  526. let res = await api.searchShip({
  527. term: queryString,
  528. });
  529. let ships = [];
  530. if (res.data.status == 0) {
  531. ships = res.data.result;
  532. for (let i of ships) {
  533. i.value = `${i.shipName}`;
  534. }
  535. shipsCache.value = ships;
  536. cb(ships);
  537. }
  538. },
  539. 1000,
  540. { leading: true }
  541. );
  542. const selectShip = (item) => {
  543. voyageForm.voyageForm.shipId = item.shipId;
  544. };
  545. const searchCargoOwner = _.debounce(
  546. async (queryString, cb) => {
  547. if (!queryString) return;
  548. let res = await api.searchUser({
  549. term: queryString,
  550. identity: 2,
  551. });
  552. let cargoOwners = [];
  553. if (res.data.status == 0) {
  554. cargoOwners = res.data.result;
  555. for (let i of cargoOwners) {
  556. i.value = `${i.userName}`;
  557. }
  558. cargoOwnersCache.value = cargoOwners;
  559. cb(cargoOwners);
  560. }
  561. },
  562. 1000,
  563. { leading: true }
  564. );
  565. const selectCargoOwner = (item) => {
  566. voyageForm.voyageForm.cargoOwnerId = item.userId;
  567. };
  568. const getCol = _.debounce(
  569. async (queryString, cb) => {
  570. if (!queryString) return;
  571. let res = await api.getCol({
  572. term: queryString,
  573. });
  574. if (res.data.status == 0) {
  575. colCache.value = [...colCache.value, ...res.data.result];
  576. colCache.value = _.uniqBy(colCache.value, "key");
  577. cb(res.data.result);
  578. }
  579. },
  580. 1000,
  581. { leading: true }
  582. );
  583. const selectLoadPort = (item) => {
  584. voyageForm.voyageForm.loadPortId = item.key;
  585. voyageForm.voyageForm.loadPort = item.value;
  586. };
  587. const selectDischargeProt = (item) => {
  588. voyageForm.voyageForm.dischargeProtId = item.key;
  589. voyageForm.voyageForm.dischargeProt = item.value;
  590. };
  591. function resetAddVoyageForm() {
  592. voyageAddDialogVisible.value = false;
  593. addVoyageForm.value.resetFields();
  594. }
  595. let sortradio = ref(0);
  596. onMounted(() => {
  597. getVoyageList();
  598. });
  599. </script>
  600. <style scoped>
  601. .search-btn {
  602. display: inline-block;
  603. width: 60px;
  604. height: 32px;
  605. background: #0094fe;
  606. border-radius: 2px;
  607. font-size: 14px;
  608. font-family: PingFangSC-Regular, PingFang SC;
  609. font-weight: 400;
  610. color: #ffffff;
  611. text-align: center;
  612. line-height: 32px;
  613. margin-left: 10px;
  614. cursor: pointer;
  615. }
  616. .cargo-owner-add {
  617. width: 80px;
  618. height: 32px;
  619. border-radius: 2px;
  620. border: 1px solid #0094fe;
  621. font-size: 14px;
  622. font-family: PingFangSC-Regular, PingFang SC;
  623. font-weight: 400;
  624. color: #0094fe;
  625. line-height: 32px;
  626. text-align: center;
  627. cursor: pointer;
  628. }
  629. :deep().el-dialog {
  630. width: 560px;
  631. padding: 20px 50px;
  632. border-radius: 6px;
  633. }
  634. :deep() .el-dialog__title {
  635. font-size: 18px;
  636. font-family: PingFangSC-Regular, PingFang SC;
  637. font-weight: 400;
  638. color: #0094fe;
  639. }
  640. .normal-label {
  641. font-size: 14px;
  642. font-family: PingFangSC-Regular, PingFang SC;
  643. font-weight: 400;
  644. color: #353a42;
  645. margin-right: 10px;
  646. }
  647. .show-input {
  648. width: 280px;
  649. height: 32px;
  650. background: #ffffff;
  651. border-radius: 2px;
  652. border: 1px solid #dee0e3;
  653. font-size: 14px;
  654. font-family: PingFangSC-Regular, PingFang SC;
  655. font-weight: 400;
  656. color: #333333;
  657. line-height: 32px;
  658. padding-left: 12px;
  659. margin-right: 40px;
  660. }
  661. .radio-btns {
  662. height: 38px;
  663. width: 70px;
  664. border: 1px solid #1486f9;
  665. line-height: 38px;
  666. text-align: center;
  667. font-size: 14px;
  668. font-family: PingFangSC-Regular, PingFang SC;
  669. font-weight: 400;
  670. color: #0094fe;
  671. cursor: pointer;
  672. }
  673. .left-radius {
  674. border-top-left-radius: 19px;
  675. border-bottom-left-radius: 19px;
  676. width: 80px;
  677. }
  678. .right-radius {
  679. border-top-right-radius: 19px;
  680. border-bottom-right-radius: 19px;
  681. width: 80px;
  682. }
  683. .currentbtn {
  684. background: #1486f9;
  685. color: #fff;
  686. }
  687. .search-btn {
  688. display: inline-block;
  689. width: 60px;
  690. height: 38px;
  691. background: #0094fe;
  692. border-radius: 2px;
  693. font-size: 14px;
  694. font-family: PingFangSC-Regular, PingFang SC;
  695. font-weight: 400;
  696. color: #ffffff;
  697. text-align: center;
  698. line-height: 38px;
  699. margin-left: 10px;
  700. cursor: pointer;
  701. }
  702. .voyage-add {
  703. width: 80px;
  704. height: 36px;
  705. border-radius: 2px;
  706. border: 1px solid #0094fe;
  707. font-size: 14px;
  708. font-family: PingFangSC-Regular, PingFang SC;
  709. font-weight: 400;
  710. color: #0094fe;
  711. line-height: 36px;
  712. text-align: center;
  713. cursor: pointer;
  714. }
  715. :deep() .el-dialog {
  716. width: 800px;
  717. }
  718. :deep() .el-form-item {
  719. margin-right: 22px;
  720. width: 300px;
  721. }
  722. :deep() .el-autocomplete {
  723. width: 220px;
  724. }
  725. .el-radio {
  726. margin-right: 10px;
  727. }
  728. .el-radio:last-child {
  729. margin-right: 20px;
  730. }
  731. </style>