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.
 
 
 
 
 

194 lines
4.4 KiB

<template>
<avue-crud
ref="crudRef"
:option="option"
:data="data"
v-model="formData"
v-model:page="page"
v-model:search="queryCondition"
@row-del="rowDel"
@refresh-change="onLoad"
@on-load="onLoad"
@search-change="searchChange"
@row-dblclick="rowDblclick"
>
<template #menu-left="{}">
<el-button
type="primary"
icon="el-icon-plus"
@click="rowSave()"
v-permission="pageCode + 'add'"
>新增</el-button
>
</template>
<template #menu="{ row, index }">
<el-button
type="primary"
text
icon="el-icon-edit"
@click="rowUpdate(row)"
v-permission="pageCode + 'modify'"
>编辑</el-button
>
<el-popconfirm
title="此操作将删除数据, 是否继续?"
confirm-button-text="删除"
cancel-button-text="取消"
icon="el-icon-delete"
icon-color="red"
@confirm="rowDel(row, index)"
>
<template #reference>
<el-button type="primary" text icon="el-icon-delete" v-permission="pageCode + 'remove'"
>删除</el-button
>
</template>
</el-popconfirm>
</template>
</avue-crud>
<AddPage ref="addPage" @refresh="onLoad" />
<ModifyPage ref="modifyPage" @refresh="onLoad" />
<ViewPage ref="viewPage" />
</template>
<script setup>
import { ref, getCurrentInstance, reactive } from 'vue'
import AddPage from './add.vue'
import ModifyPage from './modify.vue'
import ViewPage from './view.vue'
//获取this
let { proxy } = getCurrentInstance()
const option = ref(null)
const data = ref(null)
let moduleParam = reactive({
entityType: 'personProductModel',
pageType: 'addOrModify'
})
let formData = ref({})
let queryCondition = ref({})
let pageInfo = reactive({
// 页码
pageNum: 1,
// 页码大小
pageSize: 10
})
// 排序信息
let sortInfo = reactive({
sort_field: 'id',
sort_sortType: 'descending'
})
let page = reactive({
total: 0,
currentPage: 1,
pageSize: 10
})
const MODULE_CODE = 'costManagement'
const ENTITY_TYPE = 'costTable'
const pageCode = `${MODULE_CODE}:${ENTITY_TYPE}:`
const api = eval('proxy.$api.' + MODULE_CODE + '.' + ENTITY_TYPE)
option.value = {
dialogWidth: '80%', //弹窗宽度
searchMenuSpan: 6, //搜索按钮宽度
addBtn: false, //隐藏新增按钮
editBtn: false, //隐藏编辑按钮
delBtn: false, //隐藏删除按钮
column: [
{
label: '项目名称',
labelWidth: 120,
prop: 'projectName',
search: true,
searchLabelWidth: 120
},
{
label: '造价日期',
labelWidth: 120,
prop: 'costDate',
type: 'date',
format: 'YYYY-MM-DD',
search: true,
searchLabelWidth: 120
},
{
label: '总投资',
labelWidth: 120,
prop: 'totalInvestment',
type: 'number',
precision: 2,
mim: 0,
searchLabelWidth: 120,
disabled: true
}
]
// group: [
// {
// label: '造价信息',
// prop: 'jbxx',
// icon: 'el-icon-edit-outline',
// column: [
// {
// label: '项目名称',
// labelWidth: 120,
// prop: 'projectName',
// search: true,
// searchLabelWidth: 120,
// },
// {
// label: '总投资',
// labelWidth: 120,
// prop: 'totalInvestment',
// type: 'number',
// precision: 2,
// mim: 0,
// searchLabelWidth: 120,
// disabled: true,
// }
// ]
// },
// {
// label: '造价详情',
// prop: 'jbxx',
// icon: 'el-icon-edit-outline',
// column: [
// {
// label: '',
// prop: 'id'
// },
// ]
// }
// ]
}
data.value = []
function rowSave(row, done, loading) {
proxy.$refs.addPage.init()
}
function rowDel(row, index) {
api.remove(row.id)
onLoad()
}
function rowUpdate(row, index, done, loading) {
proxy.$refs.modifyPage.init(row.id)
}
function onLoad() {
pageInfo.pageNum = page.currentPage
const params = Object.assign(queryCondition.value, pageInfo, sortInfo)
api.page(params).then((res) => {
data.value = res.data.records
page.total = res.data.total
// res.data.total
})
}
function rowDblclick(row, index) {
proxy.$refs.viewPage.init(row.id)
}
function searchChange(val, done) {
onLoad()
done()
}
</script>
<style>
.el-input,
.el-input-number {
width: 100% !important;
}
</style>