소스 검색

fix: 增加非空判断

zh 2 년 전
부모
커밋
2db37aef46

+ 92 - 68
src/components/SalesDialog/SalesDialog.vue

@@ -1,40 +1,53 @@
 <template>
   <div>
-    <el-dialog
-      title="添加产品"
-      :visible.sync="dialogVisible"
-      :before-close="onClose"
-      width="75%"
-    >
+    <el-dialog title="添加产品" :visible.sync="dialogVisible" :before-close="onClose" width="75%">
       <template-page
-        style="width: 100%;
-        height: 100%;"
         ref="pageRef"
-        :getList="getList"
-        :tableAttributes="tableAttributes"
-        :tableEvents="tableEvents"
-      >
-      </template-page>
+        style="width: 100%; height: 100%"
+        :get-list="getList"
+        :table-attributes="tableAttributes"
+        :table-events="tableEvents"
+      />
       <span slot="footer" class="dialog-footer">
-    <el-button @click="$parent.dialogVisible = false" size="mini">取 消</el-button>
-    <el-button type="primary" @click="confirm" size="mini">确 定</el-button>
-  </span>
+        <el-button size="mini" @click="$parent.dialogVisible = false">取 消</el-button>
+        <el-button type="primary" size="mini" @click="confirm">确 定</el-button>
+      </span>
     </el-dialog>
   </div>
 </template>
 <script>
 import TemplatePage from '@/components/template/template-page-1.vue'
 import import_mixin from '@/components/template/import_mixin.js'
+import { boolean } from 'yargs'
 
 export default {
   components: { TemplatePage },
   mixins: [import_mixin],
   props: {
-    dialogVisible: false,
-    func: Function,
-    customerNumber:String,
-    returnId:String,
-    itemId:String
+    dialogVisible: {
+      type: Boolean,
+      default: false
+    },
+    func: {
+      type: Function,
+      default: () => {}
+    },
+    customerNumber: {
+      type: String,
+      default: null
+    },
+    returnId: {
+      type: String,
+      default: null
+    },
+    itemId: {
+      type: String,
+      default: null
+    },
+    dataList: {
+      type: Array,
+      default: () => []
+    }
   },
   data() {
     return {
@@ -70,7 +83,7 @@ export default {
       tableAttributes: {
         // 启用勾选列
         selectColumn: true,
-        selectable:this.selectable
+        selectable: this.selectable
       },
       // 表格事件
       tableEvents: {
@@ -93,8 +106,6 @@ export default {
     },
     // 监听勾选变化
     selectionChange(data) {
-
-
       this.recordSelected = data
     },
     addWarehouse() {
@@ -106,77 +117,90 @@ export default {
     detailsWarehouse() {
       this.pageType = 3
     },
-    onClose(){
+    onClose() {
       this.$parent.dialogVisible = false
-
     },
     operation() {
       return (h, { row, index, column }) => {
         return (
-          <div class="operation-btns">
+          <div class='operation-btns'>
             (
-            <el-button
-              size="mini"
-              type="primary"
-              onClick={() => {
-              }}
-            >
+            <el-button size='mini' type='primary' onClick={() => {}}>
               查看
             </el-button>
-            ) }
-            (
-            <el-button
-              size="mini"
-              type="primary"
-              onClick={() => {
-              }}
-            >
+            ) } (
+            <el-button size='mini' type='primary' onClick={() => {}}>
               审批
             </el-button>
             ) }
-            {(
-              <el-popconfirm
-                title="是否确定操作?"
-                onConfirm={() => {
-                }}
-              >
-                <el-button size="mini" type="primary" slot="reference">
+            {
+              <el-popconfirm title='是否确定操作?' onConfirm={() => {}}>
+                <el-button size='mini' type='primary' slot='reference'>
                   确认返还
                 </el-button>
               </el-popconfirm>
-            )}
+            }
           </div>
         )
       }
-
     },
-    confirm(){
-      if (this.recordSelected.length){
-        this.$emit('confirm',this.recordSelected)
-      }else{
+    confirm() {
+      if (this.recordSelected.length) {
+        this.$emit('confirm', this.recordSelected)
+      } else {
         this.$errorMsg('请选择产品')
       }
       // this.$parent.dialogVisible = false
     },
-    selectable(row,index){
-      if (this.customerNumber){
-        if (row.customerNumber == this.customerNumber && row.disabled){
+    selectable(row, index) {
+      if (this.dataList.length) {
+        if (this.returnId !== null) {
+          for (let j = 0; j < this.dataList.length; j++) {
+            if (
+              row.id == this.dataList[j].id ||
+            row.disabled === false
+            ) {
+              if (
+                row.itemId == this.dataList[j].itemId ||
+              row.disabled === false
+              ) {
+                this.$set(row, 'disabled', false)
+              } else {
+                this.$set(row, 'disabled', true)
+              }
+            } else {
+              this.$set(row, 'disabled', true)
+            }
+          }
+        } else {
+          for (let j = 0; j < this.dataList.length; j++) {
+            if (
+              row.id == this.dataList[j].id ||
+            row.disabled === false
+            ) {
+              this.$set(row, 'disabled', false)
+            } else {
+              this.$set(row, 'disabled', true)
+            }
+          }
+        }
+      }
+
+      if (this.customerNumber) {
+        if (row.customerNumber == this.customerNumber && row.disabled) {
           return true
-        }else{
-          return  false
+        } else {
+          return false
         }
-      }else if(this.returnId){
-        if (row.id == this.returnId && row.disabled){
+      } else if (this.returnId) {
+        if (row.id == this.returnId && row.disabled) {
           return true
-
-        }else{
-          return  false
+        } else {
+          return false
         }
+      } else {
+        return true
       }
-      else {
-        return  true
-      }
-
     }
     // 批量删除
     // dels() {

+ 5 - 0
src/views/sales_control/sales_management/components/customer_sales_form.vue

@@ -41,6 +41,7 @@
       ref="dia"
       :dialog-visible="dialogVisible"
       :customer-number="customerNumber"
+      :data-list="dataList"
       :func="getDialogList"
       @confirm="confirm"
     />
@@ -114,6 +115,10 @@ export default {
     if (this.detailsId) {
       getFrontOrderDetail({ id: this.detailsId }).then(res => {
         this.dataList = res.data.orders
+        // this.dataList  = res.data.orders.map(k => {
+        //   k.disabledId = k.customerStockId
+        //   return k
+        // })
         this.customerNumber = res.data.customerNumber
         this.$refs.header.screenForm = res.data
         this.$refs.header.screenForm.disabled = this.disabled = true

+ 19 - 18
src/views/sales_control/sales_management/components/return_sales_form.vue

@@ -1,41 +1,41 @@
 <template>
   <div>
     <el-page-header
-      @back="handleBack"
       :content="detailsId ? '编辑' : '新增'"
       style="padding: 20px 20px 0 20px"
-    ></el-page-header>
+      @back="handleBack"
+    />
     <return-sales-header ref="header" :details="details" />
     <sales-table
-      :dataList="dataList"
+      :data-list="dataList"
       :column="column"
-      :isOperation="detailsId ? false : true"
-      isSelection
+      :is-operation="detailsId ? false : true"
+      is-selection
       @handleSelection="handleSelection"
     >
       <template #bts>
         <div v-if="!detailsId">
-          <el-button type="primary" v-if="dis" size="mini" @click="dialogVisible = true">添加</el-button>
-          <el-button type="danger" v-if="dis" size="mini" @click="delChange">删除</el-button>
+          <el-button v-if="dis" type="primary" size="mini" @click="dialogVisible = true">添加</el-button>
+          <el-button v-if="dis" type="danger" size="mini" @click="delChange">删除</el-button>
         </div>
       </template>
       <template #events>
         <div v-if="!detailsId">
           <el-button type="primary" :disabled="!dis" size="mini" @click="handelSubmit(1)">提交</el-button>
-          <el-button size="mini" @click="onReset" v-if="dis">重置</el-button>
-          <el-button size="mini" v-if="isFront !== false" :disabled="dis" @click="handleInform(2)">退货通知</el-button>
+          <el-button v-if="dis" size="mini" @click="onReset">重置</el-button>
+          <el-button v-if="isFront !== false" size="mini" :disabled="dis" @click="handleInform(2)">退货通知</el-button>
         </div>
         <div v-else>
           <el-button type="primary" size="mini" @click="handelSubmit(2)">保存</el-button>
-          <el-button size="mini" @click="onReset" v-if="!detailsId">重置</el-button>
+          <el-button v-if="!detailsId" size="mini" @click="onReset">重置</el-button>
         </div>
       </template>
       <template v-slot:custom="{ item: { row, $index } }">
         <div>{{ diffQty(row) }}</div>
       </template>
       <template v-slot:custom="{ item: { row, $index } }">
-        <el-radio label="1" v-model="row.flag">增加</el-radio>
-        <el-radio label="-1" v-model="row.flag">减少</el-radio>
+        <el-radio v-model="row.flag" label="1">增加</el-radio>
+        <el-radio v-model="row.flag" label="-1">减少</el-radio>
       </template>
       <template v-slot:operation="{ item: { row, $index } }">
         <el-popconfirm v-if="dis" style="margin-left: 10px" title="删除?" @onConfirm="handleDel(row, $index)">
@@ -45,9 +45,10 @@
     </sales-table>
     <sales-dialog
       ref="dia"
-      :dialogVisible="dialogVisible"
-      :returnId="returnId"
-      :itemId="itemId"
+      :data-list="dataList"
+      :dialog-visible="dialogVisible"
+      :return-id="returnId"
+      :item-id="itemId"
       :func="getDialogList"
       @confirm="confirm"
     />
@@ -206,7 +207,7 @@ export default {
         k.diffQty = Number(k.qty) - Number(k.refundQty)
         k.qty = k.refundQty
       })
-      let obj = {
+      const obj = {
         id: Object.freeze(this.dataList[0].id)
       }
       if (!this.detailsId) {
@@ -242,7 +243,7 @@ export default {
       //   })
       // }
     },
-    //去掉相同数据
+    // 去掉相同数据
     resArr(arr1, arr2) {
       return arr1.filter(v => arr2.every(val => val.id != v.id))
     },
@@ -359,7 +360,7 @@ export default {
         this.handleBack()
       })
     },
-    
+
     handleBack() {
       this.$emit('close')
     },

+ 17 - 15
src/views/stock_control/sales_management/components/customer_sales_form.vue

@@ -1,9 +1,12 @@
 <template>
   <div>
-    <el-page-header @back="handleBack" :content="detailsId?'编辑':'新增'" style=" padding: 20px 20px 0 20px;"
-    ></el-page-header>
+    <el-page-header
+      :content="detailsId?'编辑':'新增'"
+      style=" padding: 20px 20px 0 20px;"
+      @back="handleBack"
+    />
     <sales-header ref="header" />
-    <sales-table :dataList="dataList" :column="column" isOperation isSelection @handleSelection="handleSelection">
+    <sales-table :data-list="dataList" :column="column" is-operation is-selection @handleSelection="handleSelection">
       <template #bts>
         <div>
           <el-button type="primary" size="mini" @click="dialogVisible=true">添加</el-button>
@@ -22,8 +25,8 @@
         </div>
       </template>
       <template v-slot:custom="{item:{row,$index}}">
-        <el-radio label="1" v-model="row.flag">增加</el-radio>
-        <el-radio label="-1" v-model="row.flag">减少</el-radio>
+        <el-radio v-model="row.flag" label="1">增加</el-radio>
+        <el-radio v-model="row.flag" label="-1">减少</el-radio>
       </template>
       <template v-slot:operation="{item:{row,$index}}">
         <el-popconfirm
@@ -35,8 +38,12 @@
         </el-popconfirm>
       </template>
     </sales-table>
-    <sales-dialog :dialogVisible="dialogVisible" :customerNumber="customerNumber" :func="getDialogList"
-                  @confirm="confirm"
+    <sales-dialog
+      :data-list="dataList"
+      :dialog-visible="dialogVisible"
+      :customer-number="customerNumber"
+      :func="getDialogList"
+      @confirm="confirm"
     />
   </div>
 </template>
@@ -55,14 +62,14 @@ export default {
     SalesTable,
     SalesDialog
   },
-  props: ['detailsId','pageType'],
+  props: ['detailsId', 'pageType'],
   data() {
     return {
       dialogVisible: false,
       customerNumber: '',
       dataList: [],
       selection: [],
-      disabled:false,
+      disabled: false,
       flag: 1,
       dis: true,
       column: [
@@ -118,7 +125,7 @@ export default {
       getFrontOrderDetail({ id: this.detailsId }).then(res => {
         this.dataList = res.data.orders
         this.$refs.header.screenForm = res.data
-        this.$refs.header.screenForm.disabled =this.disabled  = res.data.status !== 1?true:false
+        this.$refs.header.screenForm.disabled = this.disabled = res.data.status !== 1
 
         this.$refs.header.screenForm.provinceId = res.data.province
         this.$refs.header.screenForm.cityId = res.data.city
@@ -143,7 +150,6 @@ export default {
       this.$refs.header.screenForm.stockType = this.dataList[0].stockType
       this.customerNumber = this.dataList[0].customerNumber
       this.dialogVisible = false
-
     },
     handleDel(item, index) {
       this.dataList.splice(index, 1)
@@ -152,7 +158,6 @@ export default {
           this.$refs.header.screenForm = {}
           this.customerNumber = ''
         })
-
       }
     },
     delChange() {
@@ -169,7 +174,6 @@ export default {
           this.$refs.header.screenForm = {}
           this.customerNumber = ''
         })
-
       }
     },
     handleSelection(data) {
@@ -211,14 +215,12 @@ export default {
 
           this.$forceUpdate()
         })
-
       } else {
         updateFrontOrder(params).then(res => {
           this.$successMsg('编辑成功')
           this.handleBack()
           this.$forceUpdate()
         })
-
       }
     },
     handleBack() {

+ 39 - 41
src/views/stock_control/sales_management/components/return_sales_form.vue

@@ -1,8 +1,8 @@
 <template>
   <div>
-    <el-page-header @back="handleBack" :content="detailsId?'编辑':'新增'" style=" padding: 20px 20px 0 20px;"></el-page-header>
-    <return-sales-header ref="header" :details="details"/>
-    <sales-table :dataList="dataList" :column="column" isOperation isSelection @handleSelection="handleSelection">
+    <el-page-header :content="detailsId?'编辑':'新增'" style=" padding: 20px 20px 0 20px;" @back="handleBack" />
+    <return-sales-header ref="header" :details="details" />
+    <sales-table :data-list="dataList" :column="column" is-operation is-selection @handleSelection="handleSelection">
       <template #bts>
         <div>
           <el-button type="primary" size="mini" @click="dialogVisible=true">添加</el-button>
@@ -22,8 +22,8 @@
 
       </template>
       <template v-slot:custom="{item:{row,$index}}">
-        <el-radio label="1" v-model="row.flag">增加</el-radio>
-        <el-radio label="-1" v-model="row.flag">减少</el-radio>
+        <el-radio v-model="row.flag" label="1">增加</el-radio>
+        <el-radio v-model="row.flag" label="-1">减少</el-radio>
       </template>
       <template v-slot:operation="{item:{row,$index}}">
         <el-popconfirm
@@ -35,7 +35,7 @@
         </el-popconfirm>
       </template>
     </sales-table>
-    <sales-dialog :dialogVisible="dialogVisible" :customerNumber="customerNumber" :func="getDialogList" @confirm="confirm" />
+    <sales-dialog :data-list="dataList" :dialog-visible="dialogVisible" :customer-number="customerNumber" :func="getDialogList" @confirm="confirm" />
   </div>
 </template>
 
@@ -60,16 +60,16 @@ export default {
     SalesTable,
     SalesDialog
   },
-  props:['detailsId','pageType'],
+  props: ['detailsId', 'pageType'],
   data() {
     return {
       dialogVisible: false,
-      customerNumber:'',
+      customerNumber: '',
       dataList: [],
       selection: [],
-      flag:1,
-      dis:true,
-      details:{},
+      flag: 1,
+      dis: true,
+      details: {},
       column: [
         {
           prop: 'materialName',
@@ -100,7 +100,7 @@ export default {
         {
           prop: 'qty',
           label: '已退数量',
-          width: '180',
+          width: '180'
         },
         {
           prop: 'volume',
@@ -117,20 +117,20 @@ export default {
           label: '备注',
           width: '180',
           isInput: true,
-          type:'text'
+          type: 'text'
         }
       ]
     }
   },
   created() {
     if (this.detailsId) {
-      detailRefund({id:this.detailsId}).then(res=>{
+      detailRefund({ id: this.detailsId }).then(res => {
         this.dataList = res.data.orders
         this.details = res.data
         this.details.customerOrderNo = this.dataList[0].id
-        this.customerNumber=this.dataList[0].customerNumber
+        this.customerNumber = this.dataList[0].customerNumber
       })
-    }else{
+    } else {
       Object.assign(this.$data, this.$options.data())
     }
   },
@@ -146,20 +146,19 @@ export default {
       this.details = this.dataList[0]
       this.details.customerOrderNo = this.dataList[0].id
       this.details.id = ''
-      this.customerNumber=this.dataList[0].customerNumber
-       // this.$refs.header.details.customerName = this.dataList[0].customerName
-       // this.$refs.header.details.customerNumber = this.dataList[0].customerNumber
-       // this.$refs.header.details.customerNumber = this.dataList[0].pickTime
-       // this.$refs.header.details.customerNumber = this.dataList[0].userName
-       // this.$refs.header.details.customerNumber = this.dataList[0].phone
-       // this.$refs.header.details.customerNumber = this.dataList[0].stockType
+      this.customerNumber = this.dataList[0].customerNumber
+      // this.$refs.header.details.customerName = this.dataList[0].customerName
+      // this.$refs.header.details.customerNumber = this.dataList[0].customerNumber
+      // this.$refs.header.details.customerNumber = this.dataList[0].pickTime
+      // this.$refs.header.details.customerNumber = this.dataList[0].userName
+      // this.$refs.header.details.customerNumber = this.dataList[0].phone
+      // this.$refs.header.details.customerNumber = this.dataList[0].stockType
       this.dialogVisible = false
-
     },
     handleDel(item, index) {
       this.dataList.splice(index, 1)
-      if (!this.dataList.length){
-        this.$nextTick(()=>{
+      if (!this.dataList.length) {
+        this.$nextTick(() => {
           this.details = {}
           this.customerNumber = ''
         })
@@ -174,8 +173,8 @@ export default {
           }
         })
       })
-      if (!this.dataList.length){
-        this.$nextTick(()=>{
+      if (!this.dataList.length) {
+        this.$nextTick(() => {
           this.details = {}
           this.customerNumber = ''
         })
@@ -185,16 +184,16 @@ export default {
       this.selection = data
     },
 
-    handelSubmit(type,status=1) {
-      if (!this.dataList.length){
+    handelSubmit(type, status = 1) {
+      if (!this.dataList.length) {
         this.$errorMsg('请添加产品')
         return
       }
       for (let i = 0; i < this.dataList.length; i++) {
         this.dataList[i].id = ''
         this.dataList[i].directFlag = this.dataList[i].flag
-        if (Number(this.dataList[i].refundQty)<0 || !this.dataList[i].refundQty){
-          this.$errorMsg(`第${i+1}产品退货数量有误`)
+        if (Number(this.dataList[i].refundQty) < 0 || !this.dataList[i].refundQty) {
+          this.$errorMsg(`第${i + 1}产品退货数量有误`)
           return
         }
       }
@@ -202,31 +201,30 @@ export default {
       const params = {
         ...this.$refs.header.details,
         orders: this.dataList,
-        customerOrderNo:this.details.customerOrderNo,
+        customerOrderNo: this.details.customerOrderNo,
         status
       }
-      if (type===1){
+      if (type === 1) {
         params.id = ''
         addRefund(params).then(res => {
           this.$successMsg('新增成功')
           // this.pageType = 0
-          this.dis =false
+          this.dis = false
           this.$forceUpdate()
         })
-
-      }else {
-        updateRefund(params).then(res=>{
+      } else {
+        updateRefund(params).then(res => {
           this.$successMsg('编辑成功')
           this.handleBack()
           this.$forceUpdate()
         })
       }
     },
-    handleBack(){
+    handleBack() {
       this.$emit('close')
     },
-    handleInform(status=2){
-      sendRefund({id:this.$refs.header.details.id,status})
+    handleInform(status = 2) {
+      sendRefund({ id: this.$refs.header.details.id, status })
     }
 
   }

+ 6 - 3
src/views/supply/transferOrder/transferOrderForm.vue

@@ -575,11 +575,14 @@ export default {
       this.itemRecordSelected = data
     },
     selectable(row, index) {
-      for (let j = 0; j < this.selectData.length; j++) {
-        if (row.id === this.selectData[j].disabledId) {
-          this.$set(row, 'disabledId', this.selectData[j].disabledId)
+      if (this.selectData.length) {
+        for (let j = 0; j < this.selectData.length; j++) {
+          if (row.id === this.selectData[j].disabledId) {
+            this.$set(row, 'disabledId', this.selectData[j].disabledId)
+          }
         }
       }
+
       if (!row.disabledId) {
         return true
       } else {