
<template>
  <div>
    <basicLayout 
      ref="basicLayout" 
      formPath="projectChange/quotation" 
      tableName="quotationTable" 
      idName="sa_quotedpriceid" 
      :apiId="{query:20221020165103,del:20221020165503}"
      :options="options"
      customTitle="报价单">
      <template v-slot:tbList="scope">
        <div>
          {{scope.data.column.data[scope.data.column.columnname] || scope.data.column.columnname == 'operation' ? scope.data.column.data[[scope.data.column.columnname]] : '--'}}
        </div>
      </template>
      <template v-slot:tbOpreation="scope">
        <el-button v-if="scope.data.data.status == '新建' && tool.checkAuth($route.name,'quotation_submit')" type="text" size="mini" @click="submit(scope.data.data)">提 交</el-button>
        <el-button v-if="scope.data.data.status == '提交' && scope.data.data.status != '审核' && tool.checkAuth($route.name,'quotation_check')" type="text" size="mini" @click="check(scope.data.data)">审 核</el-button>
        <el-button size="mini" type="text" class="inline-16" @click="$router.push({path:'/quotationDetail',query:{id:scope.data.data.sa_quotedpriceid,rowindex:scope.data.data.rowindex}})">详 情</el-button>
        <buillDetail class="inline-16" :rowData="scope.data.data"/>
        <delete-btn v-if="tool.checkAuth($route.name,'delete')" :id="scope.data.data.sa_quotedpriceid" nameId="20221020165503" nameKey="sa_quotedpriceids" @deleteSuccess="$refs.basicLayout.listData()" />
      </template>
    </basicLayout>
  </div>
</template>

<script>
import buillDetail from './modules/buillDetail'
export default {
  data () {
    return {
      options:[
        {
          label:'全部',
          value:''
        },
        {
          label:'新建',
          value:'新建'
        },{
          label:'提交',
          value:'提交'
        },
        {
          label:'审核',
          value:'审核'
        }
      ],
      productList:''
    }
  },
  provide () {
    return {
      productList:() => this.productList
    }
  },
  components:{buillDetail},
  methods:{
    async submit (data) {
      let res = await this.$api.requested({
        "id": 20221020165303,
        "version":1,
        "content": { 
            "sa_quotedpriceid":data.sa_quotedpriceid
        }
      })
      this.tool.showMessage(res,() => {
        this.$refs.basicLayout.listData()
      })
    },
    async check (data) {
      let res = await this.$api.requested({
          "id": 20221020165403,
          "version":1,
          "content": { 
            "sa_quotedpriceid":data.sa_quotedpriceid
          }
      })
      this.tool.showMessage(res,() => {
        this.$refs.basicLayout.listData()
      })
    },
    /* 获取可添加的商品 */
    async getProductList () {
      let res = await this.$api.requested({
        "id": 20221020164903,
        "version":1,
        "content": {
            "sa_projectid":this.$route.query.id
        }
      })
      this.productList = res.data
    }
  },
  created() {
    this.getProductList()
  }
}

</script>
<style scoped>
/* /deep/.el-table__cell .cell {
  display: flex;
  justify-content: s;
} */
</style>