生丝标准设置模块 连续添加2个表头错误的问题修改,修改添加表头的逻辑
| | |
| | | |
| | | <el-table |
| | | ref="fromTable" |
| | | v-if="tableShow" |
| | | :data="tableList.tableData" |
| | | style="width: 100%" |
| | | @selection-change="handleSelectionChange" |
| | |
| | | } |
| | | " |
| | | ></el-input> |
| | | <div class="common-select-btn" @click="clearupColumn(item.prop)"> |
| | | {{item.prop}} |
| | | <div class="common-select-btn" @click="clearupColumn(item.prop,i)"> |
| | | <i class="el-icon-remove" title="删除"></i> |
| | | </div> |
| | | </div> |
| | |
| | | type: Boolean, |
| | | default: true |
| | | }, |
| | | // 是否可以编辑表头 |
| | | isEdit: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | silkTableList: { |
| | | type: Object, |
| | | default: () => { |
| | |
| | | productList: [], |
| | | tableList: [], |
| | | projectIndex: 0, |
| | | projectOptions: getDataByType("projectOptions") |
| | | projectOptions: getDataByType("projectOptions"), |
| | | tableShow:true, |
| | | } |
| | | }, |
| | | created() { |
| | |
| | | this.getTableInfo() |
| | | }, |
| | | immediate: true |
| | | } |
| | | }, |
| | | 'silkTableList.tableColumn': { |
| | | handler() { |
| | | this.tableShow=false; |
| | | this.$nextTick(()=>{ |
| | | this.tableShow=true; |
| | | this.$forceUpdate() |
| | | }) |
| | | |
| | | }, |
| | | immediate: true |
| | | }, |
| | | }, |
| | | computed: {}, |
| | | methods: { |
| | |
| | | this.$emit("addColumnInputChange", val, prop) |
| | | }, |
| | | editColumnInput(item,i,prop){ |
| | | console.log(item,'===item') |
| | | console.log(i,'===i') |
| | | console.log(prop,'===prop') |
| | | if(prop.indexOf('prop')!=-1){ |
| | | if(prop.indexOf('prop')!=-1&&this.isEdit){ |
| | | item.addColumn=true; |
| | | this.$set(this.tableList.tableColumn[i],'addColumn',true) |
| | | this.$forceUpdate() |
| | | this.$emit("editColumnInput", item, i,prop) |
| | | } |
| | | |
| | | }, |
| | | // 删除列 |
| | | clearupColumn(prop) { |
| | | clearupColumn(prop,index) { |
| | | console.log(prop) |
| | | this.$emit("clearupColumn", prop) |
| | | this.$emit("clearupColumn", prop,index) |
| | | } |
| | | }, |
| | | //解决表格抖动问题 |
| | |
| | | } |
| | | .el-input__inner { |
| | | // text-align: left; |
| | | text-align: center !important; |
| | | // text-align: center !important; |
| | | } |
| | | } |
| | | </style> |
| | |
| | | :silk-table-list="silkTableList" |
| | | @inputContent="inputContent" |
| | | @addProjectClick="addBtnClick" |
| | | :isEdit='isEdit' |
| | | @clearupProject="clearupProject" |
| | | @deleteClick="clearupProject" |
| | | @addColumnClick="addColumnClick" |
| | |
| | | { label: "特野", prop: "rankC", inputFloat: true } |
| | | ], |
| | | tableColumn: [], |
| | | columnNum: 0, |
| | | dataObj: { |
| | | checkItem: 1, |
| | | startFineness: 0, |
| | |
| | | currentIndex = index |
| | | } |
| | | }) |
| | | this.columnNum = list.length + 1 |
| | | for (let j = 0; j < list.length; j++) { |
| | | this.tableColumn.splice(currentIndex+j, 0, list[j]) |
| | | } |
| | |
| | | }, |
| | | // 保存编辑按钮切换 |
| | | editSaveClick() { |
| | | let isOk=false; |
| | | this.silkTableList.tableColumn.map((item)=>{ |
| | | if(!item.label||!item.prop){ |
| | | isOk=true |
| | | } |
| | | }) |
| | | if(isOk){ |
| | | this.$message.error('请先填写完成表头!') |
| | | return true; |
| | | } |
| | | this.isEdit = !this.isEdit |
| | | this.silkTableList.tableData.map((item)=>{ |
| | | item.addColumn=false; |
| | | }) |
| | | |
| | | let tableData=JSON.parse( |
| | | JSON.stringify(this.silkTableList.tableData) |
| | | ); |
| | |
| | | }, |
| | | // 添加列 |
| | | addColumnClick() { |
| | | let propStr = "prop" + this.columnNum |
| | | let currentIndex=0 |
| | | this.tableColumn.map((item, index) => { |
| | | if (item.prop == 'rankA') { |
| | | currentIndex = index |
| | | } |
| | | }) |
| | | let num=0 |
| | | if(this.tableColumn.length>0){ |
| | | if(this.tableColumn[Number(currentIndex)-1].prop.indexOf('prop')!=-1){ |
| | | num=this.tableColumn[Number(currentIndex)-1].prop.slice(4) |
| | | } |
| | | } |
| | | let propStr = "prop" + (Number(num)+1) |
| | | |
| | | this.tableColumn.splice(currentIndex, 0, { label: "", prop: propStr, inputFloat: true, addColumn: true }) |
| | | this.$set(this.dataObj, propStr, 0) |
| | | this.$set(this.rankObj, propStr, 0) |
| | | this.columnInputList.push({ rankProp: propStr, rankName: "", rankValue: 0 }) |
| | | console.log(this.tableColumn, this.dataObj, "32323", this.columnInputList) |
| | | this.silkTableList.tableColumn = this.tableColumn |
| | | this.columnNum += 1 |
| | | let allList = this.tableData.map((item) => { |
| | | return { |
| | | ...item, |
| | |
| | | }) |
| | | this.tableData = allList |
| | | this.silkTableList.tableData = allList |
| | | this.$forceUpdate() |
| | | }, |
| | | // 删除列 |
| | | clearupColumn(prop) { |