刘翔宇-旅管家 4 years ago
parent 0cdcb72f29
commit 40719aa2ea

@ -0,0 +1,57 @@
import request from '@/utils/request'
export function listaccidentparameters(params) {
return request({
url: '/api/admin/accident/parameters',
method: 'get',
params:params
})
}
export function listaccident(params) {
return request({
url: '/api/admin/accident/index',
method: 'get',
params:params
})
}
export function store(data) {
return request({
url: '/api/admin/accident/store',
method: 'post',
data
})
}
export function save(data) {
return request({
url: '/api/admin/accident/save',
method: 'post',
data
})
}
export function del(id) {
return request({
url: '/api/admin/accident/destroy',
method: 'get',
params: {
id
}
})
}
export function get(id) {
return request({
url: '/api/admin/accident/show',
method: 'get',
params: {
id
}
})
}

@ -0,0 +1,50 @@
import request from '@/utils/request'
export function save(data) {
return request({
url: '/api/admin/parameter/save',
method: 'post',
data
})
}
export function store(data) {
return request({
url: '/api/admin/parameter/store',
method: 'post',
data
})
}
export function getparameter(param) {
return request({
url: '/api/admin/parameter/show',
method: 'get',
params: param
})
}
export function listparameter(param) {
return request({
url: '/api/admin/parameter/index',
method: 'get',
params: param
})
}
export function del(id) {
return request({
url: '/api/admin/parameter/delete',
method: 'get',
params: {
id
}
})
}
export function delDetail(id) {
return request({
url: '/api/admin/parameter/detail-delete',
method: 'get',
params: {
id
}
})
}

@ -16,6 +16,8 @@
}
// to fixed https://github.com/ElemeFE/element/issues/2461
.el-dialog {
transform: none;

@ -1,8 +1,414 @@
<template>
</template>
<script>
</script>
<style>
<template>
<div class="container">
<!-- 查询配置 -->
<div style="padding: 0px 20px">
<div ref="lxHeader">
<LxHeader icon="md-apps" text="事故上报" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
<div slot="content"></div>
<slot>
<div>
<Input style="width: 200px; margin-right: 10px" v-model="searchFields.KeyWord" placeholder="关键字搜索" />
<Button type="primary" @click="load" style="margin-left: 10px">查询</Button>
<Button type="primary" @click="edit()" style="margin-left: 10px">新增</Button>
</div>
</slot>
</LxHeader>
</div>
<div ref="lxTable">
<el-table :data="tableData" :height="tableHeight" style="width: 100%">
<el-table-column type="index" width="50" align="center"> </el-table-column>
<el-table-column :prop="column.field" :align="column.align" v-for="(column,index) in columns"
:label="column.title" :width="column.width">
<template slot-scope="scope">
<div v-if="column.type == 'img'">
<img v-for="(file, vIndex) in getFilePath( scope.row[column.field], column)" :key="vIndex"
@click="viewImg(scope.row, column, file.path)" class="table-img" :src="file.path" />
</div>
<div v-else-if="column.type=='format'">
<div v-if="column.field=='task_departments_report'">
<el-link type="primary">
{{scope.row["safety_task_departments_count"]+"/"+scope.row["safety_task_departments_report_count"]}}
</el-link>
</div>
<div v-if="column.field=='task_departments'">
<el-tag v-for="(tag, tIndex) in scope.row['safety_task_departments']"
style="margin-right: 5px;margin-bottom: 5px;">
{{tag.departments.name}}
</el-tag>
</div>
</div>
<div v-else-if="column.type=='opt'">
<Button ghost size="small" @click="edit(scope.row)" type="primary"
style="margin-left: 10px;">编辑</Button>
<Button ghost size="small" @click="del(scope.row)" type="error" style="margin-left: 10px;">删除</Button>
</div>
<div v-else>{{scope.row[column.field]}}</div>
</template>
</el-table-column>
</el-table>
<div class="pagination">
<el-pagination @current-change="handleCurrentChange" :current-page="paginations.page"
:page-size="paginations.page_size" background layout="prev, pager, next" :total="paginations.total">
</el-pagination>
</div>
</div>
</div>
<el-dialog title="任务编辑" :visible.sync="dialogFormVisible" fullscreen width="90%">
<div class="dialogConcent" :style="{height:clientHeight+'px'}">
<el-scrollbar style="flex: 1">
<el-form :model="form" :rules="rules" ref="form" label-position="right" :label-width="formLabelWidth">
<el-form-item label="任务名称" prop="title">
<el-input v-model="form.title" placeholder="请填写任务名称" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="任务日期" prop="daterange">
<el-date-picker type="datetimerange" v-model="form.daterange" value-format="yyyy-MM-dd HH:mm:ss"
range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="内容" prop="content">
<div style="width: 99.9%;">
<tinymce v-model="form.content" :height="300" />
</div>
</el-form-item>
<el-form-item label="附件" prop="file_list">
<el-upload class="upload-demo" :on-success="handlesuccess" :data="uploadOther"
action="/api/admin/upload-file" :on-remove="handleRemove" :before-remove="beforeRemove"
:on-exceed="handleExceed" :file-list="fileList">
<el-button size="small" type="primary">点击上传</el-button>
</el-upload>
</el-form-item>
<el-form-item label="科室" prop="department_list">
<el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">
</el-checkbox>
<div style="margin: 15px 0;"></div>
<el-checkbox-group v-model="form.department_list" @change="handleCheckedDeptChange">
<el-checkbox v-for="dept in deptOptions" :label="dept.id" :key="dept.id">{{dept.name}}</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-form>
</el-scrollbar>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="resetForm('form')"> </el-button>
<el-button type="primary" v-preventReClick @click="submitForm('form')"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
getToken
} from '@/utils/auth'
import LxHeader from "@/components/LxHeader/index.vue";
import Tinymce from '@/components/Tinymce'
import {
save,
store,
del,
get,
listtask
} from "../../api/accident/index.js";
import {
listdept
} from "../../api/system/department.js"
export default {
components: {
LxHeader,
Tinymce
},
data() {
return {
checkAll: false,
isIndeterminate: true,
paginations: {
page: 1,
page_size: 15,
total: 0
},
tableHeight: 0,
dialogFormVisible: false,
formLabelWidth: "120px",
clientHeight: 0,
form: {
title: "",
content: "",
file_list: "",
start_date: "",
end_date: "",
department_list: [],
daterange: null
},
fileList: [],
tableData: [],
rules: {
title: [{
required: true,
message: '请输入标题',
trigger: 'blur'
}],
department_list: [{
required: true,
message: '请选择科室',
trigger: 'blur'
}],
daterange: [{
required: true,
message: '请选择日期区间',
trigger: 'blur'
}]
},
indexUrl: "/api/admin/task/index",
tableHeight: 900,
searchFields: {
KeyWord: ""
},
columns: [{
field: "title",
title: "任务名称",
type: "string",
width: 280
},
{
field: "start_date",
title: "开始时间",
type: "date",
width: 160,
align: "center"
},
{
field: "end_date",
title: "结束时间",
type: "date",
width: 160,
align: "center"
},
{
field: "task_departments",
title: "科室",
type: "format",
align: "left"
},
{
field: "task_departments_report",
title: "上报(全部/已上报)",
type: "format",
width: 180,
align: "center"
},
{
field: "操作",
title: "操作",
width: 220,
type: "opt",
}
],
uploadOther: {
token: ""
},
deptOptions: []
}
},
created() {
this.uploadOther.token = getToken();
this.loadDeptOptions();
this.initLoad();
this.load();
},
methods: {
loadDeptOptions() {
listdept().
then((res) => {
this.deptOptions = res;
}).catch(error => {
console.log(error)
reject(error)
})
},
handleCheckAllChange(val) {
console.log(val)
let options = [];
for (var m of this.deptOptions) {
options.push(m.id);
}
this.form.department_list = val ? options : [];
this.isIndeterminate = false;
},
handleCheckedDeptChange(value) {
let checkedCount = value.length;
this.checkAll = checkedCount === this.deptOptions.length;
this.isIndeterminate = checkedCount > 0 && checkedCount < this.deptOptions.length;
},
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;
},
handleCurrentChange(page) {
this.paginations.page = page;
this.load();
},
load() {
listtask({
page: this.paginations.page,
page_size: this.paginations.page_size,
}).then(response => {
this.tableData = response.data;
this.paginations.page_size = response.total;
}).catch(error => {
console.log(error)
reject(error)
})
},
del(obj) {
var that = this;
if (obj) {
this.$Modal.confirm({
title: '确认要删除数据?',
onOk: () => {
del(obj.id).then(response => {
this.$Message.success('操作成功');
that.load();
}).catch(error => {
console.log(error)
reject(error)
})
},
onCancel: () => {
//this.$Message.info('Clicked cancel');
}
});
}
},
show(obj) {
this.clientHeight = document.documentElement.clientHeight - 84 - 110;
this.dialogViewVisible = true;
this.info(obj);
},
info(obj) {
var that = this;
get(obj.id).then(res => {
let result = Object.assign(that.form, res);
that.form = result;
let _files = [];
for (var mod of result.files) {
let m = Object.assign({}, mod);
m.name = mod.original_name;
_files.push(m);
}
that.form.daterange = [res.start_date, res.end_date];
for (var m of res.safety_task_departments) {
that.form.department_list.push(m.department_id);
}
that.fileList = _files;
}).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;
},
submitForm(formName) {
var that = this;
this.$refs[formName].validate((valid) => {
if (valid) {
that.form.start_date = that.form.daterange[0];
that.form.end_date = that.form.daterange[1];
if (that.form.id) {
that.form.safety_task_id = that.form.id;
save(that.form).then(response => {
//console.log(response)
this.$Message.success('操作成功');
that.load();
that.dialogFormVisible = false;
}).catch(error => {
//reject(error)
})
} else {
store(that.form).then(response => {
//console.log(response)
this.$Message.success('操作成功');
that.load();
that.dialogFormVisible = false;
}).catch(error => {
//reject(error)
})
}
that.fileList = [];
} else {
this.$Message.error('数据校验失败');
console.log('error submit!!');
return false;
}
});
},
handleRemove(file, fileList) {
console.log(fileList);
let listUrl = [];
for (var m of fileList) {
if (m.response)
listUrl.push(m.response.id);
else
listUrl.push(m.id);
}
this.form.file_list = listUrl;
},
handleExceed(files, fileList) {},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${ file.name }`);
},
handlesuccess(response, file, fileList) {
console.log(fileList);
let listUrl = [];
for (var m of fileList) {
if (m.response)
listUrl.push(m.response.id);
else
listUrl.push(m.id);
}
this.form.file_list = listUrl;
},
resetForm(formName) {
var that = this;
this.$refs[formName].resetFields();
that.dialogFormVisible = false;
},
}
}
</script>
<style>
.dialogConcent {
overflow-y: auto;
}
</style>

@ -1,8 +1,358 @@
<template>
</template>
<script>
</script>
<style>
<template>
<div class="container">
<!-- 查询配置 -->
<div style="padding: 0px 20px">
<div ref="lxHeader">
<LxHeader icon="md-apps" text="安全生产任务上报" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
<div slot="content"></div>
<slot>
<div>
<Input style="width: 200px; margin-right: 10px" v-model="searchFields.KeyWord" placeholder="关键字搜索" />
<Button type="primary" @click="load" style="margin-left: 10px">查询</Button>
</div>
</slot>
</LxHeader>
</div>
<div ref="lxTable">
<el-table :data="tableData" :height="tableHeight" style="width: 100%">
<el-table-column type="index" width="50" align="center"> </el-table-column>
<el-table-column :prop="column.field" :align="column.align" v-for="(column,index) in columns"
:label="column.title" :width="column.width">
<template slot-scope="scope">
<div v-if="column.type == 'img'">
<img v-for="(file, vIndex) in getFilePath( scope.row[column.field], column)" :key="vIndex"
@click="viewImg(scope.row, column, file.path)" class="table-img" :src="file.path" />
</div>
<div v-else-if="column.type=='format'">
<div v-if="column.field=='task_departments_report'">
<el-link type="primary">
{{scope.row["safety_task_departments_count"]+"/"+scope.row["safety_task_departments_report_count"]}}
</el-link>
</div>
<div v-if="column.field=='task_departments'">
<el-tag v-for="(tag, tIndex) in scope.row['safety_task_departments']"
style="margin-right: 5px;margin-bottom: 5px;">
{{tag.departments.name}}
</el-tag>
</div>
</div>
<div v-else-if="column.type=='opt'">
<Button ghost size="small" @click="edit(scope.row)" type="primary"
style="margin-left: 10px;">上报</Button>
</div>
<div v-else>{{scope.row[column.field]}}</div>
</template>
</el-table-column>
</el-table>
<div class="pagination">
<el-pagination @current-change="handleCurrentChange" :current-page="paginations.page"
:page-size="paginations.page_size" background layout="prev, pager, next" :total="paginations.total">
</el-pagination>
</div>
</div>
</div>
</div>
</template>
<script>
import {
getToken
} from '@/utils/auth'
import LxHeader from "@/components/LxHeader/index.vue";
import Tinymce from '@/components/Tinymce'
import {
save,
store,
del,
get,
listtask
} from "../../api/daily/index.js";
import {
listdept
} from "../../api/system/department.js"
export default {
components: {
LxHeader,
Tinymce
},
data() {
return {
checkAll: false,
isIndeterminate: true,
paginations: {
page: 1,
page_size: 15,
total: 0
},
tableHeight: 0,
dialogFormVisible: false,
formLabelWidth: "120px",
clientHeight: 0,
form: {
title: "",
content: "",
file_list: "",
start_date: "",
end_date: "",
department_list: [],
daterange: null
},
fileList: [],
tableData: [],
rules: {
title: [{
required: true,
message: '请输入标题',
trigger: 'blur'
}],
department_list: [{
required: true,
message: '请选择科室',
trigger: 'blur'
}],
daterange: [{
required: true,
message: '请选择日期区间',
trigger: 'blur'
}]
},
indexUrl: "/api/admin/task/index",
tableHeight: 900,
searchFields: {
KeyWord: ""
},
columns: [{
field: "title",
title: "任务名称",
type: "string"
},
{
field: "start_date",
title: "开始时间",
type: "date",
width: 160,
align: "center"
},
{
field: "end_date",
title: "结束时间",
type: "date",
width: 160,
align: "center"
},
{
field: "task_departments_report",
title: "上报状态",
type: "format",
width: 180,
align: "center"
},
{
field: "操作",
title: "操作",
width: 220,
type: "opt",
}
],
uploadOther: {
token: ""
},
deptOptions: []
}
},
created() {
this.uploadOther.token = getToken();
this.loadDeptOptions();
this.initLoad();
this.load();
},
methods: {
loadDeptOptions() {
listdept().
then((res) => {
this.deptOptions = res;
}).catch(error => {
console.log(error)
reject(error)
})
},
handleCheckAllChange(val) {
console.log(val)
let options = [];
for (var m of this.deptOptions) {
options.push(m.id);
}
this.form.department_list = val ? options : [];
this.isIndeterminate = false;
},
handleCheckedDeptChange(value) {
let checkedCount = value.length;
this.checkAll = checkedCount === this.deptOptions.length;
this.isIndeterminate = checkedCount > 0 && checkedCount < this.deptOptions.length;
},
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;
},
handleCurrentChange(page) {
this.paginations.page = page;
this.load();
},
load() {
listtask({
page: this.paginations.page,
page_size: this.paginations.page_size,
}).then(response => {
this.tableData = response.data;
this.paginations.page_size = response.total;
}).catch(error => {
console.log(error)
reject(error)
})
},
del(obj) {
var that = this;
if (obj) {
this.$Modal.confirm({
title: '确认要删除数据?',
onOk: () => {
del(obj.id).then(response => {
this.$Message.success('操作成功');
that.load();
}).catch(error => {
console.log(error)
reject(error)
})
},
onCancel: () => {
//this.$Message.info('Clicked cancel');
}
});
}
},
show(obj) {
this.clientHeight = document.documentElement.clientHeight - 84 - 110;
this.dialogViewVisible = true;
this.info(obj);
},
info(obj) {
var that = this;
get(obj.id).then(res => {
let result = Object.assign(that.form, res);
that.form = result;
let _files = [];
for (var mod of result.files) {
let m = Object.assign({}, mod);
m.name = mod.original_name;
_files.push(m);
}
that.form.daterange = [res.start_date, res.end_date];
for (var m of res.safety_task_departments) {
that.form.department_list.push(m.department_id);
}
that.fileList = _files;
}).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;
},
submitForm(formName) {
var that = this;
this.$refs[formName].validate((valid) => {
if (valid) {
that.form.start_date = that.form.daterange[0];
that.form.end_date = that.form.daterange[1];
if (that.form.id) {
that.form.safety_task_id = that.form.id;
save(that.form).then(response => {
//console.log(response)
this.$Message.success('操作成功');
that.load();
that.dialogFormVisible = false;
}).catch(error => {
//reject(error)
})
} else {
store(that.form).then(response => {
//console.log(response)
this.$Message.success('操作成功');
that.load();
that.dialogFormVisible = false;
}).catch(error => {
//reject(error)
})
}
that.fileList = [];
} else {
this.$Message.error('数据校验失败');
console.log('error submit!!');
return false;
}
});
},
handleRemove(file, fileList) {
console.log(fileList);
let listUrl = [];
for (var m of fileList) {
if (m.response)
listUrl.push(m.response.id);
else
listUrl.push(m.id);
}
this.form.file_list = listUrl;
},
handleExceed(files, fileList) {},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${ file.name }`);
},
handlesuccess(response, file, fileList) {
console.log(fileList);
let listUrl = [];
for (var m of fileList) {
if (m.response)
listUrl.push(m.response.id);
else
listUrl.push(m.id);
}
this.form.file_list = listUrl;
},
resetForm(formName) {
var that = this;
this.$refs[formName].resetFields();
that.dialogFormVisible = false;
},
}
}
</script>
<style>
.dialogConcent {
overflow-y: auto;
}
</style>

@ -66,8 +66,8 @@
<el-form-item label="任务日期" prop="daterange">
<el-date-picker v-model="form.daterange" value-format="yyyy-MM-dd" type="daterange" range-separator=""
start-placeholder="开始日期" end-placeholder="结束日期">
<el-date-picker type="datetimerange" v-model="form.daterange" value-format="yyyy-MM-dd HH:mm:ss"
range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
@ -184,14 +184,14 @@
field: "start_date",
title: "开始时间",
type: "date",
width: 120,
width: 160,
align: "center"
},
{
field: "end_date",
title: "结束时间",
type: "date",
width: 120,
width: 160,
align: "center"
},
{

@ -3,7 +3,7 @@
<!-- 查询配置 -->
<div style="padding: 0px 20px">
<div ref="lxHeader">
<LxHeader icon="md-apps" text="部门管理" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
<LxHeader icon="md-apps" text="栏目管理" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
<div slot="content"></div>
<slot>
<div>

@ -0,0 +1,330 @@
<template>
<div class="container">
<!-- 查询配置 -->
<div style="padding: 0px 20px">
<div ref="lxHeader">
<LxHeader icon="md-apps" text="字典数据" 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">新增字典</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="字典编码" sortable width="180">
</el-table-column>
<el-table-column prop="name" label="字典名称" sortable width="220">
</el-table-column>
<el-table-column prop="remark" label="备注" sortable>
</el-table-column>
<el-table-column prop="sort" align="center" label="排序" sortable width="80">
</el-table-column>
<el-table-column fixed="right" label="操作" width="300">
<template slot-scope="scope">
<Button type="primary" @click="addchildren(scope.row)" size="small" style="margin-left: 10px;"
ghost>下一级</Button>
<Button type="error" @click="del(scope.row)" size="small" style="margin-left: 10px;" ghost>删除</Button>
<Button type="primary" @click="edit(scope.row)" size="small" style="margin-left: 10px;" ghost>编辑</Button>
</template>
</el-table-column>
</el-table>
</div>
</div>
<el-dialog title="字典编辑" :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="24">
<el-form-item label="上级">
<el-input v-model="form.pname" disabled autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="字典编码" 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="字典名称" 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="是否启用" prop="status">
<el-select v-model="form.status">
<el-option label="启用" value="1"></el-option>
<el-option label="不启用" value="0"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="排序">
<el-input v-model="form.sort" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注">
<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>新增参数</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="数据值Text" 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="排序" 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="状态" 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="备注">
<template slot-scope="scope">
<el-input v-model="scope.row.remark" />
</el-input>
</template>
</el-table-column>
<el-table-column label="操作" width="100" align="center">
<template slot-scope="scope">
<Button type="error" @click="delRow(scope.row,scope.$index)" size="small" style="margin-left: 10px;"
ghost>删除</Button>
</template>
</el-table-column>
</el-table>
</div>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="resetForm('form')"> </el-button>
<el-button type="primary" @click="submitForm('form')"> </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: "根级别",
number: "",
id: "",
pid: "0",
name: "",
status: "1",
sort: 0,
remark: "",
detail_list: [{
id: "",
value: "",
sort: "1",
status: true,
remark: ""
}]
},
rules: {
name: [{
required: true,
message: '请输入菜单名称',
trigger: 'blur'
}],
url: [{
required: true,
message: '请输入菜单路径',
trigger: 'blur'
}],
visible: [{
required: true,
message: '请选择是否显示',
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("操作成功");
this.form.detail_list.splice(index, 1);
}).catch(error => {
//reject(error)
this.$message.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);
}).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('操作成功');
that.dialogFormVisible = false;
that.load();
}).catch(error => {})
} else {
store(that.form).then(response => {
console.log(response)
this.$Message.success('操作成功');
that.dialogFormVisible = false;
that.load();
}).catch(error => {})
}
} else {
this.$Message.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: '确认要删除数据?',
onOk: () => {
del({
id: obj.id
}).then(response => {
this.$Message.success('操作成功');
that.load();
}).catch(error => {
console.log(error)
reject(error)
})
},
onCancel: () => {
//this.$Message.info('Clicked cancel');
}
});
}
},
}
};
</script>
Loading…
Cancel
Save