|
|
@@ -0,0 +1,365 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
|
|
+ <el-form-item label="时间" prop="qhTime">
|
|
|
+ <el-date-picker clearable
|
|
|
+ v-model="queryParams.qhTime"
|
|
|
+ type="date"
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
+ placeholder="请选择时间">
|
|
|
+ </el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="类别" prop="qhType">
|
|
|
+ <el-select v-model="queryParams.qhType" placeholder="请选择类别" clearable style="width: 150px;" @change="handleTypeChange">
|
|
|
+ <el-option label="原油" value="原油"></el-option>
|
|
|
+ <el-option label="炼化" value="炼化"></el-option>
|
|
|
+ <el-option label="聚酯" value="聚酯"></el-option>
|
|
|
+ <el-option label="纺丝" value="纺丝"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="品名" prop="qhClass">
|
|
|
+ <el-select v-model="queryParams.qhClass" placeholder="请选择品名" clearable style="width: 150px;">
|
|
|
+ <el-option
|
|
|
+ v-for="item in qhClassOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="价格" prop="price">
|
|
|
+ <el-input
|
|
|
+ v-model="queryParams.price"
|
|
|
+ placeholder="请输入价格"
|
|
|
+ clearable
|
|
|
+ @keyup.enter="handleQuery"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
|
|
+ <el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <el-row :gutter="10" class="mb8">
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ icon="Plus"
|
|
|
+ @click="handleAdd"
|
|
|
+ >新增</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="success"
|
|
|
+ plain
|
|
|
+ icon="Edit"
|
|
|
+ :disabled="single"
|
|
|
+ @click="handleUpdate"
|
|
|
+ >修改</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ plain
|
|
|
+ icon="Delete"
|
|
|
+ :disabled="multiple"
|
|
|
+ @click="handleDelete"
|
|
|
+ >删除</el-button>
|
|
|
+ </el-col>
|
|
|
+ <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-table v-loading="loading" :data="qhList" @selection-change="handleSelectionChange">
|
|
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
|
+<!-- <el-table-column label="ID" align="center" prop="qhId" />-->
|
|
|
+ <el-table-column label="时间" align="center" prop="qhTime" width="180">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ parseTime(scope.row.qhTime, '{y}-{m}-{d}') }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="类别" align="center" prop="qhType" />
|
|
|
+ <el-table-column label="品名" align="center" prop="qhClass" />
|
|
|
+ <el-table-column label="价格" align="center" prop="price" />
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)">修改</el-button>
|
|
|
+ <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <pagination
|
|
|
+ v-show="total>0"
|
|
|
+ :total="total"
|
|
|
+ v-model:page="queryParams.pageNum"
|
|
|
+ v-model:limit="queryParams.pageSize"
|
|
|
+ @pagination="getList"
|
|
|
+ />
|
|
|
+
|
|
|
+ <!-- 添加或修改期货价格对话框 -->
|
|
|
+ <el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
|
|
+ <el-form ref="qhRef" :model="form" :rules="rules" label-width="80px">
|
|
|
+ <el-form-item label="时间" prop="qhTime">
|
|
|
+ <el-date-picker clearable
|
|
|
+ v-model="form.qhTime"
|
|
|
+ type="date"
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
+ placeholder="请选择时间">
|
|
|
+ </el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="类别" prop="qhType">
|
|
|
+ <el-select v-model="form.qhType" placeholder="请选择类别" style="width: 150px;" @change="handleFormTypeChange">
|
|
|
+ <el-option label="原油" value="原油"></el-option>
|
|
|
+ <el-option label="炼化" value="炼化"></el-option>
|
|
|
+ <el-option label="聚酯" value="聚酯"></el-option>
|
|
|
+ <el-option label="纺丝" value="纺丝"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="品名" prop="qhClass">
|
|
|
+ <el-select v-model="form.qhClass" placeholder="请选择品名" style="width: 150px;">
|
|
|
+ <el-option
|
|
|
+ v-for="item in formQhClassOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="价格" prop="price">
|
|
|
+ <el-input v-model="form.price" placeholder="请输入价格" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
+ <el-button @click="cancel">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup name="Qh">
|
|
|
+import { listQh, getQh, delQh, addQh, updateQh } from "@/api/lean/qh";
|
|
|
+
|
|
|
+const { proxy } = getCurrentInstance();
|
|
|
+
|
|
|
+const qhList = ref([]);
|
|
|
+const open = ref(false);
|
|
|
+const loading = ref(true);
|
|
|
+const showSearch = ref(true);
|
|
|
+const ids = ref([]);
|
|
|
+const single = ref(true);
|
|
|
+const multiple = ref(true);
|
|
|
+const total = ref(0);
|
|
|
+const title = ref("");
|
|
|
+
|
|
|
+// 品名选项,根据类别变化
|
|
|
+const qhClassOptions = ref([
|
|
|
+ { label: 'WTI(/桶)', value: 'WTI(/桶)' },
|
|
|
+ { label: 'Brent(/桶)', value: 'Brent(/桶)' },
|
|
|
+ { label: 'PX(元/t)', value: 'PX(元/t)' },
|
|
|
+ { label: 'OM(元/t)', value: 'OM(元/t)' },
|
|
|
+ { label: 'PTA(元/t)', value: 'PTA(元/t)' },
|
|
|
+ { label: 'MEG(元/t)', value: 'MEG(元/t)' },
|
|
|
+ { label: 'FDY(元/t)', value: 'FDY(元/t)' },
|
|
|
+ { label: 'DTY(元/t)', value: 'DTY(元/t)' },
|
|
|
+ { label: 'POY(元/t)', value: 'POY(元/t)' }
|
|
|
+]);
|
|
|
+
|
|
|
+// 表单中的品名选项
|
|
|
+const formQhClassOptions = ref([
|
|
|
+ { label: 'WTI(/桶)', value: 'WTI(/桶)' },
|
|
|
+ { label: 'Brent(/桶)', value: 'Brent(/桶)' },
|
|
|
+ { label: 'PX(元/t)', value: 'PX(元/t)' },
|
|
|
+ { label: 'OM(元/t)', value: 'OM(元/t)' },
|
|
|
+ { label: 'PTA(元/t)', value: 'PTA(元/t)' },
|
|
|
+ { label: 'MEG(元/t)', value: 'MEG(元/t)' },
|
|
|
+ { label: 'FDY(元/t)', value: 'FDY(元/t)' },
|
|
|
+ { label: 'DTY(元/t)', value: 'DTY(元/t)' },
|
|
|
+ { label: 'POY(元/t)', value: 'POY(元/t)' }
|
|
|
+]);
|
|
|
+
|
|
|
+const data = reactive({
|
|
|
+ form: {},
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ qhTime: null,
|
|
|
+ qhType: null,
|
|
|
+ qhClass: null,
|
|
|
+ price: null,
|
|
|
+ orderByColumn: "qh_time",
|
|
|
+ isAsc: "descending"
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+const { queryParams, form, rules } = toRefs(data);
|
|
|
+
|
|
|
+// 类别与品名的映射关系
|
|
|
+const typeClassMap = {
|
|
|
+ '原油': ['WTI(/桶)', 'Brent(/桶)'],
|
|
|
+ '炼化': ['PX(元/t)', 'OM(元/t)'],
|
|
|
+ '聚酯': ['PTA(元/t)', 'MEG(元/t)'],
|
|
|
+ '纺丝': ['FDY(元/t)', 'DTY(元/t)', 'POY(元/t)']
|
|
|
+};
|
|
|
+
|
|
|
+/** 查询期货价格列表 */
|
|
|
+function getList() {
|
|
|
+ loading.value = true;
|
|
|
+ listQh(queryParams.value).then(response => {
|
|
|
+ qhList.value = response.rows;
|
|
|
+ total.value = response.total;
|
|
|
+ loading.value = false;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// 取消按钮
|
|
|
+function cancel() {
|
|
|
+ open.value = false;
|
|
|
+ reset();
|
|
|
+}
|
|
|
+
|
|
|
+// 表单重置
|
|
|
+function reset() {
|
|
|
+ form.value = {
|
|
|
+ qhId: null,
|
|
|
+ qhTime: null,
|
|
|
+ qhType: null,
|
|
|
+ qhClass: null,
|
|
|
+ price: null
|
|
|
+ };
|
|
|
+ proxy.resetForm("qhRef");
|
|
|
+}
|
|
|
+
|
|
|
+/** 搜索按钮操作 */
|
|
|
+function handleQuery() {
|
|
|
+ queryParams.value.pageNum = 1;
|
|
|
+ getList();
|
|
|
+}
|
|
|
+
|
|
|
+/** 重置按钮操作 */
|
|
|
+function resetQuery() {
|
|
|
+ proxy.resetForm("queryRef");
|
|
|
+ queryParams.value.qhType = null;
|
|
|
+ queryParams.value.qhClass = null;
|
|
|
+ qhClassOptions.value = getAllClassOptions();
|
|
|
+ handleQuery();
|
|
|
+}
|
|
|
+
|
|
|
+// 多选框选中数据
|
|
|
+function handleSelectionChange(selection) {
|
|
|
+ ids.value = selection.map(item => item.qhId);
|
|
|
+ single.value = selection.length != 1;
|
|
|
+ multiple.value = !selection.length;
|
|
|
+}
|
|
|
+
|
|
|
+/** 新增按钮操作 */
|
|
|
+function handleAdd() {
|
|
|
+ reset();
|
|
|
+ open.value = true;
|
|
|
+ title.value = "添加期货价格";
|
|
|
+ formQhClassOptions.value = getAllClassOptions();
|
|
|
+}
|
|
|
+
|
|
|
+/** 修改按钮操作 */
|
|
|
+function handleUpdate(row) {
|
|
|
+ reset();
|
|
|
+ const _qhId = row.qhId || ids.value
|
|
|
+ getQh(_qhId).then(response => {
|
|
|
+ form.value = response.data;
|
|
|
+ open.value = true;
|
|
|
+ title.value = "修改期货价格";
|
|
|
+ // 根据已选择的类别更新品名选项
|
|
|
+ if (form.value.qhType) {
|
|
|
+ handleFormTypeChange(form.value.qhType);
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/** 提交按钮 */
|
|
|
+function submitForm() {
|
|
|
+ proxy.$refs["qhRef"].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ if (form.value.qhId != null) {
|
|
|
+ updateQh(form.value).then(response => {
|
|
|
+ proxy.$modal.msgSuccess("修改成功");
|
|
|
+ open.value = false;
|
|
|
+ getList();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ addQh(form.value).then(response => {
|
|
|
+ proxy.$modal.msgSuccess("新增成功");
|
|
|
+ open.value = false;
|
|
|
+ getList();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/** 删除按钮操作 */
|
|
|
+function handleDelete(row) {
|
|
|
+ const _qhIds = row.qhId || ids.value;
|
|
|
+ proxy.$modal.confirm('是否确认删除期货价格编号为"' + _qhIds + '"的数据项?').then(function() {
|
|
|
+ return delQh(_qhIds);
|
|
|
+ }).then(() => {
|
|
|
+ getList();
|
|
|
+ proxy.$modal.msgSuccess("删除成功");
|
|
|
+ }).catch(() => {});
|
|
|
+}
|
|
|
+
|
|
|
+/** 导出按钮操作 */
|
|
|
+function handleExport() {
|
|
|
+ proxy.download('lean/qh/export', {
|
|
|
+ ...queryParams.value
|
|
|
+ }, `qh_${new Date().getTime()}.xlsx`)
|
|
|
+}
|
|
|
+
|
|
|
+// 获取所有品名选项
|
|
|
+function getAllClassOptions() {
|
|
|
+ return [
|
|
|
+ { label: 'WTI(/桶)', value: 'WTI(/桶)' },
|
|
|
+ { label: 'Brent(/桶)', value: 'Brent(/桶)' },
|
|
|
+ { label: 'PX(元/t)', value: 'PX(元/t)' },
|
|
|
+ { label: 'OM(元/t)', value: 'OM(元/t)' },
|
|
|
+ { label: 'PTA(元/t)', value: 'PTA(元/t)' },
|
|
|
+ { label: 'MEG(元/t)', value: 'MEG(元/t)' },
|
|
|
+ { label: 'FDY(元/t)', value: 'FDY(元/t)' },
|
|
|
+ { label: 'DTY(元/t)', value: 'DTY(元/t)' },
|
|
|
+ { label: 'POY(元/t)', value: 'POY(元/t)' }
|
|
|
+ ];
|
|
|
+}
|
|
|
+
|
|
|
+// 处理查询条件中类别变化
|
|
|
+function handleTypeChange(value) {
|
|
|
+ if (value && typeClassMap[value]) {
|
|
|
+ qhClassOptions.value = typeClassMap[value].map(item => ({
|
|
|
+ label: item,
|
|
|
+ value: item
|
|
|
+ }));
|
|
|
+ } else {
|
|
|
+ qhClassOptions.value = getAllClassOptions();
|
|
|
+ }
|
|
|
+ queryParams.value.qhClass = null;
|
|
|
+}
|
|
|
+
|
|
|
+// 处理表单中类别变化
|
|
|
+function handleFormTypeChange(value) {
|
|
|
+ if (value && typeClassMap[value]) {
|
|
|
+ formQhClassOptions.value = typeClassMap[value].map(item => ({
|
|
|
+ label: item,
|
|
|
+ value: item
|
|
|
+ }));
|
|
|
+ } else {
|
|
|
+ formQhClassOptions.value = getAllClassOptions();
|
|
|
+ }
|
|
|
+ form.value.qhClass = null;
|
|
|
+}
|
|
|
+
|
|
|
+getList();
|
|
|
+</script>
|