封装搜索、表格、新增表单

This commit is contained in:
qq787203167
2022-01-19 17:53:19 +08:00
parent fa0e712ccf
commit e634323ff3
9 changed files with 744 additions and 2 deletions
+1
View File
@@ -22,6 +22,7 @@
"dom-align": "1.12.0",
"echarts": "^5.0.2",
"enquire.js": "^2.1.6",
"jquery": "^3.6.0",
"js-base64": "^3.6.0",
"js-cookie": "^2.2.0",
"jsencrypt": "^3.0.0-rc.1",
+4
View File
@@ -0,0 +1,4 @@
import Vue from 'vue';
let bus = new Vue();
Vue.prototype.$eventBus = bus;
export default bus;
+274
View File
@@ -0,0 +1,274 @@
<template>
<a-spin :spinning="confirmLoading">
<a-form-model :model="formInline" v-if="isFormInline" class="formAdd" :rules="rules" ref="ruleForm">
<a-row :gutter="24">
<div v-for="(item,index) in dataList" :key="index">
<a-col :span="12" v-if="item.type === 'INPUT'">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span :class="{'title-text-text':false}">{{item.enName}}</span><br>
<span :class="{'title-text-text':false}">{{item.name}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.attrModel">
<a-input class="box-input" v-model="formInline[item.attrModel]" :placeholder="item.placeholder"/>
</a-form-model-item>
</div>
</a-col>
<a-col :span="12" v-else-if="item.type === 'CHECKBOX'">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span :class="{'title-text-text':false}">{{item.enName}}</span><br>
<span :class="{'title-text-text':false}">{{item.name}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.attrModel">
<j-multi-select-tag class="box-input" v-model="formInline[item.attrModel]"
:placeholder="$t('selectStatus')" :type="'checkbox'"
:triggerChange="false" dictCode="valid_status"/>
</a-form-model-item>
</div>
</a-col>
<a-col :span="12" v-else-if="item.type === 'DATE'">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span :class="{'title-text-text':false}">{{item.enName}}</span><br>
<span :class="{'title-text-text':false}">{{item.name}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.name">
<a-date-picker class="box-input" v-model="formInline[item.attrModel]" @change="onChange"
style="width: 100%"/>
</a-form-model-item>
</div>
</a-col>
<a-col :span="12" v-else-if="item.type === 'SELECT'">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span :class="{'title-text-text':false}">{{item.enName}}</span><br>
<span :class="{'title-text-text':false}">{{item.name}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.name">
<j-dict-select-tag class="box-input" v-model="formInline[item.attrModel]"
:placeholder="$t('selectStatus')" :type="'select'"
:triggerChange="false" dictCode="valid_status"/>
</a-form-model-item>
</div>
</a-col>
<a-col :span="12" v-else-if="item.type === 'SELECTALL'">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span :class="{'title-text-text':false}">{{item.enName}}</span><br>
<span :class="{'title-text-text':false}">{{item.name}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.name">
<j-multi-select-tag class="box-input" v-model="formInline[item.attrModel]"
:placeholder="$t('selectStatus')" :type="'select'"
:triggerChange="false" dictCode="valid_status"/>
</a-form-model-item>
</div>
</a-col>
<a-col :span="12" v-else-if="item.type === 'RADIO'">
<div class="box-title-text">
<div class="title-text">
<span class="Required">*</span>
<span :class="{'title-text-text':false}">{{item.enName}}</span><br>
<span :class="{'title-text-text':false}">{{item.name}}</span>
</div>
<a-form-model-item class="itemModel" :prop="item.name">
<j-dict-select-tag v-model="formInline[item.attrModel]" :placeholder="$t('selectStatus')"
:type="'radio'" :triggerChange="false" dictCode="valid_status"/>
</a-form-model-item>
</div>
</a-col>
</div>
</a-row>
</a-form-model>
</a-spin>
</template>
<script>
export default {
name: 'index',
props: {
url: {
type: Object,
default: {}
}
},
data() {
return {
formInline: {},
isFormInline: false,
rules: {
title: [
{ required: true, message: 'Please input Activity name', trigger: 'blur' }
]
},
labelCol: {
xs: { span: 24 },
sm: { span: 6 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 17 }
},
dataList: [
{
id: 1,
type: 'INPUT',
name: '名称',
placeholder: '请输入名称',
attrModel: 'name',
enName: 'Name'
},
{
id: 2,
type: 'INPUT',
name: '标题',
placeholder: '请输入标题',
attrModel: 'title',
enName: 'title'
},
{
id: 3,
type: 'RADIO',
name: '单选',
placeholder: '请输入标题',
enName: 'Single choice',
validStatus: 'valid_status',
attrModel: 'radio'
},
{
id: 4,
type: 'CHECKBOX',
name: '多选',
enName: 'title',
placeholder: '请输入标题',
attrModel: 'checkbox',
validStatus:'valid_status',
},
{
id: 5,
type: 'SELECT',
name: '下拉单选',
enName: 'title',
placeholder: '请输入标题',
attrModel: 'radio',
validStatus:'valid_status',
},
{
id: 6,
type: 'SELECTALL',
name: '下拉多选',
enName: 'title',
placeholder: '请输入标题',
validStatus:'valid_status',
attrModel: 'selectAll'
}
],
validatorRules: {},
confirmLoading: false
}
},
mounted() {
this.isFormInline = false
this.isFormInline = true
},
methods: {
sumber() {
console.log(1)
this.$refs.ruleForm.validate(valid => {
if (valid) {
alert('submit!')
} else {
console.log('error submit!!')
return false
}
})
}
}
}
</script>
<style>
.formAdd .ant-form-item-label {
width: 130px;
}
.formAdd .ant-form-item-control-wrapper {
display: inline-block;
width: calc(100% - 130px);
}
.formAdd .ant-form-item {
margin-bottom: 20px;
}
.itemModel .ant-form-item-control-wrapper {
width: 100%;
}
.box-input .ant-select-selection--single {
height: 38px;
}
.box-input .ant-select-selection--multiple {
height: 38px;
}
.box-input .ant-select-selection__rendered {
line-height: 38px;
height: 38px;
}
.box-input .ant-select-selection--multiple .ant-select-selection__rendered > ul > li{
margin-top:6px;
}
</style>
<style scoped>
.box-title-text {
line-height: 1.4;
display: flex;
/*align-items: center;*/
}
.title-text {
width: 114px;
text-align: right;
display: inline-block;
font-weight: bold;
font-size: 14px;
margin-right: 16px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.box-input {
display: inline-block;
height: 38px;
width: 100%;
}
.itemModel {
width: calc(100% - 130px);
display: inline-block;
}
.Required {
color: red;
margin-right: 4px;
}
.title-text-text {
margin-top: 11px;
display: inline-block;
}
</style>
+78
View File
@@ -0,0 +1,78 @@
<template>
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row :gutter="24">
<a-col :md="6" :sm="8" v-for="(item,index) in searchList" :key="index" style="line-height: 48px">
<div class="box-title-text">
<div class="title-text">
<span>{{item.enName}}</span><br>
<span>{{item.name}}</span>
</div>
<a-input class="box-input" :placeholder="item.placeholder" v-model="queryParam[item.attrModel]"></a-input>
</div>
</a-col>
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-col :md="6" :sm="24">
<a-button class="box-button" type="primary" @click="searchQuery">{{$t('query')}}</a-button>
<a-button class="box-button" style="margin-left: 8px" @click="searchReset">{{$t('reset')}}</a-button>
</a-col>
</span>
</a-row>
</a-form>
</template>
<script>
import eventBUs from '../../common/event.js'
export default {
name: 'index',
props: {
searchList: {
type: Array,
default: []
}
},
data() {
return {
queryParam: {}
}
},
mounted() {
},
methods: {
searchQuery() {
eventBUs.$emit('searchQuery', this.queryParam)
},
searchReset() {
this.queryParam = {}
eventBUs.$emit('searchQuery', this.queryParam)
}
}
}
</script>
<style scoped>
.box-title-text {
line-height: 1.4;
display: flex;
align-items: center;
}
.title-text {
display: inline-block;
font-weight: bold;
font-size: 14px;
margin-right: 16px;
}
.box-input {
display: inline-block;
width: 80%;
height: 38px;
margin-top: 2px;
}
.box-button {
height: 38px;
margin-top: 2px;
}
</style>
+224
View File
@@ -0,0 +1,224 @@
<template>
<div style="height: 100%">
<div class="box">
<table class="box-table" cellpadding="0" cellspacing="0">
<thead>
<tr id="table_thead_tr">
<a-checkbox-group @change="checkboxAll($event)">
<th class="checkbox" style="margin-top: 24px;display: inline-block">
<a-checkbox></a-checkbox>
</th>
</a-checkbox-group>
</tr>
</thead>
<tbody id="table_tbody_tr">
<a-checkbox-group @change="checkboxChange" style="display: contents" v-model="checkboxList">
<tr v-for="item in jsonBody">
<td class="checkbox">
<a-checkbox :value="item.id"></a-checkbox>
</td>
<td v-for="val in Object.keys(item)" v-if="val != 'id'" class="box-td" :title="item[val]">
{{item[val]}}
</td>
<td class="box-td box-th-po">
<a class="text" v-if="Collection">收藏</a>
<a class="text" v-if="subscribe">订阅</a>
<a class="text" v-if="edit">编辑</a>
<a class="text" v-if="del">删除</a>
</td>
</tr>
</a-checkbox-group>
</tbody>
</table>
</div>
<div class="page">
<a-pagination
:show-total="total => ` ${total} `"
show-quick-jumper
show-size-changer
:page-size.sync="pageSize"
:total="500"
@change="onChange"
/>
</div>
</div>
</template>
<script>
import eventBUs from '../../common/event'
export default {
name: 'index',
props: {
edit: {
type: Boolean,
default: false
},
del: {
type: Boolean,
default: false
},
Collection: {
type: Boolean,
default: false
},
subscribe: {
type: Boolean,
default: false
},
url: {
type: Object,
default: {}
}
},
data() {
return {
pageSize: 20,
jsonHead: [
{
'name': '序号',
'enName': 'Swrial number'
},
{
'name': '编号',
'enName': 'Swrial number'
},
{
'name': '标题',
'enName': 'Title'
},
{
'name': '发布日期',
'enName': 'Release data'
},
{
'name': '标准实施日期',
'enName': 'Standard data'
},
{
'name': '状态',
'enName': 'State'
}
],
jsonBody: [
{
// 'col1': '河流1',
id: 1,
'col2': '河流26dsfdsfdsfdsfsfdsfsfsfsfsdfsfsfdsfsfdsfdsfdsfdsfdsf1232132132132131321321321312312321321321312dsf',
'col3': '大羊沟6dsfdsfdsfdsfsfdsfsfsfsfsdfsfsfdsfsfdsfdsfdsfdsfdsf1232132132132131321321321312312321321321312dsf',
'col4': '待审批6dsfdsfdsfdsfsfdsfsfsfsfsdfsfsfdsfsfdsfdsfdsfdsfdsf1232132132132131321321321312312321321321312dsf',
'col5': '待审批6dsfdsfdsfdsfsfdsfsfsfsfsdfsfsfdsfsfdsfdsfdsfdsfdsf1232132132132131321321321312312321321321312dsf',
'col6': '待审批6dsfdsfdsfdsfsfdsfsfsfsfsdfsfsfdsfsfdsfdsfdsfdsfdsf1232132132132131321321321312312321321321312dsf',
'col7': 0.6
},
{
// 'col1': '河流1',
id: 2,
'col2': '河流2',
'col3': '大羊沟',
'col4': '待审批',
'col5': 0.6,
'col6': '0.6dsfdsfdsfdsfsfdsfsfsfsfsdfsfsfdsfsfdsfdsfdsfdsfdsf1232132132132131321321321312312321321321312dsf',
'col7': 0.6
}
],
checkboxList: []
}
},
mounted() {
eventBUs.$on('searchQuery', target => {
console.log(target);
});
eventBUs.$on('searchReset', target => {
console.log(target);
});
this.getData()
},
methods: {
getData() {
var jsonHead = this.jsonHead
for (var i = 0; i < jsonHead.length; i++) {
$('#table_thead_tr').append('<th class="box-th">' + jsonHead[i].enName + '</br>' + jsonHead[i].name + '</th>')
}
let th = '<th class="box-th box-th-po">' + 'Operation ' + '</br>' + '操作' + '</th>'
$('#table_thead_tr').append(th)
},
checkboxChange(value) {
console.log(value)
},
checkboxAll(event) {
this.checkboxList = []
if (event.length > 0) {
this.jsonBody.forEach(res => {
this.checkboxList.push(res.id)
})
}
},
onChange() {
}
}
}
</script>
<style scoped>
.box {
width: 100%;
height: calc(100% - 100px);
overflow: auto;
}
.box-table {
width: 100%;
overflow: auto;
position: relative;
}
.checkbox {
min-width: 30px;
margin-top: 10px;
}
.text {
margin-right: 16px;
}
.page {
text-align: right;
margin-top: 20px;
}
</style>
<style>
.box-th {
min-width: 100px;
max-width: 300px;
padding: 20px 20px;
box-sizing: border-box;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: left;
}
.box-td {
min-width: 100px;
max-width: 300px;
padding: 20px 20px;
box-sizing: border-box;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: left;
}
.box-th-po {
max-width: 340px;
position: sticky;
right: 0;
background: #fff;
padding: 20px 0 20px 20px;
box-sizing: border-box;
text-align: left;
}
</style>
+1
View File
@@ -6,6 +6,7 @@ import App from './App.vue'
import Storage from 'vue-ls'
import router from './router'
import store from './store/'
import $ from 'jquery'
import {
VueAxios
} from "@/utils/request"
+83
View File
@@ -0,0 +1,83 @@
<template>
<a-card :bordered="false">
<div class="table-page-search-wrapper">
<search :searchList="searchList"/>
</div>
<div class="table-operator">
<a-button @click="handleCompare()" type="primary" icon="plus">{{$t('DataComparison')}}</a-button>
</div>
<div>
<tableData edit del :url="{}"/>
</div>
<addForm ref="addFormClick"/>
</a-card>
</template>
<script>
import search from '@/components/search/index'
import tableData from '@/components/tableDate/index'
import { JeroListMixin } from '@/mixins/JeroListMixin'
import addForm from './modules/addForm'
export default {
name: 'index',
// mixins: [JeroListMixin],
components: {
search,
addForm,
tableData
},
data() {
return {
searchList: [
{ name: '名称', placeholder: '请输入姓名', attrModel: 'name', enName: 'title' },
{ name: '标题', placeholder: '请输入标题', attrModel: 'title', enName: 'title' }
],
selectedRowKeys: [],
dataSource: [],
loading: false,
columns: [
{
title: this.$t('tableName'),
align: 'center',
dataIndex: 'dataTable',
width: '120'
}, {
title: this.$t('DataID'),
align: 'center',
dataIndex: 'dataId',
width: '120'
}, {
title: this.$t('VersionNumber'),
align: 'center',
dataIndex: 'dataVersion',
width: '50'
}, {
title: this.$t('DataContent'),
align: 'center',
dataIndex: 'dataContent',
width: '150',
scopedSlots: { customRender: 'dataContent' }
}, {
title: this.$t('creator'),
align: 'center',
dataIndex: 'createBy',
width: '100'
}
]
}
},
methods: {
onSelectChange() {
},
handleCompare() {
this.$refs.addFormClick.add()
}
}
}
</script>
<style scoped>
</style>
@@ -0,0 +1,72 @@
<template>
<a-drawer
:title="title"
:maskClosable="true"
:width="drawerWidth"
placement="right"
:closable="true"
@close="handleCancel"
:visible="visible"
style="height: 100%;overflow: auto;padding-bottom: 53px;">
<addFormData
ref="addFormDataRef"
v-if="visible"
:url="url"
/>
<div class="drawer-bootom-button">
<a-popconfirm :title="$t('AreYouWantDiscardEditing')" @confirm="handleCancel" :okText="$t('determine')"
:cancelText="$t('cancel')">
<a-button style="margin-right: .8rem">{{$t('cancel')}}</a-button>
</a-popconfirm>
<a-button @click="handleSubmit" type="primary" :loading="confirmLoading">{{$t('submit')}}</a-button>
</div>
</a-drawer>
</template>
<script>
import addFormData from '@/components/addForm/index'
export default {
name: 'addForm',
components: {
addFormData
},
data() {
return {
title: '添加',
drawerWidth: 1000,
visible: false,
confirmLoading: false,
url: {}
}
},
methods: {
handleCancel() {
this.visible = false
},
add() {
this.visible = true
},
edit() {
this.visible = true
},
handleSubmit() {
this.$refs.addFormDataRef.sumber()
}
}
}
</script>
<style scoped>
.drawer-bootom-button {
position: absolute;
bottom: 0;
width: 100%;
border-top: 1px solid #e8e8e8;
padding: 10px 16px;
text-align: right;
left: 0;
background: #fff;
border-radius: 0 0 2px 2px;
}
</style>
+7 -2
View File
@@ -4,7 +4,7 @@ const CompressionPlugin = require("compression-webpack-plugin")
function resolve(dir) {
return path.join(__dirname, dir)
}
const webpack = require('webpack')
// vue.config.js
module.exports = {
/*
@@ -38,7 +38,12 @@ module.exports = {
deleteOriginalAssets: false // 不删除源文件
}))
}
config.plugin('provide').use(webpack.ProvidePlugin, [{
$: 'jquery',
jquery: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}])
// 配置 webpack 识别 markdown 为普通的文件
config.module
.rule('markdown')