agencyCompanyList.vue 6.1 KB

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