<template>
  <div class="app-container">
    <div class="search-bx">
      <div class="search">
        <el-row :gutter="0">
          <el-input
            v-model="tableObj.getdataListParm.parammaps.repairCode"
            placeholder="维修服务编号"
            class="filter-item"
            style="width: 120px; padding-bottom: 10px"
          />

          <el-select
            v-model="tableObj.getdataListParm.parammaps.statusName"
            placeholder="服务状态"
            class="filter-item"
            style="width: 120px"
            clearable
          >
            <el-option
              v-for="item in statusNameList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select>

          <el-select
            v-model="tableObj.getdataListParm.parammaps.repairResult"
            placeholder="维修结果"
            class="filter-item"
            style="width: 120px"
            clearable
          >
            <el-option
              v-for="item in repairResultNameList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select>

          <el-select
            v-model="tableObj.getdataListParm.parammaps.typeName"
            placeholder="维修类型"
            class="filter-item"
            style="width: 120px"
            clearable
          >
            <el-option
              v-for="item in repairTypeNameList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select>

          <el-select
            v-model="tableObj.getdataListParm.parammaps.employeeId"
            placeholder="服务人员"
            class="filter-item"
            style="width: 120px"
            clearable
          >
            <el-option
              v-for="item in employeeNameList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select>

          <!-- <el-autocomplete v-model="tableObj.getdataListParm.parammaps.customerName" :fetch-suggestions="customer_search" placeholder="客户名称" style="width: 200px;margin-right:10px" @select="change_customer_select" @clear="clear_customer_select" @blur="customer_search_blur" clearable>
                <template slot-scope="{ item }">
                  <span class="name">{{ item.name }}</span>
                </template>
              </el-autocomplete> -->

          <el-input
            v-model="tableObj.getdataListParm.parammaps.customerName"
            placeholder="客户名称"
            style="width: 180px"
            class="filter-item"
            clearable
          />

          <el-select
            v-model="tableObj.getdataListParm.parammaps.groupId"
            placeholder="集团"
            class="filter-item"
            style="width: 120px"
            clearable
          >
            <el-option
              v-for="item in groupNameList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select>

          <el-date-picker
            v-model="tableObj.getdataListParm.parammaps.inputDatetime1"
            class="inputDatetime filter-item"
            type="daterange"
            range-separator="至"
            start-placeholder="服务开始日期"
            end-placeholder="服务开始日期"
            style="width: 250px"
          />

          <el-date-picker
            v-model="tableObj.getdataListParm.parammaps.inputDatetime2"
            class="inputDatetime filter-item"
            type="daterange"
            range-separator="至"
            start-placeholder="服务完成日期"
            end-placeholder="服务完成日期"
            style="width: 250px"
          />

          <el-input
            v-model="tableObj.getdataListParm.parammaps.postCode"
            placeholder="快递单号"
            style="width: 120px"
          ></el-input>

          <el-select
            v-model="tableObj.getdataListParm.parammaps.costStatus"
            placeholder="款项状态"
            class="filter-item"
            style="width: 120px"
            clearable
          >
            <el-option
              v-for="item in moneyNameList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select>

          <el-input
            v-model="tableObj.getdataListParm.parammaps.beginServiceCost"
            placeholder="服务费用"
            style="width: 80px"
          ></el-input>
          -
          <el-input
            v-model="tableObj.getdataListParm.parammaps.endServiceCost"
            placeholder="服务费用"
            style="width: 80px"
          ></el-input>

          <el-date-picker
            v-model="tableObj.getdataListParm.parammaps.inputDatetime3"
            class="inputDatetime filter-item"
            type="daterange"
            range-separator="至"
            start-placeholder="支付时间"
            end-placeholder="支付时间"
            style="width: 250px"
          />

          <el-date-picker
            v-model="tableObj.getdataListParm.parammaps.inputDatetime4"
            class="inputDatetime filter-item"
            type="daterange"
            range-separator="至"
            start-placeholder="收款时间"
            end-placeholder="收款时间"
            style="width: 250px"
          />

          <el-button class="successBorder" @click="form_search">查询</el-button>
          <el-button class="successBorder" @click="form_clear">重置</el-button>

          <el-button
            v-if="isRepairAdd"
            class="success"
            icon="el-icon-plus"
            @click="form_add"
            >新增</el-button
          >
          <!-- <el-button  class="success" icon="el-icon-upload2" @click="form_export">导出</el-button> -->
        </el-row>
      </div>

      <!-- <div class="operation">


        <el-row :gutter="0">
          <el-col :span="21">
            <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" @click="form_add">新增</el-button>
          </el-col>
          <el-col :span="3">
              <el-dropdown>
                <el-button class="export">导出</el-button>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item @click.native="form_export(1)">导出模板</el-dropdown-item>
                  <el-dropdown-item @click.native="form_export(2)">导出数据</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
          </el-col>
        </el-row>
      </div> -->
    </div>

    <div class="table">
      <el-table
        :key="tableObj.tableKey"
        v-loading="tableObj.listLoading"
        element-loading-text="给我一点时间"
        :data="tableObj.list"
        border
        fit
        highlight-current-row
        style="width: 100%"
        :row-style="rowStyle"
        :cell-style="cellStyle"
        class="elTable table-fixed"
        :max-height="myHeight"
      >
        <!-- <el-table-column type="selection" align="center" width="50" /> -->
        <el-table-column
          label="序号"
          align="center"
          type="index"
          width="50px"
          fixed="left"
        >
          <template slot-scope="scope">
            <span>{{
              scope.$index + (tableObj.pageNum - 1) * tableObj.pageSize + 1
            }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="维修服务编号"
          min-width="120px"
          align="center"
          fixed="left"
        >
          <template slot-scope="scope">
            <span
              style="color: #409eff; cursor: pointer"
              @click="form_see(scope.row)"
              >{{ scope.row.repairCode }}</span
            >
          </template>
        </el-table-column>
        <el-table-column
          label="服务状态"
          min-width="90px"
          align="center"
          fixed="left"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.statusName }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="客户名称"
          min-width="190px"
          align="center"
          fixed="left"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.customerName }}</span>
          </template>
        </el-table-column>

        <el-table-column label="客户对接人" min-width="100px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.receiverName }}</span>
          </template>
        </el-table-column>

        <el-table-column label="服务开始时间" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.serviceBeginDate }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="问题详情"
          min-width="120px"
          align="center"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <span>{{ scope.row.problem }}</span>
          </template>
        </el-table-column>
        <el-table-column label="维修结果" min-width="120px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.repairResult }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="服务费用"
          min-width="110px"
          align="center"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <span>{{ scope.row.serviceCost }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="款项状态"
          min-width="110px"
          align="center"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <span>{{ scope.row.costStatus }}</span>
          </template>
        </el-table-column>

        <el-table-column label="支付时间" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.payDate }}</span>
          </template>
        </el-table-column>

        <el-table-column
          label="所属集团"
          min-width="90px"
          align="center"
          fixed="left"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.groupName }}</span>
          </template>
        </el-table-column>

        <el-table-column label="维修类型" min-width="120px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.typeName }}</span>
          </template>
        </el-table-column>
        <el-table-column label="沟通结果" min-width="120px" align="center">
          <template slot-scope="scope">
            <el-tooltip
              v-if="scope.row.talkResult == '查看'"
              class="item"
              effect="dark"
              :content="
                '建议方案：' +
                scope.row.proposal +
                '\n\n\n' +
                '处理结果：' +
                scope.row.processingResults
              "
              placement="right"
            >
              <span>查看</span>
            </el-tooltip>

            <span v-else>{{ scope.row.talkResult }}</span>
          </template>
        </el-table-column>

        <el-table-column label="快递单号" min-width="120px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.postCode }}</span>
          </template>
        </el-table-column>

        <el-table-column label="收款时间" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.collectDate }}</span>
          </template>
        </el-table-column>

        <el-table-column label="服务完成时间" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.serviceSuccessDate }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="服务人员"
          min-width="110px"
          align="center"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <span>{{ scope.row.employeeName }}</span>
          </template>
        </el-table-column>

        <el-table-column
          label="备注"
          min-width="120px"
          align="center"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <span>{{ scope.row.remark }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="服务总结"
          min-width="120px"
          align="center"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <span>{{ scope.row.serviceSummary }}</span>
          </template>
        </el-table-column>
        <el-table-column label="录入时间" min-width="110px" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.createrDate }}</span>
          </template>
        </el-table-column>

        <el-table-column
          label="操作"
          align="center"
          :width="autoWidth"
          v-if="autoWidth !== 0"
          class-name="small-padding fixed-width"
          fixed="right"
        >
          <template slot-scope="{ row }">
            <!-- <el-button class="miniPrimary" @click="form_see(row)"
            >服务反馈</el-button>
            <el-button class="miniSuccess" @click="form_edit(row)"
            >编辑</el-button>
            <el-button class="miniDanger" @click="form_delete(row)"
            >删除</el-button>
            <el-button class="miniSuccess" @click="form_complete(row)"
            >完成</el-button>

            <el-button class="miniSuccess" @click="form_revoke(row)"
            >撤销</el-button> -->

            <el-button
              class="miniPrimary"
              @click="form_see(row)"
              v-if="isRepairFeed && row.isFeedBack == '1'"
              >服务反馈</el-button
            >
            <el-button
              class="miniSuccess"
              @click="form_edit(row)"
              v-if="isRepairAdd && row.isModify == '1'"
              >编辑</el-button
            >
            <el-button
              class="miniDanger"
              @click="form_delete(row)"
              v-if="isRepairAdd && row.isDel == '1'"
              >删除</el-button
            >
            <el-button
              class="miniSuccess"
              @click="form_complete(row)"
              v-if="isRepairComplete && row.isComplete == '1'"
              >完成</el-button
            >

            <el-button
              class="miniSuccess"
              @click="form_revoke(row)"
              v-if="isRepairAdd && row.isRevoke == '1'"
              >撤销</el-button
            >
          </template>
        </el-table-column>
      </el-table>

      <el-row :gutter="0">
        <el-col :span="6" :offset="12" style="color: #f00">
          列表服务总金额：{{ tableSumMoney }}
        </el-col>
      </el-row>

      <pagination
        v-show="tableObj.total >= 0"
        :total="tableObj.total"
        :page.sync="tableObj.getdataListParm.offset"
        :limit.sync="tableObj.getdataListParm.pagecount"
        @pagination="get_table_data"
      />
    </div>

    <!-- 新增/编辑 -->
    <el-dialog
      :title="textMap[create.dialogStatus]"
      :visible.sync="create.dialogFormVisible"
      :close-on-click-modal="false"
      width="95%"
    >
      <div class="app-add">
        <el-form
          ref="temp"
          :rules="create.rules"
          :model="create.temp"
          label-position="right"
          label-width="150px"
          style="width: 95%; margin: 0 auto 50px"
        >
          <el-row :gutter="25">
            <el-col :span="8">
              <el-row v-if="create.dialogStatus == 'see'">
                <el-form-item label="维修编号：" prop="repairCode">
                  <el-input
                    ref="repairCode"
                    v-model="create.temp.repairCode"
                    class="filter-item"
                    style="width: 100%"
                    disabled
                  />
                </el-form-item>
              </el-row>

              <!-- <el-form-item label="所属集团：" prop="groupId">
                      <el-select v-model="create.temp.groupId" placeholder="所属集团" class="filter-item" style="width: 100%;" filterable  @change="change_group" clearable :disabled="create.dialogStatus=='see' || create.dialogStatus=='update' ">
                          <el-option v-for="item in groupNameList" :key="item.id" :label="item.name" :value="item.id" />
                      </el-select>
                  </el-form-item> -->

              <el-form-item label="客户名称：" prop="customerId">
                <el-select
                  v-model="create.temp.customerId"
                  filterable
                  placeholder="客户名称"
                  class="filter-item"
                  style="width: 100%"
                  clearable
                  @change="change_customer"
                  :disabled="
                    create.dialogStatus == 'see' ||
                    create.dialogStatus == 'update'
                  "
                >
                  <el-option
                    v-for="item in create.customerNameList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>

              <el-form-item label="集团：" prop="groupName">
                <el-input
                  ref="groupName"
                  v-model="create.temp.groupName"
                  class="filter-item"
                  style="width: 100%"
                  disabled
                />
              </el-form-item>

              <el-form-item label="维修类型：" prop="typeName">
                <el-select
                  ref="typeName"
                  v-model="create.temp.typeName"
                  filterable
                  placeholder="请选择维修类型"
                  class="filter-item"
                  style="width: 100%"
                  :disabled="create.dialogStatus == 'see'"
                  @change="change_repair"
                >
                  <el-option
                    v-for="item in repairTypeNameList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>

              <!-- <el-form-item label="客户对接人：" prop="receiverName">
                    <el-input ref="receiverName" v-model="create.temp.receiverName" class="filter-item" style="width: 100%;"  placeholder="请输入接待人" :disabled="create.dialogStatus=='see'" />
                  </el-form-item> -->

              <el-form-item label="客户对接人：" prop="receiverName">
                <el-select
                  v-model="create.temp.receiverName"
                  style="width: 100%"
                  placeholder="请选择"
                  filterable
                  allow-create
                  @change="change_receiverName"
                  :disabled="create.dialogStatus == 'see'"
                >
                  <el-option
                    v-for="item in receiverList"
                    :key="item.name"
                    :label="item.name"
                    :value="item.name"
                  >
                  </el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="对接人电话：" prop="receiverTel">
                <el-input
                  ref="receiverTel"
                  v-model="create.temp.receiverTel"
                  class="filter-item"
                  style="width: 100%"
                  placeholder="请输入电话"
                  :disabled="create.dialogStatus == 'see'"
                />
              </el-form-item>

              <el-form-item label="服务开始时间：" prop="serviceBeginDate">
                <el-date-picker
                  v-model="create.temp.serviceBeginDate"
                  type="date"
                  placeholder="选择日期"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                  style="width: 100%"
                  :clearable="false"
                  :disabled="create.dialogStatus == 'see'"
                />
              </el-form-item>

              <!-- <el-form-item label="服务人员：" prop="employeeId">
                    <el-select ref="employeeId" v-model="create.temp.employeeId" filterable placeholder="请选择服务人员" class="filter-item" style="width: 100%;" :disabled="create.dialogStatus=='see'">
                      <el-option v-for="item in employeeNameList" :key="item.id" :label="item.name" :value="item.id" />
                    </el-select>
                  </el-form-item> -->

              <el-form-item label="服务人员：" prop="employeeName">
                <el-input
                  ref="employeeName"
                  v-model="create.temp.employeeName"
                  placeholder=""
                  class="filter-item"
                  style="width: 100%"
                  disabled
                />
              </el-form-item>

              <el-form-item label="问题详情：" prop="problem">
                <el-input
                  ref="problem"
                  v-model="create.temp.problem"
                  type="textarea"
                  :autosize="{ minRows: 1.3, maxRows: 4 }"
                  placeholder=""
                  maxlength="255"
                  class="filter-item"
                  style="width: 100%"
                  :disabled="create.dialogStatus == 'see'"
                />
              </el-form-item>

              <el-form-item
                label="建议方案："
                prop="proposal"
                v-if="create.temp.typeName == '电话回访维修'"
              >
                <el-input
                  ref="proposal"
                  v-model="create.temp.proposal"
                  type="textarea"
                  :autosize="{ minRows: 4, maxRows: 8 }"
                  :rows="8"
                  placeholder="请输入备注，最多200个字"
                  maxlength="200"
                  class="filter-item"
                  style="width: 100%"
                  :disabled="create.dialogStatus == 'see'"
                />
              </el-form-item>

              <el-form-item
                label="处理结果："
                prop="processingResults"
                v-if="create.temp.typeName == '电话回访维修'"
              >
                <el-input
                  ref="processingResults"
                  v-model="create.temp.processingResults"
                  type="textarea"
                  :autosize="{ minRows: 4, maxRows: 8 }"
                  :rows="8"
                  placeholder="请输入备注，最多200个字"
                  maxlength="200"
                  class="filter-item"
                  style="width: 100%"
                  :disabled="create.dialogStatus == 'see'"
                />
              </el-form-item>

              <el-form-item
                label="沟通结果："
                prop="proposal"
                v-if="create.temp.typeName == '邮寄公司维修'"
              >
                <el-radio-group v-model="create.temp.proposal">
                  <el-radio
                    label="客户愿意维修"
                    :disabled="create.dialogStatus == 'see'"
                    >客户愿意维修</el-radio
                  >
                  <el-radio
                    label="客户不愿维修"
                    :disabled="create.dialogStatus == 'see'"
                    >客户不愿维修</el-radio
                  >
                </el-radio-group>
              </el-form-item>

              <el-form-item
                label="沟通结果："
                prop="proposal"
                v-if="create.temp.typeName == '上门维修'"
              >
                <el-radio-group v-model="create.temp.proposal">
                  <el-radio
                    label="先付款后维修"
                    :disabled="create.dialogStatus == 'see'"
                    >先付款后维修</el-radio
                  >
                  <el-radio
                    label="先上门排查"
                    :disabled="create.dialogStatus == 'see'"
                    >先上门排查</el-radio
                  >
                </el-radio-group>
              </el-form-item>

              <el-form-item label="备注：" prop="remark">
                <el-input
                  ref="remark"
                  v-model="create.temp.remark"
                  type="textarea"
                  :autosize="{ minRows: 1.3, maxRows: 4 }"
                  placeholder=""
                  maxlength="255"
                  class="filter-item"
                  style="width: 100%"
                  :disabled="create.dialogStatus == 'see'"
                />
              </el-form-item>
            </el-col>

            <el-col :span="16">
              <h3 v-if="create.dialogStatus == 'see'">备货单信息</h3>
              <h3 v-else>快速添加备货单</h3>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="下单日期：" prop="orderDate">
                    <el-date-picker
                      v-model="create.stockTemp.orderDate"
                      type="date"
                      placeholder="选择日期"
                      format="yyyy-MM-dd"
                      value-format="yyyy-MM-dd"
                      style="width: 100%"
                      :clearable="false"
                      :disabled="create.dialogStatus == 'see'"
                      :picker-options="setDisabled"
                    />
                  </el-form-item>
                </el-col>

                <el-col :span="12">
                  <el-form-item label="关联接收快递：" prop="postalId">
                    <el-select
                      ref="postalId"
                      v-model="create.stockTemp.postalId"
                      filterable
                      placeholder="请选择接收快递"
                      class="filter-item"
                      style="width: 100%"
                      :disabled="create.dialogStatus == 'see'"
                      @change="change_postal"
                      clearable
                    >
                      <el-option
                        v-for="item in create.postalNameList"
                        :key="item.id"
                        :label="item.postCode"
                        :value="item.id"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row>
                <el-col :span="12">
                  <el-form-item label="备货原因：" prop="reasonName">
                    <el-select
                      ref="reasonName"
                      v-model="create.stockTemp.reasonName"
                      filterable
                      placeholder="请选择备货原因"
                      class="filter-item"
                      style="width: 100%"
                      allow-create
                      :disabled="create.dialogStatus == 'see'"
                    >
                      <el-option
                        v-for="item in reasonNameList"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>

                <el-col :span="12">
                  <el-form-item label="预定发货时间：" prop="planSendDate">
                    <el-date-picker
                      v-model="create.stockTemp.planSendDate"
                      type="date"
                      placeholder="选择日期"
                      format="yyyy-MM-dd"
                      value-format="yyyy-MM-dd"
                      style="width: 100%"
                      :clearable="false"
                      :disabled="create.dialogStatus == 'see'"
                    />
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row>
                <el-col :span="12">
                  <el-form-item label="订单来源：" prop="sourceName">
                    <el-select
                      ref="sourceName"
                      v-model="create.stockTemp.sourceName"
                      filterable
                      placeholder="请选择订单原因"
                      class="filter-item"
                      style="width: 100%"
                      allow-create
                      :disabled="create.dialogStatus == 'see'"
                      clearable
                    >
                      <el-option
                        v-for="item in sourceNameList"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id"
                      />
                    </el-select>
                  </el-form-item>
                </el-col>

                <el-col :span="12">
                  <el-form-item label="备注：" prop="remark">
                    <span
                      style="
                        color: #f57272;
                        position: absolute;
                        top: 0px;
                        left: -63px;
                      "
                      >*</span
                    >
                    <el-input
                      ref="remark"
                      v-model="create.stockTemp.remark"
                      type="textarea"
                      :autosize="{ minRows: 1.3, maxRows: 4 }"
                      placeholder="请输入备注，最多255个字"
                      maxlength="255"
                      class="filter-item"
                      style="width: 100%"
                      :disabled="create.dialogStatus == 'see'"
                    />
                  </el-form-item>
                </el-col>
              </el-row>

              <h3>快递接收货品清单</h3>
              <el-row
                v-if="
                  create.dialogStatus == 'create' ||
                  create.dialogStatus == 'update'
                "
              >
                <el-form-item label="添加备货物品：" prop="visiterId">
                  <el-select
                    ref="visiterId"
                    v-model="create.temp.visiterId"
                    filterable
                    placeholder="请选择备货物品"
                    class="filter-item"
                    style="width: 100%"
                    :disabled="create.dialogStatus == 'see'"
                    @change="change_receProduct"
                  >
                    <el-option
                      v-for="item in receProductNameList"
                      :key="item.productsId"
                      :label="
                        '产品名称：' +
                        item.productsName +
                        ' 型号：' +
                        item.model +
                        ' 规格：' +
                        item.Specifications
                      "
                      :value="item.productsId"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-row>
              <el-row>
                <el-table
                  :key="contact.tableKey"
                  v-loading="contact.listLoading"
                  element-loading-text="给我一点时间"
                  :data="tableStockList"
                  border
                  fit
                  highlight-current-row
                  style="width: 100%"
                  :row-style="rowStyle"
                  :cell-style="cellStyle"
                  class="elTable table-fixed"
                >
                  <el-table-column
                    label="序号"
                    align="center"
                    type="index"
                    width="50px"
                  >
                    <template slot-scope="scope">
                      <span>{{ scope.$index + 1 }}</span>
                    </template>
                  </el-table-column>

                  <el-table-column
                    label="产品名称"
                    min-width="110px"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <span>{{ scope.row.productsName }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="型号"
                    min-width="110px"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <span>{{ scope.row.model }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="规格"
                    min-width="110px"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <span>{{ scope.row.Specifications }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="数量"
                    min-width="110px"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <span v-if="create.dialogStatus == 'see'">{{
                        scope.row.nums
                      }}</span>
                      <el-input
                        v-if="
                          create.dialogStatus == 'update' ||
                          create.dialogStatus == 'create'
                        "
                        v-model="scope.row.nums"
                        style="width: 95%; padding: 10px 0"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="单价(元)"
                    min-width="110px"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <span>{{ scope.row.price }}</span>
                    </template>
                  </el-table-column>

                  <el-table-column
                    label="总价(元)"
                    min-width="110px"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <span>{{ scope.row.sumPrice }}</span>
                    </template>
                  </el-table-column>

                  <el-table-column
                    label="备注"
                    min-width="280px"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <span v-if="create.dialogStatus == 'see'">{{
                        scope.row.remark
                      }}</span>
                      <el-input
                        v-if="
                          create.dialogStatus == 'update' ||
                          create.dialogStatus == 'create'
                        "
                        v-model="scope.row.remark"
                        type="textarea"
                        :autosize="{ minRows: 1.3, maxRows: 4 }"
                        style="width: 95%; padding: 10px 0"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    v-if="
                      create.dialogStatus == 'update' ||
                      create.dialogStatus == 'create'
                    "
                    label="操作"
                    align="center"
                    width="110"
                    class-name="small-padding fixed-width"
                    fixed="right"
                  >
                    <template slot-scope="{ row }">
                      <el-button
                        v-if="
                          create.dialogStatus == 'update' ||
                          create.dialogStatus == 'create'
                        "
                        class="miniDanger"
                        @click="form_delete2(row)"
                        >删除</el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </el-row>

              <el-row type="flex" justify="end">
                <el-col style="color: #ff4949" :span="6" :offset="18"
                  >列表货物总价：{{ stockSumPrice }}</el-col
                >
              </el-row>

              <el-divider></el-divider>

              <h3 v-if="create.dialogStatus == 'see'">反馈记录</h3>
              <el-row v-if="create.dialogStatus == 'see'">
                <div v-for="item in feedRecordList">
                  <div>
                    <span>{{ item.num }}</span>
                    <span>{{ item.remark }}</span>
                  </div>
                  <el-row type="flex" justify="end">
                    <el-col :span="6">
                      {{ item.createDate }}
                    </el-col>
                    <el-col :span="6"> 反馈人：{{ item.employeeName }} </el-col>
                  </el-row>
                  <el-divider></el-divider>
                </div>

                <el-input
                  type="textarea"
                  :rows="4"
                  placeholder="请输入内容"
                  v-model="feedRecordTemp.parammaps.remark"
                >
                </el-input>

                <el-button class="success" @click="feedRecord_save()"
                  >确认</el-button
                >
              </el-row>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button
            class="cancelClose"
            @click="
              create.dialogFormVisible = false;
              get_table_data();
            "
            >关闭</el-button
          >

          <el-button
            class="success"
            @click="form_complete(create.temp)"
            v-if="isRepairComplete && create.temp.isComplete == '1'"
            >完成服务</el-button
          >
          <el-button
            v-if="
              create.dialogStatus === 'create' ||
              create.dialogStatus === 'update'
            "
            class="success"
            :disabled="isokDisable"
            @click="
              create.dialogStatus === 'create'
                ? add_dialog_save()
                : form_edit_save()
            "
            >确认</el-button
          >
        </div>
      </div>
    </el-dialog>

    <!-- 撤销 -->
    <el-dialog
      title="确认是否撤销"
      :visible.sync="revoke.dialogFormVisible"
      :close-on-click-modal="false"
      width="60%"
    >
      <div class="app-add">
        <el-form
          ref="revoketemp"
          :rules="revoke.rules"
          :model="revoke.temp"
          label-position="right"
          label-width="150px"
          style="width: 80%; margin: 0 auto 50px"
        >
          <el-form-item label="撤销原因：" prop="revokeReason">
            <el-input
              ref="remark"
              v-model="revoke.temp.revokeReason"
              type="textarea"
              :autosize="{ minRows: 4, maxRows: 8 }"
              :rows="8"
              placeholder="请输入备注，最多200个字"
              maxlength="200"
              class="filter-item"
              style="width: 100%"
            />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button
            class="cancelClose"
            @click="
              revoke.dialogFormVisible = false;
              get_table_data();
            "
            >关闭</el-button
          >
          <el-button class="success" @click="form_revoke_save()"
            >确认</el-button
          >
        </div>
      </div>
    </el-dialog>

    <!-- 完成 -->
    <el-dialog
      title="确认是否完成"
      :visible.sync="complete.dialogFormVisible"
      :close-on-click-modal="false"
      width="40%"
      :before-close="dialog_complete_close"
    >
      <div class="app-add">
        <el-form
          ref="completetemp"
          :rules="complete.rules"
          :model="complete.temp"
          label-position="right"
          label-width="150px"
          style="width: 80%; margin: 0 auto 50px"
        >
          <el-form-item label="维修结果：" prop="repairResult">
            <el-select
              ref="repairResult"
              v-model="complete.temp.repairResult"
              placeholder="请选择"
              class="filter-item"
              style="width: 100%"
            >
              <el-option
                v-for="item in repairResultNameList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
          </el-form-item>

          <el-form-item label="快递名称：" prop="postName">
            <el-select
              ref="postName"
              v-model="complete.temp.postName"
              placeholder="请选择快递"
              class="filter-item"
              style="width: 100%"
              @change="change_post_status"
            >
              <el-option
                v-for="item in postNameList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
          </el-form-item>

          <el-form-item label="快递单号：" prop="postCode" v-if="postShow">
            <el-input
              ref="postCode"
              v-model="complete.temp.postCode"
              class="filter-item"
              style="width: 100%"
            />
          </el-form-item>

          <el-form-item label="款项状态：" prop="costStatus">
            <el-select
              ref="costStatus"
              v-model="complete.temp.costStatus"
              class="filter-item"
              style="width: 100%"
              @change="change_money_status"
              allow-create
            >
              <el-option
                v-for="item in moneyStatusList"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
          </el-form-item>

          <el-form-item label="服务费用：" prop="serviceCost" v-if="moneyShow">
            <el-input
              ref="serviceCost"
              v-model="complete.temp.serviceCost"
              class="filter-item"
              style="width: 95%"
            />元
          </el-form-item>

          <el-form-item label="支付时间：" prop="payDate" v-if="moneyShow">
            <el-date-picker
              v-model="complete.temp.payDate"
              type="date"
              placeholder="选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
              style="width: 100%"
              :clearable="false"
            />
          </el-form-item>

          <el-form-item label="服务总结：" prop="serviceSummary">
            <el-input
              ref="serviceSummary"
              v-model="complete.temp.serviceSummary"
              type="textarea"
              :autosize="{ minRows: 1.3, maxRows: 5 }"
              :rows="3"
              placeholder="请输入服务总结，最多255个字"
              maxlength="255"
              class="filter-item"
              style="width: 100%"
            />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button class="cancelClose" @click="dialog_complete_close()"
            >关闭</el-button
          >
          <el-button class="success" @click="form_complete_save()"
            >确认</el-button
          >
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  GetDataByName,
  PostDataByName,
  failproccess,
  ExecDataByConfig,
  GetDataByNames,
  checkButtons,
  calculativeWidth,
  wxpush,
} from "@/api/common";
import Cookies from "js-cookie";
import { parseTime, json2excel } from "@/utils/index.js";
import Pagination from "@/components/Pagination";
import { MessageBox } from "element-ui";

import ContractDetail from "@/componentView/ContractDetail.vue";

export default {
  name: "RepairService",
  components: { Pagination, ContractDetail },
  data() {
    return {
      myHeight: document.documentElement.clientHeight - 85 - 220,
      employeid: Cookies.get("employeid"),
      isRoleEdit: [],
      isRepairAdd: [],
      isRepairFeed: [],
      isRepairComplete: [],

      rowData: {},
      isHome: "",

      send_select_list: [
        { name: "getCustomerSelect", offset: 0, pagecount: 0, parammaps: {} },
        {
          name: "getDictListSelect1",
          offset: 0,
          pagecount: 0,
          parammaps: { pid: "54" },
        },
        { name: "getEmployeesSelect", offset: 0, pagecount: 0, parammaps: {} },
        {
          name: "getDictListSelect2",
          offset: 0,
          pagecount: 0,
          parammaps: { pid: "58" },
        },
        {
          name: "getDictListSelect3",
          offset: 0,
          pagecount: 0,
          parammaps: { pid: "59" },
        },

        {
          name: "getProductsEnable",
          offset: 0,
          pagecount: 0,
          parammaps: { enable: "1" },
        },
      ],

      // 下拉框 - 客户名称
      customerNameList: [
        // {id: 1425, name: "测试12"},
        // {id: 1423, name: "朝日牧场（唯品牧场）"},
        // {id: 1422, name: "富源牧业（眉山）有限公司（眉山富源）"}
      ],
      //  下拉框 - 集团
      groupNameList: [
        // {id: 253, name: "无"},
        // {id: 207, name: "星连星牧业"},
        // {id: 208, name: "海高牧业"},
        // {id: 254, name: "完达山"}
      ],
      // 下拉框 - 服务人员
      employeeNameList: [
        // {id: 18, name: "韩佳佳"},
        // {id: 19, name: "多秋阳"},
        // {id: 20, name: "张明星"},
      ],

      // 下拉框 - 服务状态
      statusNameList: [
        { name: "服务中", id: "服务中" },
        { name: "已完成", id: "已完成" },
        { name: "已撤销", id: "已撤销" },
        { name: "超时", id: "超时" },
      ],
      // 下拉框 - 维修结果
      repairResultNameList: [
        { name: "已修复", id: "已修复" },
        { name: "未修复", id: "未修复" },
      ],

      // 下拉框 - 维修类型
      repairTypeNameList: [
        { name: "电话回访维修", id: "电话回访维修" },
        { name: "邮寄公司维修", id: "邮寄公司维修" },
        { name: "上门维修", id: "上门维修" },
      ],
      // 下拉框 - 款项状态
      moneyNameList: [
        { name: "未收款", id: "未收款" },
        { name: "已收款", id: "已收款" },
        { name: "无需收款", id: "无需收款" },
      ],

      // 下拉框 - 款项状态
      moneyStatusList: [
        { name: "需要收款", id: "需要收款" },
        { name: "无需收款", id: "无需收款" },
      ],

      // 下拉框 - 快递名称
      postNameList: [
        { id: "无需快递", name: "无需快递" },
        { id: "中通快递", name: "中通快递" },
        { id: "申通快递", name: "申通快递" },
        { id: "圆通快递", name: "圆通快递" },
        { id: "顺丰快递", name: "顺丰快递" },
        { id: "韵达快递", name: "韵达快递" },
        { id: "德邦快递", name: "德邦快递" },
        { id: "京东快递", name: "京东快递" },
        { id: "其他快递", name: "其他快递" },
      ], //

      // statusNameList: [{ "name": "待备货", "id": "待备货" }, { "name": "已完成", "id": "已完成" }],
      // 下拉框 - 单据状态
      billStatusNameList: [
        { name: "正常", id: "正常" },
        { name: "已撤销", id: "已撤销" },
      ],
      //下拉框 - 订单来源
      sourceNameList: [
        { name: "订单输入", id: "订单输入" },
        { name: "网络输入", id: "网络输入" },
        { name: "销售输入", id: "销售输入" },
      ],
      //下拉框 - 备货原因
      reasonNameList: [
        { name: "购买", id: "购买" },
        { name: "维修", id: "维修" },
        { name: "更换", id: "更换" },
      ], //

      // 收件货品
      receProductNameList: [
        //  {"Specifications":"CC","categoryId":39,"categoryName":"铲车表","model":"套","price":"0.00","productsId":73,"productsName":"显示终端","remark":"质保期1年","sort":49},
        //  {"Specifications":"AWT15-0115","categoryId":40,"categoryName":"称重表","model":"套","price":"0.00","productsId":74,"productsName":"称重显示模组","remark":"质保期1年","sort":50},
        //  {"Specifications":"TMR","categoryId":38,"categoryName":"TMR表","model":"套","price":"0.00","productsId":76,"productsName":"新TMR表","remark":"","sort":1},
        //  {"Specifications":"CZB","categoryId":40,"categoryName":"称重表","model":"套","price":"0.00","productsId":77,"productsName":"称重表","remark":"","sort":1}
      ],

      //表格请求参数~~
      tableObj: {
        getdataListParm: {
          name: "getRepair",
          page: 1,
          offset: 1,
          pagecount: parseInt(Cookies.get("pagecount")),
          returntype: "Map",
          parammaps: {
            roleId: Cookies.get("g_roleId"),
            userId: Cookies.get("g_userId"),
            repairCode: "",
            customerId: "",
            customerName: "",
            groupId: "",
            statusName: "",
            employeeId: "",
            typeName: "",
            repairResult: "",
            costStatus: "",
            postCode: "",
            beginServiceCost: "",
            endServiceCost: "",

            inputDatetime1: "",
            inputDatetime2: "",
            inputDatetime3: "",
            inputDatetime4: "",

            beginServiceBeginDate: "",
            endServiceBeginDate: "",
            beginServiceSuccessDate: "",
            endServiceSuccessDate: "",
            beginPayDate: "",
            endPayDate: "",
            beginCollectDate: "",
            endCollectDate: "",
          },
        },
        tableKey: 0,
        list: [],
        total: 0,
        listLoading: true,
        temp: {},
      },

      tableSumMoney: 1000,

      download: {
        getdataListParm: {
          name: "getRepair",
          page: 1,
          offset: 1,
          pagecount: 0,
          returntype: "Map",
          parammaps: {
            roleId: Cookies.get("g_roleId"),
            userId: Cookies.get("g_userId"),
            repairCode: "",
            customerId: "",
            customerName: "",
            groupId: "",
            statusName: "",
            employeeId: "",
            typeName: "",
            repairResult: "",
            costStatus: "",
            postCode: "",
            beginServiceCost: "",
            endServiceCost: "",

            inputDatetime1: "",
            inputDatetime2: "",
            inputDatetime3: "",
            inputDatetime4: "",

            beginServiceBeginDate: "",
            endServiceBeginDate: "",
            beginServiceSuccessDate: "",
            endServiceSuccessDate: "",
            beginPayDate: "",
            endPayDate: "",
            beginCollectDate: "",
            endCollectDate: "",
          },
        },
        tableKey: 0,
        list: [],
        total: 0,
        listLoading: true,
        temp: {},
      },

      // 新增/编辑
      create: {
        dialogFormVisible: false,
        dialogStatus: "",
        temp: {
          customerId: "",
          groupId: "",
          groupName: "",
          sdate: parseTime(new Date(), "{y}-{m}-{d}"),
          reasonId: "",
          sourceId: "",
          remark: "",
          id: "",
          modifyName: "add",
          receiverChoose: "true",
          statusName: "",
          created: "",
          employeeName: "",
          successDate: "",
          contractCode: "",
          orderDate: "",
          reasonName: "",
          sourceName: "",
          postalId: "",
          postalName: "",
          planSendDate: "",
          proposal: "",
          processingResults: "",
          receiverTel: "",
          receiverName: "",
        },
        //备货单的请求
        stockTemp: {
          contractCode: "",
          customerId: "",
          orderDate: "",
          reasonName: "",
          sourceName: "",
          postalId: "",
          postalName: "",
          planSendDate: "",
          remark: "",
          createrId: "",
          sourceName: "",
          createSource: "2",
        },
        receiverList: [
          // {"name":1,"id":1},
          // {"name":2,"id":2},
        ],

        rules: {
          customerId: [{ required: true, message: "必填", trigger: "blur" }],
          //  groupId: [{ required: true, message: '必填', trigger: 'blur' }],
          typeName: [{ required: true, message: "必填", trigger: "blur" }],
          receiverName: [{ required: true, message: "必填", trigger: "blur" }],
          serviceBeginDate: [
            { required: true, message: "必填", trigger: "blur" },
          ],

          // reasonId: [{ required: true, message: '必填', trigger: 'blur' }],
          // visiterId: [{ required: true, message: '必填', trigger: 'blur' }]
        },
        // 客户名称
        getdataListParmCust: {
          name: "getCustomerByGroupId",
          returntype: "Map",
          parammaps: { groupId: "" },
        },
        customerNameList: [],
        // 关联接收快递名称 - 选中客户后加载
        getdataListParmPostal: {
          name: "getPostalsByCustomerId",
          page: 1,
          offset: 1,
          pagecount: 10,
          returntype: "Map",
          parammaps: { customerId: "" },
        },
        postalNameList: [], //关联接收快递名称

        // 关联快递下拉时调用 - 弹窗里的货品表格
        getdataListParmPostalGoods: {
          name: "getPostalGoodsById",
          page: 1,
          offset: 1,
          pagecount: 10,
          returntype: "Map",
          parammaps: { postalId: "" },
        },

        // 弹窗里的右上表单，仅编辑查看时调用
        getdataListParmStockTemp: {
          name: "getStockupById",
          page: 1,
          offset: 1,
          pagecount: 10,
          returntype: "Map",
          parammaps: { id: "" },
        },

        // 弹窗里的表格，仅编辑查看时调用
        getdataListParm4: {
          name: "getStockGoodsBySid",
          page: 1,
          offset: 1,
          pagecount: 10,
          returntype: "Map",
          parammaps: { id: "" },
        },
      },

      LastInsertId: "",
      textMap: {
        create: "新增",
        see: "查看",
        update: "编辑",
      },

      setDisabled: {
        disabledDate(time) {
          return time.getTime() > Date.now(); // 可选历史天、可选当前天、不可选未来天
          //return time.getTime() > Date.now() - 8.64e7;  // 可选历史天、不可选当前天、不可选未来天
          // return time.getTime() < Date.now() - 8.64e7;  // 不可选历史天、可选当前天、可选未来天
          // return time.getTime() < Date.now(); // 不可选历史天、不可选当前天、可选未来天
        },
      },

      // 管理
      contact: {
        dialogFormVisible: false,
        dialogStatus: "",
        temp: {
          id: "",
          contactName: "",
          telephone: "",
          address: "",
          remark: "",
        },
        rules: {},
        getdataListParm: {
          name: "getContacts",
          page: 1,
          offset: 1,
          pagecount: 10,
          returntype: "Map",
          parammaps: { customerId: "" },
        },
        tableKey: 0,
        list: [],
        total: 0,
        listLoading: false,
      },
      //备货表格
      tableStockList: [],

      // 完成
      complete: {
        dialogFormVisible: false,
        dialogStatus: "",
        temp: {
          repairResult: "已修复",
          postName: "无需快递",
          postCode: "",
          costStatus: "需要收款",
          serviceCost: "",
          payDate: "",
          serviceSummary: "",
          id: "",
        },
        rules: {
          // revokeReason: [{ required: true, message: '必填', trigger: 'blur' }],
        },
      },
      moneyShow: true,
      postShow: false,

      //获取反馈记录
      getFeedRecordParm: {
        name: "getRepairFeedbackById",
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: "Map",
        parammaps: { id: "" },
      },
      //保存反馈记录
      feedRecordTemp: {
        name: "insertRepairFeedback",
        page: 1,
        offset: 1,
        pagecount: 1000,
        returntype: "Map",
        parammaps: {
          repairId: "",
          createrId: "",
          remark: "",
        },
      },
      //反馈记录
      feedRecordList: [
        // {id:1, num: 1, txt: '主板缺失零件，疫情关系，无法采购，延期1天',   director:'epans', date:"2022-12-01"},
        // {id:1, num: 1, txt: '主板缺失零件，疫情关系，无法采购，延期1天',   director:'epans', date:"2022-12-01"},
        // {id:1, num: 1, txt: '主板缺失零件，疫情关系，无法采购，延期1天',   director:'epans', date:"2022-12-01"},
      ],

      // 撤销
      revoke: {
        dialogFormVisible: false,
        dialogStatus: "",
        temp: { revokeReason: "", id: "" },
        rules: {
          revokeReason: [{ required: true, message: "必填", trigger: "blur" }],
        },
      },

      autoWidth: 130,
      stockSumPrice: 0,
      requestParam: {},
      isokDisable: false,
      selectList: [],
      rowStyle: { maxHeight: 50 + "px", height: 45 + "px" },
      cellStyle: { padding: 0 + "px" },
    };
  },

  watch: {
    tableStockList: {
      deep: true,
      handler: function (item) {
        //计算总价格
        var sum = 0;
        this.tableStockList.forEach(function (i) {
          sum = parseInt(i.nums) * parseFloat(i.price) + sum;
        });
        this.stockSumPrice = sum;
      },
    },
  },

  created() {
    this.get_select_list();

    this.get_auto_buttons();

    var num = this.$route.params.num;
    console.log(num);
    if (num !== null && num !== "" && num !== undefined) {
      this.tableObj.getdataListParm.parammaps.repairCode = num;
    }

    var rowData = this.$route.params.rowData;
    var isHome = this.$route.params.isHome;
    var codeNum = this.$route.params.codeNum;

    console.log(
      "rowData",
      rowData,
      "======isHome",
      isHome,
      "======codeNum",
      codeNum
    );

    if (isHome == "home") {
      this.rowData = rowData;
      this.isHome = isHome;
      this.tableObj.getdataListParm.parammaps.repairCode = codeNum;
      this.get_table_data();
    } else {
      this.rowData = {};
      this.isHome = "";
      this.codeNum = "";

      this.get_table_data();
    }
  },

  methods: {
    //获取按钮权限
    get_auto_buttons() {
      const Edit = "RepairService";
      const isRoleEdit = checkButtons(
        JSON.parse(sessionStorage.getItem("buttons")),
        Edit
      );
      this.isRoleEdit = isRoleEdit;

      const RepairAdd = "business:repair:add";
      const isRepairAdd = checkButtons(
        this.$store.state.user.buttons,
        RepairAdd
      );
      this.isRepairAdd = isRepairAdd;

      const RepairFeed = "business:repair:feedback";
      const isRepairFeed = checkButtons(
        this.$store.state.user.buttons,
        RepairFeed
      );
      this.isRepairFeed = isRepairFeed;

      const RepairComplete = "business:repair:complete";
      const isRepairComplete = checkButtons(
        this.$store.state.user.buttons,
        RepairComplete
      );
      this.isRepairComplete = isRepairComplete;

      //操作的宽度
      // var widthCount = calculativeWidth(isRepairAdd,isRepairAdd,isRepairComplete,isRepairFeed)
      // this.autoWidth = widthCount
    },
    //获取所有下拉框的内容
    get_select_list() {
      GetDataByNames(this.send_select_list).then((response) => {
        this.create.customerNameList = response.data.getCustomerSelect.list;
        console.log("客户名称下拉框", this.create.customerNameList);
        this.groupNameList = response.data.getDictListSelect1.list;
        console.log("集团下拉框", this.groupNameList);
        this.employeeNameList = response.data.getEmployeesSelect.list;
        console.log("服务人员下拉框", this.employeeNameList);
        // this.reasonNameList = response.data.getDictListSelect2.list
        // console.log("备货原因下拉框", this.reasonNameList)
        // this.sourceNameList = response.data.getDictListSelect3.list
        // console.log("订单来源下拉框", this.sourceNameList)

        // response.data.getProductsEnable.list.map(function (i) {
        //   return (i.productsId = i.id)
        // })
        response.data.getProductsEnable.list.map(function (i) {
          return (i.customerId = "");
        });
        response.data.getProductsEnable.list.map(function (i) {
          return (i.nums = "");
        });
        response.data.getProductsEnable.list.map(function (i) {
          return (i.remark = "");
        });
        this.receProductNameList = response.data.getProductsEnable.list;
        console.log("收件货品下拉框", this.receProductNameList);
      });
    },
    //加载表格
    get_table_data() {
      var me = this;

      this.tableObj.listLoading = true;
      console.log(
        "this.tableObj.getdataListParm======>",
        this.tableObj.getdataListParm
      );
      GetDataByName(this.tableObj.getdataListParm).then((response) => {
        console.log("table数据======>", response.data.list);
        if (response.msg !== "fail") {
          if (response.data.list !== null) {
            this.tableObj.list = response.data.list;
            this.tableObj.pageNum = response.data.pageNum;
            this.tableObj.pageSize = response.data.pageSize;
            this.tableObj.total = response.data.total;

            //计算操作栏宽度
            var btnNum = 0;
            var arrList = response.data.list;
            arrList.forEach(function (row) {
              var itemBtnNum = 0;
              if (me.isRepairFeed && row.isFeedBack == "1") {
                itemBtnNum = itemBtnNum + 1;
              }
              if (me.isRepairAdd && row.isModify == "1") {
                itemBtnNum = itemBtnNum + 1;
              }
              if (me.isRepairAdd && row.isDel == "1") {
                itemBtnNum = itemBtnNum + 1;
              }
              if (me.isRepairComplete && row.isComplete == "1") {
                itemBtnNum = itemBtnNum + 1;
              }
              if (me.isRepairAdd && row.isRevoke == "1") {
                itemBtnNum = itemBtnNum + 1;
              }

              console.log(itemBtnNum);
              if (itemBtnNum > btnNum) {
                btnNum = itemBtnNum;
              }
            });
            console.log("btnNum=============", btnNum);
            me.autoWidth = btnNum * 90;
          } else {
            this.tableObj.list = [];
          }
        } else {
          this.$notify({
            title: "查询列表失败",
            message: response.data,
            type: "error",
            duration: 2000,
          });
        }
        setTimeout(() => {
          this.tableObj.listLoading = false;
        }, 100);
      });

      var send_price = {
        name: "getRepairOfPrice",
        parammaps: this.tableObj.getdataListParm.parammaps,
      };

      GetDataByName(send_price).then((response) => {
        console.log("table总价格数据======>", response);
        if (response.data.list !== null) {
          this.tableSumMoney = response.data.list[0].totlePrice;
        } else {
          this.tableSumMoney = "";
        }
      });
    },
    form_search() {
      console.log("点击了查询");

      if (
        this.tableObj.getdataListParm.parammaps.inputDatetime1 !== "" &&
        this.tableObj.getdataListParm.parammaps.inputDatetime1 !== null
      ) {
        this.tableObj.getdataListParm.parammaps.beginServiceBeginDate =
          parseTime(
            this.tableObj.getdataListParm.parammaps.inputDatetime1[0],
            "{y}-{m}-{d}"
          );
        this.tableObj.getdataListParm.parammaps.endServiceBeginDate = parseTime(
          this.tableObj.getdataListParm.parammaps.inputDatetime1[1],
          "{y}-{m}-{d}"
        );
      } else {
        this.tableObj.getdataListParm.parammaps.inputDatetime1 = "";
        this.tableObj.getdataListParm.parammaps.beginServiceBeginDate = "";
        this.tableObj.getdataListParm.parammaps.endServiceBeginDate = "";
      }

      if (
        this.tableObj.getdataListParm.parammaps.inputDatetime2 !== "" &&
        this.tableObj.getdataListParm.parammaps.inputDatetime2 !== null
      ) {
        this.tableObj.getdataListParm.parammaps.beginServiceSuccessDate =
          parseTime(
            this.tableObj.getdataListParm.parammaps.inputDatetime2[0],
            "{y}-{m}-{d}"
          );
        this.tableObj.getdataListParm.parammaps.endServiceSuccessDate =
          parseTime(
            this.tableObj.getdataListParm.parammaps.inputDatetime2[1],
            "{y}-{m}-{d}"
          );
      } else {
        this.tableObj.getdataListParm.parammaps.inputDatetime2 = "";
        this.tableObj.getdataListParm.parammaps.beginServiceSuccessDate = "";
        this.tableObj.getdataListParm.parammaps.endServiceSuccessDate = "";
      }

      if (
        this.tableObj.getdataListParm.parammaps.inputDatetime3 !== "" &&
        this.tableObj.getdataListParm.parammaps.inputDatetime3 !== null
      ) {
        this.tableObj.getdataListParm.parammaps.beginPayDate = parseTime(
          this.tableObj.getdataListParm.parammaps.inputDatetime3[0],
          "{y}-{m}-{d}"
        );
        this.tableObj.getdataListParm.parammaps.endPayDate = parseTime(
          this.tableObj.getdataListParm.parammaps.inputDatetime3[1],
          "{y}-{m}-{d}"
        );
      } else {
        this.tableObj.getdataListParm.parammaps.inputDatetime3 = "";
        this.tableObj.getdataListParm.parammaps.beginPayDate = "";
        this.tableObj.getdataListParm.parammaps.endPayDate = "";
      }

      if (
        this.tableObj.getdataListParm.parammaps.inputDatetime4 !== "" &&
        this.tableObj.getdataListParm.parammaps.inputDatetime4 !== null
      ) {
        this.tableObj.getdataListParm.parammaps.beginCollectDate = parseTime(
          this.tableObj.getdataListParm.parammaps.inputDatetime4[0],
          "{y}-{m}-{d}"
        );
        this.tableObj.getdataListParm.parammaps.endCollectDate = parseTime(
          this.tableObj.getdataListParm.parammaps.inputDatetime4[1],
          "{y}-{m}-{d}"
        );
      } else {
        this.tableObj.getdataListParm.parammaps.inputDatetime4 = "";
        this.tableObj.getdataListParm.parammaps.beginCollectDate = "";
        this.tableObj.getdataListParm.parammaps.endCollectDate = "";
      }
      this.tableObj.getdataListParm.offset = 1;
      this.get_table_data();
    },
    form_clear() {
      console.log("点击了重置");

      this.tableObj.getdataListParm.parammaps.customerName = "";
      this.tableObj.getdataListParm.parammaps.repairCode = "";
      this.tableObj.getdataListParm.parammaps.customerId = "";
      this.tableObj.getdataListParm.parammaps.groupId = "";
      this.tableObj.getdataListParm.parammaps.employeeId = "";
      this.tableObj.getdataListParm.parammaps.statusName = "";
      this.tableObj.getdataListParm.parammaps.typeName = "";
      this.tableObj.getdataListParm.parammaps.repairResult = "";
      this.tableObj.getdataListParm.parammaps.postCode = "";
      this.tableObj.getdataListParm.parammaps.costStatus = "";

      this.tableObj.getdataListParm.parammaps.beginServiceCost = "";
      this.tableObj.getdataListParm.parammaps.endServiceCost = "";

      this.tableObj.getdataListParm.parammaps.inputDatetime1 = "";
      this.tableObj.getdataListParm.parammaps.inputDatetime2 = "";
      this.tableObj.getdataListParm.parammaps.inputDatetime3 = "";
      this.tableObj.getdataListParm.parammaps.inputDatetime4 = "";

      this.tableObj.getdataListParm.parammaps.beginServiceBeginDate = "";
      this.tableObj.getdataListParm.parammaps.endServiceBeginDate = "";
      this.tableObj.getdataListParm.parammaps.beginServiceSuccessDate = "";
      this.tableObj.getdataListParm.parammaps.endServiceSuccessDate = "";
      this.tableObj.getdataListParm.parammaps.beginPayDate = "";
      this.tableObj.getdataListParm.parammaps.endPayDate = "";
      this.tableObj.getdataListParm.parammaps.beginCollectDate = "";
      this.tableObj.getdataListParm.parammaps.endCollectDate = "";
      this.tableObj.getdataListParm.offset = 1;
      this.get_table_data();
    },

    // 新增
    form_reset() {
      this.create.temp = {
        customerId: "",
        customerName: "",
        groupId: "",
        groupName: "",
        sdate: parseTime(new Date(), "{y}-{m}-{d}"),
        reasonId: "",
        sourceId: "",
        remark: "",
        id: "",
        modifyName: "add",
        receiverChoose: "true",
        statusName: "",
        created: "",
        employeeName: "",
        successDate: "",
        proposal: "",
        processingResults: "",
        receiverTel: "",
        receiverName: "",
      };

      this.create.stockTemp = {
        contractCode: "",
        customerId: "",
        orderDate: "",
        reasonName: "",
        sourceName: "",
        postalId: "",
        postalName: "",
        planSendDate: "",
        remark: "",
        createrId: "",
        sourceName: "",
        createSource: "2",
      };

      this.LastInsertId = "";
      this.tableStockList = [];
    },

    //客户失去焦点
    customer_search_blur(item) {
      console.log("客户失去焦点");
      this.tableObj.getdataListParm.parammaps.customerId = "";
      this.tableObj.getdataListParm.parammaps.customerName = "";
      this.customerNameList = [];
    },

    //模糊查询客户
    customer_search(queryString, cb) {
      console.log("模糊查询输入值", queryString);
      GetDataByName({
        name: "getCustomerNameFuzzy",
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: "Map",
        parammaps: { inputvalue: queryString },
      }).then((response) => {
        this.customerNameList = response.data.list;
        console.log("客户名称下拉框", response);
        cb(response.data.list);
      });
    },

    //模糊查询客户选择
    change_customer_select(item) {
      console.log("客户名称模糊查询选中值", item);
      this.tableObj.getdataListParm.parammaps.customerId = item.id;
      this.tableObj.getdataListParm.parammaps.customerName = item.name;
    },

    //清空客户选择
    clear_customer_select(item) {
      this.tableObj.getdataListParm.parammaps.customerId = "";
      this.tableObj.getdataListParm.parammaps.customerName = "";
      document.activeElement.blur();
    },

    //监听 - 集团
    change_group(item) {
      console.log(item);
      console.log(this.create.temp.groupId);
      this.create.temp.groupId = item;
      this.create.getdataListParmCust.parammaps.groupId = item;

      this.create.temp.customerName = "";
      this.create.temp.customerId = "";
      this.create.customerNameList = [];

      this.get_customer_list();
      this.$forceUpdate();
    },
    // 弹窗中的客户
    get_customer_list() {
      GetDataByName(this.create.getdataListParmCust).then((response) => {
        if (response.data.list !== null) {
          this.create.customerNameList = response.data.list;
          console.log("弹窗中的客户数据", response.data.list);
        } else {
          this.create.customerNameList = [];
        }
      });
    },

    //监听 - 下拉中客户名称
    change_customer(item) {
      console.log(item);
      this.create.temp.customerId = item;
      this.create.getdataListParmPostal.parammaps.customerId = item;
      this.get_postalNameList();
      this.get_groupName(item);

      this.get_receiverList(item);
    },

    // 获取集团名称
    get_groupName(customerId) {
      var me = this;
      var send_data = {
        name: "getgroupNameById",
        returntype: "Map",
        parammaps: { id: customerId },
      };
      GetDataByName(send_data).then((response) => {
        console.log(response);
        if (response.data.list !== null) {
          me.create.temp.groupName = response.data.list[0].groupName;
          me.create.temp.groupId = response.data.list[0].groupId;
        } else {
          me.create.temp.groupName = "";
          me.create.temp.groupId = "";
        }
      });
    },

    change_receiverName(item) {
      console.log(item);
      var findItem = this.receiverList.filter((items) => items.name == item);
      console.log(findItem);
      var receiverTel = findItem[0].telephone;
      console.log(receiverTel);

      this.create.temp.receiverTel = receiverTel;

      this.$forceUpdate();
    },

    // 获取联系人下拉
    get_receiverList(customerId) {
      var me = this;
      var send_data = {
        name: "getContacts",
        returntype: "Map",
        parammaps: { customerId: customerId },
      };
      GetDataByName(send_data).then((response) => {
        console.log(response);
        if (response.data.list !== null) {
          me.receiverList = response.data.list;
        } else {
          me.receiverList = [];
        }
      });
    },

    //获取 - 关联接收快递查询
    get_postalNameList() {
      GetDataByName(this.create.getdataListParmPostal).then((response) => {
        if (response.data.list !== null) {
          this.create.postalNameList = response.data.list;
          console.log("关联接收数据", response.data.list);
        } else {
          this.create.postalNameList = [];
        }
      });
    },

    //监听 - 下拉 - 维修类型
    change_repair(item) {
      console.log(item);

      // { "name": "电话回访维修", "id": "电话回访维修" },
      //   { "name": "邮寄公司维修", "id": "邮寄公司维修" },
      //   { "name": "上门维修", "id": "上门维修" }

      this.create.temp.typeName = item;

      if (item == "电话回访维修") {
        this.create.temp.processingResults = "";
        this.create.temp.proposal = "";
      } else if (item == "邮寄公司维修") {
        this.create.temp.proposal = "客户愿意维修";
      } else {
        this.create.temp.proposal = "先付款后维修";
      }
    },

    //下拉 - 快递
    change_postal(item) {
      console.log("关联接收快递ID ", item);
      this.create.getdataListParmPostalGoods.parammaps.postalId = item;

      var itemname = "";
      var contactName = "";
      var receiverTel = "";
      var remark = "";

      this.create.postalNameList.forEach(function (i) {
        if (item == i.id) {
          itemname = i.postCode;
          contactName = i.contactName;
          receiverTel = i.telephone;
          remark = i.remark;
        }
      });

      this.create.temp.receiverName = contactName;
      this.create.temp.receiverTel = receiverTel;

      // this.create.stockTemp.remark = remark

      this.create.stockTemp.postalId = item;
      this.create.stockTemp.postalName = itemname;
      this.tableStockList = [];
      this.getReceProduct();
    },

    //下拉 - 备货品
    change_receProduct(item) {
      console.log("备货品ID ", item);
      var index = this.receProductNameList.findIndex(
        (obj) => obj.productsId == item
      );
      console.log("备货品index ", index);
      var ifHasId = this.tableStockList.findIndex(
        (obj) => obj.productsId == item
      );
      console.log("备货品是否存在列表 ", ifHasId);

      var addRow = Object.assign({}, this.receProductNameList[index]);
      addRow.nums = 1;
      addRow.remark = "";
      if (ifHasId == "-1") {
        this.tableStockList.unshift(addRow);
      }
    },
    //小表格中的删除
    form_delete2(row) {
      console.log("小表格中的删除", row);
      var index = this.tableStockList.findIndex((obj) => obj.id == row.id);
      this.tableStockList.splice(index, 1);
    },

    //新增
    form_add() {
      console.log("点击了新增");
      this.form_reset();

      this.create.temp.employeeId = Cookies.get("g_userId");
      this.create.temp.employeeName = Cookies.get("g_empname");

      this.create.dialogStatus = "create";
      this.create.dialogFormVisible = true;
    },
    //新增保存
    add_dialog_save() {
      console.log("点击了新增保存", this.create.temp);
      this.isokDisable = true;
      setTimeout(() => {
        this.isokDisable = false;
      }, 1000);
      this.$refs["temp"].validate((valid) => {
        if (valid) {
          this.isokDisable = true;
          setTimeout(() => {
            this.isokDisable = false;
          }, 1000);

          var customerId = this.create.temp.customerId;
          var groupId = this.create.temp.groupId;
          this.tableStockList.map(function (i) {
            return (i.customerId = customerId);
          });
          this.tableStockList.map(function (i) {
            return (i.postalId = "");
          });

          this.create.stockTemp.createrId = Cookies.get("employeid");
          this.create.stockTemp.customerId = customerId;

          this.create.stockTemp.groupId = groupId;
          this.create.temp.createrId = Cookies.get("employeid");
          this.create.temp.stockupId = "@insertStockup.LastInsertId";

          console.log("点击了新增保存", this.create.temp);
          console.log("点击了新增保存", this.tableStockList);

          if (
            this.create.stockTemp.remark == "" ||
            this.create.stockTemp.remark == null
          ) {
            this.$notify({
              title: "保存失败！",
              message: "请输入备货单的备注内容！",
              type: "warning",
              duration: 2000,
            });
            return false;
          }

          var send_data = {
            common: { returnmap: "0" },
            data: [
              {
                name: "insertStockup",
                type: "e",
                parammaps: this.create.stockTemp,
              },
              {
                name: "insertStockupGoods",

                resultmaps: {
                  list: this.tableStockList,
                },
                children: [
                  {
                    name: "insertStockupGoods",
                    type: "e",
                    parammaps: {
                      productsId: "@insertStockupGoods.productsId",
                      nums: "@insertStockupGoods.nums",
                      remark: "@insertStockupGoods.remark",
                      customerId: "@insertStockupGoods.customerId",
                      stockupId: "@insertStockup.LastInsertId",
                    },
                  },
                ],
              },
              {
                name: "insertRepair",
                type: "e",
                parammaps: this.create.temp,
              },
              {
                name: "refreshRepairOfStockupId",
                type: "e",
                parammaps: {
                  stockupId: "@insertStockup.LastInsertId",
                  id: "@insertRepair.LastInsertId",
                },
              },

              {
                name: "insertContactsOfService",
                type: "e",
                parammaps: {
                  customerId: this.create.temp.customerId,
                  contactName: this.create.temp.receiverName,
                  telephone: this.create.temp.receiverTel,
                },
              },
            ],
          };

          var isEmpty = this.tableStockList.find((i) => i.nums == "");
          if (isEmpty) {
            this.$message({
              type: "error",
              message: "货品数量不可为空",
              duration: 2000,
            });
          } else {
            ExecDataByConfig(send_data).then((response) => {
              console.log("新增保存发送参数", send_data);
              if (response.msg !== "fail") {
                this.$notify({
                  title: "成功",
                  message: "保存成功",
                  type: "success",
                  duration: 2000,
                });
                this.create.dialogFormVisible = false;
                this.get_table_data();

                var rowId = response.data[2].resultmaps.LastInsertId;
                this.get_wxPush(39, "维修服务", rowId);
              } else {
                this.$notify({
                  title: "失败",
                  message: "保存失败" + response.data,
                  type: "error",
                  duration: 2000,
                });
              }
            });
          }
        }
      });
    },

    //微信推送
    get_wxPush(remindId, remindTypeName, rowId) {
      var send_weixin_data1 = {
        name: "getRemindData",
        parammaps: {
          userId: Cookies.get("g_userId"),
          remindId: remindId,
          remindTypeName: remindTypeName,
          rowId: rowId,
        },
      };

      GetDataByName(send_weixin_data1).then((response) => {
        console.log("微信推送(获取参数)======>", response);
        if (response.data.message == "ok") {
          var receiverStr = response.data.list[0].receivers;
          var receiverArr = receiverStr.split(",");
          var value1 = response.data.list[0].value1;
          var value2 = response.data.list[0].value2;
          var value3 = response.data.list[0].value3;
          var value4 = response.data.list[0].value4;
          var send_weixin_data2 = {
            target: receiverArr,
            serviceId: remindId,
            content: [
              { color: "#173177", value: value1 },
              { color: "#173177", value: value2 },
              { color: "#173177", value: value3 },
              { color: "#173177", value: value4 },
            ],
          };

          wxpush(send_weixin_data2).then((response) => {
            console.log("微信推送(获取参数)======>", response);
          });
          // this.tableSumMoney = response.data.list[0].totlePrice
        } else {
          // this.$notify({ title: '失败', message: '消息推送失败', type: 'error', duration: 2000 })
        }
      });
    },

    // 查看
    form_see(row) {
      this.form_reset();
      this.create.temp = Object.assign({}, row);
      console.log("点击了查看", row);

      // this.create.getdataListParmCust.parammaps.groupId = row.groupId
      // this.get_customer_list()

      this.create.getdataListParmPostal.parammaps.customerId = row.customerId;
      // this.create.temp.barname = this.houseNameList.find(obj => obj.id === item).bname
      this.get_postalNameList();
      this.create.getdataListParm4.parammaps.id = row.stockupId;
      this.getReceProduct2();

      this.create.getdataListParmStockTemp.parammaps.id = row.stockupId;
      this.get_stockTemp();

      this.reset_feedRecord();

      this.getFeedRecordParm.parammaps.id = row.id;
      this.feedRecordTemp.parammaps.repairId = row.id;
      this.get_feedRecord();

      this.create.dialogStatus = "see";
      this.create.dialogFormVisible = true;
    },

    // 查看中的反馈记录
    get_feedRecord() {
      GetDataByName(this.getFeedRecordParm).then((response) => {
        console.log("查看中的反馈记录", response.data.list);
        if (response.data.list !== null) {
          this.feedRecordList = response.data.list;
        } else {
          this.feedRecordList = [];
        }
      });
    },

    // 反馈 - 重置.
    reset_feedRecord() {
      this.feedRecordList = [];
      this.feedRecordTemp.parammaps.repairId = "";
      this.feedRecordTemp.parammaps.createrId = "";
      this.feedRecordTemp.parammaps.remark = "";
    },

    // 编辑
    form_edit(row) {
      this.form_reset();
      console.log("点击了编辑", row);

      this.create.temp = Object.assign({}, row);
      this.create.temp.id = row.id;

      // this.create.getdataListParmCust.parammaps.groupId = row.groupId
      // this.get_customer_list()

      this.create.getdataListParmPostal.parammaps.customerId = row.customerId;
      this.get_postalNameList();

      this.create.getdataListParm4.parammaps.id = row.stockupId;
      this.getReceProduct2();

      this.create.getdataListParmStockTemp.parammaps.id = row.stockupId;
      this.get_stockTemp();

      //加载联系人下拉
      this.get_receiverList(row.customerId);

      this.create.temp.employeeId = Cookies.get("g_userId");
      this.create.temp.employeeName = Cookies.get("g_empname");

      this.create.dialogStatus = "update";
      this.create.dialogFormVisible = true;
    },

    // 查看和编辑中的小表格
    getReceProduct() {
      GetDataByName(this.create.getdataListParmPostalGoods).then((response) => {
        console.log("查看和编辑中的小表格", response.data.list);
        if (response.data.list !== null) {
          this.tableStockList = response.data.list;
        }
      });
    },

    // 查看和编辑中的小表格
    getReceProduct2() {
      GetDataByName(this.create.getdataListParm4).then((response) => {
        console.log("查看和编辑中的小表格", response.data.list);
        if (response.data.list !== null) {
          this.tableStockList = response.data.list;
        }
      });
    },

    // 弹窗的右上表单 - 编辑和查看时
    get_stockTemp() {
      GetDataByName(this.create.getdataListParmStockTemp).then((response) => {
        console.log("弹窗的右上表单", response.data.list);
        if (response.data.list !== null) {
          this.create.stockTemp = response.data.list[0];
        }
      });
    },

    // 反馈记录 - 保存
    feedRecord_save() {
      if (
        this.feedRecordTemp.parammaps.remark == "" ||
        this.feedRecordTemp.parammaps.remark == null
      ) {
        this.$notify({
          title: "反馈失败！",
          message: "请输入反馈内容！",
          type: "warning",
          duration: 2000,
        });
      } else {
        this.feedRecordTemp.parammaps.createrId = Cookies.get("employeid");
        PostDataByName(this.feedRecordTemp).then((response) => {
          if (response.msg === "fail") {
            this.$notify({
              title: "反馈失败",
              message: response.data,
              type: "warning",
              duration: 2000,
            });
          } else {
            this.$notify({
              title: "反馈成功",
              message: "反馈成功",
              type: "success",
              duration: 2000,
            });

            // this.create.dialogFormVisible = false
            // this.get_table_data()

            this.get_feedRecord();
            this.feedRecordTemp.parammaps.remark = "";
            this.$forceUpdate();

            var rowId = this.getFeedRecordParm.parammaps.id;
            this.get_wxPush(40, "维修服务", rowId);
          }
        });
      }
    },

    // 编辑保存
    form_edit_save() {
      this.isokDisable = true;
      setTimeout(() => {
        this.isokDisable = false;
      }, 1000);
      this.$refs["temp"].validate((valid) => {
        if (valid) {
          this.isokDisable = true;
          setTimeout(() => {
            this.isokDisable = false;
          }, 1000);

          var customerId = this.create.temp.customerId;
          this.tableStockList.map(function (i) {
            return (i.customerId = customerId);
          });
          this.tableStockList.map(function (i) {
            return (i.postalId = "");
          });

          this.create.stockTemp.createrId = Cookies.get("employeid");
          this.create.stockTemp.customerId = customerId;
          this.create.temp.createrId = Cookies.get("employeid");

          console.log("点击了编辑保存", this.create.temp);
          console.log("点击了编辑保存", this.tableStockList);

          var stockupId = this.create.temp.stockupId;
          this.tableStockList.forEach(function (item) {
            item.stockupId = stockupId;
          });

          if (
            this.create.stockTemp.remark == "" ||
            this.create.stockTemp.remark == null
          ) {
            this.$notify({
              title: "保存失败！",
              message: "请输入备货单的备注内容！",
              type: "warning",
              duration: 2000,
            });
            return false;
          }

          var send_data = {
            common: { returnmap: "0" },
            data: [
              {
                name: "updateRepair",
                type: "e",
                parammaps: this.create.temp,
              },
              {
                name: "updateStockup",
                type: "e",
                parammaps: this.create.stockTemp,
              },
              {
                name: "delStockupGoods",
                type: "e",
                parammaps: {
                  stockupId: this.create.temp.stockupId,
                },
              },
              {
                name: "insertStockupGoods",
                resultmaps: {
                  list: this.tableStockList,
                },
                children: [
                  {
                    name: "insertStockupGoods",
                    type: "e",
                    parammaps: {
                      stockupId: "@insertStockupGoods.stockupId",
                      productsId: "@insertStockupGoods.productsId",
                      nums: "@insertStockupGoods.nums",
                      remark: "@insertStockupGoods.remark",
                      customerId: "@insertStockupGoods.customerId",
                    },
                  },
                ],
              },

              {
                name: "insertContactsOfService",
                type: "e",
                parammaps: {
                  customerId: this.create.temp.customerId,
                  contactName: this.create.temp.receiverName,
                  telephone: this.create.temp.receiverTel,
                },
              },
            ],
          };

          var isEmpty = this.tableStockList.find((i) => i.nums == "");
          if (isEmpty) {
            this.$message({
              type: "error",
              message: "货品数量不可为空",
              duration: 2000,
            });
          } else {
            ExecDataByConfig(send_data).then((response) => {
              console.log("新增保存发送参数", send_data);
              if (response.msg !== "fail") {
                this.$notify({
                  title: "成功",
                  message: "保存成功",
                  type: "success",
                  duration: 2000,
                });
                this.create.dialogFormVisible = false;
                this.get_table_data();

                var rowId = this.create.temp.id;
                this.get_wxPush(39, "维修服务", rowId);
              } else {
                this.$notify({
                  title: "失败",
                  message: "保存失败" + response.data,
                  type: "error",
                  duration: 2000,
                });
              }
            });
          }
        }
      });
    },

    // 删除
    form_delete(row) {
      MessageBox.confirm("是否确认删除此信息?", {
        confirmButtonText: "确认",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          var send_data = {
            name: "delRepair",
            parammaps: {
              id: row.id,
            },
          };

          PostDataByName(send_data).then((response) => {
            if (response.msg === "fail") {
              this.$notify({
                title: "删除失败",
                message: response.data,
                type: "warning",
                duration: 2000,
              });
            } else {
              this.$notify({
                title: "成功",
                message: "删除成功",
                type: "success",
                duration: 2000,
              });
              this.get_table_data();
            }
          });
        })
        .catch(() => {
          this.$message({ type: "info", message: "已取消删除" });
        });
    },

    // 完成
    form_complete(row) {
      console.log("点击了完成", row);
      this.reset_complete();

      this.complete.temp.id = row.id;
      this.complete.temp.remark = row.remark;
      this.complete.temp.serviceSummary = row.stockRemark;

      this.complete.dialogFormVisible = true;
    },
    // 完成 - 重置
    reset_complete() {
      this.complete.temp.repairResult = "已修复";
      this.complete.temp.postName = "无需快递";
      this.complete.temp.postCode = "";
      this.complete.temp.costStatus = "需要收款";
      this.complete.temp.serviceCost = "";
      this.complete.temp.payDate = "";
      this.complete.temp.serviceSummary = "";
      this.complete.temp.id = "";

      this.moneyShow = true;

      this.postShow = false;
    },

    // 完成 - 确认
    form_complete_save() {
      this.$refs["completetemp"].validate((valid) => {
        if (valid) {
          var send_data = {
            name: "completeRepair",
            parammaps: this.complete.temp,
          };

          var isCost = false;
          if (this.complete.temp.costStatus == "需要收款") {
            if (this.complete.temp.serviceCost == "") {
              isCost = true;
            } else {
              isCost = false;
            }
          } else {
            isCost = false;
          }

          if (isCost) {
            this.$notify({
              title: "失败",
              message: "需要收款时必须填写服务费用！",
              type: "error",
              duration: 2000,
            });
          } else {
            PostDataByName(send_data).then((response) => {
              console.log("完成发送参数", this.requestParam);
              if (response.msg !== "fail") {
                this.$notify({
                  title: "成功",
                  message: "完成成功",
                  type: "success",
                  duration: 2000,
                });
                this.complete.dialogFormVisible = false;
                this.create.dialogFormVisible = false;

                var rowId = this.complete.temp.id;
                this.get_wxPush(43, "维修服务", rowId);

                this.get_table_data();
                if (this.isHome == "home") {
                  // 返回首页
                  this.$router.push({
                    name: "Dashboard",
                    params: { isTodo: "repair" },
                  });
                }
              } else {
                this.$notify({
                  title: "失败",
                  message: "完成失败" + response.data,
                  type: "error",
                  duration: 2000,
                });
              }
            });
          }
        }
      });
    },

    // 完成 - 款项 - 下拉
    change_money_status(item) {
      console.log(item);
      if (item == "需要收款") {
        this.moneyShow = true;
      } else {
        this.moneyShow = false;
      }
    },

    // 完成 - 快递 - 下拉
    change_post_status(item) {
      console.log(item);
      if (item == "无需快递") {
        this.postShow = false;
      } else {
        this.postShow = true;
      }
    },

    // 撤销
    form_revoke(row) {
      console.log("点击了撤销", row);
      this.reset_revoke();

      this.revoke.temp.id = row.id;
      this.revoke.dialogFormVisible = true;
    },
    // 撤销 - 重置
    reset_revoke() {
      this.revoke.temp.revokeReason = "";
    },

    // 撤销 - 确认
    form_revoke_save() {
      this.$refs["revoketemp"].validate((valid) => {
        if (valid) {
          var send_data = {
            name: "revokeRepair",
            parammaps: this.revoke.temp,
          };

          this.$confirm("是否撤销该条记录?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
            .then(() => {
              PostDataByName(send_data).then((response) => {
                console.log("撤销发送参数", send_data);
                if (response.msg !== "fail") {
                  this.$notify({
                    title: "成功",
                    message: "撤销成功",
                    type: "success",
                    duration: 2000,
                  });
                  this.revoke.dialogFormVisible = false;
                  this.get_table_data();

                  var rowId = this.revoke.temp.id;
                  this.get_wxPush(42, "维修服务", rowId);
                } else {
                  this.$notify({
                    title: "失败",
                    message: "撤销失败" + response.data,
                    type: "error",
                    duration: 2000,
                  });
                }
              });
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "已取消删除",
              });
            });
        }
      });
    },

    dialog_complete_close() {
      this.complete.dialogFormVisible = false;
      this.get_table_data();
      if (this.isHome == "home") {
        // 返回首页
        this.$router.push({ name: "Dashboard", params: { isTodo: "repair" } });
      }
    },

    // 导出
    form_export(item) {
      this.download.getdataListParm.parammaps =
        this.tableObj.getdataListParm.parammaps;

      GetDataByName(this.download.getdataListParm).then((response) => {
        if (response.data.list !== null) {
          this.download.list = response.data.list;
        } else {
          this.download.list = [];
        }
        var excelDatas = [
          {
            tHeader: [
              "序号",
              "维修服务编号",
              "服务状态",
              "客户名称",
              "客户集团",
              "维修类型",
              "沟通结果",
              "快递单号",
              "款项状态",
              "服务费用",
              "支付时间",
              "收款时间",
              "服务开始时间",
              "服务完成时间",
              "服务人员",
              "问题详情",
              "备注",
              "服务总结",
              "录入日期",
            ],
            filterVal: [
              "sort",
              "repairCode",
              "statusName",
              "customerName",
              "groupName",
              "typeName",
              "proposal",
              "postCode",
              "costStatus",
              "serviceCost",
              "payDate",
              "collectDate",
              "serviceBeginDate",
              "serviceSuccessDate",
              "employeeName",
              "problem",
              "remark",
              "serviceSummary",
              "createrDate",
            ],
            tableDatas: this.download.list,
            sheetName: "Sheet1",
          },
        ];
        json2excel(excelDatas, "维修服务", true, "xlsx");
      });
    },

    // 导入
    form_inport() {
      console.log("点击了导入");
    },
  },
};
</script>
<style lang="scss" scoped>
.search {
  padding-top: 10px;
  clear: both;
}
.table {
  margin-top: 10px;
}

/deep/ .el-input.is-disabled .el-input__inner {
  color: #000000 !important;
}
/deep/ .el-textarea.is-disabled .el-textarea__inner {
  color: #000000 !important;
}
/deep/ .el-radio__input.is-disabled + span.el-radio__label {
  color: #000000 !important;
}
/deep/ .el-checkbox__input.is-disabled + span.el-checkbox__label {
  color: #000000 !important;
}
</style>
