statementOfAccountDialog.vue 4.45 KB
<!-- 库存对账单弹窗 -->
<template>
  <GLDialog title="库存对账单" :visible.sync="dialogVisible" class="statementOfAccountDialog" :destroy-on-close="true"
    :close-on-click-modal="false" :before-close="handleClose" @onOk="handleConfirm" @onCancel="handleClose">
    <el-form ref="statementOfAccountForm" :model="dataForm" :rules="formRules" label-width="154px" size="small">
      <el-form-item label="时间:" prop="dataMonthStr">
        <el-date-picker v-model="dataForm.dataMonthStr" type="month" :clearable="false" value-format="yyyy-MM"
          :append-to-body="false" format="yyyy-MM" class="form-node" placeholder="选择时间"
          popper-class="statement-of-account-month-picker" :picker-options="beforeRangePickerOptions"></el-date-picker>
      </el-form-item>
      <el-form-item label="仓库:" prop="yqMerchantId">
        <el-select v-model="dataForm.yqMerchantId" class="form-node" filterable @change="yqMerchantIdChange"
          placeholder="请选择仓库">
          <el-option v-for="(subItem, subIndex) in stockList" :key="subIndex" :value="subItem.merchantNo"
            :label="subItem.merchantName"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="门店:" prop="merchantId">
        <el-select v-model="dataForm.merchantId" class="form-node" filterable placeholder="请选择门店">
          <el-option v-for="(subItem, subIndex) in merchantList" :key="subIndex" :value="subItem.merchantId"
            :label="subItem.merchantName"></el-option>
        </el-select>
      </el-form-item>
    </el-form>
  </GLDialog>
</template>

<script>
import { beforeRangePickerOptions } from '@/components/glsx-combi-form/common'
// import { membraneTypeList } from '@/utils/constants.js'
export default {
  name: 'statementOfAccountDialog',

  props: {
    visible: {
      type: Boolean,
      default: false
    },
    yqMerchantList: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      beforeRangePickerOptions,
      dataForm: {
        dataMonthStr: '',
        yqMerchantId: '',
        merchantId: ''
      },
      // membraneTypeList: membraneTypeList,
      formRules: {
        dataMonthStr: [{ required: true, message: '请选择时间', trigger: 'change' }],
        yqMerchantId: [{ required: true, message: '请选择仓库', trigger: 'change' }],
        merchantId: [{ required: true, message: '请选择门店', trigger: 'change' }]
      },
      merchantList: []
    }
  },

  computed: {
    dialogVisible: {
      get() {
        return this.visible
      },
      set(val) {
        this.$emit('update:visible', val)
      }
    },
    stockList: {
      get() {
        let list = this.$common.utils.deepClone(this.yqMerchantList) || []
        if (list[0]?.merchantName == '全部') {
          list.shift()
        }
        return list
      }
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.$refs['statementOfAccountForm'] && this.$refs['statementOfAccountForm'].resetFields()
    })
  },

  methods: {
    // 门店
    merchantSelectFocus() {
      if (!this.dataForm?.yqMerchantId) return this.$message.error('请先选择仓库')
    },
    // 仓库
    yqMerchantIdChange(e) {
      this.dataForm.merchantId = ''
      this.merchantList = []
      this.$nextTick(() => {
        this.$refs['statementOfAccountForm'].clearValidate()
      })
      let _headOffice = {}
      _headOffice = this.stockList.find(item => item.merchantNo === e)
      _headOffice.merchantId = _headOffice.merchantNo
      // 获取仓库下的门店列表
      this.$apis.stockManage
        .getServicemerchantrefList({
          yqMerchantId: e
        })
        .then(res => {
          this.merchantList = res || []
          this.merchantList.push(_headOffice) // 园区店可选择自己
        })
    },
    handleClose() {
      this.dialogVisible = false
    },
    handleConfirm() {
      this.$refs['statementOfAccountForm'].validate(valid => {
        if (valid) {
          this.$emit('handleRelateProConfirm', this.dataForm)
        }
      })
    }
  }
}
</script>
<style scoped lang="scss">
.statementOfAccountDialog {
  .form-node {
    width: 432px;
  }
}
</style>
<style lang="scss">
.statement-of-account-month-picker {
  .el-picker-panel__body-wrapper .el-picker-panel__body .el-picker-panel__content .el-month-table td.current:not(.disabled) .cell {
    color: #fff;
    background: #5850ff;
    border-radius: 18px;
  }

  .el-month-table td.today .cell {
    color: #5850ff;
  }
}</style>