| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <template>
- <z-paging ref="paging" v-model="list" bgColor="#f7f7f7" @query="query" safe-area-inset-bottom>
- <template #top>
- <ut-navbar title="种养殖任务" :fixed="false">
- <template #left><view class=""></view></template>
- </ut-navbar>
- </template>
- <view class="d-flex a-c pd-24 pb-0 bg-#f7f7f7">
- <view class="min-w-170 flex1">
- <ut-action-sheet v-model="form.taskType" :tabs="[{ label: '全部', value: '' }, ...pt_task_type]" @change="onRefresh" title="选择原料类型">
- <view class="d-flex search-select-item a-c">
- <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>
- <up-icon size="24rpx" color="#333" name="arrow-down-fill" class="mr-5"></up-icon>
- </view>
- </ut-action-sheet>
- </view>
- <view class="h-86 pl-20 w-100%">
- <ut-search ref="searchRef" v-model="form.keyword" @search="changeSeach" margin="0" :border="false" placeholder="搜批次号、品种名、基地名" bgColor="#fff" height="86rpx" borderRadius="10rpx"></ut-search>
- </view>
- </view>
- <view class="pd-24 bg-#f7f7f7" :style="{ width: windowInfo ? windowInfo.screenWidth - 26 + 'px' : '100%' }">
- <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>
- </view>
- <view class="pd-24">
- <up-swipe-action>
- <up-swipe-action-item v-for="(item, index) in list" :key="index" :options="options2" class="mb-20" @click="clickTempSwipe">
- <task :data="item" @click="$u.route({ type: 'navigateTo', url: '/plant/port/port-detail/index', params: { id: item?.id } })" />
- </up-swipe-action-item>
- </up-swipe-action>
- </view>
- <view class="h-210" v-if="list?.length"></view>
- <view v-if="list?.length" :style="{ height: `${safeAreaBottom}px` }"></view>
- <template #empty>
- <view class="d-flex flex-cln a-c" style="margin-top: -200rpx">
- <ut-empty class="mg-at" color="#ccc" size="28rpx" image="/static/images/plant/noEmptyBase.png">暂无进行中的养殖任务</ut-empty>
- <text class="c-#ccc f-s-28">点击下方按钮去添加吧~</text>
- </view>
- </template>
- <template #bottom>
- <ut-tabar activeTab="planting"></ut-tabar>
- </template>
- </z-paging>
- <ut-suspension v-if="sus?.left" :imageWidth="60" :imageHeight="60" :x="sus?.left" :y="sus?.bottom" :inertia="false" :snap-threshold="40">
- <image src="/static/images/common/btn_add_logo.png" mode="widthFix" class="w-120 h-120" @click="showDeleteDialog = true"></image>
- </ut-suspension>
- <ut-confirm-dialog v-model:show="showDeleteDialog" width="80vw" title="请选择要创建的任务类型" :confirmText="'确认选择'" :cancelText="'取消'" @confirm="handlechoseConfirm" @cancel="handleDeleteCancel">
- <view class="" v-for="item in pt_task_type" :key="item?.value">
- <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)">
- <view class="radius-50% mg-8">
- <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>
- </view>
- <view class="c-#333 f-s-34">
- {{ item?.label }}
- </view>
- <view class="flex1"></view>
- <view class="d-flex">
- <img v-if="basetype === item.value" class="w-30 h-30" src="/static/images/plant/chooseSuccessfully.png" mode="widthFix" alt="" />
- </view>
- </view>
- </view>
- </ut-confirm-dialog>
- </template>
- <script setup lang="ts">
- import { useClientRequest } from '@/utils/request';
- import { onShareAppMessage } from '@dcloudio/uni-app';
- import Task from './models/task.vue';
- const { proxy } = getCurrentInstance() as ComponentInternalInstance;
- const { pt_task_type } = toRefs<any>(proxy?.useDict('pt_task_type'));
- setTimeout(() => {
- console.log(pt_task_type.value, 'pt_task_type');
- }, 2000);
- const list = ref<unknown[]>();
- const form = ref({ taskType: '', keyword: '' });
- const paging = ref();
- const windowInfo = uni.getWindowInfo();
- const safeAreaBottom = windowInfo.safeAreaInsets.bottom;
- const systemInfo = uni.getSystemInfoSync();
- const sus = ref({
- left: 0,
- bottom: 0,
- });
- sus.value.left = systemInfo.windowWidth - 10;
- sus.value.bottom = systemInfo.windowHeight - 200;
- //分段器的配置
- const subList = ref(['进行中', '已结束']);
- const subCurrent = ref(0);
- const sectionChange = (index: number) => {
- subCurrent.value = index;
- paging.value.reload();
- };
- const changeSeach = () => {
- paging.value.reload();
- };
- const query = async (pageNum: number, pageSize: number) => {
- const params = {
- pageNum,
- pageSize,
- ...form.value,
- };
- const res = await useClientRequest.get('/plt-api/app/plantationTask/list', params);
- if (res) {
- const { rows } = res;
- paging.value.complete(rows);
- }
- };
- const options2 = reactive([
- {
- text: '复制任务',
- style: {
- backgroundColor: '#37A954',
- width: '80rpx',
- fontSize: '28rpx',
- },
- },
- {
- text: '结束任务',
- style: {
- backgroundColor: '#F74C30',
- width: '80rpx',
- fontSize: '28rpx',
- },
- },
- ]);
- const onRefresh = () => {
- paging.value.reload();
- };
- //选择创建类型
- const showDeleteDialog = ref(false);
- const basetype = ref();
- const handlechose = (item: string) => {
- basetype.value = item;
- };
- // 处理取消
- const handleDeleteCancel = () => {
- showDeleteDialog.value = false;
- basetype.value = null;
- };
- const handlechoseConfirm = () => {
- uni.$u.route({ type: 'navigateTo', url: '/plant/port/port-create/index', params: { taskType: basetype.value } });
- };
- const clickTempSwipe = async (event: object) => {
- const { name, index } = event as any;
- if (index === 1) {
- try {
- const res = await uni.showModal({
- title: '结束提示',
- content: '确定结束该任务吗?',
- confirmColor: '#f56c6c',
- });
- if (!res.confirm) return;
- await uni.showLoading({
- title: '结束中...',
- mask: true,
- });
- // await useClientRequest.get(`/plt-api/app/base/delById/${name}`);
- uni.hideLoading();
- uni.showToast({
- title: '结束成功',
- icon: 'success',
- });
- paging.value?.reload();
- } catch (error) {
- console.error('结束任务失败:', error);
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- // @import '@/assets/styles/theme.scss';
- .search-select-item {
- height: 86rpx;
- background-color: #fff;
- border-radius: 10rpx;
- box-sizing: border-box;
- padding-left: 16rpx;
- padding-right: 16rpx;
- padding-top: 14rpx;
- padding-bottom: 14rpx;
- }
- :deep(.u-subsection__item) {
- border: 1px solid transparent !important;
- }
- :deep(.u-swipe-action-item__right__button__wrapper__text) {
- line-height: 1.6 !important;
- white-space: normal;
- }
- </style>
|