<template>
  <div class="main-contain">
    <div class="position">
      <bread-crumb :crumbs="crumbs"></bread-crumb>
    </div>
    <div class="app-container">
      <div style="display: flex;align-items: center;justify-content: space-between;">
        <div>
            <el-input
            size="small"
            style="width: 200px;"
            class="filter-item"
            v-model.trim="searchKey"
            placeholder="请输入单据编号或操作人姓名"
            />
            <el-button
            size="small"
            class="filter-item"
            type="primary"
            icon="el-icon-search"
            @click="search"
            >搜索</el-button
            >
            <el-date-picker
            size="small"
            v-model="start_time"
            type="date"
            style="margin-left:5px;width:140px;"
            placeholder="选择日期">
            </el-date-picker>
            <el-date-picker
            size="small"
            v-model="end_time"
            type="date"
            style="margin-left:5px;width:140px;"
            placeholder="选择日期">
            </el-date-picker>
        </div>
        <div>
            <el-button size="small" type="primary" @click="dialogVisible = true">新增</el-button>
            <el-button size="small" type="primary" @click="toCheck">核对</el-button>
            <!-- <el-button size="small" type="primary" @click="print">打印</el-button>
            <el-button size="small" type="primary" @click="toExport">导出</el-button> -->
        </div>
      </div>
      <div>
            <div style="width:100%;margin-right:10px;margin-top:10px">
                <el-table :data="tableList" border :height="tableHeight" :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }"   @selection-change="changePrice">
                    <el-table-column type="selection" width="55" align="center"> </el-table-column>
                    <el-table-column prop="date" label="单据编码" width="100">
                        <template slot-scope="scope" align="center">
                          {{scope.row.warehousing_order}}
                        </template>
                    </el-table-column>
                    <el-table-column label="耗材名称" width="100" align="center">
                        <template slot-scope="scope">
                           {{scope.row.good_name}}
                        </template>
                    </el-table-column>
                    <el-table-column label="规格" width="100" align="center">
                      <template slot-scope="scope">
                         {{scope.row.specification_name}}
                      </template>
                    </el-table-column>
                    <el-table-column label="单位" width="100" align="center">
                      <template slot-scope="scope">
                         {{scope.row.packing_unit}}
                      </template>
                    </el-table-column>
                    <!-- <el-table-column label="调价数量" width="100" align="center">
                      <template slot-scope="scope">
                       {{scope.row.count}}
                      </template>
                    </el-table-column> -->
                    <el-table-column label="原进货价" width="100" align="center">
                      <template slot-scope="scope">
                       {{scope.row.buy_price}}
                      </template>
                    </el-table-column>
                    <el-table-column label="原零售价" width="100" align="center">
                      <template slot-scope="scope">
                       {{scope.row.packing_price}}
                     </template>
                    </el-table-column>
                    <el-table-column label="现零价" width="100" align="center">
                      <template slot-scope="scope">
                       {{scope.row.new_price}}
                     </template>
                    </el-table-column>
                    <el-table-column label="生产厂商" width="100" align="center">
                      <template slot-scope="scope">
                       {{scope.row.manufacturer}}
                      </template>
                    </el-table-column>
                    <el-table-column label="经销商" width="100" align="center">
                      <template slot-scope="scope">
                        {{scope.row.dealer}}
                      </template>
                    </el-table-column>
                    <el-table-column label="操作人" width="100" align="center">
                      <template slot-scope="scope">
                        {{getDoctor(scope.row.creater)}}
                      </template>
                    </el-table-column>
                    <el-table-column label="核对人" width="100" align="center">
                      <template slot-scope="scope">
                         {{getDoctor(scope.row.checker)}}
                      </template>
                    </el-table-column>
                    <el-table-column label="状态" width="100" align="center">
                      <template slot-scope="scope">
                        <span v-if="scope.row.checker_status == 2">未核对</span>
                        <span v-if="scope.row.checker_status == 1">已核对</span>  
                      </template>
                    </el-table-column>
                    <el-table-column prop="date" label="调价日期" width="100" align="center">
                     <template slot-scope="scope">
                          {{getTime(scope.row.start_time)}}
                     </template> 
                    </el-table-column>
                    <el-table-column label="备注" width="100" align="center">
                       <template slot-scope="scope">
                         {{scope.row.remark}}
                       </template>
                    </el-table-column>
                   <el-table-column label="操作" align="center" width="200">
                    <template slot-scope="scope">
                      <el-button type="primary" size="small" @click="modifyPrice(scope.row.id,scope.row.checker_status)">编辑</el-button>
                      <el-button  type="danger" size="small" @click="deleteStockPrice(scope.row.id,scope.row.checker_status,scope.$index)">删除</el-button>
                    </template>
                  </el-table-column>
                </el-table>

                <el-pagination
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :page-sizes="[10, 20, 40, 100]"
                  :page-size="10"
                  background
                  style="margin-top:20px;text-align: right"
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="total">
               </el-pagination>
            </div>
        </div>
    </div>
    <el-dialog
        title="库房调价"
        :visible.sync="dialogVisible"
        width="1200px">
        <el-form :model="form" class="modifyDialog" label-width="120px">
            <el-form-item label="耗材名称">
                <!-- <el-input v-model="form.name"></el-input> -->
               <el-autocomplete
                    class="checkSearch"
                    popper-class="my-autocomplete"
                    v-model="form.good_name"
                    :fetch-suggestions="querySearchAsync"
                    :trigger-on-focus="true"
                    placeholder="请输入耗材名称"
                    @select="handleSelect"
                    @input="changeGoodName(scope.$index)"
                    style="width:160px;"
                  >
                    <i class="el-icon-search el-input__icon" slot="suffix"></i>
                  <template slot-scope="{ item }">
                    <div class="name">{{ item.good_name +"  " +item.specification_name + "  "+item.manufacturer }}</div>
                  </template>
                 </el-autocomplete>
            </el-form-item>
            <el-form-item label="原价格">
                <el-input v-model="form.packing_price"></el-input>
            </el-form-item>
            <el-form-item label="现价格">
                <el-input v-model="form.new_price"></el-input>
            </el-form-item>
            <!-- <el-form-item label="调价数量">
                <el-input v-model="form.count" type="number"></el-input>
            </el-form-item> -->
            <el-form-item label="备注" style="width:66%;">
                <div style="display:flex;">
                    <el-input v-model="form.remark"></el-input>
                    <el-button style="margin-left:5px;" type="primary" @click="addPrice">添加</el-button>
                </div>
            </el-form-item>
        </el-form>
        <el-table :data="tableData" border :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }">
            <el-table-column prop="date" label="单据编号" width="100" align="center">
                <template slot-scope="scope">
                {{scope.row.warehousing_order}}
                </template>
            </el-table-column>
            <el-table-column prop="date" label="耗材名称" width="100" align="center">
               <template slot-scope="scope">
                {{scope.row.good_name}}
              </template>
            </el-table-column>
            <el-table-column prop="name" label="规格" width="100" align="center">
              <template slot-scope="scope">
               {{scope.row.specification_name}}
               </template>
            </el-table-column>
            <el-table-column prop="name" label="单位" width="100" align="center">
              <template slot-scope="scope">
               {{scope.row.warehousing_unit}}
               </template>
            </el-table-column>
            <!-- <el-table-column prop="name" label="调价数量" width="100" align="center">
              <template slot-scope="scope">
                {{scope.row.count}}
              </template> 
            </el-table-column> -->
            <el-table-column prop="name" label="原进货价" width="100" align="center">
               <template slot-scope="scope">
                {{scope.row.buy_price}}
               </template> 
            </el-table-column>
            <el-table-column prop="name" label="原零售价" width="100" align="center">
               <template slot-scope="scope">
               {{scope.row.packing_price}}
              </template> 
            </el-table-column>
            <el-table-column prop="name" label="新零售价" width="100" align="center">
               <template slot-scope="scope">
                {{scope.row.new_price}}
               </template>   
            </el-table-column>
            <el-table-column prop="manufacturer" label="生产厂商" width="100" align="center">
                <template slot-scope="scope">
                 {{scope.row.manufacturer}}
               </template>     
            </el-table-column>
            <el-table-column prop="name" label="批准文号" width="100" align="center">
              <template slot-scope="scope">
                 {{scope.row.license_number}}
               </template>    
            </el-table-column>
            <el-table-column prop="name" label="经销商" width="100" align="center">
               <template slot-scope="scope">
                 {{scope.row.dealer}}
               </template>    
            </el-table-column>
            <el-table-column prop="name" label="备注" width="100" align="center">
              <template slot-scope="scope">
                 {{scope.row.remark}}
               </template>   
            </el-table-column>
            <el-table-column
            fixed="right"
            width="100"
            label="操作">
                <template slot-scope="scope">
                    <el-button type="text" size="small" @click="deletePrice(scope.$index)">删除</el-button>
                    <el-button type="text" size="small" @click="editPrice(scope.row)">编辑</el-button>
                </template>
            </el-table-column>
        </el-table>
        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="saveAdjustPrice">确 定</el-button>
        </span>
    </el-dialog>
    
    <!-- 编辑调价 -->
    <el-dialog
        title="编辑"
        :visible.sync="editPriceDialogVisible"
        width="50%">
        <span>
          <el-form  :model="form">
            <el-row>
               <el-col>
                <el-form-item label="耗材名称:">
                    <el-autocomplete
                        class="checkSearch"
                        popper-class="my-autocomplete"
                        v-model="form.good_name"
                        :fetch-suggestions="querySearchAsync"
                        :trigger-on-focus="true"
                        placeholder="请输入耗材名称"
                        @select="handleSelect"
                        @input="changeGoodName(scope.$index)"
                        style="width:160px;"
                    >
                        <i class="el-icon-search el-input__icon" slot="suffix"></i>
                    <template slot-scope="{ item }">
                        <div class="name">{{ item.good_name +"  " +item.specification_name + "  "+item.manufacturer }}</div>
                    </template>
                    </el-autocomplete>
                </el-form-item>
               <el-form-item label="原价格：">
                 <el-input v-model="form.packing_price" style="width:200px"></el-input>
               </el-form-item>
               <el-form-item label="现价格：">
                    <el-input v-model="form.new_price" style="width:200px"></el-input>
                </el-form-item>
             </el-col> 
            </el-row>
            <!-- <el-row>
             <el-col>
               <el-form-item label="调价数量：">
                    <el-input v-model="form.count"  style="width:200px"></el-input>
                </el-form-item>
                <el-form-item label="备注：">
                    <div style="display:flex;">
                        <el-input v-model="form.remark"  style="width:200px"></el-input>
                    </div>
                </el-form-item>
              </el-col>  
            </el-row> -->
          </el-form>
        </span>
        <span slot="footer" class="dialog-footer">
            <el-button @click="editPriceDialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="upatePrice">保存</el-button>
        </span>
    </el-dialog>

    <el-dialog
        title="耗材调价核对"
        :visible.sync="checkDialogVisible"
        width="30%"
        >
        <span>
          <el-form :model="form">
            <el-row>
              <el-col>
                <el-form-item label="核对时间">
                 <el-date-picker
                    size="small"
                    v-model="check_time"
                    type="date"
                    style="margin-left:5px;width:140px;"
                    placeholder="选择日期">
                  </el-date-picker>
                </el-form-item>  
              </el-col>
            </el-row>  
             <el-row>
              <el-col>
                <el-form-item label="核对人">
                  <el-select v-model="checker" placeholder="请选择">
                    <el-option
                    v-for="item in doctorList"
                    :key="item.admin_user_id"
                    :label="item.user_name"
                    :value="item.admin_user_id">
                    </el-option>
                 </el-select>
                </el-form-item>  
              </el-col>
            </el-row>  
          </el-form>  
        </span>
        <span slot="footer" class="dialog-footer">
            <el-button @click="checkDialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="SaveCheckedPrice">保 存</el-button>
        </span>
    </el-dialog>



    <el-dialog
        title="耗材调价编辑"
        :visible.sync="modifyDialogVisible"
        width="30%"
        >
        <span>
          <el-form :model="form">
         <el-row>
               <el-col>
                <el-form-item label="耗材名称:">
                    <el-autocomplete
                        class="checkSearch"
                        popper-class="my-autocomplete"
                        v-model="form.good_name"
                        :fetch-suggestions="querySearchAsync"
                        :trigger-on-focus="true"
                        placeholder="请输入耗材名称"
                        @select="handleSelect"
                        @input="changeGoodName(scope.$index)"
                        :disabled="true"
                        style="width:160px;"
                    >
                        <i class="el-icon-search el-input__icon" slot="suffix"></i>
                    <template slot-scope="{ item }">
                        <div class="name">{{ item.good_name +"  " +item.specification_name + "  "+item.manufacturer }}</div>
                    </template>
                    </el-autocomplete>
                </el-form-item>
               <el-form-item label="原价格：">
                 <el-input v-model="form.packing_price" style="width:200px"></el-input>
               </el-form-item>
               <el-form-item label="现价格：">
                    <el-input v-model="form.new_price" style="width:200px"></el-input>
                </el-form-item>
                <el-form-item label="备注：">
                    <el-input v-model="form.remark" style="width:200px"></el-input>
                </el-form-item>
             </el-col> 
            </el-row>
          </el-form>  
        </span>
        <span slot="footer" class="dialog-footer">
            <el-button @click="modifyDialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="updateStockPrice">保 存</el-button>
        </span>
    </el-dialog>
  </div>
</template>

<script>
import BreadCrumb from "../components/bread-crumb";
import { postSearchGoodWarehouseList,saveAdjustPrice,getAllStockPrice,SaveCheckedPrice,getModifyPriceDetail,updateStockPrice,deleteStockPrice} from "@/api/stock"
import { uParseTime } from '@/utils/tools'
export default {
    name: "stockModifyPrice",
    components:{
        BreadCrumb
    },
    data() {
        return{
            crumbs: [
                { path: false, name: "库存管理" },
                { path: false, name: "耗材管理" },
                { path: false, name: "耗材调价" }
            ],
            tableHeight: '',
            fullHeight: document.documentElement.clientHeight,
            searchKey:'',
            value1:'',
            value2:'',
            tableData: [],
            dialogVisible:false,
            form: {
                id:"",
                good_name: '',
                packing_price:'',
                new_price:"",
                count:"",
                remark:"",
                warehousing_order:"",
                manufacturer:"",
                dealer:"",
                license_number:"",
                warehousing_unit:"",
                specification_name:"",
                buy_price:"",
                good_id:"",
                packing_unit:"",
            },
            goodList:[],
            manufacturerList:[],
            dealerList:[],
            currentIndex: 0,
            editPriceDialogVisible:false,
            tableList:[],
            doctorList:[],
            start_time:"",
            end_time:"",
            ids:"",
            check_time:new Date(),
            checker:this.$store.getters.xt_user.user.id,
            checkDialogVisible:false,
            limit:10,
            page:1,
            total:0,
            modifyDialogVisible:false,
            id:0,
        }
    },
    methods:{
        search(){
          this.getAllStockPrice()
        },
        print(){
            if(this.ids == ""){
              this.$message.error("请勾选打印数据")
              return
            }
            this.$router.push({path:'/stock/stockModifyPricePrint?ids='+this.ids})
            
        },
        querySearchAsync(keyword, cb) {
            let key = '';
            if (keyword != undefined) {
             key = keyword
            }
            postSearchGoodWarehouseList(key).then(response => {
            if (response.data.state == 1) {
            
                var list = response.data.data.list
                console.log("列表数据",list)
                this.goodList = list
                var manufacturerList = response.data.data.manufacturerList
                this.manufacturerList = manufacturerList
                var dealer =  response.data.data.dealerList
                this.dealerList = dealer
                for(let i=0;i<this.goodList.length;i++){
                  for(let j=0;j<this.manufacturerList.length;j++){
                    if(this.goodList[i].manufacturer == this.manufacturerList[j].id){
                        this.goodList[i].manufacturer = this.manufacturerList[j].manufacturer_name
                    }
                  }
                }

                for(let i=0;i<this.goodList.length;i++){
                   for(let j=0;j<this.dealerList.length;j++){
                     if(this.goodList[i].dealer == this.dealerList[j].id){
                       this.goodList[i].dealer = this.dealerList[j].dealer_name
                     }
                   }
                }
            
                cb(this.goodList)
            } else {
                cb([])
            }
            })
        },
        changeGoodName(val){
         this.currentIndex = val
        },
        handleSelect(val){
          console.log("val23232323",val)
          this.form.id = val.id
          this.form.good_id = val.good_id,
          this.form.good_name = val.good_name
          this.form.packing_price = val.packing_price
          this.form.warehousing_order = val.warehousing_order
          this.form.license_number = val.license_number
          if(val.dealer == 0){
            this.form.dealer = ""
          }else{
            this.form.dealer = val.dealer
          }
          if(this.form.manufacturer == 0){
            this.form.manufacturer = ""
          }else{
            this.form.manufacturer = val.manufacturer
          }
          this.form.specification_name = val.specification_name
          this.form.remark = val.remark
          this.form.buy_price = val.buy_price
          this.form.warehousing_unit = val.packing_unit
         
      },
      addPrice(){
        var obj = {
         id:this.form.id,
         good_name:this.form.good_name,
         specification_name:this.form.specification_name,
         warehousing_order:this.form.warehousing_order,
         good_name:this.form.good_name,
         packing_price:this.form.packing_price,
         license_number:this.form.license_number,
         dealer:this.form.dealer,
         manufacturer:this.form.manufacturer,  
         warehousing_unit:this.form.warehousing_unit, 
         start_time:this.getTime(new Date()),
         count:this.form.count,
         new_price:this.form.new_price,
         remark:this.form.remark,
         buy_price:this.form.buy_price,
         good_id:this.form.good_id,
        }
       this.tableData.push(obj)
       this.form.good_name = ""
       this.form.specification_name  = ""
       this.form.warehousing_order = ""
       this.form.good_name = ""
       this.form.packing_price = ""
       this.form.license_number= ""
       this.form.dealer = ""
       this.form.manufacturer = ""
       this.form.warehousing_unit = ""
       this.form.count = ""
       this.form.new_price = ""
       this.form.remark = ""
       this.form.buy_price= ""
      },
      getTime(val) {
         if(val < 0){
           return ""
         }
         if(val == ""){
          return ""
         }else {
          return uParseTime(val, '{y}-{m}-{d}')
         }
      },
     deletePrice(index){
      this.tableData.splice(index,1)
     },
     editPrice(row){
      console.log("row232233223",row)
      this.form.good_name = row.good_name
      this.form.packing_price = row.packing_price
      this.form.packing_unit = row.packing_unit
      this.form.new_price = row.new_price
      this.form.count = row.count
      this.form.remark = row.remark
      this.form.id = row.id
      this.editPriceDialogVisible = true  
     },
     upatePrice(){
       for(let i=0;i<this.tableData.length;i++){
         if(this.form.id == this.tableData[i].id){
            this.tableData[i].good_name = this.form.good_name
            this.tableData[i].packing_price = this.form.packing_price
            this.tableData[i].new_price = this.form.new_price
            this.tableData[i].count = this.form.count
            this.tableData[i].remark = this.form.remark
         }
       }
       this.editPriceDialogVisible = false
       this.form.good_name = ""
       this.form.packing_price = ""
       this.form.new_price = ""
       this.form.count = ""
       this.form.remark = ""
     },
     saveAdjustPrice(){
         for(let i=0;i<this.tableData.length;i++){
           this.tableData[i].buy_price = this.tableData[i].buy_price.toString()
           this.tableData[i].packing_price = this.tableData[i].packing_price.toString()
           this.tableData[i].new_price = this.tableData[i].new_price.toString()
          //  this.tableData[i].count =  parseInt(this.tableData[i].count)
            this.tableData[i].count = 0
           if(this.tableData[i].dealer == 0){
             this.tableData[i].dealer = ""
           }
           if(this.tableData[i].manufacturer == 0){
             this.tableData[i].manufacturer = ""
           }
         }
         var params= {
           tableData:this.tableData,
         }
      
      console.log("parasm222",params)
      saveAdjustPrice(params).then(response=>{
        if(response.data.state == 1){
          var msg =  response.data.data.msg
          console.log("msg",msg)
          this.$message.success("保存成功!")
          this.dialogVisible = false
          this.tableData = []
          this.getAllStockPrice()
        }
      })  
     },
     getAllStockPrice(){
         var params = {
            keyword:this.searchKey,
            start_time:this.start_time,
            end_time:this.end_time,
            limit:this.limit,
            page:this.page,
         }
        console.log("params",params)
       getAllStockPrice(params).then(response=>{
         if(response.data.state == 1){
           var list = response.data.data.list
           console.log("zhognguoffs",list)
           this.tableList = list
           var doctor = response.data.data.doctor
           console.log("doctor",doctor)
           this.doctorList = doctor
           this.total = response.data.data.total
         }
       })  
     },
     getDoctor(id){
       var user_name = ""
       for(let i=0;i<this.doctorList.length;i++){
          if(id == this.doctorList[i].admin_user_id){
             user_name = this.doctorList[i].user_name
          }
       }
       return user_name
     },
     changePrice(val){
       console.log("val23232322323",val)
      
       var arr = []
      
       for(let i=0;i<val.length;i++){
         arr.push(val[i].id)
       }
      var str = arr.join(",")
    
      console.log("str",str)
      this.ids = str
     
     },
     toCheck(){
      if(this.ids.length <=0){
         this.$message.error("请勾选核对数据")
         return
       }else{
         this.checkDialogVisible = true
       }
    
     },
     SaveCheckedPrice(){
       
         var params = {
            ids:this.ids,
            check_time:this.getTime(this.check_time),
            checker:this.checker,
         }
       console.log("params",params)
       SaveCheckedPrice(params).then(response=>{
         if(response.data.state == 1){
           var adjustPrice = response.data.data.adjustPrice
           this.$message.success("保存成功")
           this.getAllStockPrice() 
           this.checkDialogVisible = false
         }
       })
     },
     handleSizeChange(val){
       this.limit = val
       this.getAllStockPrice()
      },
     handleCurrentChange(val){
        this.page = val
        this.getAllStockPrice()
      },
     toExport(){
      import('@/vendor/Export2Excel').then(excel => {
        for(let i=0;i<this.tableList.length;i++){
          this.tableList[i].start_time = this.getTime(this.tableList[i].start_time)
          this.tableList[i].creater =  this.getDoctor(this.tableList[i].creater)
          this.tableList[i].checker = this.getDoctor(this.tableList[i].checker)
        }
        console.log("表格",this.tableList)
        const tHeader = ['单据编码','调价日期','操作人','审核人','耗材名称','规格','生产厂家','批注文书','经销商','数量','原零价','现零价','进货价','零售总价','批号','生产日期','有效日期']
        const filterVal = ['warehousing_order', 'start_time','creater','checker','good_name','specification_name','manufacturer','license_number','dealer','count','packing_price','new_price','buy_price','','','','']
        console.log("table",this.tableList)
      
        const data = this.formatJson(filterVal, this.tableList)
        excel.export_json_to_excel({
          header: tHeader,
          data,
          filename: '调价明细表'
        })
      this.downloadLoading = false
     })
    },
    formatJson(filterVal, jsonData) {
      return jsonData.map(v => filterVal.map(j => v[j]));
     },
     modifyPrice(id,check_status){
       if(check_status == 1){
         this.$message.error("已核对不能编辑")
         return
       }
       getModifyPriceDetail(id).then(response=>{
         if(response.data.state == 1){
           var info =  response.data.data.detail
           console.log("info",info)
           this.id = info.id
           this.good_id = info.good_id,
           this.form.good_name = info.good_name
           if(info.new_price == 0){
            this.form.new_price = ""
           }else{
             this.form.new_price = info.new_price
           }
          
           this.form.packing_price = info.packing_price
           this.form.remark = info.remark
           this.modifyDialogVisible = true
         }
       })
     },
     updateStockPrice(){
         var params = {
           new_price:this.form.new_price.toString(),
           id:this.id,
           packing_price:this.form.packing_price.toString(),
           remark:this.form.remark,
           good_id:this.form.good_id,
           good_name:this.form.good_name,
         }
         console.log("params",params)
       updateStockPrice(params).then(response=>{
          if(response.data.state == 1){
            var adjust = response.data.data.adjust
            this.$message.success("保存成功")
             this.modifyDialogVisible = false
             this.getAllStockPrice()
          }
       })
     },
     deleteStockPrice(id,check_status,index){
       if(check_status == 1){
         this.$message.error("已核对不能编辑")
         return
       }
        this.$confirm('是否删除所选内容?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let params = {
            id:id,
          }
          deleteStockPrice(params).then(response => {
            if (response.data.state == 1) {
              var msg = response.data.data.msg
              this.$message.success("保存成功")
              this.tableList.splice(index,1)
            } 
          })
        }).catch(() => {
          this.loading = false
        });
     }
    },
    created(){
        let tableHeight = document.body.clientHeight - 200;
        this.tableHeight = tableHeight
        this.getAllStockPrice()
    },
    mounted() {
      const that = this;
      window.onresize = () => {
        return (() => {
          window.fullHeight = document.documentElement.clientHeight;
          that.fullHeight = window.fullHeight
        })()
      }
    },
    watch: {
      fullHeight(val) {
        if (!this.timer) {
          this.fullHeight = val
          let tableHeight = val - 200
          this.tableHeight = tableHeight
          this.timer = true
          let that = this
          setTimeout(function() {
            that.timer = false
          }, 400)
        }
      }

    }
};
</script>

<style rel="stylesheet/scss" lang="scss">
.app-container {
  // margin: 20px;
  font-size: 15px;
}
.modifyDialog{
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 10px;
    .el-form-item{
        width: 33%;
    }
}
.el-table td,
.el-table th.is-leaf,
.el-table--border,
.el-table--group {
  border-color: #d0d3da;
}
.el-table--border::after,
.el-table--group::after,
.el-table::before {
  background-color: #d0d3da;
}
::-webkit-scrollbar{
    height: 20px !important;
}
</style>
