戴艳蓉 %!s(int64=3) %!d(string=hai) anos
pai
achega
e54746e9e5

BIN=BIN
public/static/收货地址模板.xlsx


BIN=BIN
src/assets/file/dTemplate.xlsx


+ 123 - 20
src/views/sellOut/salesOrder/components/addEdit.vue

@@ -12,6 +12,7 @@
     element-loading-text="拼命加载中"
     element-loading-spinner="el-icon-loading"
     element-loading-background="rgba(0, 0, 0, 0.8)"
+    append-to-body
   >
     <el-card style="margin-top: -20px">
       <el-row :gutter="10">
@@ -167,32 +168,33 @@
         </el-col>
         <el-col :span="24" style="padding: 0 0 22px 0">
           <div style="height: 30px">
+            <a href="./static/收货地址模板.xlsx">
+              <el-tooltip
+                class="fr"
+                style="margin: 3px 0 0 0"
+                effect="dark"
+                content="下载收货地址模板"
+                placement="top"
+              >
+                <i
+                  class="el-icon-circle-plus-outline tb-icon"
+                  style="color: #63cbe7"
+                ></i>
+              </el-tooltip>
+            </a>
             <el-tooltip
               class="fr"
               style="margin: 3px 0 0 0"
               effect="dark"
-              content="下载收货地址模板"
+              content="导入收货地址"
               placement="top"
             >
               <i
                 class="el-icon-circle-plus-outline tb-icon"
                 style="color: #63cbe7"
-                @click="DownloadTemplate"
+                @click="openAddModal(-1)"
               ></i>
             </el-tooltip>
-            <!-- <el-tooltip
-              class="fr"
-              style="margin: 3px 0 0 0"
-              effect="dark"
-              content="下载收货地址模板"
-              placement="top"
-            >
-              <i
-                class="el-icon-circle-plus-outline tb-icon"
-                style="color: #63cbe7"
-                @click="openHouseModal(-1)"
-              ></i>
-            </el-tooltip> -->
           </div>
           <el-form :model="addrForm" ref="addrForm" :size="'mini'">
             <el-table
@@ -379,6 +381,14 @@
             </el-table>
           </el-form>
         </el-col>
+
+        <el-col :span="24">
+          <in-addr-model
+            :show-model="addrmodel"
+            @cancel="addrmodel = false"
+            @refresh="addrRefresh"
+          />
+        </el-col>
         <el-col :span="24" style="text-align: right">
           <el-button :size="'mini'" type="primary" @click="submitForm"
             >保 存
@@ -393,11 +403,12 @@ import resToken from "@/mixins/resToken";
 import asyncRequest from "@/apis/service/sellOut/salesOrder/detail";
 import searchStockGoodModal from "@/components/search-stock-good-modal";
 import { isnumber, isMobile } from "@/utils/validate";
+import inAddrModel from "./in-addr-model";
 export default {
   name: "allot",
   props: ["showModel", "id"],
   mixins: [resToken],
-  components: { searchStockGoodModal },
+  components: { searchStockGoodModal, inAddrModel },
   data() {
     const validatemobile = (rule, value, callback) => {
       if (value === "") {
@@ -424,6 +435,7 @@ export default {
     };
     return {
       loading: false,
+      addrmodel: false,
       title: "新建销售订单",
       showModelThis: this.showModel,
       showGoodsModel: false,
@@ -517,10 +529,32 @@ export default {
       console.log("closeModel!!");
       this.showModelThis = false;
     },
+    openAddModal(index) {
+      this.addrmodel = true;
+    },
+    addrRefresh(e) {
+      console.log(e);
+    },
     DownloadTemplate() {
-      if(!this.loading){
-        this.loading=false
-        
+      if (!this.loading) {
+        this.loading = true;
+        const bloc = dataURLtoBlob(fileUrl);
+        const blob = new Blob([bloc], {
+          type: "application/vnd.ms-excel",
+        });
+        const downLoadEle = document.createElement("a");
+        // 通过返回的二进制数据来创建一个对象URL.
+        const href = URL.createObjectURL(blob);
+        downLoadEle.href = href;
+        // 信息表为自定义文件名
+        downLoadEle.download = "信息表";
+        document.body.appendChild(downLoadEle);
+        downLoadEle.click();
+        document.body.removeChild(downLoadEle);
+        // 当加载完成后释放对象URL.
+        window.URL.revokeObjectURL(href);
+        // window.open(fileUrl, "_blank");
+        this.loading = false;
       }
     },
     goods_class_change(e) {
@@ -798,4 +832,73 @@ export default {
 };
 </script>
 
-   
+   
+   <style lang="scss" scoped>
+// .capitalClaim {
+  .excelUploadBox {
+    position: relative;
+    width: 100%;
+    height: 120px;
+    line-height: 120px;
+    box-sizing: border-box;
+    &:hover {
+      cursor: pointer;
+    }
+    .el-icon-receiving {
+      width: 100%;
+      text-align: center;
+      height: 50px;
+      display: block;
+      font-size: 32px;
+      line-height: 90px;
+      color: #d3d4d6;
+    }
+    .boxM {
+      width: 100%;
+      display: block;
+      text-align: center;
+      line-height: 65px;
+      height: 60px;
+      color: #909399;
+    }
+  }
+  .excelUpload {
+    top: 0;
+    left: 0;
+    position: absolute;
+    z-index: 2;
+    width: 100%;
+    height: 120px;
+    line-height: 120px;
+    box-sizing: border-box;
+  }
+  .excelUploadRes {
+    width: 100%;
+    height: 120px;
+    line-height: 120px;
+    box-sizing: border-box;
+    i {
+      width: 55px;
+      height: 120px;
+      line-height: 120px;
+      text-align: center;
+      font-size: 20px;
+      &.fl {
+        padding-left: 16px;
+      }
+      &.fr {
+        padding-right: 16px;
+        &:hover {
+          cursor: pointer;
+        }
+      }
+    }
+    span {
+      width: 386px;
+      line-height: 16px;
+      margin: 52px 0 0 0;
+      font-size: 16px;
+    }
+  }
+// }
+</style>

+ 1 - 0
src/views/sellOut/salesOrder/components/addForm.vue

@@ -340,6 +340,7 @@ import resToken from "@/mixins/resToken";
 import asyncRequest from "@/apis/service/sellOut/salesOrder/detail";
 import searchStockGoodModal from "@/components/search-stock-good-modal";
 import { isnumber, isMobile } from "@/utils/validate";
+
 export default {
   name: "salesOrderDetail",
   mixins: [mixinPage, resToken],

+ 318 - 0
src/views/sellOut/salesOrder/components/in-addr-model.vue

@@ -0,0 +1,318 @@
+<template>
+  <el-dialog
+    v-loading="loading"
+    title="导入数据"
+    :center="true"
+    align="left"
+    top="20vh"
+    width="700px"
+    :close-on-click-modal="false"
+    :visible.sync="showModelThis"
+    element-loading-text="拼命加载中"
+    element-loading-spinner="el-icon-loading"
+    element-loading-background="rgba(0, 0, 0, 0.8)"
+    append-to-body
+    @close="closeModel"
+  >
+    <el-card>
+      <el-row :gutter="10">
+        <el-col :span="24">
+          <el-form
+            ref="ruleForm"
+            :model="ruleForm"
+            status-icon
+            :rules="rules"
+            label-width="110px"
+            class="demo-ruleForm"
+          >
+            <el-form-item label="表格文件" prop="execl">
+              <el-card shadow="never" :body-style="{ padding: '0px' }">
+                <div class="excelUploadBox" v-if="!isfile">
+                  <i class="el-icon-receiving"></i>
+                  <span class="boxM"> 点击此处,上传文件!</span>
+
+                  <upload-excel
+                    :accept="'.xls'"
+                    class="excelUpload"
+                    :uploadcondition="beforeAvatarUpload"
+                    @UploadErrorEvent="UploadErrorEvent"
+                    @UploadSuccessEvent="UploadSuccessEvent"
+                  />
+                </div>
+                <div v-else class="excelUploadRes clear">
+                  <i class="el-icon-document fl"></i>
+                  <span class="fl"> {{ ruleForm.execl.name }}</span>
+                  <i class="el-icon-close fr" @click="fileClose"></i>
+                </div>
+              </el-card>
+            </el-form-item>
+          </el-form>
+        </el-col>
+        <el-col :span="24" style="text-align: right">
+          <el-button v-if="!isDetail" type="primary" @click="submitForm"
+            >保 存
+          </el-button>
+          <el-button @click="showModelThis = false">{{
+            isDetail ? "关 闭" : "取 消"
+          }}</el-button>
+        </el-col>
+      </el-row>
+    </el-card>
+  </el-dialog>
+</template>
+<script>
+import asyncRequest from "@/apis/service/sellOut/salesOrder/detail";
+import resToken from "@/mixins/resToken";
+import { isnumber, isnumber2, isAlphanumeric } from "@/utils/validate";
+export default {
+  name: "Account",
+  props: ["showModel", "id", "sitem"],
+  mixins: [resToken],
+  data() {
+    const validatePrice = (rule, value, callback) => {
+      if (value === "") {
+        callback(new Error("不能为空!"));
+      } else {
+        if (isnumber2(value)) {
+          callback();
+        } else {
+          callback(new Error("仅支持整数或两位小数!"));
+        }
+      }
+    };
+    const validateWeight = (rule, value, callback) => {
+      if (value === "") {
+        callback(new Error("不能为空!"));
+      } else {
+        if (!isnumber(value)) {
+          callback(new Error("仅支持整数!"));
+        } else {
+          callback();
+        }
+      }
+    };
+    const validateCode = (rule, value, callback) => {
+      if (value === "") {
+        callback(new Error("不能为空!"));
+      } else {
+        if (!isAlphanumeric(value)) {
+          callback(new Error("仅支持字母和数字!"));
+        } else {
+          callback();
+        }
+      }
+    };
+    return {
+      loading: false,
+      showModelThis: this.showModel,
+      isfile: false,
+      ruleForm: {
+        execl: "",
+      },
+      rules: {
+        execl: [
+          {
+            required: true,
+            message: "请选择文件",
+            trigger: "change",
+          },
+        ],
+      },
+    };
+  },
+  watch: {
+    showModel: function (val) {
+      this.showModelThis = val;
+      if (val) {
+        this.initForm();
+      }
+    },
+    showModelThis(val) {
+      if (!val) {
+        this.$emit("cancel");
+      }
+    },
+  },
+  methods: {
+    closeModel() {
+      console.log("closeModel!!");
+    },
+    async resetForm() {
+      // 重置
+      await this.$nextTick(() => {
+        if (this.$refs.ruleForm) {
+          this.$refs.ruleForm.resetFields();
+          this.$refs.ruleForm.clearValidate();
+          this.ruleForm = {
+            execl: "",
+          };
+        }
+      });
+    },
+    beforeAvatarUpload(file) {
+      console.log(file.type);
+      let isJPG = false;
+      if (file.type === "application/vnd.ms-excel") {
+        isJPG = true;
+      }
+      const isLt2M = file.size / 1024 / 1024 < 3;
+      if (!isJPG) {
+        this.$message.error("文件格式不正确!");
+      }
+      if (!isLt2M) {
+        this.$message.error("文件大小不能超过 3MB!");
+      }
+      this.isfile = false;
+      return isJPG && isLt2M;
+    },
+    fileClose() {
+      this.isfile = false;
+      this.ruleForm.execl = "";
+      this.$refs.ruleForm.validateField("execl");
+    },
+    //图片上传失败
+    UploadErrorEvent() {
+      this.isfile = false;
+      this.$message.error("文件上传失败!");
+      this.$refs.ruleForm.validateField("execl");
+    },
+    //图片上传成功
+    UploadSuccessEvent(data) {
+      console.log(data);
+      this.isfile = true;
+      this.ruleForm.execl = data.file;
+      this.$message.success("文件上传成功!");
+      this.$refs.ruleForm.validateField("execl");
+    },
+    handleSelectionChange(e, type) {
+      if (type === 0) {
+        this.list0 = e;
+        this.ruleForm.wsm_code = e && e.length > 0 ? e[0].wsm_code : "";
+      } else {
+        this.list1 = e;
+        this.ruleForm.addrid = e && e.length > 0 ? e[0].id : "";
+      }
+      console.log(type);
+      console.log(this.ruleForm.wsm_code, this.ruleForm.addrid);
+      console.log(this.ruleForm);
+    },
+    async initForm() {
+      this.isfile = false;
+      this.loading = true;
+      await this.resetForm();
+      this.loading = false;
+    },
+
+    // 保存更改
+    async submitForm() {
+      await this.$refs.ruleForm.validate(async (valid) => {
+        if (valid) {
+          const item = JSON.parse(JSON.stringify(this.ruleForm));
+          if (this.list0.length === 0) {
+            this.$message.warning("请选择发货仓库!");
+            return;
+          }
+          if (this.list1.length === 0) {
+            this.$message.warning("请选择收货地址!");
+            return;
+          }
+          if (this.list0.length !== 1) {
+            this.$message.warning("只能选择一个发货仓库!");
+            return;
+          }
+          if (this.list1.length !== 1) {
+            this.$message.warning("只能选择一个收货地址!");
+            return;
+          }
+          let cNum = parseInt(this.list0[0].wsend_num);
+          let aNum = parseInt(this.list1[0].wsend_num);
+          let num = parseInt(this.ruleForm.send_num);
+          if (num > cNum) {
+            this.$message.warning("发货数量不能大于仓库未发货数量!");
+            return;
+          }
+          if (num > aNum) {
+            this.$message.warning("发货数量不能大于收货地址未发货数量!");
+            return;
+          }
+          this.loading = true;
+          console.log(item);
+          item.post_name = item.post_name.toString();
+          const res = await asyncRequest.saleout(item);
+          this.loading = false;
+          if (res && res.code === 0) {
+            this.$notify.success({
+              title: "添加成功",
+              message: "",
+            });
+            this.showModelThis = false;
+            this.$emit("refresh"); //抛出事件给详情页。
+          } else if (res && res.code >= 100 && res.code <= 104) {
+            await this.logout();
+          } else {
+            this.$message.warning(res.message);
+          }
+        } else {
+          console.log("error submit!!");
+          return false;
+        }
+      });
+    },
+  },
+};
+</script>
+
+   <style lang="scss" scoped>
+.account {
+  .gongshi {
+    span {
+      vertical-align: top;
+      display: inline-block;
+      color: #000;
+    }
+    .icon-span {
+      padding: 0 5px;
+      height: 40px;
+      line-height: 40px;
+      font-size: 20px;
+      color: #606266;
+      display: inline-block;
+      // vertical-align: top;
+      // display: inline-block;
+    }
+    .label {
+      height: 40px;
+      line-height: 40px;
+    }
+    .tuan {
+      &.chu {
+        width: 60px;
+        height: 40px;
+        display: inline-block;
+        span {
+          width: 60px;
+          display: inline-block;
+          line-height: 20px;
+          text-align: center;
+          font-size: 12px;
+          height: 20px;
+          &:last-child {
+            border-top: 1px solid #606266;
+          }
+        }
+      }
+      &.cheng {
+        .name {
+          height: 40px;
+          line-height: 40px;
+        }
+        .icon-span {
+          line-height: 40px;
+          font-size: 16px;
+          padding: 0 1px;
+        }
+      }
+    }
+  }
+}
+</style>