agencyCompanyList.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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="height: 32px; width: 330px; line-height: 32px"
  11. ></el-input>
  12. <div class="seach-btn" @click="getAgencyList">查询</div>
  13. </div>
  14. <el-button type="primary" @click="visable = true">添加代理</el-button>
  15. </div>
  16. <el-dialog v-model="visable" title="添加代理" width="550px">
  17. <template v-slot:default>
  18. <div class="df jcc">
  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="proxyName" label="代理名称">
  27. <el-input
  28. style="width: 280px"
  29. v-model="ruleForm.proxyName"
  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. </div>
  46. </template>
  47. <template v-slot:footer>
  48. <div class="dialog-footer">
  49. <el-button @click="resetForm">取 消</el-button>
  50. <el-button type="primary" @click="addAgency(ruleForm)">
  51. 确 定
  52. </el-button>
  53. </div>
  54. </template>
  55. </el-dialog>
  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="userName"
  66. label="代理公司"
  67. min-width="100"
  68. align="center"
  69. ></el-table-column>
  70. <el-table-column
  71. prop="contactName"
  72. label="联系人"
  73. min-width="100"
  74. align="center"
  75. ></el-table-column>
  76. <el-table-column
  77. prop="phone"
  78. label="手机号"
  79. min-width="80"
  80. align="center"
  81. ></el-table-column>
  82. <el-table-column
  83. prop="createTime"
  84. label="入驻时间"
  85. min-width="160"
  86. align="center"
  87. ></el-table-column>
  88. <el-table-column label="操作" min-width="120" align="center">
  89. <template v-slot="scope">
  90. <div class="df aic jcsa">
  91. <!-- <el-switch
  92. v-model="scope.row.accountStatus"
  93. active-color="#13ce66"
  94. inactive-color="#ff4949"
  95. active-text="启用"
  96. inactive-text="禁用"
  97. :active-value="1"
  98. :inactive-value="0"
  99. /> -->
  100. <el-button disabled size="small" type="danger">删除</el-button>
  101. </div>
  102. </template>
  103. </el-table-column>
  104. </el-table>
  105. <div style="width: 100%; text-align: right; margin-top: 43px">
  106. <el-pagination
  107. background
  108. layout="prev, pager, next"
  109. :total="total"
  110. @current-change="pageChange"
  111. ></el-pagination>
  112. </div>
  113. </div>
  114. </div>
  115. </template>
  116. <script setup>
  117. import api from "../../apis/fetch";
  118. import { ref, onMounted, reactive } from "vue";
  119. import { ElNotification, ElMessageBox } from "element-plus";
  120. let tableData = ref([]);
  121. let currentPage = ref(1);
  122. let total = ref(0);
  123. let term = ref("");
  124. let loginAccountId = ref(0);
  125. let ruleForm = ref({
  126. proxyName: "",
  127. contactName: "",
  128. contactPhone: "",
  129. });
  130. const rules = reactive({
  131. proxyName: [
  132. {
  133. required: true,
  134. message: "请填写代理名称",
  135. trigger: "blur",
  136. },
  137. ],
  138. contactPhone: [
  139. {
  140. required: true,
  141. message: "请填联系人手机号",
  142. trigger: "blur",
  143. },
  144. ],
  145. contactName: [
  146. {
  147. required: true,
  148. message: "请填写联系人名称",
  149. trigger: "blur",
  150. },
  151. ],
  152. });
  153. async function getAgencyList() {
  154. let res = await api.getAgencyList({
  155. term: term.value,
  156. currentPage: currentPage.value,
  157. size: 10,
  158. loginAccountId: loginAccountId.value,
  159. });
  160. if (res.data.status == 0) {
  161. tableData.value = res.data.result;
  162. total.value = res.data.total;
  163. } else {
  164. tableData.value = [];
  165. total.value = 0;
  166. }
  167. }
  168. function pageChange(e) {
  169. currentPage.value = e;
  170. getAgencyList();
  171. }
  172. let visable = ref(false);
  173. let form = ref(null);
  174. async function addAgency() {
  175. console.log(ruleForm.value);
  176. let res = await api.addAgency({
  177. ...ruleForm.value,
  178. loginAccountId: loginAccountId.value,
  179. });
  180. console.log(res);
  181. let status = res.data.status == 0;
  182. ElNotification({
  183. title: status ? "成功" : "失败",
  184. duration: 1500,
  185. message: res.data.msg,
  186. type: status ? "success" : "error",
  187. });
  188. resetForm();
  189. getAgencyList();
  190. }
  191. function resetForm() {
  192. visable.value = false;
  193. form.value.resetFields();
  194. }
  195. function closeModal() {
  196. proxyName.value = "";
  197. contactPhone.value = "";
  198. contactName.value = "";
  199. }
  200. onMounted(() => {
  201. loginAccountId.value = localStorage.loginAccountId;
  202. getAgencyList();
  203. });
  204. </script>
  205. <style scoped>
  206. .seach-btn {
  207. display: inline-block;
  208. width: 60px;
  209. height: 38px;
  210. background: #0094fe;
  211. border-radius: 2px;
  212. font-size: 14px;
  213. font-family: PingFangSC-Regular, PingFang SC;
  214. font-weight: 400;
  215. color: #ffffff;
  216. text-align: center;
  217. line-height: 38px;
  218. margin-left: 10px;
  219. cursor: pointer;
  220. }
  221. </style>