cargoOwnerCompanyList.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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="getCargoOwnerCompanyList">查询</div>
  13. </div>
  14. <div class="cargo-owner-add" @click="dialogFormVisible = true">
  15. 添加货主公司
  16. </div>
  17. <el-dialog title="添加货主公司" v-model="dialogFormVisible">
  18. <template v-slot:default>
  19. <el-form
  20. :model="ruleForm"
  21. :rules="rules"
  22. ref="form"
  23. label-width="110px"
  24. label-position="left"
  25. >
  26. <el-form-item prop="companyName" label="货主公司名称">
  27. <el-input
  28. style="width: 280px"
  29. v-model="ruleForm.companyName"
  30. ></el-input>
  31. </el-form-item>
  32. <el-form-item prop="contactName" label="联系人">
  33. <el-input
  34. style="width: 280px"
  35. v-model="ruleForm.contactName"
  36. ></el-input>
  37. </el-form-item>
  38. <el-form-item prop="contactPhone" label="联系人手机号">
  39. <el-input
  40. style="width: 280px"
  41. v-model="ruleForm.contactPhone"
  42. ></el-input>
  43. </el-form-item>
  44. </el-form>
  45. </template>
  46. <template v-slot:footer>
  47. <div class="dialog-footer">
  48. <el-button @click="resetForm">取 消</el-button>
  49. <el-button type="primary" @click="addCargoOwnerCompany(ruleForm)">
  50. 确 定
  51. </el-button>
  52. </div>
  53. </template>
  54. </el-dialog>
  55. </div>
  56. <div style="margin-top: 24px">
  57. <el-table :data="tableData" stripe style="width: 100%">
  58. <el-table-column
  59. type="index"
  60. label="序号"
  61. min-width="80"
  62. align="center"
  63. ></el-table-column>
  64. <el-table-column
  65. prop="companyName"
  66. label="货主公司名称"
  67. min-width="120"
  68. align="center"
  69. ></el-table-column>
  70. <el-table-column
  71. prop="contactName"
  72. label="联系人"
  73. min-width="120"
  74. align="center"
  75. ></el-table-column>
  76. <el-table-column
  77. prop="contactPhone"
  78. label="联系人手机号"
  79. min-width="160"
  80. align="center"
  81. ></el-table-column>
  82. <el-table-column
  83. prop="createTime"
  84. label="入驻时间"
  85. min-width="200"
  86. align="center"
  87. >
  88. <template v-slot="scope">
  89. {{ subTimeStr(scope.row.createTime) }}
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="操作" min-width="80" align="center">
  93. <template v-slot="scope">
  94. <el-button
  95. @click="cargoOwnerCompanyDetail(scope.row.id, tableData)"
  96. type="text"
  97. size="small"
  98. >
  99. 查看详情
  100. </el-button>
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. <div style="width: 100%; text-align: right; margin-top: 43px">
  105. <el-pagination
  106. background
  107. layout="prev, pager, next"
  108. :total="total"
  109. @current-change="pageChange"
  110. ></el-pagination>
  111. </div>
  112. </div>
  113. </div>
  114. </template>
  115. <script setup>
  116. import { ref, h, reactive, toRefs, onMounted } from "vue";
  117. import { ElNotification, ElMessageBox, ElMessage } from "element-plus";
  118. import store from "../../store";
  119. import router from "../../router";
  120. import md5 from "md5";
  121. import api from "../../apis/fetch";
  122. import { subTimeStr } from "../../utils/utils";
  123. let currentPage = ref(1);
  124. let term = ref("");
  125. let tableData = ref([]);
  126. let total = ref(0);
  127. let dialogFormVisible = ref(false);
  128. let form = ref(null);
  129. const ruleForm = ref({
  130. companyName: "",
  131. contactName: "",
  132. contactPhone: "",
  133. });
  134. const rules = ref({
  135. companyName: [
  136. { required: true, message: "请填写货主公司名称", trigger: "blur" },
  137. ],
  138. contactName: [{ required: true, message: "请填写联系人", trigger: "blur" }],
  139. contactPhone: [
  140. { required: true, message: "请填写手机号", trigger: "blur" },
  141. { min: 11, max: 11, message: "请正确填写手机号", trigger: "blur" },
  142. ],
  143. });
  144. async function getCargoOwnerCompanyList() {
  145. tableData.value = [];
  146. let res = await api.getCargoOwnerCompanyList({
  147. currentPage: currentPage.value,
  148. size: 10,
  149. term: term.value,
  150. });
  151. term.value = "";
  152. if (res.data.status == 0) {
  153. tableData.value = res.data.result;
  154. total.value = res.data.total;
  155. }
  156. }
  157. function resetForm() {
  158. dialogFormVisible.value = false;
  159. form.value.resetFields();
  160. }
  161. async function addCargoOwnerCompany() {
  162. form.value.validate(async (valid) => {
  163. if (valid) {
  164. let { companyName, contactName, contactPhone } = ruleForm.value;
  165. let res = await api.addCargoOwnerCompany({
  166. companyName,
  167. contactName,
  168. contactPhone,
  169. });
  170. console.log(res);
  171. if (res.data.status == 0) {
  172. ElNotification.success({
  173. title: "添加成功",
  174. duration: 0,
  175. message: `${companyName}:${res.data.msg}`,
  176. type: "success",
  177. });
  178. resetForm();
  179. getCargoOwnerCompanyList();
  180. } else {
  181. ElNotification.error({
  182. title: "失败",
  183. duration: 3000,
  184. message: res.data.msg,
  185. });
  186. }
  187. } else {
  188. return false;
  189. }
  190. });
  191. }
  192. async function cargoOwnerCompanyDetail(id) {
  193. router.push({
  194. path: "/cargoOwnerManage/cargoOwnerCompanyDetail",
  195. query: {
  196. id,
  197. },
  198. });
  199. }
  200. function pageChange(e) {
  201. currentPage.value = e;
  202. getCargoOwnerCompanyList();
  203. }
  204. onMounted(() => {
  205. getCargoOwnerCompanyList();
  206. });
  207. </script>
  208. <style scoped>
  209. .seach-btn {
  210. display: inline-block;
  211. width: 60px;
  212. height: 38px;
  213. background: #0094fe;
  214. border-radius: 2px;
  215. font-size: 14px;
  216. font-family: PingFangSC-Regular, PingFang SC;
  217. font-weight: 400;
  218. color: #ffffff;
  219. text-align: center;
  220. line-height: 38px;
  221. margin-left: 15px;
  222. cursor: pointer;
  223. box-sizing: border-box;
  224. }
  225. .cargo-owner-add {
  226. width: 120px;
  227. height: 36px;
  228. border-radius: 2px;
  229. border: 1px solid #0094fe;
  230. font-size: 14px;
  231. font-family: PingFangSC-Regular, PingFang SC;
  232. font-weight: 400;
  233. color: #0094fe;
  234. line-height: 36px;
  235. text-align: center;
  236. cursor: pointer;
  237. margin-right: 20px;
  238. }
  239. :deep().el-dialog {
  240. width: 560px;
  241. padding: 20px 50px;
  242. border-radius: 6px;
  243. }
  244. :deep() .el-dialog__title {
  245. font-size: 18px;
  246. font-family: PingFangSC-Regular, PingFang SC;
  247. font-weight: 400;
  248. color: #0094fe;
  249. }
  250. </style>