优化提交任务

This commit is contained in:
24kycj
2025-02-12 15:05:29 +08:00
parent 992cc81fc8
commit 3dc39b86e6
+155 -139
View File
@@ -145,9 +145,9 @@
</div> </div>
</div> </div>
<div class="work_right"> <div class="work_right">
<div v-if="form.copy_type == 3" class="flex_box flex_row_center work_no"> <!-- <div v-if="form.copy_type == 3" class="flex_box flex_row_center work_no">
<img src="@/assets/images/ElBanCircle.png" /> <img src="@/assets/images/ElBanCircle.png" />
</div> </div> -->
<div class="flex_box work_right_top"> <div class="flex_box work_right_top">
<div class="flex_box"> <div class="flex_box">
<div class="work_right_top_label">标签</div> <div class="work_right_top_label">标签</div>
@@ -269,7 +269,6 @@ export default {
ass_task: [], ass_task: [],
task_freq: 1, task_freq: 1,
archive_path: '', archive_path: '',
finished_check: false
}, },
testForm: { testForm: {
req_name: 'submit_task', req_name: 'submit_task',
@@ -594,6 +593,8 @@ export default {
// 提交 // 提交
workSubmit() { workSubmit() {
let that = this let that = this
that.form.ass_task = []
that.form.has_copy_task = false
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
const files = this.$refs.files.getLists() const files = this.$refs.files.getLists()
let fileList = [] let fileList = []
@@ -619,157 +620,172 @@ export default {
}) })
return return
} }
if (this.setForm.isArrow) { if (that.form.copy_type == 3) {
let overList = [] that.$alert('请将光盘装入打开的驱动器,然后手动关闭托盘后点击确定', '温馨提示', {
for (let i = 0; i < fileList.length; i++) { confirmButtonText: '确定',
if (fileList[i].size > diskSize) { showCancelButton: true,
overList.push(fileList[i].name) callback: (rel) => {
if (rel === 'confirm') {
that.form.ass_task = [
{
ass_task_index: 1
}
]
that.form.has_copy_task = true
submit()
}
} }
} });
if (overList.length) { }
const fileNames = overList.join(',') if (that.form.copy_type == 4) {
this.$notify({ that.$alert('请将需要读取的光盘放入右盘仓,然后点击确定', '温馨提示', {
message: `文件${fileNames} 大小超过磁盘容量${this.$filterSize(diskSize)},请重新选择文件!`, confirmButtonText: '确定',
type: 'warning' showCancelButton: true,
}) callback: (rel) => {
return if (rel === 'confirm') {
} submit()
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 function submit() {
return 0 if (that.setForm.isArrow) {
}) let overList = []
} else if (this.setForm.disk === 3) { for (let i = 0; i < fileList.length; i++) {
// 按文件大小排序 if (fileList[i].size > diskSize) {
fileList.sort((a, b) => a.size - b.size) overList.push(fileList[i].name)
} else { }
// 按最后修改时间排序 }
fileList.sort((a, b) => a.mtime - b.mtime) if (overList.length) {
} const fileNames = overList.join(',')
let index = 1 that.$notify({
let total_size = 0 message: `文件${fileNames} 大小超过磁盘容量${that.$filterSize(diskSize)},请重新选择文件!`,
let task = {
ass_task_index: index,
task_size: 0,
path_file: []
}
for (let i = 0; i < fileList.length; i++) {
if (fileList[i].size > diskSize) {
this.$notify({
message: `文件${fileList[i].name} 大小超过设备容量,请重新选择文件!`,
type: 'warning' type: 'warning'
}) })
return return
} }
if (total_size + fileList[i].size > diskSize) { if (that.setForm.disk === 2) {
that.form.ass_task.push(task) // 按文件名排序
total_size = 0 fileList.sort((a, b) => {
index++ if (a.name.toLowerCase() < b.name.toLowerCase()) return -1
task = { if (a.name.toLowerCase() > b.name.toLowerCase()) return 1
ass_task_index: index, return 0
task_size: 0, })
path_file: [] } else if (that.setForm.disk === 3) {
} // 按文件大小排序
fileList.sort((a, b) => a.size - b.size)
} else {
// 按最后修改时间排序
fileList.sort((a, b) => a.mtime - b.mtime)
} }
total_size += fileList[i].size let index = 1
task.path_file.push(fileList[i].path) let total_size = 0
task.task_size += fileList[i].size let task = {
if (i === fileList.length - 1) that.form.ass_task.push(task) ass_task_index: index,
task_size: 0,
path_file: []
}
for (let i = 0; i < fileList.length; i++) {
if (fileList[i].size > diskSize) {
that.$notify({
message: `文件${fileList[i].name} 大小超过设备容量,请重新选择文件!`,
type: 'warning'
})
return
}
if (total_size + fileList[i].size > diskSize) {
that.form.ass_task.push(task)
total_size = 0
index++
task = {
ass_task_index: index,
task_size: 0,
path_file: []
}
}
total_size += fileList[i].size
task.path_file.push(fileList[i].path)
task.task_size += fileList[i].size
if (i === fileList.length - 1) that.form.ass_task.push(task)
}
} else {
let task = {
ass_task_index: 1,
task_size: 0,
path_file: []
}
for (let i = 0; i < fileList.length; i++) {
task.path_file.push(fileList[i].path)
task.task_size += fileList[i].size
}
if (task.task_size > diskSize) {
that.$notify({
message: `文件大小超过设备容量!`,
type: 'warning'
})
return
}
that.form.ass_task.push(task)
} }
} else { if (that.form.copy_type == 4 && !that.form.archive_path) {
let task = { that.$notify({
ass_task_index: 1, message: `请输入光盘数据恢复路径!`,
task_size: 0,
path_file: []
}
for (let i = 0; i < fileList.length; i++) {
task.path_file.push(fileList[i].path)
task.task_size += fileList[i].size
}
if (task.task_size > diskSize) {
this.$notify({
message: `文件大小超过设备容量!`,
type: 'warning' type: 'warning'
}) })
return return
} }
that.form.ass_task.push(task) that.form.burn_speed = that.setForm.speed
} that.form.is_finished_check = that.setForm.isCheck
if (that.form.copy_type == 4 && !that.form.archive_path) { that.form.is_finished_close = that.setForm.isClose
this.$notify({ that.form.is_finished_delete = that.setForm.isDel
message: `请输入光盘数据恢复路径!`, that.form.is_printer_labal_failed = that.setForm.isPrint
type: 'warning' // csv文件处理
}) if (!that.form.udf_file && that.soonList.length > 0) {
return that.soonList.forEach((item) => {
} if (item.type == 1&&that.$refs[item.origin_name][0].files[0]) {
that.form.burn_speed = that.setForm.speed item.val = that.$refs[item.origin_name][0].files[0].path
that.form.is_finished_check = that.setForm.isCheck }
that.form.is_finished_close = that.setForm.isClose if (!item.val) {
that.form.is_finished_delete = that.setForm.isDel item.val = item.default || ''
that.form.is_printer_labal_failed = that.setForm.isPrint }
// csv文件处理
if (!that.form.udf_file && that.soonList.length > 0) {
that.soonList.forEach((item) => {
if (item.type == 1&&that.$refs[item.origin_name][0].files[0]) {
item.val = that.$refs[item.origin_name][0].files[0].path
}
if (!item.val) {
item.val = item.default || ''
}
})
let csv1 = that.soonList.map(item => item.origin_name).join(',')
let csv2 = that.soonList.map(item => item.val).join(',')
that.csvForm.req_info.file_text = csv1 + '\n' + csv2
that.$store.dispatch('chat/websocketsend', that.csvForm).then(() => {
}).catch(() => {
})
}
that.submitLoading = true
if (that.form.json_file) that.form.has_print_task = true
if (fileList.length) that.form.has_copy_task = true
let theForm = { ...that.form }
if (!theForm.udf_file) delete theForm.udf_file
that.testForm.req_info = theForm
// 保存默认设置
localStorage.setItem('workForm', JSON.stringify({
cd_type: that.form.cd_type,
copy_type: that.form.copy_type
}))
that.$store.dispatch('chat/websocketsend', that.testForm).then(() => {
setTimeout(() => {
that.$notify({
message: '新建作业成功',
type: 'success'
}) })
let csv1 = that.soonList.map(item => item.origin_name).join(',')
let csv2 = that.soonList.map(item => item.val).join(',')
that.csvForm.req_info.file_text = csv1 + '\n' + csv2
that.$store.dispatch('chat/websocketsend', that.csvForm).then(() => {
}).catch(() => {
})
}
that.submitLoading = true
if (that.form.json_file) that.form.has_print_task = true
if (fileList.length) that.form.has_copy_task = true
let theForm = { ...that.form }
if (!theForm.udf_file) delete theForm.udf_file
that.testForm.req_info = theForm
// 保存默认设置
localStorage.setItem('workForm', JSON.stringify({
cd_type: that.form.cd_type,
copy_type: that.form.copy_type
}))
that.$store.dispatch('chat/websocketsend', that.testForm).then(() => {
setTimeout(() => {
that.$notify({
message: '新建作业成功',
type: 'success'
})
that.submitLoading = false
that.close()
}, 1500)
}).catch(() => {
that.submitLoading = false that.submitLoading = false
that.close() })
if (that.form.copy_type == 3) { }
that.$alert('请将光盘装入打开的驱动器,然后手动关闭托盘后点击确定', '温馨提示', {
confirmButtonText: '确定',
callback: () => {
}
});
}
if (that.form.copy_type == 4) {
that.$alert('请将需要读取的光盘放入右盘仓,然后点击确定', '温馨提示', {
confirmButtonText: '确定',
callback: () => {
}
});
}
}, 1500)
}).catch(() => {
that.submitLoading = false
})
}, },
// 获取模板文件列表 // 获取模板文件列表
getTemplates() { getTemplates() {
let that = this
const filePath = path.join(exePath, 'User Templates'); const filePath = path.join(exePath, 'User Templates');
fs.readdir(filePath, (err, files) => { fs.readdir(filePath, (err, files) => {
if (err) { if (err) {
@@ -782,7 +798,7 @@ export default {
value: path.join('User Templates', file) value: path.join('User Templates', file)
} }
}) })
this.templates = fileList that.templates = fileList
} }
}) })
}, },