sailingSchedule.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <template>
  2. <div class="full-container-p24">
  3. <div style="display: flex; justify-content: space-between">
  4. <div style="display: flex">
  5. <el-input
  6. placeholder="请输入货主/港口名称"
  7. prefix-icon="el-icon-search"
  8. v-model="term"
  9. clearable
  10. style="width: 330px"
  11. ></el-input>
  12. <div class="seach-btn" @click="getTransPortsList(1)">查询</div>
  13. </div>
  14. <div class="cargo-owner-add" @click="dialogFormVisible = true">
  15. 添加航期
  16. </div>
  17. <el-dialog
  18. title="添加航期"
  19. @closed="resetForm()"
  20. v-model="dialogFormVisible"
  21. >
  22. <template v-slot:default>
  23. <el-form
  24. :model="ruleForm"
  25. :rules="rules"
  26. ref="form"
  27. label-width="110px"
  28. label-position="left"
  29. >
  30. <el-form-item prop="cargoOwnerIds" label="货主名称">
  31. <RemoteSelect
  32. api="getCargoOwnerCompanySelect"
  33. v-model="cargoOwnerCompanyStr"
  34. multiple
  35. @selectItem="selectCargoOwnerCompany($event)"
  36. class="mb10"
  37. ></RemoteSelect>
  38. </el-form-item>
  39. <el-form-item prop="departurePortId" label="始发港">
  40. <RemoteSelect
  41. api="getPortsSelect"
  42. v-model="departurePortStr"
  43. @selectItem="selectDeparturePort($event)"
  44. class="mb10"
  45. ></RemoteSelect>
  46. </el-form-item>
  47. <el-form-item prop="destinationPortId" label="目的地港">
  48. <RemoteSelect
  49. api="getPortsSelect"
  50. v-model="destinationPortStr"
  51. @selectItem="selectDdestinationPort($event)"
  52. class="mb10"
  53. ></RemoteSelect>
  54. </el-form-item>
  55. <el-form-item prop="sailingPeriod" label="航期">
  56. <el-input
  57. style="width: 193px"
  58. v-model="ruleForm.sailingPeriod"
  59. ></el-input>
  60. </el-form-item>
  61. </el-form>
  62. </template>
  63. <template v-slot:footer>
  64. <div class="dialog-footer">
  65. <el-button @click="resetForm">取 消</el-button>
  66. <el-button type="primary" @click="addTransPort(ruleForm)">
  67. 确 定
  68. </el-button>
  69. </div>
  70. </template>
  71. </el-dialog>
  72. </div>
  73. <div style="margin-top: 24px">
  74. <el-table :data="tableData" stripe style="width: 100%">
  75. <el-table-column
  76. type="index"
  77. label="序号"
  78. min-width="80"
  79. align="center"
  80. ></el-table-column>
  81. <el-table-column
  82. prop="cargoOwnerName"
  83. label="货主名称"
  84. min-width="120"
  85. align="center"
  86. ></el-table-column>
  87. <el-table-column
  88. prop="departurePort"
  89. label="始发港"
  90. min-width="120"
  91. align="center"
  92. ></el-table-column>
  93. <el-table-column
  94. prop="destinationPort"
  95. label="目的地港"
  96. min-width="120"
  97. align="center"
  98. ></el-table-column>
  99. <el-table-column
  100. prop="sailingPeriod"
  101. label="航期"
  102. min-width="120"
  103. align="center"
  104. >
  105. <template v-slot="scope"> {{ scope.row.sailingPeriod }} 天 </template>
  106. </el-table-column>
  107. <el-table-column
  108. prop="createTime"
  109. label="添加时间"
  110. min-width="200"
  111. align="center"
  112. >
  113. <template v-slot="scope">
  114. {{ subTimeStr(scope.row.createTime) }}
  115. </template>
  116. </el-table-column>
  117. <!-- <el-table-column label="操作" min-width="80" align="center">
  118. <template v-slot="scope">
  119. <el-button size="mini" type="danger">删除</el-button>
  120. </template>
  121. </el-table-column> -->
  122. </el-table>
  123. <div style="width: 100%; text-align: right; margin-top: 43px">
  124. <el-pagination
  125. background
  126. layout="prev, pager, next"
  127. :current-page="currentPage"
  128. :total="total"
  129. @current-change="pageChange"
  130. ></el-pagination>
  131. </div>
  132. </div>
  133. </div>
  134. </template>
  135. <script setup>
  136. import { ref, h, reactive, toRefs, onMounted } from "vue";
  137. import { ElNotification, ElMessageBox, ElMessage } from "element-plus";
  138. import store from "../../store";
  139. import router from "../../router";
  140. import md5 from "md5";
  141. import api from "../../apis/fetch";
  142. import { subTimeStr } from "../../utils/utils";
  143. let currentPage = ref(1);
  144. let term = ref("");
  145. let tableData = ref([]);
  146. let total = ref(0);
  147. let dialogFormVisible = ref(false);
  148. let form = ref(null);
  149. const ruleForm = ref({
  150. cargoOwnerIds: "",
  151. departurePortId: "",
  152. destinationPortId: "",
  153. sailingPeriod: "",
  154. });
  155. const rules = ref({
  156. cargoOwnerIds: [
  157. { required: true, message: "请填写货主名称", trigger: "blur" },
  158. ],
  159. departurePortId: [
  160. { required: true, message: "请填写始发港", trigger: "blur" },
  161. ],
  162. destinationPortId: [
  163. { required: true, message: "请填写目的地港", trigger: "blur" },
  164. ],
  165. sailingPeriod: [{ required: true, message: "请填写航期", trigger: "blur" }],
  166. });
  167. async function getTransPortsList(page) {
  168. currentPage.value = page || currentPage.value;
  169. let res = await api.getTransPortsList({
  170. currentPage: currentPage.value,
  171. size: 10,
  172. term: term.value,
  173. });
  174. if (res.data.status == 0) {
  175. tableData.value = res.data.result;
  176. total.value = res.data.total;
  177. } else {
  178. tableData.value = [];
  179. total.value = 0;
  180. }
  181. }
  182. function resetForm() {
  183. dialogFormVisible.value = false;
  184. cargoOwnerCompanyStr.value = [];
  185. departurePortStr.value = "";
  186. destinationPortStr.value = "";
  187. form.value.resetFields();
  188. }
  189. async function addTransPort() {
  190. form.value.validate(async (valid) => {
  191. if (valid) {
  192. let { cargoOwnerIds, departurePortId, destinationPortId, sailingPeriod } =
  193. ruleForm.value;
  194. let res = await api.addTransPort({
  195. cargoOwnerIds,
  196. departurePortId,
  197. destinationPortId,
  198. sailingPeriod,
  199. });
  200. console.log(res);
  201. if (res.data.status == 0) {
  202. ElNotification.success({
  203. title: "添加成功",
  204. duration: 2000,
  205. message: `${cargoOwnerIds}:${res.data.msg}`,
  206. type: "success",
  207. });
  208. resetForm();
  209. getTransPortsList();
  210. } else {
  211. ElNotification.error({
  212. title: "失败",
  213. duration: 3000,
  214. message: res.data.msg,
  215. });
  216. }
  217. } else {
  218. return false;
  219. }
  220. });
  221. }
  222. async function changeSwitch(status, portId) {
  223. let res = await api.updatePortStatus({
  224. status,
  225. portId,
  226. });
  227. if (res.data.status == 0) {
  228. ElNotification.success({
  229. title: "成功",
  230. duration: 2000,
  231. message: res.data.msg,
  232. });
  233. }
  234. }
  235. async function cargoOwnerCompanyDetail(id) {
  236. router.push({
  237. path: "/cargoOwnerManage/cargoOwnerCompanyDetail",
  238. query: {
  239. id,
  240. },
  241. });
  242. }
  243. function pageChange(e) {
  244. currentPage.value = e;
  245. getTransPortsList();
  246. }
  247. let cargoOwnerCompanyStr = ref([]);
  248. function selectCargoOwnerCompany(e) {
  249. ruleForm.value.cargoOwnerIds = e.join(",");
  250. }
  251. let departurePortStr = ref("");
  252. function selectDeparturePort(e) {
  253. ruleForm.value.departurePortId = e;
  254. }
  255. let destinationPortStr = ref("");
  256. function selectDdestinationPort(e) {
  257. ruleForm.value.destinationPortId = e;
  258. }
  259. let options = ref([
  260. {
  261. value: "武汉",
  262. key: "1",
  263. },
  264. {
  265. value: "南京",
  266. key: "2",
  267. },
  268. {
  269. value: "郑州",
  270. key: "3",
  271. },
  272. ]);
  273. let cargoOwnerId = ref("");
  274. async function remoteMethod(term) {
  275. let res = await api.getCargoOwnerCompanySelect({
  276. term,
  277. });
  278. options.value = res.data.result;
  279. console.log(res);
  280. }
  281. function selectCargoOwner(e) {
  282. console.log(e);
  283. }
  284. let loading = ref(false);
  285. onMounted(() => {
  286. getTransPortsList();
  287. });
  288. </script>
  289. <style scoped>
  290. .seach-btn {
  291. display: inline-block;
  292. width: 60px;
  293. height: 38px;
  294. background: #0094fe;
  295. border-radius: 2px;
  296. font-size: 14px;
  297. font-family: PingFangSC-Regular, PingFang SC;
  298. font-weight: 400;
  299. color: #ffffff;
  300. text-align: center;
  301. line-height: 38px;
  302. margin-left: 15px;
  303. cursor: pointer;
  304. box-sizing: border-box;
  305. }
  306. .cargo-owner-add {
  307. width: 120px;
  308. height: 36px;
  309. border-radius: 2px;
  310. border: 1px solid #0094fe;
  311. font-size: 14px;
  312. font-family: PingFangSC-Regular, PingFang SC;
  313. font-weight: 400;
  314. color: #0094fe;
  315. line-height: 36px;
  316. text-align: center;
  317. cursor: pointer;
  318. margin-right: 20px;
  319. }
  320. :deep().el-dialog {
  321. width: 560px;
  322. padding: 20px 50px;
  323. border-radius: 6px;
  324. }
  325. :deep() .el-dialog__title {
  326. font-size: 18px;
  327. font-family: PingFangSC-Regular, PingFang SC;
  328. font-weight: 400;
  329. color: #0094fe;
  330. }
  331. </style>