ruleConfigurationList.vue 7.78 KB
<!-- 订单列表 -->
<template>
  <d2-container class="rule-list">
    <div class="header" slot="header">
      <d2-search ref="showSearch" class="show-search" :search-form="searchForm" :label-width="'150px'"
                 :form-data="showFormData" />
      <div class="up-btns">
        <el-button :id="tableParams.btnId" size="small" type="primary">
          查询
        </el-button>
        <el-button size="small" @click="handleReset"> 重置 </el-button>
      </div>
    </div>
    <div class="d2-container-content">
      <d2-table-header>
        <!-- <el-button type="primary" @click="handleAddRule" size="small">
          新增
        </el-button> -->
        <!-- <el-button type="primary" @click="massDevelopmentNonFusion" size="small"> 批量开通非融合 </el-button>
        <el-button type="primary" @click="handleExport" size="small"> 导出 </el-button> -->
        <auth-button :show-btn-ids="['9100104', '9100105']" category="Button" />
      </d2-table-header>
      <d2-table ref="ruleTable" :get-list-api="getListApi" :search-form="searchFormSearch" :table-params="tableParams"
                :before-search-fn="beforeSearchFn" :selectable-fn="selectableFn">
        <auth-button slot="auth-button" slot-scope="scope" :data="scope.scope" />
      </d2-table>
    </div>

    <ruleConfigurationDialog v-if="isRuleVisible" :rule-id="ruleId" :is-rule-visible.sync="isRuleVisible"
                             @update="handleSearch" :is-edit="disEdit">
    </ruleConfigurationDialog>
  </d2-container>
</template>

<script>
import ruleConfigurationDialog from "./components/ruleConfigurationDialog"
import { Util } from "@/common/util"
import {
  getList,
  // insertorUpdate,
  // quotationDetail,
  vdruleExport, goodsModeBatchSet
} from "@api/vdrule"
const mode = {
  0: "融合报价",
  1: "非融合报价"
}
const status = {
  0: "待配置",
  1: "已配置"
}
export default {
  name: "RuleConfigurationList",
  components: {
    ruleConfigurationDialog
  },
  data() {
    return {
      // parkServiceList: [],
      isRuleVisible: false,

      dialogTitle: "",
      showFormData: [
        {
          label: "商户名称",
          name: "merchantName",
          type: "input",
          isClear: true,
          keyFn: this.keyDowmGetList
        },
        {
          label: "商品名称",
          name: "goodsName",
          type: "input",
          isClear: true,
          keyFn: this.keyDowmGetList
        },
        {
          label: '配置状态',
          name: 'status',
          type: 'select',
          optionList: [{
            label: '待配置',
            value: 0
          }, {
            label: '已配置',
            value: 1
          }],
          optionId: 'value',
          optionLabel: 'label'
          // optionsName: 'productTypeList'
        },
        {
          label: "创建时间",
          name: "createTime",
          type: "datePicker",
          isClear: true
        }
      ],
      searchForm: {
        merchantName: "",
        createTime: []
      },
      isEdit: false,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: "list",
        tableOption: true,
        mutiSelectUniqueKey: 'id',
        mutiSelectName: 'ruleConfigurationList',
        tableColumns: [
          {
            label: "商户名称",
            prop: "merchantName"
          },
          {
            label: "商品名称",
            prop: "goodsName"
          },
          {
            label: "权益模式",
            prop: "mode",
            formatter: (cellValue) => {
              return mode[cellValue.mode] || '-'
            }
          },
          {
            label: "配置状态",
            prop: "status",
            formatter: (cellValue) => {
              return status[cellValue.status] || '-'
            }
          },
          {
            label: "计算规则",
            prop: "calculatePlan"
          },
          {
            label: "分配方案",
            prop: "distributePlan"
          },
          {
            label: "创建时间",
            prop: "createTime"
          },
          {
            label: "更新时间",
            prop: "updateTime"
          },
          {
            label: "操作人",
            prop: "operator"
          }
        ]
      },
      getListApi: getList,
      searchFormSearch: {},
      tableData: [],
      total: 0,
      page: {
        pageNum: 1,
        pageSize: 20
      }
    }
  },
  mounted() {
  },
  methods: {
    massDevelopmentNonFusion() {
      var selectedData = []
      console.log(this.$refs.ruleTable.mutiSelectArr.ruleConfigurationList)
      if (this.$refs.ruleTable.mutiSelectArr.ruleConfigurationList) {
        selectedData = this.$refs.ruleTable.mutiSelectArr.ruleConfigurationList
      }
      if (!selectedData?.length) {
        this.$message({
          message: "请选择需要批量配置的规则",
          type: "warning",
          showClose: true
        })
        return false
      }
      const ids = selectedData.map((item) => {
        return item.id
      })

      console.log(ids)
      goodsModeBatchSet({ ruleGoodsIds: ids }).then(res => {
        console.log(res)
        this.notice.okTips('批量开通成功')
        this.handleSearch()
      }).catch((err) => {
        console.log(err)
      })
      // this.merchantDialogVisible = !this.merchantDialogVisible
    },
    selectableFn(row, index) {
      var isSelect = true
      if (row.status == '1' || row.mode == '0') { // 状态 或者 模式是融合禁止选中
        isSelect = false
      }
      return isSelect
    },
    getParams() {
      const params = Util.deepClone(this.searchForm)
      const form = this.searchForm
      if (form.createTime && form.createTime.length) {
        params.minCreateTime = Util.dateFormate(
          form.createTime[0],
          "YYYY-MM-DD HH:mm:ss"
        )
        params.maxCreateTime =
          Util.dateFormate(form.createTime[1], "YYYY-MM-DD") + " 23:59:59"
      }
      delete params.createDate
      return params
    },
    beforeSearchFn() {
      return new Promise((resolve) => {
        this.searchFormSearch = this.getParams()
        delete this.searchFormSearch.createDate
        resolve()
      })
    },
    // 新增门店end
    handleReset() {
      this.searchForm = {
        merchantName: "",
        createTime: ""
      }
      this.handleSearch()
    },
    keyDowmGetList() {
      this.handleSearch()
    },
    handleSearch() {
      this.$refs.ruleTable.refreshTable(false, true)
    },
    // 导出
    handleExport() {
      var params = this.getParams()
      vdruleExport(params).then((res) => {
        window.location.href = res
      })
    },
    // 查看详情
    handleDetail(data) {
      this.ruleId = data.id
      this.isRuleVisible = true
      this.disEdit = true
    },
    handleEdit(data) {
      this.ruleId = data.id
      this.isRuleVisible = true
      this.disEdit = false
    }

  }
}
</script>
<style lang="scss" scoped>
// .configuration-wrap {
//   .title {
//     font-size: 14px;
//     color: #333333;
//     display: flex;
//     align-items: center;
//     cursor: pointer;
//   }

//   ::v-deep .el-form-item {
//     margin-bottom: 15px;
//     width: 284px;
//   }

//   .rule-title {
//     border: 6px solid transparent;
//     border-bottom: 6px solid #333;
//     margin-right: 10px;
//     margin-top: -7px;
//   }

//   .expanded {
//     transform: rotate(180deg);
//     margin-top: 6px;
//   }

//   .computation-bg {
//     width: 526px;
//     background: #f9f9f9;
//     padding: 12px 20px;
//     box-sizing: border-box;
//     margin-bottom: 16px;
//   }

//   .insurance-bg {
//     width: 526px;
//     height: 94px;
//     background: #f9f9f9;
//     padding: 12px 20px;
//     box-sizing: border-box;
//     margin-bottom: 16px;
//   }
// }
</style>