gaoshp
2024-04-01 df220d8a73a149ee83908120a649f630dc6794f7
主数据-机器-工位采集模板
已添加2个文件
已修改1个文件
236 ■■■■■ 文件已修改
src/api/model/workingCondition.js 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/console/basic-data/working-condition/index.vue 187 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/console/workstation/Dialog.vue 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/model/workingCondition.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,47 @@
/*
 * @Date: 2024-03-24 11:37:47
 * @LastEditors: gaoshp
 * @LastEditTime: 2024-04-01 21:44:49
 * @FilePath: /cps-web/src/api/model/workingCondition.js
 */
import config from "@/config"
import http from "@/utils/request"
export default {
    getList: {
        url: `${config.API_URL}/blade-cps/workstation-wcs/listWcsSetting`,
        name: "获取工位采集列表",
        get: async function(params){
            return await http.get(this.url, params);
        },
    },
    getwcsUsageList: {
        url: `${config.API_URL}/blade-cps/workstation-wcs-usage/list`,
        name: "获取数据标签",
        get: async function(params){
            return await http.get(this.url, params);
        },
    },
    save: {
        url: `${config.API_URL}/blade-cps/workstation-wcs/save/setting`,
        name: "保存",
        post: async function(params){
            return await http.post(this.url, params);
        },
    },
    update: {
        url: `${config.API_URL}/blade-cps/workstation-wcs/update`,
        name: "更新",
        post: async function(params){
            return await http.put(this.url, params);
        },
    },
    del: {
        url: `${config.API_URL}/blade-cps/workstation-wcs`,
        name: "删除",
        post: async function(params,data){
            return await http.delete(this.url, params,{data});
        },
    }
}
src/views/console/basic-data/working-condition/index.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,187 @@
<!--
 * @Date: 2024-04-01 20:28:18
 * @LastEditors: gaoshp
 * @LastEditTime: 2024-04-01 21:50:06
 * @FilePath: /cps-web/src/views/console/basic-data/working-condition/index.vue
-->
<template>
    <el-container>
        <el-header style="justify-content:flex-start">
            <el-button @click="table_add" type="primary" icon="el-icon-plus"></el-button>
            <el-button type="danger" plain icon="el-icon-delete" @click="batchDel"></el-button>
        </el-header>
        <el-main>
            <el-table v-bind="$attrs" :data="tableData" :row-key="rowKey" :border="true" :stripe="true"
                @selection-change="selectionChange">
                <el-table-column type="selection" />
                <el-table-column prop="dataItem" label="工位变量名称" />
                <el-table-column prop="dataTypeDesc" label="数据标签" />
                <el-table-column prop="usageName" label="计算方法" />
                <el-table-column prop="collectSettingItem" label="采集变量名称" />
                <el-table-column label="操作" fixed="right" align="right" width="160">
                    <template #default="scope">
                        <el-button-group>
                            <el-button text type="primary" size="small"
                                @click="table_edit(scope.row, scope.$index)">编辑</el-button>
                            <el-popconfirm title="确定删除吗?" @confirm="table_del(scope.row, scope.$index, '0')">
                                <template #reference>
                                    <el-button text type="primary" size="small">删除</el-button>
                                </template>
                            </el-popconfirm>
                        </el-button-group>
                    </template>
                </el-table-column>
            </el-table>
        </el-main>
        <el-drawer v-model="drawer" title="新建" :before-close="handleClose">
            <el-form :model="form" :rules="rules" :disabled="mode == 'show'" ref="dialogForm" label-width="120px"
                label-position="center">
                <el-row>
                    <el-col :span="24">
                        <el-form-item label="工位变量名称" prop="dataItem">
                            <el-input style="width: 240px" v-model="form.dataItem" placeholder="工位变量名称"
                                clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="数据标签" prop="usageId">
                            <el-select v-model="form.usageId" clearable placeholder="数据标签" style="width: 240px">
                                <el-option v-for="item in workstation_param_type" :key="item.id" :label="item.usageName"
                                    :value="item.id" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="采集变量名称" prop="collectSettingItem">
                            <el-input style="width: 240px" v-model="form.collectSettingItem" placeholder="采集变量名称"
                                clearable></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <template #footer>
                <div style="flex: auto">
                    <el-button @click="cancelClick">cancel</el-button>
                    <el-button type="primary" @click="confirmClick">confirm</el-button>
                </div>
            </template>
        </el-drawer>
    </el-container>
</template>
<script>
import config from "@/config/table";
export default {
    data() {
        return {
            config,
            tableData: [],
            workstation_param_type: [],
            drawer: false,
            form: {
                dataItem: '',
                usageId: '',
                collectSettingItem: ''
            },
            rules: {
                dataItem: [
                    { required: true, message: '请输入工位变量名称' }
                ],
                usageId: [
                    { required: true, message: '请选择数据标签' }
                ],
                collectSettingItem: [
                    { required: true, message: '请输入采集变量名称' }
                ],
            },
            selection: []
        }
    },
    created() {
        this.init()
    },
    methods: {
        init() {
            this.$API.workingCondition.getwcsUsageList.get().then(res => {
                this.workstation_param_type = res.data
            })
            this.$API.workingCondition.getList.get().then(res => {
                if (res.code == 200) {
                    this.tableData = res.data
                }
            })
        },
        batchDel() {
            console.log(this.selection)
            this.$API.workingCondition.del.post(
                {}, this.selection.map(v => v.id)
            ).then(res => {
                this.drawer = false
                this.init()
            })
        },
        selectionChange(selection) {
            this.selection = selection
        },
        table_add() {
            this.row = {}
            this.drawer = true
            this.$nextTick(() => {
                this.$refs.dialogForm.resetFields()
            })
        },
        table_edit(row) {
            this.row = row
            this.form.dataItem = row.dataItem
            this.form.usageId = row.usageId
            this.form.collectSettingItem = row.collectSettingItem
            this.drawer = true
        },
        table_del(row) {
            this.$API.workingCondition.del.post(
                {}, [row.id]
            ).then(res => {
                this.drawer = false
                this.init()
            })
        },
        cancelClick() {
            this.drawer = false
        },
        confirmClick() {
            let { collectType: dataType } = this.workstation_param_type.find(v => v.id === this.form.usageId)
            this.$refs.dialogForm.validate().then(res => {
                if (res) {
                    if (!this.row.id) {
                        this.$API.workingCondition.save.post([
                            {
                                ...this.form,
                                dataType
                            }
                        ]).then(res => {
                            this.drawer = false
                            this.init()
                        })
                    } else {
                        this.$API.workingCondition.update.post(
                            {
                                ...this.row,
                                ...this.form,
                                dataType
                            }
                        ).then(res => {
                            this.drawer = false
                            this.init()
                        })
                    }
                }
            })
        },
    }
}
</script>
<style lang="scss" scoped></style>
src/views/console/workstation/Dialog.vue
@@ -254,8 +254,6 @@
            this.params = params
            return this
        },
        //表单提交方法
        submit() {
            this.$refs.dialogForm.validate(async (valid) => {