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.

233 lines
7.4 KiB

4 years ago
<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.number="searchFields.Name" 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 class="table-tree">
<el-table :data="tableData" :height="tableHeight" style="width: 100%">
<el-table-column type="index" width="50" align="center" label="序号"> </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=='opt'">
<Button ghost size="small" @click="edit(scope.row)" type="primary"
style="margin-left: 10px;">编辑</Button>
</div>
<div v-else-if="column.type=='type'" v-for="item in parameters.carType">
<div v-if="item.id==scope.row[column.field]">
{{item.value}}
</div>
</div>
<div v-else>{{scope.row[column.field]}}</div>
</template>
</el-table-column>
</el-table>
</div>
</div>
<el-dialog title="详情编辑" :visible.sync="dialogFormVisible" fullscreen width="90%">
<el-form :model="form" :rules="rules" ref="form" label-position="right" :label-width="formLabelWidth">
<el-form-item label="入场时间" prop="date">
<el-date-picker style="width:100%" v-model="form.date" type="datetime" placeholder="选择入场时间">
</el-date-picker>
</el-form-item>
<el-form-item label="车牌号码" prop="card">
<el-input v-model="form.card" placeholder="请填写车牌号码" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="联系方式" prop="tel">
<el-input v-model="form.tel" placeholder="请填写联系方式" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="类型" prop="type">
<el-select v-model="form.type" placeholder="请选择类型" style="width:100%">
<el-option v-for="item in parameters.carType" :key="item.value" :label="item.value" :value="item.id">
</el-option>
</el-select>
</el-form-item>
</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 Tinymce from '@/components/Tinymce'
import {
} from "../../api/resource/parking.js";
import {
getparameteritem
} from "../../api/system/dictionary.js"
export default {
components: {
LxHeader,
Tinymce
},
created() {
this.initLoad();
this.load();
},
mounted() {},
data() {
return {
dialogFormVisible: false,
formLabelWidth: "120px",
parameters: {
carType: []
},
form: {
date: "",
tel: "姑苏区体育场路4号",
card: "09:30-17:50",
type: "200",
},
columns: [{
field: "date",
title: "入场时间",
type: "string",
},
{
field: "card",
title: "车牌号",
type: "string",
},
{
field: "type",
title: "类型",
type: "type",
},
{
field: "tel",
title: "联系方式",
type: "string",
align: "center"
},
{
field: "操作",
title: "操作",
width: 220,
type: "opt",
}
],
rules: {
},
tableHeight: 0,
//查询条件字段
searchFields: {
KeyWord: ""
},
tableData: [{
date: "2022-05-07 10:00",
tel: "1894号",
card: "苏E1124",
type: 26,
}]
}
},
methods: {
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;
//加载自定义参数
getparameteritem("car-type").then(res => {
this.parameters.carType = res.detail;
});
},
load() {
var that = this;
},
show(obj) {
this.clientHeight = document.documentElement.clientHeight - 84 - 110;
this.dialogViewVisible = true;
this.info(obj);
},
info(obj) {
var that = this;
},
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) {
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(obj.id).then(response => {
this.$Message.success('操作成功');
that.load();
}).catch(error => {
console.log(error)
reject(error)
})
},
onCancel: () => {
//this.$Message.info('Clicked cancel');
}
});
}
},
}
};
</script>