<template>
  <div class="quickBuy">
    <div class="head-title">
        评价标签列表
        <el-button @click="CommonJump('commentLabelEdit')" style="float:right;margin-top: -5px;margin-left:20px;" size="small" type="primary">添加标签</el-button>
    </div>
    <div class="content">
        <div>
            <div class="searchInput" style="width:250px">
                <el-input style="display:inline-block;width:225px;height:30px"
                placeholder="请输入标签名称搜索"
                v-model="msg.Name"
                @clear="msg.pageIndex=1,getList()"
                @keyup.enter.native="msg.pageIndex=1,getList()"
                size="small"
                clearable>
                </el-input>
                <span @click="msg.pageIndex=1,getList()" class="el-icon-search" style="color:#979dad;font-size:14px;position:relative;top:1px"></span>
            </div>
            <!-- <el-select size="small" @change="msg.pageIndex=1,getList()" v-model="msg.IsDefault" placeholder="请选择">
                <el-option label="不限" :value="0"></el-option>
                <el-option label="是" :value="1"></el-option>
                <el-option label="否" :value="2"></el-option>
            </el-select> -->
            
        </div>
        <el-table
            :data="tableData"
            v-loading="loading"
            border
            style="width: 100%;margin:20px 0">
            <el-table-column
            prop="Id"
            width="80"
            label="ID">
            </el-table-column>
            <el-table-column
            prop="Name"
            label="标签名称">
            </el-table-column>
            <el-table-column
            prop="UpdateDate"
            width="200"
            label="添加日期">
            </el-table-column>
            <el-table-column
            prop="address"
            width="200"
            label="操作">
            <template slot-scope="scope">
                <el-tooltip class="item" effect="dark" content="编辑" placement="top">
                    <img @click="CommonJump('commentLabelEdit',{ServiceId:scope.row.Id})" style="width:32px;height:32px;margin:0 10px" src="../../assets/img/userman/edit.png" alt="">
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="删除" placement="top">
                <img @click="Delete(scope.row)" style="width:32px;height:32px;margin:0 10px" src="../../assets/img/userman/del.png" alt="">
                </el-tooltip>
            </template>    
            </el-table-column>
        </el-table>
        <el-pagination style="text-align:right"
                background
                @current-change="handleCurrentChange"
                :page-size="msg.pageSize"
                layout="prev, pager, next"
                :current-page.sync="msg.pageIndex"
                :total="total">
        </el-pagination>
    </div>
        
  </div>
</template>

<script>
export default {
    name: "quickBuy",
    data(){
        return{
            editState:false,
            msg:{
                pageIndex:1,
                pageSize:15,
                Name:'',
            },
            total:0,
            tableData:[],
            loading:false,
            addMsg:{
                Id:0,
                Name:'',
            },
            msg1:{
                Id:0,
                Name:'',
            },

        }
    },
    created(){
        this.getList();

    },
    methods:{
        Delete(item){
            let that=this;
            that.$confirm('是否删除?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.apipost('/api/Order/RemoveCommentLabel',{Id:item.Id},
                    res => {
                    if (res.data.resultCode === 1) {
                        this.getList();
                        this.Success(res.data.message)

                    } else {
                        this.Error(res.data.message);
                    }
                    },
                    null
                );
            }).catch(() => {
                
            });
        },
        Edit(row,num){
            let addMsg=row;
            this.apipost('/api/Order/SetCommentLabel',addMsg,
                res => {
                if (res.data.resultCode === 1) {
                    this.getList();
                    this.Success(res.data.message)

                } else {
                    this.Error(res.data.message);
                }
                },
                null
            );

        },
        
        handleCurrentChange(val) {
            this.msg.pageIndex = val;
            this.getList();
        },
        getList(){
            this.loading=true;
            this.apipost("/api/Order/GetCommentLabelPage", this.msg, res => {
                this.loading=false;
                if(res.data.resultCode==1){
                    this.total=res.data.data.count;
                    let pageData=res.data.data.pageData;
                    pageData.forEach(item=>{
                        item.SortNew=item.Sort;
                        item.editState=false;
                    })
                    this.tableData=pageData;
                }
                
            })
        },
    },
};
</script>

<style>

.quickBuy .content .searchInput{
    border: 1px solid #DCDFE6;
    border-radius: 4px;
}
.quickBuy .content .searchInput .el-input__inner{
    border:none;outline:none;
    height: 30px!important;
    line-height: 30px!important;
}
.quickBuy .content .searchInput{
    line-height: normal;
    display: inline-table;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    width:250px;
    margin-right: 20px;
}
.quickBuy .content{
    background: #fff;
    margin-top:10px;
    padding: 20px;
    box-sizing: border-box;
}
</style>