feat(wpm): manage files for individual outputs

This commit is contained in:
caoqianming 2026-08-03 10:22:00 +08:00
parent 3618c553d3
commit 7da285b6f9
4 changed files with 126 additions and 2 deletions

View File

@ -341,6 +341,12 @@ export default {
},
mlogbw: {
files: {
name: "产出附件",
req: async function (id, data) {
return await http.put(`${config.API_URL}/wpm/mlogbw/${id}/files/`, data);
},
},
list: {
name: "列表",
req: async function (data) {

View File

@ -0,0 +1,105 @@
<template>
<span>
<el-button link type="primary" :disabled="!row.id" @click="open">
附件{{ fileCount }}
</el-button>
<el-dialog
v-model="visible"
:title="`${row.number || ''} 产出附件`"
width="620px"
append-to-body
destroy-on-close
>
<el-upload
v-model:file-list="fileList"
:disabled="disabled"
:http-request="uploadRequest"
:before-upload="beforeUpload"
:on-preview="preview"
multiple
>
<el-button v-if="!disabled" type="primary">上传文件</el-button>
<template #tip>
<div class="el-upload__tip">支持文件图片和视频可一次选择多个文件</div>
</template>
</el-upload>
<template #footer>
<el-button @click="visible = false">关闭</el-button>
<el-button v-if="!disabled" type="primary" :loading="saving" @click="save">保存</el-button>
</template>
</el-dialog>
</span>
</template>
<script>
export default {
name: "OutputMaterialFiles",
props: {
row: { type: Object, required: true },
disabled: { type: Boolean, default: false },
},
data() {
return {
visible: false,
saving: false,
fileList: [],
};
},
computed: {
fileCount() {
return (this.row.files_ || []).length;
},
},
methods: {
open() {
this.fileList = (this.row.files_ || []).map((file) => ({
id: file.id,
name: file.name,
url: file.path,
status: "success",
}));
this.visible = true;
},
beforeUpload(file) {
if (file.size <= 0) {
this.$message.warning("不能上传空文件");
return false;
}
return true;
},
uploadRequest(param) {
const data = new FormData();
data.append("file", param.file);
this.$API.common.upload.post(data, {
onUploadProgress: (event) => {
if (event.total) {
param.onProgress({ percent: Math.round((event.loaded / event.total) * 100) });
}
},
}).then(param.onSuccess).catch(param.onError);
},
preview(file) {
const url = file.url || file.response?.path;
if (url) window.open(url, "_blank");
},
async save() {
const uploading = this.fileList.some((file) => ["ready", "uploading"].includes(file.status));
if (uploading) {
this.$message.warning("请等待文件上传完成");
return;
}
const ids = this.fileList.map((file) => file.id || file.response?.id).filter(Boolean);
this.saving = true;
try {
const result = await this.$API.wpm.mlogbw.files.req(this.row.id, { files: ids });
this.row.files = result.files;
this.row.files_ = result.files_;
this.visible = false;
this.$message.success("附件已保存");
} finally {
this.saving = false;
}
},
},
};
</script>

View File

@ -233,6 +233,11 @@
<el-input v-else v-model="scope.row.note" placeholder="备注"></el-input>
</template>
</el-table-column>
<el-table-column v-if="mode == 'outs'" label="附件" width="100px" align="center">
<template #default="scope">
<output-material-files :row="scope.row" :disabled="isSubmit" />
</template>
</el-table-column>
<el-table-column label="操作" width="160" align="center" fixed="right" v-if="!isSubmit">
<template #default="scope">
<el-button
@ -429,7 +434,10 @@
</el-drawer>
</template>
<script>
import OutputMaterialFiles from "@/components/OutputMaterialFiles.vue";
export default {
components: { OutputMaterialFiles },
props: {
mlogb: {
type: String,

View File

@ -63,6 +63,7 @@
<span style="color:#f56c6c;">{{ getDefectCount(item.defect_name) }}</span>
</th>
<th class="w_80" v-show="isColVisible('note')">备注</th>
<th class="w_100">附件</th>
<th class="w_150 sticky-cell sticky-right-action" v-if="!isSubmit">操作</th>
</tr>
</thead>
@ -129,6 +130,9 @@
<input v-if="row.isEdit" v-model="row.note" placeholder="备注">
<span v-else style="width: 100%;height: 100%;display: inline-block;">{{ row.note }}</span>
</td>
<td class="w_100">
<output-material-files :row="row" :disabled="isSubmit" />
</td>
<td
class="w_150 sticky-cell sticky-right-action operation-cell"
:class="{ 'is-menu-open': openedActionMenu === actionMenuKey(row, index) }"
@ -323,8 +327,9 @@
<script>
import { ElLoading } from "element-plus";
import scFileImport from "@/components/scFileImport";
import OutputMaterialFiles from "@/components/OutputMaterialFiles.vue";
export default {
components: {scFileImport},
components: { scFileImport, OutputMaterialFiles },
props: {
qct: {
type: String,