haoxuan
2024-04-16 d3642faa7f79bc1e8992e528ad102587a2c44499
src/views/productManage/silkRegisterForm/addPage.vue
@@ -54,6 +54,7 @@
              <el-date-picker
                v-model="form.finishDate"
                value-format="yyyy-MM-dd"
                :picker-options="pickerOptions"
                type="date"
                placeholder="选择日期"
                class="select-width"
@@ -65,6 +66,7 @@
                v-model="form.market"
                placeholder="请选择"
                class="select-width"
                @change="getGroupNumber"
              >
                <el-option
                  v-for="item in marketList"
@@ -80,7 +82,7 @@
                v-model="form.name"
                placeholder="请选择"
                class="select-width"
                @change="getGroupNumber"
                @change="getGroupNumber('name')"
              >
                <el-option
                  v-for="item in nameList"
@@ -114,6 +116,7 @@
                placeholder="请先选择车间"
                no-data-text="请先选择车间"
                class="select-width"
                @change="getGroupNumber()"
              >
                <el-option
                  v-for="item in workshopGroupList"
@@ -208,7 +211,7 @@
            >保存</el-button
          >
          <!-- </template>
</CommonSearch> -->
          </CommonSearch> -->
        </div>
      </div>
      <div class="body-two body">
@@ -424,11 +427,12 @@
</template>
<script>
// getWorkshopManageList,
// getWorkshopManageList
import {
  saveRegister,
  getDictList,
  getRegisterDetails,
  getCarNumber
} from "@/api/productManage/silkRegisterForm.js";
import {
  getCheckDetails,
@@ -464,6 +468,10 @@
        finishDate: [
          { required: true, message: "请选择", trigger: ["change", "blur"] },
        ],
        // 庄口
        market: [
          { required: true, message: "请选择", trigger: ["change", "blur"] },
        ],
        // 车间 应该true
        name: [
          { required: true, message: "请选择", trigger: ["change", "blur"] },
@@ -487,6 +495,11 @@
        position: [
          { required: true, message: "请填写", trigger: ["change", "blur"] },
        ],
      },
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < new Date().getTime() - 86400000;
        },
      },
      tableTwoList: {
        tableInfomation: [],
@@ -540,12 +553,18 @@
          {
            label: "纤度合计",
            prop: "sum",
            inputNumber: true,
            isRequird: true,
          }, // 下次回访日期
        ],
      },
      tableData: [],
      tableData: [
        {
            productId: 1,
            position: null,
            fineness: null,
            quantity: null,
            sum: null,
          }
        ],
      registerId: "",
      inspectID: "",
      isRegisterSave: false,
@@ -563,7 +582,7 @@
    this.getDetailsData();
  },
  methods: {
    getDetailsData(id) {
    async getDetailsData(id) {
      if (this.activeName == "first") {
        this.form = {
          number: "",
@@ -578,7 +597,7 @@
          position: "",
        };
        if (this.registerId) {
          getRegisterDetails({ id: id ? id : this.registerId }).then(
         await getRegisterDetails({ id: id ? id : this.registerId }).then(
            (response) => {
              if (response.code === 200) {
                let config = JSON.parse(
@@ -586,9 +605,15 @@
                );
                this.form = config;
                this.getGroupNumber()
                this.tableList.tableData = config.finenessList
                let finenessList=config.finenessList
                  ? config.finenessList
                  : [];
                if(finenessList.length>0){
                  finenessList.map((item,index)=>{
                    item.productId=index+1
                  })
                }
                this.tableList.tableData = finenessList
                this.tableData = this.tableList.tableData;
              }
            }
@@ -735,7 +760,7 @@
        }
      });
    },
    getGroupNumber() {
    async getGroupNumber(val) {
      if (this.form.name) {
        //组别
        let number = "";
@@ -745,17 +770,41 @@
            break;
          }
        }
        getWorkshopManageGroup({ number: number }).then((res) => {
        await getWorkshopManageGroup({ number: number }).then((res) => {
          if (res.code == 200) {
            this.workshopGroupList = [];
            let workshopGroupList = res.data || {};
            this.workshopGroupList=[]
            if(val=='name'){
              this.form.workshopGroup=''
            }
            if (Object.keys(workshopGroupList).length > 0) {
              for (let i in workshopGroupList) {
                this.workshopGroupList.push(workshopGroupList[i]);
              }
            }
          }
        });
        })
        if(this.form.workshopGroup&&this.form.market){
            getCarNumber({
              workshopName:this.form.name,
              marketName:this.form.market,
              groupNumber:this.form.workshopGroup,
            }).then((res) => {
              if (res.code == 200) {
                this.tableData=[]
                let data = res.data?JSON.parse(JSON.stringify(res.data)) : [];
               if(Object.keys(data).length>0){
                for(let i in data){
                    this.tableData.push({position:data[i],productId:Number(i)+1})
                }
               }
               this.tableList.tableData = this.tableData
              }else{
                this.tableData=[]
              }
            });
          }
      } else {
        this.workshopGroupList = [];
      }
@@ -783,7 +832,11 @@
        if (item.productId === row.productId) {
          item[prop] = val;
        }
        if(item.fineness&&item.quantity){
          item.sum=Number(item.fineness)*Number(item.quantity).toFixed(2)
        }
      });
      this.tableList.tableData= this.tableData
    },
    tabsClick() {
      // if (tab.name === "first") {
@@ -835,6 +888,7 @@
            sum: "",
          },
        ];
        this.tableData =this.tableList.tableData
      } else {
        this.form.measureFineness = "";
        this.form.twiceChange = "";
@@ -850,15 +904,26 @@
        if (valid) {
          let form = JSON.parse(JSON.stringify(this.form));
          // params.workshopGroup=Number(params.workshopGroup)
          this.isAddloading = true;
          if (this.activeName == "first") {
            delete form.circleTwo;
            let finenessList = JSON.parse(
              JSON.stringify(this.tableList.tableData)
            );
            let isContinue=false
            for (let i in finenessList) {
              if(!finenessList[i].position||!finenessList[i].fineness||!finenessList[i].quantity||!finenessList[i].sum){
                isContinue=true
                break;
              }
            }
            if(isContinue){
              this.$message.error('请填写完整再保存!')
              return true;
            }
            for (let i in finenessList) {
              delete finenessList[i].productId;
            }
            this.isAddloading = true;
            let params = {
              finenessList: finenessList,
              ...form,
@@ -867,6 +932,7 @@
            if (this.inspectID) {
              params.ID = this.form.ID ? this.form.ID : Number(this.inspectID);
            }
            saveRegister(params)
              .then((res) => {
                if (res.code == 200) {
@@ -896,6 +962,7 @@
                ? this.form.ID
                : Number(this.registerId);
            }
            this.isAddloading = true;
            saveCheck(paramsTwo)
              .then((res) => {
                if (res.code == 200) {