feat(wpm): manage files for individual outputs
This commit is contained in:
parent
3618c553d3
commit
7da285b6f9
|
|
@ -341,6 +341,12 @@ export default {
|
||||||
|
|
||||||
},
|
},
|
||||||
mlogbw: {
|
mlogbw: {
|
||||||
|
files: {
|
||||||
|
name: "产出附件",
|
||||||
|
req: async function (id, data) {
|
||||||
|
return await http.put(`${config.API_URL}/wpm/mlogbw/${id}/files/`, data);
|
||||||
|
},
|
||||||
|
},
|
||||||
list: {
|
list: {
|
||||||
name: "列表",
|
name: "列表",
|
||||||
req: async function (data) {
|
req: async function (data) {
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
@ -233,6 +233,11 @@
|
||||||
<el-input v-else v-model="scope.row.note" placeholder="备注"></el-input>
|
<el-input v-else v-model="scope.row.note" placeholder="备注"></el-input>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</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">
|
<el-table-column label="操作" width="160" align="center" fixed="right" v-if="!isSubmit">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button
|
<el-button
|
||||||
|
|
@ -429,7 +434,10 @@
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
import OutputMaterialFiles from "@/components/OutputMaterialFiles.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: { OutputMaterialFiles },
|
||||||
props: {
|
props: {
|
||||||
mlogb: {
|
mlogb: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@
|
||||||
<span style="color:#f56c6c;">{{ getDefectCount(item.defect_name) }}</span>
|
<span style="color:#f56c6c;">{{ getDefectCount(item.defect_name) }}</span>
|
||||||
</th>
|
</th>
|
||||||
<th class="w_80" v-show="isColVisible('note')">备注</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>
|
<th class="w_150 sticky-cell sticky-right-action" v-if="!isSubmit">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
@ -128,7 +129,10 @@
|
||||||
<td class="w_80 " v-show="isColVisible('note')">
|
<td class="w_80 " v-show="isColVisible('note')">
|
||||||
<input v-if="row.isEdit" v-model="row.note" placeholder="备注">
|
<input v-if="row.isEdit" v-model="row.note" placeholder="备注">
|
||||||
<span v-else style="width: 100%;height: 100%;display: inline-block;">{{ row.note }}</span>
|
<span v-else style="width: 100%;height: 100%;display: inline-block;">{{ row.note }}</span>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="w_100">
|
||||||
|
<output-material-files :row="row" :disabled="isSubmit" />
|
||||||
|
</td>
|
||||||
<td
|
<td
|
||||||
class="w_150 sticky-cell sticky-right-action operation-cell"
|
class="w_150 sticky-cell sticky-right-action operation-cell"
|
||||||
:class="{ 'is-menu-open': openedActionMenu === actionMenuKey(row, index) }"
|
:class="{ 'is-menu-open': openedActionMenu === actionMenuKey(row, index) }"
|
||||||
|
|
@ -323,8 +327,9 @@
|
||||||
<script>
|
<script>
|
||||||
import { ElLoading } from "element-plus";
|
import { ElLoading } from "element-plus";
|
||||||
import scFileImport from "@/components/scFileImport";
|
import scFileImport from "@/components/scFileImport";
|
||||||
|
import OutputMaterialFiles from "@/components/OutputMaterialFiles.vue";
|
||||||
export default {
|
export default {
|
||||||
components: {scFileImport},
|
components: { scFileImport, OutputMaterialFiles },
|
||||||
props: {
|
props: {
|
||||||
qct: {
|
qct: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue