更新
This commit is contained in:
114
src/views/cost/costStatistics/add-or-updata.vue
Normal file
114
src/views/cost/costStatistics/add-or-updata.vue
Normal file
@@ -0,0 +1,114 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2021-11-18 14:16:25
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2024-04-19 16:59:45
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<el-form
|
||||
:model="dataForm"
|
||||
:rules="dataRule"
|
||||
ref="dataForm"
|
||||
@keyup.enter.native="dataFormSubmit()"
|
||||
label-width="80px">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="原料名称" prop="materialName">
|
||||
<el-input
|
||||
v-model="dataForm.materialName"
|
||||
disabled
|
||||
placeholder="请输入原料名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="单价" prop="matPrice">
|
||||
<el-input
|
||||
v-model="dataForm.matPrice"
|
||||
disabled
|
||||
style="width: 70%"
|
||||
placeholder="请输入单价" />
|
||||
(元/吨)
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="总价" prop="price">
|
||||
<el-input-number
|
||||
:min="0"
|
||||
style="width: 80%"
|
||||
v-model="dataForm.price"
|
||||
clearable
|
||||
placeholder="请输入总价" />
|
||||
(元)
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="累计用量" prop="quantity">
|
||||
<el-input-number
|
||||
:min="0"
|
||||
style="width: 80%"
|
||||
v-model="dataForm.quantity"
|
||||
clearable
|
||||
placeholder="请输入累计用量" />
|
||||
(吨)
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import basicAdd from '@/mixins/basic-add';
|
||||
import { updateMaterialHis } from '@/api/cost/costMaterial';
|
||||
|
||||
export default {
|
||||
mixins: [basicAdd],
|
||||
data() {
|
||||
return {
|
||||
urlOptions: {
|
||||
updateURL: updateMaterialHis,
|
||||
},
|
||||
dataForm: {
|
||||
id: undefined,
|
||||
price: undefined,
|
||||
quantity: undefined,
|
||||
matPrice: undefined,
|
||||
materialName: undefined,
|
||||
recTime: undefined,
|
||||
},
|
||||
dataRule: {
|
||||
price: [{ required: true, message: '总价不能为空', trigger: 'blur' }],
|
||||
quantity: [
|
||||
{ required: true, message: '累计用量不能为空', trigger: 'blur' },
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
init(val, statisticType) {
|
||||
this.visible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields();
|
||||
this.dataForm = JSON.parse(JSON.stringify(val));
|
||||
this.dataForm.statisticType = statisticType;
|
||||
});
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
this.dataForm.modifyPrice = this.dataForm.price;
|
||||
this.dataForm.modifyQuantity = this.dataForm.quantity;
|
||||
// 修改的提交
|
||||
this.urlOptions.updateURL(this.dataForm).then((response) => {
|
||||
this.$modal.msgSuccess('修改成功');
|
||||
this.visible = false;
|
||||
this.$emit('refreshDataList');
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
346
src/views/cost/costStatistics/index.vue
Normal file
346
src/views/cost/costStatistics/index.vue
Normal file
@@ -0,0 +1,346 @@
|
||||
<template>
|
||||
<div class="app-container energyOverlimitLog">
|
||||
<div v-show="activeName === 'his'">
|
||||
<!-- 搜索工作栏 -->
|
||||
<search-bar
|
||||
:formConfigs="formConfig"
|
||||
ref="searchBarForm"
|
||||
@headBtnClick="buttonClick" />
|
||||
</div>
|
||||
<div v-show="activeName === 'now'">
|
||||
<!-- 搜索工作栏 -->
|
||||
<search-bar
|
||||
:formConfigs="formConfig2"
|
||||
ref="searchBarForm2"
|
||||
@headBtnClick="buttonClick" />
|
||||
</div>
|
||||
<el-tabs v-model="activeName" @tab-click="toggleTab">
|
||||
<el-tab-pane label="历史成本" name="his"></el-tab-pane>
|
||||
<el-tab-pane label="成本查询" name="now"></el-tab-pane>
|
||||
</el-tabs>
|
||||
<!-- 列表 -->
|
||||
<div v-if="activeName === 'his'">
|
||||
<base-table
|
||||
:page="listQuery.pageNo"
|
||||
:limit="listQuery.pageSize"
|
||||
:table-props="tableProps"
|
||||
:table-data="tableData"
|
||||
:max-height="tableH">
|
||||
<method-btn
|
||||
v-if="tableBtn.length"
|
||||
slot="handleBtn"
|
||||
:width="80"
|
||||
label="操作"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleClick" />
|
||||
</base-table>
|
||||
</div>
|
||||
<div v-if="activeName === 'now'">
|
||||
<base-table
|
||||
:page="listQuery.pageNo"
|
||||
:limit="listQuery.pageSize"
|
||||
:table-props="tableProps2"
|
||||
:table-data="tableData2"
|
||||
:max-height="tableH" />
|
||||
</div>
|
||||
<pagination
|
||||
:page.sync="listQuery.pageNo"
|
||||
:limit.sync="listQuery.pageSize"
|
||||
:total="listQuery.total"
|
||||
@pagination="getDataList" />
|
||||
<base-dialog
|
||||
:dialogTitle="addOrEditTitle"
|
||||
:dialogVisible="addOrUpdateVisible"
|
||||
@cancel="handleCancel"
|
||||
@confirm="handleConfirm"
|
||||
:before-close="handleCancel"
|
||||
width="50%">
|
||||
<add-or-update
|
||||
ref="addOrUpdate"
|
||||
@refreshDataList="successSubmit"></add-or-update>
|
||||
</base-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AddOrUpdate from './add-or-updata';
|
||||
import basicPage from '@/mixins/basic-page';
|
||||
import { getMaterialPage } from '@/api/base/material';
|
||||
import {
|
||||
getMaterialHisPage,
|
||||
getMaterialRealtimePage,
|
||||
} from '@/api/cost/costMaterial';
|
||||
import { parseTime } from '@/filter/code-filter';
|
||||
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
||||
import typeRule from './typeRule';
|
||||
const tableProps = [
|
||||
{
|
||||
prop: 'recTime',
|
||||
label: '日期',
|
||||
filter: (val) => parseTime(val, '{y}年{m}月{d}日'),
|
||||
},
|
||||
{
|
||||
prop: 'materialName',
|
||||
label: '原料名称',
|
||||
},
|
||||
{
|
||||
prop: 'matPrice',
|
||||
label: '单价(元/吨)',
|
||||
align: 'right',
|
||||
},
|
||||
{
|
||||
prop: 'quantity',
|
||||
label: '累计使用量(吨)',
|
||||
},
|
||||
{
|
||||
prop: 'price',
|
||||
label: '总价(元)',
|
||||
align: 'right',
|
||||
},
|
||||
];
|
||||
const tableProps2 = [
|
||||
{
|
||||
prop: 'materialName',
|
||||
label: '原料名称',
|
||||
},
|
||||
{
|
||||
prop: 'matPrice',
|
||||
label: '单价(元/吨)',
|
||||
align: 'right',
|
||||
},
|
||||
{
|
||||
prop: 'time',
|
||||
label: '单价生效时间',
|
||||
subcomponent: typeRule,
|
||||
},
|
||||
{
|
||||
prop: 'quantity',
|
||||
label: '累计使用量(吨)',
|
||||
},
|
||||
{
|
||||
prop: 'price',
|
||||
label: '总价(元)',
|
||||
align: 'right',
|
||||
},
|
||||
];
|
||||
export default {
|
||||
name: 'costMaterial',
|
||||
mixins: [basicPage, tableHeightMixin],
|
||||
data() {
|
||||
return {
|
||||
urlOptions: {
|
||||
getDataListURL: getMaterialHisPage,
|
||||
},
|
||||
formConfig: [
|
||||
{
|
||||
type: 'select',
|
||||
label: '维度',
|
||||
selectOptions: [
|
||||
{ id: 1, name: '日' },
|
||||
{ id: 2, name: '周' },
|
||||
{ id: 3, name: '月' },
|
||||
],
|
||||
param: 'statisticType',
|
||||
defaultSelect: 1, // 默认值,
|
||||
clearable: false,
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
label: '原料名称',
|
||||
selectOptions: [],
|
||||
param: 'name',
|
||||
labelField: 'name',
|
||||
filterable: true,
|
||||
},
|
||||
{
|
||||
type: 'datePicker',
|
||||
label: '时间范围',
|
||||
dateType: 'daterange',
|
||||
format: 'yyyy-MM-dd',
|
||||
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
||||
rangeSeparator: '-',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
param: 'searchTime',
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
btnName: '查询',
|
||||
name: 'search',
|
||||
color: 'primary',
|
||||
},
|
||||
],
|
||||
formConfig2: [
|
||||
{
|
||||
type: 'select',
|
||||
label: '原料名称',
|
||||
selectOptions: [],
|
||||
param: 'name',
|
||||
labelField: 'name',
|
||||
filterable: true,
|
||||
},
|
||||
{
|
||||
type: 'datePicker',
|
||||
label: '时间范围',
|
||||
dateType: 'daterange',
|
||||
format: 'yyyy-MM-dd',
|
||||
valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
||||
rangeSeparator: '-',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
param: 'searchTime',
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
btnName: '查询',
|
||||
name: 'search',
|
||||
color: 'primary',
|
||||
},
|
||||
],
|
||||
listQuery: {
|
||||
statisticType: 1,
|
||||
},
|
||||
activeName: 'his',
|
||||
tableProps,
|
||||
tableProps2,
|
||||
tableBtn: [
|
||||
this.$auth.hasPermi(`monitoring:cost-material-his:update`)
|
||||
? {
|
||||
type: 'edit',
|
||||
btnName: '编辑',
|
||||
}
|
||||
: undefined,
|
||||
].filter((v) => v),
|
||||
tableData: [],
|
||||
tableData2: [],
|
||||
};
|
||||
},
|
||||
components: {
|
||||
AddOrUpdate,
|
||||
},
|
||||
created() {
|
||||
const params = {
|
||||
pageNo: 1,
|
||||
pageSize: 100,
|
||||
};
|
||||
getMaterialPage(params).then((response) => {
|
||||
this.formConfig[1].selectOptions = response.data.list;
|
||||
this.formConfig2[0].selectOptions = response.data.list;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
buttonClick(val) {
|
||||
switch (val.btnName) {
|
||||
case 'search':
|
||||
this.listQuery.pageNo = 1;
|
||||
this.listQuery.pageSize = 10;
|
||||
this.listQuery.materialId = val.name || null;
|
||||
this.listQuery.statisticType = val.statisticType || 1;
|
||||
this.listQuery.startTime = val.searchTime ? val.searchTime[0] : null;
|
||||
this.listQuery.endTime = val.searchTime
|
||||
? val.searchTime[1].substr(0, 10) + ' 23:59:59'
|
||||
: null;
|
||||
if (this.activeName === 'his') {
|
||||
this.getDataList();
|
||||
} else {
|
||||
this.getDataList2();
|
||||
}
|
||||
break;
|
||||
case 'add':
|
||||
this.addOrUpdateHandle();
|
||||
break;
|
||||
case 'export':
|
||||
this.listQuery.pageNo = 1;
|
||||
this.listQuery.pageSize = 10;
|
||||
this.listQuery.name = val.name;
|
||||
this.listQuery.startTime = val.searchTime ? val.searchTime[0] : null;
|
||||
this.listQuery.endTime = val.searchTime
|
||||
? val.searchTime[1].substr(0, 10) + ' 23:59:59'
|
||||
: null;
|
||||
this.handleExport();
|
||||
break;
|
||||
default:
|
||||
console.log(val);
|
||||
}
|
||||
},
|
||||
toggleTab() {
|
||||
if (this.activeName === 'his') {
|
||||
this.$refs.searchBarForm.resetForm();
|
||||
this.listQuery.name = null;
|
||||
this.listQuery.startTime = null;
|
||||
this.listQuery.endTime = null;
|
||||
this.listQuery.statisticType = 1;
|
||||
this.listQuery.pageNo = 1;
|
||||
this.getDataList();
|
||||
} else {
|
||||
this.$refs.searchBarForm2.resetForm();
|
||||
this.listQuery.name = null;
|
||||
this.listQuery.startTime = null;
|
||||
this.listQuery.endTime = null;
|
||||
this.listQuery.pageNo = 1;
|
||||
this.getDataList2();
|
||||
}
|
||||
},
|
||||
// 获取数据2列表
|
||||
getDataList2() {
|
||||
if (this.listQuery.startTime) {
|
||||
getMaterialRealtimePage(this.listQuery).then((response) => {
|
||||
this.tableData2 = response.data.list;
|
||||
this.listQuery.total = response.data.total;
|
||||
});
|
||||
} else {
|
||||
this.$message.warning('请选择时间范围');
|
||||
}
|
||||
},
|
||||
//tableBtn点击
|
||||
handleClick(val) {
|
||||
if (val.type === 'edit') {
|
||||
this.addOrUpdateVisible = true;
|
||||
this.addOrEditTitle = '编辑';
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(val.data, this.listQuery.statisticType);
|
||||
});
|
||||
} else {
|
||||
this.otherMethods(val);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.energyOverlimitLog {
|
||||
.el-tabs__nav::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 2px;
|
||||
background-color: #e4e7ed;
|
||||
}
|
||||
|
||||
.el-tabs__nav-wrap::after {
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.el-tabs__item {
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.el-tabs__item:hover {
|
||||
color: rgba(0, 0, 0, 0.85);
|
||||
}
|
||||
|
||||
.el-tabs__item.is-active {
|
||||
color: rgba(0, 0, 0, 0.85);
|
||||
}
|
||||
|
||||
.el-tabs__item {
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
|
||||
.searchBarBox {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
23
src/views/cost/costStatistics/typeRule.vue
Normal file
23
src/views/cost/costStatistics/typeRule.vue
Normal file
@@ -0,0 +1,23 @@
|
||||
<!--
|
||||
* @Author: zwq
|
||||
* @Date: 2023-12-05 13:45:59
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2024-04-15 17:12:03
|
||||
* @Description
|
||||
-->
|
||||
<template>
|
||||
<div>
|
||||
<span>{{ parseTime(injectData.startTime,'{y}年{m}月{d}日') + '-' + (parseTime(injectData.endTime)?parseTime(injectData.endTime,'{y}年{m}月{d}日'):'永久') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: '',
|
||||
props: {
|
||||
injectData: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user