<template>
  <div class="app-container">
 
        <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="网店id" prop="storeId">
          <el-input v-model="form.storeId" placeholder="请输入网店id" />
        </el-form-item>
        <el-form-item label="三方订单号" prop="outerOrderNo">
          <el-input v-model="form.outerOrderNo" placeholder="请输入三方订单号" />
        </el-form-item>
        <el-form-item label="内部订单号" prop="innerOrderNo">
          <el-input v-model="form.innerOrderNo" placeholder="请输入内部订单号" />
        </el-form-item>
        <el-form-item label="预占编码" prop="preemptCode">
          <el-input v-model="form.preemptCode" placeholder="请输入预占编码" />
        </el-form-item>
        <el-form-item label="流转状态 0 异常 1正常 2待处理">
          <el-radio-group v-model="form.circulationStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="流转异常原因" prop="failureReason">
          <el-input v-model="form.failureReason" placeholder="请输入流转异常原因" />
        </el-form-item>
   
        <el-form-item label="三方销售单来源  0接口抓取 1手工建单" prop="orderSource">
          <el-input v-model="form.orderSource" placeholder="请输入三方销售单来源  0接口抓取 1手工建单" />
        </el-form-item>
        <el-form-item label="内部销售单来源  0普通转单 1手工单  2复制单" prop="innerOrderSource">
          <el-input v-model="form.innerOrderSource" placeholder="请输入内部销售单来源  0普通转单 1手工单  2复制单" />
        </el-form-item>
        <el-form-item label="平台订单状态 0未成交  1已成交">
          <el-radio-group v-model="form.orderStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="回写状态 0未回写 1回写成功  2回写失败">
          <el-radio-group v-model="form.syncStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="售后状态  0无售后 1售后处理中 2退款中 3退款成功">
          <el-radio-group v-model="form.refundStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="支付方式  0微信支付 1支付宝支付  3财付通  4连连支付  5网银在线  6货到付款 7银行汇款 8 其它" prop="payType">
          <el-select v-model="form.payType" placeholder="请选择支付方式  0微信支付 1支付宝支付  3财付通  4连连支付  5网银在线  6货到付款 7银行汇款 8 其它">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="支付状态  0无售后 1售后处理中 2退款中 3退款成功">
          <el-radio-group v-model="form.payStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="审核类型  0寻源前待审核   1发货前待审核" prop="auditType">
          <el-select v-model="form.auditType" placeholder="请选择审核类型  0寻源前待审核   1发货前待审核">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="审核状态 1待一审  2一审不通过  3待二审  4二审不通过 5审核通过  ">
          <el-radio-group v-model="form.auditStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="订单阶段 0三方销售单  1内部销售单" prop="orderStage">
          <el-input v-model="form.orderStage" placeholder="请输入订单阶段 0三方销售单  1内部销售单" />
        </el-form-item>
        <el-form-item label="有无赠品  0无  1有" prop="isGift">
          <el-input v-model="form.isGift" placeholder="请输入有无赠品  0无  1有" />
        </el-form-item>
        <el-form-item label="商品数量" prop="goodsNum">
          <el-input v-model="form.goodsNum" placeholder="请输入商品数量" />
        </el-form-item>
        <el-form-item label="商品行数量" prop="skuNum">
          <el-input v-model="form.skuNum" placeholder="请输入商品行数量" />
        </el-form-item>
        <el-form-item label="三方承担优惠金额" prop="thirdDiscountAmount">
          <el-input v-model="form.thirdDiscountAmount" placeholder="请输入三方承担优惠金额" />
        </el-form-item>
        <el-form-item label="商家承担优惠金额" prop="businessDiscountAmount">
          <el-input v-model="form.businessDiscountAmount" placeholder="请输入商家承担优惠金额" />
        </el-form-item>
        <el-form-item label="优惠合计" prop="totalDiscount">
          <el-input v-model="form.totalDiscount" placeholder="请输入优惠合计" />
        </el-form-item>
        <el-form-item label="商品总金额" prop="totalAmount">
          <el-input v-model="form.totalAmount" placeholder="请输入商品总金额" />
        </el-form-item>
        <el-form-item label="应收总金额" prop="amountReceivable">
          <el-input v-model="form.amountReceivable" placeholder="请输入应收总金额" />
        </el-form-item>
        <el-form-item label="买家实付" prop="buyerPayAmount">
          <el-input v-model="form.buyerPayAmount" placeholder="请输入买家实付" />
        </el-form-item>
        <el-form-item label="买家实付" prop="buyerRealPrice">
          <el-input v-model="form.buyerRealPrice" placeholder="请输入买家实付" />
        </el-form-item>
        <el-form-item label="物流方式  0不包邮  1卖家包邮" prop="shippingType">
          <el-select v-model="form.shippingType" placeholder="请选择物流方式  0不包邮  1卖家包邮">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="商品总成本" prop="costAmount">
          <el-input v-model="form.costAmount" placeholder="请输入商品总成本" />
        </el-form-item>
        <el-form-item label="运费" prop="postage">
          <el-input v-model="form.postage" placeholder="请输入运费" />
        </el-form-item>
        <el-form-item label="物流ids" prop="logisticsIds">
          <el-input v-model="form.logisticsIds" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="标签" prop="tags">
          <el-input v-model="form.tags" placeholder="请输入标签" />
        </el-form-item>
        <el-form-item label="买家昵称" prop="buyerNick">
          <el-input v-model="form.buyerNick" placeholder="请输入买家昵称" />
        </el-form-item>
        <el-form-item label="买家备注" prop="buyerRemark">
          <el-input v-model="form.buyerRemark" placeholder="请输入买家备注" />
        </el-form-item>
        <el-form-item label="商家备注" prop="orderRemark">
          <el-input v-model="form.orderRemark" placeholder="请输入商家备注" />
        </el-form-item>
        <el-form-item label="客服备注" prop="serviceRemark">
          <el-input v-model="form.serviceRemark" placeholder="请输入客服备注" />
        </el-form-item>
        <el-form-item label="支付单号" prop="payNo">
          <el-input v-model="form.payNo" placeholder="请输入支付单号" />
        </el-form-item>
        <el-form-item label="发票类别 0无需开票 1电子发票 2增值税普通发票 3增值税专用发票">
          <el-radio-group v-model="form.invoiceStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="发票抬头" prop="invoiceTopic">
          <el-input v-model="form.invoiceTopic" placeholder="请输入发票抬头" />
        </el-form-item>
        <el-form-item label="发票内容">
          <editor v-model="form.invoiceContent" :min-height="192"/>
        </el-form-item>
        <el-form-item label="发货状态  0初始 1全部待发货 2部分发货 3全部发货成功  4全部发货失败 ">
          <el-radio-group v-model="form.deliveryStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="收货状态  0初始 1待收货  2部分收货  3全部已收货 ">
          <el-radio-group v-model="form.receivingStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="预占状态  0全部待预占 1部分预占  2全部预占成功  3全部预占失败  4取消预占  ">
          <el-radio-group v-model="form.preemptionStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="寻源状态  0全部待寻源 1部分寻源 2全部寻源成功 3全部寻源失败  4取消寻源">
          <el-radio-group v-model="form.sourceStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="挂起状态  0未挂起  1部分挂起  2全部挂起成功  4全部挂起失败">
          <el-radio-group v-model="form.suspendStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="预占回写状态 0全部待回写 1部分回写 2全部回写成功 3全部会写失败">
          <el-radio-group v-model="form.syncPreempStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="发货回写状态  0全部待回写  1部分回写  2全部回写成功 3全部回写失败">
          <el-radio-group v-model="form.syncDeliveryStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="三方平台下单时间" prop="orderTime">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.orderTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择三方平台下单时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="支付时间" prop="payTime">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.payTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择支付时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="拉单时间" prop="pullTime">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.pullTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择拉单时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="物流打包时间" prop="lastShipTime">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.lastShipTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择物流打包时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="预计发货时间" prop="predictDeliveryTime">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.predictDeliveryTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择预计发货时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="确认收货时间" prop="receiveTime">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.receiveTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择确认收货时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="创建人ID" prop="createUserId">
          <el-input v-model="form.createUserId" placeholder="请输入创建人ID" />
        </el-form-item>
        <el-form-item label="修改人ID" prop="updateUserId">
          <el-input v-model="form.updateUserId" placeholder="请输入修改人ID" />
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>

   
  </div>
</template>

<script>
import { listOrder, getOrder, delOrder, addOrder, updateOrder, exportOrder } from "@/api/oms/orderInternal";
export default {
  name: "Store",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {  },
      // 表单校验
      rules: {
            // storeName: [
            //   { required: true, message: "网店名称不能为空", trigger: "blur" }
            // ],
            // storeType: [
            //    { required: true, message: "网店类型不能为空", trigger: "blur" }
            // ],
            // channelType: [
            //   { required: true, message: "请选择渠道类型", trigger: "blur" }
            // ],
            // linkUsername: [
            //   { required: true, message: "联系人状态不能为空", trigger: "blur" }
            // ],
            // status: [
            //   { required: true, message: "请选择店铺状态", trigger: "blur" }
            // ],
            // channelWarehouseName: [
            //   { required: true, message: "渠道仓名称不能为空", trigger: "blur" }
            // ],
      }
    };
  },
  created() {

   
  },
  methods: {
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
// 表单重置
    reset() {
      this.form = {
        id: null,
        storeId: null,
        outerOrderNo: null,
        innerOrderNo: null,
        preemptCode: null,
        circulationStatus: 0,
        failureReason: null,
        orderType: null,
        orderSource: null,
        innerOrderSource: null,
        orderStatus: 0,
        syncStatus: 0,
        refundStatus: 0,
        payType: null,
        payStatus: 0,
        auditType: null,
        auditStatus: 0,
        orderStage: null,
        isGift: null,
        goodsNum: null,
        skuNum: null,
        thirdDiscountAmount: null,
        businessDiscountAmount: null,
        totalDiscount: null,
        totalAmount: null,
        amountReceivable: null,
        buyerPayAmount: null,
        buyerRealPrice: null,
        shippingType: null,
        costAmount: null,
        postage: null,
        logisticsIds: null,
        tags: null,
        buyerNick: null,
        buyerRemark: null,
        orderRemark: null,
        serviceRemark: null,
        payNo: null,
        invoiceStatus: 0,
        invoiceTopic: null,
        invoiceContent: null,
        deliveryStatus: 0,
        receivingStatus: 0,
        preemptionStatus: 0,
        sourceStatus: 0,
        suspendStatus: 0,
        syncPreempStatus: 0,
        syncDeliveryStatus: 0,
        orderTime: null,
        payTime: null,
        pullTime: null,
        lastShipTime: null,
        predictDeliveryTime: null,
        receiveTime: null,
        createUserId: null,
        createTime: null,
        updateUserId: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const storeId = row.storeId || this.ids
      getStore(storeId).then(response => {
        this.form = response.data;
        this.form.channelWarehouseName=row.channelWarehouseName;
        if(this.form.channelType!=null){
            this.form.channelType = this.form.channelType.toString();
        }
        if(this.form.storeType!=null){
            this.form.storeType = this.form.storeType.toString();
        }
        if(this.form.status!=null){
            this.form.status = this.form.status.toString();
        }
        this.open = true;
        this.title = "修改网店";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.storeId != null) {
            updateStore(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }
            });
          } else {
            addStore(this.form).then(response => {
              if (response.code === 200) {
                  this.msgSuccess("新增成功");
                  this.open = false;
                  this.getList();
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const storeIds = row.storeId || this.ids;
      this.$confirm('是否确认删除网店编号为"' + storeIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delStore(storeIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有网店数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportStore(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
    }
  }
};
</script>
