优化调整

This commit is contained in:
24kycj
2024-11-14 13:25:03 +08:00
parent ca9448b60f
commit 5e0c2dfc1a
5 changed files with 289 additions and 146 deletions
+76 -93
View File
@@ -134,12 +134,11 @@
<div class="work_files">
<div class="work_files_box">
<!-- 文件列表 -->
<files ref="files" :onSizechange="sizeChange" :complete="upload_over" />
<files ref="files" :onSizechange="sizeChange" :complete="upload_over"></files>
</div>
<div class="work_files_progress">
<el-progress :text-inside="true" :percentage="file_percent" :format="format" :color="customColors"></el-progress>
</div>
<!-- <div class="work_files_progress">
<div class="work_files_progress_content" :style="{ width: fileProgess + '%' }"></div>
<div class="work_files_progress_text">0.0MB/0MB</div>
</div> -->
</div>
</div>
<div class="work_right">
@@ -165,16 +164,11 @@
<div class="wook_soon_label">{{ item.name }}</div>
<div class="wook_soon_input">
<div v-if="scope.row.type == 1">
<input
type="file"
accept="image/*"
:ref="item.name"
:data-name="item.name" />
<input type="file" accept="image/*" :ref="item.name" :data-name="item.name" />
</div>
<div v-if="scope.row.type == 3 || scope.row.type == 4 || scope.row.type == 5">
<el-input clearable :disabled="csvIsExist" v-model="item.val" placeholder="请输入"></el-input>
</div>
</div>
<div @click="openFile2" v-if="item.type == 3 || item.type == 4 || item.type == 5" class="wook_soon_add">添加字段</div>
</div>
@@ -192,8 +186,8 @@
</div>
</div>
<div class="flex_box footer_btns">
<el-button type="primary" class="footer_save" @click="workSubmit">保存</el-button>
<el-button type="primary" class="footer_submit" @click="workSubmit">提交</el-button>
<el-button type="primary" class="footer_save" @click="workSave" :loading="saveFlag">保存</el-button>
<el-button type="primary" class="footer_submit" @click="workSubmit" :loading="submitFlag">提交</el-button>
</div>
</div>
</div>
@@ -223,6 +217,8 @@ export default {
return {
addShow: false,
submitLoading: false,
saveFlag: false,
submitFlag: false,
size_form: null,
type_form: 0,
file_form: 0,
@@ -273,43 +269,8 @@ export default {
}
},
// CD类型:CD 700MB1DVD 4.7GB2 DVD_DL 8.5GB:3BD 25GB4,BD_DL 50GB:5,BD_TL 100GB:6,BD_QL 128GB:7
cd_types: [
{
value: 1,
label: 'CD 700MB',
size: 700*1024*1024
},
{
value: 2,
label: 'DVD 4.7GB',
size: 4.7*1024*1024*1024
},
{
value: 3,
label: 'DVD_DL 8.5GB',
size: 8.5*1024*1024*1024
},
{
value: 4,
label: 'BD 25GB',
size: 25*1024*1024*1024
},
{
value: 5,
label: 'BD_DL 50GB',
size: 50*1024*1024*1024
},
{
value: 6,
label: 'BD_TL 100GB',
size: 100*1024*1024*1024
},
{
value: 7,
label: 'BD_QL 128GB',
size: 128*1024*1024*1024
}
],
CDTypes: [],
cd_types: [],
copyList: [],
fileProgess: 30,
// 模板列表
@@ -326,6 +287,11 @@ export default {
soonImg: '',
showList: true,
csvIsExist: false,
totalSize: 0,
customColors: [
{ color: '#67C23A', percentage: 99 },
{ color: '#F56C6C', percentage: 100 }
],
// 高级设置
setShow: false,
setForm: {},
@@ -393,14 +359,34 @@ export default {
watch: {
'$store.state.user.setForm': {
handler(val) {
this.setForm = val
this.setForm = { ...val }
},
deep: true,
immediate: true
},
'$store.state.chat.CDTypes': {
handler(val) {
this.CDTypes = { ...val }
},
deep: true,
immediate: true
},
'$store.state.chat.cd_types': {
handler(val) {
this.cd_types = [...val]
},
deep: true,
immediate: true
}
},
computed: {
...mapGetters(['name', 'roles'])
...mapGetters(['name', 'roles']),
file_percent() {
const diskSize = this.cd_types.find((item) => item.value === this.form.cd_type).size
console.log(diskSize)
let t = diskSize ? this.$accDiv(this.totalSize, diskSize)*100 : 0
return t > 100 ? 100.1 : t
},
},
mounted() {
this.getTemplates()
@@ -408,6 +394,12 @@ export default {
this.form.label = dayjs().format('YYYY-MM-DD')
},
methods: {
// 进度条处理
format(percentage) {
const diskSize = this.cd_types.find((item) => item.value === this.form.cd_type).size
let t = diskSize ? `${this.$filterSize(this.totalSize)}/${this.$filterSize(diskSize)}` : ''
return t
},
// 添加文件处理
addFolder() {
this.$refs.files.addFolder()
@@ -416,8 +408,7 @@ export default {
this.$refs.files.addFile()
},
sizeChange(size) {
console.log(size)
this.size = size
this.totalSize = size
},
async upload_over() {
// //左侧内容上传结束
@@ -539,24 +530,31 @@ export default {
},
// 保存
workSave() {
that.saveFlag = true
setTimeout(() => {
that.saveFlag = false
}, 1000);
},
// 提交
workSubmit() {
let that = this
const files = this.$refs.files.getLists()
let fileList = []
that.submitFlag = true
setTimeout(() => {
that.submitFlag = false
}, 1000);
for (let key in files) {
let file = {...files[key]}
let file = { ...files[key] }
try {
const fileStats = fs.statSync(files[key].path);
const fileStats = fs.statSync(files[key].path)
file.mtime = fileStats.mtimeMs
fileList.push(file)
} catch (error) {
console.error('Error reading file:', error);
console.error('Error reading file:', error)
}
}
if (that.form.json_file === ''&& fileList.length === 0) {
if (that.form.json_file === '' && fileList.length === 0) {
this.$message({
message: '请上传作业文件',
type: 'warning'
@@ -564,7 +562,7 @@ export default {
return
}
if (this.setForm.isArrow) {
const diskSize = this.cd_types.find(item => item.value === this.form.cd_type).size
const diskSize = this.cd_types.find((item) => item.value === this.form.cd_type).size
let overList = []
for (let i = 0; i < fileList.length; i++) {
if (fileList[i].size > diskSize) {
@@ -582,16 +580,16 @@ export default {
if (this.setForm.disk === 2) {
// 按文件名排序
fileList.sort((a, b) => {
if (a.name.toLowerCase() < b.name.toLowerCase()) return -1;
if (a.name.toLowerCase() > b.name.toLowerCase()) return 1;
return 0;
});
if (a.name.toLowerCase() < b.name.toLowerCase()) return -1
if (a.name.toLowerCase() > b.name.toLowerCase()) return 1
return 0
})
} else if (this.setForm.disk === 3) {
// 按最后修改时间排序
fileList.sort((a, b) => a.mtime - b.mtime);
fileList.sort((a, b) => a.mtime - b.mtime)
} else {
// 按文件大小排序
fileList.sort((a, b) => a.size - b.size);
fileList.sort((a, b) => a.size - b.size)
}
let index = 1
let total_size = 0
@@ -668,14 +666,14 @@ export default {
// 选择模板
changeTemplate(e) {
let that = this
const absolutePath = path.resolve(e);
const absolutePath = path.resolve(e)
fs.realpath(absolutePath, (err, fullPath) => {
if (err) {
console.error(err);
return;
console.error(err)
return
}
that.form.json_file = fullPath
});
})
fs.readFile(e, 'utf8', (err, data) => {
if (err) {
console.error('读取文件时出错:', err)
@@ -823,7 +821,7 @@ export default {
},
setSure() {
this.setShow = false
this.$store.commit('setData', {name: 'setForm', data: this.setForm})
this.$store.commit('setData', { name: 'setForm', data: this.setForm })
}
}
}
@@ -984,29 +982,14 @@ export default {
overflow-y: scroll;
}
.work_files_progress {
height: 22px;
padding: 2px 0;
position: relative;
border-radius: 12px;
background-color: #ffe6e6;
.work_files_progress_content {
transition: all 0.5s;
width: 0;
height: 18px;
background: #e54d4d;
border-radius: 10px;
}
.work_files_progress_text {
font-weight: 500;
font-size: 10px;
color: #ffffff;
line-height: 22px;
padding-left: 16px;
position: absolute;
left: 0;
top: 0;
z-index: 8;
::v-deep {
.el-progress-bar__outer {
height: 24px!important;
font-size: 12px;
color: #000;
}
}
}
}
}