<template>
  <div class="tenant">
    <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" highlight-current-row
             :selectConfig="selectConfig" :table-events="{
                    select: select,
                }" :action-list="[]" @get-list="getList" @moreSearch="() => (queryDialogVisible = true)">

      <template #orderId="{ item }">
        <div style="display: flex; justify-content: flex-start;line-height: 34px;height: 34px" @click="getDtl(item);">
          <div v-if="item.hasEx=='1'">
            <img src="@/assets/images/jdyc.png" alt="" style="width: 34px" />
          </div>
          <div v-else style="width: 34px">

          </div>
          <span style="color: blue">{{item.orderId}}</span>
        </div>
      </template>

      <template #diversionType="{item}">
        <div style="width:100%">
          <div v-if="item.diversionType">
            {{dictValueLabel(item.diversionType,diversionTypeData)}}
          </div>
          <div v-else>
            <el-button type="primary" text @click="handleDiversionType(item)">分流</el-button>
          </div>
        </div>
      </template>

      <template #remark="{ item }">
        <div style="width: 200px;overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
          <div v-if="item.hasEx == '1'" @click="showTipRemark(item)">
            <i class="iconfont icon-iconm_banli" style="margin-right: 5px"></i>
            <span v-if="isNullOrUndefined(item.remark)">编辑备注</span>
            <el-tooltip v-else class="item" effect="dark" :content="item.remark" placement="top">
              {{item.remark}}
            </el-tooltip>
          </div>
        </div>
      </template>
    </byTable>
    <!--回告-->
    <el-dialog :z-index="1500" title="采购单回告" v-if="tellDialogVisible" v-model="formData.data" width="1500px" v-loading="loading">
      <el-descriptions title="基础信息" />
      <el-form label-width="auto" :rules="rules">
        <el-row>
          <el-col :span="8">
            <el-form-item label="采购单号：" :span="8">
              {{formData.data.orderId}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="配送中心：" :span="8">
              {{formData.data.deliverCenterName}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="入库时间：" :span="8">
              {{formData.data.storageTime}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="预计送货时间：" :span="8">
              <el-date-picker v-model="formData.data.deliveryTime" type="datetime" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss"
                              placeholder="请选择预计送货时间" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-descriptions title="采购单明细" />
          <el-table :data="formData.data.jdOrderDetailsList" stripe style="width: 100%">
            <!--            <el-table stripe style="width: 100%">-->
            <el-table-column prop="wareId" label="京东商品编号" width="180">
              <template #default="scope">
                <span
                      :style="scope.row.productName=='' || scope.row.productName == undefined || scope.row.productName == 'undefined'?'color: red':''">{{scope.row.wareId}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="wareName" label="京东商品名称">
              <template #default="scope">
                <span
                      :style="scope.row.productName=='' || scope.row.productName == undefined || scope.row.productName == 'undefined'?'color: red':''">{{scope.row.wareName}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="productName" label="产品名称" />
            <el-table-column prop="originalNum" label="采购数量" />
            <el-table-column prop="confirmNum" label="确认数量">
              <template v-slot="scope">
                <el-form-item :rules="rules['confirmNum']">
                  <el-input-number :min="0" :step="1" :max="scope.row.originalNum" v-model="scope.row.confirmNum" placeholder="请输入确认数量" />
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column prop="purchasePrice" label="采购价" />
            <el-table-column prop="nonDeliveryReason" label="不满足发货原因">
              <template v-slot="scope">
                <el-form-item :rules="rules['nonDeliveryReason']">
                  <el-input v-model="scope.row.nonDeliveryReason" placeholder="请输入不满足发货原因" />
                </el-form-item>
              </template>
            </el-table-column>
          </el-table>
        </el-row>
      </el-form>
      <template #footer>
        <el-button @click="tellDialogVisible = false" size="large">取 消</el-button>
        <el-button type="primary" @click="submitForm" size="large" :loading="submitLoading">采购单回告</el-button>
      </template>
    </el-dialog>

    <!--详情-->
    <el-dialog :z-index="1500" title="采购单详情" v-if="dialogVisible" v-model="formData.data" width="1500px" v-loading="loading">
      <el-descriptions title="基础信息" />
      <el-form label-width="auto" :rules="rules">
        <el-row>
          <el-col :span="8">
            <el-form-item label="京东订单号：" :span="8">
              {{formData.data.orderId}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="订购时间：" :span="8" label-position="right">
              {{formData.data.createdDate}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="供应商名称：" :span="8">
              {{formData.data.providerName}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="采购总金额：" :span="8">
              {{formData.data.totalPrice}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="配送中心名称：" :span="8">
              {{formData.data.deliverCenterName}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="采购员姓名：" :span="8">
              {{formData.data.purchaserName}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="删除状态：" :span="8">
              {{formData.data.statusName}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否EPT定制：" :span="8">
              {{formData.data.isEptCustomized?'是':'否'}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="订单状态：" :span="8">
              {{formData.data.stateName}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="完成时间：" :span="8">
              {{formData.data.completedDate}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="账期：" :span="8">
              {{formData.data.accountPeriod}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="收货负责人：" :span="8">
              {{formData.data.receiverName}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="收货电话：" :span="8">
              {{formData.data.warehousePhone}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="详细地址：" :span="8">
              {{formData.data.address}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="采购类型：" :span="8">
              {{formData.data.orderTypeName}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="订单属性：" :span="8">
              {{formData.data.orderAttributeName}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="回告状态：" :span="8">
              {{formData.data.confirmStateName}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="顾客单号：" :span="8">
              {{formData.data.customerOrderid}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="品种数量：" :span="8">
              {{formData.data.wareVariety}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="预计到货时间：" :span="8">
              {{formData.data.deliveryTime}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否可回告：" :span="8">
              {{formData.data.isCanConfirm?"可回告":"不可回告"}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="是否有差异：" :span="8">
              {{formData.data.isExistActualNumDif=='0'?"存在差异":"无差异"}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否已结算：" :span="8">
              {{formData.data.balanceStatus?"已结算":"未结算"}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="入库时间：" :span="8">
              {{formData.data.storageTime}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="TC转运标识：" :span="8">
              {{formData.data.tcFlagName}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="预约时间：" :span="8">
              {{formData.data.bookTime}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-descriptions title="采购单明细" />
          <div style="line-height: 34px;height: 34px;display: flex">
            <span>（</span>
            <span><img src="@/assets/images/jdsh.png" alt="" style="width: 34px" /></span><span>多货</span>
            <span><img src="@/assets/images/jddh.png" alt="" style="width: 34px" /></span><span>少货</span>
            <span>）</span>
          </div>

          <el-table :data="formData.data.jdOrderDetailsList" stripe style="width: 100%">
            <!--            <el-table stripe style="width: 100%">-->
            <el-table-column prop="wareId" label="京东商品编号" width="175">
              <template #default="scope">
                <div style="display: flex; justify-content: center;line-height: 34px;height: 34px">
                  <div v-if="scope.row.exDesc=='1'">
                    <img src="@/assets/images/jdsh.png" alt="" style="width: 34px" />
                  </div>
                  <div v-if="scope.row.exDesc=='2'">
                    <img src="@/assets/images/jddh.png" alt="" style="width: 34px" />
                  </div>
                  <div
                       :style="scope.row.productName=='' || scope.row.productName == undefined || scope.row.productName == 'undefined'?'color: red':''">
                    {{scope.row.wareId}}
                  </div>
                </div>

              </template>
            </el-table-column>
            <el-table-column prop="wareName" label="京东商品名称" min-width="200">
              <template #default="scope">
                <span
                      :style="scope.row.productName=='' || scope.row.productName == undefined || scope.row.productName == 'undefined'?'color: red':''">{{scope.row.wareName}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="productName" label="产品名称" width="150" />
            <el-table-column prop="deliverCenterName" label="配送中心名称" width="110" />
            <el-table-column prop="purchasePrice" label="采购价" width="80" />
            <el-table-column prop="originalNum" label="原始采购数量" width="110" />
            <el-table-column prop="confirmNum" label="回告数量" width="80" />
            <el-table-column prop="actualNum" label="实收数量" width="80" />
            <el-table-column prop="nonDeliveryReason" label="不满足原因" width="100" />
            <el-table-column prop="totalPrice" label="采购总金额" width="110" />
            <el-table-column prop="storeName" label="库房名称" width="180" />
            <el-table-column prop="wareProperty" label="EPT采购单定制相关信息" width="180" />
          </el-table>
        </el-row>
      </el-form>
      <template #footer>
        <el-button @click="dialogVisible = false" size="large">取 消</el-button>
      </template>
    </el-dialog>

    <!--修改备注-->
    <el-dialog :z-index="1500" title="编辑备注" v-if="remarkDialogVisible" v-model="formData.data" width="800px" v-loading="loading">
      <el-form label-width="auto" :rules="rules">
        <el-row>
          <el-col>
            <el-form-item label="备注：" :span="8">
              <el-input type="textarea" :rows="3" v-model="formData.data.remark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <el-button @click="remarkDialogVisible = false" size="large">取 消</el-button>
        <el-button type="primary" @click="submitRemark" size="large" :loading="submitLoadingRemark">提 交</el-button>
      </template>
    </el-dialog>

    <!--高级搜索-->
    <el-dialog :title="'高级检索'" v-model="queryDialogVisible" width="500px" destroy-on-close>
      <el-form :model="sourceList.pagination" label-width="100px" label-position="top">
        <el-form-item label="采购单号">
          <el-input v-model="sourceList.pagination.orderId" placeholder="请输入采购单号" oninput="value=value.replace(/[^\d.]/g,'')" />
        </el-form-item>
        <el-form-item label="京东商品编号">
          <el-input v-model="sourceList.pagination.wareId" placeholder="请输入京东商品编号" oninput="value=value.replace(/[^\d.]/g,'')" />
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="handleReset" size="large">重置</el-button>
        <el-button @click="handleQuery" type="primary" size="large">搜索</el-button>
      </template>
    </el-dialog>

    <el-dialog :title="'设置分流'" v-model="dialogVisibleOne" width="500" destroy-on-close>
      <byForm v-loading="submitLoading" :formConfig="formConfig" :formOption="formOption" v-model="formData.dataOne" :rules="rulesOne" ref="byform">
      </byForm>
      <template #footer>
        <el-button @click="dialogVisibleOne = false" size="large">取 消</el-button>
        <el-button type="primary" @click="submitFormOne('byform')" size="large" :loading="submitLoading">
          确 定
        </el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ElMessage, ElMessageBox } from "element-plus";
import byTable from "@/components/byTable/index";
import byForm from "@/components/byForm/index";
import { computed, nextTick, reactive, ref } from "vue";
import { isNullOrUndefined } from "@tinymce/tinymce-vue/lib/es2015/main/ts/Utils";
const { proxy } = getCurrentInstance();
const props = defineProps({
  selectStatus: {
    type: Boolean,
    default: false,
  },
});
const router = useRouter();
const loading = ref(false);
const deliveryCenter = ref([]);
const confirmState = ref([]);
const orderState = ref([]);

const blessingTypeList = ref([]);
const submitLoading = ref(false);
const submitLoadingRemark = ref(false);
const sourceList = ref({
  data: [],
  pagination: {
    total: 0,
    pageNum: 1,
    pageSize: 10,
  },
});

const diversionTypeData = ref([
  {
    label: "仓库发货",
    value: "10",
  },
  {
    label: "工厂发货",
    value: "20",
  },
]);

let rules = ref({
  deliverCenterId: [
    { required: true, message: "请选择配送中心", trigger: "blur" },
  ],
  nonDeliveryReason: [
    { required: true, message: "请输入不满足发货原因", trigger: "blur" },
  ],
  confirmNum: [{ required: true, message: "请输入确认数量", trigger: "blur" }],
  remark: [{ required: true, message: "请输入备注", trigger: "blur" }],
});

const queryDialogVisible = ref(false);
const dialogVisible = ref(false);
const remarkDialogVisible = ref(false);
const tellDialogVisible = ref(false);

let modalType = ref("add");
const selectConfig = computed(() => {
  return [
    {
      label: "订单状态",
      prop: "state",
      data: orderState.value,
    },
    {
      label: "回告状态",
      prop: "confirmState",
      data: confirmState.value,
    },
    {
      label: "是否确认",
      prop: "businessStatus",
      data: [
        {
          label: "未确认",
          value: "0",
        },
        {
          label: "已确认（无需出库）",
          value: "1",
        },
        {
          label: "已确认（需出库）",
          value: "3",
        },
        {
          label: "已回告",
          value: "2",
        },
      ],
    },
    {
      label: "是否可回告",
      prop: "isCanConfirm",
      data: [
        {
          label: "可回告",
          value: true,
        },
        {
          label: "不可回告",
          value: false,
        },
      ],
    },
    {
      label: "是否异常",
      prop: "hasEx",
      data: [
        {
          label: "异常",
          value: "1",
        },
        {
          label: "无异常",
          value: "0",
        },
      ],
    },
    {
      label: "是否备注",
      prop: "hasRemark",
      data: [
        {
          label: "有备注",
          value: "1",
        },
        {
          label: "无备注",
          value: "0",
        },
      ],
    },
    {
      label: "异常处理状态",
      prop: "handleStatus",
      data: [
        {
          label: "已处理",
          value: "2",
        },
        {
          label: "未处理",
          value: "1",
        },
      ],
    },
    {
      label: "分流",
      prop: "diversionType",
      data: diversionTypeData.value,
    },
  ];
});

const config = computed(() => {
  return [
    {
      attrs: {
        label: "京东订单号",
        slot: "orderId",
        align: "left",
        width: 200,
      },
    },
    {
      attrs: {
        label: "分流",
        slot: "diversionType",
        align: "left",
        width: 80,
      },
      render(val) {
        if (val) {
          return proxy.dictValueLabel(val, diversionTypeData.value);
        } else {
          return "";
        }
      },
    },

    {
      attrs: {
        label: "订购时间",
        prop: "createdDate",
        align: "left",
        width: 170,
      },
    },
    {
      attrs: {
        label: "供应商名称",
        prop: "providerName",
        align: "left",
        width: 220,
      },
    },
    {
      attrs: {
        label: "采购总金额",
        prop: "totalPrice",
        align: "left",
        width: 110,
      },
      render(totalPrice) {
        return proxy.moneyFormat(totalPrice, 2);
      },
    },
    {
      attrs: {
        label: "配送中心名称",
        prop: "deliverCenterName",
        align: "left",
        width: 110,
      },
    },
    {
      attrs: {
        label: "订单状态",
        prop: "state",
        align: "left",
        width: 80,
      },
      render(value) {
        return proxy.dictValueLabel(value, orderState.value);
      },
    },
    {
      attrs: {
        label: "回告状态",
        prop: "confirmState",
        align: "left",
        width: 80,
      },
      render(value) {
        return proxy.dictValueLabel(value, confirmState.value);
      },
    },
    {
      attrs: {
        label: "是否可回告",
        prop: "isCanConfirm",
        align: "left",
        width: 100,
      },
      render(value) {
        return value ? "可回告" : "不可回告";
      },
    },
    {
      attrs: {
        label: "详细地址",
        prop: "address",
        align: "left",
        "min-width": 250,
      },
    },
    {
      attrs: {
        label: "采购类型",
        prop: "orderTypeName",
        align: "left",
        width: 100,
      },
    },
    {
      attrs: {
        label: "备注",
        slot: "remark",
        width: 200,
        align: "left",
      },
    },
    // {
    //   attrs: {
    //     label: "是否有异常",
    //     prop: "hasEx",
    //     align: "left",
    //     width: 100,
    //   },
    //   render(value) {
    //     let label = "未确认";
    //     if (value == "1") {
    //       label = "异常";
    //     } else if (value == "0") {
    //       label = "无异常";
    //     }
    //     return label;
    //   },
    // },
    {
      attrs: {
        label: "系统是否确认",
        prop: "businessStatus",
        align: "left",
        width: 110,
      },
      render(value) {
        let label = "未确认";
        if (value == "1") {
          label = "已确认（无需出库）";
        } else if (value == "2") {
          label = "已回告";
        } else if (value == "3") {
          label = "已确认（需出库）";
        }
        return label;
      },
    },
    {
      attrs: {
        label: "处理状态",
        prop: "handleStatus",
        align: "left",
        width: 100,
      },
      render(type) {
        if (type == "2") {
          return "已处理";
        } else if (type == "1") {
          return "未处理";
        } else {
          return "";
        }
      },
    },
    {
      attrs: {
        label: "操作",
        width: "200",
        align: "center",
        fixed: "right",
      },
      renderHTML(row) {
        return props.selectStatus
          ? [
              {
                attrs: {
                  label: "选择",
                  type: "primary",
                  text: true,
                },
                el: "button",
                click() {
                  proxy.$emit("selectOrder", row);
                },
              },
            ]
          : [
              //   {
              //     attrs: {
              //       label: "详情",
              //       type: "primary",
              //       text: true,
              //     },
              //     el: "button",
              //     click() {
              //       getDtl(row);
              //     },
              //   },
              row.businessStatus == 0 && row.diversionType == "10"
                ? {
                    attrs: {
                      label: "采购单确认（需出库）",
                      type: "danger",
                      text: true,
                    },
                    el: "button",
                    click() {
                      ElMessageBox.confirm("是否确认当前采购单状态?", "提示", {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        type: "warning",
                      }).then(() => {
                        confirmBusinessStatus(row, true);
                      });
                    },
                  }
                : {},
              row.businessStatus == 0 && row.diversionType == "10"
                ? {
                    attrs: {
                      label: "采购单确认（无需出库）",
                      type: "danger",
                      text: true,
                    },
                    el: "button",
                    click() {
                      ElMessageBox.confirm("是否确认当前采购单状态?", "提示", {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        type: "warning",
                      }).then(() => {
                        confirmBusinessStatus(row, false);
                      });
                    },
                  }
                : {},
              // row.businessStatus == 1 && row.isCanConfirm
              //   ? {
              //       attrs: {
              //         label: "回告",
              //         type: "danger",
              //         text: true,
              //       },
              //       el: "button",
              //       click() {
              //         getTellDtl(row);
              //       },
              //     }
              //   : {},
            ];
      },
    },
  ];
});

let formData = reactive({
  data: {
    coverList: [],
    audioList: [],
  },
  dataOne: {},
});

const getDictlist = async () => {
  proxy
    .getDictOne(["delivery_center", "confirmState", "OrderState"])
    .then((res) => {
      deliveryCenter.value = res["delivery_center"].map((x) => ({
        label: x.dictValue,
        value: x.dictKey,
      }));
      confirmState.value = res["confirmState"].map((x) => ({
        label: x.dictValue,
        value: x.dictKey,
      }));
      orderState.value = res["OrderState"].map((x) => ({
        label: x.dictValue,
        value: x.dictKey,
      }));
    });
};

const getList = async (req) => {
  sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  loading.value = true;
  if (props.selectStatus) {
    sourceList.value.pagination.diversionType = "10";
  }
  proxy.post("/jdOrder/page", sourceList.value.pagination).then((res) => {
    sourceList.value.data = res.rows;
    sourceList.value.pagination.total = res.total;
    setTimeout(() => {
      loading.value = false;
    }, 200);
  });
};

// const tableRowClassName = (row, callback) => {
//   if (row.row.hasEx == 1) {
//     callback('error-row') ;
//   } else  {
//     callback('') ;
//   }
// }

const openModal = () => {
  dialogVisible.value = true;
  modalType.value = "add";
  formData.data = {
    content: "",
  };
};
const selection = ref({
  data: [],
});
const select = (_selection, row) => {
  selection.value.data = _selection;
};

const getDtl = (row) => {
  modalType.value = "edit";
  proxy.post("/jdOrder/detail", { id: row.id }).then((res) => {
    formData.data = res;
    dialogVisible.value = true;
  });
};

const getTellDtl = (row) => {
  modalType.value = "edit";
  proxy.post("/jdOrder/detail", { id: row.id }).then((res) => {
    formData.data = res;
    tellDialogVisible.value = true;
  });
};

const showTipRemark = (row) => {
  remarkDialogVisible.value = true;
  formData.data = {
    id: row.id,
    remark: row.remark,
  };
};

/**
 * 确认采购单状态
 * @param row
 */
const confirmBusinessStatus = (row, flag) => {
  let businessStatus = row.businessStatus == "1" ? 0 : 1;
  proxy
    .post("/jdOrder/confirmBusinessStatus", {
      id: row.id,
      businessStatus: businessStatus,
      isOut: flag,
    })
    .then(
      () => {
        ElMessage({
          message: "确认成功",
          type: "success",
        });
        dialogVisible.value = false;
        submitLoading.value = false;
        getList();
      },
      (err) => {
        console.log(err);
        submitLoading.value = false;
      }
    );
};

//订单回告
const submitForm = () => {
  ElMessageBox.confirm("是否确认回告当前采购单?", "提示", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  }).then(() => {
    submitLoading.value = true;
    //TODO 这里应该是订单回告
    proxy.post("/jdOrder/tellBackOrer", formData.data).then(
      () => {
        ElMessage({
          message: "回告成功",
          type: "success",
        });
        tellDialogVisible.value = false;
        submitLoading.value = false;
        getList();
      },
      (err) => {
        console.log(err);
        submitLoading.value = false;
      }
    );
  });
};

//保存备注方法
const submitRemark = () => {
  ElMessageBox.confirm("是否保存备注?", "提示", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  }).then(() => {
    submitLoadingRemark.value = true;
    proxy.post("/jdOrder/saveRemark", formData.data).then(
      () => {
        ElMessage({
          message: "保存成功",
          type: "success",
        });
        remarkDialogVisible.value = false;
        submitLoadingRemark.value = false;
        getList();
      },
      (err) => {
        console.log(err);
        submitLoadingRemark.value = false;
      }
    );
  });
};

//高级搜索
const handleReset = () => {
  sourceList.value.pagination = {
    pageNum: sourceList.value.pagination.pageNum,
    pageSize: sourceList.value.pagination.pageSize,
    arr: [],
  };
  handleQuery();
};

const handleQuery = () => {
  if (
    sourceList.value.pagination.arr &&
    sourceList.value.pagination.arr.length > 1
  ) {
    sourceList.value.pagination.purchaseStartTime =
      sourceList.value.pagination.arr[0];
    sourceList.value.pagination.purchaseEndTime =
      sourceList.value.pagination.arr[1];
  }
  queryDialogVisible.value = false;
  getList();
};

getDictlist();
getList();

const dialogVisibleOne = ref(false);
const byform = ref(null);
const formOption = reactive({
  inline: true,
  labelWidth: 100,
  itemWidth: 100,
  rules: [],
});
const rulesOne = ref({
  diversionType: [{ required: true, message: "请选择分流", trigger: "change" }],
});
const formConfig = computed(() => {
  return [
    {
      type: "select",
      prop: "diversionType",
      label: "分流",
      readonly: true,
      data: diversionTypeData.value,
      // style: {
      //   width: "100%",
      // },
    },
  ];
});
const handleDiversionType = (row) => {
  formData.dataOne = {
    id: row.id,
    diversionType: "",
  };
  dialogVisibleOne.value = true;
};

const submitFormOne = () => {
  byform.value.handleSubmit((valid) => {
    ElMessageBox.confirm("是否确认当前操作?", "提示", {
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      type: "warning",
    }).then(() => {
      submitLoading.value = true;
      proxy.post("/jdOrder/saveDiversion", formData.dataOne).then(
        (res) => {
          ElMessage({
            message: "操作成功",
            type: "success",
          });
          dialogVisibleOne.value = false;
          submitLoading.value = false;
          getList();
        },
        (err) => (submitLoading.value = false)
      );
    });
  });
};
</script>

<style lang='scss' scoped>
.tenant {
  padding: 20px;
}
:deep(.el-form-item--default) {
  margin-bottom: 0px;
}
.el-table .error-row {
  background: rgba(245, 108, 108, 0.68);
}
</style>
