index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <z-paging ref="paging" v-model="list" bgColor="#f7f7f7" @query="query" safe-area-inset-bottom>
  3. <template #top>
  4. <ut-navbar title="往来单位管理" :fixed="false" border :breadcrumb="false"></ut-navbar>
  5. <view class="d-flex a-c pd-25">
  6. <view class="min-w-220 flex1">
  7. <ut-action-sheet v-model="form.cusType" :tabs="pt_cus_type" mode="custom" @change="onRefresh" title="选择往来单位性质">
  8. <view class="d-flex search-select-item a-c">
  9. <view class="flex1 ov-hd f-s-28 c-333 text-center f-w-5 w-s-no">{{ selectDictLabel(pt_cus_type, form.cusType) || '全部' }}</view>
  10. <up-icon size="24rpx" color="#333" name="arrow-down-fill" class="mr-5"></up-icon>
  11. </view>
  12. </ut-action-sheet>
  13. </view>
  14. <view class="h-86 pl-20 w-100%">
  15. <ut-search ref="searchRef" v-model="form.keyword" @search="onRefresh" margin="0" :border="false" :placeholder="placeholder" bgColor="#fff" height="86rpx" borderRadius="10rpx"></ut-search>
  16. </view>
  17. </view>
  18. <ut-tabs v-model="form.cpyType" :tabs="pt_cpy_type" @change="onRefresh"></ut-tabs>
  19. </template>
  20. <template>
  21. <view class="pl-25 pr-25">
  22. <up-swipe-action>
  23. <up-swipe-action-item v-for="item in list" :name="item?.id" :key="item?.id" :disabled="item?.storeCount" :options="optionsAction" @click="clickSwipe" class="mb-20 b-radius">
  24. <view @click.stop="clickItem(item)" class="b-radius bg-#fff pd-24 p-rtv base-shadow">
  25. <view class="d-flex j-sb a-c li-item-head mb-16">
  26. <view class="li-left-tag">{{ selectDictLabel(pt_cus_type, item?.cusType) }}</view>
  27. <view class="f-s-22 c-#666">{{ item?.updateTime || item?.createTime }}</view>
  28. </view>
  29. <view class="f-s-34 c-#333 f-w-500">{{ item?.cusName }}</view>
  30. <view class="f-s-24 c-#666">{{ item?.cusCode }}</view>
  31. <view class="pd-5"></view>
  32. <view class="f-s-28 pd2-5-0">
  33. <span class="c-#666">联系电话:</span>
  34. <span class="c-#333 f-w-600">{{ item?.contactTel }}</span>
  35. </view>
  36. </view>
  37. </up-swipe-action-item>
  38. </up-swipe-action>
  39. </view>
  40. </template>
  41. <!-- 空数据处理 -->
  42. <template #empty>
  43. <ut-empty class="mg-at" size="28rpx" color="#999" padding="10rpx"> 暂无往来单位信息,点击+号新增吧</ut-empty>
  44. </template>
  45. </z-paging>
  46. <ut-suspension @click="$u.route({ url: '/plant/contact-unit/unit-edit/index' })">
  47. <image src="@/static/images/common/btn_add_logo.png" mode="widthFix" class="w-120 h-120"></image>
  48. </ut-suspension>
  49. </template>
  50. <script setup lang="ts">
  51. import { useClientRequest } from '@/utils/request';
  52. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  53. const { pt_cus_type, pt_cpy_type } = toRefs<any>(proxy?.useDict('pt_cus_type', 'pt_cpy_type'));
  54. const paging = ref();
  55. const list = ref<any[]>([]);
  56. const placeholder = ref('搜往来单位名称、代码');
  57. const form = ref({
  58. keyword: '',
  59. cusType: '',
  60. cpyType: '',
  61. });
  62. const query = async (pageNum: number, pageSize: number) => {
  63. const params = {
  64. pageNum,
  65. pageSize,
  66. ...form.value,
  67. };
  68. const res = await useClientRequest.get<any>('/plt-api/app/customer/list', params);
  69. if (!res || res.code !== 200) return;
  70. const { rows } = res;
  71. paging.value.complete(rows);
  72. };
  73. const onRefresh = () => {
  74. paging.value.reload();
  75. };
  76. const optionsAction = reactive([
  77. {
  78. text: '删除',
  79. style: {
  80. backgroundColor: '#f56c6c',
  81. },
  82. },
  83. ]);
  84. const clickSwipe = async (event: object) => {
  85. const { name, index } = event as any;
  86. if (index === 0) {
  87. // 删除
  88. const res = await uni.showModal({
  89. title: '删除提示',
  90. content: '删除后不可撤回,请谨慎操作!',
  91. confirmColor: '#f56c6c',
  92. });
  93. console.log(res);
  94. if (res.confirm) {
  95. const delRes = await useClientRequest.get(`/plt-api/app/customer/remove/${name}`);
  96. if (delRes && delRes.code === 200) {
  97. uni.showToast({ title: '删除成功', icon: 'none' });
  98. onRefresh();
  99. }
  100. }
  101. }
  102. };
  103. const clickItem = (item: any) => {
  104. uni.$u.route({
  105. type: 'navigateTo',
  106. url: '/plant/contact-unit/unit-detail/index',
  107. params: {
  108. id: item?.id,
  109. },
  110. });
  111. };
  112. onMounted(() => {
  113. uni.$on('refreshContactUnitList', () => {
  114. onRefresh();
  115. });
  116. });
  117. </script>
  118. <style lang="scss" scoped>
  119. // @import '@/assets/styles/theme.scss';
  120. .search-select-item {
  121. height: 86rpx;
  122. background-color: #fff;
  123. border-radius: 10rpx;
  124. box-sizing: border-box;
  125. padding-left: 16rpx;
  126. padding-right: 16rpx;
  127. padding-top: 14rpx;
  128. padding-bottom: 14rpx;
  129. }
  130. .li-item-head {
  131. margin-left: -24rpx;
  132. margin-top: -24rpx;
  133. }
  134. .li-left-tag {
  135. padding: 4rpx 12rpx;
  136. background-color: #ebf6ee;
  137. color: #37a954;
  138. border-radius: 16rpx 0 16rpx 0;
  139. font-size: 20rpx;
  140. font-weight: 500;
  141. }
  142. </style>