|
|
@@ -0,0 +1,184 @@
|
|
|
+<template>
|
|
|
+ <ele-modal
|
|
|
+ width="75vw"
|
|
|
+ :visible.sync="visible"
|
|
|
+ v-if="visible"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ custom-class="ele-dialog-form"
|
|
|
+ title="工艺文件"
|
|
|
+ append-to-body
|
|
|
+ :maxable="true"
|
|
|
+ @closed="onClose"
|
|
|
+ >
|
|
|
+ <ele-pro-table
|
|
|
+ ref="fileTable"
|
|
|
+ :columns="jobColumns1"
|
|
|
+ :datasource="tableData"
|
|
|
+ :need-page="false"
|
|
|
+ :immediate="true"
|
|
|
+ row-key="code"
|
|
|
+ >
|
|
|
+ <!-- 表头工具栏 -->
|
|
|
+ <template v-slot:toolbar v-if="canEdit">
|
|
|
+ <el-button type="primary" @click="addFile">添加</el-button>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <!-- 操作列 -->
|
|
|
+ <template v-slot:action="{ row, $index }">
|
|
|
+ <el-link v-if="canEdit" type="primary" @click="handleDel($index)">
|
|
|
+ 删除
|
|
|
+ </el-link>
|
|
|
+ <el-link type="primary" @click="fileDetails(row)"> 详情 </el-link>
|
|
|
+ </template>
|
|
|
+ </ele-pro-table>
|
|
|
+
|
|
|
+ <!-- 底部按钮 -->
|
|
|
+ <span slot="footer" class="dialog-footer" v-if="canEdit">
|
|
|
+ <el-button @click="visible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="saveFile">保 存</el-button>
|
|
|
+ </span>
|
|
|
+
|
|
|
+ <fileIndex v-if="fileShow" @close="fileClose" />
|
|
|
+ </ele-modal>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import dictMixins from '@/mixins/dictMixins';
|
|
|
+ import { newFilePageAPI } from '@/api/material/file';
|
|
|
+ import fileIndex from '../file/index.vue';
|
|
|
+ import { setFileUrl } from '@/components/addDoc/util.js';
|
|
|
+
|
|
|
+ export default {
|
|
|
+ components: { fileIndex },
|
|
|
+ mixins: [dictMixins],
|
|
|
+
|
|
|
+ props: {
|
|
|
+ attributeData: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({})
|
|
|
+ },
|
|
|
+ isWt: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ visible: false,
|
|
|
+ fileShow: false,
|
|
|
+ routeData: null,
|
|
|
+ tableData: [],
|
|
|
+
|
|
|
+ jobColumns1: [
|
|
|
+ {
|
|
|
+ label: '编码',
|
|
|
+ prop: 'code',
|
|
|
+ width: 180,
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '文档名称',
|
|
|
+ prop: 'name',
|
|
|
+ align: 'center',
|
|
|
+ minWidth: 200,
|
|
|
+ showOverflowTooltip: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '文件名称',
|
|
|
+ prop: 'storagePath',
|
|
|
+ align: 'center',
|
|
|
+ minWidth: 200,
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ formatter: (_, __, val) =>
|
|
|
+ Array.isArray(val) && val.length ? val[0].name : '-'
|
|
|
+ },
|
|
|
+ { label: '版本', prop: 'version', align: 'center', minWidth: 100 },
|
|
|
+ {
|
|
|
+ label: '创建时间',
|
|
|
+ prop: 'createTime',
|
|
|
+ align: 'center',
|
|
|
+ minWidth: 110,
|
|
|
+ showOverflowTooltip: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '操作',
|
|
|
+ columnKey: 'action',
|
|
|
+ slot: 'action',
|
|
|
+ width: 260,
|
|
|
+ align: 'center'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ };
|
|
|
+ },
|
|
|
+
|
|
|
+ computed: {
|
|
|
+ /** 是否可编辑 */
|
|
|
+ canEdit() {
|
|
|
+ const { approvalStatus, parentId, resourceBomId } = this.attributeData;
|
|
|
+ const notApproved = approvalStatus !== 1 && approvalStatus !== 2;
|
|
|
+
|
|
|
+ return (
|
|
|
+ (!this.isWt && parentId === '0' && notApproved) ||
|
|
|
+ (!resourceBomId && !this.isWt && notApproved)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ methods: {
|
|
|
+ open(item) {
|
|
|
+ this.routeData = item;
|
|
|
+ this.visible = true;
|
|
|
+ this.fetchFiles();
|
|
|
+ },
|
|
|
+
|
|
|
+ async fetchFiles() {
|
|
|
+ const ids = this.routeData?.fileParam?.map((i) => i.id) || [];
|
|
|
+
|
|
|
+ if (!ids.length) {
|
|
|
+ this.tableData = [];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const res = await newFilePageAPI({
|
|
|
+ ids: `'${ids.join(',')}'`
|
|
|
+ });
|
|
|
+
|
|
|
+ this.tableData = res || [];
|
|
|
+ },
|
|
|
+
|
|
|
+ addFile() {
|
|
|
+ this.fileShow = true;
|
|
|
+ },
|
|
|
+
|
|
|
+ fileClose(list) {
|
|
|
+ this.tableData = list || [];
|
|
|
+ this.fileShow = false;
|
|
|
+ },
|
|
|
+
|
|
|
+ handleDel(index) {
|
|
|
+ this.tableData.splice(index, 1);
|
|
|
+ },
|
|
|
+
|
|
|
+ fileDetails(row) {
|
|
|
+ window.open(setFileUrl(row));
|
|
|
+ },
|
|
|
+
|
|
|
+ saveFile() {
|
|
|
+ if (!this.tableData.length) {
|
|
|
+ return this.$message.warning('请添加工艺路线');
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$emit('updataFile', this.tableData);
|
|
|
+ this.visible = false;
|
|
|
+ },
|
|
|
+
|
|
|
+ onClose() {
|
|
|
+ this.visible = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+</script>
|
|
|
+
|
|
|
+<style></style>
|