zouyu
2023-11-10 131bc7a32291a13e5e9d379c4978e02795e6b3dc
src/views/common/param-mergeTemplate.vue
@@ -8,8 +8,7 @@
                </avue-text-ellipsis>
            </template>
            <template slot="paramValue" slot-scope="scope">
                <el-input @blur="checkType(scope.row)" :readonly="routingTemplateId != null"
                    :placeholder="'请输入' + scope.row.paramType" v-model="scope.row.paramValue" />
                <el-input @blur="checkType(scope.row)" :disabled="routingTemplateId!=null" :placeholder="'请输入'+scope.row.paramType" v-model="scope.row.paramValue"/>
            </template>
        </avue-crud>
        <!-- <el-table :data="tableData" ref="commonTree" :span-method="objectSpanMethod" border row-key="id" style="width: 100%">
@@ -173,62 +172,22 @@
        this.rowSort()
        this.rowCalc()
    },
    beforeMount() {
        // this.rowSort()
        // this.rowCalc()
        // this.$nextTick(()=>{
        // })
    beforeDestroy(){
        console.log("销毁前");
    },
    beforeDestroy() {
    data(){
        return {
        }
    },
    mounted() {
    },
    activated(){
        this.doLayout()
    },
    methods: {
        doLayout(){
            let that=this
            this.$nextTick(()=>{
                that.$refs.commonTree.dolayout()
            })
        },
            getSpanArr(data) {
            this.mergeArr.forEach((key, index1) => {
                let count = 0; // 用来记录需要合并行的起始位置
                this.mergeObj[key] = []; // 记录每一列的合并信息
                data.forEach((item, index) => {
                    // index == 0表示数据为第一行,直接 push 一个 1
                    if(index === 0) {
                        this.mergeObj[key].push(1);
                    } else {
                        // 判断当前行是否与上一行其值相等 如果相等 在 count 记录的位置其值 +1 表示当前行需要合并 并push 一个 0 作为占位
                        if(item[key] === data[index - 1][key]) {
                            this.mergeObj[key][count] += 1;
                            this.mergeObj[key].push(0);
                        } else {
                            // 如果当前行和上一行其值不相等
                            count = index; // 记录当前位置
                            this.mergeObj[key].push(1); // 重新push 一个 1
                        }
                    }
                })
            })
        },
        // 默认接受四个值 { 当前行的值, 当前列的值, 行的下标, 列的下标 }
        objectSpanMethod({ row, column, rowIndex, columnIndex }) {
            // 判断列的属性
            if(this.mergeArr.indexOf(column.property) !== -1) {
                // 判断其值是不是为0
                if(this.mergeObj[column.property][rowIndex]) {
                    return [this.mergeObj[column.property][rowIndex], 1]
                } else {
                    // 如果为0则为需要合并的行
                    return [0, 0];
    methods:{
        checkType(row){
            if(row.paramType == '数值格式'){
                let val = row.paramValue
                const reg = /^[0-9]*$/
                if(!reg.test(val)){
                    row.paramValue = ''
                    this.$message.warning("请输入数值格式的数据!")
                }
            }
        },