<!--
|
* @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>
|