gaoshp
2024-10-05 fa37d06890dabf79562128d22f7b043025732802
update
已添加2个文件
已修改5个文件
293 ■■■■■ 文件已修改
src/utils/request.js 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/console/system/collection.vue 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/console/workstation/Coll.vue 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/console/workstation/CollDialog.vue 158 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/console/workstation/Dialog.vue 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/console/workstation/index.vue 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
vue.config.js 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/request.js
@@ -129,7 +129,27 @@
            })
        })
    },
    /** post è¯·æ±‚ query string parameters
     * @param  {string} url æŽ¥å£åœ°å€
     * @param  {object} data è¯·æ±‚参数
     * @param  {object} config å‚æ•°
     */
    getJ: function (url, params = {}, config = {}) {
        return new Promise((resolve, reject) => {
            axios({
                method: 'post',
                url: url,
                headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' },
                params: params,
                ...config
            }).then((response) => {
                resolve(response.data);
            }).catch((error) => {
                resolve(error.data);
                reject(error);
            })
        })
    },
    /** post è¯·æ±‚ request payload
     * @param  {string} url æŽ¥å£åœ°å€
     * @param  {object} data è¯·æ±‚参数
@@ -177,6 +197,7 @@
            })
        })
    },
    /** put è¯·æ±‚
     * @param  {string} url æŽ¥å£åœ°å€
     * @param  {object} data è¯·æ±‚参数
src/views/console/system/collection.vue
@@ -1,7 +1,7 @@
<!--
 * @Date: 2024-10-02 20:34:08
 * @LastEditors: gaoshp
 * @LastEditTime: 2024-10-03 10:08:26
 * @LastEditTime: 2024-10-05 10:07:12
 * @FilePath: /cps-web/src/views/console/system/collection.vue
-->
<template>
@@ -13,9 +13,8 @@
                    <el-button type="primary">新增模版</el-button>
                </el-header>
                <el-main>
                    <scTable style="width: 100%;" ref="table" row-key="id" border :params="params" :apiObj="apiObj"
                        stripe paginationLayout="total, prev, pager, next" @dataChange="dataChange"
                        @row-click="rowClick" highlight-current-row>
                    <scTable highlight-current-row @dataChange="dataChange" @row-click="rowClick" ref="table"
                        :params="params" :apiObj="apiObj" @selection-change="selectionChange" stripe>
                        <el-table-column prop="" label="模版名称" width="100px" />
                        <el-table-column prop="" label="类型" />
                        <el-table-column prop="" label="默认轮询" />
@@ -54,7 +53,7 @@
                    let params = {
                    }
                    return await this.$HTTP.get(`/api/blade-cps/check-project/page`, {}, { params }).then(res => {
                    return await this.$HTTP.get(`/api/smart-collect/tpl/page`, {}, { params }).then(res => {
                        res.data.records = res?.data?.records.map(v => {
                            return {
                                ...v,
src/views/console/workstation/Coll.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
<!--
 * @Date: 2024-10-05 09:51:45
 * @LastEditors: gaoshp
 * @LastEditTime: 2024-10-05 09:53:47
 * @FilePath: /cps-web/src/views/console/workstation/Coll.vue
-->
<template>
    <div>
    </div>
</template>
<script>
    export default {
    }
</script>
<style lang="scss" scoped>
</style>
src/views/console/workstation/CollDialog.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,158 @@
<template>
    <el-dialog title="数据点" v-model="visible" :width="'100%'" destroy-on-close @closed="$emit('closed')">
        <el-select v-model="type" placeholder="Select" size="small" style="width: 240px" @change="changeType">
            <el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.id" />
        </el-select>
        <scFormTable v-show="type" ref="table1" v-model="tabledata" stripe hideDelete :hideAdd="!type"
            :addTemplate="addTemplate">
            <el-table-column v-for="item in cols" :key="item.prop" :prop="item.prop" :label="item.label">
                <template #default="scope">
                    <el-select v-model="scope.row[item.prop]" placeholder="Select" size="small"
                        v-if="scope.row.status && item.type === 'option'">
                        <el-option v-for="item in item.options" :key="item" :label="item" :value="item" />
                    </el-select>
                    <el-switch size="small" v-model="scope.row[item.prop]"
                        v-else-if="scope.row.status && item.type === 'boolean'" />
                    <el-input size="small" v-model="scope.row[item.prop]" placeholder=""
                        v-else-if="scope.row.status"></el-input>
                    <span v-else>{{ scope.row[item.prop] }}</span>
                </template>
            </el-table-column>
            <el-table-column label="操作" prop="state" width="120">
                <template #default="scope">
                    <el-button-group>
                        <el-button text type="primary" size="small">编辑</el-button>
                        <el-button text type="primary">复制</el-button>
                        <el-popconfirm width="220" title="确定将选择的数据删除" @confirm="del(scope.row)">
                            <template #reference>
                                <el-button text type="primary" size="small">删除</el-button>
                            </template>
                        </el-popconfirm>
                    </el-button-group>
                </template>
            </el-table-column>
        </scFormTable>
        <template #footer>
            <el-button @click="visible = false">取 æ¶ˆ</el-button>
            <el-button v-if="mode != 'show'" type="primary" :loading="isSaveing" @click="submit()">保 å­˜</el-button>
        </template>
    </el-dialog>
</template>
<script>
import deepmerge from 'deepmerge'
import http from "@/utils/request"
export default {
    emits: ['success', 'closed'],
    props: {
        option: {
            type: Object
        }
    },
    computed: {
    },
    data() {
        return {
            mode: "add",
            visible: false,
            isSaveing: false,
            params: {},
            tabledata: [],
            apiObj: null,
            addTemplate: {
                name: '',
                describe: '',
                deviceAddress: '',
                status: '2' // ä¸å­˜åœ¨å·²ä¿å­˜ 1: æ­£åœ¨ç¼–辑 2: æ–°å¢ž
            },
            type: '',
            typeList: []
        }
    },
    created() {
    },
    methods: {
        changeType(val) {
            console.log(val)
            console.log(JSON.parse(this.typeList.find(v => v.id === val).dpHeadFull))
            try {
                this.cols = JSON.parse(this.typeList.find(v => v.id === val).dpHeadFull)
            } catch (error) {
            }
        },
        //显示
        open(mode = 'add', params) {
            this.isSaveing = false;
            this.mode = mode;
            this.visible = true;
            this.params = params
            this.getDetailList({
                workstationId: this.params.id,
            })
            return this
        },
        getDetailList(params) {
            this.$HTTP.get(`/api/smart-collect/tpl/typelist`, {}, { params }).then(res => {
                this.typeList = res.data || [];
                // return res
            }).finally(() => {
                this.$HTTP.get(`/api/blade-cps/workstation/listDatapointsByWorkstationId`, {}, { params }).then(res => {
                    // res.data.records = res?.data?.records.map(v => {
                    //     return {
                    //         ...v,
                    //         statusName: v.status ? '启用' : '禁用'
                    //     }
                    // })
                    this.type = res.data.type
                    this.tabledata = res.data.dpConfig || [];
                    // return res
                })
            })
        },
        //表单提交方法
        submit() {
            console.log(this.tabledata)
            this.$HTTP.put('/api/blade-cps/workstation/saveDatapoints', {
                dpConfig: JSON.stringify(this.tabledata),
                workstationId: this.params.id,
                type: this.type
            })
        },
    }
}
</script>
<style lang="scss" scoped>
.workbranch {
    list-style: none;
    padding-left: 50px;
    li {
        margin-top: 8px;
        span {
            display: inline-block;
            width: 25px;
            height: 25px;
            line-height: 25px;
            text-align: center;
            border-radius: 50%;
            background: #ccc;
            margin-right: 8px;
        }
    }
}
</style>
src/views/console/workstation/Dialog.vue
@@ -41,13 +41,33 @@
                        <scUpload v-model="form.avatar" title="工位图片"></scUpload>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                <el-col :span="12" v-show="!form.id">
                    <el-form-item label="生产日历" prop="calendarCode">
                        <el-select v-model="form.calendarCode" style="width: 240px">
                            <el-option v-for="item in options.calendarList" :key="item.id" :label="item.name"
                                :value="item.code" />
                        </el-select>
                    </el-form-item>
                </el-col>
                <!-- ä¿®æ”¹çš„æ¬¡æ—¥ç”Ÿæ•ˆ -->
                <el-col :span="11" v-show="form.id">
                    <el-form-item label="生产日历" prop="calendarCode">
                        <el-select v-model="form.calendarCodeWaiting" style="width: 240px">
                            <el-option v-for="item in options.calendarList" :key="item.id" :label="item.name"
                                :value="item.code" />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="1" v-show="form.id">
                    <div style="display: flex;align-items: center;height: 32px;margin-bottom: 18px;">
                        <el-tooltip class="box-item" effect="dark" content="修改后的日历次日生效" placement="top-start">
                            <el-icon>
                                <el-icon-warning-filled style="vertical-align: middle" />
                            </el-icon>
                        </el-tooltip>
                    </div>
                </el-col>
                <el-col :span="24" style="padding:12px 0;" v-if="form.type == 0">
                    æœºå™¨ä¿¡æ¯
@@ -199,6 +219,7 @@
                status: '',
                avatar: '',
                calendarCode: '',
                calendarCodeWaiting: '',
                linkWay: '',
                machineId: '',
                machineCode: '',
@@ -302,6 +323,7 @@
                Object.keys(this.form).forEach(key => {
                    this.form[key] = params[key]
                })
                if (this.form.calendarCode) this.form.calendarCodeWaiting = this.form.calendarCodeWaiting || this.form.calendarCode
                this.$HTTP.get(`/api/blade-cps/workstation/get?workstationId=${params.id}`).then(res => {
                    this.form = res?.data
                    this.$HTTP.get(`/api/blade-cps/workstation-workbench/listWorkbench?workstationId=${params.id}`).then(res => {
src/views/console/workstation/index.vue
@@ -140,15 +140,17 @@
                                                    <el-container>
                                                        <el-header>
                                                            <h2>采集信息</h2>
                                                            <el-button v-show="list.length > 0"
                                                            <!-- <el-button v-show="list.length > 0"
                                                                @click="() => { editFlag = !editFlag; showTable = !editFlag }"
                                                                style="margin-left: auto;" text type="primary"
                                                                size="small">{{ editFlag ? '取消' : '配置工位采集'
                                                                }}</el-button>
                                                            <el-button v-show="editFlag" @click="saveInfo" text
                                                                type="primary" size="small">保存</el-button>
                                                                type="primary" size="small">保存</el-button> -->
                                                            <!-- <el-button text type="primary" size="small"
                                                                @click="editDMP">修改DMP配置</el-button> -->
                                                            <el-button @click="editCollection" text type="primary"
                                                                size="small">数据点编辑</el-button>
                                                        </el-header>
                                                        <el-main>
                                                            <el-table :data="list" height="200px"
@@ -392,17 +394,20 @@
            </el-tabs>
        </el-card>
        <Dialog ref="dialog" @success="success" :option="{ types, status, group }"></Dialog>
        <CollDialog ref="CollDialog" @success="success" :option="{ previewData }"></CollDialog>
    </el-main>
</template>
<script>
import pmsPng from '@/assets/pms.png'
import Dialog from './Dialog.vue'
import CollDialog from './CollDialog.vue'
import machinePng from '@/assets/machine.png'
export default {
    name: 'system',
    components: {
        Dialog
        Dialog,
        CollDialog
    },
    data() {
        return {
@@ -482,7 +487,6 @@
            handler(val) {
                this.queryList().then(() => {
                    if (val == 1) {
                        console.log('>>>>>>>>>>>>>>', this.treeCheckedNode)
                        this.apiObj = this.$API.workstation.getList
                        this.params = {
                            groupId: this.treeCheckedNode.id,
@@ -511,8 +515,11 @@
        this.queryList()
    },
    methods: {
        // æ•°æ®ç‚¹ç¼–辑
        editCollection() {
            this.$refs.CollDialog.open('edit', this.previewData)
        },
        handleSelectionChange(val) {
            console.log(val)
            val.forEach(v => {
                v.bigScreen = true
                v.realTimeData = true
@@ -520,7 +527,6 @@
            })
            this.list.forEach(v => {
                if (val.filter(item => v.id === item.id).length == 0) {
                    console.log(v)
                    v.bigScreen = false
                    v.realTimeData = false
                    v.processParameter = false
@@ -573,7 +579,6 @@
                    let data = this.formatData(res.data)
                    this.group = data
                    this.showGrouploading = false
                    console.log('>>>>>>>>>>>>>>>>>>>>>')
                    // this.$nextTick(() => {
                    if (!flag) {
                        debugger
@@ -626,13 +631,11 @@
                    groupCategory: this.treeCheckedNode.groupCategory
                }, this.form)
                return this.$API.workstation.saveWorkstationGroup.post(data).then(res => {
                    console.log(res)
                    this.queryList(true)
                })
            }
            let data = Object.assign({}, this.treeCheckedNode, this.form)
            this.$API.workstation.saveWorkstationGroup.put(data).then(res => {
                console.log(res)
                this.queryList(true)
            })
        },
@@ -655,7 +658,6 @@
        },
        rowClick(data) {
            this.previewData = data
            console.log(data, '>>>>>>>>>>>')
            if (!data.id) {
                Object.keys(this.basic).forEach(key => {
                    this.basic[key] = '-'
@@ -667,7 +669,8 @@
                this.workbenchVOList = []
                return
            }
            this.$HTTP.get(`/api/blade-cps/workstation/listDmpVariablesByWorkstationId?workstationId=${data.id}`).then(res => {
            console.log(data, '>>>>>>>>>>>')
            this.$HTTP.get(`/api/blade-cps/workstation/listDmpVariablesByMachineId?machineId=${data.machineId}`).then(res => {
                this.list = res?.data?.dmpVariablesVOList
                Object.keys(this.basic).forEach(key => {
                    this.basic[key] = res?.data?.[key] || '-'
@@ -681,7 +684,6 @@
            })
        },
        groupClick1(data) {
            console.log('-------', data)
            var params = {
                groupId: data.id,
                keyWord: this.keyWord,
@@ -694,7 +696,6 @@
        dataChange(res, data) {
            if (data.length > 0) {
                console.log(data[0], '>>>>>>>>')
                this.$refs.table.setCurrentRow(data[0])
                this.previewData = data[0]
                this.rowClick(data[0])
vue.config.js
@@ -1,8 +1,8 @@
/*
 * @Date: 2024-03-23 09:49:06
 * @LastEditors: Sneed
 * @LastEditTime: 2024-04-10 22:11:52
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/vue.config.js
 * @LastEditors: gaoshp
 * @LastEditTime: 2024-10-05 17:23:49
 * @FilePath: /cps-web/vue.config.js
 */
const { defineConfig } = require('@vue/cli-service')
@@ -22,6 +22,30 @@
        open: false, //运行后自动打开浏览器
        port: process.env.VUE_APP_PORT, //挂载端口
        proxy: {
            '/api/smart-collect': {
                target: 'http://120.46.212.231:4102',
                // ws: true,
                changeOrigin: true,
                pathRewrite: {
                    '^/api': '/'
                }
            },
            '/api/blade-cps/workstation/listDatapointsByWorkstationId': {
                target: 'http://120.46.212.231:4102',
                // ws: true,
                changeOrigin: true,
                pathRewrite: {
                    '^/api': '/'
                }
            },
            '/api/blade-cps/workstation/saveDatapoints': {
                target: 'http://120.46.212.231:4102',
                // ws: true,
                changeOrigin: true,
                pathRewrite: {
                    '^/api': '/'
                }
            },
            '/api': {
                target: process.env.VUE_APP_API_BASEURL,
                ws: true,
@@ -29,6 +53,7 @@
                    // '^/api': '/'
                }
            },
        }
    },