zouyu
2025-11-12 1bef995d9a6cc817bea0318a2a33ea013fe69deb
src/views/business/productOrder/components/addOrder.vue
@@ -14,9 +14,13 @@
          <el-select v-show="active==1" v-model="template" placeholder="下单模板" size="small"
                     @change="selectInsOrderTemplateById">
            <el-option v-for="(a, ai) in templates" :key="ai" :label="a.name" :value="a.id">
              <span style="float: left">{{ a.name }}</span>
              <i class="el-icon-delete" style="float: right; color: #66b1ff; font-size: 16px"
                 @click.stop="handleDelete(a)"></i>
              <div style="display: flex; align-items: center; justify-content: space-between;">
                <span>{{ a.name }}</span>
                <i class="el-icon-delete"
                   style="color: #66b1ff; font-size: 16px; cursor: pointer;"
                   @click.stop="handleDelete(a)">
                </i>
              </div>
            </el-option>
          </el-select>
          <el-button v-show="active==1" size="small" @click="templateDia=true">
@@ -587,7 +591,7 @@
} from "@/api/business/rawMaterialOrder";
import {
  addInsOrder, addInsOrderTemplate, delInsOrderTemplate,
  getQuarterOnOrder, selectInsOrderTemplateById,
  getQuarterOnOrder, judgeNotSpotCheckOrder, selectInsOrderTemplateById,
  selectOrderManDay,
  updateInsOrder,
  upInsOrder,
@@ -597,7 +601,9 @@
import {selectsStandardMethodByFLSSM} from "@/api/standard/standardLibrary";
import limsTable from "@/components/Table/lims-table.vue";
import {selectCustomPageList} from "@/api/system/customer";
import { bigEval } from "@/utils/bigEval";
import {mapGetters} from "vuex";
import {addQuarter, updateQuarterOnOrder} from "@/api/business/finishedProductSampling";
export default {
  name: 'AddOrder',
@@ -793,10 +799,10 @@
    }
  },
  watch: {
    sampleList() {
      this.addObj.method = null
      this.productList = []
    },
    // sampleList() {
    //   this.addObj.method = null
    //   this.productList = []
    // },
    productList: {
      deep: true,
      handler(val) {
@@ -1028,6 +1034,37 @@
          return symbolItem
        }
      },
    /**
     * 获取小数的最大位数
     * @param number  型号参数
     * @param ask     要求值
     * @param calcNum 计算值
     */
    getDecimalPlaces(number, ask, calcNum) {
      console.log("计算小数点-->", number, ask, calcNum);
      let count1 = 0;
      let count2 = 0;
      const reg = /(\d+\.)(\d+)/g;
      let matches = [];
      if (ask) {
        matches = ask.match(reg);
      }
      if (
        matches &&
        matches.length > 0 &&
        matches[0].toString().indexOf(".") > -1
      ) {
        count1 = matches[0].toString().split(".")[1].length;
      }
      if (number.toString().indexOf(".") > -1) {
        count2 = number.toString().split(".")[1].length;
      }
      if (calcNum.toString().indexOf(".") > -1) {
        const pointLength2 = calcNum.toString().split(".")[1].length;
        count2 = count2 > pointLength2 ? count2 : pointLength2;
      }
      return count1 > count2 ? count1 : count2;
    },
      handleAsk(ask,symbolItem, value) {
        try{
          let code = [">", "<", "=", ">", "<", "≥", "≤", "±"];
@@ -1040,7 +1077,13 @@
              let index = code.findIndex(b => m.includes(b))
              if (index > -1) {
                let arr = m.split(code[index]).filter(b => !!b)
                let num = eval(this.replaceAll(arr[0], symbolItem, value))
                let calcNum = this.$Big(
                  bigEval(this.replaceAll(arr[0], symbolItem, value))
                );
                let num = calcNum.toFixed(
                  this.getDecimalPlaces(value, ask, calcNum)
                );
                // let num = eval(this.replaceAll(arr[0], symbolItem, value))
                m = code[index] + '' + num
                arr1.push(m)
              }
@@ -1069,7 +1112,13 @@
            let index = code.findIndex(b => ask.includes(b))
            if (index > -1) {
              let arr = ask.split(code[index]).filter(b => !!b)
              let num = eval(this.replaceAll(arr[0], symbolItem, value))
              let calcNum = this.$Big(
                bigEval(this.replaceAll(arr[0], symbolItem, value))
              );
              let num = calcNum.toFixed(
                this.getDecimalPlaces(value, ask, calcNum)
              );
              // let num = eval(this.replaceAll(arr[0], symbolItem, value))
              return code[index] + '' + num
            }
          }
@@ -1255,36 +1304,62 @@
        }
      },
      saveMethod(sampleList){
        this.saveLoad = true
        if (this.addObj.quarterItemId) {
          this.addObj.quarterItemId = this.addObj.quarterItemId[1]
        }
        if(this.tabIndex==4&&this.active==2){
          if (this.addObj.createTime) {
            delete this.addObj.createTime
          }
          // 退回后提交
          updateInsOrder({insOrder: this.addObj, sampleProduct: sampleList}).then(res => {
            this.saveLoad = false
            this.$message.success('已提交')
            this.bsm3Dia = false;
            this.closeOpenPage()
          }).catch(e=>{
            this.saveLoad = false
          })
        }else{
          // 常规提交
          addInsOrder({insOrder: this.addObj, sampleList: sampleList}).then(res => {
            this.saveLoad = false
            this.$message.success('已提交')
            this.bsm3Dia = false;
            this.closeOpenPage()
          }).catch(e=>{
            this.saveLoad = false
          })
        if (this.addObj.createTime) {
          delete this.addObj.createTime
        }
        if (this.addObj.orderType === '抽检') {
          judgeNotSpotCheckOrder({ insOrder: this.addObj, sampleList: sampleList }).then(res => {
            if (res.data === true) {
              this.saveData(sampleList);
            } else {
              // const message = res.message.replace(/\n/g, '<br>');
              this.$confirm(res.message, '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                dangerouslyUseHTMLString: true, // 👈 关键点:允许 HTML
                message: res.message // 这里也可以省略,因为第二个参数是 title,第三个是 options
              }).then(() => {
                this.saveData(sampleList);
              }).catch(() => {
                this.$message({
                  type: 'info',
                  message: '已取消'
                });
              });
            }
          });
        } else {
          this.saveData(sampleList)
        }
      },
    saveData(sampleList) {
      this.saveLoad = true
      if(this.tabIndex==4&&this.active==2){
        // 退回后提交
        updateInsOrder({insOrder: this.addObj, sampleProduct: sampleList}).then(res => {
          this.saveLoad = false
          this.$message.success('已提交')
          this.bsm3Dia = false;
          this.closeOpenPage()
        }).catch(e=>{
          this.saveLoad = false
        })
      }else{
        // 常规提交
        addInsOrder({insOrder: {...this.addObj,typeSource:-1}, sampleList: sampleList}).then(res => {
          this.saveLoad = false
          this.$message.success('已提交')
          this.bsm3Dia = false;
          this.closeOpenPage()
        }).catch(e=>{
          this.saveLoad = false
        })
      }
    },
      upInsOrderOfState(state) {
        if (state == 1) {
          this.saveLoad = true
@@ -1355,8 +1430,8 @@
          this.addObj.code = selects.code
          this.addObj.phone = selects.phone
          this.addObj.companyId = selects.departId
          this.addObj.production = '中天科技装备电缆有限公司'
          this.addObj.productionEn = 'Zhongtian Technology Industrial Wire&Cable System CO.,LTD'
          this.addObj.production = '中天耐丝有限公司'
          this.addObj.productionEn = 'Zhongtian Naisi Co., Ltd.'
          if(this.active==1){
            this.selectInsOrderTemplate()
          }