Forráskód Böngészése

1.修改入库单合计成本的合计 ---cjh

17767204043 3 éve
szülő
commit
bc1e759ef7

+ 296 - 123
src/views/BasicSettings/PartSettings/detail.vue

@@ -5,28 +5,28 @@
         type == 1 ? '复制' : type == 2 ? '编辑' : type == 3 ? '查看' : '新增'
       "
     >
-      <Button type="primary" style="margin-right:5px" ghost @click="back()"
+      <Button type="primary" style="margin-right: 5px" ghost @click="back()"
         >取消</Button
       >
       <Button type="primary" v-show="type != 3" @click="handleSaveData"
         >保存</Button
       >
     </Toptitle>
-    <div style="height:90%">
-      <Row type="flex" justify="space-between" style="padding:10px 0">
+    <div style="height: 90%">
+      <Row type="flex" justify="space-between" style="padding: 10px 0">
         <Col span="4">
           <span>ID:</span>
           <span>
             <Input
               type="text"
               disabled
-              style="width:80px"
+              style="width: 80px"
               v-model="formData.id"
               placeholder="自动生成"
             />
           </span>
         </Col>
-        <Col span="12" style="display:flex;align-items: center;">
+        <Col span="12" style="display: flex; align-items: center">
           <span>工艺属性分类:</span>
           <span>
             <Select
@@ -34,7 +34,7 @@
               filter-by-label
               clearable
               v-model="formData.process_id"
-              style="width: 100px;margin-right:5px"
+              style="width: 100px; margin-right: 5px"
               @on-change="(e) => handleProcessSelected(e, 1)"
             >
               <Option
@@ -52,7 +52,7 @@
               clearable
               @on-change="(e) => handleGetProcessIds(formData.process_id, e, 1)"
               v-model="formData.type_title"
-              style="width: 100px;margin-right:5px"
+              style="width: 100px; margin-right: 5px"
             >
               <Option
                 v-for="(item, index) in type_title_list"
@@ -84,7 +84,7 @@
               filterable
               v-model="formData.process_ids"
               @change="changeProvinceSelect"
-              style="width: 300px;height:32px"
+              style="width: 300px; height: 32px"
               @remove-tag="removeProvinceTag"
             >
               <el-option
@@ -128,7 +128,7 @@
         type="flex"
         align="bottom"
         justify="space-between"
-        style="padding-bottom:5px"
+        style="padding-bottom: 5px"
       >
         <Col><span>规则:</span> </Col>
         <Col>
@@ -140,24 +140,23 @@
           >
         </Col>
       </Row>
-      <div style="height:85%;overflow:auto">
+      <div style="height: 85%; overflow: auto">
         <Table
+          v-if="false"
           :columns="tableColumns"
           border
           :max-height="600"
           :data="tableData"
-          :loading='loading'
+          :loading="loading"
         >
-         <template slot="partDetailProduct" slot-scope="{ index }">
+          <template slot="partDetailProduct" slot-scope="{ index }">
             <Select
               v-model="tableData[index].product_id"
               transfer
               filterable
               clearable
-              @on-change="
-                (e) => handleProduct(tableData[index], index, e)
-              "
-             placeholder="全部"
+              @on-change="(e) => handleProduct(tableData[index], index, e)"
+              placeholder="全部"
             >
               <Option
                 v-for="item in product"
@@ -172,7 +171,7 @@
               v-model="tableData[index].parts_detail_id"
               transfer
               @on-change="
-                (e) => handlePartDetailSelected(tableData[index], index, e,1)
+                (e) => handlePartDetailSelected(tableData[index], index, e, 1)
               "
             >
               <Option
@@ -196,21 +195,21 @@
           <template slot="numSlot" slot-scope="{ index }">
             <Input
               type="text"
-              style="width:80px"
+              style="width: 80px"
               v-model.lazy="tableData[index].num"
             />
           </template>
           <template slot="minSlot" slot-scope="{ index }">
             <Input
               type="text"
-              style="width:80px"
+              style="width: 80px"
               v-model="tableData[index].min"
             />
           </template>
           <template slot="maxSlot" slot-scope="{ index }">
             <Input
               type="text"
-              style="width:80px"
+              style="width: 80px"
               v-model="tableData[index].max"
             />
           </template>
@@ -227,18 +226,178 @@
           <template slot="setSlot" slot-scope="{ index }">
             <div>
               <a
-                style="margin:0 5px;"
+                style="margin: 0 5px"
                 @click="handleSet(tableData[index], index, 2)"
                 >复制</a
               >
               <a
-                style="margin:0 5px;"
+                style="margin: 0 5px"
                 @click="handleSet(tableData[index], index, 3)"
                 >删除</a
               >
             </div>
           </template>
         </Table>
+        <u-table
+          :data="tableData"
+          :height="height"
+          use-virtual
+          :data-changes-scroll-top="false"
+          :row-height="rowHeight"
+          big-data-checkbox
+          border
+        >
+          <u-table-column label="关联产品" prop="product_id" minWidth="120" align="center">
+            <template v-slot="scope">
+              <Select
+                v-model="tableData[scope.$index].product_id"
+                transfer
+                filterable
+                clearable
+                @on-change="
+                  (e) => handleProduct(tableData[scope.$index], scope.$index, e)
+                "
+                placeholder="全部"
+              >
+                <Option
+                  v-for="item in product"
+                  :key="item.id"
+                  :label="item.title"
+                  :value="item.id"
+                ></Option>
+              </Select>
+            </template>
+          </u-table-column>
+          <u-table-column
+            prop="parts_detail_id"
+            label="零部件名称"
+            minWidth="140"
+            align="center"
+          >
+            <template v-slot="scope">
+              <Select
+                v-model="tableData[scope.$index].parts_detail_id"
+                transfer
+                @on-change="
+                  (e) =>
+                    handlePartDetailSelected(
+                      tableData[scope.$index],
+                      scope.$index,
+                      e,
+                      1
+                    )
+                "
+              >
+                <Option
+                  v-for="(item, index) in tableData[scope.$index]
+                    .part_detail_list"
+                  :key="index"
+                  :label="item.spare_parts"
+                  :value="item.id"
+                ></Option>
+              </Select>
+            </template>
+          </u-table-column>
+          <u-table-column
+            prop="parts_detail_title"
+            align="center"
+            label="物料名称"
+            minWidth="100"
+          >
+          </u-table-column>
+          <u-table-column label="测量字段" prop="basics_measure_id" minWidth="100" align="center">
+            <template v-slot="scope">
+              <Select
+                v-model="tableData[scope.$index].basics_measure_id"
+                transfer
+              >
+                <Option
+                  v-for="(item, index) in measure_list"
+                  :key="index"
+                  :label="item.title"
+                  :value="item.id"
+                ></Option>
+              </Select>
+            </template>
+          </u-table-column>
+          <u-table-column prop="num"  label="数量" minWidth="120" align="center">
+            <template v-slot="scope">
+              <Input
+                type="text"
+                style="width: 80px"
+                v-model.lazy="tableData[scope.$index].num"
+              />
+            </template>
+          </u-table-column>
+          <!-- <u-table-column label="最小数值(含)" minWidth="120" align="center" prop="product_id">
+            <template v-slot="scope">
+              <Input
+                type="text"
+                style="width: 80px"
+                v-model.lazy="tableData[scope.$index].num"
+              />
+            </template>
+          </u-table-column> -->
+          <u-table-column label="最小数值(含)" minWidth="120" align="center"  prop="min">
+            <template v-slot="scope">
+              <Input
+                type="text"
+                style="width: 80px"
+                v-model="tableData[scope.$index].min"
+              />
+            </template>
+          </u-table-column>
+          <u-table-column label="最大数值" minWidth="120" align="center"  prop="max">
+            <template v-slot="scope">
+              <Input
+                type="text"
+                style="width: 80px"
+                v-model="tableData[scope.$index].max"
+              />
+            </template>
+          </u-table-column>
+          <u-table-column
+            prop="material_detail_id"
+            label="物料规格"
+            minWidth="100"
+            align="center"
+          >
+            <template v-slot="scope">
+              <Select
+                v-model="tableData[scope.$index].material_detail_id"
+                transfer
+              >
+                <Option
+                  v-for="(item, index) in material"
+                  :key="index"
+                  :label="item.materialDetailShow"
+                  :value="item.id"
+                ></Option>
+              </Select>
+            </template>
+          </u-table-column>
+          <u-table-column
+            prop=""
+            label="操作"
+            minWidth="120"
+            align="center"
+          >
+            <template slot-scope="{ row }">
+              <div>
+                <a
+                  style="margin: 0 5px"
+                  @click="handleSet(tableData[row.$index], row.$index, 2)"
+                  >复制</a
+                >
+                <a
+                  style="margin: 0 5px"
+                  @click="handleSet(tableData[row.$index], row.$index, 3)"
+                  >删除</a
+                >
+              </div>
+            </template>
+          </u-table-column>
+        </u-table>
       </div>
     </div>
   </div>
@@ -256,8 +415,10 @@ export default {
   data() {
     // 这里存放数据
     return {
-      loading:true,
-      state:false,
+      height: 0,
+      rowHeight: 55,
+      loading: true,
+      state: false,
       type: this.$route.query.type,
       id: this.$route.query.id,
       formData: {
@@ -322,8 +483,8 @@ export default {
       type_title_list: [],
       process_list: [],
       measure_list: [],
-      product:[],
-      material:[]
+      product: [],
+      material: [],
     };
   },
   // 生命周期 - 创建完成(可以访问当前this实例)
@@ -337,9 +498,9 @@ export default {
       this.parts_list = res.data.data;
     });
     //表格中关联产品下拉表
-    this.axios.get('/api/product').then(res=>{
+    this.axios.get("/api/product").then((res) => {
       this.product = res.data.data;
-    })
+    });
     //表格中测量字段下拉表
     this.axios.get("/api/basics_measure_index").then((res) => {
       this.measure_list = res.data.data;
@@ -350,42 +511,43 @@ export default {
   },
   // 生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {
+    this.height = 500;
     this.id && this.initData(this.id); //id是这张单子的id
-    if(this.$route.query.type == 5){
+    if (this.$route.query.type == 5) {
       this.loading = false;
     }
   },
   methods: {
-    handleProduct(row, index, id){ //id是产品的product_id
+    handleProduct(row, index, id) {
+      //id是产品的product_id
       let list = [];
       let ids = [];
-       this.part_detail_list.forEach(v=>{
-          ids.push(v.product_id)
-       })
-    if(ids.indexOf(id)>=0){
-     this.part_detail_list.forEach(v=>{
-       if(v.product_id == id){
-          list.push(v)
-       }
-     });
-      row.part_detail_list = list;
-      console.log(row);
-     }
-     if(ids.indexOf(id)<0){
-      // row.part_detail_list = JSON.parse(JSON.stringify(this.part_detail_list));
-      this.part_detail_list.forEach(v=>{
-        if(v.product_id == 0){
-          list.push(v)
-        }
-      })
-      row.part_detail_list = list;
-      
-     }
-    row.change_state = true;
-     row.parts_detail_id = 0;
-    
-     console.log(this.tableData[index]);
-       this.handlePartDetailSelected(row, index, row.parts_detail_id);
+      this.part_detail_list.forEach((v) => {
+        ids.push(v.product_id);
+      });
+      if (ids.indexOf(id) >= 0) {
+        this.part_detail_list.forEach((v) => {
+          if (v.product_id == id) {
+            list.push(v);
+          }
+        });
+        row.part_detail_list = list;
+        console.log(row);
+      }
+      if (ids.indexOf(id) < 0) {
+        // row.part_detail_list = JSON.parse(JSON.stringify(this.part_detail_list));
+        this.part_detail_list.forEach((v) => {
+          if (v.product_id == 0) {
+            list.push(v);
+          }
+        });
+        row.part_detail_list = list;
+      }
+      row.change_state = true;
+      row.parts_detail_id = 0;
+
+      console.log(this.tableData[index]);
+      this.handlePartDetailSelected(row, index, row.parts_detail_id);
     },
     back() {
       this.$router.go(-1);
@@ -422,12 +584,12 @@ export default {
       if (!this.formData.part_id) {
         return this.$Message.warning("请先选择部件");
       }
-      let list =[];
-      this.part_detail_list.forEach(v=>{
-            if(v.product_id==0){
-              list.push(v)
-            }
-      })
+      let list = [];
+      this.part_detail_list.forEach((v) => {
+        if (v.product_id == 0) {
+          list.push(v);
+        }
+      });
       row.part_detail_list = JSON.parse(JSON.stringify(list));
       row.part_id = this.formData.part_id;
       const obj = JSON.parse(JSON.stringify(row));
@@ -448,13 +610,15 @@ export default {
           this.formData = res.data.detail;
           this.formData.process_id = this.formData.bp_id;
           this.tableData = res.data.list;
-          res.data.material_list.forEach(v=>{
+          res.data.material_list.forEach((v) => {
             v.id = v.material_detail_id;
-            v.materialDetailShow= v.long + "*" + v.width
+            v.materialDetailShow = v.long + "*" + v.width;
           });
           this.material = res.data.material_list;
-          console.log(this.material)
-          this.tableData.map(v=>{v.change_state=false})
+          console.log(this.material);
+          this.tableData.map((v) => {
+            v.change_state = false;
+          });
           //工艺属性分类赋值第一个
           this.handleProcessSelected(res.data.detail.process_id);
           //工艺属性分类赋值第二个
@@ -489,74 +653,83 @@ export default {
           }
         });
     },
-    handlePartSelected(id, type) { //id搜索条件中的部件名称part_id
+    handlePartSelected(id, type) {
+      //id搜索条件中的部件名称part_id
 
       id &&
-        this.axios.get("/api/parts_detail", { params: { id } }).then((res) => {//获取产品名称part_id中所有零部件名称
+        this.axios.get("/api/parts_detail", { params: { id } }).then((res) => {
+          //获取产品名称part_id中所有零部件名称
           this.part_detail_list = res.data.detail;
           let product_ids = [];
-          this.part_detail_list.forEach(v=>{
-              product_ids.push(v.product_id)
-          })
+          this.part_detail_list.forEach((v) => {
+            product_ids.push(v.product_id);
+          });
 
-          if (type == 2) {//type==2来区分编辑还是新增
-          // console.log(this.part_detail_list)
-          // console.log(product_ids);
-          //  console.log(this.tableData)
-            this.tableData.map((v, k) => {//给零部件下拉框赋值
+          if (type == 2) {
+            //type==2来区分编辑还是新增
+            // console.log(this.part_detail_list)
+            // console.log(product_ids);
+            //  console.log(this.tableData)
+            this.tableData.map((v, k) => {
+              //给零部件下拉框赋值
               let list = [];
-              if(v.product_id == 0||product_ids.indexOf(v.product_id)<0){
-               this.part_detail_list.forEach(element=>{
-                 if(element.product_id==0){
-                   list.push(element)
-                 }
-               })
-                 v.part_detail_list = JSON.parse(JSON.stringify(list))
+              if (v.product_id == 0 || product_ids.indexOf(v.product_id) < 0) {
+                this.part_detail_list.forEach((element) => {
+                  if (element.product_id == 0) {
+                    list.push(element);
+                  }
+                });
+                v.part_detail_list = JSON.parse(JSON.stringify(list));
                 // v.part_detail_list = JSON.parse(JSON.stringify(this.part_detail_list));
-                  //  v.part_detail_list = this.part_detail_list.filter(v=>{v.product_id==0})
-                  //  console.log(v.part_detail_list)
+                //  v.part_detail_list = this.part_detail_list.filter(v=>{v.product_id==0})
+                //  console.log(v.part_detail_list)
               }
-              if(product_ids.indexOf(v.product_id)>=0&&v.product_id != 0){
-                      this.part_detail_list.forEach(m=>{
-                        if(m.product_id == v.product_id){
-                          list.push(m)
-                        }
-                      })
-               v.part_detail_list = JSON.parse(JSON.stringify(list) );
+              if (product_ids.indexOf(v.product_id) >= 0 && v.product_id != 0) {
+                this.part_detail_list.forEach((m) => {
+                  if (m.product_id == v.product_id) {
+                    list.push(m);
+                  }
+                });
+                v.part_detail_list = JSON.parse(JSON.stringify(list));
               }
               // console.log(this.material)
-          // console.log(v.part_detail_list)
-            //  this.material.forEach(m=>{
-            //    if(v.material_detail_id == m.material_detail_id){
-            //       this.tableData[k].parts_detail_title = m.
-            //    }
-              
-            //  })
+              // console.log(v.part_detail_list)
+              //  this.material.forEach(m=>{
+              //    if(v.material_detail_id == m.material_detail_id){
+              //       this.tableData[k].parts_detail_title = m.
+              //    }
+
+              //  })
               // this.handlePartDetailSelected(v, k, v.parts_detail_id);
-            })
+            });
           } else {
             this.tableData = [];
           }
           this.tableData = JSON.parse(JSON.stringify(this.tableData));
         });
-        this.loading = false;
+      this.loading = false;
     },
-  handlePartDetailSelected(row, index, id,type) {//id是零部件的parts_detail_id
-  if(row.change_state||type){
-      row.part_detail_list.forEach(element => {
-        if(element.id == id){
-          row.num = element.number;
-          console.log('cc')
-        }
-      });}
-      if (id) {//id是零部件的parts_detail_id
-        const material_id = this.part_detail_list.filter((v) => v.id == id)[0].material_id; //通过零部件的parts_detail_id来找到当前零部件下拉框中物料名称id
+    handlePartDetailSelected(row, index, id, type) {
+      //id是零部件的parts_detail_id
+      if (row.change_state || type) {
+        row.part_detail_list.forEach((element) => {
+          if (element.id == id) {
+            row.num = element.number;
+            console.log("cc");
+          }
+        });
+      }
+      if (id) {
+        //id是零部件的parts_detail_id
+        const material_id = this.part_detail_list.filter((v) => v.id == id)[0]
+          .material_id; //通过零部件的parts_detail_id来找到当前零部件下拉框中物料名称id
         this.axios
           .get("/api/material", { params: { id: material_id } }) //通过得到的material_id找到物料的名称
           .then((res) => {
             this.tableData[index].parts_detail_title = res.data[0].title; //物料名字赋值
-            
-            this.tableData[index].materialDetailList = res.data[0].detail.map( //物料尺寸赋值
+
+            this.tableData[index].materialDetailList = res.data[0].detail.map(
+              //物料尺寸赋值
               (v) => {
                 return { id: v.id, materialDetailShow: v.long + "*" + v.width };
               }
@@ -564,18 +737,18 @@ export default {
             this.tableData.splice(index, 1, this.tableData[index]);
           });
       }
-      console.log(this.tableData[index])
+      console.log(this.tableData[index]);
     },
     handleSaveData() {
       let state = false;
-      console.log(this.tableData)
-      this.tableData.forEach(v=>{
-            if(v.product_id!=0&&!v.parts_detail_id){
-                 state =true;
-            }
-      })
-      if(state){
-       return this.$Message.warning('有产品未选择零部件名称!')
+      console.log(this.tableData);
+      this.tableData.forEach((v) => {
+        if (v.product_id != 0 && !v.parts_detail_id) {
+          state = true;
+        }
+      });
+      if (state) {
+        return this.$Message.warning("有产品未选择零部件名称!");
       }
       if (this.type == 1) {
         this.formData.id = "";

+ 40 - 2
src/views/PurchasingManage/InstockOrder/edit.vue

@@ -2101,6 +2101,8 @@ export default {
       //  }
     },
     Summary({ columns, data }) {
+      let a = 0;
+      let b = 0;
       const sums = {};
       columns.forEach((column, index) => {
         const key = column.key;
@@ -2111,13 +2113,37 @@ export default {
           };
           return;
         }
+        const values1 = data.map((item) => Number(item[key]));
+
+        if (key == "no_tax_total_price") {
+          const v1 = values1.reduce((prev, curr) => {
+            const value = Number(curr);
+            if (!isNaN(value)) {
+              return prev + curr;
+            } else {
+              return prev;
+            }
+          }, 0);
+          a = v1;
+        }
+        if (key == "transport_price") {
+          const v2 = values1.reduce((prev, curr) => {
+            const value = Number(curr);
+            if (!isNaN(value)) {
+              return prev + curr;
+            } else {
+              return prev;
+            }
+          }, 0);
+          b = a + v2;
+        }
+
         const values = data.map((item) => Number(item[key]));
         if (
           key === "num" ||
           key === "no_tax_total_price" ||
           key === "tax_total_price" ||
           key === "total" ||
-          key === "total_cost" ||
           key === "transport_price"
         ) {
           const v = values.reduce((prev, curr) => {
@@ -2139,6 +2165,11 @@ export default {
               value: v.toFixed(2),
             };
           }
+        } else if (key == "total_cost") {
+          sums[key] = {
+            key,
+            value: b.toFixed(2),
+          };
         } else {
           sums[key] = {
             key,
@@ -2234,6 +2265,13 @@ export default {
             ).toFixed(2);
           });
           this.tableData = res.data.list.data;
+          this.tableData.forEach((e) => {
+            let total_cost_value = (
+              e.no_tax_total_price * 1 +
+              e.transport_price * 1
+            ).toFixed(2);
+            this.$set(e, "total_cost", total_cost_value);
+          });
           this.otherPriceList =
             res.data.price_list.length != 0
               ? res.data.price_list
@@ -2320,7 +2358,7 @@ export default {
           e.no_tax_total_price * 1 +
           e.transport_price * 1
         ).toFixed(2);
-        this.$set(e, "total_cost",total_cost_value);
+        this.$set(e, "total_cost", total_cost_value);
       });
       let obj = JSON.parse(JSON.stringify(this.searchData));
       obj.order_time =

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 568 - 331
src/views/PurchasingManage/redFontInstockOrder/edit.vue


Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott