ConstructionDetailModal.js 2.96 KB
// components/SelectInvoiceModal/SelectInvoiceModal.js
import api from '~/tabWorkOrder/api'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    visible: {
      type: Boolean,
      value: false,
      observer: function (n, o) {
        this.handleOpen()
      }
    },
    orderInfo: {
      type: Object,
      value: {}
    },
    orderCode: {
      type: String,
      value: ''
    }
  },

  /**
   * 组件的生命周期
   */
  lifetimes: {
    // attached() {
    //   this.handleOpen()
    // }
  },

  /**
   * 组件的初始数据
   */
  data: {
    // selectType: 82,
    loading: false
  },

  /**
   * 组件的方法列表
   */
  methods: {
	openInventoryPopup(e){
		console.log(e)
		let {inventory:{
			upgradeGoodsCommodityCode,
			upgradeGoodsCustomCode,
			specification,
			stock
		  }} = e.target.dataset
		  const inventoryData ={
			upgradeGoodsCommodityCode,
			upgradeGoodsCustomCode,
			specification,
			stock
		  }
		this.triggerEvent('openInventory', inventoryData)
	},
    navto(e) {
      let { item } = e.currentTarget.dataset
      console.log(item, 'item')
      let path = item.electronicFlag == 1 ? 'tabRepairOrder.repairOrderDetail' : 'tabRepairOrder.confirmWorkOrder'
      wx.$router.go(path, {
        ...item
      })
      this.handleCancel()
    },
    selectType(e) {
      let { type } = e.currentTarget.dataset
      this.setData({
        selectType: type
      })
    },
    handleOpen() {
      let { orderCode } = this.data
      api
        .listConstruction({ orderCode })
        .then(res => {
          console.log(res, 'listConstruction')
          let listConstruction = res.data.map(item => {
            item.subGoodsName = item.subOrderList
              .map(sub => sub.upgradeGoodsName)
			  .join('/')
			  item.upgradeGoodsCommodityCode = item.subOrderList
              .map(sub => sub.upgradeGoodsCommodityCode)
			  .join('/')
			  item.upgradeGoodsCustomCode = item.subOrderList
              .map(sub => sub.upgradeGoodsCustomCode)
			  .join('/')
			  item.specification = item.subOrderList
              .map(sub => sub.specification)
			  .join('/')
			  item.stock = item.subOrderList
              .map(sub => sub.stock)
              .join('/')
            item.mainTechnician = item.mainTechnicianList
              .map(sub => sub.technicianName)
              .join('/')
            return item
          })
          // console.log(listConstruction, 'listConstruction')
          this.setData({
            constructionList: listConstruction
          })
        })
        .catch(err => {
          console.log(err)
        })
      wx.$modal(
        this,
        {
          show: true,
          tabTitleShow: true,
          tapTitle: '查看客户施工单',
          success: res => { },
          error: () => { }
        },
        '#modal'
      )
    },
    handleCancel() {
      this.triggerEvent('cancel')
    },
    handleConfirm() {
      this.triggerEvent('confirm')
      this.handleCancel()
    }
  }
})