This commit is contained in:
许允枞 2025-03-11 14:52:46 +08:00
parent fd1ec60815
commit ecca353d9f

View File

@ -1,21 +1,26 @@
<!-- 发起订单 -->
<template>
<view class="content">
<!-- <view class="c-top">-->
<!-- <view class="" @click="getback()">-->
<!-- <uni-icons type="left" size="18"></uni-icons>-->
<!-- </view>-->
<!-- <view class="c-title">新增文件</view>-->
<!-- <view class=""></view>-->
<!-- </view>-->
<!-- <view class="c-top">-->
<!-- <view class="" @click="getback()">-->
<!-- <uni-icons type="left" size="18"></uni-icons>-->
<!-- </view>-->
<!-- <view class="c-title">新增文件</view>-->
<!-- <view class=""></view>-->
<!-- </view>-->
<headersVue titles="新增文件" style="position: static !important;">
<u-icon name="arrow-left" color="#fff" size="18"></u-icon>
</headersVue>
<view class="dil">
<view class="tinput" v-if="maneizhi=='2'">
<view class="text1"> <text class="hong1">*</text> 文件路径</view>
<view class="you" >
<ss-upload v-if="maneizhi==2" ref="ssUpload" @getFile="getFile" @uploadSuccess="uploadSuccess" :uploadOptions="uploadOptions" :isUploadServer="isUploadServer" :webviewStyle="webviewStyle" :fileInput="fileInput" >
<view class="text1">
<text class="hong1">*</text>
文件路径
</view>
<view class="you">
<ss-upload v-if="maneizhi==2" ref="ssUpload" @getFile="getFile" @uploadSuccess="uploadSuccess"
:uploadOptions="uploadOptions" :isUploadServer="isUploadServer" :webviewStyle="webviewStyle"
:fileInput="fileInput">
<text>附件上传</text>
</ss-upload>
@ -32,25 +37,35 @@
</view>
<!-- #endif -->
<!-- #ifdef APP-PLUS-->
<view style="margin-top:40rpx">{{filesApp}}</view>
<view style="margin-top:40rpx">{{ filesApp }}</view>
<!-- #endif -->
<!-- <view style="margin-top:40rpx;word-break: break-all;" v-if="result">
上传服务器结果{{result}}
</view> -->
</view>
<view class="xinput" >
<view class="text1"> <text class="hong1">*</text> 分类</view>
<view class="xinput">
<view class="text1">
<text class="hong1">*</text>
分类
</view>
<view class="xz">
<view :class="{'xlan':maneizhi == item.id}" class="kuang" v-for="(item,index) in taplist" :key="index" @click="getzhi2(item.id,item.text)">
<view class="">{{item.text}}</view>
<view :class="{'xlan':maneizhi == item.id}" class="kuang" v-for="(item,index) in taplist" :key="index"
@click="getzhi2(item.id,item.text)">
<view class="">{{ item.text }}</view>
</view>
</view>
</view>
<!-- 填空 -->
<view class="tinput">
<view class="text1" v-if="maneizhi=='1'"> <text class="hong1">*</text> 文件夹名称</view>
<view class="text1" v-else> <text class="hong1">*</text> 文件名称</view>
<view class="text1" v-if="maneizhi=='1'">
<text class="hong1">*</text>
文件夹名称
</view>
<view class="text1" v-else>
<text class="hong1">*</text>
文件名称
</view>
<view class="you">
<input type="text" placeholder="请输入名称" v-model="box.fileName">
</view>
@ -59,11 +74,13 @@
<!-- style="height: 0px; overflow: hidden; display: none;" -->
<view class="tinput" v-if="maneizhi=='2'">
<view class="text1"> <text class="hong1">*</text> 提醒时间</view>
<view class="text1">
<text class="hong1">*</text>
提醒时间
</view>
<view class="you" @click="show = true ">
<text>{{time|| ''}}</text>
<text>{{ time || '' }}</text>
</view>
</view>
<u-datetime-picker
@ -85,72 +102,73 @@
</template>
<script>
import request from '../../utils/request'
import config from '@/config'
import { getToken } from '@/utils/auth'
import upload from '@/utils/upload.js'
import headersVue from "@/components/header/headers.vue";
var wvCurrent;
export default{
components: {headersVue},
data(){
return{
time:'请选择提醒时间',
value1:'2023-10-10',
baseUrl:this.$baseUrl,
show:false,
maneizhi:2,
type:'add',
fileId:null,
id:1,
import request from '../../utils/request'
import config from '@/config'
import {getToken} from '@/utils/auth'
import upload from '@/utils/upload.js'
import headersVue from "@/components/header/headers.vue";
taplist:[
{text:'文件夹',id:1},
{text:'文件',id:2},
var wvCurrent;
export default {
components: {headersVue},
data() {
return {
time: '请选择提醒时间',
value1: '2023-10-10',
baseUrl: this.$baseUrl,
show: false,
maneizhi: 2,
type: 'add',
fileId: null,
id: 1,
taplist: [
{text: '文件夹', id: 1},
{text: '文件', id: 2},
],
box:{
type:2,
fatherId:'',
filePath:'',
fileName:'',
warnTime:'',
box: {
type: 2,
fatherId: '',
filePath: '',
fileName: '',
warnTime: '',
},
fileLists: null,
files: [],
filesApp:'',
isUploadServer:true,
uploadOptions:{},
webviewStyle:{
filesApp: '',
isUploadServer: true,
uploadOptions: {},
webviewStyle: {
height: '60px',
width:'130px',
position:'',
background:'transparent',
width: '130px',
position: '',
background: 'transparent',
position: 'absolute',
top:'95px',
right:'20px',
top: '95px',
right: '20px',
},
fileInput:{//apphtmlinput
fileStyle:{
fileInput: {//apphtmlinput
fileStyle: {
borderRadius: '10px',
backgroundColor: '#000000',
color: '#fff',
fontSize: '20px',
},
fileTitle:''
fileTitle: ''
},
fileInputs:{//apphtmlinput
fileStyle:{
fileInputs: {//apphtmlinput
fileStyle: {
borderRadius: '10px',
backgroundColor: '#000000',
color: '#fff',
fontSize: '20px',
},
fileTitle:'上传附件'
fileTitle: '上传附件'
},
result:'',
uploadWaiting: false,
result: '',
uploadWaiting: true,
}
},
@ -159,13 +177,13 @@
this.fileId = option.fileId
this.uploadOptions = {
//
url:this.$baseUrl + '/common/upload', //,
url: this.$baseUrl + '/common/upload', //,
//get,post
type:'post',
type: 'post',
// key
name: 'file',
//
header:{"Authorization": 'Bearer ' + getToken()},
header: {"Authorization": 'Bearer ' + getToken()},
// body
formData: config.formData
}
@ -173,25 +191,25 @@
mounted() {
},
onShow() {
if(this.type == 'edit') this.getDetail();
if (this.type == 'edit') this.getDetail();
},
methods:{
async getDetail(){
methods: {
async getDetail() {
let res = await request({
url: '/inspectionFile/inspectionFile/'+this.fileId,
url: '/inspectionFile/inspectionFile/' + this.fileId,
method: 'get'
})
if(res.code == 200){
if (res.code == 200) {
this.box = res.data
this.maneizhi = this.box.type
this.time = this.box.warnTime
}
},
cancels(){
cancels() {
this.show = false
},
confirms(e){
confirms(e) {
var timestamp = e.value;
var date = new Date(timestamp);
var year = date.getFullYear();
@ -204,64 +222,64 @@
},
//
async getnewsadd(){
if(this.maneizhi =='2'){
if (this.box.fileName==''||this.box.warnTime==''){
async getnewsadd() {
if (this.maneizhi == '2') {
if (this.box.fileName == '' || this.box.warnTime == '') {
uni.showToast({
title:'必填项不能有空!',
icon:'none'
title: '必填项不能有空!',
icon: 'none'
})
return
}
if (!this.uploadWaiting){
if (!this.uploadWaiting) {
uni.showToast({
title:'请等待上传完成!',
icon:'none'
title: '请等待上传完成!',
icon: 'none'
})
return
}
if(this.box.filePath==''){
if (this.box.filePath == '') {
uni.showToast({
title:'必填项不能有空!',
icon:'none'
title: '必填项不能有空!',
icon: 'none'
})
return
}
}else{
if(this.box.fileName==''){
} else {
if (this.box.fileName == '') {
uni.showToast({
title:'必填项不能有空!',
icon:'none'
title: '必填项不能有空!',
icon: 'none'
})
return
}
}
this.uploadWaiting = false
if(this.type == 'add'){
if (this.type == 'add') {
this.box.fatherId = this.fileId
let res = await request({
url: '/inspectionFile/inspectionFile/add',
method: 'post',
data:this.box
data: this.box
})
if(res.code == 200){
if (res.code == 200) {
uni.showToast({
title:'发布成功'
title: '发布成功'
})
setTimeout(() => {
uni.navigateBack();
}, 1000);
}
}
if(this.type == 'edit'){
if (this.type == 'edit') {
let res = await request({
url: '/inspectionFile/inspectionFile/edit',
method: 'post',
data:this.box
data: this.box
})
if(res.code == 200){
if (res.code == 200) {
uni.showToast({
title:'发布成功'
title: '发布成功'
})
setTimeout(() => {
//
@ -273,27 +291,27 @@
},
getback(){
getback() {
uni.navigateBack({
delta:1,
delta: 1,
})
},
getzhi2(id,text){
if(this.type == 'add'){
getzhi2(id, text) {
if (this.type == 'add') {
this.maneizhi = id
this.value =text
this.value = text
this.box.type = id
}
},
uploadFile(){
setTimeout(()=>{
uploadFile() {
setTimeout(() => {
this.$refs.ssUpload.uploadFile()
})
},
//
getFile(result){
getFile(result) {
//#ifdef H5 || MP-WEIXIN
this.files = result.tempFiles
@ -302,42 +320,44 @@
this.filesApp = result
// #endif
},
uploadSuccess(result){
uploadSuccess(result) {
this.result = result
this.box.filePath = result[0].data.url
console.log(result)
console.log(this.box.filePath,'图片路径')
console.log(this.box.filePath, '图片路径')
this.uploadWaiting = true
uni.showToast({
title:'上传完成',
icon:'none'
title: '上传完成',
icon: 'none'
})
}
}
}
}
</script>
<style scoped lang="scss">
.content{
.content {
width: 100%;
height: calc(100vh);
background-color: #F6F6F6;
box-sizing: border-box;
// padding-top: 45px;
}
}
.dil{
.dil {
box-sizing: border-box;
background-color: #F6F6F6;
padding: 0px 12px;
}
.top-icon{
}
.top-icon {
margin-bottom: 45px;
}
.c-top{
}
.c-top {
width: 100%;
box-sizing: border-box;
padding: 15px;
@ -346,31 +366,36 @@
align-items: center;
background-color: white;
padding-top: 40px;
}
.c-title{
}
.c-title {
font-size: 18px;
font-weight: bold
}
.top{
}
.top {
box-sizing: border-box;
padding: 0px 15px;
width: 100%;
background-color: white;
}
.top-box{
}
.top-box {
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
padding: 20px 0px;
}
.tb-left{
}
.tb-left {
height: 100%;
width: 80%;
display: flex;
align-items: center;
}
.uicon{
}
.uicon {
width: 18px;
height: 18px;
border-radius: 4px;
@ -383,34 +408,39 @@
font-weight: bold;
margin-right: 6px;
}
.tb-right{
}
.tb-right {
width: 20px;
height: 26px;
image{
image {
width: 100%;
height: 100%;
}
}
.text1{
}
.text1 {
font-size: 16px;
font-weight: bold;
color: #363636;
}
.hong1{
}
.hong1 {
margin-top: 5px;
font-size: 12px;
font-weight: 400;
color: #FF5453;
}
.hong2{
}
.hong2 {
margin-top: 5px;
font-size: 12px;
font-weight: 400;
}
.tinput{
}
.tinput {
width: 100%;
display: flex;
background: white;
@ -420,25 +450,29 @@
padding: 16px;
margin-top: 14px;
margin-bottom: 14px;
}
.xinput{
}
.xinput {
width: 100%;
background: white;
box-sizing: border-box;
padding: 16px;
margin-top: 14px;
}
.you{
}
.you {
text-align: right;
}
.xz{
}
.xz {
margin-top: 10px;
display: flex;
align-items: center;
}
.kuang{
}
.kuang {
width: 80px;
height: 23px;
background: #ECECEC;
@ -449,16 +483,18 @@
color: #666666;
font-size: 14px;
margin-right: 15px;
}
.xlan{
}
.xlan {
background: #CDE7FF !important;
color: #1D62FF !important;
border: 1px solid #2A96FE;
}
.anniu{
}
.anniu {
width: 100%;
background: linear-gradient(180deg, #327DFB 0%, #327DFB 100%);
border-radius: 50px ;
border-radius: 50px;
height: 40px;
display: flex;
justify-content: center;
@ -467,10 +503,10 @@
margin-top: 20px;
color: white;
}
}
button::after {
button::after {
border: none;
}
}
</style>