浏览代码

代码优化

chrislee 10 月之前
父节点
当前提交
fea06ffadf

+ 7 - 7
src/utils/httpRequest.js

@@ -2,7 +2,7 @@ import Vue from 'vue'
 import axios from 'axios'
 import router from '@/router'
 import qs from 'qs'
-import merge from 'lodash/merge'
+// import merge from 'lodash/merge'
 import { clearLoginInfo } from '@/utils'
 
 const http = axios.create({
@@ -53,9 +53,9 @@ http.adornUrl = (actionName) => {
  * @param {*} openDefultParams 是否开启默认参数?
  */
 http.adornParams = (params = {}, openDefultParams = true) => {
-  var defaults = {
-    't': new Date().getTime()
-  }
+  // var defaults = {
+  //   't': new Date().getTime()
+  // }
   // return openDefultParams ? merge(defaults, params) : params
   return params
 }
@@ -69,9 +69,9 @@ http.adornParams = (params = {}, openDefultParams = true) => {
  *  form: 'application/x-www-form-urlencoded; charset=utf-8'
  */
 http.adornData = (data = {}, openDefultdata = true, contentType = 'json') => {
-  var defaults = {
-    't': new Date().getTime()
-  }
+  // var defaults = {
+  //   't': new Date().getTime()
+  // }
   // data = openDefultdata ? merge(defaults, data) : data
   return contentType === 'json' ? JSON.stringify(data) : qs.stringify(data)
 }

+ 42 - 44
src/views/modules/production/scheduling.vue

@@ -223,7 +223,6 @@
   import { getSchedulingList, getChildren } from '@/api/production'
   import SchedulingCheck from '@/views/modules/production/scheduling-check'
   import SchedulingPreCheck from '@/views/modules/production/scheduling-pre-check'
-  import PurchaseAddOrUpdate from '@/views/modules/sale/purchase-add-or-update'
   import SchedulingPurchase from '@/views/modules/production/scheduling-purchase'
   import SchedulingCommission from '@/views/modules/production/scheduling-commission'
   import CraftsDetail from '@/views/modules/tech/crafts-detail-dialog'
@@ -238,7 +237,6 @@ export default {
       CraftsDetail,
       SchedulingCommission,
       SchedulingPurchase,
-      PurchaseAddOrUpdate,
       SchedulingPreCheck,
       SchedulingCheck,
       Detail,
@@ -310,10 +308,10 @@ export default {
           }
         ],
         multipleSelection: [],
-        selectedRows:[],
+        selectedRows: [],
         batchIncomeBtnDisabled: false,
         batchBtnDisabled: false,
-        optionsType: [],
+        optionsType: []
       }
     },
     created () {
@@ -494,47 +492,47 @@ export default {
           }
         })
       },
-      //监听批量选择的行
-      handleSelectionChange(rows){
+      // 监听批量选择的行
+      handleSelectionChange (rows) {
         this.selectedRows = rows
 
-        //控制批量操作按钮
+        // 控制批量操作按钮
         this.batchIncomeBtnDisabled = false
         this.batchBtnDisabled = false
-        for(let index=0;index<this.selectedRows.length;index++){
+        for (let index = 0; index < this.selectedRows.length; index++) {
           let item = this.selectedRows[index]
-          if(Number(item.prodState) === 2){
-          
+          if (Number(item.prodState) === 2) {
+
           } else {
             this.batchIncomeBtnDisabled = true
           }
 
-          if(Number(item.prodState) === 2){
-          
+          if (Number(item.prodState) === 2) {
+
           } else {
             this.batchBtnDisabled = true
           }
         }
       },
-      //批量转采购
-      batchBuyHandle(){
-        if(this.selectedRows.length == 0){
-           this.$message.error("请先勾选数据")
-           return
+      // 批量转采购
+      batchBuyHandle () {
+        if (this.selectedRows.length === 0) {
+          this.$message.error('请先勾选数据')
+          return
         }
 
         let list = []
         this.selectedRows.forEach(item => {
           list.push({
-            detailId:Math.round(Math.random() * 1000000),
+            detailId: Math.round(Math.random() * 1000000),
             materialName: item.materialName,
-            specification:item.productSpec,
+            specification: item.productSpec,
             purchaseType: '',
-            cnt:item.cnt,
-            unitName:'',
-            deadline:'',
-            batchNumber:item.batchNumber,
-            notes:''
+            cnt: item.cnt,
+            unitName: '',
+            deadline: '',
+            batchNumber: item.batchNumber,
+            notes: ''
           })
         })
 
@@ -543,38 +541,38 @@ export default {
           this.$refs.addOrUpdate.init(0, null, null, list)
         })
       },
-      //批量转委外
-      batchOutsourceHandle(){
-        if(this.selectedRows.length == 0){
-           this.$message.error("请先勾选数据")
-           return
+      // 批量转委外
+      batchOutsourceHandle () {
+        if (this.selectedRows.length === 0) {
+          this.$message.error('请先勾选数据')
+          return
         }
 
         let list = []
         this.selectedRows.forEach(item => {
           list.push({
-            detailId:Math.round(Math.random() * 1000000),
+            detailId: Math.round(Math.random() * 1000000),
             productName: item.productName,
-            productNumber:item.productNumber,
+            productNumber: item.productNumber,
             productSpec: item.productSpec,
-            cnt:item.cnt,
-            unitName:'',
-            deadline:'',
-            batchNumber:item.batchNumber,
-            arrivedTime:'',
-            qualifiedCnt:'',
-            price:'',
-            taxPrice:'',
-            taxAmount:'',
-            taxRateVal:'',
-            specificationExplian:'',
-            notes:''
+            cnt: item.cnt,
+            unitName: '',
+            deadline: '',
+            batchNumber: item.batchNumber,
+            arrivedTime: '',
+            qualifiedCnt: '',
+            price: '',
+            taxPrice: '',
+            taxAmount: '',
+            taxRateVal: '',
+            specificationExplian: '',
+            notes: ''
           })
         })
 
         this.addOrUpdateOutsourceVisible = true
         this.$nextTick(() => {
-          this.$refs.addOrUpdateOutsource.init(null,null,null,list)
+          this.$refs.addOrUpdateOutsource.init(null, null, null, list)
         })
       }
     }

+ 1 - 1
src/views/modules/sale/outsource-add-or-update.vue

@@ -247,7 +247,7 @@ export default {
           this.prodProductionIds = scheduleIds
         }
         this.productDetails = []
-        if(productDetails){
+        if (productDetails) {
           this.productDetails = productDetails
         }
         this.dataForm = {

+ 87 - 89
src/views/modules/sale/outsource-pop.vue

@@ -57,7 +57,7 @@
             </el-col>
           </el-row>
         </div>
-       
+
       </el-form>
         <span slot="footer" class="dialog-footer">
           <el-button @click="onChose">取消</el-button>
@@ -67,105 +67,103 @@
 </template>
 
 <script>
-  import { updatePurCommissionDetailBatch } from '@/api/sale'
-  import SupplierComponent from '../common/supplier-component'
+import {updatePurCommissionDetailBatch} from '@/api/sale'
+import SupplierComponent from '../common/supplier-component'
 
 export default {
-    name: 'outsource-pop',
-    components: {
-      SupplierComponent
+  name: 'outsource-pop',
+  components: {
+    SupplierComponent
+  },
+  computed: {
+    orgId: {
+      get () { return this.$store.state.user.orgId }
+    }
+  },
+  data () {
+    return {
+      id: 0,
+      dataForm: {
+        price: 1,
+        taxPrice: 1,
+        taxRate: 1,
+        cnt: 1,
+        list: []
+      },
+      dataRule: {
+        supplierId: [{ required: true, message: '请选择供应商', trigger: 'change' }],
+        price: [{ required: true, message: '不含税单价不能为空', trigger: 'change' }],
+        taxPrice: [{ required: true, message: '含税单价不能为空', trigger: 'change' }],
+        taxRate: [{ required: true, message: '税率不能为空', trigger: 'change' }]
+      },
+      subTitle: ''// 副标题
+    }
+  },
+  methods: {
+    onChose () {
+      this.$emit('onChose')
     },
-    computed: {
-      orgId: {
-        get () { return this.$store.state.user.orgId }
+    async init (rows) {
+      if (rows instanceof Array) {
+        this.subTitle = '批量委外'
+        this.dataForm.list = []
+        this.dataForm.list = rows.map(item => {
+          return {
+            productName: item.productName,
+            productSpec: item.productSpec,
+            mapNumber: item.mapNumber,
+            supplierId: '',
+            purComDetailId: item.purComDetailId,
+            cnt: item.cnt,
+            price: 1,
+            taxPrice: 1,
+            taxRate: 1
+          }
+        })
+      } else {
+        this.subTitle = '委外'
+        this.dataForm.list = [
+          {
+            productName: item.productName,
+            productSpec: item.productSpec,
+            mapNumber: item.mapNumber,
+            supplierId: '',
+            purComDetailId: rows.id,
+            cnt: rows.cnt,
+            price: 1,
+            taxPrice: 1,
+            taxRate: 1
+          }
+        ]
       }
     },
-    data () {
-      return {
-        id: 0,
-        dataForm: {
-          price: 1,
-          taxPrice: 1,
-          taxRate: 1,
-          cnt: 1,
-          list:[]
-        },
-        dataRule: {
-          supplierId: [{ required: true, message: '请选择供应商', trigger: 'change' }],
-          price: [{ required: true, message: '不含税单价不能为空', trigger: 'change' }],
-          taxPrice: [{ required: true, message: '含税单价不能为空', trigger: 'change' }],
-          taxRate: [{ required: true, message: '税率不能为空', trigger: 'change' }]
-        },
-        subTitle:''//副标题
-      }
+    validateField (type) {
+      this.$refs.dataForm.validateField(type)
     },
-    methods: {
-      onChose () {
-        this.$emit('onChose')
-      },
-      async init (rows) {
-        if(rows instanceof Array){
-          this.subTitle = '批量委外'
-          this.dataForm.list = []
-          let list = rows.map(item => {
-            return {
-              productName: item.productName,
-              productSpec: item.productSpec,
-              mapNumber: item.mapNumber,
-              supplierId: '',
-              purComDetailId:item.purComDetailId, 
-              cnt:item.cnt,
-              price:1,
-              taxPrice:1,
-              taxRate:1
+      // 表单提交
+    dataFormSubmit () {
+      this.$refs['dataForm'].validate((valid) => {
+        if (valid) {
+          updatePurCommissionDetailBatch(this.dataForm.list).then(({data}) => {
+            if (data && data.code === '200') {
+              this.$message({
+                message: '操作成功',
+                type: 'success',
+                duration: 1500,
+                onClose: () => {
+                  this.onChose()
+                  this.$emit('refreshDataList')
+                }
+              })
+            } else {
+              this.$message.error(data.msg)
             }
           })
-          this.dataForm.list = list
-        }
-        else{
-          this.subTitle = '委外'
-          this.dataForm.list = [
-            {
-              productName: item.productName,
-              productSpec: item.productSpec,
-              mapNumber: item.mapNumber,
-              supplierId: '',
-              purComDetailId:rows.id, 
-              cnt:rows.cnt,
-              price:1,
-              taxPrice:1,
-              taxRate:1
-            }
-            ]
         }
-      },
-      validateField (type) {
-        this.$refs.dataForm.validateField(type)
-      },
-      // 表单提交
-      dataFormSubmit () {
-        this.$refs['dataForm'].validate((valid) => {
-          if (valid) {
-            updatePurCommissionDetailBatch(this.dataForm.list).then(({data}) => {
-              if (data && data.code === '200') {
-                this.$message({
-                  message: '操作成功',
-                  type: 'success',
-                  duration: 1500,
-                  onClose: () => {
-                    this.onChose()
-                    this.$emit('refreshDataList')
-                  }
-                })
-              } else {
-                this.$message.error(data.msg)
-              }
-            })
-          }
-        })
-      }
+      })
     }
   }
+}
 </script>
 
 <style scoped>

+ 3 - 3
src/views/modules/sale/purchase-add-or-update.vue

@@ -187,7 +187,7 @@
           this.prodProductionIds = scheduleIds
         }
         this.materialDetails = []
-        if(materialDetails){
+        if (materialDetails) {
           this.materialDetails = materialDetails
         }
         this.dataForm = {
@@ -293,7 +293,7 @@
         // this.calTotal()
       },
       addMaterialCallback (data) {
-        console.log("1111",data)
+        console.log('1111', data)
         if (!data) return
         this.addMaterialVisible = false
         let i = this.materialDetails.findIndex((item) => item.detailId === data.detailId)
@@ -301,7 +301,7 @@
           this.materialDetails.splice(i, 1)
         }
         this.materialDetails.push(data)
-        console.log("222",this.materialDetails)
+        console.log('222', this.materialDetails)
         // this.calTotal()
       },
       // 百分比

+ 11 - 11
src/views/modules/sale/purchase-operate.vue

@@ -77,7 +77,7 @@
             </el-col>
           </el-row>
         </div>
-       
+
       </el-form>
       <span slot="footer" class="dialog-footer">
       <el-button @click="onChose">取消</el-button>
@@ -97,7 +97,7 @@
     data () {
       let validateSupplier = (rule, value, callback) => {
         if (!this.dataForm.supplierId && !this.dataForm.supplierOther) {
-          //callback(new Error('请至少填写一项供应商信息'))
+          // callback(new Error('请至少填写一项供应商信息'))
           callback()
         } else {
           // 任意值被填写,清除验证提示
@@ -112,7 +112,7 @@
         id: 0,
         dataForm: {
           cnt: 1,
-          list:[]
+          list: []
         },
         dataRule: {
           supplierId: [{required: true, validator: validateSupplier, trigger: 'change'}],
@@ -123,7 +123,7 @@
           taxRate: [{ required: true, message: '请输入税率', trigger: 'change' }]
         },
         optionsPB: [], // 采购依据(字典)
-        subTitle: '' //副标题
+        subTitle: '' // 副标题
       }
     },
     methods: {
@@ -143,10 +143,10 @@
         this.getPbList()
         // this.dataForm = row
 
-        if(row instanceof Array){
-            this.subTitle = '批量采购'
-            this.dataForm.list = []
-            this.dataForm.list = [...row]
+        if (row instanceof Array) {
+          this.subTitle = '批量采购'
+          this.dataForm.list = []
+          this.dataForm.list = [...row]
         } else {
           this.subTitle = '采购'
           this.dataForm.list = [row]
@@ -160,8 +160,8 @@
         this.$refs['dataForm'].validate((valid) => {
           if (valid) {
             // 检查供应商
-            let param = {};
-            for(let index=0; index < this.dataForm.list.length; index++){
+            let param = {}
+            for (let index = 0; index < this.dataForm.list.length; index++) {
               let item = this.dataForm.list[index]
               if (!item.supplierId && !item.supplierOther) {
                 this.$message.error('请填写供应商')
@@ -173,7 +173,7 @@
               param[index] = item
             }
 
-            console.log("param", param)
+            console.log('param', param)
 
             this.$http({
               url: this.$http.adornUrl(`/biz-service/purchaseDetail/batch/updatePurchaseDetail`),

+ 22 - 22
src/views/modules/sale/purchase.vue

@@ -291,9 +291,9 @@
           {code: '4', value: '入库中'},
           {code: '5', value: '入库异常'}
         ],
-        batchIncomeBtnDisabled:false,
-        batchBuyBtnDisabled:false,
-        selectedRows:[]
+        batchIncomeBtnDisabled: false,
+        batchBuyBtnDisabled: false,
+        selectedRows: []
       }
     },
     created () {
@@ -470,48 +470,48 @@
         let url = this.$http.adornUrl('/biz-service/purchaseDetail/exportExcel/' + procurementId)
         window.open(url + '?_token=' + Vue.cookie.get('token'), '_blank')
       },
-      //监听批量选择的行
-      handleSelectionChange(rows){
+      // 监听批量选择的行
+      handleSelectionChange (rows) {
         this.selectedRows = rows
 
-        //控制批量操作按钮
+        // 控制批量操作按钮
         this.batchIncomeBtnDisabled = false
         this.batchBuyBtnDisabled = false
-        for(let index=0;index<this.selectedRows.length;index++){
+        for (let index = 0; index < this.selectedRows.length; index++) {
           let item = this.selectedRows[index]
-          if(Number(item.approvalState) === 3  && (Number(item.purchaseState) === 2 || Number(item.purchaseState) === 5)){
-          
+          if (Number(item.approvalState) === 3 && (Number(item.purchaseState) === 2 || Number(item.purchaseState) === 5)) {
+
           } else {
             this.batchIncomeBtnDisabled = true
           }
 
-          if(Number(item.approvalState) === 3  && Number(item.purchaseState) === 1){
-          
+          if (Number(item.approvalState) === 3 && Number(item.purchaseState) === 1) {
+
           } else {
             this.batchBuyBtnDisabled = true
           }
         }
       },
-      //批量采购
-      batchBuyHandel(){
-        if(this.selectedRows.length == 0){
-           this.$message.error("请先勾选数据")
-           return
+      // 批量采购
+      batchBuyHandel () {
+        if (this.selectedRows.length === 0) {
+          this.$message.error('请先勾选数据')
+          return
         }
         this.operateVisible = true
         this.$nextTick(() => {
           this.$refs.operate.init(this.selectedRows)
         })
       },
-      //批量入库
-      batchIncomeHandel(){
-        if(this.selectedRows.length == 0){
-           this.$message.error("请先勾选数据")
-           return
+      // 批量入库
+      batchIncomeHandel () {
+        if (this.selectedRows.length === 0) {
+          this.$message.error('请先勾选数据')
+          return
         }
 
         let list = []
-        for(let index=0;index<this.selectedRows.length;index++){
+        for (let index = 0; index < this.selectedRows.length; index++) {
           let item = this.selectedRows[index]
           let dataForm = {
             ...item,

+ 4 - 4
src/views/modules/warehouse/stock-order-inbound.vue

@@ -230,12 +230,12 @@
             }
           })
         } else if (item) {
-          if(item instanceof Array){
+          if (item instanceof Array) {
             item.forEach(obj => {
-               obj.applicant = this.$store.state.user.id
-               this.addOne(obj)
+              obj.applicant = this.$store.state.user.id
+              this.addOne(obj)
             })
-          }else{
+          } else {
             item.applicant = this.$store.state.user.id
             this.addOne(item)
           }