Docpre.vue 8 KB
Newer Older
jianglong committed
1 2 3
<!-- 单据表格模块 -->


4
        <!-- 前后端字段path及前后端字段docgrdm.docgrd   后端docgrd为List<Docgrd>类型 -->
wangyanjiao committed
5
<template>
6
    <div class="docpre">
7
        
wangyanjiao committed
8
        <c-col :span="24" style="margin-bottom: 30px;">
9
            <el-form-item :prop="`${argadr.grp}.${rol}.docgrd`" label=""  label-width="0px">
10
                <c-table max-height="300px" style="text-align: center;" stripe
11 12
                    :list="this.model[argadr.grp][rol].docgrd || []" :paginationShow="false" :border="true">
                    <el-table-column :label="model[argadr.grp][rol].docdsclab || '提交单据'" class="messageLabel">
13 14 15 16 17 18
                        <el-table-column label="1st" width="auto" prop="cmail1" background-color="red">
                            <template slot-scope="scope">
                                <c-input v-model="scope.row.cmail1" @change="docpre" :disabled="disabledCmail1"
                                    maxlength="12">
                                </c-input>
                            </template>
wangyanjiao committed
19

20 21 22 23 24 25 26 27
                        </el-table-column>
                        <el-table-column label="2nd" width="auto" prop="cmail2">
                            <template slot-scope="scope">
                                <c-input v-model="scope.row.cmail2" @change="docpre" :disabled="disabledCmail2"
                                    maxlength="12">
                                </c-input>
                            </template>
                        </el-table-column>
28
                        <el-table-column label="单据" prop="docnam" width="auto">
29
                            <template slot="header" slot-scope="scope">
zhujiazhan committed
30
                                <c-row>
31
                                    <c-col :span="12">
wangna committed
32
                                        <span style="line-height: 64px;">单据</span>
33 34 35
                                    </c-col>
                                    <c-col :span="12">
                                        <div style="float: right;">
Wuyuqiu committed
36 37
                                            <c-button  @click="addTableValue" v-if="ifShowAdd"></c-button><br>
                                            <c-button  @click="deleteTable" v-if="ifShowDelete"></c-button>
38 39
                                        </div>
                                    </c-col>
zhujiazhan committed
40
                                </c-row>
41 42 43

                            </template>
                            <template slot-scope="scope">
44 45
                              <el-form-item :prop="`${argadr.grp}.${rol}.docgrd.`+ scope.$index +'.docnam'">
                                <!-- check时有提示信息,需用el-form-item标签包起来,且有prop=  -->
46 47 48 49 50 51 52
                                <!-- {{scope.row.docnam}} -->
                                <c-select style="width: 100%" placeholder="请选择" v-model="scope.row.docnam"
                                    :disabled="disabledDocnam">
                                    <el-option v-for="item in codes[argadr.code]" :key="item.value" :label="item.label"
                                        @change="docpre" :value="item.value">
                                    </el-option>
                                </c-select>
53
                              </el-form-item>
54 55
                            </template>
                        </el-table-column>
56 57 58
                    </el-table-column>
                </c-table>
            </el-form-item>
wangyanjiao committed
59
        </c-col>
60

wangyanjiao committed
61 62 63 64
    </div>
</template>
<script>
import commonProcess from "~/mixin/commonProcess";
65 66 67
import CodeTable from "~/config/CodeTable";
import Event from "~/model/Botdcr/Event"
import Utils from "~/utils";
wangyanjiao committed
68 69
export default {

70

wangyanjiao committed
71 72 73 74 75 76 77
    inject: ["root"],
    mixins: [commonProcess],


    data() {
        return {
            data: [],
78 79 80 81 82 83 84 85 86 87 88 89 90


            codes: { ...CodeTable },
            newValue: {
                id: 0,
                cmail1: "",
                cmail2: "",
                docnam: "",
                description: "",
                serialNum: "",
                tableName: "",
                tcddoc: "",
            },
wangyanjiao committed
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
        };
    },
    watch: {},

    props: {
        model: {
            type: Object,
            default: undefined,
        },
        argadr: {
            type: Object,
            default: function () {
                return {
                    grp: "", //所属模块  eg:bdtp,botp...
                    path: "",    // path为存储数据字段所对应的default方法
106
                    code: "",   //表格选项码表参数
wangyanjiao committed
107 108 109
                };
            },
        },
110 111 112 113
        rol: {
            type: String,
            default: "docgrdm",
        },
wangyanjiao committed
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
        disabledCmail1: {
            type: Boolean,
            default: false,
        },
        disabledCmail2: {
            type: Boolean,
            default: false,
        },
        disabledDocnam: {
            type: Boolean,
            default: false,
        },
        ifShowAdd: {
            type: Boolean,
            default: true,
        },
        ifShowDelete: {
            type: Boolean,
            default: true,
        },
    },



    methods: {
        ...Event,
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
        setColSpan: function () {
            // console.log(this.$el.getElementsByClassName("el-table__header"))
            // 获取表头的所有单元格
            var x = this.$el.getElementsByClassName("el-table__header")
            console.log(x)
            var x1 = this.$el.getElementsByClassName("el-table__header")[0].rows[1].cells
            var x2 = this.$el.getElementsByClassName("el-table__header")[0].rows[0].cells

            x1[2].colSpan = 2   // document
            // 将gutter的display设为none
            x1[3].style.display = 'none'    //gutter

            x2[0].colSpan = 4   //  docdsclab
            // x2[0].style.background-color = '#FFF'
            // 将gutter的display设为none
            x2[1].style.display = 'none'    //gutter


        },
wangyanjiao committed
159 160 161
        addTableValue(index) {
            var newTableValue = Object.assign({}, this.newValue);
            const serial = Utils.generateUUID();
162
            var grp = this.argadr.grp;
wangyanjiao committed
163
            newTableValue.serialNum = serial;
164
            // this.model[argadr.grp].docgrdm.docgrd.splice(index - 1, 0, newTableValue);
165
            this.model[grp][rol].docgrd.splice(index - 1, 0, newTableValue);
wangyanjiao committed
166 167
        },
        deleteTable(index) {
168 169
            // 'this.model.${argadr.grp}.docgrdm.docgrd.splice(index, 1)';
            var grp = this.argadr.grp;
170
            this.model[grp][rol].docgrd.splice(index, 1);
wangyanjiao committed
171 172 173 174 175 176 177 178 179 180 181 182 183 184
        },
        async docpre() {
            let rtnmsg = await this.executeDefault(this.argadr.path)
            // let rtnmsg = await this.executeDefault('bodgrp.blk.docpre')
            if (rtnmsg.respCode == SUCCESS) {
                //TODO 处理数据逻辑
                this.updateModel(rtnmsg.data)
            }
            else {
                this.$notify.error({ title: '错误', message: '服务请求失败!' });
            }
        },
    },
    created: function () {
185 186 187 188 189 190
    },
    mounted() {
        // 注意一定要保证DOM渲染完成后在进行合并操作,否则会找不到元素
        this.$nextTick(function () {
            this.setColSpan();
        })
wangyanjiao committed
191 192 193
    }
};

194 195


wangyanjiao committed
196
</script>
197
<style scoped>
wangyanjiao committed
198 199 200 201 202
.messageLabel>>>.el-form-item__label {
    text-align: left;
    font-weight: bold;
    font-size: 12px;
}
203

204 205 206
.docpre>>>.el-form-item__content{
    margin-left:0px;
}
Wuyuqiu committed
207 208
/* .add_del_button:hover {
    cursor: pointer; 
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
    background-color: rgb(230, 227, 227);
}

.add_del_button {
    display: block;
    flex: 0;
    line-height: 15px;
    text-align: center;
    font-size: 12px;
    border-radius: 5px;
    border: 1px solid rgb(194, 192, 192);
    background-color: rgb(240, 240, 240);
}

.add_button {
    margin-bottom: 2px;
Wuyuqiu committed
225
} */
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247

/* body .el-table th.gutter {
    display: table-cell !important;
    height:0px;
    font-weight: 0px;
    border-bottom: 1px solid #bbb !important;
    position: absolute;
    right:0;
    top: 0;

} */

/* 
.gutter {
    display: none;
    width: 0px !important;
    background: rgb(51, 51, 51);
}

tr {
    background: rgb(51, 51, 51);
} */
wangyanjiao committed
248
</style>