瀏覽代碼

修改bug

qukaidi 3 年之前
父節點
當前提交
bd071abd62
共有 2 個文件被更改,包括 2206 次插入116 次删除
  1. 1929 0
      src/views/dealer/sales/detail copy.vue
  2. 277 116
      src/views/dealer/sales/detail.vue

+ 1929 - 0
src/views/dealer/sales/detail copy.vue

@@ -0,0 +1,1929 @@
+<template>
+  <div class="borderless" v-loading="pageLoading">
+    <div class="customer-head">
+      <div class="customer-back">
+        <el-button
+          type="danger"
+          style="border: none;background: none;color: red"
+          icon="el-icon-arrow-left"
+          @click="backToList"
+          :loading="btnLoading"
+          >返回列表</el-button
+        >
+      </div>
+      <div class="add-customer-btn">
+        <el-button
+          v-if="checker && form.status != 3"
+          type="primary"
+          size="small"
+          class="el-button--small-yh"
+          @click.stop="openCheckDialog"
+        >
+          审批
+        </el-button>
+        <el-button
+          v-if="form.status > 0"
+          @click.native="(checkScheduleDialog = true), (checkId = form.id)"
+          type="primary"
+          size="small"
+          class="el-button--small-yh"
+          >审核进度</el-button
+        >
+        <el-button
+          type="primary"
+          size="small"
+          class="el-button--small-yh"
+          @click.stop="openEdit"
+          v-if="form.id && disabled"
+          >编 辑</el-button
+        >
+        <el-button
+          type="primary"
+          v-if="!checkDisabled && confirmDisabled"
+          :disabled="!form.id || disabled"
+          size="small"
+          @click="pleaseCheck"
+          :loading="btnLoading"
+          class="el-button--small-yh"
+          >请核</el-button
+        >
+        <el-button
+          type="primary"
+          v-if="form.status == 1"
+          :disabled="disabled"
+          size="small"
+          @click="repealCancel"
+          :loading="btnLoading"
+          >撤销请核</el-button
+        >
+        <el-button
+          type="primary"
+          size="small"
+          style="margin-right: 8px;"
+          @click="dealerSubmit"
+          :disabled="disabled || checkDisabled"
+          :loading="btnLoading"
+          v-if="form.id"
+        >
+          {{
+            form.confirmStatus == 0
+              ? "确认订单"
+              : form.confirmStatus == 3
+              ? "撤销订单"
+              : ""
+          }}
+        </el-button>
+        <el-dropdown style="margin-right: 8px;">
+          <el-button type="warning" size="small"
+            >账单处理<i class="el-icon-arrow-down el-icon--right"></i
+          ></el-button>
+          <el-dropdown-menu slot="dropdown">
+            <!--            <el-dropdown-item-->
+            <!--              @click.native="applySettlement('收费')"-->
+            <!--              :disabled="disabled"-->
+            <!--            >生成账单-->
+            <!--            </el-dropdown-item>-->
+            <el-dropdown-item
+              @click.native="openApplicationDialog"
+              :disabled="!form.id"
+              >查看账单
+            </el-dropdown-item>
+          </el-dropdown-menu>
+        </el-dropdown>
+        <el-button
+          type="success"
+          :disabled="!form.id"
+          size="small"
+          @click="copyDoc"
+          :loading="btnLoading"
+        >
+          复制单据
+        </el-button>
+        <el-button
+          type="primary"
+          @click="editCustomer"
+          size="small"
+          :loading="btnLoading"
+          :disabled="disabled"
+          >保存数据
+        </el-button>
+      </div>
+    </div>
+    <div class="customer-main">
+      <containerTitle title="基础信息" />
+      <basic-container :showBtn="true">
+        <avue-form
+          ref="form"
+          class="trading-form"
+          v-model="form"
+          :option="option"
+        >
+          <template slot="corpId">
+            <crop-select
+              v-model="form.corpId"
+              @getCorpData="getCorpData"
+              corpType="KH"
+              :disabled="disabled || confirmDisabled || checkDisabled"
+            />
+          </template>
+          <template slot="belongToCorpId">
+            <crop-select
+              v-model="form.belongToCorpId"
+              @getCorpData="getGSData"
+              corpType="GS"
+              :disabled="disabled || confirmDisabled || checkDisabled"
+            />
+          </template>
+          <template slot="storageId">
+            <warehouse-select
+              v-model="form.storageId"
+              @returnBack="storageChange"
+              :configuration="configurationWarehouse"
+              :disabled="disabled || confirmDisabled || checkDisabled"
+            />
+          </template>
+          <template slot="chargeMember">
+            <el-select
+              v-model="form.chargeMember"
+              filterable
+              clearable
+              size="small"
+              :disabled="disabled"
+            >
+              <el-option
+                v-for="(item, index) in userList"
+                :key="index"
+                :label="item.realName"
+                :value="item.realName"
+              ></el-option>
+            </el-select>
+          </template>
+        </avue-form>
+      </basic-container>
+      <containerTitle title="商品信息" />
+      <basic-container>
+        <avue-crud
+          ref="crud"
+          :data="dataList"
+          :option="tableOption"
+          :cell-style="cellStyle"
+          @saveColumn="saveColumn"
+          @resetColumn="resetColumn"
+        >
+          <template slot="headerSerial" slot-scope="{ column }">
+            <el-button
+              type="primary"
+              icon="el-icon-circle-plus-outline"
+              circle
+              size="mini"
+              :disabled="
+                disabled || !form.storageId || confirmDisabled || checkDisabled
+              "
+              @click="$refs.crud.rowCellAdd()"
+            ></el-button>
+          </template>
+          <template slot="menuLeft">
+            <el-button
+              type="primary"
+              icon="el-icon-plus"
+              size="small"
+              @click.stop="newDetails"
+              :disabled="
+                disabled || !form.storageId || confirmDisabled || checkDisabled
+              "
+              >录入明细</el-button
+            >
+            <el-button
+              type="info"
+              icon="el-icon-printer"
+              size="small"
+              @click.stop="openReport"
+              >报表打印</el-button
+            >
+            <el-button
+              type="primary"
+              size="small"
+              icon="el-icon-download"
+              @click="downloadHandle"
+              >下载模板</el-button
+            >
+            <el-upload
+              :action="baseURL"
+              :headers="headers"
+              :disabled="
+                disabled || confirmDisabled || !form.storageId || checkDisabled
+              "
+              :on-progress="uploading"
+              :show-file-list="false"
+              :data="uploadParam"
+              accept=".xls,.xlsx"
+              multiple
+              :on-success="importTemplate"
+              :on-error="uploadError"
+              style="float: right"
+            >
+              <el-button
+                type="primary"
+                size="small"
+                icon="el-icon-upload"
+                :disabled="
+                  disabled ||
+                    confirmDisabled ||
+                    !form.storageId ||
+                    checkDisabled
+                "
+                >导 入</el-button
+              >
+            </el-upload>
+          </template>
+          <template slot="menu" slot-scope="{ row, index }">
+            <el-button
+              size="small"
+              icon="el-icon-edit"
+              type="text"
+              @click="rowCell(row, index)"
+              :disabled="disabled || confirmDisabled || checkDisabled"
+              >{{ row.$cellEdit ? "保存" : "修改" }}</el-button
+            >
+            <el-button
+              size="small"
+              icon="el-icon-delete"
+              type="text"
+              @click="rowDel(row, index)"
+              :disabled="disabled || confirmDisabled || checkDisabled"
+              >删除</el-button
+            >
+          </template>
+          <template slot="code" slot-scope="{ row, index }">
+            <span v-if="row.$cellEdit" style="display:flex">
+              <el-select
+                v-model="row.code"
+                placeholder="请选择"
+                filterable
+                size="small"
+                style="width:60%"
+                @change="codeChange(row, index)"
+                :disabled="!form.storageId"
+              >
+                <el-option
+                  v-for="item in goodsoptions"
+                  :key="item.id"
+                  :label="item.code"
+                  :value="item.code"
+                >
+                </el-option>
+              </el-select>
+              <el-button
+                icon="el-icon-search"
+                size="small"
+                @click="rePick(row, index)"
+              ></el-button>
+            </span>
+            <span v-else> {{ row.code }}</span>
+          </template>
+          <template slot="cname" slot-scope="{ row, index }">
+            <span v-if="row.$cellEdit" style="display:flex">
+              <el-select
+                v-model="row.itemId"
+                placeholder="请选择"
+                size="small"
+                filterable
+                style="width:60%"
+                @change="cnameChange(row, index)"
+                :disabled="!form.storageId"
+              >
+                <el-option
+                  v-for="item in goodsoptions"
+                  :key="item.id"
+                  :label="item.cname"
+                  :value="item.id"
+                >
+                </el-option>
+              </el-select>
+              <el-button
+                icon="el-icon-search"
+                size="small"
+                @click="rePick(row, index)"
+              ></el-button>
+            </span>
+            <span v-else> {{ row.cname }}</span>
+          </template>
+          <template slot="orderQuantity" slot-scope="{ row, index }">
+            <el-input-number
+              v-if="row.$cellEdit"
+              v-model="row.orderQuantity"
+              size="small"
+              :controls="false"
+              :precision="0"
+              @input="amountChange(row)"
+              :disabled="!form.storageId"
+              style="width: 100%"
+            />
+            <span v-else>{{ row.orderQuantity | IntegerFormat }}</span>
+          </template>
+          <template slot="price" slot-scope="{ row, index }">
+            <el-input-number
+              v-if="row.$cellEdit"
+              v-model="row.price"
+              size="small"
+              :controls="false"
+              :precision="2"
+              @input="amountChange(row)"
+              style="width: 100%"
+              :disabled="!form.storageId"
+            ></el-input-number>
+            <span v-else>{{ row.price }}</span>
+          </template>
+          <!--          单位-->
+          <template slot="unit" slot-scope="{ row, index }">
+            <el-select
+              v-if="row.$cellEdit"
+              v-model="row.unit"
+              size="small"
+              clearable
+              filterable
+              :disabled="!form.storageId"
+            >
+              <el-option
+                v-for="(item, index) in unitOption"
+                :key="index"
+                :label="item.dictValue"
+                :value="item.dictValue"
+              />
+            </el-select>
+            <span v-else>{{ row.unit }}</span>
+          </template>
+          <template slot="amount" slot-scope="{ row, index }">
+            <span>{{ row.amount | decimalFormat }}</span>
+          </template>
+          <template slot="storageQuantity" slot-scope="{ row, index }">
+            <span>{{ row.storageQuantity | IntegerFormat }}</span>
+          </template>
+          <template slot="lotNo" slot-scope="{ row, index }">
+            <span v-if="row.batch == 1" style="color: #c90707;margin-right: 3px"
+              >*</span
+            >
+            <el-select
+              v-if="row.$cellEdit"
+              v-model="row.lotNo"
+              size="small"
+              filterable
+              allow-create
+              clearable
+              @change="lotNoChange(row)"
+              :disabled="!form.storageId"
+            >
+              <el-option
+                v-for="(item, index) in row.arr"
+                :key="index"
+                :label="item.lotNo"
+                :value="item.lotNo"
+              />
+            </el-select>
+            <span v-else>{{ row.lotNo }}</span>
+          </template>
+          <template slot="newJob" slot-scope="{ row, index }">
+            <span
+              style="color: #1e9fff;cursor: pointer"
+              @click="openHistory(row)"
+              >{{ row.newJob }}</span
+            >
+          </template>
+          <template slot="remarks" slot-scope="{ row, index }">
+            <el-input
+              v-if="row.$cellEdit"
+              v-model="row.remarks"
+              size="small"
+              :disabled="!form.storageId"
+            />
+            <span v-else>{{ row.remarks }}</span>
+          </template>
+        </avue-crud>
+      </basic-container>
+      <containerTitle title="详细信息" />
+      <basic-container :showBtn="true">
+        <avue-form
+          ref="form1"
+          class="trading-form"
+          v-model="form"
+          :option="detailOption"
+        ></avue-form>
+      </basic-container>
+      <containerTitle title="附件管理"></containerTitle>
+      <c-upload
+        :data="uploadData"
+        deleteUrl="/api/blade-client/corpsbank/update"
+        :enumerationValue="84"
+        :disabled="disabled || confirmDisabled || checkDisabled"
+      />
+    </div>
+    <!--    商品弹窗-->
+    <el-dialog
+      title="导入商品"
+      append-to-body
+      class="el-dialogDeep"
+      :visible.sync="dialogVisible"
+      width="80%"
+      :close-on-click-modal="false"
+      :destroy-on-close="true"
+      :close-on-press-escape="false"
+      @close="closeGoods"
+      top="5vh"
+      v-dialog-drag
+    >
+      <span>
+        <el-row>
+          <el-col :span="4">
+            <div>
+              <el-scrollbar>
+                <basic-container>
+                  <avue-tree
+                    :option="treeOption"
+                    @node-click="nodeClick"
+                    :style="treeStyle"
+                  />
+                </basic-container>
+              </el-scrollbar>
+            </div>
+          </el-col>
+          <el-col :span="20">
+            <avue-crud
+              :option="goodsOption"
+              :table-loading="loading"
+              :data="goodsListShow"
+              ref="goodsCrud"
+              :search.sync="search"
+              @search-change="searchChange"
+              @selection-change="selectionChange"
+              @row-click="rowClick"
+              :page.sync="page"
+              @on-load="onLoad"
+              @saveColumn="saveGoodsColumn"
+              @resetColumn="resetGoodsColumn"
+              :cell-style="cellStyle"
+            >
+              <template slot="menuLeft">
+                <el-tabs v-model="activeName" @tab-click="tabHandle">
+                  <el-tab-pane label="查询结果" name="searchList"></el-tab-pane>
+                  <el-tab-pane
+                    label="已选定数据"
+                    name="importStaging"
+                  ></el-tab-pane>
+                </el-tabs>
+              </template>
+              <template slot-scope="scope" slot="menu">
+                <el-button
+                  type="text"
+                  icon="el-icon-edit"
+                  size="small"
+                  @click.stop="importStagList(scope.row, scope.index)"
+                  v-if="activeName == 'searchList'"
+                  :disabled="
+                    goodsListSave.findIndex(item => item.id == scope.row.id) !==
+                      -1
+                  "
+                  >选择
+                </el-button>
+                <el-button
+                  type="text"
+                  icon="el-icon-delete"
+                  size="small"
+                  @click.stop="removeStagList(scope.row, scope.index)"
+                  v-else
+                  >移除
+                </el-button>
+              </template>
+            </avue-crud>
+          </el-col>
+        </el-row>
+      </span>
+
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="dialogVisible = false">取 消</el-button>
+        <el-button
+          type="primary"
+          @click="importGoods"
+          :disabled="selectionList.length == 0 && goodsListSave.length == 0"
+          >导入</el-button
+        >
+      </span>
+    </el-dialog>
+    <!--    报表-->
+    <report-dialog
+      :switchDialog="switchDialog"
+      :reportId="form.id"
+      reportName="经销商-销售单"
+      @onClose="onClose()"
+    />
+    <!--    账单-->
+    <el-dialog
+      append-to-body
+      title="账单"
+      class="el-dialogDeep"
+      :visible.sync="financialAccountDialog"
+      width="70%"
+      :close-on-click-modal="false"
+      :destroy-on-close="true"
+      :close-on-press-escape="false"
+      v-dialog-drag
+    >
+      <financial-account
+        :billType="billType"
+        :billData="{}"
+        :arrList="applyPaymentList"
+        :belongCompany="form.belongToCorpId"
+        @choceFun="choceFun"
+      />
+    </el-dialog>
+    <!--    历史记录-->
+    <view-history
+      v-if="historyVisible"
+      ref="history"
+      :params="historyParams"
+      @closeDialog="closeDialog"
+    />
+    <el-dialog
+      append-to-body
+      title="审批"
+      class="el-dialogDeep"
+      :visible.sync="checkDialog"
+      width="50%"
+      :close-on-click-modal="false"
+      :destroy-on-close="true"
+      :close-on-press-escape="false"
+      v-dialog-drag
+    >
+      <check
+        :checkData="checkData"
+        :checkDetail="false"
+        :idList="[]"
+        @choceCheckFun="choceCheckFun"
+      >
+      </check>
+    </el-dialog>
+    <el-dialog
+      append-to-body
+      title="审批进度"
+      class="el-dialogDeep"
+      :visible.sync="checkScheduleDialog"
+      width="40%"
+      :close-on-click-modal="false"
+      :destroy-on-close="true"
+      :close-on-press-escape="false"
+      v-dialog-drag
+    >
+      <check-schedule
+        :checkId="checkId"
+        :batchNo="batchNo"
+        @choceScheduleFun="choceScheduleFun"
+      >
+      </check-schedule>
+    </el-dialog>
+    <el-dialog
+      title="申请记录"
+      append-to-body
+      class="el-dialogDeep"
+      :visible.sync="applicationDialog"
+      width="60%"
+      :close-on-click-modal="false"
+      :destroy-on-close="true"
+      :close-on-press-escape="false"
+      v-dialog-drag
+    >
+      <bill-application :billId="form.id" @choceApplication="choceApplication">
+      </bill-application>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import tableOption from "./config/customerContact.json";
+import goodsOption from "./config/commodity.json";
+import { getDeptLazyTree, getGoods } from "@/api/basicData/customerInquiry";
+import { getUserInfo } from "@/api/system/user";
+import { gainUser } from "@/api/basicData/customerInquiry";
+import { selectGoodsNum } from "@/api/basicData/inventoryAccount"; // 库存查询
+import { detail as KHDetail } from "@/api/basicData/customerInformation";
+import {
+  dataDetail,
+  removeGoods,
+  typeSave,
+  getLotNo,
+  dealerSubmit,
+  historyPrice,
+  itemDetail,
+  pleaseCheck,
+  repealCancel
+} from "@/api/dealer/sales";
+import reportDialog from "@/components/report-dialog/main";
+import {
+  isDiscount,
+  isPercentage,
+  micrometerFormat,
+  IntegerFormat
+} from "@/util/validate";
+import financialAccount from "../../../components/finance/financialAccount";
+import check from "@/components/check/check";
+import checkSchedule from "@/components/check/checkSchedule";
+import billApplication from "@/components/bill/billApplication";
+import { customerList as feeList } from "@/api/basicData/basicFeesDesc";
+import { getDetail } from "@/api/basicData/inventoryAccount";
+import { getToken } from "@/util/auth";
+import { getCurrentDate } from "@/util/date";
+import viewHistory from "../componet/history";
+import { getMarketPrice, getPurchasePrice } from "@/api/basicData/fees";
+import { contrastObj, contrastList } from "@/util/contrastData";
+
+export default {
+  name: "detail",
+  props: {
+    detailData: {
+      type: Object
+    }
+  },
+  components: {
+    reportDialog,
+    billApplication,
+    financialAccount,
+    check,
+    checkSchedule,
+    viewHistory
+  },
+  data() {
+    return {
+      orderNumber: true,
+      pageLoading: false,
+      btnLoading: false,
+      disabled: false, // 编辑
+      confirmDisabled: false, // 确认禁用
+      form: {},
+      option: {
+        menuBtn: false,
+        labelWidth: 100,
+        column: [
+          {
+            label: "客户名称",
+            prop: "corpId",
+            rules: [
+              {
+                required: true,
+                message: " ",
+                trigger: "change"
+              }
+            ],
+            span: 16,
+            slot: true
+          },
+          {
+            label: "业务时间",
+            prop: "businesDate",
+            span: 8,
+            type: "date",
+            format: "yyyy-MM-dd",
+            valueFormat: "yyyy-MM-dd 00:00:00",
+            rules: [
+              {
+                required: true,
+                message: "",
+                trigger: "blur"
+              }
+            ]
+          },
+          {
+            label: "所属公司",
+            prop: "belongToCorpId",
+            rules: [
+              {
+                required: true,
+                message: " ",
+                trigger: "change"
+              }
+            ],
+            span: 16,
+            slot: true
+          },
+          {
+            label: "发货仓库",
+            prop: "storageId",
+            span: 8,
+            rules: [
+              {
+                required: true,
+                message: " ",
+                trigger: "change"
+              }
+            ]
+          },
+          {
+            label: "电话",
+            prop: "corpTel",
+            span: 8
+          },
+          {
+            label: "地址",
+            prop: "arrivalAddress",
+            span: 8
+          },
+          {
+            label: "业务员",
+            prop: "chargeMember",
+            span: 8
+          },
+          {
+            label: "结算方式",
+            prop: "paymentType",
+            span: 8,
+            type: "select",
+            dicUrl: "/api/blade-system/dict-biz/dictionary?code=payment_term",
+            props: {
+              label: "dictValue",
+              value: "dictValue"
+            }
+          },
+          {
+            label: "配送方式",
+            prop: "distributionMode",
+            span: 8
+          },
+          {
+            label: "系统编号",
+            prop: "sysNo",
+            span: 8,
+            disabled: true
+          },
+          {
+            label: "订单号",
+            prop: "orderNo",
+            span: 8,
+            disabled: true
+          },
+          {
+            label: "备注",
+            prop: "orderRemark",
+            type: "textarea",
+            minRows: 2,
+            span: 24
+          }
+        ]
+      },
+      detailOption: {
+        menuBtn: false,
+        labelWidth: 100,
+        column: [
+          {
+            label: "系统号",
+            prop: "sysNo",
+            span: 8,
+            disabled: true
+          },
+          {
+            label: "打印时间",
+            prop: "printTime",
+            span: 8,
+            disabled: true
+          },
+          {
+            label: "打印次数",
+            prop: "printNumber",
+            span: 8,
+            disabled: true
+          },
+          {
+            label: "客户欠款",
+            prop: "corpDebt",
+            span: 8,
+            disabled: true
+          },
+          {
+            label: "总数量",
+            prop: "orderQuantity",
+            span: 8,
+            disabled: true
+          },
+          {
+            label: "应收金额",
+            prop: "debitAmount",
+            span: 8,
+            disabled: true
+          },
+          {
+            label: "总金额",
+            prop: "amount",
+            span: 8,
+            disabled: true
+          },
+          {
+            label: "制单人",
+            prop: "createUserName",
+            span: 8,
+            disabled: true
+          }
+        ]
+      },
+      dataList: [],
+      tableOption: {},
+      dialogVisible: false,
+      selectionList: [],
+      treeDeptId: null,
+      reData: null,
+      treeOption: {
+        nodeKey: "id",
+        lazy: true,
+        treeLoad: function(node, resolve) {
+          const parentId = node.level === 0 ? 0 : node.data.id;
+          getDeptLazyTree(parentId).then(res => {
+            resolve(
+              res.data.data.map(item => {
+                return {
+                  ...item,
+                  leaf: !item.hasChildren
+                };
+              })
+            );
+          });
+        },
+        addBtn: false,
+        menu: false,
+        size: "small",
+        props: {
+          label: "title",
+          value: "value",
+          children: "children"
+        }
+      },
+      page: {
+        pageSize: 10,
+        currentPage: 1,
+        total: 0
+      },
+      search: {},
+      goodsList: [],
+      loading: false,
+      goodsOption: {},
+      treeStyle: "height:" + (window.innerHeight - 315) + "px",
+      goodsoptions: [],
+      // 仓库配置
+      configurationWarehouse: {
+        multipleChoices: false,
+        multiple: false,
+        collapseTags: false,
+        placeholder: "请点击右边按钮选择",
+        dicData: []
+      },
+      uploadData: [],
+      goodData: [], // 存储所有商品信息
+      switchDialog: false, // 报表弹窗控制
+      userList: [],
+      activeName: "searchList",
+      // 商品列表数据合计
+      goodsListShow: [],
+      // 商品列表暂存
+      goodsListSave: [],
+      pageList: {
+        pageSize: 10,
+        currentPage: 1,
+        total: 0
+      },
+      applyPaymentList: [],
+      billType: "收费", //账单类型
+      billData: {}, //账单需要数据
+      applySettlementDialog: false, //生成账单组件
+      financialAccountDialog: false,
+      feesOption: [],
+      unitOption: [],
+      baseURL: "/api/blade-purchase-sales/orderitems/importDealerOrder",
+      headers: { "Blade-Auth": "Bearer " + getToken() },
+      uploadParam: {},
+      historyVisible: false,
+      historyParams: {},
+      oldForm: {},
+      oldDataList: [],
+      oldUploadData: [],
+      checkDisabled: false, // 审核状态
+      checker: false,
+      checkId: "",
+      batchNo: "",
+      checkDialog: false,
+      checkScheduleDialog: false,
+      checkData: {},
+      applicationDialog: false // 历史账单查看弹窗
+    };
+  },
+  async created() {
+    this.getWorkDicts("unit").then(res => {
+      this.unitOption = res.data.data;
+    });
+    this.tableOption = await this.getColumnData(
+      this.getColumnName(79),
+      tableOption
+    );
+    this.goodsOption = await this.getColumnData(
+      this.getColumnName(80),
+      goodsOption
+    );
+    getGoods(1, 10).then(res => {
+      if (res.data.data.total > 0) {
+        this.goodsoptions = res.data.data.records;
+        if (Math.ceil(res.data.data.total / 10) > 1) {
+          for (let i = 2; i <= Math.ceil(res.data.data.total / 10); i++) {
+            getGoods(i, 10).then(e => {
+              this.goodsoptions = this.goodsoptions.concat(e.data.data.records);
+            });
+          }
+        }
+      }
+    });
+    getUserInfo().then(res => {
+      this.$set(this.form, "createUserName", res.data.data.realName);
+      this.$set(this.form, "createUser", res.data.data.id);
+    });
+    gainUser().then(res => {
+      this.userList = res.data.data;
+    });
+    feeList().then(res => {
+      this.feesOption = res.data.data.records;
+    });
+    this.$set(this.form, "businesDate", getCurrentDate());
+    this.$set(this.form, "status", 0);
+    this.$set(this.form, "confirmStatus", 0);
+    if (this.detailData.query) {
+      this.disabled = true;
+      this.option.column.map(e => {
+        this.$set(e, "disabled", true);
+      });
+      this.queryData(this.detailData.id);
+    } else if (this.detailData.auditId) {
+      this.checker = true;
+      this.batchNo = this.detailData.check.batchNo;
+      this.queryData(this.detailData.id);
+    } else {
+      this.dataList = [
+        {
+          code: null,
+          cname: null,
+          typeno: null,
+          brandItem: null,
+          specsOne: null,
+          specsTwo: null,
+          unit: null,
+          storageQuantity: 0,
+          orderQuantity: 0,
+          size: null,
+          price: 0,
+          amount: 0,
+          $cellEdit: true
+        }
+      ];
+    }
+  },
+  filters: {
+    IntegerFormat(num) {
+      return IntegerFormat(num);
+    },
+    decimalFormat(num) {
+      return num ? Number(num).toFixed(2) : "0.00";
+    }
+  },
+  methods: {
+    // 查询
+    queryData(id) {
+      this.pageLoading = true;
+      dataDetail(id)
+        .then(res => {
+          this.form = res.data.data;
+          this.form.amount = Number(this.form.amount).toFixed(2);
+          if (this.form.storageId) {
+            this.uploadParam = {
+              storageId: this.form.storageId
+            };
+          }
+          this.confirmDisabled = this.form.confirmStatus == 3 ? true : false;
+          this.checkDisabled = this.form.status > 0 ? true : false;
+          if (this.confirmDisabled) {
+            // this.option.column.map(e => {
+            //   this.$set(e, 'disabled', true)
+            // })
+          }
+          this.dataList = this.form.orderItemsList
+            ? this.form.orderItemsList
+            : [];
+          this.uploadData = this.form.orderFilesList
+            ? this.form.orderFilesList
+            : [];
+          delete this.form.orderItemsList;
+          delete this.form.orderFilesList;
+          this.oldForm = { ...this.form };
+          this.oldDataList = [...this.dataList];
+          this.oldUploadData = [...this.uploadData];
+          this.dataList.forEach(async item => {
+            if (item.batch == 1) {
+              item.arr = await this.getLotNo({
+                itemId: item.itemId,
+                storageId: this.form.storageId,
+                tradeType: "JXS"
+              });
+            }
+          });
+        })
+        .finally(() => {
+          this.pageLoading = false;
+        });
+    },
+    cellStyle() {
+      return "padding:0;height:40px;";
+    },
+    openEdit() {
+      this.disabled = false;
+      this.option.column.map(e => {
+        if (this.confirmDisabled || this.checkDisabled) {
+          if (
+            e.prop == "businesDate" ||
+            e.prop == "sysNo" ||
+            e.prop == "orderNo"
+          ) {
+            this.$set(e, "disabled", true);
+          } else {
+            this.$set(e, "disabled", false);
+          }
+        } else {
+          this.$set(e, "disabled", false);
+        }
+      });
+    },
+    copyDoc() {
+      this.$emit("copyOrder", this.form.id);
+    },
+    getCorpData(row) {
+      KHDetail(row.id).then(res => {
+        if (res.data.data.belongtocompany) {
+          this.$set(this.form, "belongToCorpId", res.data.data.belongtocompany);
+        } else {
+          this.$set(this.form, "belongToCorpId", null);
+        }
+      });
+    },
+    getGSData(row) {},
+    //修改提交触发
+    editCustomer(status) {
+      this.$refs["form"].validate((valid, done) => {
+        done();
+        if (valid) {
+          for (let item in this.dataList) {
+            if (this.dataList[item].batch == 1 && !this.dataList[item].lotNo) {
+              return this.$message.error(
+                "第" + (Number(item) + 1) + "行明细批次号未填写"
+              );
+            }
+          }
+          // 总金额计算
+          let amount = 0;
+          this.dataList.forEach((item, index) => {
+            if (item.batch == 1 && !item.lotNo) {
+            }
+            amount = Number(amount) + Number(item.amount);
+          });
+          this.$set(this.form, "debitAmount", amount.toFixed(2));
+          this.$set(this.form, "amount", amount.toFixed(2));
+          this.form.billType = "XS";
+          this.$set(this.form, "orderItemsList", this.dataList);
+          this.$set(this.form, "orderFilesList", this.uploadData);
+          this.btnLoading = true;
+          typeSave(this.form)
+            .then(res => {
+              this.$message({
+                type: "success",
+                message: this.form.id ? "修改成功!" : "新增成功!"
+              });
+              this.queryData(res.data.data.id);
+            })
+            .finally(() => {
+              this.btnLoading = false;
+            });
+        } else {
+          return false;
+        }
+      });
+    },
+    //返回列表
+    backToList() {
+      this.$emit("goBack");
+    },
+    async saveColumn() {
+      const inSave = await this.saveColumnData(
+        this.getColumnName(79),
+        this.tableOption
+      );
+      if (inSave) {
+        this.$message.success("保存成功");
+        //关闭窗口
+        this.$refs.crud.$refs.dialogColumn.columnBox = false;
+        this.$nextTick(() => {
+          this.$refs.crud.doLayout();
+        });
+      }
+    },
+    async resetColumn() {
+      this.tableOption = tableOption;
+      const inSave = await this.delColumnData(
+        this.getColumnName(79),
+        tableOption
+      );
+      if (inSave) {
+        this.$nextTick(() => {
+          this.$refs.crud.doLayout();
+        });
+        this.$message.success("重置成功");
+        //关闭窗口
+        setTimeout(() => {
+          this.$refs.crud.$refs.dialogColumn.columnBox = false;
+        }, 1000);
+      }
+    },
+    //商品明细导入
+    newDetails() {
+      this.$refs["form"].validate(valid => {
+        if (valid) {
+          this.dialogVisible = !this.dialogVisible;
+        }
+      });
+    },
+    // 获得库存价
+    async getStockInfo(data) {
+      //tradeType JXS
+      //goodsId
+      //storageId
+      //lotNo 批次号
+      let form = {};
+      await getDetail(data).then(res => {
+        const a = res.data.data
+          ? res.data.data
+          : {
+              stock: 0,
+              balanceAmount: 0,
+              balanceQuantity: 0
+            };
+        this.$set(
+          form,
+          "purchaseAmount",
+          a.inQuantity
+            ? a.inQuantity == 0
+              ? 0
+              : (Number(a.inAmount) / Number(a.inQuantity)).toFixed(2)
+            : 0
+        );
+        this.$set(form, "stock", a.balanceQuantity);
+      });
+      return form;
+    },
+    // 获得批次号
+    async getLotNo(data) {
+      let arr = [];
+      await getLotNo(data).then(res => {
+        arr = res.data.data ? res.data.data : [];
+      });
+      return arr;
+    },
+    importGoods() {
+      let form = {};
+      if (this.reData) {
+        if (this.selectionList.length != 1) {
+          return this.$message.error("重新选择的时候只能选择一条数据");
+        } else {
+          this.selectionList.forEach(e => {
+            this.dataList.forEach(async (item, index) => {
+              if (index == this.reData.index) {
+                getMarketPrice({ code: e.code, isFreight: 0, isLabel: 0 }).then(
+                  response => {
+                    if (response.data.data.length > 0) {
+                      this.$set(e, "price", response.data.data[0].salePrice);
+                    } else {
+                      this.$set(e, "price", "0");
+                    }
+                  }
+                );
+                let historyData = await this.getHistoryData(e, 1); // 获得最新数据
+                if (historyData.length > 0) {
+                  e.newJob = historyData[0].price;
+                  e.newDate = historyData[0].businesDate;
+                } else {
+                  e.newJob = null;
+                  e.newDate = null;
+                }
+                if (e.batch == 0) {
+                  form = await this.getStockInfo({
+                    tradeType: "JXS",
+                    goodsId: e.id,
+                    storageId: this.form.storageId
+                  });
+                  item.storageQuantity = form.stock;
+                  item.purchaseAmount = form.purchaseAmount;
+                } else {
+                  item.storageQuantity = 0;
+                  item.purchaseAmount = 0;
+                  item.arr = await this.getLotNo({
+                    itemId: e.id,
+                    storageId: this.form.storageId,
+                    tradeType: "JXS"
+                  });
+                }
+                item.itemId = e.id;
+                item.code = e.code;
+                item.cname = e.cname;
+                item.corpId = e.corpId;
+                item.corpName = e.corpName;
+                item.brandItem = e.brandItem;
+                item.specsOne = e.specsOne;
+                item.specsTwo = e.specsTwo;
+                item.typeno = e.typeno;
+                item.unit = e.unit;
+                item.size = e.size;
+                item.priceCategory = e.goodsTypeName;
+                item.purchaseAmount = e.purchaseAmount;
+                item.batch = e.batch;
+                item.newDate = e.newDate;
+                item.newJob = e.newJob;
+                item.price = e.price;
+                item.$cellEdit = true;
+              }
+            });
+          });
+        }
+      } else {
+        if (this.goodsListSave.length > 0) {
+          // 暂存的有数据
+          this.goodsListSave.forEach(async e => {
+            getMarketPrice({ code: e.code, isFreight: 0, isLabel: 0 }).then(
+              response => {
+                if (response.data.data.length > 0) {
+                  this.$set(e, "price", response.data.data[0].salePrice);
+                } else {
+                  this.$set(e, "price", "0");
+                }
+              }
+            );
+            let historyData = await this.getHistoryData(e, 1); // 获得最新数据
+            if (historyData.length > 0) {
+              e.newJob = historyData[0].price;
+              e.newDate = historyData[0].businesDate;
+            } else {
+              e.newJob = null;
+              e.newDate = null;
+            }
+            if (e.batch == 0) {
+              form = await this.getStockInfo({
+                tradeType: "JXS",
+                goodsId: e.id,
+                storageId: this.form.storageId
+              });
+              e.storageQuantity = form.stock;
+              e.purchaseAmount = form.purchaseAmount;
+              e.arr = [];
+            } else {
+              e.storageQuantity = 0;
+              e.purchaseAmount = 0;
+              e.arr = await this.getLotNo({
+                itemId: e.id,
+                storageId: this.form.storageId,
+                tradeType: "JXS"
+              });
+            }
+            this.dataList.push({
+              itemId: e.id,
+              code: e.code,
+              cname: e.cname,
+              brandItem: e.brandItem,
+              specsOne: e.specsOne,
+              specsTwo: e.specsTwo,
+              typeno: e.typeno,
+              corpId: e.corpId,
+              corpName: e.corpName,
+              unit: e.unit,
+              size: e.size,
+              price: e.price,
+              amount: 0,
+              orderQuantity: 0,
+              storageQuantity: e.storageQuantity,
+              purchaseAmount: e.purchaseAmount,
+              batch: e.batch,
+              arr: e.arr,
+              newJob: e.newJob,
+              newDate: e.newDate,
+              $cellEdit: true
+            });
+          });
+        } else {
+          this.selectionList.forEach(async e => {
+            getMarketPrice({ code: e.code, isFreight: 0, isLabel: 0 }).then(
+              response => {
+                if (response.data.data.length > 0) {
+                  this.$set(e, "price", response.data.data[0].salePrice);
+                } else {
+                  this.$set(e, "price", "0");
+                }
+              }
+            );
+            let historyData = await this.getHistoryData(e, 1); // 获得最新数据
+            if (historyData.length > 0) {
+              e.newJob = historyData[0].price;
+              e.newDate = historyData[0].businesDate;
+            } else {
+              e.newJob = null;
+              e.newDate = null;
+            }
+            if (e.batch == 0) {
+              form = await this.getStockInfo({
+                tradeType: "JXS",
+                goodsId: e.id,
+                storageId: this.form.storageId
+              });
+              e.storageQuantity = form.stock;
+              e.purchaseAmount = form.purchaseAmount;
+              e.arr = [];
+            } else {
+              e.storageQuantity = 0;
+              e.purchaseAmount = 0;
+              e.arr = await this.getLotNo({
+                itemId: e.id,
+                storageId: this.form.storageId,
+                tradeType: "JXS"
+              });
+            }
+            this.dataList.push({
+              itemId: e.id,
+              code: e.code,
+              cname: e.cname,
+              brandItem: e.brandItem,
+              specsOne: e.specsOne,
+              specsTwo: e.specsTwo,
+              typeno: e.typeno,
+              corpId: e.corpId,
+              corpName: e.corpName,
+              unit: e.unit,
+              size: e.size,
+              amount: 0,
+              orderQuantity: 0,
+              storageQuantity: e.storageQuantity,
+              purchaseAmount: e.purchaseAmount,
+              batch: e.batch,
+              arr: e.arr,
+              newJob: e.newJob,
+              newDate: e.newDate,
+              price: e.price,
+              $cellEdit: true
+            });
+          });
+        }
+      }
+      this.dialogVisible = false;
+    },
+    closeGoods() {
+      this.selectionList = [];
+      this.treeDeptId = "";
+      this.reData = null;
+      this.activeName = "searchList";
+      this.goodsListSave = [];
+    },
+    nodeClick(data) {
+      this.treeDeptId = data.id;
+      this.page.currentPage = 1;
+      this.onLoad(this.page);
+    },
+    //商品查询
+    onLoad(page, params = {}) {
+      let obj = this.deepClone(Object.assign(params, this.search));
+      this.loading = true;
+      getGoods(page.currentPage, page.pageSize, this.treeDeptId, obj)
+        .then(res => {
+          const data = res.data.data;
+          this.page.total = data.total;
+          this.goodsList = data.records;
+          this.pageList.total = data.total;
+          this.goodsListShow = data.records;
+          if (this.page.total) {
+            this.goodsOption.height = window.innerHeight - 350;
+          }
+        })
+        .finally(() => {
+          this.loading = false;
+        });
+    },
+    searchChange(params, done) {
+      this.search = this.deepClone(params);
+      this.onLoad(this.page, params);
+      done();
+    },
+    selectionChange(list) {
+      this.selectionList = list;
+    },
+    rowClick(row) {
+      this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
+    },
+    async saveGoodsColumn() {
+      const inSave = await this.saveColumnData(
+        this.getColumnName(80),
+        this.goodsOption
+      );
+      if (inSave) {
+        this.$message.success("保存成功");
+        //关闭窗口
+        this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
+        this.$nextTick(() => {
+          this.$refs.goodsCrud.doLayout();
+        });
+      }
+    },
+    async resetGoodsColumn() {
+      this.goodsOption = goodsOption;
+      const inSave = await this.delColumnData(
+        this.getColumnName(80),
+        goodsOption
+      );
+      if (inSave) {
+        this.$nextTick(() => {
+          this.$refs.goodsCrud.doLayout();
+        });
+        this.$message.success("重置成功");
+        //关闭窗口
+        setTimeout(() => {
+          this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
+        }, 1000);
+      }
+    },
+    // 报表
+    openReport() {
+      this.switchDialog = !this.switchDialog;
+    },
+    // 报表关闭
+    onClose(val) {
+      this.switchDialog = val;
+    },
+    rowCell(row, index) {
+      if (row.$cellEdit == true) {
+        this.$set(row, "$cellEdit", false);
+      } else {
+        this.$set(row, "$cellEdit", true);
+      }
+    },
+    rowDel(row, index) {
+      this.$confirm("确定删除数据?", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        if (row.id) {
+          removeGoods(row.id).then(res => {
+            this.$message({
+              type: "success",
+              message: "删除成功!"
+            });
+            this.dataList.splice(row.$index, 1);
+          });
+        } else {
+          this.$message({
+            type: "success",
+            message: "删除成功!"
+          });
+          this.dataList.splice(row.$index, 1);
+        }
+      });
+    },
+    codeChange(row) {
+      let form = {};
+      this.goodsoptions.forEach(async e => {
+        if (e.code == row.code) {
+          getMarketPrice({ code: e.code, isFreight: 0, isLabel: 0 }).then(
+            response => {
+              if (response.data.data.length > 0) {
+                this.$set(e, "price", response.data.data[0].salePrice);
+              } else {
+                this.$set(e, "price", "0");
+              }
+              this.$set(
+                row,
+                "amount",
+                (Number(e.price) * Number(row.orderQuantity)).toFixed(2)
+              );
+            }
+          );
+          let historyData = await this.getHistoryData(e, 1); // 获得最新数据
+          if (historyData.length > 0) {
+            e.newJob = historyData[0].price;
+            e.newDate = historyData[0].businesDate;
+          } else {
+            e.newJob = null;
+            e.newDate = null;
+          }
+          if (e.batch == 0) {
+            form = await this.getStockInfo({
+              tradeType: "JXS",
+              goodsId: e.id,
+              storageId: this.form.storageId
+            });
+            e.storageQuantity = form.stock;
+            e.purchaseAmount = form.purchaseAmount;
+            e.arr = [];
+          } else {
+            e.storageQuantity = 0;
+            e.purchaseAmount = 0;
+            e.arr = await this.getLotNo({
+              itemId: e.id,
+              storageId: this.form.storageId,
+              tradeType: "JXS"
+            });
+          }
+          row.itemId = e.id;
+          row.storageQuantity = e.storageQuantity;
+          row.cname = e.cname;
+          row.code = e.code;
+          row.corpId = e.corpId;
+          row.corpName = e.corpName;
+          row.brandItem = e.brandItem;
+          row.specsOne = e.specsOne;
+          row.specsTwo = e.specsTwo;
+          row.typeno = e.typeno;
+          row.unit = e.unit;
+          row.size = e.size;
+          row.arr = e.arr;
+          row.priceCategory = e.goodsTypeName;
+          row.purchaseAmount = e.purchaseAmount;
+          row.batch = e.batch;
+          row.newJob = e.newJob;
+          row.newDate = e.newDate;
+          row.price = e.price;
+        }
+      });
+    },
+    cnameChange(row) {
+      let form = {};
+      this.goodsoptions.forEach(async e => {
+        if (e.id == row.itemId) {
+          getMarketPrice({ code: e.code, isFreight: 0, isLabel: 0 }).then(
+            response => {
+              if (response.data.data.length > 0) {
+                this.$set(e, "price", response.data.data[0].salePrice);
+              } else {
+                this.$set(e, "price", "0");
+              }
+              this.$set(
+                row,
+                "amount",
+                (Number(e.price) * Number(row.orderQuantity)).toFixed(2)
+              );
+            }
+          );
+          let historyData = await this.getHistoryData(e, 1); // 获得最新数据
+          if (historyData.length > 0) {
+            e.newJob = historyData[0].price;
+            e.newDate = historyData[0].businesDate;
+          } else {
+            e.newJob = null;
+            e.newDate = null;
+          }
+          if (e.batch == 0) {
+            form = await this.getStockInfo({
+              tradeType: "JXS",
+              goodsId: e.id,
+              storageId: this.form.storageId
+            });
+            e.storageQuantity = form.stock;
+            e.purchaseAmount = form.purchaseAmount;
+            e.arr = [];
+          } else {
+            e.storageQuantity = 0;
+            e.purchaseAmount = 0;
+            e.arr = await this.getLotNo({
+              itemId: e.id,
+              storageId: this.form.storageId,
+              tradeType: "JXS"
+            });
+          }
+          row.storageQuantity = e.storageQuantity;
+          row.cname = e.cname;
+          row.code = e.code;
+          row.corpId = e.corpId;
+          row.corpName = e.corpName;
+          row.brandItem = e.brandItem;
+          row.specsOne = e.specsOne;
+          row.specsTwo = e.specsTwo;
+          row.typeno = e.typeno;
+          row.unit = e.unit;
+          row.size = e.size;
+          row.arr = e.arr;
+          row.priceCategory = e.goodsTypeName;
+          row.purchaseAmount = e.purchaseAmount;
+          row.batch = e.batch;
+          row.newDate = e.newDate;
+          row.newJob = e.newJob;
+          row.price = e.price;
+        }
+      });
+    },
+    rePick(row, index) {
+      this.reData = {
+        ...row,
+        index: index
+      };
+      this.newDetails();
+    },
+    // 商品信息价格计算
+    amountChange(row) {
+      if (!row.orderQuantity) {
+        row.orderQuantity = 0;
+      }
+      if (!row.price) {
+        row.price = 0;
+      }
+      row.amount = Number(row.price) * Number(row.orderQuantity);
+    },
+    // 标签页切换
+    tabHandle(data) {
+      if (data.name == "searchList") {
+        this.goodsListShow = this.goodsList;
+        this.page.total = this.pageList.total;
+      } else if (data.name == "importStaging") {
+        this.goodsListShow = this.goodsListSave;
+        this.page.total = 0;
+      }
+    },
+    removeStagList(row, index) {
+      this.goodsListSave.splice(row.$index, 1);
+    },
+    importStagList(row, index) {
+      this.goodsListSave.push(row);
+    },
+    // 生成结算
+    applySettlement(type) {
+      this.beforeBillData(true, type);
+      this.financialAccountDialog = true;
+    },
+    //生成账单 拿到主表信息
+    beforeBillData(bool, type) {
+      this.billType = type;
+      this.applyPaymentList = [];
+      this.dataList.map(e => {
+        const form = {
+          srcOrderno: this.form.orgOrderNo,
+          srcParentId: this.form.id,
+          itemType: "销售",
+          corpsName: this.form.corpName,
+          corpId: this.form.corpId,
+          currency: "CNY",
+          exchangeRate: "1",
+          taxRate: "0",
+          accDate: this.form.businesDate,
+          srcType: 1,
+          chargeMember: this.form.chargeMember,
+          parentId: this.form.id,
+          tradeType: "JXS",
+          optionType: "JXS",
+          amount: e.amount,
+          costType: this.feesOption.find(item => item.cname == "货款")
+            ? this.feesOption.find(item => item.cname == "货款").id
+            : null,
+          srcFeesId: e.id,
+          goodName: e.cname,
+          price: e.price,
+          quantity: e.orderQuantity,
+          unit: e.unit
+        };
+        this.applyPaymentList.push(form);
+      });
+    },
+    //关闭账单
+    choceFun() {
+      this.financialAccountDialog = false;
+    },
+    // 批次号选择
+    async lotNoChange(row) {
+      if (row.lotNo) {
+        const form = await this.getStockInfo({
+          tradeType: "JXS",
+          goodsId: row.itemId,
+          storageId: this.form.storageId,
+          lotNo: row.lotNo
+        });
+        row.storageQuantity = form.stock;
+        row.purchaseAmount = form.purchaseAmount;
+      } else {
+        row.storageQuantity = 0;
+        row.purchaseAmount = 0;
+      }
+    },
+    // 确认或者取消订单
+    dealerSubmit() {
+      if (this.verification()) {
+        let dealer;
+        if (this.form.confirmStatus == 0) {
+          dealer = 1;
+        } else if (this.form.confirmStatus == 3) {
+          dealer = 2;
+        }
+        this.btnLoading = true;
+        dealerSubmit({
+          id: this.form.id,
+          dealer
+        })
+          .then(res => {
+            if (res.data.code == 200) {
+              this.$message.success("操作成功");
+              this.queryData(this.form.id);
+            } else {
+              this.$message.error(res.data.msg);
+            }
+          })
+          .finally(() => {
+            this.btnLoading = false;
+          });
+      }
+    },
+    // 下载模板
+    downloadHandle() {
+      this.$confirm("是否下载模板文件?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      })
+        .then(() => {
+          window.open(
+            `/api/blade-purchase-sales/orderitems/exportDealerOrder?${
+              this.website.tokenHeader
+            }=${getToken()}`
+          );
+        })
+        .catch(() => {
+          this.$message({
+            type: "info",
+            message: "已取消"
+          });
+        });
+    },
+    //文件上传时
+    uploading(event, file, fileList) {
+      this.openFullScreen(false, "文件正在解析中");
+    },
+    importTemplate(res, file) {
+      this.openFullScreen(true);
+      res.data.forEach(item => {});
+      this.dataList = this.dataList.concat(res.data);
+    },
+    uploadError(err, file, fileList) {
+      this.openFullScreen(true);
+      this.$message.error(JSON.parse(err.message).msg);
+    },
+    //遮罩层
+    openFullScreen(res, text) {
+      const loading = this.$loading({
+        lock: true,
+        text: text,
+        spinner: "el-icon-loading",
+        background: "rgba(0, 0, 0, 0.7)"
+      });
+      if (res === true) loading.close();
+    },
+    // 仓库选择
+    storageChange(value) {
+      if (this.form.storageId) {
+        this.uploadParam = {
+          storageId: value
+        };
+      }
+    },
+    // 获得历史数据
+    async getHistoryData(row, typeId = null) {
+      let data;
+      const params = {
+        typeId,
+        tradeType: "JXS",
+        billType: "XS",
+        itemId: row.id
+      };
+      await historyPrice(params).then(res => {
+        data = res.data.data ? res.data.data : [];
+      });
+      return data;
+    },
+    openHistory(row) {
+      this.historyParams = {
+        tradeType: "JXS",
+        billType: "XS",
+        itemId: row.itemId
+      };
+      this.historyVisible = true;
+      this.$nextTick(() => {
+        this.$refs.history.init();
+      });
+    },
+    closeDialog() {
+      this.historyVisible = false;
+    },
+    // 销售金额获取
+    async getMarketPrice(row) {
+      await getMarketPrice({ code: row.code }).then(res => {
+        this.salesPriceOtion = res.data.data;
+      });
+    },
+    // 验证新旧值对比
+    verification() {
+      if (
+        contrastObj(this.form, this.oldForm) ||
+        contrastList(this.dataList, this.oldDataList) ||
+        contrastList(this.uploadData, this.oldUploadData)
+      ) {
+        this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        })
+          .then(() => {
+            this.editCustomer();
+          })
+          .catch(() => {
+            return false; //取消改动数据
+          });
+      } else {
+        return true;
+      }
+    },
+    // 请核
+    pleaseCheck() {
+      if (this.verification()) {
+        const data = {
+          id: this.form.id,
+          checkType: "xsqh",
+          url: "/dealer/sales/index",
+          pageStatus: "this.$store.getters.dealerSaleStatus",
+          pageLabel: "销售订单(D)",
+          checkFlag: 2
+        };
+        this.btnLoading = true;
+        pleaseCheck(data)
+          .then(res => {
+            this.$message.success("请核成功");
+            this.queryData(this.form.id);
+          })
+          .catch(() => {
+            this.$message.error("请核失败");
+          })
+          .finally(() => {
+            this.btnLoading = false;
+          });
+      }
+    },
+    repealCancel() {
+      this.$confirm("您确定撤回此次申请吗?", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        const data = {
+          id: this.form.id,
+          checkType: "xsqh",
+          pageLabel: "销售订单(D)",
+          checkFlag: 2
+        };
+        this.pageLoading = true;
+        repealCancel(data)
+          .then(res => {
+            this.$message.success("撤回成功");
+            this.queryData(this.form.id);
+          })
+          .finally(() => {
+            this.pageLoading = false;
+          });
+      });
+    },
+    //打开审核
+    openCheckDialog() {
+      this.checkData = this.detailData.check;
+      this.checkDialog = true;
+    },
+    //关闭审核
+    choceCheckFun() {
+      this.checkDialog = false;
+    },
+    choceScheduleFun() {
+      this.checkScheduleDialog = false;
+    },
+    // 查看申请记录
+    openApplicationDialog() {
+      this.applicationDialog = true;
+    },
+    //关闭记录
+    choceApplication() {
+      this.applicationDialog = false;
+    }
+  }
+};
+</script>
+
+<style lang="scss" scoped>
+.trading-form ::v-deep .el-form-item {
+  margin-bottom: 8px !important;
+}
+::v-deep .el-form-item__error {
+  display: none !important;
+}
+::v-deep .select-component {
+  display: flex !important;
+}
+</style>

+ 277 - 116
src/views/dealer/sales/detail.vue

@@ -178,7 +178,7 @@
     </div>
     <!--    商品弹窗-->
     <el-dialog title="导入商品" append-to-body class="el-dialogDeep" :visible.sync="dialogVisible" width="80%"
-      :close-on-click-modal="false" :destroy-on-close="true" :close-on-press-escape="false" @close="closeGoods"
+      :close-on-click-modal="false" :destroy-on-close="true" :close-on-press-escape="false" @closed="closeGoods"
       top="5vh" v-dialog-drag>
       <span>
         <el-row>
@@ -846,71 +846,140 @@ export default {
         if (this.selectionList.length != 1) {
           return this.$message.error("重新选择的时候只能选择一条数据");
         } else {
+          let goodsList = []
           this.selectionList.forEach(e => {
-            this.dataList.forEach(async (item, index) => {
-              if (index == this.reData.index) {
-                salesOrderEntry({ code: e.code, isFreight: 0, isLabel: 0, itemId: e.id, billType: "XS", tradeType: "JXS", storageId: this.form.storageId, stockGoods: { id: e.id, storageId: this.form.storageId, } })
-                getMarketPrice({ code: e.code, isFreight: 0, isLabel: 0 }).then(
-                  response => {
-                    if (response.data.data.length > 0) {
-                      this.$set(e, "price", response.data.data[0].salePrice);
-                    } else {
-                      this.$set(e, "price", "0");
-                    }
-                  }
-                );
-                let historyData = await this.getHistoryData(e, 1); // 获得最新数据
-                if (historyData.length > 0) {
-                  e.newJob = historyData[0].price;
-                  e.newDate = historyData[0].businesDate;
-                } else {
-                  e.newJob = null;
-                  e.newDate = null;
-                }
-                if (e.batch == 0) {
-                  form = await this.getStockInfo({
-                    tradeType: "JXS",
-                    goodsId: e.id,
-                    storageId: this.form.storageId
-                  });
-                  item.storageQuantity = form.stock;
-                  item.purchaseAmount = form.purchaseAmount;
-                } else {
-                  item.storageQuantity = 0;
-                  item.purchaseAmount = 0;
-                  item.arr = await this.getLotNo({
-                    itemId: e.id,
-                    storageId: this.form.storageId,
-                    tradeType: "JXS"
-                  });
+            goodsList.push({
+              itemId: e.id,
+              code: e.code
+            })
+            // this.dataList.forEach(async (item, index) => {
+            //   if (index == this.reData.index) {
+            // getMarketPrice({ code: e.code, isFreight: 0, isLabel: 0 }).then(
+            //   response => {
+            //     if (response.data.data.length > 0) {
+            //       this.$set(e, "price", response.data.data[0].salePrice);
+            //     } else {
+            //       this.$set(e, "price", "0");
+            //     }
+            //   }
+            // );
+            // let historyData = await this.getHistoryData(e, 1); // 获得最新数据
+            // if (historyData.length > 0) {
+            //   e.newJob = historyData[0].price;
+            //   e.newDate = historyData[0].businesDate;
+            // } else {
+            //   e.newJob = null;
+            //   e.newDate = null;
+            // }
+            // if (e.batch == 0) {
+            //   form = await this.getStockInfo({
+            //     tradeType: "JXS",
+            //     goodsId: e.id,
+            //     storageId: this.form.storageId
+            //   });
+            //   item.storageQuantity = form.stock;
+            //   item.purchaseAmount = form.purchaseAmount;
+            // } else {
+            //   item.storageQuantity = 0;
+            //   item.purchaseAmount = 0;
+            //   item.arr = await this.getLotNo({
+            //     itemId: e.id,
+            //     storageId: this.form.storageId,
+            //     tradeType: "JXS"
+            //   });
+            // }
+            // item.itemId = e.id;
+            // item.code = e.code;
+            // item.cname = e.cname;
+            // item.corpId = e.corpId;
+            // item.corpName = e.corpName;
+            // item.brandItem = e.brandItem;
+            // item.specsOne = e.specsOne;
+            // item.specsTwo = e.specsTwo;
+            // item.typeno = e.typeno;
+            // item.unit = e.unit;
+            // item.size = e.size;
+            // item.priceCategory = e.goodsTypeName;
+            // item.purchaseAmount = e.purchaseAmount;
+            // item.batch = e.batch;
+            // item.newDate = e.newDate;
+            // item.newJob = e.newJob;
+            // item.price = e.price;
+            // item.$cellEdit = true;
+            //   }
+            // });
+
+
+          });
+          salesOrderEntry({ isFreight: 0, isLabel: 0, billType: "XS", tradeType: "JXS", storageId: this.form.storageId, salesOrderEntry: goodsList }).then(res => {
+            this.selectionList.forEach(e => {
+              this.dataList.forEach(async (item, index) => {
+                if (index == this.reData.index) {
+                  // getMarketPrice({ code: e.code, isFreight: 0, isLabel: 0 }).then(
+                  //   response => {
+                  //     if (response.data.data.length > 0) {
+
+                  //     } else {
+                  //       this.$set(e, "price", "0");
+                  //     }
+                  //   }
+                  // );
+                  e.price = res.data.data[index].salePrice.length > 0 ? res.data.data[index].salePrice[0].salePrice : 0
+                  // let historyData = await this.getHistoryData(e, 1); // 获得最新数据
+                  // if (historyData.length > 0) {
+                  //   e.newJob = historyData[0].price;
+                  //   e.newDate = historyData[0].businesDate;
+                  // } else {
+                  //   e.newJob = null;
+                  //   e.newDate = null;
+                  // }
+                  // if (e.batch == 0) {
+                  //   form = await this.getStockInfo({
+                  //     tradeType: "JXS",
+                  //     goodsId: e.id,
+                  //     storageId: this.form.storageId
+                  //   });
+                  //   item.storageQuantity = form.stock;
+                  //   item.purchaseAmount = form.purchaseAmount;
+                  // } else {
+                  //   item.storageQuantity = 0;
+                  //   item.purchaseAmount = 0;
+                  //   item.arr = await this.getLotNo({
+                  //     itemId: e.id,
+                  //     storageId: this.form.storageId,
+                  //     tradeType: "JXS"
+                  //   });
+                  // }
+                  item.itemId = e.id;
+                  item.code = e.code;
+                  item.cname = e.cname;
+                  item.corpId = e.corpId;
+                  item.corpName = e.corpName;
+                  item.brandItem = e.brandItem;
+                  item.specsOne = e.specsOne;
+                  item.specsTwo = e.specsTwo;
+                  item.typeno = e.typeno;
+                  item.unit = e.unit;
+                  item.size = e.size;
+                  item.priceCategory = e.goodsTypeName;
+                  item.purchaseAmount = e.purchaseAmount;
+                  item.batch = e.batch;
+                  item.newDate = e.newDate;
+                  item.newJob = e.newJob;
+                  item.price = e.price;
+                  item.$cellEdit = true;
                 }
-                item.itemId = e.id;
-                item.code = e.code;
-                item.cname = e.cname;
-                item.corpId = e.corpId;
-                item.corpName = e.corpName;
-                item.brandItem = e.brandItem;
-                item.specsOne = e.specsOne;
-                item.specsTwo = e.specsTwo;
-                item.typeno = e.typeno;
-                item.unit = e.unit;
-                item.size = e.size;
-                item.priceCategory = e.goodsTypeName;
-                item.purchaseAmount = e.purchaseAmount;
-                item.batch = e.batch;
-                item.newDate = e.newDate;
-                item.newJob = e.newJob;
-                item.price = e.price;
-                item.$cellEdit = true;
-              }
+              });
+
+
             });
-          });
+          })
         }
       } else {
         if (this.goodsListSave.length > 0) {
           // 暂存的有数据
           this.goodsListSave.forEach(async e => {
-             salesOrderEntry({ code: e.code, isFreight: 0, isLabel: 0, itemId: e.id, billType: "XS", tradeType: "JXS", storageId: this.form.storageId, stockGoods: { id: e.id, storageId: this.form.storageId, } })
+            salesOrderEntry({ code: e.code, isFreight: 0, isLabel: 0, itemId: e.id, billType: "XS", tradeType: "JXS", storageId: this.form.storageId, stockGoods: { id: e.id, storageId: this.form.storageId, } })
             getMarketPrice({ code: e.code, isFreight: 0, isLabel: 0 }).then(
               response => {
                 if (response.data.data.length > 0) {
@@ -971,67 +1040,159 @@ export default {
             });
           });
         } else {
-          this.selectionList.forEach(async e => {
-            salesOrderEntry({ code: e.code, isFreight: 0, isLabel: 0, itemId: e.id, billType: "XS", tradeType: "JXS", storageId: this.form.storageId, stockGoods: { id: e.id, storageId: this.form.storageId, } })
-            getMarketPrice({ code: e.code, isFreight: 0, isLabel: 0 }).then(
-              response => {
-                if (response.data.data.length > 0) {
-                  this.$set(e, "price", response.data.data[0].salePrice);
-                } else {
-                  this.$set(e, "price", "0");
-                }
-              }
-            );
-            let historyData = await this.getHistoryData(e, 1); // 获得最新数据
-            if (historyData.length > 0) {
-              e.newJob = historyData[0].price;
-              e.newDate = historyData[0].businesDate;
-            } else {
-              e.newJob = null;
-              e.newDate = null;
-            }
-            if (e.batch == 0) {
-              form = await this.getStockInfo({
-                tradeType: "JXS",
-                goodsId: e.id,
-                storageId: this.form.storageId
-              });
-              e.storageQuantity = form.stock;
-              e.purchaseAmount = form.purchaseAmount;
-              e.arr = [];
-            } else {
-              e.storageQuantity = 0;
-              e.purchaseAmount = 0;
-              e.arr = await this.getLotNo({
+          let goodsList = []
+          let arr = []
+          arr = this.selectionList
+          this.selectionList.forEach(e => {
+            goodsList.push({
+              code: e.code,
+              itemId: e.id
+            })
+            // getMarketPrice({ code: e.code, isFreight: 0, isLabel: 0 }).then(
+            //   response => {
+            //     if (response.data.data.length > 0) {
+            //       this.$set(e, "price", response.data.data[0].salePrice);
+            //     } else {
+            //       this.$set(e, "price", "0");
+            //     }
+            //   }
+            // );
+            // let historyData = await this.getHistoryData(e, 1); // 获得最新数据
+            // if (historyData.length > 0) {
+            //   e.newJob = historyData[0].price;
+            //   e.newDate = historyData[0].businesDate;
+            // } else {
+            //   e.newJob = null;
+            //   e.newDate = null;
+            // }
+            // if (e.batch == 0) {
+            //   form = await this.getStockInfo({
+            //     tradeType: "JXS",
+            //     goodsId: e.id,
+            //     storageId: this.form.storageId
+            //   });
+            //   e.storageQuantity = form.stock;
+            //   e.purchaseAmount = form.purchaseAmount;
+            //   e.arr = [];
+            // } else {
+            //   e.storageQuantity = 0;
+            //   e.purchaseAmount = 0;
+            //   e.arr = await this.getLotNo({
+            //     itemId: e.id,
+            //     storageId: this.form.storageId,
+            //     tradeType: "JXS"
+            //   });
+            // }
+            // this.dataList.push({
+            //   itemId: e.id,
+            //   code: e.code,
+            //   cname: e.cname,
+            //   brandItem: e.brandItem,
+            //   specsOne: e.specsOne,
+            //   specsTwo: e.specsTwo,
+            //   typeno: e.typeno,
+            //   corpId: e.corpId,
+            //   corpName: e.corpName,
+            //   unit: e.unit,
+            //   size: e.size,
+            //   amount: 0,
+            //   orderQuantity: 0,
+            //   storageQuantity: e.storageQuantity,
+            //   purchaseAmount: e.purchaseAmount,
+            //   batch: e.batch,
+            //   arr: e.arr,
+            //   newJob: e.newJob,
+            //   newDate: e.newDate,
+            //   price: e.price,
+            //   $cellEdit: true
+            // });
+          });
+          salesOrderEntry({ isFreight: 0, isLabel: 0, billType: "XS", tradeType: "JXS", storageId: this.form.storageId, salesOrderEntry: goodsList }).then(res => {
+            let data = res.data.data
+            arr.forEach((e, index) => {
+              //   if (index == this.reData.index) {
+              //   // getMarketPrice({ code: e.code, isFreight: 0, isLabel: 0 }).then(
+              //   //   response => {
+              //   //     if (response.data.data.length > 0) {
+
+              //   //     } else {
+              //   //       this.$set(e, "price", "0");
+              //   //     }
+              //   //   }
+              //   // );
+              //   item.price=res.data.data[index].salePrice.length > 0 ? res.data.data[index].salePrice[0].salePrice : 0
+              //   // let historyData = await this.getHistoryData(e, 1); // 获得最新数据
+              //   // if (historyData.length > 0) {
+              //   //   e.newJob = historyData[0].price;
+              //   //   e.newDate = historyData[0].businesDate;
+              //   // } else {
+              //   //   e.newJob = null;
+              //   //   e.newDate = null;
+              //   // }
+              //   // if (e.batch == 0) {
+              //   //   form = await this.getStockInfo({
+              //   //     tradeType: "JXS",
+              //   //     goodsId: e.id,
+              //   //     storageId: this.form.storageId
+              //   //   });
+              //   //   item.storageQuantity = form.stock;
+              //   //   item.purchaseAmount = form.purchaseAmount;
+              //   // } else {
+              //   //   item.storageQuantity = 0;
+              //   //   item.purchaseAmount = 0;
+              //   //   item.arr = await this.getLotNo({
+              //   //     itemId: e.id,
+              //   //     storageId: this.form.storageId,
+              //   //     tradeType: "JXS"
+              //   //   });
+              //   // }
+              //   item.itemId = e.id;
+              //   item.code = e.code;
+              //   item.cname = e.cname;
+              //   item.corpId = e.corpId;
+              //   item.corpName = e.corpName;
+              //   item.brandItem = e.brandItem;
+              //   item.specsOne = e.specsOne;
+              //   item.specsTwo = e.specsTwo;
+              //   item.typeno = e.typeno;
+              //   item.unit = e.unit;
+              //   item.size = e.size;
+              //   item.priceCategory = e.goodsTypeName;
+              //   item.purchaseAmount = e.purchaseAmount;
+              //   item.batch = e.batch;
+              //   item.newDate = e.newDate;
+              //   item.newJob = e.newJob;
+              //   // item.price = e.price;
+              //   item.$cellEdit = true;
+              // }
+              console.log(index)
+              this.dataList.push({
+                price: data[index].salePrice.length > 0 ? data[index].salePrice[0].salePrice : 0,
+                newJob: data[index].historicalProcurement.length > 0 ? data[index].historicalProcurement[0].price : null,
+                newDate: data[index].historicalProcurement.length > 0 ? data[index].businesDate[0].price : null,
+                storageQuantity: e.batch == 0 ? (data[index].stockGoodsDetail ? data[index].stockGoodsDetail.stock : 0) : 0,
+                purchaseAmount: e.batch == 0 ? (data[index].stockGoodsDetail ? data[index].stockGoodsDetail.purchaseAmount : 0) : 0,
+                arr: e.batch != 0 ? data[index].goodsBatch : null,
                 itemId: e.id,
-                storageId: this.form.storageId,
-                tradeType: "JXS"
+                code: e.code,
+                cname: e.cname,
+                corpId: e.corpId,
+                corpName: e.corpName,
+                brandItem: e.brandItem,
+                specsOne: e.specsOne,
+                specsTwo: e.specsTwo,
+                typeno: e.typeno,
+                unit: e.unit,
+                size: e.size,
+                priceCategory: e.goodsTypeName,
+                // purchaseAmount:e.purchaseAmount,
+                batch: e.batch,
+                $cellEdit: true
               });
-            }
-            this.dataList.push({
-              itemId: e.id,
-              code: e.code,
-              cname: e.cname,
-              brandItem: e.brandItem,
-              specsOne: e.specsOne,
-              specsTwo: e.specsTwo,
-              typeno: e.typeno,
-              corpId: e.corpId,
-              corpName: e.corpName,
-              unit: e.unit,
-              size: e.size,
-              amount: 0,
-              orderQuantity: 0,
-              storageQuantity: e.storageQuantity,
-              purchaseAmount: e.purchaseAmount,
-              batch: e.batch,
-              arr: e.arr,
-              newJob: e.newJob,
-              newDate: e.newDate,
-              price: e.price,
-              $cellEdit: true
+
+
             });
-          });
+          })
         }
       }
       this.dialogVisible = false;