batchReview.vue 6.39 KB
<!-- 编辑 - 对账单模版信息 -->
<template>
  <d2-container v-loading="loading">
    <div class="edit-page edit-tmpl" style="padding: 20px" v-for="(item, index) in selectList" :key="index">
      <glsx-combi-form class="edit-form-container" :ref="'editFormRef' + index" label-width="150px" default-width="414px" :form-ref="editChildRef" :form-obj="item" :form-data="editFormData" :form-rules="formRules">
      </glsx-combi-form>
    </div>
    <div class="footer">
      <el-button @click="handleConfirm" type="primary" :loading="loading">确定</el-button>
      <el-button @click="handleCancel">取消</el-button>
    </div>
  </d2-container>
</template>

<script>
import {
  operatorBatchAudit,
  businessBatchAudit
} from "@/api/purchaseShopping.js"
import { Util, deepClone } from "@/common/util"
import { getShippingEntityInfoAll } from "@api/serviceManage"
export default {
  name: "BatchReview",
  data() {
    const editItemStyle = {
      width: "50%",
      marginRight: '0px'
    }
    const lineItemStyle = {
      width: "100%",
      marginRight: '0px'
    }
    return {
      loading: false,
      editChildRef: "editChildRef",
      formRules: {
        sendOutMerchantId: [
          { required: true, message: "请选择发货主体", trigger: "change" }
        ]
      },
      selectList: [],
      editFormData: [
        {
          label: "订单编号",
          name: "orderCode",
          type: "showTxt",
          style: editItemStyle
        }, {
          label: "下单门店",
          name: "merchantName",
          type: "showTxt",
          style: editItemStyle
        }, {
          label: "订单总价/元",
          name: "totalPrice",
          type: "showTxt",
          style: editItemStyle,
          formatter: (cellValue) => {
            return "¥" + cellValue.totalPrice
          }
        }, {
          label: "下单时间",
          name: "orderTime",
          type: "showTxt",
          style: editItemStyle,
          formatter: (cellValue) => {
            return cellValue.orderTime ? Util.dateFormate(cellValue.orderTime, 'YYYY-MM-DD HH:mm:ss') : '--'
          }
        }, {
          label: "运营审核时间",
          name: "operatorReviewDate",
          type: "showTxt",
          isHide: true,
          style: editItemStyle,
          formatter: (cellValue) => {
            return cellValue.operatorReviewDate ? Util.dateFormate(cellValue.operatorReviewDate, 'YYYY-MM-DD HH:mm:ss') : '--'
          }
        }, {
          label: "发货主体",
          name: "sendOutMerchantId",
          isHide: true,
          style: lineItemStyle,
          type: "select",
          optionList: [],
          optionId: "shippingEntityId",
          optionLabel: "shippingEntity",
          optionsName: "shippingEntityList"
        },
        {
          label: "备注",
          name: "remark",
          type: "input",
          placeholder: "请输入",
          style: lineItemStyle,
          inputType: "textarea",
          maxlength: "200",
          rows: 4,
          showLimit: true
        }
      ],
      baseData: {
        shippingEntityList: []
      }
    }
  },
  mounted() {
    console.log(this.$route, 'this.$route.query')
    this.fromPage = this.$route.query.fromPage || 'procurementReview'
    this.selectList = deepClone(this.$route.query.list || '[]')
    this.showOrHideAttr("editFormData", "发货主体", this.fromPage == "procurementBusiness")
    this.showOrHideAttr("editFormData", "运营审核时间", this.fromPage == "procurementReview")
    this.getShippingEntityInfoAll()
  },
  methods: {
    showOrHideAttr(formName, label, isHide) {
      const idx = this[formName].findIndex((item) => item.label == label)
      this[formName][idx].isHide = isHide
    },
    getShippingEntityInfoAll() {
      // 获取发货主体数据
      getShippingEntityInfoAll({}).then((res) => {
        this.baseData.shippingEntityList = res || []
        this.getOptionsList("editFormData", false)
      })
    },
    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 (['select', 'radio'].includes(item.type) && 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)
            }
          }
        })
      }
    },

    handleConfirm() {
      if (this.loading) {
        return true
      }
      const _api = this.fromPage == "procurementReview" ? operatorBatchAudit : businessBatchAudit
      this.loading = true
      const params = {
        json: JSON.stringify({ auditList: this.selectList })
      }
      _api(params).then((res) => {
        this.notice.okTips("批量审核成功")
        this.handleCancel()
      }).finally(() => {
        this.loading = false
      })
    },

    // 取消按钮返回列表页
    handleCancel() {
      this.$router.push({
        name: this.fromPage || "procurementReview"
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.edit-page.edit-tmpl {
  margin: 0 20px 20px;
  background: #ffffff;

  .title {
    height: 50px;
    line-height: 50px;
    padding: 0 20px;
    border-bottom: 1px solid #e5e5e5;
    font-size: 16px;
    font-weight: 600;
    color: #333333;
  }
}
::v-deep .el-form-item--small .el-form-item__label,
::v-deep .el-form-item--small .el-form-item__content {
  line-height: 20px;
}
.edit-tmpl {
  .add-mer-btn {
    margin-left: 12px;
  }
}
.footer {
  text-align: center;
}
</style>