devicesmgt/sgzb-ui/src/views/base/section/index.vue

381 lines
13 KiB
Vue
Raw Normal View History

2023-12-12 13:36:08 +08:00
<template>
2024-01-22 09:18:46 +08:00
<div class="app-container" id="section">
2024-04-25 16:00:19 +08:00
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="标段工程名称" prop="lotName">
2023-12-12 13:36:08 +08:00
<el-input
v-model="queryParams.lotName"
placeholder="请输入标段工程名称"
2024-04-25 16:00:19 +08:00
clearable
maxlength="50"
2023-12-12 13:36:08 +08:00
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
2024-04-25 16:00:19 +08:00
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
2023-12-12 13:36:08 +08:00
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
2024-04-25 16:00:19 +08:00
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
2023-12-12 13:36:08 +08:00
</el-col>
<el-col :span="1.5">
2024-04-25 16:00:19 +08:00
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
</el-col>
2024-04-25 16:00:19 +08:00
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
2023-12-12 13:36:08 +08:00
</el-row>
2024-04-25 16:00:19 +08:00
<el-table v-loading="loading" :data="projectLot" @selection-change="handleSelectionChange">
2023-12-12 13:36:08 +08:00
<el-table-column type="selection" width="55" align="center" />
2024-04-25 16:03:49 +08:00
<<<<<<< HEAD
<el-table-column label="序号" align="center" type="index" />
2024-04-25 16:00:19 +08:00
<el-table-column label="标段工程名称" align="center" prop="lotName" :show-overflow-tooltip="true" />
<el-table-column label="工程类型" align="center" prop="typeName" :show-overflow-tooltip="true" />
<el-table-column label="所属工程项目" align="center" prop="ownPro" :show-overflow-tooltip="true" />
<el-table-column label="所属上级" align="center" prop="deptName" :show-overflow-tooltip="true" />
<el-table-column label="联系人" align="center" prop="linkMan" :show-overflow-tooltip="true" />
<el-table-column label="联系电话" align="center" prop="telphone" :show-overflow-tooltip="true" />
2024-04-25 16:03:49 +08:00
=======
2024-04-25 14:51:15 +08:00
<el-table-column label="序号" align="center" width="80" type="index">
2024-04-25 16:03:49 +08:00
<template scope="scope">
2024-04-25 14:51:15 +08:00
<span>{{ (queryParams.pageNum - 1) * 10 + scope.$index + 1 }}</span>
2024-04-25 16:03:49 +08:00
</template>
2024-04-25 14:51:15 +08:00
</el-table-column>
2024-04-25 16:03:49 +08:00
<el-table-column label="标段工程名称" align="center" prop="lotName" :show-overflow-tooltip="true" />
<el-table-column label="工程类型" align="center" prop="typeName" :show-overflow-tooltip="true" />
<el-table-column label="所属工程项目" align="center" prop="ownPro" :show-overflow-tooltip="true" />
<el-table-column label="所属上级" align="center" prop="deptName" :show-overflow-tooltip="true" />
<el-table-column label="联系人" align="center" prop="linkMan" :show-overflow-tooltip="true" />
<el-table-column label="联系电话" align="center" prop="telphone" :show-overflow-tooltip="true" />
>>>>>>> 0e681358a987a27cf0ca5da93cd80f30abbe2c0c
<el-table-column label="状态" align="center" prop="status" width="180">
2023-12-12 13:36:08 +08:00
<template slot-scope="scope">
<el-switch
2023-12-22 17:13:57 +08:00
active-value="0"
inactive-value="1"
@change="changeStatus(scope.row)"
2023-12-22 17:13:57 +08:00
v-model="scope.row.status"
2024-04-25 16:00:19 +08:00
></el-switch>
2023-12-12 13:36:08 +08:00
</template>
</el-table-column>
2024-04-25 16:00:19 +08:00
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
2023-12-12 13:36:08 +08:00
<template slot-scope="scope">
2024-04-25 16:00:19 +08:00
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
2023-12-12 13:36:08 +08:00
</template>
</el-table-column>
</el-table>
<pagination
2023-12-22 17:13:57 +08:00
v-show="total > 0"
2023-12-12 13:36:08 +08:00
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改参数配置对话框 -->
2024-03-19 11:12:02 +08:00
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body :close-on-click-modal="false">
2023-12-12 13:36:08 +08:00
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="标段工程名称" prop="lotName">
2024-04-25 16:00:19 +08:00
<el-input v-model="form.lotName" placeholder="请输入标段工程名称" maxlength="50" />
</el-form-item>
2024-03-04 16:39:06 +08:00
<!-- <el-form-item label="所属工程项目" prop="ownPro">
2023-12-22 17:13:57 +08:00
<el-select
2024-02-26 18:43:14 +08:00
v-model="form.ownPro" filterable
2023-12-22 17:13:57 +08:00
placeholder="请选择所属工程项目"
style="width: 100%"
>
<el-option
v-for="item in ProjectSelect"
:key="item.proName"
:label="item.proName"
:value="item.proName"
2023-12-22 17:13:57 +08:00
v-if="item.status != '1'"
></el-option>
</el-select>
2024-03-04 16:39:06 +08:00
</el-form-item> -->
<el-form-item label="工程类型" prop="typeId">
<!-- <el-input v-model="form.typeId" placeholder="请选择工程类型" /> -->
2023-12-22 17:13:57 +08:00
<el-select
2024-04-25 16:00:19 +08:00
v-model="form.typeId"
filterable
2023-12-22 17:13:57 +08:00
placeholder="请选择工程类型"
style="width: 100%"
@change="selecType"
>
<el-option
v-for="item in typeList"
:key="item.id"
:label="item.name"
:value="item.id"
2023-12-22 17:13:57 +08:00
v-if="item.status != '1'"
></el-option>
</el-select>
2023-12-12 13:36:08 +08:00
</el-form-item>
<el-form-item label="所属上级" prop="deptId">
2024-04-25 16:03:49 +08:00
<<<<<<< HEAD
2024-04-25 16:00:19 +08:00
<treeselect v-model="form.deptId" :options="deptOptions" placeholder="请选择所属上级" @select="select" />
2024-04-25 16:03:49 +08:00
=======
2023-12-22 17:13:57 +08:00
<treeselect
v-model="form.deptId"
:options="deptOptions"
2024-04-25 16:03:49 +08:00
noChildrenText="没有数据了"
noOptionsText="没有数据"
noResultsText="没有搜索结果"
2023-12-22 17:13:57 +08:00
placeholder="请选择所属上级"
@select="select"
/>
2024-04-25 16:03:49 +08:00
>>>>>>> 0e681358a987a27cf0ca5da93cd80f30abbe2c0c
2023-12-12 13:36:08 +08:00
</el-form-item>
<el-form-item label="联系人" prop="linkMan">
2024-04-25 16:00:19 +08:00
<el-input v-model="form.linkMan" placeholder="请输入联系人" maxlength="20" />
2023-12-12 13:36:08 +08:00
</el-form-item>
<el-form-item label="联系电话" prop="telphone">
2024-04-25 16:21:40 +08:00
<el-input v-model="form.telphone" placeholder="请输入联系电话" maxlength="11" onkeyup="this.value = this.value.replace(/[^\d]/g,'');"/>
2023-12-12 13:36:08 +08:00
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" :loading="isLoading" @click="submitForm"> </el-button>
2023-12-12 13:36:08 +08:00
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
2024-04-25 16:00:19 +08:00
import { addProjectLot, delProjectLot, ProjectLotList, updateProjectLot, getProjectSelect } from '@/api/base/base'
import { unitTypeList } from '@/api/base/base'
import { deptTreeSelect } from '@/api/system/user'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
2023-12-12 13:36:08 +08:00
export default {
2024-04-25 16:00:19 +08:00
name: 'Section',
2023-12-12 13:36:08 +08:00
dicts: ['sys_normal_disable'],
components: { Treeselect },
2023-12-12 13:36:08 +08:00
data() {
return {
isLoading: false,
2023-12-12 13:36:08 +08:00
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 表格数据
projectLot: [],
2023-12-22 17:13:57 +08:00
//字典数据
typeList: [],
//所属项目工程列表
ProjectSelect: [],
// 部门树选项
deptOptions: undefined,
2023-12-12 13:36:08 +08:00
// 弹出层标题
2024-04-25 16:00:19 +08:00
title: '',
2023-12-12 13:36:08 +08:00
// 是否显示弹出层
open: false,
// 日期范围
dateRange: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
lotName: undefined,
2023-12-12 13:36:08 +08:00
dictType: undefined,
2024-04-25 16:00:19 +08:00
status: undefined,
2023-12-12 13:36:08 +08:00
},
// 表单参数
form: {},
// 表单校验
rules: {
2024-04-25 16:00:19 +08:00
lotName: [{ required: true, message: '标段工程名称不能为空', trigger: 'blur' }],
2023-12-22 17:13:57 +08:00
// ownPro: [
// { required: true, message: "所属工程项目不能为空", trigger: "blur" }
// ],
2024-04-25 16:00:19 +08:00
typeId: [{ required: true, message: '工程类型不能为空', trigger: 'blur' }],
deptId: [{ required: true, message: '所属上级不能为空', trigger: 'blur' }],
// ownPro: [
// { required: true, message: "所属工程项目", trigger: "blur" }
// ]
2024-04-25 16:00:19 +08:00
},
}
2023-12-12 13:36:08 +08:00
},
created() {
this.getType()
this.getDeptTree()
2024-04-25 16:00:19 +08:00
this.getList()
this.getProjectSelect()
2023-12-12 13:36:08 +08:00
},
methods: {
//获取所属项目工程下拉数据
2023-12-22 17:13:57 +08:00
getProjectSelect() {
getProjectSelect().then(response => {
2024-04-25 16:00:19 +08:00
this.ProjectSelect = response.rows
2023-12-22 17:13:57 +08:00
})
},
//获取工程类型
2023-12-22 17:13:57 +08:00
getType() {
2024-04-25 16:00:19 +08:00
unitTypeList({ id: '5' }).then(response => {
this.typeList = response.rows
2023-12-22 17:13:57 +08:00
})
},
2023-12-22 17:13:57 +08:00
selecType(id) {
// this.typeList.forEach(item => {
// if(item.id == id){
// this.form.typeName = item.name
// }
// });
},
/** 查询部门下拉树结构 */
getDeptTree() {
deptTreeSelect().then(response => {
2024-04-25 16:00:19 +08:00
this.deptOptions = response.data
})
},
2023-12-22 17:13:57 +08:00
select(row) {
2024-04-25 16:00:19 +08:00
// console.log(row.label)
// this.form.deptName = row.label;
},
//更新
2023-12-22 17:13:57 +08:00
changeStatus(row) {
let param = {
2023-12-22 17:13:57 +08:00
lotId: row.lotId,
2024-04-25 16:00:19 +08:00
status: row.status,
}
updateProjectLot(param).then(response => {
2024-04-25 16:00:19 +08:00
this.getList()
})
},
2023-12-12 13:36:08 +08:00
/** 查询字典类型列表 */
getList() {
2024-04-25 16:00:19 +08:00
this.loading = true
ProjectLotList(this.queryParams).then(response => {
2024-04-25 16:00:19 +08:00
this.projectLot = response.rows
this.total = response.total
this.loading = false
})
2023-12-12 13:36:08 +08:00
},
// 取消按钮
cancel() {
2024-04-25 16:00:19 +08:00
this.open = false
this.reset()
2023-12-12 13:36:08 +08:00
},
// 表单重置
reset() {
this.form = {
lotId: undefined,
lotName: undefined,
2023-12-12 13:36:08 +08:00
dictType: undefined,
2024-04-25 16:00:19 +08:00
status: '0',
remark: undefined,
}
this.resetForm('form')
2023-12-12 13:36:08 +08:00
},
/** 搜索按钮操作 */
handleQuery() {
2024-04-25 16:00:19 +08:00
this.queryParams.pageNum = 1
this.getList()
2023-12-12 13:36:08 +08:00
},
/** 重置按钮操作 */
resetQuery() {
2024-04-25 16:00:19 +08:00
this.dateRange = []
this.resetForm('queryForm')
this.handleQuery()
2023-12-12 13:36:08 +08:00
},
/** 新增按钮操作 */
handleAdd() {
2024-04-25 16:00:19 +08:00
this.reset()
this.open = true
this.title = '新增'
2023-12-12 13:36:08 +08:00
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.lotId)
2023-12-22 17:13:57 +08:00
this.single = selection.length != 1
2023-12-12 13:36:08 +08:00
this.multiple = !selection.length
},
/** 修改按钮操作 */
handleUpdate(row) {
2024-04-25 16:00:19 +08:00
this.reset()
2023-12-22 17:13:57 +08:00
ProjectLotList({ lotId: row.lotId }).then(response => {
this.form = response.rows[0]
2024-04-25 16:00:19 +08:00
})
this.open = true
this.title = '编辑'
2023-12-12 13:36:08 +08:00
},
/** 提交按钮 */
2023-12-22 17:13:57 +08:00
submitForm: function () {
2024-04-25 16:00:19 +08:00
this.$refs['form'].validate(valid => {
2023-12-12 13:36:08 +08:00
if (valid) {
2024-04-25 16:00:19 +08:00
this.isLoading = true
if (this.form.lotId != undefined) {
2024-04-25 16:00:19 +08:00
updateProjectLot(this.form)
.then(response => {
this.$modal.msgSuccess('修改成功')
this.open = false
this.isLoading = false
this.getList()
})
.catch(() => {
this.isLoading = false
})
2023-12-12 13:36:08 +08:00
} else {
2024-04-25 16:00:19 +08:00
addProjectLot(this.form)
.then(response => {
this.$modal.msgSuccess('新增成功')
this.open = false
this.isLoading = false
this.getList()
})
.catch(() => {
this.isLoading = false
})
2023-12-12 13:36:08 +08:00
}
}
2024-04-25 16:00:19 +08:00
})
2023-12-12 13:36:08 +08:00
},
/** 删除按钮操作 */
handleDelete(row) {
2024-04-25 16:00:19 +08:00
const lotIds = row.lotId || this.ids
this.$modal
.confirm('是否确认删除该数据项?')
.then(function () {
return delProjectLot(lotIds)
})
.then(() => {
this.getList()
this.$modal.msgSuccess('删除成功')
})
.catch(() => {})
2023-12-12 13:36:08 +08:00
},
/** 导出按钮操作 */
handleExport() {
2024-04-25 16:00:19 +08:00
this.download(
'base/bmProjectLot/export',
{
...this.queryParams,
dataCondition: this.ids,
},
`标段工程_${new Date().getTime()}.xlsx`
)
2023-12-12 13:36:08 +08:00
},
/** 刷新缓存按钮操作 */
handleRefreshCache() {
refreshCache().then(() => {
2024-04-25 16:00:19 +08:00
this.$modal.msgSuccess('刷新成功')
this.$store.dispatch('dict/cleanDict')
})
},
},
}
2023-12-12 13:36:08 +08:00
</script>