<template>
  <div>
    <basicLayout
        ref="quotedPriceList"
        formPath="QuotedPrice"
        tableName="quotedPriceTable"
        idName="sa_quotedpriceid"
        :apiId="{query:20221020165103,del:20221020165503}"
        :options="options"
        :detail-path="{path:'/quotedPriceDetail'}"
      >
      <template #custom >
        <div class="mt-10">
          <label  class="search__label" >范围:</label>
          <el-select class="inline-24" v-model="tabName" placeholder="请选择数据分类" @change="selectChange" size="small" clearable>
            <el-option
                v-for="item in editableTabs"
                :key="item.name"
                :label="item.title"
                :value="item.name">
            </el-option>
          </el-select>
        </div>
        <div class="mt-10">
          <label  class="search__label" >报价类型:</label>
          <el-select class="inline-24" v-model="selectParam.isproject" placeholder="请选择报价类型" @change="selectChange" size="small" clearable>
            <el-option
                v-for="item in isprojectList"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </div>
        <div class="mt-10">
          <label  class="search__label" >状态:</label>
          <el-select class="inline-24" v-model="selectParam.status" placeholder="请选择状态" @change="selectChange" size="small" clearable>
            <el-option
                v-for="item in statusList"
                :key="item.value"
                :label="item.value"
                :value="item.value">
            </el-option>
          </el-select>
        </div>
       <div class="mt-10">
         <label class="search__label" >创建日期:</label>
         <el-date-picker
             style="margin-right: 24px !important;"
             size="small"
             @change="selectChange"
             value-format="yyyy-MM-dd"
             v-model="dateSelect"
             type="daterange"
             range-separator="至"
             start-placeholder="开始日期"
             end-placeholder="结束日期"
             clearable>
         </el-date-picker>
       </div>
      </template>
      <template v-slot:tbList="scope">
        <div v-if="scope.data.column.columnname === 'projectname'">
          {{scope.data.column.data.projectname?scope.data.column.data.projectnum + '/' + scope.data.column.data.projectname:'--'}}
        </div>
        <div v-else-if="scope.data.column.columnname === 'specialoffer'">
          <div v-if="scope.data.column.data.specialoffer === 0">
            否
          </div>
          <div v-else-if="scope.data.column.data.specialoffer === 1">
            是
          </div>
          <div v-else>--</div>
        </div>
        <div v-else-if="scope.data.column.columnname === 'invaliddate'">
          <p>{{scope.data.column.data.begdate?scope.data.column.data.begdate+ '到' + scope.data.column.data.enddate:'--'}}</p>
        </div>
        <div v-else-if="scope.data.column.columnname === 'salesman'">
          {{issaler?'--':scope.data.column.data.createby}}
        </div>
        <div v-else-if="scope.data.column.columnname === 'distributor'">
          {{issaler?scope.data.column.data.createby:'--'}}
        </div>
        <div v-else>
          {{scope.data.column.data[[scope.data.column.columnname]]}}
        </div>
      </template>
<!--      <template v-slot:tbOpreation="scope">
        <el-button size="mini" type="text" @click="$router.push({path:'/quotedPriceDetail',query:{id:scope.data.data.sa_quotedpriceid,rowindex:scope.data.data.rowindex}})">详情</el-button>
      </template>-->
    </basicLayout>

  </div>
</template>

<script>

export default {
  name: "index",
  data(){
    return {
      issaler:false,
      options:[],
      tabName:"1",
      tabIndex:"1",
      dateSelect:'',
      editableTabs: [ {
        title: '我负责的',
        name: "1",
      }, {
        title: '我参与的',
        name: "2",
      }, {
        title: '我下属负责的',
        name: "3",
      }, {
        title: '我下属参与的',
        name: "4",
      }],
      statusList:[
        {
          value:'新建'
        },
        {
          value:'提交'
        },
        {
          value:'审核'
        }
      ],
      isprojectList:[
        {
          label:'普通报价',
          value:'0'
        },
        {
          label:'项目报价',
          value:'1'
        }
      ],
      selectParam: {
        status:'',
        isproject:'',
        startdate:'',
        enddate:'',
      },
    }
  },
  methods:{
    selectChange(){
      this.tabIndex = this.tabName
      if (this.dateSelect !== '' && this.dateSelect !== null){
        this.selectParam.startdate = this.dateSelect[0]
        this.selectParam.enddate = this.dateSelect[1]
      }else {
        this.selectParam.startdate = ''
        this.selectParam.enddate = ''
      }
      this.$refs.quotedPriceList.param.content.type = this.tabIndex
      this.$refs.quotedPriceList.param.content.where = this.selectParam
      this.$refs.quotedPriceList.listData()
    },
    async isSaler(){
      const res = await this.$api.requested({
        classname: "common.usercenter.usercenter",
        content: {},
        method: "queryUserMsg"
      })
      console.log(res,"是否营销")
      this.issaler = res.data.hr.issaler
      console.log(this.issaler)
    }
  },
  mounted() {
    this.isSaler()
  }
}
</script>

<style scoped>

</style>