index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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" :name="item?.id" :options="subCurrent === 0 ? options2 : options" class="mb-20" @click="clickTempSwipe">
  27. <task :data="item" @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 } })" />
  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="subCurrent == 0">
  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="subCurrent == 1">
  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. const subCurrent = ref(0);
  98. const sectionChange = (index: number) => {
  99. subCurrent.value = index;
  100. if (index == 0) {
  101. form.value.status = 1;
  102. } else {
  103. form.value.status = 9;
  104. }
  105. paging.value.reload();
  106. };
  107. const changeSeach = () => {
  108. paging.value.reload();
  109. };
  110. const query = async (pageNum: number, pageSize: number) => {
  111. const params = {
  112. pageNum,
  113. pageSize,
  114. ...form.value,
  115. };
  116. const res = await useClientRequest.get('/plt-api/app/plantationTask/list', params);
  117. if (res) {
  118. const { rows } = res;
  119. paging.value.complete(rows);
  120. }
  121. };
  122. const options2 = reactive([
  123. {
  124. text: '复制任务',
  125. style: {
  126. backgroundColor: '#37A954',
  127. width: '80rpx',
  128. fontSize: '28rpx',
  129. },
  130. },
  131. {
  132. text: '结束任务',
  133. style: {
  134. backgroundColor: '#F74C30',
  135. width: '80rpx',
  136. fontSize: '28rpx',
  137. },
  138. },
  139. ]);
  140. const options = reactive([
  141. {
  142. text: '恢复任务',
  143. style: {
  144. backgroundColor: '#F19F18',
  145. width: '80rpx',
  146. fontSize: '28rpx',
  147. },
  148. },
  149. ]);
  150. const onRefresh = () => {
  151. paging.value.reload();
  152. };
  153. //选择创建类型
  154. const showDeleteDialog = ref(false);
  155. const basetype = ref('1');
  156. const handlechose = (item: string) => {
  157. basetype.value = item;
  158. };
  159. // 处理取消
  160. const handleDeleteCancel = () => {
  161. showDeleteDialog.value = false;
  162. };
  163. const handlechoseConfirm = () => {
  164. uni.$u.route({ type: 'navigateTo', url: '/plant/port/port-create/index', params: { taskType: basetype.value } });
  165. };
  166. const clickTempSwipe = async (event: object) => {
  167. const { name, index } = event as any;
  168. if (subCurrent.value == 1) {
  169. const res = await uni.showModal({
  170. title: '恢复提示',
  171. content: '确定恢复该任务吗?',
  172. confirmColor: '#f56c6c',
  173. });
  174. if (!res.confirm) return;
  175. await uni.showLoading({
  176. title: '恢复中...',
  177. mask: true,
  178. });
  179. await useClientRequest.get(`/plt-api/app/plantationTask/recover/${name}`);
  180. uni.hideLoading();
  181. uni.showToast({
  182. title: '恢复成功',
  183. icon: 'success',
  184. });
  185. paging.value?.reload();
  186. }
  187. if (index === 1 && subCurrent.value == 0) {
  188. try {
  189. const res = await uni.showModal({
  190. title: '结束提示',
  191. content: '确定结束该任务吗?',
  192. confirmColor: '#f56c6c',
  193. });
  194. if (!res.confirm) return;
  195. await uni.showLoading({
  196. title: '结束中...',
  197. mask: true,
  198. });
  199. await useClientRequest.get(`/plt-api/app/plantationTask/complete/${name}`);
  200. uni.hideLoading();
  201. uni.showToast({
  202. title: '结束成功',
  203. icon: 'success',
  204. });
  205. paging.value?.reload();
  206. } catch (error) {
  207. console.error('结束任务失败:', error);
  208. }
  209. }
  210. };
  211. </script>
  212. <style lang="scss" scoped>
  213. // @import '@/assets/styles/theme.scss';
  214. .search-select-item {
  215. height: 86rpx;
  216. background-color: #fff;
  217. border-radius: 10rpx;
  218. box-sizing: border-box;
  219. padding-left: 16rpx;
  220. padding-right: 16rpx;
  221. padding-top: 14rpx;
  222. padding-bottom: 14rpx;
  223. }
  224. :deep(.u-subsection__item) {
  225. border: 1px solid transparent !important;
  226. }
  227. :deep(.u-swipe-action-item__right__button__wrapper__text) {
  228. line-height: 1.6 !important;
  229. white-space: normal;
  230. }
  231. </style>