<template>
  <div class="app-container">
    <div class="search-bx">
      <div class="search">
        <el-row :gutter="0">
          <el-input
            v-model="tableObj.getdataListParm.parammaps.reimbursementCode"
            placeholder="报销申请编号"
            class="filter-item"
            style="width: 120px"
          />

          <el-select
            v-model="tableObj.getdataListParm.parammaps.employeeId"
            placeholder="申报人"
            class="filter-item"
            style="width: 120px"
            clearable
            filterable
          >
            <el-option
              v-for="item in empNameList"
              :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.inputDatetime1"
            class="inputDatetime filter-item"
            type="daterange"
            range-separator="至"
            start-placeholder="申报时间"
            end-placeholder="申报时间"
            style="width: 250px"
          />

          <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.declareTypeName"
            placeholder="申报类型"
            class="filter-item"
            style="width: 120px"
            clearable
          >
            <el-option
              v-for="item in declareTypeList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select>

          <el-input
            v-model="tableObj.getdataListParm.parammaps.postCode"
            placeholder="寄送发票快递单号"
            class="filter-item"
            style="width: 120px"
          />

          <el-button class="successBorder" @click="form_search">查询</el-button>
          <el-button class="successBorder" @click="form_clear">重置</el-button>
        </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
          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="110px"
          align="center"
          fixed="left"
        >
          <template slot-scope="scope">
            <span
              style="color: #409eff; cursor: pointer"
              @click="form_see(scope.row)"
              >{{ scope.row.reimbursementCode }}</span
            >
          </template>
        </el-table-column>
        <el-table-column
          label="申请单状态"
          min-width="110px"
          align="center"
          fixed="left"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.statusName }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="申报人"
          min-width="90px"
          align="center"
          fixed="left"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.employeeName }}</span>
          </template>
        </el-table-column>

        <el-table-column
          label="申报类型"
          min-width="110px"
          align="center"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <span>{{ scope.row.declareTypeName }}</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.declareDate }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="申报原因"
          min-width="110px"
          align="center"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <span>{{ scope.row.declareReason }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="发票照片"
          min-width="110px"
          align="center"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <span
              style="color: #409eff; cursor: pointer"
              @click="form_see_nums(scope.row)"
              >查看</span
            >
          </template>
        </el-table-column>

        <el-table-column
          label="寄送发票快递单号"
          min-width="140px"
          align="center"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <span>{{ scope.row.postData }}</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="操作"
          align="center"
          :width="autoWidth"
          v-if="autoWidth !== 0"
          class-name="small-padding fixed-width"
          fixed="right"
        >
          <template slot-scope="{ row }">
            <el-button
              class="miniSuccess"
              @click="form_adopt(row)"
              v-if="roleSet(row)"
              >通过</el-button
            >

            <el-button
              class="miniDanger"
              @click="form_reject(row)"
              v-if="roleSet(row)"
              >驳回</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <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%"
      :before-close="dialog_close"
    >
      <div class="app-add">
        <el-form
          ref="tempTableForm"
          :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="declareTypeLength">
              <el-form-item label="报销人：" prop="employeeName">
                <el-input
                  ref="employeeName"
                  v-model="create.temp.employeeName"
                  class="filter-item"
                  style="width: 100%"
                  disabled
                />
              </el-form-item>

              <el-form-item label="申报类型：" prop="declareTypeName">
                <el-select
                  ref="declareTypeName"
                  v-model="create.temp.declareTypeName"
                  placeholder=" "
                  class="filter-item"
                  style="width: 100%"
                  filterable
                  :disabled="create.dialogStatus == 'see'"
                >
                  <el-option
                    v-for="(item, index) in declareTypeList"
                    :key="index"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>

              <el-form-item label="申报金额：" prop="serviceCost">
                <el-input
                  ref="serviceCost"
                  v-model="create.temp.serviceCost"
                  class="filter-item"
                  style="width: 100%"
                  disabled
                />
              </el-form-item>

              <el-form-item label="寄送发票快递名称：" prop="postName">
                <el-input
                  ref="postName"
                  v-model="create.temp.postName"
                  class="filter-item"
                  style="width: 100%"
                  maxlength="11"
                  placeholder=" "
                  disabled
                />
              </el-form-item>

              <el-form-item label="寄送发票快递单号：" prop="postCode">
                <el-input
                  ref="postCode"
                  v-model="create.temp.postCode"
                  class="filter-item"
                  style="width: 100%"
                  maxlength="11"
                  placeholder=" "
                  disabled
                />
              </el-form-item>

              <el-form-item label="申报原因：" prop="declareReason">
                <el-input
                  ref="declareReason"
                  v-model="create.temp.declareReason"
                  type="textarea"
                  :autosize="{ minRows: 4, maxRows: 8 }"
                  :rows="8"
                  placeholder=" "
                  maxlength="200"
                  class="filter-item"
                  style="width: 100%"
                  disabled
                />
              </el-form-item>

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

              <el-form-item label="发票照片：" prop="scenePhoto1">
                <el-upload
                  id="uploadPic"
                  list-type="picture-card"
                  class="uploadPic"
                  :action="uploadImageUrl"
                  :limit="9"
                  :headers="headers"
                  :file-list="fileList"
                  :on-preview="handlePicPreview"
                  :auto-upload="true"
                  :on-change="
                    (file, fileList) => {
                      return handlePicChange(file, fileList);
                    }
                  "
                  :on-success="
                    (response, file, fileList) => {
                      return handlePicSuccess(response, file, fileList);
                    }
                  "
                  :on-remove="
                    (file, fileList) => {
                      return handlePicRemove(file, fileList);
                    }
                  "
                >
                  <!-- <i slot="default" class="el-icon-plus"></i> -->
                </el-upload>
                <el-dialog
                  :visible.sync="dialogVisible"
                  append-to-body
                  width="40%"
                >
                  <img width="80%" :src="dialogImageUrl" alt="" />
                </el-dialog>
              </el-form-item>
            </el-col>

            <el-col :span="16" v-show="declareType == 1">
              <h3>报销清单</h3>

              <el-row>
                <el-col :span="8">
                  <el-form-item label="申报人：" prop="employeeName">
                    <el-input v-model="create.temp.employeeName" disabled />
                  </el-form-item>
                </el-col>

                <el-col :span="8">
                  <el-form-item label="时间：" prop="billDate">
                    <el-date-picker
                      v-model="create.temp.billDate"
                      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-col :span="8">
                  <el-form-item label="金额：" prop="vdate">
                    <el-input v-model="sumPriceAll1" disabled />
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row>
                <el-table
                  key="0"
                  :data="tableTravelList"
                  border
                  fit
                  highlight-current-row
                  style="width: 100%"
                  :row-style="rowStyle"
                  :cell-style="cellStyle"
                  class="elTable table-fixed"
                  show-summary
                  :summary-method="getSummaries1"
                >
                  <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.businessDate }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="出差地"
                    min-width="110px"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <span>{{ scope.row.businessAdress }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="拜见人"
                    min-width="110px"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <span>{{ scope.row.clienter }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="差旅费"
                    min-width="110px"
                    align="center"
                  >
                    <el-table-column
                      label="交通费"
                      min-width="110px"
                      align="center"
                      prop="toll"
                    >
                      <template slot-scope="scope">
                        <span>{{ scope.row.toll }}</span>
                      </template>
                    </el-table-column>
                    <el-table-column
                      label="油费"
                      min-width="110px"
                      align="center"
                      prop="oilCost"
                    >
                      <template slot-scope="scope">
                        <span>{{ scope.row.oilCost }}</span>
                      </template>
                    </el-table-column>
                    <el-table-column
                      label="住宿费"
                      min-width="110px"
                      align="center"
                      prop="hotelCost"
                    >
                      <template slot-scope="scope">
                        <span>{{ scope.row.hotelCost }}</span>
                      </template>
                    </el-table-column>
                  </el-table-column>
                  <el-table-column
                    label="业务招待费"
                    min-width="110px"
                    align="center"
                    prop="serviceCost"
                  >
                    <template slot-scope="scope">
                      <span>{{ scope.row.serviceCost }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="其他费用"
                    min-width="110px"
                    align="center"
                    prop="otherCost"
                  >
                    <template slot-scope="scope">
                      <span>{{ scope.row.otherCost }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="合计"
                    min-width="110px"
                    align="center"
                    prop="sumPrice"
                  >
                    <template slot-scope="scope">
                      <span> {{ scope.row.sumPrice }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="出差单号"
                    min-width="110px"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <span>{{ scope.row.travelCode }}</span>
                    </template>
                  </el-table-column>
                </el-table>
              </el-row>
            </el-col>

            <el-col :span="16" v-show="declareType == 2">
              <h3>报销清单</h3>

              <el-row>
                <el-col :span="8">
                  <el-form-item label="申报人：" prop="employeeName">
                    <el-input v-model="create.temp.employeeName" disabled />
                  </el-form-item>
                </el-col>

                <el-col :span="8">
                  <el-form-item label="时间：" prop="billDate">
                    <el-date-picker
                      v-model="create.temp.billDate"
                      type="date"
                      placeholder=" "
                      format="yyyy-MM-dd"
                      value-format="yyyy-MM-dd"
                      style="width: 100%"
                      :clearable="false"
                      disabled
                    />
                  </el-form-item>
                </el-col>

                <el-col :span="8">
                  <el-form-item label="合计金额：" prop="vdate">
                    <el-input v-model="sumPriceAll2" disabled />
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row>
                <el-table
                  key="0"
                  :data="tableBuyList"
                  border
                  fit
                  highlight-current-row
                  style="width: 100%"
                  :row-style="rowStyle"
                  :cell-style="cellStyle"
                  class="elTable table-fixed"
                  show-summary
                  :summary-method="getSummaries2"
                >
                  <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.goodsType }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="名称"
                    min-width="110px"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <span>{{ scope.row.goodsName }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="购买日期"
                    min-width="110px"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <span>{{ scope.row.purchaseDate }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="数量"
                    min-width="110px"
                    align="center"
                    prop="goodsNum"
                  >
                    <template slot-scope="scope">
                      <span>{{ scope.row.goodsNum }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="单位名称"
                    min-width="110px"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <span>{{ scope.row.company }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="单价"
                    min-width="110px"
                    align="center"
                    prop="goodsPrice"
                  >
                    <template slot-scope="scope">
                      <span>{{ scope.row.goodsPrice }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="合计"
                    min-width="110px"
                    align="center"
                    prop="sumPrice"
                  >
                    <template slot-scope="scope">
                      <span> {{ scope.row.sumPrice }}</span>
                    </template>
                  </el-table-column>
                </el-table>
              </el-row>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button
            class="success"
            v-if="roleSet(create.temp)"
            @click="form_adopt(create.temp)"
            >审核通过</el-button
          >
          <el-button
            class="success"
            v-if="roleSet(create.temp)"
            @click="form_reject(create.temp)"
            >驳回</el-button
          >
          <el-button class="cancelClose" @click="dialog_close()"
            >关闭</el-button
          >
        </div>
      </div>
    </el-dialog>

    <!-- 查看/反馈 -->
    <el-dialog
      title="发票详情"
      :visible.sync="createSeeNums.dialogFormVisible"
      :close-on-click-modal="false"
      width="75%"
    >
      <div class="app-add">
        <el-row>
          <el-col :span="6" v-for="(item, index) in tableInvocieList">
            <el-col :span="24">
              <el-image
                style="width: 350px; height: 350px; display: inline-block"
                :src="item"
              ></el-image>
            </el-col>
          </el-col>
        </el-row>
        <div slot="footer" class="dialog-footer">
          <el-button
            class="cancelClose"
            @click="createSeeNums.dialogFormVisible = false"
            >关闭</el-button
          >
        </div>
      </div>
    </el-dialog>

    <!-- 通过 -->
    <el-dialog
      title="确认是否审核通过"
      :visible.sync="adopt.dialogFormVisible"
      :close-on-click-modal="false"
      width="40%"
      :before-close="dialog_close_adopt"
    >
      <div class="app-add">
        <el-form
          ref="adopttemp"
          :rules="adopt.rules"
          :model="adopt.temp"
          label-position="right"
          label-width="150px"
          style="width: 80%; margin: 0 auto 50px"
        >
          <el-form-item label="备注：" prop="remark">
            <el-input
              ref="remark"
              v-model="adopt.temp.remark"
              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="dialog_close_adopt()"
            >关闭</el-button
          >
          <el-button class="success" @click="form_adopt_save()">确认</el-button>
        </div>
      </div>
    </el-dialog>

    <!-- 驳回 -->
    <el-dialog
      title="是否驳回申请"
      :visible.sync="reject.dialogFormVisible"
      :close-on-click-modal="false"
      width="40%"
      :before-close="dialog_close_reject"
    >
      <div class="app-add">
        <el-form
          ref="rejecttemp"
          :rules="reject.rules"
          :model="reject.temp"
          label-position="right"
          label-width="150px"
          style="width: 80%; margin: 0 auto 50px"
        >
          <el-form-item label="驳回原因：" prop="remark">
            <el-input
              ref="remark"
              v-model="reject.temp.remark"
              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="dialog_close_reject()"
            >关闭</el-button
          >
          <el-button class="success" @click="form_reject_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 } from "@/utils/index.js";
import Pagination from "@/components/Pagination";
import { MessageBox } from "element-ui";
import { getToken } from "@/utils/auth";
import TravelDetail from "@/componentView/TravelDetail.vue";

export default {
  name: "ExpensesApplyApproval",
  components: { Pagination, TravelDetail },
  data() {
    return {
      autoWidth: 180,
      myHeight: document.documentElement.clientHeight - 85 - 160,
      autoWidth: 220,
      sumPriceAll1: 0,
      sumPriceAll2: 0,
      dialogImageUrl: "",
      dialogVisible: false,
      //图片请求地址
      uploadImageUrl: process.env.VUE_APP_BASE_API + "authdata/uploaderimage",
      //图片请求头
      headers: {
        optname: "insertcustompic",
        id: 1,
        token: getToken(), // 从cookie里获取token，并赋值token
      },

      rowData: {},
      isHome: "",

      //图片路径
      fileList: [],

      employeid: Cookies.get("employeid"),

      g_userId: Cookies.get("g_userId"),

      isRoleEdit: [],
      isExpensesAdopt: [],

      send_select_list: [
        {
          name: "getUserFuzzy",
          offset: 0,
          pagecount: 0,
          parammaps: { inputvalue: "" },
        },
      ],
      customerNameList: [], // 客户名称
      loading: false,
      groupNameList: [], // 集团
      visiterNameList: [],
      receiverNameList: [],
      nextNameList: [],

      //1 出差，2 采购  3其它
      declareType: 1,
      declareTypeLength: 8,

      // 下拉框 - 申报人

      empNameList: [],
      // 下拉框 - 申报类型
      declareTypeList: [
        { name: "出差", id: "出差" },
        { name: "物流费", id: "物流费" },
        { name: "交通费", id: "交通费" },
        { name: "办公费", id: "办公费" },
        { name: "通讯费", id: "通讯费" },
        { name: "业务招待费", id: "业务招待费" },
        { name: "房租及业务管理费", id: "房租及业务管理费" },
        { name: "水电费", id: "水电费" },
        { name: "社保", id: "社保" },
        { name: "公积金", id: "公积金" },
        { name: "工资", id: "工资" },
        { name: "手续费", id: "手续费" },
        { name: "采购", id: "采购" },
        { name: "其他费用", id: "其他费用" },
      ],

      // 下拉框 - 出差单
      statusNameList: [
        { name: "草稿", id: "草稿" },
        { name: "一审中", id: "一审中" },
        { name: "二审中", id: "二审中" },
        { name: "三审中", id: "三审中" },
        { name: "审核通过", id: "审核通过" },
        { name: "已撤销", id: "已撤销" },
        { name: "被驳回", id: "被驳回" },
      ],

      // 下拉框 - 出差单
      returnMoneyList: [
        { name: "已回款", id: "已回款" },
        { name: "未回款", id: "未回款" },
      ],

      // 下拉框 - 采购类型
      buyTypeList: [
        { name: "原材料", id: "原材料" },
        { name: "外购", id: "外购" },
      ],

      //表格请求参数~~
      tableObj: {
        getdataListParm: {
          name: "getReimbursementApproval",
          page: 1,
          offset: 1,
          pagecount: 10,
          returntype: "Map",
          parammaps: {
            roleId: Cookies.get("g_roleId"),
            userId: Cookies.get("g_userId"),
            reimbursementCode: "",
            employeeId: "",
            statusName: "",
            declareTypeName: "",
            costStatus: "",
            postCode: "",
            beginServiceCost: "",
            endServiceCost: "",

            beginDeclareDate: "",
            endDeclareDate: "",
            inputDatetime1: "",
          },
        },
        tableKey: 0,
        list: [],
        total: 0,
        listLoading: true,
        temp: {},
      },

      // 新增/编辑
      create: {
        dialogFormVisible: false,
        dialogStatus: "",
        temp: {
          employeeId: "",
          declareTypeName: "",
          serviceCost: "",
          billDate: parseTime(new Date(), "{y}-{m}-{d}"),
          postName: "",
          postCode: "",
          declareReason: "",
          remark: "",
          scenePhoto1: -1,
          scenePhoto2: -1,
          scenePhoto3: -1,
          scenePhoto4: -1,
          scenePhoto5: -1,
          scenePhoto6: -1,
          scenePhoto7: -1,
          scenePhoto8: -1,
          scenePhoto9: -1,
          scenePhoto10: -1,
          picname1: "",
          picname2: "",
          picname3: "",
          picname4: "",
          picname5: "",
          picname6: "",
          picname7: "",
          picname8: "",
          picname9: "",
          picname10: "",
          userIds: "",
        },
        rules: {
          // customerName: [{ required: true, message: '必填', trigger: 'blur' }],
          // vdate: [{ required: true, message: '必填', trigger: 'blur' }],
          // visiterId: [{ required: true, message: '必填', trigger: 'blur' }],
          // receiverId: [{ required: true, message: '必填', trigger: 'blur' }],
          // receiverTel: [{ required: true, message: '必填', trigger: 'blur' }],
          // content: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
          // scenePhoto1: [{ required: true, message: '必填', trigger: 'blur' }],
        },
        // 出差小表格
        getTableTravelListParm: {
          name: "getReimbursementBusiness",
          returntype: "Map",
          parammaps: { id: "" },
        },
        //  采购小表格
        getTableBuyListParm: {
          name: "getReimbursementPurchase",
          returntype: "Map",
          parammaps: { id: "" },
        },
      },

      //发票信息
      tableInvocieList: [],

      createSeeNums: {
        dialogFormVisible: false,
      },

      selectList1: [],

      //出差小表格
      tableTravelList: [
        // {id:1,NoEdit:true,Edit:false},
        // {id:2,NoEdit:false,Edit:true},
      ],
      //z这里表格初始ID
      tableTravelId: 91,

      //采购小表格
      tableBuyList: [
        // {id:1,NoEdit:true,Edit:false},
        // {id:2,NoEdit:false,Edit:true},
      ],
      //z这里表格初始ID
      tableBuyId: 91,

      //出差单组件
      travelData: {},
      seeTravel: {
        dialogFormVisible: false,
      },

      travelExpenId: 0,

      // 通过
      adopt: {
        dialogFormVisible: false,
        dialogStatus: "",
        temp: { remark: "", id: "", statusName: "" },
        rules: {
          remark: [{ required: true, message: "必填", trigger: "blur" }],
        },
      },
      // 驳回
      reject: {
        dialogFormVisible: false,
        dialogStatus: "",
        temp: { remark: "", id: "", statusName: "" },
        rules: {
          remark: [{ required: true, message: "必填", trigger: "blur" }],
        },
      },

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

      requestParam: {},
      isokDisable: false,

      rowStyle: { maxHeight: 50 + "px", height: 45 + "px" },
      cellStyle: { padding: 0 + "px" },
    };
  },

  created() {
    this.get_table_data();
    this.get_select_list();
    this.get_auto_buttons();

    console.log("isRoleEdit", sessionStorage.getItem("buttons"));
    console.log(Cookies.get("employeid"));
    var rowData = this.$route.params.rowData;
    var isHome = this.$route.params.isHome;
    var codeNum = this.$route.params.codeNum;

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

      this.get_table_data();
    }
  },

  watch: {
    tableTravelList: {
      deep: true,
      handler: function (item) {
        //计算总价格
        var sum = 0;
        this.tableTravelList.forEach(function (i) {
          sum =
            parseFloat(i.toll) +
            parseFloat(i.oilCost) +
            parseFloat(i.hotelCost) +
            parseFloat(i.serviceCost) +
            parseFloat(i.otherCost) +
            sum;
        });

        this.sumPriceAll1 = sum;
      },
    },
    tableBuyList: {
      deep: true,
      handler: function (item) {
        //计算总价格
        var sum = 0;
        this.tableBuyList.forEach(function (i) {
          sum = parseFloat(i.goodsPrice) * parseFloat(i.goodsNum) + sum;
        });

        this.sumPriceAll2 = sum;
      },
    },
  },

  methods: {
    roleSet(row) {
      var result = true;
      console.log(row.userIds);

      if (row.userIds) {
        if (
          this.isExpensesAdopt &&
          row.userIds.split(",").includes(this.g_userId)
        ) {
          result = true;
        } else {
          result = false;
        }
      } else {
        result = false;
      }
      // if(this.isRoleEdit  == '1' && row.userIds.split(',').includes(this.g_userId)){
      //   result = true
      // } else{
      //   result = false
      // }
      return result;
    },
    getSummaries1(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "合计";
          return;
        }
        const values = data.map((item) => Number(item[column.property]));
        console.log(column.property);
        console.log(values);
        if (!values.every((value) => isNaN(value))) {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          // sums[index] += ' 元';
        } else {
          sums[index] = "-";
        }
      });

      return sums;
    },

    getSummaries2(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "合计";
          return;
        }

        if (index === 6) {
          sums[index] = "-";
          return;
        }
        const values = data.map((item) => Number(item[column.property]));
        console.log(column.property);
        console.log(values);
        if (!values.every((value) => isNaN(value))) {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          // sums[index] += ' 元';
        } else {
          sums[index] = "-";
        }
      });

      return sums;
    },

    // 查看
    form_see_nums(row) {
      console.log(row);

      var tableInvocieList = [];

      if (row.scenePhoto1 !== "-1") {
        var url = process.env.VUE_APP_BASE_API + row.picname1;
        tableInvocieList.push(url);
      }

      this.tableInvocieList = tableInvocieList;
      console.log(this.tableInvocieList);

      this.createSeeNums.dialogFormVisible = true;
    },

    //图片展示
    handlePicPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    handlePicChange(file, fileList) {},
    //文件上传成功后的操作
    handlePicSuccess(response, file, fileList) {
      console.log("文件上传成功时的钩子response", response);
      console.log("文件上传成功时的钩子file", file);
      console.log("fileList", fileList);

      //3张图片时，关闭新增的按钮
      if (fileList.length == 9) {
        document.getElementById("uploadPic").lastChild.style.display = "none";
      } else {
        document.getElementById("uploadPic").lastChild.style.display =
          "inline-block";
      }

      if (
        this.create.temp.scenePhoto1 === undefined ||
        this.create.temp.scenePhoto1 == -1
      ) {
        console.log("111");
        this.create.temp.scenePhoto1 = response.execresult.LastInsertId;
      } else if (
        this.create.temp.scenePhoto2 === undefined ||
        this.create.temp.scenePhoto2 == -1
      ) {
        console.log("222");
        this.create.temp.scenePhoto2 = response.execresult.LastInsertId;
      } else if (
        this.create.temp.scenePhoto3 === undefined ||
        this.create.temp.scenePhoto3 == -1
      ) {
        console.log("333");
        this.create.temp.scenePhoto3 = response.execresult.LastInsertId;
      } else if (
        this.create.temp.scenePhoto4 === undefined ||
        this.create.temp.scenePhoto4 == -1
      ) {
        console.log("444");
        this.create.temp.scenePhoto4 = response.execresult.LastInsertId;
      } else if (
        this.create.temp.scenePhoto5 === undefined ||
        this.create.temp.scenePhoto5 == -1
      ) {
        console.log("555");
        this.create.temp.scenePhoto5 = response.execresult.LastInsertId;
      } else if (
        this.create.temp.scenePhoto6 === undefined ||
        this.create.temp.scenePhoto6 == -1
      ) {
        console.log("666");
        this.create.temp.scenePhoto6 = response.execresult.LastInsertId;
      } else if (
        this.create.temp.scenePhoto7 === undefined ||
        this.create.temp.scenePhoto7 == -1
      ) {
        console.log("777");
        this.create.temp.scenePhoto7 = response.execresult.LastInsertId;
      } else if (
        this.create.temp.scenePhoto8 === undefined ||
        this.create.temp.scenePhoto8 == -1
      ) {
        console.log("888");
        this.create.temp.scenePhoto8 = response.execresult.LastInsertId;
      } else if (
        this.create.temp.scenePhoto9 === undefined ||
        this.create.temp.scenePhoto9 == -1
      ) {
        console.log("999");
        this.create.temp.scenePhoto9 = response.execresult.LastInsertId;
      } else if (
        this.create.temp.scenePhoto10 === undefined ||
        this.create.temp.scenePhoto10 == -1
      ) {
        console.log("999");
        this.create.temp.scenePhoto10 = response.execresult.LastInsertId;
      }
      console.log("this.picArr1", this.picArr1);

      console.log("this.create.temp", this.create.temp);
    },
    //图片文件删除
    handlePicRemove(file, fileList) {
      console.log(file, "文件列表移除文件时的钩子file---");
      console.log(fileList, "文件列表移除文件时的钩子fileList--");
      // this.$set(this.create.temp, "scenePhoto1", -1)
      // this.$set(this.create.temp, "scenePhoto2", -1)
      // this.$set(this.create.temp, "scenePhoto3", -1)
      //10张图片时，关闭新增的按钮
      if (fileList.length == 10) {
        document.getElementById("uploadPic").lastChild.style.display = "none";
      } else {
        document.getElementById("uploadPic").lastChild.style.display =
          "inline-block";
      }
      this.create.temp.scenePhoto1 = -1;
      this.create.temp.scenePhoto2 = -1;
      this.create.temp.scenePhoto3 = -1;
      this.create.temp.scenePhoto4 = -1;
      this.create.temp.scenePhoto5 = -1;
      this.create.temp.scenePhoto6 = -1;
      this.create.temp.scenePhoto7 = -1;
      this.create.temp.scenePhoto8 = -1;
      this.create.temp.scenePhoto9 = -1;
      this.create.temp.scenePhoto10 = -1;

      if (fileList.length == 10) {
        this.create.temp.scenePhoto1 =
          fileList[0].response.execresult.LastInsertId;
        this.create.temp.scenePhoto2 =
          fileList[1].response.execresult.LastInsertId;
        this.create.temp.scenePhoto3 =
          fileList[2].response.execresult.LastInsertId;
        this.create.temp.scenePhoto4 =
          fileList[3].response.execresult.LastInsertId;
        this.create.temp.scenePhoto5 =
          fileList[4].response.execresult.LastInsertId;
        this.create.temp.scenePhoto6 =
          fileList[5].response.execresult.LastInsertId;
        this.create.temp.scenePhoto7 =
          fileList[6].response.execresult.LastInsertId;
        this.create.temp.scenePhoto8 =
          fileList[7].response.execresult.LastInsertId;
        this.create.temp.scenePhoto9 =
          fileList[8].response.execresult.LastInsertId;
        this.create.temp.scenePhoto10 =
          fileList[9].response.execresult.LastInsertId;
      } else if (fileList.length == 9) {
        this.create.temp.scenePhoto1 =
          fileList[0].response.execresult.LastInsertId;
        this.create.temp.scenePhoto2 =
          fileList[1].response.execresult.LastInsertId;
        this.create.temp.scenePhoto3 =
          fileList[2].response.execresult.LastInsertId;
        this.create.temp.scenePhoto4 =
          fileList[3].response.execresult.LastInsertId;
        this.create.temp.scenePhoto5 =
          fileList[4].response.execresult.LastInsertId;
        this.create.temp.scenePhoto6 =
          fileList[5].response.execresult.LastInsertId;
        this.create.temp.scenePhoto7 =
          fileList[6].response.execresult.LastInsertId;
        this.create.temp.scenePhoto8 =
          fileList[7].response.execresult.LastInsertId;
        this.create.temp.scenePhoto9 =
          fileList[8].response.execresult.LastInsertId;
      } else if (fileList.length == 8) {
        this.create.temp.scenePhoto1 =
          fileList[0].response.execresult.LastInsertId;
        this.create.temp.scenePhoto2 =
          fileList[1].response.execresult.LastInsertId;
        this.create.temp.scenePhoto3 =
          fileList[2].response.execresult.LastInsertId;
        this.create.temp.scenePhoto4 =
          fileList[3].response.execresult.LastInsertId;
        this.create.temp.scenePhoto5 =
          fileList[4].response.execresult.LastInsertId;
        this.create.temp.scenePhoto6 =
          fileList[5].response.execresult.LastInsertId;
        this.create.temp.scenePhoto7 =
          fileList[6].response.execresult.LastInsertId;
        this.create.temp.scenePhoto8 =
          fileList[7].response.execresult.LastInsertId;
      } else if (fileList.length == 7) {
        this.create.temp.scenePhoto1 =
          fileList[0].response.execresult.LastInsertId;
        this.create.temp.scenePhoto2 =
          fileList[1].response.execresult.LastInsertId;
        this.create.temp.scenePhoto3 =
          fileList[2].response.execresult.LastInsertId;
        this.create.temp.scenePhoto4 =
          fileList[3].response.execresult.LastInsertId;
        this.create.temp.scenePhoto5 =
          fileList[4].response.execresult.LastInsertId;
        this.create.temp.scenePhoto6 =
          fileList[5].response.execresult.LastInsertId;
        this.create.temp.scenePhoto7 =
          fileList[6].response.execresult.LastInsertId;
      } else if (fileList.length == 6) {
        this.create.temp.scenePhoto1 =
          fileList[0].response.execresult.LastInsertId;
        this.create.temp.scenePhoto2 =
          fileList[1].response.execresult.LastInsertId;
        this.create.temp.scenePhoto3 =
          fileList[2].response.execresult.LastInsertId;
        this.create.temp.scenePhoto4 =
          fileList[3].response.execresult.LastInsertId;
        this.create.temp.scenePhoto5 =
          fileList[4].response.execresult.LastInsertId;
        this.create.temp.scenePhoto6 =
          fileList[5].response.execresult.LastInsertId;
      } else if (fileList.length == 5) {
        this.create.temp.scenePhoto1 =
          fileList[0].response.execresult.LastInsertId;
        this.create.temp.scenePhoto2 =
          fileList[1].response.execresult.LastInsertId;
        this.create.temp.scenePhoto3 =
          fileList[2].response.execresult.LastInsertId;
        this.create.temp.scenePhoto4 =
          fileList[3].response.execresult.LastInsertId;
        this.create.temp.scenePhoto5 =
          fileList[4].response.execresult.LastInsertId;
      } else if (fileList.length == 4) {
        this.create.temp.scenePhoto1 =
          fileList[0].response.execresult.LastInsertId;
        this.create.temp.scenePhoto2 =
          fileList[1].response.execresult.LastInsertId;
        this.create.temp.scenePhoto3 =
          fileList[2].response.execresult.LastInsertId;
        this.create.temp.scenePhoto4 =
          fileList[3].response.execresult.LastInsertId;
      } else if (fileList.length == 3) {
        this.create.temp.scenePhoto1 =
          fileList[0].response.execresult.LastInsertId;
        this.create.temp.scenePhoto2 =
          fileList[1].response.execresult.LastInsertId;
        this.create.temp.scenePhoto3 =
          fileList[2].response.execresult.LastInsertId;
      } else if (fileList.length == 2) {
        this.create.temp.scenePhoto1 =
          fileList[0].response.execresult.LastInsertId;
        this.create.temp.scenePhoto2 =
          fileList[1].response.execresult.LastInsertId;
      } else if (fileList.length == 1) {
        this.create.temp.scenePhoto1 =
          fileList[0].response.execresult.LastInsertId;
      }
      console.log(this.create.temp);
    },
    //获取按钮权限
    get_auto_buttons() {
      const Edit = "ExpensesApplyApproval";
      const isRoleEdit = checkButtons(
        JSON.parse(sessionStorage.getItem("buttons")),
        Edit
      );
      this.isRoleEdit = isRoleEdit;

      const ExpensesAdopt = "approval:expenses:adopt";
      const isExpensesAdopt = checkButtons(
        this.$store.state.user.buttons,
        ExpensesAdopt
      );
      this.ExpensesAdopt = ExpensesAdopt;
    },
    //获取所有下拉框的内容
    get_select_list() {
      GetDataByNames(this.send_select_list).then((response) => {
        this.empNameList = response.data.getUserFuzzy.list;
        console.log("出差人下拉框", this.empNameList);
      });
    },

    //加载表格
    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.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.roleSet(row)) {
              itemBtnNum = itemBtnNum + 2;
            }

            console.log(itemBtnNum);
            if (itemBtnNum > btnNum) {
              btnNum = itemBtnNum;
            }
          });

          console.log("btnNum=============", btnNum);
          me.autoWidth = btnNum * 90;
        } else {
          this.tableObj.list = [];
        }
        setTimeout(() => {
          this.tableObj.listLoading = false;
        }, 100);
      });
    },
    form_search() {
      console.log("点击了查询");

      if (
        this.tableObj.getdataListParm.parammaps.inputDatetime1 !== "" &&
        this.tableObj.getdataListParm.parammaps.inputDatetime1 !== null
      ) {
        this.tableObj.getdataListParm.parammaps.beginDeclareDate = parseTime(
          this.tableObj.getdataListParm.parammaps.inputDatetime1[0],
          "{y}-{m}-{d}"
        );
        this.tableObj.getdataListParm.parammaps.endDeclareDate = parseTime(
          this.tableObj.getdataListParm.parammaps.inputDatetime1[1],
          "{y}-{m}-{d}"
        );
      } else {
        this.tableObj.getdataListParm.parammaps.inputDatetime1 = "";
        this.tableObj.getdataListParm.parammaps.beginDeclareDate = "";
        this.tableObj.getdataListParm.parammaps.endDeclareDate = "";
      }
      this.tableObj.getdataListParm.offset = 1;
      this.get_table_data();
    },
    form_clear() {
      console.log("点击了重置");
      this.tableObj.getdataListParm.parammaps.reimbursementCode = "";
      this.tableObj.getdataListParm.parammaps.employeeId = "";
      this.tableObj.getdataListParm.parammaps.statusName = "";
      this.tableObj.getdataListParm.parammaps.declareTypeName = "";
      this.tableObj.getdataListParm.parammaps.postCode = "";
      this.tableObj.getdataListParm.parammaps.beginServiceCost = "";
      this.tableObj.getdataListParm.parammaps.costStatus = "";
      this.tableObj.getdataListParm.parammaps.endServiceCost = "";

      this.tableObj.getdataListParm.parammaps.beginDeclareDate = "";
      this.tableObj.getdataListParm.parammaps.endDeclareDate = "";
      this.tableObj.getdataListParm.parammaps.inputDatetime1 = "";
      this.tableObj.getdataListParm.offset = 1;
      this.get_table_data();
    },

    // 新增
    form_reset() {
      (this.create.temp = {
        employeeId: "",
        declareTypeName: "",
        serviceCost: "",
        billDate: parseTime(new Date(), "{y}-{m}-{d}"),
        postName: "",
        postCode: "",
        declareReason: "",
        remark: "",
        scenePhoto1: -1,
        scenePhoto2: -1,
        scenePhoto3: -1,
        scenePhoto4: -1,
        scenePhoto5: -1,
        scenePhoto6: -1,
        scenePhoto7: -1,
        scenePhoto8: -1,
        scenePhoto9: -1,
        scenePhoto10: -1,
        picname1: "",
        picname2: "",
        picname3: "",
        picname4: "",
        picname5: "",
        picname6: "",
        picname7: "",
        picname8: "",
        picname9: "",
        picname10: "",
        userIds: "",
      }),
        (this.tableTravelList = []);
      this.tableBuyList = [];
      this.fileList = [];
    },

    //监听 - 申报类型
    change_declare(item) {
      console.log(item);
      //1 出差，2 采购  3其它
      //declareType:1,
      if (item == "出差") {
        this.declareType = 1;
        this.declareTypeLength = 8;
      } else if (item == "采购") {
        this.declareType = 2;
        this.declareTypeLength = 8;
      } else {
        this.declareType = 3;
        this.declareTypeLength = 24;
      }

      this.$forceUpdate();
    },

    // 查看
    form_see(row) {
      console.log("点击了查看", row);
      // this.$nextTick(() => {
      //   this.$refs.temp.resetFields()
      // })

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

      this.create.temp.id = row.id;

      this.create.temp.userIds = row.userIds;

      if (row.declareTypeName == "出差") {
        this.declareType = 1;
        this.declareTypeLength = 8;
        this.create.getTableTravelListParm.parammaps.id = row.id;
        this.getTableTravelList();
      } else if (row.declareTypeName == "采购") {
        this.declareType = 2;
        this.declareTypeLength = 8;
        this.create.getTableBuyListParm.parammaps.id = row.id;
        this.getTableBuyList();
      } else {
        this.declareType = 3;
        this.declareTypeLength = 24;
      }

      // 现场照片
      const urlArray = [];
      const urlArrayId = [];
      const fileList = [];

      if (this.create.temp.picname1 != undefined) {
        urlArray.push(process.env.VUE_APP_BASE_API + this.create.temp.picname1);
        urlArrayId.push(this.create.temp.scenePhoto1);
      }
      if (this.create.temp.picname2 != undefined) {
        urlArray.push(process.env.VUE_APP_BASE_API + this.create.temp.picname2);
        urlArrayId.push(this.create.temp.scenePhoto2);
      }
      if (this.create.temp.picname3 != undefined) {
        urlArray.push(process.env.VUE_APP_BASE_API + this.create.temp.picname3);
        urlArrayId.push(this.create.temp.scenePhoto3);
      }
      if (this.create.temp.picname4 != undefined) {
        urlArray.push(process.env.VUE_APP_BASE_API + this.create.temp.picname4);
        urlArrayId.push(this.create.temp.scenePhoto4);
      }
      if (this.create.temp.picname5 != undefined) {
        urlArray.push(process.env.VUE_APP_BASE_API + this.create.temp.picname5);
        urlArrayId.push(this.create.temp.scenePhoto5);
      }
      if (this.create.temp.picname6 != undefined) {
        urlArray.push(process.env.VUE_APP_BASE_API + this.create.temp.picname6);
        urlArrayId.push(this.create.temp.scenePhoto6);
      }
      if (this.create.temp.picname7 != undefined) {
        urlArray.push(process.env.VUE_APP_BASE_API + this.create.temp.picname7);
        urlArrayId.push(this.create.temp.scenePhoto7);
      }
      if (this.create.temp.picname8 != undefined) {
        urlArray.push(process.env.VUE_APP_BASE_API + this.create.temp.picname8);
        urlArrayId.push(this.create.temp.scenePhoto8);
      }
      if (this.create.temp.picname9 != undefined) {
        urlArray.push(process.env.VUE_APP_BASE_API + this.create.temp.picname9);
        urlArrayId.push(this.create.temp.scenePhoto9);
      }
      if (this.create.temp.picname10 != undefined) {
        urlArray.push(
          process.env.VUE_APP_BASE_API + this.create.temp.picname10
        );
        urlArrayId.push(this.create.temp.scenePhoto10);
      }

      console.log("urlArray", urlArray);
      console.log("urlArrayId", urlArrayId);

      for (let i = 0; i < urlArray.length; i++) {
        var urlObj = {
          url: "",
          response: { execresult: { LastInsertId: "" } },
        };
        urlObj.url = urlArray[i];
        // this.$set(urlObj, 'url', urlArray[i])
        // this.$set(urlObj, 'response', 15)
        urlObj.response.execresult.LastInsertId = urlArrayId[i];
        fileList.push(urlObj);
      }

      this.fileList = fileList;

      console.log("fileList", fileList);

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

    getTableTravelList() {
      GetDataByName(this.create.getTableTravelListParm).then((response) => {
        if (response.data.list !== null) {
          if (this.create.dialogStatus == "see") {
            for (let i = 0; i < response.data.list.length; i++) {
              this.$set(response.data.list[i], "Edit", false); // 编辑
              this.$set(response.data.list[i], "NoEdit", true); // 不可编辑/输入
            }
          } else {
            for (let i = 0; i < response.data.list.length; i++) {
              this.$set(response.data.list[i], "Edit", true); // 编辑
              this.$set(response.data.list[i], "NoEdit", false); // 不可编辑/输入
              this.$set(response.data.list[i], "tableTravelId", i);
            }
          }
          this.tableTravelList = response.data.list;
        } else {
          this.tableTravelList = [];
        }

        console.log("出差小表格", this.tableTravelList);
      });
    },
    getTableBuyList() {
      GetDataByName(this.create.getTableBuyListParm).then((response) => {
        if (response.data.list !== null) {
          if (this.create.dialogStatus == "see") {
            for (let i = 0; i < response.data.list.length; i++) {
              this.$set(response.data.list[i], "Edit", false); // 编辑
              this.$set(response.data.list[i], "NoEdit", true); // 不可编辑/输入
            }
          } else {
            for (let i = 0; i < response.data.list.length; i++) {
              this.$set(response.data.list[i], "Edit", true); // 编辑
              this.$set(response.data.list[i], "NoEdit", false); // 不可编辑/输入
              this.$set(response.data.list[i], "tableBuyId", i);
            }
          }
          this.tableBuyList = response.data.list;
        } else {
          this.tableBuyList = [];
        }
        console.log("采购小表格", this.tableBuyList);
      });
    },

    // 通过
    form_adopt(row) {
      console.log("点击了通过", row);
      this.reset_adopt();

      this.adopt.temp.id = row.id;
      this.adopt.temp.statusName = row.statusName;

      this.adopt.dialogFormVisible = true;
    },
    // 通过 - 重置
    reset_adopt() {
      this.adopt.temp.remark = "";
      this.adopt.temp.statusName = "";
    },

    // 通过 - 确认
    form_adopt_save() {
      this.$refs["adopttemp"].validate((valid) => {
        if (valid) {
          var send_data = {
            common: { returnmap: "0" },
            data: [
              {
                name: "insertApproval",
                type: "e",
                parammaps: {
                  typeName: "报销审批",
                  objectId: this.adopt.temp.id,
                  statusId: "1",
                  remark: this.adopt.temp.remark,
                  userId: Cookies.get("employeid"),
                  stepName: this.adopt.temp.statusName,
                },
              },

              {
                name: "updateReimbursementSuccess",
                type: "e",
                parammaps: { id: this.adopt.temp.id },
              },
            ],
          };

          ExecDataByConfig(send_data).then((response) => {
            console.log("通过发送参数", send_data);
            if (response.msg !== "fail") {
              this.$notify({
                title: "成功",
                message: "通过成功",
                type: "success",
                duration: 2000,
              });
              this.adopt.dialogFormVisible = false;
              this.create.dialogFormVisible = false;

              this.get_table_data();

              var rowId = this.adopt.temp.id;
              var statusName = this.adopt.temp.statusName;

              if (statusName == "一审中") {
                this.get_wxPush(59, "报销", rowId);
              } else if (statusName == "二审中") {
                this.get_wxPush(60, "报销", rowId);
              } else if (statusName == "三审中") {
                this.get_wxPush(61, "报销", rowId);
              }

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

    // 驳回
    form_reject(row) {
      console.log("点击了驳回", row);
      this.reset_reject();

      this.reject.temp.id = row.id;
      this.reject.temp.statusName = row.statusName;
      this.reject.dialogFormVisible = true;
    },
    // 驳回 - 重置
    reset_reject() {
      this.reject.temp.remark = "";
      this.reject.temp.statusName = "";
    },

    // 驳回 - 确认
    form_reject_save() {
      this.$refs["rejecttemp"].validate((valid) => {
        if (valid) {
          var send_data = {
            common: { returnmap: "0" },
            data: [
              {
                name: "insertApproval",
                type: "e",
                parammaps: {
                  typeName: "报销审批",
                  objectId: this.reject.temp.id,
                  statusId: "0",
                  remark: this.reject.temp.remark,
                  userId: Cookies.get("employeid"),
                  stepName: this.reject.temp.statusName,
                },
              },

              {
                name: "updateReimbursementFalse",
                type: "e",
                parammaps: { id: this.reject.temp.id },
              },
            ],
          };

          ExecDataByConfig(send_data).then((response) => {
            console.log("驳回发送参数", send_data);
            if (response.msg !== "fail") {
              this.$notify({
                title: "成功",
                message: "驳回成功",
                type: "success",
                duration: 2000,
              });
              this.reject.dialogFormVisible = false;
              this.create.dialogFormVisible = false;

              this.get_table_data();

              var rowId = this.reject.temp.id;
              var statusName = this.reject.temp.statusName;

              if (statusName == "一审中") {
                this.get_wxPush(62, "报销", rowId);
              } else if (statusName == "二审中") {
                this.get_wxPush(63, "报销", rowId);
              } else if (statusName == "三审中") {
                this.get_wxPush(64, "报销", rowId);
              }

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

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

    dialog_close_adopt() {
      this.adopt.dialogFormVisible = false;
      this.get_table_data();
      if (this.isHome == "home") {
        // 返回首页
        this.$router.push({
          name: "Dashboard",
          params: { isTodo: "expenseapp" },
        });
      }
    },
    dialog_close_reject() {
      this.reject.dialogFormVisible = false;
      this.get_table_data();
      if (this.isHome == "home") {
        // 返回首页
        this.$router.push({
          name: "Dashboard",
          params: { isTodo: "expenseapp" },
        });
      }
    },
    //微信推送
    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 })
        }
      });
    },
  },
};
</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>
