index.vue 9.8 KB

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