shipCheckTemplateList.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <div class="full-container-p24">
  3. <div class="df jcsb">
  4. <div style="display: flex">
  5. <el-input
  6. placeholder="请输入模板名称"
  7. prefix-icon="el-icon-search"
  8. v-model="term"
  9. clearable
  10. size="large"
  11. class="mr30"
  12. style="width: 300px"
  13. ></el-input>
  14. <el-button
  15. size="large"
  16. type="primary"
  17. @click="getSecurityTemplateList(1)"
  18. >
  19. 查询
  20. </el-button>
  21. </div>
  22. <el-button size="large" type="primary" @click="showDialog">
  23. 创建安检模板
  24. </el-button>
  25. </div>
  26. <div style="margin-top: 24px">
  27. <el-table border :data="tableData" stripe style="width: 100%">
  28. <el-table-column
  29. type="index"
  30. label="序号"
  31. width="80"
  32. align="center"
  33. ></el-table-column>
  34. <el-table-column
  35. prop="securityCheckName"
  36. label="船东名称"
  37. min-width="120"
  38. align="center"
  39. ></el-table-column>
  40. <el-table-column
  41. prop="shipLen"
  42. label="适用船型"
  43. min-width="120"
  44. align="center"
  45. ></el-table-column>
  46. <el-table-column
  47. prop="createTime"
  48. label="创建时间"
  49. min-width="120"
  50. align="center"
  51. >
  52. <template v-slot="scope">
  53. {{ subTimeStr(scope.row.createTime) }}
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="操作" min-width="80" align="center">
  57. <template v-slot="scope">
  58. <el-button
  59. @click="getSecurityTemplateDetail(scope.row.id)"
  60. type="primary"
  61. text
  62. size="small"
  63. >
  64. 编辑
  65. </el-button>
  66. <el-button
  67. @click="
  68. deleteSecurityTemplate(
  69. scope.row.id,
  70. scope.row.securityCheckName
  71. )
  72. "
  73. type="danger"
  74. text
  75. size="small"
  76. >
  77. 删除
  78. </el-button>
  79. </template>
  80. </el-table-column>
  81. </el-table>
  82. <div class="df aic jcfe mt40 mr20">
  83. <el-pagination
  84. background
  85. layout="prev, pager, next"
  86. :current-page="currentPage"
  87. :total="total"
  88. @current-change="pageChange"
  89. ></el-pagination>
  90. </div>
  91. </div>
  92. </div>
  93. </template>
  94. <script setup>
  95. import { ref, h, reactive, toRefs, onMounted } from "vue";
  96. import { ElNotification, ElMessageBox, ElMessage } from "element-plus";
  97. import store from "../../store";
  98. import router from "../../router";
  99. import md5 from "md5";
  100. import api from "../../apis/fetch";
  101. import { subTimeStr } from "../../utils/utils";
  102. function showDialog() {
  103. router.push("/shipSecurityManage/shipCheckTemplateDetail");
  104. }
  105. let currentPage = ref(1);
  106. let term = ref("");
  107. let tableData = ref([]);
  108. let total = ref(0);
  109. async function getSecurityTemplateList(page) {
  110. currentPage.value = page || currentPage.value;
  111. let res = await api.getSecurityTemplateList({
  112. currentPage: currentPage.value,
  113. size: 10,
  114. term: term.value,
  115. });
  116. if (res.data.status == 0) {
  117. tableData.value = res.data.result;
  118. total.value = res.data.total;
  119. } else {
  120. tableData.value = [];
  121. total.value = 0;
  122. }
  123. }
  124. async function getSecurityTemplateDetail(id) {
  125. router.push({
  126. path: "/shipSecurityManage/shipCheckTemplateDetail",
  127. query: {
  128. id,
  129. },
  130. });
  131. }
  132. function deleteSecurityTemplate(id, securityCheckName) {
  133. ElMessageBox.confirm(`确认删除安检模板: ${securityCheckName} ?`, "提示", {
  134. confirmButtonText: "确认",
  135. cancelButtonText: "取消",
  136. type: "warning",
  137. })
  138. .then(async () => {
  139. let { data } = await api.deleteSecurityTemplate({
  140. id,
  141. });
  142. if (data.status == 0) {
  143. ElMessage({
  144. type: "success",
  145. message: data.msg,
  146. duration: 1500,
  147. });
  148. }
  149. getSecurityTemplateList();
  150. })
  151. .catch(() => {});
  152. }
  153. function pageChange(e) {
  154. currentPage.value = e;
  155. getSecurityTemplateList();
  156. }
  157. onMounted(() => {
  158. getSecurityTemplateList();
  159. });
  160. </script>
  161. <style scoped>
  162. .seach-btn {
  163. display: inline-block;
  164. width: 60px;
  165. height: 38px;
  166. background: #0094fe;
  167. border-radius: 2px;
  168. font-size: 14px;
  169. font-family: PingFangSC-Regular, PingFang SC;
  170. font-weight: 400;
  171. color: #ffffff;
  172. text-align: center;
  173. line-height: 38px;
  174. margin-left: 10px;
  175. cursor: pointer;
  176. }
  177. .cargo-owner-add {
  178. width: 80px;
  179. height: 32px;
  180. border-radius: 2px;
  181. border: 1px solid #0094fe;
  182. font-size: 14px;
  183. font-family: PingFangSC-Regular, PingFang SC;
  184. font-weight: 400;
  185. color: #0094fe;
  186. line-height: 32px;
  187. text-align: center;
  188. cursor: pointer;
  189. }
  190. :deep().el-dialog {
  191. width: 560px;
  192. padding: 20px 50px;
  193. border-radius: 6px;
  194. }
  195. :deep() .el-dialog__title {
  196. font-size: 18px;
  197. font-family: PingFangSC-Regular, PingFang SC;
  198. font-weight: 400;
  199. color: #0094fe;
  200. }
  201. </style>