gaoshp
2024-11-05 e2fdfe540eaf160dc7d063c60667041edcc64e86
src/views/console/tooling/fixture.vue
@@ -1,7 +1,7 @@
<!--
 * @Date: 2024-05-12 20:02:31
 * @LastEditors: Sneed
 * @LastEditTime: 2024-05-16 22:07:06
 * @LastEditTime: 2024-06-16 16:17:58
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/console/tooling/fixture.vue
-->
<template>
@@ -9,10 +9,11 @@
        <el-aside width="200px">
            <el-container>
                <el-main>
                    <el-tree default-expand-all ref="group" node-key="id" :data="treeData" :props="{
                        label: 'name',
                        disabled: 'isGroup'
                    }" @node-click="nodeClick">
                    <el-tree :expand-on-click-node="false" default-expand-all ref="group" node-key="id" :data="treeData"
                        :props="{
                            label: 'name',
                            disabled: 'isGroup'
                        }" @node-click="nodeClick">
                        <template #default="{ node, data }">
                            <div :class="data.isGroup ? 'active' : ''" class="custom-tree-node">
                                <span>{{ node.label || data.code }}</span>
@@ -41,8 +42,8 @@
        <el-container v-if="selectNode.id">
            <el-header>
                <el-button @click="table_add" type="primary" icon="el-icon-plus"></el-button>
                <import-table style="margin:0 8px" exportUrl="/api/blade-cps/fixture/export/template"
                    uploadUrl="/api/blade-cps/fixture/import-fixture"></import-table>
                <import-table style="margin:0 8px" exportUrl="/api/smis/fixture/export/template"
                    uploadUrl="/api/smis/fixture/import-fixture"></import-table>
                <el-popconfirm title="确定删除吗?" @confirm="del(selection, '0')">
                    <template #reference>
                        <el-button type="danger" :disabled="selection.length === 0" plain icon="el-icon-delete"
@@ -118,6 +119,28 @@
                                <template #default="scope">
                                    <el-button-group>
                                        <el-popconfirm title="确定删除吗?" @confirm="table_del1(scope.row, '0')">
                                            <template #reference>
                                                <el-button text type="primary" size="small">删除</el-button>
                                            </template>
                                        </el-popconfirm>
                                    </el-button-group>
                                </template>
                            </el-table-column>
                        </el-table>
                        <h2 style="margin:14px 0;">关联文档</h2>
                        <el-upload style="margin-left: 8px;" :show-file-list="false" class="upload"
                            :http-request="request">
                            <el-button type="primary">上传文件</el-button>
                        </el-upload>
                        <el-table :data="fileList" style="width: 100%" stripe>
                            <el-table-column label="文档名称" prop="fileName"></el-table-column>
                            <el-table-column label="创建时间" prop="createTime"></el-table-column>
                            <el-table-column label="大小" prop="fileLength"></el-table-column>
                            <el-table-column label="操作" fixed="right" align="right" width="160">
                                <template #default="scope">
                                    <el-button-group>
                                        <el-button text type="primary" size="small" @click="downFile">下载</el-button>
                                        <el-popconfirm title="确定删除吗?" @confirm="delFile(scope.row, '0')">
                                            <template #reference>
                                                <el-button text type="primary" size="small">删除</el-button>
                                            </template>
@@ -221,6 +244,7 @@
            },
            info: {},
            infoList: [],
            fileList: [],
            selectNode: {},
            apiObj: {
                get: async (data) => {
@@ -229,7 +253,7 @@
                        groupId: this.selectNode.id,
                        ...this.params
                    }
                    return await this.$HTTP.get(`/api/blade-cps/fixture/page`, {}, { params }).then(res => {
                    return await this.$HTTP.get(`/api/smis/fixture/page`, {}, { params }).then(res => {
                        return res
                    })
                }
@@ -250,7 +274,8 @@
            },
            trayId: [],
            surfaceId: [],
            selection: []
            selection: [],
            row: {}
        }
    },
    watch: {
@@ -258,6 +283,7 @@
            handler(val) {
                this.info = {}
                this.infoList = []
                this.fileList = []
                if (val) {
                    this.queryInfo()
                }
@@ -266,7 +292,7 @@
        'trayForm.trayId': {
            handler(val) {
                if (val) {
                    this.$HTTP.get(`/api/blade-cps/tray-surface/list/${val}`).then(res => {
                    this.$HTTP.get(`/api/smis/tray-surface/list/${val}`).then(res => {
                        this.surfaceId = res.data
                        if (!this.surfaceId.find(v => v.id === this.trayForm.surfaceId)) {
                            this.trayForm.surfaceId = ''
@@ -282,11 +308,45 @@
    },
    created() {
        this.init()
        this.$HTTP.post(`/api/blade-cps/tray/list`).then(res => {
        this.$HTTP.post(`/api/smis/tray/list`).then(res => {
            this.trayId = res.data
        })
    },
    methods: {
        request(options) {
            const formData = new FormData()
            console.log(options)
            formData.append('file', options.file)
            this.$HTTP.post(`/api/blade-resource/oss/endpoint/put-file`, formData).then(resFile => {
                this.$HTTP.post(`/api/smis/fixture/file`, {
                    contentType: options.file.type,
                    fileLength: options.file.size,
                    fileLink: resFile.data.link,
                    fileName: resFile.data.originalName,
                    objectKey: resFile.data.name,
                    parentId: this.row.id
                }).then(res => {
                    if (res.success) {
                        this.rowClick(this.row)
                    } else {
                        this.$message.error(res.msg)
                    }
                })
            })
        },
        delFile(row) {
            this.$HTTP.delete(`/api/smis/tool-appendix/remove`, [row.id]).then(res => {
                if (res.success) {
                    this.rowClick(this.row)
                } else {
                    this.$message.error(res.msg)
                }
            })
        },
        downFile(row) {
            window.open(row.fileLink)
        },
        selectionChange(selection) {
            this.selection = selection
        },
@@ -302,13 +362,13 @@
            this.visibleGroup = true
        },
        delArea(data) {
            this.$HTTP.delete(`/api/blade-cps/tray/remove-tree?id=${data.id}`).then(res => {
            this.$HTTP.delete(`/api/smis/tray/remove-tree?id=${data.id}`).then(res => {
                this.init()
            })
        },
        saveGroup() {
            if (!this.formGroup.id) {
                this.$HTTP.post(`/api/blade-cps/group`, {
                this.$HTTP.post(`/api/smis/group`, {
                    groupCategory: 1,
                    groupType: "group_fixture",
                    parentId: this.selectNode.id,
@@ -318,7 +378,7 @@
                    this.init()
                })
            } else {
                this.$HTTP.put(`/api/blade-cps/group`, {
                this.$HTTP.put(`/api/smis/group`, {
                    groupCategory: 1,
                    groupType: "group_fixture",
                    parentId: this.selectNode.id,
@@ -351,14 +411,14 @@
        },
        confirm() {
            if (this.trayForm.id) {
                return this.$HTTP.put(`/api/blade-cps/fixture/update`, {
                return this.$HTTP.put(`/api/smis/fixture/update`, {
                    ...this.trayForm
                }).then(res => {
                    this.dialog = false
                    this.queryInfo()
                })
            }
            this.$HTTP.post(`/api/blade-cps/fixture/${this.trayForm.fixtureGroupId}/insert`, {
            this.$HTTP.post(`/api/smis/fixture/${this.trayForm.fixtureGroupId}/insert`, {
                ...this.trayForm
            }).then(res => {
                this.dialog = false
@@ -366,12 +426,12 @@
            })
        },
        del(ids) {
            this.$HTTP.delete(`/api/blade-cps/fixture/remove`, ids.map(v => v.id)).then(res => {
            this.$HTTP.delete(`/api/smis/fixture/remove`, ids.map(v => v.id)).then(res => {
                this.queryInfo()
            })
        },
        init() {
            this.$HTTP.post(`/api/blade-cps/tray/tooling-tree`, {
            this.$HTTP.post(`/api/smis/tray/tooling-tree`, {
                groupCategory: 1,
                groupType: "group_fixture"
            }).then(res => {
@@ -382,10 +442,10 @@
        queryInfo() {
            if (!this.selectNode.id) return
            this.$refs?.table?.reload()
            // this.$HTTP.get(`/api/blade-cps/tray/${this.selectNode.id}`).then(res => {
            // this.$HTTP.get(`/api/smis/tray/${this.selectNode.id}`).then(res => {
            //     this.info = res.data
            // })
            // this.$HTTP.get(`/api/blade-cps/tray-surface/list/${this.selectNode.id}`).then(res => {
            // this.$HTTP.get(`/api/smis/tray-surface/list/${this.selectNode.id}`).then(res => {
            //     this.info = res.data
            // })
        },
@@ -393,13 +453,14 @@
            data?.[0] && this.rowClick(data?.[0])
        },
        rowClick(row) {
            this.row = row
            console.log(row.id)
            this.queryChildInfo(row.id)
        },
        async queryChildInfo(id) {
            if (!id) return
            this.showLoading = true
            await this.$HTTP.get(`/api/blade-cps/fixture/get/${id}`).then(res => {
            await this.$HTTP.get(`/api/smis/fixture/get/${id}`).then(res => {
                this.info = res.data
                this.infoList = [
                    {
@@ -410,8 +471,9 @@
                        trayName: res.data.trayName,
                    }
                ]
                this.fileList = res.data.toolAppendixVOList
            })
            // await this.$HTTP.get(`/api/blade-cps/tray-surface/list/${id}`).then(res => {
            // await this.$HTTP.get(`/api/smis/tray-surface/list/${id}`).then(res => {
            //     this.infoList = res.data
            // })
            this.showLoading = false
@@ -420,7 +482,7 @@
            this.selectNode = node
        },
        table_del1(row) {
            this.$HTTP.delete(`/api/blade-cps/tray-fixture`, [{ id: row.id, othersId: row.othersId }]).then(res => {
            this.$HTTP.delete(`/api/smis/tray-fixture`, [{ id: row.id, othersId: row.othersId }]).then(res => {
                this.$message.success('操作成功')
                this.queryChildInfo(this.info.id)
            })