<template>
  <div>
    <basicLayout
        ref="list"
        :oldFormPath="{
        add:'HManagement/projectTarget/target/modules'
        }"
        tableName="projectTarget"
        idName="sa_salestargetbillid"
        :apiId="{query:20220903170002,del:20221118103402}"
        :options="options"
        :detailPath="{
        path:'/projectTarget_edit'
        }"
    >
      <div slot="custom" style="display:flex">
        <label class="search__label " style="margin:auto;width: 40px;margin-right: 10px">状态:</label>
        <el-select  class="inline-24" @change="selectChange" v-model="selectParam.status" placeholder="请选择状态" size="small" clearable>
          <el-option v-for="(item,index) in statusData" :key="item.value" :value="item.value" :label="item.label"></el-option>
        </el-select>
      </div>
      <template v-slot:tbList="scope">
        <div>
          <div v-if="scope.data.column.columnname === 'status'">
            <span style="color:#3874f6" v-if="scope.data.column.data[[scope.data.column.columnname]] == '新建'">{{scope.data.column.data[[scope.data.column.columnname]]}}</span>
            <span style="color:#52c41a" v-else-if="scope.data.column.data[[scope.data.column.columnname]] == '已下达'">{{scope.data.column.data[[scope.data.column.columnname]]}}</span>
            <span style="color:#333333" v-else-if="scope.data.column.data[[scope.data.column.columnname]] == '关闭'">{{scope.data.column.data[[scope.data.column.columnname]]}}</span>
          </div>
          <div v-else>
            {{scope.data.column.data[[scope.data.column.columnname]]}}
          </div>
        </div>
      </template>
      <template v-slot:tbOpreation="scope">
        <add_project v-if="scope.data.data.status === '新建'" class="inline-16" :data="scope.data.data" @onSuccess="onSuccess"></add_project>
      </template>
    </basicLayout>
  </div>
</template>

<script>
import {mapGetters} from 'vuex'

import list from './modules/list.vue'
import add from './modules/add.vue'
import onissue from './modules/issue.vue'
import adjustment from './modules/adjustment.vue'
import add_project from './modules/addProject.vue'

export default {
  data () {
    return {
      drawer:false,
      options:[],
      statusData:[
        {
          value:'新建',
          label:'新建'
        },
        {
          value:'已下达',
          label:'已下达'
        }
      ],
      selectParam:{
        status:''
      }
    }
  },
  components:{
    list,
    add,
    onissue,
    adjustment,
    add_project
  },
  watch: {
  /*$route (val) {
    if (val.path == '/mProjectTarget') {
      this.$refs.list.listData()
    }
  },*/
  DrawerShow (val) {
    val ? this.drawer = true : this.drawer = false
  }
  },
  computed: {
    ...mapGetters({
      DrawerShow:'DrawerShow'
    })
  },
  methods:{
    closeDrawer () {
      this.$router.push('/mProjectTarget')
      this.$store.dispatch('DrawerShowChange',false)
    },
    onSuccess () {
      this.$refs['list'].listData()
    },
    selectChange(){
      this.$refs.list.param.content.where = this.selectParam
      this.$refs.list.listData()
    }
  }
}
</script>
<style>
</style>