calculation_jp.html 14.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409

    <!DOCTYPE html>
    <html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>台数計算</title>
        <script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
        <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
        <!-- 引入样式 -->
        <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
        <!-- 引入组件库 -->
        <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    </head>

    <body>
        <div class="box">
            <img src="./images/logo.png" class="logo-img">
            <div class="line"></div>
            <div class="content">
                <div class="co-type" style="justify-content:space-between">
                    <div class="type-se">
                        <div class="typeTitle">設備の種類</div>
                        <el-select style="width: 200px" v-model="type" clearable placeholder="種類を選択してください"
                            @change="toQuery"
                            no-data-text="無し"
                            >
                            <el-option v-for="item in typeOptions" :key="item.boxName" :label="item.boxName"
                                :value="item.boxName" >
                            </el-option>
                        </el-select>
                    </div>
                    <div>設備高さ:{{ boxHeight }} mm</div>
                </div>
                <div class="both-btn">
                    <el-select style="width: 200px" 
                    no-data-text="無し"
                    v-model="sizeValue" clearable placeholder="直径を選択してください"
                        @change="toQuerySize">
                        <el-option v-for="item in sizeOptions" 
                       
                        :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                    </el-select>
                    <el-select v-model="thickValue" style="width: 200px" 
                    no-data-text="無し"
                    clearable placeholder="厚みを選択してください"
                      @change="toQuery">
                        <el-option v-for="item in thickOptions" 
                        no-data-text="無し"
                        :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                    </el-select>
                    <div>
                        <el-button size="small" round style="background-color:#00558C" @click="handleAdd()">追加
                        </el-button>
                    </div>

                </div>
                <el-table ref="table" :header-cell-style="{ color: '#FFF', background: '#1C4D84' }" :data="reelNameList"
                    style="width:45%">
                    <template slot="empty">
                        <span style="color: #969799">データ無し</span>
                    </template>
                    <el-table-column prop="size" align="center" label="直径"></el-table-column>
                    <el-table-column prop="thick" align="center" label="厚み"></el-table-column>
                    <el-table-column label="必要数量" align="center" width="180">
                        <template slot-scope="scope">
                            <el-input placeholder="必要数量を入力してください" v-model="scope.row.amount" min="1" clearable
                                type="number">
                            </el-input>
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" align="center">
                        <template slot-scope="scope">
                            <el-button type="danger" icon="el-icon-delete" size="mini"
                                @click="onDelete(scope.$index, scope.row)">
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div class="btn">
                    <el-button size="small" round style="background-color:#00558C" @click="handleCalculation()">計算
                    </el-button>
                </div>
                <!-- 計算結果 -->
                <div class="co-result">
                    <div class="co-title">計算結果</div>
                    <div class="co-type">
                        <div>設備の種類:{{ boxName }}</div>
                        <div style="margin-left: 10px;">台数:{{ boxCount }}台</div>
                    </div>
                    <el-table :header-cell-style="{ color: '#000000', background: '#DDDDDD' }" :data="resultData"
                        :cell-style="cellStyle" style="width: 100%">
                        <template slot="empty">
                            <span style="color: #969799">データ無し</span>
                        </template>
                        <el-table-column label="寸法" align="center" prop="w,h">
                            <template slot-scope="scope">
                                {{ scope.row.w }} x {{ scope.row.h }}
                            </template>
                        </el-table-column>
                        <el-table-column prop="needNum" label="必要数量" align="center">
                        </el-table-column>
                        <el-table-column prop="capacity" label="容量" align="center">
                        </el-table-column>


                    </el-table>
                </div>

            </div>
        </div>
        <!-- 底部 -->
        <div class="bottom-part">
            <div class="con-bottom bottom-line">Neotel Technology Co., Ltd</div>
            <div class="con-bottom" style="background-color:#00558C"></div>
        </div>

    </body>
    <script>
        new Vue({
        el: '.box', //elを現在のVueインスタンスがどのコンテナに対応しているかを指定するために使用し、値はセレクタ文字列です。
        data: {

            type: '',
            typeOptions: [],//設備の種類
            resSizeMap: [],//インタフェースからの元の寸法
            sizeOptions: [],//寸法ドロップダウンリスト
            sizeValue: '',
            thickValue: '',
            thickOptions: [],//厚みドロップダウンリスト
            reelNameList: [],
            resultData: [],
            boxName: '',
            boxCount: '',//台数
            boxHeight: '',
        },
        mounted() {
            this.getList()
        },
        methods: {
            // テーブルデータの取得
            getList() {
                axios.get('/baseData', {
                })
                    .then(res => {
                        this.typeOptions = res.data.data.boxDataList
                        this.resSizeMap = res.data.data.reelSizeMap
                        const resArr = Object.keys(res.data.data.reelSizeMap);//获取到对象中key值
                        resArr.sort((a, b) => a - b)
                        this.sizeOptions = resArr.map(item => {
                            return {
                                name: item,
                                id: item,
                            }
                        })

                        console.log(resArr, 'data');

                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            // 下拉框选择事件
            toQuery() {
                let that = this
                console.log(that.type)
                for (let i = 0; i < that.typeOptions.length; i++) {
                    if (that.type == that.typeOptions[i].boxName) {
                        that.boxHeight = that.typeOptions[i].boxHeight
                    }
                }

            },
            // 尺寸下拉框change事件
            toQuerySize() {
                console.log(this.sizeValue, this.resSizeMap, 'size')
                for (var key in this.resSizeMap) {
                    if (key == this.sizeValue) {
                        console.log(this.resSizeMap[key])
                        this.thickOptions = this.resSizeMap[key].map(item => {
                            return {
                                name: item,
                                id: item,
                            }
                        })
                    }
                }
                console.log(this.thickOptions)
            },
            // 追加
            handleAdd() {
                let that = this
                if (that.reelNameList.length > 0) {
                    let exist = false;//判断是否存在
                    that.reelNameList.map(item => {
                        if (item.size == that.sizeValue && item.thick == that.thickValue) {
                            exist = true;
                            that.$message({
                                message: 'すでに存在します~',
                                type: 'error'
                            });
                            return
                        }
                    })
                    if (!exist) {
                        that.reelNameList.push({ size: this.sizeValue, thick: this.thickValue })
                    }
                } else {
                    console.log('数组小于0')
                    that.reelNameList.push({ size: that.sizeValue, thick: that.thickValue })
                }
            },
            // 删除
            onDelete(index, row) {

                this.reelNameList.splice(index, 1)
            },
            // 计算 按钮点击事件
            handleCalculation() {
                let that = this
                let newArr = {};
                this.reelNameList.map(itm => {
                  if(itm.amount){
                   newArr[itm.size + ' ' + 'x' + ' ' + itm.thick] = itm.amount
                  }
                })
                if (!that.type) {
                    that.$message({
                        message: '設備の種類を選んでください',
                        type: 'error'
                    });
                    return
                }
                var arr = Object.keys(newArr)//判断对象是否为空
                if (arr.length==0) {
                    that.$message({
                        message: '必要数量を記入してください',
                        type: 'error'
                    });
                    return
                }
                let query = {
                    boxName: this.type
                }
                let data = Object.assign(query, newArr)
                axios
                    .post('/capacity',
                        data
                        // data:JSON.stringify(Object.assign(query, newArr))
                    )
                    .then(function (res) {

                        if (res.data.code === 0) {
                            console.log(res.data.data.capacityItems)
                            that.boxName = res.data.data.boxName
                            that.boxCount = res.data.data.boxCount
                            that.resultData = res.data.data.capacityItems

                        } else {
                            that.$message({
                                message: res.data.msg,
                                type: 'error'
                            });
                        }


                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },

            //设置指定行、列、具体单元格颜色
            cellStyle({ row, column, rowIndex, columnIndex }) {
                if (rowIndex === 0) { //指定坐标rowIndex :行,columnIndex :列
                    return 'background:#F6F4F4'
                } else {
                    return ''
                }

            }
        }
    })

    </script>
    <style scoped>
    * {
        padding: 0;
        margin: 0;
    }
    
    .box {
        margin: 22px 59px 22px 64px
    }
    
    .logo-img {
        width: 98px;
        height: 40px;
        margin-bottom: 11px;
    }
    
    .line {
        border: thin solid #BABABA;
    }
    
    .content {
        margin-top: 42px;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-bottom: 150px;
    }
    
    .co-type {
        width: 45%;
        display: flex;
        align-items: center;
        margin-bottom: 25px;
    }
    
    .type-se {
        display: flex;
        align-items: center
    }
    
    .typeTitle {
        margin-right: 20px;
        font-family: Noto Sans SC;
        font-size: 14px;
        font-weight: 400;
    
    }
    
    .both-btn {
        margin-bottom: 25px;
        width: 45%;
        display: flex;
        justify-content: space-between
    }
    
    .el-button {
        background: #1C4D84;
        border: 1px solid #1C4D84 !important;
        color: #ffffff !important;
        border-radius: 4px;
    }
    
    .el-button--small.is-round {
        padding: 9px 35px !important;
    }
    
    .el-button.is-round {
        border-radius: 10px !important;
    }
    
    .btn {
        width: 45%;
        margin: 27px 0px;
        display: flex;
        justify-content: flex-end;
    }
    
    .co-result {
        width: 45%;
        color: rgb(0, 0, 0);
        font-family: Noto Sans SC;
        font-size: 14px;
        font-weight: 400;
    }
    
    .co-title {
        margin-bottom: 9px;
    
    }
    
    .bottom-part {
        position: fixed;
        bottom: 0;
        width: 100%;
        margin-top: 47px;
        z-index: 99;
    }
    
    .bottom-line {
        background-color: #1A6698;
    }
    
    .con-bottom {
        height: 40px;
        color: #02D1AE;
        text-align: center;
        font-size: 14px;
        line-height: 40px;
    }
    
    .el-button:hover {
        color: #ffffff !important;
        border-color: #1A6698 !important;
        background-color: #1A6698 !important;
    }
    </style>

    </html>