Browse Source

销售订单

cz 2 years ago
parent
commit
7ffe48b095

+ 0 - 0
src/components/WDLY/order/details.vue


+ 62 - 24
src/views/WDLY/outInBound/logistics/index.vue

@@ -23,7 +23,7 @@
       >
         <template #one="{ item }">
           <div style="cursor: pointer; color: #409eff">
-            {{ item.fileName }}
+            {{ item.businessCode }}
           </div>
         </template>
         <template #two="{ item }">
@@ -196,24 +196,30 @@ const activities = ref([]);
 let roomDialogVisible = ref(false);
 let modalType = ref("add");
 let rules = ref({
-  code: [{ required: true, message: "请输入spu编码", trigger: "blur" }],
-  name: [{ required: true, message: "请输入spu名称", trigger: "blur" }],
+  businessType: [
+    { required: true, message: "请选择数据来源", trigger: "change" },
+  ],
+  logisticsCompanyCode: [
+    { required: true, message: "请选择物流/快递公司", trigger: "change" },
+  ],
+  code: [{ required: true, message: "请输入物流/快递单号", trigger: "blur" }],
+  isKd100: [{ required: true, message: "请选择是否同步", trigger: "change" }],
 });
 const { proxy } = getCurrentInstance();
 const selectConfig = reactive([
   {
     label: "数据来源",
-    prop: "type",
+    prop: "businessType",
     data: [],
   },
   {
     label: "物流状态",
-    prop: "type",
+    prop: "logisticsStatus",
     data: [],
   },
   {
     label: "完成状态",
-    prop: "type",
+    prop: "status",
     data: [
       {
         label: "待接收",
@@ -236,39 +242,42 @@ const config = computed(() => {
     {
       attrs: {
         label: "数据来源",
-        prop: "code",
+        prop: "businessType",
+      },
+      render(type) {
+        return proxy.dictDataEcho(type, businessType.value);
       },
     },
     {
       attrs: {
         label: "关联单号",
-        prop: "name",
+        prop: "businessCode",
         slot: "one",
       },
     },
     {
       attrs: {
         label: "物流/快递公司",
-        prop: "remark",
+        prop: "logisticsCompanyCode",
       },
     },
     {
       attrs: {
         label: "物流/快递单号",
-        prop: "remark",
+        prop: "code",
         slot: "two",
       },
     },
     {
       attrs: {
         label: "物流状态",
-        prop: "remark",
+        prop: "logisticsStatus",
       },
     },
     {
       attrs: {
         label: "创建时间",
-        prop: "remark",
+        prop: "createTime",
       },
     },
 
@@ -335,14 +344,14 @@ const treeData = ref([]);
 const formConfig = reactive([
   {
     type: "select",
-    prop: "warehouseId",
+    prop: "businessType",
     label: "数据来源",
     data: [],
     itemWidth: 61,
   },
   {
     type: "select",
-    prop: "warehouseId",
+    prop: "logisticsCompanyCode",
     label: "物流/快递信息",
     data: [],
     itemWidth: 40,
@@ -352,13 +361,13 @@ const formConfig = reactive([
   },
   {
     type: "input",
-    prop: "warehouseId",
+    prop: "code",
     label: " ",
     itemWidth: 60,
   },
   {
     type: "radio",
-    prop: "type",
+    prop: "isKd100",
     label: "是否同步",
     required: true,
     border: true,
@@ -369,7 +378,7 @@ const formConfig = reactive([
   },
   {
     type: "input",
-    prop: "name",
+    prop: "remark",
     label: "备注",
     itemType: "textarea",
   },
@@ -378,7 +387,7 @@ const getList = async (req) => {
   sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
   loading.value = true;
   proxy
-    .post("/productSpu/page", sourceList.value.pagination)
+    .post("/logisticsInfos/page", sourceList.value.pagination)
     .then((message) => {
       console.log(message);
       sourceList.value.data = message.rows;
@@ -392,7 +401,7 @@ const openModal = () => {
   dialogVisible.value = true;
   modalType.value = "add";
   formData.data = {
-    stockWaitDetailsList: [],
+    isKd100: "1",
   };
 };
 
@@ -400,7 +409,7 @@ const submitForm = () => {
   console.log(byform.value);
   byform.value.handleSubmit((valid) => {
     submitLoading.value = true;
-    proxy.post("/productSpu/" + modalType.value, formData.data).then(
+    proxy.post("/logisticsInfos/" + modalType.value, formData.data).then(
       (res) => {
         ElMessage({
           message: modalType.value == "add" ? "添加成功" : "编辑成功",
@@ -499,12 +508,41 @@ const handleClickCode = (row) => {
     type: "success",
   });
   let id = row.id;
-  // proxy.post("/fileInfo/getList", { businessIdList: [id] }).then((res) => {
-  //   const file = res[id][0];
-  //   window.open(file.fileUrl, "_blank");
-  // });
+  proxy.post("/logisticsInfos/getLogistics", { id }).then((res) => {
+    console.log(res, "wss");
+  });
   openRecord.value = true;
 };
+
+const businessType = ref([
+  {
+    dictValue: "采购入库",
+    dictKey: "1",
+  },
+  {
+    dictValue: "京东订单出库",
+    dictKey: "2",
+  },
+  {
+    dictValue: "销售订单出库",
+    dictKey: "3",
+  },
+  {
+    dictValue: "京东退货",
+    dictKey: "4",
+  },
+]);
+
+onMounted(() => {
+  selectConfig[0].data = businessType.value.map((x) => ({
+    label: x.dictValue,
+    value: x.dictKey,
+  }));
+  formConfig[0].data = businessType.value.map((x) => ({
+    label: x.dictValue,
+    value: x.dictKey,
+  }));
+});
 </script>
   
 <style lang="scss" scoped>

+ 161 - 72
src/views/WDLY/outInBound/transfer/index.vue

@@ -21,13 +21,24 @@
         ]"
         @get-list="getList"
       >
-        <template #slotName="{ item }">
-          {{ item.createTime }}
+        <template #code="{ item }">
+          <div
+            style="cursor: pointer; color: #409eff"
+            @click="getDtl(item, 'detail')"
+          >
+            {{ item.code }}
+          </div>
         </template>
       </byTable>
     </div>
     <el-dialog
-      :title="modalType == 'add' ? '新增调仓' : '调仓接收'"
+      :title="
+        modalType == 'add'
+          ? '新增调仓'
+          : modalType == 'edit'
+          ? '调仓接收'
+          : '调仓详情'
+      "
       v-model="dialogVisible"
       width="800"
       v-loading="loading"
@@ -45,33 +56,47 @@
               type="primary"
               @click="openProduct = true"
               style="margin-bottom: 10px"
+              v-if="modalType == 'add'"
             >
               添加物品
             </el-button>
-            <el-table :data="formData.data.stockWaitDetailsList">
-              <el-table-column prop="name" label="物品编码" />
-              <el-table-column prop="name" label="物品名称" />
-              <el-table-column prop="name" label="规格型号" />
+            <el-table :data="formData.data.stockTransferDetailsList">
+              <el-table-column prop="productCode" label="物品编码" />
+              <el-table-column prop="productName" label="物品名称" />
+              <el-table-column prop="productSpec" label="规格型号" />
+              <el-table-column
+                prop="outQuantity"
+                label="调仓数量"
+                v-if="modalType == 'detail'"
+              />
+              <el-table-column
+                prop="inQuantity"
+                label="接收数量"
+                v-if="modalType == 'detail'"
+              />
+
               <el-table-column
-                prop="name"
+                prop="outQuantity"
                 label="调仓数量"
                 v-if="modalType == 'edit'"
               />
               <el-table-column
-                prop="quantity"
+                prop="outQuantity"
                 label="调仓数量"
                 min-width="150"
                 v-if="modalType == 'add'"
               >
                 <template #default="{ row, $index }">
                   <el-form-item
-                    :prop="'stockWaitDetailsList.' + $index + '.quantity'"
-                    :rules="rules.quantity"
+                    :prop="
+                      'stockTransferDetailsList.' + $index + '.outQuantity'
+                    "
+                    :rules="rules.outQuantity"
                     :inline-message="true"
                   >
                     <el-input-number
-                      v-model="row.quantity"
-                      :precision="4"
+                      v-model="row.outQuantity"
+                      :precision="2"
                       :controls="false"
                       :min="0"
                     />
@@ -79,20 +104,20 @@
                 </template>
               </el-table-column>
               <el-table-column
-                prop="quantity"
+                prop="inQuantity"
                 label="接收数量"
                 min-width="150"
                 v-if="modalType == 'edit'"
               >
                 <template #default="{ row, $index }">
                   <el-form-item
-                    :prop="'stockWaitDetailsList.' + $index + '.quantity'"
-                    :rules="rules.quantity"
+                    :prop="'stockTransferDetailsList.' + $index + '.inQuantity'"
+                    :rules="rules.inQuantity"
                     :inline-message="true"
                   >
                     <el-input-number
-                      v-model="row.quantity"
-                      :precision="4"
+                      v-model="row.inQuantity"
+                      :precision="2"
                       :controls="false"
                       :min="0"
                     />
@@ -100,7 +125,12 @@
                 </template>
               </el-table-column>
 
-              <el-table-column prop="zip" label="操作" width="100">
+              <el-table-column
+                prop="zip"
+                label="操作"
+                width="100"
+                v-if="modalType == 'add'"
+              >
                 <template #default="{ $index }">
                   <el-button type="primary" link @click="handleRemove($index)"
                     >删除</el-button
@@ -111,7 +141,7 @@
           </div>
         </template>
       </byForm>
-      <template #footer>
+      <template #footer v-if="modalType != 'detail'">
         <el-button @click="dialogVisible = false" size="large">取 消</el-button>
         <el-button
           type="primary"
@@ -144,7 +174,7 @@
 import { ElMessage, ElMessageBox } from "element-plus";
 import byTable from "@/components/byTable/index";
 import byForm from "@/components/byForm/index";
-import { computed, defineComponent, ref } from "vue";
+import { computed, defineComponent, ref, watch } from "vue";
 import useUserStore from "@/store/modules/user";
 import SelectProduct from "@/components/WDLY/product/SelectProduct";
 
@@ -156,41 +186,50 @@ const sourceList = ref({
     total: 3,
     pageNum: 1,
     pageSize: 10,
+    outWarehouseId: "",
+    inWarehouseId: "",
+    inStatus: "",
   },
 });
 let dialogVisible = ref(false);
 let openProduct = ref(false);
-
 let roomDialogVisible = ref(false);
 let modalType = ref("add");
 let rules = ref({
-  code: [{ required: true, message: "请输入spu编码", trigger: "blur" }],
-  name: [{ required: true, message: "请输入spu名称", trigger: "blur" }],
+  outWarehouseId: [
+    { required: true, message: "请选择调出仓库", trigger: "change" },
+  ],
+  inWarehouseId: [
+    { required: true, message: "请选择调入仓库", trigger: "change" },
+  ],
+  outQuantity: [{ required: true, message: "请输入调仓数量", trigger: "blur" }],
+  inQuantity: [{ required: true, message: "请输入接收数量", trigger: "blur" }],
 });
 const { proxy } = getCurrentInstance();
 const selectConfig = reactive([
   {
     label: "调出仓库",
-    prop: "type",
+    prop: "outWarehouseId",
     data: [],
   },
   {
     label: "调入仓库",
-    prop: "type",
+    prop: "inWarehouseId",
     data: [],
   },
   {
     label: "接收状态",
-    prop: "type",
+    prop: "inStatus",
     data: [
       {
         label: "待接收",
-        value: "1",
+        value: "0",
       },
       {
         label: "部分接收",
-        value: "2",
+        value: "1",
       },
+
       {
         label: "已接收",
         value: "2",
@@ -203,50 +242,53 @@ const config = computed(() => {
   return [
     {
       attrs: {
+        slot: "code",
         label: "单号",
-        prop: "code",
       },
     },
     {
       attrs: {
         label: "调出仓库",
-        prop: "name",
+        prop: "outWarehouseName",
       },
     },
     {
       attrs: {
         label: "调出人",
-        prop: "remark",
+        prop: "outUserName",
       },
     },
     {
       attrs: {
         label: "调出时间",
-        prop: "remark",
+        prop: "createTime",
       },
     },
     {
       attrs: {
         label: "接收状态",
-        prop: "remark",
+        prop: "inStatus",
+      },
+      render(inStatus) {
+        return inStatus == 0 ? "待接收" : inStatus == 1 ? "部分接收" : "已接收";
       },
     },
     {
       attrs: {
         label: "调入仓库",
-        prop: "remark",
+        prop: "inWarehouseName",
       },
     },
     {
       attrs: {
         label: "接收人",
-        prop: "remark",
+        prop: "inUserName",
       },
     },
     {
       attrs: {
         label: "接收时间",
-        prop: "remark",
+        prop: "inTime",
       },
     },
 
@@ -264,10 +306,11 @@ const config = computed(() => {
               label: "接收",
               type: "primary",
               text: true,
+              disabled: row.inStatus > 1,
             },
             el: "button",
             click() {
-              getDtl(row);
+              getDtl(row, "edit");
             },
           },
           {
@@ -278,7 +321,7 @@ const config = computed(() => {
             },
             el: "button",
             click() {
-              getDtl(row);
+              // getDtl(row);
             },
           },
         ];
@@ -289,7 +332,6 @@ const config = computed(() => {
 
 let formData = reactive({
   data: {},
-  treeData: [],
 });
 const formOption = reactive({
   inline: true,
@@ -298,7 +340,6 @@ const formOption = reactive({
   rules: [],
 });
 const byform = ref(null);
-const treeData = ref([]);
 const formConfig = reactive([
   {
     type: "title",
@@ -306,26 +347,26 @@ const formConfig = reactive([
   },
   {
     type: "select",
-    prop: "warehouseId",
+    prop: "outWarehouseId",
     label: "调出仓库",
     itemWidth: 33,
-    disabled: modalType.value === "edit",
+    disabled: false,
     data: [],
   },
   {
     type: "select",
-    prop: "warehouseId",
+    prop: "inWarehouseId",
     label: "调入仓库",
     itemWidth: 33,
-    disabled: modalType.value === "edit",
+    disabled: false,
     data: [],
   },
   {
     type: "input",
-    prop: "name",
+    prop: "remark",
     label: "调拨说明",
     itemType: "textarea",
-    disabled: modalType.value === "edit",
+    disabled: false,
   },
   {
     type: "title",
@@ -336,11 +377,12 @@ const formConfig = reactive([
     slotName: "products",
   },
 ]);
+
 const getList = async (req) => {
   sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
   loading.value = true;
   proxy
-    .post("/productSpu/page", sourceList.value.pagination)
+    .post("/stockTransfer/page", sourceList.value.pagination)
     .then((message) => {
       console.log(message);
       sourceList.value.data = message.rows;
@@ -350,42 +392,86 @@ const getList = async (req) => {
       }, 200);
     });
 };
+
 const openModal = () => {
   dialogVisible.value = true;
   modalType.value = "add";
   formData.data = {
-    stockWaitDetailsList: [],
+    stockTransferDetailsList: [],
   };
 };
 
 const submitForm = () => {
-  console.log(byform.value);
   byform.value.handleSubmit((valid) => {
-    submitLoading.value = true;
-    proxy.post("/productSpu/" + modalType.value, formData.data).then(
-      (res) => {
-        ElMessage({
-          message: modalType.value == "add" ? "添加成功" : "编辑成功",
-          type: "success",
+    if (modalType.value == "add") {
+      if (formData.data.outWarehouseId === formData.data.inWarehouseId)
+        return ElMessage({
+          message: "调出仓库和调入仓库不可一致!",
+          type: "info",
         });
-        dialogVisible.value = false;
-        submitLoading.value = false;
-        getList();
-      },
-      (err) => (submitLoading.value = false)
-    );
+
+      if (!formData.data.stockTransferDetailsList.length > 0)
+        return ElMessage({
+          message: "请添加调仓明细",
+          type: "info",
+        });
+    } else {
+      const list = formData.data.stockTransferDetailsList;
+      for (let i = 0; i < list.length; i++) {
+        const e = list[i];
+        if (Number(e.inQuantity) > Number(e.outQuantity)) {
+          return ElMessage({
+            message: `接收数量不可大于调出数量!`,
+            type: "info",
+          });
+        }
+      }
+    }
+    const requestUrl =
+      modalType.value == "add"
+        ? "/stockTransfer/add"
+        : "/stockTransfer/receive";
+    submitLoading.value = true;
+    const data = {
+      id: formData.data.id,
+      stockTransferDetailsList: formData.data.stockTransferDetailsList,
+    };
+    proxy
+      .post(requestUrl, modalType.value == "add" ? formData.data : data)
+      .then(
+        (res) => {
+          ElMessage({
+            message: modalType.value == "add" ? "添加成功" : "接收成功",
+            type: "success",
+          });
+          dialogVisible.value = false;
+          submitLoading.value = false;
+          getList();
+        },
+        (err) => (submitLoading.value = false)
+      );
   });
 };
 
-const getDtl = (row) => {
-  modalType.value = "edit";
-  proxy.post("/productSpu/detail", { id: row.id }).then((res) => {
-    res.stockWaitDetailsList = res.productInfoList;
+const getDtl = (row, type) => {
+  modalType.value = type;
+  proxy.post("/stockTransfer/detail", { id: row.id }).then((res) => {
+    if (type == "edit") {
+      res.stockTransferDetailsList.forEach(
+        (x) => (x.inQuantity = x.outQuantity)
+      );
+    }
     formData.data = res;
     dialogVisible.value = true;
   });
 };
 
+watch(modalType, () => {
+  formConfig[1].disabled = modalType.value != "add" ? true : false;
+  formConfig[2].disabled = modalType.value != "add" ? true : false;
+  formConfig[3].disabled = modalType.value != "add" ? true : false;
+});
+
 const warehouseList = ref([]);
 const warehouseListData = () => {
   // // 币种数据
@@ -418,16 +504,19 @@ getList();
 warehouseListData();
 
 const handleSelect = (row) => {
-  const flag = formData.data.stockWaitDetailsList.some((x) => x.id === row.id);
+  const flag = formData.data.stockTransferDetailsList.some(
+    (x) => x.productId === row.id
+  );
   if (flag)
     return ElMessage({
       message: "该物品已选择",
       type: "info",
     });
-  formData.data.stockWaitDetailsList.push({
-    name: row.name,
-    code: row.code,
-    id: row.id,
+  formData.data.stockTransferDetailsList.push({
+    productSpec: row.spec,
+    productName: row.name,
+    productCode: row.code,
+    productId: row.id,
   });
   return ElMessage({
     message: "选择成功",
@@ -436,7 +525,7 @@ const handleSelect = (row) => {
 };
 
 const handleRemove = (index) => {
-  formData.data.stockWaitDetailsList.splice(index, 1);
+  formData.data.stockTransferDetailsList.splice(index, 1);
   return ElMessage({
     message: "删除成功",
     type: "success",

+ 686 - 0
src/views/WDLY/salesMange/order/index.vue

@@ -0,0 +1,686 @@
+<template>
+  <div class="tenant">
+    <!-- <Banner /> -->
+    <div class="content">
+      <byTable
+        :source="sourceList.data"
+        :pagination="sourceList.pagination"
+        :config="config"
+        :loading="loading"
+        highlight-current-row
+        :selectConfig="selectConfig"
+        :table-events="{
+          //element talbe事件都能传
+          select: select,
+        }"
+        :action-list="[
+          {
+            text: '添加订单',
+            action: () => openModal('add'),
+          },
+        ]"
+        @get-list="getList"
+      >
+        <template #code="{ item }">
+          <div
+            style="cursor: pointer; color: #409eff"
+            @click="getDtl(item, 'detail')"
+          >
+            {{ item.code }}
+          </div>
+        </template>
+        <template #address="{ item }">
+          <div>
+            {{ item.countryName }}, {{ item.provinceName }} ,
+            {{ item.cityName }}, {{ item.detailedAddress }}
+          </div>
+        </template>
+      </byTable>
+    </div>
+    <el-dialog
+      :title="modalType == 'add' ? '添加订单' : '调仓接收'"
+      v-model="dialogVisible"
+      width="800"
+      v-loading="loading"
+    >
+      <byForm
+        :formConfig="formConfig"
+        :formOption="formOption"
+        v-model="formData.data"
+        :rules="rules"
+        ref="byform"
+      >
+        <template #address>
+          <el-row style="width: 100%">
+            <el-col :span="8">
+              <el-form-item prop="countryId">
+                <el-select
+                  v-model="formData.data.countryId"
+                  placeholder="国家"
+                  @change="(val) => getCityData(val, '20', true)"
+                >
+                  <el-option
+                    v-for="item in countryData"
+                    :label="item.chineseName"
+                    :value="item.id"
+                  >
+                  </el-option>
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item prop="provinceId">
+                <el-select
+                  v-model="formData.data.provinceId"
+                  placeholder="省/洲"
+                  @change="(val) => getCityData(val, '30', true)"
+                >
+                  <el-option
+                    v-for="item in provinceData"
+                    :label="item.name"
+                    :value="item.id"
+                  >
+                  </el-option>
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item prop="cityId">
+                <el-select v-model="formData.data.cityId" placeholder="城市">
+                  <el-option
+                    v-for="item in cityData"
+                    :label="item.name"
+                    :value="item.id"
+                  >
+                  </el-option>
+                </el-select>
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row style="margin-top: 20px; width: 100%">
+            <el-col :span="24">
+              <el-form-item prop="detailedAddress">
+                <el-input
+                  v-model="formData.data.detailedAddress"
+                  type="textarea"
+                >
+                </el-input>
+              </el-form-item>
+            </el-col>
+          </el-row>
+        </template>
+        <template #products>
+          <div style="width: 100%">
+            <el-button
+              type="primary"
+              @click="openProduct = true"
+              style="margin-bottom: 10px"
+            >
+              添加物品
+            </el-button>
+            <el-table :data="formData.data.orderDetailsList">
+              <el-table-column prop="productCode" label="产品编码" />
+              <el-table-column prop="productName" label="产品名称" />
+              <el-table-column prop="price" label="单价" min-width="150">
+                <template #default="{ row, $index }">
+                  <el-form-item
+                    :prop="'orderDetailsList.' + $index + '.price'"
+                    :rules="rules.price"
+                    :inline-message="true"
+                  >
+                    <el-input-number
+                      v-model="row.price"
+                      :precision="4"
+                      :controls="false"
+                      :min="0"
+                      @change="totalAmount"
+                    />
+                  </el-form-item>
+                </template>
+              </el-table-column>
+              <el-table-column prop="quantity" label="数量" min-width="150">
+                <template #default="{ row, $index }">
+                  <el-form-item
+                    :prop="'orderDetailsList.' + $index + '.quantity'"
+                    :rules="rules.quantity"
+                    :inline-message="true"
+                  >
+                    <el-input-number
+                      v-model="row.quantity"
+                      :precision="4"
+                      :controls="false"
+                      :min="0"
+                      @change="totalAmount"
+                    />
+                  </el-form-item>
+                </template>
+              </el-table-column>
+              <el-table-column prop="total" label="小计" />
+              <el-table-column prop="remark" label="备注" min-width="200">
+                <template #default="{ row, $index }">
+                  <el-form-item
+                    :prop="'orderDetailsList.' + $index + '.remark'"
+                    :rules="rules.remark"
+                    :inline-message="true"
+                  >
+                    <el-input v-model="row.remark" placeholder="请输入" />
+                  </el-form-item>
+                </template>
+              </el-table-column>
+              <el-table-column
+                prop="zip"
+                label="操作"
+                width="60"
+                fixed="right"
+                align="center"
+              >
+                <template #default="{ $index }">
+                  <el-button type="primary" link @click="handleRemove($index)"
+                    >删除</el-button
+                  >
+                </template>
+              </el-table-column>
+            </el-table>
+          </div>
+        </template>
+      </byForm>
+      <template #footer>
+        <el-button @click="dialogVisible = false" size="large">取 消</el-button>
+        <el-button
+          type="primary"
+          @click="submitForm('byform')"
+          size="large"
+          :loading="submitLoading"
+        >
+          确 定
+        </el-button>
+      </template>
+    </el-dialog>
+    <el-dialog
+      v-model="openProduct"
+      title="选择产品"
+      width="70%"
+      append-to-body
+    >
+      <SelectProduct @handleSelect="handleSelect"></SelectProduct>
+      <template #footer>
+        <span class="dialog-footer">
+          <el-button @click="openProduct = false">取消</el-button>
+        </span>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+  
+<script setup>
+/* eslint-disable vue/no-unused-components */
+import { ElMessage, ElMessageBox } from "element-plus";
+import byTable from "@/components/byTable/index";
+import byForm from "@/components/byForm/index";
+import { computed, defineComponent, ref } from "vue";
+import useUserStore from "@/store/modules/user";
+import SelectProduct from "@/components/WDLY/product/SelectProduct";
+
+const loading = ref(false);
+const submitLoading = ref(false);
+const sourceList = ref({
+  data: [],
+  pagination: {
+    total: 3,
+    pageNum: 1,
+    pageSize: 10,
+  },
+});
+let dialogVisible = ref(false);
+let openProduct = ref(false);
+
+let roomDialogVisible = ref(false);
+let modalType = ref("add");
+let rules = ref({
+  customerInfoId: [
+    {
+      required: true,
+      message: "请选择客户",
+      trigger: "change",
+    },
+  ],
+  type: [
+    {
+      required: true,
+      message: "请选择订单类型",
+      trigger: "change",
+    },
+  ],
+  countryId: [
+    {
+      required: true,
+      message: "请选择国家",
+      trigger: "change",
+    },
+  ],
+  provinceId: [
+    {
+      required: true,
+      message: "请选择省/洲",
+      trigger: "change",
+    },
+  ],
+  cityId: [
+    {
+      required: true,
+      message: "请选择城市",
+      trigger: "change",
+    },
+  ],
+
+  contacts: [
+    {
+      required: true,
+      message: "请输入姓名",
+      trigger: "blur",
+    },
+  ],
+  phone: [
+    {
+      required: true,
+      message: "请输入联系电话",
+      trigger: "blur",
+    },
+  ],
+  detailedAddress: [
+    {
+      required: true,
+      message: "请输入详细地址",
+      trigger: "blur",
+    },
+  ],
+  price: [
+    {
+      required: true,
+      message: "请输入单价",
+      trigger: "blur",
+    },
+  ],
+  quantity: [
+    {
+      required: true,
+      message: "请输入数量",
+      trigger: "blur",
+    },
+  ],
+});
+const { proxy } = getCurrentInstance();
+const selectConfig = reactive([
+  {
+    label: "订单类型",
+    prop: "type",
+    data: [],
+  },
+  {
+    label: "订单状态",
+    prop: "status",
+    data: [
+      {
+        label: "进行中",
+        value: "1",
+      },
+      {
+        label: "已完成",
+        value: "2",
+      },
+      {
+        label: "已取消",
+        value: "3",
+      },
+    ],
+  },
+]);
+
+const config = computed(() => {
+  return [
+    {
+      attrs: {
+        label: "订单类型",
+        prop: "type",
+      },
+      render(type) {
+        return proxy.dictDataEcho(type, salesType.value);
+      },
+    },
+    {
+      attrs: {
+        label: "订单编号",
+        prop: "code",
+        slot: "code",
+      },
+    },
+    {
+      attrs: {
+        label: "客户名称",
+        prop: "customerInfoName",
+      },
+    },
+    {
+      attrs: {
+        label: "订单金额",
+        prop: "amountMoney",
+      },
+      render(money) {
+        return proxy.moneyFormat(money, 4);
+      },
+    },
+    {
+      attrs: {
+        label: "收件人",
+        prop: "contacts",
+      },
+    },
+    {
+      attrs: {
+        label: "联系电话",
+        prop: "phone",
+      },
+    },
+    {
+      attrs: {
+        label: "收件城市",
+        prop: "address",
+        slot: "address",
+      },
+    },
+    {
+      attrs: {
+        label: "下单时间",
+        prop: "createTime",
+      },
+    },
+    {
+      attrs: {
+        label: "订单状态",
+        prop: "status",
+      },
+      render(status) {
+        return status == 1 ? "进行中" : status == 2 ? "已完成" : "已取消";
+      },
+    },
+
+    {
+      attrs: {
+        label: "操作",
+        width: "200",
+        align: "right",
+      },
+      // 渲染 el-button,一般用在最后一列。
+      renderHTML(row) {
+        return [
+          row.status == 1
+            ? {
+                attrs: {
+                  label: "结束",
+                  type: "primary",
+                  text: true,
+                },
+                el: "button",
+                click() {
+                  getDtl(row, 2);
+                },
+              }
+            : {},
+          row.status == 1
+            ? {
+                attrs: {
+                  label: "取消",
+                  type: "primary",
+                  text: true,
+                },
+                el: "button",
+                click() {
+                  getDtl(row, 3);
+                },
+              }
+            : {},
+        ];
+      },
+    },
+  ];
+});
+
+let formData = reactive({
+  data: {},
+  treeData: [],
+});
+const formOption = reactive({
+  inline: true,
+  labelWidth: 100,
+  itemWidth: 100,
+  rules: [],
+});
+const byform = ref(null);
+const treeData = ref([]);
+const formConfig = reactive([
+  {
+    type: "select",
+    prop: "customerInfoId",
+    label: "客户名称",
+    isLoad: {
+      url: `/tenantUser/list?pageNum=1&pageSize=9999&tenantId=${
+        useUserStore().user.tenantId
+      }`,
+      labelKey: "nickName",
+      labelVal: "userId",
+      method: "get",
+      resUrl: "rows",
+    },
+  },
+  {
+    type: "select",
+    prop: "type",
+    label: "订单类型",
+    itemWidth: 100,
+    data: [],
+  },
+  {
+    type: "input",
+    prop: "contacts",
+    label: "收件人",
+    itemWidth: 20,
+  },
+  {
+    type: "input",
+    prop: "phone",
+    label: " ",
+    itemWidth: 30,
+  },
+  {
+    type: "slot",
+    slotName: "address",
+    prop: "countryId",
+    label: "收件地址",
+    required: true,
+  },
+  {
+    type: "title",
+    title: "订单明细",
+  },
+  {
+    type: "slot",
+    slotName: "products",
+  },
+  {
+    type: "input",
+    prop: "amountMoney",
+    label: "订单金额",
+    disabled: true,
+    itemWidth: 20,
+  },
+]);
+const getList = async (req) => {
+  sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
+  loading.value = true;
+  proxy.post("/orderInfo/page", sourceList.value.pagination).then((message) => {
+    console.log(message);
+    sourceList.value.data = message.rows;
+    sourceList.value.pagination.total = message.total;
+    setTimeout(() => {
+      loading.value = false;
+    }, 200);
+  });
+};
+const openModal = () => {
+  dialogVisible.value = true;
+  modalType.value = "add";
+  formData.data = {
+    orderDetailsList: [],
+    countryId: "China",
+  };
+  getCityData(formData.data.countryId, "20");
+};
+
+const submitForm = () => {
+  console.log(byform.value);
+  byform.value.handleSubmit((valid) => {
+    const list = formData.data.orderDetailsList;
+    if (!list.length > 0)
+      return ElMessage({
+        message: `请添加订单明细!`,
+        type: "info",
+      });
+    for (let i = 0; i < list.length; i++) {
+      const e = list[i];
+      if (e.quantity == 0) {
+        return ElMessage({
+          message: `数量不能为0!`,
+          type: "info",
+        });
+      }
+    }
+    submitLoading.value = true;
+    proxy.post("/orderInfo/" + modalType.value, formData.data).then(
+      (res) => {
+        ElMessage({
+          message: modalType.value == "add" ? "添加成功" : "编辑成功",
+          type: "success",
+        });
+        dialogVisible.value = false;
+        submitLoading.value = false;
+        getList();
+      },
+      (err) => (submitLoading.value = false)
+    );
+  });
+};
+
+const getDtl = (row, status) => {
+  const statusNmae = status == 2 ? "结束" : "取消";
+  // 弹窗提示是否删除
+  ElMessageBox.confirm(`您确定执行${statusNmae}操作吗?`, "提示", {
+    confirmButtonText: "确定",
+    cancelButtonText: "取消",
+    type: "warning",
+  }).then(() => {
+    // 删除
+    proxy
+      .post("/orderInfo/edit", {
+        id: row.id,
+        status,
+      })
+      .then((res) => {
+        ElMessage({
+          message: "操作成功",
+          type: "success",
+        });
+        getList();
+      });
+  });
+};
+
+const warehouseList = ref([]);
+const salesType = ref([]);
+
+const getDict = () => {
+  proxy.getDict(["order_sales_type"]).then((res) => {
+    salesType.value = res["order_sales_type"];
+    formConfig[1].data = salesType.value.map((x) => ({
+      label: x.dictValue,
+      value: x.dictKey,
+    }));
+    selectConfig[0].data = salesType.value.map((x) => ({
+      label: x.dictValue,
+      value: x.dictKey,
+    }));
+  });
+};
+const countryData = ref([]);
+const provinceData = ref([]);
+const cityData = ref([]);
+
+const getCityData = (id, type, isChange) => {
+  proxy.post("/areaInfo/list", { parentId: id }).then((res) => {
+    if (type === "20") {
+      provinceData.value = res;
+      if (isChange) {
+        formData.data.provinceId = "";
+        formData.data.cityId = "";
+      }
+    } else if (type === "30") {
+      cityData.value = res;
+      if (isChange) {
+        formData.data.cityId = "";
+      }
+    } else {
+      countryData.value = res;
+    }
+  });
+};
+getCityData("0");
+getList();
+getDict();
+
+const totalAmount = () => {
+  let sum = 0;
+  for (let i = 0; i < formData.data.orderDetailsList.length; i++) {
+    const e = formData.data.orderDetailsList[i];
+    e.total = (e.price * 1000000 * e.quantity) / 1000000;
+    sum += e.total;
+  }
+  formData.data.amountMoney = sum;
+};
+
+const handleSelect = (row) => {
+  const flag = formData.data.orderDetailsList.some(
+    (x) => x.productId === row.id
+  );
+  if (flag)
+    return ElMessage({
+      message: "该物品已选择",
+      type: "info",
+    });
+  formData.data.orderDetailsList.push({
+    productName: row.name,
+    productCode: row.code,
+    productId: row.id,
+    total: "",
+    quantity: null,
+    price: null,
+  });
+  return ElMessage({
+    message: "选择成功",
+    type: "success",
+  });
+};
+
+const handleRemove = (index) => {
+  formData.data.orderDetailsList.splice(index, 1);
+  totalAmount();
+  return ElMessage({
+    message: "删除成功",
+    type: "success",
+  });
+};
+</script>
+  
+<style lang="scss" scoped>
+.tenant {
+  padding: 20px;
+}
+</style>