|
@@ -19,82 +19,40 @@
|
|
|
</el-tab-pane>
|
|
|
</el-tabs>
|
|
|
|
|
|
- <!--表格 -->
|
|
|
- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
|
|
|
- <el-form-item label="表记编号" prop="deviceCode">
|
|
|
- <el-input v-model="queryParams.deviceCode" placeholder="请输入设备代码" clearable @keyup.enter.native="handleQuery" />
|
|
|
+ <!-- 填报按钮 -->
|
|
|
+ <el-button type="primary" icon="el-icon-info" size="mini" @click="handleRecord">填报</el-button>
|
|
|
+ <!-- 历史抄表记录 -->
|
|
|
+ <el-form ref="recListForm" :model="recListForm" label-width="80px">
|
|
|
+ <el-form-item label="年份" prop="year">
|
|
|
+ <el-date-picker v-model="recListForm.year" :clearable="false" @change="getHistoryList" value-format="yyyy" type="year"
|
|
|
+ placeholder="选择年份">
|
|
|
+ </el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="计量设备" prop="year">
|
|
|
+ <el-input disabled :value="recListForm.deviceCode" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item>
|
|
|
- <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>
|
|
|
+ <el-form-item label="抄表历史" prop="recList">
|
|
|
+ <el-table v-loading="loading" :data="recListForm.recList" max-height="280px">
|
|
|
+ <el-table-column label="年份" align="center" prop="year" />
|
|
|
+ <el-table-column label="月份" align="center" prop="meterMonth" >
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <!-- 使用 JavaScript 字符串方法截取月份部分 -->
|
|
|
+ {{ scope.row.meterMonth.slice(-2) }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="抄表示数" align="center" prop="meterReading" />
|
|
|
+ <el-table-column label="用量" align="center" prop="increase" />
|
|
|
+ <el-table-column label="抄表日期" align="center" prop="meterTime" />
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="!canEdit(scope.row.meterMonth)"
|
|
|
+ @click="updateRecord(scope.row)">修改</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
- <el-table v-loading="loading" :data="deviceList">
|
|
|
- <el-table-column label="表计名称" align="left" prop="deviceName" width="200px">
|
|
|
- <template slot-scope="scope">
|
|
|
- <span>{{ scope.row.deviceName }}</span>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="设备代码" align="center" prop="deviceCode" />
|
|
|
- <el-table-column label="计量标签" align="center" prop="objTag">
|
|
|
- <template slot-scope="scope">
|
|
|
- <span>{{ getObjTagName(scope.row.objTag) }}</span>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="抄表周期" align="center" prop="colCycle">
|
|
|
- <template slot-scope="scope">
|
|
|
- <span>{{ getColCycleName(scope.row.colCycle) }}</span>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="上次抄表日期" align="center" prop="lastTime" />
|
|
|
- <el-table-column label="上次抄表示数" align="center" prop="lastReading" />
|
|
|
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
- <template slot-scope="scope">
|
|
|
- <el-button size="mini" type="text" :disabled="!canFill(scope.row.lastTime)" icon="el-icon-info" @click="handleRecord(scope.row)">
|
|
|
- 填报</el-button>
|
|
|
- <el-button size="mini" type="text" icon="el-icon-document" @click="handleViewRec(scope.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" />
|
|
|
- <!-- 历史抄表记录 -->
|
|
|
-<!-- <el-dialog :title="title" :visible.sync="recListOpen" width="1200px" append-to-body>-->
|
|
|
- <el-form ref="recListForm" :model="recListForm" label-width="80px">
|
|
|
- <el-form-item label="年份" prop="year">
|
|
|
- <el-date-picker v-model="recListForm.year" :clearable="false" @change="getHistoryList" value-format="yyyy" type="year"
|
|
|
- placeholder="选择年份">
|
|
|
- </el-date-picker>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="计量设备" prop="year">
|
|
|
- <el-input disabled :value="recListForm.deviceCode" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="抄表历史" prop="recList">
|
|
|
- <el-table v-loading="loading" :data="recListForm.recList" max-height="280px">
|
|
|
- <el-table-column label="年份" align="center" prop="year" />
|
|
|
- <el-table-column label="月份" align="center" prop="meterMonth" >
|
|
|
- <template slot-scope="scope">
|
|
|
- <!-- 使用 JavaScript 字符串方法截取月份部分 -->
|
|
|
- {{ scope.row.meterMonth.slice(-2) }}
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="抄表示数" align="center" prop="meterReading" />
|
|
|
- <el-table-column label="用量" align="center" prop="increase" />
|
|
|
- <el-table-column label="抄表日期" align="center" prop="meterTime" />
|
|
|
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
- <template slot-scope="scope">
|
|
|
- <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="!canEdit(scope.row.meterMonth)"
|
|
|
- @click="updateRecord(scope.row)">修改</el-button>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
-<!-- <div slot="footer" class="dialog-footer">-->
|
|
|
-<!-- <el-button @click="closeRecList">关 闭</el-button>-->
|
|
|
-<!-- </div>-->
|
|
|
-<!-- </el-dialog>-->
|
|
|
+
|
|
|
<!-- 填报 -->
|
|
|
<el-dialog :title="fillTitle" :visible.sync="fillFormOpen" width="500px" append-to-body>
|
|
|
<el-form ref="fillForm" :model="fillForm" label-width="150px">
|
|
@@ -127,43 +85,6 @@
|
|
|
<el-button @click="fillCancel">取 消</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
-
|
|
|
-<!-- <!– 历史抄表记录 –>-->
|
|
|
-<!-- <el-dialog :title="title" :visible.sync="recListOpen" width="1200px" append-to-body>-->
|
|
|
-<!-- <el-form ref="recListForm" :model="recListForm" label-width="80px">-->
|
|
|
-<!-- <el-form-item label="年份" prop="year">-->
|
|
|
-<!-- <el-date-picker v-model="recListForm.year" :clearable="false" @change="getHistoryList" value-format="yyyy" type="year"-->
|
|
|
-<!-- placeholder="选择年份">-->
|
|
|
-<!-- </el-date-picker>-->
|
|
|
-<!-- </el-form-item>-->
|
|
|
-<!-- <el-form-item label="计量设备" prop="year">-->
|
|
|
-<!-- <el-input disabled :value="recListForm.deviceCode" />-->
|
|
|
-<!-- </el-form-item>-->
|
|
|
-<!-- <el-form-item label="抄表历史" prop="recList">-->
|
|
|
-<!-- <el-table v-loading="loading" :data="recListForm.recList" max-height="280px">-->
|
|
|
-<!-- <el-table-column label="年份" align="center" prop="year" />-->
|
|
|
-<!-- <el-table-column label="月份" align="center" prop="meterMonth" >-->
|
|
|
-<!-- <template slot-scope="scope">-->
|
|
|
-<!-- <!– 使用 JavaScript 字符串方法截取月份部分 –>-->
|
|
|
-<!-- {{ scope.row.meterMonth.slice(-2) }}-->
|
|
|
-<!-- </template>-->
|
|
|
-<!-- </el-table-column>-->
|
|
|
-<!-- <el-table-column label="抄表示数" align="center" prop="meterReading" />-->
|
|
|
-<!-- <el-table-column label="用量" align="center" prop="increase" />-->
|
|
|
-<!-- <el-table-column label="抄表日期" align="center" prop="meterTime" />-->
|
|
|
-<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
|
|
|
-<!-- <template slot-scope="scope">-->
|
|
|
-<!-- <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="!canEdit(scope.row.meterMonth)"-->
|
|
|
-<!-- @click="updateRecord(scope.row)">修改</el-button>-->
|
|
|
-<!-- </template>-->
|
|
|
-<!-- </el-table-column>-->
|
|
|
-<!-- </el-table>-->
|
|
|
-<!-- </el-form-item>-->
|
|
|
-<!-- </el-form>-->
|
|
|
-<!-- <div slot="footer" class="dialog-footer">-->
|
|
|
-<!-- <el-button @click="closeRecList">关 闭</el-button>-->
|
|
|
-<!-- </div>-->
|
|
|
-<!-- </el-dialog>-->
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
@@ -172,7 +93,7 @@
|
|
|
<script>
|
|
|
import { listDevice } from '@/api/device/meterDevice'
|
|
|
import { listMeterReadingByParam, getLastRecord, addMeterReading, updateMeterReading } from '@/api/device/meterRead'
|
|
|
-import { areaTreeSelect } from '@/api/basecfg/area'
|
|
|
+import { getDeviceTree } from '@/api/device/meterDevice'
|
|
|
import Treeselect from '@riophae/vue-treeselect'
|
|
|
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
|
|
import { dateFormat } from '@/utils/index.js'
|
|
@@ -249,10 +170,17 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- this.getAreaTreeSelect('0', 1)
|
|
|
- this.getList()
|
|
|
+ this.getAreaTreeSelect().then(() => {
|
|
|
+ this.getList();
|
|
|
+ /** 自动触发第一个 id 非 null 的树节点*/
|
|
|
+ this.$nextTick(() => {
|
|
|
+ const firstValidNode = this.findFirstValidNode(this.areaOptions);
|
|
|
+ if (firstValidNode) {
|
|
|
+ this.handleNodeClick(firstValidNode);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
},
|
|
|
-
|
|
|
methods: {
|
|
|
/** 查询计量设备列表 */
|
|
|
getList() {
|
|
@@ -288,7 +216,6 @@ export default {
|
|
|
this.handleQuery()
|
|
|
},
|
|
|
handleTabChange() {
|
|
|
- // 根据newTabName给someParam赋值
|
|
|
if (this.activeTab === 'first') {
|
|
|
// 电表抄表
|
|
|
this.queryParams.meterCls = '45'
|
|
@@ -296,37 +223,18 @@ export default {
|
|
|
// 水表抄表
|
|
|
this.queryParams.meterCls = '70'
|
|
|
}
|
|
|
+ this.getAreaTreeSelect() // 重新加载设备树
|
|
|
this.handleQuery()
|
|
|
},
|
|
|
- getObjTypeName(objType) {
|
|
|
- const typeMap = {
|
|
|
- 1: '区块',
|
|
|
- 2: '设备'
|
|
|
- }
|
|
|
- return typeMap[objType] || '未知'
|
|
|
- },
|
|
|
- getColCycleName(colCycle) {
|
|
|
- const cycleMap = {
|
|
|
- 0: '实时',
|
|
|
- 1: '分钟',
|
|
|
- 2: '小时',
|
|
|
- 3: '天',
|
|
|
- 4: '月'
|
|
|
- }
|
|
|
- return cycleMap[colCycle] || ''
|
|
|
- },
|
|
|
- getObjTagName(objTag) {
|
|
|
- const tagMap = {
|
|
|
- 0: '公摊表',
|
|
|
- 1: '个户表'
|
|
|
- }
|
|
|
- return tagMap[objTag] || '未知'
|
|
|
- },
|
|
|
- async getAreaTreeSelect(areaCode, layer) {
|
|
|
- await areaTreeSelect(areaCode, layer).then(response => {
|
|
|
- this.areaOptions = response.data
|
|
|
+
|
|
|
+ async getAreaTreeSelect() {
|
|
|
+ await getDeviceTree(0, this.queryParams.meterCls, 1).then(response => {
|
|
|
+ this.areaOptions = response.data || []
|
|
|
+ }).catch(error => {
|
|
|
+ console.error('获取设备树失败:', error)
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
// 筛选节点
|
|
|
filterNode(value, data) {
|
|
|
if (!value) return true
|
|
@@ -334,19 +242,36 @@ export default {
|
|
|
},
|
|
|
// 节点单击事件
|
|
|
handleNodeClick(data) {
|
|
|
- this.queryParams.areaCode = data.id
|
|
|
- this.handleQuery()
|
|
|
- },
|
|
|
- handleViewRec(row) {
|
|
|
- this.recListForm = this.$options.data().recListForm
|
|
|
- this.resetForm('recListForm')
|
|
|
- this.title = row.deviceName
|
|
|
- this.curRow = row
|
|
|
+ if (data.id === null) {
|
|
|
+ this.$message.warning('该节点不是设备不可点击');
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.recListForm.year = dateFormat(new Date(), 'yyyy')
|
|
|
- this.recListForm.deviceCode = row.deviceCode
|
|
|
- this.getHistoryList()
|
|
|
- this.recListOpen = true
|
|
|
+ this.recListForm.deviceCode = data.id
|
|
|
+ listMeterReadingByParam({
|
|
|
+ deviceCode: data.id,
|
|
|
+ year: dateFormat(new Date(), 'yyyy'),
|
|
|
+ orderFlag: 'desc'
|
|
|
+ }).then(response => {
|
|
|
+ this.recListForm.recList = response.data || []
|
|
|
+ this.curRow = this.recListForm.recList;
|
|
|
+ })
|
|
|
},
|
|
|
+ /** 第一个 id 非 null 的节点*/
|
|
|
+ findFirstValidNode(nodes) {
|
|
|
+ for (const node of nodes) {
|
|
|
+ if (node.id !== null) {
|
|
|
+ return node;
|
|
|
+ }
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ const foundNode = this.findFirstValidNode(node.children);
|
|
|
+ if (foundNode) return foundNode;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
getHistoryList() {
|
|
|
const { areaCode, deviceCode } = this.curRow
|
|
|
listMeterReadingByParam({
|
|
@@ -358,54 +283,97 @@ export default {
|
|
|
this.recListForm.recList = response.data || []
|
|
|
})
|
|
|
},
|
|
|
- async handleRecord(row) {
|
|
|
- this.fillForm = this.$options.data().fillForm
|
|
|
- this.resetForm('fillForm')
|
|
|
- this.fillTitle = row.deviceName
|
|
|
- this.fillForm.deviceCode = row.deviceCode
|
|
|
- this.fillForm.areaCode = row.areaCode
|
|
|
- this.fillForm.magnification = row.magnification
|
|
|
- this.fillForm.lastTime = row.lastTime
|
|
|
- this.fillForm.lastReading = row.lastReading
|
|
|
- this.ifAdd = true
|
|
|
- // let existFlag = false
|
|
|
- // // 获取上次填报记录
|
|
|
- // await getLastRecord(row.areaCode, row.deviceCode).then(({ data }) => {
|
|
|
- // if (data) {
|
|
|
- // if (data.meterMonth === this.currentMonth) {
|
|
|
- // existFlag = true
|
|
|
- // } else {
|
|
|
- // this.fillForm.lastTime = data.meterTime
|
|
|
- // this.fillForm.lastReading = data.meterReading
|
|
|
- // }
|
|
|
- // }
|
|
|
- // })
|
|
|
- // if (row.meterMonth===this.currentMonth) {
|
|
|
- // this.$modal.msgError('当前月份已填报')
|
|
|
- // } else {
|
|
|
- this.fillFormOpen = true
|
|
|
- // }
|
|
|
+
|
|
|
+ /** 新填报*/
|
|
|
+ handleRecord() {
|
|
|
+ this.fillForm = this.$options.data().fillForm;
|
|
|
+ this.resetForm('fillForm');
|
|
|
+ this.fillTitle = '填报抄表记录';
|
|
|
+
|
|
|
+ // 获取最新抄表记录
|
|
|
+ const latestRecord = this.recListForm.recList[0];
|
|
|
+ if (!latestRecord) {
|
|
|
+ this.$modal.msgError('没有可填报的记录');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 填充填报表单数据
|
|
|
+ this.fillForm.deviceCode = this.recListForm.deviceCode;
|
|
|
+ this.fillForm.areaCode = latestRecord.areaCode;
|
|
|
+ this.fillForm.magnification = latestRecord.magnification || 1;
|
|
|
+ this.fillForm.lastTime = latestRecord.meterTime;
|
|
|
+ this.fillForm.lastReading = latestRecord.meterReading;
|
|
|
+
|
|
|
+ this.fillFormOpen = true; // 打开填报表单
|
|
|
},
|
|
|
+ // async handleRecord(row) {
|
|
|
+ // this.fillForm = this.$options.data().fillForm
|
|
|
+ // this.resetForm('fillForm')
|
|
|
+ // this.fillTitle = row.deviceName
|
|
|
+ // this.fillForm.deviceCode = row.deviceCode
|
|
|
+ // this.fillForm.areaCode = row.areaCode
|
|
|
+ // this.fillForm.magnification = row.magnification
|
|
|
+ // this.fillForm.lastTime = row.lastTime
|
|
|
+ // this.fillForm.lastReading = row.lastReading
|
|
|
+ // this.ifAdd = true
|
|
|
+ // let existFlag = false
|
|
|
+ // // 获取上次填报记录
|
|
|
+ // await getLastRecord(row.areaCode, row.deviceCode).then(({ data }) => {
|
|
|
+ // if (data) {
|
|
|
+ // if (data.meterMonth === this.currentMonth) {
|
|
|
+ // existFlag = true
|
|
|
+ // } else {
|
|
|
+ // this.fillForm.lastTime = data.meterTime
|
|
|
+ // this.fillForm.lastReading = data.meterReading
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // if (row.meterMonth===this.currentMonth) {
|
|
|
+ // this.$modal.msgError('当前月份已填报')
|
|
|
+ // } else {
|
|
|
+ // this.fillFormOpen = true
|
|
|
+ // // }
|
|
|
+ // },
|
|
|
canEdit(meterMonth) {
|
|
|
return meterMonth === this.currentMonth
|
|
|
},
|
|
|
canFill (lastTime) {
|
|
|
return dateFormat(new Date(lastTime),'yyyyMM')!==this.currentMonth
|
|
|
},
|
|
|
+ /**新修改*/
|
|
|
updateRecord(row) {
|
|
|
- this.ifAdd = false
|
|
|
- this.fillFormOpen = true
|
|
|
- this.fillForm = this.$options.data().fillForm
|
|
|
- this.resetForm('fillForm')
|
|
|
- this.fillTitle = this.curRow.objName
|
|
|
- this.fillForm.deviceCode = this.curRow.deviceCode
|
|
|
- this.fillForm.areaCode = this.curRow.areaCode
|
|
|
- this.fillForm.magnification = this.curRow.magnification
|
|
|
- this.fillForm.id = row.id
|
|
|
- this.fillForm.lastTime = row.lastTime
|
|
|
- this.fillForm.lastReading = row.lastReading
|
|
|
- this.fillForm.meterReading = row.meterReading
|
|
|
+ this.ifAdd = false;
|
|
|
+ this.fillFormOpen = true;
|
|
|
+ this.fillForm = this.$options.data().fillForm;
|
|
|
+ this.resetForm('fillForm');
|
|
|
+ this.fillTitle = `修改抄表记录 - ${row.deviceCode}`;
|
|
|
+
|
|
|
+ // 获取当前选中的设备信息
|
|
|
+ const currentDevice = this.recListForm.recList.find(
|
|
|
+ (item) => item.deviceCode === row.deviceCode
|
|
|
+ );
|
|
|
+ this.fillForm.deviceCode = row.deviceCode; // 设备编号
|
|
|
+ this.fillForm.areaCode = currentDevice.areaCode; // 区域代码
|
|
|
+ this.fillForm.magnification = currentDevice.magnification || 1; // 综合倍率
|
|
|
+ this.fillForm.id = row.id; // 抄表记录 ID
|
|
|
+ this.fillForm.lastTime = row.meterTime; // 上次抄表日期
|
|
|
+ this.fillForm.lastReading = row.meterReading; // 上次抄表示数
|
|
|
+ this.fillForm.meterReading = row.meterReading; // 本次抄表示数(默认为上次抄表示数)
|
|
|
},
|
|
|
+ // updateRecord(row) {
|
|
|
+ // this.ifAdd = false
|
|
|
+ // this.fillFormOpen = true
|
|
|
+ // this.fillForm = this.$options.data().fillForm
|
|
|
+ // this.resetForm('fillForm')
|
|
|
+ // this.fillTitle = this.curRow.objName
|
|
|
+ // this.fillForm.deviceCode = this.curRow.deviceCode
|
|
|
+ // this.fillForm.areaCode = this.curRow.areaCode
|
|
|
+ // this.fillForm.magnification = this.curRow.magnification
|
|
|
+ // this.fillForm.id = row.id
|
|
|
+ // this.fillForm.lastTime = row.lastTime
|
|
|
+ // this.fillForm.lastReading = row.lastReading
|
|
|
+ // this.fillForm.meterReading = row.meterReading
|
|
|
+ // },
|
|
|
submitFillForm() {
|
|
|
this.$refs['fillForm'].validate(valid => {
|
|
|
if (valid) {
|