cargoOwnerCompanyDetail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. <template>
  2. <div class="line-container-p24">
  3. <i class="el-icon-arrow-left"></i>
  4. <div
  5. class="dib go-back ml8"
  6. @click="router.replace('/cargoOwnerManage/cargoOwnerCompanyList')"
  7. >
  8. 返回货主列表
  9. </div>
  10. </div>
  11. <div class="container-title">货主信息</div>
  12. <div class="line-container-p24 df aic">
  13. <div class="normal-label">货主名称</div>
  14. <div class="show-input">{{ cargoOwnerName }}</div>
  15. <div class="normal-label">联系人</div>
  16. <div class="show-input">{{ contactName }}</div>
  17. <div class="normal-label">联系人手机号</div>
  18. <div class="show-input">{{ contactPhone }}</div>
  19. </div>
  20. <div class="container-title">账号信息</div>
  21. <div class="line-container-p24">
  22. <div style="display: flex; justify-content: space-between">
  23. <div style="display: flex">
  24. <el-input
  25. placeholder="名称/手机号"
  26. prefix-icon="el-icon-search"
  27. v-model="term"
  28. clearable
  29. style="width: 330px"
  30. ></el-input>
  31. <div class="seach-btn" @click="getCargoOwnerAccountList(1)">查询</div>
  32. </div>
  33. <div class="cargo-owner-add" @click="dialogFormVisible = true">
  34. 添加账号
  35. </div>
  36. <el-dialog
  37. title="添加账号"
  38. v-model="dialogFormVisible"
  39. @closed="resetForm"
  40. >
  41. <template v-slot:default>
  42. <el-form
  43. :model="ruleForm"
  44. :rules="rules"
  45. ref="form"
  46. label-width="110px"
  47. label-position="left"
  48. >
  49. <el-form-item label="货主公司名称">
  50. {{ cargoOwnerName }}
  51. </el-form-item>
  52. <el-form-item prop="userName" label="姓名">
  53. <el-input
  54. style="width: 280px"
  55. v-model="ruleForm.userName"
  56. ></el-input>
  57. </el-form-item>
  58. <el-form-item prop="phone" label="手机号">
  59. <el-input
  60. style="width: 280px"
  61. v-model="ruleForm.phone"
  62. ></el-input>
  63. </el-form-item>
  64. <el-form-item prop="password" label="密码">
  65. <el-input
  66. style="width: 280px"
  67. v-model="ruleForm.password"
  68. ></el-input>
  69. </el-form-item>
  70. <!-- <el-form-item prop="cargo" label="关联货种">
  71. <el-select
  72. v-model="ruleForm.cargo"
  73. placeholder="请选择"
  74. style="width: 280px"
  75. >
  76. <el-option
  77. v-for="item in options"
  78. :key="item.value"
  79. :label="item.label"
  80. :value="item.key"
  81. />
  82. </el-select>
  83. </el-form-item> -->
  84. </el-form>
  85. </template>
  86. <template v-slot:footer>
  87. <div class="dialog-footer">
  88. <el-button @click="resetForm">取 消</el-button>
  89. <el-button type="primary" @click="addCargoOwnerAccount(ruleForm)">
  90. 确认添加
  91. </el-button>
  92. </div>
  93. </template>
  94. </el-dialog>
  95. </div>
  96. <div style="margin-top: 24px">
  97. <el-table :data="tableData" stripe style="width: 100%">
  98. <el-table-column
  99. type="index"
  100. label="序号"
  101. min-width="80"
  102. align="center"
  103. ></el-table-column>
  104. <el-table-column
  105. prop="userName"
  106. label="姓名"
  107. min-width="120"
  108. align="center"
  109. ></el-table-column>
  110. <el-table-column
  111. prop="phone"
  112. label="手机号"
  113. min-width="120"
  114. align="center"
  115. ></el-table-column>
  116. <el-table-column
  117. prop="password"
  118. label="密码"
  119. min-width="160"
  120. align="center"
  121. ></el-table-column>
  122. <el-table-column
  123. prop="deptName"
  124. label="部门"
  125. min-width="160"
  126. align="center"
  127. >
  128. <template v-slot="scope">
  129. {{ scope.row.deptName || "暂无部门" }}
  130. </template>
  131. </el-table-column>
  132. <el-table-column
  133. prop="roleName"
  134. label="职位"
  135. min-width="160"
  136. align="center"
  137. >
  138. <template v-slot="scope">
  139. {{ scope.row.roleName || "暂无职位" }}
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. <div style="width: 100%; text-align: right; margin-top: 43px">
  144. <el-pagination
  145. background
  146. layout="prev, pager, next"
  147. :current-page="currentPage"
  148. :total="total"
  149. @current-change="pageChange"
  150. ></el-pagination>
  151. </div>
  152. </div>
  153. </div>
  154. <div class="container-title">代理信息</div>
  155. <div class="line-container-p24">
  156. <div style="display: flex; justify-content: space-between">
  157. <div style="display: flex">
  158. <el-input
  159. placeholder="公司名称/联系人/手机号"
  160. prefix-icon="el-icon-search"
  161. v-model="term2"
  162. clearable
  163. style="width: 330px"
  164. ></el-input>
  165. <div class="seach-btn" @click="getAgencyCompanyByCargoOwnerCompany(1)">
  166. 查询
  167. </div>
  168. </div>
  169. <div class="cargo-owner-add" @click="dialogFormVisible2 = true">
  170. 关联代理公司
  171. </div>
  172. <el-dialog
  173. title="关联代理公司"
  174. v-model="dialogFormVisible2"
  175. @closed="resetForm2"
  176. >
  177. <template v-slot:default>
  178. <el-form
  179. :model="ruleForm2"
  180. :rules="rules2"
  181. ref="form2"
  182. label-width="110px"
  183. label-position="left"
  184. >
  185. <el-form-item prop="proxyId" label="代理公司:">
  186. <RemoteSearch
  187. api="getAgencySelect"
  188. v-model="agencyStr"
  189. @selectItem="selectAgency($event)"
  190. class="mb10"
  191. ></RemoteSearch>
  192. </el-form-item>
  193. </el-form>
  194. </template>
  195. <template v-slot:footer>
  196. <div class="dialog-footer">
  197. <el-button @click="resetForm2">取 消</el-button>
  198. <el-button type="primary" @click="relateCargoAgency(ruleForm2)">
  199. 确认关联
  200. </el-button>
  201. </div>
  202. </template>
  203. </el-dialog>
  204. </div>
  205. <div style="margin-top: 24px">
  206. <el-table :data="tableData2" stripe style="width: 100%">
  207. <el-table-column
  208. type="index"
  209. label="序号"
  210. min-width="80"
  211. align="center"
  212. ></el-table-column>
  213. <el-table-column
  214. prop="agencyName"
  215. label="代理公司名称"
  216. min-width="120"
  217. align="center"
  218. ></el-table-column>
  219. <el-table-column
  220. prop="contactName"
  221. label="联系人"
  222. min-width="120"
  223. align="center"
  224. ></el-table-column>
  225. <el-table-column
  226. prop="contactPhone"
  227. label="联系人手机号"
  228. min-width="160"
  229. align="center"
  230. ></el-table-column>
  231. </el-table>
  232. <div style="width: 100%; text-align: right; margin-top: 43px">
  233. <el-pagination
  234. background
  235. layout="prev, pager, next"
  236. :current-page="currentPage2"
  237. :total="total2"
  238. @current-change="pageChange2"
  239. ></el-pagination>
  240. </div>
  241. </div>
  242. </div>
  243. </template>
  244. <script setup>
  245. import { ref, h, reactive, toRefs, onMounted } from "vue";
  246. import { ElNotification, ElMessageBox, ElMessage } from "element-plus";
  247. import store from "../../store";
  248. import router from "../../router";
  249. import { useRoute } from "vue-router";
  250. import api from "../../apis/fetch";
  251. import { subTimeStr } from "../../utils/utils";
  252. const route = useRoute();
  253. let cargoOwnerName = ref();
  254. let contactName = ref();
  255. let contactPhone = ref();
  256. async function getCargoOwnerCompanyDetail() {
  257. let res = await api.getCargoOwnerCompanyDetail({
  258. cargoOwnerId: route.query.id,
  259. });
  260. if (res.data.status == 0) {
  261. cargoOwnerName.value = res.data.result.cargoOwnerName;
  262. contactName.value = res.data.result.contactName;
  263. contactPhone.value = res.data.result.contactPhone;
  264. } else {
  265. console.log(res);
  266. }
  267. }
  268. let tableData = ref([]);
  269. let term = ref("");
  270. let currentPage = ref(1);
  271. let total = ref(0);
  272. let dialogFormVisible = ref(false);
  273. let form = ref(null);
  274. async function getCargoOwnerAccountList(page) {
  275. currentPage.value = page || currentPage.value;
  276. let res = await api.getCargoOwnerAccountList({
  277. cargoOwnerId: route.query.id,
  278. currentPage: currentPage.value,
  279. size: 10,
  280. term: term.value,
  281. });
  282. if (res.data.status == 0) {
  283. tableData.value = res.data.result;
  284. total.value = res.data.total;
  285. } else {
  286. tableData.value = [];
  287. total.value = 0;
  288. }
  289. }
  290. const ruleForm = ref({
  291. userName: "",
  292. phone: "",
  293. password: "",
  294. cargo: "",
  295. });
  296. const rules = ref({
  297. userName: [{ required: true, message: "请填写姓名", trigger: "blur" }],
  298. phone: [
  299. { required: true, message: "请填写手机号", trigger: "blur" },
  300. { min: 11, max: 11, message: "请正确填写手机号", trigger: "blur" },
  301. ],
  302. password: [{ required: false, message: "请填写密码", trigger: "blur" }],
  303. cargo: [{ required: true, message: "请选择货种", trigger: "blur" }],
  304. });
  305. let options = ref([]);
  306. async function getCargoList() {
  307. let res = await api.getCargoList({
  308. cargoOwnerId: route.query.id,
  309. });
  310. options.value = res.data.result;
  311. }
  312. function resetForm() {
  313. dialogFormVisible.value = false;
  314. form.value.resetFields();
  315. }
  316. function pageChange(e) {
  317. currentPage.value = e;
  318. getCargoOwnerAccountList();
  319. }
  320. async function addCargoOwnerAccount() {
  321. form.value.validate(async (valid) => {
  322. if (valid) {
  323. let { userName, phone, password, cargo } = ruleForm.value;
  324. let res = await api.addCargoOwnerAccount({
  325. cargoOwnerId: route.query.id,
  326. userName,
  327. phone,
  328. password,
  329. cargo,
  330. });
  331. console.log(res);
  332. if (res.data.status == 0) {
  333. ElNotification.success({
  334. title: "添加成功",
  335. duration: 2000,
  336. message: `${userName}:${res.data.msg}`,
  337. type: "success",
  338. });
  339. resetForm();
  340. getCargoOwnerAccountList();
  341. } else {
  342. ElNotification.error({
  343. title: "失败",
  344. duration: 3000,
  345. message: res.data.msg,
  346. });
  347. }
  348. } else {
  349. return false;
  350. }
  351. });
  352. }
  353. let tableData2 = ref([]);
  354. let term2 = ref("");
  355. let currentPage2 = ref(1);
  356. let total2 = ref(0);
  357. let dialogFormVisible2 = ref(false);
  358. let form2 = ref(null);
  359. async function getAgencyCompanyByCargoOwnerCompany(page) {
  360. currentPage2.value = page || currentPage2.value;
  361. let res = await api.getAgencyCompanyByCargoOwnerCompany({
  362. cargoOwnerId: route.query.id,
  363. currentPage: currentPage2.value,
  364. size: 10,
  365. term: term2.value,
  366. });
  367. if (res.data.status == 0) {
  368. tableData2.value = res.data.result;
  369. total2.value = res.data.total;
  370. } else {
  371. tableData2.value = [];
  372. total2.value = 0;
  373. }
  374. }
  375. let agencyStr = ref("");
  376. const ruleForm2 = ref({
  377. proxyId: "",
  378. });
  379. const rules2 = ref({
  380. proxyId: [{ required: true, message: "请选择代理公司", trigger: "blur" }],
  381. });
  382. function selectAgency(item) {
  383. ruleForm2.value.proxyId = item.key;
  384. }
  385. function resetForm2() {
  386. dialogFormVisible2.value = false;
  387. agencyStr.value = "";
  388. form2.value.resetFields();
  389. }
  390. function pageChange2(e) {
  391. currenrPage2.value = e;
  392. getAgencyCompanyByCargoOwnerCompany();
  393. }
  394. async function relateCargoAgency() {
  395. form2.value.validate(async (valid) => {
  396. if (valid) {
  397. let { proxyId } = ruleForm2.value;
  398. let res = await api.relateCargoAgency({
  399. cargoOwnerId: route.query.id,
  400. proxyId,
  401. });
  402. console.log(res);
  403. if (res.data.status == 0) {
  404. ElNotification.success({
  405. title: "添加成功",
  406. duration: 2000,
  407. message: `${res.data.msg}`,
  408. type: "success",
  409. });
  410. resetForm2();
  411. getAgencyCompanyByCargoOwnerCompany();
  412. } else {
  413. ElNotification.error({
  414. title: "失败",
  415. duration: 3000,
  416. message: res.data.msg,
  417. });
  418. }
  419. } else {
  420. return false;
  421. }
  422. });
  423. }
  424. onMounted(() => {
  425. getCargoOwnerCompanyDetail();
  426. getCargoOwnerAccountList();
  427. getAgencyCompanyByCargoOwnerCompany();
  428. // getCargoList();
  429. });
  430. </script>
  431. <style scoped>
  432. .go-back {
  433. font-size: 16px;
  434. font-family: PingFangSC-Medium, PingFang SC;
  435. font-weight: 500;
  436. color: #333d43;
  437. line-height: 100%;
  438. cursor: pointer;
  439. }
  440. .normal-label {
  441. font-size: 14px;
  442. font-family: PingFangSC-Regular, PingFang SC;
  443. font-weight: 400;
  444. color: #353a42;
  445. margin-right: 10px;
  446. }
  447. .show-input {
  448. width: 200px;
  449. height: 32px;
  450. background: #ffffff;
  451. border-radius: 2px;
  452. border: 1px solid #dee0e3;
  453. font-size: 14px;
  454. font-family: PingFangSC-Regular, PingFang SC;
  455. font-weight: 400;
  456. color: #333333;
  457. line-height: 32px;
  458. padding-left: 12px;
  459. margin-right: 40px;
  460. }
  461. .radio-btns {
  462. height: 38px;
  463. width: 103px;
  464. border: 1px solid #1486f9;
  465. line-height: 38px;
  466. text-align: center;
  467. font-size: 14px;
  468. font-family: PingFangSC-Regular, PingFang SC;
  469. font-weight: 400;
  470. color: #0094fe;
  471. cursor: pointer;
  472. }
  473. .left-radius {
  474. border-top-left-radius: 19px;
  475. border-bottom-left-radius: 19px;
  476. }
  477. .right-radius {
  478. border-top-right-radius: 19px;
  479. border-bottom-right-radius: 19px;
  480. }
  481. .currentbtn {
  482. background: #1486f9;
  483. color: #fff;
  484. }
  485. .seach-btn {
  486. display: inline-block;
  487. width: 60px;
  488. height: 38px;
  489. background: #0094fe;
  490. border-radius: 2px;
  491. font-size: 14px;
  492. font-family: PingFangSC-Regular, PingFang SC;
  493. font-weight: 400;
  494. color: #ffffff;
  495. text-align: center;
  496. line-height: 38px;
  497. margin-left: 15px;
  498. cursor: pointer;
  499. box-sizing: border-box;
  500. }
  501. .seach-btn {
  502. display: inline-block;
  503. width: 60px;
  504. height: 38px;
  505. background: #0094fe;
  506. border-radius: 2px;
  507. font-size: 14px;
  508. font-family: PingFangSC-Regular, PingFang SC;
  509. font-weight: 400;
  510. color: #ffffff;
  511. text-align: center;
  512. line-height: 38px;
  513. margin-left: 15px;
  514. cursor: pointer;
  515. box-sizing: border-box;
  516. }
  517. .cargo-owner-add {
  518. width: 120px;
  519. height: 36px;
  520. border-radius: 2px;
  521. border: 1px solid #0094fe;
  522. font-size: 14px;
  523. font-family: PingFangSC-Regular, PingFang SC;
  524. font-weight: 400;
  525. color: #0094fe;
  526. line-height: 36px;
  527. text-align: center;
  528. cursor: pointer;
  529. margin-right: 20px;
  530. }
  531. :deep().el-dialog {
  532. width: 560px;
  533. padding: 20px 50px;
  534. border-radius: 6px;
  535. }
  536. :deep() .el-dialog__title {
  537. font-size: 18px;
  538. font-family: PingFangSC-Regular, PingFang SC;
  539. font-weight: 400;
  540. color: #0094fe;
  541. }
  542. </style>