chooseOrderDialog.vue 9.5 KB
<template>
  <GLDialog title="选择订单" mode="big" :visible.sync="visible" @before-close="handleClose" @confirmDialog="handleAddConfirm" @onCancel="handleClose">
    <div class="order-list">
      <div class="flex">
        <GLCombiForm :formObj="searchForm" :label-width="'90px'" :form-data="showFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
        <!-- <div class="up-btns">
          <el-button @click="handleSearch" size="small" type="primary">
            查询
          </el-button>
        </div> -->
      </div>
      <div class="table-wrap">
        <el-table :data="tableData" border>
          <el-table-column align="center">
            <template slot-scope="scope">
              <el-radio v-model="orderId" :label="scope.row.orderCode" @input="getCurrentOrderData">
                <span class="order-name">{{ scope.row.orderCode }}</span>
              </el-radio>
            </template>
          </el-table-column>
          <el-table-column prop="key" label="序号" align="center" />
          <el-table-column label="订单编号" align="center" width="150" prop="orderCode" />
          <el-table-column label="订单状态" align="center" prop="status">
            <template slot-scope="scope">
              <span>{{ statusOpts[scope.row.status] }}</span>
            </template>
          </el-table-column>
          <el-table-column label="订单时间" align="center" width="160" prop="orderTimeStr" />
          <el-table-column label="客户姓名" align="center" prop="customerName" />
          <el-table-column label="商品名称" align="center" width="180" prop="subOrderList">
            <template slot-scope="scope">
              <span v-for="(item, index) in scope.row.subOrderList" :key="index">
                <p v-if="item.upgradeGoodsId">
                  <el-tooltip class="item" :content="item.upgradeGoodsName" placement="right">
                    <span>
                      {{
                        item.upgradeGoodsName
                          ? item.upgradeGoodsName.length > 10
                            ? item.upgradeGoodsName.substring(0, 10) + "..."
                            : item.upgradeGoodsName
                          : "-"
                      }}
                    </span>
                  </el-tooltip>
                </p>
                <p v-else>{{ item.baseGoodsName }}</p>
              </span>
            </template>
          </el-table-column>
          <el-table-column label="总价" align="center" prop="totalPrice">
            <template slot-scope="scope">
              <span>
                {{ scope.row.totalPrice ? "¥" + scope.row.totalPrice : 0 }}</span>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="page.pageNum" :page-sizes="[10, 20, 30, 40]" :page-size="page.pageSize" :total="total" layout="sizes,total,->,prev,pager,next,jumper" />
      </div>
    </div>
  </GLDialog>
</template>
<script>
// import { Util } from "@/common/util"
// import { deductOrderPage } from "@api/point"
import * as dayjs from 'dayjs'
export default {
  data() {
    return {
      sellerUserId: "",
      orderId: "",
      tableData: [],
      orderData: [],
      searchForm: {
        customerName: "",
        orderCode: "",
        status: "",
        paySuccessDate: []
      },
      searchFormSearch: {},
      total: 0,
      page: {
        pageNum: 1,
        pageSize: 10
      },
      showFormData: [
        {
          label: "客户",
          name: "customerName",
          type: "input",
          isClear: true
        },
        {
          label: "订单编号",
          name: "orderCode",
          type: "input",
          isClear: true
        },
        {
          label: "订单状态",
          name: "status",
          type: "select",
          optionList: [],
          optionId: "confId",
          optionLabel: "confLabel",
          optionsName: "orderStatusList"
        },
        {
          label: "订单日期",
          name: "paySuccessDate",
          type: "datePicker",
          labelWidth: 72,
          isClear: true,
          pickerOptions: "rangePickerOptions"
        }
      ],
      statusOpts: {
        1: "待升级",
        2: "战败",
        3: "待支付",
        4: "已支付",
        // 5: '已退款',
        6: "已评价",
        9: "已撤销",
        10: "已关闭",
        11: "错误订单",
        12: "已退款",
        13: "待上传"
      },
      baseData: {
        orderStatusList: [
          // {
          //   confId: 1,
          //   confLabel: "待升级"
          // },
          // {
          //   confId: 2,
          //   confLabel: "战败"
          // },
          // {
          //   confId: 3,
          //   confLabel: "待支付"
          // },
          {
            confId: 4,
            confLabel: "已支付"
          },
          /* {
          confId: 5,
          confLabel: '已退款'
        },  */
          // {
          //     confId: 6,
          //     confLabel: "已评价"
          //   },
          //   {
          //     confId: 9,
          //     confLabel: "已撤销"
          //   },
          //   {
          //     confId: 10,
          //     confLabel: "已关闭"
          //   },
          //   {
          //     confId: 11,
          //     confLabel: "错误订单"
          //   },
          {
            confId: 12,
            confLabel: "已退款"
          }
        ]
      }
    }
  },
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    chooseOrderData: {
      type: Array,
      default: () => []
    }
  },
  computed: {
    isVisible: {
      get() {
        return this.visible
      },
      set(newVal) { }
    }
  },
  created() {
    this.searchForm.userId = this.$route.query.userId
    this.searchForm.merchantId = this.$route.query.merchantId
    this.getList()
  },
  mounted() {
    this.getOptionsList()
  },
  methods: {
    getList() {
      var params = this.getParams()
      params = {
        ...this.page,
        ...params
      }
      console.log(params)
      console.log(params)
      this.$apis.points.deductOrderPage(params).then((res) => {
        this.tableData = res.list.map((item, index) => {
          item.paySuccessDate = item.paySuccessDate ? dayjs(item.paySuccessDate).format('YYYY-MM-DD HH:mm:ss') : ''
          item.key = index + 1 + this.page.pageSize * (this.page.pageNum - 1)
          return item
        })
        this.page.pageNum = res.pageNum
        this.page.pageSize = res.pageSize
        this.total = res.total
        this.init()
      })
    },
    // 每页条数
    handleSizeChange(value) {
      this.page.pageSize = value
      this.getList()
    },

    // 页码
    handleCurrentChange(value) {
      this.page.pageNum = value
      this.getList()
    },
    init() {
      this.orderId = this.chooseOrderData.length
        ? this.chooseOrderData[0].orderCode
        : ""
      this.orderData = this.chooseOrderData
    },
    getCurrentOrderData(value) {
      this.orderData = this.tableData.filter((item) => item.orderCode == value)
    },
    handleAddConfirm() {
      this.$emit("chooseOrder", this.orderData)
    },
    handleClose() {
      this.$emit("dialogClose")
    },
    handleSearch() {
      this.page.pageNum = 1
      this.getList()
    },
    getParams() {
      this.searchFormSearch = this.$common.utils.deepClone(this.searchForm)
      if (this.searchFormSearch.paySuccessDate && this.searchFormSearch.paySuccessDate.length) {
        this.searchFormSearch.paySuccessStartDate = dayjs(this.searchFormSearch.paySuccessDate[0]).format('YYYY-MM-DD') + ' 00:00:00'
        this.searchFormSearch.paySuccessEndDate = dayjs(this.searchFormSearch.paySuccessDate[1]).format('YYYY-MM-DD') + ' 23:59:59'
      }
      delete this.searchFormSearch.paySuccessDate
      return this.searchFormSearch
    },
    getOptionsList(hasAll = true) {
      this.showFormData.forEach((item, index) => {
        if (item.type === "select") {
          if (
            hasAll &&
            this.baseData[item.optionsName]?.length &&
            this.baseData[item.optionsName][0][
            this.showFormData[index].optionLabel
            ] !== "全部"
          ) {
            if (item.optionsName != "parkServiceList") {
              // 服务对接由于是多选不应该添加全部选项
              const temp = {}
              temp[this.showFormData[index].optionId] = ""
              temp[this.showFormData[index].optionLabel] = "全部"
              this.baseData[item.optionsName].unshift(temp)
            }
          }
          this.$set(
            this.showFormData[index],
            "optionList",
            this.baseData[item.optionsName]
          )
        }
      })
    }
  }
}
</script>
<style lang='scss' scoped>
.order-list {
  height: 540px;
}
.flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.table-wrap {
  height: 500px;
  overflow-y: auto;
}
.show-search {
  display: flex;
  align-items: center;
  ::v-deep .el-form {
    display: flex;
    align-items: center;

    .el-form-item {
      display: flex;
      width: 100%;
      margin-bottom: 0px;
    }
    .el-col {
      width: auto !important;
    }
    .el-form-item__label {
      width: 70px !important;
      white-space: nowrap;
    }
    .el-form-item__content {
      width: 170px;
    }
  }
  ::v-deep .d2-search-block {
    padding: 16px 0 0 !important;
  }
}
.order-name {
  display: inline-block;
  color: transparent;
  width: 0;
}
</style>