You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

334 lines
11 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div class="container">
<!-- 查询配置 -->
<div>
<div ref="lxHeader">
<LxHeader icon="md-apps" :text="$route.meta.title" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
<div slot="content"></div>
<slot>
<div>
<!-- <Button type="primary" @click="load"></Button> -->
<Button type="primary" @click="edit()" style="margin-left: 10px">add parameter</Button>
</div>
</slot>
</LxHeader>
</div>
<div class="table-tree">
<el-table :data="tableData" :height="tableHeight" class="v-table" style="width: 100%;margin-bottom: 20px;"
row-key="id" border default-expand-all :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
<el-table-column type="index" align="center">
</el-table-column>
<el-table-column prop="number" label="Parameter Encoding" sortable width="180">
</el-table-column>
<el-table-column prop="name" label="Parameter Name" sortable width="220">
</el-table-column>
<el-table-column prop="remark" label="Remark" sortable>
</el-table-column>
<el-table-column prop="sort" align="center" label="Sort" sortable width="80">
</el-table-column>
<el-table-column fixed="right" label="Operate" width="300">
<template slot-scope="scope">
<!-- <Button type="primary" @click="addchildren(scope.row)" size="small" style="margin-left: 10px;"
ghost>next level</Button> -->
<Button type="primary" @click="edit(scope.row)" size="small" style="margin-left: 10px;" ghost>edit</Button>
<Button type="error" @click="del(scope.row)" size="small" style="margin-left: 10px;" ghost>delete</Button>
</template>
</el-table-column>
</el-table>
</div>
</div>
<el-dialog title="Edit Parameter" :visible.sync="dialogFormVisible" width="80%">
<el-form :model="form" :rules="rules" ref="form" label-position="right" :label-width="formLabelWidth">
<el-row :gutter="20">
<el-col :span="6">
<el-form-item label="Parent Id">
<el-input v-model="form.pid" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="Parent Name">
<el-input v-model="form.pname" disabled autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="Parameter Encoding" prop="number">
<el-input v-model="form.number" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="Parameter Name" prop="name">
<el-input v-model="form.name" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="Visible" prop="status">
<el-select v-model="form.status">
<el-option label="Yse" value="1"></el-option>
<el-option label="No" value="0"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="Sort">
<el-input v-model="form.sort" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="Remark">
<el-input v-model="form.remark" type="textarea" autocomplete="off"></el-input>
</el-form-item>
</el-col>
</el-row>
<div class="table-tree">
<div style="display: flex;justify-content: flex-end;margin-right: 20px;margin-bottom: 10px;">
<Button type="primary" @click="addRow()" size="small" style="margin-left: 10px;" ghost>Add Row</Button>
</div>
<el-table :data="this.form.detail_list" height="400" class="v-table" style="width: 100%;margin-bottom: 20px;">
<el-table-column type="index" align="center">
</el-table-column>
<el-table-column prop="id" align="center" label="ID" width="120">
</el-table-column>
<el-table-column prop="value" label="Value" width="320">
<template slot-scope="scope">
<el-input v-model="scope.row.value" >
</el-input>
</template>
</el-table-column>
<el-table-column prop="sort" align="center" label="sort" width="80">
<template slot-scope="scope">
<el-input v-model="scope.row.sort" >
</el-input>
</template>
</el-table-column>
<el-table-column prop="status" align="center" label="Available" width="180">
<template slot-scope="scope">
<el-switch v-model="scope.row.status" >
</el-switch>
</template>
</el-table-column>
<el-table-column prop="remark" label="Remark">
<template slot-scope="scope">
<el-input v-model="scope.row.remark" >
</el-input>
</template>
</el-table-column>
<el-table-column label="Operate" width="100" align="center">
<template slot-scope="scope">
<Button type="error" @click="delRow(scope.row,scope.$index)" size="small" style="margin-left: 10px;"
ghost>delete</Button>
</template>
</el-table-column>
</el-table>
</div>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="resetForm('form')">cancel</el-button>
<el-button type="primary" @click="submitForm('form')">confirm</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import LxHeader from "@/components/LxHeader/index.vue";
import {
save,
listparameter,
del,
store,
getparameter,
delDetail
} from "../../api/system/dictionary.js";
export default {
components: {
LxHeader
},
created() {
this.initLoad();
this.load();
},
mounted() {},
data() {
return {
dialogFormVisible: false,
formLabelWidth: "120px",
form: {
pname: "Root Level",
number: "",
id: "",
pid: "0",
name: "",
status: "1",
sort: 0,
remark: "",
detail_list: [{
id: "",
value: "",
sort: "1",
status: true,
remark: ""
}]
},
rules: {
name: [{
required: true,
message: 'Please Input',
trigger: 'blur'
}],
url: [{
required: true,
message: 'Please Input',
trigger: 'blur'
}],
visible: [{
required: true,
message: 'Please Select',
trigger: 'blur'
}],
},
tableHeight: 0,
//查询条件字段
searchFields: {
KeyWord: ""
},
tableData: []
}
},
methods: {
addRow() {
var len = this.form.detail_list.length;
this.form.detail_list.push({
value: "",
sort: len + 1,
status: true,
remark: ""
})
},
delRow(obj, index) {
if (obj.id) {
delDetail(obj.id).then(response => {
this.$message.success("Success");
this.form.detail_list.splice(index, 1);
}).catch(error => {
//reject(error)
this.$message.error("Error");
})
} else {
this.form.detail_list.splice(index, 1);
}
},
initLoad() {
var that = this;
var clientHeight = document.documentElement.clientHeight
var lxHeader_height = 96.5; //查询 头部
var paginationHeight = 37; //分页的高度
var topHeight = 50; //页面 头部
let tableHeight = clientHeight - lxHeader_height - topHeight - paginationHeight - 20;
that.tableHeight = tableHeight;
},
load() {
var that = this;
listparameter().then(response => {
that.tableData = response.data;
}).catch(error => {
//reject(error)
})
},
show(obj) {
this.clientHeight = document.documentElement.clientHeight - 84 - 110;
this.dialogViewVisible = true;
this.info(obj);
},
info(obj) {
var that = this;
getparameter({
id: obj.id
}).then(response => {
for (var m of response.detail) {
m.status = m.status == 1;
}
response.detail_list = response.detail;
let result = Object.assign(that.form, response);
that.form.status = result.status.toString();
}).catch(error => {
//reject(error)
})
},
edit(obj) {
this.form = this.$options.data().form;
this.clientHeight = document.documentElement.clientHeight - 84 - 110;
if (obj) {
var that = this;
that.info(obj);
} else {}
this.dialogFormVisible = true;
},
addchildren(obj) {
this.form = this.$options.data().form
if (obj) {
this.form.pname = obj.name;
this.form.pid = obj.id;
this.dialogFormVisible = true;
}
},
submitForm(formName) {
var that = this;
this.$refs[formName].validate((valid) => {
if (valid) {
if (that.form.id) {
save(that.form).then(response => {
console.log(response)
this.$Message.success('Success');
that.dialogFormVisible = false;
that.load();
}).catch(error => {})
} else {
store(that.form).then(response => {
console.log(response)
this.$Message.success('Success');
that.dialogFormVisible = false;
that.load();
}).catch(error => {})
}
} else {
this.$Message.error('Error');
return false;
}
});
},
resetForm(formName) {
var that = this;
this.$refs[formName].resetFields();
that.dialogFormVisible = false;
},
del(obj) {
var that = this;
if (obj) {
this.$Modal.confirm({
title: 'Are you sure to delete it',
onOk: () => {
del(obj.id).then(response => {
this.$Message.success('Success');
that.load();
}).catch(error => {
console.log(error)
reject(error)
})
},
onCancel: () => {
//this.$Message.info('Clicked cancel');
}
});
}
},
}
};
</script>