gaoshp
2024-04-14 037af3bed10918cf24629f9a7f7e207af059ee96
update
已修改5个文件
490 ■■■■ 文件已修改
src/api/model/workstation.js 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/scUpload/index.vue 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/console/workstation/Dialog.vue 315 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/console/workstation/index.vue 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mdc/configuration.vue 92 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/model/workstation.js
@@ -1,8 +1,8 @@
/*
 * @Date: 2024-03-24 11:37:47
 * @LastEditors: gaoshp
 * @LastEditTime: 2024-03-31 21:34:40
 * @FilePath: /cps-web/src/api/model/workstation.js
 * @LastEditors: Sneed
 * @LastEditTime: 2024-04-14 15:02:51
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/api/model/workstation.js
 */
import config from "@/config"
import http from "@/utils/request"
@@ -55,7 +55,20 @@
        delete: async function(params){
            return await http.delete(this.url, params);
        }
        // /blade-cps/workstation?type=1&workstationIds=1689546460820299778
    },
    add: {
        url: `${config.API_URL}/blade-cps/workstation/submit`,
        name: "添加工位",
        post: async function(params){
            return await http.post(this.url, params);
        },
    },
    getlistnoband: {
        url: `${config.API_URL}/blade-cps/machine/list-no-band`,
        name: "获取未绑定工位",
        get: async function(params){
            return await http.get(this.url, params);
        }
    }
    
}
src/components/scUpload/index.vue
@@ -95,7 +95,8 @@
                    height: this.height + "px"
                },
                cropperDialogVisible: false,
                cropperFile: null
                cropperFile: null,
                hostNew: ''
            }
        },
        watch:{
@@ -108,15 +109,23 @@
            }
        },
        mounted() {
            this.value = this.modelValue
            this.newFile(this.modelValue)
            this.getHost().then(res => {
                this.value = this.modelValue
                this.newFile(this.modelValue)
            })
        },
        methods: {
            getHost () {
                if (this.host) return this.hostNew = this.host
                return this.$API.setting.component.getImgHost.get().then(res => {
                    this.hostNew = res.data + '/visual/'
                })
            },
            newFile(url){
                if(url){
                    this.file = {
                        status: "success",
                        url: `${this.host}${url}`
                        url: `${this.hostNew}${url}`
                    }
                }else{
                    this.file = null
src/views/console/workstation/Dialog.vue
@@ -7,123 +7,136 @@
                    基础信息
                </el-col>
                <el-col :span="12">
                    <el-form-item label="工位编号" prop="userName">
                        <el-input style="width: 240px" v-model="form.userName" placeholder="工位编号" clearable></el-input>
                    <el-form-item label="工位编号" prop="code">
                        <el-input style="width: 240px" :disabled="form.id" v-model="form.code" placeholder="工位编号" clearable></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="工位名称" prop="userName">
                        <el-input style="width: 240px" v-model="form.userName" placeholder="工位名称" clearable></el-input>
                    <el-form-item label="工位名称" prop="name">
                        <el-input style="width: 240px" v-model="form.name" placeholder="工位名称" clearable></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="工位类型" prop="userName">
                        <el-select v-model="type" style="width: 240px">
                    <el-form-item label="工位类型" prop="type">
                        <el-select v-model="form.type" style="width: 240px" :disabled="form.id">
                            <el-option v-for="item in options.types" :key="item.value" :label="item.label"
                                :value="item.value" />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="所属工位组" prop="userName">
                        <el-tree-select v-model="form.userName" :data="options.group" :render-after-expand="false"
                    <el-form-item label="所属工位组" prop="groupName">
                        <el-tree-select @node-click="nodeClick" v-model="form.groupName" :data="options.group"  :check-on-click-node="true"
                            style="width: 240px" />
                        <!-- <el-select v-model="type" style="width: 240px">
                            <el-option v-for="item in options" :key="item.value" :label="item.label"
                                :value="item.value" />
                        </el-select> -->
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="状态" prop="userName">
                        <el-select v-model="type" style="width: 240px">
                            <el-option v-for="item in options.status" :key="item.value" :label="item.label"
                                :value="item.value" />
                        </el-select>
                    <el-form-item label="状态" prop="status">
                        <el-switch v-model="form.status" :active-value="1" :inactive-value="0"/>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="工位图片" prop="avatar">
                        <sc-upload v-model="form.avatar" title="工位图片"></sc-upload>
                        <scUpload v-model="form.avatar" title="工位图片"></scUpload>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="生产日历" prop="userName">
                        <el-select v-model="type" style="width: 240px">
                    <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.id" />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="24" style="padding:12px 0;">
                <el-col :span="24" style="padding:12px 0;" v-if="form.type == 0">
                    机器信息
                </el-col>
                <el-col :span="12">
                    <el-form-item label="选择机器" prop="userName">
                        <!-- <el-select v-model="type" style="width: 240px">
                            <el-option v-for="item in options.linkWays" :key="item.value" :label="item.label"
                                :value="item.value" />
                        </el-select> -->
                        <el-radio-group v-model="form.userName">
                            <el-radio v-for="item in options.linkWays" :key="item.value" :value="item.value">{{item.label}}</el-radio>
                <el-col :span="12" v-if="form.type == 0 && !form.id">
                    <el-form-item label="选择机器" prop="linkWay" >
                        <el-radio-group v-model="form.linkWay">
                            <el-radio v-for="item in options.linkWays" :key="item.value" :label="item.value">{{item.label}}</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="机器编号" prop="userName">
                        <el-input style="width: 240px" v-model="form.userName" placeholder="机器编号" clearable></el-input>
                <el-col :span="12" v-if="(form.type == 0 && form.linkWay == 0) || form.id">
                    <!-- machineCode -->
                    <el-form-item label="机器编号" prop="machineId">
                        <!-- <el-input style="width: 240px" v-model="form.machineId" placeholder="机器编号" clearable></el-input> -->
                        <el-select v-if="!form.id" v-model="form.machineId" style="width: 240px" @change="change" clear filterable>
                            <el-option v-for="item in options.listnoband" :key="item.id" :label="item.machineName" :value="item.id"
                               >
                            {{ `${item?.machineCode}-${item?.machineName}-${item?.brand}`  }}</el-option>
                        </el-select>
                        <el-input v-if="form.id" :disabled="form.id" v-model="form.machineName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24" style="padding:12px 0;">
                    扩展信息
                </el-col>
                <el-col :span="12">
                    <el-form-item label="工种" prop="userName">
                        <el-select v-model="type" style="width: 240px">
                    <el-form-item label="工种" prop="deviceType">
                        <el-select v-model="form.deviceType" style="width: 240px">
                            <el-option v-for="item in options.work_type" :key="item.dictKey" :label="item.dictValue"
                                :value="item.dictKey" />
                                :value="item.dictKey - 0" />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="加工属性" prop="userName">
                        <el-select v-model="type" style="width: 240px">
                    <el-form-item label="加工属性" prop="properties">
                        <el-select v-model="form.properties" style="width: 240px">
                            <el-option v-for="item in options.machining_type" :key="item.dictKey" :label="item.dictValue"
                                :value="item.dictKey" />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="程序传输方式" prop="userName">
                        <el-select v-model="type" style="width: 240px">
                            <el-option   label="FTP"  value="1" />
                            <el-option   label="串口"  value="" />
                    <el-form-item label="程序传输方式" prop="transmissionMethod">
                        <el-select v-model="form.transmissionMethod" style="width: 240px">
                            <el-option   label="FTP"  :value="1" />
                            <el-option   label="串口"  :value="2" />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="FTP目录" prop="userName">
                        <el-select v-model="type" style="width: 240px">
                            <el-option v-for="item in options" :key="item.value" :label="item.label"
                    <el-form-item label="FTP目录" prop="ftpDirectoryType">
                        <el-select v-model="form.ftpDirectoryType" style="width: 240px">
                            <el-option v-for="item in options.ftpDirectoryType" :key="item.value" :label="item.label"
                                :value="item.value" />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="工作台" prop="userName">
                        <el-select v-model="type" style="width: 240px">
                            <el-option v-for="item in options" :key="item.value" :label="item.label"
                                :value="item.value" />
                <el-col :span="12" v-if="form.ftpDirectoryType == 1">
                    <el-form-item label="关联目录" prop="directoryId">
                        <el-select v-model="form.directoryId" style="width: 240px">
                            <el-option v-for="item in options.directorys" :key="item.id" :label="item.name"
                                :value="item.id" />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="4">
                    <!-- <el-form-item label="工作台" prop="workbenchVOList"> -->
                    <!-- </el-form-item> -->
                    <span>工作台</span>
                </el-col>
                <el-col style="margin-bottom: 14px;">
                    <ul class="workbranch">
                        <li v-for="item in form.workbenchVOList">
                            <span>{{ item.sort}}</span>
                            <el-input v-model="item.name" style="width: 200px"></el-input>
                        </li>
                    </ul>
                    <el-button style="margin-left: 50px;margin-top: 8px" @click="addWork">添加工作台</el-button>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="数据权限" prop="userName">
                        <el-select v-model="type" style="width: 240px">
                            <el-option v-for="item in options" :key="item.value" :label="item.label"
                                :value="item.value" />
                        </el-select>
                    <el-form-item label="数据权限" prop="createDept">
                        <el-tree-select clearable @node-click="nodeClickTree" v-model="form.createDept" :data="tree"  :check-on-click-node="true"
                            style="width: 240px">
                            <template #default="{ data: { title } }">
      {{ title }}</template
    >
                        </el-tree-select>
                    </el-form-item>
                </el-col>
            </el-row>
@@ -155,7 +168,10 @@
                calendarList: this.calendarList,
                linkWays: this.linkWays,
                work_type: this.work_type,
                machining_type: this.machining_type
                machining_type: this.machining_type,
                listnoband: this.listnoband,
                directorys: this.directorys,
                ftpDirectoryType: this.ftpDirectoryType
            }
        }
    },
@@ -172,67 +188,82 @@
            isSaveing: false,
            //表单数据
            form: {
                id: "",
                userName: "",
                avatar: "",
                name: "",
                dept: "",
                group: []
                id: '',
                code: '',
                name: '',
                type: '',
                groupName: '',
                status: '',
                avatar: '',
                calendarCode: '',
                linkWay: '',
                machineId: '',
                machineCode: '',
                machineName: '',
                deviceType: '',
                properties: '',
                transmissionMethod: '',
                ftpDirectoryType: '',
                workbenchVOList: [],
                createDept: '',
            },
            //验证规则
            rules: {
                avatar: [
                    { required: true, message: '请上传头像' }
                ],
                userName: [
                    { required: true, message: '请输入登录账号' }
                code: [
                    { required: true, message: '必填' }
                ],
                name: [
                    { required: true, message: '请输入真实姓名' }
                    { required: true, message: '必填' }
                ],
                password: [
                    { required: true, message: '请输入登录密码' },
                    {
                        validator: (rule, value, callback) => {
                            if (this.form.password2 !== '') {
                                this.$refs.dialogForm.validateField('password2');
                            }
                            callback();
                        }
                    }
                type: [
                    { required: true, message: '必填' }
                ],
                password2: [
                    { required: true, message: '请再次输入密码' },
                    {
                        validator: (rule, value, callback) => {
                            if (value !== this.form.password) {
                                callback(new Error('两次输入密码不一致!'));
                            } else {
                                callback();
                            }
                        }
                    }
                groupName: [
                    { required: true, message: '必填' }
                ],
                dept: [
                    { required: true, message: '请选择所属部门' }
                status: [
                    { required: true, message: '必填' }
                ],
                group: [
                    { required: true, message: '请选择所属角色', trigger: 'change' }
                ]
                linkWay:[
                    { required: true, message: '必填' }
                ],
                machineId:[
                    { required: true, message: '必填' }
                ],
                directoryId:[
                    { required: true, message: '必填' }
                ],
            },
            //所需数据选项
            calendarList: [],
            work_type: [],
            machining_type: [],
            listnoband: [],
            directorys: [],
            ftpDirectoryType: [
                {
                    label: '不关联目录',
                    value: 0
                },
                {
                    label: '关联目录',
                    value: 1
                },
                {
                    label: '创建同名目录',
                    value: 2
                },
            ],
            linkWays: [
                {
                    label: '关联机器',
                    value: '0'
                    value: 0
                }, {
                    label: '创建同名机器',
                    value: '1'
                    value: 1
                }
            ]
            ],
            tree: []
        }
    },
    created() {
@@ -245,13 +276,40 @@
        this.$API.system.dic.getDic.get({ code: 'machining_type' }).then(res => {
            this.machining_type = res.data
        })
        this.$API.workstation.getlistnoband.get().then(res => {
            this.listnoband = res.data
        })
        this.$HTTP.get(`/api/blade-system/data-scope-manager/tree`).then(res => {
            this.tree = res.data.map(item => {
                return {
                    ...item,
                    label: item.title
                }
            })
        })
    },
    methods: {
        //显示
        open(mode = 'add', params) {
            this.mode = mode;
            this.visible = true;
            this.params = params
            if (params) {
                Object.keys(this.form).forEach(key => {
                    this.form[key] = params[key]
                })
                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 => {
                        this.form.workbenchVOList =res?.data?.workstationList || []
                    })
                })
            }else {
                this.form.id = ''
                Object.keys(this.form).forEach(key => {
                    this.form[key] = ''
                })
            }
            return this
        },
        //表单提交方法
@@ -259,7 +317,7 @@
            this.$refs.dialogForm.validate(async (valid) => {
                if (valid) {
                    this.isSaveing = true;
                    var res = await this.$API.demo.post.post(this.form);
                    var res = await this.$API.workstation.add.post(this.form);
                    this.isSaveing = false;
                    if (res.code == 200) {
                        this.$emit('success', this.form, this.mode)
@@ -279,14 +337,69 @@
            this.form.userName = data.userName
            this.form.avatar = data.avatar
            this.form.name = data.name
            this.form.group = data.group
            this.form.dept = data.dept
            //可以和上面一样单个注入,也可以像下面一样直接合并进去
            //Object.assign(this.form, data)
        },
        change (id) {
            let row = this.options.listnoband.find(v=>v.id ==id)
            if (!row)  {
                this.form.machineCode = ''
                this.form.machineId = ''
                this.form.machineName = ''
            }else {
                this.form.machineCode = row.machineCode
                this.form.machineId = row.id
                this.form.machineName = row.machineName
            }
            this.$HTTP.get(`/api/blade-dnc/ftp-director/get-machine-of-workstation-ftp?id=${this.form.machineId}`).then(res => {
                this.directorys = res.data
            })
            console.log(row)
        },
        nodeClick (node) {
            console.log(node)
            if (node.parentId == 0) return
            this.$nextTick(() => {
                this.form.groupId = node.id
                this.form.groupName = node.name
            })
        },
        nodeClickTree (node) {
            this.$nextTick(() => {
                this.form.createDept = node.id
            })
        },
        addWork () {
            this.form.workbenchVOList.push({
                sort: this.form.workbenchVOList.length + 1,
                name: ''
            })
        }
    }
}
</script>
<style></style>
<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/index.vue
@@ -19,7 +19,7 @@
                            <el-header>
                                <div class="left-panel">
                                    <el-button @click="table_add" type="primary" icon="el-icon-plus"></el-button>
                                    <el-button type="danger" plain icon="el-icon-delete"></el-button>
                                    <el-button type="danger" plain icon="el-icon-delete" @click="batchDel"></el-button>
                                    <!-- <el-button type="primary" plain>导入</el-button>
                                    <el-button type="primary" plain>批量操作</el-button> -->
                                </div>
@@ -64,12 +64,12 @@
                                                        <el-button text type="primary" size="small">删除</el-button>
                                                    </template>
                                                </el-popconfirm>
                                                <el-popconfirm title="确定停用吗?"
                                                <!-- <el-popconfirm title="确定停用吗?"
                                                    @confirm="table_del(scope.row, scope.$index,'1')">
                                                    <template #reference>
                                                        <el-button text type="primary" size="small">停用</el-button>
                                                    </template>
                                                </el-popconfirm>
                                                </el-popconfirm> -->
                                            </el-button-group>
                                        </template>
                                    </el-table-column>
@@ -85,9 +85,9 @@
                                                <li>工位编号 {{previewData.code}}</li>
                                                <li>工位组 {{previewData.groupName}}</li>
                                                <li>工位名称 {{previewData.name}}</li>
                                                <li>工位类型 {{previewData.type}}</li>
                                                <li>工位类型 {{types.find(v => v.value == previewData.type)?.label}}</li>
                                                <li>工位日历 {{previewData.calendarName}}</li>
                                                <li>状态 {{previewData.status}}</li>
                                                <li>状态 {{previewData.status ? '启用' : '禁用'}}</li>
                                            </ul>
                                        </div>
                                        <el-tabs tab-position="top" class="custom-tabs" v-model="normal">
@@ -237,7 +237,7 @@
            </el-tabs>
        </el-card>
        <Dialog ref="dialog" :option="{types,status,group}"></Dialog>
        <Dialog ref="dialog" @success="success" :option="{types,status,group}"></Dialog>
    </el-main>
</template>
@@ -263,29 +263,25 @@
            params: {},
            keyWord: '',
            type: '',
            statu: '1',
            statu: 1,
            types: [
                {
                    label: '所有',
                    value: ''
                },
                {
                    label: '机器',
                    value: '0'
                    value: 0
                },
                {
                    label: '人工',
                    value: '1'
                    value: 1
                },
            ],
            status: [
                {
                    label: '启用',
                    value: '1'
                    value: 1
                },
                {
                    label: '停用',
                    value: '0'
                    value: 0
                }
            ],
            previewData: {},
@@ -305,7 +301,8 @@
            treeCheckKey: [],
            beltline_type: [],
            group_tag: [],
            addGroupShow: false
            addGroupShow: false,
            selection: []
        }
    },
    watch: {
@@ -360,6 +357,9 @@
                this.group_tag = res.data
            })
        },
        success () {
            this.search()
        },
        async queryList(flag) {
            this.showGrouploading = true
@@ -483,13 +483,18 @@
            this.$refs.dialog.open('edit',row)
        },
        table_del(row, index,type) {
            this.$API.workstation.deleteWork.delete({
                type,
                workstationIds:row.id
            }).then(() => {
            this.$HTTP.delete(`/api/blade-cps/workstation?type=0&workstationIds=${row.id}`).then(res => {
                this.search()
            })
        },
        selectionChange (selection) {
            this.selection = selection
        },
        batchDel () {
            this.$HTTP.delete(`/api/blade-cps/workstation?type=0&workstationIds=${this.selection.map(item => item.id).join(',')}`).then(res => {
                this.search()
            })
        }
    }
}
</script>
src/views/mdc/configuration.vue
@@ -1,24 +1,100 @@
<!--
 * @Date: 2024-04-09 22:11:21
 * @LastEditors: Sneed
 * @LastEditTime: 2024-04-13 22:15:00
 * @LastEditTime: 2024-04-14 10:31:10
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/configuration.vue
 * 应用设置
-->
<template>
    <el-main>
        <el-card shadow="never">
            应用设置
            <el-tabs :tab-position="'left'" class="demo-tabs">
                <el-tab-pane label="实时看板查询组设置">
                    <el-row>
                        <el-col :span="4">
                            页面排列方式
                        </el-col>
                        <el-col :span="20">
                            <el-radio-group v-model="radio">
                                <el-radio :value="1">充满屏幕</el-radio>
                                <el-radio :value="2">设置行列</el-radio>
                            </el-radio-group>
                        </el-col>
                        <el-col :span="4">
                            设置行数
                        </el-col>
                        <el-col :span="20">
                            <el-input-number v-model="num" :min="1" :max="10" @change="handleChange" />
                        </el-col>
                        <el-col :span="4">
                            设置列数
                        </el-col>
                        <el-col :span="20">
                            <el-input-number v-model="num" :min="1" :max="10" @change="handleChange" />
                        </el-col>
                        <el-col>
                            下面陈列拥有标签的所有工位组,请选择需要在实时看板页面查询的组,并设定一个默认组
                            如果未配置查询组,实时工况页面默认查询所有工位
                        </el-col>
                        <el-col>
                            柔性产线
                        </el-col>
                        <el-col>
                            <el-card style="max-width: 480px">
                                <template #header>
                                <div class="card-header">
                                    <span>千文科技</span>
                                </div>
                                </template>
                                <p>所有的> 千文科技</p>
                            </el-card>
                        </el-col>
                        <el-col>
                            车间
                        </el-col>
                        <el-col>
                            <el-card style="max-width: 480px">
                                <template #header>
                                <div class="card-header">
                                    <span>千文科技</span>
                                </div>
                                </template>
                                <p>所有的> 千文科技</p>
                            </el-card>
                            <el-card style="max-width: 480px">
                                <template #header>
                                <div class="card-header">
                                    <span>千文科技</span>
                                </div>
                                </template>
                                <p>所有的> 千文科技</p>
                            </el-card>
                        </el-col>
                    </el-row>
                </el-tab-pane>
                <el-tab-pane label="状态和绩效时间设置">
                </el-tab-pane>
                <el-tab-pane label="效率统计设置">
                </el-tab-pane>
                <el-tab-pane label="采集数据标签设置">
                </el-tab-pane>
            </el-tabs>
        </el-card>
    </el-main>
</template>
<script>
    export default {
    }
export default {
    data() {
        return {
        }
    },
}
</script>
<style lang="scss" scoped>
</style>
<style lang="scss" scoped></style>