<template>
    <div class="plantingPlan ">
        <div class="page-content">
            <div class="table-title">
                <img src="../../assets/vrcodeImg/agriculturalProcess.png" alt="" />
                农事作业工序
            </div>
            <div class="flex-view">

                <div class="vrcode-input-sel">
                    <div class="el-dropdown-link">
                        <input v-model="TypeSel" type="text" class="input-input" placeholder="请输入种植模式名称">
                    </div>
                </div>
                <div class="vrcode-btn save-btn" @click="addModel = true">
                        <img src="../../assets/img/add.png" alt="">添加
                    </div>
            </div>
            <div class="vrcode-table">
                <div class="vrcode-table-view table-view">
                    <el-table :data="tableData" :row-class-name="tableRowClassName" height="520" style="width: 100%">
                        <el-table-column prop="id" label="序号"></el-table-column>
                        <el-table-column prop="data0" label="名称"></el-table-column>
                        <el-table-column prop="data1" label="温室清洁时间"></el-table-column>
                        <el-table-column prop="data3" label="消毒杀菌时间"></el-table-column>
                        <el-table-column prop="data2" label="清洁方式"></el-table-column>
                        <el-table-column prop="data5" label="使用药剂">
                            <template slot-scope="scope">
                                <div class="table-flex">
                                    <div class="isOpen" :class="scope.row.data5 ? 'open-green' : 'open-red'">
                                        {{ scope.row.data5 ? '已公开' : '未公开' }}
                                    </div>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column :label="$t('nameText.operations')" width="200">
                            <template slot-scope="scope">

                                <div class="vrcode-table-btn">
                                    <div class="vrcode-btn blue-btn" @click="addModel = true">
                                        {{$t('nameText.edit')}}
                                    </div>
                                    <div class="vrcode-btn red-btn">
                                        {{$t('nameText.delete')}}
                                    </div>
                                </div>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
            </div>
        </div>

        <el-dialog title="提示" top="5vh" :visible.sync="addModel" width="380px" class="vrcode-model"
            :append-to-body="true">
            <div class="vrcode-model-title">
                编辑名称
            </div>
            <div class="vrcode-content">
                <div class="vrcode-view">
                    <div class="vrcode-input w-100">
                        <div class="input-title">名称</div>
                        <input type="text" placeholder="请输入名称">
                    </div>

                </div>
            </div>
            <span slot="footer" class="dialog-footer">
                <div class="vrcode-btn save-btn" @click="addModel = false">保存</div>
                <div class="vrcode-btn cancle-btn" @click="addModel = false">{{$t('index.cancel')}}</div>
            </span>
        </el-dialog>

    </div>
</template>
<script>
export default {
    data() {
        return {
            edit: false,
            addModel: false,
            tableData: [{
                id: '13', data0: '西红柿种植',
                data1: '施肥',
                data2: '刘永强',
                data3: '',
                data4: '2023-04-05 21:00',
                data5: true,
            }, {}, {}, {}, {}, {}, {}, {},],
            typeSelList: [{ name: '1#平均空气温度', value: 1, },
            { name: '2#平均空气温度', value: 2, },
            { name: '1#空气温度', value: 3, },
            { name: '2#空气温度', value: 4, },
            { name: '3#空气温度', value: 5, },
            { name: '4#空气温度', value: 6, },
            { name: '5#空气温度', value: 7, },
            { name: '6#空气温度', value: 8, },
            { name: '7#空气温度', value: 9, },
            { name: '8#空气温度', value: 10, },],
            TypeSel: '',
            value1: '',
            modelisTrue: false,
            imgList: ['https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg']
        }
    },
    mounted() { },
    methods: {
        handleCommand() {

        },
        tableRowClassName({ row, rowIndex }) {
            if (rowIndex % 2 == 1) {
                return 'warning-row';
            } else if (rowIndex % 2 == 0) {
                return 'success-row';
            }
            return '';
        },
        delImage(index) {
            console.log('删除图片', index);
            this.imgList.splice(index, 1);
        },
        handleImageChange(event) {
            const files = event.target.files;
            if (files.length > 0) {
                for (let i = 0; i < files.length; i++) {
                    const reader = new FileReader();

                    reader.onload = (e) => {
                        this.imgList.push(e.target.result);
                    };

                    reader.readAsDataURL(files[i]);
                }
                this.$refs.fileInput.value = '';
            } else {
                console.log(null);
            }

        }
    },

}
</script>
<style lang="scss"></style>