<template>
  <div>
    <div>
      <el-page-header @back="goBack" content="存货调价单"> </el-page-header>
    </div>
    <br /><br />
    <div>
      <el-form
        ref="screenForm"
        label-width="100px"
        size="small"
        label-position="left"
      >
        <el-row :gutter="20">
          <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="单据编号">
              <el-input
                placeholder="系统自动生成"
                disabled
                v-model="base.billId"
              ></el-input>
            </el-form-item>
          </el-col>
          <!-- <el-col :xs="24" :sm="12" :lg="6">
                     <el-form-item label="调价业务员">
                       <el-select
                         placeholder="请选择调价业务员"
                         filterable
                         @change="handleUser"
                         v-model="serviceId"
                       >
                         <el-option
                           v-for="(item, index) in userList"
                           :label="item.nickName"
                           :value="item.roleId"
                           :key="index"
                         ></el-option>
                       </el-select>
                     </el-form-item>
                   </el-col>
                   <el-col :xs="24" :sm="12" :lg="6">
                     <el-form-item label="调价部门">
                       <el-input
                         placeholder="调价部门"
                         disabled
                         v-model="adminCompanyName"
                       ></el-input>
                     </el-form-item>
                   </el-col> -->
          <!-- <el-col :xs="24" :sm="12" :lg="6">
                     <el-form-item label="销售类型">
                       <el-select
                         placeholder="请选择销售类型"
                         filterable
                         v-model="saleTypeId"
                       >
                         <el-option
                           v-for="item in typeList"
                           :label="item.saleName"
                           :value="item.id"
                         ></el-option>
                       </el-select>
                     </el-form-item>
                   </el-col> -->
          <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="文件编码">
              <el-input placeholder="请输入" v-model="base.remark"></el-input>
            </el-form-item>
          </el-col>

          <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="" class="fr"> </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="mymain-container">
      <!-- 列表 -->
      <div class="table">
        <el-form v-if="!detail.length" size="small" label-position="left">
          <el-table
            v-loading="listLoading"
            :data="items"
            element-loading-text="Loading"
            border
            fit
            highlight-current-row
            stripe
          >
            <el-table-column
              align="center"
              label="操作类型"
              prop="nname"
              min-width="160"
              show-overflow-tooltip
            >
              <!-- <el-button type="text" class="textColor">修改</el-button> -->
              <template slot-scope="scope">
                <el-button
                  type="text"
                  class="textColor"
                  @click="hanleDeleInd(scope.$index)"
                  >删除</el-button
                >
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="销售类型"
              prop="saleTypeId"
              min-width="160"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-form-item>
                  <el-select
                    placeholder="请选择销售类型"
                    filterable
                    v-model="scope.row.saleTypeId"
                  >
                    <el-option
                      v-for="item in typeList"
                      :label="item.saleName"
                      :value="item.id"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="存货编码"
              prop="materialNumber"
              min-width="160"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-form-item>
                  <el-input
                    disabled
                    v-model="scope.row.materialNumber"
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="存货名称"
              prop="materialName"
              min-width="160"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-form-item>
                  <el-input
                    disabled
                    v-model="scope.row.materialName"
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="规格型号"
              prop="specification"
              min-width="160"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-form-item>
                  <el-input
                    disabled
                    v-model="scope.row.specification"
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="计量单位"
              prop="unit"
              min-width="160"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-form-item>
                  <el-input v-model="scope.row.unit"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="批发价"
              prop="batchPrice"
              min-width="160"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-form-item>
                  <el-input v-model="scope.row.batchPrice"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="格力折扣"
              prop="discAmount"
              min-width="160"
              show-overflow-tooltip
              ><template slot-scope="scope">
                <el-form-item>
                  <el-input v-model="scope.row.discAmount"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="返利类型"
              prop="rebateUseRate"
              min-width="160"
              show-overflow-tooltip
              ><template slot-scope="scope">
                <el-form-item>
                  <el-select
                    multiple
                    v-model="scope.row.walletRebateId"
                    placeholder="请选择返利类型"
                    @change="handelRebateList($event, scope.$index, scope.row)"
                  >
                    <el-option
                      v-for="(item, index) in rebateList"
                      :key="item.index"
                      :value="item.walletRebateId"
                      :label="item.name"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="生效日期"
              prop="startDate"
              min-width="160"
              show-overflow-tooltip
              ><template slot-scope="scope">
                <el-form-item>
                  <el-date-picker
                    v-model="scope.row.startDate"
                    type="date"
                    placeholder="请输入调价日期"
                    value-format="yyyy-MM-dd"
                  >
                  </el-date-picker>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="失效日期"
              prop="endDate"
              min-width="160"
              show-overflow-tooltip
              ><template slot-scope="scope">
                <el-form-item>
                  <el-date-picker
                    v-model="scope.row.endDate"
                    type="date"
                    placeholder="请输入调价日期"
                    value-format="yyyy-MM-dd"
                  >
                  </el-date-picker>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="是否促销价"
              prop="isPromote"
              min-width="160"
              show-overflow-tooltip
              ><template slot-scope="scope">
                <el-form-item>
                  <el-select
                    v-model="scope.row.isPromote"
                    placeholder="请选择是否促销价"
                  >
                    <el-option
                      v-for="item in scope.row.isPromoteArr"
                      :key="item.bool"
                      :value="item.bool"
                      :label="item.value"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="数量"
              prop="qty"
              min-width="160"
              show-overflow-tooltip
              ><template slot-scope="scope">
                <el-form-item>
                  <el-input v-model="scope.row.qty"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="现金钱包"
              prop="wallets"
              min-width="160"
              show-overflow-tooltip
              ><template slot-scope="scope">
                <el-form-item>
                  <el-select
                    multiple
                    v-model="scope.row.walletsId"
                    @change="handelWallets($event, scope.$index, scope.row)"
                    placeholder="请选择现金钱包"
                  >
                    <el-option
                      v-for="item in walleList"
                      :key="item.id"
                      :value="item.id"
                      :label="item.name"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="发布"
              prop="isPublish"
              min-width="160"
              show-overflow-tooltip
              ><template slot-scope="scope">
                <el-form-item>
                  <el-select
                    v-model="scope.row.isPublish"
                    placeholder="请选择是否发布"
                  >
                    <el-option
                      v-for="item in scope.row.isPublishArr"
                      :key="item.bool"
                      :value="item.bool"
                      :label="item.value"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
          </el-table>
        </el-form>
        <el-form :model="detail" v-else size="small" label-position="left">
          <el-table
            v-loading="listLoading"
            :data="detail"
            element-loading-text="Loading"
            border
            fit
            highlight-current-row
            stripe
          >
            <el-table-column
              align="center"
              label="操作类型"
              prop="nname"
              min-width="160"
              show-overflow-tooltip
            >
              <!-- <el-button type="text" class="textColor">修改</el-button> -->
              <template slot-scope="scope">
                <el-button
                  type="text"
                  class="textColor"
                  @click="hanleDeleInd(scope.$index)"
                  >删除</el-button
                >
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="销售类型"
              prop="saleTypeId"
              min-width="160"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-form-item>
                  <el-select
                    placeholder="请选择销售类型"
                    v-model="scope.row.saleTypeId"
                  >
                    <el-option
                      v-for="item in typeList"
                      :label="item.name"
                      :value="item.id"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="存货编码"
              prop="materialNumber"
              min-width="160"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-form-item>
                  <el-input v-model="scope.row.materialNumber"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="存货名称"
              prop="materialName"
              min-width="160"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-form-item>
                  <el-input v-model="scope.row.materialName"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="规格型号"
              prop="specification"
              min-width="160"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-form-item>
                  <el-input v-model="scope.row.specification"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="计量单位"
              prop="unit"
              min-width="160"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-form-item>
                  <el-input v-model="scope.row.SalesType"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="批发价"
              prop="batchPrice"
              min-width="160"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <el-form-item>
                  <el-input v-model="scope.row.batchPrice"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="零售价"
              prop="retailPrice"
              min-width="160"
              show-overflow-tooltip
              ><template slot-scope="scope">
                <el-form-item>
                  <el-input v-model="scope.row.retailPrice"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="返利使用比例"
              prop="rebateUseRate"
              min-width="160"
              show-overflow-tooltip
              ><template slot-scope="scope">
                <el-form-item>
                  <el-input v-model="scope.row.rebateUseRate"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="生效日期"
              prop="startDate"
              min-width="160"
              show-overflow-tooltip
              ><template slot-scope="scope">
                <el-form-item>
                  <el-date-picker
                    v-model="scope.row.startDate"
                    type="date"
                    placeholder="请输入调价日期"
                    value-format="yyyy-MM-dd"
                  >
                  </el-date-picker>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="失效日期"
              prop="endDate"
              min-width="160"
              show-overflow-tooltip
              ><template slot-scope="scope">
                <el-form-item>
                  <el-date-picker
                    v-model="scope.row.endDate"
                    type="date"
                    placeholder="请输入调价日期"
                    value-format="yyyy-MM-dd"
                  >
                  </el-date-picker>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="是否促销价"
              prop="isPromote"
              min-width="160"
              show-overflow-tooltip
              ><template slot-scope="scope">
                <el-form-item>
                  <el-select
                    v-model="scope.row.isPromote"
                    placeholder="请选择是否促销价"
                  >
                    <el-option
                      v-for="item in scope.row.isPromoteArr"
                      :key="item.bool"
                      :value="item.bool"
                      :label="item.value"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="数量"
              prop="qty"
              min-width="160"
              show-overflow-tooltip
              ><template slot-scope="scope">
                <el-form-item>
                  <el-input v-model="scope.row.qty"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="支付钱包类型"
              prop="wallets"
              min-width="160"
              show-overflow-tooltip
              ><template slot-scope="scope">
                <el-form-item>
                  <el-select
                    v-model="scope.row.isPublish"
                    placeholder="请选择支付钱包类型"
                  >
                    <el-option
                      v-for="item in scope.row.rebateList"
                      :key="item.walletRebateId"
                      :value="item.walletRebateId"
                      :label="item.name"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="发布"
              prop="isPublish"
              min-width="160"
              show-overflow-tooltip
              ><template slot-scope="scope">
                <el-form-item>
                  <el-select
                    v-model="scope.row.isPublish"
                    placeholder="请选择是否发布"
                  >
                    <el-option
                      v-for="item in scope.row.isPublishArr"
                      :key="item.bool"
                      :value="item.bool"
                      :label="item.value"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
          </el-table>
        </el-form>
        <el-dialog
          title="提示"
          :visible.sync="centerDialogVisible"
          width="50%"
          center
          class="dia"
        >
          <el-form
            :model="form"
            ref="form"
            label-width="80px"
            :inline="false"
            size="normal"
          >
            <el-form-item label="产品类型">
              <el-select v-model="materialId" placeholder="请选择" width="100%">
                <el-option
                  v-for="item in materialLis"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-form>

          <span slot="footer" class="dialog-footer">
            <el-button @click="centerDialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="hanleAdd">确 定</el-button>
          </span>
        </el-dialog>
      </div>
    </div>
    <div class="btn-group clearfix">
      <el-button size="small" @click="handleReseat">重置</el-button>
      <el-button size="small" type="primary" @click="hanleSbumit"
        >提交</el-button
      >
      <el-button
        style="float: right"
        type="primary"
        size="small"
        @click="centerDialogVisible = true"
        >添加</el-button
      >
    </div>

    <el-dialog title="" :visible.sync="centerDialogVisible" width="80%" center>
      <div>
        <el-form
          ref="screenForm"
          :model="screenForm"
          label-width="70px"
          size="small"
          label-position="left"
        >
          <el-row :gutter="20">
            <el-col :xs="24" :sm="12" :lg="6">
              <el-form-item label="名称" prop="keyword">
                <el-input
                  placeholder="请输入名称"
                  v-model="screenForm.keyword"
                ></el-input>
              </el-form-item>
            </el-col>

            <el-col :xs="24" :sm="12" :lg="18" class="tr">
              <el-form-item label="">
                <el-button size="small" @click="resetScreenForm"
                  >清空</el-button
                >
                <el-button size="small" type="primary" @click="submitScreenForm"
                  >搜索</el-button
                >
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div class="mymain-container">
        <div class="table">
          <el-table
            v-loading="listLoading"
            :data="dataList"
            element-loading-text="Loading"
            border
            fit
            highlight-current-row
            stripe
            @select-all="handleSelectionAllChange"
            @selection-change="handleSelectionChange"
          >
            <el-table-column align="center" type="selection" width="55">
            </el-table-column>
            <el-table-column
              align="center"
              label="使用组织"
              prop="useOrgName"
              min-width="100"
            ></el-table-column>
            <el-table-column
              align="center"
              label="编码"
              prop="number"
              min-width="100"
              label-class-name="bianma"
              class-name="fontstyle"
            ></el-table-column>

            <el-table-column
              align="center"
              label="名称"
              prop="name"
              min-width="100"
            ></el-table-column>
            <el-table-column
              align="center"
              label="规格型号"
              prop="specification"
              min-width="100"
            ></el-table-column>
            <el-table-column
              align="center"
              label="数据状态"
              prop="forbidStatus"
              min-width="100"
            >
              <template slot-scope="scope">
                <el-tag type="success" v-if="scope.row.forbidStatus == 'A'"
                  >正常</el-tag
                >
                <el-tag type="danger" v-else>禁用</el-tag>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="是否维护商城资料"
              prop="maintainData"
              min-width="100"
            ></el-table-column>
            <el-table-column
              align="center"
              label="是否维护内外机档案"
              prop="maintainFiles"
              min-width="100"
            ></el-table-column>
            <el-table-column
              align="center"
              label="基本单位"
              prop="baseUnitId"
              min-width="100"
            ></el-table-column>
            <el-table-column
              align="center"
              label="已使用"
              prop="used"
              min-width="100"
            ></el-table-column>
          </el-table>
        </div>
        <!-- 分页 -->
        <div class="fr">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[5]"
            :page-size="10"
            layout="total, sizes, prev, pager, next, jumper"
            :total="listTotal"
          >
          </el-pagination>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="centerDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="handleDetermine">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import {
  getProductRriceAdd,
  getProductRriceDetail,
  getTypeList,
  getMaterialList,
  getRebate,
  getUserList,
  getMaterialDetail,
  getWalletList,
} from "@/api/basic_data/material";

import MaterialListDetail from "./material_list-detail.vue";
import Mixin from "@/mixin/index";
export default {
  mixins: [Mixin],
  data() {
    return {
      listLoading: false,
      screenForm: {},
      base: {
        adminCompanyId: "",
        adminWebsitId: "",
        billId: "",
        examineNote: "",
        examineResult: true,
        examineStatus: "",
        id: null,
        serviceId: "",
        serviceName: "",
        remark: "",
        saleTypeId: "",
      },
      items: [],
      centerDialogVisible: false,
      materialLis: [],
      materialId: "",
      rebateList: [],
      typeList: [],
      saleTypeId: "",
      serviceId: "",
      adminCompanyId: "",
      serviceName: "",
      adminCompanyName: "",
      adminWebsitId: "",
      remark: "",
      detail: [],
      form: {},
      startDate: "",
      userList: [],
      centerDialogVisible: false,
      screenForm: {
        keyword: "",
      },
      selectData: [],
      walleList: [],
    };
  },
  mounted() {
    let params = {
      pageNum: 1,
      pageSize: -1,
      saleCode: "",
      saleName: "",
      status: "",
    };
    getTypeList(params).then((res) => {
      this.typeList = res.data.records;
    });
    getUserList({
      pageNum: 1,
      pageSize: -1,
      adminWebsitId: "",
      isCustomer: 0,
      roleId: "",
      status: "",
      userName: "",
    }).then((res) => {
      this.userList = res.data.records;
    });
    getWalletList({ mainId: "", walletName: "" }).then((res) => {
      this.walleList = res.data;
    });
    let rebateParams = {
      pageNum: 1,
      pageSize: -1,
      mainName: "",
      saleTypeCode: "",
      saleTypeName: "",
      status: "",
    };
    getRebate(rebateParams).then((res) => {
      this.rebateList = res.data.records;
    });
  },
  methods: {
    // xua
    handelWallets(e, index, row) {
      for (let i = 0; i < e.length; i++) {
        if (this.items[index].wallets.length) {
          console.log(1212);
          for (let j = 0; j < this.items[index].wallets.length; j++) {
            if (e[i] !== this.items[index].wallets[j].walletId) {
              this.$set(this.items[index], "wallets", [
                ...this.items[index].wallets,
                {
                  type: "COMMONLY",
                  id: "",
                  updPriceBillId: row.cid,
                  updPriceBillItemId: row.cid,
                  walletId: e[i],
                },
              ]);
            }
          }
        } else {
          console.log(987);
          this.$set(this.items[index], "wallets", [
            {
              type: "COMMONLY",
              id: "",
              updPriceBillId: row.id,
              updPriceBillItemId: row.id,
              walletId: e[0],
            },
          ]);
        }
      }

      console.log(this.items[index], 456);
    },
    handelRebateList(e, index, row) {
      for (let i = 0; i < e.length; i++) {
        if (this.items[index].wallets.length) {
          console.log(1212);
          for (let j = 0; j < this.items[index].wallets.length; j++) {
            if (e[i] !== this.items[index].wallets[j].walletId) {
              this.$set(this.items[index], "wallets", [
                ...this.items[index].wallets,
                {
                  type: "REBATE",
                  id: "",
                  updPriceBillId: row.cid,
                  updPriceBillItemId: row.cid,
                  walletId: e[i],
                },
              ]);
            }
          }
        } else {
          console.log(987);

          this.$set(this.items[index], "rebateWallets", [
            {
              type: "REBATE",
              id: "",
              updPriceBillId: row.id,
              updPriceBillItemId: row.id,
              walletId: e[0],
            },
          ]);
        }
      }
    },
    handleUser(e) {
      const adminCompany = this.userList.filter((k) => {
        return e == k.roleId;
      })[0];
      this.adminWebsitId = adminCompany.adminUserId;
      this.adminCompanyName = adminCompany.adminCompanyName;
      this.serviceName = adminCompany.nickName || "d";
      this.serviceId = adminCompany.roleId;
    },
    goBack() {
      this.$parent.show = 1;
      // 更新父组件数据
      this.$parent.getList();
    },
    indexMethod(index) {
      console.log(index);
    },
    hanleDeleInd(index) {
      this.items.splice(index, 1);
    },
    handleDetermine() {
      if (this.selectData.length) {
        for (let i = 0; i < this.selectData.length; i++) {
          this.items.push({
            baseUnitId: "",
            batchPrice: "",
            unit: "",
            billId: "",
            endDate: "",
            isPromote: "",
            isPublish: "",
            materialId: this.selectData[i].id,
            materialName: this.selectData[i].name,
            materialNumber: this.selectData[i].number,
            discAmount: "",
            materialOldNumber: this.selectData[i].oldNumber,
            parentId: "",
            walletRebateName: "",
            walletRebateId: [],
            rebateRate: "",
            qty: "",
            rebateUseRate: "",
            retailPrice: "" || 0,
            saleTypeId: "",
            specification: this.selectData[i].specification,
            startDate: this.selectData[i].startDate,
            wallets: [],
            rebateWallets: [],
            rebateList: [...this.rebateList],
            isPublishArr: [
              {
                value: "是",
                bool: true,
              },
              {
                value: "否",
                bool: false,
              },
            ],
            isPromoteArr: [
              {
                value: "是",
                bool: true,
              },
              {
                value: "否",
                bool: false,
              },
            ],
            cid: this.selectData[i].id,
          });
        }
        this.selectData = [];
        this.centerDialogVisible = false;
      } else {
        this.$errorMsg("请选择内容");
      }
    },
    getMaterialList() {
      let params = {
        pageNum: 1,
        pageSize: 10,
        keyword: "",
        bindMain: true,
      };
      getMaterialList(params).then((res) => {
        this.materialLis = res.data.records;
      });
    },
    handleSelectionAllChange(e) {
      this.selectData = e;
    },
    handleSelectionChange(e) {
      this.selectData = e;
    },
    hanleAdd() {
      if (this.materialId) {
        this.centerDialogVisible = false;
      } else {
        this.$errorMsg("请选择产品");
      }
    },
    getList() {
      this.listLoading = true;
      let params = {
        pageNum: this.currentPage,
        pageSize: 5 || this.pageSize,
        keyword: this.screenForm.keyword,
        bindMain: true,
      };
      getMaterialList(params).then((res) => {
        this.dataList = res.data.records;
        this.listTotal = res.data.total;
        this.listLoading = false;
      });
    },
    hanleSbumit() {
      for (let i = 0; i < this.items.length; i++) {
        this.items[i].wallets = [
          ...this.items[i].rebateWallets,
          ...this.items[i].wallets,
        ];
        for (let j = i + 1; j < this.items.length; j++) {
          if (this.items[i].materialNumber == this.items[j].materialNumber) {
            if (this.items[i].saleTypeId == this.items[j].saleTypeId) {
              this.$errorMsg("有存货编码销售类型相同");
              return;
            }
          }
        }
      }
      const params = {
        ...this.base,
        items: this.items,
        saleTypeId: this.saleTypeId,
        adminWebsitId: this.adminWebsitId,
        serviceId: this.serviceId,
        adminCompanyName: this.adminCompanyName,
        serviceName: this.nickName,
      };
      getProductRriceAdd(params).then((res) => {
        this.$successMsg("成功");
        getProductRriceDetail({ id: res.data }).then((res) => {
          this.base.billId = res.data.billId;
          this.$parent.show = 1;
          this.$parent.getList();
        });
      });
    },
    handleReseat() {
      this.base = {
        adminCompanyId: "",
        adminWebsitId: "",
        billId: "",
        examineNote: "",
        examineResult: true,
        examineStatus: "",
        id: null,
        serviceId: "",
        serviceName: "",
        remark: "",
        saleTypeId: "",
      };
      this.saleTypeId = "";
      this.items = [];
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-date-editor--date {
  width: 100%;
}
.dia .el-select--normal {
  width: 100%;
}
</style>
