Browse Source

refactor(交付物): 调整交付物细节;完善逻辑

deliver
wally 4 years ago
parent
commit
25ccd36e14
  1. 1
      CHANGELOG.md
  2. 6
      components/FinancialClause/FinancialClause.vue
  3. 20
      components/Plugin/Plugin.vue
  4. 10
      components/RoleButton/RoleButton.vue
  5. 25
      pages.json
  6. 53
      pages/checkLog/checkLog.vue
  7. 52
      pages/checkerList/checkerList.vue
  8. 70
      pages/submitLog/submitLog.vue
  9. 105
      pages/submitlist/submitlist.vue
  10. 3
      plugins/p-deliver-check/check-form-modal.vue
  11. 55
      plugins/p-deliver-check/p-deliver-check.vue
  12. 225
      plugins/p-deliver-upload/p-deliver-upload.vue
  13. 231
      plugins/p-deliver/p-deliver.vue
  14. 6
      plugins/p-task-title/p-task-title.vue

1
CHANGELOG.md

@ -48,6 +48,7 @@
createTask | 修复createTask v-model的问题 | [b20d3f0](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/b20d3f0)
- | defineExpose, defineEmits不需要引入 | [902cacc](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/902cacc)
交付物 | 修复检查人选择组件之间相互影响的bug | [435c0bd](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/435c0bd)
交付物 | 重构交付物审核部分,修复审核bug | [5fd8889](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/5fd8889)
- | 修复p-deliver报错taskRef的问题 | [880cf7c](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/880cf7c)
- | 修复一些内容 | [3cdb1ce](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/3cdb1ce)
- | 删除多余的引入 | [050b12a](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/050b12a)

6
components/FinancialClause/FinancialClause.vue

@ -1,7 +1,7 @@
<template>
<div class="h-7 bg-white rounded-md">
<view>
<!-- 预算和奖金 -->
<view class="flex h-3">
<view class="flex">
<view class="flex-1 rounded p-0">
<u-line-progress :percent="100" active-color="#93C5FD">
<view class="text-black">预算2000</view>
@ -22,7 +22,7 @@
<u-line-progress :percent="100" active-color="#FBBF24"> <view class="text-black">日常采购 50</view> </u-line-progress>
</view>
</view>
</div>
</view>
</template>
<script setup>

20
components/Plugin/Plugin.vue

@ -1,11 +1,11 @@
<template>
<view class="u-font-14" style="height: 100%">
<view class="u-font-14 rounded-md mt-1 bg-white" style="height: 100%">
<view @click="setStorage">
<Render :task="task" :pluginId="pluginId" :styleType="styleType" :pluginTaskId="pluginTaskId" :param="param" />
<!-- <plugin-default /> -->
<!-- <component :task="task" :is="pluginComponent"></component> -->
<p-task-title :task="task" v-if="pluginId === '1'" />
<p-task-description :task="task" v-if="pluginId === '2'" />
<p-task-title v-if="pluginId === '1'" />
<!-- <p-task-description :task="task" v-if="pluginId === '2'" />
<p-task-duration-delay :task="task" v-if="pluginId === '3'" />
<p-task-start-time-delay :task="task" v-if="pluginId === '4'" />
<p-upload-deliverable :task="task" v-if="pluginId === '5' && isMine" />
@ -17,24 +17,22 @@
<p-manage-role :task="task" v-if="pluginId === '10'" />
<p-manage-member :task="task" v-if="pluginId === '11'" />
<p-manage-task :task="task" v-if="pluginId === '12'" />
<p-wbs-import :task="task" v-if="pluginId === '13' || pluginId === '14'" />
<p-wbs-import :task="task" v-if="pluginId === '13' || pluginId === '14'" /> -->
<!-- 财务条插件 -->
<!-- 角色对应的管理按钮 -->
<f-button />
<!-- <f-button /> -->
<!-- 进度条 -->
<f-financial />
<!-- <f-financial /> -->
<!-- 交付物插件 -->
<!-- <p-deliver :task="task" v-if="pluginId === '15'" /> -->
<!-- TODO: 判断显示条件 -->
<p-deliver-check :task="task" />
<p-deliver v-if="pluginId === '15'" />
</view>
</view>
</template>
<script setup>
import { computed } from 'vue';
import { computed, provide } from 'vue';
import { useStore } from 'vuex';
import FFinancial from '../../plugins/f-Financial/f-Financial.vue';
import FButton from '../../plugins/f-button/f-button.vue';
@ -47,6 +45,8 @@ const props = defineProps({
param: { type: String, default: '' },
});
provide('task', props.task);
const store = useStore();
const roleId = computed(() => store.state.role.roleId);
const token = computed(() => store.state.user.token);

10
components/RoleButton/RoleButton.vue

@ -1,11 +1,11 @@
<template>
<div class="bg-white p-2 my-4 rounded-md h-8" v-show="!isFinance">
<button class="my-2 mx-8 h-6 text-xs bg-blue-500 text-white leading-6">资源管理</button>
<div class="p-2" v-show="!isFinance">
<button class="my-2 mx-8 text-xs bg-blue-500 text-white leading-6">资源管理</button>
</div>
<div class="bg-white p-2 my-4 rounded-md h-8 flex" v-show="isFinance">
<button class="my-2 ml-8 mr-4 h-6 text-xs bg-blue-500 text-white leading-6 w-full">财务审批</button>
<button class="my-2 mr-8 h-6 text-xs bg-blue-500 text-white leading-6 w-full">财务统计</button>
<div class="p-2 flex" v-show="isFinance">
<button class="my-2 ml-8 mr-4 text-xs bg-blue-500 text-white leading-6 w-full">财务审批</button>
<button class="my-2 mr-8 text-xs bg-blue-500 text-white leading-6 w-full">财务统计</button>
</div>
</template>

25
pages.json

@ -1,5 +1,5 @@
{
"pages": [ //pageshttps://uniapp.dcloud.io/collocation/pages
"pages": [
{
"path": "pages/index/index",
"style": {
@ -13,7 +13,6 @@
"navigationBarTextStyle": "white"
}
},
//
{
"path": "pages/user/accountLogin",
"style": {
@ -21,32 +20,24 @@
"navigationBarTextStyle": "white"
}
},
//
{
"path": "pages/user/login",
"style": {
"navigationStyle": "custom",
"navigationBarTextStyle": "white"
}
}
//
,{
"path" : "pages/submitList/submitList",
"style" :
},
{
"navigationStyle": "historty",
"navigationBarTitleText": "历史交付物"
}
"path": "pages/submitLog/submitLog",
"style": {
"navigationBarTitleText": "交付物上传记录"
}
//
,{
"path" : "pages/checkerList/checkerList",
"style" :
},
{
"navigationStyle": "kkkkk",
"path": "pages/checkLog/checkLog",
"style": {
"navigationBarTitleText": "审核记录"
}
}
],
"globalStyle": {

53
pages/checkLog/checkLog.vue

@ -0,0 +1,53 @@
<template>
<theme class="pt-1 h-full">
<view class="h-full overflow-y-scroll bg-white rounded-md p-3 text-gray-400">
<view v-for="item in checkerList" class="flex justify-between">
<view>
<view class="mb-1 text-gray-800">
{{ item.checkerName }}
</view>
<view class="mb-1 text-xs">
{{ item.remark }}
</view>
<view class="text-xs" v-if="+item.checkTime > 0">
{{ dayjs(+item.checkTime).format('MM-DD HH:mm') }}
</view>
</view>
<view class="flex flex-col justify-center">
<view class="mb-1 text-green-600" v-if="item.status === 1"> 已通过 </view>
<view class="mb-1 text-red-600" v-if="item.status === 2"> 已驳回 </view>
<view v-if="+item.score > 0">
<zwp-ring-timing mode="chart" :value="item.score" active-color="#F59E0B" radius="30" bar-width="4">
<text class="text-yellow-500 font-medium">{{ item.score }}</text>
</zwp-ring-timing>
</view>
</view>
</view>
</view>
</theme>
</template>
<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import dayjs from 'dayjs';
const checkerList = ref([]);
onLoad(options => {
getQueryCheckLog(options);
});
async function getQueryCheckLog(options) {
try {
const param = { deliverRecordId: options.deliverRecordId };
const data = await uni.$u.api.queryCheckLog(param);
checkerList.value = data;
} catch (error) {
console.log('error: ', error);
uni.$ui.showToast('获取检查交付物历史失败');
}
}
</script>
<style lang="scss"></style>

52
pages/checkerList/checkerList.vue

@ -1,52 +0,0 @@
<template>
<theme class="pt-1 h-full">
<view class="h-full overflow-y-scroll bg-white mx-5 my-2 rounded-md p-3 text-gray-400">
<view v-for="item in checkerList" class="flex justify-between">
<view>
<view class="pb-2 text-gray-800">
{{ item.checkerName }}
</view>
<view class="pb-1">
{{ item.remark }}
</view>
<view class="pb-2" v-if="item.checkTime > 0">
{{ dayjs(+item.checkTime).format('MM-DD HH:mm') }}
</view>
</view>
<view>
<view>{{ item.status === 1 ? '已通过' : '已驳回' }}</view>
<view v-if="item.score > 0">
<u-circle-progress active-color="#FA8C16" :percent="item.score" width="90" border-width="7" class="mt-2">
<view class="u-progress-content">
<view class="progress-dot text-white text-center">{{ item.score }}</view>
</view>
</u-circle-progress>
</view>
</view>
</view>
</view>
</theme>
</template>
<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import dayjs from 'dayjs';
const checkerList = ref([]);
onLoad(options => {
(async function getQueryCheckLog() {
try {
const param = { deliverRecordId: options.deliverRecordId };
const data = await uni.$u.api.queryCheckLog(param);
checkerList.value = data;
} catch (error) {
console.log('error: ', error);
uni.$ui.showToast('获取检查交付物历史失败');
}
}());
});
</script>
<style lang="scss"></style>

70
pages/submitLog/submitLog.vue

@ -0,0 +1,70 @@
<template>
<theme>
<view class="h-full w-full px-3 pt-1 overflow-y-scroll">
<view class="bg-white my-2 rounded-md p-3 text-gray-400" v-for="item in listRef">
<!-- 插件名称和提交时间显示 -->
<view class="flex justify-between mb-2">
<view class="text-gray-800">{{ deliverName }}</view>
<view class="text-xs">{{ dayjs(+item.submitTime).format('MM-DD HH:mm') }}</view>
</view>
<!-- 提交的链接 -->
<view class="break-all text-blue-400 text-xs">
{{ item.details[0] }}
</view>
<!-- 该插件物的审核人 -->
<view class="mb-1 mt-3">审核人</view>
<view class="flex justify-between mb-2" v-for="checkItem in item.checkerList">
<view>
<view class="mb-1 text-gray-800 font-semibold">
{{ checkItem.checkerName }}
</view>
<view class="mb-1 text-xs">
{{ checkItem.remark }}
</view>
<view class="mb-1 text-xs" v-if="+checkItem.checkTime > 0">
{{ dayjs(+checkItem.checkTime).format('MM-DD HH:mm') }}
</view>
</view>
<view class="text-center text-xs">
<view v-if="checkItem.status == null" class="text-gray-400">待审核</view>
<view v-else-if="checkItem.status === 1">
<view class="text-green-600 mb-1">已通过</view>
<zwp-ring-timing mode="chart" :value="checkItem.score" active-color="#F59E0B" radius="30" bar-width="4">
<text class="text-yellow-500 font-medium">{{ checkItem.score }}</text>
</zwp-ring-timing>
</view>
<view class="text-red-600" v-else>已驳回</view>
</view>
</view>
</view>
</view>
</theme>
</template>
<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import dayjs from 'dayjs';
const listRef = ref([]);
const deliverName = ref('');
onLoad(options => {
// id
(async function getHistory() {
try {
const param = { deliverId: options.deliverId };
const data = await uni.$u.api.getDeliverHistory(param);
deliverName.value = data.deliverName;
listRef.value = data.deliverRecordList;
} catch (error) {
console.log('error: ', error);
uni.$ui.showToast('获取交付物历史失败');
}
})();
});
</script>
<style lang="scss"></style>

105
pages/submitlist/submitlist.vue

@ -1,105 +0,0 @@
<template>
<theme class="pt-1">
<view class="h-full w-full overflow-y-scroll">
<view class="bg-white mx-5 my-2 rounded-md p-3 text-gray-400" v-for="item in listRef">
<!-- 插件名称和提交时间显示 -->
<view class="flex justify-between mb-2">
<view class="text-gray-800">{{ name }}</view>
<view>{{ dayjs(+item.submitTime).format('MM-DD HH:mm') }}</view>
</view>
<!-- 提交的链接 -->
<view class="w-64 break-all text-blue-400 py-2">
{{ item.details[0] }}
</view>
<!-- 该插件物的审核人 -->
<view class="mb-2">审核人</view>
<view class="flex justify-between my-3" v-for="items in item.checkerList">
<view>
<view class="pb-2 text-gray-800">
{{ items.checkerName }}
</view>
<view class="pb-2">
{{ items.remark }}
</view>
<view class="pb-2" v-if="items.checkTime > 0">
{{ dayjs(+items.checkTime).format('MM-DD HH:mm') }}
</view>
</view>
<view class="text-center">
<view v-show="items.isMine !== 1">{{ item.status == null ? '待审核' : item.status === 1 ? '已通过' : '已驳回' }}</view>
<view v-show="items.isMine === 1 && items.status == null" class="text-sm">待审核</view>
<view v-show="items.isMine === 1 && items.status !== null" class="text-sm">
<view>
{{ items.status === 1 ? '已通过' : '已驳回' }}
</view>
<view v-if="items.score > 0">
<u-circle-progress active-color="#FA8C16" :percent="items.score" width="90" border-width="7" class="mt-2">
<view class="u-progress-content">
<view class="progress-dot text-white text-center">{{ items.score }}</view>
</view>
</u-circle-progress>
</view>
</view>
</view>
</view>
</view>
</view>
</theme>
</template>
<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import dayjs from 'dayjs';
// const listRef = ref([
// {
// plugname:'V0.8',
// subtime:'12/25 13:01',
// link:'https://www.baidu.com/',
// reviewer:[
// {
// name:'',
// time: '12/25 14:22',
// advise:'',
// state:'',
// grade:80
// },
// {
// name:'',
// time: '12/28 8:22',
// advise:'',
// state:'',
// grade:''
// },
// {
// name:'',
// time: '',
// advise:'',
// state:'',
// grade:''
// },
// ]
// },
// ])
const listRef = ref([]);
const name = ref('');
onLoad(options => {
// id
(async function getHistory() {
try {
const param = { deliverId: options.deliverId };
const data = await uni.$u.api.getDeliverHistory(param);
name.value = data.deliverName;
listRef.value = data.deliverRecordList;
} catch (error) {
console.log('error: ', error);
uni.$ui.showToast('获取交付物历史失败');
}
}());
});
</script>
<style lang="scss"></style>

3
plugins/p-deliver-check/check-form-modal.vue

@ -54,7 +54,6 @@ const score = ref(100); // 评分
* @param {string} mode 'RESOLVE'|'REJECT'
*/
async function handleSubmit(mode) {
console.log('mode: ', mode);
try {
const deliverRecordId = props.data.deliverRecordId();
const param = {
@ -68,7 +67,7 @@ async function handleSubmit(mode) {
handleHide(); // +
uni.$ui.showToast('审核信息提交成功');
//
emits('submit-end', mode);
emits('submit-end', param);
} catch (error) {
console.error('error: ', error);
uni.$ui.showToast('审核信息提交失败, 请稍后重试');

55
plugins/p-deliver-check/p-deliver-check.vue

@ -1,10 +1,10 @@
<template>
<view class="bg-white p-3 rounded-md">
<view class="p-3">
<!-- 交付物名称 -->
<view class="flex justify-between" @click="collapsed = !collapsed">
<text>
{{ deliverData ? deliverData.deliverName : '' }}
</text>
<!-- {{ deliverData ? deliverData.deliverName : '' }} -->
<text> 审核状态 </text>
<!-- 展开折叠按钮 -->
<u-icon :name="collapsed ? 'arrow-up' : 'arrow-down'"></u-icon>
</view>
@ -12,23 +12,24 @@
<view v-show="collapsed" class="mt-1">
<!-- 提交人和时间信息 -->
<view class="text-gray-400 text-xs">
<text class="mr-4" v-if="deliverData && deliverData.submitMemberName">{{ deliverData.submitMemberName }}</text>
<text v-if="deliverData && deliverData.submitTime"> {{ dayjs(+deliverData.submitTime).format('MM-DD HH:mm') }}</text>
上传人<text class="mr-4" v-if="deliverData.submitMemberName">{{ deliverData.submitMemberName }}</text>
上传时间
<text v-if="deliverData.submitTime"> {{ dayjs(+deliverData.submitTime).format('MM-DD HH:mm') }}</text>
</view>
<!-- 提交的链接信息 -->
<view class="break-all text-blue-400 text-xs" v-if="deliverData && deliverData.details && deliverData.details[0]">
<view class="break-all text-blue-400 text-xs" v-if="deliverData.details && deliverData.details[0]">
{{ deliverData.details[0] }}
</view>
<!-- 审核人 标题 -->
<view class="text-gray-400 flex justify-between mt-3">
<text>审核</text>
<text class="text-blue-400 text-sm" @click="moreRecords">更多记录</text>
<text class="text-blue-400 text-xs" @click="openMoreRecords">更多记录</text>
</view>
<!-- 审核人 列表 -->
<view v-if="deliverData && deliverData.checkerList">
<view v-if="deliverData.checkerList">
<!-- 遍历审核人信息 -->
<view class="mt-2 text-sm flex justify-between" v-for="item in deliverData.checkerList">
<view>
@ -68,49 +69,27 @@
</view>
</view>
<checkFormModal :data="checkModal" @hide="checkModal.mode = 'HIDE'" @submit-end="handleUpdateCheckStatus" />
<checkFormModal :data="checkModal" @hide="checkModal.mode = 'HIDE'" @submit-end="$emit('check-success')" />
</view>
</template>
<script setup>
import { ref, computed, reactive } from 'vue';
import { useStore } from 'vuex';
import { ref, reactive, inject } from 'vue';
import dayjs from 'dayjs';
import checkFormModal from './check-form-modal.vue';
const props = defineProps({ task: { type: Object, default: () => {} } });
const store = useStore();
const deliverData = inject('deliver');
defineEmits(['check-success']);
const collapsed = ref(false);
const deliverData = ref(null); //
const checkModal = reactive({
mode: 'HIDE', // HIDE-> RESOLVE-> REJECT->
deliverRecordId: () => (deliverData.value ? deliverData.value.deliverRecordId : ''), // id
});
//
(async function getDeliverList() {
try {
const param = { taskId: props.task.id };
deliverData.value = await uni.$u.api.getDeliverByTaskId(param);
} catch (error) {
console.error('getDeliverList error: ', error);
}
})();
//
function moreRecords() {
const { deliverRecordId } = store.state.deliver;
uni.navigateTo({ url: `/pages/checkerList/checkerList?deliverRecordId=${deliverRecordId}` });
}
/**
*
* @param {string} mode RESOLVE|REJECT
*/
function handleUpdateCheckStatus(mode) {
const { checkerList } = deliverData.value;
const target = checkerList.find(item => item.isMine);
target.status = mode === 'RESOLVE' ? 1 : 2;
function openMoreRecords() {
const { deliverRecordId } = deliverData.value;
uni.navigateTo({ url: `/pages/checkLog/checkLog?deliverRecordId=${deliverRecordId}` });
}
</script>

225
plugins/p-deliver-upload/p-deliver-upload.vue

@ -0,0 +1,225 @@
<template>
<!-- 是自己的任务 且该任务有交付物 才显示提交组件 -->
<view class="bg-white p-2 rounded-md relative" @longpress.prevent="showMask = true">
<!-- 插件名称输入和提交 -->
<view class="flex item-center justify-between py-3 pl-2">
<view class="flex-1">
<text v-if="deliver.deliverName">
{{ deliver.deliverName }}
</text>
</view>
<!-- 提交 -->
<u-button
type="primary"
size="mini"
@click="submit"
class="self-center"
:disabled="submitState"
:ripple="true"
:loading="submitBtnLoading"
>
提交
</u-button>
<!-- 查看提交历史的按钮 -->
<u-icon name="arrow-right" class="ml-3" @click="openDeliverHistory"></u-icon>
</view>
<!-- 插件上传方式 -->
<view>
<view class="link-box">
<u-input v-model="linkValue" type="text" :border="true" placeholder="请输入交付物地址/链接" class="input"></u-input>
</view>
<view class="mt-3">
<u-button size="mini" :plain="true" type="primary" class="mr-3" @click="paste">粘贴</u-button>
<u-button size="mini" :plain="true" type="primary" class="mr-3" @click="uploadFile">文件</u-button>
<u-button size="mini" :plain="true" type="primary" class="mr-3" @click="uploadPhoto">拍照</u-button>
</view>
</view>
<!-- 编辑和删除的遮罩层 -->
<view class="mask flex items-center justify-center bg-grey" v-show="showMask" @click="showMask = false">
<view class="bg-yellow-500 text-white w-12 h-12 text-center leading-12 rounded-w-12 mx-8" @click.stop="showEditModal = true">
修改
</view>
<view class="bg-red-500 text-white w-12 h-12 text-center leading-12 rounded-w-12 mx-8" @click.stop="showDeleteModal = true">
删除
</view>
<!-- 删除的二次提示modal -->
<u-modal v-model="showDeleteModal" :content="content" :show-cancel-button="true" @confirm="confirmDelete"></u-modal>
</view>
<!-- 编辑交付物标题的modal -->
<u-mask :show="showEditModal" @click="showEditModal = false">
<view class="modal-content-wrap" @click.stop>
<view class="modal-content-head">交付物标题名称</view>
<view class="modal-content-body">
<u-input :border="true" placeholder="请输入交付物名称" v-model="newInputRef"></u-input>
</view>
<view class="modal-content-foot">
<view class="cancel" @click="showEditModal = false">取消</view>
<view class="confirm" @click="confirmEditDeliverName">确定</view>
</view>
</view>
</u-mask>
<!-- 插件审核人员选择 -->
<Reviewer ref="reviewerRef" />
</view>
</template>
<script setup>
import { ref, computed, inject } from 'vue';
import { useStore } from 'vuex';
import { UPLOAD_URL } from '@/config/index';
import { UPLOAD_EXTENSION } from '@/config/deliver';
const deliver = inject('deliver');
const task = inject('task');
const store = useStore();
const emits = defineEmits(['upload-success']);
const reviewerRef = ref(null);
const submitBtnLoading = ref(false);
const linkValue = ref(''); //
const showMask = ref(false); //
const showEditModal = ref(false); // modal
const newInputRef = ref(''); //
const showDeleteModal = ref(false); // modal
const content = '是否确定删除';
const showBadge = ref(false); // u-badge
//
const submitState = computed(() => !linkValue.value);
const projectId = computed(() => store.getters['project/projectId']);
//
function validateDeliverForm(checkedCheckers) {
const reg = /^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?$/;
if (!reg.test(linkValue.value)) {
// toast
uni.$ui.showToast('请输入正确的链接');
return false;
}
//
if (!checkedCheckers || !checkedCheckers.length) {
uni.$ui.showToast('请选择检查人');
return false;
}
return true;
}
//
async function submit() {
const { checkedCheckers } = reviewerRef.value; //
//
if (!validateDeliverForm(checkedCheckers)) return;
submitBtnLoading.value = true; // loading
//
try {
const checkerList = [];
checkedCheckers.forEach(item => {
checkerList.push(item.memberId);
});
const param = {
projectId: projectId.value,
deliverId: deliver.value.deliverId,
fileList: [linkValue.value],
checkerList,
};
await uni.$u.api.submitDeliverInfo(param);
uni.$ui.showToast('提交交付物信息成功');
resetControlState(); //
emits('upload-success');
} catch (error) {
console.log('error: ', error);
uni.$ui.showToast('提交交付物信息失败');
}
}
//
function resetControlState() {
submitBtnLoading.value = false; // loading
linkValue.value = ''; //
reviewerRef.value.collapsed = true; //
}
//
function openDeliverHistory() {
const { deliverId } = deliver.value;
// console.log(deliverId)
uni.navigateTo({ url: `/pages/submitLog/submitLog?deliverId=${deliverId}` });
}
//
function paste() {
uni.getClipboardData({
success(res) {
linkValue.value = res.data;
},
});
}
//
async function uploadFile() {
try {
const data = await uni.$upload.chooseAndUpload(UPLOAD_URL, {}, UPLOAD_EXTENSION, 'files');
// console.log(data[0]);
linkValue.value = data[0].visitUrl;
} catch (error) {
console.error('error: ', error);
}
}
// TODO:
async function uploadPhoto() {
try {
const data = await uni.$upload.chooseAndUpload(UPLOAD_URL, {}, UPLOAD_EXTENSION, 'files');
// console.log(data[0])
linkValue.value = data[0].visitUrl;
} catch (error) {
console.error('error: ', error);
}
}
//
async function confirmEditDeliverName() {
// TODO: task
if (!newInputRef.value) {
uni.$ui.showToast('输入不能为空');
}
try {
const param = {
projectId: projectId.value,
taskId: task.id,
deliverName: newInputRef.value,
};
await uni.$u.api.editDeliverName(param);
// uni.$ui.showToast('');
//
showEditModal.value = false;
showMask.value = false;
showBadge.value = false;
newInputRef.value = '';
} catch (error) {
console.error('error: ', error);
uni.$ui.showToast('修改交付物名称失败');
}
}
//
async function confirmDelete() {
try {
showDeleteModal.value = true;
deliverRef.value = false;
await uni.$u.api.deleteDeliver();
uni.$ui.showToast('删除交付物成功');
} catch (error) {
console.error('error: ', error);
uni.$ui.showToast('删除交付物失败');
}
}
</script>

231
plugins/p-deliver/p-deliver.vue

@ -1,244 +1,35 @@
<template>
<!-- 是自己的任务 且该任务有交付物 才显示提交组件 -->
<view class="my-2 bg-white p-2 rounded-md relative" @longpress.prevent="showMask = true" v-if="isMine && deliver">
<!-- 插件名称输入和提交 -->
<view class="flex item-center justify-between py-3 pl-2">
<view class="flex-1">
<span class="relative px-1" v-if="deliver && deliver.deliverName">
<!-- <u-badge :is-dot="true" is-center v-show="showBadge"></u-badge> -->
{{ deliver.deliverName }}
</span>
</view>
<!-- 提交 -->
<u-button
type="primary"
size="mini"
@click="submit"
class="self-center"
:disabled="submitState"
:ripple="true"
:loading="submitBtnLoading"
>
提交
</u-button>
<!-- 查看提交历史的按钮 -->
<u-icon name="arrow-right" class="ml-3" @click="openDeliverHistory"></u-icon>
</view>
<!-- 插件上传方式 -->
<view>
<view class="link-box">
<u-input v-model="linkValue" type="text" :border="true" placeholder="请输入交付物地址/链接" class="input"></u-input>
</view>
<view class="mt-3">
<u-button size="mini" :plain="true" type="primary" class="mr-3" @click="paste">粘贴</u-button>
<u-button size="mini" :plain="true" type="primary" class="mr-3" @click="uploadFile">文件</u-button>
<u-button size="mini" :plain="true" type="primary" class="mr-3" @click="uploadPhoto">拍照</u-button>
</view>
</view>
<!-- 编辑和删除的遮罩层 -->
<view class="mask flex items-center justify-center bg-grey" v-show="showMask" @click="showMask = false">
<view class="bg-yellow-500 text-white w-12 h-12 text-center leading-12 rounded-w-12 mx-8" @click.stop="showEditModal = true">
修改
</view>
<view class="bg-red-500 text-white w-12 h-12 text-center leading-12 rounded-w-12 mx-8" @click.stop="deleteDeliver">删除</view>
<!-- 删除的二次提示modal -->
<u-modal v-model="showDeleteModal" :content="content" :show-cancel-button="true" @confirm="confirmDelete"></u-modal>
</view>
<!-- 编辑交付物标题的modal -->
<u-mask :show="showEditModal" @click="showEditModal = false">
<view class="modal-content-wrap">
<view class="rect rounded-md" @tap.stop>
<view class="text-center my-7 font-semibold">交付物标题名称</view>
<view>
<u-input :border="true" class="m-5" placeholder="请输入交付物名称" v-model="newInputRef"></u-input>
</view>
<view class="flex justify-around h-12 mt-7 justify-self-stretch box-modal-border">
<view class="leading-12 flex-1 text-center delete-modal-border" @click="showEditModal = false">取消</view>
<view class="text-blue-700 leading-12 flex-1 text-center" @click="confirmEditDeliverName">确定</view>
</view>
</view>
</view>
</u-mask>
<!-- 上传提交 -->
<p-deliver-upload v-if="isMine && deliver" @upload-success="getDeliverData"></p-deliver-upload>
<!-- 插件审核人员选择 -->
<Reviewer ref="reviewerRef" />
<p-deliver-check v-if="deliver" @check-success="getDeliverData"></p-deliver-check>
</view>
</template>
<script setup>
import { ref, computed } from 'vue';
import { useStore } from 'vuex';
import { UPLOAD_URL } from '@/config/index';
import { UPLOAD_EXTENSION } from '@/config/deliver';
import { ref, inject, provide, computed } from 'vue';
const props = defineProps({ task: { type: Object, default: () => {} } });
const store = useStore();
const reviewerRef = ref(null);
const submitBtnLoading = ref(false);
const linkValue = ref(''); //
const showMask = ref(false); //
const showEditModal = ref(false); // modal
const newInputRef = ref(''); //
const showDeleteModal = ref(false); // modal
const content = '是否确定删除';
const showBadge = ref(false); // u-badge
const task = inject('task');
const deliver = ref(null); //
//
const submitState = computed(() => !linkValue.value);
const projectId = computed(() => store.getters['project/projectId']);
const isMine = computed(() => store.getters['role/isMine']); //
provide('deliver', deliver);
// id
(async function getDeliverData() {
async function getDeliverData() {
try {
const { id: taskId } = props.task;
const { id: taskId } = task;
if (!taskId) return;
const param = { taskId: props.task.id };
const param = { taskId };
const data = await uni.$u.api.getDeliverByTaskId(param);
deliver.value = data;
} catch (error) {
console.log('error: ', error);
}
})();
//
function validateDeliverForm(checkedCheckers) {
const reg = /^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?$/;
if (!reg.test(linkValue.value)) {
// toast
uni.$ui.showToast('请输入正确的链接');
return false;
}
//
if (!checkedCheckers || !checkedCheckers.length) {
uni.$ui.showToast('请选择检查人');
return false;
}
return true;
}
//
async function submit() {
const { checkedCheckers } = reviewerRef.value; //
//
if (!validateDeliverForm(checkedCheckers)) return;
submitBtnLoading.value = true; // loading
//
try {
const checkerList = [];
checkedCheckers.forEach(item => {
checkerList.push(item.memberId);
});
const param = {
projectId: projectId.value,
deliverId: deliver.value.deliverId,
fileList: [linkValue.value],
checkerList,
};
await uni.$u.api.submitDeliverInfo(param);
uni.$ui.showToast('提交交付物信息成功');
resetControlState(); //
} catch (error) {
console.log('error: ', error);
uni.$ui.showToast('提交交付物信息失败');
}
}
//
function resetControlState() {
submitBtnLoading.value = false; // loading
linkValue.value = ''; //
reviewerRef.value.collapsed = true; //
}
//
function openDeliverHistory() {
const { deliverId } = deliver.value;
// console.log(deliverId)
uni.navigateTo({ url: `/pages/submitList/submitList?deliverId=${deliverId}` });
}
//
function paste() {
uni.getClipboardData({
success(res) {
linkValue.value = res.data;
},
});
}
//
async function uploadFile() {
try {
const data = await uni.$upload.chooseAndUpload(UPLOAD_URL, {}, UPLOAD_EXTENSION, 'files');
// console.log(data[0]);
linkValue.value = data[0].visitUrl;
} catch (error) {
console.error('error: ', error);
}
}
// TODO:
async function uploadPhoto() {
try {
const data = await uni.$upload.chooseAndUpload(UPLOAD_URL, {}, UPLOAD_EXTENSION, 'files');
// console.log(data[0])
linkValue.value = data[0].visitUrl;
} catch (error) {
console.error('error: ', error);
}
}
//
async function confirmEditDeliverName() {
// TODO: task
if (!newInputRef.value) {
uni.$ui.showToast('输入不能为空');
}
try {
const param = {
projectId: projectId.value,
taskId: props.task.id,
deliverName: newInputRef.value,
};
await uni.$u.api.editDeliverName(param);
// uni.$ui.showToast('');
//
showEditModal.value = false;
showMask.value = false;
showBadge.value = false;
newInputRef.value = '';
} catch (error) {
console.error('error: ', error);
uni.$ui.showToast('修改交付物名称失败');
}
}
//
function deleteDeliver() {
showDeleteModal.value = true;
}
//
async function confirmDelete() {
// TODO:
// TODO:
try {
showDeleteModal.value = true;
deliverRef.value = false;
await uni.$u.api.deleteDeliver();
uni.$ui.showToast('删除交付物成功');
} catch (error) {
console.error('error: ', error);
}
}
getDeliverData();
</script>

6
plugins/p-task-title/p-task-title.vue

@ -1,7 +1,7 @@
<template>
<!-- 任务名插件 -->
<view class="box shadow-lg">
<view class="bg-white rounded-md h-10 leading-10 pl-2">{{ task.name }}</view>
<view class="bg-white rounded-md pl-2">{{ task.name }}</view>
</view>
</template>
@ -10,10 +10,10 @@ defineProps({ task: { type: Object, default: () => {} } });
</script>
<style scoped lang="scss">
.box{
.box {
border-radius: 8px;
background: #fff;
padding: 16px;
overflow: hidden;
}
}
</style>

Loading…
Cancel
Save