Browse Source

零售单管理添加详情与打印功能/零售单提交功能/成品出库打印添加qrCodeId

lph 1 year ago
parent
commit
f1e278fb0a

+ 19 - 1
zkqy-ui/src/api/system/retailMange.js

@@ -33,11 +33,29 @@ export function addRetailOrder(data) {
     data: data
   })
 }
-// 新增零售订单
+// 编辑零售订单
 export function editRetailOrder(data) {
   return request({
     url: '/system/order/editRetailOrder',
     method: 'put',
     data: data
   })
+}
+
+// 提交零售单  获取提交详情
+export function retailProductInvoiceInfo(params) {
+  return request({
+    url: '/system/ProductInvoice/productInvoiceInfo',
+    method: 'get',
+    params
+  })
+}
+
+// 获取库存箱数
+export function getProductInventory(data) {
+  return request({
+    url: '/system/ProductInventory/getProductInventory',
+    method: 'post',
+    data: data
+  })
 }

+ 60 - 4
zkqy-ui/src/utils/other.js

@@ -44,7 +44,63 @@ export function inputDisableComplete() {
  * @return {*} 
  */
 export function getDictLabel(value, dictLsit = []) {
-      return dictLsit.find((item) => {
-        return item.value == value;
-      })?.label;
-}
+  return dictLsit.find((item) => {
+    return item.value == value;
+  })?.label;
+}
+
+export class numToCapital {
+  uppercase(num) {
+    let minus = "";
+    let m_str = "";
+    const text = num.toString();
+    const zh = '零壹贰叁肆伍陆柒捌玖';
+    if (text.indexOf("-") === 0) {
+      num = text.replace("-", "");
+      minus = "负"
+    }
+    let money_num = Number(num);
+    let money = Math.round(money_num * 100).toString(10);
+    const len = money.length;
+    for (let i = 0; i < len; i++) {
+      m_str = m_str + zh.charAt(parseInt(money.charAt(i))) + this.sitToUnit(len - i - 1)
+    }
+    m_str = m_str.replace("零分", "");
+    m_str = m_str.replace("零角", "零");
+    let yy = 0;
+    while (true) {
+      let len = m_str.length;
+      m_str = m_str.replace("零圆", "圆");
+      m_str = m_str.replace("零万", "万");
+      m_str = m_str.replace("零亿", "亿");
+      m_str = m_str.replace("零仟", "零");
+      m_str = m_str.replace("零佰", "零");
+      m_str = m_str.replace("零零", "零");
+      m_str = m_str.replace("零拾", "零");
+      m_str = m_str.replace("亿万", "亿零");
+      m_str = m_str.replace("万仟", "万零");
+      m_str = m_str.replace("仟佰", "仟零");
+      yy = m_str.length;
+      if (yy === len) {
+        break
+      }
+    }
+    yy = m_str.length;
+    if (m_str.charAt(yy - 1) === "零") {
+      m_str = m_str.substring(0, yy - 1)
+    }
+    yy = m_str.length;
+    if (m_str.charAt(yy - 1) === "圆") {
+      m_str = m_str + "整"
+    }
+    return minus + m_str
+  }
+  sitToUnit(a) {
+    if (a > 10) {
+      a = a - 8;
+      return (this.sitToUnit(a))
+    }
+    const zh = '分角圆拾佰仟万拾佰仟亿';
+    return zh.charAt(a)
+  }
+}

+ 8 - 7
zkqy-ui/src/utils/print/codeListPrint.js

@@ -44,35 +44,36 @@ function codeListPrint(data, domId) {
       directionOfTwist,//捻向
       qrCodeData,
       boxNum,//箱号
-      packaging
+      packaging,
+      qrCodeId,
     } = item
     // let theNumber = Number(printFormat) //小包装:1  大包装:2
     let theNumber = packaging == 3 ? 2 : 1;  //车丝和小包装都是1  大包装是2
 
     console.log(theNumber);
     // 循环打印
-    let uuid = uuidv4().slice(0, 8);
+    // let uuid = uuidv4().slice(0, 8);
     while (theNumber > 0) {
       theNumber--;
       res += (printFormat == 3 ? '' : preHtml);
       // let qrCodeData = '123456';
       // let temp = id + '@' + uuid + '@' + canisterNum + '@' + suttle + '@' + grossWeight + '@' + lotNum + '@' + productName + '@' + productSpecifications + '@' + productColor + '@' + levels + '@' + qrCode + '@' + boxNum
-      let temp = id + '@' + uuid + '@' + canisterNum + '@' + suttle + '@' + grossWeight + '@' + qrCode
+      let temp = id + '@' + qrCodeId + '@' + canisterNum + '@' + suttle + '@' + grossWeight + '@' + qrCode
       // let resStr = encodeURIComponent(temp)
       if (printFormat == 3) {//打印英文版
         uuidList.push({
-          id: uuid + '' + theNumber,
+          id: qrCodeId + '' + theNumber,
           qrCodeData: temp,//id uuid 筒数 净重 毛重 批次 品种 规格 色号 等级 码单号 箱号 
           size: 180,
         })
-        res = printEN(uuid + '' + theNumber, item, res)
+        res = printEN(qrCodeId + '' + theNumber, item, res)
       } else {//打印中文版
         uuidList.push({
-          id: uuid + '' + theNumber,
+          id: qrCodeId + '' + theNumber,
           qrCodeData: temp,//id uuid 筒数 净重 毛重 批次 品种 规格 色号 等级 码单号 箱号
           size: 120,
         })
-        res = printCN(uuid + '' + theNumber, item, res) + endHtml;
+        res = printCN(qrCodeId + '' + theNumber, item, res) + endHtml;
       }
     }
   }

+ 1 - 1
zkqy-ui/src/views/bussiness/processMange_line.vue

@@ -49,7 +49,7 @@
                 v-for="(item, index) in productLineList"
                 :key="index"
                 :label="item.productionLineName"
-                :value="item.productionLineNo"
+                :value="item.id"
               >
                 <span class="discribe" style="float: left">{{
                   item.productionLineName

+ 488 - 0
zkqy-ui/src/views/orderMange/components/dialogForm/RetailProvide.vue

@@ -0,0 +1,488 @@
+<template>
+  <div class="form-wrap">
+    <div class="title"><span>诸暨市新丝维纤维有限公司销售开单</span></div>
+    <el-row :gutter="20">
+      <el-form
+        ref="form"
+        :model="form"
+        :rules="rules"
+        label-width="100px"
+        class="form"
+        :inline="true"
+      >
+        <el-col :span="24">
+          <el-form-item prop="noticeNumber" label="通知单号:" size="mini">
+            {{ form.noticeNumber }}
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="通知日期:" prop="noticeDate" size="mini">
+            <!-- <el-date-picker
+              v-model="form.noticeDate"
+              type="date"
+              size="mini"
+              placeholder="选择日期"
+            >
+            </el-date-picker> -->
+            {{ form.noticeDate }}
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="销售员:" prop="salesman" size="mini">
+            <!-- <el-input
+              v-model="form.salesman"
+              placeholder=""
+              size="mini"
+              clearable
+            ></el-input> -->
+            {{ form.salesman }}
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="当前库存:" size="mini">
+            {{ "箱数: " + form.inventoryBoxNum }}
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="8">
+          <el-form-item label="开票员:" prop="drawer" size="mini">
+            {{ form.drawer }}
+            <!-- <el-input
+              v-model="form.drawer"
+              placeholder=""
+              size="mini"
+              clearable
+            ></el-input> -->
+
+            <!-- <el-select
+              width="100px"
+              v-model="form.drawer"
+              placeholder=""
+              clearable
+              filterable
+            >
+              <el-option
+                v-for="item in []"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              >
+              </el-option>
+            </el-select> -->
+          </el-form-item>
+        </el-col>
+
+        <!-- <el-divider direction="horizontal" content-position="center"
+          >11111</el-divider
+        > -->
+
+        <el-col :span="8">
+          <el-form-item label="客户名称" size="mini">
+            {{ form.customName }}
+            <!-- <el-select
+              v-model="form.customerId"
+              placeholder=""
+              clearable
+              filterable
+            >
+              <el-option
+                v-for="item in customerOptions"
+                :key="item.id"
+                :label="item.customName"
+                :value="item.id"
+              >
+              </el-option>
+            </el-select> -->
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="备 注:" prop="dispatchNoteRemark" size="mini">
+            <el-input
+              v-model="form.dispatchNoteRemark"
+              placeholder=""
+              size="mini"
+              clearable
+            ></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="货车登记:" prop="truckRegistration" size="mini">
+            <el-input
+              v-model="form.truckRegistration"
+              placeholder=""
+              size="mini"
+              clearable
+            ></el-input>
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="8">
+          <el-form-item label="开票类型:" prop="billingType" size="mini">
+            <!-- <el-select
+              v-model="form.billingType"
+              placeholder=""
+              clearable
+              filterable
+            >
+              <el-option
+                v-for="item in dict.type.billing_type"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              >
+              </el-option>
+            </el-select> -->
+            {{ "一类开票" }}
+          </el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="单据类型:" prop="documentType" size="mini">
+            <!-- <el-select
+              v-model="form.documentType"
+              placeholder=""
+              clearable
+              filterable
+            >
+              <el-option
+                v-for="item in dict.type.document_type"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              >
+              </el-option>
+            </el-select> -->
+            销售
+          </el-form-item>
+        </el-col>
+      </el-form>
+    </el-row>
+    <el-table
+      show-summary
+      :data="tableData"
+      :summary-method="getSummaries"
+      @cell-click="cellClick"
+      border
+      stripe
+    >
+      <el-table-column
+        v-for="(col, index) in columns"
+        :prop="col.id"
+        :key="index"
+        :label="col.label"
+      >
+      </el-table-column>
+      <el-table-column label="备注" prop="productRemark">
+        <!-- <template slot-scope="scope">
+          <el-input
+            v-model="scope.row.productRemark"
+            size="mini"
+            clearable
+          ></el-input>
+        </template> -->
+      </el-table-column>
+    </el-table>
+  </div>
+</template>
+
+<script>
+import {
+  productInvoiceInfo,
+  queryDropDownBoxData,
+} from "@/api/tablelist/commonTable";
+import {
+  retailProductInvoiceInfo,
+  getProductInventory,
+} from "@/api/system/retailMange.js";
+import { mapState } from "vuex";
+import moment from "moment";
+export default {
+  name: "RetailProvide",
+  props: ["currentRow"],
+  dicts: ["billing_type", "document_type"],
+  components: {},
+  data() {
+    return {
+      isEdit: false,
+      customerOptions: [], //客户选项
+      form: {
+        noticeNumber: "", //通知单号
+        noticeDate: "", //通知日期
+        salesman: "", //销售员
+        customerId: "", //客户编号
+        drawer: "", //开票员
+        dispatchNoteRemark: "", //发货单备注
+        billingType: "", //开票类型
+        truckRegistration: "", //货车登记
+        documentType: "", //单据类型
+        sellingUnit: "", //售货单位
+        auditOpinion: "", //审核意见
+        inventoryBoxNum: "", //库存箱数
+        inventoryWeight: "", //库存重量
+
+        batchNumberType: 1, //批次类型
+        computeType: 1, //计算方式
+      },
+      rules: {},
+      tableData: [
+        {
+          // productCode: "", //编码
+          // productName: "", //品名
+          // productSpecifications: "", //规格
+          // lotNum: "", //批号
+          // levels: "", //等级
+          // boxNum: "", //箱数
+          // weight: "", //重量
+          // unitPrice: "", //单价
+          // saleAmount: "", //销售金额
+          // productColor: "", //色泽
+          // productType: "", //类型
+          // bottomPrice: "", //底价
+          // productRemark: "", //备注
+        },
+      ],
+      columns: [
+        {
+          id: "productCode",
+          label: "编码",
+        },
+        {
+          id: "productName",
+          label: "品名",
+        },
+        {
+          id: "productSpecifications",
+          label: "规格",
+        },
+        // {
+        //   id: "lotNum",
+        //   label: "批号",
+        // },
+        // {
+        //   id: "levels",
+        //   label: "等级",
+        // },
+        {
+          id: "actualWeight",
+          label: "箱数",
+        },
+        // {
+        //   id: "weight",
+        //   label: "重量",
+        // },
+        {
+          id: "unitPrice",
+          label: "单价",
+        },
+        {
+          id: "saleAmount",
+          label: "销售金额",
+        },
+        {
+          id: "productColor",
+          label: "色泽",
+        },
+        {
+          id: "productType",
+          label: "类型",
+        },
+        {
+          id: "unitPrice",
+          label: "底价",
+        },
+      ],
+    };
+  },
+  computed: {
+    ...mapState({
+      username: (state) => state.user.name,
+    }),
+  },
+  methods: {
+    // 自定义合计方法
+    getSummaries(param) {
+      const { columns, data } = param;
+      const sums = [];
+      columns.forEach((column, index) => {
+        if (index === 0) {
+          sums[index] = "合计";
+          return;
+        }
+        const values = data.map((item) => Number(item[column.property]));
+        if (!values.every((value) => isNaN(value))) {
+          if (index == 3 || index == 4 || index == 5) {
+            sums[index] = values.reduce((prev, curr) => {
+              const value = Number(curr);
+              if (!isNaN(value)) {
+                return prev + curr;
+              } else {
+                return prev;
+              }
+            }, 0);
+          } else {
+            sums[index] = "";
+          }
+        } else {
+          sums[index] = "";
+        }
+      });
+      console.log(sums);
+      return sums;
+    },
+    // 初始化下拉框数据
+    async initDropDownBoxData() {
+      try {
+        let res = await queryDropDownBoxData([
+          {
+            basicMap: {
+              tableName: "customer",
+            },
+          },
+        ]);
+        if (res.code == 200) {
+          console.log(res);
+          this.customerOptions = res.data.resultMap.customer;
+        } else {
+          throw new Error(res);
+        }
+      } catch (error) {
+        console.log(error);
+      }
+    },
+    // 单号生成
+    getOrderNo() {
+      let year = new Date().getFullYear();
+      let month = new Date().getMonth() + 1;
+      let day = new Date().getDate();
+      if (month < 10) {
+        month = "0" + month;
+      }
+      if (day < 10) {
+        day = "0" + day;
+      }
+      let hour = new Date().getHours();
+      let minute = new Date().getMinutes();
+      let second = new Date().getSeconds();
+      if (hour < 10) {
+        hour = "0" + hour;
+      }
+      if (minute < 10) {
+        minute = "0" + minute;
+      }
+      if (second < 10) {
+        second = "0" + second;
+      }
+      let orderNo = year + month + day + hour + minute + second;
+      return orderNo;
+    },
+    // 获取发货单详情
+    async productInvoiceInfo(row) {
+      // 获取下拉框数据
+      await this.initDropDownBoxData();
+      let { saleNo, saleDate, salesman, customName } = row;
+      console.log(row);
+      let payload = {
+        saleOrderNo: saleNo,
+      };
+      let res = await retailProductInvoiceInfo(payload);
+      if (res.code == 200) {
+        this.tableData = res.data.saleProductInfoList;
+        this.tableData.forEach((item) => {
+          // item.saleOrderNo = saleOrderSaleNo;
+          let { boxNum, actualWeight, unitPrice } = item;
+          item.saleAmount = (Number(actualWeight) * Number(unitPrice)).toFixed(
+            2
+          );
+        });
+        // 表单字段循环赋值
+        // for (const key of Object.keys(this.form)) {
+        //   this.form[key] = res.data[key];
+        // }
+        // 初始化表单数据  start
+        this.form.customName = customName;
+        this.form.customerId = res.data.customerId;
+        this.form.noticeDate = moment(new Date()).format("YYYY-MM-DD");
+        this.form.salesman = salesman;
+        this.form.drawer = this.username;
+        this.form.documentType = "1";
+        this.form.billingType = "1";
+        this.form.saleOrderNo = saleNo;
+        this.form.inventoryBoxNum = res.data.inventoryBoxNum;
+        console.log(this.form);
+
+        // 初始化表单数据  end
+        this.form.inventoryWeight = Number(this.form.inventoryWeight)?.toFixed(
+          2
+        );
+        this.isEdit = res.data.id ? true : false;
+        if (!this.isEdit) {
+          this.form.drawer = this.username;
+          this.form.noticeNumber = this.getOrderNo();
+          this.form.status = 1;
+        } else {
+          this.form.noticeNumber = res.data.noticeNumber;
+          this.form.id = res.data.id;
+          this.form.dispatchNoteRemark = res.data.dispatchNoteRemark;
+          this.form.truckRegistration = res.data.truckRegistration;
+        }
+        this.form.batchNumberType = 1;
+        this.form.computeType = 1;
+      } else {
+        console.log(res);
+      }
+    },
+    // 表格点击获取数据
+    async cellClick(row, column, cell, event) {
+      console.log(row);
+      let { productId } = row;
+      try {
+        let payLoad = {
+          productId,
+        };
+        let res = await getProductInventory(payLoad);
+        if (res.code == 200) {
+          this.form.inventoryBoxNum = res.data.inventoryBoxNum;
+        } else {
+          console.log(res);
+        }
+      } catch (error) {
+        console.log(error);
+      }
+    },
+
+    // 获取表单数据
+    getAllData() {
+      let res = {};
+      this.$refs.form.validate(async (valid) => {
+        console.log(valid);
+        if (valid) {
+          res = {
+            flag: true,
+            isEdit: this.isEdit,
+            data: {
+              formData: this.form,
+              tableData: this.tableData,
+            },
+          };
+        } else {
+          res = {
+            flag: false,
+          };
+        }
+      });
+      return res;
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.form-wrap {
+  width: 100%;
+  .title {
+    display: flex;
+    justify-content: center;
+    font-size: 20px;
+    font-weight: 700;
+  }
+}
+</style>

+ 1 - 1
zkqy-ui/src/views/orderMange/index.vue

@@ -1817,7 +1817,7 @@ export default {
 
           await this.getDropDownData();
           this.productionTableData = sale_products.map((item) => {
-            item.productType = this.productionOptions.find(
+            item.productType = this.allProductionOptions.find(
               (i) => item.productNo == i.productNo
             )?.productType;
             return item;

+ 412 - 184
zkqy-ui/src/views/orderMange/retailMange/index.vue

@@ -142,6 +142,12 @@
         <el-table-column prop="deliveryDate" label="交货日期" />
         <el-table-column prop="saleLeadTime" label="交货天数" />
         <el-table-column prop="saleAmountInWords" label="合计金额(大写)" />
+        <el-table-column prop="status" label="状态">
+          <template slot-scope="scope">{{
+            getDictLabel(scope.row.status, "sales_order_status")
+          }}</template>
+        </el-table-column>
+
         <el-table-column prop="salesman" label="销售员" />
         <el-table-column prop="remark" label="备注" />
         <el-table-column label="操作">
@@ -160,6 +166,24 @@
                     >修改
                   </el-button>
                 </el-dropdown-item>
+                <el-dropdown-item>
+                  <el-button
+                    size="mini"
+                    type="text"
+                    icon="el-icon-tickets"
+                    @click="handlePrint(scope.row)"
+                    >详情
+                  </el-button>
+                </el-dropdown-item>
+                <el-dropdown-item>
+                  <el-button
+                    size="mini"
+                    type="text"
+                    icon="el-icon-folder-checked"
+                    @click="handleSubmit(scope.row)"
+                    >提交
+                  </el-button>
+                </el-dropdown-item>
                 <el-dropdown-item>
                   <el-button
                     size="mini"
@@ -243,6 +267,35 @@
                 </el-select>
               </el-form-item>
             </el-col>
+
+            <el-col :span="12">
+              <el-form-item v-if="isLeader" label="业务员:">
+                <el-select
+                  size="small"
+                  v-model="formData.salesman"
+                  placeholder="请选择业务员"
+                  clearable
+                  filterable
+                  @change="salemanChange"
+                >
+                  <el-option
+                    v-for="item in salesmanList"
+                    :key="item.value"
+                    :label="item.label"
+                    :value="item.value"
+                  >
+                  </el-option>
+                </el-select>
+              </el-form-item>
+              <el-form-item v-else label="业务员:">
+                <!-- <el-input
+            v-model="formData.salesman"
+            size="small"
+            clearable
+          ></el-input> -->
+                {{ nickName }}
+              </el-form-item>
+            </el-col>
             <el-col :span="12">
               <el-form-item label="联系人:" size="normal">
                 {{ formData.contactPerson }}
@@ -255,47 +308,54 @@
               </el-form-item>
             </el-col>
             <el-col :span="12">
+              <el-form-item label-width="120px" label="合计金额(大写):">
+                <!-- <el-input
+                  v-model="formData.saleAmountInWords"
+                  size="small"
+                  clearable
+                ></el-input> -->
+                {{ formData.saleAmountInWords }}
+              </el-form-item>
+            </el-col>
+            <!-- <el-col :span="12">
+              <el-form-item label="付款方式:">
+                <el-select
+                  v-model="formData.salePayType"
+                  size="small"
+                  clearable
+                  filterable
+                >
+                  <el-option
+                    v-for="item in dict.type.retail_order_pay_method"
+                    :key="item.value"
+                    :label="item.label"
+                    :value="item.value"
+                  ></el-option>
+                </el-select>
+                零售单
+              </el-form-item>
+            </el-col> -->
+
+            <!-- <el-col :span="12">
               <el-form-item
                 label-width="120px"
                 prop="saleOrderEstimatedTime"
                 label="预计下单时间:"
               >
-                <!-- <el-date-picker
-                  size="small"
-                  v-model="formData.saleOrderEstimatedTime"
-                  value-format="yyyy-MM-dd"
-                  format="yyyy-MM-dd"
-                  type="date"
-                  placeholder="选择日期"
-                >
-                </el-date-picker> -->
                 {{ formData.saleOrderEstimatedTime }}
               </el-form-item>
-            </el-col>
+            </el-col> -->
 
-            <el-col :span="12">
+            <!-- <el-col :span="12">
               <el-form-item label="交货日期:" size="normal" prop="deliveryDate">
-                <!-- <el-date-picker
-                  size="small"
-                  v-model="formData.deliveryDate"
-                  value-format="yyyy-MM-dd"
-                  format="yyyy-MM-dd"
-                  type="date"
-                  placeholder="选择日期"
-                >
-                </el-date-picker> -->
                 {{ formData.deliveryDate }}
               </el-form-item>
-            </el-col>
-            <el-col :span="12">
+            </el-col> -->
+            <!-- <el-col :span="12">
               <el-form-item label="交货天数:" size="normal" prop="saleLeadTime">
-                <!-- <el-input
-                  size="small"
-                  v-model="formData.saleLeadTime"
-                ></el-input> -->
                 {{ formData.saleLeadTime }}
               </el-form-item>
-            </el-col>
+            </el-col> -->
             <el-col :span="24">
               <el-divider>货品明细</el-divider>
             </el-col>
@@ -443,37 +503,7 @@
               @click="addProduct"
               >添加货品</el-button
             >
-            <el-col :span="12">
-              <el-form-item label-width="120px" label="合计金额(大写)">
-                <el-input
-                  v-model="formData.saleAmountInWords"
-                  size="small"
-                  clearable
-                ></el-input>
-              </el-form-item>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item label="付款方式">
-                <!-- <el-input
-                v-model="formData.salePayType"
-                size="small"
-                clearable
-              ></el-input> -->
-                <el-select
-                  v-model="formData.salePayType"
-                  size="small"
-                  clearable
-                  filterable
-                >
-                  <el-option
-                    v-for="item in dict.type.retail_order_pay_method"
-                    :key="item.value"
-                    :label="item.label"
-                    :value="item.value"
-                  ></el-option>
-                </el-select>
-              </el-form-item>
-            </el-col>
+
             <!-- <el-col :span="12" v-show="formData.salePayType == '1'">
               <el-form-item prop="earnestMoney" label="定金">
                 <el-input
@@ -495,41 +525,9 @@
                 clearable
               ></el-input>
             </el-col>
-            <el-col :span="24">
+            <!-- <el-col :span="24">
               <el-divider>审计人员数据</el-divider>
-            </el-col>
-            <el-col :span="12">
-              <el-form-item v-if="isLeader" label="业务员:">
-                <!-- <el-input
-            v-model="formData.salesman"
-            size="small"
-            clearable
-          ></el-input> -->
-                <el-select
-                  v-model="formData.salesman"
-                  placeholder="请选择业务员"
-                  clearable
-                  filterable
-                  @change="salemanChange"
-                >
-                  <el-option
-                    v-for="item in salesmanList"
-                    :key="item.value"
-                    :label="item.label"
-                    :value="item.value"
-                  >
-                  </el-option>
-                </el-select>
-              </el-form-item>
-              <el-form-item v-else label="业务员:">
-                <!-- <el-input
-            v-model="formData.salesman"
-            size="small"
-            clearable
-          ></el-input> -->
-                {{ nickName }}
-              </el-form-item>
-            </el-col>
+            </el-col> -->
           </el-form>
         </el-row>
         <div slot="footer" class="dialog-footer">
@@ -539,7 +537,7 @@
       </el-dialog>
 
       <!-- 自定义弹窗 -->
-      <el-dialog title="提" :visible.sync="deliverShow" width="1200px">
+      <el-dialog title="提" :visible.sync="deliverShow" width="1200px">
         <!-- <DialogTemplate
         ref="dialogRef"
         :groupKey="groupKey"
@@ -550,7 +548,7 @@
         @addList="addListHandler"
       >
       </DialogTemplate> -->
-        <Deliver ref="deliverRef" :currentRow="currentRow"></Deliver>
+        <RetailProvide ref="deliverRef"></RetailProvide>
         <span slot="footer" class="dialog-footer">
           <el-button @click="deliverShow = false">取 消</el-button>
           <el-button type="primary" @click="btnComfirm">确 定</el-button>
@@ -609,6 +607,7 @@ import {
   addRetailOrder,
   getRetailOrderInfo,
   editRetailOrder,
+  retailProductInvoiceInfo,
 } from "@/api/system/retailMange.js";
 import { listData } from "@/api/system/tenant/data";
 import { getToken } from "@/utils/auth";
@@ -626,15 +625,30 @@ import { v4 as uuidv4 } from "uuid";
 import { mapState } from "vuex";
 import moment from "moment";
 import Deliver from "@/views/orderMange/components/dialogForm/Deliver.vue";
+import RetailProvide from "@/views/orderMange/components/dialogForm/RetailProvide.vue";
 import OutBound from "@/views/orderMange/components/dialogForm/OutBound.vue";
 import outBoundPrint from "@/utils/print/outBoundPrint";
 import { listCustomer } from "@/api/system/customer";
+import { numToCapital } from "@/utils/other";
 export default {
   name: "retailMange",
-  dicts: ["payment_method", "direction_of_twist", "retail_order_pay_method"],
-  components: { Queryfrom, Menu, DialogTemplate, Deliver, OutBound },
+  dicts: [
+    "payment_method",
+    "direction_of_twist",
+    "retail_order_pay_method",
+    "sales_order_status",
+  ],
+  components: {
+    Queryfrom,
+    Menu,
+    DialogTemplate,
+    Deliver,
+    OutBound,
+    RetailProvide,
+  },
   data() {
     return {
+      totalMoney: "", //合计金额  小写
       createById: "", //创建者id
       salesmanList: [], //销售员列表
       isLeader: false, //当前登录用户是否为领导
@@ -873,7 +887,20 @@ export default {
     // 得到当前展示的table的唯一标识
     this.tableKey = this.$route.query.tableKey;
   },
-  watch: {},
+  watch: {
+    totalMoney: {
+      handler(newVal, oldVal) {
+        if (isNaN(Number(newVal))) {
+          this.formData.saleAmountInWords = "零";
+        } else {
+          const ntc = new numToCapital();
+          this.formData.saleAmountInWords = ntc.uppercase(newVal);
+        }
+      },
+      deep: true,
+      immediate: true,
+    },
+  },
   async mounted() {
     await this.getDropDownData();
   },
@@ -1041,15 +1068,20 @@ export default {
         ) {
           sums[index] = "";
         } else if (!values.every((value) => isNaN(value))) {
-          sums[index] = values.reduce((prev, curr) => {
-            const value = Number(curr);
-            if (!isNaN(value)) {
-              return prev + curr;
-            } else {
-              return prev;
-            }
-          }, 0);
-          sums[index];
+          sums[index] = values
+            .reduce((prev, curr) => {
+              const value = Number(curr);
+              if (!isNaN(value)) {
+                return prev + curr;
+              } else {
+                return prev;
+              }
+            }, 0)
+            ?.toFixed(2);
+          console.log(sums[index], index);
+          if (index == 4) {
+            this.totalMoney = sums[index];
+          }
         } else {
           sums[index] = "N/A";
         }
@@ -1274,11 +1306,45 @@ export default {
         callback(new Error("校验失败,请稍后再试"));
       }
     },
+    // 校验表格数据
+    validateTableData() {
+      if (this.productionTableData.length == 0) {
+        return {
+          res: false,
+          msg: "请添加货品明细",
+        };
+      }
+      let res = this.productionTableData.every((item) => {
+        return (
+          item.productNo &&
+          item.productNumber &&
+          item.productUnitPrice &&
+          item.productAmounts &&
+          item.sliceType &&
+          item.colourNumber
+        );
+      });
+      if (!res) {
+        return {
+          res: false,
+          msg: "请填写完整货品明细",
+        };
+      }
+      return {
+        res: true,
+        msg: "",
+      };
+    },
     // 审计   提交编辑结果按钮回调
     async editConfirm() {
       this.$refs.formDataRef.validate(async (valid) => {
         if (valid) {
           console.log(valid);
+          let tableValidate = this.validateTableData();
+          if (!tableValidate.res) {
+            this.$message.warning(tableValidate.msg);
+            return;
+          }
           let {
             id,
             //订单表数据
@@ -1316,6 +1382,7 @@ export default {
             contactPerson, //联系人
             remark: orderRemark,
             salesman: this.isLeader ? salesman : this.nickName,
+            status: 1,
           };
           payload.saleProductsList = this.productionTableData;
 
@@ -1637,6 +1704,89 @@ export default {
         return null;
       }
     },
+    // 初始化数据
+    initData(data) {
+      let {
+        id,
+        //订单表数据
+        saleNo,
+        saleCustomNo,
+        saleDate,
+        saleOrderEstimatedTime,
+        saleLeadTime,
+        deliveryDate,
+        saleAmounts,
+        saleAmountInWords,
+        salePayType,
+        salesman,
+        customAddress,
+        customCountryType, //国家类型
+        contactPerson, //联系人
+
+        // 工艺表数据
+        remark,
+
+        // 产品列表
+        saleProductsList,
+      } = data;
+      Object.assign(this.formData, {
+        id,
+        //订单表数据
+        saleNo,
+        saleCustomNo,
+        saleDate,
+        saleOrderEstimatedTime,
+        saleLeadTime,
+        deliveryDate,
+        saleAmounts,
+        saleAmountInWords,
+        salePayType,
+        salesman,
+        customAddress,
+        customCountryType, //国家类型
+        contactPerson, //联系人
+
+        // 工艺表数据
+        orderRemark: remark,
+      });
+      this.customChangeHandler(saleCustomNo);
+      this.productionTableData = saleProductsList.map((item) => {
+        let {
+          id,
+          saleProductNo,
+          productNo, //货品编号
+          productName, //货品名称
+          productNumber, //销售数量
+          productWeight, //销售重量kg
+          productUnitPrice, //单价
+          productAmounts, //金额
+          sliceType, //切片类型  初始为  切片
+          sliceTypeLabel,
+          colourNumberLabel,
+          colourNumber, //色号
+          remark, //备注
+        } = item;
+        let productType = this.allProductionOptions.find(
+          (i) => productNo == i.productNo
+        )?.productType;
+        return {
+          id,
+          saleProductNo,
+          productNo, //货品编号
+          productType, //类型
+          productName, //货品名称
+          productNumber, //销售数量
+          productWeight, //销售重量kg
+          productUnitPrice, //单价
+          productAmounts, //金额
+          sliceType, //切片类型  初始为  切片
+          sliceTypeLabel,
+          colourNumberLabel,
+          colourNumber, //色号
+          remark,
+        };
+      });
+    },
     /** 修改按钮操作 */
     async handleUpdate(row) {
       console.log(row);
@@ -1652,84 +1802,7 @@ export default {
         let res = await getRetailOrderInfo(row.id);
         console.log(res);
         if (res.code == 200) {
-          let {
-            id,
-            //订单表数据
-            saleNo,
-            saleCustomNo,
-            saleDate,
-            saleOrderEstimatedTime,
-            saleLeadTime,
-            deliveryDate,
-            saleAmounts,
-            saleAmountInWords,
-            salePayType,
-            salesman,
-            customAddress,
-            customCountryType, //国家类型
-            contactPerson, //联系人
-
-            // 工艺表数据
-            remark,
-
-            // 产品列表
-            saleProductsList,
-          } = res.data;
-          Object.assign(this.formData, {
-            id,
-            //订单表数据
-            saleNo,
-            saleCustomNo,
-            saleDate,
-            saleOrderEstimatedTime,
-            saleLeadTime,
-            deliveryDate,
-            saleAmounts,
-            saleAmountInWords,
-            salePayType,
-            salesman,
-            customAddress,
-            customCountryType, //国家类型
-            contactPerson, //联系人
-
-            // 工艺表数据
-            orderRemark: remark,
-          });
-          this.customChangeHandler(saleCustomNo);
-          this.productionTableData = saleProductsList.map((item) => {
-            let {
-              id,
-              saleProductNo,
-              productNo, //货品编号
-              productType, //类型
-              productName, //货品名称
-              productNumber, //销售数量
-              productWeight, //销售重量kg
-              productUnitPrice, //单价
-              productAmounts, //金额
-              sliceType, //切片类型  初始为  切片
-              sliceTypeLabel,
-              colourNumberLabel,
-              colourNumber, //色号
-              remark, //备注
-            } = item;
-            return {
-              id,
-              saleProductNo,
-              productNo, //货品编号
-              productType, //类型
-              productName, //货品名称
-              productNumber, //销售数量
-              productWeight, //销售重量kg
-              productUnitPrice, //单价
-              productAmounts, //金额
-              sliceType, //切片类型  初始为  切片
-              sliceTypeLabel,
-              colourNumberLabel,
-              colourNumber, //色号
-              remark,
-            };
-          });
+          this.initData(res.data);
           this.open = true;
         } else {
           this.$message.error(res.msg);
@@ -1738,6 +1811,161 @@ export default {
         console.log(error);
       }
     },
+    //详情  打印回调
+    async handlePrint(row) {
+      await this.getDropDownData();
+      this.isLeader = !this.userInfo.roles.includes("salesman");
+      if (!this.isLeader) {
+        this.createById = this.userInfo.userId;
+      }
+      await this.getRoleUser();
+      try {
+        let res = await getRetailOrderInfo(row.id);
+        console.log(res);
+        if (res.code == 200) {
+          this.initData(res.data);
+          this.printDomData = this.getPrintDom(res.data);
+          this.detailShow = true;
+          this.$nextTick(() => {
+            this.$refs.detailTable.innerHTML = this.printDomData;
+          });
+        } else {
+          this.$message.error(res.msg);
+        }
+      } catch (error) {
+        console.log(error);
+      }
+    },
+    // 提交  回调
+    async handleSubmit(row) {
+      this.deliverShow = true;
+      this.$nextTick(() => {
+        this.$refs.deliverRef.productInvoiceInfo(row);
+      });
+    },
+    // 获取打印dom
+    getPrintDom(data) {
+      let {
+        id,
+        //订单表数据
+        saleNo,
+        saleCustomNo,
+        saleDate,
+        saleOrderEstimatedTime,
+        saleLeadTime,
+        deliveryDate,
+        saleAmounts,
+        saleAmountInWords,
+        salePayType,
+        salesman,
+        customAddress,
+        customCountryType, //国家类型
+        contactPerson, //联系人
+
+        // 工艺表数据
+        orderRemark,
+      } = this.formData;
+      this.productionTableData;
+      let customData = this.customerOptions.find(
+        (item) => item.customNo == saleCustomNo
+      );
+      let customerName = customData ? customData.customName : "";
+      let printStr = `
+        <table style="width:1200px; border-collapse:collapse;" border="1" cellpadding="10" align="center">
+            <div style="text-align:center;font-size: 20px;">诸暨市新丝维纤维有限公司</div>
+            <div style="text-align:center;">销售合同审计单</div>
+            <tbody>
+                <tr>
+                    <td width="600px" colspan="4">合同号:${saleNo}</td>
+                    <td width="600px" colspan="4">日期:${saleDate.replace(
+                      "T",
+                      " "
+                    )}</td>
+                </tr>
+                <tr align="center">
+                    <td width="300px" colspan="2">客户名称:</td>
+                    <td width="300px" colspan="2">${customerName}</td>
+                    <td colspan="2">业务员:</td>
+                    <td colspan="2">${salesman}</td>
+
+                </tr>
+                <tr align="center">
+                    <td width="300px" colspan="2">客户地址:</td>
+                    <td width="300px" colspan="2">${customAddress}</td>
+                    <td width="300px" colspan="2">客户国别:</td>
+                    <td width="300px" colspan="2">${customCountryType}</td>
+                </tr>
+                <tr align="center">
+                    <td width="300px" colspan="2">联系人:</td>
+                    <td width="150px" colspan="1">${contactPerson}</td>
+                    <td  colspan="2">合计金额(大写):</td>
+                    <td colspan="3">${saleAmountInWords}</td>
+                </tr>
+                <tr align="center">
+                    <td colspan="8">货品明细</td>
+                </tr>
+                <tr align="center">
+                    <td width="150px">品名</td>
+                    <td width="150px">类型</td>
+                    <td width="150px">箱数</td>
+                    <td width="150px">单价</td>
+                    <td width="150px">金额</td>
+                    <td width="150px">切片型号</td>
+                    <td width="150px">色号</td>
+                    <td width="150px">备注</td>
+                </tr>`;
+      let amountTotal = 0,
+        singlTotal = 0,
+        moneyTotal = 0;
+      for (let i = 0; i < this.productionTableData.length; i++) {
+        let item = this.productionTableData[i];
+        amountTotal += Number(item.productNumber);
+        singlTotal += Number(item.productUnitPrice);
+        moneyTotal += Number(item.productAmounts);
+        let productData = this.productionOptions.find(
+          (pro) => pro.productNo == item.productNo
+        );
+        item.sliceTypeLabel =
+          this.sliceTypeOptions.find((k) => k.materielCode == item.sliceType)
+            ?.materielName || "";
+        item.colourNumberLabel = this.colourNumberOptions.find(
+          (k) => k.materielCode == item.colourNumber
+        )?.materieColorNumber;
+        let productName = productData ? productData.productName : "";
+        let productType = productData ? productData.productType : "";
+        printStr += `<tr align="center">
+                    <td>${productName}</td>
+                    <td>${productType}</td>
+                    <td>${item.productNumber}</td>
+                    <td>${item.productUnitPrice}</td>
+                    <td>${item.productAmounts}</td>
+                    <td>${item.sliceTypeLabel}</td>
+                    <td>${item.colourNumberLabel}</td>
+                    <td>${item.remark}</td>
+                </tr>`;
+      }
+      // 计算小计
+      amountTotal = amountTotal.toFixed(2);
+      singlTotal = singlTotal.toFixed(2);
+      moneyTotal = moneyTotal.toFixed(2);
+      printStr += `
+        <tr align="center">
+          <td>小计:</td>
+           <td></td>
+          <td>${amountTotal}</td>
+          <td>${singlTotal}</td>
+          <td>${moneyTotal}</td>
+          <td></td>
+          <td></td>
+          <td></td>
+        </tr>`;
+      printStr += `<tr align="left">
+                    <td colspan="8">订单备注:${orderRemark}</td>
+                </tr>
+                </tbody>
+        </table>`;
+      return printStr;
+    },
     // 添加真正的字段名
     addRealFieldName(row) {
       let fieldList = Object.keys(row);