import {
  listStore,
  onFile
} from "@/api/intelligent-warehouse/warehouse-management/file-onShelves"
export const mixin = {
  data() {
    return {
      storeHomes: [],
      firstList: [],
      secondList: [],
      thirdList: [],
      fourthList: [],
      fifthList: [],
      sixthList: [],
      addressObj: {},

      flieList: [],
      fileData: [],
      fileStatus: false,
      qu1:require("@/assets/img/11.png"),
      qu2:require("@/assets/img/1.png"),
      lie1:require("@/assets/img/6.png"),
      lie2:require("@/assets/img/2.png"),
      mian1:require("@/assets/img/7.png"),
      mian2:require("@/assets/img/3.png"),
      mian3:require("@/assets/img/8.png"),
      mian4:require("@/assets/img/18.png"),
      jie1:require("@/assets/img/9.png"),
      jie2:require("@/assets/img/4.png"),
      ceng1:require("@/assets/img/10.png"),
      ceng2:require("@/assets/img/5.png"),
      dangan:require("@/assets/img/index.png"),
      windowUrl: 'http://' + window.location.host
    }
  },
  methods: {
    getImg() {
      if (process.env.NODE_ENV === 'development') {
          this.qu1 = process.env.VUE_APP_URL + '/point-strategy/images/storage/11.png',
          this.qu2 = process.env.VUE_APP_URL + '/point-strategy/images/storage/1.png',
          this.lie1 = process.env.VUE_APP_URL + '/point-strategy/images/storage/6.png',
          this.lie2 = process.env.VUE_APP_URL + '/point-strategy/images/storage/2.png',
          this.mian1 = process.env.VUE_APP_URL + '/point-strategy/images/storage/7.png',
          this.mian2 = process.env.VUE_APP_URL + '/point-strategy/images/storage/3.png',
          this.mian3 = process.env.VUE_APP_URL + '/point-strategy/images/storage/8.png',
          this.mian4 = process.env.VUE_APP_URL + '/point-strategy/images/storage/18.png',
          this.jie1 = process.env.VUE_APP_URL + '/point-strategy/images/storage/9.png',
          this.jie2 = process.env.VUE_APP_URL + '/point-strategy/images/storage/4.png',
          this.ceng1 = process.env.VUE_APP_URL + '/point-strategy/images/storage/10.png',
          this.ceng2 = process.env.VUE_APP_URL + '/point-strategy/images/storage/5.png',
          this.dangan = process.env.VUE_APP_URL + '/point-strategy/images/storage/index.png'
      } else {
        this.qu1 = this.windowUrl + '/point-strategy/images/storage/11.png',
          this.qu2 = this.windowUrl + '/point-strategy/images/storage/1.png',
          this.lie1 = this.windowUrl + '/point-strategy/images/storage/6.png',
          this.lie2 = this.windowUrl + '/point-strategy/images/storage/2.png',
          this.mian1 = this.windowUrl + '/point-strategy/images/storage/7.png',
          this.mian2 = this.windowUrl + '/point-strategy/images/storage/3.png',
          this.mian3 = this.windowUrl + '/point-strategy/images/storage/8.png',
          this.mian4 = this.windowUrl + '/point-strategy/images/storage/18.png',
          this.jie1 = this.windowUrl + '/point-strategy/images/storage/9.png',
          this.jie2 = this.windowUrl + '/point-strategy/images/storage/4.png',
          this.ceng1 = this.windowUrl + '/point-strategy/images/storage/10.png',
          this.ceng2 = this.windowUrl + '/point-strategy/images/storage/5.png',
          this.dangan = this.windowUrl + '/point-strategy/images/storage/index.png'
      }
    },

    changeCeng(id) {
      this.fifthList.map(item => {
        if (item.id === id) {
          item.activeImg = true
          this.addressObj.positionId = item.id
          this.addressObj.layer = item.id
          this.addressObj.boxPosition = item.wholeName
        } else {
          item.activeImg = false
        }
      })
      this.sixthList = []
      this.getList(id, 6).then(res => {})
    },
    changeJie(id) {
      this.fourthList.map(item => {
        if (item.id === id) {
          item.activeImg = true
          this.addressObj.boxSection = item.id
        } else {
          item.activeImg = false
        }
      })
      this.fifthList = []
      this.sixthList = []
      this.getList(id, 5).then(res => {
        if (this.fifthList.length) {
          this.addressObj.positionId = this.fifthList[0].id
          this.addressObj.layer = this.fifthList[0].id
          this.addressObj.boxPosition = this.fifthList[0].wholeName
          this.getList(this.fifthList[0].id, 6).then(res => {})
        }
      })
    },
    changeMian(id) {
      this.thirdList.map(item => {
        if (item.id === id) {
          item.activeImg = true
          this.addressObj.side = item.id
        } else {
          item.activeImg = false
        }
      })
      this.fourthList = []
      this.fifthList = []
      this.sixthList = []
      this.getList(id, 4).then(res => {
        if (this.fourthList.length) {
          this.addressObj.boxSection = this.fourthList[0].id
          this.getList(this.fourthList[0].id, 5).then(res => {
            if (this.fifthList.length) {
              this.addressObj.positionId = this.fifthList[0].id
              this.addressObj.layer = this.fifthList[0].id
              this.addressObj.boxPosition = this.fifthList[0].wholeName
              this.getList(this.fifthList[0].id, 6).then(res => {})
            }
          })
        }
      })
    },
    changeLie(id) {
      this.secondList.map(item => {
        if (item.id === id) {
          item.activeImg = true
          this.addressObj.line = item.id
        } else {
          item.activeImg = false
        }
      })
      this.thirdList = []
      this.fourthList = []
      this.fifthList = []
      this.sixthList = []

      this.getList(id, 3).then(res => {
        if (this.thirdList.length) {
          this.addressObj.side = this.secondList[0].id
          this.getList(this.thirdList[0].id, 4).then(res => {
            if (this.fourthList.length) {
              this.addressObj.boxSection = this.fourthList[0].id
              this.getList(this.fourthList[0].id, 5).then(res => {
                if (this.fifthList.length) {
                  this.addressObj.positionId = this.fifthList[0].id
                  this.addressObj.layer = this.fifthList[0].id
                  this.addressObj.boxPosition = this.fifthList[0].wholeName
                  this.getList(this.fifthList[0].id, 6).then(res => {})
                }
              })
            }
          })
        }
      })
    },
    changeQu(id) {
      this.firstList.map(item => {
        if (item.id === id) {
          item.activeImg = true
          this.addressObj.area = item.id
        } else {
          item.activeImg = false
        }
      })
      this.secondList = []
      this.thirdList = []
      this.fourthList = []
      this.fifthList = []
      this.sixthList = []
      this.getList(id, 2).then(res => {
        if (this.secondList.length) {
          this.addressObj.line = this.secondList[0].id
          this.getList(this.secondList[0].id, 3).then(res => {
            if (this.thirdList.length) {
              this.addressObj.side = this.secondList[0].id
              this.getList(this.thirdList[0].id, 4).then(res => {
                if (this.fourthList.length) {
                  this.addressObj.boxSection = this.fourthList[0].id
                  this.getList(this.fourthList[0].id, 5).then(res => {
                    if (this.fifthList.length) {
                      this.addressObj.positionId = this.fifthList[0].id
                      this.addressObj.layer = this.fifthList[0].id
                      this.addressObj.boxPosition = this.fifthList[0].wholeName
                      this.getList(this.fifthList[0].id, 6).then(res => {})
                    }
                  })
                }
              })
            }
          })
        }
      })
    },
    roomClick(id) {
      this.storeHomes.map(item => {
        if (item.id === id) {
          item.activeImg = true
          this.addressObj.storehouse = item.id
        } else {
          item.activeImg = false
        }
      })
      this.firstList = []
      this.secondList = []
      this.thirdList = []
      this.fourthList = []
      this.fifthList = []
      this.sixthList = []
      this.getList(id, 1).then(res => {
        if (this.firstList.length) {
          this.addressObj.area = this.firstList[0].id
          this.getList(this.firstList[0].id, 2).then(res => {
            if (this.secondList.length) {
              this.addressObj.line = this.secondList[0].id
              this.getList(this.secondList[0].id, 3).then(res => {
                if (this.thirdList.length) {
                  this.addressObj.side = this.secondList[0].id
                  this.getList(this.thirdList[0].id, 4).then(res => {
                    if (this.fourthList.length) {
                      this.addressObj.boxSection = this.fourthList[0].id
                      this.getList(this.fourthList[0].id, 5).then(res => {
                        if (this.fifthList.length) {
                          this.addressObj.positionId = this.fifthList[0].id
                          this.addressObj.layer = this.fifthList[0].id
                          this.addressObj.boxPosition = this.fifthList[0].wholeName
                          this.getList(this.fifthList[0].id, 6).then(res => {})
                        }
                      })
                    }
                  })
                }
              })
            }
          })
        }
      })

    },


    ShelvesClick() {
      this.firstList = []
      this.secondList = []
      this.thirdList = []
      this.fourthList = []
      this.fifthList = []
      this.sixthList = []
      this.getList(-1, 0).then(res => {
        if (this.storeHomes.length) {
          this.addressObj.storehouse = this.storeHomes[0].id
          this.getList(this.storeHomes[0].id, 1).then(res => {
            if (this.firstList.length) {
              this.addressObj.area = this.firstList[0].id
              this.getList(this.firstList[0].id, 2).then(res => {
                if (this.secondList.length) {
                  this.addressObj.line = this.secondList[0].id
                  this.getList(this.secondList[0].id, 3).then(res => {
                    if (this.thirdList.length) {
                      this.addressObj.side = this.thirdList[0].id
                      this.getList(this.thirdList[0].id, 4).then(res => {
                        if (this.fourthList.length) {
                          this.addressObj.boxSection = this.fourthList[0].id
                          this.getList(this.fourthList[0].id, 5).then(res => {
                            if (this.fifthList.length) {
                              this.addressObj.positionId = this.fifthList[0].id
                              this.addressObj.layer = this.fifthList[0].id
                              this.addressObj.boxPosition = this.fifthList[0].wholeName
                              this.getList(this.fifthList[0].id, 6).then(res => {})
                            }
                          })
                        }
                      })
                    }
                  })
                }
              })
            }
          })
        }
      })
    },

    async getList(data, key) {
      if (key === 6) {
        onFile({
          positionId: data
        }).then(res => {
          this.sixthList = res.body.list
        })
        return
      }
      await listStore({
        pId: data
      }).then(res => {
        let data = res.body.list
        data.forEach(item => {
          this.$set(item, 'activeImg', false)
        })
        if (data.length) {
          data[0].activeImg = true
        }
        switch (key) {
          case 0:
            this.storeHomes = data
            break;
          case 1:
            this.firstList = data
            break;
          case 2:
            this.secondList = data
            break;
          case 3:
            this.thirdList = data
            break;
          case 4:
            this.fourthList = data
            break;
          case 5:
            this.fifthList = data
            break;

        }
      })
    },
  },
  created() {
    //this.getImg()
  }
}
