CheckDialog.vue 5.08 KB
<!-- 审核 -->
<template>
  <baseDialog :dialog-config="dialogConfig" :is-show.sync="visible" class="accountDailog" @handleClick="handleAddConfirm">
    <div class="reject-dialog">
      <glsx-combi-form class="edit-form-container" ref="editFormRef" label-width="150px" default-width="350px"
        :form-ref="editChildRef" :form-obj="infoForm" :form-data="editFormData" :form-rules="formRules"></glsx-combi-form>
      <span :style="{ 'margin-left': '150px' }">{{ txtObj[fromPage] }}</span>
    </div>
  </baseDialog>
</template>

<script>
import { operatorreviewOperatorAudit, businessreviewBusinessAudit } from '@/api/purchaseShopping.js'
import { getShippingEntityInfoAll } from "@api/serviceManage"
import { deepClone } from '@/common/util'
export default {
  name: 'CheckDialog',
  data() {
    return {
      userInfo: this.$store.state.d2admin.user.info,
      txtObj: {
        procurementReview: '说明:订单审核后会自动流转至商务进行复审',
        procurementBusiness: '说明:订单审核后会自动流转至供应商进行确认并发货'
      },
      infoForm: {
        sendOutMerchantId: ''
      },
      dialogConfig: {
        title: '审核',
        width: '750px'
      },
      editChildRef: 'editChildRef',
      formRules: {
        sendOutMerchantId: [{ required: true, message: '请选择发货主体', trigger: 'change' }]
      },
      editFormData: [{
        label: '发货主体',
        name: 'sendOutMerchantId',
        isHide: true,
        type: 'select',
        optionList: [],
        optionId: 'shippingEntityId',
        optionLabel: 'shippingEntity',
        optionsName: 'shippingEntityList'
      }, {
        label: '备注',
        name: 'remark',
        type: 'input',
        maxlength: '20'
      }],
      baseData: {
        shippingEntityList: []
      }
    }
  },

  props: {
    fromPage: {
      type: String,
      default: 'procurementReview'
    },
    checkVisible: {
      type: Boolean,
      default: false
    },
    paramsObj: {
      type: Object,
      default: {}
    }
  },
  computed: {
    visible: {
      get() {
        return this.checkVisible
      },
      set(newVal) {
        this.$emit('dialogClose', { flag: newVal, attrName: 'checkVisible' })
      }
    }
  },

  mounted() {
    this.showOrHideAttr('editFormData', '发货主体', this.fromPage == 'procurementBusiness')
    if (this.fromPage != 'procurementBusiness') {
      // 获取发货主体数据
      getShippingEntityInfoAll({}).then(res => {
        this.baseData.shippingEntityList = res || []
        this.getOptionsList('editFormData', false)
      })
    }
  },

  methods: {
    showOrHideAttr(formName, label, isHide) {
      const idx = this[formName].findIndex(item => item.label == label)
      this[formName][idx].isHide = isHide
    },
    getOptionsList(formName, hasAll = true, refreshSigle) {
      if (refreshSigle) {
        var item = this[formName].find(k => k.name == refreshSigle)
        var index = this[formName].findIndex(k => k.name == refreshSigle)
        this.$set(this[formName][index], 'optionList', deepClone(this.baseData[item.optionsName]))
        if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
          const temp = {}
          temp[this[formName][index].optionId] = ''
          temp[this[formName][index].optionLabel] = '全部'
          this[formName][index].optionList.unshift(temp)
        }
      } else {
        this[formName].forEach((item, index) => {
          if (item.type === 'select' && this.baseData[item.optionsName].length) {
            this.$set(this[formName][index], 'optionList', deepClone(this.baseData[item.optionsName]))
            if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
              const temp = {}
              temp[this[formName][index].optionId] = ''
              temp[this[formName][index].optionLabel] = '全部'
              this[formName][index].optionList.unshift(temp)
            }
          }
        })
      }
    },

    handleAddConfirm() {
      // return
      this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
        if (valid) {
          // console.log(valid)
          // return
          var infoForm = deepClone(this.infoForm)
          var params = {}
          params.sendOutMerchantId = infoForm.sendOutMerchantId
          params.remark = infoForm.remark
          params.orderCode = this.paramsObj.orderCode
          const _api = this.fromPage == 'procurementBusiness' ? businessreviewBusinessAudit : operatorreviewOperatorAudit

          _api(params).then(res => {
            this.notice.okTips('操作成功')
            this.visible = true
          })
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.reject-dialog {
  margin: 65px 0;

  .reject-input {
    ::v-deep .el-textarea__inner {
      height: 70px;
    }
  }

  .el-textarea .el-input__count {
    right: 90px;
    bottom: -10px;
    font-size: 12px;
    color: #999999;
  }

  .tips {
    color: #999999;
  }
}
</style>