diff --git a/src/renderer/components/workAdd/workAdd.vue b/src/renderer/components/workAdd/workAdd.vue index bade81e..f0f68fe 100644 --- a/src/renderer/components/workAdd/workAdd.vue +++ b/src/renderer/components/workAdd/workAdd.vue @@ -145,9 +145,9 @@
-
+
标签
@@ -269,7 +269,6 @@ export default { ass_task: [], task_freq: 1, archive_path: '', - finished_check: false }, testForm: { req_name: 'submit_task', @@ -594,6 +593,8 @@ export default { // 提交 workSubmit() { 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 files = this.$refs.files.getLists() let fileList = [] @@ -619,157 +620,172 @@ export default { }) return } - if (this.setForm.isArrow) { - let overList = [] - for (let i = 0; i < fileList.length; i++) { - if (fileList[i].size > diskSize) { - overList.push(fileList[i].name) + if (that.form.copy_type == 3) { + that.$alert('请将光盘装入打开的驱动器,然后手动关闭托盘后点击确定', '温馨提示', { + confirmButtonText: '确定', + showCancelButton: true, + 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(',') - this.$notify({ - message: `文件${fileNames} 大小超过磁盘容量${this.$filterSize(diskSize)},请重新选择文件!`, - type: 'warning' - }) - return - } - 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 - }) - } else if (this.setForm.disk === 3) { - // 按文件大小排序 - fileList.sort((a, b) => a.size - b.size) - } else { - // 按最后修改时间排序 - fileList.sort((a, b) => a.mtime - b.mtime) - } - let index = 1 - let total_size = 0 - 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} 大小超过设备容量,请重新选择文件!`, + }); + } + if (that.form.copy_type == 4) { + that.$alert('请将需要读取的光盘放入右盘仓,然后点击确定', '温馨提示', { + confirmButtonText: '确定', + showCancelButton: true, + callback: (rel) => { + if (rel === 'confirm') { + submit() + } + } + }); + } + function submit() { + if (that.setForm.isArrow) { + let overList = [] + for (let i = 0; i < fileList.length; i++) { + if (fileList[i].size > diskSize) { + overList.push(fileList[i].name) + } + } + if (overList.length) { + const fileNames = overList.join(',') + that.$notify({ + message: `文件${fileNames} 大小超过磁盘容量${that.$filterSize(diskSize)},请重新选择文件!`, 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: [] - } + if (that.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 + }) + } 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 - task.path_file.push(fileList[i].path) - task.task_size += fileList[i].size - if (i === fileList.length - 1) that.form.ass_task.push(task) + let index = 1 + let total_size = 0 + let 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 { - 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) { - this.$notify({ - message: `文件大小超过设备容量!`, + if (that.form.copy_type == 4 && !that.form.archive_path) { + that.$notify({ + message: `请输入光盘数据恢复路径!`, type: 'warning' }) return } - that.form.ass_task.push(task) - } - if (that.form.copy_type == 4 && !that.form.archive_path) { - this.$notify({ - message: `请输入光盘数据恢复路径!`, - type: 'warning' - }) - return - } - that.form.burn_speed = that.setForm.speed - that.form.is_finished_check = that.setForm.isCheck - that.form.is_finished_close = that.setForm.isClose - that.form.is_finished_delete = that.setForm.isDel - 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' + that.form.burn_speed = that.setForm.speed + that.form.is_finished_check = that.setForm.isCheck + that.form.is_finished_close = that.setForm.isClose + that.form.is_finished_delete = that.setForm.isDel + 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' + }) + that.submitLoading = false + that.close() + }, 1500) + }).catch(() => { 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() { + let that = this const filePath = path.join(exePath, 'User Templates'); fs.readdir(filePath, (err, files) => { if (err) { @@ -782,7 +798,7 @@ export default { value: path.join('User Templates', file) } }) - this.templates = fileList + that.templates = fileList } }) },