diff --git a/src/renderer/App.vue b/src/renderer/App.vue index d554583..8f737c6 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -5,53 +5,56 @@ diff --git a/src/renderer/components/workAdd/files/listItem.vue b/src/renderer/components/workAdd/files/listItem.vue index 5cae4eb..1f50dd8 100644 --- a/src/renderer/components/workAdd/files/listItem.vue +++ b/src/renderer/components/workAdd/files/listItem.vue @@ -45,7 +45,7 @@ export default { if (size == -1) { return '正在计算...'; } - return bytesToSize(size); + return this.$filterSize(size); }, getIcon(name) { if (this.info.folder) { diff --git a/src/renderer/components/workAdd/workAdd.vue b/src/renderer/components/workAdd/workAdd.vue index 4c98a00..0401342 100644 --- a/src/renderer/components/workAdd/workAdd.vue +++ b/src/renderer/components/workAdd/workAdd.vue @@ -186,7 +186,7 @@
@@ -213,6 +213,14 @@ import files from './files/file' export default { name: 'UserInfo', components: { fileEmpty, files }, + props: { + saveWorkList: { + type: Object | undefined + }, + isNew: { + type: Boolean + }, + }, data() { return { addShow: false, @@ -410,6 +418,57 @@ export default { }, deep: true, immediate: true + }, + isNew: { + immediate: true, + handler(val) { + let that = this + that.$nextTick(function () { + if (!that.isNew) { + that.isNew = true + that.$nextTick(() => { + that.$refs.files.allSize = that.saveWorkList.size + that.$refs.files.allNumber = that.saveWorkList.filesList.length + that.$refs.files.filesList = that.saveWorkList.filesList + }) + that.soonList = that.saveWorkList.soonList + that.soonImg = that.saveWorkList.soonImg + that.totalSize = that.saveWorkList.totalSize + for (let key in that.form) { + that.form[key] = that.saveWorkList[key] + } + that.form.task_name = that.saveWorkList.task_name + if (that.saveWorkList.json_file) { + fs.readFile(that.saveWorkList.json_file, 'utf8', (err, data) => { + if (err) { + console.error('读取文件时出错:', err) + return + } + let name = that.saveWorkList.json_file.split('\\')[1] + that.fileLists[0] = new File([data], name, { + type: '' + }) + // that.readFile(data) + }) + } + if (that.saveWorkList.udf_file) { + that.csvIsExist = true + console.log(that.saveWorkList.udf_file, that.csvIsExist) + fs.readFile(that.saveWorkList.udf_file, 'utf8', (err, data) => { + if (err) { + console.error('读取文件时出错:', err) + return + } + let name = that.saveWorkList.udf_file.split('\\')[1] + that.file_name = name + that.fileLists[0] = new File([data], name, { + type: '' + }) + }) + } + } + }) + } } }, computed: { @@ -447,10 +506,60 @@ export default { async upload_over() {}, // 保存 workSave() { - that.saveFlag = true - setTimeout(() => { - that.saveFlag = false - }, 1000) + let that = this + if (that.form.json_file === '' && that.$refs.files.filesList.length === 0) { + that.$message({ + message: '请上传作业文件', + type: 'warning' + }) + return + } + let t = true + for (let i in that.$refs.files.filesList) { + if (that.$refs.files.filesList[i].size == -1) { + t = false + } + } + if (t) { + let save = {...that.form} + save.filesList = that.$refs.files.getLists() + save.totalSize = that.totalSize + if (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 || '' + } + }) + } + save.soonImg = that.soonImg + save.soonList = that.soonList + console.log(save) + const v = JSON.stringify(save) + dialog + .showSaveDialog({ + title: 'Save', + filters: [{ name: 'Soon Work', extensions: ['swk'] }] + }) + .then((result) => { + fs.writeFileSync(result.filePath, v) + that.$message({ + message: '保存成功', + type: 'success' + }) + }) + .catch((err) => { + console.log(err) + }) + } else { + that.$message({ + offset: 100, + message: '请等待计算', + type: 'warning' + }) + } }, // 提交 workSubmit() { @@ -552,6 +661,7 @@ export default { that.form.ass_task.push(task) } // csv文件处理 + console.log(that.form.udf_file, that.soonList) 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]) { @@ -564,6 +674,8 @@ export 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 + console.log(that.csvForm.req_info.file_text) + return that.$store.dispatch('chat/websocketsend', that.csvForm).then(() => { }).catch(() => { @@ -722,10 +834,12 @@ export default { //let flag = true; //校验结果 let first_line = this.result.split('\n')[0].replace('\r', '').split(',') //第一行 let second_line = this.result.split('\n')[1].replace('\r', '').split(',') //第二行 - let i = 0 - for (let item of first_line) { - that.$set(that.soonform, item, second_line[i]) - i++ + console.log(first_line, second_line) + for (let i = 0; i < first_line.length; i++) { + let index = that.soonList.findIndex(soon => soon.origin_name === first_line[i]) + if(index > -1) { + that.soonList[index].val = second_line[i] + } } that.csvIsExist = true } @@ -1078,7 +1192,7 @@ export default { font-weight: 500; font-size: 16px; color: #25aed9; - line-height: 30px; + line-height: 40px; text-align: center; margin-left: 30px; } diff --git a/src/renderer/store/modules/chat.js b/src/renderer/store/modules/chat.js index 6385060..bf0bc2c 100644 --- a/src/renderer/store/modules/chat.js +++ b/src/renderer/store/modules/chat.js @@ -157,6 +157,36 @@ const defaultData = { // start_time: '2024-04-01 12:00:00', // finish_time: '2024-04-01 12:00:00', // task_status: 2 + // }, + // { + // task_size: 100000, + // cd_type: 2, + // start_time: '2024-04-01 12:00:00', + // finish_time: '2024-04-01 12:00:00', + // task_status: 2 + // } + // ] + // }, + // { + // task_uuid: '202042152', + // task_name: '复制任务', + // finish_freq: 2, + // total_freq: 10, + // task_status: 2, + // ass_task: [ + // { + // task_size: 100000, + // cd_type: 2, + // start_time: '2024-04-01 12:00:00', + // finish_time: '2024-04-01 12:00:00', + // task_status: 2 + // }, + // { + // task_size: 100000, + // cd_type: 2, + // start_time: '2024-04-01 12:00:00', + // finish_time: '2024-04-01 12:00:00', + // task_status: 2 // } // ] // } @@ -364,7 +394,7 @@ const actions = { for (let i = 0; i < errors.length; i++) { if (errors[i] == 1) { setTimeout(() => { - commit('setData', { name: 'printer_error', data: {type: 'error', confirm: Error1[i], req: 'continue_task' } }) + commit('setData', { name: 'printer_error', data: {type: 'error', notify: Error1[i] } }) }, 500); } } @@ -374,7 +404,7 @@ const actions = { for (let i = 0; i < errors.length; i++) { if (errors[i] == 1) { setTimeout(() => { - commit('setData', { name: 'printer_error', data: {type: 'error', confirm: Error2[i], req: 'continue_task' } }) + commit('setData', { name: 'printer_error', data: {type: 'error', notify: Error2[i] } }) }, 500); } } @@ -384,7 +414,7 @@ const actions = { for (let i = 0; i < errors.length; i++) { if (errors[i] == 1) { setTimeout(() => { - commit('setData', { name: 'printer_error', data: {type: 'error', confirm: Error3[i], req: 'continue_task' } }) + commit('setData', { name: 'printer_error', data: {type: 'error', notify: Error3[i] } }) }, 500); } } diff --git a/src/renderer/views/dashboard/index.vue b/src/renderer/views/dashboard/index.vue index 928008c..1e2e3a4 100644 --- a/src/renderer/views/dashboard/index.vue +++ b/src/renderer/views/dashboard/index.vue @@ -121,7 +121,7 @@
-
-
+
+
-
-
+
+