index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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">
  5. <template #left><view class=""></view></template>
  6. </ut-navbar>
  7. </template>
  8. <view class="d-flex a-c pd-24 pb-0 bg-#f7f7f7">
  9. <view class="min-w-170 flex1">
  10. <ut-action-sheet v-model="form.taskType" :tabs="[{ label: '全部', value: '' }, ...pt_task_type]" @change="onRefresh" title="选择原料类型">
  11. <view class="d-flex search-select-item a-c">
  12. <view class="flex1 ov-hd f-s-28 c-333 text-center f-w-5 w-s-no">{{ selectDictLabel(pt_task_type, form.taskType) || '全部' }}</view>
  13. <up-icon size="24rpx" color="#333" name="arrow-down-fill" class="mr-5"></up-icon>
  14. </view>
  15. </ut-action-sheet>
  16. </view>
  17. <view class="h-86 pl-20 w-100%">
  18. <ut-search ref="searchRef" v-model="form.keyword" @search="changeSeach" margin="0" :border="false" placeholder="搜批次号、品种名、基地名" bgColor="#fff" height="86rpx" borderRadius="10rpx"></ut-search>
  19. </view>
  20. </view>
  21. <view class="pd-24 bg-#f7f7f7" :style="{ width: windowInfo ? windowInfo.screenWidth - 26 + 'px' : '100%' }">
  22. <up-subsection :list="subList" :current="subCurrent" @change="sectionChange" style="width: 100%; height: 100rpx; background-color: #fff" inactive-color="#999" active-color="#37A954" fontSize="36rpx" mode="subsection"></up-subsection>
  23. </view>
  24. <view class="pd-24">
  25. <up-swipe-action>
  26. <up-swipe-action-item v-for="(item, index) in list" :key="index" :options="options2" class="mb-20" @click="clickTempSwipe">
  27. <task :data="item" @click="$u.route({ type: 'navigateTo', url: '/plant/port/port-detail/index', params: { id: item?.id } })" />
  28. </up-swipe-action-item>
  29. </up-swipe-action>
  30. </view>
  31. <view class="h-210" v-if="list?.length"></view>
  32. <view v-if="list?.length" :style="{ height: `${safeAreaBottom}px` }"></view>
  33. <template #empty>
  34. <view class="d-flex flex-cln a-c" style="margin-top: -200rpx">
  35. <ut-empty class="mg-at" color="#ccc" size="28rpx" image="/static/images/plant/noEmptyBase.png">暂无进行中的养殖任务</ut-empty>
  36. <text class="c-#ccc f-s-28">点击下方按钮去添加吧~</text>
  37. </view>
  38. </template>
  39. <template #bottom>
  40. <ut-tabar activeTab="planting"></ut-tabar>
  41. </template>
  42. </z-paging>
  43. <ut-suspension v-if="sus?.left" :imageWidth="60" :imageHeight="60" :x="sus?.left" :y="sus?.bottom" :inertia="false" :snap-threshold="40">
  44. <image src="/static/images/common/btn_add_logo.png" mode="widthFix" class="w-120 h-120" @click="showDeleteDialog = true"></image>
  45. </ut-suspension>
  46. <ut-confirm-dialog v-model:show="showDeleteDialog" width="80vw" title="请选择要创建的任务类型" :confirmText="'确认选择'" :cancelText="'取消'" @confirm="handlechoseConfirm" @cancel="handleDeleteCancel">
  47. <view class="" v-for="item in pt_task_type" :key="item?.value">
  48. <view style="border: 1rpx solid" :style="{ backgroundColor: item?.value == basetype ? '#EBF6EE' : '#f7f7f7', borderColor: item?.value == basetype ? '#37A954' : 'transparent' }" class="pr-30 d-flex a-c mb-20 radius-100" @click="handlechose(item.value)">
  49. <view class="radius-50% mg-8">
  50. <up-avatar size="90rpx" :src="item?.avatar || 'https://ta.zycpzs.cn/oss-file/smart-trace/szyy/images/common/avatar.png'" class="mr-20"></up-avatar>
  51. </view>
  52. <view class="c-#333 f-s-34">
  53. {{ item?.label }}
  54. </view>
  55. <view class="flex1"></view>
  56. <view class="d-flex">
  57. <img v-if="basetype === item.value" class="w-30 h-30" src="/static/images/plant/chooseSuccessfully.png" mode="widthFix" alt="" />
  58. </view>
  59. </view>
  60. </view>
  61. </ut-confirm-dialog>
  62. </template>
  63. <script setup lang="ts">
  64. import { useClientRequest } from '@/utils/request';
  65. import { onShareAppMessage } from '@dcloudio/uni-app';
  66. import Task from './models/task.vue';
  67. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  68. const { pt_task_type } = toRefs<any>(proxy?.useDict('pt_task_type'));
  69. setTimeout(() => {
  70. console.log(pt_task_type.value, 'pt_task_type');
  71. }, 2000);
  72. const list = ref<unknown[]>();
  73. const form = ref({ taskType: '', keyword: '' });
  74. const paging = ref();
  75. const windowInfo = uni.getWindowInfo();
  76. const safeAreaBottom = windowInfo.safeAreaInsets.bottom;
  77. const systemInfo = uni.getSystemInfoSync();
  78. const sus = ref({
  79. left: 0,
  80. bottom: 0,
  81. });
  82. sus.value.left = systemInfo.windowWidth - 10;
  83. sus.value.bottom = systemInfo.windowHeight - 200;
  84. //分段器的配置
  85. const subList = ref(['进行中', '已结束']);
  86. const subCurrent = ref(0);
  87. const sectionChange = (index: number) => {
  88. subCurrent.value = index;
  89. paging.value.reload();
  90. };
  91. const changeSeach = () => {
  92. paging.value.reload();
  93. };
  94. const query = async (pageNum: number, pageSize: number) => {
  95. const params = {
  96. pageNum,
  97. pageSize,
  98. ...form.value,
  99. };
  100. const res = await useClientRequest.get('/plt-api/app/plantationTask/list', params);
  101. if (res) {
  102. const { rows } = res;
  103. paging.value.complete(rows);
  104. }
  105. };
  106. const options2 = reactive([
  107. {
  108. text: '复制任务',
  109. style: {
  110. backgroundColor: '#37A954',
  111. width: '80rpx',
  112. fontSize: '28rpx',
  113. },
  114. },
  115. {
  116. text: '结束任务',
  117. style: {
  118. backgroundColor: '#F74C30',
  119. width: '80rpx',
  120. fontSize: '28rpx',
  121. },
  122. },
  123. ]);
  124. const onRefresh = () => {
  125. paging.value.reload();
  126. };
  127. //选择创建类型
  128. const showDeleteDialog = ref(false);
  129. const basetype = ref();
  130. const handlechose = (item: string) => {
  131. basetype.value = item;
  132. };
  133. // 处理取消
  134. const handleDeleteCancel = () => {
  135. showDeleteDialog.value = false;
  136. basetype.value = null;
  137. };
  138. const handlechoseConfirm = () => {
  139. uni.$u.route({ type: 'navigateTo', url: '/plant/port/port-create/index', params: { taskType: basetype.value } });
  140. };
  141. const clickTempSwipe = async (event: object) => {
  142. const { name, index } = event as any;
  143. if (index === 1) {
  144. try {
  145. const res = await uni.showModal({
  146. title: '结束提示',
  147. content: '确定结束该任务吗?',
  148. confirmColor: '#f56c6c',
  149. });
  150. if (!res.confirm) return;
  151. await uni.showLoading({
  152. title: '结束中...',
  153. mask: true,
  154. });
  155. // await useClientRequest.get(`/plt-api/app/base/delById/${name}`);
  156. uni.hideLoading();
  157. uni.showToast({
  158. title: '结束成功',
  159. icon: 'success',
  160. });
  161. paging.value?.reload();
  162. } catch (error) {
  163. console.error('结束任务失败:', error);
  164. }
  165. }
  166. };
  167. </script>
  168. <style lang="scss" scoped>
  169. // @import '@/assets/styles/theme.scss';
  170. .search-select-item {
  171. height: 86rpx;
  172. background-color: #fff;
  173. border-radius: 10rpx;
  174. box-sizing: border-box;
  175. padding-left: 16rpx;
  176. padding-right: 16rpx;
  177. padding-top: 14rpx;
  178. padding-bottom: 14rpx;
  179. }
  180. :deep(.u-subsection__item) {
  181. border: 1px solid transparent !important;
  182. }
  183. :deep(.u-swipe-action-item__right__button__wrapper__text) {
  184. line-height: 1.6 !important;
  185. white-space: normal;
  186. }
  187. </style>