ah_jjzhgd_webservice/ah-jjzhgd-web/src/views/basic/area/index.vue

340 lines
10 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="app-container">
<div class="filter-container">
<el-input
v-model="listQuery.proName"
placeholder="工程名称"
style="width: 200px"
class="filter-item"
:maxlength="30"
@keyup.enter.native="handleFilter"
/>
<el-input
v-model="listQuery.areaName"
placeholder="区域名称"
style="width: 200px"
class="filter-item ml-20"
:maxlength="30"
@keyup.enter.native="handleFilter"
/>
<el-button
style="margin-left: 40px"
class="filter-item"
type="primary"
@click="handleFilter"
>
查询
</el-button>
<el-button class="filter-item" style="margin-left: 10px" type="primary" @click="handleCreate">
新增
</el-button>
<!-- <el-button v-throttle-click="handleExport" class="filter-item" style="margin-left: 10px" type="primary">
导出
</el-button> -->
</div>
<el-table
:key="tableKey"
v-loading="listLoading"
:data="list"
border
fit
highlight-current-row
style="width: 100%"
:max-height="tableHeight"
>
<el-table-column label="序号" align="center" width="80" type="index">
<template scope="scope">
<span>{{ (listQuery.pageNum - 1) * 10 + scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column label="区域名称" align="center" prop="areaName" />
<el-table-column label="标段工程" align="center" prop="proName" />
<el-table-column label="备注" align="center" prop="remarks" />
<el-table-column label="杆塔名称" align="center" prop="gtName" />
<el-table-column label="是否是有限空间" align="center" prop="areaType">
<template slot-scope="{ row }">
{{ row.areaType && getStatus(row.areaType) }}
</template>
</el-table-column>
<!-- <el-table-column label="设备状态" align="center" prop="onLine">-->
<!-- <template slot-scope="{ row }">-->
<!-- {{ getStatus(row.onLine) }}-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="160">
<template slot-scope="{ row }">
<el-button type="primary" size="mini" @click="handleUpdate(row)">编辑</el-button>
<el-button type="danger" size="mini" @click="handleDelete(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="listQuery.pageNum"
:limit.sync="listQuery.pageSize"
@pagination="getList"
/>
<!-- 编辑模态框-->
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" width="630px" @closed="handleClosedModal">
<el-form
ref="dataForm"
:rules="rules"
:model="temp"
label-position="right"
label-width="150px"
>
<el-form-item label="区域名称:" prop="areaName">
<el-input v-model="temp.areaName" placeholder="区域名称" :maxlength="50" />
</el-form-item>
<el-form-item label="标段工程:" prop="bidCode">
<ProjectSelect :bind-type.sync="currentProjectType" :bind-value.sync="temp.bidCode" @change="handleProjectChange" />
</el-form-item>
<el-form-item v-if="currentProjectType === '线路'" label="杆塔ID" prop="gtId">
<GtSelect ref="gtSelectRef" :bid-code="temp.bidCode" :bind-value.sync="temp.gtId" />
</el-form-item>
<el-form-item label="备注:" prop="remarks">
<el-input v-model="temp.remarks" placeholder="备注" :maxlength="200" />
</el-form-item>
<el-form-item label="是否是有限空间:" prop="areaType">
<el-select v-model="temp.areaType" placeholder="请选择" style="width: 100%" clearable>
<el-option v-for="item in Object.keys(areaTypeMap)" :key="item" :value="Number(item)" :label="areaTypeMap[item]" />
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false"> 关闭 </el-button>
<el-button v-throttle-click="dialogStatus === 'create' ? createData : updateData" type="primary">
提交
</el-button>
</div>
</el-dialog>
<modul-dialog ref="pwdVerifiersDialog" :title="componentDialog.title" :width="componentDialog.width"
v-model="componentDialog.openFalg">
<component :is="componentDialog.modulName" />
</modul-dialog>
</div>
</template>
<script>
import Pagination from '@/components/Pagination'
import _ from 'lodash/fp'
// import { downloadFile } from '@/utils/download'
import { addAreaItem, deleteAreaItem, getAreaList, updateAreaItem } from '@/api/basic/area'
import ProjectSelect from '@/views/device/sideband/components/ProjectSelect.vue'
import GtSelect from '@/views/device/sideband/components/GtSelect.vue'
import { verifyPwd } from '@/api/verifyPwd'
import modulDialog from '@/components/pwdVerifiers/pwdVerifiers.vue'
const areaTypeMap = {
0: '否',
1: '是'
}
const defaultTmp = {
areaName: '',
bidCode: '',
remarks: '',
gtId: '',
areaType: ''
}
export default {
components: { GtSelect, ProjectSelect, Pagination,modulDialog },
data() {
return {
checkRow:{},
componentDialog: {
modulName: '', //组件名称
title: '',
width: '',
openFalg: false
},
tableKey: 0,
list: [],
currentProjectType: '',
areaTypeMap: areaTypeMap,
total: 0,
listLoading: false,
listQuery: {
pageNum: 1,
pageSize: 10,
proName: '',
areaName: ''
},
tableHeight: 650,
temp: _.cloneDeep(defaultTmp),
dialogFormVisible: false,
dialogStatus: '',
textMap: {
update: '编辑',
create: '新增'
},
rules: {
areaName: [{ required: true, message: '不能为空', trigger: 'blur' }],
bidCode: [{ required: true, message: '不能为空', trigger: 'change' }],
areaType: [{ required: true, message: '不能为空', trigger: 'change' }],
remarks: [{ required: false, message: '不能为空', trigger: 'blur' }],
gtId: [{ required: false, message: '不能为空', trigger: 'change' }]
}
}
},
created() {
this.getList()
},
methods: {
openModulDialog(title, modulName, width, openFalg) {
this.componentDialog.title = title
this.componentDialog.modulName = modulName
this.componentDialog.width = width
this.componentDialog.openFalg = openFalg
},
verifiersPwd(data) {
verifyPwd(data).then((response) => {
this.$message({
showClose: true,
message: response.msg,
type: 'success',
duration: 500
})
// 关闭验证密码页面
this.componentDialog.openFalg = false;
if (this.$refs.pwdVerifiersDialog) {
this.$refs.pwdVerifiersDialog.resetForm();
}
this.isOpenEditDialog();
})
},
getStatus(val) {
return this.areaTypeMap[val]
},
// 导出
handleExport() {
// exportArea().then(res => {
// downloadFile({ fileName: '设备详情.xlsx', fileData: res, fileType: 'application/vnd.ms-excel;charset=utf-8' })
// })
},
getList() {
this.listLoading = true
getAreaList(this.listQuery).then((response) => {
this.list = response.rows.map(item => {
return item
})
this.total = response.total
})
setTimeout(()=>{
this.listLoading = false
},500)
},
// 查询
handleFilter() {
this.listQuery.pageNum = 1
this.getList()
},
// 新增
handleCreate() {
this.dialogStatus = 'create'
this.dialogFormVisible = true
},
createData() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
addAreaItem(this.temp).then((response) => {
this.$message({
showClose: true,
message: response.msg,
type: 'success',
duration: 2000
})
this.getList()
this.dialogFormVisible = false
}).finally(() => {
// this.dialogFormVisible = false
})
}
})
},
// 编辑
handleUpdate(row) {
this.checkRow = _.cloneDeep(row);
this.openModulDialog('验证密码', 'pwdVerifiers', '600px', true)
},
isOpenEditDialog(){
let row = this.checkRow;
this.temp = Object.assign({}, row)
this.temp.areaType = Number(this.temp.areaType)
this.dialogStatus = 'update'
this.dialogFormVisible = true
},
updateData() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.commitUpdateData();
}
})
},
commitUpdateData() {
updateAreaItem(this.temp).then((response) => {
this.$message({
showClose: true,
message: response.msg,
type: 'success',
duration: 2000
})
this.checkRow = {};
this.getList()
this.dialogFormVisible = false
}).finally(() => {
})
},
// 删除数据
handleDelete(row, index) {
this.$confirm(`确定要删除该数据吗?`, {
type: 'warning',
title: '操作提示',
beforeClose: async(action, instance, done) => {
if (action === 'confirm') {
deleteAreaItem({ areaId: row.areaId }).then((response) => {
done()
this.$message({
showClose: true,
message: response.msg,
type: 'success',
duration: 2000
})
this.getList()
})
} else {
done()
}
}
})
},
handleClosedModal() {
this.$refs['dataForm'].resetFields()
this.temp = _.cloneDeep(defaultTmp)
this.currentProjectType = ''
},
handleProjectChange(val) {
const gtSelectRef = this.$refs.gtSelectRef
this.$nextTick(() => {
gtSelectRef.getList(() => {
const gtList = gtSelectRef.options
if (this.temp.areaId && !gtList.find(item => item.value === this.temp.gtId)) {
this.temp.areaId = ''
this.bidCode = ''
this.gtId = ''
}
})
})
}
}
}
</script>