|
@@ -17,9 +17,22 @@
|
|
|
:key="groupIndex"
|
|
|
@click="changeCurrentGroup(groupIndex)"
|
|
|
>
|
|
|
+ <p style="margin-top: 10px" v-if="param1 == 2 && groupIndex > 0">
|
|
|
+ 数据操作:
|
|
|
+ <el-select v-model="valueYW" size="small" placeholder="请选择">
|
|
|
+ <el-option
|
|
|
+ v-for="item in optionsYW"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </p>
|
|
|
+
|
|
|
<p class="SP1">
|
|
|
<span>
|
|
|
- 执行器{{ groupIndex + 1 }}
|
|
|
+ 执行器{{ groupIndex + 1 }}:
|
|
|
<el-input
|
|
|
style="margin: 0 10px"
|
|
|
size="small"
|
|
@@ -28,6 +41,21 @@
|
|
|
<el-button size="small" type="text" @click="dialogVisible = true"
|
|
|
>上传附件</el-button
|
|
|
>
|
|
|
+ <!-- 删除执行器组按钮 -->
|
|
|
+ <el-button
|
|
|
+ size="small"
|
|
|
+ type="text"
|
|
|
+ @click="removeGroup(groupIndex)"
|
|
|
+ >删除执行器组</el-button
|
|
|
+ >
|
|
|
+ <span v-if="param1 == 2" style="margin-left: 10px;">
|
|
|
+ <el-switch
|
|
|
+ v-model="group.choiceVal"
|
|
|
+ active-text="合并"
|
|
|
+ inactive-text="拼接"
|
|
|
+ >
|
|
|
+ </el-switch>
|
|
|
+ </span>
|
|
|
</span>
|
|
|
</p>
|
|
|
|
|
@@ -53,28 +81,32 @@
|
|
|
"
|
|
|
>
|
|
|
<el-table-column type="selection" width="55"> </el-table-column>
|
|
|
- <el-table-column
|
|
|
- v-for="(key, colIndex) in table.columnKeys"
|
|
|
- :key="colIndex"
|
|
|
- :label="'Item ' + (parseInt(key) + 1)"
|
|
|
- :prop="key.toString()"
|
|
|
- ></el-table-column>
|
|
|
+ <template v-for="(rowKeys, rowIndex) in table.columnKeys">
|
|
|
+ <el-table-column
|
|
|
+ v-for="(key, colIndex) in rowKeys"
|
|
|
+ :key="`row-${rowIndex}-col-${colIndex}`"
|
|
|
+ :label="'Item ' + (key + 1)"
|
|
|
+ :prop="key.toString()"
|
|
|
+ ></el-table-column>
|
|
|
+ </template>
|
|
|
</el-table>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<div class="database">
|
|
|
- <el-tabs type="border-card">
|
|
|
+ {{ activeName }}
|
|
|
+ <el-tabs type="border-card" v-model="activeName">
|
|
|
<!-- 动态生成标签页 -->
|
|
|
<el-tab-pane
|
|
|
v-for="(group, groupIndex) in groups"
|
|
|
:key="groupIndex"
|
|
|
+ :name="String(groupIndex + 1)"
|
|
|
:label="'执行器组 ' + (groupIndex + 1)"
|
|
|
>
|
|
|
<div class="pair">
|
|
|
<p v-for="(item, index) in modelList" :key="index">
|
|
|
- <span>{{ item.name }}</span>
|
|
|
+ <span>{{ item.standardizedName }}</span>
|
|
|
<el-select
|
|
|
size="small"
|
|
|
v-model="item.val"
|
|
@@ -97,18 +129,18 @@
|
|
|
<p>添加数据字段</p>
|
|
|
<div class="search">
|
|
|
<el-input size="small" v-model="field"></el-input>
|
|
|
- <el-button size="small" type="text" @click="newVisible = true"
|
|
|
+ <!-- <el-button size="small" type="text" @click="newVisible = true"
|
|
|
>自定义</el-button
|
|
|
- >
|
|
|
+ > -->
|
|
|
</div>
|
|
|
-
|
|
|
+ <!-- {{ dynamicCheckOptions }}{{ activeName }} -->
|
|
|
<el-checkbox-group
|
|
|
v-model="checkList"
|
|
|
@change="duoxuan"
|
|
|
class="repetition"
|
|
|
>
|
|
|
<el-checkbox
|
|
|
- v-for="(item, index) in checkOptions"
|
|
|
+ v-for="(item, index) in currentCheckOptions"
|
|
|
:key="index"
|
|
|
:label="item"
|
|
|
>
|
|
@@ -118,7 +150,9 @@
|
|
|
</div>
|
|
|
</el-tab-pane>
|
|
|
</el-tabs>
|
|
|
- <el-button class="fixed-button" type="primary" @click="submitData"> 保存 </el-button>
|
|
|
+ <el-button class="fixed-button" type="primary" @click="submitData">
|
|
|
+ 保存
|
|
|
+ </el-button>
|
|
|
</div>
|
|
|
|
|
|
<!-- 弹窗 -->
|
|
@@ -129,37 +163,59 @@
|
|
|
:before-close="handleClose"
|
|
|
>
|
|
|
<el-form ref="form" :model="form" label-width="100px">
|
|
|
+ <!-- 上传附件 -->
|
|
|
<el-form-item label="上传附件:">
|
|
|
<el-upload
|
|
|
class="upload-demo"
|
|
|
- action="https://jsonplaceholder.typicode.com/posts/"
|
|
|
- :on-preview="handlePreview"
|
|
|
- :on-remove="handleRemove"
|
|
|
- :before-remove="beforeRemove"
|
|
|
- multiple
|
|
|
- :limit="3"
|
|
|
- :on-exceed="handleExceed"
|
|
|
:file-list="fileList"
|
|
|
+ action
|
|
|
+ :multiple="false"
|
|
|
+ :before-upload="beforeUpload"
|
|
|
+ :limit="1"
|
|
|
+ :auto-upload="false"
|
|
|
+ :on-change="handleOnChange"
|
|
|
+ :http-request="handleUpload"
|
|
|
>
|
|
|
<el-button @click="onUpload" size="small">上传</el-button>
|
|
|
</el-upload>
|
|
|
</el-form-item>
|
|
|
+
|
|
|
+ <!-- 是否有列名 -->
|
|
|
<el-form-item label="是否有列名:">
|
|
|
- <el-radio-group v-model="form.resource">
|
|
|
- <el-radio label="是"></el-radio>
|
|
|
- <el-radio label="否"></el-radio>
|
|
|
+ <el-radio-group
|
|
|
+ v-model="form.hasColName"
|
|
|
+ @change="onHasColNameChange"
|
|
|
+ >
|
|
|
+ <el-radio :label="1">是</el-radio>
|
|
|
+ <el-radio :label="0">否</el-radio>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
+
|
|
|
+ <!-- 列名所在行 -->
|
|
|
<el-form-item label="列名所在行:">
|
|
|
- <el-input v-model="form.name"></el-input>
|
|
|
+ <el-input
|
|
|
+ v-model="form.readRowNum"
|
|
|
+ :disabled="form.hasColName !== 1"
|
|
|
+ ></el-input>
|
|
|
</el-form-item>
|
|
|
|
|
|
+ <!-- 范围最小值 -->
|
|
|
<el-form-item label="范围最小值:">
|
|
|
- <el-input v-model="form.name"></el-input>
|
|
|
+ <el-input
|
|
|
+ v-model="form.minRowNum"
|
|
|
+ :disabled="form.hasColName !== 0"
|
|
|
+ ></el-input>
|
|
|
</el-form-item>
|
|
|
+
|
|
|
+ <!-- 范围最大值 -->
|
|
|
<el-form-item label="范围最大值:">
|
|
|
- <el-input v-model="form.name"></el-input>
|
|
|
+ <el-input
|
|
|
+ v-model="form.maxRowNum"
|
|
|
+ :disabled="form.hasColName !== 0"
|
|
|
+ ></el-input>
|
|
|
</el-form-item>
|
|
|
+
|
|
|
+ <!-- 提交按钮 -->
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" @click="onSubmit()">立即创建</el-button>
|
|
|
</el-form-item>
|
|
@@ -205,48 +261,52 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import axios from "axios";
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
+ optionsYW: [
|
|
|
+ {
|
|
|
+ value: "1",
|
|
|
+ label: "合并",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: "2",
|
|
|
+ label: "拼接",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ valueYW: "",
|
|
|
+ form: {
|
|
|
+ file: [],
|
|
|
+ hasColName: "",
|
|
|
+ readRowNum: "",
|
|
|
+ minRowNum: "",
|
|
|
+ maxRowNum: "",
|
|
|
+ },
|
|
|
+ activeName: "1",
|
|
|
+ dynamicCheckOptions: {}, // 用于存储动态的 checkOptions,例如 checkOptions1, checkOptions2 等
|
|
|
+
|
|
|
dialogVisible: false,
|
|
|
newVisible: false,
|
|
|
zxqName: "",
|
|
|
- tableData: [
|
|
|
- { 0: "2023-12-01", 1: "2023-12-02", 2: "2023-12-03", 3: "2023-12-04" },
|
|
|
- { 0: "2023-12-01", 1: "2023-12-02", 2: "2023-12-03", 3: "2023-12-04" },
|
|
|
- { 0: "2023-12-01", 1: "2023-12-02", 2: "2023-12-03", 3: "2023-12-04" },
|
|
|
- ],
|
|
|
+ // tableData: [
|
|
|
+ // { 0: "2023-12-01", 1: "2023-12-02", 2: "2023-12-03", 3: "2023-12-04" },
|
|
|
+ // { 0: "2023-12-01", 1: "2023-12-02", 2: "2023-12-03", 3: "2023-12-04" },
|
|
|
+ // { 0: "2023-12-01", 1: "2023-12-02", 2: "2023-12-03", 3: "2023-12-04" },
|
|
|
+ // ],
|
|
|
columnKeys: [],
|
|
|
- form: {},
|
|
|
+
|
|
|
fileList: [],
|
|
|
tables: [],
|
|
|
groups: [
|
|
|
{
|
|
|
+ choiceVal: "",
|
|
|
inputValue: "", // 输入框默认值
|
|
|
tables: [
|
|
|
- {
|
|
|
- columnKeys: ["0", "1", "2", "3"], // 默认的列
|
|
|
- data: [
|
|
|
- {
|
|
|
- 0: "2023-12-01",
|
|
|
- 1: "2023-12-02",
|
|
|
- 2: "2023-12-03",
|
|
|
- 3: "2023-12-04",
|
|
|
- },
|
|
|
- {
|
|
|
- 0: "2023-12-05",
|
|
|
- 1: "2023-12-06",
|
|
|
- 2: "2023-12-07",
|
|
|
- 3: "2023-12-08",
|
|
|
- },
|
|
|
- {
|
|
|
- 0: "2023-12-09",
|
|
|
- 1: "2023-12-10",
|
|
|
- 2: "2023-12-11",
|
|
|
- 3: "2023-12-12",
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
+ // {
|
|
|
+ // columnKeys: [], // 默认的列
|
|
|
+ // data: [],
|
|
|
+ // },
|
|
|
],
|
|
|
},
|
|
|
],
|
|
@@ -257,90 +317,150 @@ export default {
|
|
|
checkList: [],
|
|
|
multipleSelection: [],
|
|
|
checkOptions: [], // 循环的选项
|
|
|
- modelList: [
|
|
|
- { name: "模板1", val: [] },
|
|
|
- { name: "模板2", val: [] },
|
|
|
- ],
|
|
|
+ modelList: [],
|
|
|
inputList: [
|
|
|
{ value: "" }, // 默认有一个输入框
|
|
|
],
|
|
|
+ param1: null,
|
|
|
+ param2: null,
|
|
|
+ choiceVal: "",
|
|
|
};
|
|
|
},
|
|
|
-
|
|
|
+ computed: {
|
|
|
+ currentCheckOptions() {
|
|
|
+ const checkOptionsKey = `checkOptions${Number(this.activeName)}`;
|
|
|
+ if (!this.dynamicCheckOptions[checkOptionsKey]) {
|
|
|
+ this.$set(this.dynamicCheckOptions, checkOptionsKey, []); // 初始化
|
|
|
+ }
|
|
|
+ return this.dynamicCheckOptions[checkOptionsKey];
|
|
|
+ },
|
|
|
+ },
|
|
|
mounted() {
|
|
|
- if (this.tableData.length > 0) {
|
|
|
- this.columnKeys = Object.keys(this.tableData[0]); // 动态提取列名
|
|
|
- }
|
|
|
+ // if (this.tableData.length > 0) {
|
|
|
+ // this.columnKeys = Object.keys(this.tableData[0]); // 动态提取列名
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.param1 = this.$route.query.param1;
|
|
|
+ this.param2 = this.$route.query.param2;
|
|
|
+ this.GETinquire();
|
|
|
},
|
|
|
- methods: {
|
|
|
-
|
|
|
- submitData(){
|
|
|
-console.log(this.groups,'groups');
|
|
|
|
|
|
- },
|
|
|
- // 获取默认表格模板
|
|
|
- getDefaultTable() {
|
|
|
- return {
|
|
|
- columnKeys: ["0", "1", "2", "3"],
|
|
|
- data: [
|
|
|
- {
|
|
|
- 0: "2023-12-01",
|
|
|
- 1: "2023-12-02",
|
|
|
- 2: "2023-12-03",
|
|
|
- 3: "2023-12-04",
|
|
|
- },
|
|
|
- {
|
|
|
- 0: "2023-12-05",
|
|
|
- 1: "2023-12-06",
|
|
|
- 2: "2023-12-07",
|
|
|
- 3: "2023-12-08",
|
|
|
- },
|
|
|
- {
|
|
|
- 0: "2023-12-09",
|
|
|
- 1: "2023-12-10",
|
|
|
- 2: "2023-12-11",
|
|
|
- 3: "2023-12-12",
|
|
|
- },
|
|
|
- ],
|
|
|
- };
|
|
|
+ methods: {
|
|
|
+ // 清空与选择无关的字段
|
|
|
+ onHasColNameChange() {
|
|
|
+ if (this.form.hasColName === 1) {
|
|
|
+ this.form.minRowNum = "";
|
|
|
+ this.form.maxRowNum = "";
|
|
|
+ }
|
|
|
+ if (this.form.hasColName === 0) {
|
|
|
+ this.form.readRowNum = "";
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
- // 上传操作
|
|
|
- onUpload() {
|
|
|
- this.dialogVisible = true;
|
|
|
+ GETinquire() {
|
|
|
+ const url = `/ETLapi/baseTemplateField/template/${this.param2}`; //
|
|
|
+ axios
|
|
|
+ .get(url)
|
|
|
+ .then((res) => {
|
|
|
+ this.modelList = res.data.datas;
|
|
|
+ })
|
|
|
+ .catch((error) => {});
|
|
|
},
|
|
|
|
|
|
// 仅在当前 group 下新增表格
|
|
|
onSubmit() {
|
|
|
- const newTable = {
|
|
|
- columnKeys: ["0", "1", "2", "3"], // 默认列
|
|
|
- data: [
|
|
|
- {
|
|
|
- 0: "2023-12-01",
|
|
|
- 1: "2023-12-02",
|
|
|
- 2: "2023-12-03",
|
|
|
- 3: "2023-12-04",
|
|
|
- },
|
|
|
- {
|
|
|
- 0: "2023-12-01",
|
|
|
- 1: "2023-12-02",
|
|
|
- 2: "2023-12-03",
|
|
|
- 3: "2023-12-04",
|
|
|
- },
|
|
|
- {
|
|
|
- 0: "2023-12-01",
|
|
|
- 1: "2023-12-02",
|
|
|
- 2: "2023-12-03",
|
|
|
- 3: "2023-12-04",
|
|
|
+ if (!this.form.file || !(this.form.file.raw instanceof File)) {
|
|
|
+ this.$message.error("请上传文件后再提交");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const formData = new FormData();
|
|
|
+ if (this.form.file && this.form.file.raw instanceof File) {
|
|
|
+ const file = this.form.file.raw; // 获取原始文件数据
|
|
|
+ console.log(file, "file");
|
|
|
+ formData.append("file", file, file.name); // 使用原始文件名作为文件名
|
|
|
+ } else {
|
|
|
+ console.error("文件未正确传递");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 将表单数据添加到 FormData 中
|
|
|
+ // formData.append("file", this.form.file); // 假设你要上传一个文件,字段名为 'file'
|
|
|
+ // 检查是否有值,如果有值才添加到 formData 中
|
|
|
+ if (this.form.hasColName !== undefined) {
|
|
|
+ formData.append("hasColName", this.form.hasColName);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.form.maxRowNum !== "" && this.form.maxRowNum !== null) {
|
|
|
+ formData.append("maxRowNum", this.form.maxRowNum);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.form.minRowNum !== "" && this.form.minRowNum !== null) {
|
|
|
+ formData.append("minRowNum", this.form.minRowNum);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.form.readRowNum !== "" && this.form.readRowNum !== null) {
|
|
|
+ formData.append("readRowNum", this.form.readRowNum);
|
|
|
+ }
|
|
|
+
|
|
|
+ axios
|
|
|
+ .post("/ETLapi/processExecutor/readExcelData", formData, {
|
|
|
+ headers: {
|
|
|
+ "Content-Type": "multipart/form-data", // 确保 Content-Type 设置为 multipart/form-data
|
|
|
},
|
|
|
- ],
|
|
|
- };
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ const newTable = {
|
|
|
+ columnKeys: res.data.datas.cols,
|
|
|
+ data: res.data.datas.data,
|
|
|
+ };
|
|
|
+
|
|
|
+ this.groups[this.currentGroupIndex].tables.push(newTable);
|
|
|
+ this.$message.success("文件上传成功");
|
|
|
+ this.dialogVisible = false;
|
|
|
+ this.resetForm();
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ this.$message.error("上传失败,请重试");
|
|
|
+ console.error("上传失败:", error);
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
- // 只在当前 group 的 tables 数组中新增表格
|
|
|
- this.groups[this.currentGroupIndex].tables.push(newTable);
|
|
|
+ // 上传的
|
|
|
+ beforeUpload(file) {
|
|
|
+ this.form.file = file;
|
|
|
+ console.log("文件上传前:", this.form.file);
|
|
|
+ // 你可以在这里进行一些处理,如检查文件类型、大小等
|
|
|
+ return true; // 返回 true 继续上传,返回 false 则阻止上传
|
|
|
+ },
|
|
|
+ handleOnChange(file, fileList) {
|
|
|
+ this.form.file = file; // 更新选中文件
|
|
|
+ this.fileList = fileList; // 更新文件列表
|
|
|
+ },
|
|
|
|
|
|
- console.log("新增后的 groups 数据:", this.groups);
|
|
|
- this.dialogVisible = false;
|
|
|
+ submitData() {
|
|
|
+ const url = "/ETLapi/processGroup/addProcessGroup";
|
|
|
+ const payload = {
|
|
|
+ joinType: this.param1,
|
|
|
+ name: this.zxqName,
|
|
|
+ processExecutorInDataList: this.groups.map((group) => ({
|
|
|
+ knownFieldsList: this.selectoptions,
|
|
|
+ mappingFieldList: this.modelList.map((item) => ({
|
|
|
+ dataNameList: item.val,
|
|
|
+ standardizedName: item.standardizedName, // 获取每个 item 的 standardizedName
|
|
|
+ templateFiledId: item.id, //
|
|
|
+ })),
|
|
|
+ name: group.inputValue, //
|
|
|
+ })),
|
|
|
+ templateId: this.param2,
|
|
|
+ }; //
|
|
|
+
|
|
|
+ // return;
|
|
|
+ axios
|
|
|
+ .post(url, payload)
|
|
|
+ .then((res) => {})
|
|
|
+ .catch((error) => {
|
|
|
+ console.error("请求失败:", error);
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
// 切换当前 group
|
|
@@ -353,47 +473,114 @@ console.log(this.groups,'groups');
|
|
|
this.groups[groupIndex].tables.splice(tableIndex, 1);
|
|
|
},
|
|
|
|
|
|
+ // 删除整个执行器组
|
|
|
+ removeGroup(groupIndex) {
|
|
|
+ this.groups.splice(groupIndex, 1); // 删除执行器组
|
|
|
+ },
|
|
|
+
|
|
|
// 新增执行器组
|
|
|
addGroup() {
|
|
|
this.groups.push({
|
|
|
inputValue: "",
|
|
|
- tables: [this.getDefaultTable()],
|
|
|
+ tables: [],
|
|
|
});
|
|
|
+ console.log(this.groups);
|
|
|
+ this.activeName = String(this.groups.length);
|
|
|
},
|
|
|
-
|
|
|
handleSelectionChange(val, groupIndex, tableIndex) {
|
|
|
+ this.activeName = String(groupIndex + 1);
|
|
|
+ console.log(val, groupIndex, tableIndex);
|
|
|
const currentTable = this.groups[groupIndex].tables[tableIndex]; // 获取当前表格
|
|
|
// 提取每行所有字段的值(不管字段名是什么)
|
|
|
currentTable.selectedValues = val.flatMap((item) => Object.values(item)); // 获取每一行的所有值
|
|
|
|
|
|
+ // 动态生成对应 groupIndex 的 checkOptions 键名
|
|
|
+ const groupCheckOptionsKey = `checkOptions${groupIndex + 1}`;
|
|
|
+
|
|
|
+ // 如果该 checkOptions 还没有定义,则初始化为空数组
|
|
|
+ if (!this.dynamicCheckOptions[groupCheckOptionsKey]) {
|
|
|
+ this.dynamicCheckOptions[groupCheckOptionsKey] = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ const groupCheckOptions = this.dynamicCheckOptions[groupCheckOptionsKey];
|
|
|
+
|
|
|
// 计算新增和移除的选项
|
|
|
const added = currentTable.selectedValues.filter(
|
|
|
(item) =>
|
|
|
- !this.checkOptions.includes(item) &&
|
|
|
+ !groupCheckOptions.includes(item) &&
|
|
|
!this.inputList.some((input) => input.value === item) // 排除掉 confirm 添加的值
|
|
|
);
|
|
|
|
|
|
- const removed = this.checkOptions.filter(
|
|
|
+ const removed = groupCheckOptions.filter(
|
|
|
(item) =>
|
|
|
!currentTable.selectedValues.includes(item) &&
|
|
|
!this.inputList.some((input) => input.value === item) // 排除掉 confirm 添加的值
|
|
|
);
|
|
|
|
|
|
- // 更新 checkOptions
|
|
|
+ // 更新 groupCheckOptions
|
|
|
if (added.length) {
|
|
|
- this.checkOptions.push(...added);
|
|
|
+ groupCheckOptions.push(...added);
|
|
|
}
|
|
|
if (removed.length) {
|
|
|
- this.checkOptions = this.checkOptions.filter(
|
|
|
- (item) => !removed.includes(item)
|
|
|
- );
|
|
|
+ this.dynamicCheckOptions[groupCheckOptionsKey] =
|
|
|
+ groupCheckOptions.filter((item) => !removed.includes(item));
|
|
|
}
|
|
|
|
|
|
- // 重新计算 checkOptions,包含所有选中行的所有字段值
|
|
|
- this.checkOptions = this.groups
|
|
|
- .flatMap((group) => group.tables) // 遍历所有组的所有表格
|
|
|
- .flatMap((table) => table.selectedValues || []); // 合并所有表格的选中行的字段值
|
|
|
+ // 重新计算该组内所有选中行的所有字段值
|
|
|
+ this.dynamicCheckOptions[groupCheckOptionsKey] = this.groups[
|
|
|
+ groupIndex
|
|
|
+ ].tables.flatMap((table) => table.selectedValues || []); // 合并该组内所有表格的选中行的字段值
|
|
|
+ console.log(this.dynamicCheckOptions, [groupCheckOptionsKey]);
|
|
|
},
|
|
|
+ // handleSelectionChange(val, groupIndex, tableIndex) {
|
|
|
+ // this.activeName = String(groupIndex + 1); // 设置当前活动的 group 名称
|
|
|
+ // console.log(val, groupIndex, tableIndex);
|
|
|
+
|
|
|
+ // const currentTable = this.groups[groupIndex].tables[tableIndex]; // 获取当前表格
|
|
|
+ // // 提取每行所有字段的值(不管字段名是什么)
|
|
|
+ // currentTable.selectedValues = val.flatMap((item) => Object.values(item)); // 获取每一行的所有值
|
|
|
+
|
|
|
+ // // 动态生成对应 groupIndex 的 checkOptions 键名
|
|
|
+ // const groupCheckOptionsKey = `checkOptions${groupIndex + 1}`;
|
|
|
+
|
|
|
+ // // 如果该 checkOptions 还没有定义,则初始化为空数组
|
|
|
+ // if (!this.dynamicCheckOptions[groupCheckOptionsKey]) {
|
|
|
+ // this.dynamicCheckOptions[groupCheckOptionsKey] = [];
|
|
|
+ // }
|
|
|
+
|
|
|
+ // const groupCheckOptions = this.dynamicCheckOptions[groupCheckOptionsKey];
|
|
|
+
|
|
|
+ // // 获取 val 中的所有选中的值
|
|
|
+ // const selectedValues = currentTable.selectedValues;
|
|
|
+
|
|
|
+ // // 计算新增的选项(仅处理 val 中存在的值)
|
|
|
+ // const added = selectedValues.filter(
|
|
|
+ // (item) =>
|
|
|
+ // !groupCheckOptions.includes(item) &&
|
|
|
+ // !this.inputList.some((input) => input.value === item) // 排除掉 confirm 添加的值
|
|
|
+ // );
|
|
|
+
|
|
|
+ // // 计算移除的选项(从 checkOptions 中移除不在 val 中的项)
|
|
|
+ // const removed = groupCheckOptions.filter(
|
|
|
+ // (item) =>
|
|
|
+ // !selectedValues.includes(item) &&
|
|
|
+ // !this.inputList.some((input) => input.value === item) // 排除掉 confirm 添加的值
|
|
|
+ // );
|
|
|
+
|
|
|
+ // // 只处理 val 中传参的值,更新 groupCheckOptions
|
|
|
+ // if (added.length) {
|
|
|
+ // groupCheckOptions.push(...added); // 添加新选项
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (removed.length) {
|
|
|
+ // // 移除不在 val 中的项
|
|
|
+ // this.dynamicCheckOptions[groupCheckOptionsKey] =
|
|
|
+ // groupCheckOptions.filter((item) => !removed.includes(item));
|
|
|
+ // }
|
|
|
+
|
|
|
+ // // 输出动态 checkOptions 的状态
|
|
|
+ // console.log(this.dynamicCheckOptions, [groupCheckOptionsKey]);
|
|
|
+ // },
|
|
|
duoxuan(val) {
|
|
|
console.log(val);
|
|
|
|
|
@@ -414,7 +601,8 @@ console.log(this.groups,'groups');
|
|
|
this.inputList.forEach((item) => {
|
|
|
if (item.value) {
|
|
|
// 如果有值才添加
|
|
|
- this.checkOptions.push(item.value);
|
|
|
+ const checkOptionsKey = `checkOptions${Number(this.activeName)}`;
|
|
|
+ this.dynamicCheckOptions[checkOptionsKey].push(item.value);
|
|
|
}
|
|
|
});
|
|
|
console.log(this.selectoptions);
|
|
@@ -424,24 +612,69 @@ console.log(this.groups,'groups');
|
|
|
done();
|
|
|
},
|
|
|
|
|
|
- handleRemove(file, fileList) {
|
|
|
- console.log(file, fileList);
|
|
|
+ handleUpload({ file, onSuccess, onError, formData }) {
|
|
|
+ // 使用 fetch 上传文件
|
|
|
+ fetch("YOUR_UPLOAD_URL", {
|
|
|
+ method: "POST",
|
|
|
+ body: formData, // 将 FormData 作为请求体
|
|
|
+ })
|
|
|
+ .then((response) => {
|
|
|
+ if (!response.ok) {
|
|
|
+ throw new Error(`上传失败,状态码:${response.status}`);
|
|
|
+ }
|
|
|
+ return response.json(); // 假设返回 JSON 数据
|
|
|
+ })
|
|
|
+ .then((data) => {
|
|
|
+ console.log("上传成功", data);
|
|
|
+ // 调用 onSuccess,通知 el-upload 上传成功
|
|
|
+ onSuccess(data);
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ console.error("上传失败", error);
|
|
|
+ onError(error); // 调用 onError,通知 el-upload 上传失败
|
|
|
+ });
|
|
|
},
|
|
|
-
|
|
|
- handlePreview(file) {
|
|
|
- console.log(file);
|
|
|
+ // 清空上传
|
|
|
+ resetForm() {
|
|
|
+ this.form = {
|
|
|
+ file: null,
|
|
|
+ hasColName: null,
|
|
|
+ readRowNum: "",
|
|
|
+ minRowNum: "",
|
|
|
+ maxRowNum: "",
|
|
|
+ };
|
|
|
+ this.fileList = [];
|
|
|
},
|
|
|
-
|
|
|
- handleExceed(files, fileList) {
|
|
|
- this.$message.warning(
|
|
|
- `当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
|
|
|
- files.length + fileList.length
|
|
|
- } 个文件`
|
|
|
- );
|
|
|
+ // 上传操作
|
|
|
+ onUpload() {
|
|
|
+ this.dialogVisible = true;
|
|
|
},
|
|
|
|
|
|
- beforeRemove(file, fileList) {
|
|
|
- return this.$confirm(`确定移除 ${file.name}?`);
|
|
|
+ // 获取默认表格模板
|
|
|
+ getDefaultTable() {
|
|
|
+ return {
|
|
|
+ columnKeys: ["0", "1", "2", "3"],
|
|
|
+ data: [
|
|
|
+ {
|
|
|
+ 0: "2023-12-01",
|
|
|
+ 1: "2023-12-02",
|
|
|
+ 2: "2023-12-03",
|
|
|
+ 3: "2023-12-04",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 0: "2023-12-05",
|
|
|
+ 1: "2023-12-06",
|
|
|
+ 2: "2023-12-07",
|
|
|
+ 3: "2023-12-08",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 0: "2023-12-09",
|
|
|
+ 1: "2023-12-10",
|
|
|
+ 2: "2023-12-11",
|
|
|
+ 3: "2023-12-12",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
},
|
|
|
},
|
|
|
};
|
|
@@ -495,11 +728,14 @@ console.log(this.groups,'groups');
|
|
|
|
|
|
span {
|
|
|
display: inline-block;
|
|
|
- width: 150px;
|
|
|
+ width: 140px;
|
|
|
}
|
|
|
|
|
|
.el-select {
|
|
|
- width: 180px;
|
|
|
+ width: 190px;
|
|
|
+ .el-tag {
|
|
|
+ width: 70%;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|