123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522 |
- <template>
- <view class="container">
- <page-title>周报录入</page-title>
- <view class="cards-list">
- <view class="card only-card">
-
- <view class="card-item first-card-item">
- <view class="card-item-name">项目名称</view>
- <view class="card-item-input">{{pageForm.subName || "--"}}</view>
- </view>
-
- <view class="card-item">
- <view class="card-item-name">主体单位</view>
- <view class="card-item-input">{{pageForm.UnitName || "--"}}</view>
- </view>
-
- <view class="card-item">
- <view class="card-item-name">录入周期</view>
- <view class="card-item-input">{{editTime || "--"}}</view>
- </view>
-
-
- {{pageForm.subPlanId}}
-
-
-
- <view class="card-item">
- <view class="card-item-name">项目进展情况<span class="must-input">*</span></view>
- </view>
- <view class="card-item">
- <u--textarea class="card-item-textarea" v-model="pageForm.content" :disabled="banSubmit"></u--textarea>
- </view>
-
- <view class="card-item">
- <view class="card-item-name">项目延期原因</view>
- </view>
- <view class="card-item">
- <u--textarea class="card-item-textarea" v-model="pageForm.reason" :disabled="banSubmit"></u--textarea>
- </view>
-
- <view class="card-item">
- <view class="card-item-name">进度<span class="must-input">*</span></view>
- <view class="card-item-name flex">
- <input type="number" v-model="pageForm.numBl" class="card-item-input" placeholder="填写进度"
- placeholder-style="color: #D8D8D8" maxlength="20" :disabled="banSubmit" />
- <view class="card-item-unit">%</view>
- </view>
- </view>
-
- <view class="card-item flex-align-start">
- <view class="card-item-name" style="min-width: 156rpx;">图片附件</view>
- <u-upload :fileList="uploadListPhoto" @afterRead="afterReadPhoto" @delete="delFilePhoto"
- uploadIcon="plus"></u-upload>
- </view>
-
- <view class="card-item flex-align-start">
- <view class="card-item-name" style="min-width: 156rpx;">视频附件</view>
- <u-upload :fileList="uploadListVideo" @afterRead="afterReadVideo" @delete="delFileVideo"
- @onVideoClick="videoClick" name="file" uploadIcon="plus" accept="video"></u-upload>
- </view>
-
- <view class="card-item flex-align-start">
- <view class="card-item-name" style="min-width: 156rpx;">其他附件</view>
- <view class="upload-file-area">
- <view class="upload-file-name" v-for="(item,index) in uploadListFile" :key="index"
- @click="showFile('pdf',item.url)">
- {{item.fileName}}
- </view>
- </view>
- </view>
- </view>
- <view class="confirm-btn" :class="banSubmit?'ban-submit':''" @click="confirmParams()">确定</view>
- </view>
-
- <u-picker :show="subPlanShow" :columns="subPlanList" @confirm="subPlanClose" @cancel="subPlanClose"
- @close="subPlanClose" closeOnClickOverlay></u-picker>
- </view>
- </template>
- <script setup>
- import config from '@/config.js'
- import {
- ref
- } from 'vue'
- import {
- onLoad
- } from "@dcloudio/uni-app"
- import {
- uploadFilePromise
- } from "@/utils/request_new.js"
- import {
- getWeeklyById,
- saveWeekly
- } from "@/api/work/weeklyAndMonthly.js"
- let editTime = ref(null)
- let pageForm = ref({
- year: null,
- beginDate: null,
- endDate: null,
- subId: null,
- subName: null,
- UnitName: null,
- subPlanId: null,
- content: null,
- reason: null,
- numBl: null,
- listFile: [],
- })
- let fileTypeCode = {
- 0: "dir",
- 1: "txt",
- 2: "doc",
- 3: "docx",
- 4: "xls",
- 5: "xlsx",
- 6: "ppt",
- 7: "pptx",
- 8: "pdf",
- 9: "swf",
- 101: "jpg",
- 102: "image",
- 103: "jpeg",
- 104: "bmp",
- 105: "gif",
- 201: "avi",
- 202: "wmv",
- 202: "flv",
- 203: "video"
- }
-
- let subPlanShow = ref(false)
- let subPlanList = ref([])
- let subPlanContentList = ref([])
- function subPlanOpen() {
- subPlanShow.value = true
- }
- function subPlanClose(e) {
- if (e) {
- pageForm.value.subPlanId = e.value[0]
- pageForm.value.content = subPlanContentList.value.find(item => item.time === e.value[0]).content
- }
- subPlanShow.value = false
- }
- function parseDate(date, year) {
- pageForm.value.year = year;
- const index = date.indexOf("至")
- pageForm.value.beginDate = date.substring(0, index)
- pageForm.value.endDate = date.substring(index + 1)
- }
-
- function getWeeklyDetail(sendParams) {
- let params = {
- subId: sendParams.subId,
- startDate: sendParams.startDate,
- year: sendParams.year
- }
- getWeeklyById(params).then(res => {
- pageForm.value.subName = res.data.subName;
- pageForm.value.UnitName = res.data.UnitName;
- pageForm.value.subId = res.data.subId;
- pageForm.value.numBl = res.data.weekInfo.numBl;
- pageForm.value.content = res.data.weekInfo.content;
- pageForm.value.reason = res.data.weekInfo.reason;
-
-
- conbineFileList(res.data.listFile)
- })
- }
- function combinePlanList(list) {
- let subPlanListItem = []
- let subPlanContentListTemp = []
- for (let i in list) {
- let showName = `${list[i].beginDate}至${list[i].endDate}`;
- let content = list[i].content;
- let id = list[i].id;
- subPlanListItem.push(showName)
- subPlanContentListTemp.push({
- id,
- content,
- time: showName,
- })
- }
- subPlanList.value.push(subPlanListItem)
- subPlanContentList.value = subPlanContentListTemp
- }
-
- function showHavingData(data) {
-
- if (data.sub_plan_id) {
- let statuItem = subPlanContentList.value.find(item => item.id === data.sub_plan_id)
- if (statuItem) {
- pageForm.value.content = statuItem.content;
- pageForm.value.subPlanId = statuItem.time
- }
- }
- }
-
- function conbineFileList(list) {
-
- const statusList = list.map(item => {
- let orginal = {
- ...item
- }
- return Object.assign(
- orginal, {
- status: 'success'
- })
- })
-
- let listPhoto = statusList.filter(item => ['101', '102', '103', '104', '105'].includes(item.fileType))
- uploadListPhoto.value = listPhoto
-
- let listVideo = statusList.filter(item => ['202', '203'].includes(item.fileType));
- uploadListVideo.value = listVideo;
-
- let exceptPhotoList = statusList.filter(item => !listPhoto.includes(item));
- uploadListFile.value = exceptPhotoList.filter(item => !listVideo.includes(item));
-
- const dataList = list.map(item => {
- let orginal = {
- ...item
- }
- return {
- id: orginal.id,
- fileName: orginal.fileName,
- fileType: orginal.fileType,
- fileAddre: orginal.fileAddre
- }
- })
- pageForm.value.listFile = dataList
-
- listFileOrginal = dataList
- }
-
- let listFileOrginal = []
- let uploadListPhoto = ref([])
- let uploadListVideo = ref([])
- let uploadListFile = ref([])
-
- async function afterReadPhoto(event) {
- if (banSubmit.value) return
- let lists = [].concat(event.file);
- let fileListLen = uploadListPhoto.value.length;
- lists.map((item) => {
- uploadListPhoto.value.push({
- ...item,
- status: 'uploading',
- message: '上传中'
- })
- })
- for (let i = 0; i < lists.length; i++) {
- const resultObj = await uploadFilePromise(lists[i].url);
-
- let fileItem = {
- fileName: resultObj.data.resultList[0].name,
- fileType: resultObj.data.resultList[0].ftype,
- fileAddre: resultObj.data.resultList[0].id
- }
- pageForm.value.listFile.push(fileItem)
-
- const serverAddress = uni.getStorageSync("serverAddress");
- const baseUrlIp = serverAddress ? serverAddress : config.baseUrl;
- const preViewUrl = baseUrlIp + "/projects//static/file/";
-
-
- let item = uploadListPhoto.value[fileListLen]
-
- let type = fileTypeCode[resultObj.data.resultList[0].ftype]
- uploadListPhoto.value.splice(fileListLen, 1, Object.assign(item, {
- status: 'success',
- message: '',
- url: preViewUrl + resultObj.data.resultList[0].id + "/showfile",
- id: resultObj.data.resultList[0].id,
- preView: preViewUrl + resultObj.data.resultList[0].id + "/showfile",
-
- }))
- fileListLen++
- }
- }
-
- function delFilePhoto(event) {
- if (banSubmit.value) return
-
- uploadListPhoto.value.splice(event.index, 1);
-
- let delFileIndex = pageForm.value.listFile.findIndex(item => item.fileAddre === event.file.fileAddre || item
- .fileAddre ===
- event.file.id);
- let delFile = pageForm.value.listFile[delFileIndex];
-
- if (delFile && delFile.id) {
-
- delFile.logicDeleteFlag = 1
- } else {
- pageForm.value.listFile.splice(delFileIndex, 1)
- }
- }
- function waterMarkShow(event) {
- return uni.navigateTo({
- url: `/pages/weekly/media/index?url=${event.url}&time=${event.createTime}`
- })
- }
-
- async function afterReadVideo(event) {
- if (banSubmit.value) return
- let lists = [].concat(event.file);
- let fileListLen = uploadListVideo.value.length;
- lists.map((item) => {
- uploadListVideo.value.push({
- ...item,
- status: 'uploading',
- message: '上传中'
- })
- })
- for (let i = 0; i < lists.length; i++) {
- const resultObj = await uploadFilePromise(lists[i].url);
- let fileItem = {
- fileName: resultObj.data.resultList[0].name,
- fileType: resultObj.data.resultList[0].ftype,
- fileAddre: resultObj.data.resultList[0].id
- }
- pageForm.value.listFile.push(fileItem)
-
- const serverAddress = uni.getStorageSync("serverAddress");
- const baseUrlIp = serverAddress ? serverAddress : config.baseUrl;
- const preViewUrl = baseUrlIp + "/projects//static/file/";
-
-
- let item = uploadListVideo.value[fileListLen]
-
- let type = fileTypeCode[resultObj.data.resultList[0].ftype]
- uploadListVideo.value.splice(fileListLen, 1, Object.assign(item, {
- status: 'success',
- message: '',
- url: preViewUrl + resultObj.data.resultList[0].id + "/showfile",
- id: resultObj.data.resultList[0].id,
- preView: preViewUrl + resultObj.data.resultList[0].id + "/showfile",
-
- }))
- fileListLen++
- }
- }
-
- function delFileVideo(event) {
- if (banSubmit.value) return
- uploadListVideo.value.splice(event.index, 1);
-
- let delFileIndex = pageForm.value.listFile.findIndex(item => item.fileAddre === event.file.fileAddre || item
- .fileAddre ===
- event.file.id);
- let delFile = pageForm.value.listFile[delFileIndex];
-
- if (delFile && delFile.id) {
-
- delFile.logicDeleteFlag = 1
- } else {
- pageForm.value.listFile.splice(delFileIndex, 1)
- }
- }
-
- function videoClick(event) {
- showFile(event.fileType, event.url)
- }
-
- function showFile(type, filePath) {
- uni.navigateTo({
- url: `/pages/projectInfo/media/index?type=${type}&filePath=${filePath}`
- })
- }
-
- let banSubmit = ref(false);
- let isSubmit = ref(false);
-
- function confirmParams() {
-
- if (banSubmit.value || isSubmit.value) return;
-
- if (((pageForm.value.content ?? '') === '') || ((pageForm.value.numBl ?? '') === '')) {
- return uni.showModal({
- title: '请检查',
- content: '进度与项目进展情况为必填项。',
- showCancel: false
- })
- }
-
- uni.showModal({
- title: "保存确认",
- content: "确定要保存该周报录入吗?",
- success: function(res) {
- if (res.confirm) {
- let params = Object.assign({}, pageForm.value)
- delete(params.UnitName)
- delete(params.subName)
- let subPlanIdItem = subPlanContentList.value.find(item => item.time === params.subPlanId)
- params.subPlanId = subPlanIdItem ? subPlanIdItem.id : null
- isSubmit.value = true;
- saveWeekly(params).then(res => {
- if (res.code === 200) {
- isSubmit.value = false;
- banSubmit.value = true;
- uni.showToast({
- title: "保存成功",
- icon: "success",
- duration: 2000
- })
- }
- }).catch(() => {
- isSubmit.value = false;
- uni.showToast({
- title: "保存失败",
- icon: "error",
- duration: 2000
- })
- })
- } else if (res.cancel) {
- uni.showToast({
- title: "取消保存",
- icon: "none",
- duration: 2000,
- })
- }
- },
- })
- }
- onLoad((options) => {
- editTime.value = options.kj_month
- parseDate(options.kj_month, options.year)
- getWeeklyDetail(options)
- })
- </script>
- <style lang="scss" scoped>
- .must-input {
- color: #f00;
- }
- </style>
|