123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804 |
- <template>
- <div class="global-variable" v-loading="loading">
- <div class="condition">
- <el-form
- ref="ruleForm"
- :inline="true"
- :model="formInline"
- class="demo-form-inline"
- >
- <el-form-item label="批次编号:" prop="batchCode">
- <el-input
- v-model="formInline.batchCode"
- placeholder="请输入批次编号"
- size="small"
- ></el-input>
- </el-form-item>
- <el-form-item label="状态:" prop="transferState">
- <el-select
- v-model="formInline.transferState"
- placeholder="请选择状态"
- size="small "
- >
- <el-option
- v-for="item in stateDataList"
- :key="item.value"
- :label="item.lable"
- :value="item.value"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="onSubmit" size="small"
- >查询</el-button
- >
- <el-button @click="reset('ruleForm')" size="small">重置</el-button>
- </el-form-item>
- </el-form>
- </div>
- <div class="list-page">
- <div class="newly">
- <el-button type="primary" @click="addData" size="small">新增</el-button>
- </div>
- <el-table
- class="center-align-table"
- :data="tableData"
- border
- :cell-style="rowStyle"
- stripe
- style="width: 100%"
- >
- <!-- Table Columns -->
- <el-table-column
- fixed
- prop="batchCode"
- align="center"
- label="批次编号"
- width="230"
- >
- </el-table-column>
- <el-table-column prop="fieldCode" align="center" label="风场编号">
- </el-table-column>
- <el-table-column
- prop="engineCount"
- align="center"
- label="机组数量"
- width="100"
- >
- </el-table-column>
- <el-table-column prop="" align="center" label="异常状态" width="100">
- <template slot-scope="scope">
- {{ scope.row.transferState == 2 ? "异常" : "未异常" }}
- </template>
- </el-table-column>
- <el-table-column
- prop="abnormal"
- label="异常信息"
- width="100"
- align="center"
- >
- <template slot-scope="scope">
- <el-button
- v-if="scope.row.transferState == 2"
- @click="particulars(scope.row)"
- type="text"
- size="small"
- >详情</el-button
- >
- <span v-else>/</span>
- </template>
- </el-table-column>
- <el-table-column prop="" align="center" label="状态" width="100">
- <template slot-scope="scope">
- {{
- scope.row.transferState == -1
- ? "未转换"
- : scope.row.transferState == 0
- ? "转换中"
- : scope.row.transferState == 1
- ? "转换成功"
- : scope.row.transferState == 2
- ? "转换失败"
- : "/"
- }}
- </template>
- </el-table-column>
- <el-table-column prop="transferTypeName" align="center" label="类型">
- </el-table-column>
- <el-table-column
- prop="transferFinishTime"
- align="center"
- label="转换时间"
- >
- </el-table-column>
- <el-table-column
- prop="transition"
- align="center"
- fixed="right"
- label="操作"
- width="150"
- >
- <template slot-scope="scope">
- <el-button
- v-if="
- scope.row.transferState !== -1 &&
- (scope.row.transferAddr !== null ||
- scope.row.transferAddr !== '')
- "
- @click="handleEdit(scope.row)"
- type="text"
- size="small"
- >编辑</el-button
- >
- <el-button
- @click="handleClick(scope.row.downloadUrl)"
- type="text"
- size="small"
- >下载</el-button
- >
- <el-button
- v-if="
- scope.row.transferState == -1 &&
- (scope.row.transferAddr === null ||
- scope.row.transferAddr === '')
- "
- @click="editTransferState(scope.row, '转换')"
- type="text"
- size="small"
- >转换</el-button
- >
- <el-button
- v-else
- @click="editTransferState(scope.row, '重新转换')"
- type="text"
- size="small"
- >重新转换</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- <div class="pagination-container">
- <el-pagination
- @current-change="handleCurrentChange"
- :current-page.sync="formInline.pageNum"
- layout="total, prev, pager, next"
- :page-size="formInline.pageSize"
- :total="formInline.totalSize"
- >
- </el-pagination>
- </div>
- </div>
- <!-- 弹出层 -->
- <!-- 新增 -->
- <el-dialog
- title="新增(批次列表为空时,请前往性能分析下批次管理中添加批次!)"
- :visible.sync="nuedialog"
- class="dialogBox"
- width="900px"
- :before-close="handleCloses"
- >
- <div v-loading="loadingView" class="views">
- <el-form ref="form" :model="newform" label-width="150px">
- <el-row>
- <el-form-item
- label="批次编号:"
- prop="batchCode"
- :rules="batchCodeRules"
- >
- <el-select
- filterable
- v-model="newform.batchCode"
- placeholder="请选择批次编号"
- size="small"
- >
- <el-option
- v-for="item in batchList"
- :key="item"
- :label="item"
- :value="item"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-row>
- <el-row
- v-for="(item, index) in newform.dataTransferTypePathDtoList"
- :key="item.transferType"
- >
- <el-col :span="11">
- <el-form-item
- :label="item.transferTypeName + ':'"
- :prop="'transferAddr_' + index"
- :rules="getFileAddrRules(index)"
- >
- <el-input
- :min="1"
- v-model="item.transferAddr"
- :placeholder="'请输入' + item.transferTypeName"
- size="small"
- @change="ensureMinValue(item, 'transferAddr')"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="13">
- <el-form-item
- :label="item.timeGranularityName + ':'"
- :prop="'timeGranularity_' + index"
- :rules="getTimeGranularityRules(index)"
- >
- <el-input
- type="number"
- :min="1"
- v-model="item.timeGranularity"
- :placeholder="'请输入' + item.timeGranularityName"
- size="small"
- @input="ensureMinValue(item, 'timeGranularity')"
- >
- <template slot="append">秒</template></el-input
- >
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="cancel('form')" size="small">取 消</el-button>
- <el-button type="primary" @click="newly('form')" size="small"
- >确 定</el-button
- >
- </span>
- </div>
- </el-dialog>
- <!-- 编辑 -->
- <el-dialog
- title="编辑"
- :visible.sync="editNuedialog"
- class="dialogBox"
- width="900px"
- :before-close="handleCloses"
- >
- <div v-loading="loadingViewEdit" class="views">
- <el-form
- ref="editForm"
- :model="newEditForm"
- label-width="160px"
- :rules="editRules"
- >
- <el-row>
- <el-form-item label="批次编号:" prop="batchCode">
- <el-select
- v-model="newEditForm.batchCode"
- placeholder="请选择批次编号"
- size="small"
- disabled
- >
- <el-option
- v-for="item in batchList"
- :key="item"
- :label="item"
- :value="item"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-row>
- <el-row>
- <el-col :span="11">
- <el-form-item
- :label="
- newEditForm.dataTransferTypePathDtoList[0].transferTypeName +
- ':'
- "
- prop="dataTransferTypePathDtoList.0.transferAddr"
- >
- <!-- :rules="{
- required: true,
- message:
- '请输入' +
- newEditForm.dataTransferTypePathDtoList[0].transferTypeName,
- trigger: 'blur',
- }" -->
- <el-input
- disabled
- v-model="
- newEditForm.dataTransferTypePathDtoList[0].transferAddr
- "
- :placeholder="
- '请输入' +
- newEditForm.dataTransferTypePathDtoList[0].transferTypeName
- "
- size="small"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="13">
- <el-form-item
- :label="
- newEditForm.dataTransferTypePathDtoList[0]
- .timeGranularityName + ':'
- "
- prop="dataTransferTypePathDtoList.0.timeGranularity"
- :rules="{
- required: true,
- message:
- '请输入' +
- newEditForm.dataTransferTypePathDtoList[0]
- .timeGranularityName,
- trigger: 'blur',
- }"
- >
- <el-input
- type="number"
- :min="1"
- v-model="
- newEditForm.dataTransferTypePathDtoList[0].timeGranularity
- "
- :placeholder="
- '请输入' +
- newEditForm.dataTransferTypePathDtoList[0]
- .timeGranularityName
- "
- size="small"
- >
- <template slot="append">秒</template></el-input
- >
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="editCancel('editForm')" size="small"
- >取 消</el-button
- >
- <el-button type="primary" @click="editly('editForm')" size="small"
- >确 定</el-button
- >
- </span>
- </div>
- </el-dialog>
- <!-- 异常信息详情 -->
- <el-dialog
- title="异常详情"
- :visible.sync="unusualdialog"
- width="800px"
- :before-close="handleCloses"
- >
- {{ errInfo }}
- </el-dialog>
- <!-- 转换\重新转换 -->
- <el-dialog
- :title="editTransferStateTitle"
- :visible.sync="editTransferStateLoading"
- width="400px"
- :before-close="handleCloses"
- >
- <div v-loading="loadingViewEdit" class="views">
- <el-form
- ref="editStateForm"
- :model="editTransferStateForm"
- label-width="160px"
- >
- <el-form-item
- label="数据转换路径:"
- prop="dataTransferTypePath"
- :rules="{
- required: true,
- message: '请输入数据转换路径',
- trigger: 'blur',
- }"
- >
- <el-input
- v-model="editTransferStateForm.dataTransferTypePath"
- :placeholder="'请输入数据转换路径'"
- size="small"
- ></el-input>
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="editstateCancel('editStateForm')" size="small"
- >取 消</el-button
- >
- <el-button
- type="primary"
- @click="editStately('editStateForm')"
- size="small"
- >确 定</el-button
- >
- </span>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import {
- queryDataTransferList,
- fieldBatchListForDataTransfer,
- addDataTransferList,
- editTimeGranularityQuery,
- dataTransfer,
- } from "@/api/dataManage";
- import axios from "axios";
- export default {
- data() {
- return {
- loading: false,
- editTransferStateForm: {
- transferAddr: "",
- dataTransferTypePath: "",
- },
- editTransferStateTitle: "",
- editTransferStateLoading: false,
- loadingView: false,
- formInline: {
- batchCode: "",
- transferState: "",
- pageNum: 1,
- pageSize: 10,
- totalSize: 0,
- },
- batchCodeRules: [
- {
- required: true,
- message: "批次编号不能为空",
- trigger: ["change", "blur"],
- },
- ],
- editRules: {
- batchCode: {
- required: true,
- message: "批次编号不能为空",
- trigger: ["change", "blur"],
- },
- },
- rules: {
- batchCode: {
- required: true,
- message: "批次编号不能为空",
- trigger: "change",
- },
- },
- errInfo: "",
- stateDataList: [
- {
- lable: "未转换",
- value: -1,
- },
- {
- lable: "转换中",
- value: 0,
- },
- {
- lable: "转换成功",
- value: 1,
- },
- {
- lable: "转换失败",
- value: 2,
- },
- ],
- batchList: [],
- tableData: [],
- nuedialog: false,
- unusualdialog: false,
- newform: {
- batchCode: "",
- dataTransferTypePathDtoList: [],
- },
- editNuedialog: false,
- loadingViewEdit: false,
- newEditForm: {
- batchCode: "",
- dataTransferTypePathDtoList: [{}],
- },
- };
- },
- created() {
- this.getTableList();
- this.getBatchCodeList();
- },
- methods: {
- handleCloses(done) {
- this.$confirm("确认关闭?")
- .then((_) => {
- this.getBatchCodeList();
- done();
- })
- .catch((_) => {});
- },
- ensureMinValue(item, field) {
- if (item[field] < 1) {
- item[field] = 1;
- }
- },
- editstateCancel(formName) {
- this.$refs[formName] && this.$refs[formName].resetFields();
- this.editTransferStateForm = {};
- this.editTransferStateForm.dataTransferTypePath = "";
- this.editTransferStateLoading = false;
- this.loadingViewEdit = false;
- this.getBatchCodeList();
- },
- editStately(formName) {
- this.$refs[formName].validate((valid) => {
- if (valid) {
- this.loadingViewEdit = true;
- dataTransfer({
- dataTransferAddr: this.editTransferStateForm.dataTransferTypePath,
- dataTransferType: this.editTransferStateForm.transferType,
- batchCode: this.editTransferStateForm.batchCode,
- })
- .then((res) => {
- this.$message({
- message: "操作成功",
- type: "success",
- });
- this.getTableList();
- this.editstateCancel();
- })
- .catch((error) => {
- this.loadingViewEdit = false;
- });
- } else {
- return false;
- }
- });
- },
- //转换\重新转换
- editTransferState(row, title) {
- this.editTransferStateForm = row;
- this.editTransferStateTitle = title;
- this.editTransferStateLoading = true;
- },
- handleEdit(row) {
- this.editNuedialog = true;
- this.newEditForm.batchCode = row.batchCode;
- this.newEditForm.dataTransferTypePathDtoList[0] = row;
- },
- editCancel() {
- this.newform = {
- batchCode: "",
- dataTransferTypePathDtoList: [{}],
- };
- this.editNuedialog = false;
- this.loadingViewEdit = false;
- this.getTableList();
- this.getBatchCodeList();
- },
- editly(formName) {
- this.$refs[formName].validate((valid) => {
- if (valid) {
- this.loadingViewEdit = true;
- editTimeGranularityQuery({
- timeGranularity:
- this.newEditForm.dataTransferTypePathDtoList[0].timeGranularity,
- dataTransferType:
- this.newEditForm.dataTransferTypePathDtoList[0].transferType,
- batchCode: this.newEditForm.batchCode,
- })
- .then((res) => {
- this.$message({
- message: "编辑成功",
- type: "success",
- });
- this.editCancel();
- })
- .catch((error) => {
- console.log("shibai", error);
- this.loadingViewEdit = false;
- });
- } else {
- return false;
- }
- });
- },
- getFileAddrRules(index) {
- return [{ validator: this.validateFileAddr, trigger: "blur" }];
- },
- getTimeGranularityRules(index) {
- return [
- {
- validator: (rule, value, callback) =>
- this.validateTimeGranularity(rule, value, callback, index),
- trigger: "blur",
- },
- ];
- },
- validateFileAddr(rule, value, callback) {
- // 判断是否至少有一项 transferAddr 有值
- const hasFileAddr = this.newform.dataTransferTypePathDtoList.some(
- (item) => item.transferAddr
- );
- if (!hasFileAddr) {
- callback(new Error("请至少填写一个数据路径"));
- } else {
- callback();
- }
- },
- validateTimeGranularity(rule, value, callback, index) {
- // 判断对应的 transferAddr 有值,则对应的 timeGranularity 也必须有值
- const currentItem = this.newform.dataTransferTypePathDtoList[index];
- if (currentItem.transferAddr && !currentItem.timeGranularity) {
- callback(new Error("请填写时间粒度"));
- } else {
- callback();
- }
- },
- cancel(formName) {
- this.$refs[formName] && this.$refs[formName].resetFields();
- this.newform = {
- batchCode: "",
- dataTransferTypePathDtoList: [],
- };
- this.getBatchCodeList();
- this.nuedialog = false;
- this.loadingView = false;
- },
- rowStyle() {
- return "text-align:center";
- },
- // 查询
- onSubmit() {
- this.getTableList();
- },
- // 重置
- reset(formName) {
- this.$refs[formName].resetFields();
- this.getTableList();
- },
- // 新增
- newly(formName) {
- this.$refs[formName].validate((valid) => {
- if (valid) {
- console.log(this.newform, "newform");
- this.loadingView = true;
- addDataTransferList({ ...this.newform })
- .then((res) => {
- this.$message({
- message: "新增成功",
- type: "success",
- });
- this.getTableList();
- this.cancel();
- this.loadingView = false;
- })
- .catch(() => {
- this.loadingView = false;
- });
- } else {
- return false;
- }
- });
- },
- //异常详情
- particulars(row) {
- this.unusualdialog = true;
- this.errInfo = row.errInfo;
- },
- //下载
- async handleClick(downloadUrl) {
- let newWindow = window.open(downloadUrl, "_blank");
- if (
- !newWindow ||
- newWindow.closed ||
- typeof newWindow.closed == "undefined"
- ) {
- alert("弹出窗口已被阻止!请允许弹出式窗口访问本网站。");
- }
- },
- // async handleClick() {
- // try {
- // // 获取 HTML 内容
- // const response = await axios.get("/downLoadApi", {
- // responseType: "blob",
- // }); // 确保响应类型为 Blob
- // const reader = new FileReader();
- // reader.onload = function (event) {
- // const htmlContent = event.target.result; // 读取的 HTML 内容
- // const newWindow = window.open("", "_blank");
- // newWindow.document.open();
- // newWindow.document.write(htmlContent);
- // newWindow.document.close();
- // // 获取当前页面的 URL
- // const currentUrl = window.location.href;
- // const proxyUrl = currentUrl.substring(0, currentUrl.indexOf("/", 8)); // 从第8个字符开始搜索,找到第一个 "/" 为止
- // // 拼接代理地址和接口路径
- // const apiEndpoint = proxyUrl + "/downLoadApi";
- // // 拼接新的路径
- // const newUrl = apiEndpoint + "/downLoadApi";
- // // 设置 base 元素
- // const baseElement = newWindow.document.createElement("base");
- // baseElement.href = newUrl; // 使用代理地址和接口路径
- // newWindow.document.head.appendChild(baseElement);
- // };
- // reader.readAsText(response.data, "utf-8"); // 以 UTF-8 编码读取 Blob
- // } catch (error) {
- // console.error("Failed to fetch data:", error);
- // this.$message.error("无法打开新链接");
- // }
- // },
- async getTableList() {
- try {
- this.loading = true;
- const result = await queryDataTransferList({
- ...this.formInline,
- totalSize: undefined,
- });
- this.tableData = result.data.list;
- this.formInline.totalSize = result.data.totalSize;
- this.loading = false;
- } catch (error) {
- this.$message({
- type: "error",
- message: "请检查是否连接网络",
- });
- }
- },
- //分页数据切换
- handleCurrentChange(val) {
- this.formInline.pageNum = val;
- this.getTableList();
- },
- //新增按钮
- addData() {
- if (this.batchList === null || this.batchList.length === 0) {
- this.$confirm(
- "批次列表为空,请前往性能分析菜单下的批次管理中添加批次!确认跳转到批次管理菜单吗?",
- "提示",
- {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }
- )
- .then(() => {
- this.$router.push("/home/performance/batchMag?id=22");
- this.$message({
- type: "success",
- message: "成功!",
- });
- })
- .catch(() => {
- this.$message({
- type: "info",
- message: "已取消",
- });
- });
- } else {
- this.nuedialog = true;
- }
- },
- //获取批次编号列表接口
- async getBatchCodeList() {
- this.loading = true;
- try {
- const result = await fieldBatchListForDataTransfer();
- this.batchList = result.data.batchCodeList;
- this.newform.dataTransferTypePathDtoList =
- result.data.dataTransferTypeVoList;
- this.loading = false;
- } catch (error) {
- this.loading = false;
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- ::v-deep.dialogBox {
- .el-form-item__content .el-input--small .el-input__inner {
- width: 188px !important;
- }
- .el-row {
- margin: 5px 0;
- }
- .dialog-footer {
- margin-top: 20px;
- justify-content: center !important;
- }
- .el-input-group {
- width: auto;
- }
- }
- </style>
|