list.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <ion-page class="list-page company-list-page">
  3. <ion-header class="header-theme2">
  4. <ion-toolbar>
  5. <ion-buttons slot="start">
  6. <ion-icon :icon="arrowBackOutline" @click="onBack"></ion-icon>
  7. </ion-buttons>
  8. <ion-title>企业信息收集</ion-title>
  9. <ion-buttons slot="end">
  10. <ion-icon :icon="addCircleOutline" @click="onAdd"></ion-icon>
  11. </ion-buttons>
  12. </ion-toolbar>
  13. </ion-header>
  14. <ion-content>
  15. <ion-item class="search-item">
  16. <ion-input placeholder="请输入公司名称" class="custom"
  17. v-model="searchParams.companyName" style="border: 1px solid #f2f2f5;border-radius: 14px;--padding-start: 10px;height: 35px;"></ion-input>
  18. <ion-button slot="end" style="height: 33px;width: 70px;margin-left: 10px;--box-shadow: none;--border-radius: 14px;" @click="reload" >搜索
  19. </ion-button>
  20. </ion-item>
  21. <div class="bw-vue-list">
  22. <div class="list-content" v-if="!loading">
  23. <ion-list>
  24. <div v-for="(record,key) in dataList" :key="key">
  25. <ion-item-sliding>
  26. <ion-item detail @click="onDetail(record.companyID)">
  27. <ion-label>
  28. <div class="multi-title">
  29. <h2>{{ record.companyName }}</h2>
  30. </div>
  31. <p>地点:{{record.companyAddress}}</p>
  32. <p>联系人:{{record.userName}}</p>
  33. <div class="multi-title">
  34. <p>联系电话:{{record.userMobile}}</p>
  35. <p>岗位数量:{{ record.postCount }}</p>
  36. </div>
  37. </ion-label>
  38. </ion-item>
  39. <ion-item-options>
  40. <ion-item-option @click="onEdit(record.companyID)">
  41. <ion-icon :icon="buildOutline"></ion-icon>
  42. </ion-item-option>
  43. <ion-item-option color="danger" @click="setDelAlertOpen(true, record.companyID)">
  44. <ion-icon :icon="trashOutline"></ion-icon>
  45. </ion-item-option>
  46. </ion-item-options>
  47. </ion-item-sliding>
  48. </div>
  49. </ion-list>
  50. </div>
  51. </div>
  52. <b-empty v-if="dataList.length<=0" :loading="loading"/>
  53. <ion-infinite-scroll threshold="100px" @ionInfinite="onScroll($event)">
  54. <ion-infinite-scroll-content
  55. :loadingText="pagination.total>pagination.current*pagination.pageSize?'正在加载...':'暂无更多'"
  56. loadingSpinner="bubbles">
  57. </ion-infinite-scroll-content>
  58. </ion-infinite-scroll>
  59. </ion-content>
  60. <ion-alert
  61. :is-open="delAlertOpen"
  62. header="删除确认"
  63. message="确定要删除该企业吗?"
  64. :buttons="delAlertButtons"
  65. @didDismiss="setDelAlertOpen(false, null)"
  66. ></ion-alert>
  67. <ion-alert
  68. :is-open="infoAlertOpen"
  69. :header="infoAlterData.title"
  70. :message="infoAlterData.message"
  71. :buttons="infoAlertButtons"
  72. @didDismiss="setInfoAlertOpen(false)"
  73. ></ion-alert>
  74. <ion-loading
  75. :is-open="delLoading"
  76. message="删除中..."
  77. @didDismiss="setDelLoadingOpen(false)" >
  78. </ion-loading>
  79. </ion-page>
  80. </template>
  81. <script lang="ts">
  82. import {buildOutline,trashOutline,arrowBackOutline, addCircleOutline} from 'ionicons/icons';
  83. import {computed, defineComponent, reactive, ref} from 'vue';
  84. import {useRoute, useRouter} from "vue-router";
  85. import {useUserStore} from '@/store/modules/user';
  86. import {IonIcon, onIonViewDidEnter} from '@ionic/vue';
  87. import BEmpty from "@/components/empty.vue";
  88. import {post} from "@/api/common";
  89. import {getCompanyList} from '@/api/company/index';
  90. export default defineComponent({
  91. name: 'CompanyList',
  92. components: {IonIcon, BEmpty},
  93. setup() {
  94. const router = useRouter();
  95. const route = useRoute();
  96. const curUserID = ref("");
  97. const total = ref(10);
  98. const loading = ref(true);
  99. const searchParams = reactive({
  100. pageIndex: 1,
  101. pageSize: 5,
  102. loginUserID: '',
  103. companyName: '',
  104. });
  105. const pagination = computed(() => ({
  106. total: total,
  107. current: searchParams.pageIndex,
  108. pageSize: searchParams.pageSize
  109. }));
  110. const dataList = ref<any>([]);
  111. const loadData = async function () {
  112. loading.value = true;
  113. const loginUserInfo = useUserStore().getUserInfo;
  114. searchParams.loginUserID = curUserID.value = loginUserInfo.userID == undefined?"":loginUserInfo.userID;
  115. getCompanyList(searchParams).then(data => {
  116. dataList.value = dataList.value.concat(data.list);
  117. total.value = data.total;
  118. console.log(dataList.value);
  119. })
  120. loading.value = false;
  121. }
  122. const reload = () => {
  123. dataList.value = [];
  124. searchParams.pageIndex = 1;
  125. loadData();
  126. }
  127. const onScroll = (e: any) => {
  128. setTimeout(() => {
  129. e.target.complete();
  130. if (pagination.value.total.value > pagination.value.current * pagination.value.pageSize) {
  131. searchParams.pageIndex += 1;
  132. loadData();
  133. }
  134. }, 500);
  135. }
  136. // 信息弹窗内容
  137. const infoAlterData = reactive({
  138. title:"",
  139. message:""
  140. })
  141. // 删除警告弹窗开关
  142. const delAlertOpen = ref(false);
  143. // 删除警告弹窗按钮定义
  144. const infoAlertButtons = [
  145. {
  146. text: '确定',
  147. role: 'confirm',
  148. handler: () => {
  149. reload();
  150. },
  151. },
  152. ];
  153. // 删除数据
  154. const delCompanyID = ref("");
  155. // 删除加载
  156. const delLoading = ref(false);
  157. // 信息弹窗开关
  158. const infoAlertOpen = ref(false);
  159. // 删除警告弹窗按钮定义
  160. const delAlertButtons = [
  161. {
  162. text: '取消',
  163. role: 'cancel',
  164. handler: () => {
  165. reload();
  166. },
  167. },
  168. {
  169. text: '确定',
  170. role: 'confirm',
  171. handler: () => {
  172. delLoading.value = true;
  173. post("companyService/company/delete",[delCompanyID.value],"企业信息删除").then((res) => {
  174. /*infoAlterData.title = "提示";
  175. infoAlterData.message = "删除成功";
  176. setInfoAlertOpen(true);*/
  177. }).finally(()=>{
  178. delLoading.value = false;
  179. reload();
  180. });
  181. },
  182. },
  183. ];
  184. // 设置要删除的企业信息
  185. function setDelAlertOpen(value: boolean, companyID: any) {
  186. delAlertOpen.value = value;
  187. if(companyID != null) {
  188. delCompanyID.value = companyID;
  189. }
  190. }
  191. // 设置信息提示弹窗开关
  192. function setInfoAlertOpen(value: boolean) {
  193. infoAlertOpen.value = value;
  194. }
  195. // 设置删除弹窗开启关闭
  196. function setDelLoadingOpen(value: boolean) {
  197. delLoading.value = value;
  198. }
  199. const onDetail = (companyID:string) => {
  200. router.push({path: './detail', query: {reload: 1,id: companyID,loginUserID:curUserID.value}});
  201. }
  202. const onAdd = () => {
  203. router.push({path: './edit', query: {reload: 1,id: null,status: 1,loginUserID:curUserID.value}});
  204. }
  205. const onEdit = (companyID: string) => {
  206. router.push({path: './edit', query: {reload: 1, id: companyID,status: 1,loginUserID:curUserID.value}});
  207. }
  208. const onBack = () => {
  209. router.push('../');
  210. }
  211. onIonViewDidEnter(() => {
  212. if(route.query.reload)reload();
  213. });
  214. return {
  215. arrowBackOutline,
  216. addCircleOutline,
  217. buildOutline,
  218. trashOutline,
  219. router,
  220. total,
  221. loading,
  222. dataList,
  223. pagination,
  224. searchParams,
  225. delCompanyID,
  226. delAlertButtons,
  227. infoAlertButtons,
  228. delAlertOpen,
  229. infoAlertOpen,
  230. delLoading,
  231. infoAlterData,
  232. onBack,
  233. onAdd,
  234. onDetail,
  235. onScroll,
  236. onEdit,
  237. setDelAlertOpen,
  238. setInfoAlertOpen,
  239. setDelLoadingOpen,
  240. loadData,
  241. reload,
  242. }
  243. }
  244. });
  245. </script>
  246. <style lang="less">
  247. .custom{
  248. --placeholder-color: gray;
  249. --placeholder-opacity: 0.5;
  250. }
  251. .search-item{
  252. margin: 10px 0;
  253. font-size: 14px;
  254. ion-input{
  255. border: 1px solid #f2f2f5;
  256. border-radius: 4px;
  257. --padding-start: 10px;
  258. width: 100px;
  259. }
  260. input{
  261. padding: 6px !important;
  262. }
  263. }
  264. .company-list-page {
  265. .list-content {
  266. margin: 0px 15px !important;
  267. background-color: white !important;
  268. border-radius: 0 !important;
  269. ion-item {
  270. font-size: 14px;
  271. p {
  272. font-size: 12px;
  273. }
  274. }
  275. }
  276. }
  277. </style>