node configure增改接近完成,删除后端还没做

This commit is contained in:
Yu Sun
2022-07-07 01:27:45 +08:00
parent 331a941941
commit e018f19f09
189 changed files with 25627 additions and 9 deletions

View File

@@ -0,0 +1,228 @@
<template>
<d2-container>
<d2-crud
ref="d2Crud"
:columns="columns"
:data="data"
:rowHandle="rowHandle"
add-title="新增节点"
edit-title="修改节点信息"
:add-template="addTemplate"
:edit-template="editTemplate"
:form-options="formOptions"
:add-rules="addRules"
@row-add="handleRowAdd"
@row-edit="handleRowEdit"
@row-remove="handleRowRemove"
@dialog-cancel="handleDialogCancel">
<el-button slot="header" style="margin-bottom: 5px" @click="addRow">新增</el-button>
</d2-crud>
</d2-container>
</template>
<script>
import { assign, each, pickBy, startsWith } from 'lodash'
export default {
data () {
return {
columns: [
{
title: '序号',
key: 'id'
},
{
title: '节点编码',
key: 'code'
},
{
title: '节点名称',
key: 'name'
},
{
title: '类型',
key: 'type'
},
{
title: '流程',
key: 'flow_code'
},
{
title: '工序编码',
key: 'process_code'
},
{
title: '工作站',
key: 'workstation'
},
{
title: '创建时间',
key: 'create_time'
},
{
title: '备注',
key: 'note'
}
],
data: [],
rowHandle: {
minWidth: '200',
edit: {
icon: 'el-icon-edit',
text: '编辑',
size: 'small',
show (index, row) {
if (row.showEditButton) {
return true
}
return false
}
},
remove: {
icon: 'el-icon-delete',
size: 'small',
fixed: 'right',
confirm: true,
show (index, row) {
if (row.showRemoveButton) {
return true
}
return false
}
}
},
addTemplate: {
code: {
title: '节点编码'
},
name: {
title: '节点名称'
},
type: {
title: '类型',
value: '',
component: {
name: 'el-select',
options: [
{
value: 'text',
label: '字符串'
},
{
value: 'int',
label: '整数'
},
{
value: 'float8',
label: '浮点数'
},
{
value: 'bool',
label: '逻辑值'
}
],
span: 12
}
},
flow_code: {
title: '流程'
},
process_code: {
title: '工序编码'
},
workstation: {
title: '工作站'
},
note: {
title: '备注'
}
},
editTemplate: {
name: {
title: '节点名称'
},
flow_code: {
title: '流程'
},
workstation: {
title: '工作站'
},
note: {
title: '备注'
}
},
formOptions: {
labelWidth: '80px',
labelPosition: 'left',
saveLoading: false
},
addRules: {
code: [{ required: true, type: 'string', message: '节点编码必须填写', trigger: 'blur' }],
name: [{ required: true, type: 'string', message: '节点名称必须填写', trigger: 'blur' }],
type: [{ required: true, message: '必须指定节点类型', trigger: 'blur' }],
process_code: [{ required: true, type: 'string', message: '工序编码必须填写', trigger: 'blur' }]
}
}
},
methods: {
async getNodes () {
try {
const res = await this.$api.QUERY_NODE()
this.data = each(res, (o) => (
assign(o, {
showEditButton: true,
showRemoveButton: true
})
))
} catch (e) {
console.log(e)
}
},
// 普通的新增
addRow () {
this.$refs.d2Crud.showDialog({
mode: 'add'
})
},
async handleRowAdd (row) {
this.formOptions.saveLoading = true
await this.$api.ADD_NODE(assign(row, { action: 'add_node' }))
this.$message({
message: '添加成功',
type: 'success'
})
this.formOptions.saveLoading = false
},
async handleRowEdit ({ index, row }) {
this.formOptions.saveLoading = true
await this.$api.UPDATE_NODE(assign(pickBy(row, (v, k) => (!startsWith(k, 'show'))), { action: 'update_node' }))
this.$message({
message: '编辑成功',
type: 'success'
})
this.formOptions.saveLoading = false
},
handleRowRemove ({ index, row }, done) {
setTimeout(() => {
console.log(index)
console.log(row)
this.$message({
message: '删除成功',
type: 'success'
})
done()
}, 300)
},
handleDialogCancel (done) {
this.$message({
message: '取消保存',
type: 'warning'
})
done()
}
},
mounted () {
this.getNodes()
}
}
</script>

View File