cargoOwnerCompanyList.vue 7.4 KB

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