表格组件封装完善,协议管理,类型管理页面创建

This commit is contained in:
BianLzhaoMin 2024-08-08 10:44:23 +08:00
parent 949a04de73
commit 26480bc213
13 changed files with 482 additions and 16 deletions

View File

@ -96,6 +96,7 @@
border border
ref="tableRef" ref="tableRef"
select-on-indeterminate select-on-indeterminate
style="width: 100%"
> >
<el-table-column <el-table-column
type="selection" type="selection"
@ -129,9 +130,16 @@
</template> </template>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="操作" v-show="handleShow"> <el-table-column
align="center"
label="操作"
v-if="handleShow"
:min-width="dynamicWidth"
>
<template slot-scope="{ row }"> <template slot-scope="{ row }">
<slot :data="row" name="handle"></slot> <div class="optionDivRef">
<slot :data="row" name="handle">-</slot>
</div>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -167,7 +175,15 @@ export default {
}) })
}, },
}, },
watch: {
handleShow: {
handler(newValue) {
if (!newValue) {
this.dynamicWidth = 0
}
},
},
},
data() { data() {
return { return {
// //
@ -180,8 +196,16 @@ export default {
indexNumShow: true, indexNumShow: true,
// //
handleShow: true, handleShow: true,
// label
columCheckList: [], columCheckList: [],
tableList: [], //
tableList: [
{ scrapNum: '测试' },
{ scrapNum: '123' },
{ scrapNum: '测试' },
],
//
dynamicWidth: 0,
} }
}, },
@ -197,7 +221,9 @@ export default {
}) })
this.getTableList() this.getTableList()
}, },
updated() {
this.dynamicWidth = this.getOperatorWidth()
},
methods: { methods: {
/** 获取列表数据 */ /** 获取列表数据 */
async getTableList() { async getTableList() {
@ -217,6 +243,37 @@ export default {
checkboxChange(list) { checkboxChange(list) {
this.columCheckList = list this.columCheckList = list
}, },
/** 动态设置操作列的列宽 */
getOperatorWidth() {
const operatorColumn =
document.getElementsByClassName('optionDivRef')
//
let width = 100
//
let paddingSpacing = 0
//
let buttonCount = 0
if (operatorColumn.length > 0) {
Array.prototype.forEach.call(operatorColumn, function (item) {
//
width = width > item.offsetWidth ? width : item.offsetWidth
const buttons = item.getElementsByClassName('el-button')
buttonCount = buttons.length
buttonCount =
buttonCount > buttons.length
? buttonCount
: buttons.length
})
// 2*-1
// if (buttonCount > 2) {
// width += paddingSpacing * (buttonCount - 1)
// }
return width
}
},
}, },
} }
</script> </script>
@ -234,4 +291,13 @@ export default {
padding: 6px 18px; padding: 6px 18px;
} }
} }
::v-deep .optionDivRef {
white-space: nowrap;
display: inline-block;
.el-button {
padding: 6px 12px;
}
}
</style> </style>

View File

@ -83,6 +83,18 @@ export const constantRoutes = [
component: () => import('@/views/BasicManage/ContactUnits'), component: () => import('@/views/BasicManage/ContactUnits'),
name: 'ContactUnits', name: 'ContactUnits',
meta: { title: '往来单位', icon: 'dashboard', affix: true } meta: { title: '往来单位', icon: 'dashboard', affix: true }
},
{
path: 'UnitType',
component: () => import('@/views/BasicManage/UnitType'),
name: 'UnitType',
meta: { title: '单位类型', icon: 'dashboard', affix: true }
},
{
path: 'ProtocolManage',
component: () => import('@/views/BasicManage/ProtocolManage'),
name: 'ProtocolManage',
meta: { title: '协议管理', icon: 'dashboard', affix: true }
} }
] ]
}, },

View File

@ -1,4 +1,5 @@
<template> <template>
<!-- 往来单位 新增编辑 表单组件 -->
<div> <div>
<el-form <el-form
label-width="100px" label-width="100px"
@ -46,6 +47,7 @@
<script> <script>
export default { export default {
name: 'FormContactUnits',
data() { data() {
return { return {
contactUnitsParams: { contactUnitsParams: {

View File

@ -27,6 +27,7 @@ import { formLabel, columnsList, dialogConfig } from './config'
import { commonMixin } from '@/mixins/common.js' import { commonMixin } from '@/mixins/common.js'
import FormContactUnits from './components/form-contact-units.vue' import FormContactUnits from './components/form-contact-units.vue'
export default { export default {
name: 'ContactUnits',
mixins: [commonMixin], // mixins: [commonMixin], //
components: { FormContactUnits }, components: { FormContactUnits },
data() { data() {

View File

@ -1,4 +1,5 @@
<template> <template>
<!-- 工程管理 新增编辑 表单组件 -->
<div> <div>
<el-form <el-form
label-width="100px" label-width="100px"
@ -110,6 +111,7 @@
<script> <script>
export default { export default {
name: 'FormProject',
data() { data() {
return { return {
projectParams: { projectParams: {

View File

@ -18,7 +18,4 @@ export const dialogConfig = {
outerWidth: '70%', outerWidth: '70%',
outerTitle: '', outerTitle: '',
outerVisible: false, outerVisible: false,
innerWidth: '50%',
innerTitle: '',
innerVisible: false,
} }

View File

@ -8,6 +8,10 @@
<el-button>导入</el-button> <el-button>导入</el-button>
<el-button>导出</el-button> <el-button>导出</el-button>
</template> </template>
<template slot="handle" slot-scope="{ data }">
<el-button type="primary" size="mini">编辑</el-button>
<el-button type="danger" size="mini">删除</el-button>
</template>
</TableModel> </TableModel>
<!-- 新增弹框 --> <!-- 新增弹框 -->
@ -27,6 +31,7 @@ import { formLabel, columnsList, dialogConfig } from './config'
import { commonMixin } from '@/mixins/common.js' import { commonMixin } from '@/mixins/common.js'
import FormProject from './components/form-project' import FormProject from './components/form-project'
export default { export default {
name: 'ProjectManage',
mixins: [commonMixin], // mixins: [commonMixin], //
components: { components: {
FormProject, FormProject,

View File

@ -0,0 +1,160 @@
<template>
<!-- 协议管理 新增编辑 表单组件 -->
<div>
<el-form
label-width="100px"
size="medium"
ref="protocolParamsRef"
:model="protocolParams"
:rules="protocolParamsRules"
>
<el-row type="flex" justify="space-between" :gutter="24">
<el-col :span="12">
<el-form-item label="租赁单位" prop="pro_name">
<el-input v-model="protocolParams.pro_name" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="授权人" prop="pro_unit">
<el-input v-model="protocolParams.pro_unit" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :span="12">
<el-form-item label="租赁工程" prop="pro_type_of">
<el-select
v-model="protocolParams.pro_type_of"
></el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="联系电话" prop="pro_type">
<el-select
v-model="protocolParams.pro_type"
></el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :span="12">
<el-form-item label="合同编号" prop="pro_type">
<el-select
v-model="protocolParams.pro_type"
></el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="租赁期限" prop="pro_nature">
<el-select
v-model="protocolParams.pro_nature"
></el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :span="12">
<el-form-item label="开始日期" prop="pro_user">
<el-input v-model="protocolParams.pro_user" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="备注" prop="pro_phone">
<el-input v-model="protocolParams.pro_phone" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :span="12">
<el-form-item label="合同附件">
<el-input />
</el-form-item>
</el-col>
<el-col :span="12"> </el-col>
</el-row>
<el-form-item>
<el-button type="success" @click="onSubmit">确认</el-button>
<el-button
@click="
() => {
this.$emit('closeDialog')
}
"
>取消</el-button
>
</el-form-item>
</el-form>
</div>
</template>
<script>
export default {
name: 'FormProtocol',
data() {
return {
protocolParams: {
pro_name: '',
pro_code: '',
pro_unit: '',
pro_type_of: '',
pro_type: '',
pro_nature: '',
pro_user: '',
pro_phone: '',
},
//
protocolParamsRules: {
pro_name: [
{
required: true,
message: '请选择租赁单位',
trigger: 'blur',
},
],
pro_unit: [
{
required: true,
message: '请输入授权人',
trigger: 'blur',
},
],
pro_type_of: [
{
required: true,
message: '请选择租赁工程',
trigger: 'blur',
},
],
pro_type: [
{
required: true,
message: '请输入联系电话',
trigger: 'blur',
},
],
},
}
},
methods: {
/** 确认按钮 */
onSubmit() {
this.$refs.protocolParamsRef.validate((valid) => {
if (valid) {
console.log('校验通过')
// 1. Api
// 2.
this.$emit('closeDialog')
}
})
},
},
}
</script>
<style scoped>
::v-deep .el-select {
width: 100%;
}
</style>

View File

@ -0,0 +1,26 @@
export const formLabel = [
{ f_label: '关键字', f_model: 'keywords', f_type: 'date' },
{ f_label: '关键字', f_model: 'keywords', f_type: 'ipt' },
{ f_label: '状态', f_model: 'keywords', f_type: 'sel' },
]
export const columnsList = [
{ t_props: 'scrapNum', t_label: '协议签订时间', },
{ t_props: '', t_label: '协议编号' },
{ t_props: 'repairNum', t_label: '合同编号' },
{ t_props: 'unitName', t_label: '租赁单位', },
{ t_props: 'projectName', t_label: '租赁工程', },
{ t_props: 'itemType', t_label: '开始日期', },
{ t_props: 'itemType', t_label: '租赁期限(天)', },
{ t_props: 'itemType', t_label: '授权人', },
{ t_props: 'itemType', t_label: '授权人电话', },
{ t_props: 'itemType', t_label: '租赁单位类型', },
{ t_props: 'itemType', t_label: '附件图片', },
{ t_props: 'itemType', t_label: '备注', },
]
export const dialogConfig = {
outerWidth: '70%',
outerTitle: '',
outerVisible: false,
}

View File

@ -1,10 +1,61 @@
<template> <template>
<!-- 协议管理 --> <!-- 协议管理 -->
<div> 协议管理 </div> <div class="app-container">
<!-- 表格 -->
<TableModel :formLabel="formLabel" :columnsList="columnsList">
<template slot="btn">
<el-button type="primary" @click="addProtocol()"
>新增协议</el-button
>
<el-button>导出</el-button>
</template>
<template slot="handle" slot-scope="{ data }">
<el-button type="primary" size="mini">查看</el-button>
<el-button type="primary" size="mini">编辑</el-button>
<el-button type="danger" size="mini">删除</el-button>
</template>
</TableModel>
<!-- 新增弹框 -->
<DialogModel
:dialogConfig="dialogConfig"
@closeDialogOuter="closeDialogOuter"
>
<template slot="outerContent">
<FormProtocol @closeDialog="closeDialog" />
</template>
</DialogModel>
</div>
</template> </template>
<script> <script>
export default {} import { formLabel, columnsList, dialogConfig } from './config'
import { commonMixin } from '@/mixins/common.js'
import FormProtocol from './components/form-protocol'
export default {
name: 'ProtocolManage',
mixins: [commonMixin], //
components: {
FormProtocol,
},
data() {
return {
formLabel,
columnsList,
dialogConfig,
}
},
methods: {
/** 新增协议 */
addProtocol() {
this.dialogConfig.outerTitle = '新增协议'
this.dialogConfig.outerVisible = true
console.log('新增协议---')
},
/** 关闭弹框 */
closeDialog() {
this.dialogConfig.outerVisible = false
},
},
}
</script> </script>
<style></style>

View File

@ -0,0 +1,80 @@
<template>
<!-- 单位类型 新增编辑 表单组件 -->
<div>
<el-form
label-width="120px"
size="medium"
ref="unitsTypeParamsRef"
:model="unitsTypeParams"
:rules="unitsTypeParamsRules"
>
<el-form-item label="单位类型名称" prop="pro_type_name">
<el-input v-model="unitsTypeParams.pro_type_name" />
</el-form-item>
<el-form-item label="启用状态" prop="pro_type">
<el-switch
active-text="启用"
inactive-text="禁用"
v-model="unitsTypeParams.pro_type"
></el-switch>
</el-form-item>
<el-form-item>
<el-button @click="onSubmit">确定</el-button>
<el-button
@click="
() => {
this.$emit('closeDialog')
}
"
>取消</el-button
>
</el-form-item>
</el-form>
</div>
</template>
<script>
export default {
name: 'FormUnitsType',
data() {
return {
unitsTypeParams: {
pro_type_name: '',
pro_type: '',
},
//
unitsTypeParamsRules: {
pro_type_name: [
{
required: true,
message: '请输入单位类型名称',
trigger: 'blur',
},
],
pro_type: [
{
required: true,
message: '请选择施工单位',
trigger: 'blur',
},
],
},
}
},
methods: {
/** 确认按钮 */
onSubmit() {
this.$refs.unitsTypeParamsRef.validate((valid) => {
if (valid) {
console.log('校验通过')
// 1. Api
// 2.
this.$emit('closeDialog')
}
})
},
},
}
</script>

View File

@ -0,0 +1,14 @@
export const formLabel = [
{ f_label: '单位名称', f_model: 'keywords', f_type: 'ipt' },
]
export const columnsList = [
{ t_props: 'scrapNum', t_label: '单位类型', },
{ t_props: '', t_label: '状态' },
]
export const dialogConfig = {
outerWidth: '40%',
outerTitle: '',
outerVisible: false,
}

View File

@ -1,10 +1,60 @@
<template> <template>
<!-- 单位类型 --> <!-- 单位类型 -->
<div> 单位类型 </div> <div class="app-container">
<!-- 表格 -->
<TableModel :formLabel="formLabel" :columnsList="columnsList">
<template slot="btn">
<el-button type="primary" @click="addUnitType()"
>新建</el-button
>
<el-button>导入</el-button>
<el-button>导出</el-button>
</template>
<template slot="handle" slot-scope="{ data }">
<el-button type="primary" size="mini">编辑</el-button>
<el-button type="danger" size="mini">删除</el-button>
</template>
</TableModel>
<!-- 新增弹框 -->
<DialogModel
:dialogConfig="dialogConfig"
@closeDialogOuter="closeDialogOuter"
>
<template slot="outerContent">
<FormUnitsType @closeDialog="closeDialog" />
</template>
</DialogModel>
</div>
</template> </template>
<script> <script>
export default {} import { formLabel, columnsList, dialogConfig } from './config'
import { commonMixin } from '@/mixins/common.js'
import FormUnitsType from './components/form-units-type'
export default {
name: 'UnitType',
mixins: [commonMixin], //
components: {
FormUnitsType,
},
data() {
return {
formLabel,
columnsList,
dialogConfig,
}
},
methods: {
/** 新建单位类型 */
addUnitType() {
this.dialogConfig.outerTitle = '新建单位类型'
this.dialogConfig.outerVisible = true
},
/** 关闭弹框 */
closeDialog() {
this.dialogConfig.outerVisible = false
},
},
}
</script> </script>
<style></style>