Merge pull request 'projects/mesxc-zjl' (#189) from projects/mesxc-zjl into projects/mesxc-test

Reviewed-on: #189
This commit is contained in:
朱菊兰 2024-01-25 17:21:16 +08:00
commit a7dd966e3f
5 changed files with 163 additions and 63 deletions

View File

@ -15,7 +15,7 @@ VUE_APP_TITLE = MES系统
# VUE_APP_BASE_API = 'http://100.64.0.26:48082' # VUE_APP_BASE_API = 'http://100.64.0.26:48082'
# VUE_APP_BASE_API = 'http://10.70.2.2:8080' # VUE_APP_BASE_API = 'http://10.70.2.2:8080'
VUE_APP_BASE_API = 'http://192.168.0.33:48082' VUE_APP_BASE_API = 'http://192.168.0.33:48082'
# VUE_APP_BASE_API = 'http://192.168.4.173:48080' # VUE_APP_BASE_API = 'http://192.168.1.20:48080'
# VUE_APP_BASE_API = 'http://192.168.2.173:48080' # VUE_APP_BASE_API = 'http://192.168.2.173:48080'
# VUE_APP_BASE_API = 'http://192.168.1.49:48082' # VUE_APP_BASE_API = 'http://192.168.1.49:48082'
# VUE_APP_BASE_API = 'http://192.168.1.8:48082' # VUE_APP_BASE_API = 'http://192.168.1.8:48082'

View File

@ -0,0 +1,38 @@
<template>
<div class="tableInner">
<!-- <el-input v-model="list[itemProp]" @blur="changeInput" /> -->
<el-input-number v-model="list[itemProp]" @change="changeInput" :min="0" :max="999999999" style='width: 100%;' :controls='false' :precision='2'></el-input-number>
</div>
</template>
<script>
export default {
name: 'InputArea',
props: {
injectData: {
type: Object,
default: () => ({})
},
itemProp: {
type: String
}
},
data() {
return {
list: this.injectData
}
},
methods: {
changeInput() {
console.log(this.list)
this.$emit('emitData', this.list)
}
}
}
</script>
<style scoped>
.tableInner .el-input__inner {
border: none;
padding: 0;
height: 33px;
}
</style>

View File

@ -0,0 +1,44 @@
<template>
<div class="tableInner">
<el-select v-model="list[itemProp]" placeholder="请选择" style="width: 100%;" @change="changeSelect">
<el-option
v-for="item in getDictDatas(DICT_TYPE.TABLE_NAME)"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</div>
</template>
<script>
export default {
name: 'SelectArea',
props: {
injectData: {
type: Object,
default: () => ({})
},
itemProp: {
type: String
}
},
data() {
return {
list: this.injectData
}
},
methods: {
changeSelect() {
console.log(this.list)
this.$emit('emitData', this.list)
}
}
}
</script>
<style scoped>
.tableInner .el-input__inner {
border: none;
padding: 0;
height: 33px;
}
</style>

View File

@ -13,33 +13,6 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span='12'>
<el-form-item label="水/气表名" prop="tableName">
<el-select v-model="form.tableName" placeholder="请选择" style="width: 100%;" filterable>
<el-option
v-for="item in getDictDatas(DICT_TYPE.TABLE_NAME)"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span='12'>
<el-form-item label="抄表数" prop="readingQuantity">
<el-input-number v-model="form.readingQuantity" :min="0" :max="999999999999" :controls='false' style="width: 50%;"></el-input-number>
<el-select v-model="form.unit" placeholder="单位" style="width: 50%;">
<el-option
v-for="item in getDictDatas(DICT_TYPE.ENERGY_UNIT)"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span='12'> <el-col :span='12'>
<el-form-item label="抄表日期" prop="recordTime"> <el-form-item label="抄表日期" prop="recordTime">
<el-date-picker <el-date-picker
@ -53,11 +26,37 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20">
<el-col :span='24'>
<base-table
border
:table-props="tableProps"
:table-data="tableData"
:add-button-show="addButtonShow"
@emitFun="inputChange"
@emitButtonClick="emitButtonClick"
/>
</el-col>
</el-row>
</el-form> </el-form>
</template> </template>
<script> <script>
import { energyQuantityManualCreate, energyQuantityManualUpdate, energyQuantityManualGet } from '@/api/base/energyQuantityManual' import { energyQuantityManualCreate, energyQuantityManualUpdate, energyQuantityManualGet } from '@/api/base/energyQuantityManual'
import moment from 'moment' import moment from 'moment'
import InputArea from './InputArea'
import SelectArea from './SelectArea'
const tableProps = [
{
prop: 'tableName',
label: '表名',
subcomponent: SelectArea
},
{
prop: 'readingQuantity',
label: '抄表数',
subcomponent: InputArea
}
]
export default { export default {
name: 'EnergyQuantityManualAdd', name: 'EnergyQuantityManualAdd',
props: { props: {
@ -71,18 +70,17 @@ export default {
}, },
data() { data() {
return { return {
tableProps,
tableData: [],
addButtonShow:'新增',
form: { form: {
id: '', id: '',
energyTypeId: '', energyTypeId: '',
tableName: '',
readingQuantity: null,
unit: '', unit: '',
recordTime: '' recordTime: ''
}, },
rules: { rules: {
energyTypeId: [{ required: true, message: '能源类型不能为空', trigger: 'change' }], energyTypeId: [{ required: true, message: '能源类型不能为空', trigger: 'change' }],
tableName: [{ required: true, message: '水/气表名不能为空', trigger: 'change' }],
readingQuantity: [{ required: true, message: '抄表数不能为空', trigger: 'blur' }],
recordTime: [{ required: true, message: '抄表日期不能为空', trigger: 'change' }] recordTime: [{ required: true, message: '抄表日期不能为空', trigger: 'change' }]
}, },
isEdit: false isEdit: false
@ -96,38 +94,71 @@ export default {
} else if (params.type === 'meterReading') { } else if (params.type === 'meterReading') {
this.isEdit = false this.isEdit = false
this.form.energyTypeId = params.energyTypeId this.form.energyTypeId = params.energyTypeId
this.form.tableName = params.tableName + '' let obj = {}
obj.tableName = params.tableName + ''
obj.readingQuantity = 0
this.tableData.push(obj)
}else { }else {
this.isEdit = true this.isEdit = true
this.form.id = params.id this.form.id = params.id
this.addButtonShow = ''
energyQuantityManualGet({id: this.form.id}).then(res => { energyQuantityManualGet({id: this.form.id}).then(res => {
if (res.code === 0) { if (res.code === 0) {
this.form.energyTypeId = res.data.energyTypeId this.form.energyTypeId = res.data.energyTypeId
this.form.tableName = res.data.tableName ? res.data.tableName+'' : ''
this.form.readingQuantity = res.data.readingQuantity
this.form.unit = res.data.unit ? res.data.unit+'' : ''
this.form.recordTime = res.data.recordTime ? res.data.recordTime : null this.form.recordTime = res.data.recordTime ? res.data.recordTime : null
let obj = {}
obj.tableName = res.data.tableName ? res.data.tableName+'' : ''
obj.readingQuantity = res.data.readingQuantity
this.tableData.push(obj)
} }
}) })
} }
}, },
inputChange(val) {
this.tableData[val._pageIndex - 1][val.prop] = val[val.prop]
},
emitButtonClick() {
let obj = {}
obj.tableName = ''
obj.readingQuantity = 0
this.tableData.push(obj)
},
submitForm() { submitForm() {
this.$refs['energyQuantityManualForm'].validate((valid) => { this.$refs['energyQuantityManualForm'].validate((valid) => {
if (valid) { if (valid) {
if (!this.form.unit) { //
this.$modal.msgError("抄表数单位不能为空"); if (this.tableData.length === 0) {
this.$modal.msgError("抄表数据不能为空");
return false return false
}else{
for (let item of this.tableData) {
console.log(item)
if (!item.tableName || (!item.readingQuantity && item.readingQuantity!==0)) {
this.$modal.msgError("抄表数据有空值,请检查");
return false
}
}
} }
if (this.isEdit) { if (this.isEdit) {
// //
energyQuantityManualUpdate({...this.form}).then((res) => { energyQuantityManualUpdate({
id:this.form.id,
energyTypeId:this.form.energyTypeId,
recordTime:this.form.recordTime,
tableName:this.tableData[0].tableName,
readingQuantity:this.tableData[0].readingQuantity
}).then((res) => {
if (res.code === 0) { if (res.code === 0) {
this.$modal.msgSuccess("操作成功"); this.$modal.msgSuccess("操作成功");
this.$emit('successSubmit') this.$emit('successSubmit')
} }
}) })
} else { } else {
energyQuantityManualCreate({...this.form}).then((res) => { energyQuantityManualCreate({
energyTypeId:this.form.energyTypeId,
recordTime:this.form.recordTime,
data:this.tableData
}).then((res) => {
if (res.code === 0) { if (res.code === 0) {
this.$modal.msgSuccess("操作成功"); this.$modal.msgSuccess("操作成功");
this.$emit('successSubmit') this.$emit('successSubmit')
@ -143,6 +174,8 @@ export default {
this.$refs.energyQuantityManualForm.resetFields() this.$refs.energyQuantityManualForm.resetFields()
this.form.unit = '' this.form.unit = ''
this.isEdit = false this.isEdit = false
this.addButtonShow = '新增'
this.tableData = []
} }
} }
} }

View File

@ -60,6 +60,12 @@ const tableProps = [
minWidth: 110, minWidth: 110,
showOverflowtooltip: true showOverflowtooltip: true
}, },
{
prop: 'unit',
label: '单位',
filter: publicFormatter('energy_unit'),
minWidth: 110
},
{ {
prop: 'tableName', prop: 'tableName',
label: '水/气表名', label: '水/气表名',
@ -77,18 +83,7 @@ const tableProps = [
label: '抄表值' label: '抄表值'
}, },
{ {
prop: 'recordTimeLast', prop: 'useQty',
label: '上期抄表日期',
filter: parseTimeTable('{y}-{m}-{d}'),
minWidth: 110
},
{
prop: 'readingQuantityLast',
label: '上期抄表值',
minWidth: 110
},
{
prop: 'diff',
label: '差值' label: '差值'
} }
] ]
@ -156,17 +151,7 @@ export default {
this.$auth.hasPermi('base:energy-quantity-manual:update') this.$auth.hasPermi('base:energy-quantity-manual:update')
? { ? {
type: 'edit', type: 'edit',
btnName: '编辑', btnName: '编辑'
showParam: {
type: '&',
data: [
{
type: 'equal',
name: 'latest',
value: 1
}
]
}
} }
: undefined, : undefined,
this.$auth.hasPermi('base:energy-quantity-manual:delete') this.$auth.hasPermi('base:energy-quantity-manual:delete')