<template>
  <div>

    <el-button @click="handle">客商管理(客户10,供应商1)</el-button>
    <el-button @click="handleTwo">物料管理</el-button>
    <br>
    <el-button @click="handleThree">库房管理_dialog_组件</el-button>
    <el-button @click="handleThree2">库房管理_组件</el-button>
    <el-button @click="handleThree3">库房管理_单个组件（旧）</el-button>
    <br>
    <el-button @click="handleThreeKf">库房管理_库房</el-button>
    <el-button @click="handleThreeQh">库房管理_区号</el-button>
    <el-button @click="handleThreeDw">库房管理_垛位</el-button>
    <br>
    <br>
    <label>
      <el-button type="danger" size="large" @click="handleThreeKfQhDw">库房管理-库房-区号-垛位(新)</el-button>

    </label>
    <br>
    <br>
    <el-button @click="handleFour">模拟库存变更记录</el-button>
    <el-button @click="handleFive">模拟库存变更记录——fign接口</el-button>
    <el-button @click="handleSix">库存现有量——接口</el-button>
    <el-button @click="handleFive">库存现有量——fign接口</el-button>
    <el-button @click="handleHT">合同</el-button>
    <el-button @click="handleJHY">检化验-fign接口</el-button>
  </div>
<!-- :tpTypeShow="true" true显示select，  tpType 10  客户， 1 供应商 -->
  <Popup_base_ks ref="PopupRef" :tpTypeShow="true"  :tpType="'10'" :trade-partner-name="'淄博'" :key="timeKey1" @receive-from-child="retu"></Popup_base_ks>
  <Popup_base_wl ref="PopupRefTwo" :key="timeKey1" @receive-from-child="retu"></Popup_base_wl>
  <Popup_base_ht ref="PopupRefHT" @receive-from-child="retu"></Popup_base_ht>
  <Popup_sto_config ref="PopupRefThree" @receive-from-child="retu"></Popup_sto_config>
  <el-dialog v-model="dialogVisible_1" :close-on-click-modal="false" draggable width="800px" height="500px">
    <Popup_sto_config_component @receive-from-child="retu">

    </Popup_sto_config_component>
    <!--  强制刷新 key  -->
    <Popup_sto_config_component :key="timeKey1" @receive-from-child="retu">

    </Popup_sto_config_component>
    <!--  强制刷新 key  -->
    <Popup_sto_config_component :key="timeKey1" :store-nm="''" :area-cd="''" :stack-cd="''" @receive-from-child="retu">

    </Popup_sto_config_component>

  </el-dialog>
  <el-dialog v-model="dialogVisible" :close-on-click-modal="false" draggable width="800px" height="500px">
    <div style="display: flex;align-items: center;justify-content: center">
      <Popup_sto_config_one :key=timeKey1 :level1="true" @receive-from-child="retu"></Popup_sto_config_one>
      <Popup_sto_config_one :key=timeKey2 :level2="true" @receive-from-child="retu"></Popup_sto_config_one>
      <Popup_sto_config_one :key=timeKey3 :level3="true" @receive-from-child="retu"
                            :button-show="true"></Popup_sto_config_one>
    </div>

  </el-dialog>
  <el-dialog v-model="dialogVisibleKf" :close-on-click-modal="false" draggable width="800px" height="500px">

    <Popup_sto_config_kf @receive-from-child="returnKf"></Popup_sto_config_kf>
  </el-dialog>
  <el-dialog v-model="dialogVisibleQh" :close-on-click-modal="false" draggable width="800px" height="500px">

    <Popup_sto_config_Qh></Popup_sto_config_Qh>
  </el-dialog>
  <el-dialog v-model="dialogVisibleDw" :close-on-click-modal="false" draggable width="800px" height="500px">

    <Popup_sto_config_Dw></Popup_sto_config_Dw>
  </el-dialog>
  <el-dialog v-model="dialogVisibleKfQhDw" :close-on-click-modal="false" draggable width="800px" height="500px">
    <el-tag>根据业务选择组件就行</el-tag>
    <div style="display: flex;">
      <span style="width: 300px"> 库房模糊选择</span>
      <Popup_sto_config_kf :store-nm="''" @receive-from-child="returnKf"></Popup_sto_config_kf>

    </div>
    <div style="display: flex;">
      <span style="width: 300px"> 库房模糊选择，但库房为必选择</span>
<!--  如果只是库房选择，  :if-item-kf="false" ，或者不传递参数就行，组件设置了默认参数。  -->
<!--  设置  :if-item-kf="true", 是库房联动库存现有量，  查询出的库房 包含了库存现有量， 简意就是 A库房，在库存现有量中有数据， A库房才会查询出来。  否则查询不出来。  -->
      <Popup_sto_config_kf_bx :store-nm="''" :if-item-kf="false" :item-cd="'10101000001'" @receive-from-child="returnKf"></Popup_sto_config_kf_bx>

    </div>
    <Popup_sto_config_Qh :kf-id="storeId" :area-cd="areaCd" @receive-from-child="returnQh"></Popup_sto_config_Qh>
    <Popup_sto_config_Dw :qh-id="areaId" :stack-cd="stackCd" @receive-from-child="returnDw"></Popup_sto_config_Dw>
  </el-dialog>


  <div style="border: 1px solid red; display: none">
    <el-tag>用于表格数据回显</el-tag>
    <p>只支持将字典数据传入到组件中，进行数据回显。</p>
    <el-button @click="bg">变更</el-button>
    <select-text :value="valueSe" :dicType="'SAL_DELV_STS'"  :optionList="dictList.SAL_DELV_STS"></select-text>

    <Selector  :dic-type="'SAL_DELV_STS'"></Selector>
  </div>
</template>

<script setup>
import {
  ref,
  reactive,
  onMounted,
  getCurrentInstance
} from 'vue'

const show = ref(false)
const tmsFlag = ref('1')
const tmsFlag2 = ref('')

const dialogVisible_1 = ref(false)
const dialogVisible = ref(false)
const dialogVisibleKf = ref(false)
const dialogVisibleQh = ref(false)
const dialogVisibleDw = ref(false)
const dialogVisibleKfQhDw = ref(false)
const refOne1 = ref(null)
const refOne2 = ref(null)
const refOne3 = ref(null)
const {
  proxy
} = getCurrentInstance()
import style from '@/tools/style'

const cardBodyStyle = ref(style.card)
import Popup_base_ks from "@/views/bas/Popup_base_ks.vue";
import Popup_base_wl from "@/views/bas/Popup_base_wl.vue";
import Popup_base_ht from "@/views/cot/components/Popup_base_ht.vue";
import Popup_sto_config from "@/views/sto/components/Popup_sto_config.vue";
import Popup_sto_config_one from "@/views/sto/components/Popup_sto_config_one.vue";
import Popup_sto_config_component from "@/views/sto/components/Popup_sto_config_component.vue";
import Popup_sto_config_kf from "@/views/sto/components/Popup_sto_config_kf.vue";
import Popup_sto_config_kf_bx from "@/views/sto/components/Popup_sto_config_kf_bx.vue";
import Popup_sto_config_Qh from "@/views/sto/components/Popup_sto_config_Qh.vue";
import Popup_sto_config_Dw from "@/views/sto/components/Popup_sto_config_Dw.vue";
import Selector from "@/components/Selector.vue";


import selectText from '@/views/sal/components/Selector_text.vue'


const timeKey1 = ref(null)
const timeKey2 = ref(null)
const timeKey3 = ref(null)

const PopupRef = ref(null)
const PopupRefTwo = ref(null)
const PopupRefThree = ref(null)
const PopupRefThree2 = ref(null)
const PopupRefThree3 = ref(null)
const handle = () => {
  PopupRef.value.open()
}
const handleTwo = () => {
  PopupRefTwo.value.open()
}
const handleThree = () => {
  PopupRefThree.value.open()
}
const handleThree2 = () => {
  timeKey1.value = new Date().getTime()
  dialogVisible_1.value = true
}
const handleThree3 = () => {

  timeKey1.value = new Date().getTime() - 100
  timeKey2.value = new Date().getTime() + 2
  timeKey3.value = new Date().getTime() * 1.1
  console.log(timeKey1.value)
  console.log(timeKey2.value)
  console.log(timeKey3.value)
  dialogVisible.value = true
}
const handleThreeKf = () => {

  dialogVisibleKf.value = true
}
const handleThreeQh = () => {

  dialogVisibleQh.value = true
}
const handleThreeDw = () => {

  dialogVisibleDw.value = true
}
const handleThreeKfQhDw = () => {

  dialogVisibleKfQhDw.value = true
}
const handleFour = () => {
  var url = 'sto/TransRecord/add'
  var map = {
    deptCd: 'deptCd',
    compCd: 'compCd',
    itemCd: 'MTK123',
    itemNm: '翡翠金',
    itemType: '固体',
    qty: '10',
    uom: 'kg',
    storeCd: 'beiku',
    storeNm: '北库',
    areaCd: '',
    stackCd: '',
    qtyWet: '9',
    transactionId: 'STO_STOCKTAKING',
    transactionTable: '盘库记录表',
    transactionDate: '2024-10-18 15:04:22',
    transactionType: 'A3',
  }
  var param = {
    json: JSON.stringify(map)
  }

  proxy.$axios.post(url, param).then(response => {
    if (response.data.code == 0) {
      console.log(response)
      ElMessage({
        message: '保存成功',
        type: 'success',
      })

    } else {
      // ElMessage.error('操作失败！' + response.data.msg)
      ElMessage({
        message: '操作失败' + response.data.msg,
        type: 'error'
      })
    }
  })
}
const handleFive = () => {
  var url = 'sal/Delv/testDemo'
  var map = {
    deptCd: 'deptCd',
    compCd: 'compCd',
    itemCd: 'MTK123',
    itemNm: '翡翠金',
    itemType: '固体',
    qty: '10',
    uom: 'kg',
    storeCd: 'beiku',
    storeNm: '北库',
    areaCd: '',
    stackCd: '',
    qtyWet: '9',
    transactionId: 'STO_STOCKTAKING',
    transactionTable: '盘库记录表',
    transactionDate: '2024-10-18 15:04:22',
    transactionType: 'A3',
  }
  var param = {
    json: JSON.stringify(map)
  }

  proxy.$axios.post(url, param).then(response => {
    if (response.data.code == 0) {
      console.log(response)
      ElMessage({
        message: '保存成功',
        type: 'success',
      })

    } else {
      // ElMessage.error('操作失败！' + response.data.msg)
      ElMessage({
        message: '操作失败' + response.data.msg,
        type: 'error'
      })
    }
  })
}
const handleJHY = () => {
  var url = 'sto/TransRecord/test'
  var map = {
    deptCd: 'deptCd',
    compCd: 'compCd',
    itemCd: 'MTK123',
    itemNm: '翡翠金',
    itemType: '固体',
    qty: '10',
    uom: 'kg',
    storeCd: 'beiku',
    storeNm: '北库',
    areaCd: '',
    stackCd: '',
    qtyWet: '9',
    transactionId: 'STO_STOCKTAKING',
    transactionTable: '盘库记录表',
    transactionDate: '2024-10-18 15:04:22',
    transactionType: 'A3',
  }
  var param = {
    json: JSON.stringify(map)
  }

  proxy.$axios.post(url, param).then(response => {
    if (response.data.code == 0) {
      console.log(response)
      ElMessage({
        message: '保存成功',
        type: 'success',
      })

    } else {
      // ElMessage.error('操作失败！' + response.data.msg)
      ElMessage({
        message: '操作失败' + response.data.msg,
        type: 'error'
      })
    }
  })
}
const handleSix = () => {
  var url = 'sto/Onhand/queryOnhand'
  var map = {
    itemCd: '10101000002',
    storeCd: 'dk',
  }
  var param = {
    params: JSON.stringify(map)
  }

  proxy.$axios.post(url, param).then(response => {
    if (response.data.code == 0) {
      console.log(response)
      ElMessage({
        message: '保存成功',
        type: 'success',
      })

    } else {
      // ElMessage.error('操作失败！' + response.data.msg)
      ElMessage({
        message: '操作失败' + response.data.msg,
        type: 'error'
      })
    }
  })
}

const PopupRefHT = ref(null)
const handleHT = () => {
  PopupRefHT.value.open()
}
const retu = (val) => {
  console.log("val", val)
}
const storeId = ref('')
const storeCd = ref('')

const areaId = ref('')
const areaCd = ref('')

const stackId = ref('')
const stackCd = ref('')
const returnKf = (val) => {
  storeId.value = val.id
  storeCd.value = val.storeCd
  areaId.value = val.areaId
  areaCd.value = val.areaCd
  stackCd.value = val.stackCd
  stackId.value = val.stackId


}

const returnQh = (val) => {
  areaId.value = val.id
  areaCd.value = val.areaCd
  stackCd.value = val.stackCd
  stackId.value = val.stackId

}

const returnDw = (val) => {
  stackCd.value = val.stackCd
  stackId.value = val.id
}

const change = (val) => {
  console.log(val)
  tmsFlag.value = val
}
const change2 = (val) => {
  console.log(val)
  tmsFlag2.value = val
}
const dictList = ref({})
const dictData = () => {
  var url = 'framework/Common/querySelectorList'
  var param = {
    type: JSON.stringify(['SAL_DELV_STS'])
  }
  proxy.$axios.get(url, param).then(response => {
    if (response.data.code == '0') {
      dictList.value = response.data.data
    } else {
      ElMessage.error('操作失败！' + response.data.msg)
    }
  })
}
const valueSe = ref('A')
const bg = ()=>{
  valueSe.value = 'B'
}
onMounted(()=>{
  dictData()
})
</script>

<style>
</style>
