233 lines
7.0 KiB
Vue
233 lines
7.0 KiB
Vue
<template>
|
|
<!-- 基础页面 -->
|
|
<div class="app-container">
|
|
<el-form v-show="showSearch" :model="queryParams" ref="queryForm" size="small" inline @submit.native.prevent>
|
|
<el-form-item prop="keyWord">
|
|
<el-input
|
|
class="w240"
|
|
v-model="queryParams.keyWord"
|
|
placeholder="请输入关键字"
|
|
clearable
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
|
|
<!-- 表单按钮 -->
|
|
<el-form-item>
|
|
<el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
|
|
<el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
|
|
<el-row :gutter="10" class="mb8">
|
|
<el-col :span="1.5">
|
|
<el-button type="" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
|
|
</el-col>
|
|
<el-col :span="1.5">
|
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增项目部</el-button>
|
|
</el-col>
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
</el-row>
|
|
|
|
<el-table :data="tableList" fit highlight-current-row style="width: 100%" border>
|
|
<el-table-column
|
|
type="index"
|
|
width="55"
|
|
label="序号"
|
|
align="center"
|
|
:index="(index) => (queryParams.pageNum - 1) * queryParams.pageSize + index + 1"
|
|
/>
|
|
<el-table-column
|
|
v-for="(column, index) in tableColumns"
|
|
show-overflow-tooltip
|
|
:key="index"
|
|
:label="column.label"
|
|
:prop="column.prop"
|
|
align="center"
|
|
>
|
|
<!-- 插槽 -->
|
|
<template v-slot="{ row }" v-if="column.prop == 'useStatus'">
|
|
<span>
|
|
<el-switch
|
|
v-model="row.useStatus"
|
|
active-value="1"
|
|
inactive-value="0"
|
|
@change="changeSwitch(row)"
|
|
></el-switch>
|
|
</span>
|
|
</template>
|
|
<template v-slot="{ row }" v-else-if="column.prop == 'bidNum'">
|
|
<span v-if="row.bidNum > 0" @click="handleLot(row)" style="color: #409eff; cursor: pointer">{{
|
|
row.bidNum
|
|
}}</span>
|
|
<span v-else>{{ row.bidNum }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<!-- 操作 -->
|
|
<el-table-column label="操作" align="center" width="150">
|
|
<template slot-scope="{ row }">
|
|
<el-button type="text" size="mini" icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
|
|
<el-button type="text" size="mini" icon="el-icon-delete" style="color: #f56c6c" @click="handleDelete(row)">
|
|
删除
|
|
</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
|
|
<!-- 分页 -->
|
|
<pagination
|
|
v-show="total > 0"
|
|
:total="total"
|
|
:page.sync="queryParams.pageNum"
|
|
:limit.sync="queryParams.pageSize"
|
|
@pagination="getList"
|
|
/>
|
|
|
|
<LotList ref="lotList" />
|
|
<AddEditProDep ref="addEditProDep" @getList="getList" />
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { getDepartsAPI, editDepartStatusAPI, delDepartAPI } from '@/api/project-manage/index.js'
|
|
|
|
export default {
|
|
components: {
|
|
LotList: () => import('./components/LotList'),
|
|
AddEditProDep: () => import('./components/AddEditProDep'),
|
|
},
|
|
data() {
|
|
return {
|
|
showSearch: true,
|
|
queryParams: {
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
keyWord: '', // 关键字
|
|
},
|
|
total: 0, // 总条数
|
|
// 表头
|
|
tableColumns: [
|
|
{ label: '分公司名称', prop: 'branchCompanyName' },
|
|
{ label: '项目部名称', prop: 'departName' },
|
|
{ label: '状态', prop: 'useStatus' },
|
|
{ label: '标段工程数量', prop: 'bidNum' },
|
|
{ label: '更新人员', prop: 'updateUserName' },
|
|
{ label: '更新时间', prop: 'updateTime' },
|
|
{ label: '备注', prop: 'remark' },
|
|
],
|
|
// 表格数据
|
|
tableList: [],
|
|
}
|
|
},
|
|
created() {
|
|
this.getList()
|
|
},
|
|
methods: {
|
|
// 查询
|
|
handleQuery() {
|
|
this.queryParams.pageNum = 1
|
|
this.getList()
|
|
},
|
|
// 重置
|
|
handleReset() {
|
|
this.queryParams.pageNum = 1
|
|
this.queryParams.pageSize = 10
|
|
this.$refs.queryForm.resetFields()
|
|
this.getList()
|
|
},
|
|
// 获取列表
|
|
async getList() {
|
|
console.log('列表-查询', this.queryParams)
|
|
const loading = this.$loading({ text: '加载中...' })
|
|
try {
|
|
const params = { ...this.queryParams }
|
|
const res = await getDepartsAPI(params)
|
|
// console.log('🚀 ~ 获取列表 ~ res:', res)
|
|
this.tableList = res.rows
|
|
this.total = res.total
|
|
loading.close()
|
|
} catch (error) {
|
|
console.log('🚀 ~ 获取列表 ~ error:', error)
|
|
this.tableList = []
|
|
this.total = 0
|
|
loading.close()
|
|
}
|
|
},
|
|
changeSwitch(row) {
|
|
console.log('🚀 ~ changeSwitch ~ row:', row)
|
|
this.$confirm('是否确认修改状态?', '提示', {
|
|
type: 'warning',
|
|
showCancelButton: true,
|
|
cancelButtonText: '取消',
|
|
confirmButtonText: '确定',
|
|
})
|
|
.then(() => {
|
|
editDepartStatusAPI({ id: row.id, useStatus: row.useStatus }).then((res) => {
|
|
if (res.code == 200) {
|
|
this.$message({
|
|
type: 'success',
|
|
message: '修改成功',
|
|
})
|
|
this.getList()
|
|
}
|
|
})
|
|
})
|
|
.catch(() => {
|
|
console.log('取消修改', row.useStatus)
|
|
row.useStatus = row.useStatus == '1' ? '0' : '1'
|
|
this.$message({
|
|
type: 'info',
|
|
message: '已取消',
|
|
})
|
|
})
|
|
},
|
|
handleLot(data) {
|
|
this.$refs.lotList.openDialog(data)
|
|
},
|
|
handleAdd() {
|
|
console.log('🚀 ~ handleAdd ~:')
|
|
this.$refs.addEditProDep.openDialog({ dialogTitle: '新增项目部', isAdd: true })
|
|
},
|
|
handleEdit(row) {
|
|
console.log('🚀 ~ handleEdit ~ row:', row)
|
|
this.$refs.addEditProDep.openDialog({ ...row, dialogTitle: '编辑项目部', isAdd: false })
|
|
},
|
|
handleDelete(row) {
|
|
console.log('🚀 ~ handleDelete ~ row:', row)
|
|
this.$confirm('是否确定删除?', '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning',
|
|
})
|
|
.then(() => {
|
|
delDepartAPI({ id: row.id }).then((res) => {
|
|
this.$message({
|
|
type: 'success',
|
|
message: '删除成功!',
|
|
})
|
|
this.getList()
|
|
})
|
|
})
|
|
.catch(() => {
|
|
console.log('取消删除')
|
|
})
|
|
},
|
|
// 导出数据
|
|
handleExport() {
|
|
try {
|
|
let fileName = `项目部管理_${new Date().getTime()}.xLsx`
|
|
let url = 'smart-site/depart/export'
|
|
const params = { ...this.queryParams }
|
|
console.log('🚀 ~ 导出 ~ params:', params)
|
|
this.download(url, params, fileName)
|
|
} catch (error) {
|
|
console.log('导出数据失败', error)
|
|
}
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped></style>
|